| 1 |
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{C as t,T as n,a as r,k as i,w as a}from"./client-BF7bXNK1.js";import{n as o}from"./QueryClientProvider-9JNFZ3bI.js";import{t as s}from"./useQuery-B5MkrwpZ.js";import{t as c}from"./useMutation-B1P2qjz8.js";import{t as l}from"./chevron-right-Bo79-x2y.js";import{t as u}from"./chevron-left-BzMQbms3.js";import{n as d}from"./ToastContext-DZTRNQaL.js";import{t as f}from"./cog-BANSqh7u.js";import{t as p}from"./download-C8T6y5NP.js";import{t as m}from"./loader-circle-BBi1Q5Of.js";import{t as h}from"./play-COIh00zF.js";import{t as g}from"./printer-xOB5bYzi.js";import{t as _}from"./trash-2-C_S1I3B2.js";import{t as v}from"./triangle-alert-DVMl7nrd.js";import{t as y}from"./x-B6CZ7IPv.js";import{t as b}from"./Button-CzgwmHYz.js";import{t as x}from"./ConfirmModal-DcNL3bIh.js";import{n as S}from"./useUiSettings-Da40fbsp.js";import{n as C}from"./index-Cwxho1Yx.js";var w=t(`combine`,[[`path`,{d:`M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`1l7d7l`}],[`path`,{d:`M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`9955pe`}],[`path`,{d:`m7 15 3 3`,key:`4hkfgk`}],[`path`,{d:`m7 21 3-3H5a2 2 0 0 1-2-2v-2`,key:`1xljwe`}],[`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1cdgtw`}],[`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`,key:`zi3rio`}]]),T=e(i(),1),E=a();function D({source:e,onClose:t}){let{t:i}=n(),a=o(),{showToast:l}=d(),[u,f]=(0,T.useState)(null),[p,m]=(0,T.useState)(null),[g,_]=(0,T.useState)(1),{trackJob:v}=C(),{data:b,isLoading:x}=s({queryKey:[`slicer-pipelines`],queryFn:()=>r.listSlicerPipelines()}),{data:w}=s({queryKey:[`printers`],queryFn:()=>r.getPrinters()}),{data:D}=S(),A=D?.pipeline_max_copies??50,j={kind:e.kind,id:e.id},M=c({mutationFn:e=>r.checkPipelineEligibility(e,j)}),N=c({mutationFn:({pipelineId:e,force:t})=>r.runPipeline(e,j,t,g),onSuccess:n=>{a.invalidateQueries({queryKey:[`slicer-pipelines`]}),a.invalidateQueries({queryKey:[`pipeline-runs`]}),n.slice_job_id&&v(n.slice_job_id,e.kind,e.filename),l(i(`library.runWithPipeline.toast.started`,`Pipeline run started`),`success`),t()},onError:e=>{l(e.message||i(`library.runWithPipeline.toast.failed`,`Could not start run`),`error`)}}),P=b?.pipelines??[],F=(w??[]).reduce((e,t)=>(e[t.id]=t,e),{});return(0,E.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-label":i(`library.runWithPipeline.modalTitle`,`Run with pipeline`),children:(0,E.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-2xl w-full max-w-md max-h-[80vh] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary`,children:[(0,E.jsxs)(`h3`,{className:`text-sm font-semibold text-white flex items-center gap-2`,children:[(0,E.jsx)(h,{className:`w-4 h-4 text-bambu-green`}),u&&p?i(`library.runWithPipeline.confirmTitle`,`Confirm run`):i(`library.runWithPipeline.modalTitle`,`Run with pipeline`)]}),(0,E.jsx)(`button`,{type:`button`,onClick:t,"aria-label":i(`common.close`,`Close`),className:`text-bambu-gray hover:text-white`,children:(0,E.jsx)(y,{className:`w-4 h-4`})})]}),(0,E.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-3`,children:u&&p?(0,E.jsx)(k,{pipeline:u,report:p,source:e,onBack:()=>{f(null),m(null)},onConfirm:()=>{u&&N.mutate({pipelineId:u.id,force:!0})},running:N.isPending}):(0,E.jsx)(O,{source:e,pipelines:P,printerById:F,loading:x||M.isPending,onPick:async e=>{if(!(e.target_printer_id||e.target_kind===`printer_class`&&e.target_model_class)){l(i(`library.runWithPipeline.noTargetMessage`,`This pipeline has no target printer set. Open it in Settings to pick one.`),`error`);return}f(e);try{let t=await M.mutateAsync(e.id);m(t),t.ok&&N.mutate({pipelineId:e.id,force:!1})}catch(e){l(e instanceof Error&&e.message||i(`library.runWithPipeline.toast.failed`,`Could not start run`),`error`),f(null)}},copies:g,maxCopies:A,onCopiesChange:_})})]})})}function O({source:e,pipelines:t,printerById:r,loading:i,onPick:a,copies:o,maxCopies:s,onCopiesChange:c}){let{t:l}=n();return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[l(`library.runWithPipeline.sourceHint`,`Source`),`:`,` `,(0,E.jsx)(`span`,{className:`text-white`,children:e.filename})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`label`,{className:`text-xs text-bambu-gray`,htmlFor:`run-pipeline-copies`,children:[l(`library.runWithPipeline.copies`,`Copies`),`:`]}),(0,E.jsx)(`input`,{id:`run-pipeline-copies`,type:`number`,min:1,max:s,value:o,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)||c(Math.max(1,Math.min(s,t)))},"aria-label":l(`library.runWithPipeline.copies`,`Copies`),className:`w-20 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded text-white`}),(0,E.jsx)(`span`,{className:`text-xs text-bambu-gray/60`,children:l(`library.runWithPipeline.copiesHint`,`max {{n}}`,{n:s})})]}),i&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,E.jsx)(m,{className:`w-4 h-4 animate-spin`}),l(`library.runWithPipeline.loading`,`Loading…`)]}),!i&&t.length===0&&(0,E.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:l(`library.runWithPipeline.empty`,`No pipelines saved yet. Open the Slice dialog and click "Save as pipeline" to create one.`)}),!i&&t.length>0&&(0,E.jsx)(`ul`,{className:`space-y-1.5`,"aria-label":l(`library.runWithPipeline.pipelineListAria`,`Available pipelines`),children:t.map(e=>{let t=e.target_kind===`printer_class`,n=e.target_printer_id?r[e.target_printer_id]?.name:null,i=t&&e.target_model_class?l(`library.runWithPipeline.classTarget`,`Any {{model}}`,{model:e.target_model_class}):null;return(0,E.jsx)(`li`,{children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>a(e),disabled:!(e.target_printer_id||t&&e.target_model_class),className:`w-full text-left px-3 py-2 rounded-md border border-bambu-dark-tertiary bg-bambu-dark/40 hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(f,{className:`w-3.5 h-3.5 text-bambu-green flex-shrink-0`}),(0,E.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.name})]}),(0,E.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray flex items-center gap-1`,children:[(0,E.jsx)(g,{className:`w-3 h-3`}),i?(0,E.jsx)(`span`,{children:i}):n?(0,E.jsx)(`span`,{children:n}):(0,E.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:l(`library.runWithPipeline.noTarget`,`No target printer set`)})]})]})},e.id)})})]})}function k({pipeline:e,report:t,source:r,onBack:i,onConfirm:a,running:o}){let{t:s}=n();return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[(0,E.jsxs)(`p`,{children:[s(`library.runWithPipeline.confirmIntro`,`Pre-flight found issues with this run`),`:`]}),(0,E.jsxs)(`p`,{className:`mt-1`,children:[(0,E.jsxs)(`span`,{className:`text-bambu-gray/70`,children:[s(`library.runWithPipeline.sourceHint`,`Source`),`: `]}),(0,E.jsx)(`span`,{className:`text-white`,children:r.filename})]}),(0,E.jsxs)(`p`,{children:[(0,E.jsxs)(`span`,{className:`text-bambu-gray/70`,children:[s(`library.runWithPipeline.pipelineHint`,`Pipeline`),`: `]}),(0,E.jsx)(`span`,{className:`text-white`,children:e.name})]}),t.target_printer_name&&(0,E.jsxs)(`p`,{children:[(0,E.jsxs)(`span`,{className:`text-bambu-gray/70`,children:[s(`library.runWithPipeline.targetHint`,`Target`),`: `]}),(0,E.jsx)(`span`,{className:`text-white`,children:t.target_printer_name})]})]}),(0,E.jsx)(`ul`,{className:`space-y-1.5`,children:t.issues.map((e,t)=>(0,E.jsxs)(`li`,{className:`flex items-start gap-2 text-xs`,children:[(0,E.jsx)(v,{className:`w-3.5 h-3.5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5`}),(0,E.jsx)(`span`,{className:`text-bambu-gray`,children:(0,E.jsx)(A,{issue:e})})]},t))}),(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:i,disabled:o,className:`px-3 py-1.5 text-xs text-bambu-gray hover:text-white`,children:s(`common.back`,`Back`)}),(0,E.jsxs)(`button`,{type:`button`,onClick:a,disabled:o,className:`px-3 py-1.5 text-xs bg-amber-500 hover:bg-amber-600 text-white rounded disabled:opacity-50 flex items-center gap-1`,children:[o?(0,E.jsx)(m,{className:`w-3 h-3 animate-spin`}):(0,E.jsx)(h,{className:`w-3 h-3`}),s(`library.runWithPipeline.runAnyway`,`Run anyway`)]})]})]})}function A({issue:e}){let{t}=n();switch(e.kind){case`printer_not_set`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.printerNotSet`,`No target printer set on this pipeline.`)});case`printer_not_found`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.printerNotFound`,`Target printer no longer exists.`)});case`printer_disabled`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.printerDisabled`,`Target printer is disabled.`)});case`printer_offline`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.printerOffline`,`Target printer is offline.`)});case`filament_type_mismatch`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.filamentType`,`Filament slot {{slot}}: expected {{expected}}, AMS has {{actual}}`,{slot:(e.slot_index??0)+1,expected:e.expected??`?`,actual:e.actual??`?`})});case`filament_color_mismatch`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.filamentColor`,`Filament slot {{slot}}: colour differs (expected {{expected}}, AMS has {{actual}})`,{slot:(e.slot_index??0)+1,expected:e.expected??`?`,actual:e.actual??`?`})});case`ams_slot_missing`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.amsSlotMissing`,`AMS slot {{slot}} not available on this printer`,{slot:(e.slot_index??0)+1})});case`filament_unverified`:return(0,E.jsx)(E.Fragment,{children:t(`library.runWithPipeline.issue.filamentUnverified`,`Filament slot {{slot}} comes from a cloud / standard preset and could not be statically verified.`,{slot:(e.slot_index??0)+1})});default:return(0,E.jsx)(E.Fragment,{children:e.kind})}}function j({onFiles:e,onRejected:t,extensions:n,disabled:r=!1}){let[i,a]=(0,T.useState)(!1),o=(0,T.useRef)(e),s=(0,T.useRef)(t),c=(0,T.useRef)(n);(0,T.useEffect)(()=>{o.current=e},[e]),(0,T.useEffect)(()=>{s.current=t},[t]),(0,T.useEffect)(()=>{c.current=n},[n]);let l=(0,T.useCallback)(e=>{r||(e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&a(!0))},[r]),u=(0,T.useCallback)(e=>{r||(e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&a(!0))},[r]),d=(0,T.useCallback)(e=>{if(r)return;e.preventDefault();let t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&a(!1)},[r]),f=(0,T.useCallback)(e=>{if(r)return;e.preventDefault(),a(!1);let t=Array.from(e.dataTransfer.files);if(t.length===0)return;let n=c.current,i=n&&n.length>0?t.filter(e=>n.some(t=>e.name.toLowerCase().endsWith(t))):t;i.length>0?o.current(i):s.current?.()},[r]);return(0,T.useEffect)(()=>{if(!i)return;let e=()=>a(!1),t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`drop`,e),document.addEventListener(`dragend`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`drop`,e),document.removeEventListener(`dragend`,e),document.removeEventListener(`keydown`,t)}},[i]),{isDraggingOver:i,dragHandlers:{onDragOver:l,onDragEnter:u,onDragLeave:d,onDrop:f}}}function M(e){let{archiveName:t,photos:n,initialIndex:i,onClose:a,onDelete:o}=e,[s,c]=(0,T.useState)(()=>Math.min(Math.max(i??0,0),Math.max(n.length-1,0))),[d,f]=(0,T.useState)(!1);if((0,T.useEffect)(()=>{if(d)return;let e=e=>{e.key===`Escape`&&a(),e.key===`ArrowLeft`&&c(e=>Math.max(0,e-1)),e.key===`ArrowRight`&&c(e=>Math.min(n.length-1,e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,n.length,d]),(0,T.useEffect)(()=>{s>=n.length&&c(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return a(),null;let m=t=>e.getPhotoUrl?e.getPhotoUrl(t):r.getArchivePhotoUrl(e.archiveId,t),h=n[s],g=m(h);return(0,E.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-50`,onClick:e=>{e.stopPropagation(),a()},children:[(0,E.jsxs)(`div`,{className:`relative w-full h-full flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 bg-black/50`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:t}),(0,E.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Photo `,s+1,` of `,n.length]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(b,{variant:`secondary`,size:`sm`,onClick:()=>{let e=document.createElement(`a`);e.href=g,e.download=`${t}_photo_${s+1}.jpg`,e.click()},children:[(0,E.jsx)(p,{className:`w-4 h-4`}),`Download`]}),o&&(0,E.jsx)(b,{variant:`secondary`,size:`sm`,onClick:()=>{o&&f(!0)},className:`text-red-400 hover:text-red-300`,children:(0,E.jsx)(_,{className:`w-4 h-4`})}),(0,E.jsx)(`button`,{onClick:a,className:`p-2 text-bambu-gray hover:text-white transition-colors`,children:(0,E.jsx)(y,{className:`w-6 h-6`})})]})]}),(0,E.jsxs)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden`,children:[s>0&&(0,E.jsx)(`button`,{onClick:()=>c(e=>e-1),className:`absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,E.jsx)(u,{className:`w-8 h-8 text-white`})}),(0,E.jsx)(`img`,{src:g,alt:`Photo ${s+1}`,className:`max-w-full max-h-full object-contain rounded-lg`,style:{maxHeight:`calc(100vh - 200px)`}}),s<n.length-1&&(0,E.jsx)(`button`,{onClick:()=>c(e=>e+1),className:`absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,E.jsx)(l,{className:`w-8 h-8 text-white`})})]}),n.length>1&&(0,E.jsx)(`div`,{className:`flex justify-center gap-2 p-4 bg-black/50`,children:n.map((e,t)=>(0,E.jsx)(`button`,{onClick:()=>c(t),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${t===s?`border-bambu-green`:`border-transparent hover:border-bambu-gray`}`,children:(0,E.jsx)(`img`,{src:m(e),alt:`Thumbnail ${t+1}`,className:`w-full h-full object-cover`})},e))})]}),d&&(0,E.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,E.jsx)(x,{title:`Delete Photo`,message:`Delete this photo? This cannot be undone.`,confirmText:`Delete`,variant:`danger`,onConfirm:()=>{o?.(h),f(!1)},onCancel:()=>f(!1)})})]})}export{w as i,j as n,D as r,M as t};
|