1import{r as n,ck as V,j as e,a9 as Y,aa as q,ab as G,ac as J,ar as g,D as d,ax as Q,ay as U,az as D,b6 as b,Y as A,aA as E,L as j,I as W,K as y,B as i,bM as X,aR as L,a4 as B,ad as Z}from"./index-Cz3wH2jj.js";import{t as F}from"./entityTag-D1e4LtxC.js";function ae({open:C,onOpenChange:T,selectedProductIds:r,tags:c,productTags:R,onCreateTag:z,onDeleteTag:_,onBulkAddTag:I,onBulkRemoveTag:K}){const[o,M]=n.useState("add"),[m,f]=n.useState(""),[w,O]=n.useState(F[10].value),[l,x]=n.useState([]),[$,h]=n.useState(!1),[N,u]=n.useState(!1),p=s=>{let a=0;return r.forEach(t=>{(R[t]||[]).includes(s)&&a++}),a===0?"none":a===r.length?"all":"some"},H=async()=>{if(!m.trim())return;u(!0);const s=await z(m.trim(),w);u(!1),s&&(f(""),h(!1))},k=s=>{x(a=>a.includes(s)?a.filter(t=>t!==s):[...a,s])},S=async()=>{if(u(!0),o==="add")for(const s of l)await I(r,s);else for(const s of l)await K(r,s);u(!1),x([]),T(!1)},v=()=>{x([]),h(!1),f(""),T(!1)};return V({open:C,onClose:v,onSave:S,canSave:l.length>0&&!N}),e.jsx(Y,{open:C,onOpenChange:v,children:e.jsxs(q,{className:"max-w-md",children:[e.jsx(G,{children:e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(g,{className:"h-5 w-5"}),"Manage Tags",e.jsxs(d,{variant:"secondary",className:"ml-2",children:[r.length," product",r.length!==1?"s":""]})]})}),e.jsxs(Q,{value:o,onValueChange:s=>{M(s),x([])},children:[e.jsxs(U,{className:"grid w-full grid-cols-2",children:[e.jsxs(D,{value:"add",className:"gap-2",children:[e.jsx(b,{className:"h-4 w-4"}),"Add Tags"]}),e.jsxs(D,{value:"remove",className:"gap-2",children:[e.jsx(A,{className:"h-4 w-4"}),"Remove Tags"]})]}),e.jsxs(E,{value:"add",className:"space-y-4 mt-4",children:[$?e.jsxs("div",{className:"space-y-3 p-3 border border-border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Tag Name"}),e.jsx(W,{placeholder:"Enter tag name...",value:m,onChange:s=>f(s.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.map(s=>e.jsx("button",{className:y("h-6 w-6 rounded-full transition-all",w===s.value&&"ring-2 ring-offset-2 ring-offset-background ring-primary"),style:{backgroundColor:s.value},onClick:()=>O(s.value),title:s.name},s.value))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(i,{size:"sm",onClick:H,disabled:!m.trim()||N,children:[e.jsx(X,{className:"h-4 w-4 mr-1"}),"Create"]}),e.jsx(i,{size:"sm",variant:"ghost",onClick:()=>h(!1),children:"Cancel"})]})]}):e.jsxs(i,{variant:"outline",className:"w-full justify-start gap-2 border-dashed",onClick:()=>h(!0),children:[e.jsx(b,{className:"h-4 w-4"}),"Create New Tag"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{className:"text-muted-foreground",children:"Select tags to add"}),e.jsx(L,{className:"h-[200px] border border-border rounded-lg",children:c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8 text-muted-foreground",children:[e.jsx(g,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No tags created yet"}),e.jsx("p",{className:"text-xs",children:"Create your first tag above"})]}):e.jsx("div",{className:"p-2 space-y-1",children:c.map(s=>{const a=p(s.id),t=l.includes(s.id);return e.jsxs("div",{className:y("flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors",t?"bg-primary/10":"hover:bg-muted"),onClick:()=>k(s.id),children:[e.jsx(B,{checked:t,className:"pointer-events-none"}),e.jsx("div",{className:"h-3 w-3 rounded-full flex-shrink-0",style:{backgroundColor:s.color}}),e.jsx("span",{className:"flex-1 text-sm",children:s.name}),a==="all"&&e.jsx(d,{variant:"secondary",className:"text-xs",children:"All have"}),a==="some"&&e.jsx(d,{variant:"outline",className:"text-xs",children:"Some have"})]},s.id)})})})]})]}),e.jsx(E,{value:"remove",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{className:"text-muted-foreground",children:"Select tags to remove from selected products"}),e.jsx(L,{className:"h-[260px] border border-border rounded-lg",children:c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8 text-muted-foreground",children:[e.jsx(g,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No tags to remove"})]}):e.jsxs("div",{className:"p-2 space-y-1",children:[c.map(s=>
1{const a=p(s.id),t=l.includes(s.id);return a==="none"?null:e.jsxs("div",{className:y("flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors",t?"bg-destructive/10":"hover:bg-muted"),onClick:()=>k(s.id),children:[e.jsx(B,{checked:t,className:"pointer-events-none"}),e.jsx("div",{className:"h-3 w-3 rounded-full flex-shrink-0",style:{backgroundColor:s.color}}),e.jsx("span",{className:"flex-1 text-sm",children:s.name}),a==="all"&&e.jsx(d,{variant:"secondary",className:"text-xs",children:"On all"}),a==="some"&&e.jsx(d,{variant:"outline",className:"text-xs",children:"On some"})]},s.id)}),c.every(s=>p(s.id)==="none")&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[e.jsx(g,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No tags on selected products"})]})]})})]})})]}),e.jsxs(Z,{className:"flex-col sm:flex-row gap-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground mr-auto",children:["Press ",e.jsx("kbd",{className:"px-1.5 py-0.5 text-xs bg-muted rounded border",children:"Ctrl"}),"+",e.jsx("kbd",{className:"px-1.5 py-0.5 text-xs bg-muted rounded border",children:"Enter"})," to save"]}),e.jsx(i,{variant:"outline",onClick:v,children:"Cancel"}),e.jsx(i,{onClick:S,disabled:l.length===0||N,className:o==="remove"?"bg-destructive hover:bg-destructive/90":"",children:o==="add"?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"h-4 w-4 mr-1"}),"Add ",l.length>0&&`(${l.length})`," Tags"]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"h-4 w-4 mr-1"}),"Remove ",l.length>0&&`(${l.length})`," Tags"]})})]})]})})}export{ae as BulkTagDialog};
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.