PageSourceSearch

https://artovniapanel.netlify.app/assets/index-39B9R2DQ.js

js artovniapanel.netlify.app collected 2026-10-03 10:29:35 UTC 56,317 bytes, 2 lines download raw bytes

1import{r as N,g as We,bJ as Ye,q as I,bI as L,$ as He,dw as Se,j as e,h as ie,u as v,a as X,E as Ae,H as D,T as d,B as C,t as z,cH as Te,as as ne,dx as Ge,dy as Ve,e as ke,s as Z,ct as Je,cu as Xe,cv as Ze,dz as Pe,dA as es,n as $,dB as ss,w as we,dC as ts,ag as P,cq as as,dD as is,dv as ns,p as ye,dE as ls,dF as cs,dG as Oe,bb as ve,ak as rs,ae as ds,ah as os,al as ms}from"./index-DuW3Du4C.js";import{D as le}from"./constants-B_DGV-YA.js";import{T as ee}from"./two-column-page-DytkrvgI.js";import{u as us,a as xs}from"./claims-CmtIdcso.js";import{C as E}from"./container-DsjJodZX.js";import{u as ps,a as fs}from"./exchanges-BhFCDgrj.js";import{A as Me}from"./arrow-path-BQbXJ-hs.js";import{a as hs,b as gs,u as js}from"./returns-CV3K5elj.js";import{B as se}from"./user-link-CIMdn8Tk.js";import{u as qe}from"./use-date-Bf1RdJiX.js";import{g as U,i as ys}from"./addresses-g4Mo512s.js";import{a as q,g as O,i as vs}from"./money-amount-helpers-CTCsm_8j.js";import{g as bs,a as _s,O as Ns}from"./order-payment-section-BGeGVOze.js";import{P as Q}from"./popover-DBucpiAz.js";import{u as R}from"./use-prompt-CCmpSRM-.js";import{C as K}from"./copy-KWYZA3lK.js";import{f as Cs}from"./format-provider-BwjwpvNd.js";import{F as zs}from"./constants-nkFSh8Vi.js";import{X as De}from"./x-circle-DzVXmvwP.js";import{f as Ss}from"./format-GXSyk8So.js";import{S as F}from"./status-badge-D40yV60F.js";import{b as As,c as Ts,a as ks,g as ws}from"./order-helpers-s0T-zqoe.js";import{C as Os}from"./check-circle-C1nRWPLF.js";import{f as be}from"./format-currency-Cv-PBHZE.js";import{g as Ms}from"./rma-DZ_CHK12.js";import{c as qs}from"./index-UBaWW9TO.js";import{M as Ds}from"./storefront-g47VL-K1.js";import{C as Es}from"./check-circle-solid-TJ-dpbck.js";import{S as Is}from"./square-two-stack-lc5iRyDf.js";import"./arrow-up-right-on-box-D2Nfkh1p.js";import"./Trans-vX8tGOfp.js";import"./x-mark-mini-BRPZ56rb.js";import"./check-DV2eQOwz.js";import"./subDays-BDrQHhME.js";import"./currencies-CBGG4lfe.js";import"./document-text-BolC8x_X.js";import"./arrow-down-right-mini-FvdN3Sle.js";import"./index-CdNsXhPQ.js";import"./prompt-Cz8eFyDb.js";var $s=Object.defineProperty,J=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,_e=(s,t,i)=>t in s?$s(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i,Ls=(s,t)=>{for(var i in t||(t={}))Ee.call(t,i)&&_e(s,i,t[i]);if(J)for(var i of J(t))Ie.call(t,i)&&_e(s,i,t[i]);return s},Fs=(s,t)=>{var i={};for(var a in s)Ee.call(s,a)&&t.indexOf(a)<0&&(i[a]=s[a]);if(s!=null&&J)for(var a of J(s))t.indexOf(a)<0&&Ie.call(s,a)&&(i[a]=s[a]);return i};const $e=N.forwardRef((s,t)=>{var i=s,{color:a="currentColor"}=i,n=Fs(i,["color"]);return N.createElement("svg",Ls({xmlns:"http://www.w3.org/2000/svg",width:15,height:15,viewBox:"0 0 15 15",fill:"none",ref:t},n),N.createElement("path",{stroke:a,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13.056 7.5H1.944M9.278 3.722 13.056 7.5l-3.778 3.778"}))});$e.displayName="ArrowLongRight";const Rs="payment-collection",Bs=He(Rs),Us=(s,t,i)=>We({mutationFn:a=>Ye.admin.paymentCollection.markAsPaid(t,a),onSuccess:(a,n,c)=>{I.invalidateQueries({queryKey:L.details()}),I.invalidateQueries({queryKey:L.preview(s)}),I.invalidateQueries({queryKey:Bs.all})},...i}),pa=s=>{const{id:t}=s.params||{},{order:i}=Se(t,{fields:le},{initialData:s.data,enabled:!!t});return i?e.jsxs("span",{children:["#",i.display_id]}):null},Qs=s=>({queryKey:L.detail(s),queryFn:async()=>ie(`/vendor/orders/${s}`,{method:"GET",query:{fields:le}})}),fa=async({params:s})=>{const t=s.id,i=Qs(t);return I.ensureQueryData(i)},Ks=({orderPreview:s})=>{var u;const{t}=v(),i=(u=s==null?void 0:s.order_change)==null?void 0:u.claim_id,{mutateAsync:a}
1=us(i,s.id),n=X(),c=async()=>{n(`/orders/${s.id}/claims`)},r=async()=>{await a(void 0,{onSuccess:()=>{z.success(t("orders.claims.toast.canceledSuccessfully"))},onError:p=>{z.error(p.message)}})};if(i)return e.jsx("div",{style:{background:"repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"},className:"-m-4 mb-1 border-b border-l p-4",children:e.jsx(E,{className:"flex items-center justify-between p-0",children:e.jsxs("div",{className:"flex w-full flex-row justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-6 pt-4",children:[e.jsx(Ae,{className:"text-ui-fg-subtle"}),e.jsx(D,{level:"h2",children:t("orders.claims.panel.title")})]}),e.jsx("div",{className:"gap-2 px-6 pb-4",children:e.jsx(d,{children:t("orders.claims.panel.description")})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",children:[e.jsx(C,{size:"small",variant:"secondary",onClick:r,children:t("orders.claims.cancel.title")}),e.jsx(C,{size:"small",variant:"secondary",onClick:c,children:t("actions.continue")})]})]})})})},Ws=({orderPreview:s})=>{var u;const{t}=v(),i=(u=s==null?void 0:s.order_change)==null?void 0:u.exchange_id,{mutateAsync:a}=ps(i,s.id),n=X(),c=async()=>{n(`/orders/${s.id}/exchanges`)},r=async()=>{await a(void 0,{onSuccess:()=>{z.success(t("orders.exchanges.toast.canceledSuccessfully"))},onError:p=>{z.error(p.message)}})};if(i)return e.jsx("div",{style:{background:"repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"},className:"-m-4 mb-1 border-b border-l p-4",children:e.jsx(E,{className:"flex items-center justify-between p-0",children:e.jsxs("div",{className:"flex w-full flex-row justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-6 pt-4",children:[e.jsx(Me,{className:"text-ui-fg-subtle"}),e.jsx(D,{level:"h2",children:t("orders.exchanges.panel.title")})]}),e.jsx("div",{className:"gap-2 px-6 pb-4",children:e.jsx(d,{children:t("orders.exchanges.panel.description")})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",children:[e.jsx(C,{size:"small",variant:"secondary",onClick:r,children:t("orders.exchanges.cancel.title")}),e.jsx(C,{size:"small",variant:"secondary",onClick:c,children:t("actions.continue")})]})]})})})},Ys=({orderPreview:s})=>{const{t}=v(),i=s==null?void 0:s.order_change,a=i==null?void 0:i.return_id,n=(i==null?void 0:i.change_type)==="return_request"&&!!i.return_id,{mutateAsync:c}=hs(a,s.id),r=X(),u=async()=>{r(`/orders/${s.id}/returns`)},p=async()=>{await c(void 0,{onSuccess:()=>{z.success(t("orders.returns.toast.canceledSuccessfully"))},onError:x=>{z.error(x.message)}})};if(!(!a||!n))return e.jsx("div",{style:{background:"repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"},className:"-m-4 mb-1 border-b border-l p-4",children:e.jsx(E,{className:"flex items-center justify-between p-0",children:e.jsxs("div",{className:"flex w-full flex-row justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-6 pt-4",children:[e.jsx(Te,{className:"text-ui-fg-subtle"}),e.jsx(D,{level:"h2",children:t("orders.returns.panel.title")})]}),e.jsx("div",{className:"gap-2 px-6 pb-4",children:e.jsx(d,{children:t("orders.returns.panel.description")})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",children:[e.jsx(C,{size:"small",variant:"secondary",onClick:p,children:t("orders.returns.cancel.title")}),e.jsx(C,{size:"small",variant:"secondary",onClick:u,children:t("actions.continue")})]})]})})})};function Hs(s){const{t}=v(),[i,a]=N.useState(!1),n=s.itemsToSend,c=s.itemsToReturn,r=s.itemsMap,u=s.title,p=()=>{a(!0)},x=()=>{a(!1)};if(!(!(n!=null&&n.length)&&!(c!=null&&c.length)))return e.jsxs(Q,{open:i,children:[e.jsx(Q.Trigger,{onMouseEnter:p,onMouseLeave:x,autoFocus:!1,className:"focus-visible:outline-none",children:e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:u})}),e.jsx(Q.Content,{align:"center",side:"top",className:"bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",children:e.jsxs("div",{className:"flex flex-col",children:[!!(n!=null&&n.length)&&e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"txt-compact-small-plus mb-1",children:t("orders.activity.events.common.toSend")}),e.jsxs("div",{className:"flex flex-col",children:[n==null?void 0:n.map(j=>{const y=r==null?void 0:r.get(j.item_id);return e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[j.quantity,"x"]}),e.jsx(ne,{src:y==null?void 0:y.thumbnail}),e.jsx(d,{className:"txt-compact-small text-ui-fg-subtle truncate",children:`${y==null?void 0:y.variant_title} · ${y==null?void 0:y.product_title}`})]},j.id)}),e.jsx("div",{className:"flex flex-1 flex-row items-center gap-2"})]})]}),!!(c!=null&&c.length)&&e.jsxs("div",{className:"border-t-2 border-dotted p-3",children:[e.jsx("div",{className:"txt-compact-small-plus mb-1",children:t("orders.activity.events.common.toReturn")}),e.jsxs("div",{className:"flex flex-col",children:[c==null?void 0:c.map(j=>{const y=r==null?void 0:r.get(j.item_id);return e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[j.quantity,"x"]}),e.jsx(ne,{src:y==null?void 0:y.thumbnail}),e.jsx(d,{className:"txt-compact-small text-ui-fg-subtle truncate",children:`${y==null?void 0:y.variant_title} · ${y==null?void 0:y.product_title}`})]},j.id)}),e.jsx("div",{className:"flex flex-1 flex-row items-center gap-2"})]})]})]})})]})}function te(s){const{t}=v(),[i,a]=N.useState(!1),n=s.previous,c=s.next,r=s.title,u=()=>{a(!0)},p=()=>{a(!1)};
1return!n&&!c?null:e.jsxs(Q,{open:i,children:[e.jsx(Q.Trigger,{onMouseEnter:u,onMouseLeave:p,autoFocus:!1,className:"focus-visible:outline-none",children:e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:r})}),e.jsx(Q.Content,{align:"center",side:"top",className:"bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",children:e.jsxs("div",{className:"flex flex-col",children:[!!n&&e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"txt-compact-small-plus mb-1",children:t("labels.from")}),e.jsx("p",{className:"txt-compact-small text-ui-fg-subtle",children:n})]}),!!c&&e.jsxs("div",{className:"border-t-2 border-dotted p-3",children:[e.jsx("div",{className:"txt-compact-small-plus mb-1",children:t("labels.to")}),e.jsx("p",{className:"txt-compact-small text-ui-fg-subtle",children:c})]})]})})]})}const Gs=["transfer","update_order"],Vs=({order:s})=>{const t=Js(s);if(t.length<=3)return e.jsx("div",{className:"flex flex-col gap-y-0.5",children:t.map((c,r)=>e.jsx(V,{title:c.title,timestamp:c.timestamp,isFirst:r===t.length-1,itemsToSend:c.itemsToSend,itemsToReturn:c.itemsToReturn,itemsMap:c.itemsMap,children:c.children},r))});const i=t.slice(0,2),a=t.slice(2,t.length-1),n=t[t.length-1];return e.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[i.map((c,r)=>e.jsx(V,{title:c.title,timestamp:c.timestamp,itemsToSend:c.itemsToSend,itemsToReturn:c.itemsToReturn,itemsMap:c.itemsMap,children:c.children},r)),e.jsx(Xs,{activities:a}),e.jsx(V,{title:n.title,timestamp:n.timestamp,isFirst:!0,itemsToSend:n.itemsToSend,itemsToReturn:n.itemsToReturn,itemsMap:n.itemsMap,children:n.children})]})},Js=s=>{const{t}=v(),{order_changes:i=[]}=Ge(s.id,{change_type:["edit","claim","exchange","return","transfer","update_order"]}),a=i.filter(m=>!Gs.includes(m.change_type)),n=at(s,a),{order_items:c=[]}=Ve(s.id,{fields:"+quantity",item_id:n},{enabled:!!a.length}),r=N.useMemo(()=>{var _;const m=new Map((_=s==null?void 0:s.items)==null?void 0:_.map(A=>[A.id,A]));for(const A of n){const T=c.find(o=>o.item.id===A);T&&m.set(A,{...T.item,quantity:T.quantity})}return m},[s.items,c,n]),u=[],p=[],x=[],j=bs(s),y=[],S=!1;return N.useMemo(()=>{var o,g;const m=[];for(const l of j){const f=l.amount;m.push({title:t("orders.activity.events.payment.awaiting"),timestamp:l.created_at,children:e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:q(f,l.currency_code)})}),l.canceled_at&&m.push({title:t("orders.activity.events.payment.canceled"),timestamp:l.canceled_at,children:e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:q(f,l.currency_code)})}),l.captured_at&&m.push({title:t("orders.activity.events.payment.captured"),timestamp:l.captured_at,children:e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:q(f,l.currency_code)})});for(const k of l.refunds||[])m.push({title:t("orders.activity.events.payment.refunded"),timestamp:k.created_at,children:e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:q(k.amount,l.currency_code)})})}for(const l of s.fulfillments||[])m.push({title:t("orders.activity.events.fulfillment.created"),timestamp:l.created_at,children:e.jsx(ae,{fulfillment:l})}),l.delivered_at&&m.push({title:t("orders.activity.events.fulfillment.delivered"),timestamp:l.delivered_at,children:e.jsx(ae,{fulfillment:l})}),l.shipped_at&&m.push({title:t("orders.activity.events.fulfillment.shipped"),timestamp:l.shipped_at,children:e.jsx(ae,{fulfillment:l,isShipment:!0})}),l.canceled_at&&m.push({title:t("orders.activity.events.fulfillment.canceled"),timestamp:l.canceled_at});const _=new Map;for(const l of u)_.set(l.id,l),!(l.claim_id||l.exchange_id)&&(m.push({title:t("orders.activity.events.return.created",{returnId:l.id.slice(-7)}),timestamp:l.created_at,itemsToReturn:l==null?void 0:l.items,itemsMap:r,children:e.jsx(Ne,{orderReturn:l,isCreated:!l.canceled_at})}),l.canceled_at&&m.push({title:t("orders.activity.events.return.canceled",{returnId:l.id.slice(-7)}),timestamp:l.canceled_at}),(l.status==="received"||l.status==="partially_received")&&m.push({title:t("orders.activity.events.return.received",{returnId:l.id.slice(-7)}),timestamp:l.received_at,itemsToReturn:l==null?void 0:l.items,itemsMap:r,children:e.jsx(Ne,{orderReturn:l,isReceived:!0}
1)}));for(const l of p){const f=_.get(l.return_id);m.push({title:t(l.canceled_at?"orders.activity.events.claim.canceled":"orders.activity.events.claim.created",{claimId:l.id.slice(-7)}),timestamp:l.canceled_at||l.created_at,itemsToSend:l.additional_items,itemsToReturn:f==null?void 0:f.items,itemsMap:r,children:e.jsx(Zs,{claim:l,claimReturn:f})})}for(const l of x){const f=_.get(l.return_id);m.push({title:t(l.canceled_at?"orders.activity.events.exchange.canceled":"orders.activity.events.exchange.created",{exchangeId:l.id.slice(-7)}),timestamp:l.canceled_at||l.created_at,itemsToSend:l.additional_items,itemsToReturn:f==null?void 0:f.items,itemsMap:r,children:e.jsx(Ps,{exchange:l,exchangeReturn:f})})}for(const l of i.filter(f=>f.change_type==="edit")){const f=l.status==="confirmed";l.status!=="pending"&&m.push({title:t(`orders.activity.events.edit.${l.status}`,{editId:l.id.slice(-7)}),timestamp:l.status==="requested"?l.requested_at:l.status==="confirmed"?l.confirmed_at:l.status==="declined"?l.declined_at:l.status==="canceled"?l.canceled_at:l.created_at,children:f?e.jsx(et,{edit:l}):null})}for(const l of i.filter(f=>f.change_type==="transfer"))l.requested_at&&m.push({title:t("orders.activity.events.transfer.requested",{transferId:l.id.slice(-7)}),timestamp:l.requested_at,children:e.jsx(st,{transfer:l})}),l.confirmed_at&&m.push({title:t("orders.activity.events.transfer.confirmed",{transferId:l.id.slice(-7)}),timestamp:l.confirmed_at}),l.declined_at&&m.push({title:t("orders.activity.events.transfer.declined",{transferId:l.id.slice(-7)}),timestamp:l.declined_at});for(const l of i.filter(f=>f.change_type==="update_order")){const f=(g=(o=l.actions[0])==null?void 0:o.details)==null?void 0:g.type;f==="shipping_address"&&m.push({title:e.jsx(te,{title:t("orders.activity.events.update_order.shipping_address"),previous:U({address:l.actions[0].details.old}).join(", "),next:U({address:l.actions[0].details.new}).join(", ")}),timestamp:l.created_at,children:e.jsxs("div",{className:"text-ui-fg-subtle mt-2 flex gap-x-2 text-sm",children:[t("fields.by")," ",e.jsx(se,{id:l.created_by})]})}),f==="billing_address"&&m.push({title:e.jsx(te,{title:t("orders.activity.events.update_order.billing_address"),previous:U({address:l.actions[0].details.old}).join(", "),next:U({address:l.actions[0].details.new}).join(", ")}),timestamp:l.created_at,children:e.jsxs("div",{className:"text-ui-fg-subtle mt-2 flex gap-x-2 text-sm",children:[t("fields.by")," ",e.jsx(se,{id:l.created_by})]})}),f==="email"&&m.push({title:e.jsx(te,{title:t("orders.activity.events.update_order.email"),previous:l.actions[0].details.old,next:l.actions[0].details.new}),timestamp:l.created_at,children:e.jsxs("div",{className:"text-ui-fg-subtle mt-2 flex gap-x-2 text-sm",children:[t("fields.by")," ",e.jsx(se,{id:l.created_by})]})})}s.canceled_at&&m.push({title:t("orders.activity.events.canceled.title"),timestamp:s.canceled_at});const A=m.sort((l,f)=>new Date(f.timestamp).getTime()-new Date(l.timestamp).getTime()),T={title:t("orders.activity.events.placed.title"),timestamp:s.created_at,children:e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:q(s.total,s.currency_code)})};return[...A,T]},[s,j,u,x,i,y,S,r])},V=({title:s,timestamp:t,isFirst:i=!1,children:a,itemsToSend:n,itemsToReturn:c,itemsMap:r})=>{const{getFullDate:u,getRelativeDate:p}=qe();return e.jsxs("div",{className:"grid grid-cols-[20px_1fr] items-start gap-2",children:[e.jsxs("div",{className:"flex size-full flex-col items-center gap-y-0.5",children:[e.jsx("div",{className:"flex size-5 items-center justify-center",children:e.jsx("div",{className:"bg-ui-bg-base shadow-borders-base flex size-2.5 items-center justify-center rounded-full",children:e.jsx("div",{className:"bg-ui-tag-neutral-icon size-1.5 rounded-full"})})}),!i&&e.jsx("div",{className:"bg-ui-border-base w-px flex-1"})]}),e.jsxs("div",{className:ke({"pb-4":!i}),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[n!=null&&n.length||c!=null&&c.length?e.jsx(Hs,{title:s,itemsToSend:n,itemsToReturn:c,itemsMap:r},s):e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:s}
1),t&&e.jsx(Z,{content:u({date:t,includeTime:!0}),children:e.jsx(d,{size:"small",leading:"compact",className:"text-ui-fg-subtle text-right",children:p(t)})})]}),e.jsx("div",{children:a})]})]})},Xs=({activities:s})=>{const[t,i]=N.useState(!1),{t:a}=v();return s.length?e.jsxs(Je,{open:t,onOpenChange:i,children:[!t&&e.jsxs("div",{className:"grid grid-cols-[20px_1fr] items-start gap-2",children:[e.jsx("div",{className:"flex size-full flex-col items-center",children:e.jsx("div",{className:"border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-right bg-repeat-y"})}),e.jsx("div",{className:"pb-4",children:e.jsx(Xe,{className:"text-left",children:e.jsx(d,{size:"small",leading:"compact",weight:"plus",className:"text-ui-fg-muted",children:a("orders.activity.showMoreActivities_one",{count:s.length})})})})]}),e.jsx(Ze,{children:e.jsx("div",{className:"flex flex-col gap-y-0.5",children:s.map((n,c)=>e.jsx(V,{title:n.title,timestamp:n.timestamp,itemsToSend:n.itemsToSend,itemsToReturn:n.itemsToReturn,itemsMap:n.itemsMap,children:n.children},c))})})]}):null},ae=({fulfillment:s})=>{const{t}=v(),i=s.items.reduce((a,n)=>a+n.quantity,0);return e.jsx("div",{children:e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:t("orders.activity.events.fulfillment.items",{count:i})})})},Ne=({orderReturn:s,isCreated:t,isReceived:i})=>{const a=R(),{t:n}=v(),{mutateAsync:c}=gs(s.id,s.order_id),r=async()=>{await a({title:n("orders.returns.cancel.title"),description:n("orders.returns.cancel.description"),confirmText:n("actions.confirm"),cancelText:n("actions.cancel")})&&await c()},u=s.items.reduce((p,x)=>p+(i?x.received_quantity:x.quantity),0);return e.jsxs("div",{className:"flex items-start gap-1",children:[e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:n("orders.activity.events.return.items",{count:u})}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-[2px] flex items-center leading-none",children:"⋅"}),e.jsx(C,{onClick:r,className:"text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",variant:"transparent",size:"small",children:n("actions.cancel")})]})]})},Zs=({claim:s,claimReturn:t})=>{const i=R(),{t:a}
1=v(),n=!!s.created_at,{mutateAsync:c}=xs(s.id,s.order_id),r=async()=>{await i({title:a("orders.claims.cancel.title"),description:a("orders.claims.cancel.description"),confirmText:a("actions.confirm"),cancelText:a("actions.cancel")})&&await c()},u=(s.additional_items||[]).reduce((x,j)=>x+j.quantity,0),p=((t==null?void 0:t.items)||[]).reduce((x,j)=>x+j.quantity,0);return e.jsxs("div",{children:[u>0&&e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:a("orders.activity.events.claim.itemsInbound",{count:u})}),p>0&&e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:a("orders.activity.events.claim.itemsOutbound",{count:p})}),!n&&e.jsx(C,{onClick:r,className:"text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",variant:"transparent",size:"small",children:a("actions.cancel")})]})},Ps=({exchange:s,exchangeReturn:t})=>{const i=R(),{t:a}=v(),n=!!s.canceled_at,{mutateAsync:c}=fs(s.id,s.order_id),r=async()=>{await i({title:a("orders.exchanges.cancel.title"),description:a("orders.exchanges.cancel.description"),confirmText:a("actions.confirm"),cancelText:a("actions.cancel")})&&await c()},u=(s.additional_items||[]).reduce((x,j)=>x+j.quantity,0),p=((t==null?void 0:t.items)||[]).reduce((x,j)=>x+j.quantity,0);return e.jsxs("div",{children:[u>0&&e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:a("orders.activity.events.exchange.itemsInbound",{count:u})}),p>0&&e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:a("orders.activity.events.exchange.itemsOutbound",{count:p})}),!n&&e.jsx(C,{onClick:r,className:"text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",variant:"transparent",size:"small",children:a("actions.cancel")})]})},et=({edit:s})=>{const{t}=v(),[i,a]=N.useMemo(()=>tt(s.actions),[s]);return e.jsxs("div",{children:[i>0&&e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[t("labels.added"),": ",i]}),a>0&&e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[t("labels.removed"),": ",a]})]})},st=({transfer:s})=>{var p;const t=R(),{t:i}=v(),a=s.actions[0],{customer:n}=Pe(a.reference_id),c=!!s.confirmed_at,{mutateAsync:r}=es(s.order_id),u=async()=>{await t({title:i("general.areYouSure"),description:i("actions.cannotUndo"),confirmText:i("actions.delete"),cancelText:i("actions.cancel")})&&await r()};return e.jsxs("div",{children:[e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[i("orders.activity.from"),":"," ",(p=a.details)==null?void 0:p.original_email]}),e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[i("orders.activity.to"),":"," ",n!=null&&n.first_name?`${n==null?void 0:n.first_name} ${n==null?void 0:n.last_name}`:n==null?void 0:n.email]}),!c&&e.jsx(C,{onClick:u,className:"text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",variant:"transparent",size:"small",children:i("actions.cancel")})]})};function tt(s){let t=0,i=0;return s.forEach(a=>{if(a.action==="ITEM_ADD"&&(t+=a.details.quantity),a.action==="ITEM_UPDATE"){const n=a.details.quantity_diff;n>0?t+=n:i+=Math.abs(n)}}),[t,i]}function at(s,t){if(!(t!=null&&t.length))return[];const i=new Set,a=new Map(s.items.map(n=>[n.id,!0]));return t.forEach(n=>{n.actions.forEach(c=>{var r;(r=c.details)!=null&&r.reference_id&&c.details.reference_id.startsWith("ordli_")&&!a.has(c.details.reference_id)&&i.add(c.details.reference_id)})}),Array.from(i)}const it=({order:s})=>{const{t}=v();return e.jsxs(E,{className:"flex flex-col gap-y-8 px-6 py-4",children:[e.jsx("div",{className:"flex flex-col gap-y-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(D,{level:"h2",children:t("orders.activity.header")})})}),e.jsx(Vs,{order:s})]})},nt=({data:s})=>{const{t}=v(),i=s.customer_id,a=ot(s),n=s.email,c=(a||n||"").charAt(0).toUpperCase();return e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:t("fields.id")}),e.jsx($,{to:`/customers/${i}`,className:"focus:shadow-borders-focus rounded-[4px] outline-none transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[e.jsx(ss,{size:"2xsmall",fallback:c}),e.jsx(d,{size:"small",leading:"compact",className:"text-ui-fg-subtle hover:text-ui-fg-base transition-fg truncate",children:a||n})]})})]})},lt=({data:s})=>{var a,n;const{t}=v(),i=((a=s.shipping_address)==null?void 0:a.company)||((n=s.billing_address)==null?void 0:n.company);return i?e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:t("fields.company")}),e.jsx(d,{size:"small",leading:"compact",className:"truncate",children:i})]}):null},ct=({data:s})=>{var u;const{t}=v(),i=((u=s.billing_address)==null?void 0:u.metadata)||{},a=s.metadata||{},n=i.want_invoice===!0||a.want_invoice===!0,c=i.nip||a.nip||"",r=i.is_company===!0||a.is_company===!0||!!c;return!n&&!c&&!r?null:e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:t("fields.invoice_data","Dane do faktury")}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsxs(d,{size:"small",leading:"compact",className:"text-ui-fg-muted",children:[t("fields.wants_invoice","Faktura VAT"),":"]}),e.jsx(d,{size:"small",leading:"compact",className:n?"text-ui-fg-base font-medium":"text-ui-fg-muted",children:n?t("fields.yes","Tak"):t("fields.no","Nie")})]}),c&&e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(d,{size:"small",leading:"compact",className:"text-ui-fg-muted",children:"NIP:"}),e.jsxs("div",{className:"flex items-center gap-x-1",children:[e.jsx(d,{size:"small",leading:"compact",className:"font-mono",children:c}),e.jsx(K,{content:c,className:"text-ui-fg-muted"})]})]}),r&&e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsxs(d,{size:"small",leading:"compact",className:"text-ui-fg-muted",children:[t("fields.customer_type","Typ klienta"),":"]}),e.jsx(d,{size:"small",leading:"compact",children:t("fields.company_customer","Firma")})]})]})]})},rt=({data:s})=>{var n,c;const{t}=v(),i=((n=s.shipping_address)==null?void 0:n.phone)||((c=s.billing_address)==null?void 0:c.phone),a=s.email||"";return e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:t("orders.customer.contactLabel")}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_20px] items-start gap-x-2",children:[e.jsx(d,{size:"small",leading:"compact",className:"text-pretty break-all",children:a}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{content:a,className:"text-ui-fg-muted"})})]}),i&&e.jsxs("div",{className:"grid grid-cols-[1fr_20px] items-start gap-x-2",children:[e.jsx(d,{size:"small",leading:"compact",className:"text-pretty break-all",children:i}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{content:a,className:"text-ui-fg-muted"})})]})]})]})},Ce=({address:s,type:t})=>{const{t:i}=v();return e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:i(t==="shipping"?"addresses.shippingAddress.label":"addresses.billingAddress.label")}),s?e.jsxs("div",{className:"grid grid-cols-[1fr_20px] items-start gap-x-2",children:[e.jsx(d,{size:"small",leading:"compact",children:U({address:s}).map((a,n)=>e.jsxs("span",{className:"break-words",children:[a,e.jsx("br",{})]},n))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{content:U({address:s}).join(`
2`),className:"text-ui-fg-muted"})})]}):e.jsx(d,{size:"small",leading:"compact",children:"-"})]})},dt=({data:s})=>{const{t}=v();return e.jsxs("div",{className:"divide-y",children:[e.jsx(Ce,{address:s.shipping_address,type:"shipping"}),ys(s.shipping_address,s.billing_address)?e.jsxs("div",{className:"grid grid-cols-2 items-center px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",className:"text-ui-fg-subtle",children:t("addresses.billingAddress.label")}),e.jsx(d,{size:"small",leading:"compact",className:"text-ui-fg-muted",children:t("addresses.billingAddress.sameAsShipping")})]}):e.jsx(Ce,{address:s.billing_address,type:"billing"})]})},W=Object.assign({},{ID:nt,Company:lt,Contact:rt,Addresses:dt,InvoiceData:ct}),ot=s=>{const{first_name:t,last_name:i}=s.shipping_address||{},{first_name:a,last_name:n}=s.billing_address||{},{first_name:c,last_name:r}=s.customer||{}
2,u=[c,r].filter(Boolean).join(" "),p=[t,i].filter(Boolean).join(" "),x=[a,n].filter(Boolean).join(" ");return u||p||x},mt=({order:s})=>e.jsxs(E,{className:"divide-y p-0",children:[e.jsx(ut,{}),e.jsx(xt,{order:s}),e.jsx(W.ID,{data:s}),e.jsx(W.Contact,{data:s}),e.jsx(W.Company,{data:s}),e.jsx(W.InvoiceData,{data:s}),e.jsx(W.Addresses,{data:s}),e.jsx(pt,{order:s})]}),ut=()=>{const{t:s}=v();return e.jsx("div",{className:"flex items-center justify-between px-6 py-4",children:e.jsx(D,{level:"h2",children:s("fields.customer")})})},xt=({order:s})=>{var i;const t=(i=s.metadata)==null?void 0:i.order_note;return typeof t!="string"||!t.trim()?null:e.jsx("div",{className:"px-6 py-4",children:e.jsxs("div",{className:"rounded-lg border border-ui-tag-orange-border bg-ui-tag-orange-bg p-3",children:[e.jsx(d,{size:"small",weight:"plus",className:"text-ui-tag-orange-text mb-1",children:"Notatka od klienta"}),e.jsx(d,{size:"small",className:"whitespace-pre-wrap text-ui-fg-base",children:t})]})})},pt=({order:s})=>{var S;const{t}=v(),i=(S=s.shipping_methods)==null?void 0:S.find(m=>m.data&&(m.data.parcel_machine||m.data.parcelMachine||m.data.inpost_point||m.data.inpostPoint||m.data.point_id||m.data.pointId||m.data.display_address));if(!i||!i.data)return null;const a=i.data,n=a.display_address,c=a.parcel_machine||a.parcelMachine||a.inpost_point||a.inpostPoint||{},r=a.point_id||a.pointId||c.id||"",u=c.name||r||"";if(!r&&!u&&!n)return null;const p=i.name||"",x=i.shipping_option_id||"",j=p||(x?`${t("fields.shipping_option","Option")}: ${x.split("_").pop()}`:void 0),y=()=>{if(!c.address)return t("fields.address_unavailable","Address information unavailable");const m=[c.address,c.postal_code||c.postCode,c.city].filter(Boolean);return m.length>0?m.join(", "):t("fields.address_unavailable","Address information unavailable")};return e.jsxs("div",{className:"flex flex-col gap-y-2 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{size:"base",className:"font-medium",children:t("fields.parcel_machine_info","Informacje o paczkomacie")}),j&&e.jsx(we,{size:"small",children:j})]}),r&&e.jsxs("div",{className:"flex flex-col gap-y-1 mt-2",children:[e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[t("fields.point_code","Kod paczkomatu"),":"]}),e.jsx(d,{size:"base",children:r})]}),e.jsxs("div",{className:"flex flex-col gap-y-1 mt-1",children:[e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[t("fields.address","Address"),":"]}),e.jsx(d,{size:"base",children:n||y()})]}),a.description&&e.jsxs("div",{className:"flex flex-col gap-y-1 mt-1",children:[e.jsxs(d,{size:"small",className:"text-ui-fg-subtle",children:[t("fields.description","Description"),":"]}),e.jsx(d,{size:"base",children:a.description})]})]})},ft=s=>{if(s.length===0)return[];const t=[...s].sort((n,c)=>new Date(n.created_at).getTime()-new Date(c.created_at).getTime()),i=[];let a=[t[0]];for(let n=1;n<t.length;n++){const c=t[n],r=t[n-1];new Date(c.created_at).getTime()-new Date(r.created_at).getTime()<=5e3?a.push(c):(i.push(a),a=[c])}return i.push(a),i},ht=({order:s})=>{const t=s.fulfillments||[],i=ft(t);return e.jsxs("div",{className:"flex flex-col gap-y-3",children:[e.jsx(jt,{order:s}),i.map((a,n)=>e.jsx(yt,{index:n,fulfillments:a,order:s},a[0].id))]})},gt=({item:s,currencyCode:t})=>{var i;return e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",children:[e.jsxs("div",{className:"flex items-start gap-x-4",children:[e.jsx(ne,{src:s.thumbnail}),e.jsxs("div",{children:[e.jsx($,{to:`/products/${s.product_id}`,className:"text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",children:e.jsx(d,{size:"small",leading:"compact",weight:"plus",className:"text-ui-fg-base hover:text-ui-fg-interactive",children:s.title})}),s.variant_sku&&e.jsxs("div",{className:"flex items-center gap-x-1",children:[e.jsx(d,{size:"small",children:s.variant_sku}),e.jsx(K,{content:s.variant_sku,className:"text-ui-fg-muted"})]}),((i=s.variant)==null?void 0:i.options)&&s.variant.options.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-1 mt-1",children:s.variant.options.map((a,n)=>{var c,r;return e.jsxs("span",{className:"text-xs",children:[e.jsxs("span",{className:"text-ui-fg-muted",children:[((c=a.option)==null?void 0:c.title)||"Option",":"]}
2)," ",e.jsx("span",{className:"text-ui-fg-subtle font-medium",children:a.value}),n<(((r=s.variant.options)==null?void 0:r.length)||0)-1&&e.jsx("span",{className:"text-ui-fg-muted mx-1",children:"·"})]},n)})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-x-4",children:[e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(d,{size:"small",children:O(Number(s.unit_price),t)})}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs(d,{children:[e.jsx("span",{className:"tabular-nums",children:s.quantity-s.detail.fulfilled_quantity}),"x"]})}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(d,{size:"small",children:O(Number(s.subtotal||0),t)})})]})]},s.id)},jt=({order:s})=>{const t=s.items.filter(a=>a.requires_shipping&&a.detail.fulfilled_quantity<a.quantity),i=s.items.filter(a=>!a.requires_shipping&&a.detail.fulfilled_quantity<a.quantity);return e.jsxs(e.Fragment,{children:[!!t.length&&e.jsx(ze,{order:s,unfulfilledItems:t,requiresShipping:!0}),!!i.length&&e.jsx(ze,{order:s,unfulfilledItems:i,requiresShipping:!1})]})},ze=({order:s,unfulfilledItems:t,requiresShipping:i=!1})=>{const{t:a}=v();if(s.status!=="canceled")return e.jsxs(E,{className:"divide-y p-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[e.jsx(D,{level:"h2",children:a("orders.fulfillment.unfulfilledItems")}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[i&&e.jsx(F,{color:"red",className:"text-nowrap",children:a("orders.fulfillment.requiresShipping")}),e.jsx(F,{color:"red",className:"text-nowrap",children:a("orders.fulfillment.awaitingFulfillmentBadge")})]})]}),e.jsx("div",{children:t.map(n=>e.jsx(gt,{item:n,currencyCode:s.currency_code},n.id))}),e.jsx("div",{className:"px-6 py-4 flex justify-end",children:e.jsx($,{to:`/orders/${s.id}/fulfillment?requires_shipping=${i}`,children:e.jsx(C,{children:a("orders.fulfillment.fulfillItems")})})})]})},yt=({fulfillments:s,order:t,index:i})=>{var re,de,oe;const{t:a}=v(),n=R(),c=X(),r=s[0],u=!!r.location_id,p=r.metadata||{},x=s.map(h=>(h.metadata||{}).tracking_status).filter(Boolean),j=x.find(h=>h==="exception"||h==="register_rejected")||(x.every(h=>h==="delivered")?x[0]:void 0)||x[0],y=s.flatMap(h=>(h.labels||[]).map(b=>({...b,fulfillment_id:h.id}))),S=x.some(h=>["pending_register","registered","tracking_active"].includes(h||"")),m=((oe=(de=(re=r.shipping_option)==null?void 0:re.service_zone)==null?void 0:de.fulfillment_set)==null?void 0:oe.type)===zs.Pickup,{stock_location:_,isError:A,error:T}=ts(r.location_id,void 0,{enabled:u});let o=r.requires_shipping?m?"Awaiting pickup":"Awaiting shipping":"Awaiting delivery",g="blue",l=r.created_at;const f=s.every(h=>h.canceled_at),k=s.every(h=>h.delivered_at),w=s.every(h=>h.shipped_at),M=s.some(h=>h.canceled_at),B=s.some(h=>h.shipped_at);f?(o="Canceled",g="red",l=r.canceled_at):k?(o="Delivered",g="green",l=r.delivered_at):w&&(o="Shipped",g="green",l=r.shipped_at);const H=!M&&!B&&!k&&r.requires_shipping&&!m,ce=!M&&!k,Fe=j==="delivered"?"green":j==="exception"||j==="register_rejected"?"red":"blue",Re=async()=>{if(await n({title:a("general.areYouSure"),description:S?`${a("orders.fulfillment.markAsDeliveredWarning")} Tracking is active or waiting for automatic updates. Manual delivery may trigger downstream payout and email flows before carrier confirmation.`:a("orders.fulfillment.markAsDeliveredWarning"),confirmText:a("actions.continue"),cancelText:a("actions.cancel"),variant:"confirmation"}))try{for(const b of s)await ie(`/vendor/orders/${t.id}/fulfillments/${b.id}/mark-as-delivered`,{method:"POST"});await I.invalidateQueries({queryKey:L.detail(t.id)}),await I.invalidateQueries({queryKey:L.lists()}),z.success(a(m?"orders.fulfillment.toast.fulfillmentPickedUp":"orders.fulfillment.toast.fulfillmentDelivered"))}catch(b){z.error(b.message)}},Be=async()=>{if(B){z.warning(a("orders.fulfillment.toast.fulfillmentShipped"));return}if(await n({title:a("general.areYouSure"),description:a("orders.fulfillment.cancelWarning"),confirmText:a("actions.continue"),cancelText:a("actions.cancel")}))try{for(const b of s)await ie(`/vendor/orders/${t.id}/fulfillments/${b.id}/cancel`,{method:"POST"});await I.invalidateQueries({queryKey:L.detail(t.id)}),await I.invalidateQueries({queryKey:L.lists()}),z.success(a("orders.fulfillment.toast.canceled"))}catch(b){z.error(b.message)}},Ue=()=>{const h=s.map(b=>b.id).join(",");c(`./${r.id}/create-shipment?group=${h}`)};if(A)throw T;const Qe=s.flatMap(h=>h.items||[]);return e.jsxs(E,{className:"divide-y p-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[e.jsx(D,{level:"h2",children:a("orders.fulfillment.number",{number:i+1})}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx(Z,{content:Ss(new Date(l),"dd MMM, yyyy, HH:mm:ss"),children:e.jsx(F,{color:g,className:"text-nowrap",children:o})}),e.jsx(P,{groups:[{actions:[{label:a("actions.cancel"),icon:e.jsx(De,{}),onClick:Be,disabled:M}]}]})]})]}),e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:a("orders.fulfillment.itemsLabel")}),e.jsx("ul",{className:"space-y-1",children:Qe.map(h=>{var me,ue,xe,pe;const b=(me=t.items)==null?void 0:me.find(G=>
2G.id===h.line_item_id),Ke=((ue=b==null?void 0:b.variant)==null?void 0:ue.options)&&((xe=b==null?void 0:b.variant)==null?void 0:xe.options.length)>0;return e.jsxs("li",{children:[b!=null&&b.product_id?e.jsx($,{to:`/products/${b.product_id}`,className:"text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",children:e.jsxs(d,{size:"small",leading:"compact",children:[h.quantity,"x ",h.title]})}):e.jsxs(d,{size:"small",leading:"compact",children:[h.quantity,"x ",h.title]}),Ke&&(b==null?void 0:b.variant)&&e.jsx("div",{className:"flex flex-wrap items-center gap-1 ml-6 mt-0.5",children:(pe=b.variant.options)==null?void 0:pe.map((G,fe)=>{var he,ge,je;return e.jsxs("span",{className:"text-xs",children:[e.jsxs("span",{className:"text-ui-fg-muted",children:[((he=G.option)==null?void 0:he.title)||"Option",":"]})," ",e.jsx("span",{className:"text-ui-fg-subtle font-medium",children:G.value}),fe<(((je=(ge=b==null?void 0:b.variant)==null?void 0:ge.options)==null?void 0:je.length)||0)-1&&e.jsx("span",{className:"text-ui-fg-muted mx-1",children:"·"})]},fe)})})]},h.line_item_id)})})]}),u&&e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:a("orders.fulfillment.shippingFromLabel")}),_?e.jsx($,{to:`/settings/locations/${_.id}`,className:"text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",children:e.jsx(d,{size:"small",leading:"compact",children:_.name})}):e.jsx(as,{className:"w-16"})]}),e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:a("fields.provider")}),e.jsx(d,{size:"small",leading:"compact",children:Cs(r.provider_id)})]}),e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:a("orders.fulfillment.trackingLabel")}),e.jsx("div",{children:y.length>0?e.jsx("ul",{children:y.map(h=>h.url&&h.url.length>0&&h.url!=="#"?e.jsx("li",{children:e.jsx("a",{href:h.url,target:"_blank",rel:"noopener noreferrer",className:"text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",children:e.jsx(d,{size:"small",leading:"compact",children:h.tracking_number})})},`${h.fulfillment_id}-${h.tracking_number}`):e.jsx("li",{children:e.jsx(d,{size:"small",leading:"compact",children:h.tracking_number})},`${h.fulfillment_id}-${h.tracking_number}`))}):e.jsx(d,{size:"small",leading:"compact",children:"-"})})]}),j&&e.jsxs("div",{className:"text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4",children:[e.jsx(d,{size:"small",leading:"compact",weight:"plus",children:"Tracking API"}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(F,{color:Fe,children:j.replace(/_/g," ")}),p.tracking_provider&&e.jsx(d,{size:"small",leading:"compact",children:p.tracking_provider})]})]}),(H||ce)&&e.jsxs("div",{className:"bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",children:[ce&&e.jsx(C,{onClick:Re,variant:"secondary",children:a(m?"orders.fulfillment.markAsPickedUp":"orders.fulfillment.markAsDelivered")}),H&&e.jsx(C,{onClick:Ue,variant:"secondary",children:a("orders.fulfillment.markAsShipped")})]})]})},vt=({order:s})=>{var y;const{t}=v(),i=R(),{getFullDate:a}=qe(),{mutateAsync:n}=is(s.id),{mutate:c,isPending:r}=ns(s.id,{onSuccess:()=>{z.success(t("orders.listActions.completeSuccess"))},onError:()=>{z.error(t("orders.listActions.completeError"))}}),u=r||s.status==="completed"||s.status==="canceled",p=s.fulfillment_status==="delivered",x=async()=>{await i({title:t("general.areYouSure"),description:t("orders.cancelWarning",{id:`#${s.display_id}`}),confirmText:t("actions.continue"),cancelText:t("actions.cancel")})&&await n(void 0,{onSuccess:()=>{z.success(t("orders.orderCanceled"))},onError:m=>{z.error(m.message)}})},j=()=>{u||c()};return e.jsxs(E,{className:"flex items-center justify-between px-6 py-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-x-1",children:[e.jsxs(D,{children:["#",s.display_id]}),e.jsx(K,{content:`#${s.display_id}`,className:"text-ui-fg-muted"})]}),e.jsx(d,{size:"small",className:"text-ui-fg-subtle",children:t("orders.onDateFromSalesChannel",{date:a({date:s.created_at,includeTime:!0}),salesChannel:(y=s.sales_channel)==null?void 0:y.name})})]}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsxs("div",{className:"flex items-center gap-x-1.5",children:[e.jsx(Nt,{order:s}),e.jsx(_t,{order:s}),e.jsx(bt,{order:s})]}),e.jsx(P,{groups:[{actions:[...p?[{label:r?`${t("actions.complete")}...`:t("actions.complete"),onClick:j,disabled:u,icon:e.jsx(Os,{})}]:[],{label:t("actions.cancel"),onClick:x,disabled:!!s.canceled_at,icon:e.jsx(De,{})}]}]})]})]})},bt=({order:s})=>{const{t}=v(),{label:i,color:a}=ws(t,s.fulfillment_status);return e.jsx(F,{color:a,className:"text-nowrap",children:i})},_t=({order:s})=>{const{t}=v(),i=Ts(s),{label:a,color:n}=ks(t,i);return e.jsx(F,{color:n,className:"text-nowrap",children:a})},Nt=({order:s})=>{const{t}=v(),i=As(t,s.status);return i?e.jsx(F,{color:i.color,className:"text-nowrap",children:i.label}):null},Le=ye.forwardRef(({paymentCollection:s,order:t},i)=>{const[a,n]=N.useState(!1),[c,r]=N.useState(!1),[u,p]=N.useState("CopyPaymentLink"),{t:x}=v(),j=async y=>{y.stopPropagation(),n(!0),qs(`${Ds}/payment-collection/${s.id}`),setTimeout(()=>{n(!1)},2e3)};return ye.useEffect(()=>{if(a){p(x("actions.copied"));return}setTimeout(()=>{p(x("actions.copy"))},500)},[a]),e.jsx(Z,{content:u,open:a||c,onOpenChange:r,children:e.jsxs(C,{ref:i,variant:"secondary",size:"small","aria-label":"CopyPaymentLink code snippet",onClick:j,children:[a?e.jsx(Es,{className:"inline"}):e.jsx(Is,{className:"inline"}),x("orders.payment.paymentLink",{amount:q(s.amount,t==null?void 0:t.currency_code)})]})})});
2Le.displayName="CopyPaymentLink";function Ct({shippingMethod:s}){const{t}=v(),i=s==null?void 0:s.detail;if(!i)return;let a=t("orders.return"),n=i.return_id;if(i.claim_id&&(a=t("orders.claim"),n=i.claim_id),i.exchange_id&&(a=t("orders.exchange"),n=i.exchange_id),!!n)return e.jsx(Z,{content:e.jsxs(we,{size:"2xsmall",rounded:"full",children:[a,": #",n.slice(-7)]}),children:e.jsx(ls,{className:"inline-block text-ui-fg-muted ml-1"})})}const zt=({order:s})=>{var T;const{t}=v(),i=R(),{reservations:a}=cs({},{enabled:Array.isArray(s==null?void 0:s.items)}),{order:n}=Oe(s.id),{returns:c=[]}=js({status:"requested",order_id:s.id,fields:"+received_at"}),r=N.useMemo(()=>c.filter(o=>!o.canceled_at),[c]),u=!!r.length,p=N.useMemo(()=>{var g;if(!a)return!1;const o=new Map(a.map(l=>[l.line_item_id,l.id]));for(const l of s.items)if((g=l.variant)!=null&&g.manage_inventory&&l.quantity-l.detail.fulfilled_quantity>0&&!o.has(l.id))return!0;return!1},[a]),x=s.payment_collections.find(o=>o.status==="not_paid"),{mutateAsync:j}=Us(s.id,x==null?void 0:x.id),y=((T=s.summary)==null?void 0:T.pending_difference)||0,S=!vs(y,s.currency_code),m=x&&y>0&&S,_=x&&y<0&&S,A=async o=>{await i({title:t("orders.payment.markAsPaid"),description:t("orders.payment.markAsPaidPayment",{amount:be(o.amount,s.currency_code)}),confirmText:t("actions.confirm"),cancelText:t("actions.cancel"),variant:"confirmation"})&&await j({order_id:s.id},{onSuccess:()=>{z.success(t("orders.payment.markAsPaidPaymentSuccess",{amount:be(o.amount,s.currency_code)}))},onError:l=>{z.error(l.message)}})};return e.jsxs(E,{className:"divide-y divide-dashed p-0",children:[e.jsx(St,{order:s,orderPreview:n}),e.jsx(At,{order:s}),e.jsx(Tt,{order:s}),(p||u||m||_)&&e.jsxs("div",{className:"bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",children:[u&&(r.length===1?e.jsx(C,{asChild:!0,variant:"secondary",size:"small",children:e.jsx($,{to:`/orders/${s.id}/returns/${r[0].id}/receive`,children:t("orders.returns.receive.action")})}):e.jsx(P,{groups:[{actions:r.map(o=>{let g=o.id,l="Return";return o.exchange_id&&(g=o.exchange_id,l="Exchange"),o.claim_id&&(g=o.claim_id,l="Claim"),{label:t("orders.returns.receive.receiveItems",{id:`#${g.slice(-7)}`,returnType:l}),icon:e.jsx($e,{}),to:`/orders/${s.id}/returns/${o.id}/receive`}})}],children:e.jsx(C,{variant:"secondary",size:"small",children:t("orders.returns.receive.action")})})),p&&e.jsx(C,{asChild:!0,variant:"secondary",size:"small",children:e.jsx($,{to:"allocate-items",children:t("orders.allocateItems.action")})}),m&&e.jsx(Le,{paymentCollection:x,order:s}),m&&e.jsx(C,{size:"small",variant:"secondary",onClick:()=>A(x),children:t("orders.payment.markAsPaid")}),_&&e.jsx(C,{size:"small",variant:"secondary",asChild:!0,children:e.jsx($,{to:`/orders/${s.id}/refund`,children:t("orders.payment.refundAmount",{amount:q(y*-1,s==null?void 0:s.currency_code)})})})]})]})},St=({order:s,orderPreview:t})=>{var c,r,u,p,x,j,y,S,m,_,A,T,o;const{t:i}=v(),a=s.items.every(g=>!(Ms(g)>0)),n=((c=t==null?void 0:t.order_change)==null?void 0:c.change_type)==="edit";return e.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[e.jsx(D,{level:"h2",children:i("fields.summary")}),e.jsx(P,{groups:[{actions:[{label:i("orders.returns.create"),to:`/orders/${s.id}/returns`,icon:e.jsx(Te,{}),disabled:a||n||!!((r=t==null?void 0:t.order_change)!=null&&r.exchange_id)||!!((u=t==null?void 0:t.order_change)!=null&&u.claim_id)},{label:(p=t==null?void 0:t.order_change)!=null&&p.id&&((x=t==null?void 0:t.order_change)!=null&&x.exchange_id)?i("orders.exchanges.manage"):i("orders.exchanges.create"),to:`/orders/${s.id}/exchanges`,icon:e.jsx(Me,{}),disabled:a||n||!!((j=t==null?void 0:t.order_change)!=null&&j.return_id)&&!((y=t==null?void 0:t.order_change)!=null&&y.exchange_id)||!!((S=t==null?void 0:t.order_change)!=null&&S.claim_id)},{label:(m=t==null?void 0:t.order_change)!=null&&m.id&&((_=t==null?void 0:t.order_change)!=null&&_.claim_id)?i("orders.claims.manage"):i("orders.claims.create"),to:`/orders/${s.id}/claims`,icon:e.jsx(Ae,{}),disabled:a||n||!!((A=t==null?void 0:t.order_change)!=null&&A.return_id)&&!((T=t==null?void 0:t.order_change)!=null&&T.claim_id)||!!((o=t==null?void 0:t.order_change)!=null&&o.exchange_id)}]}]})]})},Y=({label:s,value:t,secondaryValue:i,tooltip:a})=>e.jsxs("div",{className:"grid grid-cols-3 items-center",children:[e.jsxs(d,{size:"small",leading:"compact",children:[s," ",a]}),e.jsx("div",{className:"text-right",children:e.jsx(d,{size:"small",leading:"compact",children:i})}),e.jsx("div",{className:"text-right",children:e.jsx(d,{size:"small",leading:"compact",children:t})})]}),At=({order:s})=>{var T;const{t}=v(),[i,a]=N.useState(!1),[n,c]=N.useState(!1),{sellerDiscounts:r,platformDiscounts:u}=N.useMemo(()=>{const o=[],g=[];
2return s.items.forEach(l=>{var f;return(f=l.adjustments)==null?void 0:f.forEach(k=>{const w=k.amount||0;k.code==="LOYALTY_POINTS"?g.push({code:"Punkty lojalnościowe",amount:w}):o.push({code:k.code||"Rabat",amount:w})})}),{sellerDiscounts:o,platformDiscounts:g}},[s]),p=N.useMemo(()=>{var g;let o=0;return(g=s.shipping_methods)==null||g.forEach(l=>{const f=l.amount||0,w=(l.adjustments||[]).reduce((M,B)=>M+(B.amount||0),0);f>0&&w>=f&&(o+=f)}),o},[s]),x=r.reduce((o,g)=>o+g.amount,0),j=u.reduce((o,g)=>o+g.amount,0),y=s.item_total+x+j,S=N.useMemo(()=>{const o={};return s.items.forEach(g=>{var l;(l=g.tax_lines)==null||l.forEach(f=>{o[f.code]=(o[f.code]||0)+f.total})}),s.shipping_methods.forEach(g=>{var l;(l=g.tax_lines)==null||l.forEach(f=>{o[f.code]=(o[f.code]||0)+f.total})}),o},[s]),m=!!((T=s.region)!=null&&T.automatic_taxes),_=!!Object.keys(S).length,A=(s.shipping_methods||[]).reduce((o,g)=>{const l=g.amount||0,k=(g.adjustments||[]).reduce((w,M)=>w+(M.amount||0),0);return l>0&&k>=l?o+0:o+(m?g.total||0:g.subtotal||0)},0);return e.jsxs("div",{className:"text-ui-fg-subtle flex flex-col gap-y-2 px-6 py-4",children:[e.jsx(Y,{label:e.jsxs("span",{className:"flex items-center gap-1",children:[t("orders.summary.itemSubtotal")," ",t("orders.summary.originalPrice")]}),value:O(y,s.currency_code)}),r.length>0&&e.jsx(Y,{label:e.jsxs("span",{className:"flex items-center gap-1",children:[t("orders.summary.yourPromotions"),e.jsx("span",{className:"txt-compact-xsmall text-ui-tag-orange-text bg-ui-tag-orange-bg px-1.5 py-0.5 rounded",children:t("orders.summary.yourCost")})]}),secondaryValue:r.map(o=>o.code).join(", "),value:`- ${O(x,s.currency_code)}`}),u.length>0&&e.jsx(e.Fragment,{children:u.map((o,g)=>e.jsx(Y,{label:e.jsxs("span",{className:"flex items-center gap-1",children:[o.code,e.jsx("span",{className:"txt-compact-xsmall text-ui-tag-green-text bg-ui-tag-green-bg px-1.5 py-0.5 rounded",children:t("orders.summary.platformCovers")})]}),value:`- ${O(o.amount,s.currency_code)}`},g))}),(r.length>0||u.length>0)&&e.jsx("div",{className:"border-t border-dashed my-1"}),e.jsx(Y,{label:e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[t("orders.summary.itemTotal"),e.jsx("span",{className:"txt-compact-xsmall text-ui-tag-green-text bg-ui-tag-green-bg px-1.5 py-0.5 rounded font-normal",children:t("orders.summary.youWillReceiveFull")})]}),value:O(y,s.currency_code)}),e.jsx(Y,{label:e.jsxs("span",{onClick:()=>c(o=>!o),className:"flex cursor-pointer items-center gap-1",children:[e.jsx("span",{children:t(m?"orders.summary.shippingTotal":"orders.summary.shippingSubtotal")}),p>0&&e.jsx("span",{className:"txt-compact-xsmall text-ui-tag-orange-text bg-ui-tag-orange-bg px-1.5 py-0.5 rounded",children:t("orders.summary.freeShippingYourCost")}),e.jsx(ve,{style:{transform:`rotate(${n?0:-90}deg)`}})]}),value:O(A,s.currency_code)}),n&&e.jsx("div",{className:"flex flex-col gap-1 pl-5",children:(s.shipping_methods||[]).sort((o,g)=>o.created_at.localeCompare(g.created_at)).map((o,g)=>{var M;const l=o.amount||0,k=(o.adjustments||[]).reduce((B,H)=>B+(H.amount||0),0),w=l>0&&k>=l;return e.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[e.jsx("div",{children:e.jsxs("span",{className:"txt-small text-ui-fg-subtle font-medium",children:[o.name,((M=o.detail)==null?void 0:M.return_id)&&` (${t("fields.returnShipping")})`,w&&` ${t("orders.summary.freeLabel")}`," ",e.jsx(Ct,{shippingMethod:o},g)]})}),e.jsx("div",{className:"relative flex-1",children:e.jsx("div",{className:"bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed"})}),e.jsx("span",{className:"txt-small text-ui-fg-muted",children:w?e.jsx("span",{className:"line-through text-ui-fg-disabled",children:O(l,s.currency_code)}):O(m?o.total:o.subtotal,s.currency_code)})]},o.id)})}),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("div",{onClick:()=>_&&a(o=>!o),className:ke("flex items-center gap-1",{"cursor-pointer":_}),children:[e.jsx("span",{className:"txt-small select-none",children:t(m?"orders.summary.taxTotalIncl":"orders.summary.taxTotal")}),_&&e.jsx(ve,{style:{transform:`rotate(${i?0:-90}deg)`}})]}),e.jsx("div",{className:"text-right",children:e.jsx(d,{size:"small",leading:"compact",children:O(s.tax_total,s.currency_code)})})]}),i&&e.jsx("div",{className:"flex flex-col gap-1 pl-5",children:Object.entries(S).map(([o,g])=>e.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[e.jsx("div",{children:e.jsx("span",{className:"txt-small text-ui-fg-subtle font-medium",children:o})}),e.jsx("div",{className:"relative flex-1",children:e.jsx("div",{className:"bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed"})}),e.jsx("span",{className:"txt-small text-ui-fg-muted",children:O(g,s.currency_code)})]},o))})]})]})},Tt=({order:s})=>{var i;const{t}=v();return e.jsxs("div",{className:" flex flex-col gap-y-2 px-6 py-4",children:[e.jsxs("div",{className:"text-ui-fg-base flex items-center justify-between",children:[e.jsx(d,{weight:"plus",className:"text-ui-fg-subtle",size:"small",leading:"compact",children:t("fields.total")}),e.jsx(d,{weight:"plus",className:"text-ui-fg-subtle",size:"small",leading:"compact",children:q(s.total,s.currency_code)})]}),e.jsxs("div",{className:"text-ui-fg-base flex items-center justify-between",children:[e.jsx(d,{weight:"plus",className:"text-ui-fg-subtle",size:"small",leading:"compact",children:t("fields.paidTotal")}),e.jsx(d,{weight:"plus",className:"text-ui-fg-subtle",size:"small",leading:"compact",children:q(_s(s.payment_collections||[]),s.currency_code)})]}),e.jsxs("div",{className:"text-ui-fg-base flex items-center justify-between",children:[e.jsx(d,{className:"text-ui-fg-subtle text-semibold",size:"small",leading:"compact",weight:"plus",children:t("orders.returns.outstandingAmount")}),e.jsx(d,{className:"text-ui-fg-subtle text-bold",size:"small",leading:"compact",weight:"plus",children:q(((i=s.summary)==null?void 0:i.pending_difference)||0,s.currency_code)})]})]})},ha=()=>{const s=rs(),{id:t}=ds(),{getWidgets:i}=os(),{order:a,isLoading:n,isError:c,error:r}=Se(t,{fields:le},{initialData:s});a&&(a.items=a.items.sort((x,j)=>x.created_at>j.created_at?1:x.created_at<j.created_at?-1:0));const{order:u,isLoading:p}=Oe(t);if(n||!a||p)return e.jsx(ms,{mainSections:4,sidebarSections:2,showJSON:!0});if(c)throw r;return e.jsxs(ee,{widgets:{after:i("order.details.after"),before:i("order.details.before"),sideAfter:i("order.details.side.after"),sideBefore:i("order.details.side.before")},data:a,hasOutlet:!0,children:[e.jsxs(ee.Main,{children:[e.jsx(Ks,{orderPreview:u}),e.jsx(Ws,{orderPreview:u}),e.jsx(Ys,{orderPreview:u}),e.jsx(vt,{order:a}),e.jsx(zt,{order:a}),e.jsx(Ns,{order:a}),e.jsx(ht,{order:a})]}),e.jsxs(ee.Sidebar,{children:[e.jsx(mt,{order:a}),e.jsx(it,{order:a})]})]})};export{pa as Breadcrumb,ha as Component,fa as loader};

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.