PageSourceSearch

https://ds.zopi.io/assets/js/module-DdhB1fcj.js

js zopi.io collected 2026-09-24 09:53:49 UTC 66,505 bytes, 221 lines download raw bytes

1import{r as a,j as e}from"./module-g4nfU4qS.js";import{u as tn}from"./module-CP88euwI.js";import{i as Ae,a as sn}from"./module-AkyW2Ruw.js";import{a as X,c as dn,aw as Ie,R as le,M as ye,p as S,ae as Me,ap as cn,F as re,aR as J,e as ln,U as hn,aB as Te,au as pn,C as se,W as un,N as Ee,bp as mn,h as fn,u as Cn,an as _n,ah as gn}from"../index-DWyIa0gL.js";import{H as W}from"./module-CNVTF9TH.js";import{l as P}from"./module-kEjItqhR.js";import"./module-CLsn7ldt.js";import"./module-BnWCsivz.js";import"./module-BRy6BJs6.js";import{M as be,l as K,bV as Re,bg as Ue,n as q,r as Se,C as je,m as Y,g as pe,bW as we,bX as Pe,h as Ke,a$ as Ye,bY as Ve,y as xn,aR as vn,bZ as yn,b9 as Ne,au as bn,e as oe,o as Sn,S as jn,b_ as Le,bu as An,a as Ce,at as In}from"./module-CndrmyLu.js";import{B as Mn,$ as me,a0 as Oe,a1 as kn,E as ue,a2 as _e,f as Tn,a3 as Fe,a4 as En,a5 as Rn,u as wn,v as Pn}from"./module-CxltrVFs.js";import"./module-ClTBx2Nk.js";import"./module-B0vxmspb.js";import{u as Nn,o as Ze,a as Ln}from"./module-C1JDE-Bi.js";import"./module-D2RLwbSq.js";import{a as Je}from"./module-BzM7VDfa.js";import{d as On}from"./module-CVphjg2G.js";import"./module-BjfZYBMc.js";import"./module-DtACTtM6.js";import"./module-BI5bqnt8.js";import"./module-DiCIOLtz.js";import"./module-BK4nBkK6.js";import{e as ie,f as Be,a as ge}from"./module-Bh5dGB7-.js";import{g as Fn,a as ae,f as De,A as Bn,p as de,v as We}from"./module-DYRc1myh.js";import{I as Dn}from"./module-hy_LLdhE.js";import{u as Wn}from"./module-DHRHeQUK.js";import"./module-CkAgo4Og.js";import"./module-BndIsuim.js";import"./module-CbyKh5Um.js";import"./module-CpA3Gb_i.js";import"./module-CLuAD4R5.js";import"./module-DYLXRpC5.js";import"./module-DHVO85nS.js";import"./module-BSPv5tIW.js";import"./module-BHCKjyDG.js";import"./module-M2MMyV6m.js";import"./module-BBruC8m-.js";import"./module-arTw0fVe.js";import"./module-CYrDBt6T.js";import"./module-DCoKLf-v.js";import"./module-DFeDTf4p.js";import"./module-YfaRQf3K.js";import"./module-duNjR6wQ.js";import"./module-tV3IJ5Y1.js";import"./module-C4TimWWB.js";import"./module-CZPcUW2s.js";import"./module-BDscFCCP.js";import"./module-aXdEWYlg.js";import"./module-B4SPueXG.js";import"./module-ubDpl0_R.js";import"./module-B_AESZ67.js";import"./module-C2S2-HMR.js";import"./module-JW1JAliT.js";import"./module-Dz8i_Leu.js";import"./module-BJwyIH4s.js";import"./module-BaA5LyCG.js";import"./module-D0mFdbeO.js";import"./module-Dk6e9ee8.js";import"./module-CDjUV5Ju.js";import"./module-BkD7Hj8s.js";import"./module-Cp8br37W.js";import"./module-CzD4bSOQ.js";import"./module-9lF95FHy.js";import"./module-BtzVbTB5.js";import"./module-D28oVHB0.js";import"./module-CimkQT29.js";import"./module-BUHjN4Hc.js";import"./module-BZ4M8-NE.js";import"./module-DMW1B1t5.js";import"./module-v8jY9nGA.js";import"./module-8JwjhRSi.js";import"./module-JSaEjBuK.js";import"./module-UTIhDGpo.js";import"./module-YKhy6aow.js";import"./module-BZ17SRdx.js";import"./module-BEIsiqOv.js";import"./module-fFtbNF-F.js";import"./module-DEtA-KhA.js";import"./module-CPh8vZck.js";import"./module-DKECUIcb.js";import"./module-Cxv9J64N.js";import"./module-BINVifEP.js";import"./module-B1TVd3K4.js";import"./module-DkegjUUZ.js";import"./module-v-CXq_RL.js";import"./module-BiI3u42N.js";import"./module-B-dksMZM.js";import"./module-B3BJzVxn.js";import"./module-CeFpPFS8.js";import"./module-BBjH2Bj1.js";import"./module-vs-8EVL6.js";import"./module-DKNNaWzV.js";import"./module-B57D9Y1u.js";import"./module-DsmTx7if.js";import"./module-6E4L_h32.js";import"./module-B5iLQXnX.js";import"./module-eWZP5eA7.js";import"./module-C-FQGDW9.js";import"./module-4S-c4oHJ.js";import"./module-DfWnE5ms.js";import"./module-WX_comao.js";import"./module-BJMi48_2.js";import"./module-MyE73HNZ.js";import"./module-D6GhiVEH.js";import"./module-Cl3hj7Sz.js";import"./module-FxXdmyPN.js";import"./module-FqpXQuLt.js";import"./module-D7zKsYo2.js";import"./module-C1gvLhAf.js";import"./module-B_b8ryxu.js";import"./module-Cv-JDcMf.js";import"./module-DYCwc-sD.js";import"./module-Ch_qCilz.js";import"./module-DWCyG3-x.js";import"./module-D4_bCcMT.js";import"./module-CNs1qBpV.js";import"./module-DI2Ne2_A.js";import"./module-C3-224fz.js";import"./module-C9ANKk3v.js";import"./module-CpL0MGZq.js";import"./module-DbIWH81b.js";import"./module-DrRIdSP-.js";import"./module-BSLCDnTV.js";import"./module-DjYUzTuj.js";import"./module-vcVAUzeC.js";import"./module-GAKWmy7o.js";import"./module-PQCKh0dx.js";import"./module-CEEhGtWX.js";import"./module-B7hx6Bgd.js";import"./module-BJwr7tuA.js";import"./module-BQobnMtX.js";import"./module-BMgpUYTo.js";import"./module-DbKNfynz.js";import"./module-C_aolqmU.js";
1import"./module-Cjxe2-Wq.js";import"./module-ZLXBeeQ1.js";import"./module--gfxRhYI.js";import"./module-Dsow35wU.js";import"./module-60F3QETU.js";import"./module-D8znQY54.js";import"./module-CPveMqlj.js";import"./module-D1zfnBJe.js";import"./module-D9KQvrmg.js";import"./module-FjFE2uWm.js";import"./module-xMQ5YY98.js";import"./module-Bx45xMUt.js";import"./module-DD3iYX1K.js";import"./module-D5ZndoG6.js";import"./module-DMkqpeS_.js";import"./module-CWBJcU5N.js";import"./module-D4Wp6AEg.js";import"./module-BgBfM8ME.js";import"./module-D46m5wfe.js";import"./module-DOgs_Y3Z.js";import"./module-CH9fmmFv.js";import"./module-7ux2xnsv.js";import"./module-CqnTjJDb.js";import"./module-DjKU-xAz.js";import"./module-C0ijFVsX.js";import"./module-B6B9y572.js";import"./module-DhTU8B_4.js";import"./module-5eLbDUjv.js";import"./module-c2V3InAJ.js";import"./module-SNETSEGx.js";import"./module-Qe-ESUUc.js";import"./module-Cj9qKt6Q.js";import"./module-B7EQxdU6.js";import"./module-DvhhVmnL.js";import"./module-CLQgGlmV.js";import"./module-CtXnX3Xp.js";import"./module-DZ4MRfGb.js";import"./module-BXLLueiB.js";import"./module-D-CCuB3j.js";import"./module-C-Y3moQM.js";import"./module-BmLAdfv_.js";import"./module-CQoQLGZn.js";import"./module-CsOSqbjs.js";import"./module-DpV-RknM.js";import"./module-BtHhgq7k.js";import"./module-aFQBCvBX.js";import"./module-ChDEcKkm.js";import"./module-CCzXKaxK.js";import"./module-Cgx2k5hB.js";import"./module-CFxIfOSP.js";import"./module-xvpIGbSh.js";import"./module-viLe5jBK.js";const Gn={note:null,first_name:null,last_name:null,city:null,country:null,province:null,country_code:null,province_code:null,address1:null,address2:null,zip:null,phone:null,email:null,fullname:null,phone_code:null,company:null},zn=(r,t)=>{if(!r||!t||t.length===0)throw new Error("Missing required data or selected variants");const n=t.reduce((h,s)=>{const C=s.productId;return h[C]||(h[C]=[]),h[C].push(s),h},{}),d=[];for(const h in n){const s=r.find(m=>m.source_product_id.toString()===h.toString());if(!s){console.error(`Product with ID ${h} not found`);continue}const C=new Map;for(const m of s.variants)C.set(m.id.toString(),m);const x=n[h].map(m=>{const i=C.get(m.variantId);if(!i)return console.error(`Variant with ID ${m.variantId} not found in product ${h}`),null;const f=m.productId,c=m.variantId;return{total_quantity:i.quantity??0,quantity:1,source:s.source,line_item_id:null,name:s.title,image:i.image??s.image,sku_id:i.sku_id,options:i.options??{},price_usd:null,cost_price:parseFloat(i.cost_price),price:i.price,product_id:f,variant_id:c.toString(),warehouses:"",supplier_id:0,product_link:s?.product_link||"",variant_name:i.name??"",supplier_name:"",source_variant_id:i.source_variant_id??null}});d.push(...x.filter(m=>m!==null))}return d},$n=r=>{const t=new Map;for(const{product_id:n,image:d}of r)(t.get(n)||t.set(n,new Set).get(n)).add(d);return Object.fromEntries(Array.from(t,([n,d])=>[n,Array.from(d)]))},Ge=r=>r?r.replace("day"," days"):"-",Hn=a.forwardRef(({type:r="import",onImportOrder:t},n)=>{const{t:d}=X(),h=Je(),{isDemoMode:s,onShowUpgradePlanDemoMode:C}=dn();Mn();const{token:x,cancel:m}=Ie(),[i,f]=a.useState(!1),[c,u]=a.useState(null),[M,j]=a.useState(!0),[k,_]=a.useState(!0),[F,g]=a.useState(""),[z,v]=a.useState(!1),[b,N]=a.useState(r!=="import"),[o,p]=a.use
1State({selectOption:"",selectedOrder:""}),A=a.useRef(null),R=a.useMemo(()=>({order_by:"created_at",sort:"desc",page:1,page_size:20,keyword:F}),[F]),{listData:y,listLoading:U,listLoadingMore:V,fetchList:l,loadMore:L,hasMore:B}=Nn(R),{convertPriceWithFormatter:Z}=me(),ee=a.useRef(!1),I=a.useRef(null),T=a.useRef(null);a.useImperativeHandle(n,()=>({open:()=>f(!0),close:()=>f(!1)}));const E=a.useCallback(({key:O,value:ne})=>{p(te=>({...te,[O]:ne}))},[]),D=a.useCallback(()=>(z||!k)&&!M?(E({key:"selectOption",value:"SelectAtLeastOption"}),!1):(E({key:"selectOption",value:""}),!0),[z,E,k,M]),$=a.useCallback(O=>{g(O),u(null),v(!1)},[]),w=a.useCallback(O=>{$(O)},[$]),G=a.useMemo(()=>y?.orders?y.orders.map(O=>({value:O.id.toString(),label:[O?.order_name||"N/A",[O.fullname,O.city].filter(Boolean).join(", ")||"N/A",`${Number(O?.total_item||0).toLocaleString("en")} ${d("Items").toLowerCase()}`,O.total_price?Z(O.total_price,!1):"N/A"].join(" - ")})):[],[y]),H=a.useCallback(O=>{const ne=y?.orders.find(te=>te.id.toString()===O);ne&&(ne.has_mapped_items||v(!0),u(O),g(ne.order_name||"N/A"))},[y?.orders]),Q=()=>{if(s()){f(!1),C("PRODUCT_LISTING");return}D()&&c&&(t?.({order_id:c||"",includes:P.join(P.compact([M&&"customer",k&&"line_items"]),",")}),fe())},nn=()=>{if(s()){f(!1),C("ORDER_FULFILLMENT");return}(D()||b)&&h({pathname:le.ORDER_LIST.SUBROUTES.CREATE_ORDER.PATH,search:b?"":`?order_id=${c}&includes=${P.join(P.compact([M&&"customer",k&&"line_items"]),",")}`})},fe=()=>{f(!1),u(null),j(!0),_(!0),g(""),v(!1),T.current&&clearTimeout(T.current)};a.useEffect(()=>(A.current=P.debounce(O=>{l(O,x)},500),()=>{A.current?.cancel()}),[]),a.useEffect(()=>{if(!i){ee.current=!1;return}if(!b)return ee.current?A.current&&A.current(R):(l(R,x),ee.current=!0),()=>{m()}},[i,R,b]),a.useEffect(()=>{if(!i||b||!I.current||U)return;const O=new IntersectionObserver(te=>{te[0].isIntersecting&&!U&&!V&&B&&L(x)},{root:I.current,threshold:0}),ne=I.current.querySelector(".sentinel");return ne&&O.observe(ne),()=>{O.disconnect()}},[i,b,U,V,B]),a.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const on=()=>U?e.jsx(q,{align:"center",children:e.jsx(Y,{padding:"200",children:e.jsx(pe,{size:"small"})})}):G.length===0&&!U&&!V?e.jsx(Y,{padding:"200",children:e.jsx(S,{alignment:"center",variant:"bodyMd",tone:"subdued",as:"span",children:F?d("NoResultsFoundFor",{var_keyword:e.jsx("b",{children:F})}):d("NoResultsFound")})}):e.jsxs(we,{onSelect:H,children:[G.map(O=>e.jsx(we.Option,{value:O.value,selected:c===O.value,children:O.label},O.value)),V&&e.jsx(q,{align:"center",children:e.jsx(Y,{padding:"200",children:e.jsx(pe,{size:"small"})})})]}),ke=()=>e.jsxs(K,{gap:"400",children:[e.jsx(Re,{activator:e.jsx(Re.TextField,{clearButton:!0,onClearButtonClick:()=>$(""),prefix:e.jsx(ye,{source:Ue}),onChange:w,label:"Select an order",labelHidden:!0,value:F,placeholder:d("SearchByOrderID"),autoComplete:"off",disabled:b}),children:e.jsxs("div",{ref:I,style:{maxHeight:"250px",overflowY:"auto"},children:[on(),e.jsx("div",{className:"sentinel",style:{height:"1px"}})]})}),e.jsxs(K,{gap:"200",children:[e.jsxs(q,{gap:"200",blockAlign:"center",children:[e.jsx(S,{variant:"headingSm",as:"h3",children:d("InformationToImport")}),o.selectOption&&e.jsx(Se,{message:d(o.selectOption),fieldID:"errorMessage"})]}),e.jsx(je,{disabled:b,label:d("UpdateCustomerInformation"),checked:M,onChange:O=>j(O)}),e.jsx(je,{disabled:z||b,label:d("AddLineItem"),checked:k,onChange:O=>_(O)})]})]}),an=()=>e.jsxs(K,{gap:"400",children:[e.jsx(Oe,{checked:b,onChange:()=>N(!0),label:d("CreateFromBlank")}),e.jsxs(K,{gap:"200",children:[e.jsx(Oe,{checked:!b,onChange:()=>N(!1),label:d("ImportInformationFromAnother")}),e.jsx(Y,{paddingInline:"400",children:ke()})]})]}),rn=r==="import"?{content:d("Import"),onAction:Q,disabled:!c||V}:{content:d("Add"),onAction:nn,disabled:!b&&!c||V};return e.jsx(be,{open:i,onClose:fe,title:d(r==="import"?"ImportOrderInformation":"CreateNewOrder"),primaryAction:rn,secondaryActions:[{content:d("Cancel"),onAction:fe}],children:e.jsx(be.Section,{children:r==="import"?ke():an()})})}),qn=()=>({fetchLogistics:a.useCallback(async(t,n,d="US")=>{try{const h=t.map(x=>kn.getProductLogistics({params:{...x,ship_from:"CN",country_code:d},token:n}));return(await Promise.all(h)).map((x,m)=>{const{data:i,status:f}=x,c=t[m];if(f===Me.OK&&i?.logistics?.length){const u=i.logistics.reduce((M,j)=>j.amount<M.amount?j:M);return{source:c.source,product_id:c.product_id,sub_variant_id:c.sub_variant_id,shipping_fee:u.amount,shipping_service:u.service_name,shipping_time:u.delivery_time,shipping_process:u.processing_time||""}}return{source:c.source,product_id:c.product_id,sub_variant_id:c.sub_variant_id,shipping_fee:null,shipping_service:null,shipping_time:null,shipping_process:null}})}catch(h){return Ae(h)?(console.log("Request cancelled"),[]):(console.error("Error fetching logistics:",h),[])}},[])}),Un=r=>
1{const[t,n]=a.useState(null),[d,h]=a.useState(!1),[s,C]=a.useState(!1),x=a.useCallback(async(f=r,c,u=!1)=>{try{u?C(!0):h(!0);const{data:M,status:j}=await Ze.getProductOrderList(f,c);if(j===Me.OK&&M)n(u?k=>({total:M?.total||0,products:[...k?.products||[],...M.products]}):M);else throw new Error(`API returned status: ${j}`)}catch(M){if(Ae(M)){console.log("Request cancelled");return}}finally{u?C(!1):h(!1)}},[r,t]),m=a.useCallback((f,c)=>{x(f,c,!1)},[x]),i=a.useCallback(f=>{if(!t||d||s)return;const c=Math.floor(t.products.length/r.page_size)+1,u={...r,page:c};x(u,f,!0)},[t,d,s,r,x]);return{data:t,loading:d,loadingMore:s,fetch:m,loadMore:i,hasMore:t?t.products.length<t.total:!1}},Kn=W.div`
2  width: 70px;
3`,Yn=W.div`
4  max-width: 85%;
5`,Xe=a.memo(({item:r,selectedVariants:t,variantIdSelected:n,onSelectProduct:d,onSelectVariant:h})=>{const{t:s}=X(),{convertPriceWithFormatter:C}=me(),x=r.type==="header",m=a.useCallback(()=>{if(!x)return{checked:!1,indeterminate:!1};const M=r.product.variants.length,j=r.product.variants.filter(F=>t.some(g=>g.productId===r.product.source_product_id&&g.variantId===F.id+"")).length,k=j===M,_=j>0&&j<M;return{checked:k,indeterminate:_}},[x,r,t]),{checked:i,indeterminate:f}=m(),c=a.useCallback(()=>{d(r.product)},[r.product,d]),u=a.useCallback(()=>{r.variant&&h(r.product.source_product_id,r.variant.id+"")},[r.product.source_product_id,r.variant,h]);return e.jsx(e.Fragment,{children:x?e.jsx(Pe,{id:r.product.source_product_id,onClick:c,persistActions:!0,children:e.jsxs(q,{gap:"200",wrap:!1,children:[e.jsx(Kn,{children:e.jsxs(q,{blockAlign:"center",align:"center",wrap:!1,children:[e.jsx(je,{label:"",checked:f?"indeterminate":i,onChange:c}),e.jsx("div",{children:e.jsx(ue,{size:"small",source:r.product.image,alt:r.product.source_product_id||""})})]})}),e.jsx(Yn,{children:e.jsx(S,{breakWord:!0,as:"span",children:r.product.title})})]})}):e.jsx(Pe,{id:`${r.product.source_product_id}-${r.variant?.id}`,onClick:u,persistActions:!0,children:e.jsx("div",{style:{paddingLeft:25},children:e.jsxs(q,{gap:"200",align:"space-between",children:[e.jsxs(q,{gap:"200",wrap:!1,children:[e.jsx("div",{onClick:M=>M.stopPropagation(),children:e.jsx(cn,{disabled:P.includes(n,r.variant?.id+""),label:"",checked:t.some(M=>M.productId===r.product.source_product_id&&M.variantId===r.variant?.id+""),onChange:u})}),e.jsx(ue,{size:"extraSmall",source:r.variant?.image,alt:r.variant?.name}),e.jsx("div",{style:{maxWidth:320},children:e.jsx(S,{as:"span",variant:"bodyMd",truncate:!0,children:Object.values(r.variant?.options||{}).join(" / ")})})]}),e.jsxs(q,{gap:"400",children:[e.jsxs(S,{as:"span",variant:"bodyMd",tone:"subdued",children:[Number(r.variant?.quantity||0).toLocaleString("en")," ",s("Instock")]}),e.jsx(S,{as:"span",variant:"bodyMd",children:r.variant?.cost_price?C(Number(r.variant.cost_price),!1):"-"})]})]})})})})}),Vn=W.div`
6  max-height: 400px;
7  min-height: 400px;
8  overflow-y: auto;
9  position: relative;
10`,Zn=W.div`
11  position: sticky;
12  top: 0;
13  left: 0;
14  width: 100%;
15  height: 65px;
16  background: white;
17  z-index: 10;
18  border-bottom: 1px solid #dfe3e8;
19
20  .Polaris-ResourceItem__ListItem {
21    list-style: none;
22  }
23`,Jn=W.div`
24  height: ${({isHeader:r})=>r?"65px":"50px"};
25  background: ${({isHeader:r})=>r?"white":"transparent"};
26  border-bottom: 1px solid #dfe3e8;
27  margin: 0;
28  padding: 0;
29  position: absolute;
30  top: 0;
31  left: 0;
32  width: 100%;
33`,Xn=W.div`
34  display: flex;
35  align-items: center;
36  justify-content: center;
37  height: 400px;
38`,Qn=W.div`
39  & ul {
40    list-style: none;
41    padding: 0;
42    margin: 0;
43  }
44
45  & li {
46    list-style: none;
47    margin: 0;
48    padding: 0;
49  }
50
51  & > div {
52    margin: 0;
53    padding: 0;
54  }
55`,eo=W.div`
56  height: 1px;
57`,no=a.memo(()=>e.jsx(Xn,{children:e.jsx(pe,{accessibilityLabel:"Loading products",size:"large"})})),oo=a.memo(()=>e.jsx(Y,{padding:"200",children:e.jsx(q,{align:"center",children:e.jsx(pe,{accessibilityLabel:"Loading more products",size:"small"})})})),ao=a.memo(({searchValue:r})=>{const{t}=X();return e.jsx(Y,{paddingInline:"400",paddingBlockEnd:"400",children:e.jsx(S,{alignment:"center",as:"span",variant:"bodyMd",tone:"subdued",children:r?t("NoResultsFoundFor",{var_keyword:e.jsx("b",{children:r})}):t("NoResultsFound")})})}),ro=a.memo(({item:r,selectedVariants:t,variantIdSelected:n,onSelectProduct:d,onSelectVariant:h})=>e.jsx(Zn,{children:e.jsx(Xe,{variantIdSelected:n,item:r,selectedVariants:t,onSelectProduct:d,onSelectVariant:h})})),to=({products:r=[],loading:t,loadingMore:n,hasMore:d,selectedVariants:h,searchValue:s,variantIdSelected:C,onLoadMore:x,handleSelectProduct:m,handleSelectVariant:i})=>
57{const f=a.useRef(null),c=a.useRef(null),[u,M]=a.useState(null),j=a.useRef(!1),k=a.useMemo(()=>{const v=[];if(!Array.isArray(r))return v;let b=0;return r.forEach(N=>{v.push({type:"header",product:N,productIndex:b}),Array.isArray(N.variants)&&N.variants.forEach(o=>{v.push({type:"variant",product:N,variant:o,productIndex:b})}),b++}),v},[r]),_=On({count:k.length,getScrollElement:()=>f.current,estimateSize:a.useCallback(v=>k[v]?.type==="header"?65:50,[k]),overscan:5}),F=_.getVirtualItems();a.useEffect(()=>{if(!c.current||!d||t||n)return;const v=new IntersectionObserver(b=>{b[0].isIntersecting&&x()},{root:f.current,rootMargin:"50px",threshold:0});return v.observe(c.current),()=>{c.current&&v.unobserve(c.current)}},[d,t,n,x]);const g=a.useCallback(()=>{!f.current||j.current||(j.current=!0,requestAnimationFrame(()=>{if(!f.current){j.current=!1;return}const v=f.current.scrollTop;let b=null;const N=_.getVirtualItems();for(const o of N){const p=k[o.index];if(!p)continue;const A=o.start,R=p.type==="header"?65:50,y=A+R;if(v>=A&&v<y){for(let U=o.index;U>=0;U--)if(k[U]?.type==="header"){b=U;break}break}}if(b===null&&k.length>0){for(let o=k.length-1;o>=0;o--)if(k[o]?.type==="header"){const p=_.getVirtualItems().find(R=>R.index===o);if((p?p.start:0)<=v){b=o;break}}}u!==b&&M(b),j.current=!1}))},[k,_,u]);a.useEffect(()=>{const v=f.current;return v&&v.addEventListener("scroll",g,{passive:!0}),()=>{v&&v.removeEventListener("scroll",g)}},[g]);const z=()=>{if(t)return e.jsx(no,{});if(k.length===0)return s?e.jsx(ao,{searchValue:s}):null;const v=u!==null?k[u]:null,b=v?.type==="header";return e.jsxs(e.Fragment,{children:[b&&e.jsx(ro,{item:v,selectedVariants:h,variantIdSelected:C,onSelectProduct:m,onSelectVariant:i}),e.jsxs(Qn,{children:[e.jsx("div",{style:{height:_.getTotalSize(),position:"relative"},children:F.map(N=>{const o=k[N.index];if(!o)return null;const p=o.type==="header";if(p&&u===N.index)return null;const A=u!==null&&N.index>u?-65:0;return e.jsx(Jn,{isHeader:p,"data-index":N.index,ref:_.measureElement,style:{transform:`translateY(${N.start+A}px)`},children:e.jsx(Xe,{variantIdSelected:C,selectedVariants:h,item:o,onSelectProduct:m,onSelectVariant:i})},N.key)})}),e.jsx(eo,{ref:c})]}),n&&e.jsx(oo,{})]})};return e.jsx(Vn,{ref:f,children:z()})},so=a.memo(to),io=a.forwardRef(({products:r,selectedVariants:t,onSelectVariant:n,onAdd:d},h)=>{const{t:s}=X(),[C,x]=a.useState(!1),[m,i]=a.useState(""),{token:f,cancel:c}=Ie(),u=a.useRef(null),M=a.useRef(!1),j=a.useMemo(()=>({keyword:m,page:1,page_size:10}),[m]),{data:k,loading:_,loadingMore:F,fetch:g,loadMore:z,hasMore:v}=Un(j),b=a.useMemo(()=>r.map(y=>y.variant_id),[r]);a.useEffect(()=>(u.current=P.debounce(y=>{g(y,f)},500),()=>{u.current?.cancel()}),[]),a.useEffect(()=>{if(!C){M.current=!1;return}return M.current?u.current&&u.current(j):(g(j,f),M.current=!0),()=>{c()}},[C,j]),a.useImperativeHandle(h,()=>({open:()=>requestAnimationFrame(()=>x(!0)),close:()=>requestAnimationFrame(()=>x(!1))}));const N=y=>{i(y)},o=y=>{requestAnimationFrame(()=>{if(y.variants.every(V=>t.some(l=>l.productId===y.source_product_id&&l.variantId===V.id+""))){const V=t.filter(l=>l.productId!==y.source_product_id||b.includes(l.variantId));n(V)}else{const V=y.variants.map(l=>({productId:y.source_product_id,variantId:l.id+""}));n([...t.filter(l=>l.productId!==y.source_product_id),...V])}})},p=(y,U)=>{requestAnimationFrame(()=>{const V={productId:y,variantId:U};n(t.some(l=>l.productId===y&&l.variantId===U)?t.filter(l=>!(l.productId===y&&l.variantId===U)):[...t,V])})},A=()=>{requestAnimationFrame(()=>{const y=zn(k?.products||[],t);d(y),x(!1)})},R=()=>{requestAnimationFrame(()=>{x(!1)})};return e.jsx(be,{open:C,onClose:R,title:s("AddProduct"),primaryAction:{content:"Add",onAction:A,disabled:t.length===0},secondaryActions:[{content:"Cancel",onAction:R}],footer:e.jsxs(S,{alignment:"start",variant:"bodyMd",as:"p",children:[e.jsx("strong",{children:t.length}),"/",P.sumBy(k?.products,y=>y.variants.length)," ",s("VariantsSelected")]}),children:e.jsxs(K,{gap:"400",children:[e.jsx(Y,{padding:"200",children:e.jsx(Ke,{label:"",labelHidden:!0,clearButton:!0,value:m,onClearButtonClick:()=>N(""),onChange:N,placeholder:"Search products",autoComplete:"off"})}),e.jsx(so,{variantIdSelected:b,products:k?.products||[],loading:_,loadingMore:F,hasMore:v,selectedVariants:t,searchValue:m,handleSelectProduct:o,handleSelectVariant:p,onLoadMore:()=>{z(f)}})]})})}),co=({note:r="",onSaveNote:t})=>{const{t:n}=X(),d=a.useRef(null);return e.jsx(Y,{background:"bg-fill",borderRadius:"300",padding:"400",shadow:"100",borderColor:"border",borderWidth:"025",children:e.jsxs(K,{gap:"400",children:[e.jsxs(q,{align:"space-between",blockAlign:"center",children:[e.jsx(S,{variant:"headingMd",as:"h2",children:n("Note")}),e.jsx(re,{variant:"tertiary",icon:Ye,onClick:()=>d.current?.open()})]}),r?e.jsx(S,{variant:"bodyMd",as:"p",children:r}):e.jsx(S,{variant:"headingMd",as:"h2",tone:"subdued",children:n("NoNote")})]})})},xe=W.div`
58  display: flex;
59  align-items: center;
60`,lo=({products:r,onUpdateProduct:t,onOpenModal:n,onRemoveProduct:d})=>{const{t:h}=X(),{convertPriceWithFormatter:s}
60=me(),C=a.useCallback(({data:i,id:f})=>{const c=r.map(u=>u?.variant_id===f?{...u,...i}:u);t(c)},[r,t]),x=a.useCallback(i=>{d(i)},[d]),m=r.map((i,f)=>[e.jsx(xe,{children:e.jsxs(q,{wrap:!1,gap:"400",blockAlign:"center",align:"center",children:[e.jsx(ue,{source:i.image,alt:i.name||"",size:"small"}),e.jsx("div",{style:{maxWidth:350},children:e.jsx(S,{truncate:!0,as:"span",variant:"bodyMd",children:i.name})})]})},`info-${f}`),e.jsx(xe,{children:e.jsx("div",{style:{maxWidth:150},children:e.jsx(Ve,{children:e.jsx(S,{as:"span",variant:"bodyMd",truncate:!0,children:Object.values(i.options).join(" / ")})})})},`options-${f}`),e.jsx(xe,{children:e.jsx("div",{style:{width:90},children:e.jsx(J,{onBlur:()=>{(!i.quantity||i.quantity<1)&&C({data:{quantity:1},id:i.variant_id})},autoComplete:"off",type:"number",min:"0",label:"",labelHidden:!0,value:i.quantity+"",onChange:c=>{C({data:{quantity:Number(c)},id:i.variant_id})}})})},`quantity-${f}`),e.jsx("div",{style:{width:80},children:e.jsx(S,{as:"span",variant:"bodyMd",children:s(P.multiply(Number(i.cost_price),i.quantity),!1)})},`quantity-${f}`),e.jsx("div",{children:e.jsx(re,{onClick:()=>x({product_id:i.product_id,variant_id:i.variant_id}),icon:xn,variant:"tertiary"})},`remove-${f}`)]);return e.jsxs("div",{children:[e.jsx(Y,{paddingInline:"400",paddingBlockStart:"400",children:e.jsxs(K,{gap:"100",children:[e.jsx(S,{variant:"headingSm",as:"h2",children:h("Products")}),e.jsx(Ke,{placeholder:h("AddProduct"),onFocus:()=>requestAnimationFrame(()=>n()),prefix:e.jsx(ye,{source:Ue}),suffix:e.jsx(ye,{source:vn}),label:"",labelHidden:!0,autoComplete:"off"})]})}),P.size(m)?e.jsx(ho,{children:e.jsx(yn,{verticalAlign:"middle",columnContentTypes:["text","text","text","text","text"],headings:[h("Items"),"",h("Quantity"),h("Cost"),""],rows:m,totals:["","",P.sumBy(r,i=>i.quantity),s(P.sumBy(r,i=>Number(i.cost_price)*i.quantity),!1),""],showTotalsInFooter:!0,totalsName:{singular:"Total",plural:"Total"}})}):e.jsx(Y,{padding:"400",children:e.jsx(S,{alignment:"center",as:"p",variant:"bodyMd",tone:"subdued",children:h("NoItemsYet")})})]})},ho=W.div`
61  position: relative;
62
63  .Polaris-DataTable {
64    position: relative;
65  }
66
67  .Polaris-DataTable__TableRow--footer {
68    position: sticky;
69    bottom: 0;
70    background-color: #fff;
71    z-index: 1;
72    border-top: 1px solid #dfe3e8;
73  }
74`,ze=[{code:"AF",hasChildren:!1,name:"Afghanistan",phone_code:"93"},{code:"ALA",hasChildren:!1,name:"Aland Islands",phone_code:"358"},{code:"AL",hasChildren:!1,name:"Albania",phone_code:"355"},{code:"GBA",hasChildren:!1,name:"Alderney",phone_code:"44"},{code:"DZ",hasChildren:!1,name:"Algeria",phone_code:"213"},{code:"AS",hasChildren:!1,name:"American Samoa",phone_code:"1"},{code:"AD",hasChildren:!1,name:"Andorra",phone_code:"376"},{code:"AO",hasChildren:!1,name:"Angola",phone_code:"244"},{code:"AI",hasChildren:!1,name:"Anguilla",phone_code:"1"},{code:"AG",hasChildren:!1,name:"Antigua and Barbuda",phone_code:"1"},{code:"AR",hasChildren:!0,name:"Argentina",phone_code:"54"},{code:"AM",hasChildren:!1,name:"Armenia",phone_code:"374"},{code:"AW",hasChildren:!1,name:"Aruba",phone_code:"297"},{code:"ASC",hasChildren:!1,name:"Ascension Island",phone_code:"61"},{code:"AU",hasChildren:!0,name:"Australia",phone_code:"61"},{code:"AT",hasChildren:!0,name:"Austria",phone_code:"43"},{code:"AZ",hasChildren:!1,name:"Azerbaijan",phone_code:"994"},{code:"BS",hasChildren:!1,name:"Bahamas",phone_code:"1"},{code:"BH",hasChildren:!1,name:"Bahrain",phone_code:"973"},{code:"BD",hasChildren:!1,name:"Bangladesh",phone_code:"880"},{code:"BB",hasChildren:!1,name:"Barbados",phone_code:"1"},{code:"BY",hasChildren:!1,name:"Belarus",phone_code:"375"},{code:"BE",hasChildren:!0,name:"Belgium",phone_code:"32"},{code:"BZ",hasChildren:!1,name:"Belize",phone_code:"501"},{code:"BJ",hasChildren:!1,name:"Benin",phone_code:"229"},{code:"BM",hasChildren:!1,name:"Bermuda",phone_code:"1"},{code:"BT",hasChildren:!1,name:"Bhutan",phone_code:"975"},{code:"BO",hasChildren:!1,name:"Bolivia",phone_code:"591"},{code:"BA",hasChildren:!1,name:"Bosnia and Herzegovina",phone_code:"387"},{code:"BW",hasChildren:!1,name:"Botswana",phone_code:"267"},{code:"BR",hasChildren:!0,name:"Brazil",phone_code:"55"},{code:"VG",hasChildren:!1,name:"Virgin Islands (British)",phone_code:"1"},{code:"BN",hasChildren:!1,name:"Brunei",phone_code:"673"},{code:"BG",hasChildren:!1,name:"Bulgaria",phone_code:"359"},{code:"BF",hasChildren:!1,name:"Burkina Faso",phone_code:"226"},{code:"BI",hasChildren:!1,name:"Burundi",phone_code:"257"},{code:"KH",hasChildren:!1,name:"Cambodia",phone_code:"855"},{code:"CM",hasChildren:!1,name:"Cameroon",phone_code:"237"},{code:"CA",hasChildren:!0,name:"Canada",phone_code:"1"},{code:"CV",hasChildren:!1,name:"Cape Verde",phone_code:"238"},{code:"BQ",hasChildren:!1,name:"Caribbean Netherlands",phone_code:"599  "},{code:"KY",hasChildren:!1,name:"Cayman Islands",phone_code:"1"},{code:"CF",hasChildren:!1,name:"Central African Republic",phone_code:"236"},{code:"TD",hasChildren:!1,name:"Chad",phone_code:"235"},{code:"CL",hasChildren:!0,name:"Chile",phone_code:"56"},{code:"CX",hasChildren:!1,name:"Christmas Island",phone_code:"61"},{code:"CC",hasChildren:!1,name:"Cocos (Keeling) Islands",phone_code:"61"},{code:"CO",hasChildren:!0,name:"Colombia",phone_code:"57"},{code:"KM",hasChildren:!1,name:"Comoros",phone_code:"269"},{code:"ZR",hasChildren:!1,name:"Congo, The Democratic Republic Of The",phone_code:"243"},{code:"CK",hasChildren:!1,name:"Cook Islands",phone_code:"682"},{code:"CR",hasChildren:!1,name:"Costa Rica",phone_code:"506"},{code:"CI",hasChildren:!1,name:"Cote D'Ivoire",phone_code:"225"},{code:"HR",hasChildren:!1,name:"Croatia",phone_code:"385"},{code:"CW",hasChildren:!1,name:"Curacao",phone_code:"599"},{code:"CY",hasChildren:!1,name:"Cyprus",phone_code:"357"},{code:"CZ",hasChildren:!0,name:"Czech Republic",phone_code:"420"},{code:"DK",hasChildren:!1,name:"Denmark",phone_code:"45"},{code:"DJ",hasChildren:!1,name:"Djibouti",phone_code:"253"},{code:"DM",hasChildren:!1,name:"Dominica",phone_code:"1"},{code:"DO",hasChildren:!1,name:"Dominican Republic",phone_code:"1"},{code:"TLS",hasChildren:!1,name:"Timor-Leste",phone_code:"670"},{code:"EC",hasChildren:!1,name:"Ecuador",phone_code:"593"}
74,{code:"EG",hasChildren:!1,name:"Egypt",phone_code:"20"},{code:"SV",hasChildren:!1,name:"El Salvador",phone_code:"503"},{code:"GQ",hasChildren:!1,name:"Equatorial Guinea",phone_code:"240"},{code:"ER",hasChildren:!1,name:"Eritrea",phone_code:"291"},{code:"EE",hasChildren:!1,name:"Estonia",phone_code:"372"},{code:"ET",hasChildren:!1,name:"Ethiopia",phone_code:"251"},{code:"FK",hasChildren:!1,name:"Falkland Islands (Malvinas)",phone_code:"500"},{code:"FO",hasChildren:!1,name:"Faroe Islands",phone_code:"298"},{code:"FJ",hasChildren:!1,name:"Fiji",phone_code:"679"},{code:"FI",hasChildren:!1,name:"Finland",phone_code:"358"},{code:"FR",hasChildren:!0,name:"France",phone_code:"33"},{code:"PF",hasChildren:!1,name:"French Polynesia",phone_code:"689"},{code:"GA",hasChildren:!1,name:"Gabon",phone_code:"241"},{code:"GM",hasChildren:!1,name:"Gambia",phone_code:"220"},{code:"GE",hasChildren:!1,name:"Georgia",phone_code:"995"},{code:"DE",hasChildren:!0,name:"Germany",phone_code:"49"},{code:"GH",hasChildren:!1,name:"Ghana",phone_code:"233"},{code:"GI",hasChildren:!1,name:"Gibraltar",phone_code:"350"},{code:"GR",hasChildren:!1,name:"Greece",phone_code:"30"},{code:"GL",hasChildren:!1,name:"Greenland",phone_code:"299"},{code:"GD",hasChildren:!1,name:"Grenada",phone_code:"1"},{code:"GP",hasChildren:!1,name:"Guadeloupe",phone_code:"590"},{code:"GU",hasChildren:!1,name:"Guam",phone_code:"1"},{code:"GT",hasChildren:!1,name:"Guatemala",phone_code:"502"},{code:"GGY",hasChildren:!1,name:"Guernsey",phone_code:"44"},{code:"GN",hasChildren:!1,name:"Guinea",phone_code:"224"},{code:"GW",hasChildren:!1,name:"Guinea-Bissau",phone_code:"245"},{code:"GY",hasChildren:!1,name:"Guyana",phone_code:"592"},{code:"GF",hasChildren:!1,name:"French Guiana",phone_code:"594"},{code:"HT",hasChildren:!1,name:"Haiti",phone_code:"509"},{code:"HN",hasChildren:!1,name:"Honduras",phone_code:"504"},{code:"HK",hasChildren:!1,name:"Hong Kong,China",phone_code:"852"},{code:"HU",hasChildren:!1,name:"Hungary",phone_code:"36"},{code:"IS",hasChildren:!1,name:"Iceland",phone_code:"354"},{code:"IN",hasChildren:!0,name:"India",phone_code:"91"},{code:"ID",hasChildren:!0,name:"Indonesia",phone_code:"62"},{code:"IQ",hasChildren:!1,name:"Iraq",phone_code:"964"},{code:"IE",hasChildren:!1,name:"Ireland",phone_code:"353"},{code:"IL",hasChildren:!0,name:"Israel",phone_code:"972"},{code:"IT",hasChildren:!0,name:"Italy",phone_code:"39"},{code:"JM",hasChildren:!1,name:"Jamaica",phone_code:"1"},{code:"JP",hasChildren:!0,name:"Japan",phone_code:"81"},{code:"JEY",hasChildren:!1,name:"Jersey",phone_code:"44"},{code:"JO",hasChildren:!1,name:"Jordan",phone_code:"962"},{code:"KZ",hasChildren:!0,name:"Kazakhstan",phone_code:"7"},{code:"KE",hasChildren:!1,name:"Kenya",phone_code:"254"},{code:"KI",hasChildren:!1,name:"Kiribati",phone_code:"686"},{code:"KR",hasChildren:!0,name:"Korea",phone_code:"82"},{code:"KS",hasChildren:!1,name:"Kosovo",phone_code:"383"},{code:"KW",hasChildren:!1,name:"Kuwait",phone_code:"965"},{code:"KG",hasChildren:!1,name:"Kyrgyzstan",phone_code:"996"},{code:"LA",hasChildren:!1,name:"Lao People's Democratic Republic",phone_code:"856"},{code:"LV",hasChildren:!1,name:"Latvia",phone_code:"371"},{code:"LB",hasChildren:!1,name:"Lebanon",phone_code:"961"},{code:"LS",hasChildren:!1,name:"Lesotho",phone_code:"266"},{code:"LR",hasChildren:!1,name:"Liberia",phone_code:"231"},{code:"LY",hasChildren:!1,name:"Libya",phone_code:"218"},{code:"LI",hasChildren:!1,name:"Liechtenstein",phone_code:"423"},{code:"LT",hasChildren:!1,name:"Lithuania",phone_code:"370"},{code:"LU",hasChildren:!1,name:"Luxembourg",phone_code:"352"},{code:"MO",hasChildren:!1,name:"Macau,China",phone_code:"853"},{code:"MG",hasChildren:!1,name:"Madagascar",phone_code:"261"},{code:"MW",hasChildren:!1,name:"Malawi",phone_code:"265"},{code:"MY",hasChildren:!0,name:"Malaysia",phone_code:"60"},{code:"MV",hasChildren:!1,name:"Maldives",phone_code:"960"},{code:"ML",hasChildren:!1,name:"Mali",phone_code:"223"},{code:"MT",hasChildren:!1,name:"Malta",phone_code:"356"},{code:"MH",hasChildren:!1,name:"Marshall Islands",phone_code:"692"},{code:"MQ",hasChildren:!1,name:"Martinique",phone_code:"596"},{code:"MR",hasChildren:!1,name:"Mauritania",phone_code:"222"},{code:"MU",hasChildren:!1,name:"Mauritius",phone_code:"230"},{code:"YT",hasChildren:!1,name:"Mayotte",phone_code:"269"},{code:"MX",hasChildren:!0,name:"Mexico",phone_code:"52"},{code:"FM",hasChildren:!1,name:"Micronesia",phone_code:"691"},{code:"MC",hasChildren:!1,name:"Monaco",phone_code:"377"},{code:"MN",hasChildren:!1,name:"Mongolia",phone_code:"976"},{code:"MNE",hasChildren:!1,name:"Montenegro",phone_code:"382"},{code:"MS",hasChildren:!1,name:"Montserrat",phone_code:"1"},{code:"MA",hasChildren:!0,name:"Morocco",phone_code:"212"},{code:"MZ",hasChildren:!1,name:"Mozambique",phone_code:"258"},{code:"MM",hasChildren:!1,name:"Myanmar",country_name:"Myanmar",phone_code:"95"},{code:"NA",hasChildren:!1,name:"Namibia",phone_code:"264"}
74,{code:"NR",hasChildren:!1,name:"Nauru",phone_code:"674"},{code:"NP",hasChildren:!1,name:"Nepal",phone_code:"977"},{code:"NL",hasChildren:!0,name:"Netherlands",phone_code:"31"},{code:"AN",hasChildren:!1,name:"Netherlands Antilles",phone_code:"599"},{code:"NC",hasChildren:!1,name:"New Caledonia",phone_code:"687"},{code:"NZ",hasChildren:!0,name:"New Zealand",phone_code:"64"},{code:"NI",hasChildren:!1,name:"Nicaragua",phone_code:"505"},{code:"NE",hasChildren:!1,name:"Niger",phone_code:"227"},{code:"NG",hasChildren:!0,name:"Nigeria",phone_code:"234"},{code:"NU",hasChildren:!1,name:"Niue",phone_code:"683"},{code:"NF",hasChildren:!1,name:"Norfolk Island",phone_code:"672"},{code:"MK",hasChildren:!1,name:"Macedonia",phone_code:"389"},{code:"MP",hasChildren:!1,name:"Northern Mariana Islands",phone_code:"1"},{code:"NO",hasChildren:!1,name:"Norway",phone_code:"47"},{code:"OM",hasChildren:!1,name:"Oman",phone_code:"968"},{code:"PK",hasChildren:!0,name:"Pakistan",phone_code:"92"},{code:"PW",hasChildren:!1,name:"Palau",phone_code:"680"},{code:"PS",hasChildren:!1,name:"Palestine",phone_code:"970"},{code:"PA",hasChildren:!1,name:"Panama",phone_code:"507"},{code:"PG",hasChildren:!1,name:"Papua New Guinea",phone_code:"675"},{code:"PY",hasChildren:!1,name:"Paraguay",phone_code:"595"},{code:"PE",hasChildren:!0,name:"Peru",phone_code:"51"},{code:"PH",hasChildren:!1,name:"Philippines",phone_code:"63"},{code:"PL",hasChildren:!0,name:"Poland",phone_code:"48"},{code:"PT",hasChildren:!0,name:"Portugal",phone_code:"351"},{code:"PR",hasChildren:!1,name:"Puerto Rico",phone_code:"1"},{code:"QA",hasChildren:!1,name:"Qatar",phone_code:"974"},{code:"MD",hasChildren:!1,name:"Moldova",phone_code:"373"},{code:"RE",hasChildren:!1,name:"Reunion",phone_code:"262"},{code:"RO",hasChildren:!1,name:"Romania",phone_code:"40"},{code:"RU",hasChildren:!1,name:"Russian Federation",phone_code:"7"},{code:"RW",hasChildren:!1,name:"Rwanda",phone_code:"250"},{code:"BLM",hasChildren:!1,name:"Saint Barthelemy",phone_code:"590"},{code:"KN",hasChildren:!1,name:"Saint Kitts and Nevis",phone_code:"1"},{code:"LC",hasChildren:!1,name:"Saint Lucia",phone_code:"1"},{code:"MAF",hasChildren:!1,name:"Saint Martin",phone_code:"721"},{code:"PM",hasChildren:!1,name:"St. Pierre and Miquelon",phone_code:"508"},{code:"VC",hasChildren:!1,name:"Saint Vincent and the Grenadines",phone_code:"1"},{code:"WS",hasChildren:!1,name:"Samoa",phone_code:"685"},{code:"SM",hasChildren:!1,name:"San Marino",phone_code:"378"},{code:"ST",hasChildren:!1,name:"Sao Tome and Principe",phone_code:"239"},{code:"SA",hasChildren:!0,name:"Saudi Arabia",phone_code:"966"},{code:"SN",hasChildren:!1,name:"Senegal",phone_code:"221"},{code:"SRB",hasChildren:!1,name:"Serbia",phone_code:"381"},{code:"SC",hasChildren:!1,name:"Seychelles",phone_code:"248"},{code:"SL",hasChildren:!1,name:"Sierra Leone",phone_code:"232"},{code:"SG",hasChildren:!1,name:"Singapore",phone_code:"65"},{code:"SX",hasChildren:!1,name:"Sint Maarten",phone_code:"1"},{code:"SK",hasChildren:!1,name:"Slovakia (Slovak Republic)",phone_code:"421"},{code:"SI",hasChildren:!1,name:"Slovenia",phone_code:"386"},{code:"SB",hasChildren:!1,name:"Solomon Islands",phone_code:"677"},{code:"SO",hasChildren:!1,name:"Somalia",phone_code:"252"},{code:"ZA",hasChildren:!1,name:"South Africa",phone_code:"27"},{code:"SGS",hasChildren:!1,name:"South Georgia and the South Sandwich Islands",phone_code:"500"},{code:"SS",hasChildren:!1,name:"South Sudan",phone_code:"211"},{code:"ES",hasChildren:!0,name:"Spain",phone_code:"34"},{code:"LK",hasChildren:!0,name:"Sri Lanka",phone_code:"94"},{code:"SR",hasChildren:!1,name:"Suriname",phone_code:"597"},{code:"SZ",hasChildren:!1,name:"Swaziland",phone_code:"268"},{code:"SE",hasChildren:!1,name:"Sweden",phone_code:"46"},{code:"CH",hasChildren:!1,name:"Switzerland",phone_code:"41"},{code:"TW",hasChildren:!1,name:"Taiwan,China",phone_code:"886"},{code:"TJ",hasChildren:!1,name:"Tajikistan",phone_code:"992"},{code:"TZ",hasChildren:!1,name:"Tanzania",phone_code:"255"},{code:"TH",hasChildren:!0,name:"Thailand",phone_code:"66"},{code:"CG",hasChildren:!1,name:"Congo, The Republic of Congo",phone_code:"242"},{code:"VA",hasChildren:!1,name:"Vatican City State (Holy See)",phone_code:"39 (066)"},{code:"TG",hasChildren:!1,name:"Togo",phone_code:"228"},{code:"TO",hasChildren:!1,name:"Tonga",phone_code:"676"},{code:"TT",hasChildren:!1,name:"Trinidad and Tobago",phone_code:"1"},{code:"TN",hasChildren:!1,name:"Tunisia",phone_code:"216"},{code:"TR",hasChildren:!0,name:"Turkey",phone_code:"90"},{code:"TM",hasChildren:!1,name:"Turkmenistan",phone_code:"993"},{code:"TC",hasChildren:!1,name:"Turks and Caicos Islands",phone_code:"1 (649)"},{code:"TV",hasChildren:!1,name:"Tuvalu",phone_code:"688"},{code:"VI",hasChildren:!1,name:"Virgin Islands (U.S.)",phone_code:"1"},{code:"UG",hasChildren:!1,name:"Uganda",phone_code:"256"},{code:"UA",hasChildren:!0,name:"Ukraine",phone_code:"380"},{code:"AE",hasChildren:!0,name:"United Arab Emirates",phone_code:"971"},{code:"UK",hasChildren:!0,name:"United Kingdom",phone_code:"44"},{code:"US",hasChildren:!0,name:"United States",phone_code:"1"},{code:"UY",hasChildren:!1,name:"Uruguay",phone_code:"598"},{code:"UZ",hasChildren:!1,name:"Uzbekistan",phone_code:"998"},{code:"VU",hasChildren:!1,name:"Vanuatu",phone_code:"678"},{code:"VE",hasChildren:!1,name:"Venezuela",phone_code:"58"},{code:"VN",hasChildren:!0,name:"Vietnam",phone_code:"84"},{code:"WF",hasChildren:!1,name:"Wallis And Futuna Islands",phone_code:"681"},{code:"YE",hasChildren:!1,name:"Yemen",phone_code:"967"},{code:"ZM",hasChildren:!1,name:"Zambia",phone_code:"260"},{code:"EAZ",hasChildren:!1,name:"Zanzibar",phone_code:"259"},{code:"ZW",hasChildren:!1,name:"Zimbabwe",phone_code:"263"}],$e={fullname:"Contact Name",address1:"Address",address2:"Apartment",zip:"Postal Code",country_code:"Country",CL:"Rut",BR:"Cpf"},He=["INVALID_COUNTRY","NOT_A_NUMBER","TOO_SHORT","TOO_LONG","INVALID_LENGTH"],qe=/^\+?(?:[0-9 \-()]+)?$/,po=({error:r="",disabled:t=!1,defaultValue:n,onChange:d})=>{const{t:h}=X(),[s,C]=a.useState("US"),[x,m]=a.useState(""),[i,f]=a.useState(""),[c,u]=a.useState(!1),{isMobile:M}=ln(),j=Fn().map(o=>({country:o,phoneCode:ae(o)})),k=a.useRef(!1),_=a.useCallback(()=>u(o=>!o),[]),F=(o="")=>{try{if(o.replace(/\s+/g,"").length>4&&o.replace(/\s+/g,"").length<=20){const R=de(o);if(R?.country)return R.country}const p=We(o),A=p&&He.includes(p)&&p!=="TOO_LONG"?null:de(o);if(A)return A?.country;if(o.trim().length<=4){const R=j.find(y=>"+"+y.phoneCode===o.trim());return R?R.phoneCode==="1"?"US":R.country:null}return null}catch(p){console.log("error getPhoneCode",p)}return null},g=(o,p)=>{try{if(o.startsWith("+")){const A=We(o,s);if(o.trim().length<=4||A&&He.includes(A))d&&d("+"+ae(p),o.replace("+"+
74ae(p),""));else{const R=de(o),y=R?R.nationalNumber:o;p&&d&&d("+"+ae(p),y),R?.countryCallingCode&&d&&d("+"+R?.countryCallingCode,y)}}else d&&d("+"+ae(p),ge("+"+ae(p)+o)?.replace("+"+ae(p),""))}catch(A){console.log("--msgError onChangeValue",A)}},z=o=>{if(o&&!o.match(qe)){m(x),g(x,s);return}const p=new Bn;if(p.input(o),p&&p.country){C(p.country),m(o),g(o,p.country);return}let A=s;if(o.startsWith("+")){if(A=F(o+""),A)C(A);else if(o.trim().length<=4){const y=j.find(U=>"+"+U.phoneCode===o.trim());y?.country&&(A=y.country,C(A))}try{if(!A&&o.length>6&&o.length<=16){const y=de(o);y.country&&(A=y.country,C(y.country))}}catch(y){console.log("msg parse phone",y)}}const R=o;m(R),g(R,A??s)},v=o=>{let p=o;try{if(o.length>6&&o.startsWith("+")&&Be(o)&&(p=ge(o)),o.length>6&&!o.startsWith("+")){const A=De(P.cloneDeep(o),s,"NATIONAL");p.replaceAll(" ","")!==A.replaceAll(" ","")?p=o:p=A}}catch(A){console.log("msg parse new phone",A)}m(p),g(p,s)},b=()=>{try{if(!n||n&&!n.match(qe))return;let o;n.startsWith("+")&&(o=F(n+""),o&&C(o));let p=n;if(n.length>6&&n.startsWith("+")&&Be(n)&&(p=ge(n),o&&p?.trim()!==n?.replace("+"+ae(o),"")?.trim()&&(p=n)),n.length>6&&!n.startsWith("+")){const A=De(JSON.parse(JSON.stringify(n)),s,"NATIONAL");p.trim().replaceAll(" ","")!==A.trim().replaceAll(" ","")?p=n:p=A}m(p)}catch(o){console.log("--msgError onGetPhoneNumberDefault",o)}};a.useEffect(()=>(b(),()=>{m(void 0),C("US"),k.current=!1}),[]),a.useEffect(()=>{n&&k.current&&(k.current=!0)},[n]),a.useEffect(()=>{c||f("")},[c]);const N=e.jsx(re,{size:"large",disclosure:"select",icon:e.jsx("div",{className:"msui-w-100 msui-flex-center",children:e.jsx(_e,{fontSize:22,country:s,renderCountry:o=>o,hiddenName:!0})}),disabled:t,onClick:()=>{requestAnimationFrame(()=>{!t&&_()})},fullWidth:!0});return e.jsx(e.Fragment,{children:M?e.jsxs(K,{gap:"100",children:[e.jsxs("div",{className:"msui-flex msui-f lex-align-items-center",style:{gap:"8px"},children:[e.jsx("div",{style:{width:"60px"},children:N}),e.jsx("div",{style:{width:"calc(100% - 60px)"},children:e.jsx(J,{disabled:t,label:"alo",labelHidden:!0,autoComplete:"off",placeholder:h("EnterYourPhone"),type:"text",value:x,onChange:o=>{requestAnimationFrame(()=>{!t&&z(o)})},onBlur:o=>{requestAnimationFrame(()=>{const p=o?.target.value;v(p)})},error:!!r})}),e.jsxs(hn,{showCloseIcon:!0,title:"Select country",zIndex:173,visible:c,onClose:_,children:[e.jsx(Y,{position:"sticky",insetBlockStart:"0",background:"bg-surface",zIndex:"12",children:e.jsx(Y,{padding:"400",paddingBlock:"200",children:e.jsx(J,{type:"search",label:"SearchField",autoComplete:"off",placeholder:h("Search"),labelHidden:!0,value:i,onChange:o=>{requestAnimationFrame(()=>{f(o)})}})})}),e.jsx(Ne,{style:{minHeight:200,maxHeight:"680px"},children:e.jsx(Y,{padding:"200",paddingBlock:"0",children:e.jsx(Te,{sections:[{items:j.filter(o=>P.lowerCase(`${ie[o.country]} +${o.phoneCode} ${o.country}`).includes(P.lowerCase(i))).map(o=>({prefix:e.jsx(_e,{fontSize:22,country:o.country,renderCountry:p=>p,hiddenName:!0}),active:s===o.country,content:`${ie[o.country]} +${o.phoneCode}`,onAction:()=>{C(o.country),m(`+${o.phoneCode}`),_(),d&&d(`+${o.phoneCode}`,"")}}))}]})})})]})]}),r&&e.jsx(Se,{message:r||"",fieldID:Math.random()+""})]}):e.jsxs(K,{gap:"100",children:[e.jsxs("div",{className:"msui-flex msui-f lex-align-items-center",style:{gap:"8px"},children:[e.jsx("div",{style:{width:"60px"},children:e.jsxs(pn,{preferredAlignment:"left",active:c,activator:N,autofocusTarget:"first-node",onClose:()=>{requestAnimationFrame(()=>{_()})},children:[e.jsx(Tn,{children:e.jsx(J,{type:"search",label:"SearchField",autoComplete:"off",placeholder:h("Search"),labelHidden:!0,value:i,onChange:o=>{requestAnimationFrame(()=>{f(o)})}})}),e.jsx(Ne,{style:{maxHeight:"400px",minWidth:250,maxWidth:350},children:e.jsx(Te,{sections:[{items:j.filter(o=>P.lowerCase(`${ie[o.country]} +${o.phoneCode} ${o.country}`).includes(P.lowerCase(i))).map(o=>({prefix:e.jsx(_e,{fontSize:22,country:o.country,renderCountry:p=>p,hiddenName:!0}),active:s===o.country,content:`${ie[o.country]} +${o.phoneCode}`,onAction:()=>{requestAnimationFrame(()=>{C(o.country),m(`+${o.phoneCode}`),_(),d&&d(`+${o.phoneCode}`,"")})}}))}]})})]})}),e.jsx("div",{style:{width:"calc(100% - 60px)"},children:e.jsx(J,{disabled:t,label:"alo",labelHidden:!0,autoComplete:"off",placeholder:h("EnterYourPhone"),type:"text",value:x,onChange:o=>{requestAnimationFrame(()=>{!t&&z(o)})},onBlur:o=>{requestAnimationFrame(()=>{const p=o?.target.value;v(p)})},error:!!r})})]}),r&&e.jsx(Se,{message:r||"",fieldID:Math.random()+""})]})})},uo=W.div`
75  .button-shipping-method {
76    display: flex;
77    justify-content: space-between;
78    width: 100%;
79    padding: 0px 5px 0px 9px;
80  }
81  .--shipping-method {
82    width: 100%;
83    height: 36px;
84    display: flex;
85    justify-content: space-between;
86
87    .Polaris-Button__Content {
88      display: flex;
89      justify-content: space-between;
90      width: 100%;
91    }
92  }
93`,he={company:[],fullname:[],email:[],phone:[],zip:[],city:[],cpf:[],rut:[],province:[],country_code:[],address1:[],address2:[]},mo=r=>{const t=r;let n=!1;const d=P.cloneDeep(he);return t.city||(d.city.push("CityCannotBeBlank"),n=!0),["fullname","zip","country_code","address1"].forEach(h=>{if(Ee(t[h])){const s=$e[h]?$e[h].replaceAll(" ",""):h.toUpperCase();d[h].push(`${s}CannotBeBlank`),n=!0}}),!Ee(t.email)&&!mn(t?.email||void 0)&&(d.email.push("PleaseEnterEmailInCorrectFormat"),n=!0),{validated:n,errors:d}},Qe=a.forwardRef((r,t)=>{const{t:n}=X(),{data:d,onSave:h}=r,[s,C]=a.useState({address1:null,address2:null,city:null,company:null,country:null,country_code:null,email:null,first_name:null,fullname:null,last_name:null,note:null,phone:null,phone_code:null,province:null,province_code:null,zip:null}),[x,m]=a.useState(!1),[i,f]=a.useState(he),c=a.useRef("");a.useImperativeHandle(t,()=>({open:()=>{m(!0)},close:()=>{m(!1),g()}}));const u=l=>{C(L=>
93({...L,...l}))},M=async l=>{const L=l;f(Z=>({...Z,company:[]}));const B=ze.find(Z=>Z.code===L);if(B&&B?.hasChildren){const Z=await _(L);s&&u({country:B.name,country_code:L,city:Z?.[0]?.city?.[0]?.n||"",province:Z?.[0]?.n||""})}else s&&u({country_code:L,city:"",province:""})},j=(l,L)=>{requestAnimationFrame(()=>{u({[l]:L})})},k=(l,L)=>{requestAnimationFrame(()=>{s&&u({phone_code:l,phone:L.replaceAll(/\s/g,"")})})},_=async l=>{let L=[];try{const B=l.toLowerCase(),ee=`${window.location.origin}/json/countries/${B}.json`;await sn.get(ee).then(function(I){const{data:T=[]}=I;L=T}).catch(function(I){console.log("error",I)})}catch{}return L},F=()=>{if(s){const{validated:l,errors:L}=mo(s);if(l){f(L);return}const B={...s},Z=ze.find(I=>I.code===B.country_code),ee={fullname:B?.fullname||"",phone_code:B.phone_code||"",phone:B?.phone||"",email:B?.email||"",country_code:B?.country_code||"",country:Z?.name||null,city:B?.city||"",province:B?.province||null,address1:B?.address1||null,address2:B?.address2||null,zip:B?.zip||null,company:B?.company||null};h(ee),m(!1),f(he)}},g=()=>{requestAnimationFrame(()=>{f(he),m(!1)})};a.useEffect(()=>{!c?.current&&s?.city&&(c.current=s?.city||"")},[s?.city]),a.useEffect(()=>{P.size(d)&&C(l=>({...l,...d}))},[d]);const z=l=>{switch(l){case"CL":return n("RutNo");case"BR":return"CPF";case"MX":return n("PassportNo");case"PE":case"TR":return n("TaxNo");default:return n("Company")}},v=()=>{const l={...s};return l?.country_code&&["CL","BR","PE","TR","MX"].includes(l.country_code)?{title:e.jsx(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:z(l?.country_code||"")}),placeholder:z(l?.country_code||"")}:{title:n("Company"),placeholder:n("Company")}},b=l=>{switch(l){case"JP":return n("HouseNo");default:return n("ApartmentSuiteEtc")}},N=()=>{const l={...s};return l?.country_code&&["JP"].includes(l.country_code)?{title:e.jsx(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:b(l?.country_code||"")}),placeholder:b(l?.country_code||"")}:{title:n("ApartmentSuiteEtc"),placeholder:n("ApartmentSuiteEtc")}},o=l=>{switch(l){case"BR":return n("ProvinceLocationTree");default:return n("Province")}},p=()=>{const l={...s};return l?.country_code&&["BR"].includes(l.country_code)?{title:e.jsx(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:o(l?.country_code||"")}),placeholder:o(l?.country_code||"")}:{title:n("Province"),placeholder:n("EnterProvince")}},A=()=>{const l=Object.keys(i).filter(L=>P.size(i[L]));return P.size(i)>0&&P.size(l)>0&&e.jsx(un,{tone:"critical",title:`${n("ThereIsCountError",{count:P.size(l)})}`,children:e.jsx(Fe,{type:"bullet",children:l.map((L,B)=>e.jsx(Fe.Item,{children:n(i[L][0])},B))})})},R=()=>e.jsxs(e.Fragment,{children:[e.jsxs(K,{gap:"100",children:[e.jsxs(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:[n("Country"),e.jsx(S,{as:"span",variant:"headingSm",tone:"critical",children:"*"})]}),e.jsx(uo,{children:e.jsx(Dn,{id:"customer_country",preferredAlignment:"left",placeholderSelect:n("EnterCountry"),value:s?.country_code||"",error:n(i.country_code[0]),onChange:M})})]}),e.jsx("div",{children:e.jsx(J,{id:"customer_province",label:p().title,autoComplete:"off",placeholder:p().placeholder,onChange:l=>j("province",l),value:s?.province||"",error:n(i.province[0])})})]}),y=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(J,{id:"customer_city",label:e.jsxs(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:[n("City"),e.jsx(S,{as:"span",variant:"headingSm",tone:"critical",children:"*"})]}),autoComplete:"off",placeholder:n("EnterCity"),onChange:l=>j("city",l),value:s?.city||"",error:n(i.city[0])})}),e.jsx(J,{placeholder:n("EnterAddress"),label:e.jsxs(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:[n("Address"),e.jsx(S,{as:"span",variant:"headingSm",tone:"critical",children:"*"})]}),id:"customer_address",value:s?.address1||"",onChange:l=>j("address1",l),error:n(i.address1[0]),autoComplete:"off"})]}),U=()=>e.jsxs(e.Fragment,{children:[e.jsx(J,{label:N().title,placeholder:N().placeholder,id:"address2",value:s?.address2||"",onChange:l=>j("address2",l),error:n(i.address2[0]),autoComplete:"off"}),e.jsx(J,{label:e.jsxs(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:[n("PostalCode"),e.jsx(S,{as:"span",variant:"headingSm",tone:"critical",children:"*"})]}),placeholder:n("ZipPostalCode"),id:"customer_zip",value:s?.zip||"",onChange:l=>j("zip",l),error:n(i.zip[0]),autoComplete:"off"})]}),V=()=>{const l=(s?.phone_code??"")+(s?.phone??"");return e.jsx(e.Fragment,{children:e.jsxs(K,{gap:"600",children:[A(),e.jsxs(bn,{columns:{xs:"6fr",md:"6fr",lg:"3fr 3fr"},gap:{xs:"200",md:"200",lg:"200"},children:[e.jsx(J,{label:e.jsxs(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:[n("ContactName"),e.jsx(S,{as:"span",variant:"headingSm",tone:"critical",children:"*"})]}),id:"customer_fullname",placeholder:n("EnterContactName"),value:s?.fullname||"",onChange:L=>{requestAnimationFrame(()=>j("fullname",L))},error:n(i.fullname[0]),autoComplete:"off"}),e.jsxs(K,{gap:"100",children:[e.jsx(S,{as:"span",variant:"headingSm",fontWeight:"regular",children:n("Tel")}
93),e.jsx(po,{defaultValue:l,onChange:(L,B)=>{requestAnimationFrame(()=>{k(L,B)})},error:n(i.phone[0])})]}),e.jsx(J,{label:n("Email"),id:"customer_email",value:s?.email||"",onChange:L=>j("email",L),error:n(i.email[0]),autoComplete:"off",placeholder:n("EnterEmailAddress")}),e.jsx(J,{label:v().title,placeholder:v().placeholder,autoComplete:"off",id:"customer_company",value:s?.company||"",onChange:L=>j("company",L),error:n(i.company[0])}),R(),y(),U()]})]})})};return e.jsxs(se,{title:"",titleHidden:!0,open:x,onClose:g,children:[e.jsx(se.Section,{children:e.jsx(S,{as:"span",fontWeight:"semibold",variant:"headingLg",children:n("CustomerInfo")})}),e.jsx(se.Section,{children:V()}),e.jsx(se.Section,{children:e.jsxs("div",{className:"msui-flex msui-flex-justify-content-end",children:[e.jsx("div",{className:"msui-mr-3",children:e.jsx(re,{onClick:g,children:n("Cancel")})}),e.jsx(re,{onClick:()=>requestAnimationFrame(()=>{F()}),variant:"primary",children:n("Save")})]})})]})});Qe.displayName="CustomerInfoModal";const fo=({data:r,onChangCustomerInfo:t})=>{const{t:n}=X(),{fullname:d="",phone:h="",address1:s="",email:C=""}=r,x=a.useRef(null),m=()=>!d&&!h&&!s&&!C?e.jsx(S,{as:"span",variant:"bodyMd",tone:"subdued",children:n("MissingCustomerInfo")}):e.jsxs(K,{gap:"200",children:[e.jsxs(q,{blockAlign:"center",gap:"200",children:[e.jsx(ce,{children:e.jsxs(oe,{as:"span",variant:"bodyMd",tone:"subdued",children:[n("Name"),":"]})}),e.jsx(oe,{as:"p",variant:"bodyMd",breakWord:!0,children:d||"-"})]}),e.jsxs(q,{blockAlign:"center",gap:"200",children:[e.jsx(ce,{children:e.jsxs(oe,{as:"span",variant:"bodyMd",tone:"subdued",children:[n("Email"),":"]})}
93),e.jsx(oe,{as:"p",variant:"bodyMd",breakWord:!0,children:C||"-"})]}),e.jsxs(q,{blockAlign:"center",gap:"200",children:[e.jsx(ce,{children:e.jsxs(oe,{as:"span",variant:"bodyMd",tone:"subdued",children:[n("PhoneNumber"),":"]})}),e.jsx(oe,{as:"p",variant:"bodyMd",breakWord:!0,children:h||"-"})]}),e.jsxs(q,{blockAlign:"center",gap:"200",children:[e.jsx(ce,{children:e.jsxs(oe,{as:"span",variant:"bodyMd",tone:"subdued",children:[n("ShippingAddress"),":"]})}),e.jsx(oe,{as:"p",variant:"bodyMd",breakWord:!0,children:s||"-"})]})]});return e.jsxs(Y,{background:"bg-fill",borderRadius:"300",padding:"400",shadow:"100",borderColor:"border",borderWidth:"025",children:[e.jsxs(K,{gap:"200",children:[e.jsxs(q,{align:"space-between",blockAlign:"center",children:[e.jsx(S,{variant:"headingMd",as:"h2",children:n("Customer")}),e.jsx(re,{variant:"tertiary",icon:Ye,onClick:()=>x.current?.open()})]}),m()]}),e.jsx(Qe,{data:r,ref:x,onSave:t})]})},ce=W.div`
94  width: 45%;
95`,Co=W.div`
96  flex: 0 0 auto;
97  min-width: 180px;
98  max-width: 180px;
99  margin-right: 8px;
100  cursor: pointer;
101
102  & .Polaris-Box {
103    border: 1px solid ${({isSelected:r})=>r?"var(--p-color-input-border-active)":"transparent"};
104    background: ${({isSelected:r})=>r?"var(--p-color-bg-surface-secondary-active)":"var(--p-color-bg-surface-secondary)"};
105    transition: all 0.2s ease-in-out;
106  }
107
108  &:hover {
109    & .Polaris-Box {
110      border-color: var(--p-color-input-border-hover);
111      background: var(--p-color-bg-surface-secondary-hover);
112    }
113  }
114`,_o=W.div`
115  overflow: hidden;
116  position: relative;
117
118  &:hover {
119    .arrow-button {
120      transition: 0.4s;
121      opacity: 1;
122    }
123  }
124`,go=W.div`
125  overflow: hidden;
126  width: 100%;
127`,xo=W.div`
128  display: flex;
129  height: 100%;
130  max-width: 420px;
131  touch-action: pan-y;
132`,en=W.div`
133  position: absolute;
134  top: 50%;
135  transform: translateY(-50%);
136  z-index: 1;
137  opacity: 0;
138`,vo=W(en)`
139  left: 2px;
140`,yo=W(en)`
141  right: 2px;
142`,bo=({data:r,imageGroups:t})=>{const{t:n}=X(),{convertPriceWithFormatter:d}=me(),[h,s]=a.useState(0),[C,x]=a.useState(!1),[m,i]=a.useState(!1),[f,c]=Wn({loop:!1}),u=a.useCallback(()=>{c&&(x(c.canScrollPrev()),i(c.canScrollNext()))},[c]);a.useEffect(()=>{if(c)return u(),c.on("select",u),c.on("reInit",u),c.on("init",u),()=>{c.off("select",u),c.off("reInit",u),c.off("init",u)}},[c,u]),a.useEffect(()=>{c&&(c.reInit(),u())},[r,c,u]);const M=a.useCallback(()=>{c&&c.scrollPrev()},[c]),j=a.useCallback(()=>{c&&c.scrollNext()},[c]),k=g=>{s(g),c&&c.scrollTo(g)},_=a.useMemo(()=>g=>g.shipping_service===null?"N/A":g.source===fn.zopi?"Zopi shipment":En[g.shipping_service]||g.shipping_service||"N/A",[]),F=()=>{if(!P.size(r))return e.jsx(S,{as:"span",variant:"bodyMd",tone:"subdued",children:n("MissingSupplierInfo")});const{shipping_fee:g=0,shipping_time:z="",shipping_process:v=""}=r?.[h]||{};return e.jsxs(K,{gap:"100",children:[e.jsxs(_o,{className:"embla",children:[e.jsx(vo,{className:"arrow-button",onClick:M,children:e.jsx(re,{disabled:!C,icon:Sn})}),e.jsx(go,{className:"embla__viewport",ref:f,children:e.jsx(xo,{className:"embla__container",children:r.map((b,N)=>e.jsx(Co,{className:"embla__slide",isSelected:h===N,onClick:()=>k(N),children:e.jsx(Y,{borderRadius:"200",padding:"200",children:e.jsxs(q,{wrap:!1,align:"center",blockAlign:"center",gap:"200",children:[e.jsx(So,{images:t?.[b?.product_id]?.slice(0,3)||[]}),e.jsx(S,{truncate:!0,as:"p",variant:"bodySm",alignment:"center",children:_(b)})]})})},`${b.shipping_service}-${N}`))})}),e.jsx(yo,{className:"arrow-button",onClick:j,children:e.jsx(re,{disabled:!m,icon:jn})})]}),e.jsxs(K,{gap:"200",children:[e.jsxs(q,{gap:"200",children:[e.jsx(ve,{children:e.jsxs(S,{as:"span",variant:"bodyMd",tone:"subdued",children:[n("ShippingCost"),":"]})}),e.jsx(S,{as:"p",variant:"bodyMd",children:g?d(g):g===0?n("Free"):"-"})]}),e.jsxs(q,{gap:"200",children:[e.jsx(ve,{children:e.jsxs(S,{as:"span",variant:"bodyMd",tone:"subdued",children:[n("ShippingTime"),":"]})}),e.jsx(S,{as:"p",variant:"bodyMd",children:Ge(z)})]}),e.jsxs(q,{gap:"200",children:[e.jsx(ve,{children:e.jsxs(S,{as:"span",variant:"bodyMd",tone:"subdued",children:[n("ProcessingTime"),":"]})}),e.jsx(S,{as:"p",variant:"bodyMd",children:Ge(v)})]})]})]})};return e.jsx(Y,{background:"bg-fill",borderRadius:"300",padding:"400",shadow:"100",borderColor:"border",borderWidth:"025",children:e.jsxs(K,{gap:"400",children:[e.jsx(S,{variant:"headingMd",as:"h2",children:n("Supplier")}),F()]})})},ve=W.div`
143  width: 45%;
144`,So=({images:r})=>P.size(r)?e.jsx(jo,{style:{width:`${24+(P.size(r)-1)*4}px`},children:r.map((t,n)=>e.jsx(Ao,{index:n,children:e.jsx(ue,{source:t,alt:t})},n+t))}):e.jsx(e.Fragment,{}),jo=W.div`
145  display: flex;
146  align-items: center;
147  justify-content: center;
148`,Ao=W.div`
149  position: absolute;
150  width: 24px;
151  height: 24px;
152  overflow: hidden;
153  transform: translateX(${r=>r.index*-4}px);
154
155  .Polaris-Thumbnail::after,
156  .Polaris-Thumbnail {
157    border-radius: var(--p-border-radius-100);
158    box-shadow: none;
159  }
160
161  .Polaris-Thumbnail {
162    border: 1px solid #e3e3e3;
163  }
164`,Io=W.div`
165  display: flex;
166  align-items: center;
167  gap: 8px;
168  width: 100%;
169
170  & >
170 div:first-child {
171    flex: 0 0 auto;
172  }
173
174  & > div:last-child {
175    flex: 1 1 auto;
176    min-width: 0;
177  }
178`,Mo=({relatedItems:r,setRelatedItems:t})=>{const{t:n}=X(),[d,h]=a.useState("Related to"),[s,C]=a.useState(""),[x,m]=a.useState([]),[i,f]=a.useState([]),c=[{key:"related_to",label:n("RelatedTo"),value:"Related to"},{key:"split_from",label:n("SplitFrom"),value:"Split from"},{key:"contains",label:n("Contains"),value:"Contains"},{key:"duplicated_by",label:n("DuplicatedBy"),value:"Duplicated by"}],u=a.useCallback(_=>{C(_),m([])},[]),M=()=>{s.trim()&&(t(_=>({..._,[d.toLowerCase().replace(" ","_")]:[..._[d.toLowerCase().replace(" ","_")]||[],s]})),C(""),f([]))},j=(_,F)=>{t(g=>{const z=g[_].filter(v=>v!==F);if(z.length===0){const{[_]:v,...b}=g;return b}return{...g,[_]:z}})},k=e.jsx(Le.TextField,{onChange:u,label:"",value:s,placeholder:n("EnterValue"),autoComplete:"off"});return e.jsx(Y,{background:"bg-fill",borderRadius:"300",padding:"400",shadow:"100",borderColor:"border",borderWidth:"025",children:e.jsxs(K,{gap:"400",children:[e.jsx(S,{variant:"headingMd",as:"h2",children:n("RelatedOrder")}),e.jsxs(K,{gap:"0",children:[e.jsxs(Io,{children:[e.jsx(Rn,{label:"",options:c,onChange:_=>h(_),value:d}),e.jsx(Le,{options:x,selected:i,onSelect:f,textField:k,actionBefore:{wrapOverflow:!0,icon:An,content:`${n("Add")} ${s||"Value"}`,onAction:M}})]}),Object.keys(r).length>0&&e.jsx(Y,{paddingBlockStart:"200",children:Object.entries(r).map(([_,F])=>F.length>0&&e.jsx(Y,{paddingBlockStart:"200",children:e.jsxs(q,{gap:"200",children:[e.jsxs(S,{variant:"bodyMd",as:"p",fontWeight:"medium",children:[c.find(g=>g.key===_)?.label||_,":"]}),e.jsx(q,{gap:"200",children:F.map(g=>e.jsx(Ve,{onRemove:()=>j(_,g),children:g},g))})]})},_))})]})]})})},ko=W.div`
179  display: grid;
180  position: relative;
181  grid-template-columns: 2fr 1fr;
182  gap: var(--p-space-400);
183  margin-top: var(--p-space-200);
184
185  @media (max-width: 768px) {
186    grid-template-columns: 1fr;
187    max-height: none;
188    overflow-y: visible;
189  }
190`,To=W.div``,Eo=W.div`
191  position: sticky;
192  align-self: start;
193
194  @media (max-width: 768px) {
195    position: relative;
196    top: 0;
197  }
198`,os=()=>{const{t:r}=X(),{token:t,cancel:n}=Ie(),d=Cn(),{fetchLogistics:h}=qn(),{detailLoading:s,detailData:C,fetchDetail:x}=Ln(),m=Ce.isShopifyEmbedded()?wn():Je(),[i]=tn(),[f,c]=a.useState({}),[u,M]=a.useState(!1),[j,k]=a.useState(!1),[_,F]=a.useState([]),[g,z]=a.useState([]),[v,b]=a.useState(Gn),[N,o]=a.useState([]),p=a.useRef(null),A=a.useRef(null),R=a.useCallback(async I=>{const T={};I.forEach(E=>{T[E.product_id]?T[E.product_id].sub_variant_id.includes(E.variant_id)||T[E.product_id].sub_variant_id.push(E.variant_id):T[E.product_id]={product_id:E.product_id,source:E.source,sub_variant_id:[E.variant_id]}});try{k(!0);const E=await h(Object.values(T),t,v.country_code||"US");z(D=>[...D,...E])}catch(E){console.error(E)}finally{k(!1)}},[h,v.country_code]);a.useEffect(()=>()=>{n()},[]);const y=a.useCallback(({order_id:I,includes:T})=>{x({order_id:I,includes:T},t)},[x]),U=a.useCallback(I=>{F(I);const T=g.flatMap(D=>(D.sub_variant_id||[]).map($=>`${D.product_id}_${$}`)),E=I.filter(D=>!T.includes(`${D.product_id}_${D.variant_id}`));E.length>0&&R(E)},[R,g]),V=a.useCallback(({product_id:I="",variant_id:T=""})=>{const E=I.toString(),D=T.toString();F($=>$.filter(w=>w?.variant_id!==D)),z($=>$.reduce((w,G)=>{if(G.product_id?.toString()!==E)return w.push(G),w;const H=(G.sub_variant_id||[]).filter(Q=>Q?.toString()!==D);return H.length>0&&w.push({...G,sub_variant_id:H}),w},[])),o($=>$.filter(w=>w?.variantId?.toString()!==D))},[]),l=a.useCallback(I=>{o(I)},[]),L=a.useCallback(I=>{const T=I.country_code!==v.country_code;b(I),T&&_.length>0&&(z([]),R(_))},[v.country_code,_,R]),B=async()=>{try{const I=P.sumBy(_,w=>Number(w.cost_price)*w.quantity),T=_.map(w=>{const G=g.find(Q=>Q.product_id===w.product_id&&P.includes(Q.sub_variant_id,w.variant_id)),H={source:G?.source||w.source||"aliexpress",product_id:w.product_id,sub_variant_id:G?.sub_variant_id||[w.variant_id],variant_id:w.variant_id,shipping_fee:G?.shipping_fee??0,shipping_service:G?.shipping_service??"N/A",shipping_time:G?.shipping_time??"N/A",shipping_process:G?.shipping_process??"N/A"};return{source:H.source,shipping_info:{variant_id:H.variant_id,shipping_fee:H.shipping_fee,shipping_service:H.shipping_service,shipping_time:H.shipping_time,shipping_process:H.shipping_process}
198,item_data:{...w,line_item_id:w.line_item_id?Number(w.line_item_id):null,supplier_id:w.supplier_id?String(w.supplier_id):void 0}}}),E={...v,total_price:I,subtotal_price:I,tags:f,line_items:T};M(!0);const{status:D,data:$}=await Ze.postCreateOrder(E,t);D===Me.OK&&(m&&m({pathname:le.ORDER_LIST.PATH,search:`?keyword=${$?.order_number}&order_status=placement`}),d.success(r("CreateOrderSuccess")))}catch(I){if(Ae(I)){console.error("Create order request cancelled");return}d.error(r("CreateOrderFailed"))}finally{M(!1)}};a.useEffect(()=>{const I=i.get("order_id"),T=i.get("includes");return I&&T&&x({order_id:I,includes:T},t),()=>{n()}},[i]);const Z=a.useCallback((I=[])=>{const T={};return I.forEach(({id:E,shipping_info:D,source_product:$,replace_supplier:w})=>{const G=w?.source_product_id||$?.product_id||"",H=w?.source||$?.source||"aliexpress",Q=`${G}_${H}_${D?.shipping_service}_${D?.shipping_time}_${D?.shipping_process}`;T[Q]?T[Q].sub_variant_id.includes(E.toString())||T[Q].sub_variant_id.push(E.toString()):T[Q]={source:H,product_id:G,shipping_service:D?.shipping_service,shipping_time:D?.shipping_time,shipping_process:D?.shipping_process,sub_variant_id:[E.toString()]}}),T},[]),ee=a.useCallback((I=[])=>I.map(({quantity:T,image:E="",id:D,cost_price:$="",variant_title:w="",source_product:G,replace_supplier:H})=>({source:H?.source||G?.source||"aliexpress",total_quantity:T,quantity:1,line_item_id:D.toString(),name:H?.name||G?.title||"",image:E,sku_id:"",options:H?.options||G?.options||{},price_usd:null,cost_price:$,product_id:H?.source_product_id||G?.product_id||"",variant_id:D.toString(),warehouses:"",supplier_id:null,product_link:H?.product_link||G?.product_link||"",variant_name:w,supplier_name:H?.supplier_name||"",source_variant_id:null,price:H?.price||G?.price||0})),[]);return a.useEffect(()=>{if(!P.size(C))return;const I=C?.line_items||[],T=C?.customer_info||{};if(I.length){const E=Z(I),D=ee(I);if(P.size(E)){const $=Object.values(E);z(w=>[...w,...$])}F($=>P.uniqBy([...$,...D],"variant_id"))}P.size(T)&&b(E=>({...E,...T}))},[C,Z,ee]),e.jsxs(e.Fragment,{children:[(s||u||j)&&e.jsx(In,{}),e.jsx(Pn,{content:le.ORDER_LIST.SUBROUTES.CREATE_ORDER.TITLE}),e.jsx(Ro,{className:_n(Ce.isShopifyEmbedded()&&"embedded"),children:e.jsxs(gn,{className:"create-order-page",fullWidth:!0,title:r("CreateOrder"),backAction:{content:r("BackToOrder"),onAction:()=>m&&m(le.ORDER_LIST.PATH)},primaryAction:{content:r("CreateOrder"),loading:u,disabled:!_.length||s||j,onAction:B},secondaryActions:[{disabled:u,content:r("ImportOrderData"),onAction:()=>p.current?.open()}],children:[e.jsx(K,{gap:"400",children:e.jsxs(ko,{children:[e.jsx(To,{children:e.jsx(Y,{background:"bg-fill",borderRadius:"300",shadow:"100",borderColor:"border",borderWidth:"025",children:e.jsx(lo,{products:_,onOpenModal:()=>A.current?.open(),onUpdateProduct:F,onRemoveProduct:V})})}),e.jsx(Eo,{style:{top:Ce.isShopifyEmbedded()?53:110},children:e.jsxs(K,{gap:"400",children:[e.jsx(co,{note:v?.note||"",onSaveNote:(I="")=>b(T=>({...T,note:I}))}),e.jsx(fo,{data:v,onChangCustomerInfo:L}),e.jsx(bo,{imageGroups:$n(_),data:g}),e.jsx(Mo,{relatedItems:f,setRelatedItems:c})]})})]})}),e.jsx(Hn,{ref:p,onImportOrder:y}),e.jsx(io,{products:_,selectedVariants:N,onSelectVariant:l,ref:A,onAdd:U})]})})]})},Ro=W.div`
199  max-width: 1428px;
200  margin: auto;
201
202  & > .create-order-page {
203    margin-top: var(--p-space-200);
204
205    & > .Polaris-Page > .Polaris-Box {
206      position: sticky !important;
207      top: 56px;
208      background: var(--p-color-bg-fill-secondary);
209      z-index: 150;
210      padding: var(--p-space-300) 0 !important;
211    }
212  }
213
214  &.embedded {
215    & > .create-order-page {
216      & > .Polaris-Page > .Polaris-Box {
217        top: 0;
218      }
219    }
220  }
221`;export{os as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.