PageSourceSearch

https://www.thecloud.so/_next/static/chunks/0l54ugdlqyb85.js?dpl=dpl_6jNeAWAF6LfvtzbM7WqKZ4TS97P9

js thecloud.so collected 2026-09-24 14:07:31 UTC 250,186 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,62356,41676,179980,376544,929637,e=>{"use strict";var t=e.i(848280),n=e.i(34388);let r="tc:pos-quick-keys:v1",a={},i=[];function s(e){return e??"personal"}function o(e,t){return e.find(e=>e.productId===t.productId&&e.variantId===t.variantId&&0===e.modifiers.length)}function l(e,t){return Math.max(0,Math.min(e,t))}function c(e){return e.unitPriceMinor*e.quantity+(e.modifiers?e.modifiers.reduce((e,t)=>e+t.priceMinor*t.quantity,0):0)}function u(e){return e.reduce((e,t)=>e+c(t),0)}function d(e,t){return"none"===e.kind?0:"comp"===e.kind?t:"percent"===e.kind?e.bps<=0?0:l(Math.round(t*e.bps/1e4),t):l(Math.round(e.amountMinor),t)}function m(e,t){return"none"===e.kind?0:"percent"===e.kind?e.bps<=0?0:Math.max(0,Math.round(t*e.bps/1e4)):Math.max(0,Math.round(e.amountMinor))}e.s(["COMP_REASONS",0,{promo:"promo",qualityIssue:"quality_issue",staff:"staff"},"computeDiscountMinor",0,d,"computeLineTotalMinor",0,c,"computeSaleAmounts",0,function(e,t){var n;let r=t.discount??{kind:"none"},a=t.tip??{kind:"none"},i=u(e),s=d(r,i),o=l(t.rewardsRedemptionMinor??0,i-s),c=s+o,p=i-c,h=(n=t.taxRateBps)<=0||p<=0?0:Math.round(p*n/1e4),f=m(a,p);return{discountMinor:c,rewardsRedemptionMinor:o,subtotalMinor:i,taxMinor:h,tipMinor:f,totalMinor:p+h+f}},"computeSubtotalMinor",0,u,"computeTipMinor",0,m,"findPoolableLine",0,o],41676),e.i(311097);let p={amountMinor:50,display:"$0.50"},h={usd:p};function f(e,t){return e>=(h[t.trim().toLowerCase()]??p).amountMinor}e.s(["computeCashChange",0,function(e,t){return Math.max(0,t-e)},"isAboveCardMinimum",0,f],179980);let x={edit:"building",ready:"payable",keep_building:"building",closed:"building",restored:"building"};function g(e){return x[e]}e.s(["nextSaleStage",0,g,"resolveSalePrimary",0,function(e){return e.itemCount<=0||"payable"===e.stage?{kind:"none"}:e.totalMinor<=0?{kind:"complete",totalMinor:e.totalMinor}:{kind:"tender",totalMinor:e.totalMinor,canChargeCard:f(e.totalMinor,e.currency)}}],376544);let v={kind:"none"},y={kind:"none"};function j(e){return{customer:e.customer,discount:e.discount,lines:e.lines,redeemRewards:e.redeemRewards,tip:e.tip}}let{Provider:b,useSelector:S,useStoreInstance:C}=(0,t.createAppStore)({createState:(e,t,l)=>({selectedSpaceId:(0,n.safeAssertId)(l?.selectedSpaceId),setSelectedSpaceId:t=>e({saleStage:"building",selectedSpaceId:t,selectedReaderId:null,lines:[],lastSale:null,discount:v,tip:y,customer:null,redeemRewards:!1}),selectedReaderId:l?.selectedReaderId??null,setSelectedReaderId:t=>e({selectedReaderId:t}),favoriteProductIdsBySpace:function(){if("u"<typeof localStorage)return a;try{let e=localStorage.getItem(r);if(!e)return a;let t=JSON.parse(e);if("object"!=typeof t||null===t)return a;let n=Object.entries(t).flatMap(([e,t])=>Array.isArray(t)?[[e,t.filter(e=>"string"==typeof e)]]:[]);return Object.fromEntries(n)}catch{return a}}(),toggleFavorite:n=>{var a,o,l;let c,u,d=(a=t().favoriteProductIdsBySpace,o=s(t().selectedSpaceId),l=n,u=(c=a[o]??i).includes(l)?c.filter(e=>e!==l):[...c,l],{...a,[o]:u});e({favoriteProductIdsBySpace:d});if("u">typeof localStorage)try{localStorage.setItem(r,JSON.stringify(d))}catch(e){console.error("[pos] persisting quick keys failed",e)}},lines:[],lastSale:null,discount:v,tip:y,customer:null,redeemRewards:!1,saleStage:"building",hydrateCart:n=>{var r;0===(r=j(t())).lines.length&&"none"===r.discount.kind&&"none"===r.tip.kind&&null===r.customer&&e({customer:n.customer,discount:n.discount,lines:n.lines,redeemRewards:n.redeemRewards,saleStage:g("restored"),tip:n.tip})},readySale:()=>e({saleStage:g("ready")}),resumeBuilding:()=>e({saleStage:g("keep_building")}),setCustomer:n=>e({customer:n,redeemRewards:!!n&&t().redeemRewards,saleStage:g("edit")}),setRedeemRewards:t=>e({redeemRewards:t,saleStage:g("edit")}),addLine:n=>{let r=o(t().lines,n),a=g("edit");r?e({lastSale:null,saleStage:a,lines:t().lines.map(e=>e.lineId===r.lineId?{...e,quantity:e.quantity+1}:e)}):e({lastSale:null,saleStage:a,lines:[...t().lines,{...n,lineId:crypto.randomUUID(),modifiers:[],quantity:1}]})},completeSale:t=>e({lastSale:t,lines:[],discount:v,tip:y,customer:null,redeemRewards:!1,saleStage:g("closed")}),setQuantity:(n,r)=>{let a=g("edit");r<=0?e({saleStage:a,lines:t().lines.filter(e=>e.lineId!==n)}):e({saleStage:a,lines:t().lines.map(e=>e.lineId===n?{...e,quantity:r}:e)})},setLineModifiers:(n,r)=>e({saleStage:g("edit"),lines:t().lines.map(e=>e.lineId===n?{...e,modifiers:r}:e)}),removeLine:n=>e({saleStage:g("edit"),lines:t().lines.filter(e=>e.lineId!==n)}),setDiscount:t=>e({discount:t,saleStage:g("edit")}),setTip:t=>e({tip:t,saleStage:g("edit")}),clearCart:()=>e({lines:[],discount:v,tip:y,customer:null,redeemRewards:!1,saleStage:g("closed")})}),getSerializableState:e=>({selectedSpaceId:e.selectedSpaceId,selectedReaderId:e.selectedReaderId}),hydrateFromSerializable:e=>e?{selectedSpaceId:(0,n.safeAssertId)(e.selectedSpaceId),selectedReaderId:e.selectedReaderId??null}:{}});function M(e){return e.selectedSpaceId}function w(e){return e.setSelectedSpaceId}function k(e){return e.selectedReaderId}function N(e){return e.setSelectedReaderId}function _(e){return e.lines}function I(e){return e.saleStage}function T(e){return e.readySale}function P(e){return e.resumeBuilding}function R(e){return e.lastSale}function D(e){return e.completeSale}function L(e){return e.addLine}function A(e){return e.setQuantity}function O(e){return e.setLineModifiers}function E(e){return e.clearCart}function B(e){return e.discount}function $(e){return e.setDiscount}function z(e){return e.tip}function F(e){return e.setTip}function q(e){return e.customer}function V(e){return e.setCustomer}function U(e){return e.redeemRewards}function H(e){return e.setRedeemRewards}function G(e){return e.toggleFavorite}function Q(e){return e.favoriteProductIdsBySpace[s(e.selectedSpaceId)]??i}e.s(["PosProvider",0,b,"posCartDraftOf",0,j,"useAddLine",0,()=>S(L),"useCartLines",0,()=>S(_),"useClearCart",0,()=>S(E),"useCompleteSale",0,()=>S(D),"useCustomer",0,()=>S(q),"useDiscount",0,()=>S(B),"useFavoriteProductIds",0,()=>S(Q),"useLastSale",0,()=>S(R),"usePosStore",0,C,"useReadySale",0,()=>S(T),"useRedeemRewards",0,()=>S(U),"useResumeBuilding",0,()=>S(P),"useSaleStage",0,()=>S(I),"useSelectedReaderId",0,()=>S(k),"useSelectedSpaceId",0,()=>S(M),"useSetCustomer",0,()=>S(V),"useSetDiscount",0,()=>S($),"useSetLineModifiers",0,()=>S(O),"useSetQuantity",0,()=>S(A),"useSetRedeemRewards",0,()=>S(H),"useSetSelectedReaderId",0,()=>S(N),"useSetSelectedSpaceId",0,()=>S(w),"useSetTip",0,()=>S(F),"useTip",0,()=>S(z),"useToggleFavorite",0,()=>S(G)],62356);var W=e.i(991543);e.s(["ReceiptText",()=>W.default],929637)},44007,e=>{"use strict";var t=e.i(931718),n=e.i(729386),r=e.i(235893),a=e.i(439779),i=e.i(485954),s=e.i(913939),o=e.i(910237),l=e.i(868280);let c=/^(?:[01]\d|2[0-3]):[0-5]\d$/,u=/^\d{4}-\d{2}-\d{2}$/,d=/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d$/,m=/^[1-9]\d*$/,p=/^\d+$/;function h(){return{id:crypto.randomUUID(),startTime:"09:00",endTime:"17:00",capacity:""}}let f=l.z.object({id:l.z.string(),startTime:l.z.string().regex(c,"Choose a valid start time."),endTime:l.z.string().regex(/^(?:(?:[01]\d|2[0-3]):[0-5]\d|24:00)$/,"Choose a valid end time."),capacity:l.z.string().refine(e=>""===e||m.test(e),"Capacity must be a positive whole number.")}).refine(e=>b(e.startTime)<b(e.endTime),"Pickup window end must be after its start."),x=l.z.object({weekday:l.z.number().int().min(0).max(6),isOpen:l.z.boolean(),slots:l.z.array(f),orderCutoffMinutes:l.z.string().refine(e=>""===e||p.test(e),"Order cutoff must be a non-negative whole number of minutes.")}),g=l.z.object({id:l.z.string(),date:l.z.string().regex(u,"Choose an exception date."),closed:l.z.boolean(),note:l.z.string(),useCustomSlots:l.z.boolean(),slots:l.z.array(f)}),v=l.z.object({weeklyAvailability:l.z.array(x).length(7),exceptionDates:l.z.array(g),orderingClosedUntil:l.z.string().refine(e=>""===e||d.test(e),"Choose a valid pause-until date and time."),pickupStartsAt
1:l.z.string().refine(e=>""===e||c.test(e),"Choose a valid first pickup time.")}).superRefine((e,t)=>{for(let n of e.weeklyAvailability)n.isOpen&&0===n.slots.length&&t.addIssue({code:"custom",message:"Every open weekday needs at least one pickup window."});let n=new Set;for(let r of e.exceptionDates)n.has(r.date)&&t.addIssue({code:"custom",message:"Each exception date can appear only once."}),n.add(r.date),!r.closed&&r.useCustomSlots&&0===r.slots.length&&t.addIssue({code:"custom",message:"Custom exception hours need at least one pickup window."})});function y(e){return String(e).padStart(2,"0")}function j(e){return`${y(Math.floor(e/60))}:${y(e%60)}`}function b(e){let[t=0,n=0]=e.split(":").map(Number);return 60*t+n}function S(e,t){return{id:t,startTime:j(e.startMinute),endTime:j(e.endMinute),capacity:void 0===e.capacity?"":String(e.capacity)}}function C(e){let t={startMinute:b(e.startTime),endMinute:b(e.endTime)};return""===e.capacity?t:{...t,capacity:Number(e.capacity)}}function M(e){let t={date:e.date,closed:e.closed},n=""===e.note.trim()?t:{...t,note:e.note.trim()};return!e.closed&&e.useCustomSlots?{...n,slots:e.slots.map(C)}:n}var w=e.i(699597),k=e.i(21079),N=e.i(433992),_=e.i(708737),I=e.i(781243),T=e.i(501932),P=e.i(76075),R=e.i(459333),D=e.i(768125);function L(e){return String(e).padStart(2,"0")}let A=Array.from({length:97},(e,t)=>{let n=15*t;return{value:`${L(Math.floor(n/60))}:${L(n%60)}`,label:function(e){if(1440===e)return"Midnight (end of day)";let t=Math.floor(e/60);return`${t%12||12}:${L(e%60)} ${t<12?"AM":"PM"}`}(n)}});function O(e){let r,a,i,s,o,l,c,u,d,m,p,h,f=(0,n.c)(32),{field:x,endOfDay:g,onChange:v}=e;if(f[0]!==g||f[1]!==x.label||f[2]!==x.value||f[3]!==v){let e=g?A:A.slice(0,-1),n=e.some(e=>e.value===x.value)?e:[{value:x.value,label:x.value},...e];u="flex min-w-0 flex-col gap-1",f[13]!==x.label?(d=(0,t.jsx)(N.Label,{children:x.label}),f[13]=x.label,f[14]=d):d=f[14],a=_.Select,s=n,f[15]!==v?(o=e=>e&&v(e),f[15]=v,f[16]=o):o=f[16],l=x.value,f[17]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(_.SelectTrigger,{className:"w-full",children:(0,t.jsx)(_.SelectValue,{})}),f[17]=c):c=f[17],r=_.SelectContent,i=n.map(E),f[0]=g,f[1]=x.label,f[2]=x.value,f[3]=v,f[4]=r,f[5]=a,f[6]=i,f[7]=s,f[8]=o,f[9]=l,f[10]=c,f[11]=u,f[12]=d}else r=f[4],a=f[5],i=f[6],s=f[7],o=f[8],l=f[9],c=f[10],u=f[11],d=f[12];return f[18]!==r||f[19]!==i?(m=(0,t.jsx)(r,{children:i}),f[18]=r,f[19]=i,f[20]=m):m=f[20],f[21]!==a||f[22]!==s||f[23]!==o||f[24]!==l||f[25]!==c||f[26]!==m?(p=(0,t.jsxs)(a,{items:s,onValueChange:o,value:l,children:[c,m]}),f[21]=a,f[22]=s,f[23]=o,f[24]=l,f[25]=c,f[26]=m,f[27]=p):p=f[27],f[28]!==u||f[29]!==d||f[30]!==p?(h=(0,t.jsxs)("div",{className:u,children:[d,p]}),f[28]=u,f[29]=d,f[30]=p,f[31]=h):h=f[31],h}function E(e){return(0,t.jsx)(_.SelectItem,{value:e.value,children:e.label},e.value)}function B(e){let a,i,s,o,l,c,u,d,m,p,h,f,x=(0,n.c)(31),{slot:g,onChange:v,onRemove:y}=e;return x[0]!==g.startTime?(a={label:"From",value:g.startTime},x[0]=g.startTime,x[1]=a):a=x[1],x[2]!==v||x[3]!==g?(i=e=>v({...g,startTime:e}),x[2]=v,x[3]=g,x[4]=i):i=x[4],x[5]!==a||x[6]!==i?(s=(0,t.jsx)(O,{endOfDay:!1,field:a,onChange:i}),x[5]=a,x[6]=i,x[7]=s):s=x[7],x[8]!==g.endTime?(o={label:"To",value:g.endTime},x[8]=g.endTime,x[9]=o):o=x[9],x[10]!==v||x[11]!==g?(l=e=>v({...g,endTime:e}),x[10]=v,x[11]=g,x[12]=l):l=x[12],x[13]!==o||x[14]!==l?(c=(0,t.jsx)(O,{endOfDay:!0,field:o,onChange:l}),x[13]=o,x[14]=l,x[15]=c):c=x[15],x[16]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(N.Label,{children:"Capacity"}),x[16]=u):u=x[16],x[17]!==v||x[18]!==g?(d=e=>v({...g,capacity:e.target.value}),x[17]=v,x[18]=g,x[19]=d):d=x[19],x[20]!==g.capacity||x[21]!==d?(m=(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[u,(0,t.jsx)(k.Input,{min:1,onChange:d,placeholder:"No limit",step:1,type:"number",value:g.capacity})]}),x[20]=g.capacity,x[21]=d,x[22]=m):m=x[22],x[23]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(D.Trash2,{}),x[23]=p):p=x[23],x[24]!==y?(h=(0,t.jsx)(r.Button,{"aria-label":"Remove pickup window",onClick:y,size:"icon-sm",type:"button",variant:"ghost",children:p}),x[24]=y,x[25]=h):h=x[25],x[26]!==h||x[27]!==s||x[28]!==c||x[29]!==m?(f=(0,t.jsxs)("div",{className:"grid grid-cols-2 items-end gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_6rem_auto]",children:[s,c,m,h]}),x[26]=h,x[27]=s,x[28]=c,x[29]=m,x[30]=f):f=x[30],f}function $(e){let a,i,s,o,l,c,u=(0,n.c)(17),{slots:d,addLabel:m,onChange:p}=e;u[0]!==p||u[1]!==d?(a=e=>p(d.map(t=>
1t.id===e.id?e:t)),u[0]=p,u[1]=d,u[2]=a):a=u[2];let f=a;return u[3]!==p||u[4]!==d||u[5]!==f?(i=d.map(e=>(0,t.jsx)(B,{onChange:f,onRemove:()=>p(d.filter(t=>t.id!==e.id)),slot:e},e.id)),u[3]=p,u[4]=d,u[5]=f,u[6]=i):i=u[6],u[7]!==p||u[8]!==d?(s=()=>p([...d,h()]),u[7]=p,u[8]=d,u[9]=s):s=u[9],u[10]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(R.Plus,{}),u[10]=o):o=u[10],u[11]!==m||u[12]!==s?(l=(0,t.jsxs)(r.Button,{onClick:s,size:"sm",type:"button",variant:"ghost",children:[o,m]}),u[11]=m,u[12]=s,u[13]=l):l=u[13],u[14]!==i||u[15]!==l?(c=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[i,l]}),u[14]=i,u[15]=l,u[16]=c):c=u[16],c}let z=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function F(e){let r,a,i,s,o,l,c,u,d=(0,n.c)(22),{day:m,onChange:p}=e;d[0]!==m||d[1]!==p?(r=e=>p({...m,isOpen:e,slots:e&&0===m.slots.length?[h()]:m.slots}),d[0]=m,d[1]=p,d[2]=r):r=d[2];let f=r,x=z[m.weekday];d[3]!==x?(a=(0,t.jsx)(w.Text,{variant:"labelBold",children:x}),d[3]=x,d[4]=a):a=d[4];let g=m.isOpen?"Open":"Closed";return d[5]!==g?(i=(0,t.jsx)(w.Muted,{children:g}),d[5]=g,d[6]=i):i=d[6],d[7]!==m.isOpen||d[8]!==f?(s=(0,t.jsx)(I.Switch,{checked:m.isOpen,onCheckedChange:f}),d[7]=m.isOpen,d[8]=f,d[9]=s):s=d[9],d[10]!==i||d[11]!==s?(o=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,s]}),d[10]=i,d[11]=s,d[12]=o):o=d[12],d[13]!==a||d[14]!==o?(l=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a,o]}),d[13]=a,d[14]=o,d[15]=l):l=d[15],d[16]!==m||d[17]!==p?(c=m.isOpen?(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsx)($,{addLabel:"Add pickup window",onChange:e=>p({...m,slots:e}),slots:m.slots}),(0,t.jsx)(q,{day:m,onChange:p})]}):null,d[16]=m,d[17]=p,d[18]=c):c=d[18],d[19]!==l||d[20]!==c?(u=(0,t.jsx)(P.Card,{children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 p-3",children:[l,c]})}),d[19]=l,d[20]=c,d[21]=u):u=d[21],u}function q(e){let r,a,i,s=(0,n.c)(7),{day:o,onChange:l}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(N.Label,{children:"Order cutoff in minutes"}),s[0]=r):r=s[0],s[1]!==o||s[2]!==l?(a=e=>l({...o,orderCutoffMinutes:e.target.value}),s[1]=o,s[2]=l,s[3]=a):a=s[3],s[4]!==o.orderCutoffMinutes||s[5]!==a?(i=(0,t.jsxs)("div",{className:"flex max-w-xs flex-col gap-1",children:[r,(0,t.jsx)(k.Input,{min:0,onChange:a,placeholder:"No additional cutoff",step:1,type:"number",value:o.orderCutoffMinutes})]}),s[4]=o.orderCutoffMinutes,s[5]=a,s[6]=i):i=s[6],i}function V(e){let r,a,i,s,o,l=(0,n.c)(13),{exception:c,onChange:u}=e;return c.closed?null:(l[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(N.Label,{children:"Special pickup hours"}),(0,t.jsx)(w.Muted,{children:"Off uses the regular weekday hours."})]}),l[0]=r):r=l[0],l[1]!==c||l[2]!==u?(a=e=>u({...c,useCustomSlots:e,slots:e&&0===c.slots.length?[h()]:c.slots}),l[1]=c,l[2]=u,l[3]=a):a=l[3],l[4]!==c.useCustomSlots||l[5]!==a?(i=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[r,(0,t.jsx)(I.Switch,{checked:c.useCustomSlots,onCheckedChange:a})]}),l[4]=c.useCustomSlots,l[5]=a,l[6]=i):i=l[6],l[7]!==c||l[8]!==u?(s=c.useCustomSlots?(0,t.jsx)($,{addLabel:"Add special pickup window",onChange:e=>u({...c,slots:e}),slots:c.slots}):null,l[7]=c,l[8]=u,l[9]=s):s=l[9],l[10]!==i||l[11]!==s?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[i,s]}),l[10]=i,l[11]=s,l[12]=o):o=l[12],o)}function U(e){let a,i,s,o,l,c,u=(0,n.c)(13),{exception:d,onChange:m,onRemove:p}=e;return u[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(N.Label,{children:"Date"}),u[0]=a):a=u[0],u[1]!==d||u[2]!==m?(i=e=>m({...d,date:e.target.value}),u[1]=d,u[2]=m,u[3]=i):i=u[3],u[4]!==d.date||u[5]!==i?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[a,(0,t.jsx)(k.Input,{onChange:i,type:"date",value:d.date})]}),u[4]=d.date,u[5]=i,u[6]=s):s=u[6],u[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(D.Trash2,{}),u[7]=o):o=u[7],u[8]!==p?(l=(0,t.jsx)(r.Button,{"aria-label":"Remove exception date",onClick:p,size:"icon-sm",type:"button",variant:"ghost",children:o}),u[8]=p,u[9]=l):l=u[9],u[10]!==s||u[11]!==l?(c=(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-2",children:[s,l]}
1),u[10]=s,u[11]=l,u[12]=c):c=u[12],c}function H(e){let r,a,i,s,o,l,c,u,d,m=(0,n.c)(26),{exception:p,onChange:h,onRemove:f}=e;return m[0]!==p||m[1]!==h||m[2]!==f?(r=(0,t.jsx)(U,{exception:p,onChange:h,onRemove:f}),m[0]=p,m[1]=h,m[2]=f,m[3]=r):r=m[3],m[4]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(N.Label,{children:"Closed all day"}),m[4]=a):a=m[4],m[5]!==p||m[6]!==h?(i=e=>h({...p,closed:e}),m[5]=p,m[6]=h,m[7]=i):i=m[7],m[8]!==p.closed||m[9]!==i?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a,(0,t.jsx)(I.Switch,{checked:p.closed,onCheckedChange:i})]}),m[8]=p.closed,m[9]=i,m[10]=s):s=m[10],m[11]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(N.Label,{children:"Note"}),m[11]=o):o=m[11],m[12]!==p||m[13]!==h?(l=e=>h({...p,note:e.target.value}),m[12]=p,m[13]=h,m[14]=l):l=m[14],m[15]!==p.note||m[16]!==l?(c=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[o,(0,t.jsx)(k.Input,{onChange:l,placeholder:"Holiday, event, or reason",value:p.note})]}),m[15]=p.note,m[16]=l,m[17]=c):c=m[17],m[18]!==p||m[19]!==h?(u=(0,t.jsx)(V,{exception:p,onChange:h}),m[18]=p,m[19]=h,m[20]=u):u=m[20],m[21]!==r||m[22]!==s||m[23]!==c||m[24]!==u?(d=(0,t.jsx)(P.Card,{children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 p-3",children:[r,s,c,u]})}),m[21]=r,m[22]=s,m[23]=c,m[24]=u,m[25]=d):d=m[25],d}function G(e){let r,a,i,s=(0,n.c)(6),{onChange:o,weekly:l}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(w.Text,{variant:"labelBold",children:"Weekly pickup hours"}),(0,t.jsx)(w.Muted,{children:"Set each pickup window and its optional order cutoff."})]}),s[0]=r):r=s[0],s[1]!==o||s[2]!==l?(a=l.map(e=>(0,t.jsx)(F,{day:e,onChange:e=>o(l.map(t=>t.weekday===e.weekday?e:t))},e.weekday)),s[1]=o,s[2]=l,s[3]=a):a=s[3],s[4]!==a?(i=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[r,a]}),s[4]=a,s[5]=i):i=s[5],i}function Q(e){let a,i,s,o,l,c,u=(0,n.c)(13),{exceptions:d,onChange:m}=e;return u[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(w.Text,{variant:"labelBold",children:"Exception dates"}),(0,t.jsx)(w.Muted,{children:"Close a date or replace its regular pickup hours."})]}),u[0]=a):a=u[0],u[1]!==d||u[2]!==m?(i=d.map(e=>(0,t.jsx)(H,{exception:e,onChange:e=>m(d.map(t=>t.id===e.id?e:t)),onRemove:()=>m(d.filter(t=>t.id!==e.id))},e.id)),u[1]=d,u[2]=m,u[3]=i):i=u[3],u[4]!==d||u[5]!==m?(s=()=>m([...d,{id:crypto.randomUUID(),date:"",closed:!0,note:"",useCustomSlots:!1,slots:[]}]),u[4]=d,u[5]=m,u[6]=s):s=u[6],u[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(R.Plus,{}),u[7]=o):o=u[7],u[8]!==s?(l=(0,t.jsxs)(r.Button,{onClick:s,size:"sm",type:"button",variant:"ghost",children:[o,"Add exception date"]}),u[8]=s,u[9]=l):l=u[9],u[10]!==i||u[11]!==l?(c=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[a,i,l]}),u[10]=i,u[11]=l,u[12]=c):c=u[12],c}function W(e){let r,a,i,s,o,l,c,u,d,m,p,h,f,x,g,v,y=(0,n.c)(42),{value:j,timezone:b,onChange:S}=e;if(y[0]!==S||y[1]!==j?(r=e=>S({...j,weeklyAvailability:e}),y[0]=S,y[1]=j,y[2]=r):r=y[2],y[3]!==r||y[4]!==j.weeklyAvailability?(a=(0,t.jsx)(G,{onChange:r,weekly:j.weeklyAvailability}),y[3]=r,y[4]=j.weeklyAvailability,y[5]=a):a=y[5],y[6]!==S||y[7]!==j?(i=e=>S({...j,exceptionDates:e}),y[6]=S,y[7]=j,y[8]=i):i=y[8],y[9]!==i||y[10]!==j.exceptionDates?(s=(0,t.jsx)(Q,{exceptions:j.exceptionDates,onChange:i}),y[9]=i,y[10]=j.exceptionDates,y[11]=s):s=y[11],y[12]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(N.Label,{children:"First pickup time"}),y[12]=o):o=y[12],y[13]!==S||y[14]!==j?(l=e=>S({...j,pickupStartsAt:e.target.value}),y[13]=S,y[14]=j,y[15]=l):l=y[15],y[16]!==l||y[17]!==j.pickupStartsAt?(c=(0,t.jsx)(k.Input,{onChange:l,type:"time",value:j.pickupStartsAt}),y[16]=l,y[17]=j.pickupStartsAt,y[18]=c):c=y[18],y[19]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(w.Muted,{children:"The earliest time customers can choose, even if you open sooner. Leave blank to offer every window above."}),y[19]=u):u=y[19],y[20]!==c?(d=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[o,c,u]}),y[20]=c,y[21]=d):d=y[21],y[22]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(N.Label,{children:"Pause pickup ordering until"}),y[22]=m):m=y[22],y[23]!==S||y[24]!==j?(p=e=>S({...j,orderingClosedUntil:e.target.value}),y[23]=S,y[24]=j,y[25]=p):p=y[25],y[26]!==p||y[27]!==j.orderingClosedUntil?(h=(0,t.jsx)(k.Input,{onChange:p,type:"datetime-local",value:j.orderingClosedUntil}),y[26]=p,y[27]=j.orderingClosedUntil,y[28]=h):h=y[28],y[29]!==b){let e;y[31]===Symbol.for("react.memo_cache_sentinel")?(e=/_/g,y[31]=e):e=y[31],f=b.replace(e," "),y[29]=b,y[30]=f}else f=y[30];return y[32]!==f?(x=(0,t.jsxs)(w.Muted,{children:["Uses ",f,". Leave blank to stay open."]}),y[32]=f,y[33]=x):x=y[33],y[34]!==h||y[35]!==x?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[m,h,x]}),y[34]=h,y[35]=x,y[36]=g):g=y[36],y[37]!==g||y[38]!==a||y[39]!==s||y[40]!==d?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-5",children:[a,s,d,g]}),y[37]=g,y[38]=a,y[39]=s,y[40]=d,y[41]=v):v=y[41],v}function X(e){let r,a,i,s,o,l=(0,n.c)(16),{field:c,id:u,onChange:d}=e;l[0]!==c.label||l[1]!==u?(r=u??c.label.toLowerCase().replace(/\s+/g,"-"),l[0]=c.label,l[1]=u,l[2]=r):r=l[2];let m=r;return l[3]!==c.label||l[4]!==m?(a=(0,t.jsx)(N.Label,{htmlFor:m,children:c.label}),l[3]=c.label,l[4]=m,l[5]=a):a=l[5],l[6]!==d?(i=e=>d(e.target.value),l[6]=d,l[7]=i):i=l[7],l[8]!==c.placeholder||l[9]!==c.value||l[10]!==m||l[11]!==i?(s=(0,t.jsx)(k.Input,{id:m,onChange:i,placeholder:c.placeholder,value:c.value}),l[8]=c.placeholder,l[9]=c.value,l[10]=m,l[11]=i,l[12]=s):s=l[12],l[13]!==a||l[14]!==s?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[a,s]}),l[13]=a,l[14]=s,l[15]=o):o=l[15],o}function K(e){let r,a,i,s,o,l,c,u,d,m,p,h,f=(0,n.c)(29),{onChange:x,timezone:g}=e;if(f[0]!==x||f[1]!==g){let e=(0,T.getTimezoneOptions)(),n=(e.includes(g)?e:[g,...e]).map(J);u="flex flex-col gap-1.5",f[11]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(N.Label,{children:"Timezone"}),f[11]=d):d=f[11],a=_.Select,s=n,f[12]!==x?(o=e=>e&&x(e),f[12]=x,f[13]=o):o=f[13],l=g,f[14]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(_.SelectTrigger,{className:"w-full",children:(0,t.jsx)(_.SelectValue,{placeholder:"Choose a timezone"})}),f[14]=c):c=f[14],r=_.SelectContent,i=n.map(Z),f[0]=x,f[1]=g,f[2]=r,f[3]=a,f[4]=i,f[5]=s,f[6]=o,f[7]=l,f[8]=c,f[9]=u,f[10]=d}else r=f[2],a=f[3],i=f[4],s=f[5],o=f[6],l=f[7],c=f[8],u=f[9],d=f[10];return f[15]!==r||f[16]!==i?(m=(0,t.jsx)(r,{children:i}),f[15]=r,f[16]=i,f[17]=m):m=f[17],f[18]!==a||f[19]!==s||f[20]!==o||f[21]!==l||f[22]!==c||f[23]!==m?(p=(0,t.jsxs)(a,{items:s,onValueChange:o,value:l,children:[c,m]}),f[18]=a,f[19]=s,f[20]=o,f[21]=l,f[22]=c,f[23]=m,f[24]=p):p=f[24],f[25]!==u||f[26]!==d||f[27]!==p?(h=(0,t.jsxs)("div",{className:u,children:[d,p]}),f[25]=u,f[26]=d,f[27]=p,f[28]=h):h=f[28],h}function Z(e){return(0,t.jsx)(_.SelectItem,{value:e.value,children:e.label},e.value)}function J(e){return{label:e.replace(/_/g," "),value:e}}
1function Y(e){let r,a,i,s,o,l,c=(0,n.c)(15),{draft:u,onChange:d}=e;return c[0]!==u.name?(r={label:"Name",placeholder:"Main Street store",value:u.name},c[0]=u.name,c[1]=r):r=c[1],c[2]!==d?(a=e=>d("name",e),c[2]=d,c[3]=a):a=c[3],c[4]!==r||c[5]!==a?(i=(0,t.jsx)(X,{field:r,onChange:a}),c[4]=r,c[5]=a,c[6]=i):i=c[6],c[7]!==d?(s=e=>d("timezone",e),c[7]=d,c[8]=s):s=c[8],c[9]!==u.timezone||c[10]!==s?(o=(0,t.jsx)(K,{onChange:s,timezone:u.timezone}),c[9]=u.timezone,c[10]=s,c[11]=o):o=c[11],c[12]!==i||c[13]!==o?(l=(0,t.jsxs)(t.Fragment,{children:[i,o]}),c[12]=i,c[13]=o,c[14]=l):l=c[14],l}let ee=[{key:"city",label:"City",placeholder:"Springfield"},{key:"region",label:"State / region",placeholder:"IL"},{key:"postalCode",label:"Postal code",placeholder:"62704"},{key:"country",label:"Country",placeholder:"US"}];function et(e){let r,a,i,s,o,l,c,u,d,m,p,h,f,x=(0,n.c)(32),{draft:g,onChange:v}=e;return x[0]!==g.addressLine1?(r={label:"Address",placeholder:"123 Main St",value:g.addressLine1},x[0]=g.addressLine1,x[1]=r):r=x[1],x[2]!==v?(a=e=>v("addressLine1",e),x[2]=v,x[3]=a):a=x[3],x[4]!==r||x[5]!==a?(i=(0,t.jsx)(X,{field:r,onChange:a}),x[4]=r,x[5]=a,x[6]=i):i=x[6],x[7]!==g.addressLine2?(s={label:"Address line 2",placeholder:"Suite 4",value:g.addressLine2},x[7]=g.addressLine2,x[8]=s):s=x[8],x[9]!==v?(o=e=>v("addressLine2",e),x[9]=v,x[10]=o):o=x[10],x[11]!==s||x[12]!==o?(l=(0,t.jsx)(X,{field:s,onChange:o}),x[11]=s,x[12]=o,x[13]=l):l=x[13],x[14]!==g.googlePlaceId?(c={label:"Google Place ID",placeholder:"ChIJ...",value:g.googlePlaceId},x[14]=g.googlePlaceId,x[15]=c):c=x[15],x[16]!==v?(u=e=>v("googlePlaceId",e),x[16]=v,x[17]=u):u=x[17],x[18]!==c||x[19]!==u?(d=(0,t.jsx)(X,{field:c,id:"location-google-place-id",onChange:u}),x[18]=c,x[19]=u,x[20]=d):d=x[20],x[21]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsxs)(w.Muted,{children:["Google review link: search.google.com/local/writereview?placeid=YOUR_PLACE_ID"," ",(0,t.jsx)(w.Text,{as:"a",href:"https://developers.google.com/maps/documentation/javascript/place-id",rel:"noreferrer",target:"_blank",variant:"link",children:"How to find your Place ID"})]}),x[21]=m):m=x[21],x[22]!==g||x[23]!==v?(p=ee.map(e=>(0,t.jsx)(X,{field:{...e,value:g[e.key]},onChange:t=>v(e.key,t)},e.key)),x[22]=g,x[23]=v,x[24]=p):p=x[24],x[25]!==p?(h=(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3",children:p}),x[25]=p,x[26]=h):h=x[26],x[27]!==h||x[28]!==i||x[29]!==l||x[30]!==d?(f=(0,t.jsxs)(t.Fragment,{children:[i,l,d,m,h]}),x[27]=h,x[28]=i,x[29]=l,x[30]=d,x[31]=f):f=x[31],f}let en=[{hint:"Customers collect orders here. The register sells from pickup locations.",ke
1y:"pickup",label:"Pickup"},{hint:"This location delivers orders locally.",key:"delivery",label:"Delivery"},{hint:"This location ships orders.",key:"shipping",label:"Shipping"}];function er({draft:e,onChange:n}){return en.map(r=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(N.Label,{children:r.label}),(0,t.jsx)(w.Muted,{children:r.hint})]}),(0,t.jsx)(I.Switch,{checked:e[r.key],onCheckedChange:e=>n(r.key,e)})]},r.key))}function ea(e){let r,i,s,o,l,c,u=(0,n.c)(16),{draft:d,onChange:m}=e;return u[0]!==d||u[1]!==m?(r=(0,t.jsx)(Y,{draft:d,onChange:m}),i=(0,t.jsx)(et,{draft:d,onChange:m}),s=(0,t.jsx)(er,{draft:d,onChange:m}),u[0]=d,u[1]=m,u[2]=r,u[3]=i,u[4]=s):(r=u[2],i=u[3],s=u[4]),u[5]!==m?(o=e=>m("availability",e),u[5]=m,u[6]=o):o=u[6],u[7]!==d.availability||u[8]!==d.timezone||u[9]!==o?(l=(0,t.jsx)(W,{onChange:o,timezone:d.timezone,value:d.availability}),u[7]=d.availability,u[8]=d.timezone,u[9]=o,u[10]=l):l=u[10],u[11]!==r||u[12]!==i||u[13]!==s||u[14]!==l?(c=(0,t.jsxs)(a.DialogBody,{className:"-mx-4 gap-4 px-4 py-1",children:[r,i,s,l]}),u[11]=r,u[12]=i,u[13]=s,u[14]=l,u[15]=c):c=u[15],c}async function ei({actions:e,draft:t,location:n,setSaving:r}){let a=function(e){if(0===e.name.trim().length)return"Give the location a name.";let t=e.country.trim();return t.length>0&&2!==t.length?"Country must be a 2-letter code (like US or DE).":null}(t);if(a)return void s.toast.error(a);let i=function(e,t){var n,r;let a=v.safeParse(e);if(!a.success)return{ok:!1,error:a.error.issues[0]?.message??"Check pickup availability."};let i={weeklyAvailability:a.data.weeklyAvailability.map(e=>{let t={weekday:e.weekday,isOpen:e.isOpen,slots:e.slots.map(C)};return""===e.orderCutoffMinutes?t:{...t,orderCutoffMinutes:Number(e.orderCutoffMinutes)}}),exceptionDates:a.data.exceptionDates.map(M),...(n=a.data.pickupStartsAt,r=t.hadPickupStart,""===n?r?{clearPickupStartsAtMinute:!0}:{}:{pickupStartsAtMinute:b(n)})};if(""===a.data.orderingClosedUntil)return t.hadOrderingPause?{ok:!0,input:{...i,clearOrderingClosedUntil:!0}}:{ok:!0,input:i};let s=function(e,t){let[n="",r=""]=e.split("T");return u.test(n)&&c.test(r)?(0,o.validZonedDateMinutesToTimestamp)(n,b(r),t):null}(a.data.orderingClosedUntil,t.timezone);return null===s?{ok:!1,error:"Pause-until time doesn't exist in this location's timezone."}:{ok:!0,input:{...i,orderingClosedUntil:s}}}(t.availability,{hadOrderingPause:n?.orderingClosedUntil!==void 0,hadPickupStart:n?.pickupStartsAtMinute!==void 0,timezone:t.timezone});if(!i.ok)return void s.toast.error(i.error);r(!0);try{var l;let r;await e.onSave({...(l=null!==n,{addressLine1:(r=e=>{let t=e.trim();return t.length>0?t:l?"":void 0})(t.addressLine1),addressLine2:r(t.addressLine2),city:r(t.city),country:r(t.country.toUpperCase()),googlePlaceId:r(t.googlePlaceId),name:t.name.trim(),postalCode:r(t.postalCode),region:r(t.region),supportedFulfillment:{delivery:t.delivery,pickup:t.pickup,shipping:t.shipping},timezone:t.timezone}),...i.input}),s.toast.success(n?"Location updated.":"Location created."),e.onClose()}catch(e){s.toast.error(e instanceof Error?e.message:"Couldn't save the location.")}finally{r(!1)}}function es(e){let r,i,s,o=(0,n.c)(5),{editing:l}=e,c=l?"Edit location":"New location";return o[0]!==c?(r=(0,t.jsx)(a.DialogTitle,{children:c}),o[0]=c,o[1]=r):r=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(a.DialogDescription,{children:"Where this shop fulfills orders. The register and checkout use it for pickup and taxes."}),o[2]=i):i=o[2],o[3]!==r?(s=(0,t.jsxs)(a.DialogHeader,{children:[r,i]}),o[3]=r,o[4]=s):s=o[4],s}function eo(e){let i,s,o,l=(0,n.c)(10),{actions:c,state:u}=e;l[0]!==c.onClose||l[1]!==u.saving?(i=(0,t.jsx)(r.Button,{disabled:u.saving,onClick:c.onClose,variant:"ghost",children:"Cancel"}),l[0]=c.onClose,l[1]=u.saving,l[2]=i):i=l[2];let d=u.editing?"Save changes":"Create location";return l[3]!==u.onSave||l[4]!==u.saving||l[5]!==d?(s=(0,t.jsx)(r.Button,{disabled:u.saving,onClick:u.onSave,children:d}),l[3]=u.onSave,l[4]=u.saving,l[5]=d,l[6]=s):s=l[6],l[7]!==i||l[8]!==s?(o=(0,t.jsxs)(a.DialogFooter,{children:[i,s]}),l[7]=i,l[8]=s,l[9]=o):o=l[9],o}e.s(["LocationEditorDialog",0,function(e){let r,s,l,c,u,d,m,p,h,f,x=(0,n.c)(28),{actions:g,container:v,location:b}=e;x[0]!==b?(r=()=>{var e,t;let n;return{addressLine1:b?.addressLine1??"",addressLine2:b?.addressLine2??"",availability:{weeklyAvailability:Array.from({length:7},(e,t)=>{let n=b?.weeklyAvailability.find(e=>e.weekday===t);return{weekday:t,isOpen:n?.isOpen??!1,slots:n?.slots.map((e,n)=>S(e,`weekday-${t}-${n}`))??[],orderCutoffMinutes:n?.orderCutoffMinutes===void 0?"":String(n.orderCutoffMinutes)}}),exceptionDates:b?.exceptionDates.map((e,t)=>({id:`exception-${e.date}-${t}`,date:e.date,closed:e.closed,note:e.note??"",useCustomSlots:void 0!==e.slots,slots:e.slots?.map((e,n)=>S(e,`exception-${t}-${n}`))??[]}))??[],orderingClosedUntil:b?.orderingClosedUntil===void 0?"":(e=b.orderingClosedUntil,t=b.timezone,n=(0,o.timestampToZonedParts)(e,t),`${n.year}-${y(n.month)}-${y(n.day)}T${y(n.hour)}:${y(n.minute)}
1`),pickupStartsAt:b?.pickupStartsAtMinute===void 0?"":j(b.pickupStartsAtMinute)},city:b?.city??"",country:b?.country??"",delivery:b?.supportedFulfillment.delivery??!1,googlePlaceId:b?.googlePlaceId??"",name:b?.name??"",pickup:b?.supportedFulfillment.pickup??!0,postalCode:b?.postalCode??"",region:b?.region??"",shipping:b?.supportedFulfillment.shipping??!1,timezone:b?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone}},x[0]=b,x[1]=r):r=x[1];let[C,M]=(0,i.useState)(r),[w,k]=(0,i.useState)(!1);x[2]===Symbol.for("react.memo_cache_sentinel")?(s=(e,t)=>M(n=>({...n,[e]:t})),x[2]=s):s=x[2];let N=s;x[3]!==g||x[4]!==C||x[5]!==b?(l=()=>ei({actions:g,draft:C,location:b,setSaving:k}),x[3]=g,x[4]=C,x[5]=b,x[6]=l):l=x[6];let _=l;x[7]!==g?(c=e=>e?void 0:g.onClose(),x[7]=g,x[8]=c):c=x[8];let I=v??void 0,T=null!==b;x[9]!==T?(u=(0,t.jsx)(es,{editing:T}),x[9]=T,x[10]=u):u=x[10],x[11]!==C?(d=(0,t.jsx)(ea,{draft:C,onChange:N}),x[11]=C,x[12]=d):d=x[12];let P=null!==b;return x[13]!==_||x[14]!==w||x[15]!==P?(m={editing:P,onSave:_,saving:w},x[13]=_,x[14]=w,x[15]=P,x[16]=m):m=x[16],x[17]!==g||x[18]!==m?(p=(0,t.jsx)(eo,{actions:g,state:m}),x[17]=g,x[18]=m,x[19]=p):p=x[19],x[20]!==p||x[21]!==I||x[22]!==u||x[23]!==d?(h=(0,t.jsxs)(a.DialogContent,{className:"sm:max-w-xl",container:I,scrollable:!0,children:[u,d,p]}),x[20]=p,x[21]=I,x[22]=u,x[23]=d,x[24]=h):h=x[24],x[25]!==h||x[26]!==c?(f=(0,t.jsx)(a.Dialog,{onOpenChange:c,open:!0,children:h}),x[25]=h,x[26]=c,x[27]=f):f=x[27],f}],44007)},592297,958413,634019,688933,760550,623482,223663,989891,891777,630596,929628,772265,722226,e=>{"use strict";var t=e.i(931718),n=e.i(729386);e.i(116233);var r=e.i(235893),a=e.i(160444),i=e.i(699597),s=e.i(843161),o=e.i(903426),l=e.i(400810),c=e.i(593445),u=e.i(448769),d=e.i(273471),m=e.i(832877),p=e.i(62356);function h(e){return(0,t.jsxs)(a.DropdownMenuRadioItem,{value:(0,u.shopIdentityValue)(e),children:[(0,t.jsx)(c.ShopIdentityAvatar,{className:"shrink-0",icon:(0,l.fromConvexIconData)((0,u.shopIdentityIconData)(e)),name:(0,u.shopIdentityLabel)(e),size:"xs"}),(0,t.jsx)(i.Text,{as:"span",className:"min-w-0 flex-1 break-words",variant:"label",children:(0,u.shopIdentityLabel)(e)})]},(0,u.shopIdentityValue)(e))}e.s(["PosAccountSwitcher",0,function(){let e,f,x,g,v,y,j,b,S,C,M,w,k,N,_,I,T,P,R,D=(0,n.c)(50),L=(0,m.useOnOpenApp)(),A=(0,p.useSelectedSpaceId)(),O=(0,p.useSetSelectedSpaceId)(),{identities:E,isLoading:B}=(0,d.useShopIdentities)();if(D[0]!==E||D[1]!==B||D[2]!==A||D[3]!==O){let n,o,d,m=(0,u.selectedShopIdentity)(E,A),p=(0,u.selectedShopIdentityLabel)(m,A),w=A??u.PERSONAL_SHOP_VALUE,k=(0,u.shopIdentityOptions)(E);D[15]!==O?(n=e=>{O((0,u.selectedSpaceIdFromShopValue)(e))},D[15]=O,D[16]=n):n=D[16];let N=n;g=a.DropdownMenu;let _=(0,t.jsx)(r.Button,{className:"min-w-0 max-w-56 justify-start",size:"identity",title:B?void 0:p,variant:"surface"}),I=B?null:(0,t.jsx)(c.ShopIdentityAvatar,{className:"shrink-0",icon:m?(0,l.fromConvexIconData)((0,u.shopIdentityIconData)(m)):void 0,name:p,size:"sm"}),T=B?"Loading shop":p;D[17]!==T?(o=(0,t.jsx)(i.Text,{as:"span",className:"line-clamp-2 min-w-0 flex-1 break-words text-left",variant:"label",children:T}),D[17]=T,D[18]=o):o=D[18],D[19]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(s.ChevronsUpDown,{className:"size-3.5 shrink-0 text-muted-foreground"}),D[19]=d):d=D[19],D[20]!==o||D[21]!==_||D[22]!==I?(M=(0,t.jsxs)(a.DropdownMenuTrigger,{"aria-label":"Switch register shop",render:_,children:[I,o,d]}),D[20]=o,D[21]=_,D[22]=I,D[23]=M):M=D[23],x=a.DropdownMenuContent,S="start",C="w-64",f=a.DropdownMenuGroup,D[24]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)(a.DropdownMenuLabel,{children:"Register"}),D[24]=b):b=D[24],e=a.DropdownMenuRadioGroup,v=N,y=w,j=k.map(h),D[0]=E,D[1]=B,D[2]=A,D[3]=O,D[4]=e,D[5]=f,D[6]=x,D[7]=g,D[8]=v,D[9]=y,D[10]=j,D[11]=b,D[12]=S,D[13]=C,D[14]=M}else e=D[4],f=D[5],x=D[6],g=D[7],v=D[8],y=D[9],j=D[10],b=D[11],S=D[12],C=D[13],M=D[14];return D[25]!==e||D[26]!==v||D[27]!==y||D[28]!==j?(w=(0,t.jsx)(e,{onValueChange:v,value:y,children:j}),D[25]=e,D[26]=v,D[27]=y,D[28]=j,D[29]=w):w=D[29],D[30]!==f||D[31]!==b||D[32]!==w?(k=(0,t.jsxs)(f,{children:[b,w]}),D[30]=f,D[31]=b,D[32]=w,D[33]=k):k=D[33],D[34]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)(a.DropdownMenuSeparator,{}),D[34]=N):N=D[34],D[35]!==L?(_=()=>{L?.("settings",{activeTab:"teams"})},D[35]=L,D[36]=_):_=D[36],D[37]===Symbol.for("react.memo_cache_sentinel")?(I=(0,t.jsx)(o.Settings2,{}),D[37]=I):I=D[37],D[38]!==_?(T=(0,t.jsxs)(a.DropdownMenuItem,{onClick:_,children:[I,"Manage shops"]}),D[38]=_,D[39]=T):T=D[39],D[40]!==x||D[41]!==T||D[42]!==S||D[43]!==C||D[44]!==k?(P=(0,t.jsxs)(x,{align:S,className:C,children:[k,N,T]}),D[40]=x,D[41]=T,D[42]=S,D[43]=C,D[44]=k,D[45]=P):P=D[45],D[46]!==g||D[47]!==P||D[48]!==M?(R=(0,t.jsxs)(g,{children:[M,P]}),D[46]=g,D[47]=P,D[48]=M,D[49]=R):R=D[49],R}],592297);var f=e.i(250186),x=e.i(8513),g=e.i(867506),v=e.i(607595),y=e.i(535352),j=e.i(431352),b=e.i(283164);e.i(857266);var S=e.i(246257),C=e.i(41676);function M(){let e,t,r,a,i,s=(0,n.c)(14),o=(0,p.useSelectedSpaceId)(),l=(0,p.useCustomer)(),c=(0,p.useCartLines)(),u=(0,p.useDiscount)();s[0]!==l||s[1]!==o?(e=o&&l?{spaceId:o,customerId:l.customerId}:"skip",s[0]=l,s[1]=o,s[2]=e):e=s[2];let d=(0,S.useQuery)(b.api.commerce.ledger.rewards.customerRewards,e);if(!d)return null;s[3]!==u||s[4]!==c?(t=(0,C.computeSubtotalMinor)(c),r=(0,C.computeDiscountMinor)(u,t),s[3]=u,s[4]=c,s[5]=t,s[6]=r):(t=s[5],r=s[6]);let m=r,h=d.points,f=d.tier,x=t-m;if(s[7]!==d.points||s[8]!==x){var g;
1g=d.points,a=g<=0||x<=0?0:500*Math.min(Math.floor(g/100),Math.floor(x/500)),s[7]=d.points,s[8]=x,s[9]=a}else a=s[9];return s[10]!==d.points||s[11]!==d.tier||s[12]!==a?(i={points:h,tier:f,redeemableMinor:a},s[10]=d.points,s[11]=d.tier,s[12]=a,s[13]=i):i=s[13],i}function w(e){let t,r,a=(0,n.c)(9),i=(0,p.useCartLines)(),s=(0,p.useDiscount)(),o=(0,p.useTip)(),l=(0,p.useRedeemRewards)(),c=M(),u=l&&c?c.redeemableMinor:0;a[0]!==s||a[1]!==i||a[2]!==u||a[3]!==e||a[4]!==o?(t=(0,C.computeSaleAmounts)(i,{taxRateBps:e,discount:s,tip:o,rewardsRedemptionMinor:u}),a[0]=s,a[1]=i,a[2]=u,a[3]=e,a[4]=o,a[5]=t):t=a[5];let d=t;return a[6]!==d||a[7]!==c?(r={amounts:d,rewards:c},a[6]=d,a[7]=c,a[8]=r):r=a[8],r}let k=new Set(["a","an","and","at","by","for","in","of","on","or","per","the","to","with"]),N=/\s+/,_=/([-/])/,I=/[A-Z]/;function T(e){let t=e.trim().split(N).filter(Boolean);return 0===t.length?"":t.map((e,n)=>{var r,a;return r=e,a=0===n||n===t.length-1,I.test(r)||!a&&k.has(r)?r:r.split(_).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}).join(" ")}function P(e){let r,a=(0,n.c)(11),{brand:i,state:s}=e;if("idle"===s.kind){let e;return a[0]!==i?(e=(0,t.jsx)(D,{brand:i}),a[0]=i,a[1]=e):e=a[1],e}if("active"===s.kind||"review"===s.kind){let e,n="review"===s.kind;return a[2]!==i||a[3]!==s.amounts||a[4]!==s.currency||a[5]!==s.lines||a[6]!==n?(e=(0,t.jsx)(A,{amounts:s.amounts,brand:i,currency:s.currency,isReview:n,lines:s.lines}),a[2]=i,a[3]=s.amounts,a[4]=s.currency,a[5]=s.lines,a[6]=n,a[7]=e):e=a[7],e}return a[8]!==i||a[9]!==s.sale?(r=(0,t.jsx)(F,{brand:i,sale:s.sale}),a[8]=i,a[9]=s.sale,a[10]=r):r=a[10],r}function R(e){let r,a=(0,n.c)(3),{brand:i}=e;return a[0]!==i.icon||a[1]!==i.name?(r=(0,t.jsx)(c.ShopIdentityAvatar,{icon:i.icon,name:i.name,size:"3xl"}),a[0]=i.icon,a[1]=i.name,a[2]=r):r=a[2],r}function D(e){let r,a,s,o,l,c=(0,n.c)(10),{brand:u}=e;return c[0]!==u?(r=(0,t.jsx)(R,{brand:u}),c[0]=u,c[1]=r):r=c[1],c[2]!==u.name?(a=(0,t.jsx)(i.H1,{variant:"hero",children:u.name}),c[2]=u.name,c[3]=a):a=c[3],c[4]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(i.Text,{variant:"bodyLargeMuted",children:"Come on in."}),c[4]=s):s=c[4],c[5]!==a?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[a,s]}),c[5]=a,c[6]=o):o=c[6],c[7]!==r||c[8]!==o?(l=(0,t.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-8 p-10 text-center",children:[r,o]}),c[7]=r,c[8]=o,c[9]=l):l=c[9],l}function L(e){let r,a,s,o=(0,n.c)(8),{brand:l}=e;return o[0]!==l.icon||o[1]!==l.name?(r=(0,t.jsx)(c.ShopIdentityAvatar,{icon:l.icon,name:l.name,size:"lg"}),o[0]=l.icon,o[1]=l.name,o[2]=r):r=o[2],o[3]!==l.name?(a=(0,t.jsx)(i.H3,{variant:"subsection",children:l.name}),o[3]=l.name,o[4]=a):a=o[4],o[5]!==r||o[6]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-center gap-3 pb-8",children:[r,a]}),o[5]=r,o[6]=a,o[7]=s):s=o[7],s}function A(e){let r,a,i,s,o,l,c=(0,n.c)(19),{amounts:u,brand:d,currency:m,isReview:p,lines:h}=e;if(c[0]!==d?(r=(0,t.jsx)(L,{brand:d}),c[0]=d,c[1]=r):r=c[1],c[2]!==m||c[3]!==h){let e;c[5]!==m?(e=e=>(0,t.jsx)(E,{currency:m,line:e},e.lineId),c[5]=m,c[6]=e):e=c[6],a=h.map(e),c[2]=m,c[3]=h,c[4]=a}else a=c[4];return c[7]!==a?(i=(0,t.jsx)(x.ScrollArea,{className:"min-h-0 flex-1",children:(0,t.jsx)("div",{className:"divide-y",children:a})}),c[7]=a,c[8]=i):i=c[8],c[9]!==u||c[10]!==m?(s=(0,t.jsx)(z,{amounts:u,currency:m}),c[9]=u,c[10]=m,c[11]=s):s=c[11],c[12]!==p?(o=p?(0,t.jsx)(O,{}):null,c[12]=p,c[13]=o):o=c[13],c[14]!==r||c[15]!==i||c[16]!==s||c[17]!==o?(l=(0,t.jsxs)("div",{className:"mx-auto flex h-full w-full max-w-4xl flex-col p-10",children:[r,i,s,o]}),c[14]=r,c[15]=i,c[16]=s,c[17]=o,c[18]=l):l=c[18],l}function O(){let e,r=(0,n.c)(1);return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("div",{className:"flex items-center justify-center gap-3 pt-6",children:[(0,t.jsx)(v.Credit
1Card,{className:"size-6 text-primary"}),(0,t.jsx)(i.Text,{variant:"bodyLarge",children:"That's your order. Pay on the card reader when you're ready."})]}),r[0]=e):e=r[0],e}function E(e){let r,a,s,o,l,c,u,d,m,p,h,x,g=(0,n.c)(31),{currency:v,line:y}=e;g[0]!==y.name?(r=T(y.name),g[0]=y.name,g[1]=r):r=g[1];let b=r;return g[2]!==y.imageUrl?(a=y.imageUrl?{url:y.imageUrl}:null,g[2]=y.imageUrl,g[3]=a):a=g[3],g[4]!==a||g[5]!==b?(s=(0,t.jsx)(f.ProductThumb,{className:"size-16 shrink-0 rounded-xl",image:a,name:b}),g[4]=a,g[5]=b,g[6]=s):s=g[6],g[7]!==y.quantity?(o=(0,t.jsxs)(i.H3,{className:"w-12 shrink-0",children:[y.quantity,"×"]}),g[7]=y.quantity,g[8]=o):o=g[8],g[9]!==b?(l=(0,t.jsx)(i.H3,{className:"truncate",children:b}),g[9]=b,g[10]=l):l=g[10],g[11]!==y.variantLabel?(c=y.variantLabel?(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"bodyLargeMuted",children:y.variantLabel}):null,g[11]=y.variantLabel,g[12]=c):c=g[12],g[13]!==y.modifiers?(u=y.modifiers.map(B),g[13]=y.modifiers,g[14]=u):u=g[14],g[15]!==l||g[16]!==c||g[17]!==u?(d=(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[l,c,u]}),g[15]=l,g[16]=c,g[17]=u,g[18]=d):d=g[18],g[19]!==s||g[20]!==o||g[21]!==d?(m=(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-5",children:[s,o,d]}),g[19]=s,g[20]=o,g[21]=d,g[22]=m):m=g[22],g[23]!==v||g[24]!==y?(p=(0,j.formatPriceMinor)((0,C.computeLineTotalMinor)(y),v),g[23]=v,g[24]=y,g[25]=p):p=g[25],g[26]!==p?(h=(0,t.jsx)(i.H3,{className:"shrink-0",children:p}),g[26]=p,g[27]=h):h=g[27],g[28]!==h||g[29]!==m?(x=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-6 py-5",children:[m,h]}),g[28]=h,g[29]=m,g[30]=x):x=g[30],x}function B(e){return(0,t.jsxs)(i.Text,{as:"span",className:"truncate",variant:"bodyLargeMuted",children:["+ ",e.name]},e.choiceId)}function $(e){let r,a,s,o=(0,n.c)(7),{label:l,value:c}=e;return o[0]!==l?(r=(0,t.jsx)(i.Text,{as:"span",variant:"bodyLargeMuted",children:l}),o[0]=l,o[1]=r):r=o[1],o[2]!==c?(a=(0,t.jsx)(i.Text,{as:"span",variant:"bodyLarge",children:c}),o[2]=c,o[3]=a):a=o[3],o[4]!==r||o[5]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[r,a]}),o[4]=r,o[5]=a,o[6]=s):s=o[6],s}function z(e){let r,a,s,o,l,c,u,d,m,p,h=(0,n.c)(28),{amounts:f,currency:x}=e;return h[0]!==f.subtotalMinor||h[1]!==x?(r=(0,j.formatPriceMinor)(f.subtotalMinor,x),h[0]=f.subtotalMinor,h[1]=x,h[2]=r):r=h[2],h[3]!==r?(a=(0,t.jsx)($,{label:"Subtotal",value:r}),h[3]=r,h[4]=a):a=h[4],h[5]!==f.discountMinor||h[6]!==x?(s=f.discountMinor>0?(0,t.jsx)($,{label:"Discount",value:`−${(0,j.formatPriceMinor)(f.discountMinor,x)}`}):null,h[5]=f.discountMinor,h[6]=x,h[7]=s):s=h[7],h[8]!==f.taxMinor||h[9]!==x?(o=(0,j.formatPriceMinor)(f.taxMinor,x),h[8]=f.taxMinor,h[9]=x,h[10]=o):o=h[10],h[11]!==o?(l=(0,t.jsx)($,{label:"Tax",value:o}),h[11]=o,h[12]=l):l=h[12],h[13]!==f.tipMinor||h[14]!==x?(c=f.tipMinor>0?(0,t.jsx)($,{label:"Tip",value:(0,j.formatPriceMinor)(f.tipMinor,x)}):null,h[13]=f.tipMinor,h[14]=x,h[15]=c):c=h[15],h[16]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Total"}),h[16]=u):u=h[16],h[17]!==f.totalMinor||h[18]!==x?(d=(0,j.formatPriceMinor)(f.totalMinor,x),h[17]=f.totalMinor,h[18]=x,h[19]=d):d=h[19],h[20]!==d?(m=(0,t.jsxs)("div",{className:"flex items-baseline justify-between pt-2",children:[u,(0,t.jsx)(i.H1,{variant:"hero",children:d})]}),h[20]=d,h[21]=m):m=h[21],h[22]!==a||h[23]!==s||h[24]!==l||h[25]!==c||h[26]!==m?(p=(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t pt-8",children:[a,s,l,c,m]}),h[22]=a,h[23]=s,h[24]=l,h[25]=c,h[26]=m,h[27]=p):p=h[27],p}function F(e){let r,a,s,o,l,c,u=(0,n.c)(13),{brand:d,sale:m}=e;return u[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(g.Check,{className:"size-16 text-primary"}),u[0]=r):r=u[0],u[1]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(i.H1,{variant:"hero",children:"Thank you"}),u[1]=a):a=u[1],u[2]!==d.name||u[3]!==m.orderNumber?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[a,(0,t.jsxs)(i.Text,{variant:"bodyLargeMuted",children:[d.name," · Order ",m.orderNumber]})]}),u[2]=d.name,u[3]=m.orderNumber,u[4]=s):s=u[4],u[5]!==m.currency||u[6]!==m.totalMinor?(
1o=(0,j.formatPriceMinor)(m.totalMinor,m.currency),u[5]=m.currency,u[6]=m.totalMinor,u[7]=o):o=u[7],u[8]!==o?(l=(0,t.jsxs)(i.Muted,{children:[o," paid"]}),u[8]=o,u[9]=l):l=u[9],u[10]!==s||u[11]!==l?(c=(0,t.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-8 p-10 text-center",children:[r,s,l]}),u[10]=s,u[11]=l,u[12]=c):c=u[12],c}e.s(["PosCustomerDisplay",0,function(e){let a,i,s,o,l,c=(0,n.c)(17),{brand:u,onExit:d,taxRateBps:m}=e,h=(0,p.useCartLines)(),f=(0,p.useLastSale)(),x=(0,p.useDiscount)(),g=(0,p.useTip)(),v=(0,p.useSaleStage)(),{amounts:j}=w(m);c[0]!==j.rewardsRedemptionMinor||c[1]!==x||c[2]!==f||c[3]!==h||c[4]!==v||c[5]!==m||c[6]!==g?(a=function(e){if(e.lines.length>0){let t={lines:e.lines,currency:e.lines[0]?.currency??"usd",amounts:(0,C.computeSaleAmounts)(e.lines,{taxRateBps:e.taxRateBps,discount:e.discount,tip:e.tip,rewardsRedemptionMinor:e.rewardsRedemptionMinor})};return"payable"===e.stage?{kind:"review",...t}:{kind:"active",...t}}return e.lastSale?{kind:"thanks",sale:e.lastSale}:{kind:"idle"}}({discount:x,lastSale:f,lines:h,rewardsRedemptionMinor:j.rewardsRedemptionMinor,stage:v,taxRateBps:m,tip:g}),c[0]=j.rewardsRedemptionMinor,c[1]=x,c[2]=f,c[3]=h,c[4]=v,c[5]=m,c[6]=g,c[7]=a):a=c[7];let b=a;return c[8]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(y.X,{}),c[8]=i):i=c[8],c[9]!==d?(s=(0,t.jsx)(r.Button,{"aria-label":"Exit customer view",className:"absolute top-4 right-4 z-10",onClick:d,size:"icon",variant:"ghost",children:i}),c[9]=d,c[10]=s):s=c[10],c[11]!==u||c[12]!==b?(o=(0,t.jsx)(P,{brand:u,state:b}),c[11]=u,c[12]=b,c[13]=o):o=c[13],c[14]!==s||c[15]!==o?(l=(0,t.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col bg-background",children:[s,o]}),c[14]=s,c[15]=o,c[16]=l):l=c[16],l}],958413);var q=e.i(323490),V=e.i(439779),U=e.i(21079),H=e.i(433992),G=e.i(679996),Q=e.i(438208),Q=Q,W=e.i(605252),W=W,X=e.i(485954),K=e.i(913939),Z=e.i(991686),J=e.i(393784),Y=e.i(107663);function ee(e){let t=e.replace(/[^0-9.-]/g,"");if(0===t.length)return 0;let n=Number.parseFloat(t);return!Number.isFinite(n)||n<=0?0:Math.round(100*n)}function et(e){return(Math.max(0,Math.round(e))/100).toFixed(2)}function en({onOpenChange:e,open:n,session:a}){let i=(0,m.usePortalContainer)(),s=(0,S.useMutation)(b.api.commerce.pos.sessions.recordCashMovement),[o,l]=(0,X.useState)("paid_in"),[c,u]=(0,X.useState)(""),[d,p]=(0,X.useState)(""),[h,f]=(0,X.useState)(!1),x=ee(c),g=x>0,v=()=>{h||(u(""),p(""),e(!1))},y=async e=>{if(e.preventDefault(),g&&!h){f(!0);try{await s({sessionId:a._id,type:o,amountMinor:x,note:""===d.trim()?void 0:d.trim()});let e=(0,j.formatPriceMinor)(x,a.currency);K.toast.success("paid_in"===o?`${e} paid in to the drawer.`:`${e} paid out of the drawer.`),v()}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't record the cash movement.")}finally{f(!1)}}};return(0,t.jsx)(V.Dialog,{onOpenChange:e=>!e&&v(),open:n,children:(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[400px]",container:i,children:[(0,t.jsxs)(V.DialogHeader,{children:[(0,t.jsx)(V.DialogTitle,{children:"Drawer cash"}),(0,t.jsxs)(V.DialogDescription,{children:["Record cash in or out of the drawer that isn't a sale. Expected in drawer:"," ",(0,j.formatPriceMinor)(a.expectedCashMinor,a.currency),"."]})]}),(0,t.jsxs)("form",{onSubmit:y,children:[(0,t.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,t.jsxs)(Z.ToggleGroup,{onValueChange:e=>{let t=e[0];("paid_in"===t||"paid_out"===t)&&l(t)},spacing:1,value:[o],children:[(0,t.jsxs)(Z.ToggleGroupItem,{"aria-label":"Paid in",value:"paid_in",children:[(0,t.jsx)(J.ArrowDownLeft,{}),"Paid in"]}),(0,t.jsxs)(Z.ToggleGroupItem,{"aria-label":"Paid out",value:"paid_out",children:[(0,t.jsx)(Y.ArrowUpRight,{}),"Paid out"]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(H.Label,{htmlFor:"pos-cash-movement-amount",children:"Amount"}),(0,t.jsx)(U.Input,{autoFocus:!0,id:"pos-cash-movement-amount",inputMode:"decimal",onChange:e=>u(e.target.value),placeholder:"0.00",value:c})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(H.Label,{htmlFor:"pos-cash-movement-note",children:"Note (optional)"}
1),(0,t.jsx)(U.Input,{id:"pos-cash-movement-note",onChange:e=>p(e.target.value),placeholder:"What was it for?",value:d})]})]}),(0,t.jsxs)(V.DialogFooter,{children:[(0,t.jsx)(r.Button,{onClick:v,type:"button",variant:"surface",children:"Cancel"}),(0,t.jsx)(r.Button,{disabled:!g||h,type:"submit",children:"Record"})]})]})]})})}var er=e.i(220023);function ea(e){return e?{spaceId:e}:{}}function ei(){let{gate:e}=(0,er.useGuestGate)();return e(ea((0,p.useSelectedSpaceId)()))}function es(e,t){return"skip"===e||null===t?"skip":{...e,...t}}function eo(e){let t=e.trim();if(""===t)return null;let n=Number(t);return!Number.isFinite(n)||n<0?null:Math.round(100*n)}function el(e){let a,i,s,o=(0,n.c)(25),{locationId:l,session:c}=e,[u,d]=(0,X.useState)(!1),[m,p]=(0,X.useState)(!1),[h,f]=(0,X.useState)(!1);if(c){let e,n,a,i,s,l,u,d,x,g;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(W.default,{className:"size-3.5"}),o[0]=e):e=o[0],o[1]!==c.currency||o[2]!==c.expectedCashMinor?(n=(0,j.formatPriceMinor)(c.expectedCashMinor,c.currency),o[1]=c.currency,o[2]=c.expectedCashMinor,o[3]=n):n=o[3],o[4]!==n?(a=(0,t.jsxs)(q.Badge,{className:"gap-1.5",variant:"secondary",children:[e,"Register open ·"," ",n]}),o[4]=n,o[5]=a):a=o[5],o[6]===Symbol.for("react.memo_cache_sentinel")?(i=()=>f(!0),o[6]=i):i=o[6],o[7]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)(r.Button,{onClick:i,variant:"surface",children:[(0,t.jsx)(G.Coins,{}),"Drawer"]}),o[7]=s):s=o[7],o[8]===Symbol.for("react.memo_cache_sentinel")?(l=()=>p(!0),o[8]=l):l=o[8],o[9]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsxs)(r.Button,{onClick:l,variant:"surface",children:[(0,t.jsx)(Q.default,{}),"Close register"]}),o[9]=u):u=o[9],o[10]!==h||o[11]!==c?(d=(0,t.jsx)(en,{onOpenChange:f,open:h,session:c}),o[10]=h,o[11]=c,o[12]=d):d=o[12],o[13]!==m||o[14]!==c?(x=(0,t.jsx)(eu,{onOpenChange:p,open:m,session:c}),o[13]=m,o[14]=c,o[15]=x):x=o[15],o[16]!==a||o[17]!==d||o[18]!==x?(g=(0,t.jsxs)(t.Fragment,{children:[a,s,u,d,x]}),o[16]=a,o[17]=d,o[18]=x,o[19]=g):g=o[19],g}return o[20]===Symbol.for("react.memo_cache_sentinel")?(a=()=>d(!0),o[20]=a):a=o[20],o[21]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxs)(r.Button,{onClick:a,variant:"surface",children:[(0,t.jsx)(W.default,{}),"Open register"]}),o[21]=i):i=o[21],o[22]!==u||o[23]!==l?(s=(0,t.jsxs)(t.Fragment,{children:[i,(0,t.jsx)(ec,{locationId:l,onOpenChange:d,open:u})]}),o[22]=u,o[23]=l,o[24]=s):s=o[24],s}function ec({locationId:e,onOpenChange:n,onOpened:a,open:i}){let s=(0,m.usePortalContainer)(),o=(0,S.useMutation)(b.api.commerce.pos.sessions.openRegister),l=ei(),[c,u]=(0,X.useState)("0"),[d,p]=(0,X.useState)(!1),h=eo(c),f=null!==h,x=()=>{u("0"),n(!1)},g=async t=>{if(t.preventDefault(),null!==h&&!d&&"skip"!==l){p(!0);try{await o({...l,locationId:e,openingFloatMinor:h,currency:"usd"}),K.toast.success("Drawer counted: register open."),x(),a?.()}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't open the register.")}finally{p(!1)}}};return(0,t.jsx)(V.Dialog,{onOpenChange:e=>!e&&x(),open:i,children:(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[400px]",container:s,children:[(0,t.jsxs)(V.DialogHeader,{children:[(0,t.jsx)(V.DialogTitle,{children:"Open register"}),(0,t.jsx)(V.DialogDescription,{className:"sr-only",children:"Enter the opening cash float to start the shift."})]}),(0,t.jsxs)("form",{onSubmit:g,children:[(0,t.jsxs)("div",{className:"space-y-2 py-4",children:[(0,t.jsx)(H.Label,{htmlFor:"pos-opening-float",children:"Opening float (USD)"}),(0,t.jsx)(U.Input,{autoFocus:!0,id:"pos-opening-float",inputMode:"decimal",min:"0",onChange:e=>u(e.target.value),step:"0.01",type:"number",value:c})]}),(0,t.jsxs)(V.DialogFooter,{children:[(0,t.jsx)(r.Button,{onClick:x,type:"button",variant:"surface",children:"Cancel"}),(0,t.jsx)(r.Button,{disabled:!f||d,type:"submit",children:"Open register"})]})]})]})})}function eu({onOpenChange:e,open:n,session:a}){let i=(0,m.usePortalContainer)(),s=(0,S.useMutation)(b.api.commerce.pos.sessions.closeRegister),[o,l]=(0,X.useState)(""),[c,u]=(0,X.useState)(!1),d=eo(o),p=null!==d,h=null===d?null:d-a.expectedCashMinor,f=()=>{l(""),e(!1)},x=async e=>{if(e.preventDefault(),null!==d&&!c){u(!0);try{let e=await s({sessionId:a._id,countedCashMinor:d}),t=(0,j.formatPriceMinor)(e.cashVarianceMinor,a.currency);K.toast.success(0===e.cashVarianceMinor?"Register closed — drawer balanced.":`Register closed — drawer variance ${t}.`),f()}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't close the register.")}finally{u(!1)}}};return(0,t.jsx)(V.Dialog,{onOpenChange:e=>!e&&f(),open:n,children:(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[400px]",container:i,children:[(0,t.jsxs)(V.DialogHeader,{children:[(0,t.jsx)(V.DialogTitle,{children:"Close register"}),(0,t.jsx)(V.DialogDescription,{children:"Count the drawer and enter the total. We compare it against the expected balance to record the shift's variance."})]}),(0,t.jsxs)("form",{onSubmit:x,children:[(0,t.jsxs)("div",{className:"space-y-4 py-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Expected in drawer"}),(0,t.jsx)("span",{className:"font-medium",children:(0,j.formatPriceMinor)(a.expectedCashMinor,a.currency)})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(H.Label,{htmlFor:"pos-counted-cash",children:"Counted cash (USD)"}),(0,t.jsx)(U.Input,{autoFocus:!0,id:"pos-counted-cash",inputMode:"decimal",min:"0",onChange:e=>l(e.target.value),placeholder:"0.00",step:"0.01",type:"number",value:o})]}),null!==h&&(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Variance"}),(0,t.jsx)("span",{className:"font-medium",children:(0,j.formatPriceMinor)(h,a.currency)})]})]}),(0,t.jsxs)(V.DialogFooter,{children:[(0,t.jsx)(r.Button,{onClick:f,type:"button",variant:"surface",children:"Cancel"}),(0,t.jsx)(r.Button,{disabled:!p||c,type:"submit",children:"Close register"})]})]})]})})}e.s(["posShopSelection",0,ea,"usePosOwner",0,function(){return(0,d.useCommerceOwner)((0,p.useSelectedSpaceId)())},"usePosShopSelection",0,ei,"withPosShopSelection",0,es],634019),e.s(["OpenRegisterDialog",0,ec,"PosRegisterControl",0,el,"PosSessionChip",0,function(e){let r,a,i,s=(0,n.c)(6),{session:o}=e;return o?(s[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(W.default,{className:"size-3.5"}),s[0]=r):r=s[0],s[1]!==o.currency||s[2]!==o.expectedCashMinor?(a=(0,j.formatPriceMinor)(o.expectedCashMinor,o.currency),s[1]=o.currency,s[2]=o.expectedCashMinor,s[3]=a):a=s[3],s[4]!==a?(i=(0,t.jsxs)(q.Badge,{className:"gap-1.5",variant:"secondary",children:[r,"Shift open ·"," ",a]}),s[4]=a,s[5]=i):i=s[5],i):null}],688933);var ed=e.i(237418),em=e.i(65725),ep=e.i(87352);let eh={cash:"Cash",card_present:"Card",store_credit:"Store credit",comp:"Comp"};
1function ef(e){return new Date(e).toLocaleString(void 0,{day:"numeric",hour:"numeric",minute:"2-digit",month:"short"})}function ex(e){let r,a,s,o=(0,n.c)(9),{emphasis:l,label:c,value:u}=e,d=l?"labelBold":"bodyMuted";o[0]!==c||o[1]!==d?(r=(0,t.jsx)(i.Text,{as:"span",variant:d,children:c}),o[0]=c,o[1]=d,o[2]=r):r=o[2];let m=l?"statValue":"label";return o[3]!==m||o[4]!==u?(a=(0,t.jsx)(i.Text,{as:"span",variant:m,children:u}),o[3]=m,o[4]=u,o[5]=a):a=o[5],o[6]!==r||o[7]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[r,a]}),o[6]=r,o[7]=a,o[8]=s):s=o[8],s}function eg(e){let a,s,o,l,c=(0,n.c)(12),{isActive:u,onSelect:d,session:m}=e,p=u?"secondary":"ghost";c[0]!==m.openedAt?(a=ef(m.openedAt),c[0]=m.openedAt,c[1]=a):a=c[1],c[2]!==a?(s=(0,t.jsx)(i.Text,{as:"span",variant:"label",children:a}),c[2]=a,c[3]=s):s=c[3];let h="open"===m.status?"default":"secondary",f="open"===m.status?"Open":"Closed";return c[4]!==h||c[5]!==f?(o=(0,t.jsx)(q.Badge,{variant:h,children:f}),c[4]=h,c[5]=f,c[6]=o):o=c[6],c[7]!==d||c[8]!==p||c[9]!==s||c[10]!==o?(l=(0,t.jsxs)(r.Button,{className:"flex-row items-center justify-between px-3 py-2",onClick:d,size:"tile",variant:p,children:[s,o]}),c[7]=d,c[8]=p,c[9]=s,c[10]=o,c[11]=l):l=c[11],l}function ev(e){let r,a,s,o,l,c,u,d,m=(0,n.c)(22),{report:p}=e;return m[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(i.Text,{as:"span",className:"pb-1",variant:"overline",children:"Cash drawer"}),m[0]=r):r=m[0],m[1]!==p.currency||m[2]!==p.openingFloatMinor?(a=(0,j.formatPriceMinor)(p.openingFloatMinor,p.currency),m[1]=p.currency,m[2]=p.openingFloatMinor,m[3]=a):a=m[3],m[4]!==a?(s=(0,t.jsx)(ex,{label:"Opening float",value:a}),m[4]=a,m[5]=s):s=m[5],m[6]!==p.currency||m[7]!==p.expectedCashMinor?(o=(0,j.formatPriceMinor)(p.expectedCashMinor,p.currency),m[6]=p.currency,m[7]=p.expectedCashMinor,m[8]=o):o=m[8],m[9]!==o?(l=(0,t.jsx)(ex,{label:"Expected in drawer",value:o}),m[9]=o,m[10]=l):l=m[10],m[11]!==p.countedCashMinor||m[12]!==p.currency?(c=void 0===p.countedCashMinor?null:(0,t.jsx)(ex,{label:"Counted",value:(0,j.formatPriceMinor)(p.countedCashMinor,p.currency)}),m[11]=p.countedCashMinor,m[12]=p.currency,m[13]=c):c=m[13],m[14]!==p.cashVarianceMinor||m[15]!==p.currency?(u=void 0===p.cashVarianceMinor?null:(0,t.jsx)(ex,{emphasis:!0,label:"Variance",value:(0,j.formatPriceMinor)(p.cashVarianceMinor,p.currency)}),m[14]=p.cashVarianceMinor,m[15]=p.currency,m[16]=u):u=m[16],m[17]!==s||m[18]!==l||m[19]!==c||m[20]!==u?(d=(0,t.jsxs)("div",{className:"flex flex-col",children:[r,s,l,c,u]}),m[17]=s,m[18]=l,m[19]=c,m[20]=u,m[21]=d):d=m[21],d}function ey(e){let r,a,s,o,l,c,u,d,m,p,h,f,g,v,y,b,S,C,M,w,k,N,_,I,T,P,R=(0,n.c)(74),{report:D}=e;R[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(i.H3,{variant:"panel",children:"Sales report"}),R[0]=r):r=R[0];let L="open"===D.status?"default":"secondary",A="open"===D.status?"Open shift":"Closed shift";R[1]!==L||R[2]!==A?(a=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[r,(0,t.jsx)(q.Badge,{variant:L,children:A})]}),R[1]=L,R[2]=A,R[3]=a):a=R[3];let O=D.cashierName,E=D.orderCount,B=1===D.orderCount?"sale":"sales";R[4]!==D.openedAt?(s=ef(D.openedAt),R[4]=D.openedAt,R[5]=s):s=R[5],R[6]!==D.cashierName||R[7]!==D.orderCount||R[8]!==B||R[9]!==s?(o=(0,t.jsxs)(i.Text,{as:"span",variant:"bodyMuted",children:[O," · ",E," ",B," ·"," ",s]}),R[6]=D.cashierName,R[7]=D.orderCount,R[8]=B,R[9]=s,R[10]=o):o=R[10],R[11]!==a||R[12]!==o?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[a,o]}),R[11]=a,R[12]=o,R[13]=l):l=R[13],R[14]!==D.currency||R[15]!==D.grossSalesMinor?(c=(0,j.formatPriceMinor)(D.grossSalesMinor,D.currency),R[14]=D.currency,R[15]=D.grossSalesMinor,R[16]=c):c=R[16],R[17]!==c?(u=(0,t.jsx)(ex,{label:"Gross sales",value:c}),R[17]=c,R[18]=u):u=R[18],R[19]!==D.currency||R[20]!==D.discountsMinor?(d=(0,j.formatPriceMinor)(D.discountsMinor,D.currency),R[19]=D.currency,R[20]=D.discountsMinor,R[21]=d):d=R[21];let $=`−${d}`;R[22]!==$?(m=(0,t.jsx)(ex,{label:"Discounts",value:$}),R[22]=$,R[23]=m):m=R[23],R[24]!==D.currency||R[25]!==D.netSalesMinor?(p=(0,j.formatPriceMinor)(D.netSalesMinor,D.currency),R[24]=D.currency,R[25]=D.netSalesMinor,R[26]=p):p=R[26],R[27]!==
1p?(h=(0,t.jsx)(ex,{label:"Net sales",value:p}),R[27]=p,R[28]=h):h=R[28],R[29]!==D.currency||R[30]!==D.taxMinor?(f=(0,j.formatPriceMinor)(D.taxMinor,D.currency),R[29]=D.currency,R[30]=D.taxMinor,R[31]=f):f=R[31],R[32]!==f?(g=(0,t.jsx)(ex,{label:"Tax",value:f}),R[32]=f,R[33]=g):g=R[33],R[34]!==D.currency||R[35]!==D.tipsMinor?(v=(0,j.formatPriceMinor)(D.tipsMinor,D.currency),R[34]=D.currency,R[35]=D.tipsMinor,R[36]=v):v=R[36],R[37]!==v?(y=(0,t.jsx)(ex,{label:"Tips",value:v}),R[37]=v,R[38]=y):y=R[38],R[39]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)(ep.Separator,{className:"my-1"}),R[39]=b):b=R[39],R[40]!==D.collectedMinor||R[41]!==D.currency?(S=(0,j.formatPriceMinor)(D.collectedMinor,D.currency),R[40]=D.collectedMinor,R[41]=D.currency,R[42]=S):S=R[42],R[43]!==S?(C=(0,t.jsx)(ex,{label:"Collected",value:S}),R[43]=S,R[44]=C):C=R[44],R[45]!==D.currency||R[46]!==D.refundsMinor?(M=(0,j.formatPriceMinor)(D.refundsMinor,D.currency),R[45]=D.currency,R[46]=D.refundsMinor,R[47]=M):M=R[47];let z=`−${M}`;return R[48]!==z?(w=(0,t.jsx)(ex,{label:"Refunds",value:z}),R[48]=z,R[49]=w):w=R[49],R[50]!==D.currency||R[51]!==D.netCollectedMinor?(k=(0,j.formatPriceMinor)(D.netCollectedMinor,D.currency),R[50]=D.currency,R[51]=D.netCollectedMinor,R[52]=k):k=R[52],R[53]!==k?(N=(0,t.jsx)(ex,{emphasis:!0,label:"Net collected",value:k}),R[53]=k,R[54]=N):N=R[54],R[55]!==u||R[56]!==m||R[57]!==h||R[58]!==g||R[59]!==y||R[60]!==C||R[61]!==w||R[62]!==N?(_=(0,t.jsxs)("div",{className:"flex flex-col",children:[u,m,h,g,y,b,C,w,N]}),R[55]=u,R[56]=m,R[57]=h,R[58]=g,R[59]=y,R[60]=C,R[61]=w,R[62]=N,R[63]=_):_=R[63],R[64]!==D.currency||R[65]!==D.tenderBreakdown?(I=D.tenderBreakdown.length>0?(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(i.Text,{as:"span",className:"pb-1",variant:"overline",children:"By tender"}),D.tenderBreakdown.map(e=>(0,t.jsx)(ex,{label:e.tipMinor>0?`${eh[e.kind]} (${e.count}) \xb7 ${(0,j.formatPriceMinor)(e.tipMinor,D.currency)} tips`:`${eh[e.kind]} (${e.count})`,value:(0,j.formatPriceMinor)(e.capturedMinor,D.currency)},e.kind))]}):null,R[64]=D.currency,R[65]=D.tenderBreakdown,R[66]=I):I=R[66],R[67]!==D?(T=(0,t.jsx)(ev,{report:D}),R[67]=D,R[68]=T):T=R[68],R[69]!==l||R[70]!==_||R[71]!==I||R[72]!==T?(P=(0,t.jsx)(x.ScrollArea,{className:"min-h-0 flex-1",classNameViewport:"px-6 py-4",children:(0,t.jsxs)("div",{className:"mx-auto flex w-full max-w-lg flex-col gap-5",children:[l,_,I,T]})}),R[69]=l,R[70]=_,R[71]=I,R[72]=T,R[73]=P):P=R[73],P}function ej(e){let r,a,i,s,o,l,c,u=(0,n.c)(4),{sessionId:d}=e,{report:m,isLoading:p}=((s=(0,n.c)(5))[0]!==d?(a=d?{sessionId:d}:"skip",s[0]=d,s[1]=a):a=s[1],l=(o=(0,S.useQuery)(b.api.commerce.pos.reporting.getSessionSalesReport,a))??null,c=null!==d&&void 0===o,s[2]!==l||s[3]!==c?(i={report:l,isLoading:c},s[2]=l,s[3]=c,s[4]=i):i=s[4],i);if(p){let e;return u[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(em.PanelSkeleton,{className:"flex-1"}),u[0]=e):e=u[0],e}if(!m){let e;return u[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ed.Empty,{children:(0,t.jsxs)(ed.EmptyHeader,{children:[(0,t.jsx)(ed.EmptyTitle,{children:"Select a shift"}),(0,t.jsx)(ed.EmptyDescription,{children:"Pick a register shift to see its sales report."})]})}),u[1]=e):e=u[1],e}return u[2]!==m?(r=(0,t.jsx)(ey,{report:m}),u[2]=m,u[3]=r):r=u[3],r}e.s(["PosReportsView",0,function(){let e,r,a,i,s,o,l,c,u,d,m,p=(0,n.c)(14),{sessions:h,isLoading:f}=(c=(0,n.c)(7),u=ei(),c[0]!==u?(s=es(u,{paginationOpts:{cursor:null,numItems:25}}),c[0]=u,c[1]=s):s=c[1],d=(0,S.useQuery)(b.api.commerce.pos.queries.listRegisterSessions,s),c[2]!==d?.page?(o=d?.page??[],c[2]=d?.page,c[3]=o):o=c[3],m=void 0===d,c[4]!==o||c[5]!==m?(l={sessions:o,isLoading:m},c[4]=o,c[5]=m,c[6]=l):l=c[6],l),[g,v]=(0,X.useState)(null),y=g??h[0]?._id??null;if(f){let e;return p[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(em.PanelSkeleton,{className:"flex-1"}),p[0]=e):e=p[0],e}if(0===h.length){let e;return p[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ed.Empty,{children:(0,t.jsxs)(ed.EmptyHeader,{children:[(0,t.jsx)(ed.EmptyTitle,{children:"No shifts yet"}),(0,t.jsx)(ed.EmptyDescription,{children:"Open the register and ring a sale. The day's takings show up here."})]})}),p[1]=e):e=p[1],e}if(p[2]!==y||p[3]!==h){let n;p[5]!==y?(n=e=>(0,t.jsx)(eg,{isActive:e._id===y,onSelect:()=>v(e._id),session:e},e._id),p[5]=y,p[6]=n):n=p[6],e=h.map(n),p[2]=y,p[3]=h,p[4]=e}else e=p[4];return p[7]!==e?(r=(0,t.jsx)(x.ScrollArea,{className:"w-72 shrink-0 border-r",classNameViewport:"p-2",children:(0,t.jsx)("div",{className:"flex flex-col gap-1",children:e})}),p[7]=e,p[8]=r):r=p[8],p[9]!==y?(a=(0,t.jsx)(ej,{sessionId:y}),p[9]=y,p[10]=a):a=p[10],p[11]!==r||p[12]!==a?(i=(0,t.jsxs)("div",{className:"flex min-h-0 flex-1",children:[r,a]}),p[11]=r,p[12]=a,p[13]=i):i=p[13],i}],760550);var eb=e.i(271944),eS=e.i(153229);function eC(e){return{lineTotalMinor:(0,C.computeLineTotalMinor)(e),modifiers:e.modifiers.map(e=>e.name),name:T(e.name),quantity:e.quantity,ref:e.lineId,variantLabel:e.variantLabel}}function eM(){return K.toast.error("Couldn't copy the link.")}function ew(){return K.toast.success("Link copied.")}function ek(){K.toast.error("Couldn't get this screen's link.")}e.s(["PosKioskLinkDialog",0,function(e){let a,s,o,l,c,u,d,p,h,f,x,g,v=(0,n.c)(26),{locationId:y,onOpenChange:j,onPresentInWindow:C,open:M}=e,w=(0,m.usePortalContainer)();v[0]!==y?(a={locationId:y},v[0]=y,v[1]=a):a=v[1];let{isPending:k,path:N,reveal:_}=function(e){let t=(0,S.useMutation)(b.api.commerce.pos.counter_display.getLink),n=ei(),[r,a]=(0,
1X.useState)(null),[i,s]=(0,X.useState)(!1),o=async()=>{if(e.locationId&&!i&&"skip"!==n){s(!0);try{let{token:r}=await t({...n,locationId:e.locationId});a(`/pos/customer?t=${r}`)}finally{s(!1)}}};return{isPending:i,path:r,reveal:o}}(a);v[2]!==k||v[3]!==M||v[4]!==N||v[5]!==_?(s=function(){!M||N||k||_().catch(ek)},o=[k,M,N,_],v[2]=k,v[3]=M,v[4]=N,v[5]=_,v[6]=s,v[7]=o):(s=v[6],o=v[7]),(0,X.useEffect)(s,o);let I=N&&1?`${window.location.origin}${N}`:null;return v[8]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsxs)(V.DialogHeader,{children:[(0,t.jsx)(V.DialogTitle,{children:"Customer view"}),(0,t.jsx)(V.DialogDescription,{children:"Show the order as it's rung. On this screen, or on a second one facing the customer."})]}),v[8]=l):l=v[8],v[9]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(eS.Monitor,{}),v[9]=c):c=v[9],v[10]!==C?(u=(0,t.jsxs)(r.Button,{className:"w-full",onClick:C,size:"panelPrimary",children:[c,"Show on this screen"]}),v[10]=C,v[11]=u):u=v[11],v[12]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Second screen"}),p=(0,t.jsx)(i.Text,{variant:"bodySmall",children:"Open this on the other device and add it to its home screen. It shows the order and nothing else. There's no way back into the register from it."}),v[12]=d,v[13]=p):(d=v[12],p=v[13]),v[14]!==I?(h=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[d,p,I?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(U.Input,{className:"flex-1",readOnly:!0,value:I}),(0,t.jsx)(r.Button,{onClick:()=>{navigator.clipboard.writeText(I).then(ew).catch(eM)},size:"icon",variant:"surface",children:(0,t.jsx)(eb.Copy,{})})]}):(0,t.jsx)("div",{className:"flex h-10 items-center"})]}),v[14]=I,v[15]=h):h=v[15],v[16]!==u||v[17]!==h?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-4 py-2",children:[u,h]}),v[16]=u,v[17]=h,v[18]=f):f=v[18],v[19]!==w||v[20]!==f?(x=(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[520px]",container:w,children:[l,f]}),v[19]=w,v[20]=f,v[21]=x):x=v[21],v[22]!==j||v[23]!==M||v[24]!==x?(g=(0,t.jsx)(V.Dialog,{onOpenChange:j,open:M,children:x}),v[22]=j,v[23]=M,v[24]=x,v[25]=g):g=v[25],g}],623482);var eN=e.i(170387),e_=e.i(972023),eI=e.i(840220);function eT(e){let t,r,a,i=(0,n.c)(6),s=(0,S.useAction)(b.api.commerce.pos.stripe.reader_splash.applyReaderSplash),o=(0,X.useRef)(!1),{isReaderOnline:l,owner:c}=e;i[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,eN.stripeCheckoutIsLiveMode)(),i[0]=t):t=i[0];let u=t;i[1]!==s||i[2]!==l||i[3]!==c?(r=function(){c&&l&&u&&!o.current&&(o.current=!0,s({owner:c}).catch(eP))},a=[s,u,l,c],i[1]=s,i[2]=l,i[3]=c,i[4]=r,i[5]=a):(r=i[4],a=i[5]),(0,X.useEffect)(r,a)}function eP(e){console.error("POS reader splash did not apply:",e)}function eR(e){let t,r,a,i,s,o=(0,n.c)(17),l=(0,S.useAction)(b.api.commerce.payments.stripe.readers.createTerminalLocation),c=(0,S.useAction)(b.api.commerce.payments.stripe.readers.listTerminalLocations),u=(0,S.useAction)(b.api.commerce.payments.stripe.readers.listTerminalReaders),d=(0,S.useAction)(b.api.commerce.payments.stripe.readers.registerTerminalReader);o[0]!==l||o[1]!==e?(t=t=>l({owner:e,...t}),o[0]=l,o[1]=e,o[2]=t):t=o[2];let m=t;o[3]!==c||o[4]!==e?(r=()=>c({owner:e}),o[3]=c,o[4]=e,o[5]=r):r=o[5];let p=r;o[6]!==u||o[7]!==e?(a=()=>u({owner:e}),o[6]=u,o[7]=e,o[8]=a):a=o[8];let h=a;o[9]!==e||o[10]!==d?(i=t=>d({owner:e,...t}),o[9]=e,o[10]=d,o[11]=i):i=o[11];let f=i;return o[12]!==m||o[13]!==p||o[14]!==h||o[15]!==f?(s={createLocation:m,listLocations:p,listReaders:h,registerReader:f},o[12]=m,o[13]=p,o[14]=h,o[15]=f,o[16]=s):s=o[16],s}var eD=e.i(781243);function eL(e){let t,r,a,i=(0,n.c)(9);i[0]!==e?(t=e?{owner:e}:"skip",i[0]=e,i[1]=t):t=i[1];let s=(0,S.useQuery)(b.api.commerce.settings.settings.getShopSettings,t),o=(0,S.useMutation)(b.api.commerce.settings.settings.setCartSettings);i[2]!==e||i[3]!==o?(r=async t=>{e&&await o({owner:e,cart:{askRewardsOnReader:t}})},i[2]=e,i[3]=o,i[4]=r):r=i[4];let l=r,c=s?.cart.askRewardsOnReader??!1,u=null!==e&&void 0===s;return i[5]!==l||i[6]!==c||i[7]!==u?(a={isEnabled:c,isLoading:u,save:l},i[5]=l,i[6]=c,i[7]=u,i[8]=a):a=i[8],a}function eA({owner:e}
1){let n=eL(e),[r,a]=(0,X.useState)(!1),s=async e=>{a(!0);try{await n.save(e),K.toast.success(e?"The reader will ask about rewards.":"The reader won't ask about rewards.")}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't save the rewards setting.")}finally{a(!1)}};return(0,t.jsx)("div",{className:"flex flex-col gap-4 border-t pt-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsx)(H.Label,{children:"Ask about rewards on the reader"}),(0,t.jsx)(i.Text,{variant:"caption",children:"Before the tip and the tap, the customer can join with their phone number: or skip it in one tap. Skipping never holds up the payment."})]}),(0,t.jsx)(eD.Switch,{checked:n.isEnabled,disabled:n.isLoading||r,onCheckedChange:s})]})})}var eO=e.i(243980);function eE({owner:e}){let r,a,s,o,l,c,u,d,m,p,h,f,x,g=((l=(0,n.c)(14))[0]!==e?(r=e?{owner:e}:"skip",l[0]=e,l[1]=r):r=l[1],c=(0,S.useQuery)(b.api.commerce.pos.reader_splash.getReaderSplashSettings,r),u=(0,S.useMutation)(b.api.commerce.settings.settings.setPosSplashSettings),d=(0,S.useAction)(b.api.commerce.pos.stripe.reader_splash.applyReaderSplash),l[2]!==e||l[3]!==u?(a=async t=>{e&&await u({owner:e,splash:{enabled:t}})},l[2]=e,l[3]=u,l[4]=a):a=l[4],m=a,l[5]!==d||l[6]!==e?(s=async()=>e?await d({owner:e}):{kind:"unchanged"},l[5]=d,l[6]=e,l[7]=s):s=l[7],p=s,h=c?.brand??null,f=c?.enabled??!1,x=null!==e&&void 0===c,l[8]!==p||l[9]!==m||l[10]!==h||l[11]!==f||l[12]!==x?(o={apply:p,brand:h,isEnabled:f,isLoading:x,save:m},l[8]=p,l[9]=m,l[10]=h,l[11]=f,l[12]=x,l[13]=o):o=l[13],o),[v,y]=(0,X.useState)(!1),[j,C]=(0,X.useState)(null),M=async e=>{y(!0),C(null);try{await g.save(e);let t=function(e){let{result:t}=e;switch(t.kind){case"applied":return{kind:"ok",message:t.locations>1?`Your brand is on the readers at ${t.locations} locations.`:"Your brand is on the reader between sales."};case"cleared":return{kind:"ok",message:"The reader is back to Stripe's screen."};case"unchanged":return{kind:"ok",message:e.enabled?"The reader already shows your brand.":"The reader is showing Stripe's screen."};case"no_locations":return{kind:"problem",message:"Pair a reader first. This shop has no reader location for the splash to go to."};case"failed":return{kind:"problem",message:t.message};default:return t}}({enabled:e,result:await g.apply()});if("problem"===t.kind)return void C(t.message);K.toast.success(t.message)}catch(e){C(e instanceof Error?e.message:"Couldn't set the reader's screen.")}finally{y(!1)}};return(0,t.jsxs)("div",{className:"flex flex-col gap-4 border-t pt-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsx)(H.Label,{children:"Show your brand on the reader"}),(0,t.jsx)(i.Text,{variant:"caption",children:"On by default. Between sales the reader shows your mark on your colour instead of Stripe's screen, and The Cloud's mark until you upload your own. Change your logo or colour and it follows."})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(eB,{brand:g.brand}),(0,t.jsx)(eD.Switch,{checked:g.isEnabled,disabled:g.isLoading||v,onCheckedChange:M})]})]}),j?(0,t.jsx)(e_.Alert,{variant:"destructive",children:(0,t.jsx)(e_.AlertDescription,{children:j})}):null]})}function eB(e){let r,a,i,s=(0,n.c)(9),{brand:o}=e;if(!o){let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"h-14 w-8 rounded-sm bg-muted"}),s[0]=e):e=s[0],e}return s[1]!==o.color?(r={backgroundColor:o.color},s[1]=o.color,s[2]=r):r=s[2],s[3]!==o.logoUrl||s[4]!==o.name?(a=o.logoUrl?(0,t.jsx)("img",{alt:o.name,className:"object-contain",height:20,src:o.logoUrl,width:20}):(0,t.jsx)(eO.CloudMark,{className:"size-5",decorative:!0}),s[3]=o.logoUrl,s[4]=o.name,s[5]=a):a=s[5],s[6]!==r||s[7]!==a?(i=(0,t.jsx)("div",{className:"flex h-14 w-8 items-center justify-center rounded-sm border border-border",style:r,children:a}),s[6]=r,s[7]=a,s[8]=i):i=s[8],i}let e$={allowCustom:!1,enabled:!1,presetBps:[]};function ez(e){let t,r,a,i=(0,n.c)(9);i[0]!==e?(t=e?{owner:e}:"skip",i[0]=e,i[1]=t):t=i[1];let s=(0,S.useQuery)(b.api.commerce.settings.settings.getShopSett
1ings,t),o=(0,S.useMutation)(b.api.commerce.settings.settings.setPosTippingSettings);i[2]!==e||i[3]!==o?(r=async t=>{e&&await o({owner:e,tipping:t})},i[2]=e,i[3]=o,i[4]=r):r=i[4];let l=r,c=null!==e&&void 0===s,u=s?.pos.tipping??e$;return i[5]!==l||i[6]!==c||i[7]!==u?(a={isLoading:c,save:l,settings:u},i[5]=l,i[6]=c,i[7]=u,i[8]=a):a=i[8],a}let eF=["first","second","third"];function eq({owner:e}){let n=ez(e),{allowCustom:a,enabled:s,presetBps:o}=n.settings,[l,c]=(0,X.useState)(null),[u,d]=(0,X.useState)(!1),m=l??o.map(e=>String(e/100)),p=async(e,t)=>{d(!0);try{await n.save(e),K.toast.success(t)}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't save the tipping settings.")}finally{d(!1)}},h=async()=>{let e=m.map(e=>Math.round(100*Number(e))).filter(e=>Number.isFinite(e)&&e>0);0===e.length?K.toast.error("Enter at least one tip percentage."):(await p({presetBps:e},"Tip amounts saved."),c(null))};return(0,t.jsxs)("div",{className:"flex flex-col gap-4 border-t pt-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsx)(H.Label,{children:"Ask for a tip on the reader"}),(0,t.jsx)(i.Text,{variant:"caption",children:"The customer picks a tip on their own screen before paying."})]}),(0,t.jsx)(eD.Switch,{checked:s,disabled:n.isLoading||u,onCheckedChange:e=>p({enabled:e},e?"Tipping is on.":"Tipping is off.")})]}),s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(H.Label,{children:"Suggested amounts"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[eF.map((e,n)=>(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(U.Input,{"aria-label":`Tip percentage ${n+1}`,className:"w-16",inputMode:"decimal",onChange:e=>{var t;let r;return t=e.target.value,void((r=[...m])[n]=t,c(r))},value:m[n]??""}),(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:"%"})]},e)),(0,t.jsx)(r.Button,{className:"ml-auto",disabled:u||null===l,onClick:h,children:"Save"})]}),(0,t.jsx)(i.Text,{variant:"caption",children:"Figured on the sale before tax. The reader shows up to three."})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsx)(H.Label,{children:"Let the customer enter their own amount"}),(0,t.jsx)(eD.Switch,{checked:a,disabled:u,onCheckedChange:e=>p({allowCustom:e},e?"Custom amounts are on.":"Custom amounts are off.")})]})]}):null]})}var eV=e.i(504710);function eU(){let e,t,r,a=(0,n.c)(8),i=ei(),s=(0,S.useQuery)(b.api.commerce.locations.queries.listRegisterLocations,i);a[0]!==s?.locations?(e=s?.locations??[],a[0]=s?.locations,a[1]=e):e=a[1],a[2]!==s?.pickupLocations?(t=s?.pickupLocations??[],a[2]=s?.pickupLocations,a[3]=t):t=a[3];let o=void 0===s;return a[4]!==e||a[5]!==t||a[6]!==o?(r={locations:e,pickupLocations:t,isLoading:o},a[4]=e,a[5]=t,a[6]=o,a[7]=r):r=a[7],r}function eH(e){return void 0!==e&&""!==e.trim()}e.s(["usePosLocations",0,eU],223663);let eG={city:"",country:"US",line1:"",postalCode:"",state:""};function eQ({onCreated:e,owner:n}){let{createLocation:a}=eR(n),[i,s]=(0,X.useState)(""),[o,l]=(0,X.useState)(eG),[c,u]=(0,X.useState)(!1),d=""!==i.trim()&&""!==o.line1.trim()&&""!==o.city.trim()&&""!==o.postalCode.trim()&&""!==o.country.trim()&&!c,m=(e,t)=>l(n=>({...n,[e]:t})),p=async t=>{if(t.preventDefault(),d){u(!0);try{let t={city:o.city.trim(),country:o.country.trim(),line1:o.line1.trim(),postalCode:o.postalCode.trim(),state:o.state.trim()||void 0};await a({address:t,displayName:i.trim()}),await e(),K.toast.success("Location added: now pair your reader to it.")}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't add the location.")}finally{u(!1)}}};return(0,t.jsxs)("form",{className:"flex flex-col gap-3",onSubmit:p,children:[(0,t.jsx)(U.Input,{"aria-label":"Location name",onChange:e=>s(e.target.value),placeholder:"Location name (e.g. Front counter)",value:i}),(0,t.jsx)(U.Input,{"aria-label":"Street address",onChange:e=>m("line1",e.target.value),placeholder:"Street address",value:o.line1}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(U.Input,{"aria-label":"City",onChange:e=>m("city",e.target.value),placeholder:"City",value:o.city}),(0,t.jsx)(U.Input,{"aria-label":"State",className:"w-24",onChange:e=>m("state",e.target.value),placeholder:"State",value:o.state})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(U.Input,{"aria-label":"Postal code",onChange:e=>m("postalCode",e.target.value),placeholder:"ZIP",value:o.postalCode}),(0,t.jsx)(U.Input,{"aria-label":"Country",className:"w-24",onChange:e=>m("country",e.target.value),placeholder:"US",value:o.country})]}),(0,t.jsx)(r.Button,{className:"self-start",disabled:!d,type:"submit",children:"Add location"})]})}function eW({onCreated:e,owner:n}){let{createLocation:a}=eR(n),{isLoading:s,locations:o}=eU(),[l,c]=(0,X.useState)(null),[u,d]=(0,X.useState)(!1),m=o.map(e=>
1(function(e){let t,n=e.addressLine1?.trim(),r=e.city?.trim(),a=e.postalCode?.trim(),i=e.country?.trim(),s=e.name.trim();if(!(eH(n)&&eH(r)&&eH(a)&&eH(i)&&eH(s)))return null;let o=e.addressLine2?.trim(),l=e.region?.trim();return{address:{city:r,country:i,line1:n,line2:eH(o)?o:void 0,postalCode:a,state:eH(l)?l:void 0},displayName:s,label:eH(t=e.region?.trim())?`${e.name} — ${r}, ${t}`:`${e.name} — ${r}`}})(e)).filter(e=>null!==e),p=async t=>{c(t.label);try{await a({address:t.address,displayName:t.displayName}),await e(),K.toast.success(`${t.displayName} is ready. Now pair your reader.`)}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't add the location.")}finally{c(null)}};return(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t pt-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)(H.Label,{children:"Where does this reader sit?"}),(0,t.jsx)(i.Text,{variant:"caption",children:"A reader registers to a location, and the card networks require a street address for anywhere a card is tapped."})]}),s?(0,t.jsx)("div",{className:"flex justify-center py-4"}):(0,t.jsx)(eX,{offers:m,onUse:p,pendingLabel:l}),m.length>0&&!u?(0,t.jsx)(r.Button,{className:"self-start",onClick:()=>d(!0),variant:"link-muted",children:"Somewhere else: type the address"}):null,u||0===m.length&&!s?(0,t.jsx)(eQ,{onCreated:e,owner:n}):null]})}function eX(e){let a,s,o=(0,n.c)(9),{offers:l,onUse:c,pendingLabel:u}=e;if(0===l.length)return null;if(o[0]!==l||o[1]!==c||o[2]!==u){let e;o[4]!==c||o[5]!==u?(e=e=>(0,t.jsxs)(r.Button,{className:"h-auto w-full justify-start gap-2 px-3.5 py-3",disabled:null!==u,onClick:()=>c(e),variant:"surface",children:[(0,t.jsx)(eV.MapPin,{}),(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"label",children:`Use ${e.label}`})]},e.label),o[4]=c,o[5]=u,o[6]=e):e=o[6],a=l.map(e),o[0]=l,o[1]=c,o[2]=u,o[3]=a}else a=o[3];return o[7]!==a?(s=(0,t.jsx)("div",{className:"flex flex-col gap-2",children:a}),o[7]=a,o[8]=s):s=o[8],s}var eK=e.i(708737);let eZ=/^[a-z]+(-[a-z]+){1,3}$/,eJ=/^sn[\s:-]/i,eY=/\d/;function e0({locations:e,onDone:n,onRegistered:r,owner:a}){var s;let o,l,{registerReader:c}=eR(a),u=(0,p.useSetSelectedReaderId)(),[d,m]=(0,X.useState)(""),[h,f]=(0,X.useState)(""),[x,g]=(0,X.useState)(e[0]?.id??null),[v,y]=(0,X.useState)(!1),j="problem"===(l=""===(o=(s={locationId:x,pairingCode:d}).pairingCode.trim().toLowerCase())?{kind:"problem",problem:"empty"}:eJ.test(o)||eY.test(o)?{kind:"problem",problem:"serial_number"}:eZ.test(o)?{kind:"ok",code:o}:{kind:"problem",problem:"malformed"}).kind?{kind:"blocked",reason:function(e){switch(e){case"empty":return"Enter the pairing code shown on the reader's screen.";case"serial_number":return"That looks like the serial number. On the reader, open Settings → Generate pairing code — it's three words, no numbers.";case"malformed":return"A pairing code is words joined by hyphens, like quick-brown-fox.";default:return e}}(l.problem),tone:"empty"===l.problem?"hint":"error"}:null===s.locationId?{kind:"blocked",reason:"Choose which location this reader sits at.",tone:"hint"}:{kind:"ready"},b="ready"===j.kind&&!v,S=async e=>{if(e.preventDefault(),b&&null!==x){y(!0);try{let e=await c({registrationCode:d,locationId:x,label:h.trim()||void 0});u(e.id),await r(),K.toast.success("Reader paired. You can take card payments now."),n()}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't pair the reader.")}finally{y(!1)}}};return(0,t.jsxs)("form",{className:"flex flex-col gap-3 border-t pt-4",onSubmit:S,children:[(0,t.jsx)(H.Label,{children:"Pair a new reader"}),e.length>1?(0,t.jsxs)(eK.Select,{items:e.map(e=>({label:e.displayName??e.id,value:e.id})),onValueChange:e=>null!==e&&g(e),value:x??void 0,children:[(0,t.jsx)(eK.SelectTrigger,{children:(0,t.jsx)(eK.SelectValue,{placeholder:"Location"})}),(0,t.jsx)(eK.SelectContent,{children:e.map(e=>(0,t.jsx)(eK.SelectItem,{value:e.id,children:e.displayName??e.id},e.id))})]}):null,(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(U.Input,{"aria-describedby":"pos-pairing-code-help","aria-invalid":"blocked"===j.kind&&"error"===j.tone,"aria-label":"Pairing code",autoCapitalize:"none",autoCorrect:"off",onChange:e=>
1m(e.target.value),placeholder:"e.g. quick-brown-fox",spellCheck:!1,value:d}),(0,t.jsx)(i.Text,{id:"pos-pairing-code-help",variant:"caption",children:"On the reader: Settings → Generate pairing code. It's three words, not the serial number (SN:…) printed on the device."})]}),(0,t.jsx)(U.Input,{"aria-label":"Reader name",onChange:e=>f(e.target.value),placeholder:"Reader name (optional)",value:h}),(0,t.jsx)(e1,{gate:j,isPending:v})]})}function e1(e){let a,s,o,l=(0,n.c)(9),{gate:c,isPending:u}=e,d="blocked"===c.kind||u;return l[0]!==d?(a=(0,t.jsx)(r.Button,{className:"self-start",disabled:d,type:"submit",children:"Pair reader"}),l[0]=d,l[1]=a):a=l[1],l[2]!==c.kind||l[3]!==c.reason||l[4]!==c.tone?(s="blocked"===c.kind?(0,t.jsx)(i.Text,{"aria-live":"polite",className:"error"===c.tone?"text-destructive":void 0,variant:"caption",children:c.reason}):null,l[2]=c.kind,l[3]=c.reason,l[4]=c.tone,l[5]=s):s=l[5],l[6]!==a||l[7]!==s?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[a,s]}),l[6]=a,l[7]=s,l[8]=o):o=l[8],o}function e2(e){let a,s,o,l,c,u=(0,n.c)(12),{isRefreshing:d,onRefresh:m,readers:h}=e,f=(0,p.useSelectedReaderId)(),x=(0,p.useSetSelectedReaderId)();return u[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(H.Label,{children:"Readers on this shop's Stripe"}),u[0]=a):a=u[0],u[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(eI.RefreshCw,{}),u[1]=s):s=u[1],u[2]!==d||u[3]!==m?(o=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[a,(0,t.jsxs)(r.Button,{disabled:d,onClick:m,variant:"ghost",children:[s,"Rescan"]})]}),u[2]=d,u[3]=m,u[4]=o):o=u[4],u[5]!==h||u[6]!==f||u[7]!==x?(l=0===h.length?(0,t.jsx)(i.Muted,{children:"Stripe has no readers registered for this shop yet. Pair one below and it will appear here. On every station, not just this one."}):(0,t.jsx)("div",{className:"flex flex-col gap-2",children:h.map(e=>(0,t.jsx)(e3,{isSelected:e.id===f,onSelect:()=>x(e.id),reader:e},e.id))}),u[5]=h,u[6]=f,u[7]=x,u[8]=l):l=u[8],u[9]!==o||u[10]!==l?(c=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[o,l]}),u[9]=o,u[10]=l,u[11]=c):c=u[11],c}function e3(e){let a,s,o,l,c,u,d,m=(0,n.c)(21),{isSelected:p,onSelect:h,reader:f}=e,x=p?"selected":"surface",v=f.label??f.id;m[0]!==v?(a=(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"label",children:v}),m[0]=v,m[1]=a):a=m[1];let y=p?"This register uses this reader":f.deviceType??"Tap to use this reader";m[2]!==y?(s=(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"caption",children:y}),m[2]=y,m[3]=s):s=m[3],m[4]!==a||m[5]!==s?(o=(0,t.jsxs)("span",{className:"flex min-w-0 flex-col items-start",children:[a,s]}),m[4]=a,m[5]=s,m[6]=o):o=m[6];let j="online"===f.status?"secondary":"outline",b=f.status??"unknown";return m[7]!==j||m[8]!==b?(l=(0,t.jsx)(q.Badge,{variant:j,children:b}),m[7]=j,m[8]=b,m[9]=l):l=m[9],m[10]!==p?(c=p?(0,t.jsx)(g.Check,{}):null,m[10]=p,m[11]=c):c=m[11],m[12]!==c||m[13]!==l?(u=(0,t.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[l,c]}),m[12]=c,m[13]=l,m[14]=u):u=m[14],m[15]!==p||m[16]!==h||m[17]!==x||m[18]!==u||m[19]!==o?(d=(0,t.jsxs)(r.Button,{"aria-pressed":p,className:"flex-row items-center justify-between gap-3 px-3.5 py-3",onClick:h,size:"tile",variant:x,children:[o,u]}),m[15]=p,m[16]=h,m[17]=x,m[18]=u,m[19]=o,m[20]=d):d=m[20],d}function e4(){let e,r=(0,n.c)(1);return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(e_.Alert,{children:(0,t.jsx)(e_.AlertDescription,{children:"This register is in test mode. Card payments run against a simulated reader, so you can practice the full sale, collect, process, capture, without any hardware. Pairing a physical reader becomes available once the shop is switched to live card payments."})}),r[0]=e):e=r[0],e}function e5({onDone:e,owner:n}){let{listLocations:a,listReaders:i}=eR(n),[s,o]=(0,X.useState)(null),[l,c]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[m,p]=(0,X.useState)(!0),h=(0,X.useCallback)(async()=>{p(!0),d(null);try{let[e,t]=await Promise.all([a(),i()]);o(e),c(t)}catch(e){d(e instanceof Error?e.message:"Couldn't load readers for this shop.")}finally{p(!1)}},[a,i]);return((0,X.useEffect)(function(){h()}
1,[h]),eT({isReaderOnline:(l?.length??0)>0,owner:n}),m&&null===l)?(0,t.jsx)("div",{className:"flex items-center justify-center py-10"}):u?(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsx)(e_.Alert,{variant:"destructive",children:(0,t.jsx)(e_.AlertDescription,{children:u})}),(0,t.jsxs)(r.Button,{className:"self-start",onClick:h,variant:"surface",children:[(0,t.jsx)(eI.RefreshCw,{className:"mr-2 h-4 w-4"}),"Try again"]})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,t.jsx)(e2,{isRefreshing:m,onRefresh:h,readers:l??[]}),(0,t.jsx)(e6,{locations:s??[],onDone:e,onRegistered:h,owner:n})]})}function e6(e){let r,a=(0,n.c)(8),{locations:i,onDone:s,onRegistered:o,owner:l}=e;if(0===i.length){let e;return a[0]!==o||a[1]!==l?(e=(0,t.jsx)(eW,{onCreated:o,owner:l}),a[0]=o,a[1]=l,a[2]=e):e=a[2],e}return a[3]!==i||a[4]!==s||a[5]!==o||a[6]!==l?(r=(0,t.jsx)(e0,{locations:i,onDone:s,onRegistered:o,owner:l}),a[3]=i,a[4]=s,a[5]=o,a[6]=l,a[7]=r):r=a[7],r}e.s(["PosReaderSettings",0,function(e){let r,a,i,s,o,l,c,u,d,p=(0,n.c)(20),{onOpenChange:h,open:f,owner:x}=e,g=(0,m.usePortalContainer)();p[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,eN.stripeCheckoutIsLiveMode)(),p[0]=r):r=p[0];let v=r;return p[1]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(V.DialogTitle,{children:"Card reader"}),p[1]=a):a=p[1],p[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxs)(V.DialogHeader,{children:[a,(0,t.jsx)(V.DialogDescription,{children:v?"Pair a Stripe reader to take card payments at the counter.":"Test mode uses a simulated reader — no pairing needed."})]}),p[2]=i):i=p[2],p[3]!==h||p[4]!==x?(s=v?(0,t.jsx)(e5,{onDone:()=>h(!1),owner:x}):(0,t.jsx)(e4,{}),p[3]=h,p[4]=x,p[5]=s):s=p[5],p[6]!==x?(o=(0,t.jsx)(eE,{owner:x}),l=(0,t.jsx)(eA,{owner:x}),c=(0,t.jsx)(eq,{owner:x}),p[6]=x,p[7]=o,p[8]=l,p[9]=c):(o=p[7],l=p[8],c=p[9]),p[10]!==g||p[11]!==s||p[12]!==o||p[13]!==l||p[14]!==c?(u=(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[460px]",container:g,children:[i,s,o,l,c]}),p[10]=g,p[11]=s,p[12]=o,p[13]=l,p[14]=c,p[15]=u):u=p[15],p[16]!==h||p[17]!==f||p[18]!==u?(d=(0,t.jsx)(V.Dialog,{onOpenChange:h,open:f,children:u}),p[16]=h,p[17]=f,p[18]=u,p[19]=d):d=p[19],d}],989891);var e7=e.i(259199),e8=e.i(484660),e9=e.i(742828),te=e.i(127234);function tt(e){let a,s,o,l,c,u,d,p,h,f,x,g,v,y=(0,n.c)(31),{amountMinor:b,children:S,currency:C,itemCount:M,onOpenChange:w,open:k}=e,N=(0,m.usePortalContainer)(),_=`Open the current sale. ${1===M?"1 item":`${M} items`}`;return y[0]!==w?(a=()=>w(!0),y[0]=w,y[1]=a):a=y[1],y[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(te.ShoppingBag,{}),y[2]=s):s=y[2],y[3]!==M?(o=M>0?(0,t.jsx)(q.Badge,{className:"absolute -top-2 -right-2",size:"sm",variant:"secondary",children:M}):null,y[3]=M,y[4]=o):o=y[4],y[5]!==o?(l=(0,t.jsxs)("span",{className:"flex items-center gap-3",children:[(0,t.jsxs)("span",{className:"relative flex items-center",children:[s,o]}),"Current sale"]}),y[5]=o,y[6]=l):l=y[6],y[7]!==b||y[8]!==C?(c=(0,j.formatPriceMinor)(b,C),y[7]=b,y[8]=C,y[9]=c):c=y[9],y[10]!==c?(u=(0,t.jsx)(i.Text,{as:"span",variant:"labelBold",children:c}),y[10]=c,y[11]=u):u=y[11],y[12]!==_||y[13]!==a||y[14]!==l||y[15]!==u?(d=(0,t.jsx)("div",{className:"pointer-events-none fixed inset-x-0 bottom-0 z-[10000] flex justify-center px-4 pb-[calc(0.75rem+env(safe-area-inset-bottom))]",children:(0,t.jsxs)(r.Button,{"aria-label":_,className:"pointer-events-auto h-14 w-full max-w-md flex-row justify-between gap-3 shadow-lg",onClick:a,size:"tile",children:[l,u]})}),y[12]=_,y[13]=a,y[14]=l,y[15]=u,y[16]=d):d=y[16],y[17]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(e9.DrawerTitle,{className:"sr-only",children:"Current sale"}),p=(0,t.jsx)(e9.DrawerDescription,{className:"sr-only",children:"Review the sale, adjust quantities, and take payment."}),y[17]=p,y[18]=h):(p=y[17],h=y[18]),y[19]!==S?(f=(0,t.jsx)("div",{className:"flex h-[75svh] flex-col",children:S}),y[19]=S,y[20]=f):f=y[20],y[21]!==N||y[22]!==f?(x=(0,t.jsxs)(e9.DrawerPopup,{container:N,children:[h,p,f]}),y[21]=N,y[22]=f,y[23]=x):x=y[23],y[24]!==w||y[25]!==k||y[26]!==x?(g=(0,t.jsx)(e9.Drawer,{onOpenChange:w,open:k,children:x}),y[24]=w,y[25]=k,y[26]=x,y[27]=g):g=y[27],y[28]!==g||y[29]!==d?(v=(0,t.jsxs)(t.Fragment,{children:[d,g]}),y[28]=g,y[29]=d,y[30]=v):v=y[30],v}var tn=e.i(890191),tr=e.i(816295),ta=e.i(459333),ti=e.i(700644);function ts(e){let r,a,s,o=(0,n.c)(7),{amount:l,label:c}=e;return o[0]!==c?(r=(0,t.jsx)(i.Text,{as:"span",className:"wrap-anywhere min-w-0 flex-1",variant:"caption",children:c}),o[0]=c,o[1]=r):r=o[1],o[2]!==l?(a=l?(0,t.jsx)(i.Text,{as:"span",className:"min-w-20 shrink-0 text-right tabular-nums",variant:"caption",children:l}):null,o[2]=l,o[3]=a):a=o[3],o[4]!==r||o[5]!==a?(s=(0,t.jsxs)("div",{className:"flex items-baseline gap-3",children:[r,a]}),o[4]=r,o[5]=a,o[6]=s):s=o[6],s}function to(e){let r,a=(0,n.c)(13),{line:i}=e;if(a[0]!==i.currency||a[1]!==i.modifiers||a[2]!==i.unitPriceMinor||a[3]!==i.variantLabel){let e,n,s,o=(0,tn.itemizeLine)({selections:i.modifiers.map(tl)});a[5]!==i.currency||a[6]!==i.unitPriceMinor?(e=(0,j.formatPriceMinor)(i.unitPriceMinor,i.currency),a[5]=i.currency,a[6]=i.unitPriceMinor,a[7]=e):e=a[7];let l=i.variantLabel??"Each";
1a[8]!==e||a[9]!==l?(n=(0,t.jsx)(ts,{amount:e,label:l}),a[8]=e,a[9]=l,a[10]=n):n=a[10],a[11]!==i.currency?(s=e=>{var n;return(0,t.jsx)(ts,{amount:(n=i.currency,void 0===e.amountMinor?"included"===e.kind?"included":"":`+${(0,j.formatPriceMinor)(e.amountMinor,n)}`),label:(0,tn.itemizedRowText)(e)},e.key)},a[11]=i.currency,a[12]=s):s=a[12],r=(0,t.jsxs)("div",{className:"flex flex-col gap-1 pl-3",children:[n,o.map(s)]}),a[0]=i.currency,a[1]=i.modifiers,a[2]=i.unitPriceMinor,a[3]=i.variantLabel,a[4]=r}else r=a[4];return r}function tl(e){return{chargedMinor:e.priceMinor*e.quantity,choiceId:e.choiceId,choiceName:e.name,quantity:e.quantity,unitPriceMinor:e.unitPriceMinor}}function tc(e){let a,s,o,l,c,u,d,m,p,h,f,x,g,v,y=(0,n.c)(36),{line:b,onCustomize:S,onDecrement:M,onIncrement:w,onSetQuantity:k}=e;y[0]!==b.name?(a=(0,t.jsx)(i.Text,{as:"span",className:"min-w-0 flex-1 truncate","data-testid":"pos-cart-line-name",title:b.name,variant:"label",children:b.name}),y[0]=b.name,y[1]=a):a=y[1],y[2]!==b?(s=(0,j.formatPriceMinor)((0,C.computeLineTotalMinor)(b),b.currency),y[2]=b,y[3]=s):s=y[3],y[4]!==s?(o=(0,t.jsx)(i.Text,{as:"span",className:"min-w-20 shrink-0 text-right tabular-nums","data-testid":"pos-cart-line-total",variant:"labelBold",children:s}),y[4]=s,y[5]=o):o=y[5],y[6]!==a||y[7]!==o?(l=(0,t.jsxs)("div",{className:"flex items-start gap-3","data-testid":"pos-cart-line-head",children:[a,o]}),y[6]=a,y[7]=o,y[8]=l):l=y[8],y[9]!==b?(c=(0,t.jsx)(to,{line:b}),y[9]=b,y[10]=c):c=y[10];let N=`Decrease ${b.name}`;y[11]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(tr.Minus,{}),y[11]=u):u=y[11],y[12]!==M||y[13]!==N?(d=(0,t.jsx)(r.Button,{"aria-label":N,className:"size-11 shrink-0",onClick:M,size:"icon",variant:"surface",children:u}),y[12]=M,y[13]=N,y[14]=d):d=y[14];let _=`Quantity for ${b.name}`;y[15]!==k?(m=e=>{let t=(0,ti.readQuantityInput)(e.target.value);"count"===t.kind&&k(t.quantity)},y[15]=k,y[16]=m):m=y[16];let I=String(b.quantity);y[17]!==m||y[18]!==I||y[19]!==_?(p=(0,t.jsx)(U.Input,{"aria-label":_,className:"h-11 w-14 shrink-0 text-center",inputMode:"numeric",onChange:m,size:"lg",value:I}),y[17]=m,y[18]=I,y[19]=_,y[20]=p):p=y[20];let T=`Increase ${b.name}`;return y[21]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(ta.Plus,{}),y[21]=h):h=y[21],y[22]!==w||y[23]!==T?(f=(0,t.jsx)(r.Button,{"aria-label":T,className:"size-11 shrink-0",onClick:w,size:"icon",variant:"surface",children:h}),y[22]=w,y[23]=T,y[24]=f):f=y[24],y[25]!==S?(x=(0,t.jsx)(r.Button,{className:"ml-auto h-11 px-2",onClick:S,variant:"link",children:"Customize"}),y[25]=S,y[26]=x):x=y[26],y[27]!==p||y[28]!==f||y[29]!==x||y[30]!==d?(g=(0,t.jsxs)("div",{className:"flex items-center gap-2","data-testid":"pos-cart-line-controls",children:[d,p,f,x]}),y[27]=p,y[28]=f,y[29]=x,y[30]=d,y[31]=g):g=y[31],y[32]!==g||y[33]!==l||y[34]!==c?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-2 py-3",children:[l,c,g]}),y[32]=g,y[33]=l,y[34]=c,y[35]=v):v=y[35],v}e.i(972063);var tu=e.i(321220),td=e.i(556053);function tm(e){let a,s,o,l,c,u=(0,n.c)(13),{label:d,onRemove:m,removeLabel:p,value:h}=e;return u[0]!==d?(a=(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"bodyMuted",children:d}),u[0]=d,u[1]=a):a=u[1],u[2]!==m||u[3]!==p?(s=m&&p?(0,t.jsx)(r.Button,{"aria-label":p,onClick:m,size:"icon-xs",variant:"ghost",children:(0,t.jsx)(y.X,{})}):null,u[2]=m,u[3]=p,u[4]=s):s=u[4],u[5]!==a||u[6]!==s?(o=(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[a,s]}),u[5]=a,u[6]=s,u[7]=o):o=u[7],u[8]!==h?(l=(0,t.jsx)(i.Text,{as:"span",variant:"label",children:h}),u[8]=h,u[9]=l):l=u[9],u[10]!==o||u[11]!==l?(c=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[o,l]}),u[10]=o,u[11]=l,u[12]=c):c=u[12],c}function tp(e){let r,a,s=(0,n.c)(3),{value:o}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Total"}),s[0]=r):r=s[0],s[1]!==o?(a=(0,t.jsxs)("div",{className:"mt-1 flex items-baseline justify-between border-t pt-3",children:[r,(0,t.jsx)(i.Text,{as:"span",variant:"statValue",children:o})]}),s[1]=o,s[2]=a):a=s[2],a}function th(e){let r,a,i,s,o,l,c,u,d,m,h,f,x,g=(0,n.c)(44),{amounts:v,currency:y}=e,b=(0,p.useDiscount)(),S=(0,p.useTip)(),M=(0,p.useSetDiscount)(),w=(0,p.useSetTip)();g[0]!==M?(r=function(){M({kind:"none"})},g[0]=M,g[1]=r):r=g[1];let k=(0,tu.useStableEvent)(r);g[2]!==w?(a=function(){w({kind:"none"})},g[2]=w,g[3]=a):a=g[3];let N=(0,tu.useStableEvent)(a);if(g[4]!==v.discountMinor||g[5]!==v.subtotalMinor||g[6]!==k||g[7]!==y||g[8]!==b){let e,n=(0,C.computeDiscountMinor)(b,v.subtotalMinor);
1i=Math.max(0,v.discountMinor-n),s="flex flex-col gap-1",g[13]!==v.subtotalMinor||g[14]!==y?(e=(0,j.formatPriceMinor)(v.subtotalMinor,y),g[13]=v.subtotalMinor,g[14]=y,g[15]=e):e=g[15],g[16]!==e?(o=(0,t.jsx)(tm,{label:"Subtotal",value:e}),g[16]=e,g[17]=o):o=g[17],l=n>0?(0,t.jsx)(tm,{label:function(e,t){switch(e.kind){case"none":return"Discount";case"comp":return"Discount (Comp)";case"percent":return`Discount (${e.bps/100}%)`;case"amount":return`Discount (${(0,j.formatPriceMinor)(e.amountMinor,t)})`;default:return(0,td.assertNever)(e)}}(b,y),onRemove:k,removeLabel:"Remove discount from sale",value:`−${(0,j.formatPriceMinor)(n,y)}`}):null,g[4]=v.discountMinor,g[5]=v.subtotalMinor,g[6]=k,g[7]=y,g[8]=b,g[9]=i,g[10]=s,g[11]=o,g[12]=l}else i=g[9],s=g[10],o=g[11],l=g[12];return g[18]!==y||g[19]!==i?(c=i>0?(0,t.jsx)(tm,{label:"Rewards",value:`−${(0,j.formatPriceMinor)(i,y)}`}):null,g[18]=y,g[19]=i,g[20]=c):c=g[20],g[21]!==v.taxMinor||g[22]!==y?(u=(0,j.formatPriceMinor)(v.taxMinor,y),g[21]=v.taxMinor,g[22]=y,g[23]=u):u=g[23],g[24]!==u?(d=(0,t.jsx)(tm,{label:"Tax",value:u}),g[24]=u,g[25]=d):d=g[25],g[26]!==v.tipMinor||g[27]!==N||g[28]!==y||g[29]!==S?(m=v.tipMinor>0?(0,t.jsx)(tm,{label:function(e,t){switch(e.kind){case"none":return"Tip";case"percent":return`Tip (${e.bps/100}%)`;case"amount":return`Tip (${(0,j.formatPriceMinor)(e.amountMinor,t)})`;default:return(0,td.assertNever)(e)}}(S,y),onRemove:N,removeLabel:"Remove tip from sale",value:`+${(0,j.formatPriceMinor)(v.tipMinor,y)}`}):null,g[26]=v.tipMinor,g[27]=N,g[28]=y,g[29]=S,g[30]=m):m=g[30],g[31]!==v.totalMinor||g[32]!==y?(h=(0,j.formatPriceMinor)(v.totalMinor,y),g[31]=v.totalMinor,g[32]=y,g[33]=h):h=g[33],g[34]!==h?(f=(0,t.jsx)(tp,{value:h}),g[34]=h,g[35]=f):f=g[35],g[36]!==f||g[37]!==s||g[38]!==o||g[39]!==l||g[40]!==c||g[41]!==d||g[42]!==m?(x=(0,t.jsxs)("div",{className:s,children:[o,l,c,d,m,f]}),g[36]=f,g[37]=s,g[38]=o,g[39]=l,g[40]=c,g[41]=d,g[42]=m,g[43]=x):x=g[43],x}var tf=e.i(922507);let tx=[{label:"Staff",value:C.COMP_REASONS.staff},{label:"Quality issue",value:C.COMP_REASONS.qualityIssue},{label:"Promo",value:C.COMP_REASONS.promo}];function tg(e){let a,i,s,o,l,c,u,d,m=(0,n.c)(19),{compReason:p,currency:h,discount:f,onApplyComp:x,onCompReasonChange:g}=e;m[0]!==g?(a=function(e){e&&(e===C.COMP_REASONS.staff||e===C.COMP_REASONS.qualityIssue||e===C.COMP_REASONS.promo)&&g(e)},m[0]=g,m[1]=a):a=m[1];let v=(0,tu.useStableEvent)(a);m[2]!==p||m[3]!==x?(i=function(){x(p)},m[2]=p,m[3]=x,m[4]=i):i=m[4];let y=(0,tu.useStableEvent)(i);m[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(eK.SelectTrigger,{className:"w-full",children:(0,t.jsx)(eK.SelectValue,{placeholder:"Reason"})}),m[5]=s):s=m[5],m[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(eK.SelectContent,{children:(0,t.jsx)(eK.SelectGroup,{children:tx.map(tv)})}),m[6]=o):o=m[6],m[7]!==p||m[8]!==v?(l=(0,t.jsxs)(eK.Select,{items:tx,onValueChange:v,value:p,children:[s,o]}),m[7]=p,m[8]=v,m[9]=l):l=m[9];let b="comp"===f.kind?"selected":"surface";return m[10]!==h?(c=(0,j.formatPriceMinor)(0,h),m[10]=h,m[11]=c):c=m[11],m[12]!==y||m[13]!==b||m[14]!==c?(u=(0,t.jsxs)(r.Button,{className:"w-full",onClick:y,variant:b,children:["Comp entire sale — ",c]}),m[12]=y,m[13]=b,m[14]=c,m[15]=u):u=m[15],m[16]!==l||m[17]!==u?(d=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[l,u]}),m[16]=l,m[17]=u,m[18]=d):d=m[18],d}function tv(e){return(0,t.jsx)(eK.SelectItem,{value:e.value,children:e.label},e.value)}var ty=e.i(778184),tj=e.i(341965),tb=e.i(723823);let tS=null,tC=new Set;function tM(e){return tC.add(e),()=>{tC.delete(e)}}function tw(){return tS}function tk(e){if(tS!==e)for(let t of(tS=e,tC))t()}function tN(e){e&&tS!==e||tk(null)}function t_(e){let r,a,i,s,o,l,c,u,d,m,p,h=(0,n.c)(12),{children:f,popoverId:x,trigger:g}=e,v=(u=(0,n.c)(5),d=(0,X.useSyncExternalStore)(tM,tw,tw),u[0]!==x?(l=function(e){e?tk(x):tS===x&&tk(null)},u[0]=x,u[1]=l):l=u[1],m=(0,tu.useStableEvent)(l),p=d===x,u[2]!==m||u[3]!==p?(c={onOpenChange:m,open:p},u[2]=m,u[3]=p,u[4]=c):c=u[4],c);return h[0]!==x?(r=function(){return()=>tN(x)},a=[x],h[0]=x,h[1]=r,h[2]=a):(r=h[1],a=h[2]),(0,X.useEffect)(r,a),h[3]!==g?(i=(0,t.jsx)(tj.PopoverTrigger,{render:g}),h[3]=g,h[4]=i):i=h[4],h[5]!==f?(s=(0,t.jsx)(tj.PopoverContent,{align:"start",className:"w-80 gap-4 p-3",side:"left",children:f}),h[5]=f,h[6]=s):s=h[6],h[7]!==v.onOpenChange||h[8]!==v.open||h[9]!==i||h[10]!==s?(o=(0,t.jsxs)(tj.Popover,{onOpenChange:v.onOpenChange,open:v.open,children:[i,s]}),h[7]=v.onOpenChange,h[8]=v.open,h[9]=i,h[10]=s,h[11]=o):o=h[11],o}function tI(e){let r,a=(0,n.c)(2),{children:s}=e;return a[0]!==s?(r=(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:s}),a[0]=s,a[1]=r):r=a[1],r}function tT(e){let r,a,i,s=(0,n.c)(6),{onValueChange:o,value:l}=e;s[0]!==o?(r=function(e){("percent"===e||"amount"===e)&&o(e)},s[0]=o,s[1]=r):r=s[1];let c=(0,tu.useStableEvent)(r);return s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)(tb.TabsList,{className:"w-full",variant:"fill",children:[(0,t.jsx)(tb.TabsTrigger,{value:"percent",children:"% Percent"}),(0,t.jsx)(tb.TabsTrigger,{value:"amount",children:"$ Amount"})]}),s[2]=a):a=s[2],s[3]!==c||s[4]!==l?(i=(0,t.jsx)(tb.Tabs,{onValueChange:c,value:l,children:a}),s[3]=c,s[4]=l,s[5]=i):i=s[5],i}function tP(e){let r,a,i=(0,n.c)(9),{activeBps:s,onApply:o,percents:l}=e;if(i[0]!==s||i[1]!==o||i[2]!==l){let e;i[4]!==s||i[5]!==o?(e=e=>(0,t.jsx)(tR,{active:s===100*e,onApply:o,percent:e},e),i[4]=s,i[5]=o,i[6]=e):e=i[6],r=l.map(e),i[0]=s,i[1]=o,i[2]=l,i[3]=r}else r=i[3];return i[7]!==r?(a=(0,t.jsx)("div",{className:"grid grid-cols-3 gap-2",children:r}),i[7]=r,i[8]=a):a=i[8],a}function tR(e){let a,i,s=(0,n.c)(7),{active:o,onApply:l,percent:c}=e;s[0]!==l||s[1]!==c?(a=function(){l(c)},s[0]=l,s[1]=c,s[2]=a):a=s[2];let u=(0,tu.useStableEvent)(a),d=o?"selected":"surface";return s[3]!==u||s[4]!==c||s[5]!==d?(i=(0,t.jsxs)(r.Button,{className:"w-full",onClick:u,variant:d,children:[c,"%"]}),s[3]=u,s[4]=c,s[5]=d,s[6]=i):i=s[6],i}function tD(e){let a,i,s,o,l,c=(0,n.c)(24),{applyLabel:u,canApply:d,error:m,helper:p,inputMode:h,label:f,onApply:x,onChange:g,placeholder:v,prefix:y,suffix:j,value:b}=e,S=void 0===h?"numeric":h,C=m??p;c[0]!==f?(a=(0,t.jsx)(H.Label,{children:f}),c[0]=f,c[1]=a):a=c[1],c[2]!==d||c[3]!==m||c[4]!==S||c[5]!==f||c[6]!==x||c[7]!==g||c[8]!==v||c[9]!==y||c[10]!==j||c[11]!==b?(i=(0,t.jsx)(tA,{canApply:d,error:m,inputMode:S,label:f,onApply:x,onChange:g,placeholder:v,prefix:y,suffix:j,value:b}),c[2]=d,c[3]=m,c[4]=S,c[5]=f,c[6]=x,c[7]=g,c[8]=v,c[9]=y,c[10]=j,c[11]=b,c[12]=i):i=c[12],c[13]!==C?(s=(0,t.jsx)(tL,{message:C}),c[13]=C,c[14]=s):s=c[14];let M=!d;return c[15]!==u||c[16]!==x||c[17]!==M?(o=(0,t.jsx)(r.Button,{className:"w-full",disabled:M,onClick:x,children:u}),c[15]=u,c[16]=x,c[17]=M,c[18]=o):o=c[18],c[19]!==a||c[20]!==i||c[21]!==s||c[22]!==o?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[a,i,s,o]}),c[19]=a,c[20]=i,c[21]=s,c[22]=o,c[23]=l):l=c[23],l}function tL(e){let r,a=(0,n.c)(2),{message:s}=e;return s?(a[0]!==s?(r=(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:s}),a[0]=s,a[1]=r):r=a[1],r):null}function tA(e){let r,a,i,s,o,l,c=(0,n.c)(21),{canApply:u,error:d,inputMode:m,label:p,onApply:h,onChange:f,placeholder:x,prefix:g,suffix:v,value:y}=e;c[0]!==f?(r=function(e){f(e.target.value)},c[0]=f,c[1]=r):r=c[1];let j=(0,tu.useStableEvent)(r);c[2]!==u||c[3]!==h?(a=function(e){"Enter"===e.key&&u&&h()},c[2]=u,c[3]=h,c[4]=a):a=c[4];let b=(0,tu.useStableEvent)(a);c[5]!==g?(i=(0,t.jsx)(tO,{align:"inline-start",value:g}),c[5]=g,c[6]=i):i=c[6];let S=!!d||void 0;return c[7]!==j||c[8]!==b||c[9]!==m||c[10]!==p||c[11]!==x||c[12]!==S||c[13]!==y?(s=(0,t.jsx)(ty.InputGroupInput,{"aria-invalid":S,"aria-label":p,inputMode:m,onCh
1ange:j,onKeyDown:b,placeholder:x,value:y}),c[7]=j,c[8]=b,c[9]=m,c[10]=p,c[11]=x,c[12]=S,c[13]=y,c[14]=s):s=c[14],c[15]!==v?(o=(0,t.jsx)(tO,{align:"inline-end",value:v}),c[15]=v,c[16]=o):o=c[16],c[17]!==i||c[18]!==s||c[19]!==o?(l=(0,t.jsxs)(ty.InputGroup,{children:[i,s,o]}),c[17]=i,c[18]=s,c[19]=o,c[20]=l):l=c[20],l}function tO(e){let r,a,i=(0,n.c)(5),{align:s,value:o}=e;return o?(i[0]!==o?(r=(0,t.jsx)(ty.InputGroupText,{children:o}),i[0]=o,i[1]=r):r=i[1],i[2]!==s||i[3]!==r?(a=(0,t.jsx)(ty.InputGroupAddon,{align:s,children:r}),i[2]=s,i[3]=r,i[4]=a):a=i[4],a):null}function tE(e){let r,a=(0,n.c)(2),{value:s}=e;return s?(a[0]!==s?(r=(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Text,{as:"span",variant:"label",children:s})}),a[0]=s,a[1]=r):r=a[1],r):null}let tB=[10,15,20],t$=/\D/g;function tz(e){let a,i,s,o,l,c,u,d,m,h=(0,n.c)(40),{currency:f,discountMinor:x}=e,g=(0,p.useDiscount)(),v=(0,p.useSetDiscount)(),y=(0,p.useSetTip)(),b=(0,p.useCartLines)(),[S,M]=(0,X.useState)("percent"),[w,k]=(0,X.useState)(""),[N,_]=(0,X.useState)(""),[I,T]=(0,X.useState)(C.COMP_REASONS.staff),P=(0,C.computeSubtotalMinor)(b),R=function(e){if(0===e.trim().length)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}(w),D=null!==R&&R>=1&&R<=100,L=ee(N),A=L>0&&L<=P,O="percent"===g.kind?g.bps:null,E="none"!==g.kind;h[0]!==v?(a=function(e){v(e),k(""),_(""),tN("discount")},h[0]=v,h[1]=a):a=h[1];let B=(0,tu.useStableEvent)(a);h[2]!==B||h[3]!==R||h[4]!==D?(i=function(){D&&null!==R&&B({bps:100*R,kind:"percent"})},h[2]=B,h[3]=R,h[4]=D,h[5]=i):i=h[5];let $=(0,tu.useStableEvent)(i);h[6]!==A||h[7]!==L||h[8]!==B?(s=function(){A&&B({amountMinor:L,kind:"amount"})},h[6]=A,h[7]=L,h[8]=B,h[9]=s):s=h[9];let z=(0,tu.useStableEvent)(s);h[10]!==v||h[11]!==y?(o=function(e){v({kind:"comp",reason:e}),y({kind:"none"}),k(""),_(""),tN("discount")},h[10]=v,h[11]=y,h[12]=o):o=h[12];let F=(0,tu.useStableEvent)(o),q=E?"secondary":"surface";return h[13]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(tf.Tag,{}),h[13]=l):l=h[13],h[14]!==f||h[15]!==g||h[16]!==x?(c=function(e,t,n){switch(e.kind){case"none":return"Discount";case"comp":return"Discount · Comp";case"percent":return`Discount \xb7 ${e.bps/100}%`;case"amount":return`Discount \xb7 ${(0,j.formatPriceMinor)(t,n)}`;default:return(0,td.assertNever)(e)}}(g,x,f),h[14]=f,h[15]=g,h[16]=x,h[17]=c):c=h[17],h[18]!==q||h[19]!==c?(u=(0,t.jsxs)(r.Button,{variant:q,children:[l,c]}),h[18]=q,h[19]=c,h[20]=u):u=h[20],h[21]!==O||h[22]!==A||h[23]!==L||h[24]!==B||h[25]!==F||h[26]!==z||h[27]!==$||h[28]!==I||h[29]!==f||h[30]!==N||h[31]!==w||h[32]!==g||h[33]!==S||h[34]!==D||h[35]!==P?(d=(0,t.jsx)(tF,{activeBps:O,amountIsValid:A,amountMinor:L,compReason:I,currency:f,customAmount:N,customPercent:w,discount:g,mode:S,onApply:B,onApplyAmount:z,onApplyComp:F,onApplyPercent:$,onCompReasonChange:T,onCustomAmountChange:_,onCustomPercentChange:k,onModeChange:M,percentIsValid:D,subtotalMinor:P}),h[21]=O,h[22]=A,h[23]=L,h[24]=B,h[25]=F,h[26]=z,h[27]=$,h[28]=I,h[29]=f,h[30]=N,h[31]=w,h[32]=g,h[33]=S,h[34]=D,h[35]=P,h[36]=d):d=h[36],h[37]!==u||h[38]!==d?(m=(0,t.jsx)(t_,{popoverId:"discount",trigger:u,children:d}),h[37]=u,h[38]=d,h[39]=m):m=h[39],m}function tF(e){let r,a,i,s,o,l,c=(0,n.c)(30),{activeBps:u,amountIsValid:d,amountMinor:m,compReason:p,currency:h,customAmount:f,customPercent:x,discount:g,mode:v,onApply:y,onApplyAmount:j,onApplyComp:b,onApplyPercent:S,onCompReasonChange:C,onCustomAmountChange:M,onCustomPercentChange:w,onModeChange:k,percentIsValid:N,subtotalMinor:_}=e;return c[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(tI,{children:"Discount"}),c[0]=r):r=c[0],c[1]!==v||c[2]!==k?(a=(0,t.jsx)(tT,{onValueChange:k,value:v}),c[1]=v,c[2]=k,c[3]=a):a=c[3],c[4]!==u||c[5]!==d||c[6]!==m||c[7]!==h||c[8]!==f||c[9]!==x||c[10]!==v||c[11]!==y||c[12]!==j||c[13]!==S||c[14]!==M||c[15]!==w||c[16]!==N||c[17]!==_?(i="percent"===v?(0,t.jsx)(tq,{activeBps:u,customPercent:x,onApply:y,onApplyPercent:S,onCustomPercentChange:w,percentIsValid:N}):(0,t.jsx)(tV,{amountIsValid:d,amountMinor:m,currency:h,customAmount:f,onApplyAmount:j,onCustomAmountChange:M,subtotalMinor:_}),c[4]=u,c[5]=d,c[6]=m,c[7]=h,c[8]=f,c[9]=x,c[10]=v,c[11]=y,c[12]=j,c[13]=S,c[14]=M,c[15]=w,c[16]=N,c[17]=_,c[18]=i):i=c[18],c[19]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ep.Separator,{}),c[19]=s):s=c[19],c[20]!==p||c[21]!==h||c[22]!==g||c[23]!==b||c[24]!==C?(o=(0,t.jsx)(tg,{compReason:p,currency:h,discount:g,onApplyComp:b,onCompReasonChange:C}),c[20]=p,c[21]=h,c[22]=g,c[23]=b,c[24]=C,c[25]=o):o=c[25],c[26]!==a||c[27]!==i||c[28]!==o?(l=(0,t.jsxs)(t.Fragment,{children:[r,a,i,s,o]}),c[26]=a,c[27]=i,c[28]=o,c[29]=l):l=c[29],l}function tq(e){let r,a,i,s,o,l=(0,n.c)(16),{activeBps:c,customPercent:u,onApply:d,onApplyPercent:m,onCustomPercentChange:p,percentIsValid:h}=e;l[0]!==d?(r=function(e){d({bps:100*e,kind:"percent"})},l[0]=d,l[1]=r):r=l[1];let f=(0,tu.useStableEvent)(r);l[2]!==p?(a=function(e){p(e.replace(t$,"").slice(0,3))},l[2]=p,l[3]=a):a=l[3];let x=(0,tu.useStableEvent)(a);l[4]!==c||l[5]!==f?(i=(0,t.jsx)(tP,{activeBps:c,onApply:f,percents:tB}),l[4]=c,l[5]=f,l[6]=i):i=l[6];let g=u.length>0&&!h?"Enter a percent from 1 to 100.":void 0;return l[7]!==u||l[8]!==x||l[9]!==m||l[10]!==h||l[11]!==g?(s=(0,t.jsx)(tD,{applyLabel:"Ap
1ply discount",canApply:h,error:g,label:"Custom discount percent",onApply:m,onChange:x,placeholder:"10",suffix:"%",value:u}),l[7]=u,l[8]=x,l[9]=m,l[10]=h,l[11]=g,l[12]=s):s=l[12],l[13]!==i||l[14]!==s?(o=(0,t.jsxs)(t.Fragment,{children:[i,s]}),l[13]=i,l[14]=s,l[15]=o):o=l[15],o}function tV(e){let r,a,i,s,o=(0,n.c)(15),{amountIsValid:l,amountMinor:c,currency:u,customAmount:d,onApplyAmount:m,onCustomAmountChange:p,subtotalMinor:h}=e,f=c>h?"Discount cannot exceed the subtotal.":void 0;if(o[0]!==l||o[1]!==d||o[2]!==m||o[3]!==p||o[4]!==f?(r=(0,t.jsx)(tD,{applyLabel:"Apply discount",canApply:l,error:f,helper:"Subtracted from the subtotal.",label:"Custom discount amount",onApply:m,onChange:p,placeholder:"2.00",prefix:"−$",value:d}),o[0]=l,o[1]=d,o[2]=m,o[3]=p,o[4]=f,o[5]=r):r=o[5],o[6]!==c||o[7]!==u||o[8]!==h)a=c<=0?null:`${(0,j.formatPriceMinor)(h,u)} → ${(0,j.formatPriceMinor)(Math.max(0,h-c),u)}`,o[6]=c,o[7]=u,o[8]=h,o[9]=a;else a=o[9];return o[10]!==a?(i=(0,t.jsx)(tE,{value:a}),o[10]=a,o[11]=i):i=o[11],o[12]!==r||o[13]!==i?(s=(0,t.jsxs)(t.Fragment,{children:[r,i]}),o[12]=r,o[13]=i,o[14]=s):s=o[14],s}var tU=e.i(4898),tU=tU;let tH=[15,18,20],tG=/\D/g;function tQ(e,t,n){return e<=0?null:`${(0,j.formatPriceMinor)(t,n)} → ${(0,j.formatPriceMinor)(t+e,n)}`}function tW(e){let a,i,s,o,l,c,u,d,m,h,f,x=(0,n.c)(43),{currency:g,tipMinor:v}=e,y=(0,p.useTip)(),b=(0,p.useSetTip)(),S=(0,p.useCartLines)(),w=(0,p.useDiscount)(),k=(0,p.useRedeemRewards)(),N=M(),[_,I]=(0,X.useState)("percent"),[T,P]=(0,X.useState)(""),[R,D]=(0,X.useState)("");x[0]!==w||x[1]!==S?(a=(0,C.computeSubtotalMinor)(S),i=(0,C.computeDiscountMinor)(w,a),x[0]=w,x[1]=S,x[2]=a,x[3]=i):(a=x[2],i=x[3]);let L=Math.max(0,a-i-(k&&N?N.redeemableMinor:0)),A=function(e){if(0===e.trim().length)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}(T),O=null!==A&&A>=1&&A<=100;x[4]!==A||x[5]!==O||x[6]!==L?(s=O&&null!==A?(0,C.computeTipMinor)({bps:100*A,kind:"percent"},L):0,x[4]=A,x[5]=O,x[6]=L,x[7]=s):s=x[7];let E=s,B=ee(R),$=B>0,z="percent"===y.kind?y.bps:null,F="none"!==y.kind;x[8]!==b?(o=function(e){b(e),P(""),D(""),tN("tip")},x[8]=b,x[9]=o):o=x[9];let q=(0,tu.useStableEvent)(o);x[10]!==q||x[11]!==A||x[12]!==O?(l=function(){O&&null!==A&&q({bps:100*A,kind:"percent"})},x[10]=q,x[11]=A,x[12]=O,x[13]=l):l=x[13];let V=(0,tu.useStableEvent)(l);x[14]!==$||x[15]!==B||x[16]!==q?(c=function(){$&&q({amountMinor:B,kind:"amount"})},x[14]=$,x[15]=B,x[16]=q,x[17]=c):c=x[17];let U=(0,tu.useStableEvent)(c),H=F?"secondary":"surface";return x[18]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(tU.default,{}),x[18]=u):u=x[18],x[19]!==g||x[20]!==y||x[21]!==v?(d=function(e,t,n){switch(e.kind){case"none":return"Tip";case"percent":return`Tip \xb7 ${e.bps/100}%`;case"amount":return`Tip \xb7 ${(0,j.formatPriceMinor)(t,n)}`;default:return(0,td.assertNever)(e)}}(y,v,g),x[19]=g,x[20]=y,x[21]=v,x[22]=d):d=x[22],x[23]!==H||x[24]!==d?(m=(0,t.jsxs)(r.Button,{variant:H,children:[u,d]}),x[23]=H,x[24]=d,x[25]=m):m=x[25],x[26]!==z||x[27]!==$||x[28]!==B||x[29]!==q||x[30]!==U||x[31]!==V||x[32]!==g||x[33]!==R||x[34]!==T||x[35]!==E||x[36]!==_||x[37]!==O||x[38]!==L?(h=(0,t.jsx)(tX,{activeBps:z,amountIsValid:$,amountMinor:B,currency:g,customAmount:R,customPercent:T,customPercentTipMinor:E,mode:_,onApply:q,onApplyAmount:U,onApplyPercent:V,onCustomAmountChange:D,onCustomPercentChange:P,onModeChange:I,percentIsValid:O,tipBaseMinor:L}),x[26]=z,x[27]=$,x[28]=B,x[29]=q,x[30]=U,x[31]=V,x[32]=g,x[33]=R,x[34]=T,x[35]=E,x[36]=_,x[37]=O,x[38]=L,x[39]=h):h=x[39],x[40]!==h||x[41]!==m?(f=(0,t.jsx)(t_,{popoverId:"tip",trigger:m,children:h}),x[40]=h,x[41]=m,x[42]=f):f=x[42],f}function tX(e){let r,a,i,s,o=(0,n.c)(23),{activeBps:l,amountIsValid:c,amountMinor:u,currency:d,customAmount:m,customPercent:p,customPercentTipMinor:h,mode:f,onApply:x,onApplyAmount:g,onApplyPercent:v,onCustomAmountChange:y,onCustomPercentChange:j,onModeChange:b,percentIsValid:S,tipBaseMinor:C}=e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(tI,{children:"Tip"}),o[0]=r):r=o[0],o[1]!==f||o[2]!==b?(a=(0,t.jsx)(tT,{onValueChange:b,value:f}),o[1]=f,o[2]=b,o[3]=a):a=o[3],o[4]!==l||o[5]!==c||o[6]!==u||o[7]!==d||o[8]!==m||o[9]!==p||o[10]!==h||o[11]!==f||o[12]!==x||o[13]!==g||o[14]!==v||o[15]!==y||o[16]!==j||o[17]!==S||o[18]!==C?(i="percent"===f?(0,t.jsx)(tK,{activeBps:l,currency:d,customPercent:p,customPercentTipMinor:h,onApply:x,onApplyPercent:v,onCustomPercentChange:j,percentIsValid:S,tipBaseMinor:C}):(0,t.jsx)(tZ,{amountIsValid:c,amountMinor:u,currency:d,customAmount:m,onApplyAmount:g,onCustomAmountChange:y,tipBaseMinor:C}),o[4]=l,o[5]=c,o[6]=u,o[7]=d,o[8]=m,o[9]=p,o[10]=h,o[11]=f,o[12]=x,o[13]=g,o[14]=v,o[15]=y,o[16]=j,o[17]=S,o[18]=C,o[19]=i):i=o[19],o[20]!==a||o[21]!==i?(s=(0,t.jsxs)(t.Fragment,{children:[r,a,i]}),o[20]=a,o[21]=i,o[22]=s):s=o[22],s}function tK(e){let r,a,i,s,o,l,c,u=(0,n.c)(23),{activeBps:d,currency:m,customPercent:p,customPercentTipMinor:h,onApply:f,onApplyPercent:x,onCustomPercentChange:g,percentIsValid:v,tipBaseMinor:y}=e;u[0]!==f?(r=function(e){f({bps:100*e,kind:"percent"})},u[0]=f,u[1]=r):r=u[1];let j=(0,tu.useStableEvent)(r);u[2]!==g?(a=function(e){g(e.replace(tG,"").slice(0,3))},u[2]=g,u[3]=a):a=u[3];let b=(0,tu.useStableEvent)(a);u[4]!==d||u[5]!==j?(i=(0,t.jsx)(tP,{activeBps:d,onApply:j,percents:tH}),u[4]=d,u[5]=j,u[6]=i):i=u[6];let S=p.length>0&&!v?"Enter a percent from 1 to 100.":void 0;return u[7]!==p||u[8]!==b||u[9]!==x||u[10]!==v||u[11]!==S?(s=(0,t.jsx)(tD,{applyLabel:"Ap
1ply tip",canApply:v,error:S,label:"Custom tip percent",onApply:x,onChange:b,placeholder:"18",suffix:"%",value:p}),u[7]=p,u[8]=b,u[9]=x,u[10]=v,u[11]=S,u[12]=s):s=u[12],u[13]!==m||u[14]!==h||u[15]!==y?(o=tQ(h,y,m),u[13]=m,u[14]=h,u[15]=y,u[16]=o):o=u[16],u[17]!==o?(l=(0,t.jsx)(tE,{value:o}),u[17]=o,u[18]=l):l=u[18],u[19]!==i||u[20]!==s||u[21]!==l?(c=(0,t.jsxs)(t.Fragment,{children:[i,s,l]}),u[19]=i,u[20]=s,u[21]=l,u[22]=c):c=u[22],c}function tZ(e){let r,a,i,s,o=(0,n.c)(14),{amountIsValid:l,amountMinor:c,currency:u,customAmount:d,onApplyAmount:m,onCustomAmountChange:p,tipBaseMinor:h}=e;return o[0]!==l||o[1]!==d||o[2]!==m||o[3]!==p?(r=(0,t.jsx)(tD,{applyLabel:"Apply tip",canApply:l,helper:"Added to the total.",label:"Custom tip amount",onApply:m,onChange:p,placeholder:"1.71",prefix:"+$",value:d}),o[0]=l,o[1]=d,o[2]=m,o[3]=p,o[4]=r):r=o[4],o[5]!==c||o[6]!==u||o[7]!==h?(a=tQ(c,h,u),o[5]=c,o[6]=u,o[7]=h,o[8]=a):a=o[8],o[9]!==a?(i=(0,t.jsx)(tE,{value:a}),o[9]=a,o[10]=i):i=o[10],o[11]!==r||o[12]!==i?(s=(0,t.jsxs)(t.Fragment,{children:[r,i]}),o[11]=r,o[12]=i,o[13]=s):s=o[13],s}let tJ=/^[^\s@]+@[^\s@.]+\.[^\s@]+$/,tY=/\D/g;function t0(e){return 10!==e.length?e:`(${e.slice(0,3)}) ${e.slice(3,6)}-${e.slice(6)}`}var t1=e.i(806281),t2=e.i(14905);function t3(e){let r,a,i,s,o=(0,n.c)(10),{canSave:l,contact:c,onEnter:u,onValueChange:d}=e;o[0]!==d?(r=function(e){d(e.target.value)},o[0]=d,o[1]=r):r=o[1];let m=(0,tu.useStableEvent)(r);o[2]!==l||o[3]!==u?(a=function(e){"Enter"===e.key&&l&&u()},o[2]=l,o[3]=u,o[4]=a):a=o[4];let p=(0,tu.useStableEvent)(a);return o[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(H.Label,{htmlFor:"pos-customer-contact",children:"Phone or email"}),o[5]=i):i=o[5],o[6]!==c||o[7]!==m||o[8]!==p?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[i,(0,t.jsx)(U.Input,{autoComplete:"off",id:"pos-customer-contact",inputMode:"tel",onChange:m,onKeyDown:p,placeholder:"(555) 123-4567 or [email protected]",value:c})]}),o[6]=c,o[7]=m,o[8]=p,o[9]=s):s=o[9],s}function t4(e){let r,a,i,s=(0,n.c)(6),{name:o,onValueChange:l}=e;s[0]!==l?(r=function(e){l(e.target.value)},s[0]=l,s[1]=r):r=s[1];let c=(0,tu.useStableEvent)(r);return s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(H.Label,{htmlFor:"pos-customer-name",children:"Name"}),s[2]=a):a=s[2],s[3]!==c||s[4]!==o?(i=(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[a,(0,t.jsx)(U.Input,{autoComplete:"off",id:"pos-customer-name",onChange:c,placeholder:"First and last (optional)",value:o})]}),s[3]=c,s[4]=o,s[5]=i):i=s[5],i}function t5(e){let r,a,i,s=(0,n.c)(6),{birthday:o,onValueChange:l}=e;s[0]!==l?(r=function(e){let t;l((t=e.target.value.replace(/\D/g,"").slice(0,4)).length<=2?t:`${t.slice(0,2)}/${t.slice(2)}`)},s[0]=l,s[1]=r):r=s[1];let c=(0,tu.useStableEvent)(r);return s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(H.Label,{htmlFor:"pos-customer-birthday",children:"Birthday"}),s[2]=a):a=s[2],s[3]!==o||s[4]!==c?(i=(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[a,(0,t.jsx)(U.Input,{autoComplete:"off",id:"pos-customer-birthday",inputMode:"numeric",onChange:c,placeholder:"MM/DD (optional)",value:o})]}),s[3]=o,s[4]=c,s[5]=i):i=s[5],i}function t6(e){return{customerId:e._id,email:e.email,name:e.name,phone:e.phone}}function t7(e){return e.name?e.name:e.phone?t0(e.phone):e.email??"Customer"}function t8(e){let t,n,r;return(t=e.trim().toLowerCase(),tJ.test(t)?t:null)?{email:e.trim()}:((r=11===(n=e.replace(tY,"")).length&&n.startsWith("1")?n.slice(1):n).length<7||r.length>15?null:r)?{phone:e.trim()}:null}function t9(e){let a,s,o,l,c,u,d,m,p=(0,n.c)(18),{customer:h,onSelect:f}=e;p[0]!==h||p[1]!==f?(a=function(){f(h)},p[0]=h,p[1]=f,p[2]=a):a=p[2];let x=(0,tu.useStableEvent)(a);if(p[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(t2.UserRound,{}),p[3]=s):s=p[3],p[4]!==h?(o=t7(h),p[4]=h,p[5]=o):o=p[5],p[6]!==o?(l=(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"label",children:o}),p[6]=o,p[7]=l):l=p[7],p[8]!==h)c=h.phone?t0(h.phone):h.email??"No contact saved",p[8]=h,p[9]=c;else c=p[9];return p[10]!==c?(u=(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"caption",children:c}),p[10]=c,p[11]=u):u=p[11],p[12]!==l||p[13]!==u?(d=(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[l,u]}),p[12]=l,p[13]=u,p[14]=d):d=p[14],p[15]!==x||p[16]!==d?(m=(0,t.jsxs)(r.Button,{className:"flex-row justify-start",onClick:x,size:"tile",variant:"surface",children:[s,d]}),p[15]=x,p[16]=d,p[17]=m):m=p[17],m}function ne({initial:e,onCaptured:a,spaceId:i}){let s,o,l,[c,u]=(0,X.useState)(e.contact),[d,m]=(0,X.useState)(e.name),[p,h]=(0,
1X.useState)(""),[f,x]=(0,X.useState)(!1),g=(o=(0,n.c)(2),l=(0,S.useMutation)(b.api.commerce.customers.mutations.upsertCustomer),o[0]!==l?(s=async e=>t6(await l(e)),o[0]=l,o[1]=s):s=o[1],s),v=t8(c),y=null!==v&&!f,j=(0,tu.useStableEvent)(async function(){if(v){x(!0);try{a(await g({...v,birthday:p.trim()||void 0,name:d.trim()||void 0,spaceId:i}))}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't save the customer.")}finally{x(!1)}}});return(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsx)(t3,{canSave:y,contact:c,onEnter:j,onValueChange:u}),(0,t.jsx)(t4,{name:d,onValueChange:m}),(0,t.jsx)(t5,{birthday:p,onValueChange:h}),(0,t.jsxs)(r.Button,{className:"h-12 w-full flex-row justify-center",disabled:!y,onClick:j,size:"tile",children:[(0,t.jsx)(t1.UserPlus,{}),"Add to sale"]})]})}function nt(e){let r,a,i,s,o,l,c,u,d,m,p,h,f,x,g,v,y,j,C,M=(0,n.c)(28),{onCaptured:w,spaceId:k}=e,[N,_]=(0,X.useState)(""),[I,T]=(0,X.useState)(null);M[0]!==N?(r=N.trim(),M[0]=N,M[1]=r):r=M[1];let P=r,{results:R,isSearching:D}=((g=(0,n.c)(11))[0]!==N?(p=N.trim(),g[0]=N,g[1]=p):p=g[1],v=p,y=null!==k&&v.length>=2,g[2]!==y||g[3]!==k||g[4]!==v?(h=y&&k?{search:v,spaceId:k}:"skip",g[2]=y,g[3]=k,g[4]=v,g[5]=h):h=g[5],j=(0,S.useQuery)(b.api.commerce.customers.queries.searchCustomers,h),C=y&&void 0===j,g[6]!==j?(f=j?j.map(t6):[],g[6]=j,g[7]=f):f=g[7],g[8]!==C||g[9]!==f?(x={isSearching:C,results:f},g[8]=C,g[9]=f,g[10]=x):x=g[10],x),L=P.length>0&&!D&&0===R.length&&null===I;M[2]===Symbol.for("react.memo_cache_sentinel")?(a=function(e){_(e.target.value),T(null)},M[2]=a):a=M[2];let A=(0,tu.useStableEvent)(a);M[3]!==P?(i=function(){let e;T(t8(e=P.trim())||e.includes("@")?{contact:e,name:""}:{contact:"",name:e})},M[3]=P,M[4]=i):i=M[4];let O=(0,tu.useStableEvent)(i);return M[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(tI,{children:"Customer"}),M[5]=s):s=M[5],M[6]!==A||M[7]!==N?(o=(0,t.jsx)(U.Input,{autoComplete:"off",autoFocus:!0,inputMode:"search",onChange:A,placeholder:"Search name, phone, or email",value:N}),M[6]=A,M[7]=N,M[8]=o):o=M[8],M[9]!==D?(l=(0,t.jsx)(nn,{isSearching:D}),M[9]=D,M[10]=l):l=M[10],M[11]!==w||M[12]!==R?(c=(0,t.jsx)(nr,{customers:R,onSelect:w}),M[11]=w,M[12]=R,M[13]=c):c=M[13],M[14]!==L||M[15]!==O||M[16]!==P?(u=(0,t.jsx)(na,{onCreate:O,search:P,visible:L}),M[14]=L,M[15]=O,M[16]=P,M[17]=u):u=M[17],M[18]!==I||M[19]!==w||M[20]!==k?(d=I?(0,t.jsx)(ne,{initial:I,onCaptured:w,spaceId:k}):null,M[18]=I,M[19]=w,M[20]=k,M[21]=d):d=M[21],M[22]!==o||M[23]!==l||M[24]!==c||M[25]!==u||M[26]!==d?(m=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[s,o,l,c,u,d]}),M[22]=o,M[23]=l,M[24]=c,M[25]=u,M[26]=d,M[27]=m):m=M[27],m}function nn(e){let r,a=(0,n.c)(1),{isSearching:s}=e;return s?(a[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:"Searching…"}),a[0]=r):r=a[0],r):null}function nr(e){let r,a,i=(0,n.c)(7),{customers:s,onSelect:o}=e;if(0===s.length)return null;if(i[0]!==s||i[1]!==o){let e;i[3]!==o?(e=e=>(0,t.jsx)(t9,{customer:e,onSelect:o},e.customerId),i[3]=o,i[4]=e):e=i[4],r=s.map(e),i[0]=s,i[1]=o,i[2]=r}else r=i[2];return i[5]!==r?(a=(0,t.jsx)("div",{className:"flex flex-col gap-2",children:r}),i[5]=r,i[6]=a):a=i[6],a}function na(e){let a,i,s=(0,n.c)(4),{onCreate:o,search:l,visible:c}=e;return c?(s[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(t1.UserPlus,{}),s[0]=a):a=s[0],s[1]!==o||s[2]!==l?(i=(0,t.jsxs)(r.Button,{className:"flex-row justify-start",onClick:o,size:"tile",variant:"dashed",children:[a,'+ Add "',l,'" as a new customer']}),s[1]=o,s[2]=l,s[3]=i):i=s[3],i):null}function ni(e){let a,i,s,o,l=(0,n.c)(15),{spaceId:c}=e,u=(0,p.useCustomer)(),d=(0,p.useSetCustomer)();l[0]!==d?(a=function(){d(null)},l[0]=d,l[1]=a):a=l[1];let m=(0,tu.useStableEvent)(a);l[2]!==d?(i=function(e){d(e),tN("customer")},l[2]=d,l[3]=i):i=l[3];let h=(0,tu.useStableEvent)(i);if(null===c)return null;if(u){let e,n,a,i;return l[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(t2.UserRound,{}),l[4]=e):e=l[4],l[5]!==u?(n=t7(u),l[5]=u,l[6]=n):n=l[6],l[7]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(y.X,{}),l[7]=a):a=l[7],l[8]!==m||l[9]!==n?(i=(0,t.jsxs)(r.Button,{onClick:m,variant:"secondary",children:[e,n,a]}),l[8]=m,l[9]=n,l[10]=i):i=l[10],i}return l[11]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)(r.Button,{variant:"surface",children:[(0,t.jsx)(t1.UserPlus,{}),"Customer"]}),l[11]=s):s=l[11],l[12]!==h||l[13]!==c?(o=(0,t.jsx)(t_,{popoverId:"customer",trigger:s,children:(0,t.jsx)(nt,{onCaptured:h,spaceId:c})}),l[12]=h,l[13]=c,l[14]=o):o=l[14],o}var ns=e.i(14846);function no(e){let a,s,o,l,c=(0,n.c)(14),{currency:u,rewards:d}=e,m=(0,p.useCustomer)(),h=(0,p.useRedeemRewards)(),f=(0,p.useSetRedeemRewards)();if(!(m&&d))return null;let x=d.redeemableMinor>0;c[0]!==d.tier?(a=(0,t.jsx)(q.Badge,{variant:"secondary",children:d.tier}),c[0]=d.tier,c[1]=a):a=c[1];let g=1===d.points?"1 point":`${d.points} points`;return c[2]!==g?(s=(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:g}
1),c[2]=g,c[3]=s):s=c[3],c[4]!==x||c[5]!==u||c[6]!==h||c[7]!==d.redeemableMinor||c[8]!==f?(o=x?(0,t.jsxs)(r.Button,{onClick:()=>f(!h),variant:h?"default":"surface",children:[(0,t.jsx)(ns.Gift,{}),h?`${(0,j.formatPriceMinor)(d.redeemableMinor,u)} off`:`Redeem ${(0,j.formatPriceMinor)(d.redeemableMinor,u)}`]}):null,c[4]=x,c[5]=u,c[6]=h,c[7]=d.redeemableMinor,c[8]=f,c[9]=o):o=c[9],c[10]!==a||c[11]!==s||c[12]!==o?(l=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,s,o]}),c[10]=a,c[11]=s,c[12]=o,c[13]=l):l=c[13],l}var nl=e.i(757234),nl=nl,nc=e.i(863829),nc=nc,nu=e.i(376544);function nd(e){let a,i,s,o,l,c,u,d,m=(0,n.c)(25),{currency:p,itemCount:h,onCard:f,onCash:x,onComplete:v,stage:y,totalMinor:b}=e;if(m[0]!==p||m[1]!==h||m[2]!==y||m[3]!==b){s=Symbol.for("react.early_return_sentinel");e:{if("none"===(a=(0,nu.resolveSalePrimary)({currency:p,itemCount:h,stage:y,totalMinor:b})).kind){s=null;break e}i=(0,j.formatPriceMinor)(a.totalMinor,p)}m[0]=p,m[1]=h,m[2]=y,m[3]=b,m[4]=a,m[5]=i,m[6]=s}else a=m[4],i=m[5],s=m[6];if(s!==Symbol.for("react.early_return_sentinel"))return s;let S=i;if("complete"===a.kind){let e,n;return m[7]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(g.Check,{}),m[7]=e):e=m[7],m[8]!==v||m[9]!==S?(n=(0,t.jsxs)(r.Button,{className:"w-full",onClick:v,size:"panelPrimary",children:[e,"Complete sale · ",S]}),m[8]=v,m[9]=S,m[10]=n):n=m[10],n}if(!a.canChargeCard){let e,n;return m[11]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(nl.default,{}),m[11]=e):e=m[11],m[12]!==x||m[13]!==S?(n=(0,t.jsxs)(r.Button,{className:"w-full",onClick:x,size:"panelPrimary",children:[e,"Take cash · ",S]}),m[12]=x,m[13]=S,m[14]=n):n=m[14],n}return m[15]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(nc.default,{}),m[15]=o):o=m[15],m[16]!==f||m[17]!==S?(l=(0,t.jsxs)(r.Button,{className:"w-full",onClick:f,size:"panelPrimary",children:[o,"Ready for payment · ",S]}),m[16]=f,m[17]=S,m[18]=l):l=m[18],m[19]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(nl.default,{}),m[19]=c):c=m[19],m[20]!==x?(u=(0,t.jsxs)(r.Button,{className:"w-full",onClick:x,size:"panelPrimary",variant:"surface",children:[c,"Cash"]}),m[20]=x,m[21]=u):u=m[21],m[22]!==l||m[23]!==u?(d=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[l,u]}),m[22]=l,m[23]=u,m[24]=d):d=m[24],d}function nm(e){let r,a,i,s,o,l,c,u,d,m,h,f,x=(0,n.c)(48),{onCard:g,onCash:v,onComplete:y,onCustomize:j,taxRateBps:b}=e,S=(0,p.useCartLines)(),C=(0,p.useSelectedSpaceId)(),M=(0,p.useSetQuantity)(),k=(0,p.useClearCart)(),N=(0,p.useSaleStage)(),_=(0,p.useReadySale)();x[0]!==g||x[1]!==_?(r=()=>{_(),g()},x[0]=g,x[1]=_,x[2]=r):r=x[2];let I=r;x[3]!==v||x[4]!==_?(a=()=>{_(),v()},x[3]=v,x[4]=_,x[5]=a):a=x[5];let T=a;x[6]!==y||x[7]!==_?(i=()=>{_(),y()},x[6]=y,x[7]=_,x[8]=i):i=x[8];let P=i,R=S[0]?.currency??"usd",{amounts:D,rewards:L}=w(b);x[9]!==S?(s=S.reduce(np,0),x[9]=S,x[10]=s):s=x[10];let A=s,O=S.length>0;return x[11]!==k||x[12]!==A||x[13]!==O?(o=(0,t.jsx)(nh,{canVoid:O,itemCount:A,onClear:k}),x[11]=k,x[12]=A,x[13]=O,x[14]=o):o=x[14],x[15]!==S||x[16]!==j||x[17]!==M?(l=(0,t.jsx)(nf,{lines:S,onCustomize:j,onSetQuantity:M}),x[15]=S,x[16]=j,x[17]=M,x[18]=l):l=x[18],x[19]!==D.discountMinor||x[20]!==D.tipMinor||x[21]!==R||x[22]!==S.length||x[23]!==C?(c=S.length>0?(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(ni,{spaceId:C}),(0,t.jsx)(tz,{currency:R,discountMinor:D.discountMinor}),(0,t.jsx)(tW,{currency:R,tipMinor:D.tipMinor})]}):null,x[19]=D.discountMinor,x[20]=D.tipMinor,x[21]=R,x[22]=S.length,x[23]=C,x[24]=c):c=x[24],x[25]!==R||x[26]!==L?(u=(0,t.jsx)(no,{currency:R,rewards:L}),x[25]=R,x[26]=L,x[27]=u):u=x[27],x[28]!==D||x[29]!==R?(d=(0,t.jsx)(th,{amounts:D,currency:R}),x[28]=D,x[29]=R,x[30]=d):d=x[30],x[31]!==D.totalMinor||x[32]!==R||x[33]!==I||x[34]!==T||x[35]!==P||x[36]!==A||x[37]!==N?(m=(0,t.jsx)(nd,{currency:R,itemCount:A,onCard:I,onCash:T,onComplete:P,stage:N,totalMinor:D.totalMinor}),x[31]=D.totalMinor,x[32]=R,x[33]=I,x[34]=T,x[35]=P,x[36]=A,x[37]=N,x[38]=m):m=x[38],x[39]!==d||x[40]!==m||x[41]!==c||x[42]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t p-4",children:[c,u,d,m]}),x[39]=d,x[40]=m,x[41]=c,x[42]=u,x[43]=h):h=x[43],x[44]!==h||x[45]!==o||x[46]!==l?(f=(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[o,l,h]}),x[44]=h,x[45]=o,x[46]=l,x[47]=f):f=x[47],f}function np(e,t){return e+t.quantity}function nh(e){let a,s,o,l,c=(0,n.c)(11),{canVoid:u,itemCount:d,onClear:m}=e,p=1===d?"1 item":`${d} items`,h=`Current sale \xb7 ${p}`;c[0]!==p?(a=(0,t.jsxs)(i.Text,{as:"span",variant:"caption",children:["· ",p]}),c[0]=p,c[1]=a):a=c[1],c[2]!==h||c[3]!==a?(s=(0,t.jsx)("div",{className:"min-w-0",children:(0,t.jsxs)(i.H3,{"aria-label":h,"aria-live":"polite",className:"flex items-baseline gap-2",variant:"panel",children:["Current sale",a]})}),c[2]=h,c[3]=a,c[4]=s):s=c[4];let f=!u;return c[5]!==m||c[6]!==f?(o=(0,t.jsx)(r.Button,{disabled:f,onClick:m,variant:"ghost",children:"Clear"}),c[5]=m,c[6]=f,c[7]=o):o=c[7],c[8]!==s||c[9]!==o?(l=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b px-4 py-3",children:[s,o]}),c[8]=s,c[9]=o,c[10]=l):l=c[10],l}function nf(e){let r,a,i=(0,n.c)(10),{lines:s,onCustomize:o,onSetQuantity:l}=e;if(0===s.length){let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(x.ScrollArea,{className:"min-h-0 flex-1",classNameViewport:"px-4",children:(0,t.jsx)(ed.Empty,{children:(0,t.jsxs)(ed.EmptyHeader,{children:[(0,t.jsx)(ed.EmptyTitle,{children:"Ready for the next one"}),(0,t.jsx)(ed.EmptyDescription,{children:"Tap anything in the case and it lands here."})]})})}),i[0]=e):e=i[0],e}if(i[1]!==s||i[2]!==o||i[3]!==l){let e;i[5]!==o||i[6]!==l?(e=e=>(0,t.jsx)(tc,{line:e,onCustomize:()=>
1o(e.lineId),onDecrement:()=>l(e.lineId,e.quantity-1),onIncrement:()=>l(e.lineId,e.quantity+1),onSetQuantity:t=>l(e.lineId,t)},e.lineId),i[5]=o,i[6]=l,i[7]=e):e=i[7],r=s.map(e),i[1]=s,i[2]=o,i[3]=l,i[4]=r}else r=i[4];return i[8]!==r?(a=(0,t.jsx)(x.ScrollArea,{className:"min-h-0 flex-1",classNameViewport:"px-4",children:(0,t.jsx)("div",{className:"divide-y",children:r})}),i[8]=r,i[9]=a):a=i[9],a}var nl=nl,nx=e.i(179980);let ng=[100,500,1e3,2e3,5e3];async function nv(e,t){var n;if(n=t.totalMinor,!(t.cashTenderedMinor>=n))throw Error("Cash tendered is less than the total due.");let r=await e.addCashTender({amountMinor:t.totalMinor,cashTenderedMinor:t.cashTenderedMinor,clientTenderId:t.clientTenderId,earn:t.earn,orderId:t.orderId,redeem:t.redeem,sessionId:t.sessionId});return{changeGivenMinor:r.changeGivenMinor,paymentStatus:r.paymentStatus}}function ny({currency:e,onConfirm:n,onOpenChange:a,open:s,totalMinor:o}){let l=(0,m.usePortalContainer)(),[c,u]=(0,X.useState)(null),[d,p]=(0,X.useState)(!1),h=c??et(o),f=ee(h),x=f>=o,g=(0,nx.computeCashChange)(o,f),v=()=>{d||(u(null),a(!1))},y=async e=>{if(e.preventDefault(),x&&!d){p(!0);try{await n(f),u(null)}finally{p(!1)}}};return(0,t.jsx)(V.Dialog,{onOpenChange:e=>!e&&v(),open:s,children:(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[400px]",container:l,children:[(0,t.jsxs)(V.DialogHeader,{children:[(0,t.jsx)(V.DialogTitle,{children:"Cash"}),(0,t.jsxs)(V.DialogDescription,{children:[(0,j.formatPriceMinor)(o,e)," due."]})]}),(0,t.jsxs)("form",{onSubmit:y,children:[(0,t.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:(function(e){if(e<=0)return[];let t=[];for(let n of ng){if(t.length>=3)break;let r=Math.ceil(e/n)*n;r===e||t.includes(r)||t.push(r)}return[e,...t]})(o).map(n=>(0,t.jsx)(r.Button,{onClick:()=>u(et(n)),type:"button",variant:f===n?"secondary":"surface",children:n===o?"Exact":(0,j.formatPriceMinor)(n,e)},n))}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(H.Label,{htmlFor:"pos-cash-tendered",children:"Amount tendered"}),(0,t.jsx)(U.Input,{autoFocus:!0,id:"pos-cash-tendered",inputMode:"decimal",onChange:e=>u(e.target.value),placeholder:"0.00",value:h})]}),x?(0,t.jsxs)("div",{className:"flex items-end justify-between",children:[(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Change due"}),(0,t.jsx)(i.Text,{as:"span",variant:"statValue",children:(0,j.formatPriceMinor)(g,e)})]}):(0,t.jsxs)(i.Muted,{children:["Enter at least ",(0,j.formatPriceMinor)(o,e),"."]})]}),(0,t.jsxs)(V.DialogFooter,{children:[(0,t.jsx)(r.Button,{onClick:v,type:"button",variant:"surface",children:"Cancel"}),(0,t.jsxs)(r.Button,{disabled:!x||d,type:"submit",children:[(0,t.jsx)(nl.default,{}),"Take cash"]})]})]})]})})}var nj=e.i(735826),nb=e.i(879520);function nS(e){let r,a,i=(0,n.c)(5),{html:s,onPrinted:o}=e;i[0]!==o?(r=e=>{let t=e.currentTarget.contentWindow;t&&(t.focus(),t.print()),o()},i[0]=o,i[1]=r):r=i[1];let l=r;return i[2]!==l||i[3]!==s?(a=(0,t.jsx)("iframe",{"aria-hidden":!0,className:"pointer-events-none absolute size-0",onLoad:l,srcDoc:s,tabIndex:-1,title:"Receipt"}),i[2]=l,i[3]=s,i[4]=a):a=i[4],a}let nC=e.i(868280).z.string().email();function nM({orderId:e}){let a,s,o,l,c,u,d,m,p,h,{receipt:f}=((o=(0,n.c)(5))[0]!==e?(a=e?{orderId:e}:"skip",o[0]=e,o[1]=a):a=o[1],c=(l=(0,S.useQuery)(b.api.commerce.pos.receipts.getOrderReceipt,a))??null,u=null!==e&&void 0===l,o[2]!==c||o[3]!==u?(s={receipt:c,isLoading:u},o[2]=c,o[3]=u,o[4]=s):s=o[4],s),x=(m=(0,n.c)(3),p=(0,S.useMutation)(b.api.commerce.orders.mutations.editOrder),h=(0,S.useAction)(b.api.commerce.pos.receipts.emailOrderReceipt),m[0]!==p||m[1]!==h?(d=async e=>(e.customer.email!==e.email&&await p({orderId:e.orderId,customer:{...e.customer,email:e.email}}),await h({orderId:e.orderId})),m[0]=p,m[1]=h,m[2]=d):d=m[2],d),[g,v]=(0,X.useState)(null),[y,j]=(0,X.useState)(!1),[C,M]=(0,X.useState)(0),w=g??f?.customer.email??"",k=!!f&&nC.safeParse(w.trim()).success&&!y,N=async()=>{if(f){j(!0);try{let t=await x({customer:f.customer,email:w.trim(),orderId:e});K.toast.success(t.sent?`Receipt sent to ${t.email}`:"No email on file for this sale.")}catch(e){K.toast.error(e instanceof Error?e.message:"Couldn't send the receipt.")}finally{j(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Receipt"}),(0,t.jsxs)(r.Button,{disabled:!f,onClick:()=>M(e=>e+1),variant:"surface",children:[(0,t.jsx)(nb.Printer,{}),"Print receipt"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(U.Input,{"aria-label":"Receipt email address",inputMode:"email",onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k&&N()},placeholder:"Email address",type:"email",value:w}),(0,t.jsxs)(r.Button,{disabled:!k,onClick:N,variant:"surface",children:[(0,t.jsx)(nj.Mail,{}),"Send"]})]}),C>0&&f?(0,t.jsx)(nS,{html:f.html,onPrinted:()=>M(0)},C):null]})}function nw(e){let a,s,o,l,c,u,d,p,h,f=(0,n.c)(25),{onOpenChange:x,open:g,sale:v}=e,y=(0,m.usePortalContainer)();return f[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(V.DialogTitle,{children:"Sale complete"}),f[0]=a):a=f[0],f[1]!==v.currency||f[2]!==v.totalMinor?(s=(0,j.formatPriceMinor)(v.totalMinor,v.currency),f[1]=v.currency,f[2]=v.totalMinor,f[3]=s):s=f[3],f[4]!==v.orderNumber||f[5]!==s?(o=(0,t.jsxs)(V.DialogHeader,{children:[a,(0,t.jsxs)(V.DialogDescription,{children:["Paid ",s," · Order"," ",v.orderNumber]})]}),f[4]=v.orderNumber,f[5]=s,f[6]=o):o=f[6],f[7]!==v.changeGivenMinor||f[8]!==v.currency?(l=v.changeGivenMinor>0?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1 py-4",children:[(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Change due"}),(0,t.jsx)(i.H1,{variant:"hero",children:(0,j.formatPriceMinor)(v.changeGivenMinor,v.currency)})]}):null,f[7]=v.changeGivenMinor,f[8]=v.currency,f[9]=l):l=f[9],f[10]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(ep.Separator,{}),f[10]=c):c=f[10],f[11]!==v.orderId?(u=(0,t.jsx)(nM,{orderId:v.orderId}),f[11]=v.orderId,f[12]=u):u=f[12],f[13]!==x?(d=(0,t.jsx)(V.DialogFooter,{children:(0,t.jsx)(r.Button,{onClick:()=>x(!1),type:"button",children:"Done"})}
1),f[13]=x,f[14]=d):d=f[14],f[15]!==y||f[16]!==o||f[17]!==l||f[18]!==u||f[19]!==d?(p=(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[400px]",container:y,children:[o,l,c,u,d]}),f[15]=y,f[16]=o,f[17]=l,f[18]=u,f[19]=d,f[20]=p):p=f[20],f[21]!==x||f[22]!==g||f[23]!==p?(h=(0,t.jsx)(V.Dialog,{onOpenChange:x,open:g,children:p}),f[21]=x,f[22]=g,f[23]=p,f[24]=h):h=f[24],h}async function nk(e,t){if(!(t.totalMinor<=0))throw Error("Only a sale that costs nothing can be completed as a comp.");return{paymentStatus:(await e.addCompTender({clientTenderId:t.clientTenderId,earn:t.earn,orderId:t.orderId,redeem:t.redeem,sessionId:t.sessionId})).paymentStatus}}function nN(e){let t=e.modifiers.map(e=>`${e.choiceId}:${e.name}:${e.priceMinor}x${e.quantity}`).join(",");return`${e.productId}:${e.variantId??""}:${e.name}:${e.unitPriceMinor}x${e.quantity}[${t}]`}async function n_(e,t){var n,r,a;let i,s,o,l,c=(0,C.computeSaleAmounts)(t.lines,{discount:t.discount,rewardsRedemptionMinor:t.rewardsRedemptionMinor,taxRateBps:t.taxRateBps,tip:t.tip}),u=(n=Date.now(),r=Math.random(),i=Math.floor(n).toString(36).toUpperCase(),s=Math.floor(1679616*r).toString(36).toUpperCase().padStart(4,"0"),`POS-${i}-${s}`),d=t.lines.map(e=>({addOns:e.modifiers.map(e=>({choiceId:e.choiceId,groupId:e.groupId,name:`${e.groupName}: ${e.name}`,priceMinor:e.priceMinor,quantity:e.quantity})),lineSubtotalMinor:e.unitPriceMinor*e.quantity,lineTotalMinor:(0,C.computeLineTotalMinor)(e),name:e.name,productId:e.productId,quantity:e.quantity,unitPriceMinor:e.unitPriceMinor,variantId:e.variantId,variantLabel:e.variantLabel})),m=await e.createOrder({currency:t.currency,customer:t.customer?{email:t.customer.email,name:t.customer.name,phone:t.customer.phone}:{},discountMinor:c.discountMinor,fulfillment:{method:"pickup"},lineItems:d,locationId:t.locationId,notes:function(e){if("comp"===e.kind&&e.reason)return`POS comp reason: ${e.reason.replaceAll("_"," ")}`}(t.discount),orderNumber:u,owner:t.owner,source:"pos",tender:{kind:"awaiting_settlement",rail:"register"},adjustments:(o=(a={amounts:c,discount:t.discount}).amounts.discountMinor-a.amounts.rewardsRedemptionMinor,l=[],o>0&&l.push({amountMinor:o,kind:"discount",label:function(e){switch(e.kind){case"none":case"amount":return"Discount";case"comp":return e.reason?`Comp — ${e.reason.replaceAll("_"," ")}`:"Comp";case"percent":return`Discount ${e.bps/100}%`;default:return(0,td.assertNever)(e)}}(a.discount)}),a.amounts.rewardsRedemptionMinor>0&&l.push({amountMinor:a.amounts.rewardsRedemptionMinor,kind:"redemption",label:"Rewards redemption"}),l),subtotalMinor:c.subtotalMinor,taxMinor:c.taxMinor,tipMinor:c.tipMinor,totalMinor:c.totalMinor});return await e.applyOrder({orderId:m}),{amounts:c,currency:t.currency,orderId:m,orderNumber:u,totalMinor:c.totalMinor}}function nI(e){var t,n;let{amounts:r,customerId:a}=e;if(!a)return{};let i={},s=(t=r.rewardsRedemptionMinor)<=0?0:100*Math.floor(t/500);s>0&&(i.redeem={customerId:a,points:s});let o=(n=r.subtotalMinor-r.discountMinor)<=0?0:Math.floor(n/100);return o>0&&(i.earn={customerId:a,points:o}),i}function nT(){let e,t,r,a,i,s=(0,n.c)(16),o=(0,S.useMutation)(b.api.commerce.orders.mutations.createOrder),l=(0,S.useMutation)(b.api.commerce.inventory.mutations.applyOrder),c=(0,S.useMutation)(b.api.commerce.pos.tenders.addCashTender),u=(0,S.useMutation)(b.api.commerce.pos.tenders.addCompTender),d=(0,S.useAction)(b.api.commerce.pos.refunds.abandonPosOrder);s[0]!==l||s[1]!==o?(e=e=>n_({applyOrder:l,createOrder:o},e),s[0]=l,s[1]=o,s[2]=e):e=s[2];let m=e;s[3]!==d?(t=async e=>{await d({orderId:e.orderId})},s[3]=d,s[4]=t):t=s[4];let p=t;s[5]!==u||s[6]!==m?(r=async e=>{let t=await m(e),n=nI({amounts:t.amounts,customerId:e.customer?.customerId??null});return await nk({addCompTender:u},{clientTenderId:crypto.randomUUID(),earn:n.earn,orderId:t.orderId,redeem:n.redeem,sessionId:e.sessionId,totalMinor:t.totalMinor}),{...t,changeGivenMinor:0}},s[5]=u,s[6]=m,s[7]=r):r=s[7];let h=r;s[8]!==c||s[9]!==m?(a=async e=>{let t=await m(e),n=nI({amounts:t.amounts,customerId:e.customer?.customerId??null}),r=await nv({addCashTender:c},{cashTenderedMinor:e.cashTenderedMinor,clientTenderId:crypto.randomUUID(),earn:n.earn,orderId:t.orderId,redeem:n.redeem,sessionId:e.sessionId,totalMinor:t.totalMinor});return{...t,changeGivenMinor:r.changeGivenMinor}},s[8]=c,s[9]=m,s[10]=a):a=s[10];let f=a;return s[11]!==p||s[12]!==f||s[13]!==h||s[14]!==m?(i={abandonOrder:p,charge:f,completeFreeSale:h,prepareOrder:m},s[11]=p,s[12]=f,s[13]=h,s[14]=m,s[15]=i):i=s[15],i}function nP(e){console.error("[pos] clearing the pending kiosk customer failed",e)}function nR(e){return e.itemCount<=0?"idle":"payable"===e.stage?"collect":"display"}let nD={idle:{idle:{cancelCollect:!1,step:"none"},display:{cancelCollect:!1,step:"show_cart"},collect:{cancelCollect:!1,step:"begin_collect"}},display:{idle:{cancelCollect:!1,step:"clear"},display:{cancelCollect:!1,step:"show_cart"},collect:{cancelCollect:!1,step:"begin_collect"}},collect:{idle:{cancelCollect:!0,step:"clear"},display:{cancelCollect:!0,step:"show_cart"},collect:{cancelCollect:!1,step:"none"}}};function nL(e){return nD[e.from][e.to]}function nA(e){return e.priceMinor*e.quantity}function nO(e){return e.quantity>1?`${e.name} \xd7${e.quantity}`:e.name}function nE(e){var t;let n,r,a=[{amountMinor:e.unitPriceMinor*e.quantity,description:(n=T((t={folded:(e.modifiers??[]).filter(e=>0===nA(e)).map(nO),name:e.name,variantLabel:e.variantLabel}).name),r=t.variantLabel?`${n} \xb7 ${t.variantLabel}`:n,0===t.folded.length?r:`${r} (${t.folded.join(", ")})`),quantity:e.quantity}];for(let t of e.modifiers??[]){let e=nA(t);0!==e&&a.push({amountMinor:e,description:`+ ${t.name}`,quantity:t.quantity})}return a}function nB(e){console.error("POS reader display did not clear on unmount:",e)}function n$(e,t){return e+t.quantity}
1function nz(e){return e.hasSession?{kind:"ready"}:"cash"===e.tender?{kind:"count_float"}:{kind:"open_silently"}}var nF="https://js.stripe.com/terminal/v1",nq=function(){var e=document.createElement("script");e.src=nF;var t=document.head||document.body;if(!t)throw Error("Expected document.body not to be null. Terminal requires a <body> element.");return t.appendChild(e),e},nV=null,nU=Promise.resolve().then(function(){return null!==nV?nV:nV=new Promise(function(e,t){if("u"<typeof window)return void e(null);if(window.StripeTerminal)return void e(window.StripeTerminal);var n=document.querySelector('script[src="'.concat(nF,'"], script[src="').concat(nF,'/"]'))||nq();n.addEventListener("load",function(){window.StripeTerminal?e(window.StripeTerminal):t(Error("StripeTerminal not available"))}),n.addEventListener("error",function(){t(Error("Failed to load StripeTerminal"))})})}),nH=!1;async function nG(e){let t=await (nH=!0,nU);return t?t.create({onFetchConnectionToken:e.onFetchConnectionToken,onUnexpectedReaderDisconnect:e.onUnexpectedReaderDisconnect??(()=>void 0)}):null}nU.catch(function(e){nH||console.warn(e)});let nQ=(0,eN.stripeCheckoutIsLiveMode)()?"No paired reader found. Connect a Stripe reader to this brand and try again.":"No simulated reader available. Check the Terminal SDK setup and try again.";var nW=e.i(362543),nX=e.i(508491),nX=nX;let nK=new Set(["ECONNRESET","ETIMEDOUT","EAI_AGAIN","StripeAPIError","StripeConnectionError","StripeRateLimitError"]);function nZ(e,t,n){return e.isCancelRequested?.()?{kind:"cancelled"}:{kind:"failed",stage:t,message:n}}async function nJ(e){let t,n=e.rewardsAsk;if(n&&!e.isCancelRequested?.()){e.onStage?.("rewards");try{t=await n.run()}catch(e){console.error("POS rewards ask did not run:",e);return}if("attached"===t.kind)try{await e.awardRewards?.()}catch(e){console.error("POS reader rewards did not post:",e)}}}async function nY(e,t){var n;let r;e.onStage?.("creating");try{r=await e.createIntent({sessionId:t.sessionId,orderId:t.orderId,clientTenderId:t.clientTenderId,amountMinor:t.amountMinor})}catch(t){return nZ(e,"creating",(0,e8.userFacingErrorMessage)(t,"Could not start the card charge."))}if(e.onTender?.(r.tenderId),"captured"===r.status)return await nJ(e),{kind:"settled",tenderId:r.tenderId,paymentStatus:"paid"};if(!r.clientSecret)return{kind:"failed",stage:"creating",message:"The card charge could not be prepared. Try again."};if(e.isCancelRequested?.())return{kind:"cancelled"};e.onStage?.("collecting");let a=await e.charger.collectPaymentMethod(r.clientSecret,"skip"===(n=t.tipping??{kind:"skip"}).kind?{config_override:{skip_tipping:!0}}:{config_override:{skip_tipping:!1},tip_configuration:n.configuration});if("error"in a)return nZ(e,"collecting",a.error.message);e.onStage?.("processing");let i=await e.charger.processPayment(a.paymentIntent);if("error"in i)return nZ(e,"processing",i.error.message);e.onStage?.("capturing");for(let n=1;n<=3;n+=1)try{let n=await e.capture({earn:t.earn,redeem:t.redeem,tenderId:r.tenderId});return await nJ(e),{kind:"settled",tenderId:r.tenderId,paymentStatus:n.paymentStatus}}catch(e){if(n<3&&function(e){let t=function(e){if("object"!=typeof e||null===e||!("statusCode"in e))return null;let{statusCode:t}=e;return"number"==typeof t?t:null}(e);if(408===t||409===t||425===t||429===t||null!==t&&t>=500)return!0;let n=function(e){if("object"!=typeof e||null===e||!("code"in e))return null;let{code:t}=e;return"string"==typeof t?t:null}(e);if(n&&nK.has(n))return!0;let r=function(e){if("object"!=typeof e||null===e||!("type"in e))return null;let{type:t}=e;return"string"==typeof t?t:null}(e);if(r&&nK.has(r))return!0;if(!(e instanceof Error))return!1;let a=e.message.toLowerCase();return a.includes("timeout")||a.includes("temporarily")||a.includes("network")||a.includes("rate limit")||a.includes("try again")}(e))continue;break}return{kind:"failed",stage:"capturing",message:"Card authorized but not captured. Void this payment before handing off the order."}}let n0=Symbol("timed-out");async function n1(e,t){try{let n=await n2(e,12e3);if(n===n0)return{kind:"refused",message:"The reader isn't answering. Retry, or go back to the sale and check the customer's screen."};if("captured"===n.status||"too_late"===n.status)return{kind:"refused",message:"captured"===n.status?"This payment already went through. Refund it instead of cancelling.":"The payment is already going through. Wait for it to finish, then refund if you need to."};return{kind:"cancelled",readerCleared:t||n.readerCleared}}catch(e){return{kind:"refused",message:e instanceof Error?e.message:"Could not cancel the charge. Check the reader."}}}async function n2(e,t){let n,r=new Promise(e=>{n=setTimeout(()=>e(n0),t)});try{return await Promise.race([e,r])}finally{clearTimeout(n)}}let n3=["rewards","creating","collecting"];function n4({amounts:e,currency:n,input:a,onComplete:i,onOpenChange:s,open:o,owner:l,session:c,stage:u,terminal:d}){var p;let h=(0,m.usePortalContainer)(),f=ez(l),x=eL(l),g=function(){let e=(0,S.useAction)(b.api.commerce.pos.stripe.card.createCardTenderIntent),t=(0,S.useAction)(b.api.commerce.pos.stripe.card.captureCardTender),n=(0,S.useAction)(b.api.commerce.pos.stripe.card.cancelCardTender),r=(0,S.useAction)(b.api.commerce.pos.stripe.reader_inputs.collectRewardsOnReader),a=(0,S.useAction)(b.api.commerce.pos.stripe.reader_inputs.cancelReaderRewardsAsk),i=(0,S.useMutation)(b.api.commerce.pos.reader_prompts.awardReaderRewards),[s,o]=(0,X.useState)(null),[l,c]=(0,X.useState)(!1),u=(0,X.useRef)(!1),d=(0,X.useRef)(null),m=(0,X.useRef)(!1),p=(0,X.useRef)(null),h=(0,X.useCallback)(async n=>{u.current=!1,d.current=null,m.current=!1,c(!1),p.current=null;let{readerId:a,rewardsAskEnabled:s}=n,l=async()=>{p.current={orderId:n.orderId,sessionId:n.sessionId};try{return await r({orderId:n.orderId,readerId:a??"",sessionId:n.sessionId})}finally{p.current=null}},h=await nY({awardRewards:async()=>{await i({orderId:n.orderId,sessionId:n.sessionId})},charger:n.charger,createIntent:t=>e(t),capture:e=>t(e),isCancelRequested:()=>u.current,onStage:e=>
1{"rewards"===e&&(m.current=!0,c(!0)),o(e)},onTender:e=>{d.current=e},rewardsAsk:a&&s?{run:l}:void 0},{sessionId:n.sessionId,orderId:n.orderId,amountMinor:n.amountMinor,clientTenderId:n.clientTenderId,earn:n.earn,redeem:n.redeem,tipping:n.tipping});return o(null),"settled"===h.kind&&c(!0),h},[i,e,t,r]),f=(0,X.useCallback)(async()=>{let e=p.current;if(!e)return!1;p.current=null;try{let{readerCleared:t}=await a(e);return t}catch(e){return console.error("POS rewards ask did not cancel:",e),!1}},[a]);return{cancel:(0,X.useCallback)(async e=>{if(u.current=!0,m.current)return{kind:"cancelled",readerCleared:!p.current||await f()};o("cancelling");let t=await f(),r=await n2(e.charger.cancelCollectPaymentMethod(),8e3),a=r!==n0&&!("error"in r),i=d.current;if(!i)return o(null),{kind:"cancelled",readerCleared:a||t};let s=await n1(n({tenderId:i,readerId:e.readerId??void 0}),a||t);return"refused"===s.kind&&(u.current=!1),s},[n,f]),isSettled:l,stage:s,run:h}}(),{abandonOrder:v,prepareOrder:y}=nT(),[C,M]=(0,X.useState)(!1),[w,k]=(0,X.useState)(!1),[N,_]=(0,X.useState)(null),[I,T]=(0,X.useState)(!1),P=(0,X.useRef)(null),R=(0,X.useRef)(!1),D=(0,X.useRef)(0),L=(0,X.useRef)(0),{connect:A}=d,O=d.status,E=e.totalMinor;(0,X.useEffect)(function(){o&&(_(null),T(!1),("idle"===O||"error"===O)&&A())},[o,A,O]);let B=(0,X.useCallback)(async()=>{let e=[a.owner.ownerType,a.owner.ownerId,a.sessionId,a.locationId,a.currency,String(a.taxRateBps),function(e){switch(e.kind){case"none":return"none";case"comp":return`comp:${e.reason??"unrecorded"}`;case"percent":return`percent:${e.bps}`;case"amount":return`amount:${e.amountMinor}`;default:return(0,td.assertNever)(e)}}(a.discount),function(e){switch(e.kind){case"none":return"none";case"percent":return`percent:${e.bps}`;case"amount":return`amount:${e.amountMinor}`;default:return(0,td.assertNever)(e)}}(a.tip),String(a.rewardsRedemptionMinor),a.customer?.customerId??"walk-in",a.lines.map(nN).join("|")].join("~"),t=P.current;if(t?.signature===e)return t;t&&(P.current=null,await v(t.order).catch(()=>K.toast.error("Could not retire the previous attempt.")));let n={clientTenderId:crypto.randomUUID(),order:await y(a),signature:e};return P.current=n,n},[v,a,y]),$=(0,X.useCallback)(async()=>{if(!(d.charger&&c)||0!==D.current)return;L.current+=1;let e=L.current;D.current=e,M(!0),_(null);try{let e=await B(),t=nI({amounts:e.order.amounts,customerId:a.customer?.customerId??null}),n=await g.run({charger:d.charger,sessionId:c._id,orderId:e.order.orderId,amountMinor:e.order.totalMinor,clientTenderId:e.clientTenderId,earn:t.earn,readerId:d.readerId,redeem:t.redeem,rewardsAskEnabled:x.isEnabled,tipping:function(e){if(!e.settings.enabled||e.eligibleAmountMinor<=0||"none"!==e.cartTip.kind)return{kind:"skip"};let t=e.settings.presetBps.map(t=>{var n;return{amount:(n=e.eligibleAmountMinor,Math.max(0,Math.round(n*t/1e4))),label:`${Number((t/100).toFixed(2))}%`}}).filter(e=>e.amount>0);return 0===t.length?{kind:"skip"}:{kind:"prompt",configuration:{options:t,hide_custom_amount:!e.settings.allowCustom}}}({cartTip:a.tip,eligibleAmountMinor:e.order.amounts.subtotalMinor-e.order.amounts.discountMinor,settings:f.settings})});if("settled"===n.kind){P.current=null,i(e.order),s(!1);return}"failed"===n.kind&&_(n.message)}catch(e){_(e instanceof Error?e.message:"Card charge failed.")}finally{D.current===e&&(D.current=0,M(!1))}},[g,a.customer,a.tip,i,s,B,x.isEnabled,c,d.charger,d.readerId,f.settings]);(0,X.useEffect)(function(){if(!o){R.current=!1;return}"ready"===O&&c&&!R.current&&(R.current=!0,$())},[o,O,c,$]);let z=(0,X.useCallback)(async()=>{if(w)return;if(!(C&&d.charger))return void s(!1);k(!0);let e=await g.cancel({charger:d.charger,readerId:d.readerId});if(k(!1),"refused"===e.kind){_(e.message),T(!0);return}e.readerCleared||K.toast.error("Cancelled here, but the reader did not confirm. Check the customer's screen."),g.isSettled||(D.current=0,M(!1));let t=P.current;t&&(P.current={...t,clientTenderId:crypto.randomUUID()}),s(!1)},[g,w,C,s,d]),F=(0,X.useCallback)(()=>{let e=P.current;e&&(P.current={...e,clientTenderId:crypto.randomUUID()}),(0,K.toast)("Check the customer's screen. The charge may still be showing."),s(!1)},[s]),q=nR({itemCount:a.lines.reduce((e,t)=>
1e+t.quantity,0),stage:u}),U=(0,X.useRef)(!1),H=g.isSettled;(0,X.useEffect)(function(){if(!o){U.current=!1;return}if(!H){if("collect"===q){U.current=!0;return}U.current&&nL({from:"collect",to:q}).cancelCollect&&(U.current=!1,z())}},[H,o,q,z]);let G=w||!(null===(p=g.stage)||n3.includes(p)),Q="rewards"===g.stage?"Skip rewards":"Cancel";return(0,t.jsx)(V.Dialog,{onOpenChange:e=>!e&&z(),open:o,children:(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[400px]",container:h,children:[(0,t.jsxs)(V.DialogHeader,{children:[(0,t.jsx)(V.DialogTitle,{children:"Taking payment"}),(0,t.jsxs)(V.DialogDescription,{children:["Sending ",(0,j.formatPriceMinor)(E,n)," to the customer's terminal."]})]}),(0,t.jsx)("div",{className:"flex min-h-24 flex-col items-center justify-center gap-3 py-4 text-center",children:(0,t.jsx)(n5,{chargeError:N,isCancelling:w,isCharging:C,readerLabel:d.readerLabel,stageLabel:g.stage?function(e){switch(e){case"rewards":return"Asking about rewards on the terminal…";case"creating":return"Sending sale to the terminal…";case"collecting":return"Waiting for the customer — tap, insert, or swipe…";case"processing":return"Processing payment…";case"capturing":return"Completing the sale…";case"cancelling":return"Cancelling on the reader…";default:return"Working…"}}(g.stage):null,terminalError:d.error,terminalStatus:d.status})}),(0,t.jsxs)(V.DialogFooter,{children:[(0,t.jsx)(r.Button,{disabled:G,onClick:z,type:"button",variant:"surface",children:w?"Cancelling…":Q}),I?(0,t.jsx)(r.Button,{onClick:F,type:"button",variant:"surface",children:"Back to sale"}):null,"error"===O?(0,t.jsx)(r.Button,{disabled:C,onClick:()=>A(),type:"button",children:"Retry connection"}):null,N&&"error"!==O?(0,t.jsx)(r.Button,{disabled:C,onClick:$,type:"button",children:"Try again"}):null]})]})})}function n5(e){let r=(0,n.c)(22),{chargeError:a,isCancelling:i,isCharging:s,readerLabel:o,stageLabel:l,terminalError:c,terminalStatus:u}=e;if(i){let e;return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("p",{className:"text-sm",children:"Cancelling on the reader…"}),r[0]=e):e=r[0],e}if("connecting"===u){let e;return r[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:"Connecting to reader…"}),r[1]=e):e=r[1],e}if("error"===u){let e,n;r[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(nW.TriangleAlert,{className:"size-5 text-destructive"}),r[2]=e):e=r[2];let a=c??"Could not connect to the reader.";return r[3]!==a?(n=(0,t.jsxs)(t.Fragment,{children:[e,(0,t.jsx)("p",{className:"text-destructive text-sm",children:a})]}),r[3]=a,r[4]=n):n=r[4],n}if(a){let e,n,i,o;return r[5]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(nW.TriangleAlert,{className:"size-5 text-destructive"}),r[5]=e):e=r[5],r[6]!==a?(n=(0,t.jsx)("p",{className:"text-destructive text-sm",children:a}),r[6]=a,r[7]=n):n=r[7],r[8]!==s||r[9]!==l?(i=s&&l?(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:l}):null,r[8]=s,r[9]=l,r[10]=i):i=r[10],r[11]!==n||r[12]!==i?(o=(0,t.jsxs)(t.Fragment,{children:[e,n,i]}),r[11]=n,r[12]=i,r[13]=o):o=r[13],o}if(s){let e,n=l??"Working…";return r[14]!==n?(e=(0,t.jsx)("p",{className:"text-sm",children:n}),r[14]=n,r[15]=e):e=r[15],e}if("ready"===u){let e,n,a,i;r[16]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(nX.default,{className:"size-3.5"}),r[16]=e):e=r[16];let s=o??"Reader connected";return r[17]!==s?(n=(0,t.jsxs)(q.Badge,{className:"gap-1.5",variant:"secondary",children:[e,s]}),r[17]=s,r[18]=n):n=r[18],r[19]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)("p",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,t.jsx)(v.Credit
1Card,{className:"size-4"}),"Ready. The sale appears on the customer's terminal."]}),r[19]=a):a=r[19],r[20]!==n?(i=(0,t.jsxs)(t.Fragment,{children:[n,a]}),r[20]=n,r[21]=i):i=r[21],i}return null}var n6=e.i(762519),n7=e.i(931260),n8=e.i(799157),n9=e.i(547523),re=e.i(681838),rt=e.i(499914);function rn(e,t){var n;return(n=t.map(e=>({...e,quantity:1})),[...e.groups].sort((e,t)=>e.displayOrder-t.displayOrder).flatMap(e=>{let t,r,a;return t=n.filter(t=>t.groupId===e.groupId).flatMap(t=>{let n=e.choices.find(e=>e.choiceId===t.choiceId);return n?[{choice:n,pick:t}]:[]}).sort((e,t)=>e.choice.displayOrder-t.choice.displayOrder),r=e.includedItemsPolicy?(0,rt.priceIncludedItems)(e.includedItemsPolicy,t.map(({choice:e,pick:t})=>({choiceId:e.choiceId,priceDeltaMinor:e.priceDeltaMinor,quantity:t.quantity}))):null,a=new Map(r?.lines.map(e=>[e.choiceId,e.chargedMinor])??[]),t.map(({choice:t,pick:n})=>({chargedMinor:a.get(t.choiceId)??t.priceDeltaMinor*n.quantity,choiceId:t.choiceId,choiceName:t.name,groupId:e.groupId,groupName:e.name,quantity:n.quantity,unitPriceMinor:t.priceDeltaMinor}))})).map(e=>({choiceId:e.choiceId,groupId:e.groupId,groupName:e.groupName,name:e.choiceName,priceMinor:e.chargedMinor,quantity:1,unitPriceMinor:e.unitPriceMinor}))}function rr(e){let r,a,s,o,l=(0,n.c)(14),{checked:c,choice:u,currency:d,onToggle:m}=e,p=`pos-modifier-choice-${u.choiceId}`;return l[0]!==c||l[1]!==p||l[2]!==m?(r=(0,t.jsx)(n6.Checkbox,{checked:c,className:"mt-0.5 shrink-0",id:p,onCheckedChange:m}),l[0]=c,l[1]=p,l[2]=m,l[3]=r):r=l[3],l[4]!==u.name?(a=(0,t.jsx)(i.Text,{as:"span",className:"min-w-0 flex-1",variant:"label",children:u.name}),l[4]=u.name,l[5]=a):a=l[5],l[6]!==u.priceDeltaMinor||l[7]!==d?(s=0===u.priceDeltaMinor?null:(0,t.jsxs)(i.Text,{as:"span",className:"shrink-0 text-right",variant:"labelBold",children:[u.priceDeltaMinor>0?"+":"−",(0,j.formatPriceMinor)(Math.abs(u.priceDeltaMinor),d)]}),l[6]=u.priceDeltaMinor,l[7]=d,l[8]=s):s=l[8],l[9]!==p||l[10]!==r||l[11]!==a||l[12]!==s?(o=(0,t.jsxs)("label",{className:"flex w-full cursor-pointer items-start gap-4 py-4 text-left",htmlFor:p,children:[r,a,s]}),l[9]=p,l[10]=r,l[11]=a,l[12]=s,l[13]=o):o=l[13],o}function ra(e){let r,a,s=(0,n.c)(5),{currency:o,group:l}=e;if(!l.includedItemsPolicy)return null;let c=l.includedItemsPolicy.includedCount;s[0]!==o||s[1]!==l.includedItemsPolicy.overflowPriceMinor?(r=(0,j.formatPriceMinor)(l.includedItemsPolicy.overflowPriceMinor,o),s[0]=o,s[1]=l.includedItemsPolicy.overflowPriceMinor,s[2]=r):r=s[2];let u=`First ${c} included, then ${r} each.`;return s[3]!==u?(a=(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:u}),s[3]=u,s[4]=a):a=s[4],a}function ri(e){let r,a,s,o,l,c,u,d,m,p,h,f,x,g=(0,n.c)(48),{currency:v,group:y,onToggle:j,selections:b}=e;if(g[0]!==y.groupId||g[1]!==b){let e;g[3]!==y.groupId?(e=e=>e.groupId===y.groupId,g[3]=y.groupId,g[4]=e):e=g[4],r=b.some(e),g[0]=y.groupId,g[1]=b,g[2]=r}else r=g[2];let S=r,[C,M]=(0,X.useState)(y.required||S),w=`pos-modifier-section-${y.groupId}`,k=y.required?" · Required":"";if(g[5]!==y.name||g[6]!==k?(a=(0,t.jsxs)(i.Text,{as:"span",variant:"label",children:[y.name,k]}),g[5]=y.name,g[6]=k,g[7]=a):a=g[7],g[8]!==y||g[9]!==b){let e;s=(e=b.filter(e=>e.groupId===y.groupId).length)>0?`${e} selected`:y.required?"Required":`${y.choices.length} options`,g[8]=y,g[9]=b,g[10]=s}else s=g[10];g[11]!==s?(o=(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:s}),g[11]=s,g[12]=o):o=g[12],g[13]!==a||g[14]!==o?(l=(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[a,o]}),g[13]=a,g[14]=o,g[15]=l):l=g[15];let N=`size-4 shrink-0 transition-transform ${C?"rotate-90":""}`;if(g[16]!==N?(c=(0,t.jsx)(n9.ChevronRight,{className:N}),g[16]=N,g[17]=c):c=g[17],g[18]!==w||g[19]!==l||g[20]!==c?(u=(0,t.jsxs)(n7.CollapsibleTrigger,{className:"flex w-full items-center gap-2 py-3 text-left","data-testid":w,children:[l,c]}),g[18]=w,g[19]=l,g[20]=c,g[21]=u):u=g[21],g[22]!==y.description?(d=y.description?(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:y.description}):null,g[22]=y.description,g[23]=d):d=g[23],g[24]!==v||g[25]!==y?(m=(0,t.jsx)(ra,{currency:v,group:y}),g[24]=v,g[25]=y,g[26]=m):m=g[26],g[27]!==v||g[28]!==y.choices||g[29]!==y.groupId||g[30]!==j||g[31]!==b){let e;g[33]!==v||g[34]!==y.groupId||g[35]!==j||g[36]!==b?(e=e=>(0,t.jsx)(rr,{checked:b.some(t=>t.choiceId===e.choiceId),choice:e,currency:v,onToggle:()=>j(y.groupId,e.choiceId)},e.choiceId),g[33]=v,g[34]=y.groupId,g[35]=j,g[36]=b,g[37]=e):e=g[37],p=y.choices.map(e),g[27]=v,g[28]=y.choices,g[29]=y.groupId,g[30]=j,g[31]=b,g[32]=p}else p=g[32];return g[38]!==p?(h=(0,t.jsx)("div",{className:"divide-y",children:p}),g[38]=p,g[39]=h):h=g[39],g[40]!==d||g[41]!==m||g[42]!==h?(f=(0,t.jsxs)(n7.CollapsibleContent,{children:[d,m,h]}),g[40]=d,g[41]=m,g[42]=h,g[43]=f):f=g[43],g[44]!==C||g[45]!==u||g[46]!==f?(x=(0,t.jsxs)(n7.Collapsible,{onOpenChange:M,open:C,children:[u,f]}),g[44]=C,g[45]=u,g[46]=f,g[47]=x):x=g[47],x}function rs(e){var a,i;let s,o,l,c,u,d,m,h,f,x,g,v,y,j,C,M,w,k=(0,n.c)(33),{line:N,onOpenChange:_}=e,I=(0,p.useSetLineModifiers)(),{configuration:T,isLoading:P}
1=(a=N?.productId??null,i=N?.variantId,y=(0,n.c)(7),j=ei(),y[0]!==a||y[1]!==j||y[2]!==i?(g=es(j,a?{productId:a,variantId:i}:null),y[0]=a,y[1]=j,y[2]=i,y[3]=g):g=y[3],M=(C=(0,S.useQuery)(b.api.commerce.pos.queries.getRegisterProductConfiguration,g))??null,w=null!==a&&void 0===C,y[4]!==M||y[5]!==w?(v={configuration:M,isLoading:w},y[4]=M,y[5]=w,y[6]=v):v=y[6],v),R=N?.lineId??null;(k[0]!==N?.modifiers?(s=N?.modifiers??[],k[0]=N?.modifiers,k[1]=s):s=k[1],k[2]!==s)?(o=s.map(e=>({choiceId:e.choiceId,groupId:e.groupId,quantity:e.quantity})),k[2]=s,k[3]=o):o=k[3];let D=o,L=D.length>0,A=(0,X.useRef)(null);k[4]!==T||k[5]!==L||k[6]!==R||k[7]!==I?(l=function(){if(!(R&&T)||A.current===R||(A.current=R,L))return;let e=(0,re.initialConfigurationSelections)(T);0!==e.length&&I(R,rn(T,e))},c=[T,L,R,I],k[4]=T,k[5]=L,k[6]=R,k[7]=I,k[8]=l,k[9]=c):(l=k[8],c=k[9]),(0,X.useEffect)(l,c),k[10]!==T||k[11]!==R||k[12]!==D||k[13]!==I?(u=(e,t)=>{if(!(R&&T))return;let n=(0,re.toggleConfigurationChoice)(T,D,{choiceId:t,groupId:e});I(R,rn(T,n))},k[10]=T,k[11]=R,k[12]=D,k[13]=I,k[14]=u):u=k[14];let O=u,E=null!==N,B=N?`Customize ${N.name}`:"Customize";k[15]!==B?(d=(0,t.jsx)(n8.SheetHeader,{children:(0,t.jsx)(n8.SheetTitle,{children:B})}),k[15]=B,k[16]=d):d=k[16];let $=N?.currency??"usd";return k[17]!==T||k[18]!==P||k[19]!==D||k[20]!==$||k[21]!==O?(m=(0,t.jsx)(ro,{configuration:T,currency:$,isLoading:P,onToggle:O,selections:D}),k[17]=T,k[18]=P,k[19]=D,k[20]=$,k[21]=O,k[22]=m):m=k[22],k[23]!==_?(h=(0,t.jsx)("div",{className:"border-t p-4",children:(0,t.jsx)(r.Button,{className:"h-12 w-full",onClick:()=>_(!1),children:"Done"})}),k[23]=_,k[24]=h):h=k[24],k[25]!==m||k[26]!==h||k[27]!==d?(f=(0,t.jsxs)(n8.SheetContent,{className:"flex w-96 max-w-[calc(100vw-2rem)] flex-col",children:[d,m,h]}),k[25]=m,k[26]=h,k[27]=d,k[28]=f):f=k[28],k[29]!==_||k[30]!==f||k[31]!==E?(x=(0,t.jsx)(n8.Sheet,{onOpenChange:_,open:E,children:f}),k[29]=_,k[30]=f,k[31]=E,k[32]=x):x=k[32],x}function ro(e){let r,a,i,s,o,l,c,u,d=(0,n.c)(24),{configuration:m,currency:p,isLoading:h,onToggle:f,selections:g}=e;if(h){let e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center"}),d[0]=e):e=d[0],e}if(d[1]!==m?.groups||d[2]!==p||d[3]!==f||d[4]!==g){l=Symbol.for("react.early_return_sentinel");e:{let e,n=m?.groups??[];if(0===n.length){let e;d[11]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ed.Empty,{children:(0,t.jsxs)(ed.EmptyHeader,{children:[(0,t.jsx)(ed.EmptyTitle,{children:"No options"}),(0,t.jsx)(ed.EmptyDescription,{children:"This item has no option groups in the catalog."})]})}),d[11]=e):e=d[11],l=e;break e}r=x.ScrollArea,s="min-h-0 flex-1",o="px-4",a="divide-y",d[12]!==p||d[13]!==f||d[14]!==g?(e=e=>(0,t.jsx)(ri,{currency:p,group:e,onToggle:f,selections:g},e.groupId),d[12]=p,d[13]=f,d[14]=g,d[15]=e):e=d[15],i=[...n].sort(rl).map(e)}d[1]=m?.groups,d[2]=p,d[3]=f,d[4]=g,d[5]=r,d[6]=a,d[7]=i,d[8]=s,d[9]=o,d[10]=l}else r=d[5],a=d[6],i=d[7],s=d[8],o=d[9],l=d[10];return l!==Symbol.for("react.early_return_sentinel")?l:(d[16]!==a||d[17]!==i?(c=(0,t.jsx)("div",{className:a,children:i}),d[16]=a,d[17]=i,d[18]=c):c=d[18],d[19]!==r||d[20]!==s||d[21]!==o||d[22]!==c?(u=(0,t.jsx)(r,{className:s,classNameViewport:o,children:c}),d[19]=r,d[20]=s,d[21]=o,d[22]=c,d[23]=u):u=d[23],u)}function rl(e,t){return e.displayOrder-t.displayOrder}function rc(e){let r,a,i,s,o,l,c,u,d,m,h,f,x,g,v,y,j,C,M,k,N,_,I,T,P,R,D,L,A=(0,n.c)(123),{locationId:O,owner:E,session:B,taxRateBps:$}=e,z=(0,e7.useIsMobile)(),F=(0,p.useCartLines)(),q=(0,p.useCustomer)(),V=(0,p.useDiscount)(),U=(0,p.useTip)(),H=(0,p.useCompleteSale)(),{charge:G,completeFreeSale:Q}=nT(),W=(R=(0,n.c)(3),D=(0,S.useMutation)(b.api.commerce.pos.sessions.openRegister),L=ei(),R[0]!==D||R[1]!==L?(P=async e=>{if("skip"===L)return null;try{let t=await D({...L,locationId:e.locationId,openingFloatMinor:0,currency:"usd",note:"Opened automatically at the first tender of the shift."});return K.toast.success("Shift started",{description:"Count the drawer from Transactions when cash comes in."}),t}catch(e){return K.toast.error((0,e8.userFacingErrorMessage)(e,"Couldn't start the shift.")),null}},R[0]=D,R[1]=L,R[2]=P):P=R[2],P),Z=function(e){let t=(0,S.useAction)(b.api.commerce.payments.stripe.terminal.createTerminalConnectionToken),n=(0,p.useSelectedReaderId)(),r=(0,X.useRef)(null),[a,i]=(0,X.useState)("idle"),[s,o]=(0,X.useState)(null),[l,c]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),m=(0,X.useCallback)(async()=>
1{if(r.current)return r.current;let n=await nG({onFetchConnectionToken:async()=>{let{secret:n}=await t({owner:e});return n},onUnexpectedReaderDisconnect:()=>{i("idle"),c(null),d(null)}});if(!n)throw Error("Could not load the card reader.");return r.current=n,n},[t,e]),h=(0,X.useCallback)(async()=>{i("connecting"),o(null);try{let e=await m(),t=await e.discoverReaders({simulated:!(0,eN.stripeCheckoutIsLiveMode)()});if("error"in t){i("error"),o(t.error.message);return}let r=function(e,t){if(t){let n=e.find(e=>e.id===t);if(n)return n}return e[0]}(t.discoveredReaders,n);if(!r){i("error"),o(nQ);return}let a=await e.connectReader(r);if("error"in a){i("error"),o(a.error.message);return}c(a.reader.label??"Card reader"),d(a.reader.id),i("ready")}catch(e){i("error"),o(e instanceof Error?e.message:"Could not connect to the card reader.")}},[m,n]),f="ready"===a?r.current:null;return{status:a,error:s,readerId:u,readerLabel:l,charger:f,display:f,connect:h}}(E),[J,Y]=(0,X.useState)(!1),[ee,et]=(0,X.useState)(!1),[en,er]=(0,X.useState)(!1),[eo,el]=(0,X.useState)(!1),[eu,ed]=(0,X.useState)(null),[em,ep]=(0,X.useState)(null),eh=F[0]?.currency??"usd",ef=(0,p.useSaleStage)(),ex=(0,p.useLastSale)(),eg=(0,p.useResumeBuilding)(),{amounts:ev}=w($);A[0]!==F?(r=F.reduce(ru,0),A[0]=F,A[1]=r):r=A[1];let ey=r;A[2]!==ev||A[3]!==eh||A[4]!==ex||A[5]!==F||A[6]!==O||A[7]!==ef?(a={amounts:ev,currency:eh,lastSale:ex,lines:F,locationId:O,stage:ef},A[2]=ev,A[3]=eh,A[4]=ex,A[5]=F,A[6]=O,A[7]=ef,A[8]=a):a=A[8],function(e){let t,r,a,i=(0,n.c)(12),s=(0,S.useMutation)(b.api.commerce.pos.counter_display.publish),o=(0,p.useSelectedSpaceId)(),{locationId:l}=e;if(i[0]!==e.amounts||i[1]!==e.currency||i[2]!==e.lastSale||i[3]!==e.lines||i[4]!==e.stage){var c;t=JSON.stringify({amounts:{discountMinor:(c={amounts:e.amounts,currency:e.currency,lastSale:e.lastSale,lines:e.lines,stage:e.stage}).amounts.discountMinor,subtotalMinor:c.amounts.subtotalMinor,taxMinor:c.amounts.taxMinor,tipMinor:c.amounts.tipMinor,totalMinor:c.amounts.totalMinor},currency:c.currency,lastSale:c.lastSale??void 0,lines:c.lines.map(eC),stage:c.stage}),i[0]=e.amounts,i[1]=e.currency,i[2]=e.lastSale,i[3]=e.lines,i[4]=e.stage,i[5]=t}else t=i[5];let u=t,d=(0,X.useRef)(null);i[6]!==u||i[7]!==l||i[8]!==s||i[9]!==o?(r=function(){l&&d.current!==u&&(d.current=u,Promise.resolve(s({...ea(o),locationId:l,...JSON.parse(u)})).catch(()=>{d.current=null}))},a=[u,l,s,o],i[6]=u,i[7]=l,i[8]=s,i[9]=o,i[10]=r,i[11]=a):(r=i[10],a=i[11]),(0,X.useEffect)(r,a)}(a),A[9]!==O?(i={locationId:O},A[9]=O,A[10]=i):i=A[10],function(e){let t,r,a,i=(0,n.c)(12),{locationId:s}=e,o=(0,p.useSelectedSpaceId)(),l=(0,p.useSetCustomer)(),c=(0,p.useCustomer)(),u=(0,S.useMutation)(b.api.commerce.pos.counter_display.clearPendingCustomer),d=ei();i[0]!==s||i[1]!==d?(t=es(d,s?{locationId:s}:null),i[0]=s,i[1]=d,i[2]=t):t=i[2];let m=(0,S.useQuery)(b.api.commerce.pos.counter_display.pendingCustomer,t),h=m?.customerId??null,f=c?.customerId??null;i[3]!==f||i[4]!==u||i[5]!==s||i[6]!==m||i[7]!==h||i[8]!==o||i[9]!==l?(r=function(){s&&m&&h&&(f!==h&&l({customerId:m.customerId,email:m.email,name:m.name,phone:m.phone}),u({...ea(o),locationId:s}).catch(nP))},a=[f,u,s,m,h,o,l],i[3]=f,i[4]=u,i[5]=s,i[6]=m,i[7]=h,i[8]=o,i[9]=l,i[10]=r,i[11]=a):(r=i[10],a=i[11]),(0,X.useEffect)(r,a)}(i),A[11]!==F||A[12]!==em?(s=F.find(e=>e.lineId===em)??null,A[11]=F,A[12]=em,A[13]=s):s=A[13];let ej=s;A[14]!==ev||A[15]!==eh||A[16]!==F||A[17]!==ef||A[18]!==Z.display?(o={amounts:ev,currency:eh,display:Z.display,lines:F,stage:ef},A[14]=ev,A[15]=eh,A[16]=F,A[17]=ef,A[18]=Z.display,A[19]=o):o=A[19],function(e){let t,r,a,i,s,o,l,c=(0,n.c)(19),{amounts:u,currency:d,display:m,lines:p,stage:h}=e;if(c[0]!==u||c[1]!==d||c[2]!==p||c[3]!==h){var f,x;let e,n,i;i=[...(f={amounts:u,currency:d,lines:p}).lines.flatMap(nE),...(x=f.amounts,n=[],x.discountMinor>0&&n.push({amountMinor:-x.discountMinor,description:"Discount",quantity:1}),x.tipMinor>0&&n.push({amountMinor:x.tipMinor,description:"Tip",quantity:1}),n)],t={type:"cart",cart:{currency:f.currency,line_items:i.map(e=>({amount:e.amountMinor,description:e.description,quantity:e.quantity})),tax:f.amounts.taxMinor,total:f.amounts.totalMinor}},c[7]!==p||c[8]!==h?(e=nR({itemCount:p.reduce(n$,0),stage:h}),c[7]=p,c[8]=h,c[9]=e):e=c[9],r=e,a=JSON.stringify(t),c[0]=u,c[1]=d,c[2]=p,c[3]=h,c[4]=t,c[5]=r,c[6]=a}else t=c[4],r=c[5],a=c[6];let g=a,v=(0,X.useRef)("idle"),y=(0,X.useRef)(null);c[10]!==t||c[11]!==m||c[12]!==g||c[13]!==r?(i=function(){let e=nL({from:v.current,to:r}),n=v.current!==r;if(v.current=r,n&&(y.current=null),m&&"none"!==e.step){if("clear"===e.step){if(""===y.current)return;y.current="",m.clearReaderDisplay().catch(()=>{y.current=null});return}y.current!==g&&(y.current=g,m.setReaderDisplay(t).catch(()=>{y.current=null}))}},s=[t,m,g,r],c[10]=t,c[11]=m,c[12]=g,c[13]=r,c[14]=i,c[15]=s):(i=c[14],s=c[15]),(0,X.useEffect)(i,s),c[16]!==m?(o=function(){return()=>{m?.clearReaderDisplay().catch(nB)}},l=[m],c[16]=m,c[17]=o,c[18]=l):(o=c[17],l=c[18]),(0,X.useEffect)(o,l)}(o);let{connect:eb}=Z,eS=Z.status,eM="ready"===eS;A[20]!==E||A[21]!==eM?(l={isReaderOnline:eM,owner:E},A[20]=E,A[21]=eM,A[22]=l):l=A[22],eT(l),A[23]!==eb||A[24]!==eS?(c=function(){"idle"===eS&&eb()},u=[eS,eb],A[23]=eb,A[24]=eS,A[25]=c,A[26]=u):(c=A[25],u=A[26]),(0,X.useEffect)(c,u),A[27]!==H?(d=e=>{H({orderNumber:e.orderNumber,totalMinor:e.totalMinor,currency:e.currency}),ed(e),er(!1)},A[27]=H,A[28]=d):d=A[28];let ew=d;A[29]!==ev.rewardsRedemptionMinor||A[30]!==G||A[31]!==eh||A[32]!==q||A[33]!==V||A[34]!==ew||A[35]!==F||A[36]!==O||A[37]!==E||A[38]!==B||A[39]!==$||A[40]!==U?(m=async e=>{if(O&&B&&F.length>0)try{let t=await G({cashTenderedMinor:e,currency:eh,customer:q,discount:V,lines:F,locationId:O,owner:E,rewardsRedemptionMinor:ev.rewardsRedemptionMinor,sessionId:B._id,taxRateBps:$,tip:U});Y(!1),ew(t)}catch(e){K.toast.error((0,e8.userFacingErrorMessage)(e,"Charge failed. Try again."))}},A[29]=ev.rewardsRedemptionMinor,A[30]=G,A[31]=eh,A[32]=q,A[33]=V,A[34]=ew,A[35]=
1F,A[36]=O,A[37]=E,A[38]=B,A[39]=$,A[40]=U,A[41]=m):m=A[41];let ek=m;A[42]!==ew?(h=e=>{ew({...e,changeGivenMinor:0})},A[42]=ew,A[43]=h):h=A[43];let e_=h;A[44]!==O||A[45]!==W||A[46]!==eg||A[47]!==B?(f=async()=>{"open_silently"!==nz({hasSession:!!B,tender:"card"}).kind||O&&await W({locationId:O})?et(!0):eg()},A[44]=O,A[45]=W,A[46]=eg,A[47]=B,A[48]=f):f=A[48];let eI=f;A[49]!==ev.rewardsRedemptionMinor||A[50]!==Q||A[51]!==eh||A[52]!==q||A[53]!==V||A[54]!==ew||A[55]!==F||A[56]!==O||A[57]!==W||A[58]!==E||A[59]!==eg||A[60]!==B||A[61]!==$||A[62]!==U?(x=async()=>{if(!(O&&F.length>0))return void eg();let e="open_silently"===nz({hasSession:!!B,tender:"comp"}).kind?await W({locationId:O}):B?._id;if(!e)return void eg();try{let t=await Q({currency:eh,customer:q,discount:V,lines:F,locationId:O,owner:E,rewardsRedemptionMinor:ev.rewardsRedemptionMinor,sessionId:e,taxRateBps:$,tip:U});ew(t)}catch(e){eg(),K.toast.error((0,e8.userFacingErrorMessage)(e,"Could not complete the sale. Try again."))}},A[49]=ev.rewardsRedemptionMinor,A[50]=Q,A[51]=eh,A[52]=q,A[53]=V,A[54]=ew,A[55]=F,A[56]=O,A[57]=W,A[58]=E,A[59]=eg,A[60]=B,A[61]=$,A[62]=U,A[63]=x):x=A[63];let eP=x;A[64]!==B?(g=()=>{"count_float"===nz({hasSession:!!B,tender:"cash"}).kind?el(!0):Y(!0)},A[64]=B,A[65]=g):g=A[65];let eR=g;A[66]!==eI||A[67]!==eR||A[68]!==eP||A[69]!==$?(v=(0,t.jsx)(nm,{onCard:eI,onCash:eR,onComplete:eP,onCustomize:ep,taxRateBps:$}),A[66]=eI,A[67]=eR,A[68]=eP,A[69]=$,A[70]=v):v=A[70];let eD=v;A[71]!==eo||A[72]!==O||A[73]!==eg?(y=O?(0,t.jsx)(ec,{locationId:O,onOpenChange:e=>{el(e),e||eg()},onOpened:()=>{el(!1),Y(!0)},open:eo}):null,A[71]=eo,A[72]=O,A[73]=eg,A[74]=y):y=A[74],A[75]!==eg?(j=e=>{Y(e),e||eg()},A[75]=eg,A[76]=j):j=A[76],A[77]!==ev.totalMinor||A[78]!==eh||A[79]!==ek||A[80]!==J||A[81]!==j?(C=(0,t.jsx)(ny,{currency:eh,onConfirm:ek,onOpenChange:j,open:J,totalMinor:ev.totalMinor}),A[77]=ev.totalMinor,A[78]=eh,A[79]=ek,A[80]=J,A[81]=j,A[82]=C):C=A[82],A[83]!==eu?(M=eu?(0,t.jsx)(nw,{onOpenChange:e=>!e&&ed(null),open:!0,sale:eu}):null,A[83]=eu,A[84]=M):M=A[84],A[85]!==ev||A[86]!==eh||A[87]!==q||A[88]!==V||A[89]!==e_||A[90]!==ee||A[91]!==F||A[92]!==O||A[93]!==E||A[94]!==eg||A[95]!==B||A[96]!==ef||A[97]!==$||A[98]!==Z||A[99]!==U?(k=O&&B?(0,t.jsx)(n4,{amounts:ev,currency:eh,input:{currency:eh,customer:q,discount:V,lines:F,locationId:O,owner:E,rewardsRedemptionMinor:ev.rewardsRedemptionMinor,sessionId:B._id,taxRateBps:$,tip:U},onComplete:e_,onOpenChange:e=>{et(e),e||eg()},open:ee,owner:E,session:B,stage:ef,terminal:Z}):null,A[85]=ev,A[86]=eh,A[87]=q,A[88]=V,A[89]=e_,A[90]=ee,A[91]=F,A[92]=O,A[93]=E,A[94]=eg,A[95]=B,A[96]=ef,A[97]=$,A[98]=Z,A[99]=U,A[100]=k):k=A[100];let eL=ej?.lineId??"none";A[101]===Symbol.for("react.memo_cache_sentinel")?(N=e=>{e||ep(null)},A[101]=N):N=A[101],A[102]!==ej||A[103]!==eL?(_=(0,t.jsx)(rs,{line:ej,onOpenChange:N},eL),A[102]=ej,A[103]=eL,A[104]=_):_=A[104],A[105]!==y||A[106]!==C||A[107]!==M||A[108]!==k||A[109]!==_?(I=(0,t.jsxs)(t.Fragment,{children:[y,C,M,k,_]}),A[105]=y,A[106]=C,A[107]=M,A[108]=k,A[109]=_,A[110]=I):I=A[110];let eA=I;if(z){let e,n;return A[111]!==ev.totalMinor||A[112]!==eh||A[113]!==en||A[114]!==ey||A[115]!==eD?(e=(0,t.jsx)(tt,{amountMinor:ev.totalMinor,currency:eh,itemCount:ey,onOpenChange:er,open:en,children:eD}),A[111]=ev.totalMinor,A[112]=eh,A[113]=en,A[114]=ey,A[115]=eD,A[116]=e):e=A[116],A[117]!==eA||A[118]!==e?(n=(0,t.jsxs)(t.Fragment,{children:[e,eA]}),A[117]=eA,A[118]=e,A[119]=n):n=A[119],n}return A[120]!==eA||A[121]!==eD?(T=(0,t.jsxs)("aside",{className:"flex h-full min-h-0 w-96 shrink-0 flex-col border-l",children:[eD,eA]}),A[120]=eA,A[121]=eD,A[122]=T):T=A[122],T}function ru(e,t){return e+t.quantity}var rd=e.i(313830);let rm=[];function rp(e){return[e.productId,e.variants]}function rh(e){return{unitPriceMinor:e.priceMinor,variantId:e.id,variantLabel:e.name}}var rf=e.i(474208),rx=e.i(707135),rg=e.i(76075);function rv(e){var a,s;let o,l,c,u,d,m,p,h,f,x,g,v,j=(0,n.c)(19),{children:b,footer:S,onClose:C,title:M}=e,w=(0,X.useRef)(null);return a=w,s=C,(c=(0,n.c)(4))[0]!==s||c[1]!==a?(o=()=>{let e=e=>{"Escape"===e.key&&s()},t=e=>{let t=e.target;t instanceof Node&&a.current?.contains(t)||s()};return document.addEventListener("keydown",e),document.addEventListener("mousedown",t),()=>{document.removeEventListener("keydown",e),document.removeEventListener("mousedown",t)}},l=[s,a],c[0]=s,c[1]=a,c[2]=o,c[3]=l):(o=c[2],l=c[3]),(0,X.useEffect)(o,l),j[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{w.current?.focus()},d=[],j[0]=u,j[1]=d):(u=j[0],d=j[1]),(0,X.useEffect)(u,d),j[2]!==M?(m=(0,t.jsx)(i.H2,{variant:"panel",children:M}),j[2]=M,j[3]=m):m=j[3],j[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(y.X,{}),j[4]=p):p=j[4],j[5]!==C?(h=(0,t.jsx)(r.Button,{"aria-label":"Close",onClick:C,size:"icon-sm",variant:"ghost",children:p}),j[5]=C,j[6]=h):h=j[6],j[7]!==m||j[8]!==h?(f=(0,t.jsxs)(rg.CardHeader,{className:"flex shrink-0 flex-row items-start justify-between gap-3",children:[m,h]}),j[7]=m,j[8]=h,j[9]=f):f=j[9],j[10]!==b?(x=(0,t.jsx)(rg.CardContent,{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:b}),j[10]=b,j[11]=x):x=j[11],j[12]!==S?(g=S?(0,t.jsx)(rg.CardFooter,{className:"relative shrink-0 flex-row items-center justify-between gap-3",children:S}):null,j[12]=S,j[13]=g):g=j[13],j[14]!==f||j[15]!==x||j[16]!==g||j[17]!==M?(v=(0,t.jsx)("div",{className:"pointer-events-none fixed inset-0 z-30 flex items-center justify-center p-4","data-testid":"pos-grid-modal-frame",children:(0,t.jsxs)(rg.Card,{"aria-label":M,className:"pointer-events-auto max-h-[80vh] w-full max-w-[30rem]",ref:w,role:"dialog",tabIndex:-1,variant:"overlay",children:[f,x,g]})}),j[14]=f,j[15]=x,j[16]=g,j[17]=M,j[18]=v):v=j[18],v}var ry=e.i(632137);function rj(e){let a,s,o,l,c,u,d,m,p,h,f,x=(0,n.c)(34),{addLabel:g,className:v,count:y,countLabel:j,onStep:b,removeLabel:S,surface:C}=e,{announce:M,cluster:w,keyClass:k,keyVariant:N}=rb[C];x[0]!==v||x[1]!==w?(a=(0,ry.cn)("flex items-center gap-1",w,v),x[0]=v,x[1]=w,x[2]=a):a=x[2],x[3]!==k?(s=(0,ry.cn)(k,"shrink-0"),x[3]=k,x[4]=s):s=x[4];let _=0===y;x[5]!==b?(o=()=>b(-1),x[5]=b,x[6]=o):o=x[6],x[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(tr.Minus,{}),x[7]=l):l=x[7],x[8]!==N||x[9]!==S||x[10]!==s||x[11]!==_||x[12]!==o?(c=(0,t.jsx)(r.Button,{"aria-label":S,className:s,disabled:_,onClick:o,size:"icon",variant:N,children:l}),x[8]=N,x[9]=S,x[10]=s,x[11]=_,x[12]=o,x[13]=c):c=x[13];let I=M?"polite":void 0,T=y>0?"labelBold":"caption";return x[14]!==y||x[15]!==j||x[16]!==I||x[17]!==T?(u=(0,t.jsx)(i.Text,{"aria-label":j,"aria-live":I,as:"span",className:"min-w-6 shrink-0 text-center text-current tabular-nums",variant:T,children:y}),x[14]=y,x[15]=j,x[16]=I,x[17]=T,x[18]=u):u=x[18],x[19]!==k?(d=(0,ry.cn)(k,"shrink-0"),x[19]=k,x[20]=d):d=x[20],x[21]!==b?(m=()=>b(1),x[21]=b,x[22]=m):m=x[22],x[23]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(ta.Plus,{}),x[23]=p):p=x[23],x[24]!==g||x[25]!==N||x[26]!==d||x[27]!==m?(h=(0,t.jsx)(r.Button,{"aria-label":g,className:d,onClick:m,size:"icon",variant:N,children:p}),x[24]=g,x[25]=N,x[26]=d,x[27]=m,x[28]=h):h=x[28],x[29]!==a||x[30]!==h||x[31]!==c||x[32]!==u?(f=(0,t.jsxs)("div",{className:a,"data-testid":"pos-quantity-stepper",children:[c,u,h]}),x[29]=a,x[30]=h,x[31]=c,x[32]=u,x[33]=f):f=x[33],f}let rb={caseTile:{announce:!1,cluster:"rounded-full bg-black/60 text-white shadow-sm ring-1 ring-white/25 backdrop-blur-md",keyClass:"size-10 rounded-full text-current hover:bg-white/15 disabled:text-white/40",keyVariant:"ghost"},panelRow:{announce:!0,cluster:"",keyClass:"size-11",keyVariant:"surface"}};function rS(e){let a,s,o,l,c,u,d,m,p=(0,n.c)(27),{currency:h,onStep:f,quantity:x,variant:g}=e;p[0]!==f||p[1]!==g?(a=()=>f(g,1),p[0]=f,p[1]=g,p[2]=a):a=p[2];let v=x>0?"selected":"surface";p[3]!==g.name?(s=(0,t.jsx)(i.Text,{as:"span",className:"min-w-0 flex-1",variant:"label",children:g.name}
1),p[3]=g.name,p[4]=s):s=p[4],p[5]!==h||p[6]!==g.priceMinor?(o=(0,j.formatPriceMinor)(g.priceMinor,h),p[5]=h,p[6]=g.priceMinor,p[7]=o):o=p[7],p[8]!==o?(l=(0,t.jsx)(i.Text,{as:"span",className:"shrink-0",variant:"labelBold",children:o}),p[8]=o,p[9]=l):l=p[9],p[10]!==a||p[11]!==v||p[12]!==s||p[13]!==l?(c=(0,t.jsxs)(r.Button,{className:"min-h-16 min-w-0 flex-1 flex-row items-center justify-between gap-3 px-4 py-3",onClick:a,size:"tile",variant:v,children:[s,l]}),p[10]=a,p[11]=v,p[12]=s,p[13]=l,p[14]=c):c=p[14];let y=`Add one ${g.name}`,b=`${g.name} on the sale`;p[15]!==f||p[16]!==g?(u=e=>f(g,e),p[15]=f,p[16]=g,p[17]=u):u=p[17];let S=`Remove one ${g.name}`;return p[18]!==x||p[19]!==S||p[20]!==y||p[21]!==b||p[22]!==u?(d=(0,t.jsx)(rj,{addLabel:y,className:"shrink-0",count:x,countLabel:b,onStep:u,removeLabel:S,surface:"panelRow"}),p[18]=x,p[19]=S,p[20]=y,p[21]=b,p[22]=u,p[23]=d):d=p[23],p[24]!==d||p[25]!==c?(m=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[c,d]}),p[24]=d,p[25]=c,p[26]=m):m=p[26],m}function rC(e,t){return 0===e.units?"Not on this sale yet":`${e.units} on this sale \xb7 ${(0,j.formatPriceMinor)(e.totalMinor,t)}`}function rM(e){let t=e.variants.map(e=>e.priceMinor);if(0===t.length)return(0,j.formatPriceMinor)(e.basePriceMinor,e.currency);let n=Math.min(...t);return n===Math.max(...t)?(0,j.formatPriceMinor)(n,e.currency):`From ${(0,j.formatPriceMinor)(n,e.currency)}`}let rw=new Set(["barcode","category","categories","collection","collections","cost","gtin","handle","id","image","images","inventory","margin","price","producthandle","productid","productsku","producttype","published","quantity","sku","slug","status","stock","supplier","tags","taxcode","type","upc","url","vendor","weight"]),rk=["allergen","ingredient"];function rN(e){let t=rk.findIndex(t=>e.includes(t));return -1===t?rk.length:t}function r_(e){var a;let s,o,l,c,u,d,m,p,h,x,g,v,y,j,C,M,w,k,N,_,I,P,R,D,L,A=(0,n.c)(53),{onClose:O,product:E,stepper:B,variants:$}=e,{detail:z,isLoading:F}=(a=E.id,I=(0,n.c)(6),P=ei(),I[0]!==a||I[1]!==P?(N=es(P,a?{productId:a}:null),I[0]=a,I[1]=P,I[2]=N):N=I[2],D=(R=(0,S.useQuery)(b.api.commerce.pos.queries.getRegisterProductDetail,N))??null,L=null!==a&&void 0===R,I[3]!==D||I[4]!==L?(_={detail:D,isLoading:L},I[3]=D,I[4]=L,I[5]=_):_=I[5],_),q=z?.customFields;A[0]!==q?(s=q?Object.entries(q).map(([e,t],n)=>({index:n,label:function(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z\d])([A-Z])/g,"$1 $2").trim();if(""===t)return e;let n=t.toLowerCase();return n.charAt(0).toUpperCase()+n.slice(1)}(e),normalized:e.toLowerCase().replace(/[\s_-]/g,""),value:t.trim()})).filter(e=>""!==e.value&&!rw.has(e.normalized)).sort((e,t)=>rN(e.normalized)-rN(t.normalized)||e.index-t.index).map(e=>({label:e.label,value:e.value})):[],A[0]=q,A[1]=s):s=A[1];let V=s;A[2]!==E||A[3]!==B?(o=rC(B.tallyOf(E),E.currency),A[2]=E,A[3]=B,A[4]=o):o=A[4],A[5]!==o?(l=(0,t.jsx)(i.Text,{"aria-live":"polite",as:"span",variant:"label",children:o}),A[5]=o,A[6]=l):l=A[6],A[7]!==O?(c=(0,t.jsx)(r.Button,{onClick:O,variant:"surface",children:"Done"}),A[7]=O,A[8]=c):c=A[8],A[9]!==l||A[10]!==c?(u=(0,t.jsxs)(t.Fragment,{children:[l,c]}),A[9]=l,A[10]=c,A[11]=u):u=A[11],A[12]!==E.name?(d=T(E.name),A[12]=E.name,A[13]=d):d=A[13],A[14]!==E.images?(m=(0,rx.firstStorefrontImage)(E.images),A[14]=E.images,A[15]=m):m=A[15],A[16]!==E.name?(p=T(E.name),A[16]=E.name,A[17]=p):p=A[17],A[18]!==m||A[19]!==p?(h=(0,t.jsx)(f.ProductThumb,{className:"aspect-square w-full rounded-xl",image:m,name:p}),A[18]=m,A[19]=p,A[20]=h):h=A[20],A[21]!==E?(x=(0,t.jsx)(rI,{product:E}),A[21]=E,A[22]=x):x=A[22],A[23]!==E.dietaryTags?(g=(0,t.jsx)(rf.DietaryTagChips,{tags:E.dietaryTags}),A[23]=E.dietaryTags,A[24]=g):g=A[24],A[25]!==E.currency||A[26]!==E.priceMinor||A[27]!==$?(v=rM({basePriceMinor:E.priceMinor,currency:E.currency,variants:$}),A[25]=E.currency,A[26]=E.priceMinor,A[27]=$,A[28]=v):v=A[28],A[29]!==v?(y=(0,t.jsx)(i.Text,{as:"span",variant:"labelBold",children:v}),A[29]=v,A[30]=y):y=A[30];let U=z?.description??E.description;return A[31]!==F||A[32]!==U?(j=(0,t.jsx)(rT,{isLoading:F,text:U}),A[31]=F,A[32]=U,A[33]=j):j=A[33],A[34]!==V?(C=(0,t.jsx)(rP,{facts:V}),A[34]=V,A[35]=C):C=A[35],A[36]!==E||A[37]!==B||A[38]!==$?(M=(0,t.jsx)(rD,{product:E,stepper:B,variants:$}),A[36]=E,A[37]=B,A[38]=$,A[39]=M):M=A[39],A[40]!==h||A[41]!==x||A[42]!==g||A[43]!==y||A[44]!==j||A[45]!==C||A[46]!==M?(w=(0,t.jsxs)("div",{className:"flex flex-col gap-4 pb-1",children:[h,x,g,y,j,C,M]}),A[40]=h,A[41]=x,A[42]=g,A[43]=y,A[44]=j,A[45]=C,A[46]=M,A[47]=w):w=A[47],A[48]!==O||A[49]!==w||A[50]!==u||A[51]!==d?(k=(0,t.jsx)(rv,{footer:u,onClose:O,title:d,children:w}),A[48]=O,A[49]=w,A[50]=u,A[51]=d,A[52]=k):k=A[52],k}function rI(e){let r=(0,n.c)(2),{product:a}=e;if(a.soldOut){let e;return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(q.Badge,{variant:"secondary",children:"Sold out: none left in the case today"}),r[0]=e):e=r[0],e}if(!a.available){let e;return r[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(q.Badge,{variant:"secondary",children:"Not for sale right now"}),r[1]=e):e=r[1],e}return null}function rT(e){let r,a=(0,n.c)(2),{isLoading:s,text:o}=e;return s&&void 0===o||!o?null:(a[0]!==o?(r=(0,t.jsx)(i.Text,{variant:"bodySmall",children:o}),a[0]=o,a[1]=r):r=a[1],r)}function rP(e){let r,a,i=(0,n.c)(4),{facts:s}=e;return 0===s.length?null:(i[0]!==s?(r=s.map(rR),i[0]=s,i[1]=r):r=i[1],i[2]!==r?(a=(0,t.jsx)("dl",{className:"flex flex-col gap-2 border-t pt-4",children:r}),i[2]=r,i[3]=a):a=i[3],a)}function rR(e){return(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("dt",{children:(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:e.label})}),(0,t.jsx)("dd",{children:(0,t.jsx)(i.Text,{as:"span",variant:"bodySmall",children:e.value})})]},e.label)}function rD(e){let r,a,s,o,l=(0,n.c)(14),{product:c,stepper:u,variants:d}=e;if(!(c.available&&!c.soldOut))return null;if(0===d.length){let e;return l[0]!==c||l[1]!==u?(e=(0,t.jsx)(rL,{product:c,stepper:u}),l[0]=c,l[1]=u,l[2]=e):e=l[2],e}if(l[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Sizes"}),a=(0,t.jsx)(i.Text,{as:"span",variant:"bodyMuted",children:"Tap a size to add it."}),l[3]=r,l[4]=a):(r=l[3],a=l[4]),l[5]!==c||l[6]!==u||l[7]!==d){let e;l[9]!==c||l[10]!==u?(e=e=>(0,t.jsx)(rS,{currency:c.currency,onStep:(e,t)=>u.step(c,rh(e),t),quantity:u.quantityOf(c,e.id),variant:e},e.id),l[9]=c,l[10]=u,l[11]=e):e=l[11],s=d.map(e),l[5]=c,l[6]=u,l[7]=d,l[8]=s}else s=l[8];return l[12]!==s?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-2 border-t pt-4",children:[r,a,s]}),l[12]=s,l[13]=o):o=l[13],o}
1function rL(e){let a,s,o,l,c,u,d,m,p,h,f,x=(0,n.c)(29),{product:g,stepper:v}=e,y=v.quantityOf(g);x[0]!==g||x[1]!==v?(a=e=>v.step(g,{unitPriceMinor:g.priceMinor},e),x[0]=g,x[1]=v,x[2]=a):a=x[2];let b=a;x[3]!==g.name?(s=T(g.name),x[3]=g.name,x[4]=s):s=x[4];let S=s,C=`Remove one ${S}`,M=0===y;x[5]!==b?(o=()=>b(-1),x[5]=b,x[6]=o):o=x[6],x[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(tr.Minus,{}),x[7]=l):l=x[7],x[8]!==C||x[9]!==M||x[10]!==o?(c=(0,t.jsx)(r.Button,{"aria-label":C,className:"size-11 shrink-0",disabled:M,onClick:o,size:"icon",variant:"surface",children:l}),x[8]=C,x[9]=M,x[10]=o,x[11]=c):c=x[11];let w=`${S} on the sale`,k=y>0?"labelBold":"caption";x[12]!==y||x[13]!==w||x[14]!==k?(u=(0,t.jsx)(i.Text,{"aria-label":w,"aria-live":"polite",as:"span",className:"w-6 shrink-0 text-center tabular-nums",variant:k,children:y}),x[12]=y,x[13]=w,x[14]=k,x[15]=u):u=x[15],x[16]!==b?(d=()=>b(1),x[16]=b,x[17]=d):d=x[17],x[18]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(ta.Plus,{}),x[18]=m):m=x[18],x[19]!==g.currency||x[20]!==g.priceMinor?(p=(0,j.formatPriceMinor)(g.priceMinor,g.currency),x[19]=g.currency,x[20]=g.priceMinor,x[21]=p):p=x[21];let N=`Add to sale \xb7 ${p}`;return x[22]!==d||x[23]!==N?(h=(0,t.jsxs)(r.Button,{className:"h-11 min-w-0 flex-1 flex-row justify-center gap-2",onClick:d,size:"tile",children:[m,N]}),x[22]=d,x[23]=N,x[24]=h):h=x[24],x[25]!==u||x[26]!==h||x[27]!==c?(f=(0,t.jsxs)("div",{className:"flex items-center gap-2 border-t pt-4",children:[c,u,h]}),x[25]=u,x[26]=h,x[27]=c,x[28]=f):f=x[28],f}function rA(e,t){let n=!0===e.soldOut;return n!==(!0===t.soldOut)?n?1:-1:T(e.name).localeCompare(T(t.name))}function rO(e){let r,a,i,s,o,l=(0,n.c)(11),{onSelect:c,sections:u,value:d}=e;return u.length<2?null:(l[0]!==c?(r=e=>{"string"==typeof e&&c(e)},l[0]=c,l[1]=r):r=l[1],l[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(tb.TabsTrigger,{value:"all",children:"Everything"}),l[2]=a):a=l[2],l[3]!==u?(i=u.map(rE),l[3]=u,l[4]=i):i=l[4],l[5]!==i?(s=(0,t.jsx)(x.ScrollArea,{scrollbars:"horizontal",children:(0,t.jsxs)(tb.TabsList,{variant:"line",children:[a,i]})}),l[5]=i,l[6]=s):s=l[6],l[7]!==r||l[8]!==s||l[9]!==d?(o=(0,t.jsx)(tb.Tabs,{onValueChange:r,value:d,children:s}),l[7]=r,l[8]=s,l[9]=d,l[10]=o):o=l[10],o)}function rE(e){return(0,t.jsx)(tb.TabsTrigger,{value:e.id,children:e.name},e.id)}var rB=e.i(11069);function r$(e){let a,s,o,l,c,u,d,m,p,h,x,g,v,y,j,b,S,C=(0,n.c)(57),{count:M,isPinned:w,isPinning:k,onDetails:N,onStep:_,onTogglePin:I,product:P,variants:R}=e;C[0]!==P.name?(a=T(P.name),C[0]=P.name,C[1]=a):a=C[1];let D=a,L=P.available&&!P.soldOut&&!k;if(C[2]!==R)s=R.length>1?`${R.length} sizes`:null,C[2]=R,C[3]=s;else s=C[3];let A=s,O=k?`${w?"Unpin":"Pin"} ${D}`:D,E=k?w:void 0;C[4]!==k||C[5]!==N||C[6]!==I||C[7]!==P?(o=()=>k?I(P):N(P),C[4]=k,C[5]=N,C[6]=I,C[7]=P,C[8]=o):o=C[8];let B=P.soldOut?"relative opacity-50":"relative";C[9]!==P.images?(l=(0,rx.firstStorefrontImage)(P.images),C[9]=P.images,C[10]=l):l=C[10],C[11]!==l||C[12]!==D?(c=(0,t.jsx)(f.ProductThumb,{className:"aspect-square w-full rounded-t-xl",image:l,name:D}),C[11]=l,C[12]=D,C[13]=c):c=C[13];let $=!0===P.soldOut;return C[14]!==w||C[15]!==k||C[16]!==$?(u=(0,t.jsx)(rz,{isPinned:w,isPinning:k,soldOut:$}),C[14]=w,C[15]=k,C[16]=$,C[17]=u):u=C[17],C[18]!==u||C[19]!==B||C[20]!==c?(d=(0,t.jsxs)("div",{className:B,children:[c,u]}),C[18]=u,C[19]=B,C[20]=c,C[21]=d):d=C[21],C[22]!==D?(m=(0,t.jsx)(i.Text,{as:"span",className:"line-clamp-2",variant:"label",children:D}),C[22]=D,C[23]=m):m=C[23],C[24]!==P.currency||C[25]!==P.priceMinor||C[26]!==R?(p=rM({basePriceMinor:P.priceMinor,currency:P.currency,variants:R}),C[24]=P.currency,C[25]=P.priceMinor,C[26]=R,C[27]=p):p=C[27],C[28]!==p?(h=(0,t.jsx)(i.Text,{as:"span",variant:"labelBold",children:p}),C[28]=p,C[29]=h):h=C[29],C[30]!==A?(x=A?(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:A}):null,C[30]=A,C[31]=x):x=C[31],C[32]!==h||C[33]!==x?(g=(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[h,x]}),C[32]=h,C[33]=x,C[34]=g):g=C[34],C[35]!==P.dietaryTags?(v=(0,t.jsx)(rf.DietaryTagChips,{compact:!0,tags:P.dietaryTags}),C[35]=P.dietaryTags,C[36]=v):v=C[36],C[37]!==m||C[38]!==g||C[39]!==v?(y=(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5 p-3","data-testid":"pos-tile-body",children:[m,g,v]}),C[37]=m,C[38]=g,C[39]=v,C[40]=y):y=C[40],C[41]!==d||C[42]!==y||C[43]!==O||C[44]!==E||C[45]!==o?(j=(0,t.jsxs)(r.Button,{"aria-label":O,"aria-pressed":E,onClick:o,size:"tile",variant:"surface",children:[d,y]}),C[41]=d,C[42]=y,C[43]=O,C[44]=E,C[45]=o,C[46]=j):j=C[46],C[47]!==M||C[48]!==L||C[49]!==_||C[50]!==P||C[51]!==D||C[52]!==R?(b=L?(0,t.jsx)(rF,{count:M,hasSizes:R.length>1,onStep:_,product:P,title:D}):null,C[47]=M,C[48]=L,C[49]=_,C[50]=P,C[51]=D,C[52]=R,C[53]=b):b=C[53],C[54]!==j||C[55]!==b?(S=(0,t.jsxs)("div",{className:"relative",children:[j,b]}),C[54]=j,C[55]=b,C[56]=S):S=C[56],S}function rz(e){let r=(0,n.c)(7),{isPinned:a,isPinning:i,soldOut:s}=e;if(i){let e,n,i=a?"default":"secondary";r[0]!==a?(e=a?(0,t.jsx)(rd.Pin,{}):(0,t.jsx)(rB.PinOff,{}),r[0]=a,r[1]=e):e=r[1];let s=a?"Pinned":"Pin";return r[2]!==i||r[3]!==e||r[4]!==s?(n=(0,t.jsxs)(q.Badge,{className:"absolute top-2 right-2",size:"sm",variant:i,children:[e,s]}),r[2]=i,r[3]=e,r[4]=s,r[5]=n):n=r[5],n}if(s){let e;return r[6]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(q.Badge,{className:"absolute top-2 right-2",size:"sm",variant:"secondary",children:"Sold out"}),r[6]=e):e=r[6],e}return null}function rF(e){let r,a,i=(0,n.c)(9),{count:s,hasSizes:o,onStep:l,product:c,title:u}=e,d=o?`Choose a size for ${u}`:`Add one ${u}`,m=o?`Choose a size to take off ${u}`:`Remove one ${u}`,p=`${u} on the sale`;return i[0]!==l||i[1]!==c?(r=e=>l(c,e),i[0]=l,i[1]=c,i[2]=r):r=i[2],i[3]!==d||i[4]!==s||i[5]!==m||i[6]!==p||i[7]!==r?(a=(0,t.jsx)(rj,{addLabel:d,className:"absolute top-3 left-3",count:s,countLabel:p,onStep:r,removeLabel:m,surface:"caseTile"}),i[3]=d,i[4]=s,i[5]=m,i[6]=p,i[7]=r,i[8]=a):a=i[8],a}function rq(e){let a,s,o,l,c,u,d,m,p,h,f=(0,n.c)(32),{onClose:x,product:g,stepper:v,variants:y}=e;f[0]!==g||f[1]!==v?(a=(e,t)=>v.step(g,rh(e),t),f[0]=g,f[1]=v,f[2]=a):a=f[2];let j=a;if(f[3]!==g||f[4]!==v?(s=rC(v.tallyOf(g),g.currency),f[3]=g,f[4]=v,f[5]=s):s=f[5],f[6]!==s?(o=(0,t.jsx)(i.Text,{"aria-live":"polite",as:"span",variant:"label",children:s}),f[6]=s,f[7]=o):o=f[7],f[8]!==x?(l=(0,t.jsx)(r.Button,{onClick:x,variant:"surface",children:"Done"}),f[8]=x,f[9]=l):l=f[9],f[10]!==o||f[11]!==l?(c=(0,t.jsxs)(t.Fragment,{children:[o,l]}),f[10]=o,f[11]=l,f[12]=c):c=f[12],f[13]!==g.name?(u=T(g.name),f[13]=g.name,f[14]=u):u=f[14],f[15]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(i.Text,{as:"span",variant:"bodyMuted",children:"Tap a size to add it."}),f[15]=d):d=f[15],f[16]!==g||f[17]!==j||f[18]!==v||f[19]!==y){let e;f[21]!==g||f[22]!==j||f[23]!==v?(e=e=>(0,t.jsx)(rS,{currency:g.currency,onStep:j,quantity:v.quantityOf(g,e.id),variant:e},e.id),f[21]=g,f[22]=j,f[23]=v,f[24]=e):e=f[24],m=y.map(e),f[16]=g,f[17]=j,f[18]=v,f[19]=y,f[20]=m}else m=f[20];return f[25]!==m?(p=(0,t.jsxs)("div",{className:"flex flex-col gap-2 pb-1",children:[d,m]}),f[25]=m,f[26]=p):p=f[26],f[27]!==x||f[28]!==c||f[29]!==u||f[30]!==p?(h=(0,t.jsx)(rv,{footer:c,onClose:x,title:u,children:p}),f[27]=x,f[28]=c,f[29]=u,f[30]=p,f[31]=h):h=f[31],h}function rV(e){return{id:e._id,name:e.name,order:e.order}}function rU(e){let r,a,i,s=(0,n.c)(11),{handlers:o,products:l}=e;s[0]!==o.pinnedIds?(r=new Set(o.pinnedIds),s[0]=o.pinnedIds,s[1]=r):r=s[1];let c=r;if(s[2]!==o||s[3]!==c||s[4]!==l){let e;s[6]!==o||s[7]!==c?(e=e=>(0,t.jsx)(r$,{count:o.countFor(e),isPinned:c.has(e.id),isPinning:o.isPinning,onDetails:o.onDetails,onStep:o.onStep,onTogglePin:o.onTogglePin,product:e,variants:o.variantsFor(e)}
1,e.id),s[6]=o,s[7]=c,s[8]=e):e=s[8],a=l.map(e),s[2]=o,s[3]=c,s[4]=l,s[5]=a}else a=s[5];return s[9]!==a?(i=(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:a}),s[9]=a,s[10]=i):i=s[10],i}function rH(e){let r,a,s,o=(0,n.c)(9),{handlers:l,section:c,showHeading:u}=e;return o[0]!==c.name||o[1]!==u?(r=u?(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:c.name}):null,o[0]=c.name,o[1]=u,o[2]=r):r=o[2],o[3]!==l||o[4]!==c.products?(a=(0,t.jsx)(rU,{handlers:l,products:c.products}),o[3]=l,o[4]=c.products,o[5]=a):a=o[5],o[6]!==r||o[7]!==a?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[r,a]}),o[6]=r,o[7]=a,o[8]=s):s=o[8],s}function rG(e){let r,a,s,o=(0,n.c)(8),{handlers:l,products:c}=e;if(0===c.length)return null;if(o[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(i.Text,{as:"span",variant:"overline",children:"Quick keys"}),o[0]=r):r=o[0],o[1]!==l||o[2]!==c){let e;o[4]!==l?(e=e=>(0,t.jsx)("div",{className:"w-36 shrink-0",children:(0,t.jsx)(r$,{count:l.countFor(e),isPinned:!0,isPinning:l.isPinning,onDetails:l.onDetails,onStep:l.onStep,onTogglePin:l.onTogglePin,product:e,variants:l.variantsFor(e)})},e.id),o[4]=l,o[5]=e):e=o[5],a=c.map(e),o[1]=l,o[2]=c,o[3]=a}else a=o[3];return o[6]!==a?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[r,(0,t.jsx)(x.ScrollArea,{scrollbars:"horizontal",children:(0,t.jsx)("div",{className:"flex gap-3 pb-2",children:a})})]}),o[6]=a,o[7]=s):s=o[7],s}function rQ(e){let r,a,i,s=(0,n.c)(7),{isSearching:o}=e,l=o?"Nothing by that name":"Nothing to sell yet";s[0]!==l?(r=(0,t.jsx)(ed.EmptyTitle,{children:l}),s[0]=l,s[1]=r):r=s[1];let c=o?"Try a shorter word, or clear the search to see the whole case.":"Add products to this shop's catalog and they'll show up here.";return s[2]!==c?(a=(0,t.jsx)(ed.EmptyDescription,{children:c}),s[2]=c,s[3]=a):a=s[3],s[4]!==r||s[5]!==a?(i=(0,t.jsx)(ed.Empty,{children:(0,t.jsxs)(ed.EmptyHeader,{children:[r,a]})}),s[4]=r,s[5]=a,s[6]=i):i=s[6],i}function rW(e){let r,a,i=(0,n.c)(15),{handlers:s,isSearching:o,sections:l}=e;if(0===l.length){let e;return i[0]!==o?(e=(0,t.jsx)(rQ,{isSearching:o}),i[0]=o,i[1]=e):e=i[1],e}if(o){let e,n;return i[2]!==l?(e=l.flatMap(rX),i[2]=l,i[3]=e):e=i[3],i[4]!==s||i[5]!==e?(n=(0,t.jsx)(rU,{handlers:s,products:e}),i[4]=s,i[5]=e,i[6]=n):n=i[6],n}if(i[7]!==s||i[8]!==l){let e;i[10]!==s||i[11]!==l.length?(e=e=>(0,t.jsx)(rH,{handlers:s,section:e,showHeading:l.length>1},e.id),i[10]=s,i[11]=l.length,i[12]=e):e=i[12],r=l.map(e),i[7]=s,i[8]=l,i[9]=r}else r=i[9];return i[13]!==r?(a=(0,t.jsx)("div",{className:"flex flex-col gap-6",children:r}),i[13]=r,i[14]=a):a=i[14],a}function rX(e){return e.products}
1function rK(e){let r=(0,n.c)(16),{modal:a,onClose:i,stepper:s,variantsFor:o}=e;switch(a.kind){case"details":{let e,n,l=a.product;return r[0]!==a.product||r[1]!==o?(e=o(a.product),r[0]=a.product,r[1]=o,r[2]=e):e=r[2],r[3]!==a.product||r[4]!==i||r[5]!==s||r[6]!==e?(n=(0,t.jsx)(r_,{onClose:i,product:l,stepper:s,variants:e}),r[3]=a.product,r[4]=i,r[5]=s,r[6]=e,r[7]=n):n=r[7],n}case"sizes":{let e,n,l=a.product;return r[8]!==a.product||r[9]!==o?(e=o(a.product),r[8]=a.product,r[9]=o,r[10]=e):e=r[10],r[11]!==a.product||r[12]!==i||r[13]!==s||r[14]!==e?(n=(0,t.jsx)(rq,{onClose:i,product:l,stepper:s,variants:e}),r[11]=a.product,r[12]=i,r[13]=s,r[14]=e,r[15]=n):n=r[15],n}default:return a}}function rZ(e){var a;let s,o,l,c,u,d,m,h,f,v,y,j,M,w,k,N,_,I,T,P,R,D,L,A,O,E,B,$,z,F,q,V,H,G,Q,W,K,Z,J,Y,ee,et,en,er=(0,n.c)(71),{onAdd:ea,owner:eo}=e,[el,ec]=(0,X.useState)(""),[eu,ed]=(0,X.useState)("all"),[em,ep]=(0,X.useState)(!1),[eh,ef]=(0,X.useState)(null),{products:ex,isLoading:eg}=function(e){let t,r,a=(0,n.c)(10),i=ei(),s=e.trim(),o=s.length>0,l=(0,S.useQuery)(b.api.commerce.pos.register_catalog.listRegisterCatalog,o?"skip":i),c=(0,S.useQuery)(b.api.commerce.pos.register_catalog.searchRegisterCatalog,es(i,o?{text:s}:null));if(o){let e,t;a[0]!==c?(e=c??[],a[0]=c,a[1]=e):e=a[1];let n=void 0===c;return a[2]!==e||a[3]!==n?(t={products:e,isLoading:n},a[2]=e,a[3]=n,a[4]=t):t=a[4],t}a[5]!==l?(t=l??[],a[5]=l,a[6]=t):t=a[6];let u=void 0===l;return a[7]!==t||a[8]!==u?(r={products:t,isLoading:u},a[7]=t,a[8]=u,a[9]=r):r=a[9],r}(el),{variantsByProduct:ev,isLoading:ey}=((O=(0,n.c)(7))[0]!==eo?(D=eo?{owner:eo}:"skip",O[0]=eo,O[1]=D):D=O[1],E=(0,S.useQuery)(b.api.commerce.catalog.products.listCatalogVariants,D),O[2]!==E?(L=new Map((E??[]).map(rp)),O[2]=E,O[3]=L):L=O[3],B=L,$=null!==eo&&void 0===E,O[4]!==$||O[5]!==B?(A={variantsByProduct:B,isLoading:$},O[4]=$,O[5]=B,O[6]=A):A=O[6],A),{categories:ej,isLoading:eb}=((H=(0,n.c)(9))[0]!==eo?(z=eo?{owner:eo}:"skip",H[0]=eo,H[1]=z):z=H[1],G=(0,S.useQuery)(b.api.commerce.catalog.categories.listCategories,z),H[2]!==G?(F=G??[],H[2]=G,H[3]=F):F=H[3],H[4]!==F?(q=F.map(rV),H[4]=F,H[5]=q):q=H[5],Q=q,W=null!==eo&&void 0===G,H[6]!==Q||H[7]!==W?(V={categories:Q,isLoading:W},H[6]=Q,H[7]=W,H[8]=V):V=H[8],V),eS=(0,p.useFavoriteProductIds)(),eC=(0,p.useToggleFavorite)(),eM=(ee=(0,n.c)(12),et=(0,p.useCartLines)(),en=(0,p.useSetQuantity)(),ee[0]!==et?(K=(e,t)=>{var n;return n={productId:e.id,variantId:t},(0,C.findPoolableLine)(et,n)?.quantity??0},ee[0]=et,ee[1]=K):K=ee[1],ee[2]!==et||ee[3]!==ea||ee[4]!==en?(Z=(e,t,n)=>{let r=function(e,t,n){let r=(0,C.findPoolableLine)(e,t);if(!r)return n>0?{kind:"ring"}:{kind:"none"};let a=r.quantity+n;return a<0?{kind:"none"}:{kind:"set",lineId:r.lineId,quantity:a}}(et,{productId:e.id,variantId:t.variantId},n);"ring"===r.kind?ea(e,t):"set"===r.kind&&en(r.lineId,r.quantity)},ee[2]=et,ee[3]=ea,ee[4]=en,ee[5]=Z):Z=ee[5],ee[6]!==et?(J=e=>{var t;let n;return t=e.id,{totalMinor:(n=et.filter(e=>e.productId===t)).reduce((e,t)=>e+(0,C.computeLineTotalMinor)(t),0),units:n.reduce((e,t)=>e+t.quantity,0)}},ee[6]=et,ee[7]=J):J=ee[7],ee[8]!==K||ee[9]!==Z||ee[10]!==J?(Y={quantityOf:K,step:Z,tallyOf:J},ee[8]=K,ee[9]=Z,ee[10]=J,ee[11]=Y):Y=ee[11],Y);er[0]!==ev?(s=e=>{var t;return t=e.id,ev.get(t)??rm},er[0]=ev,er[1]=s):s=er[1];let ew=s;er[2]!==eM||er[3]!==ew?(o=(e,t)=>{let n=function(e,t){let[n]=t;return n?1===t.length?{kind:"ring",selection:rh(n)}:{kind:"choose"}:{kind:"ring",selection:{unitPriceMinor:e}}}(e.priceMinor,ew(e));"choose"===n.kind?ef({kind:"sizes",product:e}):eM.step(e,n.selection,t)},er[2]=eM,er[3]=ew,er[4]=o):o=er[4];let ek=o;er[5]!==eM||er[6]!==ew?(l=e=>{let t=ew(e);return t.length>1?eM.tallyOf(e).units:eM.quantityOf(e,t[0]?.id)},er[5]=eM,er[6]=ew,er[7]=l):l=er[7];let eN=l;er[8]!==el?(c=el.trim(),er[8]=el,er[9]=c):c=er[9];let e_=c.length>0;if(er[10]!==ej||er[11]!==e_||er[12]!==eS||er[13]!==ex||er[14]!==eu){let e;e=(a={isSearching:e_,sections:(u=function(e){let t=e.categories.toSorted((e,t)=>e.order-t.order),n=new Map,r=[];for(let a of e.products){let e=function(e,t){return t.find(t=>e.categoryIds.some(e=>e===t.id))??null}(a,t);
1if(!e){r.push(a);continue}let i=n.get(e.id);if(i){i.push(a);continue}n.set(e.id,[a])}let a=t.flatMap(e=>{let t=n.get(e.id);return t?[{id:e.id,name:e.name,products:t.toSorted(rA)}]:[]});r.length>0&&a.push({id:"extras",name:a.length>0?"Extras":"All items",products:r.sort(rA)});let i=new Map(e.products.map(e=>[e.id,e]));return{favorites:e.favoriteIds.map(e=>i.get(e)).filter(e=>void 0!==e),sections:a}}({categories:ej,favoriteIds:eS,products:ex})).sections,shelf:eu}).sections.filter(e=>e.id===a.shelf),d=a.isSearching||0===e.length?{activeShelf:"all",sections:a.sections}:{activeShelf:a.shelf,sections:e},er[10]=ej,er[11]=e_,er[12]=eS,er[13]=ex,er[14]=eu,er[15]=u,er[16]=d}else u=er[15],d=er[16];let eI=d;er[17]===Symbol.for("react.memo_cache_sentinel")?(m=e=>ef({kind:"details",product:e}),er[17]=m):m=er[17],er[18]!==eC?(h=e=>eC(e.id),er[18]=eC,er[19]=h):h=er[19],er[20]!==eN||er[21]!==ek||er[22]!==em||er[23]!==eS||er[24]!==h||er[25]!==ew?(f={countFor:eN,isPinning:em,onDetails:m,onStep:ek,onTogglePin:h,pinnedIds:eS,variantsFor:ew},er[20]=eN,er[21]=ek,er[22]=em,er[23]=eS,er[24]=h,er[25]=ew,er[26]=f):f=er[26];let eT=f;er[27]===Symbol.for("react.memo_cache_sentinel")?(v=e=>ec(e.target.value),er[27]=v):v=er[27],er[28]!==el?(y=(0,t.jsx)(U.Input,{"aria-label":"Search products",className:"flex-1",onChange:v,placeholder:"Search products",value:el}),er[28]=el,er[29]=y):y=er[29],er[30]!==em?(j=()=>{ef(null),ep(!em)},er[30]=em,er[31]=j):j=er[31];let eP=em?"default":"surface";er[32]!==em?(M=em?(0,t.jsx)(g.Check,{}):(0,t.jsx)(rd.Pin,{}),er[32]=em,er[33]=M):M=er[33];let eR=em?"Done":"Quick keys";return er[34]!==em||er[35]!==j||er[36]!==eP||er[37]!==M||er[38]!==eR?(w=(0,t.jsxs)(r.Button,{"aria-pressed":em,onClick:j,variant:eP,children:[M,eR]}),er[34]=em,er[35]=j,er[36]=eP,er[37]=M,er[38]=eR,er[39]=w):w=er[39],er[40]!==y||er[41]!==w?(k=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[y,w]}),er[40]=y,er[41]=w,er[42]=k):k=er[42],er[43]!==em?(N=em?(0,t.jsx)(i.Text,{variant:"bodySmall",children:"Tap the items this counter sells most. They stay at the top of the case."}):null,er[43]=em,er[44]=N):N=er[44],er[45]!==eT||er[46]!==e_||er[47]!==u?(_=e_?null:(0,t.jsx)(rG,{handlers:eT,products:u.favorites}),er[45]=eT,er[46]=e_,er[47]=u,er[48]=_):_=er[48],er[49]!==e_||er[50]!==eI||er[51]!==u?(I=e_?null:(0,t.jsx)(rO,{onSelect:ed,sections:u.sections,value:eI.activeShelf}),er[49]=e_,er[50]=eI,er[51]=u,er[52]=I):I=er[52],er[53]!==eT||er[54]!==eg||er[55]!==eb||er[56]!==ey||er[57]!==e_||er[58]!==eI?(T=(0,t.jsx)(x.ScrollArea,{className:"min-h-0 flex-1",classNameViewport:"pr-2 max-md:pb-24",children:eg||ey||eb?(0,t.jsx)("div",{className:"flex h-full items-center justify-center"}):(0,t.jsx)(rW,{handlers:eT,isSearching:e_,sections:eI.sections})}),er[53]=eT,er[54]=eg,er[55]=eb,er[56]=ey,er[57]=e_,er[58]=eI,er[59]=T):T=er[59],er[60]!==eh||er[61]!==eM||er[62]!==ew?(P=eh?(0,t.jsx)(rK,{modal:eh,onClose:()=>ef(null),stepper:eM,variantsFor:ew}):null,er[60]=eh,er[61]=eM,er[62]=ew,er[63]=P):P=er[63],er[64]!==k||er[65]!==N||er[66]!==_||er[67]!==I||er[68]!==T||er[69]!==P?(R=(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-3 p-3",children:[k,N,_,I,T,P]}),er[64]=k,er[65]=N,er[66]=_,er[67]=I,er[68]=T,er[69]=P,er[70]=R):R=er[70],R}function rJ(e){let a,i,s,o=(0,n.c)(4),{onSetUpLocation:l}=e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)(ed.EmptyHeader,{children:[(0,t.jsx)(ed.EmptyTitle,{children:"No register location"}),(0,t.jsx)(ed.EmptyDescription,{children:"The register rings up sales at a pickup-enabled location. Add one and this shop can sell at the counter. And take pickup orders online."})]}),o[0]=a):a=o[0],o[1]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(eV.MapPin,{}),o[1]=i):i=o[1],o[2]!==l?(s=(0,t.jsxs)(ed.Empty,{children:[a,(0,t.jsx)(ed.EmptyContent,{children:(0,t.jsxs)(r.Button,{onClick:l,children:[i,"Set up register location"]})})]}),o[2]=l,o[3]=s):s=o[3],s}function rY(){let e,r=(0,n.c)(1);return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ed.Empty,{children:(0,t.jsxs)(ed.EmptyHeader,{children:[(0,t.jsx)(ed.EmptyTitle,{children:"No shop available"}),(0,t.jsx)(ed.EmptyDescription,{children:"Select a shop you own to open the register."})]})}),r[0]=e):e=r[0],e}function r0(e){let r,a,i,s=(0,n.c)(14),{activeLocation:o,isLoadingLocations:l,onAdd:c,onSetUpLocation:u,owner:d,pickupLocations:m,session:p,taxRateBps:h}=e;if(l){let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(em.PanelSkeleton,{className:"h-full"}),s[0]=e):e=s[0],e}if(0===m.length||!o){let e;return s[1]!==u?(e=(0,t.jsx)(rJ,{onSetUpLocation:u}),s[1]=u,s[2]=e):e=s[2],e}return s[3]!==c||s[4]!==d?(r=(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(rZ,{onAdd:c,owner:d})}),s[3]=c,s[4]=d,s[5]=r):r=s[5],s[6]!==o._id||s[7]!==d||s[8]!==p||s[9]!==h?(a=(0,t.jsx)(rc,{locationId:o._id,owner:d,session:p,taxRateBps:h}
1),s[6]=o._id,s[7]=d,s[8]=p,s[9]=h,s[10]=a):a=s[10],s[11]!==r||s[12]!==a?(i=(0,t.jsxs)("div",{className:"flex min-h-0 flex-1",children:[r,a]}),s[11]=r,s[12]=a,s[13]=i):i=s[13],i}e.s(["PosRegisterMain",0,function(e){let r,a=(0,n.c)(11),{activeLocation:i,isLoading:s,isLoadingLocations:o,onAdd:l,onSetUpLocation:c,owner:u,pickupLocations:d,session:m,taxRateBps:p}=e;if(s){let e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(em.PanelSkeleton,{className:"h-full"}),a[0]=e):e=a[0],e}if(!u){let e;return a[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(rY,{}),a[1]=e):e=a[1],e}return a[2]!==i||a[3]!==o||a[4]!==l||a[5]!==c||a[6]!==u||a[7]!==d||a[8]!==m||a[9]!==p?(r=(0,t.jsx)(r0,{activeLocation:i,isLoadingLocations:o,onAdd:l,onSetUpLocation:c,owner:u,pickupLocations:d,session:m,taxRateBps:p}),a[2]=i,a[3]=o,a[4]=l,a[5]=c,a[6]=u,a[7]=d,a[8]=m,a[9]=p,a[10]=r):r=a[10],r}],891777);let r1="tc:pos-register-token:v1";function r2(){let e=function(){if("u"<typeof localStorage)return null;try{return localStorage.getItem(r1)}catch(e){return console.error("[pos] reading the register token failed",e),null}}();if(null!==e&&e.trim().length>=16)return e.trim();let t=function(){try{return crypto.randomUUID()}catch{let e=new Uint8Array(16);crypto.getRandomValues(e);let t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`reg_${t}`}}();return function(e){if("u">typeof localStorage)try{localStorage.setItem(r1,e)}catch(e){console.error("[pos] persisting the register token failed",e)}}(t),t}e.s(["usePosRegisterCart",0,function(){let e,t,r,a,i,s=(0,n.c)(15),[o]=(0,
1X.useState)(r2),l=(0,p.usePosStore)(),c=(0,p.useSelectedSpaceId)(),u=c??"personal",d=ei();s[0]!==o||s[1]!==d?(e=es(d,{registerToken:o}),s[0]=o,s[1]=d,s[2]=e):e=s[2];let m=(0,S.useQuery)(b.api.commerce.pos.register_carts.getRegisterCart,e),h=(0,S.useMutation)(b.api.commerce.pos.register_carts.saveRegisterCart),f=(0,X.useRef)(null),x=(0,X.useRef)(null);s[3]!==u||s[4]!==m||s[5]!==l?(t=function(){void 0!==m&&f.current!==u&&(m&&l.getState().hydrateCart(m),f.current=u,x.current=JSON.stringify((0,p.posCartDraftOf)(l.getState())))},r=[u,m,l],s[3]=u,s[4]=m,s[5]=l,s[6]=t,s[7]=r):(t=s[6],r=s[7]),(0,X.useEffect)(t,r),s[8]!==u||s[9]!==o||s[10]!==h||s[11]!==c||s[12]!==l?(a=function(){let e,t,n=function({delayMs:e,save:t}){let n=null,r=null,a=!1;function i(){null!==r&&(clearTimeout(r),r=null)}function s(){if(a||null===n)return;let e=n;n=null,a=!0;let r=()=>{a=!1,s()};t(e).then(r,r)}return{flush:()=>{i(),s()},queue:t=>{n=t,i(),r=setTimeout(()=>{r=null,s()},e)}}}({delayMs:400,save:e=>h({...ea(c),registerToken:o,draft:e}).catch(e=>{console.error("[pos] saving the register's sale failed",e),x.current=null})}),r=(e=()=>n.flush(),t=()=>{"hidden"===document.visibilityState&&n.flush()},window.addEventListener("pagehide",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("pagehide",e),document.removeEventListener("visibilitychange",t)}),a=l.subscribe(()=>{if(l.getState().selectedSpaceId!==c||f.current!==u)return;let e=(0,p.posCartDraftOf)(l.getState()),t=JSON.stringify(e);t!==x.current&&(x.current=t,n.queue(e))});return()=>{a(),r(),n.flush()}},i=[u,o,h,c,l],s[8]=u,s[9]=o,s[10]=h,s[11]=c,s[12]=l,s[13]=a,s[14]=i):(a=s[13],i=s[14]),(0,X.useEffect)(a,i)}],630596);var r3=e.i(441266),r4=e.i(880698);function r5(e){return e.reduce((e,t)=>e+t.amountMinor,0)}function r6(e){return e.reduce((e,t)=>e+t.refundedMinor,0)}var r7=e.i(311097);function r8(e){return e.filter(e=>"captured"===e.status).map(e=>({id:e._id,kind:e.kind,amountMinor:e.amountMinor,refundedMinor:e.refundedMinor??0}))}function r9(e){let t=r8(e);return Math.max(0,r5(t)-r6(t))}let ae={neutral:"outline",success:"green",warning:"amber"},at={paid:{label:"Paid",tone:"success"},partially_paid:{label:"Partially paid",tone:"warning"},partially_refunded:{label:"Partially refunded",tone:"warning"},refunded:{label:"Fully refunded",tone:"neutral"},unpaid:{label:"Unpaid",tone:"neutral"}};function an(e,t){let n=r8(e),r=r5(n),a=r6(n);return r>0&&a===r?{label:"Fully refunded",tone:"neutral"}:a>0?{label:"Partially refunded",tone:"warning"}:r>0?{label:"Refundable",tone:"success"}:e.some(e=>"pending"===e.status)?{label:"Authorized",tone:"warning"}:e.some(e=>"voided"===e.status)?{label:"Voided",tone:"neutral"}:at[t]}let ar="A reason is required.";function aa(e,t){return e instanceof Error&&e.message?e.message:t}async function ai(e,t){var n,r;let a,i,s=t.reason.trim();if(0===s.length)return{ok:!1,message:ar};let o=(n=t.tenders,r=t.amount,a=r8(n),(i=function(e,t,n){if(t<=0)return{ok:!1,reason:"nothing_captured"};let r=t-n;return r<=0?{ok:!1,reason:"fully_refunded"}:void 0===e?{amountMinor:r,ok:!0}:(0,r7.isValidMinorAmount)(e)&&Number.isInteger(e)?e<=0?{ok:!1,reason:"not_positive"}:e>r?{ok:!1,reason:"exceeds_refundable"}:{amountMinor:e,ok:!0}:{ok:!1,reason:"not_minor_units"}}("full"===r.kind?void 0:r.amountMinor,r5(a),r6(a))).ok?{ok:!0}:{ok:!1,message:function(e){switch(e){case"nothing_captured":return"This sale has no captured payment to refund.";case"fully_refunded":return"This sale is already fully refunded.";case"not_minor_units":return"Enter a refund amount in whole cents.";case"not_positive":return"Enter a refund amount greater than zero.";case"exceeds_refundable":return"That is more than is left to refund on this sale.";default:return e}}(i.reason)});if(!o.ok)return{ok:!1,message:o.message};try{let n=await e.refundPosOrder({amountMinor:"full"===t.amount.kind?void 0:t.amount.amountMinor,orderId:t.orderId,reason:s,sessionId:t.sessionId});return{ok:!0,paymentStatus:n.paymentStatus,refundedMinor:n.refundedMinor}}catch(e){return{ok:!1,message:aa(e,"The refund did not go through.")}}}async function as(e,t){let n=t.reason.trim();if(0===n.length)return{ok:!1,message:ar};if("pending"!==t.tender.status)return{ok:!1,message:"Only an uncaptured payment can be voided. Refund it instead."};try{return await e.voidPosTender({reason:n,tenderId:t.tender._id}),{ok:!0}}catch(e){return{ok:!1,message:aa(e,"The void did not go through.")}}}function ao(e){let a,i,s,o,l,c,u,d,p,h,f,x,g,v,y,C,M,w,k,N,_,I,T,P,R,D,L,A,O,E,B=(0,n.c)(74),{currency:$,onOpenChange:z,open:F,orderId:q,orderNumber:G,sessionId:Q,tenders:W}=e,Z=(0,m.usePortalContainer)(),J=(0,S.useAction)(b.api.commerce.pos.refunds.refundPosOrder),[Y,en]=(0,X.useState)(null),[er,ea]=(0,X.useState)(""),[ei,es]=(0,X.useState)(!1);if(B[0]!==Z||B[1]!==$||B[2]!==ei||B[3]!==z||B[4]!==F||B[5]!==q||B[6]!==G||B[7]!==er||B[8]!==J||B[9]!==Q||B[10]!==W||B[11]!==Y){let e,n=r9(W),r=ee(l=Y??et(n)),m=r===n?{kind:"full"}:{kind:"partial",amountMinor:r};d=er.trim().length>0&&r>0,B[26]!==ei||B[27]!==z?(e=()=>{ei||(en(null),ea(""),z(!1))},B[26]=ei,B[27]=z,B[28]=e):e=B[28],c=e,u=async e=>{if(e.preventDefault(),!d||ei)return;es(!0);let t=await ai({refundPosOrder:J},{amount:m,orderId:q,reason:er,sessionId:Q,tenders:W});if(es(!1),t.ok){K.toast.success(`Refunded ${(0,j.formatPriceMinor)(t.refundedMinor,$)} on order ${G}
1.`),c();return}K.toast.error(t.message)},o=V.Dialog,B[29]!==c?(g=e=>!e&&c(),B[29]=c,B[30]=g):g=B[30],v=F,s=V.DialogContent,f="sm:max-w-[400px]",x=Z,i=V.DialogHeader,B[31]!==G?(h=(0,t.jsxs)(V.DialogTitle,{children:["Refund order ",G]}),B[31]=G,B[32]=h):h=B[32],a=V.DialogDescription,p=(0,j.formatPriceMinor)(n,$),B[0]=Z,B[1]=$,B[2]=ei,B[3]=z,B[4]=F,B[5]=q,B[6]=G,B[7]=er,B[8]=J,B[9]=Q,B[10]=W,B[11]=Y,B[12]=a,B[13]=i,B[14]=s,B[15]=o,B[16]=l,B[17]=c,B[18]=u,B[19]=d,B[20]=p,B[21]=h,B[22]=f,B[23]=x,B[24]=g,B[25]=v}else a=B[12],i=B[13],s=B[14],o=B[15],l=B[16],c=B[17],u=B[18],d=B[19],p=B[20],h=B[21],f=B[22],x=B[23],g=B[24],v=B[25];B[33]!==a||B[34]!==p?(y=(0,t.jsxs)(a,{children:[p," left to refund. Cash comes out of the open drawer; card and store credit reverse on their own rail."]}),B[33]=a,B[34]=p,B[35]=y):y=B[35],B[36]!==i||B[37]!==h||B[38]!==y?(C=(0,t.jsxs)(i,{children:[h,y]}),B[36]=i,B[37]=h,B[38]=y,B[39]=C):C=B[39],B[40]===Symbol.for("react.memo_cache_sentinel")?(M=(0,t.jsx)(H.Label,{htmlFor:"pos-refund-amount",children:"Refund amount"}),B[40]=M):M=B[40],B[41]===Symbol.for("react.memo_cache_sentinel")?(w=e=>en(e.target.value),B[41]=w):w=B[41],B[42]!==l?(k=(0,t.jsxs)("div",{className:"space-y-2",children:[M,(0,t.jsx)(U.Input,{id:"pos-refund-amount",inputMode:"decimal",onChange:w,placeholder:"0.00",value:l})]}),B[42]=l,B[43]=k):k=B[43],B[44]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)(H.Label,{htmlFor:"pos-refund-reason",children:"Reason"}),B[44]=N):N=B[44],B[45]===Symbol.for("react.memo_cache_sentinel")?(_=e=>ea(e.target.value),B[45]=_):_=B[45],B[46]!==er?(I=(0,t.jsxs)("div",{className:"space-y-2",children:[N,(0,t.jsx)(U.Input,{autoFocus:!0,id:"pos-refund-reason",onChange:_,placeholder:"Why is this being refunded?",value:er})]}),B[46]=er,B[47]=I):I=B[47],B[48]!==k||B[49]!==I?(T=(0,t.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[k,I]}),B[48]=k,B[49]=I,B[50]=T):T=B[50],B[51]!==c?(P=(0,t.jsx)(r.Button,{onClick:c,type:"button",variant:"surface",children:"Cancel"}),B[51]=c,B[52]=P):P=B[52];let eo=!d||ei;return B[53]===Symbol.for("react.memo_cache_sentinel")?(R=(0,t.jsx)(r4.Undo2,{}),B[53]=R):R=B[53],B[54]!==eo?(D=(0,t.jsxs)(r.Button,{disabled:eo,type:"submit",variant:"destructive-solid",children:[R,"Refund"]}),B[54]=eo,B[55]=D):D=B[55],B[56]!==P||B[57]!==D?(L=(0,t.jsxs)(V.DialogFooter,{children:[P,D]}),B[56]=P,B[57]=D,B[58]=L):L=B[58],B[59]!==u||B[60]!==T||B[61]!==L?(A=(0,t.jsxs)("form",{onSubmit:u,children:[T,L]}),B[59]=u,B[60]=T,B[61]=L,B[62]=A):A=B[62],B[63]!==s||B[64]!==A||B[65]!==f||B[66]!==x||B[67]!==C?(O=(0,t.jsxs)(s,{className:f,container:x,children:[C,A]}),B[63]=s,B[64]=A,B[65]=f,B[66]=x,B[67]=C,B[68]=O):O=B[68],B[69]!==o||B[70]!==O||B[71]!==g||B[72]!==v?(E=(0,t.jsx)(o,{onOpenChange:g,open:v,children:O}),B[69]=o,B[70]=O,B[71]=g,B[72]=v,B[73]=E):E=B[73],E}function al(e){let a,i,s,o,l,c,u,d,p,h,f,x,g,v,y,C,M,w=(0,n.c)(44),{currency:k,onOpenChange:N,open:_,tender:I}=e,T=(0,m.usePortalContainer)(),P=(0,S.useAction)(b.api.commerce.pos.refunds.voidPosTender),[R,D]=(0,X.useState)(""),[L,A]=(0,X.useState)(!1);w[0]!==R?(a=R.trim(),w[0]=R,w[1]=a):a=w[1];let O=a.length>0;w[2]!==L||w[3]!==N?(i=()=>{L||(D(""),N(!1))},w[2]=L,w[3]=N,w[4]=i):i=w[4];let E=i;w[5]!==E||w[6]!==L||w[7]!==O||w[8]!==R||w[9]!==I||w[10]!==P?(s=async e=>{if(e.preventDefault(),!O||L)return;A(!0);let t=await as({voidPosTender:P},{reason:R,tender:I});if(A(!1),t.ok){K.toast.success("Payment voided. The authorization was released."),E();return}K.toast.error(t.message)},w[5]=E,w[6]=L,w[7]=O,w[8]=R,w[9]=I,w[10]=P,w[11]=s):s=w[11];let B=s;w[12]!==E?(o=e=>!e&&E(),w[12]=E,w[13]=o):o=w[13],w[14]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(V.DialogTitle,{children:"Void payment"}),w[14]=l):l=w[14],w[15]!==k||w[16]!==I.amountMinor?(c=(0,j.formatPriceMinor)(I.amountMinor,k),w[15]=k,w[16]=I.amountMinor,w[17]=c):c=w[17],w[18]!==c?(u=(0,t.jsxs)(V.DialogHeader,{children:[l,(0,t.jsxs)(V.DialogDescription,{children:["Releases the ",c," ","authorization on this card. Nothing was captured, so nothing is refunded."]})]}),w[18]=c,w[19]=u):u=w[19],w[20]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(H.Label,{htmlFor:"pos-void-reason",children:"Reason"}),w[20]=d):d=w[20],w[21]===Symbol.for("react.memo_cache_sentinel")?(p=e=>D(e.target.value),w[21]=p):p=w[21],w[22]!==R?(h=(0,t.jsxs)("div",{className:"space-y-2 py-4",children:[d,(0,t.jsx)(U.Input,{autoFocus:!0,id:"pos-void-reason",onChange:p,placeholder:"Why is this being voided?",value:R})]}),w[22]=R,w[23]=h):h=w[23],w[24]!==E?(f=(0,t.jsx)(r.Button,{onClick:E,type:"button",variant:"surface",children:"Cancel"}),w[24]=E,w[25]=f):f=w[25];let $=!O||L;return w[26]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)(r3.Ban,{}),w[26]=x):x=w[26],w[27]!==$?(g=(0,t.jsxs)(r.Button,{disabled:$,type:"submit",variant:"destructive-solid",children:[x,"Void payment"]}),w[27]=$,w[28]=g):g=w[28],w[29]!==f||w[30]!==g?(v=(0,t.jsxs)(V.DialogFooter,{children:[f,g]}),w[29]=f,w[30]=g,w[31]=v):v=w[31],w[32]!==B||w[33]!==h||w[34]!==v?(y=(0,t.jsxs)("form",{onSubmit:B,children:[h,v]}
1),w[32]=B,w[33]=h,w[34]=v,w[35]=y):y=w[35],w[36]!==T||w[37]!==y||w[38]!==u?(C=(0,t.jsxs)(V.DialogContent,{className:"sm:max-w-[400px]",container:T,children:[u,y]}),w[36]=T,w[37]=y,w[38]=u,w[39]=C):C=w[39],w[40]!==_||w[41]!==C||w[42]!==o?(M=(0,t.jsx)(V.Dialog,{onOpenChange:o,open:_,children:C}),w[40]=_,w[41]=C,w[42]=o,w[43]=M):M=w[43],M}let ac={card_present:"Card",cash:"Cash",comp:"Comp",store_credit:"Store credit"},au={captured:"Captured",pending:"Authorized",voided:"Voided"};function ad(e){let r,a,s,o=(0,n.c)(9),{emphasis:l,label:c,value:u}=e,d=l?"labelBold":"bodyMuted";o[0]!==c||o[1]!==d?(r=(0,t.jsx)(i.Text,{as:"span",variant:d,children:c}),o[0]=c,o[1]=d,o[2]=r):r=o[2];let m=l?"statValue":"label";return o[3]!==m||o[4]!==u?(a=(0,t.jsx)(i.Text,{as:"span",variant:m,children:u}),o[3]=m,o[4]=u,o[5]=a):a=o[5],o[6]!==r||o[7]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[r,a]}),o[6]=r,o[7]=a,o[8]=s):s=o[8],s}function am(e){let a,s,o,l,c,u,d,m,p,h=(0,n.c)(26),{currency:f,onVoid:x,tender:g}=e,v=g.refundedMinor??0,y=ac[g.kind];h[0]!==y?(a=(0,t.jsx)(i.Text,{as:"span",variant:"label",children:y}),h[0]=y,h[1]=a):a=h[1];let b="captured"===g.status?"secondary":"outline",S=au[g.status];return h[2]!==b||h[3]!==S?(s=(0,t.jsx)(q.Badge,{variant:b,children:S}),h[2]=b,h[3]=S,h[4]=s):s=h[4],h[5]!==f||h[6]!==v?(o=v>0?(0,t.jsxs)(i.Text,{as:"span",variant:"caption",children:["−",(0,j.formatPriceMinor)(v,f)," refunded"]}):null,h[5]=f,h[6]=v,h[7]=o):o=h[7],h[8]!==a||h[9]!==s||h[10]!==o?(l=(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[a,s,o]}),h[8]=a,h[9]=s,h[10]=o,h[11]=l):l=h[11],h[12]!==f||h[13]!==g.amountMinor?(c=(0,j.formatPriceMinor)(g.amountMinor,f),h[12]=f,h[13]=g.amountMinor,h[14]=c):c=h[14],h[15]!==c?(u=(0,t.jsx)(i.Text,{as:"span",variant:"label",children:c}),h[15]=c,h[16]=u):u=h[16],h[17]!==x||h[18]!==g.status?(d="pending"===g.status?(0,t.jsxs)(r.Button,{onClick:x,variant:"ghost",children:[(0,t.jsx)(r3.Ban,{}),"Void"]}):null,h[17]=x,h[18]=g.status,h[19]=d):d=h[19],h[20]!==d||h[21]!==u?(m=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[u,d]}),h[20]=d,h[21]=u,h[22]=m):m=h[22],h[23]!==m||h[24]!==l?(p=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 py-1.5",children:[l,m]}),h[23]=m,h[24]=l,h[25]=p):p=h[25],p}function ap(e){let r,a,s,o,l,c,u,d,m,p,h=(0,n.c)(31),{transaction:f}=e,{order:x,tenders:g}=f;if(h[0]!==x.customer.email||h[1]!==x.customer.name||h[2]!==x.customer.phone||h[3]!==x.orderNumber||h[4]!==x.paymentStatus||h[5]!==g){let e;s=an(g,x.paymentStatus),h[12]!==x.customer.email||h[13]!==x.customer.name||h[14]!==x.customer.phone?(e=[x.customer.name,x.customer.email,x.customer.phone].filter(ah),h[12]=x.customer.email,h[13]=x.customer.name,h[14]=x.customer.phone,h[15]=e):e=h[15],a=e.join(" · "),l="flex items-center justify-between gap-2",h[16]!==x.orderNumber?(c=(0,t.jsxs)(i.H3,{variant:"panel",children:["Order ",x.orderNumber]}),h[16]=x.orderNumber,h[17]=c):c=h[17],r=q.Badge,o=ae[s.tone],h[0]=x.customer.email,h[1]=x.customer.name,h[2]=x.customer.phone,h[3]=x.orderNumber,h[4]=x.paymentStatus,h[5]=g,h[6]=r,h[7]=a,h[8]=s,h[9]=o,h[10]=l,h[11]=c}else r=h[6],a=h[7],s=h[8],o=h[9],l=h[10],c=h[11];h[18]!==r||h[19]!==s.label||h[20]!==o?(u=(0,t.jsx)(r,{variant:o,children:s.label}),h[18]=r,h[19]=s.label,h[20]=o,h[21]=u):u=h[21],h[22]!==l||h[23]!==c||h[24]!==u?(d=(0,t.jsxs)("div",{className:l,children:[c,u]}),h[22]=l,h[23]=c,h[24]=u,h[25]=d):d=h[25];let v=a||"Walk-in customer";return h[26]!==v?(m=(0,t.jsx)(i.Text,{variant:"bodyMuted",children:v}),h[26]=v,h[27]=m):m=h[27],h[28]!==d||h[29]!==m?(p=(0,t.jsxs)(t.Fragment,{children:[d,m]}),h[28]=d,h[29]=m,h[30]=p):p=h[30],p}function ah(e){return void 0!==e}function af(e){let r,a,i,s,o,l,c,u,d,m=(0,n.c)(28),{transaction:p}=e,{lineItems:h,order:f}=p;if(m[0]!==h||m[1]!==f.currency){let e;m[3]!==f.currency?(e=e=>(0,t.jsx)(ad,{label:`${e.quantity}\xd7 ${e.name}`,value:(0,j.formatPriceMinor)(e.lineTotalMinor,f.currency)},e._id),m[3]=f.currency,m[4]=e):e=m[4],r=h.map(e),m[0]=h,m[1]=f.currency,m[2]=r}else r=m[2];return m[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(ep.Separator,{className:"my-1"}),m[5]=a):a=m[5],m[6]!==f.currency||m[7]!==f.discountMinor?(i=f.discountMinor>0?(0,t.jsx)(ad,{label:"Discount",value:`−${(0,j.formatPriceMinor)(f.discountMinor,f.currency)}`}):null,m[6]=f.currency,m[7]=f.discountMinor,m[8]=i):i=m[8],m[9]!==f.currency||m[10]!==f.taxMinor?(s=(0,j.formatPriceMinor)(f.taxMinor,f.currency),m[9]=f.currency,m[10]=f.taxMinor,m[11]=s):s=m[11],m[12]!==s?(o=(0,t.jsx)(ad,{label:"Tax",value:s}
1),m[12]=s,m[13]=o):o=m[13],m[14]!==f.currency||m[15]!==f.tipMinor?(l=f.tipMinor>0?(0,t.jsx)(ad,{label:"Tip",value:(0,j.formatPriceMinor)(f.tipMinor,f.currency)}):null,m[14]=f.currency,m[15]=f.tipMinor,m[16]=l):l=m[16],m[17]!==f.currency||m[18]!==f.totalMinor?(c=(0,j.formatPriceMinor)(f.totalMinor,f.currency),m[17]=f.currency,m[18]=f.totalMinor,m[19]=c):c=m[19],m[20]!==c?(u=(0,t.jsx)(ad,{emphasis:!0,label:"Total",value:c}),m[20]=c,m[21]=u):u=m[21],m[22]!==r||m[23]!==i||m[24]!==o||m[25]!==l||m[26]!==u?(d=(0,t.jsxs)("div",{className:"flex flex-col",children:[r,a,i,o,l,u]}),m[22]=r,m[23]=i,m[24]=o,m[25]=l,m[26]=u,m[27]=d):d=m[27],d}function ax(e){let r,a,s,o,l,c,u=(0,n.c)(15),{transaction:d}=e,{order:m,tenders:p}=d,[h,f]=(0,X.useState)(null);u[0]!==p||u[1]!==h?(r=p.filter(e=>"pending"===e.status).find(e=>e._id===h)??null,u[0]=p,u[1]=h,u[2]=r):r=u[2];let x=r;return u[3]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(i.Text,{as:"span",className:"pb-1",variant:"overline",children:"Payment"}),u[3]=a):a=u[3],u[4]!==m||u[5]!==p?(s=p.length>0?p.map(e=>(0,t.jsx)(am,{currency:m.currency,onVoid:()=>f(e._id),tender:e},e._id)):(0,t.jsx)(i.Text,{variant:"bodyMuted",children:"No register tender is attached."}),u[4]=m,u[5]=p,u[6]=s):s=u[6],u[7]!==s?(o=(0,t.jsxs)("div",{className:"flex flex-col",children:[a,s]}),u[7]=s,u[8]=o):o=u[8],u[9]!==m||u[10]!==x?(l=x?(0,t.jsx)(al,{currency:m.currency,onOpenChange:e=>!e&&f(null),open:!0,tender:x}):null,u[9]=m,u[10]=x,u[11]=l):l=u[11],u[12]!==o||u[13]!==l?(c=(0,t.jsxs)(t.Fragment,{children:[o,l]}),u[12]=o,u[13]=l,u[14]=c):c=u[14],c}function ag(e){let a,i,s,o,l,c,u,d,m,p,h,f,x,g=(0,n.c)(38),{session:v,transaction:y}=e,{order:b,tenders:S}=y,[C,M]=(0,X.useState)(null);if(g[0]!==b._id||g[1]!==b.currency||g[2]!==b.locationId||g[3]!==C||g[4]!==v||g[5]!==S){m=Symbol.for("react.early_return_sentinel");e:{let e=r9(S);if(!((s=v?.locationId===b.locationId?v._id:null)&&e>0)){m=null;break e}i=C===b._id,a=r.Button,g[15]!==b._id?(o=()=>M(b._id),g[15]=b._id,g[16]=o):o=g[16],l="surface",g[17]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(r4.Undo2,{}),g[17]=c):c=g[17],u="Refund ",d=(0,j.formatPriceMinor)(e,b.currency)}g[0]=b._id,g[1]=b.currency,g[2]=b.locationId,g[3]=C,g[4]=v,g[5]=S,g[6]=a,g[7]=i,g[8]=s,g[9]=o,g[10]=l,g[11]=c,g[12]=u,g[13]=d,g[14]=m}else a=g[6],i=g[7],s=g[8],o=g[9],l=g[10],c=g[11],u=g[12],d=g[13],m=g[14];return m!==Symbol.for("react.early_return_sentinel")?m:(g[18]!==a||g[19]!==o||g[20]!==l||g[21]!==c||g[22]!==u||g[23]!==d?(p=(0,t.jsxs)(a,{onClick:o,variant:l,children:[c,u,d]}),g[18]=a,g[19]=o,g[20]=l,g[21]=c,g[22]=u,g[23]=d,g[24]=p):p=g[24],g[25]!==b._id?(h=e=>M(e?b._id:null),g[25]=b._id,g[26]=h):h=g[26],g[27]!==i||g[28]!==b._id||g[29]!==b.currency||g[30]!==b.orderNumber||g[31]!==s||g[32]!==h||g[33]!==S?(f=(0,t.jsx)(ao,{currency:b.currency,onOpenChange:h,open:i,orderId:b._id,orderNumber:b.orderNumber,sessionId:s,tenders:S}),g[27]=i,g[28]=b._id,g[29]=b.currency,g[30]=b.orderNumber,g[31]=s,g[32]=h,g[33]=S,g[34]=f):f=g[34],g[35]!==p||g[36]!==f?(x=(0,t.jsxs)(t.Fragment,{children:[p,f]}),g[35]=p,g[36]=f,g[37]=x):x=g[37],x)}function av(e){let r,a,i,s,o,l,c=(0,n.c)(15),{session:u,transaction:d}=e;return c[0]!==d?(r=(0,t.jsx)(ap,{transaction:d}),a=(0,t.jsx)(af,{transaction:d}),i=(0,t.jsx)(ax,{transaction:d}),c[0]=d,c[1]=r,c[2]=a,c[3]=i):(r=c[1],a=c[2],i=c[3]),c[4]!==d.order._id?(s=(0,t.jsx)(nM,{orderId:d.order._id}),c[4]=d.order._id,c[5]=s):s=c[5],c[6]!==u||c[7]!==d?(o=(0,t.jsx)(ag,{session:u,transaction:d}),c[6]=u,c[7]=d,c[8]=o):o=c[8],c[9]!==r||c[10]!==a||c[11]!==i||c[12]!==s||c[13]!==o?(l=(0,t.jsx)(x.ScrollArea,{className:"min-h-0 flex-1",classNameViewport:"px-6 py-4",children:(0,t.jsxs)("div",{className:"mx-auto flex w-full max-w-lg flex-col gap-5",children:[r,a,i,s,o]})}),c[9]=r,c[10]=a,c[11]=i,c[12]=s,c[13]=o,c[14]=l):l=c[14],l}var ay=e.i(388517);function aj(e){let a,s,o,l,c,u,d,m,p,h,f,x,g,v,y,b,S,C,M=(0,n.c)(64),{isActive:w,onSelect:k,transaction:N}=e,{order:_,tenders:I}=N;if(M[0]!==w||M[1]!==k||M[2]!==_.createdAt||M[3]!==_.currency||M[4]!==_.customer.email||M[5]!==_.customer.name||M[6]!==_.orderNumber||M[7]!==_.paymentStatus||M[8]!==_.totalMinor||M[9]!==I||M[10]!==N.channel){let e,n,y,b;o=an(I,_.paymentStatus);let S=_.customer.name&&_.customer.email?`${_.customer.name} \xb7 ${_.customer.email}`:_.customer.name??_.customer.email??"Walk-in customer";(s=r.Button,f="gap-1 px-3 py-2",x=k,g="tile",v=w?"secondary":"ghost",M[25]!==_.orderNumber?(e=(0,t.jsx)(i.Text,{as:"span",variant:"label",children:_.orderNumber}),M[25]=_.orderNumber,M[26]=e):e=M[26],M[27]!==_.currency||M[28]!==_.totalMinor?(n=(0,j.formatPriceMinor)(_.totalMinor,_.currency),M[27]=_.currency,M[28]=_.totalMinor,M[29]=n):n=M[29],M[30]!==n?(y=(0,t.jsx)(i.Text,{as:"span",variant:"label",children:n}),M[30]=n,M[31]=y):y=M[31],M[32]!==e||M[33]!==y?(c=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[e,y]}),M[32]=e,M[33]=y,M[34]=c):c=M[34],M[35]!==S?(u=(0,t.jsx)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:(0,t.jsx)(i.Text,{as:"span",className:"truncate",variant:"caption",children:S})}),M[35]=S,M[36]=u):u=M[36],p="flex items-center justify-between gap-2",M[37]!==_.createdAt)?(b=new Date(_.createdAt).toLocaleStr
1ing(void 0,{dateStyle:"medium",timeStyle:"short"}),M[37]=_.createdAt,M[38]=b):b=M[38],M[39]!==b?(h=(0,t.jsx)(i.Text,{as:"span",variant:"caption",children:b}),M[39]=b,M[40]=h):h=M[40],d="flex items-center gap-1",M[41]!==N.channel?(m=(0,t.jsx)(q.Badge,{variant:"secondary",children:N.channel}),M[41]=N.channel,M[42]=m):m=M[42],a=q.Badge,l=ae[o.tone],M[0]=w,M[1]=k,M[2]=_.createdAt,M[3]=_.currency,M[4]=_.customer.email,M[5]=_.customer.name,M[6]=_.orderNumber,M[7]=_.paymentStatus,M[8]=_.totalMinor,M[9]=I,M[10]=N.channel,M[11]=a,M[12]=s,M[13]=o,M[14]=l,M[15]=c,M[16]=u,M[17]=d,M[18]=m,M[19]=p,M[20]=h,M[21]=f,M[22]=x,M[23]=g,M[24]=v}else a=M[11],s=M[12],o=M[13],l=M[14],c=M[15],u=M[16],d=M[17],m=M[18],p=M[19],h=M[20],f=M[21],x=M[22],g=M[23],v=M[24];return M[43]!==a||M[44]!==o.label||M[45]!==l?(y=(0,t.jsx)(a,{variant:l,children:o.label}),M[43]=a,M[44]=o.label,M[45]=l,M[46]=y):y=M[46],M[47]!==y||M[48]!==d||M[49]!==m?(b=(0,t.jsxs)("div",{className:d,children:[m,y]}),M[47]=y,M[48]=d,M[49]=m,M[50]=b):b=M[50],M[51]!==b||M[52]!==p||M[53]!==h?(S=(0,t.jsxs)("div",{className:p,children:[h,b]}),M[51]=b,M[52]=p,M[53]=h,M[54]=S):S=M[54],M[55]!==s||M[56]!==c||M[57]!==u||M[58]!==S||M[59]!==f||M[60]!==x||M[61]!==g||M[62]!==v?(C=(0,t.jsxs)(s,{className:f,onClick:x,size:g,variant:v,children:[c,u,S]}),M[55]=s,M[56]=c,M[57]=u,M[58]=S,M[59]=f,M[60]=x,M[61]=g,M[62]=v,M[63]=C):C=M[63],C}function ab(e){let a,i,s,o,l,c=(0,n.c)(17),{activeId:u,feed:d,onSelect:m}=e;if(c[0]!==u||c[1]!==d.transactions||c[2]!==m){let e;c[4]!==u||c[5]!==m?(e=e=>(0,t.jsx)(aj,{isActive:e.order._id===u,onSelect:()=>m(e.order._id),transaction:e},e.order._id),c[4]=u,c[5]=m,c[6]=e):e=c[6],a=d.transactions.map(e),c[0]=u,c[1]=d.transactions,c[2]=m,c[3]=a}else a=c[3];return c[7]!==d.canLoadMore||c[8]!==d.isLoadingMore||c[9]!==d.loadMore?(i=d.canLoadMore?(0,t.jsx)(r.Button,{className:"mt-2 w-full",disabled:d.isLoadingMore,onClick:d.loadMore,size:"sm",variant:"surface",children:"Load more"}):null,c[7]=d.canLoadMore,c[8]=d.isLoadingMore,c[9]=d.loadMore,c[10]=i):i=c[10],c[11]!==a||c[12]!==i?(s=(0,t.jsx)(x.ScrollArea,{className:"min-w-0 flex-1",classNameViewport:"p-2",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[a,i]})}),c[11]=a,c[12]=i,c[13]=s):s=c[13],c[14]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(ep.Separator,{orientation:"vertical"}),c[14]=o):o=c[14],c[15]!==s?(l=(0,t.jsxs)("div",{className:"flex w-72 shrink-0",children:[s,o]}),c[15]=s,c[16]=l):l=c[16],l}function aS(e){let r,a,i,s,o,l,c,u,d,m,p,h,f,x=(0,n.c)(15),{session:g}=e,v=(u=(0,n.c)(9),d=ei(),u[0]===Symbol.for("react.memo_cache_sentinel")?(o={initialNumItems:30},u[0]=o):o=u[0],p="CanLoadMore"===(m=(0,ay.usePaginatedQuery)(b.api.commerce.pos.transactions.listShopTransactions,d,o)).status,h="LoadingFirstPage"===m.status,f="LoadingMore"===m.status,u[1]!==m?(l=()=>m.loadMore(30),u[1]=m,u[2]=l):l=u[2],u[3]!==m.results||u[4]!==p||u[5]!==h||u[6]!==f||u[7]!==l?(c={canLoadMore:p,isLoading:h,isLoadingMore:f,loadMore:l,transactions:m.results},u[3]=m.results,u[4]=p,u[5]=h,u[6]=f,u[7]=l,u[8]=c):c=u[8],c),[y,j]=(0,X.useState)(null);if(v.isLoading){let e;return x[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(em.PanelSkeleton,{className:"flex-1"}),x[0]=e):e=x[0],e}let[S]=v.transactions;if(!S){let e;return x[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ed.Empty,{children:(0,t.jsxs)(ed.EmptyHeader,{children:[(0,t.jsx)(ed.EmptyTitle,{children:"No transactions yet"}),(0,t.jsx)(ed.EmptyDescription,{children:"Create an order to see it here."})]})}),x[1]=e):e=x[1],e}x[2]!==v.transactions||x[3]!==S||x[4]!==y?(r=v.transactions.find(e=>e.order._id===y)??S,x[2]=v.transactions,x[3]=S,x[4]=y,x[5]=r):r=x[5];let C=r;return x[6]!==C.order._id||x[7]!==v?(a=(0,t.jsx)(ab,{activeId:C.order._id,feed:v,onSelect:j}),x[6]=C.order._id,x[7]=v,x[8]=a):a=x[8],x[9]!==C||x[10]!==g?(i=(0,t.jsx)(av,{session:g,transaction:C}),x[9]=C,x[10]=g,x[11]=i):i=x[11],x[12]!==a||x[13]!==i?(s=(0,t.jsxs)("div",{className:"flex min-h-0 flex-1",children:[a,i]}),x[12]=a,x[13]=i,x[14]=s):s=x[14],s}e.s(["PosTransactionsView",0,function(e){let r,a,i,s=(0,n.c)(8),{locationId:o,session:l}=e;return s[0]!==o||s[1]!==l?(r=o?(0,t.jsx)("div",{className:"flex items-center justify-end gap-2 border-b px-3 py-2",children:(0,t.jsx)(el,{locationId:o,session:l})}
1):null,s[0]=o,s[1]=l,s[2]=r):r=s[2],s[3]!==l?(a=(0,t.jsx)(aS,{session:l}),s[3]=l,s[4]=a):a=s[4],s[5]!==r||s[6]!==a?(i=(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[r,a]}),s[5]=r,s[6]=a,s[7]=i):i=s[7],i}],929628),e.s(["usePosRegisterSession",0,function(e){let t,r,a=(0,n.c)(6),i=ei();a[0]!==e||a[1]!==i?(t=es(i,e?{locationId:e}:null),a[0]=e,a[1]=i,a[2]=t):t=a[2];let s=(0,S.useQuery)(b.api.commerce.pos.queries.getOpenRegisterSession,t),o=s??null,l=null!==e&&void 0===s;return a[3]!==o||a[4]!==l?(r={session:o,isLoading:l},a[3]=o,a[4]=l,a[5]=r):r=a[5],r}],772265);let aC={icon:void 0,name:u.PERSONAL_SHOP_LABEL};e.s(["posShopBrandFromIdentity",0,function(e){return e?{icon:(0,l.fromConvexIconData)(e.iconData),name:e.name}:aC}],722226)},177067,e=>{"use strict";var t=e.i(201038);let n=t.v.union(t.v.literal("shop"),t.v.literal("user")),r=t.v.object({defaultIdentity:n}),a=t.v.object({defaultIdentity:n});t.v.object({address:t.v.string(),identity:n}),e.s(["commerceOutboundSettingsValidator",0,r,"resolvedOutboundSettingsReturnType",0,a])},306985,54225,e=>{"use strict";var t=e.i(201038),n=e.i(223263);e.i(603091);let r=t.v.union(t.v.object({categoryId:t.v.id("commerceCategories"),kind:t.v.literal("category")}),t.v.object({kind:t.v.literal("name_pattern"),pattern:t.v.string()})),a=t.v.object({leadTime:n.productLeadTimeValidator,match:r}),i=t.v.object({appliesTo:r,feePercent:t.v.number(),minNoticeHours:t.v.number()}),s=t.v.object({defaultModifierGroupIds:t.v.optional(t.v.array(t.v.id("commerceModifierGroups"))),leadTimeRules:t.v.optional(t.v.array(a)),rush:t.v.optional(i)});t.v.object({defaultModifierGroupIds:t.v.optional(t.v.array(t.v.id("commerceModifierGroups"))),leadTimeRules:t.v.optional(t.v.array(a)),rush:t.v.optional(t.v.union(i,t.v.null()))});let o=t.v.object({defaultModifierGroupIds:t.v.array(t.v.id("commerceModifierGroups")),leadTimeRules:t.v.array(a),rush:t.v.optional(i)});e.s(["commerceCatalogDefaultsValidator",0,s,"resolvedCatalogDefaultsReturnType",0,o],306985);let l=e.i(311097).BPS_PER_UNIT,c=t.v.union(t.v.literal("charging"),t.v.literal("none"),t.v.literal("unset"));t.v.union(t.v.literal("location"),t.v.literal("shop")),t.v.union(t.v.object({kind:t.v.literal("rate"),rateBps:t.v.number()}),t.v.object({kind:t.v.literal("none")}),t.v.object({kind:t.v.literal("unset")})),e.s(["TAX_RATE_BPS_MAX",0,l,"taxRateStatusValidator",0,c],54225)},187763,e=>{"use strict";var t=e.i(201038);let n=t.v.object({allowCustom:t.v.optional(t.v.boolean()),enabled:t.v.optional(t.v.boolean()),presetBps:t.v.optional(t.v.array(t.v.number()))}),r=t.v.object({enabled:t.v.optional(t.v.boolean())}),a=t.v.object({appliedAt:t.v.number(),assetKey:t.v.string(),configurationId:t.v.string(),fileId:t.v.string(),locationId:t.v.string()}),i=t.v.object({splash:t.v.optional(r),splashApplied:t.v.optional(t.v.array(a)),tipping:t.v.optional(n)}),s=t.v.object({allowCustom:t.v.boolean(),enabled:t.v.boolean(),presetBps:t.v.array(t.v.number())}),o=t.v.object({enabled:t.v.boolean()}),l=t.v.object({splash:o,tipping:s});e.s(["commercePosSettingsValidator",0,i,"resolvedPosSettingsReturnType",0,l])},797905,e=>{"use strict";var t=e.i(201038);let n=t.v.object({enabled:t.v.boolean(),label:t.v.optional(t.v.string()),newsletterId:t.v.optional(t.v.id("crmNewsletters"))});t.v.optional(t.v.id("crmContactFolders")),t.v.string(),t.v.optional(t.v.id("teams")),t.v.string(),t.v.id("crmNewsletters"),t.v.id("crmNewsletters"),t.v.optional(t.v.id("teams")),t.v.id("crmNewsletters"),t.v.id("crmNewsletters"),e.s(["newsletterOptInSettingValidator",0,n])},503836,e=>{"use strict";var t=e.i(201038);let n=t.v.object({enabled:t.v.optional(t.v.boolean()),name:t.v.optional(t.v.string()),consentLabel:t.v.optional(t.v.string()),pageIds:t.v.optional(t.v.array(t.v.id("pages")))}),r=t.v.object({enabled:t.v.optional(t.v.boolean()),headline:t.v.optional(t.v.string()),body:t.v.optional(t.v.string()),community:t.v.optional(n)}),a=t.v.object({enabled:t.v.boolean(),name:t.v.string(),consentLabel:t.v.string(),pageIds:t.v.array(t.v.id("pages"))});t.v.object({enabled:t.v.boolean(),headline:t.v.string(),body:t.v.string(),community:a}),e.s(["commerceMembershipSettingsValidator",0,r])},207617,e=>{"use strict";var t=e.i(201038),n=e.i(177067),r=e.i(797905),a=e.i(833343),i=e.i(306985),s=e.i(897655),o=e.i(311097),l=e.i(54225),c=e.i(503836),u=e.i(938241),d=e.i(402312),m=e.i(187763);let p={affirm:"affirm",afterpayClearpay:"afterpay_clearpay",card:"card",cashApp:"cashapp",klarna:"klarna",link:"link",usBankAccount:"us_bank_account"},h=t.v.union(t.v.literal(p.card),t.v.literal(p.link),t.v.literal(p.usBankAccount),t.v.literal(p.cashApp),t.v.literal(p.klarna),t.v.literal(p.affirm),t.v.literal(p.afterpayClearpay)),f=t.v.array(h);o.BPS_PER_UNIT;let x=t.v.object({accentColor:t.v.optional(t.v.union(t.v.string(),t.v.null())),headline:t.v.optional(t.v.union(t.v.string(),t.v.null())),markPlacement:t.v.optional(t.v.union(t.v.literal("header"),t.v.literal("beside_total"),t.v.literal("hidden"))),showReadyLabels:t.v.optional(t.v.boolean()),variant:t.v.optional(t.v.union(t.v.literal("summary_first"),t.v.literal("payment_first")))}),g=t.v.object({allowCustom:t.v.optional(t.v.boolean()),enabled:t.v.optional(t.v.boolean()),presetBps:t.v.optional(t.v.array(t.v.number()))}),v=t.v.object({askRewardsOnReader:t.v.optional(t.v.boolean()),checkoutLayout:t.v.optional(x),checkoutUi:t.v.optional(t.v.union(t.v.literal("auto"),t.v.literal("custom"),t.v.literal("on"),t.v.literal("off"))),collectDietary:t.v.optional(t.v.boolean()),collectNotes:t.v.optional(t.v.boolean()),collectPhone:t.v.optional(t.v.boolean()),confirmationPath:t.v.optional(t.v.union(t.v.string(),t.v.null())),dietaryTags:t.v.optional(t.v.array(a.dietaryTagValidator)),embeddedCheckout:t.v.optional(t.v.boolean()),newsletterOptIn:t.v.optional(r.newsletterOptInSettingValidator),notesPrompt:t.v.optional(t.v.string()),paymentMethods:t.v.optional(f),tipping:t.v.optional(g)}),y=t.v.object({askRewardsOnReader:t.v.boolean(),checkoutLayout:x,checkoutUi:t.v.union(t.v.literal("auto"),t.v.literal("custom"),t.v.literal("on"),t.v.literal("off")),collectDietary:t.v.boolean(),collectNotes:t.v.boolean(),collectPhone:t.v.boolean(),confirmationPath:t.v.union(t.v.string(),t.v.null()),dietaryTags:t.v.array(a.dietaryTagValidator),embeddedCheckout:t.v.boolean(),newsletterOptIn:t.v.optional(r.newsletterOptInSettingValidator),notesPrompt:t.v.string(),paymentMethods:f,tipping:t.v.object({allowCustom:t.v.boolean(),enabled:t.v.boolean(),presetBps:t.v.array(t.v.number())})}),j=l.TAX_RATE_BPS_MAX;t.v.object({rateBps:t.v.optional(t.v.number())});let b=t.v.object({rateBps:t.v.optional(t.v.number()),updatedAt:t.v.optional(t.v.number())}),S=t.v.object({rateBps:t.v.number(),status:l.taxRateStatusValidator,updatedAt:t.v.optional(t.v.number())}),C=t.v.union(...u.ORDER_CHIP_COLOR_TOKENS.map(e=>t.v.literal(e))),M=t.v.object({stage:t.v.object({cancelled:C,fulfilled:C,in_progress:C,ready:C,unfulfilled:C}),status:t.v.object({cancelled:C,completed:C,confirmed:C,pending:C,pending_payment:C})}),w=t.v.optional(t.v.union(t.v.literal("native"),t.v.literal("square"))),k=t.v.optional(t.v.object({enabled:t.v.optional(t.v.boolean()),greeting:t.v.optional(t.v.string()),houseRule:t.v.optional(t.v.string())})),N=t.v.optional(t.v.object({invoices:t.v.optional(t.v.boolean())})),_={cart:t.v.optional(v),catalog:t.v.optional(i.commerceCatalogDefaultsValidator),createdAt:t.v.number(),fulfillment:t.v.optional(s.commerceFulfillmentDefaultsValidator),isPublic:t.v.optional(t.v.boolean()),membership:t.v.optional(c.commerceMembershipSettingsValidator),orderChat:k,orderChipColors:t.v.optional(M),orderStatuses:t.v.optional(d.commerceOrderStatusSettingsValidator),outbound:t.v.optional(n.commerceOutboundSettingsValidator),ownerId:t.v.string(),ownerType:t.v.union(t.v.literal("user"),t.v.literal("space")),payByBank:N,paymentRail:w,pos:t.v.optional(m.commercePosSettingsValidator),stripeAccountOwnerLocked:t.v.optional(t.v.boolean()),tax:t.v.optional(b),timeZone:t.v.optional(t.v.string()),updatedAt:t.v.number()};t.v.object({_creationTime:t.v.number(),_id:t.v.id("commerceShopSett
1ings"),..._}),t.v.object({cart:y,catalog:i.resolvedCatalogDefaultsReturnType,fulfillment:s.resolvedFulfillmentDefaultsReturnType,isPublic:t.v.boolean(),orderChipColors:M,orderStatuses:t.v.array(d.commerceOrderStatusOptionValidator),outbound:n.resolvedOutboundSettingsReturnType,pos:m.resolvedPosSettingsReturnType,resolvedTimeZone:t.v.optional(t.v.string()),stripeAccountOwnerLocked:t.v.boolean(),tax:S,timeZone:t.v.optional(t.v.string())}),e.s(["CART_NOTES_PROMPT_MAX",0,50,"CHECKOUT_PAYMENT_METHOD",0,p,"CHECKOUT_UI_CHOICES",0,["auto","custom","on","off"],"DEFAULT_SHOP_TAX_RATE_BPS",0,0,"SHOP_TAX_RATE_BPS_MAX",0,j,"STOREFRONT_CONFIRMATION_PATH_MAX",0,2048])},186308,e=>{"use strict";var t=e.i(931718),n=e.i(729386),r=e.i(283164);e.i(857266);var a=e.i(246257);e.i(116233);var i=e.i(235893),s=e.i(708737),o=e.i(991686),l=e.i(146680),c=e.i(607595),u=e.i(153229),d=e.i(929637),m=e.i(190511),p=e.i(485954),h=e.i(44007),f=e.i(592297),x=e.i(958413),g=e.i(688933),v=e.i(760550),y=e.i(623482),j=e.i(989891),b=e.i(891777),S=e.i(630596),C=e.i(929628),M=e.i(223663),w=e.i(634019),k=e.i(772265),N=e.i(722226);e.i(177067),e.i(833343),e.i(306985),e.i(897655),e.i(311097),e.i(54225),e.i(422007),e.i(402312),e.i(187763);var _=e.i(207617),I=e.i(62356);let T=["register","transactions","reports"];function P(e){let r,a,i,o,l,c,u,d,m,p=(0,n.c)(23),{locations:h,onChange:f,value:x}=e;if(p[0]!==h||p[1]!==f||p[2]!==x){let e=h.map(D);a=s.Select,o=e,p[10]!==f?(l=e=>{null!==e&&f(e)},p[10]=f,p[11]=l):l=p[11],c=x,p[12]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(s.SelectTrigger,{className:"w-48",children:(0,t.jsx)(s.SelectValue,{})}),p[12]=u):u=p[12],r=s.SelectContent,i=e.map(R),p[0]=h,p[1]=f,p[2]=x,p[3]=r,p[4]=a,p[5]=i,p[6]=o,p[7]=l,p[8]=c,p[9]=u}else r=p[3],a=p[4],i=p[5],o=p[6],l=p[7],c=p[8],u=p[9];return p[13]!==r||p[14]!==i?(d=(0,t.jsx)(r,{children:i}),p[13]=r,p[14]=i,p[15]=d):d=p[15],p[16]!==a||p[17]!==o||p[18]!==l||p[19]!==c||p[20]!==u||p[21]!==d?(m=(0,t.jsxs)(a,{items:o,onValueChange:l,value:c,children:[u,d]}),p[16]=a,p[17]=o,p[18]=l,p[19]=c,p[20]=u,p[21]=d,p[22]=m):m=p[22],m}function R(e){return(0,t.jsx)(s.SelectItem,{value:e.value,children:e.label},e.value)}function D(e){return{label:e.name,value:e._id}}function L(e){let i,s,o,l=(0,n.c)(9),{onClose:c,owner:u}=e,d=(0,a.useMutation)(r.api.commerce.locations.mutations.createLocation),m=(0,I.useSelectedSpaceId)();l[0]!==m?(i=(0,w.posShopSelection)(m),l[0]=m,l[1]=i):i=l[1];let p=i;return l[2]!==d||l[3]!==u||l[4]!==p?(s=e=>d({owner:u,...p,...e}),l[2]=d,l[3]=u,l[4]=p,l[5]=s):s=l[5],l[6]!==c||l[7]!==s?(o=(0,t.jsx)(h.LocationEditorDialog,{actions:{onClose:c,onSave:s},container:null,location:null}),l[6]=c,l[7]=s,l[8]=o):o=l[8],o}function A(e){let r,a=(0,n.c)(14),{activeLocation:i,isLoading:s,isLoadingLocations:o,onAdd:l,onSetUpLocation:c,owner:u,pickupLocations:d,session:m,taxRateBps:p,view:h}=e;if(u&&"reports"===h){let e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(v.PosReportsView,{}),a[0]=e):e=a[0],e}if(u&&"transactions"===h){let e,n=i?._id??null;return a[1]!==m||a[2]!==n?(e=(0,t.jsx)(C.PosTransactionsView,{locationId:n,session:m}),a[1]=m,a[2]=n,a[3]=e):e=a[3],e}return a[4]!==i||a[5]!==s||a[6]!==o||a[7]!==l||a[8]!==c||a[9]!==u||a[10]!==d||a[11]!==m||a[12]!==p?(r=(0,t.jsx)(b.PosRegisterMain,{activeLocation:i,isLoading:s,isLoadingLocations:o,onAdd:l,onSetUpLocation:c,owner:u,pickupLocations:d,session:m,taxRateBps:p}),a[4]=i,a[5]=s,a[6]=o,a[7]=l,a[8]=c,a[9]=u,a[10]=d,a[11]=m,a[12]=p,a[13]=r):r=a[13],r}e.s(["PosSurface",0,function(e){let s,h,v,b,C,R,D,O,E,B,$,z,F,q,V,U,H,G,Q,W,X=(0,n.c)(74);X[0]!==e?(s=void 0===e?{}:e,X[0]=e,X[1]=s):s=X[1];let{onSetUpLocation:K}=s,{identity:Z,owner:J,isLoading:Y}=(0,w.usePosOwner)();(0,S.usePosRegisterCart)(),X[2]!==Z?(h=(0,N.posShopBrandFromIdentity)(Z),X[2]=Z,X[3]=h):h=X[3];let ee=h,et=(0,I.useAddLine)(),{pickupLocations:en,isLoading:er}=(0,M.usePosLocations)(),[ea,ei]=(0,p.useState)(null),[es,eo]=(0,p.useState)(!1),[el,ec]=(0,p.useState)(!1),[eu,ed]=(0,p.useState)(!1),[em,ep]=(0,p.useState)(!1),[eh,ef]=(0,p.useState)("register");X[4]!==en||X[5]!==ea?(v=en.find(e=>e._id===ea)??en[0]??null,X[4]=en,X[5]=ea,X[6]=v):v=X[6];let ex=v,{session:eg}=(0,k.usePosRegisterSession)(ex?._id??null),ev=function(e,t){let i,s,o=(0,n.c)(5);o[0]!==e?(i=e?{owner:e}:"skip",o[0]=e,o[1]=i):i=o[1];let l=(0,a.useQuery)(r.api.commerce.settings.settings.getShopSett
1ings,i),c=t?.taxRegion?.defaultTaxRateBps,u=l?.tax.rateBps??_.DEFAULT_SHOP_TAX_RATE_BPS;if(o[2]!==c||o[3]!==u){var d;s=(d={locationRateBps:c,shopRateBps:u}).productRateBps??d.locationRateBps??d.shopRateBps,o[2]=c,o[3]=u,o[4]=s}else s=o[4];return s}(J,ex);X[7]!==K?(b=()=>{K?K():ed(!0)},X[7]=K,X[8]=b):b=X[8];let ey=b;X[9]!==et?(C=(e,t)=>{et({productId:e.id,name:e.name,currency:e.currency,imageUrl:e.images[0]?.url??null,...t})},X[9]=et,X[10]=C):C=X[10];let ej=C;if(es&&J&&ex){let e,n;return X[11]===Symbol.for("react.memo_cache_sentinel")?(e=()=>eo(!1),X[11]=e):e=X[11],X[12]!==ee||X[13]!==ev?(n=(0,t.jsx)(x.PosCustomerDisplay,{brand:ee,onExit:e,taxRateBps:ev}),X[12]=ee,X[13]=ev,X[14]=n):n=X[14],n}X[15]===Symbol.for("react.memo_cache_sentinel")?(R=(0,t.jsx)(f.PosAccountSwitcher,{}),X[15]=R):R=X[15],X[16]!==J||X[17]!==eh?(D=J?(0,t.jsxs)(o.ToggleGroup,{onValueChange:e=>{let t=e[0];T.some(e=>e===t)&&ef(t)},spacing:1,value:[eh],children:[(0,t.jsxs)(o.ToggleGroupItem,{"aria-label":"Register",value:"register",children:[(0,t.jsx)(m.Store,{}),"Register"]}),(0,t.jsxs)(o.ToggleGroupItem,{"aria-label":"Transactions",value:"transactions",children:[(0,t.jsx)(d.ReceiptText,{}),"Transactions"]}),(0,t.jsxs)(o.ToggleGroupItem,{"aria-label":"Reports",value:"reports",children:[(0,t.jsx)(l.BarChart3,{}),"Reports"]})]}):null,X[16]=J,X[17]=eh,X[18]=D):D=X[18],X[19]!==D?(O=(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[R,D]}),X[19]=D,X[20]=O):O=X[20],X[21]!==ex||X[22]!==J||X[23]!==en||X[24]!==eh?(E="register"===eh&&J&&en.length>1&&ex?(0,t.jsx)(P,{locations:en,onChange:ei,value:ex._id}):null,X[21]=ex,X[22]=J,X[23]=en,X[24]=eh,X[25]=E):E=X[25],X[26]!==ex||X[27]!==J||X[28]!==eg||X[29]!==eh?(B="register"===eh&&J&&ex?(0,t.jsx)(g.PosSessionChip,{session:eg}):null,X[26]=ex,X[27]=J,X[28]=eg,X[29]=eh,X[30]=B):B=X[30],X[31]!==ex||X[32]!==J||X[33]!==eh?($="register"===eh&&J&&ex?(0,t.jsxs)(i.Button,{onClick:()=>ec(!0),variant:"surface",children:[(0,t.jsx)(c.CreditCard,{}),"Reader"]}):null,X[31]=ex,X[32]=J,X[33]=eh,X[34]=$):$=X[34],X[35]!==ex||X[36]!==J||X[37]!==eh?(z="register"===eh&&J&&ex?(0,t.jsxs)(i.Button,{onClick:()=>ep(!0),variant:"surface",children:[(0,t.jsx)(u.Monitor,{}),"Customer view"]}):null,X[35]=ex,X[36]=J,X[37]=eh,X[38]=z):z=X[38],X[39]!==B||X[40]!==$||X[41]!==z||X[42]!==E?(F=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[E,B,$,z]}),X[39]=B,X[40]=$,X[41]=z,X[42]=E,X[43]=F):F=X[43],X[44]!==F||X[45]!==O?(q=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b px-3 py-2",children:[O,F]}),X[44]=F,X[45]=O,X[46]=q):q=X[46];let eb=ex?._id??null;return X[47]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{ep(!1),eo(!0)},X[47]=V):V=X[47],X[48]!==em||X[49]!==eb?(U=(0,t.jsx)(y.PosKioskLinkDialog,{locationId:eb,onOpenChange:ep,onPresentInWindow:V,open:em}),X[48]=em,X[49]=eb,X[50]=U):U=X[50],X[51]!==el||X[52]!==J?(H=J?(0,t.jsx)(j.PosReaderSettings,{onOpenChange:ec,open:el,owner:J}):null,X[51]=el,X[52]=J,X[53]=H):H=X[53],X[54]!==eu||X[55]!==J?(G=J&&eu?(0,t.jsx)(L,{onClose:()=>ed(!1),owner:J}):null,X[54]=eu,X[55]=J,X[56]=G):G=X[56],X[57]!==ex||X[58]!==ej||X[59]!==ey||X[60]!==Y||X[61]!==er||X[62]!==J||X[63]!==en||X[64]!==eg||X[65]!==ev||X[66]!==eh?(Q=(0,t.jsx)(A,{activeLocation:ex,isLoading:Y,isLoadingLocations:er,onAdd:ej,onSetUpLocation:ey,owner:J,pickupLocations:en,session:eg,taxRateBps:ev,view:eh}),X[57]=ex,X[58]=ej,X[59]=ey,X[60]=Y,X[61]=er,X[62]=J,X[63]=en,X[64]=eg,X[65]=ev,X[66]=eh,X[67]=Q):Q=X[67],X[68]!==q||X[69]!==U||X[70]!==H||X[71]!==G||X[72]!==Q?(W=(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[q,U,H,G,Q]}),X[68]=q,X[69]=U,X[70]=H,X[71]=G,X[72]=Q,X[73]=W):W=X[73],W}],186308)}]);

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.