1import{a as o,j as e}from"./react-vendor-DgOoyD0u.js";import{C as _e,a as V,b as Ge,u as Re,dP as Be,br as wt,A as ot,d as lt,i as dt,df as kt,S as ge,aB as St,M as Oe,Q as Ct,aD as Ne,aC as it,eK as ct,ae as Pt,c as Lt,b7 as Mt,w as Tt,N as Et,H as $e,B as Ye,pm as At,R as Ze,bz as Rt,e1 as Dt,d_ as Ft}from"./index-gGVBATlq.js";import{b as It,c7 as Bt,F as ut,dI as Ue,a8 as Ot,cV as $t}from"./vendor-react-icons-DTNGkDGs.js";import{P as Ut}from"./PageHeaderRegistration-jUY79cPc.js";import{P as Ht,a as Vt,b as Gt}from"./index-DrqHhBUX.js";import{g as zt,p as Wt}from"./pageContentTitle-DPz0hkPm.js";import{k as qe,l as Yt}from"./productSubnavNavigation-DBHg9OXu.js";import{U as Zt,V as qt,m as gt,l as mt,W as Kt,X as Qt,Y as Jt,Z as Xt,_ as ea,$ as ta,a0 as aa,a1 as sa,a2 as ra,a3 as na,a4 as oa,a5 as la,L as da,M as ia,B as ca,u as ua,a6 as ga,D as ma,z as ze,a7 as xa,T as pa,a8 as ha,a9 as fa,aa as ba,t as ya,v as ja,r as va,j as Na,ab as Ke,ac as _a,ad as wa,p as ka}from"./products-Cm41jdw4.js";import{C as Sa}from"./index-Dndr5KMQ.js";import{E as Ca}from"./ExternalSources-BNHUWqk-.js";import{C as Pa}from"./index-lTHmdI-o.js";import{a as La,C as Ma}from"./mappingCascadeSummary-CM_BFu9E.js";import{C as Ee}from"./ChildBrandMappingStatusBadge-wmaqcd3p.js";import{D as Ta,k as Ea}from"./core.esm-B5eND4ED.js";import{S as Aa,v as Ra}from"./sortable.esm-CvdXlpau.js";import{u as Da,C as Fa,a as Ia,r as Ba,c as Oa}from"./productModifier-BsO4uDap.js";import{l as $a,f as Qe,i as Ua,C as Ha}from"./CatalogueSubNav-DqFA9-GQ.js";import{p as Je,C as He,a as Xe}from"./CatalogueListPagination-C3s8EOtD.js";import{u as Va}from"./productCategories-BsZayTSH.js";import{T as xt,L as Ga,Q as za}from"./vendor-flowbite-DLP2iZ0W.js";import{b as Wa}from"./vendor-tanstack-C4KNVybO.js";import"./vendor-mermaid-Bx-bZjuG.js";import"./vendor-cytoscape-BgeL2iwd.js";import"./vendor-lodash-DtG3RRjV.js";import"./vendor-markdown-CitJEg14.js";import"./usePillTabSlider-BQJJlb7J.js";import"./useHorizontalScrollFade-DCXhGVN_.js";import"./formatJson-DiL1gYJ-.js";import"./business-Da35vIMP.js";import"./OrganisationWorkspaceContext-CdltXD8G.js";import"./index-DeEqEilg.js";import"./ListPagination-Bee4nPyi.js";const Ya=async({payload:t,...a})=>_e("POST","/app/upload-file",t,{...a}).then(d=>d.data.response),Za=async({payload:t,...a})=>_e("POST","/app/regenerate-product",t,{...a}).then(d=>d.data.response),qa=async({payload:t,...a})=>_e("POST","/app/generate-metadata",t,{...a}).then(d=>d.data.response),Ka=async({payload:t,...a})=>_e("GET",`/app/browse-extracted-product/${t.brand_id}`,{},{...a}).then(d=>d.data.response),Qa=async({payload:t,...a})=>_e("GET",`/app/browse-brand-files/${t.brand_id}`,{},{...a}).then(d=>d.data.response),Ja=async({payload:t,token:a})=>await Ka({payload:t,token:a}),Xa=async({payload:t,token:a})=>await Ya({payload:t,token:a}),es=async({payload:t,token:a})=>await Za({payload:t,token:a}),ts=async({payload:t,token:a})=>await qa({payload:t,token:a}),as=async({payload:t,token:a})=>await Qa({payload:t,token:a}),ss={uploadFile:Xa,extractProduct:es,generateMetadata:ts,getExtractedProducts:Ja,fetchUploadedFiles:as};function Ve(t){if(t==null||t==="")return"â";const a=Number(t);return Number.isFinite(a)?`$${a.toFixed(2)}`:"â"}function et(t){return t?.length?t.join(", "):"â"}function me(t){return String(t||"").trim().replace(/\s+/g," ").toLowerCase()}function tt(t){return(t||[]).map(a=>String(a||"").trim()).filter(Boolean).sort((a,d)=>a.localeCompare(d))}function rs(t,a){const d=tt(t).map(me),c=tt(a).map(me);return d.length!==c.length?!0:d.some((i,_)=>i!==c[_])}function pt(t,a){return a?.reporting_groups?.[0]?.name||t.ho_reporting_group_name||t.identity_json?.ho?.reporting_group||null}function ht(t){return t.venue_reporting_group_name||t.identity_json?.venue?.reporting_group||null}function ft(t,a){const d=(a?.categories||[]).map(c=>c.name).filter(Boolean);return d.length>0?d:t.identity_json?.ho?.categories||[]}function bt(t){return t.identity_json?.venue?.categories||[]}function yt(t,a){const d=a?.product_name||t.ho_product_name||t.identity_json?.ho?.name,c=t.venue_product_name||t.identity_json?.venue?.name;return!!(me(d)!==me(c)||rs(ft(t,a),bt(t))||me(pt(t,a))!==me(ht(t)))}function ns(t){return t.last_push_status==="pending"}function os(t,a){return t.last_push_status==="pending"||t.last_push_status==="error"?!0:yt(t,a)}const Ae=[{value:"autoflow",label:"Auto-flow changes",helper:"Head office edits update this child brand. Price stays on this child brand."},{value:"hold",label:"Linked, no updates",helper:"Stay mapped. This child brand does not change when head office is edited."},{value:"unlinked",label:"Unlinked",helper:"Remove the mapping. The product on this child brand is not deleted."}];function jt(t){return Ae.find(a=>a.value===t)||Ae[1]}function ls(){return Ae.filter(t=>t.value!=="unlinked")}function ds({editableVenues:t,choices:a}){const d=[],c=[];for(const i of t){const _=a[i.venue_brand_id];if(!(!_||_.action==="skip")){if(_.action==="create"){d.push({venue_brand_id:i.venue_brand_id,action:"create"}),c.push({brandName:i.venue_brand_name,kind:"create"});continue}if(_.action==="map"&&_.venue_product_id){const k=_.sync_mode==="autoflow";d.push({venue_brand_id:i.venue_brand_id,action:"map",venue_product_id:Number(_.venue_product_id),sync_mode:_.sync_mode,...k?{overwrite:!0}:{}}),c.push({brandName:i.venue_brand_name,kind:k?"overwrite":"link"})}}}return{selections:d,actions:c}}const is={prefix_false_friend:"Similar name, not the same item",price_mismatch:"Prices do not match",category_mismatch:"Categories do not match",class_clash:"Food, drink, and retail cannot be mixed",ambiguous_match:"More than one possible match",modifier_mismatch:"Modifier versus a sold product",venue_deleted:"Deleted on this child brand",product_deleted:"Deleted on this child brand",missing_venue_product:"No longer on this child brand",deleted:"Deleted on this child brand",variant_mismatch:"Different drink variants",partial_name:"Names only partly overlap",low_name_confidence:"Names are not close enough"},cs=new Set(["size_conflict","size_unspecified","ai_same_item_diff_size","ai_invented_size"]);function us(t){return is[t]||t.replace(/_/g," ")}function gs(t){return(t||[]).filter(a=>!cs.has(a)).map(us).join(" · ")}function at(t){return t.venue_is_sold==null?t.identity_json?.venue?.is_sold!==!1:!!t.venue_is_sold}function ms(t){return t==="confirmed"||t==="created_from_ho"?"Linked":t==="suggested"?"Suggested":t==="ambiguous"?"Needs review":t==="pending"?"Copy in progress":t==="ignored"?"Ignored":"Not linked"}function Te({label:t,left:a,right:d}){return e.jsxs("tr",{children:[e.jsx("th",{className:"py-1.5 pr-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400",children:t}),e.jsx("td",{className:"py-1.5 pr-3 text-sm text-gray-800 dark:text-gray-200",children:a}),e.jsx("td",{className:"py-1.5 text-sm text-gray-800 dark:text-gray-200",children:d})]})}function ve(t){return mt({status:t.status||t.link?.status,venue_deleted:t.venue_deleted??t.link?.venue_deleted,venue_missing:t.venue_missing??t.link?.venue_missing,deleted:t.link?.deleted,reason_codes:[...t.reason_codes||[],...t.link?.reason_codes||[]]})}function xs(t,a){const d=mt(t);return gt({mapped:!d&&(t.status==="confirmed"||t.status==="created_from_ho"),lastPushStatus:t.last_push_status,status:t.status,action:"skip",deleted:d,syncMode:t.sync_mode,pendingPush:yt(t,a)})}function ps(t){return t.sync_mode==="autoflow"?"autoflow":"hold"}
1function hs({brandId:t,hoProductId:a,venueBrandId:d,venueBrandName:c,link:i,product:_}){const k=Kt(),E=Qt(),j=Jt(),n=Xt(),x=i.identity_json,w=x?.ho,N=x?.venue,L=o.useRef(null),[S,T]=o.useState(()=>at(i)),y=ps(i),I=jt(y).helper,O=os(i,_),A=ns(i)||n.isLoading,l=E.isLoading||j.isLoading||n.isLoading;o.useEffect(()=>{const u=at(i);if(L.current!=null){u===L.current&&(L.current=null);return}T(u)},[i]);const h=i.last_push_status==="pending"?"Updating child brandâ¦":i.last_push_status==="error"?i.last_push_error||"Update failed":i.last_push_status==="ok"?"Child brand up to date":null,v=u=>{if(u==="unlinked"){E.mutate({brand_id:t,link_id:i.id});return}u!==y&&j.mutate({brand_id:t,link_id:i.id,sync_mode:u})};return e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-4 dark:border-dm-border-subtle dark:bg-dm-surface",children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:c}),e.jsx(Ee,{compact:!0,status:xs(i,_)})]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[ms(i.status),h?` · ${h}`:""]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx("span",{children:"Available to sell"}),e.jsx(Pa,{checked:S,disabled:k.isLoading,onChange:u=>{const b=S;L.current=u,T(u),k.mutate({brand_id:t,product_id:a,venue_brand_id:Number(d),is_sold:u},{onError:()=>{L.current=null,T(b)}})}})]})]}),e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-36"}),e.jsx("th",{className:"pb-1 text-left text-xs font-medium text-gray-500 dark:text-gray-400",children:"Head office"}),e.jsx("th",{className:"pb-1 text-left text-xs font-medium text-gray-500 dark:text-gray-400",children:"Child brand"})]})}),e.jsxs("tbody",{children:[e.jsx(Te,{label:"Name",left:_.product_name||w?.name||i.ho_product_name||"â",right:i.venue_product_name||N?.name||"â"}),e.jsx(Te,{label:"Price",left:Ve(w?.price??i.ho_product_price),right:Ve(N?.price??i.venue_product_price)}),e.jsx(Te,{label:"Category",left:et(ft(i,_)),right:et(bt(i))}),e.jsx(Te,{label:"Reporting group",left:pt(i,_)||"â",right:ht(i)||"â"})]})]}),e.jsxs("fieldset",{className:"mt-4 flex flex-col gap-2 border-t border-gray-100 pt-3 text-sm dark:border-dm-border-subtle",children:[e.jsx("legend",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Link type"}),e.jsx("select",{className:"w-full max-w-xs rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200",value:y,disabled:l,"aria-label":`Link type for ${c}`,onChange:u=>v(u.target.value),children:Ae.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:I})]}),O?e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsx("button",{type:"button",className:Ge,disabled:l||A,onClick:()=>n.mutate({brand_id:t,product_id:a,venue_brand_ids:[Number(d)],overwrite_properties:!0}),children:A?"Updatingâ¦":"Push changes"})}):null]})}function fs(t,a){return t==="create"?"create":t==="map"&&a?`map:${a}`:"skip"}function bs({brandId:t,product:a}){const d=Number(a.id),c=Zt(t,d),i=qt(),[_,k]=o.useState(!1),[E,j]=o.useState({}),n=c.data?.venues||[];o.useEffect(()=>{if(!c.data?.venues)return;const l={};for(const h of c.data.venues)l[h.venue_brand_id]={action:h.action==="review"?"skip":h.action,venue_product_id:h.action==="review"?"":h.venue_product_id?String(h.venue_product_id):"",sync_mode:"hold"};j(l)},[c.data]);const x=o.useMemo(()=>n.filter(l=>l.action==="skip"&&l.link&&!ve(l)),[n]),N=o.useMemo(()=>n.filter(l=>l.action!=="skip"||l.status==="pending"||ve(l)),[n]).filter(l=>l.status!=="pending"),L=l=>E[l.venue_brand_id]||{action:l.action==="review"?"skip":l.action,venue_product_id:l.action==="review"?"":l.venue_product_id?String(l.venue_product_id):"",sync_mode:"hold"},S=o.useMemo(()=>ds({editableVenues:N,choices:Object.fromEntries(n.map(l=>[l.venue_brand_id,L(l)]))}),[N,E,n]),T=o.useMemo(()=>La(S.actions),[S]),y=(l,h)=>
1{if(h==="create"){j(v=>({...v,[l.venue_brand_id]:{action:"create",venue_product_id:"",sync_mode:"autoflow"}}));return}if(h.startsWith("map:")){j(v=>({...v,[l.venue_brand_id]:{action:"map",venue_product_id:h.slice(4),sync_mode:v[l.venue_brand_id]?.sync_mode||"hold"}}));return}j(v=>({...v,[l.venue_brand_id]:{action:"skip",venue_product_id:"",sync_mode:v[l.venue_brand_id]?.sync_mode||"hold"}}))},I=(l,h)=>{j(v=>({...v,[l]:{action:v[l]?.action||"map",venue_product_id:v[l]?.venue_product_id||"",sync_mode:h}}))},O=()=>{S.selections.length!==0&&k(!0)},A=()=>{if(S.selections.length===0){k(!1);return}i.mutate({brand_id:t,product_id:d,selections:S.selections},{onSuccess:()=>{k(!1),c.refetch()}})};return c.isLoading?e.jsx("p",{className:"text-sm text-gray-500",children:"Loading child brand mappingâ¦"}):n.length===0?e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"No Lightspeed child brands in this organisation yet."}):e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"For each child brand, map to an existing product, create a new one, or leave it. Linked child brands can auto-flow head office edits, stay linked without updates, or be unlinked. Price is never overwritten."}),N.length>0?e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-4 dark:border-dm-border-subtle dark:bg-dm-surface",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Choose what happens on each child brand"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:V,disabled:c.isFetching,onClick:()=>c.refetch(),children:"Find matches"}),e.jsx("button",{type:"button",className:Ge,disabled:i.isLoading,onClick:O,children:i.isLoading?"Savingâ¦":S.selections.length>0?"Save mappings":"Keep child brands as they are"})]})]}),e.jsx("div",{className:"flex flex-col gap-3",children:N.map(l=>{const h=L(l),v=gs(l.reason_codes);return e.jsxs("div",{className:"flex flex-col gap-1 border-t border-gray-100 pt-3 first:border-t-0 first:pt-0 dark:border-dm-border-subtle",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:l.venue_brand_name}),e.jsx(Ee,{compact:!0,status:gt({mapped:!ve(l)&&(l.status==="confirmed"||l.status==="created_from_ho"||!!l.link),lastPushStatus:l.link?.last_push_status,status:l.status||l.link?.status,action:l.action,deleted:ve(l),syncMode:l.link?.sync_mode})})]}),e.jsxs("select",{className:"rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200",value:fs(h.action,h.venue_product_id),onChange:u=>y(l,u.target.value),"aria-label":`Mapping for ${l.venue_brand_name}`,children:[e.jsx("option",{value:"skip",children:"Leave unmapped"}),e.jsx("option",{value:"create",children:"Create new product"}),(l.available||[]).map(u=>e.jsxs("option",{value:`map:${u.id}`,children:["Map to ",u.product_name,u.price!=null?` · ${Ve(u.price)}`:""]},u.id))]})]}),ve(l)?e.jsx("p",{className:"text-xs text-orange-800 dark:text-orange-200",children:"Deleted on this child brand. Map it again or create a new copy. Other child brands can still sync."}):v?e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:v}):null,h.action==="map"&&h.venue_product_id?e.jsxs("div",{className:"mt-2 flex max-w-xs flex-col gap-1",children:[e.jsx("select",{className:"rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200",value:h.sync_mode,"aria-label":`Link type for ${l.venue_brand_name}`,onChange:u=>I(l.venue_brand_id,u.target.value),children:ls().map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:jt(h.sync_mode).helper})]}):h.action==="create"?e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Head office edits will update this child brand. Price stays on this child brand."}):null]},l.venue_brand_id)})})]}):null,x.map(l=>
1l.link?e.jsx(hs,{brandId:t,hoProductId:d,venueBrandId:l.venue_brand_id,venueBrandName:l.venue_brand_name,link:l.link,product:a},l.venue_brand_id):null),e.jsx(Ma,{show:_,onClose:()=>k(!1),onConfirm:A,isSaving:i.isLoading,summary:T})]})}function ys({library:t,selectedIds:a,onChange:d}){const c=Re(),i=Da(),_=o.useMemo(()=>a.map(n=>t.find(x=>x.id===n)).filter(n=>!!n),[t,a]),k=t.filter(n=>!a.includes(n.id)),E=(n,x)=>{const w=[...a],N=n+x;N<0||N>=w.length||([w[n],w[N]]=[w[N],w[n]],d(w))},j=n=>{const{active:x,over:w}=n;if(!w)return;const N=Ia(a,L=>String(L),String(x.id),String(w.id));N&&d(N)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[_.length===0?e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No option sets linked yet."}):e.jsx(Ta,{sensors:i,collisionDetection:Ea,onDragEnd:j,children:e.jsx(Aa,{items:a.map(n=>String(n)),strategy:Ra,children:e.jsx("ul",{className:"flex flex-col gap-2",children:_.map((n,x)=>e.jsx(Fa,{id:String(n.id),children:({setNodeRef:w,style:N,dragHandle:L})=>e.jsxs("li",{ref:w,style:N,className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 dark:border-dm-border-subtle dark:bg-dm-elevated",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[L,e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:n.name}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[n.options?.length||0," options",n.min_selection!=null||n.max_selection!=null?` · ${n.min_selection??0}â${n.max_selection??0}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",className:Be,disabled:x===0,onClick:()=>E(x,-1),children:"Up"}),e.jsx("button",{type:"button",className:Be,disabled:x===_.length-1,onClick:()=>E(x,1),children:"Down"}),e.jsx("button",{type:"button",className:Be,onClick:()=>d(a.filter(S=>S!==n.id)),children:"Remove"})]})]})},n.id))})})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[k.length>0?e.jsxs("select",{className:"rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200",value:"",onChange:n=>{const x=Number(n.target.value);x&&d([...a,x])},children:[e.jsx("option",{value:"",children:"Add option set"}),k.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]}):null,e.jsx("button",{type:"button",className:V,onClick:()=>c("/settings/product/option-sets"),children:"Manage option sets"})]})]})}function js(t){if(!t)return!0;if(typeof t.is_sold=="boolean")return t.is_sold;const a=t.external_data?.is_sold;return a==null?!0:!!a}function st(t){const a=t?.external_data;return!a||typeof a!="object"?!1:a.id_str!=null&&String(a.id_str).trim()!==""?!0:a.id!=null&&String(a.id).trim()!==""}function rt({productId:t,isCreate:a=!1,onClose:d}){const c=Re(),[i,_]=wt(),{selectedBrand:k}=o.useContext(ot),{showSnackbar:E}=lt(),j=localStorage.getItem("selectedBrandId"),n=k.id===0?Number(j):k.id,[x,w]=o.useState([]),[N,L]=o.useState(""),[S,T]=o.useState(""),[y,I]=o.useState(""),[O,A]=o.useState(!1),[l,h]=o.useState(!0),[v,u]=o.useState([]),[b,F]=o.useState(""),[q,X]=o.useState(""),[xe,G]=o.useState(""),[z,ee]=o.useState([]),[W,pe]=o.useState(!1),he=o.useRef(null),[te,ae]=o.useState(!1),B=o.useRef(d);B.current=d;const{data:g,isLoading:fe}=ea(t||0,!a&&!!t),{data:be,isLoading:$}=ta({brand_id:n,limit:1e3,offset:0,enabled:!!n}),U=aa(),se=sa(),re=ra(),ne=na(),oe=oa(),De=la(),le=da(),K=ia(),Y=be?.data||[],Q=g?.tags||[],P=dt(k),{data:Z}=ca(n,P),{data:we}=ua(n,P),{data:de}=ga(n,t||0,P&&!a&&!!t),ye=!a&&P&&g?2:-1,ke=ma(i.get("tab"))&&ye>=0?ye:0;o.useEffect(()=>{if(Q&&Q.length>0){const r=Q.map(f=>({tag_type:f.tag_type,tag_value:f.tag_value}));w(r)}else w([])},[Q]),o.useEffect(()=>{g&&(L(g.product_name||""),T(g.description||""),I(g.price==null?"":String(g.price)),A(Ba(g)),h(js(g)),u((g.categories||[]).map(r=>Number(r.id))),F(g.reporting_groups?.[0]?.id?Number(g.reporting_groups[0].id):""))},[g]),o.useEffect(()=>{de?.option_sets&&ee(de.option_sets.map(r=>Number(r.id)))},[de]),o.useEffect(()=>{const r=f=>{he.current&&!he.current.contains(f.target)&&pe(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[]);const je=r=>x.some(f=>f.tag_type===r.tag_type&&f.tag_value===r.tag_value),Fe=r=>{const f=je(r);w(f?x.filter(C=>!(C.tag_type===r.tag_type&&C.tag_value===r.tag_value)):[...x,{tag_type:r.tag_type,tag_value:r.tag_value}])},Se=()=>{if(B.current){B.current();return}c("/settings/product")},Ie=o.useMemo(()=>
1{if(a)return{title:"New product",breadcrumbs:qe("New product",{onProductsClick:()=>{B.current?B.current():c("/settings/product")}}),isNested:!0,sectionIconLabel:"Settings"};if(!g)return null;const r=g.product_name?.trim()||"Product";return{title:r,breadcrumbs:qe(r,{onProductsClick:()=>{B.current?B.current():c("/settings/product")}}),isNested:!0,sectionIconLabel:"Settings"}},[a,g,c]);kt(a||!!g,Ie);const Ce=()=>({product_name:N.trim(),description:S,price:y.trim()===""?0:Number(y),...Oa(O),is_sold:l,category_ids:v,reporting_group_id:b===""?null:Number(b),option_set_ids:z}),ie=a||P||st(g),Pe=r=>{const f=l;h(r),!(a||!t)&&(P||st(g)&&ne.mutate({brand_id:n,product_id:t,is_sold:r},{onError:()=>h(f)}))},ce=r=>{c(ze(r))},ue=async()=>{if(a){if(!N.trim())return;ae(!0);try{const r=await oe.mutateAsync({brand_id:n,...Ce()}),f=Number(r?.id);f?ce(f):Se()}catch{}finally{ae(!1)}return}if(!(!g||!t)){ae(!0);try{P?await De.mutateAsync({brand_id:n,product_id:t,...Ce()}):S!==(g.description||"")&&await se.mutateAsync({product_id:t,description:S}),await U.mutateAsync({product_id:t,brand_id:n,tags:x}),P&&(E("Product saved. Choose what happens on each child brand.","success"),ce(t))}catch(r){console.error("Error saving product:",r),E("Failed to save product. Please try again.","error")}finally{ae(!1)}}};if(!a&&fe)return e.jsx("div",{className:"flex min-h-loader-tabs w-full flex-1 items-center justify-center",children:e.jsx(ge,{text:"Loading product"})});if(!a&&!g)return e.jsx("div",{className:St,children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg text-gray-700 dark:text-gray-300",children:"Product not found"}),e.jsx("button",{onClick:()=>c("/settings/product"),className:"mt-4 text-blue-600 hover:text-blue-800",children:"Back to Products"})]})});const M=te||ne.isLoading,J=Array.from(new Set(Y.map(r=>r.tag_type))).sort(),Le=J.reduce((r,f)=>(r[f]=Y.filter(C=>C.tag_type===f),r),{});return e.jsx("div",{className:"container mx-auto px-0 pb-2 sm:pb-4",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:gap-8",children:[e.jsxs("div",{className:`flex flex-col gap-2 ${zt}`,children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:a?"New product":"Product Details"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:P?"Name, price, categories, and option sets for this head office product. Saving opens child brand mapping.":"View product information, external integration data, and manage tags"})]}),e.jsx(Sa,{component:"product-detail",contentClassName:"py-2 lg:py-4",contentMinHeightClass:"",initialTabIndex:ke,onTabChange:r=>{const f=new URLSearchParams(i);r===ye?f.set("tab","child-brands"):f.delete("tab"),_(f,{replace:!0})},tabs:[{title:"Details",content:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Product Name"}),e.jsx("input",{type:"text",value:P||a?N:g?.product_name||"",onChange:r=>L(r.target.value),readOnly:!P&&!a,disabled:M,className:P||a?"w-full rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-sm text-gray-700 dark:bg-dm-elevated dark:text-gray-300":"w-full cursor-not-allowed rounded-lg border border-gray-300 bg-gray-50 px-3 py-2.5 text-sm text-gray-700 dark:bg-gray-700 dark:text-gray-300"})]}),g?.image_url&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Product Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("img",{src:g.image_url,alt:g.product_name,className:"h-24 w-24 rounded-lg border border-gray-300 object-cover dark:border-dm-border-subtle"}),e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Image URL: ",g.image_url]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),e.jsx("textarea",{value:S,onChange:r=>T(r.target.value),rows:6,disabled:M,className:"w-full rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-sm text-gray-700 focus:border-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-0 disabled:cursor-not-allowed disabled:bg-gray-50 dark:bg-dm-elevated dark:text-gray-300",placeholder:"Enter product description"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Price"}),P||a?e.jsx("input",{type:"number",step:"0.01",min:"0",value:y,onChange:r=>I(r.target.value),disabled:M,className:"w-full rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-sm text-gray-700 dark:bg-dm-elevated dark:text-gray-300"}):e.jsx("input",{type:"text",value:g?.price?`$${Number(g.price).toFixed(2)}`:"-",readOnly:!0,className:"w-full cursor-not-allowed rounded-lg border border-gray-300 bg-gray-50 px-3 py-2.5 text-sm text-gray-700 dark:bg-gray-700 dark:text-gray-300"})]}),(P||a)&&e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:O,onChange:r=>A(r.target.checked),disabled:M}),"Is modifier"]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"When on, Lightspeed stacks this under the parent item instead of as its own sale line."})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:r=>Pe(r.target.checked),disabled:M||!ie}),"Available to sell"]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:P?"Saved with the product. You then choose whether each child brand stays as it is or is overwritten. Price is never overwritten.":ie?"When off, this product is hidden on the POS sales screen.":"This product is not in Lightspeed yet."})]}),!a&&g?.orders!==void 0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Orders"}),e.jsx("input",{type:"text",value:g.orders?.toString()||"-",readOnly:!0,className:"w-full cursor-not-allowed rounded-lg border border-gray-300 bg-gray-50 px-3 py-2.5 text-sm text-gray-700 dark:bg-gray-700 dark:text-gray-300"})]}),!a&&g?.total_revenue!==void 0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Total Revenue"}),e.jsx("input",{type:"text",value:g.total_revenue?`$${g.total_revenue.toLocaleStr
1ing()}`:"-",readOnly:!0,className:"w-full cursor-not-allowed rounded-lg border border-gray-300 bg-gray-50 px-3 py-2.5 text-sm text-gray-700 dark:bg-gray-700 dark:text-gray-300"})]}),P||a?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Categories"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[(Z?.categories||[]).map(r=>e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:v.includes(Number(r.id)),onChange:f=>{const C=Number(r.id);u(R=>f.target.checked?[...R,C]:R.filter(Me=>Me!==C))},disabled:M}),r.name]},r.id)),(Z?.categories||[]).length===0?e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No categories yet."}):null,e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:q,placeholder:"New category",disabled:M,onChange:r=>X(r.target.value),className:"flex-1 rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200"}),e.jsx("button",{type:"button",className:V,disabled:M||!q.trim()||le.isLoading,onClick:async()=>{const r=q.trim();if(!r)return;const f=(Z?.categories||[]).find(R=>R.name.toLowerCase()===r.toLowerCase());if(f){u(R=>R.includes(Number(f.id))?R:[...R,Number(f.id)]),X("");return}const C=await le.mutateAsync({brand_id:n,name:r});C?.id&&u(R=>[...R,Number(C.id)]),X("")},children:"Add"})]})]})]}):g?.categories&&g.categories.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Categories"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:g.categories.map(r=>e.jsxs(Oe,{color:"gray",children:[r.name,r.source?` (${r.source})`:""]},r.id))})]}),P||a?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Reporting group"}),e.jsxs("select",{value:b,onChange:r=>F(r.target.value===""?"":Number(r.target.value)),disabled:M,className:"rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200",children:[e.jsx("option",{value:"",children:"None"}),(Z?.reporting_groups||[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:xe,placeholder:"New reporting group",disabled:M,onChange:r=>G(r.target.value),className:"flex-1 rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200"}),e.jsx("button",{type:"button",className:V,disabled:M||!xe.trim()||K.isLoading,onClick:async()=>{const r=xe.trim();if(!r)return;const f=(Z?.reporting_groups||[]).find(R=>R.name.toLowerCase()===r.toLowerCase());if(f){F(Number(f.id)),G("");return}const C=await K.mutateAsync({brand_id:n,name:r});C?.id&&F(Number(C.id)),G("")},children:"Add"})]})]}):g?.reporting_groups&&g.reporting_groups.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Reporting Groups"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:g.reporting_groups.map(r=>e.jsxs(Oe,{color:"gray",children:[r.name,r.source?` (${r.source})`:""]},r.id))})]}),(P||a)&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Option sets"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Drag to set the order they should appear."}),e.jsx(ys,{library:we?.option_sets||[],selectedIds:z,onChange:ee})]}),!a&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Product Tags"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Select tags to associate with this product. Tags are displayed as Tag Type & Tag Value."}),e.jsxs("div",{className:"relative",ref:he,children:[e.jsxs("button",{type:"button",onClick:()=>pe(!W),disabled:M||$,className:"flex w-full items-center justify-between rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-left text-sm text-gray-700 hover:bg-gray-50 focus:border-gray-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-dm-elevated dark:text-gray-300 dark:hover:bg-gray-700",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:e.jsx("span",{className:"truncate",children:x.length===0?"Select tags":`${x.length} tag${x.length===1?"":"s"} selected`})}),e.jsx(It,{className:`h-4 w-4 shrink-0 text-gray-500 transition-transform dark:text-gray-400 ${W?"rotate-180":""}`})]}),W&&e.jsx("div",{className:"absolute z-10 mt-1 max-h-96 w-full overflow-y-auto rounded-lg border border-gray-300 bg-white shadow-lg dark:bg-dm-elevated",children:$?e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading tags..."}):Y.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 border-b border-gray-200 px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:border-dm-border-subtle dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",children:[e.jsx("input",{type:"checkbox",checked:Y.length>0&&Y.every(r=>je(r)),onChange:r=>{if(r.target.checked){const f=Y.map(C=>({tag_type:C.tag_type,tag_value:C.tag_value}));w(f)}else w([])}
1,className:"h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500 dark:border-dm-border-subtle",disabled:M}),e.jsx("span",{className:"flex-1",children:"Select All"})]}),J.map(r=>{const f=Le[r];return e.jsxs("div",{children:[e.jsx("div",{className:"border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs font-semibold uppercase text-gray-600 dark:border-dm-border-subtle dark:bg-gray-700 dark:text-gray-400",children:r}),f.map(C=>{const R=je(C);return e.jsxs("label",{className:Ct,children:[e.jsx("input",{type:"checkbox",checked:R,onChange:()=>Fe(C),className:"h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500 dark:border-dm-border-subtle",disabled:M}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"font-medium",children:C.tag_type})," - ",e.jsx("span",{children:C.tag_value})]})]},`${C.tag_type}-${C.tag_value}`)})]},r)})]}):e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No tags available"})})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[x.length>0&&x.map((r,f)=>e.jsxs(Oe,{color:"blue",children:[r.tag_type,": ",r.tag_value]},`${r.tag_type}-${r.tag_value}-${f}`)),e.jsxs("button",{type:"button",title:x.length>0?"Regenerate tags":"Generate tags",onClick:()=>re.mutate({brand_id:n,product_id:Number(t)}),disabled:M||re.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-full border border-gray-300 bg-gray-100 text-sm font-medium text-gray-700 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-dm-border-subtle dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600 ${x.length===0?"px-3 py-2":"p-2"}`,children:[e.jsx(Bt,{className:`h-4 w-4 shrink-0 ${re.isPending?"animate-pulse":""}`}),x.length===0&&e.jsx("span",{children:re.isPending?"Generating...":"Generate tags"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-4 border-t border-gray-200 pt-6 dark:border-dm-border-subtle",children:[e.jsx("button",{type:"button",onClick:Se,className:"rounded-lg border border-gray-300 bg-white px-6 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:bg-dm-elevated dark:text-gray-300 dark:hover:bg-gray-700",disabled:M,children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>ue(),disabled:M||(P||a)&&!N.trim(),className:`${Ne} px-6 py-2.5 focus:outline-none focus:ring-2 focus:ring-black focus:ring-offset-2 dark:focus:ring-white`,children:te?"Saving...":a?"Create product":"Save Changes"})]})]})},...a?[]:[{title:"External Sources",content:e.jsx(Ca,{productId:t,brandId:n,timezone:k?.timezone||"Australia/Sydney"})}],...!a&&P&&g?[{title:"Child Brands",content:e.jsx(bs,{brandId:n,product:g})}]:[]]})]})})}const nt="rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-sm dark:border-dm-border-subtle dark:bg-dm-elevated dark:text-gray-200";function vs({brandId:t,unmatched:a}){const d=Re(),c=xa(),[i,_]=o.useState(""),[k,E]=o.useState(""),[j,n]=o.useState(""),[x,w]=o.useState(1),[N,L]=o.useState(1),{data:S}=Va({limit:1e3},{enabled:t>0,organisationScope:!0}),T=a?.unmatched_ho||[],y=a?.unmatched_venue||[],I=a?.venue_brands||[],O=o.useMemo(()=>$a(S?.data||[],[...T,...y]),[S?.data,T,y]),A={brandId:i,categoryName:k,search:j},l=o.useMemo(()=>Qe(T,A),[T,i,k,j]),h=o.useMemo(()=>Qe(y,A),[y,i,k,j]),v=Je(l,x),u=Je(h,N);return o.useEffect(()=>{w(1),L(1)},[i,k,j]),o.useEffect(()=>{x!==v.page&&w(v.page)},[x,v.page]),o.useEffect(()=>{N!==u.page&&L(u.page)},[N,u.page]),a?e.jsxs("div",{className:"flex flex-col gap-3 pt-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Not Linked to Head Office"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Products on child brands that are not linked to head office."})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsxs("select",{"aria-label":"Child brand",value:i,onChange:b=>_(b.target.value===""?"":Number(b.target.value)),className:`${nt} sm:w-56`,children:[e.jsx("option",{value:"",children:"All child brands"}),I.map(b=>e.jsx("option",{value:b.id,children:b.name},b.id))]}),e.jsxs("select",{"aria-label":"Category",value:k,onChange:b=>E(b.target.value),className:`${nt} sm:w-56`,children:[e.jsx("option",{value:"",children:"All categories"}),O.map(b=>e.jsx("option",{value:b,children:b},b))]}),e.jsx(xt,{placeholder:"Search name",value:j,onChange:b=>n(b.target.value),className:"min-w-3/5 text-sm sm:w-64",icon:ut})]}),l.length>0?e.jsxs("div",{children:[e.jsx("ul",{className:"list-disc pl-5 text-sm text-gray-700 dark:text-gray-300",children:v.items.map(b=>e.jsx("li",{children:e.jsx("button",{type:"button",className:"underline",onClick:()=>d(ze(Number(b.id))),children:b.product_name})},b.id))}),e.jsx(He,{page:v.page,total:v.total,rowCount:v.items.length,onPageChange:w})]}):null,h.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm text-gray-700 dark:text-gray-200",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 font-medium",children:"Child brand"}),e.jsx("th",{className:"px-4 py-3 font-medium",children:"Name"}),e.jsx("th",{className:"px-4 py-3 font-medium"})]})}),e.jsx("tbody",{children:u.items.map(b=>e.jsxs("tr",{className:"border-t border-gray-100 dark:border-dm-border-subtle",children:[e.jsx("td",{className:"px-4 py-3",children:b.brand_name}),e.jsx("td",{className:"px-4 py-3 font-medium",children:b.product_name}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{type:"button",className:V,disabled:c.isLoading,onClick:()=>c.mutate({brand_id:t,venue_brand_id:Number(b.brand_id),venue_product_id:Number(b.id)}),children:"Add to head office"})})]},`${b.brand_id}-${b.id}`))})]})}),e.jsx(He,{page:u.page,total:u.total,rowCount:u.items.length,onPageChange:L})]}):null,l.length===0&&h.length===0?e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"None match."}):null]}):e.jsx(ge,{text:"Loading products"})}const Ns=({handleClick:t})=>e.jsx("div",{className:`flex w-full items-center justify-center ${it}`,children:e.jsx("div",{className:"mx-auto w-full max-w-3xl bg-white p-6 dark:bg-dm-elevated",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center",children:[e.jsx("img",{src:"/static/images/placeholders/product_sample.png",alt:"Product Sample",className:"mb-4 h-36 object-cover md:h-48"}),e.jsx("h1",{className:"mb-4 text-lg font-bold text-gray-900 dark:text-white md:text-2xl",children:"Your products in one place"}),e.jsx("p",{className:"mb-4 text-center text-base font-normal text-gray-600 dark:text-gray-400 md:text-lg",children:"Browse everything you sell with optional AI-generated tags such as category, ingredients, or allergens. Connect a catalog or other data source to populate this list."}),e.jsx("button",{onClick:t,className:`${Ne} mt-4 p-4 text-lg font-semibold shadow`,children:"Connect a Data Source"})]})})}),_s=({handleClose:t,handleUpload:a})=>{const d=ct(),[c,i]=o.useState(!1),_=()=>d?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2",children:[e.jsx("button",{onClick:a,className:`${Ne} w-full px-6 py-3 text-base font-semibold shadow`,children:"Upload Menu"}),e.jsx("button",{onClick:t,className:"rounded-lg px-6 py-3 text-base font-semibold text-gray-600 transition hover:bg-gray-200 dark:text-gray-300 dark:hover:bg-dm-surface",children:"I'll do this later"})]}):e.jsxs("div",{className:"flex flex-row items-center justify-center gap-2",children:[e.jsx("button",{onClick:a,className:`${Ne} px-6 py-3 text-base font-semibold shadow`,children:"Upload Menu"}),e.jsx("button",{onClick:t,className:"rounded-lg bg-gray-200 px-6 py-3 text-base font-semibold text-gray-700 shadow transition hover:bg-gray-300 dark:bg-dm-muted dark:text-gray-200 dark:hover:bg-dm-border-subtle",children:"I'll do this later"})]});return e.jsx("div",{className:`m-auto flex items-center justify-center ${it}`,children:e.jsx("div",{className:"mx-auto w-full max-w-3xl bg-white p-6 dark:bg-dm-elevated",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center",children:[c?e.jsx("div",{className:"mb-4 flex h-36 w-full items-center justify-center rounded-lg bg-gray-100 dark:bg-dm-muted md:h-48","aria-hidden":!0,
1children:e.jsx(Ue,{className:"h-16 w-16 text-gray-400 dark:text-gray-500 md:h-20 md:w-20"})}):e.jsx("img",{src:"/static/images/placeholders/upload_menu.png",alt:"Upload Menu",className:"mb-4 h-36 object-cover md:h-48",onError:()=>i(!0)}),e.jsx("h1",{className:"mb-4 text-lg font-bold text-gray-900 dark:text-white md:text-2xl",children:"Upload Your Menu for Better Tagging"}),e.jsx("p",{className:"mb-4 text-center text-base font-normal text-gray-600 dark:text-gray-400 md:px-8",children:"We've connected your POS data. Now, uploading your full menu helps us fill in the gapsâlike product descriptions, ingredients, and context."}),_()]})})})},ws=t=>t.endsWith(".png")||t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".gif")||t.endsWith(".bmp")||t.endsWith(".webp"),ks=({uploadedFiles:t,onDelete:a})=>{const d=c=>{a(c)};return t?.length?e.jsx(e.Fragment,{children:t.map(c=>e.jsxs("div",{className:"flex w-full flex-row justify-between",children:[e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[ws(c.file_name)?e.jsx(Cs,{}):e.jsx(Ss,{}),c.file_name]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>d(c.id),children:e.jsx(Ps,{})})})]},c.file_name))}):null},Ss=()=>e.jsx("svg",{className:"h-6 w-6 text-gray-400 dark:text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{fillRule:"evenodd",d:"M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Z",clipRule:"evenodd"})}),Cs=()=>e.jsx("svg",{className:"h-6 w-6 text-gray-400 dark:text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{fillRule:"evenodd",d:"M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z",clipRule:"evenodd"})}),Ps=()=>e.jsx("svg",{className:"h-6 w-6 text-gray-500 dark:text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{fillRule:"evenodd",d:"M8.586 2.586A2 2 0 0 1 10 2h4a2 2 0 0 1 2 2v2h3a1 1 0 1 1 0 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a1 1 0 0 1 0-2h3V4a2 2 0 0 1 .586-1.414ZM10 6h4V4h-4v2Zm1 4a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Zm4 0a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Z",clipRule:"evenodd"})}),Ls=async({file:t,url:a})=>{const d=await fetch(a,{method:"PUT",body:t,headers:{"Content-Type":t.type}});if(!d.ok)throw new Error("S3 upload failed");return d},ir=()=>{const t=Pt(),a=Re(),{productId:d}=Lt(),c=o.useRef(""),{hasDataSource:i,isDataSourceResolved:_}=Mt(),{getAccessTokenSilently:k}=Tt(),{showSnackbar:E}=lt(),{selectedBrand:j}=o.useContext(ot),n=dt(j),[x,w]=o.useState(""),[N,L]=o.useState(""),[S,T]=o.useState(1),[y,I]=o.useState(null),[O,A]=o.useState(!1),[l,h]=o.useState(!1),[v,u]=o.useState(!1),{data:b,isFetching:F,isLoading:q,refetch:X}=pa({searchText:N,page:S,limit:Xe,enabled:n||!v,organisationScope:!1}),[xe,G]=o.useState(!1),[z,ee]=o.useState(null),W=ct(),pe=q&&S===1&&!N||!y,{data:he,refetch:te}=ha(j?.id),{mutateAsync:ae}=fa(),B=ba(),g=o.useMemo(()=>(y||[]).map(s=>s.id),[y]),{data:fe}=ya(j?.id,g,n&&g.length>0),{data:be}=ja(j?.id,n),$=va(),[U,se]=o.useState([]),[re,ne]=o.useState(!1),[oe,De]=o.useState("all"),le=Na(),K=o.useMemo(()=>{const s=new Map,m=fe?.venue_brand_count||0;for(const p of fe?.products||[]){const D=Number(p.ho_product_id);s.set(D,{confirmed:_a(Number(p.confirmed_venues)||0,p.deleted_venues),total:Number(p.venue_brand_count)||m,pendingPush:Ke(D,p.pending_push_venues??p.stale_venues??p.unsynced_venues),deletedVenues:Number(p.deleted_venues)||0})}return{map:s,total:m}},[fe,le]),Y=o.useMemo(()=>({title:"Products",breadcrumbs:Yt(),isNested:!0,sectionIconLabel:"Settings"}),[]),Q=o.useCallback(()=>{a("/settings/product")},[a]);o.useEffect(()=>{b&&(I(n||S===1?b:s=>{const m=new Set((s||[]).map(D=>D.id)),p=b.filter(D=>!m.has(D.id));return[...s||[],...p]}),u(b.length<Xe))},[b,S,n]),o.useEffect(()=>{j?.id&&te()},[j]),o.useEffect(()=>{if(t.pathname!=="/settings/product")return;const s=new URLSearchParams(t.search);if(!Ua(s.get("tab")))return;s.delete("tab");const m=s.toString();a({pathname:"/settings/product",search:m?`?${m}`:""},{replace:!0})},[t.pathname,t.search,a]),o.useEffect(()=>{if(y&&!F&&!q&&t.pathname==="/settings/product"){if(n){A(!1),h(!1);return}if(!_)return;if(!i){h(!1),A(!0);return}A(!1),y.length===0&&N===""?h(!0):h(!1)}},[y,y?.length,t.pathname,F,q,i,_,n,N]),o.useEffect(()=>{T(1),u(!1),X()},[N,X]);const P=()=>{F||T(s=>s+1)},Z=o.useRef(null),we=o.useRef(null),de=s=>{if(!s)return null;let m=s.parentElement;for(;m;){const H=window.getComputedStyle(m);if(H.overflowY==="auto"||H.overflowY==="scroll")break;m=m.parentElement}const p=m||null,D=new IntersectionObserver(H=>{const[_t]=H;_t.isIntersecting&&!F&&!v&&P()},{root:p,rootMargin:"100px",threshold:0});return D.observe(s),D};o.useEffect(()=>{if(n)return;const s=de(Z.current),m=de(we.current);return()=>{s?.disconnect(),m?.disconnect()}},[F,v,n]);const{mutate:ye,isLoading:ke}=Wa({mutationFn:async s=>{const m=await k(),{presigned_url:p,file_name:D}=await Dt.getPresignedUrl({payload:{file_name:Ft(s.name)},token:m});return await Ls({file:s,url:p}),await ss.uploadFile({payload:{brand_id:j.id.toString(),file_name:D},token:m})},onSuccess:()=>{te(),E("File uploaded successfully. Check back in a few minutes.","success"),ee(null),G(!1)},onError:s=>{E("Something went wrong. Please try again later.","error"),console.log("error uploading file",s)}});o.useEffect(()=>{const s=setTimeout(()=>{c.current!==x&&(L(x),c.current=x)},300);return()=>clearTimeout(s)},[x]);const je=s=>{s.target.files&&s.target.files.length>0&&ee(s.target.files[0])},Fe=()=>{a("/settings/integration",{replace:!0}),A(!1)},Se=()=>{G(!0),h(!1)},Ie=()=>{h(!1),A(!1)},Ce=async s=>{await ae({upload_id:s}),te()},ie=s=>{const m=Number(s.id),p=K.map.get(m);return{confirmed:p?.confirmed??0,total:p?.total??K.total,pendingPush:Ke(m,p?.pendingPush),deletedVenues:p?.deletedVenues??0}},Pe=s=>{const m=ie(s);return ka(m.confirmed,m.total,m.pendingPush,m.deletedVenues)},ce=o.useMemo(()=>{let s=0,m=0,p=0;for(const D of y||[]){const H=Pe(D).tone;H==="red"&&(s+=1),H==="orange"&&(m+=1),H==="green"&&(p+=1)}return{unmapped:s,push:m,synced:p}},[y,K,le]),ue=o.useMemo(()=>{const s=y||[];return!n||oe==="all"?s:s.filter(m=>wa(Pe(m),oe))},[y,n,oe,K,le]),M=s=>{a(ze(s))},J=n?8:6,Le=(s,m)=>{se(p=>m?p.includes(s)?p:[...p,s]:p.filter(D=>D!==s))},r=(y||[]).map(s=>Number(s.id)),f=r.length>0&&r.every(s=>U.includes(s)),C=()=>{!j?.id||U.length===0||$.mutate({brand_id:j.id,scope:"selected",product_ids:U},{onSuccess:()=>{se([]),a("/settings/product/map-jobs")}})},R=()=>{j?.id&&$.mutate({brand_id:j.id,scope:"all"},{onSuccess:()=>{ne(!1),a("/settings/product/map-jobs")}})},Me=s=>s.description===""||s.description===null?e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(Ot,{className:"text-gray-500 dark:text-gray-400"}),W?null:e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Missing Data"})]}):e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx($t,{className:"text-gray-500 dark:text-gray-400"}),W?null:e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Active"})]}),vt=()=>e.jsxs("div",{className:"w-full overflow-x-auto",children:[e.jsxs("table",{className:"w-full min-w-[600px] text-left text-sm text-gray-700 dark:text-gray-200",children:[e.jsx("thead",{className:"bg-transparent",children:e.jsxs("tr",{children:[n?e.jsx("th",{className:"w-10 px-3 py-4 sm:px-5",children:e.jsx("input",{type:"checkbox","aria-label":"Select all products on this page",checked:f,onChange:s=>{s.target.checked?se(m=>[...new Set([...m,...r])]):se(m=>m.filter(p=>!r.includes(p)))}})}):null,e.jsx("th",{className:"whitespace-nowrap px-5 py-4 text-left text-sm font-medium text-gray-700 dark:text-gray-200",children:"Product"}),e.jsx("th",{className:"whitespace-nowrap px-5 py-4 text-left text-sm font-medium text-gray-700 dark:text-gray-200",children:"Description"}),e.jsx("th",{className:"whitespace-nowrap px-5 py-4 text-left text-sm font-medium text-gray-700 dark:text-gray-200",children:"Price"}),n?e.jsx("th",{className:"whitespace-nowrap px-5 py-4 text-left text-sm font-medium text-gray-700 dark:text-gray-200",children:"Child brands"}):null,e.jsx("th",{className:"whitespace-nowrap px-5 py-4 text-left text-sm font-medium text-gray-700 dark:text-gray-200",children:"Orders"}),e.jsx("th",{className:"whitespace-nowrap px-5 py-4 text-left text-sm font-medium text-gray-700 dark:text-gray-200",children:"Total Revenue"}),e.jsx("th",{className:"whitespace-nowrap px-5 py-4 text-left text-sm font-medium text-gray-700 dark:text-gray-200",children:"Status"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-dm-surface",children:pe?e.jsx("tr",{children:e.jsx("td",{colSpan:J,className:"py-8",children:e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(ge,{text:"Loading products"})})})}):y.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:J,className:"py-8 text-center",children:e.jsx("p",{children:n?"No products yet.":"No products found."})})}):ue.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:J,className:"py-8 text-center text-sm text-gray-600 dark:text-gray-400",children:"No loaded products match this filter."})}):e.jsxs(e.Fragment,{children:[ue.map((s,m)=>e.jsxs("tr",{className:"cursor-pointer hover:bg-gray-50 dark:bg-gray-700",onClick:()=>a(`/settings/product/${s.id}`),children:[n?e.jsx("td",{className:"w-10 px-3 py-4 sm:px-5",onClick:p=>p.stopPropagation(),children:e.jsx("input",{type:"checkbox","aria-label":`Select ${s.product_name}`,checked:U.includes(Number(s.id)),onChange:p=>Le(Number(s.id),p.target.checked)})}):null,e.jsxs("td",{className:"flex min-w-[180px] items-center gap-2 px-3 py-4 sm:gap-3 sm:px-6",children:[e.jsx("img",{src:s.image_url||"/static/images/placeholders/product_image.png",alt:"Product",className:"h-10 w-10 flex-shrink-0 rounded bg-gray-100 object-cover dark:bg-gray-700 sm:h-12 sm:w-12"}),e.jsx("span",{className:"break-words font-medium",children:s.product_name})]}),e.jsx("td",{className:"px-3 py-4 text-gray-700 dark:text-gray-300 sm:px-6",children:e.jsx("div",{className:"break-words",children:s.description})}),e.jsx("td",{className:"whitespace-nowrap px-3 py-4 font-semibold sm:px-6",children:s.price?`$${Number(s.price).toFixed(2)}`:"-"}),n?e.jsx("td",{className:"whitespace-nowrap px-3 py-4 sm:px-6",onClick:p=>{p.stopPropagation(),M(Number(s.id))},children:e.jsx(Ee,{...ie(s)})}):null,e.jsx("td",{className:"whitespace-nowrap px-3 py-4 sm:px-6",children:s.orders??"-"}),e.jsx("td",{className:"whitespace-nowrap px-3 py-4 sm:px-6",children:s.total_revenue?`$${s.total_revenue.toLocaleStr
1ing()}`:"-"}),e.jsx("td",{className:"whitespace-nowrap px-3 py-4 sm:px-6",children:e.jsx("span",{className:"inline-flex rounded-lg bg-gray-100 p-2 text-xs font-semibold leading-5 text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:Me(s)})})]},s.id||m)),F&&y.length>0&&!n&&e.jsx("tr",{children:e.jsx("td",{colSpan:J,className:"py-4 text-center",children:e.jsx(ge,{inline:!0,text:"Loading more products"})})})]})})]}),e.jsx("div",{ref:Z,className:"h-1"})]}),Nt=()=>e.jsx("div",{className:"flex flex-col gap-2",children:pe?e.jsx("div",{className:"flex min-h-[400px] items-center justify-center py-8",children:e.jsx(ge,{text:"Loading products"})}):y.length===0?e.jsx("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:e.jsx("p",{children:n?"No products yet.":"No products found."})}):ue.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-gray-600 dark:text-gray-400",children:"No loaded products match this filter."}):e.jsxs(e.Fragment,{children:[ue.map((s,m)=>e.jsxs("div",{className:"flex cursor-pointer items-center gap-3 rounded-lg border bg-white p-3 hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700",onClick:()=>a(`/settings/product/${s.id}`),children:[n?e.jsx("input",{type:"checkbox","aria-label":`Select ${s.product_name}`,checked:U.includes(Number(s.id)),onClick:p=>p.stopPropagation(),onChange:p=>Le(Number(s.id),p.target.checked)}):null,e.jsx("img",{src:s.image_url||"/static/images/placeholders/product_image.png",alt:"Product",className:"h-14 w-14 flex-shrink-0 rounded bg-gray-100 object-cover dark:bg-gray-700"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-semibold",children:s.product_name}),n?e.jsx("div",{className:"mt-1",onClick:p=>{p.stopPropagation(),M(Number(s.id))},children:e.jsx(Ee,{compact:!0,...ie(s)})}):null,e.jsx("div",{className:"line-clamp-2 text-xs text-gray-500 dark:text-gray-400",children:s.description})]}),e.jsx("div",{children:e.jsx("span",{className:"inline-flex rounded-lg bg-gray-100 p-2 text-xs font-semibold leading-5 text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:Me(s)})})]},s.id||m)),F&&y.length>0&&!v&&!n&&e.jsx("div",{className:"py-4 text-center",children:e.jsx(ge,{inline:!0,text:"Loading more products"})}),e.jsx("div",{ref:we,className:"h-1"})]})}),We=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(xt,{placeholder:"Search",value:x,onChange:s=>w(s.target.value),className:"min-w-3/5 text-sm sm:w-64",icon:ut}),n?e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[["all",`All${y?` · ${y.length}`:""}`],["unmapped",`Not mapped · ${ce.unmapped}`],["push",`Push changes · ${ce.push}`],["synced",`Synced · ${ce.synced}`]].map(([s,m])=>e.jsx("button",{type:"button",className:oe===s?"rounded-full bg-gray-900 px-3 py-1 font-medium text-white dark:bg-white dark:text-gray-900":"rounded-full border border-gray-300 px-3 py-1 text-gray-700 dark:border-dm-border-subtle dark:text-gray-300",onClick:()=>De(s),children:m},s))}):null]}),n&&U.length>0?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 dark:border-dm-border-subtle dark:bg-dm-surface",children:[e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:[U.length," selected"]}),e.jsx("button",{type:"button",className:Ge,disabled:$.isLoading,onClick:C,children:$.isLoading?"Startingâ¦":"Map to child brands"})]}):null,W?Nt():vt(),n?e.jsx(He,{page:S,rowCount:y?.length??0,hasNext:!v,onPageChange:T,isLoading:F}):null]});return d==="new"?j&&!n?e.jsx(Et,{to:"/settings/product",replace:!0}):e.jsxs(e.Fragment,{children:[e.jsx($e,{children:e.jsx("title",{children:"New product"})}),e.jsx(rt,{isCreate:!0,onClose:Q})]}):d?e.jsxs(e.Fragment,{children:[e.jsx($e,{children:e.jsx("title",{children:"Edit Product"})}),e.jsx(rt,{productId:Number(d),onClose:Q})]}):O?e.jsx(Ns,{handleClick:Fe}):l?e.jsx(_s,{handleClose:Ie,handleUpload:Se}):e.jsxs(e.Fragment,{children:[e.jsx(Ut,{config:Y}),e.jsx($e,{children:e.jsx("title",{children:"Products"})}),e.jsx("div",{className:"container mx-auto px-0 pb-main-content-mobile sm:pb-main-content",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs(Ht,{compactOnMobile:!0,children:[e.jsxs("div",{children:[e.jsx(Vt,{hideOnMobile:!0,children:"Products"}),e.jsx("p",{className:Wt(!0),children:n?"Network catalogue. Green is synced, orange means head office changes still need confirming on child brands, red is not mapped.":"See all your products in one place, complete with generated tags, descriptions, and ingredients."})]}),e.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:n?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:V,disabled:$.isLoading,onClick:()=>ne(!0),children:"Map all"}),e.jsx("button",{type:"button",className:V,onClick:()=>a("/settings/product/map-jobs"),children:"Mapping review"}),e.jsx("button",{type:"button",className:V,disabled:B.isLoading,onClick:()=>B.mutate({brand_id:j.id}),children:B.isLoading?"Matchingâ¦":"Match child brands"})]}):e.jsxs("button",{type:"button",className:Ye,onClick:()=>G(!0),"aria-label":"Upload Menu",children:[e.jsx(Ue,{className:At,"aria-hidden":!0}),e.jsx("span",{className:W?"hidden":void 0,children:"Upload Menu"})]})})]}),n?e.jsxs(e.Fragment,{children:[e.jsx(Gt,{compactOnMobile:!0,tabs:e.jsx(Ha,{}),trailing:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:V,onClick:()=>a("/settings/product/auto-map"),children:"Auto map"}),e.jsx("button",{type:"button",className:Ye,onClick:()=>a("/settings/product/new"),children:"New product"})]})}),We(),(be?.unmatched_ho?.length||0)>0||(be?.unmatched_venue?.length||0)>0?e.jsx(vs,{brandId:j.id,unmatched:be}):null]}):We()]})}),e.jsx(Ze,{showModal:re,onClose:()=>ne(!1),title:"Map all products",buttonText:$.isLoading?"Startingâ¦":"Start matching",onButtonClick:R,buttonDisabled:$.isLoading,footerLayout:"actions",cancelButtonText:"Cancel",bodyContent:e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Match every head office product to each child brand. You will review the proposals before anything is created or over
1written."})}),e.jsx(Ze,{showModal:xe,onClose:()=>G(!1),title:"Menu upload",showFooter:!1,size:"3xl",bodyContent:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 p-4",children:[e.jsxs(Ga,{htmlFor:"dropzone-file",className:"flex h-48 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 hover:bg-gray-100 dark:bg-gray-700",onDragOver:s=>{s.preventDefault(),s.stopPropagation()},onDrop:s=>{s.preventDefault(),s.stopPropagation(),s.dataTransfer.files&&s.dataTransfer.files.length>0&&(ee(s.dataTransfer.files[0]),s.dataTransfer.clearData())},children:[e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(Ue,{className:"mb-3 h-8 w-8 text-gray-400"}),e.jsx("span",{className:"mb-1 text-base font-medium text-gray-500 dark:text-gray-400",children:"Drag files here to upload"}),e.jsx("span",{className:"text-sm text-gray-400 underline",children:"or browse for files"})]}),e.jsx(za,{id:"dropzone-file",className:"hidden",onChange:je,multiple:!1,accept:"application/pdf,image/png,image/jpeg"})]}),z&&e.jsxs("div",{className:"mt-2 w-full max-w-lg truncate text-left text-sm text-gray-700 dark:text-gray-300",children:["Selected file: ",z.name]}),e.jsx(ks,{uploadedFiles:he||[],onDelete:Ce}),e.jsx("button",{className:`${Ne} mt-4 flex items-center justify-center gap-2 px-4 py-3 text-lg font-semibold shadow disabled:cursor-not-allowed disabled:bg-gray-400`,onClick:()=>{z&&ye(z)},disabled:!z||ke,children:ke?e.jsx(Rt,{text:"Uploading..."}):"Upload Menu"})]})})]})};export{ir 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.