1import{a as ft,u as jt,r as i,b as I,c as y,j as t,W as Te,L as Q,B as l,aG as le,E as yt,I as v,C as kt,_ as Nt,m as x,$ as qe,U as de}from"./index-BRJ5ZK5v.js";import{B as ce}from"./badge-B3_-or2v.js";import{C as b}from"./card-CDridMaN.js";import{S as Ie,a as Le,b as Me,c as Pe,d as ue}from"./select-CmaxMc0N.js";import{D as Ae,a as Fe,b as $e,c as Ee}from"./dialog-BBwNo65S.js";import{L}from"./label-DRpmBi18.js";import{F as vt,R as Re,b as De,a as bt,c as wt}from"./ForecastLinkButton-MRsUJud-.js";import{u as St,C as Ct,R as Tt}from"./useColumnVisibility-HZI8QyCL.js";import{V as qt}from"./VariationStockRows-L_zDQssr.js";import{L as It}from"./lock-open-BtrHHk4b.js";import{P as ze}from"./plus-BykrFEEd.js";import{C as Lt}from"./chevron-up-8zgptxCn.js";import{U as Mt}from"./unlink-BlI0gPp2.js";import{C as Pt}from"./camera-DHTvMRGp.js";import{A as Oe,a as At}from"./arrow-up-C9eLeQfm.js";import{A as Ft}from"./arrow-up-down-B9smV01Q.js";import{C as $t}from"./circle-check-Bz6lbHkK.js";import{C as Et}from"./clipboard-list-CNYTEf2D.js";import{T as Rt}from"./trash-2-DtAeGN4W.js";import"./index-BdQq_4o_.js";import"./index-CHcawZx6.js";import"./index-DMe0aH8K.js";import"./check-D8iPEp1e.js";import"./index-3cz39GOp.js";import"./archive-C8OXEQul.js";import"./rotate-ccw-DkOtvza0.js";import"./printer-7YqO3dxa.js";import"./popover-CLKj-bQs.js";import"./eye-off-BA6L4_qt.js";function xs(){const f=ft(),{toast:k}=jt(),[U,Ke]=i.useState(""),[M,Be]=i.useState(!1),[P,Ve]=i.useState(!1),[C,Qe]=i.useState(!1),[A,Ue]=i.useState(!1),[w,Ze]=i.useState(!1),[Z,He]=i.useState(!0),[u,Je]=i.useState(!0),[h,H]=i.useState(null),[me,F]=i.useState(""),[Ge,T]=i.useState(!1),[J,xe]=i.useState(""),[he,ge]=i.useState(0),[g,$]=i.useState(null),[G,pe]=i.useState(1),[E,fe]=i.useState(null),[Y,_]=i.useState(!1),[W,je]=i.useState(""),[X,ye]=i.useState(""),[R,Ye]=i.useState("name"),[D,ke]=i.useState("asc"),[Ne,_e]=i.useState(()=>localStorage.getItem("restockEditorName")||""),{hiddenColumns:We,toggleColumnVisibility:Xe,isColumnVisible:j}=St("restockHiddenColumns_Zodiac"),S="Zodiac",{data:z=[],isLoading:et}=I({queryKey:["/api/restock-items",S],queryFn:async()=>{const e=await fetch(`/api/restock-items?category=${encodeURIComponent(S)}`);if(!e.ok)throw new Error("Failed to load restock items");return e.json()}}),{data:tt}=I({queryKey:["/api/square/products"]}),ee=tt?.items||[],{data:O}=I({queryKey:["/api/square/restock-inventory",S],queryFn:async()=>{const e=await fetch("/api/square/restock-inventory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:S})});return e.ok?e.json():{inventory:{}}},staleTime:6e4}),ve=O?.syncedAt;function o(e){return O?.inventory?.[e.id]?.stock??null}function d(e){return O?.inventory?.[e.id]?.regular??null}const st=/^(regular|stock|storage|back\s*stock|label|jar|container|cotton\s*wick|stock\s*cotton\s*wick)$/i;function be(e){return e.trim().toLowerCase().replace(/\.$/,"").replace(/\s+/g," ")}function at(e){const a=O?.inventory?.[e.id]?.variationStocks;if(!a)return null;const r=a.filter(p=>{const m=(p.name||"").trim();return!(st.test(m)||/^(stock|label)\s+/i.test(m)||/\b(stock|label)$/i.test(m))});if(r.length<2)return null;const n=e.variationTargets||{};return r.reduce((p,m)=>{let q=n[m.name];if(q===void 0){const ht=be(m.name);for(const[gt,pt]of Object.entries(n))if(be(gt)===ht){q=pt;break}}return q===void 0&&(q=e.target),p+Math.max(0,q-(m.count??0))},0)}function N(e){const s=d(e);if(s!==null)return Math.max(0,e.target-s);const a=at(e);return a!==null?a:Math.max(0,e.target)}const{data:K=[]}=I({queryKey:["/api/make-lists"]}),{data:rt=[]}=I({queryKey:["/api/users"]}),te=y({mutationFn:async e=>{const s=await fetch("/api/restock-items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok)throw new Error("Failed to create item");return s.json()},onSuccess:()=>{f.invalidateQueries({queryKey:["/api/restock-items"]}),T(!1),xe(""),ge(0),k({title:"Item added"})}}),nt=y({mutationFn:async({id:e,...s})=>{const a=await fetch(`/api/restock-items/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update");return a.json()},onSuccess:()=>{f.invalidateQueries({queryKey:["/api/restock-items"]}),H(null),F(""),k({title:"Saved"})}});function se(e,s,a){H({id:e,field:s}),F(String(a??""))}function ae(){if(!h)return;const e=parseInt(me)||0;nt.mutate({id:h.id,[h.field]:e,editedBy:Ne||(u?"Admin":"Staff")})}function it(){H(null),F("")}function ot(e){if(e.key==="Enter"&&(e.preventDefault(),ae()),e.key==="Escape"&&(e.preventDefault(),it()),e.key==="Tab"){if(e.preventDefault(),!h)return;ae();const s=z.find(n=>n.id===h.id);if(!s)return;const a=["target"],r=a.indexOf(h.field);if(e.shiftKey){if(r>0){const n=a[r-1];setTimeout(()=>se(h.id,n,s[n]),50)}}else if(r<a.length-1){const n=a[r+1];setTimeout(()=>se(h.id,n,s[n]),50)}}}const lt=y({mutationFn:async e=>{if(!(await fetch(`/api/restock-items/${e}`,{method:"DELETE"})).ok)throw new Error("Failed to delete")},onSuccess:()=>{f.invalidateQueries({queryKey:["/api/restock-items"]}),k({title:"Item removed"})}}),dt=y({mutationFn:async({id:e,status:s})=>{if(!(await fetch(`/api/restock-items/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:s})})).ok)throw new Error("Failed to update status")},onSuccess:()=>{f.invalidateQueries({queryKey:["/api/restock-items"]}),k({title:"Saved"})}}),we=y({mutationFn:async({id:e,skipMakeList:s})=>{if(!(await fetch(`/api/restock-items/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipMakeList:s})}
1)).ok)throw new Error("Failed to update")},onSuccess:()=>{f.invalidateQueries({queryKey:["/api/restock-items"]})}}),Se=(e,s)=>{dt.mutate({id:e,status:s})},re=y({mutationFn:async()=>{const e=await fetch("/api/restock-items/link-square",{method:"POST"});if(!e.ok)throw new Error("Failed to link");return e.json()},onSuccess:e=>{f.invalidateQueries({queryKey:["/api/restock-items"]}),k({title:`Linked ${e.linked} of ${e.total} items to Square`})}}),ne=y({mutationFn:async e=>{const s=await fetch("/api/make-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok)throw new Error("Failed to create list");return s.json()},onSuccess:()=>{f.invalidateQueries({queryKey:["/api/make-lists"]})}}),B=y({mutationFn:async e=>{const s=await fetch(`/api/make-lists/${e.listId}/items`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({squareProductId:e.squareProductId,productName:e.productName,quantity:e.quantity})});if(!s.ok){const a=await s.json();throw new Error(a.message||"Failed to add item")}return s.json()},onSuccess:()=>{f.invalidateQueries({queryKey:["/api/make-lists"]}),$(null),k({title:"Added to make list"})},onError:e=>{k({title:"Error",description:e.message,variant:"destructive"})}});function ct(e){R===e?ke(s=>s==="asc"?"desc":"asc"):(Ye(e),ke(e==="name"?"asc":"desc"))}const c=i.useMemo(()=>z.filter(s=>{if(s.status==="archived"||s.status==="new"||s.status==="seasonal"||s.status==="location"||!s.name.toLowerCase().includes(U.toLowerCase())||M&&s.squareProductId||P&&N(s)<=0)return!1;if(C){const a=d(s)??0,r=o(s)??0;if(Math.max(0,s.target-a-r)<=0)return!1}if(A&&ie(s)?.image)return!1;if(w){const a=o(s)??0;if(N(s)<=0||a<=0)return!1}return!0}).sort((s,a)=>{let r,n;switch(R){case"name":r=s.name.toLowerCase(),n=a.name.toLowerCase();break;case"target":r=s.target,n=a.target;break;case"regular":r=d(s)??-1,n=d(a)??-1;break;case"shopStock":r=o(s)??-1,n=o(a)??-1;break;case"total":r=o(s)??0,n=o(a)??0;break;case"need":{r=N(s),n=N(a);break}case"needToMake":{r=Math.max(0,s.target-(d(s)??0)-(o(s)??0)),n=Math.max(0,a.target-(d(a)??0)-(o(a)??0));break}default:r=s.name.toLowerCase(),n=a.name.toLowerCase()}return r<n?D==="asc"?-1:1:r>n?D==="asc"?1:-1:0}),[z,U,R,D,M,P,C,A,w]),ie=e=>e.squareProductId?ee.find(s=>s.id===e.squareProductId):null,Ce=c.reduce((e,s)=>e+s.target,0),ut=c.reduce((e,s)=>e+(d(s)??0),0),V=c.reduce((e,s)=>e+(o(s)??0),0),oe=c.reduce((e,s)=>e+N(s),0),mt=c.filter(e=>N(e)>0).length;async function xt(){if(!g)return;const s=ie(g)?.id||g.squareProductId||0,a=g.name;if(Y){const r=await ne.mutateAsync({name:W,assignedUserId:X?parseInt(X):null});await B.mutateAsync({listId:r.id,squareProductId:s,productName:a,quantity:G})}else E&&await B.mutateAsync({listId:E,squareProductId:s,productName:a,quantity:G})}return et?t.jsx(Te,{children:t.jsx("div",{className:"flex justify-center py-20",children:t.jsx(Q,{className:"h-8 w-8 animate-spin text-primary"})})}):t.jsx(Te,{children:t.jsxs("div",{className:"max-w-[1400px]",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center mb-8 gap-4",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-serif text-primary mb-2","data-testid":"text-zodiac-restock-title",children:"Zodiac Restock"}),ve&&t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"text-square-synced-at",children:["Square synced: ",new Date(ve).toLocaleString("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})]}),t.jsx("p",{className:"text-muted-foreground",children:"Track zodiac product inventory targets, shop stock, and production needs."})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(l,{variant:u?"default":"outline",className:u?"bg-amber-500 hover:bg-amber-600 text-white":"",onClick:()=>Je(!u),"data-testid":"button-admin-mode",children:[u?t.jsx(It,{className:"h-4 w-4 mr-2"}):t.jsx(le,{className:"h-4 w-4 mr-2"}),u?"Admin Mode":"Locked"]}),t.jsxs(l,{variant:"outline",onClick:()=>re.mutate(),disabled:re.isPending,"data-testid":"button-link-square",children:[re.isPending?t.jsx(Q,{className:"h-4 w-4 mr-2 animate-spin"}):t.jsx(yt,{className:"h-4 w-4 mr-2"}),"Link Square"]}),u&&t.jsxs(l,{className:"bg-primary text-white",onClick:()=>T(!0),"data-testid":"button-add-zodiac-item",children:[t.jsx(ze,{className:"h-4 w-4 mr-2"})," Add Item"]})]})]}),t.jsxs("div",{className:"flex items-center gap-4 mb-3",children:[t.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full bg-green-600 mr-1.5"}),"Green names indicate products linked to Square"]}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.jsx("label",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"Your Name:"}),t.jsx(v,{className:"w-32 h-7 text-xs",placeholder:"Enter name",value:Ne,onChange:e=>{_e(e.target.value),localStorage.setItem("restockEditorName",e.target.value)},"data-testid":"input-editor-name"})]})]}),t.jsx("div",{className:"mb-4",children:t.jsxs("button",{onClick:()=>He(e=>!e),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors","data-testid":"toggle-dashboard",children:[Z?t.jsx(Lt,{className:"h-4 w-4"}):t.jsx(kt,{className:"h-4 w-4"}),Z?"Hide Dashboard":"Show Dashboard"]})}),Z&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[t.jsxs(b,{className:"p-4 w-24",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Items"}),t.jsx("div",{className:"text-2xl font-bold text-primary","data-testid":"text-zodiac-total-items",children:V})]}),t.jsxs(b,{className:"p-4",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Target"}),t.jsx("div",{className:"text-2xl font-bold","data-testid":"text-zodiac-total-target",children:Ce})]}),t.jsxs(b,{className:"p-4",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Shop Stock (Square)"}),t.jsx("div",{className:"text-2xl font-bold text-green-600","data-testid":"text-zodiac-shop-stock",children:V})]}),t.jsxs(b,{className:"p-4",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Units Needed"}),t.jsx("div",{className:"text-2xl font-bold text-amber-600","data-testid":"text-zodiac-units-needed",children:oe})]}),t.jsxs(b,{className:"p-4",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Need Restock"}),t.jsx("div",{className:"text-2xl font-bold text-red-600","data-testid":"text-zodiac-need-restock",children:mt})]}),t.jsxs(b,{className:"p-4",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Need to Make"}),t.jsx("div",{className:"text-2xl font-bold text-orange-600","data-testid":"text-zodiac-need-to-make",children:c.reduce((e,s)=>e+Math.max(0,s.target-(d(s)??0)-(o(s)??0)),0)})]})]})}),t.jsxs("div",{className:"flex flex-col md:flex-row gap-4 mb-6",children:[t.jsxs("div",{className:"relative w-48",children:[t.jsx(Nt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(v,{placeholder:"Search...",className:"pl-10 bg-white",value:U,onChange:e=>Ke(e.target.value),"data-testid":"input-search-zodiac"})]}),t.jsxs(l,{variant:M?"default":"outline",size:"sm",onClick:()=>Be(e=>!e),className:x("gap-1.5",M&&"bg-[#2B4650] hover:bg-[#2B4650]/90"),"data-testid":"filter-not-linked",children:[t.jsx(Mt,{className:"h-3.5 w-3.5"}),"Not Linked"]}),t.jsxs(l,{variant:P?"default":"outline",size:"sm",onClick:()=>Ve(e=>!e),className:x("gap-1.5",P&&"bg-red-600 hover:bg-red-700"),"data-testid":"filter-need",children:[t.jsx(qe,{className:"h-3.5 w-3.5"}),"Need on Shelf"]}),t.jsxs(l,{variant:C?"default":"outline",size:"sm",onClick:()=>Qe(e=>!e),className:x("gap-1.5",C&&"bg-orange-600 hover:bg-orange-700"),"data-testid":"filter-need-to-make",children:[t.jsx(qe,{className:"h-3.5 w-3.5"}),"Need to Make"]}),t.jsxs(l,{variant:A?"default":"outline",size:"sm",onClick:()=>Ue(e=>!e),className:x("gap-1.5",A&&"bg-purple-600 hover:bg-purple-700"),"data-testid":"filter-need-photos",children:[t.jsx(Pt,{className:"h-3.5 w-3.5"}),"Need Photos"]}),t.jsx(vt,{category:S}),t.jsx(Re,{squareProducts:ee,categoryName:"Zodiac",items:c.map(e=>({name:e.name,shopStock:o(e)??0,target:e.target,needed:Math.max(0,e.target-(o(e)??0)),squareProductId:e.squareProductId,variationTargets:e.variationTargets,shelfStock:e.shelfStock}))}),C&&t.jsx(Re,{squareProducts:ee,categoryName:"Zodiac",mode:"needToMake",items:c.map(e=>({name:e.name,shopStock:o(e)??0,target:e.target,needed:Math.max(0,e.target-(d(e)??0)-(o(e)??0)),squareProductId:e.squareProductId,variationTargets:e.variationTargets,shelfStock:e.shelfStock}))}),t.jsxs(l,{variant:w?"default":"outline",size:"sm",onClick:()=>Ze(e=>!e),className:x("gap-1.5",w&&"bg-green-600 hover:bg-green-700"),"data-testid":"filter-ready-to-shelf",children:[t.jsx(Oe,{className:"h-3.5 w-3.5"}),"Ready to Shelf"]}),t.jsx(Ct,{columns:[{key:"regular",label:"Regular"},{key:"target",label:"Target"},{key:"shopStock",label:"Shop Stock"},{key:"total",label:"Total"},{key:"need",label:"Need to Restock"},{key:"needToMake",label:"Need to Make"}],hiddenColumns:We,onToggle:Xe})]}),w?t.jsx(Tt,{categoryName:"Zodiac",items:c.map(e=>({id:e.id,name:e.name,currentStock:d(e)??0,stock:o(e)??0,target:e.target}))}):t.jsx(b,{children:t.jsx("div",{className:"overflow-auto flex-1",style:{maxHeight:"calc(100vh - 200px)"},children:t.jsxs("table",{className:"w-full text-sm text-left",children:[t.jsx("thead",{className:"bg-gray-50 uppercase text-xs font-medium sticky top-0 z-10 shadow-sm",style:{color:"#2B4650"},children:t.jsxs("tr",{children:[[{key:"name",label:"Product",sub:"",align:"left"},{key:"target",label:"Target",sub:"(Target)",align:"center",lockIcon:!u},{key:"regular",label:"Regular",sub:"(Square)",align:"center",squareCol:!0},{key:"shopStock",label:"Shop Stock",sub:"(Square)",align:"center",squareCol:!0},{key:"total",label:"Total",sub:"",align:"center"},{key:"need",label:"Need to Restock",sub:"Target - Regular",align:"center"},{key:"needToMake",label:"Need to Make",sub:"Target - Reg - Shop",align:"center"}].filter(e=>e.key==="name"||j(e.key)).map(e=>t.jsx("th",{className:x("px-4 py-3 cursor-pointer select-none hover:text-gray-700 transition-colors",e.align==="center"?"text-center":"text-left"),style:e.squareCol?{color:"#16a34a",backgroundColor:"#f0fdf4"}:void 0,onClick:()=>ct(e.key),"data-testid":`sort-${e.key}`,children:t.jsxs("div",{className:x("flex flex-col items-center",e.align==="left"&&"items-start"),children:[t.jsxs("div",{className:x("flex items-center gap-1",e.align==="center"&&"justify-center"),children:[e.lockIcon&&t.jsx(le,{className:"h-3 w-3"}
1),e.label,R===e.key?D==="asc"?t.jsx(Oe,{className:"h-3 w-3"}):t.jsx(At,{className:"h-3 w-3"}):t.jsx(Ft,{className:"h-3 w-3 opacity-30"})]}),e.sub&&t.jsx("span",{className:"text-[9px] font-normal normal-case text-gray-400",children:e.sub})]})},e.key)),t.jsx("th",{className:"px-4 py-3 text-right",children:"Actions"})]})}),t.jsxs("tbody",{className:"divide-y divide-gray-100 bg-white",children:[c.map(e=>{const s=ie(e),a=o(e)??0,r=d(e)??0,n=a,p=N(e);return t.jsxs(i.Fragment,{children:[t.jsxs("tr",{className:x("hover:bg-gray-50/50",s?"bg-green-50/40":"",p>0&&!s&&"bg-red-50/30"),"data-testid":`row-zodiac-${e.id}`,children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[s?.image?t.jsx("img",{src:s.image,alt:"",className:"h-9 w-9 object-cover rounded bg-gray-100"}):t.jsx("div",{className:"h-9 w-9 rounded bg-gray-100 flex items-center justify-center",children:t.jsx(de,{className:"h-4 w-4 text-gray-400"})}),t.jsx("div",{children:t.jsx("p",{className:x("font-medium",s?"text-green-600":""),style:{color:s?void 0:"#2B4650"},children:e.name})})]})}),j("target")&&t.jsx("td",{className:"px-4 py-3 text-center",children:h?.id===e.id&&h?.field==="target"?t.jsx(v,{type:"number",className:"w-16 h-8 text-center mx-auto",value:me,onChange:m=>F(m.target.value),onBlur:ae,onKeyDown:ot,autoFocus:!0,"data-testid":`input-target-${e.id}`}):u?t.jsx("span",{className:"font-medium cursor-pointer hover:bg-blue-50 px-2 py-1 rounded transition-colors",style:{color:"#2B4650"},onClick:()=>se(e.id,"target",e.target),"data-testid":`text-target-${e.id}`,children:e.target}):t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(le,{className:"h-3 w-3 text-gray-300"}),t.jsx("span",{className:"font-medium",style:{color:"#2B4650"},"data-testid":`text-target-${e.id}`,children:e.target})]})}),j("regular")&&t.jsx("td",{className:"px-4 py-3 text-center",style:{backgroundColor:"#f0fdf4"},children:d(e)!==null?t.jsx("span",{className:"font-mono font-medium text-green-600","data-testid":`text-regular-${e.id}`,children:d(e)}):t.jsx("span",{className:"text-gray-300 text-xs","data-testid":`text-regular-${e.id}`,children:"â"})}),j("shopStock")&&t.jsx("td",{className:"px-4 py-3 text-center",style:{backgroundColor:"#f0fdf4"},children:o(e)!==null?t.jsx("span",{className:"font-mono font-medium text-green-600","data-testid":`text-shop-${e.id}`,children:a}):t.jsx("span",{className:"text-gray-300 text-xs","data-testid":`text-shop-${e.id}`,children:"â"})}),j("total")&&t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx("span",{className:"font-bold",style:{color:"#2B4650"},"data-testid":`text-total-${e.id}`,children:n})}),j("need")&&t.jsx("td",{className:"px-4 py-3 text-center",children:p>0?t.jsx(ce,{variant:"outline",className:"border-red-200 text-red-600 font-bold","data-testid":`badge-need-${e.id}`,children:p}):t.jsx($t,{className:"h-4 w-4 text-green-500 mx-auto","data-testid":`icon-ok-${e.id}`})}),j("needToMake")&&t.jsx("td",{className:"px-4 py-3 text-center",children:(()=>{if(e.skipMakeList)return t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(De,{className:"h-3 w-3 text-amber-500"}),t.jsx("span",{className:"text-xs text-amber-500 font-medium","data-testid":`text-need-to-make-${e.id}`,children:"Skip"}),u&&t.jsx("button",{onClick:()=>we.mutate({id:e.id,skipMakeList:!1}),className:"ml-1 text-[10px] text-gray-400 hover:text-gray-600 underline","data-testid":`button-unskip-${e.id}`,children:"undo"})]});const m=Math.max(0,e.target-r-a);return t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx("span",{className:x("font-bold",m>0?"text-orange-600":"text-green-600"),"data-testid":`text-need-to-make-${e.id}`,children:m}),u&&m>0&&t.jsx("button",{onClick:()=>we.mutate({id:e.id,skipMakeList:!0}),className:"ml-1 opacity-0 group-hover:opacity-100 transition-opacity",title:"Skip from make list","data-testid":`button-skip-${e.id}`,children:t.jsx(De,{className:"h-3 w-3 text-gray-300 hover:text-amber-500"})})]})})()}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsxs("div",{className:"flex gap-1 justify-end",children:[p>0&&e.squareProductId&&t.jsxs(l,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs",onClick:()=>{$(e),pe(p),fe(K.length>0?K[0].id:null),_(!1),je(""),ye("")},"data-testid":`button-add-to-list-${e.id}`,children:[t.jsx(Et,{className:"h-3 w-3 mr-1"})," List"]}),u&&t.jsx(l,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-red-400 hover:text-red-600",onClick:()=>lt.mutate(e.id),"data-testid":`button-delete-${e.id}`,children:t.jsx(Rt,{className:"h-3.5 w-3.5"})}),u&&t.jsx(bt,{itemId:e.id,onStatusChange:Se})]})})]}),t.jsx(qt,{squareInfo:s,isColumnVisible:j,columnKeys:["target","regular","shopStock","total","need","needToMake"]})]},e.id)}),c.length===0&&t.jsx("tr",{children:t.jsxs("td",{colSpan:7,className:"px-4 py-12 text-center text-muted-foreground",children:[t.jsx(de,{className:"h-8 w-8 mx-auto mb-3 text-gray-300"}
1),t.jsx("p",{children:"No zodiac restock items yet."}),t.jsx(l,{variant:"link",className:"mt-2",onClick:()=>T(!0),children:"Add your first item"})]})})]}),c.length>0&&t.jsx("tfoot",{className:"bg-gray-50 font-medium text-sm",style:{color:"#2B4650"},children:t.jsxs("tr",{children:[t.jsxs("td",{className:"px-4 py-3",children:["Totals (",c.length," items)"]}),t.jsx("td",{className:"px-4 py-3 text-center",children:Ce}),t.jsx("td",{className:"px-4 py-3 text-center",style:{backgroundColor:"#f0fdf4"},children:t.jsx("span",{className:"font-mono text-green-600",children:ut})}),t.jsx("td",{className:"px-4 py-3 text-center",style:{backgroundColor:"#f0fdf4"},children:t.jsx("span",{className:"font-mono text-green-600",children:V})}),t.jsx("td",{className:"px-4 py-3 text-center font-bold",children:V}),t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx(ce,{variant:"outline",className:x("font-bold",oe>0?"border-red-200 text-red-600":"border-green-200 text-green-600"),children:oe})}),t.jsx("td",{className:"px-4 py-3 text-center",children:(()=>{const e=c.reduce((s,a)=>a.skipMakeList?s:s+Math.max(0,a.target-(d(a)??0)-(o(a)??0)),0);return t.jsx(ce,{variant:"outline",className:x("font-bold",e>0?"border-orange-200 text-orange-600":"border-green-200 text-green-600"),children:e})})()}),t.jsx("td",{className:"px-4 py-3"})]})})]})})}),t.jsx(Ae,{open:Ge,onOpenChange:T,children:t.jsxs(Fe,{className:"sm:max-w-md",children:[t.jsx($e,{children:t.jsx(Ee,{children:"Add Zodiac Item"})}),t.jsxs("div",{className:"space-y-4 py-2",children:[t.jsxs("div",{children:[t.jsx(L,{children:"Product Name"}),t.jsx(v,{value:J,onChange:e=>xe(e.target.value),placeholder:"e.g. Aries Candle","data-testid":"input-new-item-name"})]}),t.jsxs("div",{children:[t.jsx(L,{children:"Target Stock"}),t.jsx(v,{type:"number",value:he,onChange:e=>ge(parseInt(e.target.value)||0),"data-testid":"input-new-item-target"})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(l,{variant:"outline",onClick:()=>T(!1),children:"Cancel"}),t.jsxs(l,{className:"bg-primary text-white",disabled:!J.trim()||te.isPending,onClick:()=>te.mutate({name:J.trim(),category:S,target:he}),"data-testid":"button-confirm-add-item",children:[te.isPending?t.jsx(Q,{className:"h-4 w-4 animate-spin mr-2"}):null,"Add Item"]})]})]})}),t.jsx(Ae,{open:!!g,onOpenChange:e=>{e||$(null)},children:t.jsxs(Fe,{className:"sm:max-w-md",children:[t.jsx($e,{children:t.jsx(Ee,{children:"Add to Make List"})}),g&&t.jsxs("div",{className:"space-y-4 py-2",children:[t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 rounded-lg",children:[t.jsx(de,{className:"h-5 w-5 text-primary"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:g.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.max(0,g.target-(o(g)??0))," to reach target of ",g.target]})]})]}),t.jsxs("div",{children:[t.jsx(L,{children:"Quantity"}),t.jsx(v,{type:"number",min:1,value:G,onChange:e=>pe(parseInt(e.target.value)||1),"data-testid":"input-list-quantity"})]}),Y?t.jsxs("div",{className:"space-y-3 border rounded-lg p-3 bg-blue-50/50",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(L,{className:"text-sm font-medium",children:"New Make List"}),t.jsx(l,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>_(!1),children:"Use existing"})]}),t.jsx(v,{placeholder:"List name...",value:W,onChange:e=>je(e.target.value),"data-testid":"input-new-list-name"}),t.jsxs(Ie,{value:X,onValueChange:ye,children:[t.jsx(Le,{"data-testid":"select-assignee",children:t.jsx(Me,{placeholder:"Assign to employee (optional)"})}),t.jsxs(Pe,{children:[t.jsx(ue,{value:"none",children:"Unassigned"}),rt.map(e=>t.jsx(ue,{value:e.id.toString(),children:e.name},e.id))]})]})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(L,{children:"Select Make List"}),K.length>0?t.jsxs(Ie,{value:E?.toString()||"",onValueChange:e=>fe(parseInt(e)),children:[t.jsx(Le,{"data-testid":"select-make-list",children:t.jsx(Me,{placeholder:"Choose a list..."})}),t.jsx(Pe,{children:K.map(e=>t.jsxs(ue,{value:e.id.toString(),children:[e.name," (",e.status,")"]},e.id))})]}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No lists available."}),t.jsxs(l,{variant:"link",size:"sm",className:"px-0 text-xs",onClick:()=>_(!0),"data-testid":"button-create-new-list",children:[t.jsx(ze,{className:"h-3 w-3 mr-1"})," Create New List"]})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(l,{variant:"outline",onClick:()=>$(null),children:"Cancel"}),t.jsxs(l,{className:"bg-primary text-white",disabled:B.isPending||ne.isPending||(Y?
1!W.trim():!E),onClick:xt,"data-testid":"button-confirm-add-to-list",children:[B.isPending||ne.isPending?t.jsx(Q,{className:"h-4 w-4 animate-spin mr-2"}):null,"Add to List"]})]})]})]})}),!w&&t.jsx(wt,{items:z,onStatusChange:Se})]})})}export{xs 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.