1import{r as u,j as e}from"./vendor-react-BjK7BgZ1.js";import{D as _,F as y,W as k}from"./WorkstationCard-CgRP5Joh.js";import{u as C}from"./useOrders-OdT6yAHz.js";import{a as f}from"./eventLog-CypBO-8Z.js";import{B as h}from"./Box-D6YUCR2s.js";import{a as N}from"./orderHelpers-Do6tpnVc.js";import{r as F}from"./index-DW7YeZ4h.js";import"./useDepartmentRequests-Dc5buA1o.js";import"./LoadingDots-wW2qGPcq.js";import"./labels-CdAwnqXa.js";import"./useSignedUrl-DmEdy830.js";import"./storage-Lzi06WRw.js";import"./vendor-supabase-B2C_po0q.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"3806f6685009088ca536a6f1492e1499d1ed6e58"};var o=new r.Error().stack;o&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[o]="1915da2b-8277-4604-aec0-67c31de8ad1d",r._sentryDebugIdIdentifier="sentry-dbid-1915da2b-8277-4604-aec0-67c31de8ad1d")}catch{}})();const S=["mockup_ready","mockup_progress","mockup_approved","dtg"],P=["sRGB","AdobeRGB"];function I(r){return(r.labels||[]).includes("dtg")||r.print_method==="DTG"?!0:N(r).some(c=>c.print_method==="DTG")}function v(r){if(!r)return 255;const o=parseInt(r.slice(1,3),16),i=parseInt(r.slice(3,5),16),c=parseInt(r.slice(5,7),16);return .299*o+.587*i+.114*c}function w(r){const o=N(r);for(const i of o)if(i.garment_color_hex)return i.garment_color_hex;return r.garment_color_hex||null}function D(r){const o=N(r);for(const i of o)if(i.garment_color)return i.garment_color;return r.garment_color||"Unknown"}function j(r){if(r.dtg_data)return r.dtg_data;const o=w(r),i=o?v(o)<128:!0;return{pretreatment:{needed:i,completed:!1,operator:"",completedAt:null},printFile:{url:"",dpi:300,colorProfile:"sRGB",ready:!1},whiteUnderbase:{needed:i},production:{machine:"",operator:"",completed:0,started_at:null,completed_at:null}}}function Q(){const{updateOrder:r}=C(),[o,i]=u.useState(null),[c,l]=u.useState("all"),b=u.useCallback(d=>d.filter(n=>{const a=F(n.stage,n.machine);return a==="archived"||a==="ready"||!I(n)?!1:S.includes(a)}),[]),g=u.useCallback(d=>c==="all"?d:c==="pretreat"?d.filter(n=>{const a=n.dtg_data||j(n);return a.pretreatment.needed&&!a.pretreatment.completed}):c==="production"?d.filter(n=>{const a=n.dtg_data||j(n);return a.pretreatment.completed||!a.pretreatment.needed}):d,[c]);function t(d){return j(d)}async function m(d,n){await r(d.id,{dtg_data:n,updated_at:new Date().toISOString()})}async function p(d,n){const a=[...new Set([...d.labels||[],n])];await r(d.id,{labels:a})}return e.jsx(_,{title:"DTG Station",icon:"ð¨ï¸",department:"dtg",getRelevantOrders:b,filterSlot:e.jsxs(e.Fragment,{children:[e.jsx(y,{active:c==="pretreat",onClick:()=>l(c==="pretreat"?"all":"pretreat"),children:"Needs Pretreatment"}),e.jsx(y,{active:c==="production",onClick:()=>l(c==="production"?"all":"production"),children:"In Production"})]}),children:d=>{const n=g(d);return n.length===0?e.jsx("div",{className:"text-center py-16 text-text-muted",children:e.jsx("p",{children:"No orders match this filter"})}):e.jsx("div",{className:"space-y-3",children:n.map(a=>e.jsx(O,{order:a,isOpen:o===a.id,onToggle:()=>i(o===a.id?null:a.id),getData:t,saveData:m,addLabel:p,updateOrder:r},a.id))})}})}function O({order:r,isOpen:o,onToggle:i,getData:c,saveData:l,addLabel:b,updateOrder:g}){const t=u.useMemo(()=>c(r),[r.dtg_data,r.garment_color_hex,r.designs]),m=r.quantity||0,p=w(r),d=D(r),n=p?v(p):255,a=n<128;return e.jsxs("div",{children:[e.jsx(k,{order:r,onClick:i,badges:e.jsxs(e.Fragment,{children:[t.pretreatment.needed&&e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${t.pretreatment.completed?"bg-success/20 text-success":"bg-error/20 text-error"}`,children:t.pretreatment.completed?"Pretreated":"Needs Pretreat"}),t.whiteUnderbase.needed&&e.jsx("span",{className:"text-[10px] bg-warning/20 text-warning px-1.5 py-0.5 rounded font-medium",children:"White Underbase"})]})}),o&&e.jsxs("div",{className:"mt-2 space-y-4 pl-2 border-l-2 border-purple/30 ml-4",children:[e.jsxs(h,{className:"!p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-text-primary mb-3",children:"Pretreatment"}),a&&e.jsx("div",{className:"bg-warning/10 border border-warning/20 rounded-lg p-2.5 mb-3",children:e.jsxs("span",{className:"text-xs text-warning font-medium",children:["Dark garment detected (L:",Math.round(n),") -- pretreatment recommended"]})}),e.jsxs("div",{className:"flex items-center gap-4 mb-3",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.pretreatment.needed,onChange:s=>l(r,{...t,pretreatment:{...t.pretreatment,needed:s.target.checked}}),className:"accent-brand w-4 h-4"}),e.jsx("span",{className:"text-sm text-text-primary",children:"Pretreatment Needed"})]}),p&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-5 h-5 rounded border border-border",style:{backgroundColor:p}}),e.jsx("span",{className:"text-xs text-text-muted",children:d})]})]}),t.pretreatment.needed&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Operator"}),e.jsx("input",{type:"text",value:t.pretreatment.operator,onChange:s=>l(r,{...t,pretreatment:{...t.pretreatment,operator:s.target.value}}),placeholder:"Operator name",className:"w-full max-w-xs bg-surface2 border border-border rounded px-2.5 py-1.5 text-sm text-text-primary placeholder-text-muted"})]}),t.pretreatment.completed?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-success",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"text-xs text-success",children:"Completed"}),t.pretreatment.completedAt&&e.jsxs("span",{className:"text-xs text-text-muted",children:[new Date(t.pretreatment.completedAt).toLocaleStr
1ing(),t.pretreatment.operator?` by ${t.pretreatment.operator}`:""]})]}):e.jsx("button",{onClick:async()=>{const s=new Date().toISOString(),x={...t,pretreatment:{...t.pretreatment,completed:!0,completedAt:s}};await l(r,x),await b(r,"pretreated"),f({orderId:r.id,eventType:"pretreatment_done",title:"Pretreatment Complete",description:`Pretreatment completed by ${t.pretreatment.operator||"operator"}`,actor:t.pretreatment.operator||null})},className:"px-3 py-1.5 bg-success/20 text-success rounded text-xs font-medium hover:bg-success/30 transition-colors",children:"Mark Completed"})]})]}),e.jsxs(h,{className:"!p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-text-primary mb-3",children:"Print File Prep"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"File URL"}),e.jsx("input",{type:"text",value:t.printFile.url,onChange:s=>l(r,{...t,printFile:{...t.printFile,url:s.target.value}}),placeholder:"Link or filename",className:"w-full bg-surface2 border border-border rounded px-2.5 py-1.5 text-sm text-text-primary placeholder-text-muted"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Resolution (DPI)"}),e.jsx("input",{type:"number",value:t.printFile.dpi,onChange:s=>l(r,{...t,printFile:{...t.printFile,dpi:parseInt(s.target.value)||0}}),className:"w-full bg-surface2 border border-border rounded px-2.5 py-1.5 text-sm text-text-primary font-mono"}),t.printFile.dpi>0&&t.printFile.dpi<300&&e.jsx("p",{className:"text-xs text-warning mt-1",children:"Low resolution -- may appear pixelated"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Color Profile"}),e.jsx("select",{value:t.printFile.colorProfile,onChange:s=>l(r,{...t,printFile:{...t.printFile,colorProfile:s.target.value}}),className:"w-full bg-surface2 border border-border rounded px-2.5 py-1.5 text-sm text-text-primary",children:P.map(s=>e.jsx("option",{value:s,children:s},s))})]})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.printFile.ready,onChange:s=>l(r,{...t,printFile:{...t.printFile,ready:s.target.checked}}),className:"accent-success w-4 h-4"}),e.jsx("span",{className:"text-sm text-text-primary",children:"File Ready for Print"})]})]}),e.jsxs(h,{className:"!p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-text-primary mb-3",children:"White Underbase Detection"}),e.jsx("div",{className:"flex items-center gap-4 mb-3",children:p&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded border border-border",style:{backgroundColor:p}}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-text-primary block",children:d}),e.jsxs("span",{className:"text-xs text-text-muted font-mono",children:[p," (L: ",Math.round(n),")"]})]})]})}),t.whiteUnderbase.needed?e.jsxs("div",{className:"bg-warning/10 border border-warning/30 rounded-lg p-3 mb-3",children:[e.jsx("span",{className:"text-sm font-medium text-warning",children:"White underbase needed -- dark garment detected"}),e.jsxs("p",{className:"text-xs text-text-secondary mt-1",children:["Estimated ink cost increase: +$0.50/piece (",m," pcs = $",(m*.5).toFixed(2),")"]})]}):e.jsx("div",{className:"bg-success/10 border border-success/30 rounded-lg p-3 mb-3",children:e.jsx("span",{className:"text-sm font-medium text-success",children:"No white underbase needed -- light garment"})})]}),e.jsxs(h,{className:"!p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-text-primary mb-3",children:"Production"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Machine"}),e.jsx("input",{type:"text",value:t.production.machine,onChange:s=>l(r,{...t,production:{...t.production,machine:s.target.value}}),placeholder:"e.g. Epson F2100",className:"w-full bg-surface2 border border-border rounded px-2.5 py-1.5 text-sm text-text-primary placeholder-text-muted"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Operator"}),e.jsx("input",{type:"text",value:t.production.operator,onChange:s=>l(r,{...t,production:{...t.production,operator:s.target.value}}),placeholder:"Operator name",className:"w-full bg-surface2 border border-border rounded px-2.5 py-1.5 text-sm text-text-primary placeholder-text-muted"})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Pieces Completed"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"0",max:m,value:t.production.completed,onChange:s=>l(r,{...t,production:{...t.production,completed:Math.min(parseInt(s.target.value)||0,m)}}),className:"w-24 bg-surface2 border border-border rounded px-2.5 py-1.5 text-sm text-text-primary font-mono"}),e.jsxs("span",{className:"text-sm text-text-muted",children:["/ ",m]}
1)]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex justify-between text-xs text-text-muted mb-1",children:[e.jsx("span",{children:"Progress"}),e.jsxs("span",{children:[m>0?Math.round(t.production.completed/m*100):0,"%"]})]}),e.jsx("div",{className:"h-2 bg-surface2 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-purple rounded-full transition-all",style:{width:`${m>0?t.production.completed/m*100:0}%`}})})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.production.started_at?e.jsxs("span",{className:"text-xs text-text-muted",children:["Started: ",new Date(t.production.started_at).toLocaleString()]}):e.jsx("button",{onClick:async()=>{const s=new Date().toISOString(),x={...t,production:{...t.production,started_at:s}};await l(r,x),f({orderId:r.id,eventType:"dtg_started",title:"DTG Production Started",description:`Production started by ${t.production.operator||"operator"}`,actor:t.production.operator||null})},className:"px-3 py-1.5 bg-info/20 text-info rounded text-xs font-medium hover:bg-info/30 transition-colors",children:"Start Production"}),t.production.started_at&&!t.production.completed_at&&e.jsx("button",{onClick:async()=>{const s=new Date().toISOString(),x={...t,production:{...t.production,completed_at:s,completed:m}};await l(r,x),await g(r.id,{stage:"finishing",updated_at:s}),f({orderId:r.id,eventType:"stage_changed",title:"DTG Print Complete",description:`${m} pieces printed. Moved to finishing.`,actor:t.production.operator||null})},className:"px-3 py-1.5 bg-success/20 text-success rounded text-xs font-medium hover:bg-success/30 transition-colors",children:"Mark Complete â Finishing"}),t.production.completed_at&&e.jsxs("span",{className:"text-xs text-success",children:["Completed: ",new Date(t.production.completed_at).toLocaleString()]})]})]})]})]})}export{Q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.