1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ReturnRequestDialog-BmdakniR.js","assets/index-COb3BWG8.js","assets/index--XW13po-.css","assets/label-DNJsNNpl.js","assets/textarea-Djn1xzmr.js","assets/radio-group-DVsmUsIt.js","assets/select-Y1pMYI5s.js","assets/index-CD_9dLLA.js","assets/checkbox-X5f5njlo.js","assets/order-queries-5Y6DjekV.js","assets/order-mutations-CGHpGUFC.js","assets/safe-random-uuid-C5emDdYB.js","assets/use-file-upload-C1wW8AZt.js","assets/returns-CNCTRRtN.js","assets/useMutation-BQY-xsoU.js","assets/useIsomorphicLayoutEffect-D8rpVvO2.js","assets/PhoneCameraModal-BpUvPkXL.js","assets/support-queries-Dj-9UKZV.js","assets/index-MevfkPFD.js","assets/loader-circle-OXwY4kRz.js","assets/clock-BjT2jRP1.js","assets/circle-check-BvfgDFVk.js","assets/image-plus-BJx8oGza.js","assets/refresh-cw-CoRVSjNV.js","assets/evidence-DPvJe72G.js","assets/upload-BjtQ_TFi.js","assets/video-OjlM7fhR.js","assets/order-amounts-Dt_Iupbv.js","assets/return-request-draft-BLqehDZt.js","assets/vocabulary-BqYYK51g.js","assets/triangle-alert-BLtiBg_s.js","assets/info-CQzPDbS5.js","assets/clipboard-check-IzwTOC__.js"])))=>i.map(i=>d[i]); 2import{c as Ke,j as e,b as v,a6 as Oe,B as U,F as ha,S as $,aA as As,aC as Fs,aD as _s,aE as Ls,$ as Ee,a0 as V,a3 as ne,a1 as ie,P as xe,a4 as be,a$ as It,b1 as Ds,a as we,M as ua,t as Ce,aV as pa,aH as ba,aJ as ga,b2 as Tt,b5 as ls,ao as fa,Y as Re,I as ue,b4 as Na,aG as it,m as nt,X as Dt,aW as Rt,aP as ja,d as va,ak as ya,h as ke,n as ct,ai as wa,ag as Ca,b6 as Pa,b7 as ka,b8 as Ea,b9 as Ia,ba as Ta,bb as Da,bc as Ra,bd as Sa,U as Aa,_ as Fa}from"./index-COb3BWG8.js";import{T as _a,a as La,b as Fe,c as _e}from"./tabs-f61vqlqW.js";import{B as ot,d as He,e as St,a as Oa,b as Ma,f as Ba,g as Ua,h as $a,M as za}from"./order-queries-5Y6DjekV.js";import{G as Ha}from"./store-integration-C2tBoZ8H.js";import{U as At,C as Va,a as qa,R as Ya,g as dt}from"./order-mutations-CGHpGUFC.js";import{c as Ga,G as Qa,C as Wa}from"./provider-selection-queries-DngM0zpQ.js";import{u as Ft}from"./use-toast-BXBb_A5U.js";import{A as is,b as ns}from"./alert-BcZXKgYj.js";import{p as Ka}from"./checkout-errors-B_gvqWjO.js";import{c as Xa}from"./retry-payment-status-yVo35F6j.js";import{c as Za,C as Ja}from"./CancelOrderDialog-BQZ1ZRuO.js";import{O as er,u as sr,R as tr}from"./OrderTransitionalStatus-CxRrYL1z.js";import{C as Qe}from"./circle-alert-CCGVUS_b.js";import{T as mt,a as xt,b as Ge,c as Q,d as ht,e as W}from"./table-Dmz2t2iI.js";import{B as me}from"./badge-BtMzbs5Q.js";import{S as ar,a as rr,b as lr,c as ir,d as nr}from"./select-Y1pMYI5s.js";import{S as _t}from"./star-IL9DOKsY.js";import{C as cr}from"./chevron-up-9MXJvrF7.js";import{E as Lt}from"./eye-BSNkfUPT.js";import{L as Te}from"./loader-circle-OXwY4kRz.js";import{T as Xe}from"./triangle-alert-BLtiBg_s.js";import{R as Rs}from"./refresh-cw-CoRVSjNV.js";import{S as or}from"./separator-BZBWtPhC.js";import{T as ut,c as dr}from"./store-order-line-totals-DQv1bwuF.js";import{S as mr}from"./shopping-cart-D6WFcoX6.js";import{E as ts}from"./external-link-BFGzlI4f.js";import{I as Be}from"./image-CumAHAoL.js";import{G as xr}from"./gift-2tKJY17-.js";import{T as hr}from"./tag-CrwCp0XH.js";import{R as cs}from"./receipt-C_HWBHxI.js";import{B as ur}from"./building-2-D0TjEFtb.js";import{W as pr}from"./wallet-CQmGgUi4.js";import{T as br}from"./trending-up-HRziUnAo.js";import{U as pt}from"./user-CmrQUDg0.js";import{C as Ot}from"./calendar-D8UFs2zl.js";import{C as os}from"./credit-card-D8f3Mq8o.js";import{T as Ue}from"./truck-u2tLuypV.js";import{L as he}from"./label-DNJsNNpl.js";import{T as gr}from"./textarea-Djn1xzmr.js";import{u as Me}from"./useMutation-BQY-xsoU.js";import{P as fr}from"./pen-DiaUSYyL.js";import{C as Ss}from"./copy-BpNy9jqS.js";import{C as $e}from"./clock-BjT2jRP1.js";import{C as Nr}from"./circle-check-BvfgDFVk.js";import{S as jr}from"./scale-UNitk8Bj.js";import{R as vr}from"./ruler-Bneyiuix.js";import{F as es}from"./factory-CT2v7j4Y.js";import{C as as}from"./circle-x-Brpt41T7.js";import{C as bt}from"./circle-check-big-BANmrhMR.js";import{C as gt}from"./clipboard-check-IzwTOC__.js";import{P as ft}from"./package-check-DVUPGXZC.js";import{U as yr}from"./undo-2-Ni6d2L87.js";import{Z as We,a as Mt}from"./zoom-out-BMbkwNao.js";import{C as Bt}from"./chevron-left-DN3ceSAL.js";import{C as rs}from"./camera-DUiGx1gE.js";import{A as Is}from"./arrow-left-Fzfx8Qzj.js";import{D as wr}from"./download-DnUvfH58.js";import{C as Cr}from"./circle-help-CeQMJ-ca.js";import{u as Nt}from"./useLazyQuery-DLiXDTCF.js";import"./safe-random-uuid-C5emDdYB.js";import"./order-amounts-Dt_Iupbv.js";import"./info-CQzPDbS5.js";import"./index-CD_9dLLA.js";import"./useIsomorphicLayoutEffect-D8rpVvO2.js";/** 3 * @license lucide-react v0.468.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const jt=Ke("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/** 8 * @license lucide-react v0.468.0 - ISC 9 * 10 * This source code is licensed under the ISC license. 11 * See the LICENSE file in the root directory of this source tree. 12 */const Ut=Ke("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** 13 * @license lucide-react v0.468.0 - ISC 14 * 15 * This source code is licensed under the ISC license. 16 * See the LICENSE file in the root directory of this source tree. 17 */const Pr=Ke("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** 18 * @license lucide-react v0.468.0 - ISC 19 * 20 * This source code is licensed under the ISC license. 21 * See the LICENSE file in the root directory of this source tree. 22 */const kr=Ke("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** 23 * @license lucide-react v0.468.0 - ISC 24 * 25 * This source code is licensed under the ISC license. 26 * See the LICENSE file in the root directory of this source tree. 27 */const $t=Ke("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
27y:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);function Ts(s){if(s==null)return null;let t;if(typeof s=="string"){const a=s.trim();if(a===""||!/^\d+(?:\.\d+)?$/.test(a))return null;t=Number(a)}else t=s;return Number.isFinite(t)&&t>=0?t:null}function Er(s){return Number.isInteger(s)&&s>0}function Ir(s,t,a){const o=s*t,h=Math.max(1,Math.abs(o))*Number.EPSILON*8;return Math.abs(a-o)<=h}function ds(s){const t=s.providerCostReconciliationStatus??null,a=Ts(s.providerCostLineTotal);if(t==="EXPLICIT"){const o=Ts(s.baseProviderCostPerUnit),h=Ts(s.optionInclusiveProviderPricePerUnit);return o===null||h===null||h<o||a===null||!Er(s.quantity)||!Ir(h,s.quantity,a)?{available:!1,status:t}:{available:!0,status:t,unitCost:h,lineTotal:a}}if(t==="LEGACY_QUANTITY_ONE"){const o=s.baseProviderCostPerUnit!=null||s.optionInclusiveProviderPricePerUnit!=null;return s.quantity!==1||a===null||o?{available:!1,status:t}:{available:!0,status:t,unitCost:a,lineTotal:a}}return{available:!1,status:t}}function Tr(s){let t=0;for(const a of s){const o=ds(a);if(!o.available)return null;t+=o.lineTotal}return t}const Dr=()=>e.jsxs(is,{className:"mb-6 border-[#15B67F]/30 bg-[#15B67F]/5",children:[e.jsx(Qe,{className:"h-4 w-4 text-[#15B67F]"}),e.jsx(ns,{className:"text-slate-700",children:"Your order needs a new provider. Compare options below and select one."})]});function Rr(s,t){return[...s].sort((a,o)=>{switch(t){case"score":return ss(a.score,o.score)||vt(a.costBreakdown.totalCost,o.costBreakdown.totalCost);case"price":return vt(a.costBreakdown.totalCost,o.costBreakdown.totalCost)||ss(a.score,o.score);case"speed":{const h=yt(a.productionTimeDays,o.productionTimeDays);if(h!==0)return h;const c=yt(a.deliveryDaysMin,o.deliveryDaysMin);return c!==0?c:ss(a.score,o.score)}case"quality":return Sr(a.qualityRating,o.qualityRating)||ss(a.score,o.score);default:return 0}})}function vt(s,t){return s-t}function ss(s,t){return t-s}function yt(s,t){return s===null&&t===null?0:s===null?1:t===null?-1:s-t}function Sr(s,t){return s===null&&t===null?0:s===null?1:t===null?-1:t-s}const Ar=[{value:"score",label:"Best Match"},{value:"price",label:"Lowest Price"},{value:"speed",label:"Fastest Delivery"},{value:"quality",label:"Highest Quality"}],Fr=()=>e.jsx(e.Fragment,{children:Array.from({length:5}).map((s,t)=>e.jsxs(Ge,{children:[e.jsx(W,{children:e.jsx($,{className:"h-4 w-24"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-16"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-20"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-12"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-16"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-20"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-24"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-16"})}),e.jsx(W,{children:e.jsx($,{className:"h-4 w-12"})}),e.jsx(W,{children:e.jsx($,{className:"h-8 w-28 rounded-[14px]"})})]},`skeleton-${t}`))}),_r=({onRetry:s})=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[e.jsx(kr,{className:"h-12 w-12 text-slate-300"}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("p",{className:"text-lg font-semibold text-slate-700",children:"No Providers Available"}),e.jsx("p",{className:"text-sm text-slate-500",children:"No providers can currently fulfill this order. Please contact support for assistance."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(U,{variant:"outline",size:"sm",className:"rounded-[14px]",onClick:()=>globalThis.open("mailto:[email protected]","_blank","noopener,noreferrer"),children:"Contact Support"}),s&&e.jsxs(U,{variant:"outline",size:"sm",className:"rounded-[14px]",onClick:s,children:[e.jsx(Rs,{className:"h-4 w-4 mr-2"}),"Retry"]})]})]}),Lr=({message:s,onRetry:t})=>e.jsxs(is,{variant:"destructive",className:"my-6",children:[e.jsx(Xe,{className:"h-4 w-4"}),e.jsxs(ns,{className:"flex items-center justify-between",children:[e.jsxs("span",{children:["Unable to Load Providers: ",s]}),t&&e.jsx(U,{variant:"outline",size:"sm",onClick:t,className:"ml-4 rounded-[14px]",children:"Try Again"})]})]});function Or(s,t){return s==null?"â":t?`${s}${t}`:String(s)}function se(s){if(s==null)return null;const t=typeof s=="string"?s:JSON.stringify(s)??"",a=typeof s=="number"?s:Number.parseFloat(t);return Number.isNaN(a)?null:a}function Z(s,t){const a=se(s);if(a===null)return"â";const o=t?` ${t}`:"";return`${a.toFixed(2)}${o}`}const Mr=({open:s,onClose:t,newProvider:a,orderItems:o,orderCosts:h,rejectedA
27ssignment:c,currency:r})=>{var N;const l=o.filter(j=>!j.isBrandingProduct),x=o.filter(j=>j.isBrandingProduct),u=j=>{if(!j||!a.brandingAvailability)return{available:!1,cost:null};const p=j.toLowerCase().replaceAll("_","-"),C=a.brandingAvailability.find(d=>d.brandingType.toLowerCase()===p);return C?{available:C.available,cost:C.basePricePerUnit}:{available:!1,cost:null}},b=50;return e.jsx(As,{open:s,onOpenChange:t,children:e.jsxs(Fs,{className:"max-w-4xl max-h-[85vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsxs(Ls,{className:"flex items-center gap-3 text-lg",children:[e.jsx(Lt,{className:"h-5 w-5 text-[#15B67F]"}),"Provider Comparison Details"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-red-50 border border-red-100",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(me,{variant:"destructive",className:"rounded-full text-xs",children:"Rejected"}),e.jsx("span",{className:"font-semibold text-slate-700",children:(c==null?void 0:c.providerName)||"Previous Provider"})]}),(c==null?void 0:c.rejectionReason)&&e.jsxs("p",{className:"text-xs text-red-600 mt-1",children:["Reason: ",c.rejectionReason]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-green-50 border border-green-100",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(me,{className:"rounded-full text-xs bg-[#15B67F] hover:bg-[#15B67F]",children:"New Option"}),e.jsx("span",{className:"font-semibold text-slate-700",children:a.providerName})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-slate-600",children:[e.jsx("span",{children:a.printingTechnology}),e.jsx("span",{children:a.country}),a.qualityRating&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_t,{className:"h-3 w-3 text-amber-400 fill-amber-400"}),((N=se(a.qualityRating))==null?void 0:N.toFixed(1))??"â"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-red-50/50 border border-red-100",children:[e.jsxs("p",{className:"text-sm text-red-600 font-medium mb-2",children:[(c==null?void 0:c.providerName)||"Previous Provider"," (Rejected)"]}),e.jsx("p",{className:"text-2xl font-bold text-slate-800",children:Z((se(h==null?void 0:h.totalProviderCost)??0)+(se(h==null?void 0:h.shippingCost)??0)+b,r)}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Provider: ",Z(h==null?void 0:h.totalProviderCost,r)," + Shipping: ",Z(h==null?void 0:h.shippingCost,r)," + Fee: ",Z(b,r)]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-green-50 border border-green-100",children:[e.jsxs("p",{className:"text-sm text-[#15B67F] font-medium mb-2",children:[a.providerName," (New)"]}),e.jsx("p",{className:"text-2xl font-bold text-slate-800",children:Z((se(a.costBreakdown.totalCost)??0)+b,r)}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Provider: ",Z(a.costBreakdown.totalCost-a.costBreakdown.shippingCost,r)," + Shipping: ",Z(a.costBreakdown.shippingCost,r)," + Fee: ",Z(b,r)]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-slate-700 text-sm uppercase tracking-wider",children:"Cost Comparison per Item"}),l.map((j,p)=>{const C=j.providerBasePrice,d=a.costBreakdown.lineCosts[p];return e.jsxs("div",{className:"rounded-xl border border-slate-200 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 bg-slate-50 border-b border-slate-200",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-800",children:j.productName}),e.jsxs("p",{className:"text-xs text-slate-500",children:[j.colorName," / ",j.size," ⢠Qty: ",j.quantity]})]}),j.colorHex&&e.jsx("div",{className:"h-6 w-6 rounded-full border border-slate-300 shadow-sm",style:{backgroundColor:j.colorHex},title:j.colorName})]})}),e.jsx("div",{className:"p-4",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-xs uppercase",children:[e.jsx("th",{className:"text-left py-2 font-medium",children:"Cost Type"}),e.jsx("th",{className:"text-right py-2 font-medium text-red-600",children:(c==null?void 0:c.providerName)||"Previous"}),e.jsx("th",{className:"text-center py-2 w-8"}),e.jsx("th",{className:"text-right py-2 font-medium text-[#15B6
277F]",children:a.providerName})]})}),e.jsxs("tbody",{className:"divide-y divide-slate-100",children:[e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 text-slate-600",children:"Provider Cost"}),e.jsx("td",{className:"py-2 text-right text-slate-700",children:Z(C,r)}),e.jsx("td",{className:"py-2 text-center",children:e.jsx(Ee,{className:"h-3 w-3 text-slate-300 mx-auto"})}),e.jsx("td",{className:"py-2 text-right font-medium text-slate-800",children:Z(d==null?void 0:d.basePrice,r)})]}),e.jsxs("tr",{className:"bg-slate-50 font-medium",children:[e.jsxs("td",{className:"py-2 text-slate-700",children:["Subtotal (Qty: ",j.quantity,")"]}),e.jsx("td",{className:"py-2 text-right text-slate-700",children:Z((se(C)??0)*j.quantity,r)}),e.jsx("td",{className:"py-2 text-center",children:e.jsx(Ee,{className:"h-3 w-3 text-slate-400 mx-auto"})}),e.jsx("td",{className:"py-2 text-right text-[#15B67F] font-semibold",children:Z(d==null?void 0:d.lineTotal,r)})]})]})]})})]},j.itemId)})]}),x.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-slate-700 text-sm uppercase tracking-wider",children:"Branding Cost Comparison"}),x.map(j=>{var C;const p=u(j.brandingType);return e.jsxs("div",{className:"rounded-xl border border-slate-200 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 bg-amber-50/50 border-b border-slate-200",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-800",children:j.productName}),e.jsxs("p",{className:"text-xs text-slate-500",children:[(C=j.brandingType)==null?void 0:C.replaceAll("_"," ")," ⢠Qty: ",j.quantity]})]}),e.jsx(me,{variant:"outline",className:"text-xs",children:"Branding"})]})}),e.jsx("div",{className:"p-4",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-xs uppercase",children:[e.jsx("th",{className:"text-left py-2 font-medium",children:"Cost Type"}),e.jsx("th",{className:"text-right py-2 font-medium text-red-600",children:(c==null?void 0:c.providerName)||"Previous"}),e.jsx("th",{className:"text-center py-2 w-8"}),e.jsx("th",{className:"text-right py-2 font-medium text-[#15B67F]",children:a.providerName})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 text-slate-600",children:"Branding Cost"}),e.jsx("td",{className:"py-2 text-right text-slate-700",children:j.providerBasePrice==null?"â":Z(j.providerBasePrice,r)}),e.jsx("td",{className:"py-2 text-center",children:e.jsx(Ee,{className:"h-3 w-3 text-slate-300 mx-auto"})}),e.jsx("td",{className:"py-2 text-right font-medium text-slate-800",children:p.available?Z(p.cost,r):e.jsx("span",{className:"text-amber-600 text-xs font-medium",children:"Not Available"})})]})})]})})]},j.itemId)})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 bg-slate-50 border-b border-slate-200",children:e.jsx("p",{className:"font-semibold text-slate-700 text-sm uppercase tracking-wider",children:"Order-Level Costs"})}),e.jsx("div",{className:"p-4",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-xs uppercase",children:[e.jsx("th",{className:"text-left py-2 font-medium",children:"Cost Type"}),e.jsx("th",{className:"text-right py-2 font-medium text-red-600",children:(c==null?void 0:c.providerName)||"Previous"}),e.jsx("th",{className:"text-center py-2 w-8"}),e.jsx("th",{className:"text-right py-2 font-medium text-[#15B67F]",children:a.providerName})]})}),e.jsxs("tbody",{className:"divide-y divide-slate-100",children:[e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 text-slate-600",children:"Shipping Cost"}),e.jsx("td",{className:"py-2 text-right text-slate-700",children:Z(h==null?void 0:h.shippingCost,r)}),e.jsx("td",{className:"py-2 text-center",children:e.jsx(Ee,{className:"h-3 w-3 text-slate-300 mx-auto"})}),e.jsx("td",{className:"py-2 text-right font-medium text-slate-800",children:Z(a.costBreakdown.shippingCost,r)})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 text-slate-600",children:"Order Transaction Fee"}),e.jsx("td",{className:"py-2 text-right text-slate-700",children:Z(b,r)}),e.jsx("td",{className:"py-2 text-center",children:e.jsx(Ee,{className:"h-3 w-3 text-slate-300 mx-auto"})}),e.jsx("td",{className:"py-2 text-right font-medium text-slate-800",children:Z(b,r)})]})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-xl border border-slate-200",children:[e.jsx("h5",{className:"font-medium text-slate-700 mb-3 text-sm",children:"Production Time"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-slate-700 text-sm",children:(c==null?void 0:c.productionTimeDays)==null?"â":`${c.productionTimeDays} days`}),e.jsx(Ee,{className:"h-4 w-4 text-slate-300"}),e.jsxs("span",{className:"font-medium text-slate-800",children:[a.productionTimeDays??"â"," days"]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl border border-slate-200",children:[e.jsx("h5",{className:"font-medium text-slate-700 mb-3 text-sm",children:"Delivery Time"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-slate-700 text-sm",children:(c==null?void 0:c.deliveryDaysMin)!=null&&(c==null?void 0:c.deliveryDaysMax)!=null?`${c.deliveryDaysMin}-${c.deliveryDaysMax} days`:"â"}),e.jsx(Ee,{className:"h-4 w-4 text-slate-300"}),e.jsxs("span",{className:"font-medium text-slate-800",children:[a.deliveryDaysMin??"â","-",a.deliveryDaysMax??"â"," days"]})]})]})]})]})]})})},Br=({providers:s,loading:t,error:a,onSelect:o,selectingProviderId:h,onRetry:c,currency:r,orderItems:l=[],orderCosts:x,rejectedA
27ssignments:u=[]})=>{const[b,N]=v.useState("score"),[j,p]=v.useState(null),[C,d]=v.useState(null),P=u.length>0?u.reduce((g,E)=>new Date(E.rejectedAt)>new Date(g.rejectedAt)?E:g,u[0]):void 0;if(a)return e.jsx(Lr,{message:a,onRetry:c});if(t)return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ge,{children:[e.jsx(Q,{children:"Provider"}),e.jsx(Q,{children:"Country"}),e.jsx(Q,{children:"Technology"}),e.jsx(Q,{children:"Quality"}),e.jsx(Q,{children:"Production"}),e.jsx(Q,{children:"Delivery"}),e.jsx(Q,{children:"Cost Breakdown"}),e.jsx(Q,{children:"Shipping"}),e.jsx(Q,{children:"Total"}),e.jsx(Q,{children:"Score"}),e.jsx(Q,{})]})}),e.jsx(ht,{children:e.jsx(Fr,{})})]})});if(!s||s.length===0)return e.jsx(_r,{onRetry:c});const f=Rr(s,b),I=s.length>0&&s[0].costBreakdown.lineCosts.length>1,_=h!==null;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-slate-500",children:[s.length," provider",s.length===1?"":"s"," available"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-slate-500",children:"Sort by:"}),e.jsxs(ar,{value:b,onValueChange:g=>N(g),children:[e.jsx(rr,{className:"w-[160px] rounded-[14px]",children:e.jsx(lr,{})}),e.jsx(ir,{children:Ar.map(g=>e.jsx(nr,{value:g.value,children:g.label},g.value))})]})]})]}),e.jsxs("div",{className:"relative overflow-x-auto rounded-[14px] border border-slate-200",children:[_&&e.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex flex-col items-center justify-center",children:e.jsxs("div",{className:"bg-white rounded-3xl p-12 shadow-2xl flex flex-col items-center gap-6 max-w-md mx-4",children:[e.jsx("div",{className:"h-24 w-24 rounded-full border-[8px] border-[#15B67F]/20 border-t-[#15B67F] animate-spin"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-3xl font-bold text-slate-800 mb-2",children:"Assigning Provider"}),e.jsx("p",{className:"text-lg text-slate-500",children:"Please wait while we process your selection..."})]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("div",{className:"h-4 w-4 rounded-full bg-[#15B67F] animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"h-4 w-4 rounded-full bg-[#15B67F] animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"h-4 w-4 rounded-full bg-[#15B67F] animate-bounce",style:{animationDelay:"300ms"}})]})]})}),e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ge,{className:"bg-slate-50/80",children:[e.jsx(Q,{className:"font-semibold",children:"Provider"}),e.jsx(Q,{className:"font-semibold",children:"Country"}),e.jsx(Q,{className:"font-semibold",children:"Technology"}),e.jsx(Q,{className:"font-semibold",children:"Quality"}),e.jsx(Q,{className:"font-semibold",children:"Production"}),e.jsx(Q,{className:"font-semibold",children:"Delivery"}),e.jsx(Q,{className:"font-semibold",children:"Cost"}),e.jsx(Q,{className:"font-semibold",children:"Shipping"}),e.jsx(Q,{className:"font-semibold",children:"Total"}),e.jsx(Q,{className:"font-semibold",children:"Score"}),e.jsx(Q,{})]})}),e.jsx(ht,{children:f.map(g=>{var te,X;const E=g.costBreakdown,L=j===g.configId,F=E.lineCosts.length===1?E.lineCosts[0]:null;return e.jsxs(Oe.Fragment,{children:[e.jsxs(Ge,{className:"hover:bg-slate-50/50",children:[e.jsx(W,{className:"font-medium",children:g.providerName}),e.jsx(W,{children:g.country}),e.jsx(W,{children:e.jsx(me,{variant:"outline",className:"rounded-full text-xs",children:g.printingTechnology})}),e.jsx(W,{children:g.qualityRating===null?e.jsx("span",{className:"text-slate-400",children:"â"}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_t,{className:"h-3.5 w-3.5 text-amber-400 fill-amber-400"}),((te=se(g.qualityRating))==null?void 0:te.toFixed(1))??"â"]})}),e.jsx(W,{children:Or(g.productionTimeDays," days")}),e.jsx(W,{children:g.deliveryDaysMin!==null&&g.deliveryDaysMax!==null?`${g.deliveryDaysMin}-${g.deliveryDaysMax} days`:"â"}),e.jsx(W,{children:(()=>{var H,ae,O;return F?e.jsxs("span",{className:"text-xs text-slate-600",children:[((H=se(F.basePrice))==null?void 0:H.toFixed(2))??"0.00",se(F.setupFee)?` + ${(ae=se(F.setupFee))==null?void 0:ae.toFixed(2)} setup`:"",se(F.additionalColorFee)?` + ${(O=se(F.additionalColorFee))==null?void 0:O.toFixed(2)} color`:""]}):I?e.jsxs(U,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>p(L?null:g.configId),children:[E.lineCosts.length," items",L?e.jsx(cr,{className:"h-3 w-3 ml-1"}):e.jsx(ha,{className:"h-3 w-3 ml-1"})]}):"â"})()}),e.jsx(W,{children:Z(E.shippingCost)}),e.jsx(W,{className:"font-semibold",children:Z(E.totalCost,r)}),e.jsx(W,{children:e.jsx(me,{className:"rounded-full bg-[#15B67F]/10 text-[#15B6
277F] border-[#15B67F]/20 hover:bg-[#15B67F]/10",children:((X=se(g.score))==null?void 0:X.toFixed(2))??"0.00"})}),e.jsx(W,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[l.length>0&&e.jsxs(U,{variant:"outline",size:"sm",className:"rounded-[14px] text-xs",onClick:()=>d(g),children:[e.jsx(Lt,{className:"h-3.5 w-3.5 mr-1"}),"Details"]}),e.jsx(U,{size:"sm",className:"rounded-[14px] bg-[#15B67F] hover:bg-[#15B67F]/90 text-white",disabled:_,onClick:()=>o(g.providerId,g.providerName,g.configId),children:h===g.providerId?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"h-4 w-4 mr-1 animate-spin"}),"Selecting..."]}):"Select"})]})})]}),L&&I&&e.jsx(Ge,{children:e.jsx(W,{colSpan:11,className:"bg-slate-50/50 p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Cost Breakdown per Item"}),E.lineCosts.map((H,ae)=>{var O,w,z,q;return e.jsxs("div",{className:"flex items-center gap-4 text-sm text-slate-600",children:[e.jsxs("span",{className:"w-20",children:["Qty: ",H.quantity]}),e.jsxs("span",{children:["Base: ",((O=se(H.basePrice))==null?void 0:O.toFixed(2))??"0.00",se(H.setupFee)?` + Setup: ${(w=se(H.setupFee))==null?void 0:w.toFixed(2)}`:"",se(H.additionalColorFee)?` + Color: ${(z=se(H.additionalColorFee))==null?void 0:z.toFixed(2)}`:""]}),e.jsxs("span",{className:"font-medium",children:["= ",((q=se(H.lineTotal))==null?void 0:q.toFixed(2))??"0.00"]})]},ae)})]})})})]},g.configId)})})]})]}),C&&e.jsx(Mr,{open:!!C,onClose:()=>d(null),newProvider:C,orderItems:l,orderCosts:x,rejectedAssignment:P,currency:r})]})};function Ur({order:s,storeOrder:t,loading:a=!1,className:o=""}){var C;const[h,c]=v.useState(null),[r,l]=v.useState(""),x=(d,P)=>Ds(d,P||s.currency,{minimumFractionDigits:2});if(a)return e.jsxs("div",{className:`space-y-6 ${o}`,children:[e.jsxs(V,{className:"rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[e.jsx(ne,{className:"p-6 border-b border-slate-100",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx($,{className:"h-6 w-48"})]})}),e.jsx(ie,{className:"p-6 space-y-4",children:[1,2].map(d=>e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-slate-50 rounded-xl",children:[e.jsx($,{className:"w-20 h-20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx($,{className:"h-5 w-3/4"}),e.jsx($,{className:"h-4 w-1/2"}),e.jsx($,{className:"h-4 w-1/4"})]})]},`item-${d}`))})]}),e.jsxs(V,{className:"rounded-2xl border border-primary/20 overflow-hidden",children:[e.jsx(ne,{className:"p-6 border-b border-primary/10",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx($,{className:"h-6 w-52"})]})}),e.jsx(ie,{className:"p-6",children:e.jsx($,{className:"h-32 w-full"})})]})]});if(!t)return e.jsx(V,{className:`rounded-2xl border border-slate-200 shadow-sm ${o}`,children:e.jsxs(ie,{className:"p-6 text-center text-slate-500",children:[e.jsx(xe,{className:"w-8 h-8 mx-auto mb-2 text-slate-400"}),e.jsx("p",{children:"Store order details not available"})]})});const{lineItems:u,discounts:b,printarexSummary:N,storeConnection:j}=t,p=d=>{if(!d||!(j!=null&&j.shopDomain))return null;const{shopDomain:P,platform:f}=j,I=P.startsWith("http")?P:`https://${P}`;switch(f==null?void 0:f.toUpperCase()){case"SHOPIFY":return`${I}/admin/products/${d}`;case"WOOCOMMERCE":return`${I}/wp-admin/post.php?post=${d}&action=edit`;default:return null}};return e.jsxs("div",{className:`space-y-6 ${o}`,children:[(u==null?void 0:u.length)>0&&e.jsxs(V,{className:"rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[e.jsx(ne,{className:"p-6 border-b border-slate-100",children:e.jsxs(be,{className:"text-lg font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(mr,{className:"w-5 h-5 text-primary"}),"Store Order Breakdown"]})}),e.jsxs(ie,{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-slate-500 uppercase tracking-wide",children:"Line Items"}),e.jsxs("div",{className:"space-y-3",children:[u.map((d,P)=>{var F,te;const f=(F=s.brandingItems)==null?void 0:F[P],I=((te=f==null?void 0:f.mockupImages)==null?void 0:te[0])||(f==null?void 0:f.designThumbnailUrl),_=f?ot[f.brandingProductType]||f.brandingProductType:"",g=f?ds(f):null,E=(g==null?void 0:g.status)==="REQUIRES_RECONCILIATION"?"Requires reconciliation":"Provider cost unavailable",L=g!=null&&g.available?x(g.lineTotal):E;return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-slate-50 rounded-xl",children:[d.imageUrl?e.jsx("img",{src:d.imageUrl,alt:d.title,className:"w-20 h-20 object-cover rounded-lg border border-slate-200"}):e.jsx("div",{className:"w-20 h-20 bg-slate-200 rounded-lg flex items-center justify-center",children:e.jsx(xe,{className:"w-8 h-8 text-slate-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-base font-medium text-slate-900",children:d.title}),d.variantTitle&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:d.variantTitle}),d.sku&&e.jsxs("p",{className:"text-xs text-slate-400 font-mono mt-0.5",children:["SKU: ",d.sku]}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-sm text-slate-500",children:["Qty: ",d.quantity]}),e.jsx("span",{className:"text-lg font-semibold text-slate-900",children:x(d.totalPrice,t.currency)})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[d.isPrintarexProduct&&e.jsx(me,{variant:"secondary",className:"bg-primary/10 text-primary border-0",children:"PrintaRex Product"}),p(d.externalProductId)&&e.jsxs(U,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 text-slate-600 hover:text-primary",onClick:()=>It(p(d.externalProductId)),children:[e.jsx(ts,{className:"h-3 w-3"}),"View in Store"]})]})]})]}),f?e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-violet-50 rounded-xl",children:[I?e.jsx("img",{src:I,alt:_,className:"w-20 h-20 object-cover rounded-lg border border-violet-200"}):e.jsx("div",{className:"w-20 h-20 bg-violet-100 rounded-lg flex items-center justify-center",children:e.jsx(ut,{className:"w-8 h-8 text-violet-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-base font-medium text-slate-900",children:_}),f.printAreas&&f.printAreas.length>0&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:f.printAreas.map(X=>X.areaName).join(", ")}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-sm text-slate-500",children:["Qty: ",f.quantity]}),e.jsx("span",{className:"text-lg font-semibold text-slate-900",children:L})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(me,{variant:"secondary",className:"bg-violet-100 text-violet-700 border-0",children:"Provider Cost"}),I&&e.jsxs(U,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 text-violet-600 hover:text-violet-700 border-violet-200",onClick:()=>{c(I),l(_)},children:[e.jsx(Be,{className:"h-3 w-3"}),"View Image"]}),f.designId&&f.productSlug&&e.jsxs(U,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 text-violet-600 hover:text-violet-700 border-violet-200",onClick:()=>globalThis.open(`/dashboard/branding/design/${f.productSlug}/${f.designId}`,"_blank","noopener,noreferrer"),children:[e.jsx(ts,{className:"h-3 w-3"}),"View Design"]})]})]})]}):e.jsx("div",{className:"hidden md:block"})]},`item-${d.title}-${P}`)}),s.brandingItems&&s.brandingItems.length>u.length&&s.brandingItems.slice(u.length).map((d,P)=>{var L;const f=((L=d.mockupImages)==null?void 0:L[0])||d.designThumbnailUrl,I=ot[d.brandingProductType]||d.brandingProductType,_=ds(d),g=_.status==="REQUIRES_RECONCILIATION"?"Requires reconciliation":"Provider cost unavailable",E=_.available?x(_.lineTotal):g;return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx("div",{className:"hidden md:block"}),e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-violet-50 rounded-xl",children:[f?e.jsx("img",{src:f,alt:I,className:"w-20 h-20 object-cover rounded-lg border border-violet-200"}):e.jsx("div",{className:"w-20 h-20 bg-violet-100 rounded-lg flex items-center justify-center",children:e.jsx(ut,{className:"w-8 h-8 text-violet-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-base font-medium text-slate-900",children:I}),d.printAreas&&d.printAreas.length>0&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:d.printAreas.map(F=>F.areaName).join(", ")}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-sm text-slate-500",children:["Qty: ",d.quantity]}),e.jsx("span",{className:"text-lg font-semibold text-slate-900",children:E})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(me,{variant:"secondary",className:"bg-violet-100 text-violet-700 border-0",children:"Provider Cost"}),f&&e.jsxs(U,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 text-violet-600 hover:text-violet-700 border-violet-200",onClick:()=>{c(f),l(I)},children:[e.jsx(Be,{className:"h-3 w-3"}),"View Image"]}),d.designId&&d.productSlug&&e.jsxs(U,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 text-violet-600 hover:text-violet-700 border-violet-200",onClick:()=>globalThis.open(`/dashboard/branding/design/${d.productSlug}/${d.designId}`,"_blank","noopener,noreferrer"),children:[e.jsx(ts,{className:"h-3 w-3"}),"View Design"]})]})]})]})]},`extra-branding-${P}`)})]})]}),(b==null?void 0:b.length)>0&&e.jsxs("div",{className:"pt-4 border-t border-slate-100 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-slate-500 uppercase tracking-wide",children:"Discounts Applied"}),b.map((d,P)=>e.jsxs("div",{className:"flex items-center justify-between p-4 bg-emerald-50 rounded-xl",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d.type==="GIFT_CARD"?e.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-100 flex items-center justify-center",children:e.jsx(xr,{className:"w-5 h-5 text-emerald-600"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-100 flex items-center justify-center",children:e.jsx(hr,{className:"w-5 h-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-emerald-700",children:{GIFT_CARD:"Gift Card",COUPON:"Coupon",AUTOMATIC:"Automatic Discount"}[d.type]??d.description??"Discount"}),d.code&&e.jsx("p",{className:"text-sm text-emerald-600",children:d.code})]})]}),e.jsxs("span",{className:"text-lg font-semibold text-emerald-700",children:["-",d.isPercentage?`${d.amount}%`:x(d.amount,t.currency)]})]},`discount-${d.code||d.description||P}`))]}),e.jsxs("div",{className:"pt-4 border-t border-slate-100 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-slate-500 uppercase tracking-wide",children:"Cost Summary"}),e.jsxs("div",{className:"space-y-2",children:[t.subtotalPrice!=null&&e.jsxs("div",{className:"flex justify-between text-base",children:[e.jsx("span",{className:"text-slate-600",children:"Subtotal"}),e.jsx("span",{className:"font-medium text-slate-900",children:x(t.subtotalPrice,t.currency)})]}),t.totalShipping!=null&&e.jsxs("div",{className:"flex justify-between text-base",children:[e.jsx("span",{className:"text-slate-600",children:"Shipping"}),e.jsx("span",{className:"font-medium text-slate-900",children:t.totalShipping===0?"Free":x(t.totalShipping,t.currency)})]}),t.totalTax!=null&&t.totalTax>0&&e.jsxs("div",{className:"flex justify-between text-base",children:[e.jsx("span",{className:"text-slate-600",children:"Tax"}),e.jsx("span",{className:"font-medium text-slate-900",children:x(t.totalTax,t.currency)})]}),t.totalDiscounts!=null&&t.totalDiscounts>0&&e.jsxs("div",{className:"flex justify-between text-base",children:[e.jsx("span",{className:"text-emerald-600",children:"Discount"}),e.jsxs("span",{className:"font-medium text-emerald-600",children:["-",x(t.totalDiscounts,t.currency)]})]}),(b==null?void 0:b.some(d=>d.type==="GIFT_CARD"))&&e.jsxs("div",{className:"flex justify-between text-base pt-2 border-t border-slate-100",children:[e.jsx("span",{className:"text-slate-600",children:"Total price"}),e.jsx("span",{className:"font-medium text-slate-900",children:x(t.totalPrice,t.currency)})]}),b==null?void 0:b.filter(d=>d.type==="GIFT_CARD").map((d,P)=>e.jsxs("div",{className:"flex justify-between text-base",children:[e.jsx("span",{className:"text-emerald-600",children:"Gift card"}),e.jsxs("span",{className:"font-medium text-emerald-600",children:["-",x(d.amount,t.currency)]})]},`gc-${P}`))]}),e.jsxs("div",{className:"flex justify-between text-lg pt-3 border-t border-slate-200",children:[e.jsx("span",{className:"font-semibold text-slate-900",children:"Total Paid by Customer"}),e.jsx("span",{className:"font-bold text-xl bg-gradient-to-r from-primary to-emerald-500 bg-clip-text text-transparent",children:x(t.totalPrice-((b==null?void 0:b.filter(d=>d.type==="GIFT_CARD").reduce((d,P)=>d+(P.amount||0),0))||0),t.currency)})]})]})]})]}),((C=N==null?void 0:N.lineItems)==null?void 0:C.length)>0&&e.jsxs(V,{className:"bg-gradient-to-br from-primary/5 to-emerald-500/5 rounded-2xl border border-primary/20 overflow-hidden",children:[e.jsxs(ne,{className:"p-6 border-b border-primary/10",children:[e.jsxs(be,{className:"text-lg font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(cs,{className:"w-5 h-5 text-primary"}),"PrintaRex Order Summary"]}),N.providerName&&e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-sm text-slate-600",children:[e.jsx(ur,{className:"w-4 h-4"}),e.jsxs("span",{children:["Provider:"," ",e.jsx("strong",{className:"text-slate-900",children:N.providerName})]}),e.jsx("span",{className:"text-slate-400",children:"|"}),e.jsxs("span",{children:["Currency:"," ",e.jsx("strong",{className:"text-slate-900",children:N.currency})]})]})]}),e.jsxs(ie,{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-slate-500 uppercase tracking-wide",children:"Line-Total Cost Breakdown"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 border-b border-slate-200",children:[e.jsx("th",{className:"text-left py-3 pr-4 font-medium",children:"Variant"}),e.jsx("th",{className:"text-center py-3 px-2 font-medium",children:"Qty"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium",children:"Retail Total"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium",children:"Provider Production Total"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium",children:"Shipping Total"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium",children:"Branding Total"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium",children:"PrintaRex Order Transaction Fee"}),e.jsx("th",{className:"text-right py-3 pl-2 font-medium",children:"Your Profit"})]})}),e.jsx("tbody",{children:N.lineItems.map(d=>{var I;const P=(d.bulkDiscountPct??0)>0&&d.providerCostBeforeDiscount!=null&&d.providerCostBeforeDiscount>d.providerCost,f=dr(d);return e.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[e.jsx("td",{className:"py-3 pr-4 text-slate-900 font-medium",children:d.variantDescription}),e.jsx("td",{className:"py-3 px-2 text-center text-slate-600",children:e.jsx("span",{className:"inline-flex items-center justify-center min-w-[24px] h-6 px-2 bg-slate-100 rounded-md font-medium",children:d.quantity})}),e.jsx("td",{className:"py-3 px-2 text-right text-slate-600",children:f.retailTotal.toFixed(2)}),e.jsx("td",{className:"py-3 px-2 text-right text-slate-600",children:P?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"line-through text-slate-400",children:((d.providerCostBeforeDiscount??0)*f.quantity).toFixed(2)}),e.jsx("span",{className:"ml-2 font-medium text-slate-700",children:f.providerCostTotal.toFixed(2)})]}),e.jsxs("div",{className:"text-xs text-primary",children:[(I=d.bulkDiscountPct)==null?void 0:I.toFixed(0),"% bulk discount",d.matchedT
27ierMinQty?` at ${d.matchedTierMinQty}+`:""]})]}):f.providerCostTotal.toFixed(2)}),e.jsx("td",{className:"py-3 px-2 text-right text-slate-600",children:f.shippingTotal.toFixed(2)}),e.jsx("td",{className:"py-3 px-2 text-right text-slate-600",children:f.brandingTotal.toFixed(2)}),e.jsx("td",{className:"py-3 px-2 text-right text-slate-600",children:f.orderFee.toFixed(2)}),e.jsxs("td",{className:"py-3 pl-2 text-right",children:[e.jsx("span",{className:"font-semibold text-primary",children:f.profit.toFixed(2)}),e.jsxs("span",{className:"text-slate-400 ml-1",children:["(",f.profitMargin.toFixed(0),"%)"]})]})]},`${d.variantDescription}-${d.quantity}`)})})]})})]}),e.jsxs("div",{className:"pt-4 border-t border-slate-200 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-slate-500 uppercase tracking-wide",children:"Order Totals"}),(()=>{let d=0,P=0,f=null;for(const I of N.lineItems){const _=I.quantity??0,g=I.providerCost??0,E=I.providerCostBeforeDiscount??g;d+=E*_,(I.bulkDiscountPct??0)>0&&I.providerCostBeforeDiscount!=null&&I.providerCostBeforeDiscount>g&&(P+=(E-g)*_,f==null&&I.matchedTierMinQty!=null&&(f=I.matchedTierMinQty))}return P<=0?null:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"p-3 bg-white/50 rounded-xl",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Provider Cost (Before Discount)"}),e.jsxs("p",{className:"text-base font-semibold text-slate-500 line-through",children:[N.currency," ",d.toFixed(2)]})]}),e.jsxs("div",{className:"p-3 bg-emerald-50 rounded-xl",children:[e.jsxs("p",{className:"text-xs text-emerald-700",children:["Bulk Discount",f!=null?` (${f}+ items)`:""]}),e.jsxs("p",{className:"text-base font-semibold text-emerald-700",children:["-",N.currency," ",P.toFixed(2)]})]}),e.jsxs("div",{className:"p-3 bg-white/50 rounded-xl",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Provider Cost (After Discount)"}),e.jsxs("p",{className:"text-base font-semibold text-slate-900",children:[N.currency," ",N.totalProviderCost.toFixed(2)]})]})]})})(),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"p-3 bg-white/50 rounded-xl",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Provider Production Cost"}),e.jsxs("p",{className:"text-lg font-semibold text-slate-900",children:[N.currency," ",N.totalProviderCost.toFixed(2)]})]}),e.jsxs("div",{className:"p-3 bg-white/50 rounded-xl",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Order Shipping Total"}),e.jsxs("p",{className:"text-lg font-semibold text-slate-900",children:[N.currency," ",N.totalShippingCost.toFixed(2)]})]}),e.jsxs("div",{className:"p-3 bg-white/50 rounded-xl",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Branding Cost"}),e.jsxs("p",{className:"text-lg font-semibold text-slate-900",children:[N.currency," ",N.totalBrandingCost.toFixed(2)]})]}),e.jsxs("div",{className:"p-3 bg-white/50 rounded-xl",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"PrintaRex Order Transaction Fee"}),e.jsxs("p",{className:"text-lg font-semibold text-slate-900",children:[N.currency," ",N.totalOrderFee.toFixed(2)]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-3",children:[e.jsxs("div",{className:"p-4 bg-slate-100 rounded-xl",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(pr,{className:"w-5 h-5 text-slate-600"}),e.jsx("span",{className:"text-sm font-medium text-slate-600",children:"Total Cost to You"})]}),e.jsxs("p",{className:"text-2xl font-bold text-slate-900",children:[N.currency," ",N.totalCost.toFixed(2)]})]}),e.jsxs("div",{className:"p-4 bg-gradient-to-r from-primary/10 to-emerald-500/10 rounded-xl",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(br,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"text-sm font-medium text-primary",children:"Expected Your Profit"})]}),e.jsxs("p",{className:"text-2xl font-bold text-primary",children:[N.currency," ",N.totalProfit.toFixed(2)]})]})]})]})]})]}),e.jsx(As,{open:!!h,onOpenChange:d=>!d&&c(null),children:e.jsxs(Fs,{className:"max-w-3xl p-0 overflow-hidden",children:[e.jsx(_s,{className:"p-4 border-b border-slate-100 flex flex-row items-center justify-between",children:e.jsxs(Ls,{className:"flex items-center gap-2 text-lg font-semibold",children:[e.jsx(Be,{className:"h-5 w-5 text-violet-600"}),r||"Branding Image"]})}),e.jsx("div",{className:"p-4 bg-slate-50 flex items-center justify-center min-h-[300px] max-h-[70vh]",children:h&&e.jsx("img",{src:h,alt:r||"Branding Image",className:"max-w-full max-h-[65vh] object-contain rounded-lg shadow-lg"})})]})})]})}const Os="Data has been removed as per Amazon compliance policy",$r=new Set([Os.toLowerCase(),"buyer pii removed per amazon compliance policy","[redacted]","deleted user","purged","purged user","redacted","[email protected]"]);function zr(s){return typeof s=="string"?s.trim().toLowerCase():""}function zt(s){return(s==null?void 0:s.trim().toUpperCase())==="AMAZON"}function Hr(s){const t=zr(s);return t?$r.has(t)||t.includes("amazon compliance")||t.includes("buyer pii removed")||t.endsWith(".deleted")||t.startsWith("deleted_")&&t.includes("@printarex.deleted"):!1}function Vr(s){return s==null||typeof s=="string"&&s.trim()===""}function qr(s){return s.some(t=>!Vr(t))}function Yr(s){return s?[s.firstName,s.lastName,s.fullName,s.companyName,s.addressLine1,s.addressLine2,s.city,s.stateProvince,s.postalCode,s.countryCode,s.phone,s.email,s.deliveryInstructions,s.formattedAddress]:[]}function wt(s){return s?[s.name,s.firstName,s.lastName,s.company,s.address1,s.address2,s.city,s.province,s.provinceCode,s.country,s.countryCode,s.zip,s.phone,s.email]:[]}function Ht({isAmazonStoreOrder:s,orderBuyerPiiRemoved:t,orderAddress:a,storeOrder:o,storeShippingAddress:h}){if(t||o!=null&&o.buyerPiiRemoved)return!0;
27if(!s||!o&&!h)return!1;const c=h??(o==null?void 0:o.shippingAddress);if([o==null?void 0:o.customerName,o==null?void 0:o.customerEmail,...wt(c),...Yr(a)].some(Hr))return!0;const l=[o==null?void 0:o.customerName,o==null?void 0:o.customerEmail,...wt(c)];return!qr(l)}const Gr={PENDING:{bgColor:"bg-amber-100",color:"text-amber-800",label:"Pending"},SUCCEEDED:{bgColor:"bg-green-100",color:"text-green-800",label:"Paid"},PAID:{bgColor:"bg-green-100",color:"text-green-800",label:"Paid"},FAILED:{bgColor:"bg-red-100",color:"text-red-800",label:"Failed"},EXPIRED:{bgColor:"bg-slate-100",color:"text-slate-800",label:"Expired"},REFUNDED:{bgColor:"bg-green-100",color:"text-green-800",label:"Refunded"}},Qr=s=>{const t=De(s.transactionFee),a=De(s.totalAmount),o=De(s.subtotal),h=De(s.shippingCost),c=De(s.taxAmount);if(a!=null&&o!=null&&h!=null&&c!=null){const r=a-o-h-c;if(Number.isFinite(r)&&r>0)return r}return t!=null&&t>0?t:null},De=s=>{if(s==null||s==="")return null;const t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?t:null};function Vt(s){return s.replaceAll("_"," ").toLowerCase().replaceAll(/\b\w/g,t=>t.toUpperCase())}function Wr(s){return(s??[]).filter(t=>t.rejectedAt).sort((t,a)=>new Date(a.rejectedAt??0).getTime()-new Date(t.rejectedAt??0).getTime())[0]}function Kr(s){var t;return s.status==="AWAITING_PROVIDER_ACCEPTANCE"?"Awaiting provider acceptance":s.status==="PROVIDER_ACCEPTED_PAYMENT_PENDING"?"Provider accepted - payment pending":((t=He[s.status])==null?void 0:t.label)??Vt(s.status)}function Xr(s){if(s.status==="AWAITING_PROVIDER_ACCEPTANCE")return"bg-violet-100 text-violet-800";if(s.status==="PROVIDER_ACCEPTED_PAYMENT_PENDING")return"bg-amber-100 text-amber-800";const t=He[s.status];return`${(t==null?void 0:t.bgColor)??"bg-blue-100"} ${(t==null?void 0:t.color)??"text-blue-800"}`}const Zr=({item:s,currency:t})=>{var x,u;const{locale:a}=we(),o=b=>Tt(b,t,a),h=b=>Ce(b,a),c=pa(s.productName,h),r=ba(s.colorName,h),l=((u=(x=s.mockupImages)==null?void 0:x[0])==null?void 0:u.mockupUrl)||s.designThumbnailUrl;return e.jsxs("div",{className:"group flex gap-5 p-4 rounded-xl bg-gradient-to-r from-slate-50/80 to-white border border-slate-100 hover:border-slate-200 hover:shadow-md transition-all duration-300",children:[l?e.jsx("img",{src:l,alt:c,className:"h-24 w-24 rounded-xl object-cover bg-slate-100 shadow-sm group-hover:shadow-md transition-shadow"}):e.jsx("div",{className:"h-24 w-24 rounded-xl bg-gradient-to-br from-slate-100 to-slate-50 flex items-center justify-center border border-slate-200 shadow-sm",children:e.jsx(xe,{className:"h-10 w-10 text-slate-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-semibold text-base text-slate-900",children:c}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 text-sm text-slate-600 bg-slate-100/80 px-3 py-1 rounded-full",children:[s.colorHex&&e.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-slate-300 shadow-sm",style:{backgroundColor:s.colorHex}}),e.jsx("span",{children:r})]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 text-sm text-slate-600 bg-slate-100/80 px-3 py-1 rounded-full",children:[e.jsx("span",{className:"font-medium",children:h("Size:")})," ",s.size]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 text-sm text-slate-600 bg-slate-100/80 px-3 py-1 rounded-full",children:[e.jsx("span",{className:"font-medium",children:h("Qty:")})," ",s.quantity]})]}),s.printAreas&&s.printAreas.length>0&&e.jsx("div",{className:"mt-3 flex gap-2 flex-wrap",children:s.printAreas.map(b=>e.jsx("span",{className:"text-xs bg-primary/10 text-primary font-medium px-2.5 py-1 rounded-full border border-primary/20",children:ga(b.areaName,h)},b.areaName))})]}),e.jsxs("div",{className:"text-right flex flex-col justify-center",children:[e.jsx("p",{className:"text-lg font-bold text-slate-900",children:o(s.lineTotal)}),e.jsxs("p",{className:"text-sm text-slate-500 mt-0.5",children:[o(s.unitPrice)," ",h("each")]}),s.printAreaCosts&&s.printAreaCosts>
270&&e.jsxs("p",{className:"text-xs text-primary font-medium mt-1",children:["+",o(s.printAreaCosts)," ",h("print")]})]})]})},Jr=({order:s,storeOrder:t})=>{var C,d,P,f,I,_;const{locale:a}=we(),o=g=>Ce(g,a),h=g=>{let E=g;return!g.endsWith("Z")&&!g.includes("+")&&!g.includes("-",10)&&(E=g+"Z"),ls(E,a,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})},c=(t==null?void 0:t.customerName)||((C=s.shippingAddress)==null?void 0:C.fullName)||((d=s.shippingAddress)!=null&&d.firstName&&((P=s.shippingAddress)!=null&&P.lastName)?`${s.shippingAddress.firstName} ${s.shippingAddress.lastName}`:"Customer"),r=(t==null?void 0:t.customerEmail)||((f=s.shippingAddress)==null?void 0:f.email),l=zt((I=t==null?void 0:t.storeConnection)==null?void 0:I.platform),x=Ht({isAmazonStoreOrder:l,orderBuyerPiiRemoved:s.buyerPiiRemoved,orderAddress:s.shippingAddress,storeOrder:t}),u=((_=s.payment)==null?void 0:_.status)??(s.paidAt?"PAID":null),b=u?Gr[u]:null,N=s.processingState!=null&&s.processingState!=="STABLE",j=Wr(s.assignmentHistory),p=j!=null&&s.status==="AWAITING_PROVIDER_ACCEPTANCE"&&s.providerName&&s.providerName!==j.providerName;return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs(V,{className:"lg:col-span-2 rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsxs(be,{className:"text-base flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-rose-500 to-pink-600 flex items-center justify-center shadow-md",children:e.jsx(pt,{className:"h-4 w-4 text-white"})}),e.jsx("span",{className:"font-semibold text-slate-900",children:o("Customer Details")})]})}),e.jsxs(ie,{className:"pt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[x?e.jsxs("div",{className:"flex items-start gap-3 sm:col-span-2 rounded-xl border border-amber-200 bg-amber-50 p-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-amber-100 flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"h-4 w-4 text-amber-700"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-amber-700 uppercase tracking-wide",children:o("Buyer PII")}),e.jsx("p",{className:"font-medium text-amber-900",children:o(Os)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:e.jsx(pt,{className:"h-4 w-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wide",children:o("Name")}),e.jsx("p",{className:"font-medium text-slate-900",children:c})]})]}),r&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:e.jsx(ua,{className:"h-4 w-4 text-slate-500"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wide",children:o("Email")}),e.jsx("p",{className:"font-medium text-slate-900 truncate",children:r})]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:e.jsx(Ot,{className:"h-4 w-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wide",children:o("Received")}),e.jsx("p",{className:"font-medium text-slate-900",children:h(s.createdAt)})]})]})]}),p&&e.jsxs("div",{className:"mt-4 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:o("Provider changed")}),e.jsxs("p",{className:"mt-1 text-sm text-amber-800",children:[o("The assigned provider changed after review. Current provider:")," ",s.providerName,"."]})]})]})]}),e.jsx("div",{className:"flex flex-col gap-4",children:N?e.jsx(er,{order:{createdAt:s.createdAt,processingState:s.processingState},className:"flex-1"}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"rounded-xl border border-slate-200/50 bg-white/80 p-4 flex-1",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gradient-to-br from-emerald-500 to-green-600 flex items-center justify-center shadow-md",children:e.jsx(os,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wide",children:o("Payment")}),u?e.jsx("span",{className:`mt-1 inline-flex items-center rounded-md px-2.5 py-0.5 text-xs ${(b==null?void 0:b.bgColor)??"bg-slate-100"} ${(b==null?void 0:b.color)??"text-slate-800"} border-0 font-semibold`,children:o((b==null?void 0:b.label)??Vt(u))}):e.jsx("span",{className:"mt-1 text-sm text-slate-400",children:"â"})]})]})}),e.jsx(V,{className:"rounded-xl border border-slate-200/50 bg-white/80 p-4 flex-1",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center shadow-md",children:e.jsx(Ue,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wide",children:o("Fulfillment")}),e.jsx("span",{className:`mt-1 inline-flex items-center rounded-md px-2.5 py-0.5 text-xs ${Xr(s)} border-0 font-semibold whitespace-normal text-left leading-tight`,children:o(Kr(s))})]})]})})]})})]})};function el({order:s,storeOrder:t,storeOrderLoading:a=!1}){const{locale:o}=we(),h=l=>Ce(l,o),c=Qr(s),r=(l,x)=>Tt(l,x,o,{fallbackCurrency:null});return s.orderType==="STORE_ORDER"?e.jsxs("div",{className:"space-y-6",children:[e.jsx(Jr,{order:s,storeOrder:t}),e.jsx(Ur,{order:s,storeOrder:t,loading:a})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(V,{className:"rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-4 border-b border-slate-100 bg-slate-50/50",children:e.jsxs(be,{className:"text-lg flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gradient-to-br from-primary to-emerald-600 flex items-center justify-center shadow-lg shadow-primary/30",children:e.jsx(xe,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-900",children:h("Order Items")}),e.jsxs("span",{className:"ml-2 text-sm font-normal text-slate-500",children:["(",s.itemCount," ",h(s.itemCount===1?"item":"items"),")"]})]})]})}
27),e.jsx(ie,{className:"p-6 space-y-4",children:s.items.map(l=>e.jsx(Zr,{item:l,currency:s.currency},l.itemId))})]}),e.jsxs(V,{className:"rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsxs(be,{className:"text-base flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-amber-500 to-orange-600 flex items-center justify-center shadow-md",children:e.jsx(cs,{className:"h-4.5 w-4.5 text-white"})}),e.jsx("span",{className:"font-semibold text-slate-900",children:h("Order Summary")})]})}),e.jsxs(ie,{className:"pt-4 space-y-3",children:[(()=>{const l=De(s.subtotal),x=De(s.discountAmount),u=l!=null&&x!=null&&x>0?l+x:l;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:h("Subtotal")}),e.jsx("span",{className:"font-medium text-slate-700",children:r(u,s.currency)})]}),x!=null&&x>0&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-emerald-600",children:h("Bulk discount")}),e.jsxs("span",{className:"font-medium text-emerald-600",children:["-",r(x,s.currency)]})]})]})})(),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:h("Shipping")}),e.jsx("span",{className:"font-medium text-slate-700",children:r(s.shippingCost,s.currency)})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:h("Tax")}),e.jsx("span",{className:"font-medium text-slate-700",children:r(s.taxAmount,s.currency)})]}),c!=null&&c>0&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:h("Order Fee")}),e.jsx("span",{className:"font-medium text-slate-700",children:r(c,s.currency)})]}),e.jsx(or,{className:"my-3"}),e.jsxs("div",{className:"flex justify-between items-center pt-1",children:[e.jsx("span",{className:"font-semibold text-slate-900",children:h("Total")}),e.jsx("span",{className:"text-xl font-bold text-primary",children:r(s.totalAmount,s.currency)})]})]})]})]})}const sl="https://www.postaplus.com/",tl=new Set(["postaplus.com","www.postaplus.com","etrack.postaplus.net"]);function al(s){const t=s==null?void 0:s.trim().toUpperCase();return t==="POSTA PLUS"||t==="POSTAPLUS"}function rl(s){return tl.has(new URL(s).hostname.toLowerCase())}function ll(s,t){const a=fa(t);if(a&&rl(a))return a;const o=new URLSearchParams({trackid:s,trackby:"awb"});return`${sl}?${o.toString()}`}function il({open:s,onOpenChange:t,order:a,onSuccess:o}){const{locale:h}=we(),c=p=>Ce(p,h),r=a.shippingAddress,[l,x]=v.useState({firstName:(r==null?void 0:r.firstName)||"",lastName:(r==null?void 0:r.lastName)||"",companyName:(r==null?void 0:r.companyName)||"",addressLine1:(r==null?void 0:r.addressLine1)||"",addressLine2:(r==null?void 0:r.addressLine2)||"",city:(r==null?void 0:r.city)||"",stateProvince:(r==null?void 0:r.stateProvince)||"",postalCode:(r==null?void 0:r.postalCode)||"",countryCode:(r==null?void 0:r.countryCode)||"",phone:(r==null?void 0:r.phone)||"",email:(r==null?void 0:r.email)||"",deliveryInstructions:(r==null?void 0:r.deliveryInstructions)||""}),[u,{loading:b}]=Me(At,{refetchQueries:[{query:St,variables:{orderId:a.orderId}}],awaitRefetchQueries:!0,onCompleted:p=>{var C,d;(C=p==null?void 0:p.updateShippingAddress)!=null&&C.success?(Re.success(p.updateShippingAddress.message||c("Shipping address updated")),t(!1),o()):Re.error(((d=p==null?void 0:p.updateShippingAddress)==null?void 0:d.message)||c("Failed to update address"))},onError:p=>{Re.error(p.message||c("Failed to update shipping address"))}}),N=(p,C)=>{x(d=>({...d,[p]:C}))},j=()=>
27{if(!l.addressLine1||!l.city||!l.countryCode){Re.error(c("Address line 1, city, and country code are required"));return}const p={};for(const[C,d]of Object.entries(l))d.trim()&&(p[C]=d.trim());u({variables:{orderId:a.orderId,input:p}})};return e.jsx(As,{open:s,onOpenChange:t,children:e.jsxs(Fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(Ls,{children:c("Edit Shipping Address")})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"firstName",children:c("First Name")}),e.jsx(ue,{id:"firstName",value:l.firstName,onChange:p=>N("firstName",p.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"lastName",children:c("Last Name")}),e.jsx(ue,{id:"lastName",value:l.lastName,onChange:p=>N("lastName",p.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"companyName",children:c("Company Name")}),e.jsx(ue,{id:"companyName",value:l.companyName,onChange:p=>N("companyName",p.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"addressLine1",children:c("Address Line 1 *")}),e.jsx(ue,{id:"addressLine1",value:l.addressLine1,onChange:p=>N("addressLine1",p.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"addressLine2",children:c("Address Line 2")}),e.jsx(ue,{id:"addressLine2",value:l.addressLine2,onChange:p=>N("addressLine2",p.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"city",children:c("City *")}),e.jsx(ue,{id:"city",value:l.city,onChange:p=>N("city",p.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"stateProvince",children:c("State / Province")}),e.jsx(ue,{id:"stateProvince",value:l.stateProvince,onChange:p=>N("stateProvince",p.target.value)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"postalCode",children:c("Postal Code")}),e.jsx(ue,{id:"postalCode",value:l.postalCode,onChange:p=>N("postalCode",p.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"countryCode",children:c("Country Code *")}),e.jsx(ue,{id:"countryCode",value:l.countryCode,onChange:p=>N("countryCode",p.target.value),placeholder:"AE, EG, SA...",required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"phone",children:c("Phone")}),e.jsx(ue,{id:"phone",value:l.phone,onChange:p=>N("phone",p.target.value),placeholder:"+971..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"email",children:c("Email")}),e.jsx(ue,{id:"email",type:"email",value:l.email,onChange:p=>N("email",p.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(he,{htmlFor:"deliveryInstructions",children:c("Delivery Instructions")}),e.jsx(gr,{id:"deliveryInstructions",value:l.deliveryInstructions,onChange:p=>N("deliveryInstructions",p.target.value),rows:2})]})]}),e.jsxs(Na,{children:[e.jsx(U,{variant:"outline",onClick:()=>t(!1),disabled:b,children:c("Cancel")}),e.jsx(U,{onClick:j,disabled:b,children:c(b?"Saving...":"Save Address")})]})]})})}function nl(s,t){return t!=null&&t.includes("bosta")?t:`https://bosta.co/track-shipment?tracking_number=${s}`}function cl(s,t,a){return s==="Bosta"?nl(t,a):al(s)?ll(t,a):a||"#"}function ol(s){switch(s){case"AE":return"Emirate";case"EG":return"Governorate";case"SA":return"Region";default:return"State / Province"}}const dl=new Set(["CANCELLED","REFUNDED","DELIVERED","RETURNED"]),ml={DELIVERED:"Delivered",OUT_FOR_DELIVERY:"Out for Delivery",IN_TRANSIT:"In Transit",PICKED_UP:"Picked Up",EXCEPTION:"Exception",ON_HOLD:"On Hold",RETURNED:"Returned"};function xl(s){var t;return((t=He[s])==null?void 0:t.label)||s.replaceAll("_"," ").toLowerCase().replaceAll(/\b\w/g,a=>a.toUpperCase())}function hl({order:s,storeShippingAddress:t,onOrderUpdated:a,isAmazonStoreOrder:o=!1}){var O;const{toast:h}=Ft(),{locale:c}=we(),r=w=>Ce(w,c),l=w=>{const z=w.replaceAll("_"," ");return c==="ar"?r(ml[w]??z):z},x=s.shipment,u=s.shippingAddress,[b,N]=v.useState(""),[j,p]=v.useState(!1),C=Ht({isAmazonStoreOrder:o,orderBuyerPiiRemoved:s.buyerPiiRemoved,orderAddress:s.shippingAddress,storeShippingAddress:t}),d=!C&&(s.hasMissingShippingInfo||s.status==="PENDING_SHIPPING_INFO"),P=!dl.has(s.status),[f,{loading:I}]=Me(At,{update:(w,{data:z})=>{var ce;if(!((ce=z==null?void 0:z.updateShippingAddress)!=null&&ce.success))return;const q=z.updateShippingAddress.order;if(!q)return;const re=w.identify({__typename:"Order",orderId:s.orderId});re&&w.modify({id:re,fields:{status:()=>q.status,hasMissingShippingInfo:()=>q.hasMissingShippingInfo}})},onCompleted:w=>{var z,q;(z=w==null?void 0:w.updateShippingAddress)!=null&&z.success?(Re.success(r("Phone number saved. Your order will c
27ontinue processing.")),N("")):Re.error(((q=w==null?void 0:w.updateShippingAddress)==null?void 0:q.message)||r("Failed to update shipping address."))},onError:w=>{Re.error(w.message||r("Failed to update shipping address."))}}),_=()=>{b.trim()&&f({variables:{orderId:s.orderId,input:{phone:b.trim()}}})},g=w=>{if(!w)return"-";let z=w;return!w.endsWith("Z")&&!w.includes("+")&&!w.includes("-",10)&&(z=w+"Z"),ls(z,c,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})},E=w=>w?ls(w,c,{weekday:"long",month:"long",day:"numeric"}):"-",L=()=>{if(!u)return null;const w=[];return u.addressLine1&&w.push(u.addressLine1),u.addressLine2&&w.push(u.addressLine2),u.city&&w.push(u.city),u.stateProvince&&u.postalCode?w.push(`${u.stateProvince} ${u.postalCode}`):u.stateProvince?w.push(u.stateProvince):u.postalCode&&w.push(u.postalCode),u.countryCode&&w.push(u.countryCode),w.join(` 28`)},F=()=>{const w=L();w&&(navigator.clipboard.writeText(w.replaceAll(` 29`,", ")),h({title:r("Copied"),description:r("Address copied to clipboard")}))},te=()=>{x!=null&&x.trackingNumber&&(navigator.clipboard.writeText(x.trackingNumber),h({title:r("Copied"),description:r("Tracking number copied to clipboard")}))},X=()=>{if(!u)return null;if(u.fullName)return u.fullName;const w=u.firstName,z=u.lastName;return[w,z].filter(Boolean).join(" ")||null},H=()=>(u==null?void 0:u.phone)||(t==null?void 0:t.phone)||null,ae=()=>(u==null?void 0:u.email)||null;return e.jsxs("div",{className:"space-y-6",children:[d&&e.jsx("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Xe,{className:"h-5 w-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800",children:r("Your order is on hold â please add the recipient's phone number so it can be shipped.")}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx(ue,{type:"tel",placeholder:"+971501234567",value:b,onChange:w=>N(w.target.value),className:"max-w-xs h-9 text-sm"}),e.jsx(U,{size:"sm",onClick:_,disabled:!b.trim()||I,className:"h-9",children:I?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"h-4 w-4 mr-1 animate-spin"}),r("Saving...")]}):r("Save & Continue")})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(V,{className:"rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"text-base font-semibold flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center shadow-md",children:e.jsx(it,{className:"h-4.5 w-4.5 text-white"})}),e.jsx("span",{className:"text-slate-900",children:r("Shipping Address")})]}),!C&&e.jsxs("div",{className:"flex items-center gap-1",children:[P&&e.jsx(U,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>p(!0),title:r("Edit address"),children:e.jsx(fr,{className:"h-4 w-4"})}),e.jsx(U,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:F,title:r("Copy address"),children:e.jsx(Ss,{className:"h-4 w-4"})})]})]})}),e.jsx(ie,{className:"pt-4",children:C?e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-amber-200 bg-amber-50 p-4",children:[e.jsx($t,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-700"}),e.jsx("p",{className:"text-sm font-medium text-amber-900",children:r(Os)})]}):u?e.jsxs("div",{className:"space-y-1",children:[X()&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("Recipient")}),e.jsx("span",{className:"text-sm font-medium text-slate-900",children:X()})]}),u.companyName&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("Company")}),e.jsx("span",{className:"text-sm text-slate-900",children:u.companyName})]}),u.addressLine1&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500
29w-28 flex-shrink-0",children:r("Address")}),e.jsxs("div",{className:"text-sm text-slate-900",children:[e.jsx("p",{children:u.addressLine1}),u.addressLine2&&e.jsx("p",{children:u.addressLine2})]})]}),u.city&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("City")}),e.jsx("span",{className:"text-sm text-slate-900",children:u.city})]}),u.stateProvince&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r(ol(u.countryCode))}),e.jsx("span",{className:"text-sm text-slate-900",children:u.stateProvince})]}),u.countryCode&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("Country")}),e.jsx("span",{className:"text-sm text-slate-900",children:u.countryCode})]}),u.postalCode&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("Postal Code")}),e.jsx("span",{className:"text-sm text-slate-900",children:u.postalCode})]}),(H()||ae())&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-slate-100 my-1"}),H()&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("Phone")}),e.jsx("span",{className:"text-sm text-slate-900",children:H()})]}),ae()&&e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("Email")}),e.jsx("span",{className:"text-sm text-slate-900 truncate",children:ae()})]})]}),u.deliveryInstructions&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsxs("div",{className:"flex py-2",children:[e.jsx("span",{className:"text-sm text-slate-500 w-28 flex-shrink-0",children:r("Delivery Notes")}),e.jsx("span",{className:"text-sm text-slate-900",children:u.deliveryInstructions})]})]}),e.jsx("div",{className:"pt-3",children:e.jsx(U,{variant:"outline",size:"sm",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(((O=L())==null?void 0:O.replaceAll(` 30`,", "))||"")}`,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Pr,{className:"h-4 w-4 mr-2"}),r("View on Map")]})})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-slate-500",children:[e.jsx(it,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{children:r("No shipping address available")})]})})]}),e.jsxs(V,{className:"rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsx(be,{className:"text-base font-semibold flex items-center gap-3",children:(x==null?void 0:x.shipmentMethod)==="OWN_DRIVER"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center shadow-md",children:e.jsx(jt,{className:"h-4.5 w-4.5 text-white"})}),e.jsx("span",{className:"text-slate-900",children:r("Local Delivery")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-sky-500 to-cyan-600 flex items-center justify-center shadow-md",children:e.jsx(Ue,{className:"h-4.5 w-4.5 text-white"})}),e.jsx("span",{className:"text-slate-900",children:r("Shipment Tracking")})]})})}),e.jsx(ie,{className:"pt-4",children:x?x.shipmentMethod==="OWN_DRIVER"?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"p-4 rounded-xl border border-slate-200 bg-slate-50",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(jt,{className:"h-5 w-5 text-slate-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-slate-900 mb-1",children:r("Local Delivery")}),e.jsx("p",{className:"text-sm text-slate-600",children:r("Your order is on its way with the provider's driver. No tracking link available.")})]})]})}),x.estimatedDelivery&&e.jsxs("div",{className:"p-4 rounded-xl bg-primary/5 border border-primary/20",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-primary/70 mb-1",children:r("Estimated Delivery")}),e.jsx("p",{className:"font-semibold text-primary",children:E(x.estimatedDelivery)})]}),x.customerNote&&e.jsx("div",{className:"p-4 rounded-xl bg-amber-50 border border-amber-200",children:e.jsxs("p",{className:"text-sm text-amber-800 italic",children:['"',x.customerNote,'"']})}),x.shippedAt&&e.jsxs("div",{className:"pt-3 border-t border-slate-100",children:[e.jsx("p",{className:"text-sm text-slate-500",children:r("Shipped on")}),e.jsx("p",{className:"text-slate-900",children:g(x.shippedAt)})]}),x.actualDelivery&&e.jsx("div",{className:"pt-3 border-t border-slate-100",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center rounded-md px-2.5 py-0.5 text-xs font-medium bg-green-100 text-green-800 border-0",children:r("Delivered")}),e.jsx("span",{className:"text-slate-700",children:g(x.actualDelivery)})]})})]}):e.jsxs("div",{className:"space-y-4",children:[x.carrierName&&e.jsxs("div",{className:"p-4 rounded-xl bg-slate-50 border border-slate-100",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-slate-400 mb-1",children:r("Carrier")}),e.jsx("p",{className:"font-semibold text-slate-900",children:x.carrierName})]}),x.trackingNumber&&e.jsxs("div",{className:"p-4 rounded-xl bg-slate-50 border border-slate-100",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-slate-400 mb-1",children:r("Tracking Number")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"px-2 py-1 bg-white rounded text-sm font-mono text-slate-900 border border-slate-200",children:x.trackingNumber}),e.jsx(U,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:te,children:e.jsx(Ss,{className:"h-3 w-3"})})]})]}),x.shipmentStatus&&e.jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-sky-50 to-blue-50 border border-sky-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-sky-600 font-medium",children:r("Current Status")}),x.lastStatusUpdate&&e.jsxs("span",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx($e,{className:"h-3 w-3"}),g(x.lastStatusUpdate)]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-full flex items-center justify-center shadow-md ${{DELIVERED:"bg-gradient-to-br from-green-500 to-emerald-600",OUT_FOR_DELIVERY:"bg-gradient-to-br from-blue-500 to-cyan-600",IN_TRANSIT:"bg-gradient-to-br from-purple-500 to-violet-600",PICKED_UP:"bg-gradient-to-br from-indigo-500 to-blue-600",EXCEPTION:"bg-gradient-to-br from-red-500 to-orange-600",ON_HOLD:"bg-gradient-to-br from-red-500 to-orange-600",RETURNED:"bg-gradient-to-br from-amber-500 to-yellow-600"}[x.shipmentStatus]??"bg-gradient-to-br from-slate-500 to-slate-600"}`,children:(()=>{switch(x.shipmentStatus){case"DELIVERED":return e.jsx(Nr,{className:"h-5 w-5 text-white"});case"OUT_FOR_DELIVERY":return e.jsx(Ue,{className:"h-5 w-5 text-white"});case"IN_TRANSIT":return e.jsx(xe,{className:"h-5 w-5 text-white"});case"EXCEPTION":case"ON_HOLD":return e.jsx(Qe,{className:"h-5 w-5 text-white"});default:return e.jsx(Ut,{className:"h-5 w-5 text-white"})}})()}),e.jsxs("div",{children:[e.jsx("p",{className:`font-bold text-lg ${{DELIVERED:"text-green-700",EXCEPTION:"text-red-700",ON_HOLD:"text-red-700"}[x.shipmentStatus]??"text-slate-900"}`,children:l(x.shipmentStatus)}),x.statusDescription&&e.jsx("p",{className:"text-sm text-slate-600",children:x.statusDescription})]})]})]}),x.estimatedDelivery&&e.jsxs("div",{className:"p-4 rounded-xl bg-primary/5 border border-primary/20",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-primary/70 mb-1",children:r("Estimated Delivery")}),e.jsx("p",{className:"font-semibold text-primary",children:E(x.estimatedDelivery)})]}),x.trackingNumber&&e.jsx(U,{variant:"default",size:"sm",className:"w-full bg-primary hover:bg-primary/90",asChild:!0,children:e.jsxs("a",{href:cl(x.carrierName,x.trackingNumber,x.trackingUrl||void 0),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ts,{className:"h-4 w-4 mr-2"}),r("Track Package")]})}),(x.weightKg||x.dimensions)&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[x.weightKg&&e.jsx("div",{className:"p-3 rounded-lg bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jr,{className:"h-4 w-4 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400",children:r("Weight")}),e.jsxs("p",{className:"font-medium text-slate-900",children:[x.weightKg," kg"]})]})]})}),x.dimensions&&e.jsx("div",{className:"p-3 rounded-lg bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vr,{className:"h-4 w-4 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400",children:r("Dimensions")}),e.jsx("p",{className:"font-medium text-slate-900",children:x.dimensions})]})]})})]}),x.shippedAt&&e.jsxs("div",{className:"pt-3 border-t border-slate-100",children:[e.jsx("p",{className:"text-sm text-slate-500",children:r("Shipped on")}),e.jsx("p",{className:"text-slate-900",children:g(x.shippedAt)})]}),x.actualDelivery&&e.jsx("div",{className:"pt-3 border-t border-slate-100",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center rounded-md px-2.5 py-0.5 text-xs font-medium bg-green-100 text-green-800 border-0",children:r("Delivered")}),e.jsx("span",{className:"text-slate-700",children:g(x.actualDelivery)})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-slate-500",children:[e.jsx(xe,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:r("Not shipped yet")}),e.jsxs("p",{className:"text-sm mt-1",children:[r("Status"),": ",e.jsx(me,{variant:"outline",className:"normal-case",children:r(xl(s.status))})]})]})})]})]}),e.jsx(il,{open:j,onOpenChange:p,order:s,onSuccess:()=>a==null?void 0:a()})]})}function ul({order:s}){var oe,Ne,Pe,Ie;const{locale:t}=we(),a=i=>Ce(i,t),o=i=>{if(!i)return null;let k=i;return!i.endsWith("Z")&&!i.includes("+")&&!i.includes("-",10)&&(k=i+"Z"),new Date(k).toLocaleStr
30ing("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})},h=s.status==="CANCELLED",c=s.status==="REFUNDED",r=(oe=s.statusHistory)==null?void 0:oe.find(i=>i.newStatus==="CANCELLED"),l=(Ne=s.statusHistory)==null?void 0:Ne.filter(pl).sort((i,k)=>new Date(k.createdAt).getTime()-new Date(i.createdAt).getTime())[0],x=(r==null?void 0:r.changedByType)==="ADMIN"?r:void 0,u=c&&!!x,b=Ct(r),N=s.orderType==="STORE_ORDER",j=((Pe=s.payment)==null?void 0:Pe.status)==="SUCCEEDED"||!!s.paidAt,p=yl(s.status),C=i=>{var k,T;return(T=(k=s.statusHistory)==null?void 0:k.find(Y=>Y.newStatus===i))==null?void 0:T.createdAt},d=gl(s.assignmentHistory),P=fl(s.assignmentHistory)??d,f=Nl(s.assignmentHistory),I=(P==null?void 0:P.providerName)||s.providerName||"the provider",_=(P==null?void 0:P.assignedAt)||C("AWAITING_PROVIDER_ACCEPTANCE")||C("ASSIGNED"),g=(P==null?void 0:P.acceptedAt)||C("PROVIDER_ACCEPTED_PAYMENT_PENDING")||C("ACCEPTED")||C("IN_PRODUCTION"),E=p>=2||!!_,L=jl(P)||p>=3||!!g,F=vl(f,P),te=["PAYMENT_FAILED","PAYMENT_EXPIRED","PAYMENT_UNDER_REVIEW"].includes(s.status)||["FAILED","EXPIRED","UNDER_REVIEW"].includes(((Ie=s.payment)==null?void 0:Ie.status)??""),X=F&&f?{label:"Provider Rejected",description:f.rejectionReason?`${f.providerName} declined this order: ${f.rejectionReason}`:`${f.providerName} declined this order`,date:f.rejectedAt??void 0,completed:!0,icon:as,color:"from-rose-500 to-red-600",actor:"Action by provider"}:null,H=[{label:"Provider Assigned",description:E?`Assigned to ${I} for fulfillment`:"Awaiting provider assignment",date:_,completed:E,icon:es,color:"from-indigo-500 to-violet-600"},...X?[X]:[],{label:"Provider Accepted",description:L?`${I} accepted this order`:"The assigned provider is reviewing this order",date:g,completed:L,icon:bt,color:"from-teal-500 to-emerald-600"}],ae=[{label:"Order Placed",description:"Your order has been received",date:s.createdAt,completed:!0,icon:nt,color:"from-blue-500 to-indigo-600"},{label:"Payment Confirmed",description:"Payment successfully processed",date:s.paidAt,completed:!!s.paidAt,icon:os,color:"from-emerald-500 to-green-600"},...H,{label:"Processing",description:"Your order is being prepared",date:C("IN_PRODUCTION")||(s.status==="IN_PRODUCTION"?g:void 0),completed:p>=4,icon:es,color:"from-amber-500 to-orange-600"},{label:"Quality Check",description:"Order passed quality inspection",date:C("QUALITY_CHECK"),completed:p>=5,icon:gt,color:"from-cyan-500 to-blue-600"},{label:"Ready to Ship",description:"Order is packed and ready for shipping",date:C("READY_TO_SHIP"),completed:p>=6,icon:ft,color:"from-purple-500 to-violet-600"},{label:"Shipped",description:s.shipment?`Shipped via ${s.shipment.carrierName||"carrier"}`:"Order is on its way",date:s.shippedAt,completed:!!s.shippedAt,icon:Ue,color:"from-sky-500 to-cyan-600"},{label:"Delivered",description:"Order has been delivered",date:s.deliveredAt,completed:!!s.deliveredAt,icon:xe,color:"from-green-500 to-emerald-600"}],w=L?"Provider Accepted":E?"Provider Acceptance Pending":"Provider Assignment Pending",q=L?"The provider accepted this order":E?"The assigned provider is reviewing this order":"Awaiting provider assignment",ce=j?"Payment Confirmed":te?"Merchant Payment Needs Attention":"Merchant Payment Pending",y=j?"Merchant payment has been processed":te?"Merchant payment must be resolved before production starts":"Merchant card is charged only after provider acceptance",M=[{label:"Order Received",description:"Your store order has been received",date:s.createdAt,completed:!0,icon:nt,color:"from-blue-500 to-indigo-600"},{label:w,description:q,date:L?g:_,completed:L,icon:es,color:"from-indigo-500 to-violet-600"},{label:ce,description:y,date:s.paidAt||g,completed:j,icon:os,color:"from-emerald-500 to-green-600"},{label:"Processing",description:"Your order is being prepared",date:C("IN_PRODUCTION"),completed:p>3,icon:es,color:"from-amber-500 to-orange-600"},{label:"Quality Check",description:"Order passed quality inspection",date:C("QUALITY_CHECK"),completed:p>4,icon:gt,color:"from-cyan-500 to-blue-600"},{label:"Ready to Ship",description:"Order is packed and ready for shipping",date:C("READY_TO_SHIP"),completed:p>5,icon:ft,color:"from-purple-500 to-violet-600"}
30,{label:"Shipped",description:s.shipment?`Shipped via ${s.shipment.carrierName||"carrier"}`:"Order is on its way",date:s.shippedAt,completed:!!s.shippedAt,icon:Ue,color:"from-sky-500 to-cyan-600"},{label:"Delivered",description:"Order has been delivered",date:s.deliveredAt,completed:!!s.deliveredAt,icon:xe,color:"from-green-500 to-emerald-600"}];let B=N?M:ae;!h&&!c&&l&&(B=[B[0],B[1],{label:"Store cancellation rejected",description:"Production had already started, so the order will continue to fulfilment",date:l.createdAt,completed:!0,icon:as,color:"from-amber-500 to-orange-600",actor:Ct(l)},...B.slice(2)]);const ge=c?"Order cancelled â refund issued":"Order has been cancelled";(h||c)&&(B=[B[0],B[1],{label:x?"Cancelled by admin":"Cancelled",description:u?"Order cancelled by admin â refund issued":ge,date:(x==null?void 0:x.createdAt)||s.cancelledAt||s.updatedAt,completed:!0,icon:as,color:"from-rose-500 to-red-600",actor:b}],c&&B.push({label:"Refunded",description:"Refund completed",date:s.updatedAt,completed:!0,icon:yr,color:"from-emerald-500 to-green-600"}));const fe=B.findIndex(i=>!i.completed),J=fe===-1?B.length-1:fe;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(V,{className:"rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsxs(be,{className:"text-lg flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gradient-to-br from-violet-500 to-purple-600 flex items-center justify-center shadow-lg shadow-violet-500/30",children:e.jsx($e,{className:"h-5 w-5 text-white"})}),e.jsx("span",{className:"font-semibold text-slate-900",children:a("Order Timeline")})]})}),e.jsxs(ie,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"hidden md:block mb-12",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute top-5 left-0 right-0 h-1 bg-slate-200 rounded-full"}),e.jsx("div",{className:"absolute top-5 left-0 h-1 bg-gradient-to-r from-primary to-emerald-500 rounded-full transition-all duration-500",style:{width:`${Math.max(0,J/(B.length-1)*100)}%`}}),e.jsx("div",{className:"relative flex justify-between",children:B.map((i,k)=>{const T=i.icon,Y=k===J,ee=i.completed;let ye="text-slate-400";ee?ye="text-white":Y&&(ye="text-primary");let Se="text-slate-400";return ee?Se="text-slate-900":Y&&(Se="text-primary"),e.jsxs("div",{className:"flex flex-col items-center",style:{width:`${100/B.length}%`},children:[e.jsx("div",{className:`relative z-10 flex-shrink-0 h-10 w-10 rounded-full flex items-center justify-center shadow-lg transition-all duration-300 ${ee?`bg-gradient-to-br ${i.color}`:Y?"bg-white border-2 border-primary":"bg-slate-100 border-2 border-slate-200"}`,children:e.jsx(T,{className:`h-5 w-5 ${ye}`})}),e.jsx("p",{className:`mt-3 text-xs font-medium text-center px-1 ${Se}`,children:a(i.label)})]},i.label)})})]})}),e.jsxs("div",{className:"relative pl-2",children:[e.jsx("div",{className:"absolute left-[18px] top-0 bottom-0 w-0.5 bg-gradient-to-b from-primary via-primary/50 to-slate-200"}),e.jsx("div",{className:"space-y-8",children:B.map((i,k)=>{const T=i.icon,Y=k===J,ee=i.completed;let ye="text-slate-400";return ee?ye="text-white":Y&&(ye="text-primary"),e.jsxs("div",{className:"relative flex items-start gap-5 pl-1",children:[e.jsx("div",{className:`relative z-10 flex-shrink-0 h-9 w-9 rounded-full flex items-center justify-center shadow-md transition-all duration-300 ${ee?`bg-gradient-to-br ${i.color}`:Y?"bg-white border-2 border-primary ring-4 ring-primary/20":"bg-slate-100 border-2 border-slate-200"}`,children:e.jsx(T,{className:`h-4 w-4 ${ye}`})}),e.jsxs("div",{className:`flex-1 pb-2 ${!ee&&!Y&&"opacity-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:`font-semibold ${ee?"text-slate-900":Y?"text-primary":"text-slate-400"}`,children:a(i.label)}),Y&&!ee&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-primary/10 text-primary",children:a("Current")})]}),ee&&e.jsx(bt,{className:"h-5 w-5 text-primary"})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:a(i.description)}),i.actor&&e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-medium",children:a(i.actor)}),i.date&&e.jsx("p",{className:"text-xs text-slate-400 mt-1.5 font-medium bg-slate-50 inline-block px-2 py-1 rounded",children:o(i.date)}),!i.date&&!ee&&e.jsx("p",{className:"text-xs text-slate-400 mt-1.5",children:a("Pending")})]})]},i.label)})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(V,{className:"rounded-xl border border-slate-200/50 bg-white/80 p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-slate-400 mb-1",children:a("Order Number")}),e.jsx("p",{className:"font-semibold text-slate-900",children:s.orderNumber})]}),e.jsxs(V,{className:"rounded-xl border border-slate-200/50 bg-white/80 p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-slate-400 mb-1",children:a("Current Status")}),e.jsx("p",{className:"font-semibold text-primary",children:a(u?"Cancelled by admin - refunded":bl(s.status))})]}),s.providerName&&e.jsxs(V,{className:"rounded-xl border border-slate-200/50 bg-white/80 p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-slate-400 mb-1",children:a("Fulfilled By")}),e.jsx("p",{className:"font-semibold text-slate-900",children:s.providerName})]})]})]})}function Ct(s){var a;if(!s)return;const t=(a=s.changedByName)==null?void 0:a.trim();return s.changedByType==="ADMIN"?t&&t!=="Admin"?`Action by admin: ${t}`:"Action by admin":s.changedByType==="CUSTOMER"?"Action by customer":s.changedByType==="SYSTEM"?t?`Action by ${t}`:"Action by system":s.changedByType==="PROVIDER"?t?`Action by provider: ${t}`:"Action by provider":s.changedByType==="STORE"?t?`Action by store: ${t}`:"Action by store":t?`Action by ${t}`:void 0}function pl(s){var o,h;const t=((o=s.reason)==null?void 0:o.toLowerCase())??"",a=((h=s.changedByName)==null?void 0:h.toLowerCase())??"";return t.startsWith("store cancellation rejected")||s.previousStatus===s.newStatus&&a.includes("store")&&t.includes("production already started")}function bl(s){var t;return((t=He[s])==null?void 0:t.label)||s.replaceAll("_"," ").toLowerCase().replaceAll(/\b\w/g,a=>a.toUpperCase())}function gl(s){return s==null?void 0:s.toSorted((t,a)=>ze(a)-ze(t))[0]}function fl(s){return s==null?void 0:s.filter(t=>t.isActive).toSorted((t,a)=>ze(a)-ze(t))[0]}function Nl(s){return s==null?void 0:s.filter(t=>!!t.rejectedAt).toSorted((t,a)=>ze(a)-ze(t))[0]}function ze(s){return new Date(s.acceptedAt||s.rejectedAt||s.assignedAt).getTime()}function jl(s){return!!(s!=null&&s.acceptedAt)||(s==null?void 0:s.status)==="ACCEPTED"}function vl(s,t){return s!=null&&s.rejectedAt?t!=null&&t.assignedAt?new Date(s.rejectedAt).getTime()>
30new Date(t.assignedAt).getTime():!0:!1}function yl(s){return{PENDING_PAYMENT:0,PAYMENT_FAILED:0,PAYMENT_EXPIRED:0,PAYMENT_UNDER_REVIEW:0,PAID:1,PROCESSING:1,PENDING_SHIPPING_INFO:1,PENDING_ASSIGNMENT:1,ASSIGNED:2,AWAITING_PROVIDER_ACCEPTANCE:2,PROVIDER_ACCEPTED_PAYMENT_PENDING:3,ACCEPTED:3,IN_PRODUCTION:4,QUALITY_CHECK:5,READY_TO_SHIP:6,DELIVERY_FAILED_REFUND_PENDING:6,SHIPPED:7,DELIVERED:8}[s]??0}function ms(s){return s==="PENDING"||s==="PREPARING"||s==="RETRY"}function qt(s=[],t=[]){return s.some(a=>ms(a.mockupFinalizationStatus))||t.some(a=>ms(a.mockupFinalizationStatus))}function Pt(s){return!s.mockupImages||s.mockupImages.length===0}function wl(s,t){return s<=1?"default":t?"grabbing":"grab"}const kt=["XXS","XS","S","M","L","XL","XXL","2XL","3XL","4XL","5XL"];function Yt(s){return[...s].sort((t,a)=>{const o=kt.indexOf(t.toUpperCase()),h=kt.indexOf(a.toUpperCase());return o===-1&&h===-1?t.localeCompare(a):o===-1?1:h===-1?-1:o-h})}function Cl(s){var t;return s.customerUploaded===!0||s.source==="CUSTOMER_UPLOADED"||!!s.customMockupId||!!((t=s.mockupKey)!=null&&t.startsWith("custom:"))}function Pl(s){const t=new Map;for(const a of s){if(!a.mockupImages||a.mockupImages.length===0)continue;const o=a.productName||"",h=a.colorName||"",c=`${o}::${h}`;let r=t.get(c);r||(r={key:c,productName:o,colorName:h,colorHex:a.colorHex||void 0,sizes:[],mockupImages:[]},t.set(c,r)),a.size&&!r.sizes.includes(a.size)&&r.sizes.push(a.size);for(const l of a.mockupImages)r.mockupImages.some(x=>x.mockupUrl===l.mockupUrl)||r.mockupImages.push(l)}return Array.from(t.values()).map(a=>({...a,sizes:Yt(a.sizes)}))}function kl(s){const t=new Map;for(const a of s){if(a.designSnapshotFailed)continue;const o=(a.printAreas||[]).filter(x=>!!x.thumbnailUrl);if(o.length===0)continue;const h=a.productName||"",c=a.colorName||"",r=`${h}::${c}`;let l=t.get(r);l||(l={key:r,productName:h,colorName:c,colorHex:a.colorHex||void 0,sizes:[],previews:[]},t.set(r,l)),a.size&&!l.sizes.includes(a.size)&&l.sizes.push(a.size);for(const x of o)l.previews.some(u=>u.thumbnailUrl===x.thumbnailUrl)||l.previews.push({areaName:x.areaName,thumbnailUrl:x.thumbnailUrl})}return Array.from(t.values()).map(a=>({...a,sizes:Yt(a.sizes)}))}function Le({kind:s,itemCount:t,translate:a}){const o=s==="failed",h=o?Xe:$e,c=o?"We could not generate the mockup preview for this order. Your order and production files are not affected â our team has been notified and will restore the preview.":t===1?"One item's design preview is being generated. This can take a few minutes â your order is not delayed.":`${t} items' design previews are being generated. This can take a few minutes â your order is not delayed.`;return e.jsxs("div",{className:o?"rounded-xl border border-amber-200 bg-amber-50 p-5 flex gap-4 items-start":"rounded-xl border border-slate-200 bg-slate-50 p-5 flex gap-4 items-start",role:o?"alert":"status",children:[e.jsx("div",{className:o?"h-10 w-10 rounded-lg bg-white border border-amber-200 flex items-center justify-center flex-shrink-0 shadow-sm":"h-10 w-10 rounded-lg bg-white border border-slate-200 flex items-center justify-center flex-shrink-0 shadow-sm",children:e.jsx(h,{className:o?"h-5 w-5 text-amber-500":"h-5 w-5 text-slate-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:o?"font-medium text-amber-900 text-sm":"font-medium text-slate-800 text-sm",children:a(o?"Mockup preview unavailable":"Preparing your design preview")}),e.jsx("p",{className:o?"text-sm text-amber-800 mt-0.5":"text-sm text-slate-500 mt-0.5",children:a(c)})]})]})}const El=({order:s})=>{var J,oe,Ne,Pe,Ie;const{locale:t}=we(),a=i=>Ce(i,t),[o,h]=v.useState(!1),[c,r]=v.useState([]),[l,x]=v.useState(0),[u,b]=v.useState(1),[N,j]=v.useState({x:0,y:0}),[p,C]=v.useState(!1),d=v.useRef({x:0,y:0}),P=v.useRef({x:0,y:0}),f=(J=s.items)==null?void 0:J.some(i=>i.mockupImages&&i.mockupImages.length>0),I=((oe=s.items)==null?void 0:oe.some(i=>i.isPersonalized===!0))??!1,_=(s.items||[]).filter(i=>i.designSnapshotFailed===!0&&(!i.mockupImages||i.mockupImages.length===0)),g=qt(s.items||[],s.brandingItems||[]),E=[...s.items||[],...s.brandingItems||[]],L=E.filter(i=>Pt(i)&&ms(i.mockupFinalizationStatus)),F=E.filter(i=>Pt(i)&&i.mockupFinalizationStatus==="FAILED"),te=Pl(s.items||[]),X=kl(s.items||[]),H=X.some(i=>i.previews.length>0),ae=I&&!f&&H,O=[],w=new Set;if(s.orderType==="CUSTOMIZE_YOURSELF")for(const i of s.items||[])!i.isPersonalized&&i.designThumbnailUrl&&ms(i.mockupFinalizationStatus)&&!w.has(i.designThumbnailUrl)&&(w.add(i.designThumbnailUrl),O.push({url:i.designThumbnailUrl,alt:`${i.productName} - ${i.colorName}`}));const z=I?{title:"Personalized Design Previews",description:"These previews show the buyer-personalized print areas for this order"}:{title:"Product Mockups",description:"These mockup images show how the product looked when the order was placed"},q=v.useCallback((i,k)=>{r(i),x(k),b(1),j({x:0,y:0}),h(!0)},[]),re=v.useCallback(()=>{h(!1),r([]),x(0),b(1),j({x:0,y:0})},[]),ce=v.useCallback(()=>{x(i=>i>0?i-1:c.length-1),b(1),j({x:0,y:0})},[c.length]),ve=v.useCallback(()=>{x(i=>i<c.length-1?i+1:0),b(1),j({x:0,y:0})},[c.length]),y=v.useCallback(()=>{b(i=>Math.min(i+.5,3))},[]),M=v.useCallback(()=>{b(i=>{const k=Math.max(i-.5,1);return k===1&&j({x:0,y:0}),k})},[]);v.useEffect(()=>{if(!o)return;const i=k=>{switch(k.key){case"Escape":re();break;case"ArrowLeft":ce();break;case"ArrowRight":ve();break;case"+":case"=":y();break;case"-":M();break}};return globalThis.addEventListener("keydown",i),()=>globalThis.removeEventListener("keydown",i)},[o,re,ce,ve,y,M]);const B=v.useCallback(i=>{u>1&&(C(!0),d.current={x:i.clientX,y:i.clientY},P.current={...N})},[u,N]),ge=v.useCallback(i=>{if(p&&u>1){const k=i.clientX-d.current.x,T=i.clientY-d.current.y;j({x:P.current.x+k,y:P.current.y+T})}},[p,u]),fe=v.useCallback(()=>{C(!1)},[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(V,{className:"rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsxs(be,{className:"text-base flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-purple-500 to-purple-700 flex items-center justify-center shadow-md",children:e.jsx(Be,{className:"h-4.5 w-4.5 text-white"})}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-900",children:a(z.title)}),e.jsx("p",{className:"text-xs text-slate-500 font-normal mt-0.5",children:a(z.description)})]})]})}),e.jsx(ie,{className:"pt-6",children:f?e.jsxs("div",{className:"space-y-8",children:[te.map(i=>{const k=i.mockupImages.map(T=>({url:T.mockupUrl,alt:`${i.productName} - ${T.templateName||"Mockup"}`,templateName:T.templateName}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-slate-100 flex items-center justify-center",children:e.jsx(xe,{className:"h-5 w-5 text-slate-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-slate-900",children:i.productName}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 flex-wrap",children:[e.jsx("div",{className:"h-3 w-3 rounded-full border border-slate-300",style:{backgroundColor:i.colorHex||"#ccc"}}),e.jsx("span",{children:i.colorName}),e.jsx("span",{children:"â¢"}),e.jsx("div",{className:"flex items-center gap-1",children:i.sizes.map(T=>e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-slate-100 text-slate-700 text-xs font-medium",children:T},T))})]})]})]}),e.jsx(me,{variant:"secondary",className:"text-xs",children:a(`${i.mockupImages.length} ${I?"preview":"mockup"}${i.mockupImages.length===1?"":"s"}`)})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
30p-4",children:i.mockupImages.map((T,Y)=>e.jsxs("div",{role:"button",tabIndex:0,className:"group relative aspect-square rounded-xl overflow-hidden bg-slate-100 cursor-pointer shadow-sm hover:shadow-md transition-all duration-200",onClick:()=>q(k,Y),onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&q(k,Y)},children:[e.jsx("img",{src:T.mockupUrl,alt:T.templateName||`Mockup ${Y+1}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",loading:"lazy"}),Cl(T)&&e.jsx(me,{className:"absolute left-2 top-2 border border-emerald-200 bg-emerald-50 text-emerald-700 shadow-sm",children:"Customer uploaded"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors duration-200 flex items-center justify-center",children:e.jsx(We,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity duration-200"})}),T.templateName&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/60 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:e.jsx("p",{className:"text-xs text-white truncate",children:T.templateName})})]},`${i.key}-mockup-${Y}`))})]},i.key)}),_.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-slate-50 p-5 flex gap-4 items-start",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-white border border-slate-200 flex items-center justify-center flex-shrink-0 shadow-sm",children:e.jsx($e,{className:"h-5 w-5 text-slate-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-800 text-sm",children:a("Preparing your design preview")}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:a(_.length===1?"One item's design preview is being generated. This can take a few minutes â your order is not delayed.":`${_.length} items' design previews are being generated. This can take a few minutes â your order is not delayed.`)})]})]}),F.length>0&&e.jsx(Le,{kind:"failed",itemCount:F.length,translate:a}),L.length>0&&e.jsx(Le,{kind:"in-flight",itemCount:L.length,translate:a})]}):ae?e.jsxs("div",{className:"space-y-8",children:[X.map(i=>{const k=i.previews.map(T=>({url:T.thumbnailUrl,alt:`${i.productName} - ${T.areaName}`,templateName:T.areaName}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-slate-100 flex items-center justify-center",children:e.jsx(xe,{className:"h-5 w-5 text-slate-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-slate-900",children:i.productName}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 flex-wrap",children:[e.jsx("div",{className:"h-3 w-3 rounded-full border border-slate-300",style:{backgroundColor:i.colorHex||"#ccc"}}),e.jsx("span",{children:i.colorName}),e.jsx("span",{children:"â¢"}),e.jsx("div",{className:"flex items-center gap-1",children:i.sizes.map(T=>e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-slate-100 text-slate-700 text-xs font-medium",children:T},T))})]})]})]}),e.jsx(me,{variant:"secondary",className:"text-xs",children:a(`${i.previews.length} preview${i.previews.length===1?"":"s"}`)})]}),e.jsx("div",{className:"rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:a("Product mockups are still being generated for this order copy, so we are showing the captured personalized print-area previews.")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:i.previews.map((T,Y)=>e.jsxs("div",{role:"button",tabIndex:0,className:"group relative aspect-square rounded-xl overflow-hidden bg-slate-50 border border-slate-200 cursor-pointer shadow-sm hover:shadow-md transition-all duration-200",onClick:()=>q(k,Y),onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&q(k,Y)},children:[e.jsx("img",{src:T.thumbnailUrl,alt:T.areaName,className:"w-full h-full object-contain p-3 group-hover:scale-105 transition-transform duration-300",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/15 transition-colors duration-200 flex items-center justify-center",children:e.jsx(We,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity duration-200"})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-white/90 border-t border-slate-200 p-2",children:e.jsx("p",{className:"text-xs text-slate-700 truncate",children:T.areaName})})]},`${i.key}-print-area-${T.areaName}-${Y}`))})]},i.key)}),F.length>0&&e.jsx(Le,{kind:"failed",itemCount:F.length,translate:a}),L.length>0&&e.jsx(Le,{kind:"in-flight",itemCount:L.length,translate:a})]}):O.length>0?e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-slate-500",children:a("Your saved design preview is shown while the product mockups are being prepared.")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
30p-4",children:O.map((i,k)=>e.jsx("button",{type:"button","aria-label":`${a("View saved design preview")}: ${i.alt}`,className:"aspect-square rounded-xl overflow-hidden bg-slate-100 shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>q(O,k),children:e.jsx("img",{src:i.url,alt:i.alt,className:"w-full h-full object-contain"})},i.url))}),e.jsx(Le,{kind:"in-flight",itemCount:L.length,translate:a}),F.length>0&&e.jsx(Le,{kind:"failed",itemCount:F.length,translate:a})]}):F.length>0?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("div",{className:"h-16 w-16 mx-auto rounded-full bg-amber-50 border border-amber-200 flex items-center justify-center mb-4",children:e.jsx(Xe,{className:"h-8 w-8 text-amber-500"})}),e.jsx("h3",{className:"text-lg font-medium text-slate-900 mb-2",children:a("Mockup preview unavailable")}),e.jsx("p",{className:"text-sm text-slate-500 max-w-sm mx-auto",children:a("We could not generate the mockup preview for this order. Your order and production files are not affected â our team has been notified and will restore the preview.")})]}):_.length>0||g?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("div",{className:"h-16 w-16 mx-auto rounded-full bg-slate-100 border border-slate-200 flex items-center justify-center mb-4",children:e.jsx($e,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h3",{className:"text-lg font-medium text-slate-900 mb-2",children:a("Preparing your design preview")}),e.jsx("p",{className:"text-sm text-slate-500 max-w-sm mx-auto",children:a("Your design preview is being generated. This can take a few minutes â your order is not delayed.")})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"h-16 w-16 mx-auto rounded-full bg-slate-100 flex items-center justify-center mb-4",children:e.jsx(Be,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h3",{className:"text-lg font-medium text-slate-900 mb-2",children:a("No Mockup Images Available")}),e.jsx("p",{className:"text-sm text-slate-500 max-w-md mx-auto",children:a("Mockup images are captured when orders are placed through connected stores. This order may not have associated mockups.")})]})})]}),o&&c.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",role:"presentation",onClick:re,onKeyDown:i=>{i.key==="Escape"&&re()},children:[e.jsx("button",{type:"button",className:"absolute top-4 right-4 z-50 h-10 w-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",onClick:re,children:e.jsx(Dt,{className:"h-6 w-6 text-white"})}),c.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"absolute left-4 top-1/2 -translate-y-1/2 z-50 h-12 w-12 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",onClick:i=>{i.stopPropagation(),ce()},children:e.jsx(Bt,{className:"h-8 w-8 text-white"})}),e.jsx("button",{type:"button",className:"absolute right-4 top-1/2 -translate-y-1/2 z-50 h-12 w-12 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",onClick:i=>{i.stopPropagation(),ve()},children:e.jsx(Rt,{className:"h-8 w-8 text-white"})})]}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 bg-black/50 rounded-full px-4 py-2",children:[e.jsx("button",{type:"button",className:"h-8 w-8 rounded-full hover:bg-white/10 flex items-center justify-center transition-colors disabled:opacity-50",onClick:i=>{i.stopPropagation(),M()},disabled:u<=1,children:e.jsx(Mt,{className:"h-5 w-5 text-white"})}),e.jsxs("span",{className:"text-white text-sm min-w-[3rem] text-center",children:[Math.round(u*100),"%"]}),e.jsx("button",{type:"button",className:"h-8 w-8 rounded-full hover:bg-white/10 flex items-center justify-center transition-colors disabled:opacity-50",onClick:i=>{i.stopPropagation(),y()},disabled:u>=3,children:e.jsx(We,{className:"h-5 w-5 text-white"})})]}),c.length>1&&e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 rounded-full px-4 py-1",children:[l+1," / ",c.length]}),e.jsx("div",{role:"presentation",className:"relative max-w-[90vw] max-h-[85vh] overflow-hidden",onClick:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),onMouseDown:B,onMouseMove:ge,onMouseUp:fe,onMouseLeave:fe,style:{cursor:wl(u,p)},children:e.jsx("img",{src:(Ne=c[l])==null?void 0:Ne.url,alt:(Pe=c[l])==null?void 0:Pe.alt,className:"max-w-full max-h-[85vh] object-contain select-none",style:{transform:`scale(${u}) translate(${N.x/u}px, ${N.y/u}px)`,transition:p?"none":"transform 0.2s ease-out"},draggable:!1})}),((Ie=c[l])==null?void 0:Ie.templateName)&&e.jsx("div",{className:"absolute bottom-16 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 rounded-lg px-4 py-2",children:c[l].templateName}),c.length>1&&e.jsx("div",{className:"absolute bottom-20 left-1/2 -translate-x-1/2 z-50 flex gap-2 max-w-[80vw] overflow-x-auto p-2 bg-black/30 rounded-lg",children:c.map((i,k)=>e.jsx("button",{type:"button",className:`flex-shrink-0 w-16 h-16 rounded-lg overflow-hidden border-2 transition-all ${k===l?"border-white scale-110":"border-transparent opacity-60 hover:opacity-100"}`,onClick:T=>{T.stopPropagation(),x(k),b(1),j({x:0,y:0})},children:e.jsx("img",{src:i.url,alt:i.alt,className:"w-full h-full object-cover"})},k))})]})]})};function Il(s,t){return s<=1?"default":t?"grabbing":"grab"}const Tl=s=>!!s.storageUrl,Dl=({order:s})=>{var re,ce,ve;const{locale:t}=we(),a=y=>Ce(y,t),[o,h]=v.useState(!1),[c,r]=v.useState([]),[l,x]=v.useState(0),[u,b]=v.useState(1),[N,j]=v.useState({x:0,y:0}),[p,C]=v.useState(!1),d=v.useRef({x:0,y:0}),P=v.useRef({x:0,y:0}),I=(s.qualityCheckProofs||[]).filter(Tl),_=I.filter(y=>y.imageType==="PRODUCT"),g=I.filter(y=>y.imageType==="PACKAGING"),E=I.length>0,L=v.useCallback((y,M)=>{r(y),x(M),b(1),j({x:0,y:0}),h(!0)},[]),F=v.useCallback(()=>{h(!1),r([]),x(0),b(1),j({x:0,y:0})},[]),te=v.useCallback(()=>{x(y=>y>0?y-1:c.length-1),b(1),j({x:0,y:0})},[c.length]),X=v.useCallback(()=>{x(y=>y<c.length-1?y+1:0),b(1),j({x:0,y:0})},[c.length]),H=v.useCallback(()=>{b(y=>Math.min(y+.5,3))},[]),ae=v.useCallback(()=>{b(y=>{const M=Math.max(y-.5,1);return M===1&&j({x:0,y:0}),M})},[]);v.useEffect(()=>{if(!o)return;const y=M=>{switch(M.key){case"Escape":F();break;case"ArrowLeft":te();break;case"ArrowRight":X();break;case"+":case"=":H();break;case"-":ae();break}};return globalThis.addEventListener("keydown",y),()=>globalThis.removeEventListener("keydown",y)},[o,F,te,X,H,ae]);const O=v.useCallback(y=>{u>1&&(C(!0),d.current={x:y.clientX,y:y.clientY},P.current={...N})},[u,N]),w=v.useCallback(y=>{if(p&&u>1){const M=y.clientX-d.current.x,B=y.clientY-d.current.y;j({x:P.current.x+M,y:P.current.y+B})}},[p,u]),z=v.useCallback(()=>{C(!1)},[]),q=(y,M,B)=>
30{if(M.length===0)return null;const ge=a(y),fe=M.map(J=>({url:J.storageUrl,alt:`${ge} - ${J.fileName}`,fileName:J.fileName}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-[#15B67F]/10 flex items-center justify-center",children:B==="product"?e.jsx(rs,{className:"h-5 w-5 text-[#15B67F]"}):e.jsx(xe,{className:"h-5 w-5 text-[#15B67F]"})}),e.jsx("div",{children:e.jsx("h4",{className:"font-medium text-slate-900",children:ge})})]}),e.jsxs(me,{variant:"secondary",className:"text-xs",children:[M.length," photo",M.length===1?"":"s"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:M.map((J,oe)=>e.jsxs("div",{role:"button",tabIndex:0,className:"group relative aspect-square rounded-[14px] overflow-hidden bg-slate-100 cursor-pointer shadow-sm hover:shadow-md transition-all duration-200",onClick:()=>L(fe,oe),onKeyDown:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&L(fe,oe)},children:[e.jsx("img",{src:J.storageUrl,alt:J.fileName||`${y} ${oe+1}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors duration-200 flex items-center justify-center",children:e.jsx(We,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity duration-200"})}),J.fileName&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/60 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:e.jsx("p",{className:"text-xs text-white truncate",children:J.fileName})})]},`${B}-${J.id}`))})]})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(V,{className:"rounded-[28px] border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsxs(be,{className:"text-base flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-[#15B67F] flex items-center justify-center shadow-md",children:e.jsx(rs,{className:"h-4.5 w-4.5 text-white"})}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-900",children:a("Final Product")}),e.jsx("p",{className:"text-xs text-slate-500 font-normal mt-0.5",children:a("Photos of your finished product and packaging from the provider")})]})]})}),e.jsx(ie,{className:"pt-6",children:E?e.jsxs("div",{className:"space-y-8",children:[q("Product Photos",_,"product"),q("Packaging Photos",g,"packaging")]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"h-16 w-16 mx-auto rounded-full bg-slate-100 flex items-center justify-center mb-4",children:e.jsx(rs,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h3",{className:"text-lg font-medium text-slate-900 mb-2",children:a("No Final Product Photos Yet")}),e.jsx("p",{className:"text-sm text-slate-500 max-w-md mx-auto",children:a("Final product photos will be available once your order passes quality check.")})]})})]}),o&&c.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",role:"presentation",onClick:F,onKeyDown:y=>{y.key==="Escape"&&F()},children:[e.jsx("button",{type:"button",className:"absolute top-4 right-4 z-50 h-10 w-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",onClick:F,children:e.jsx(Dt,{className:"h-6 w-6 text-white"})}),c.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"absolute left-4 top-1/2 -translate-y-1/2 z-50 h-12 w-12 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",onClick:y=>{y.stopPropagation(),te()},children:e.jsx(Bt,{className:"h-8 w-8 text-white"})}),e.jsx("button",{type:"button",className:"absolute right-4 top-1/2 -translate-y-1/2 z-50 h-12 w-12 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",onClick:y=>{y.stopPropagation(),X()},children:e.jsx(Rt,{className:"h-8 w-8 text-white"})})]}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 bg-black/50 rounded-full px-4 py-2",children:[e.jsx("button",{type:"button",className:"h-8 w-8 rounded-full hover:bg-white/10 flex items-center justify-center transition-colors disabled:opacity-50",onClick:y=>{y.stopPropagation(),ae()},disabled:u<=1,children:e.jsx(Mt,{className:"h-5 w-5 text-white"})}),e.jsxs("span",{className:"text-white text-sm min-w-[3rem] text-center",children:[Math.round(u*100),"%"]}),e.jsx("button",{type:"button",className:"h-8 w-8 rounded-full hover:bg-white/10 flex items-center justify-center transition-colors disabled:opacity-50",onClick:y=>{y.stopPropagation(),H()},disabled:u>=3,children:e.jsx(We,{className:"h-5 w-5 text-white"})})]}),c.length>1&&e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 rounded-full px-4 py-1",children:[l+1," / ",c.length]}),e.jsx("div",{role:"presentation",className:"relative max-w-[90vw] max-h-[85vh] overflow-hidden",onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),onMouseDown:O,onMouseMove:w,onMouseUp:z,onMouseLeave:z,style:{cursor:
30Il(u,p)},children:e.jsx("img",{src:(re=c[l])==null?void 0:re.url,alt:(ce=c[l])==null?void 0:ce.alt,className:"max-w-full max-h-[85vh] object-contain select-none",style:{transform:`scale(${u}) translate(${N.x/u}px, ${N.y/u}px)`,transition:p?"none":"transform 0.2s ease-out"},draggable:!1})}),((ve=c[l])==null?void 0:ve.fileName)&&e.jsx("div",{className:"absolute bottom-16 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 rounded-lg px-4 py-2",children:c[l].fileName}),c.length>1&&e.jsx("div",{className:"absolute bottom-20 left-1/2 -translate-x-1/2 z-50 flex gap-2 max-w-[80vw] overflow-x-auto p-2 bg-black/30 rounded-lg",children:c.map((y,M)=>e.jsx("button",{type:"button",className:`flex-shrink-0 w-16 h-16 rounded-lg overflow-hidden border-2 transition-all ${M===l?"border-white scale-110":"border-transparent opacity-60 hover:opacity-100"}`,onClick:B=>{B.stopPropagation(),x(M),b(1),j({x:0,y:0})},children:e.jsx("img",{src:y.url,alt:y.alt,className:"w-full h-full object-cover"})},M))})]})]})};function Rl(s,t){const a=Sl(s,t);return!s||!a?s:{...s,items:Al(s.items,a.items),brandingItems:Fl(s.brandingItems,a.brandingItems)}}function Sl(s,t){return(s==null?void 0:s.orderType)!=="STORE_ORDER"||(t==null?void 0:t.orderType)!=="STORE_ORDER"||t.orderId!==s.orderId?null:t}function Al(s,t){const a=new Map(t.map(o=>[o.itemId,o]));return s.map(o=>({...o,...a.get(o.itemId)}))}function Fl(s,t){const a=new Map((t??[]).map(o=>[o.brandingItemId,o]));return s==null?void 0:s.map(o=>({...o,...a.get(o.brandingItemId)}))}const _l=Oe.lazy(()=>Fa(()=>import("./ReturnRequestDialog-BmdakniR.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32])).then(s=>({default:s.ReturnRequestDialog}
30)));function Ll(s,t){return s&&t?"grid-cols-6":s||t?"grid-cols-5":"grid-cols-4"}const Ol=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{className:"h-8 w-48"}),e.jsx($,{className:"h-4 w-32"})]}),e.jsx($,{className:"h-8 w-28 rounded-full"})]}),e.jsx("div",{className:"flex gap-2 mb-6",children:Array.from({length:3}).map((s,t)=>e.jsx($,{className:"h-10 w-32 rounded-md"},`skeleton-${t}`))}),e.jsxs(V,{className:"rounded-[14px]",children:[e.jsx(ne,{children:e.jsx($,{className:"h-6 w-24"})}),e.jsx(ie,{className:"space-y-4",children:Array.from({length:2}).map((s,t)=>e.jsxs("div",{className:"flex gap-4",children:[e.jsx($,{className:"h-20 w-20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx($,{className:"h-5 w-48"}),e.jsx($,{className:"h-4 w-32"}),e.jsx($,{className:"h-4 w-24"})]})]},`skeleton-${t}`))})]})]});function Ml(s){return s.replaceAll("_"," ").toLowerCase().replaceAll(/\b\w/g,t=>t.toUpperCase())}function Bl(s){return s.deliveryMode==="SHIP_FROM_HUB"||s.orderType==="HUB_OUTBOUND"?"Shipped from PrintaRex Hub":s.deliveryMode==="HOLD_AT_PRINTAREX"?"Held at PrintaRex Hub":null}const Et={SHOPIFY:"Shopify",WOOCOMMERCE:"WooCommerce",AMAZON:"Amazon",NOON:"Noon"},Ul={SHOPIFY:"bg-green-400/20 text-green-200",WOOCOMMERCE:"bg-purple-400/20 text-purple-200",AMAZON:"bg-orange-400/20 text-orange-200",NOON:"bg-yellow-400/20 text-yellow-100"};function $l(s){var t;return s.status==="AWAITING_PROVIDER_ACCEPTANCE"?"Awaiting provider acceptance":s.status==="PROVIDER_ACCEPTED_PAYMENT_PENDING"?"Provider accepted - payment pending":((t=He[s.status])==null?void 0:t.label)||Ml(s.status)}const Ji=()=>{var Ks,Xs,Zs,Js,et,st,tt,at,rt;const{orderRef:s}=ja(),t=va(),[a,o]=ya(),{toast:h}=Ft(),{languageTag:c,locale:r}=we(),l=m=>Ce(m,r),[x,u]=v.useState(!1),[b,N]=v.useState(a.get("action")==="return"),[j,p]=v.useState(!1),[C,d]=v.useState(!1),[P]=Nt(Oa,{fetchPolicy:"network-only"}),[f]=Nt(Ma,{fetchPolicy:"network-only"}),I=async(m,S)=>{It(m);try{const A=await fetch(m);if(!A.ok)return;const G=await A.blob(),K=URL.createObjectURL(G),D=document.createElement("a");D.href=K,D.download=S,document.body.appendChild(D),D.click(),D.remove(),setTimeout(()=>URL.revokeObjectURL(K),1e3)}catch{}},_=async m=>{var S,A,G,K;p(!0);try{const{data:D,error:je}=await P({variables:{orderId:m}});if(je){h({title:l("Error"),description:je.message,variant:"destructive"});return}if((S=D==null?void 0:D.getInvoice)!=null&&S.success&&D.getInvoice.downloadUrl){const pe=((A=D.getInvoice.invoice)==null?void 0:A.invoiceNumber)??m;await I(D.getInvoice.downloadUrl,`invoice-${pe}.pdf`),h({title:l("Invoice Ready"),description:l(`Invoice ${((G=D.getInvoice.invoice)==null?void 0:G.invoiceNumber)??""} opened in new tab and downloaded.`)})}else h({title:l("Invoice Error"),description:((K=D==null?void 0:D.getInvoice)==null?void 0:K.message)||l("Failed to generate invoice."),variant:"destructive"})}finally{p(!1)}},g=async m=>{var S,A,G;d(!0);try{const K=await f({variables:{orderId:m}});if(K.error){h({title:l("Error"),description:K.error.message,variant:"destructive"});return}const D=(S=K.data)==null?void 0:S.getReceipt;if(D!=null&&D.success&&D.downloadUrl){const je=((A=D.receipt)==null?void 0:A.receiptNumber)??m;await I(D.downloadUrl,`receipt-${je}.pdf`),h({title:l("Receipt Ready"),description:l(`Receipt ${((G=D.receipt)==null?void 0:G.receiptNumber)||""} opened in new tab and downloaded.`)})}else h({title:l("Receipt Error"),description:(D==null?void 0:D.message)||l("Receipt not available yet."),variant:"destructive"})}finally{d(!1)}},E=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s??""),L=a.get("tab"),F=new Set(["finance","mockups","shipping","timeline","final-product","provider"]),te=L&&F.has(L)?L:"finance",[X,H]=v.useState(te),ae=m=>{H(m),m==="finance"?a.delete("tab"):a.set("tab",m),o(a,{replace:!0})};v.useEffect(()=>{const m=a.get("tab");m&&F.has(m)&&m!==X&&H(m)},[a]);const{data:O,loading:w,error:z,refetch:q}=ke(St,{variables:{orderId:s},skip:!s||!E,fetchPolicy:"cache-and-network"}),{data:re,loading:ce,error:ve,refetch:y}=ke(Ba,{variables:{orderNumber:s},skip:!s||E,fetchPolicy:"cache-and-network"}),M=(O==null?void 0:O.myOrder)??(re==null?void 0:re.orderByNumber),B=(M==null?void 0:M.orderType)==="STORE_ORDER",{data:ge,loading:fe,refetch:J}=ke(Ua,{variables:{orderId:s},skip:!s||!E||!B,fetchPolicy:"cache-and-network"}),{data:oe,loading:Ne,refetch:Pe}=ke($a,{variables:{orderNumber:s},skip:!s||E||!B,fetchPolicy:"cache-and-network"}),Ie=E?ge==null?void 0:ge.myOrder:oe==null?void 0:oe.orderByNumber,i=Rl(M,Ie),k=i?{myOrder:i}:void 0,T=Oe.useCallback(async()=>{const m=E?await q():await y();
30if(B)try{E?await J():await Pe()}catch{}return m},[B,E,q,y,J,Pe]),Y=(Ks=k==null?void 0:k.myOrder)==null?void 0:Ks.processingState,ee=Y!=null&&Y!=="STABLE",ye=qt((Xs=k==null?void 0:k.myOrder)==null?void 0:Xs.items,(Zs=k==null?void 0:k.myOrder)==null?void 0:Zs.brandingItems),Se=ee||ye;v.useEffect(()=>{if(!Se)return;const m=window.setInterval(()=>{T()},2e3);return()=>window.clearInterval(m)},[Se,T]);const Gt=(E?w:ce)||B&&(E?fe:Ne),xs=E?z:ve;v.useEffect(()=>{var m;if(E&&((m=O==null?void 0:O.myOrder)!=null&&m.orderNumber)){const S=a.get("tab"),A=S?`?tab=${S}`:"";t(`/dashboard/orders/${O.myOrder.orderNumber}${A}`,{replace:!0})}},[E,(Js=O==null?void 0:O.myOrder)==null?void 0:Js.orderNumber]);const Ms=(et=k==null?void 0:k.myOrder)==null?void 0:et.storeOrderId,Qt=((st=k==null?void 0:k.myOrder)==null?void 0:st.orderType)==="STORE_ORDER",{data:hs,loading:Wt}=ke(Ha,{variables:{id:Ms},skip:!Ms||!Qt,fetchPolicy:"cache-and-network"}),de=hs==null?void 0:hs.storeOrder,Kt=zt((tt=de==null?void 0:de.storeConnection)==null?void 0:tt.platform),[Xt,{loading:us}]=Me(Va,{onCompleted:m=>{var S,A,G,K,D;if((S=m==null?void 0:m.cancelOrder)!=null&&S.success){const je=m.cancelOrder;u(!1);const pe=Number(je.refundAmount),Es=Number.isFinite(pe)?Ds(pe,((A=O==null?void 0:O.myOrder)==null?void 0:A.currency)||((K=(G=m==null?void 0:m.cancelOrder)==null?void 0:G.order)==null?void 0:K.currency),{fallbackCurrency:null,locale:c}):l("the order amount");je.refundInitiated?h({title:l("Order Cancelled"),description:l(`Your order has been cancelled. A refund of ${Es} will be processed within ${je.refundTimeline}.`)}):h({title:l("Order Cancelled"),description:l("Your order has been cancelled successfully.")}),T()}else h({title:l("Failed to Cancel"),description:((D=m==null?void 0:m.cancelOrder)==null?void 0:D.message)||l("Could not cancel the order."),variant:"destructive"})},onError:m=>{h({title:l("Error"),description:m.message,variant:"destructive"})}}),{submitReturnRequest:Zt,submittingReturnRequest:ps}=sr({copy:l,onSuccess:async()=>{N(!1),await T()}}),[bs,gs]=v.useState({open:!1,newTotal:null}),[Bs,{loading:Ze}]=Me(qa,{onCompleted:m=>{var A,G,K;if((A=m==null?void 0:m.retryPayment)!=null&&A.success){const D=m.retryPayment;t(`/orders/${D.orderNumber||(n==null?void 0:n.orderNumber)||(n==null?void 0:n.orderId)}/retry-payment`);return}const S=Ka((G=m==null?void 0:m.retryPayment)==null?void 0:G.message);if(S){gs({open:!0,newTotal:S.newTotal});return}h({title:l("Failed to Retry Payment"),description:((K=m==null?void 0:m.retryPayment)==null?void 0:K.message)||l("Could not create new payment session."),variant:"destructive"})},onError:m=>{h({title:l("Error"),description:m.message,variant:"destructive"})}}),n=k==null?void 0:k.myOrder,Jt=!xs&&!n&&!!s&&(Gt||!(E?O!==void 0:re!==void 0)),[Us]=Me(za);v.useEffect(()=>{n!=null&&n.orderId&&Us({variables:{orderId:n.orderId}}).catch(()=>{})},[n==null?void 0:n.orderId,Us]);const Ae=(n==null?void 0:n.status)==="PENDING_PROVIDER_RESELECTION",fs=["READY_TO_SHIP","SHIPPED","DELIVERED","RETURN_REQUESTED","RETURN_APPROVED","RETURN_RECEIVED","RETURNED"].includes(n==null?void 0:n.status),[ea,Ns]=v.useState(null),js=(rt=(at=n==null?void 0:n.shippingAddress)==null?void 0:at.countryCode)==null?void 0:rt.trim(),$s=n==null?void 0:n.currency,zs=JSON.stringify(((n==null?void 0:n.items)??[]).map(m=>{var S;return{productId:m.catalogProductId||m.productId,quantity:m.quantity,printAreaCount:((S=m.printAreas)==null?void 0:S.length)??0,colorName:m.colorName,size:m.size}})),Hs=JSON.stringify(((n==null?void 0:n.assignmentHistory)??[]).filter(m=>m.rejectedAt!==null).map(m=>m.providerId)),Vs=JSON.stringify(((n==null?void 0:n.brandingItems)??[]).map(m=>m.brandingProductType).filter(m=>!!m)),sa=((n==null?void 0:n.brandingItems)??[]).map(m=>({branding:m,money:ds(m)})),qs=Tr((n==null?void 0:n.brandingItems)??[]),Je=qs===null,vs=Oe.useMemo(()=>{if(!Ae||!js||Je)return null;const m=JSON.parse(zs),S=JSON.parse(Hs),A=JSON.parse(Vs);return{items:m,shippingCountry:js,orderCurrency:$s,excludeProviderIds:S,requiredBrandingTypes:A.length>0?A:void 0}},[Hs,Je,Ae,$s,Vs,zs,js]),{data:ys,loading:ta,error:ws,refetch:aa}=ke(Ga,{variables:{input:vs},skip:!vs,fetchPolicy:"network-only"}),Cs=Oe.useMemo(()=>{const m=((n==null?void 0:n.assignmentHistory)??[]).filter(A=>A.rejectedAt!==null);return m.length===0?null:m.reduce((A,G)=>new Date(G.rejectedAt??0)>new Date(A.rejectedAt??0)?G:A,m[0]).providerConfigId},[n==null?void 0:n.assignmentHistory]),{data:Ps}=ke(Qa,{variables:{configId:Cs},skip:!Cs||!Ae,fetchPolicy:"cache-first"}),[ra]=Me(Wa,{onCompleted:m=>{var S,A,G,K;if(Ns(null),(S=m==null?void 0:m.customerReassignOrder)!=null&&S.success){const D=((A=m.customerReassignOrder.newAssignment)==null?void 0:A.providerName)??((G=m.customerReassignOrder.order)==null?void 0:G.providerName)??l("the selected provider");h({title:l("Provider Selected"),description:l(`Provider selected â Order assigned to ${D}`)}
30),T().catch(()=>{h({title:l("Provider Selected"),description:l("The provider was assigned, but the latest order details could not be refreshed. Please try again."),variant:"destructive"})})}else h({title:l("Selection Failed"),description:((K=m==null?void 0:m.customerReassignOrder)==null?void 0:K.message)??l("Could not select provider."),variant:"destructive"})},onError:m=>{Ns(null),h({title:l("Error"),description:m.message,variant:"destructive"})}}),la=(m,S,A)=>{if(Je){h({title:l("Provider comparison unavailable"),description:l("Provider comparison is blocked because branding provider cost is missing or requires reconciliation."),variant:"destructive"});return}Ns(m),ra({variables:{orderId:n==null?void 0:n.orderId,newProviderId:m,reason:"Manual selection from customer portal"}})};v.useEffect(()=>{const m=localStorage.getItem("highlightedStoreOrderId");m&&((n==null?void 0:n.storeOrderId)===m||(n==null?void 0:n.orderType)==="STORE_ORDER")&&localStorage.removeItem("highlightedStoreOrderId")},[n==null?void 0:n.storeOrderId,n==null?void 0:n.orderType]);const ia=m=>{let S=m;return!m.endsWith("Z")&&!m.includes("+")&&!m.includes("-",10)&&(S=m+"Z"),ls(S,r,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})},{data:ks}=ke(Ya,{variables:{orderId:(n==null?void 0:n.orderId)??""},skip:!(n!=null&&n.orderId),fetchPolicy:"cache-and-network"}),na=(ks==null?void 0:ks.returnRequestAffordances.canRequestReturn)===!0,Ys=n&&Za(n.status),Gs=!!n&&na,Qs=Xa(n),ca=()=>{if((n==null?void 0:n.status)==="PENDING_PAYMENT"){t(`/orders/${n.orderNumber}/retry-payment`);return}Bs({variables:{orderId:n==null?void 0:n.orderId,idempotencyKey:dt()}})},oa=()=>{gs({open:!1,newTotal:null}),Bs({variables:{orderId:n==null?void 0:n.orderId,idempotencyKey:dt()}})},Ws=()=>{gs({open:!1,newTotal:null})},da=(m,S,A)=>{Xt({variables:{orderId:m,reason:S,additionalDetails:A}})},ma=m=>{Zt(m)};if(xs)return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsx(V,{className:"rounded-[28px]",children:e.jsxs(ie,{className:"py-12 text-center",children:[e.jsx(Qe,{className:"h-12 w-12 mx-auto text-red-500 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:l("Failed to load order")}),e.jsx("p",{className:"text-gray-500 mb-4",children:xs.message}),e.jsxs("div",{className:"flex justify-center gap-3",children:[e.jsxs(U,{variant:"outline",className:"group border-primary/30 text-primary hover:bg-primary/10 hover:border-primary transition-all duration-200",onClick:()=>t("/dashboard/orders"),children:[e.jsx(Is,{className:"h-4 w-4 me-2 transition-transform duration-200 ease-[cubic-bezier(0.25,1,0.5,1)] group-hover:-translate-x-1"}),l("Back to Orders")]}),e.jsxs(U,{onClick:()=>T(),children:[e.jsx(Rs,{className:"h-4 w-4 me-2"}),l("Try Again")]})]})]})})});const xa=()=>(Ys||Gs||Qs)&&e.jsxs(V,{className:"rounded-2xl border border-slate-200/50 bg-white/80 backdrop-blur-sm shadow-lg overflow-hidden",children:[e.jsx(ne,{className:"pb-3 border-b border-slate-100 bg-slate-50/50",children:e.jsxs(be,{className:"text-base flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-slate-700 to-slate-900 flex items-center justify-center shadow-md",children:e.jsx(Ut,{className:"h-4.5 w-4.5 text-white"})}),e.jsx("span",{className:"font-semibold text-slate-900",children:l("Order Actions")})]})}),e.jsxs(ie,{className:"pt-4 flex gap-3 flex-wrap",children:[Qs&&e.jsxs(U,{disabled:Ze,onClick:ca,className:"bg-rose-500 text-white shadow-lg shadow-rose-200/70 hover:bg-rose-600",children:[Ze?e.jsx(Te,{className:"h-4 w-4 me-2 animate-spin"}):e.jsx(os,{className:"h-4 w-4 me-2"}),l("Pay Now")]}),Ys&&e.jsxs(U,{variant:"outline",disabled:us,onClick:()=>u(!0),className:"border-red-200 text-red-600 hover:bg-red-50 hover:border-red-300",children:[us?e.jsx(Te,{className:"h-4 w-4 me-2 animate-spin"}):e.jsx(as,{className:"h-4 w-4 me-2"}),l("Cancel Order")]}),Gs&&e.jsxs(U,{variant:"outline",disabled:ps,onClick:()=>N(!0),className:"border-amber-200 text-amber-600 hover:bg-amber-50 hover:border-amber-300",children:[ps?e.jsx(Te,{className:"h-4 w-4 me-2 animate-spin"}):e.jsx(Aa,{className:"h-4 w-4 me-2"}),l("Request Return")]})]})]});return e.jsxs("div",{className:"container mx-auto px-4 py-8 space-y-8",children:[e.jsxs("button",{type:"button",className:"group mb-2 flex items-center gap-2 rounded-full border border-primary/20 bg-primary/8 px-4 py-2 text-sm font-medium text-primary transition-all duration-200 hover:border-primary/40 hover:bg-primary/15 hover:shadow-sm",onClick:()=>t("/dashboard/orders"),children:[e.jsx(Is,{className:"h-4 w-4 transition-transform duration-200 ease-[
30cubic-bezier(0.25,1,0.5,1)] group-hover:-translate-x-1"}),l("Back to Orders")]}),(()=>{var m,S,A,G,K,D;if(Jt)return e.jsx(Ol,{});if(n){const je=n.status==="REFUNDED"&&((m=n.statusHistory)==null?void 0:m.some(R=>R.newStatus==="CANCELLED"&&R.changedByType==="ADMIN")),pe=He[n.status],Es=l(je?"Cancelled by admin - refunded":$l(n)),lt=Bl(n);return e.jsxs("div",{className:"space-y-8",children:[e.jsxs(V,{className:"relative overflow-hidden rounded-2xl border-0 bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 text-white shadow-2xl",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg%20width%3D%2260%22%20height%3D%2260%22%20viewBox%3D%220%200%2060%2060%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cg%20fill%3D%22%23ffffff%22%20fill-opacity%3D%220.03%22%3E%3Cpath%20d%3D%22M36%2034v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6%2034v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6%204V0H4v4H0v2h4v4h2V6h4V4H6z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E')] opacity-50"}),e.jsx("div",{className:"absolute top-0 right-0 w-96 h-96 bg-gradient-to-bl from-primary/20 via-primary/5 to-transparent rounded-full blur-3xl"}),e.jsx("div",{className:"relative p-8 max-sm:p-5",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-gradient-to-br from-primary to-emerald-600 flex items-center justify-center shadow-lg shadow-primary/30",children:e.jsx(cs,{className:"h-8 w-8 text-white"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold",children:[l("Order")," ",n.orderNumber]}),e.jsx(U,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-300 hover:text-white hover:bg-white/10",title:l("Copy order number"),onClick:()=>{navigator.clipboard.writeText(n.orderNumber),h({title:l("Order number copied")})},children:e.jsx(Ss,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-slate-300 flex items-center gap-2",children:[e.jsx(Ot,{className:"h-4 w-4"}),l("Placed on")," ",ia(n.createdAt)]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 max-sm:flex-wrap",children:[e.jsx("span",{className:`inline-flex items-center rounded-md ${(pe==null?void 0:pe.bgColor)||"bg-white/20"} ${(pe==null?void 0:pe.color)||"text-white"} border-0 text-sm px-4 py-1.5 font-medium max-w-full whitespace-normal text-start leading-tight`,children:Es}),n.sourceChannel&&Et[n.sourceChannel]&&e.jsx("span",{className:`inline-flex items-center rounded-md ${Ul[n.sourceChannel]} border-0 text-sm px-4 py-1.5 font-medium max-w-full whitespace-normal text-start leading-tight`,children:l(Et[n.sourceChannel])}),lt&&e.jsxs(ct,{to:"/account/hub",className:"inline-flex items-center rounded-[14px] border border-primary/40 bg-primary/20 px-4 py-1.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[e.jsx(xe,{className:"me-2 h-4 w-4"}),l(lt)]}),e.jsxs(U,{variant:"outline",size:"sm",disabled:j,onClick:()=>_(n.orderId),className:"border-slate-600 text-slate-200 hover:bg-white/10 hover:text-white hover:border-slate-500",children:[j?e.jsx(Te,{className:"h-4 w-4 me-2 animate-spin"}):e.jsx(wr,{className:"h-4 w-4 me-2"}),l("Invoice")]}),e.jsxs(U,{variant:"outline",size:"sm",disabled:C,onClick:()=>g(n.orderId),className:"border-slate-600 text-slate-200 hover:bg-white/10 hover:text-white hover:border-slate-500",children:[C?e.jsx(Te,{className:"h-4 w-4 me-2 animate-spin"}):e.jsx(cs,{className:"h-4 w-4 me-2"}),l("Receipt")]})]})]})})]}),n.requiresDesignRepair&&e.jsxs("div",{className:"flex gap-4 items-start rounded-2xl border border-slate-200 bg-white/80 backdrop-blur-sm shadow-sm p-5",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-slate-100 flex items-center justify-center flex-shrink-0",children:e.jsx(wa,{className:"h-5 w-5 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-slate-800 text-sm",children:l("We're verifying your design files")}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:l("Just a quick check before production starts. Your order is on track and you don't need to do anything.")})]})]}),e.jsxs(_a,{value:X,onValueChange:ae,className:"w-full",children:[e.jsxs(La,{className:`w-full max-md:justify-start max-md:overflow-x-auto scrollbar-hide md:grid ${Ll(fs,Ae)} mb-6 bg-slate-100/80 p-1 rounded-xl`,children:[e.jsxs(Fe,{value:"finance",className:"flex shrink-0 items-center gap-2 data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg",children:[e.jsx(Ca,{className:"h-4 w-4"}),l("Finance")]}),e.jsxs(Fe,{value:"mockups",className:"flex shrink-0 items-center gap-2 data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg",children:[e.jsx(Be,{className:"h-4 w-4"}),l("Mockups")]}),e.jsxs(Fe,{value:"shipping",className:"flex shrink-0 items-center gap-2 data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg",children:[e.jsx(Ue,{className:"h-4 w-4"}),l("Shipping"),n.hasMissingShippingInfo&&e.jsx(Xe,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Fe,{value:"timeline",className:"flex shrink-0 items-center gap-2 data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg",children:[e.jsx($e,{className:"h-4 w-4"}),l("Timeline")]}),fs&&e.jsxs(Fe,{value:"final-product",className:"flex shrink-0 items-center gap-2 data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg",children:[e.jsx(rs,{className:"h-4 w-4"}),l("Final Product")]}),Ae&&e.jsxs(Fe,{value:"provider",className:"flex shrink-0 items-center gap-2 data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg",children:[e.jsx(Rs,{className:"h-4 w-4"}),l("Reassign Provider")]})]}),e.jsx(_e,{value:"finance",className:"mt-0",children:e.jsx(el,{order:n,storeOrder:de,storeOrderLoading:Wt})}),e.jsx(_e,{value:"mockups",className:"mt-0",children:e.jsx(El,{order:n})}),e.jsx(_e,{value:"shipping",className:"mt-0",children:e.jsx(hl,{order:n,storeShippingAddress:de==null?void 0:de.shippingAddress,onOrderUpdated:T,isAmazonStoreOrder:Kt})}),e.jsx(_e,{value:"timeline",className:"mt-0",children:e.jsx(ul,{order:n})}),fs&&e.jsx(_e,{value:"final-product",className:"mt-0",children:e.jsx(Dl,{order:n})}),Ae&&e.jsxs(_e,{value:"provider",className:"mt-0",children:[e.jsx(Dr,{}),Je?e.jsxs(is,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Qe,{className:"h-4 w-4 text-amber-600"}),e.jsx(ns,{className:"text-amber-800",children:l("Provider comparison is blocked because branding provider cost is missing or requires reconciliation.")})]}):vs?e.jsx(Br,{providers:((S=ys==null?void 0:ys.getAvailableProvidersForOrder)==null?void 0:S.providers)??[],loading:ta,error:ws==null?void 0:ws.message,onSelect:la,selectingProviderId:ea,onRetry:()=>aa(),currency:n==null?void 0:n.currency,orderItems:[...((A=n==null?void 0:n.items)==null?void 0:A.map(R=>({itemId:R.itemId,productId:R.productId,catalogProductId:R.catalogProductId,productName:R.productName,variantSku:R.variantSku,colorName:R.colorName,colorHex:R.colorHex,size:R.size,quantity:R.quantity,unitPrice:R.unitPrice,lineTotal:R.lineTotal,providerBasePrice:R.providerBasePrice,providerSetupFee:R.providerSetupFee,providerEarning:R.providerEarning,printAreaCosts:R.printAreaCosts,isBrandingProduct:!1})))??[],...sa.flatMap(({branding:R,money:le})=>{var Ve,qe;return le.available?[{itemId:R.brandingItemId,productId:R.brandingItemId,productName:((Ve=R.brandingProductType)==null?void 0:Ve.split("-").map(Ye=>Ye.charAt(0).toUpperCase()+Ye.slice(1)).join(" "))||"Branding Item",colorName:"",size:"",quantity:R.quantity,unitPrice:le.unitCost,lineTotal:le.lineTotal,providerBasePrice:le.unitCost,isBrandingProduct:!0,brandingType:(qe=R.brandingProductType)==null?void 0:qe.replaceAll("-","_")}]:[]})],orderCosts:{shippingCost:((G=de==null?void 0:de.printarexSummary)==null?void 0:G.totalShippingCost)??(n==null?void 0:n.shippingCost),brandingCost:qs,orderTransactionFee:(n==null?void 0:n.transactionFee)??50,totalProviderCost:((K=de==null?void 0:de.printarexSummary)==null?void 0:K.totalProviderCost)??(((D=n==null?void 0:n.items)==null?void 0:D.reduce((R,le)=>R+(le.providerBasePrice||0)*le.quantity,0))||0)}
30,rejectedAssignments:((n==null?void 0:n.assignmentHistory)??[]).filter(R=>R.rejectedAt!==null).map(R=>{var Ve,qe,Ye;const le=R.providerConfigId===Cs?Ps==null?void 0:Ps.getProductPricingConfig:void 0;return{providerId:R.providerId,providerName:R.providerName,providerConfigId:R.providerConfigId,rejectedAt:R.rejectedAt,rejectionReason:R.rejectionReason??void 0,productionTimeDays:(Ve=le==null?void 0:le.capabilities)==null?void 0:Ve.productionTimeDays,deliveryDaysMin:(qe=le==null?void 0:le.shippingDelivery)==null?void 0:qe.deliveryDaysMin,deliveryDaysMax:(Ye=le==null?void 0:le.shippingDelivery)==null?void 0:Ye.deliveryDaysMax}})}):e.jsxs(is,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Qe,{className:"h-4 w-4 text-amber-600"}),e.jsx(ns,{className:"text-amber-800",children:l("Provider lookup is blocked because this order is missing a shipping country.")})]})]})]}),xa(),e.jsxs(V,{className:"relative overflow-hidden rounded-2xl border-0 bg-gradient-to-r from-slate-900 via-slate-800 to-slate-900 text-white shadow-2xl",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg%20width%3D%2260%22%20height%3D%2260%22%20viewBox%3D%220%200%2060%2060%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cg%20fill%3D%22%23ffffff%22%20fill-opacity%3D%220.03%22%3E%3Cpath%20d%3D%22M36%2034v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6%2034v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6%204V0H4v4H0v2h4v4h2V6h4V4H6z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E')] opacity-50"}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-gradient-to-bl from-primary/20 via-primary/5 to-transparent rounded-full blur-3xl"}),e.jsxs("div",{className:"relative p-6 flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-primary to-emerald-600 flex items-center justify-center shadow-lg shadow-primary/30 flex-shrink-0",children:e.jsx(Cr,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("h3",{className:"text-lg font-bold",children:l("Need help with this order?")}),e.jsx("p",{className:"text-slate-400 text-sm",children:l("Our support team is here to assist you")})]})]}),e.jsxs(U,{onClick:()=>t("/dashboard/support"),className:"bg-primary hover:bg-primary/90 text-white shadow-lg shadow-primary/30",children:[l("Contact Support"),e.jsx(Ee,{className:"h-4 w-4 ms-2"})]})]})]}),n.providerName&&e.jsxs("div",{className:"text-center py-4 space-y-1",children:[e.jsx("p",{className:"text-sm text-slate-400",children:l(`Fulfilled by ${n.providerName}`)}),n.printingTechnology&&e.jsxs("p",{className:"text-sm text-slate-400",children:[l("Printing Technology:")," ",e.jsx("span",{className:"font-medium text-slate-600",children:n.printingTechnology})]})]}),e.jsx(Ja,{order:n,open:x,onOpenChange:u,onConfirm:da,loading:us}),b&&e.jsx(Oe.Suspense,{fallback:e.jsx(tr,{label:l("Loading return request")}),children:e.jsx(_l,{order:n,open:!0,onOpenChange:N,onConfirm:ma,loading:ps})})]})}return e.jsx(V,{className:"rounded-[28px]",children:e.jsxs(ie,{className:"py-12 text-center",children:[e.jsx(xe,{className:"h-12 w-12 mx-auto text-gray-300 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:l("Order not found")}),e.jsxs("p",{className:"text-gray-500 mb-4",children:[l("We couldn't find an order:")," ",s]}),e.jsx(U,{asChild:!0,className:"group border-primary/30 bg-transparent text-primary hover:bg-primary/10 hover:border-primary border transition-all duration-200",children:e.jsxs(ct,{to:"/dashboard/orders",children:[e.jsx(Is,{className:"h-4 w-4 me-2 transition-transform duration-200 ease-[cubic-bezier(0.25,1,0.5,1)] group-hover:-translate-x-1"}),l("Back to Orders")]})})]})})})(),e.jsx(Pa,{open:bs.open,onOpenChange:m=>{m||Ws()},children:e.jsxs(ka,{children:[e.jsxs(Ea,{children:[e.jsx(Ia,{children:l("Price has changed")}),e.jsxs(Ta,{children:[l("The price has changed since you last attempted payment."),bs.newTotal!=null&&(n==null?void 0:n.currency)&&e.jsxs(e.Fragment,{children:[" ",l("New total:")," ",e.jsx("span",{className:"font-semibold text-slate-900",children:Ds(bs.newTotal,n.currency,{locale:c})}),"."]})," ",l("Confirm to continue.")]})]}),e.jsxs(Da,{children:[e.jsx(Ra,{onClick:Ws,children:l("Cancel")}),e.jsx(Sa,{onClick:oa,disabled:Ze,children:l(Ze?"Processing...":"Confirm and pay")})]})]})})]})};export{Ji as OrderDetailsPage};
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.