1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="14086f8c-8845-58e9-988b-e9442a278233")}catch(e){}}(); 2import{r as n,b5 as ct,j as e,k as f,F as q,e as B,u as Z,hW as Ft,ba as Se,aT as xt,bl as Mt,N as M,_ as O,M as dt,aj as Nt,ai as Vt,aF as _t,n as R,T as N,ad as be,B as ie,a4 as ae,q as _e,aK as Re,aI as pe,am as Ue,W as xe,A as X,be as me,hX as Pt,a6 as ke,bx as Te,l as Le,o as U,ag as Ht,a8 as le,ab as we,bg as ut,dq as De,bh as qt,dT as yt,hY as Dt,bf as Bt,aL as ge,cE as It,bj as mt,p as Me,bk as Ut,b4 as Ne,an as ze,ac as Wt,bb as $t,aA as Qe,av as D,d2 as zt,dU as We,cV as Ct,L as Qt,z as re,dm as jt,a0 as Zt,bi as Be,bv as te,aG as A,bw as Gt,bm as Kt,bn as Yt,ao as Xt,as as pt,bo as Oe,aR as Et,hZ as Jt,a9 as j,h_ as er,w as Rt,x as Ve,cj as tr,aN as Fe,V as rr,a7 as ir,bz as nr,hT as sr,h$ as or,hU as ar,i0 as lr,i1 as cr,a5 as dr,aa as ur,D as mr,aC as pr,G as hr,aM as fr,P as gr,t as vr,aP as ht}from"./index-DmqEQZ_1.js";import{P as Sr,a as br,F as yr,A as Ir}from"./index-CU4oqjyQ.js";import{E as ft}from"./ErrorBanner-BseB2pjq.js";import{u as wt}from"./useOrgCarrierServiceOptions-DbK4lkm6.js";import{s as Cr,g as Er,Q as gt,b as Rr,E as wr,a as Tr}from"./utils-BikPrd_T.js";import{C as Lr}from"./CustomBadge-CewDazW5.js";import{C as Ar}from"./CustomCarrierAccount-CkgVtrdQ.js";import{u as kr}from"./useCarrierLogo-BBrwri0x.js";import{O as Or}from"./orgCarrierAccountStatus-D983TzTG.js";import{g as Fr,i as xr}from"./shipment-BFTbbL-x.js";import{W as Mr,u as Nr}from"./useFulfillmentOrderStateBadgeProps-CcNfVG-W.js";import{u as Vr}from"./inventory-items-RQq1gc1W.js";import{S as Ce}from"./signatureHandlingServiceType-zD4fuV6h.js";import{a as vt,b as _r}from"./utils-CkIqaNIW.js";import{a as Pr}from"./useIsSelfArrangeRequired-BqKXVwfQ.js";import{u as Tt}from"./useIossEnabled-DKjuasn8.js";import{F as Y}from"./fulfillmentOrderStatus-BobmtTUr.js";import{F as ve}from"./fulfillmentOrderSubStatus-hgM2ZB06.js";import{I as Hr,C as qr}from"./countries-BhE82V1V.js";import{u as Dr}from"./useShipmentPurposeOptions-DQzxgrku.js";import{u as Br}from"./useTaxTermOptions-DnXpojCw.js";import{S as Ur}from"./shippingConfigIossNumberDtoStatus-B0SmbTHA.js";import{R as Wr,a as $r}from"./ResourceList-P0Q034_L.js";import{S as zr,R as Qr}from"./index-CcgAK-jr.js";import{p as $e}from"./pick-CPZ0J3zW.js";import{a as _,b as ee,F as W}from"./types-DNYOLowP.js";import{S as jr}from"./ShipmentMobilePageTitleSection-DY-6XG6j.js";import{u as Zr,C as Gr}from"./ConfirmCancelFulfillmentOrderModal-DWWIPzCx.js";import{u as St}from"./useFulfillmentOrderSubmitErrorMap-D4oEkMk_.js";import"./useAddressInformationSchema-Drl74oy-.js";import"./index-esm-C4bmqvkG.js";import"./index-DfZCYHDy.js";import"./CustomPhoneInput-BDQtLkB6.js";import"./option-DVC9NjBR.js";import"./groupBy-DBLwNMIR.js";import"./_createAggregator-B587KDqf.js";import"./useCountryOptions-hLpn5iu0.js";import"./empty-saved-address-banner-image-GINpmc3z.js";import"./index-Be2Slq3a.js";import"./saved-addresses-Dkxscrd1.js";import"./addressType-Dq-BWODb.js";import"./useSavedAddressFormSchema-BYlwobvn.js";import"./index-DCgKM3kH.js";import"./CountrySelect-Cz3cDhHn.js";import"./TagList-blaORFTO.js";import"./useShipmentCountrySelectProps-DH21ong4.js";import"./useCountryErrorMap-CcReXmob.js";import"./merchantOfRecord-DdjkzC68.js";import"./useIsUsOriginFulfillmentOrderEnabled-CK21FqVF.js";import"./validateAddressCompleteness-CVsSj-B9.js";import"./ValidateFulfillmentOrderAddressModal-DxI5Avuc.js";import"./dedupeSuggestedAddresses-CNnrC5NF.js";import"./resolveAddressValidationMessages-J2Nq605t.js";import"./Step-D7hxw9l3.js";import"./ProgressBar-8FdIYCbW.js";import"./carrier-services-qYSKLoQ3.js";import"./question-mark-BabpBKw_.js";import"./carrierServiceHandoverMethod-BLHbfA3K.js";import"./carrier-BOl6OKCc.js";import"./empty-CmuRKk3V.js";import"./bucket-10-B1mB5QUF.js";import"./List-DKaonmcQ.js";import"./ShipmentTagsSelect-C1X_tELp.js";import"./_baseUnset-DvIg8w3J.js";import"./last-DXTTfs9a.js";import"./useShipmentTagOptions-Bs4s7X_O.js";import"./shopify-CRNgkJkj.js";import"./index-DzebAsQt.js";import"./zonos-logo-CKwfRRSC.js";
2import"./ss-care-DVsimFIe.js";import"./BillingChargesSummary-tby__UmF.js";import"./PaymentRow-DM8uQo8g.js";import"./shipmentStatus-D7BvCoWo.js";import"./shippingBillingEntryStatus-hYY7tmAe.js";import"./shippingBillingEntryType-BYufWFD9.js";import"./auto-select-carrier-B3sg8yoG.js";import"./AddressIndicator-CtwOqNDj.js";import"./unfulfilledFulfillmentOrderListItemDtoReceiverAddressValidationStatus-BHywC0QA.js";import"./PaymentTermsAndConditions-CbG-nNPV.js";const Kr=({isSuccess:s,isError:r,quotes:i,errorQuotes:d,selectedQuotationResult:o,onQuotationResultSelect:a,onNoQuotesCtaClick:l})=>{const u=n.useMemo(()=>(i??[]).map(h=>({...h,stableRenderId:ct("quote")})),[i]),g=n.useMemo(()=>Cr({quotes:u,getTotalCost:Er}),[u]),p=n.useMemo(()=>(d??[]).map(h=>({...h,stableRenderId:ct("error-quote")})),[d]);return r?e(gt,{state:"UNKNOWN_ERROR",onNoQuotesCtaClick:l}):s&&u.length===0&&p.length===0?e(gt,{state:"NO_QUOTES",onNoQuotesCtaClick:l}):f(q,{children:[g.map(h=>{var b,v;return e(Rr,{quote:h,currency:"",isSelected:(o==null?void 0:o.type)==="quote"&&o.quote.carrierService.id===h.carrierService.id&&((b=o.quote.orgCarrierAccount)==null?void 0:b.id)===((v=h.orgCarrierAccount)==null?void 0:v.id),shouldShowHandoverMethod:!1,shouldShowTotalCost:!1,onClick:()=>{a==null||a({type:"quote",quote:h})}},h.stableRenderId)}),p.map(h=>e(wr,{errorQuote:h,currency:""},h.stableRenderId))]})},Yr=({fulfillmentOrderId:s,carrierServiceId:r,orgCarrierAccountId:i,isInternational:d,onClose:o,onCarrierServiceSelect:a})=>{const{t:l}=B(),{userOrganization:u}=Z(),[g,p]=n.useState(),[h,b]=n.useState(null),{mutateAsync:v,isLoading:c}=Ft({mutation:{onSuccess:T=>{p(T)}}}),{watch:C}=Se(),I=C("taxTerm"),F=C("lineItems"),S=C("valueAddedServices");xt(()=>{u&&(I||!d)&&F.length>0&&v({orgId:u.id,fulfillmentOrderId:s,data:{taxTerm:I??null,lineItems:F.map(T=>({productId:T.product.id,inventoryItemReceivedEntryId:T.inventoryItemReceivedEntryId??void 0,qty:T.qty})),valueAddedServices:{signatureHandling:S==null?void 0:S.signatureHandling,isAddressTranslationNeeded:S==null?void 0:S.isAddressTranslationNeeded}}})}),n.useEffect(()=>{if(g){const T=g.quotes.find(L=>{var w;return L.carrierService.id===r&&((w=L.orgCarrierAccount)==null?void 0:w.id)===i}),t=g.errorQuotes.find(L=>{var w;return L.carrierService.id===r&&((w=L.orgCarrierAccount)==null?void 0:w.id)===i});T?b({type:"quote",quote:T}):t&&b({type:"errorQuote",errorQuote:t})}},[r,i,g]);const y=n.useCallback(()=>{(h==null?void 0:h.type)==="quote"&&(a(h),o())},[a,o,h]);return f(dt,{open:!0,fullScreen:!0,title:"",titleHidden:!0,onClose:()=>{},primaryAction:{content:l("pages.fulfillmentOrder.form.fields.carrierService.manualSelect.modal.confirm"),disabled:!h||h.type==="errorQuote",onAction:y},children:[e(Mt,{title:l("pages.fulfillmentOrder.form.fields.carrierService.manualSelect.modal.title"),onClose:o}),e(dt.Section,{children:M({isLoading:c,quotation:g}).with({isLoading:!0},()=>e(Tr,{})).with({isLoading:!1,quotation:O.not(O.nullish)},T=>e(Kr,{isSuccess:T.quotation.isSuccess,quotes:T.quotation.quotes,errorQuotes:T.quotation.errorQuotes,selectedQuotationResult:h,onQuotationResultSelect:b,onNoQuotesCtaCl
2ick:o})).otherwise(()=>null)})]})},bt=({carrierServiceId:s,orgCarrierAccountId:r,isChangeDisabled:i=!1,onChange:d})=>{const{t:o}=B(),{userOrganization:a}=Z(),{carrierServices:l}=wt(),{data:u=[]}=Nt((a==null?void 0:a.id)??""),{data:g}=Vt((a==null?void 0:a.id)??""),p=n.useMemo(()=>l.find(c=>c.id===s),[s,l]),h=n.useMemo(()=>{const c=l.find(C=>C.value===(p==null?void 0:p.value));return!c||!(g!=null&&g.isEnabled)?[]:u.filter(C=>C.status===Or.enabled&&C.carrierSlug===(c==null?void 0:c.carrierSlug))},[p,l,g==null?void 0:g.isEnabled,u]),b=n.useMemo(()=>h.find(c=>c.id===r),[r,h]),v=kr(p==null?void 0:p.carrierLogoUrl);return f(R,{alignment:"center",wrap:!1,children:[e(R.Item,{children:e(_t,{size:"small",source:v,alt:(p==null?void 0:p.label)??""})}),e(R.Item,{fill:!0,children:f(R,{alignment:"center",spacing:"tight",children:[e(N,{as:"p",variant:"bodyMd",truncate:!0,children:p==null?void 0:p.label}),b&&e(be,{content:Fr(b),children:f(Lr,{className:"Polaris-Badge",$status:"highlight",children:[e(Ar,{size:20}),e(N,{variant:"bodySm",as:"span",children:b.name??b.accountNumber})]})})]})}),e(R.Item,{children:e(ie,{plain:!0,disabled:i,onClick:d,children:o("pages.fulfillmentOrder.form.fields.carrierService.change.label")})})]})},Xr=({fulfillmentOrderId:s,carrierServiceId:r,orgCarrierAccountId:i,isGlobalEOrder:d,isInternational:o,onSelectedCarrierService:a,onSelectedOrgCarrierAccount:l})=>{const{t:u}=B(),{userOrganization:g}=Z();ae(g);const[p,h]=n.useState(d?!1:!r),{value:b,setTrue:v,setFalse:c}=_e(!1),{carrierServices:C}=wt(),{watch:I}=Se(),F=I("taxTerm"),S=I("lineItems"),y=!!((F||!o)&&S.length>0),T=n.useCallback(L=>{Re(C.find(w=>w.id===L.quote.carrierService.id),pe,a),L.quote.orgCarrierAccount&&l(L.quote.orgCarrierAccount.id)},[C,a,l]),t=n.useCallback((L,w)=>{d||M(w).with("autoSelectCarrierService",()=>{h(!0),a(null),l(null)}).with("manualSelectCarrierService",()=>{h(!1),y&&v()}).exhaustive()},[y,d,a,l,v]);return n.useEffect(()=>{if(d){h(!1);return}!y&&!p&&h(!0)},[y,d,p]),f(X,{sectioned:!0,title:u("pages.fulfillmentOrder.form.fields.carrierService.label"),children:[f(R,{vertical:!0,children:[d&&e(Ue,{status:"info",children:u("pages.fulfillmentOrder.form.fields.carrierService.globalE.banner")}),e(xe,{label:u("pages.fulfillmentOrder.form.fields.carrierService.followShippingRules.label"),id:"autoSelectCarrierService",name:"carrierServiceOption",checked:p,disabled:d,onChange:t}),e(xe,{label:u("pages.fulfillmentOrder.form.fields.carrierService.manualSelect.label"),id:"manualSelectCarrierService",name:"carrierServiceOption",checked:!p,disabled:d||!y,onChange:t}),M({isCarrierServiceQuotationAvailable:y,shouldAutoSelectCarrierService:p,carrierServiceId:r,isGlobalEOrder:d}).with({isGlobalEOrder:!0,carrierServiceId:O.not(O.nullish)},()=>e(bt,{carrierServiceId:r,orgCarrierAccountId:i,isChangeDisabled:!0,onChange:()=>{}})).with({isGlobalEOrder:!0,carrierServiceId:O.nullish},()=>null).with({isCarrierServiceQuotationAvailable:!1},()=>e(Ue,{status:"warning",children:u("pages.fulfillmentOrder.form.fields.carrierService.warningBanner.desc")})).with({isCarrierServiceQuotationAvailable:!0,shouldAutoSelectCarrierService:!1,carrierServiceId:O.not(O.nullish)},()=>e(bt,{carrierServiceId:r,orgCarrierAccountId:i,onChange:v})).with({isCarrierServiceQuotationAvailable:!0,shouldAutoSelectCarrierService:!1,carrierServiceId:O.nullish},()=>e(ie,{onClick:v,children:u("pages.fulfillmentOrder.form.fields.carrierService.manualSelect.button")})).with({shouldAutoSelectCarrierService:!0},()=>null).exhaustive()]}),b&&!d&&e(Yr,{fulfillmentOrderId:s,carrierServiceId:r,orgCarrierAccountId:i,isInternational:o,onClose:c,onCarrierServiceSelect:T})]})},Jr="data:image/svg+xml,%3csvg%20width='60'%20height='60'%20viewBox='0%200%2060%2060'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_40466_187401)'%3e%3cpath%20d='M60%2051H57.4659V16.9237L29.7371%205.35941H30.3772L3.53412%2016.8969V51H1V15.5703L29.6677%203H30.4006L60%2015.5435V51Z'%20fill='black'%20stroke='black'%20stroke-width='0.5'/%3e%3cellipse%20cx='32'%20cy='52.5'%20rx='24'%20ry='4.5'%20fill='%23EBEBEB'/%3e%3cpath%20d='M31.1094%2035.2718V34.2718H30.1094H11.4707H10.4707V35.2718V48.9402V49.9402H11.4707H30.1094H31.1094V48.9402V35.2718Z'%20fill='%2317F082'%20stroke='black'%20stroke-width='2'%20stroke-miterlimit='10'/%3e%3cpath%20d='M22.0328%2035.2718H19.5476V40.8634H22.0328V35.2718Z'%20fill='black'/%3e%3cpath%20d='M52%2035.2718V34.2718H51H32.3613H31.3613V35.2718V48.9402V49.9402H32.3613H51H52V48.9402V35.2718Z'%20fill='%2317F082'%20stroke='black'%20stroke-width='2'%20stroke-miterlimit='10'/%3e%3cpath%20d='M42.9234%2035.2718H40.4382V40.8634H42.9234V35.2718Z'%20fill='black'/%3e%3cpath%20d='M40.9523%2019.4051V18.4051H39.9523H21.3136H20.3136V19.4051V33.0734V34.0734H21.3136H39.9523H40.9523V33.0734V19.4051Z'%20fill='%2317F082'%20stroke='black'%20stroke-width='2'%20stroke-miterlimit='10'/%3e%3cpath%20d='M31.8755%2019.4051H29.3904V24.9967H31.8755V19.4051Z'%20fill='black'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_40466_187401'%3e%3crect%20width='60'%20height='60'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",ei=({size:s=16,background:r="white",disabled:i=!1})=>f("svg",{width:`${s}`,height:`${s}`,viewBox:"0 0 155 155",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("rect",{width:"155",height:"155",fill:r}),e("path",{d:"M112.919 70.2227V66.4738H127V27H28V70.2227L42.081 84.7773V88.5262H28V128H127V84.7773L112.919 70.2227Z",fill:i?"#BDC1CC":"#17F082"})]});var Ee=(s=>(s.BY_SPACESHIP="bySpaceship",s.OFFLINE_DELIVERY="offlineDelivery",s))(Ee||{});const ti=U("div",{target:"eldia6v0"})({name:"89wn97",styles:"display:inline-block;vertical-align:bottom;line-height:1"}),ri=({formMethods:s,disabled:r,isSelfArrangeRequired:i,onHandleMethodChange:d})=>{const{control:o,watch:a}=s,l=a("isOfflineDelivery"),u=n.useMemo(()=>i||l?"offlineDelivery":"bySpaceship",[i,l]);return e(X,{sectioned:!0,title:f(q,{children:[`${ke("pages.fulfillmentOrder.form.details.section.deliveryMethod.title")} `,e(be,{content:e(Le,{i18nKey:"pages.fulfillmentOrder.form.details.section.deliveryMethod.helpText",components:{strong:e(N,{as:"span",variant:"bodyMd",fontWeight:"semibold",children:e("div",{})})}}),preferredPosition:"mostSpace",children:e(ti,{children:e(Te,{size:16,color:"var(--p-icon)"})})})]}),children:f(R,{vertical:!0,spacing:"loose",children:[e(me,{name:"isOfflineDelivery",control:o,render:()=>e(Pt,{name:"deliveryMethod",orientation:"vertical",options:[{icon:e(ei,{disabled:r,background:"white",size:20}),value:"bySpaceship",label:ke("pages.fulfillmentOrder.form.button.handleBySpaceship")},{icon:e(Mr,{disabled:r,size:20}),value:"offlineDelivery",label:ke("pages.fulfillmentOrder.form.button.handleOffline")}],disabled:r||i,selected:u,onChange:d})}),(l||i)&&f(R,{vertical:!1,wrap:!1,children:[e(R.Item,{fill:!0,children:e(N,{variant:"bodyMd",as:"span",children:ke("pages.fulfillmentOrder.form.details.section.deliveryMethod.desc")})}),e(R.Item,{children:e("img",{src:Jr,alt:"Warehouse Icon",height:100,width:100})})]})]})})},ii=({label:s,orgWarehouse:r,productType:i,selectedProducts:d,onInventoryItemSelect:o})=>{const{t:a}=B(),{userOrganization:l}=Z(),[u,g]=n.useState(),[p,h]=n.useState(1),[b,v]=n.useState();Ht(()=>
2{v(u)},500,[u]);const{data:c}=Vr((l==null?void 0:l.id)??"",{productType:i,keyword:b==null?void 0:b.trim(),orgWarehouseIds:[r.id],page:p,perPage:50}),C=n.useMemo(()=>(c==null?void 0:c.items.filter(y=>!d.some(T=>T.productId===y.productId&&le(T.inventoryItemReceivedEntryId))).map(y=>({label:`${y.product.sku} - ${le(y.product.name)?y.product.itemDescription:y.product.name}`,value:y.id})))??[],[c==null?void 0:c.items,d]),I=n.useCallback(y=>{Re(c,pe,T=>T.items.find(t=>t.id===y[0]),pe,o),g(void 0)},[o,c]),F=n.useCallback(()=>{h(y=>y+1)},[]),S=e(ut.TextField,{requiredIndicator:!0,value:u??void 0,label:s,placeholder:a(`pages.fulfillmentOrder.form.details.section.itemSelection.dropdownList.${we(i)}.placeholder`),onChange:g,autoComplete:"off",disabled:!i});return e(ut,{options:C,selected:[],textField:S,onSelect:I,onLoadMoreResults:F})},ni=U("span",{target:"e8cugen2"})({name:"16x4uu8",styles:"color:var(--p-text-critical);margin:0 4px"}),si=U("div",{target:"e8cugen1"})({name:"89wn97",styles:"display:inline-block;vertical-align:bottom;line-height:1"}),oi=U("div",{target:"e8cugen0"})({name:"ey5f1f",styles:"height:2px"}),ai=({index:s,isDisabled:r,lineItem:i,orgWarehouse:d,allSelectedInventoryItemReceivedEntryIds:o,onEdit:a})=>{var Q,se;const[l,u]=n.useState(!1),[g,p]=n.useState(void 0),[h,b]=n.useState(void 0),v=n.useMemo(()=>g&&De(g)>0&&h,[g,h]),{t:c}=B(),{userOrganization:C}=Z(),I=pe(C==null?void 0:C.id),{currencies:F}=qt(),{isSupportsLotLevelInventoryTracking:S}=yt(d.id),{data:y,isLoading:T}=Dt(I,{orgWarehouseId:d.id,productId:i.product.id}),{data:t}=Bt(I),L=n.useMemo(()=>t==null?void 0:t.items.find(k=>k.id===i.product.id),[t,i.product.id]),w=n.useMemo(()=>Re((y==null?void 0:y.items)??[],ge.filter(k=>i.inventoryItemReceivedEntryId===k.id||!o.includes(k.id)),ge.map(k=>({label:[k.warehouseReceivingOrder.ssid,k.lotNumber,k.expiryDate].join(" - "),value:k.id,onHandQty:k.onHandQty}))),[o,y,i.inventoryItemReceivedEntryId]),$=n.useCallback(k=>{const ce=w==null?void 0:w.find(oe=>oe.value===k);a({inventoryItemReceivedEntryId:ce?ce.value:null,qty:i.qty,unitValue:i.unitValue,currency:i.currency})},[w,i.qty,i.unitValue,i.currency,a]),de=n.useCallback(k=>{a({inventoryItemReceivedEntryId:i.inventoryItemReceivedEntryId,qty:De(k),unitValue:i.unitValue,currency:i.currency})},[i.inventoryItemReceivedEntryId,i.unitValue,i.currency,a]),he=n.useCallback((k,ce)=>{a({inventoryItemReceivedEntryId:i.inventoryItemReceivedEntryId,qty:i.qty,unitValue:De(k),currency:ce??i.currency})},[i.inventoryItemReceivedEntryId,i.qty,i.currency,a]),{value:ue,setTrue:fe,setFalse:P,toggle:ne}=_e(!le(i.inventoryItemReceivedEntryId)),G=n.useCallback(k=>{ne(),k?fe():(P(),$(""))},[$,P,fe,ne]),{getFieldState:K}=Se(),z=K(`lineItems.${s}.qty`);return f(R,{vertical:!0,spacing:"tight",children:[f(R,{wrap:!1,children:[e(R.Item,{fill:!0,children:f(R,{vertical:!0,spacing:"none",children:[f(R,{distribution:"equalSpacing",alignment:"center",children:[f(It,{id:"unitValue",children:[e(N,{as:"span",variant:"bodyMd",children:c("pages.fulfillmentOrder.form.details.section.itemSelection.unitValue.label")}),e(ni,{children:"*"}),e(be,{content:e(Le,{i18nKey:"pages.fulfillmentOrder.form.details.section.itemSelection.unitValue.tooltip",components:{strong:e(N,{as:"span",variant:"bodyMd",fontWeight:"semibold",children:e("div",{})})}}),preferredPosition:"mostSpace",children:e(si,{children:e(Te,{size:16,color:"var(--p-icon)"})})})]}),e(R.Item,{children:l?f(q,{children:[e(ie,{plain:!0,size:"slim",onClick:()=>{u(!1)},disabled:r,children:c("pages.fulfillmentOrder.form.details.section.itemSelection.unitValue.cancel")}),e(ie,{plain:!0,size:"slim",onClick:()=>{u(!1),he(g??0,h??"")},disabled:r||!v,children:c("pages.fulfillmentOrder.form.details.section.itemSelection.unitValue.save")})]}):e(ie,{plain:!0,size:"slim",onClick:()=>{u(!0),p(i.unitValue??(L==null?void 0:L.unitValue)??void 0),b(i.currency??(L==null?void 0:L.currency)??void 0)},disabled:r,children:c("pages.fulfillmentOrder.form.details.section.itemSelection.unitValue.edit")})})]}),e(oi,{}),e(mt,{label:"",value:l?g:i.unitValue??(L==null?void 0:L.unitValue)??void 0,onChange:l?k=>p(String(k).trim()===""?void 0:k):Me,type:"two-decimal",disabled:r||!l,autoComplete:"off",placeholder:c("pages.fulfillmentOrder.form.details.section.itemSelection.unitValue.placeholder"),connectedLeft:e(Ut,{label:"",placeholder:c("pages.fulfillmentOrder.form.details.section.itemSelection.currency.placeholder"),options:F,value:l?h:i.currency??(L==null?void 0:L.currency)??void 0,onChange:l?b:Me,disabled:r||!l,labelHidden:!0})})]})}),e(R.Item,{children:e(mt,{type:"integer",disabled:r,value:i.qty,min:1,onChange:de,label:c("pages.fulfillmentOrder.form.details.section.itemSelection.qty.label"),autoComplete:"off",requiredIndicator:!0,placeholder:c("pages.fulfillmentOrder.form.details.section.itemSelection.qty.placeholder"),error:!!((Q=z==null?void 0:z.error)!=null&&Q.message)})})]}),ue&&e(Ne,{disabled:r,label:c("pages.fulfillmentOrder.form.details.section.itemSelection.selectFromSpecificLot.label"),checked:!0,onChange:G}),e(R,{wrap:!1,children:e(R.Item,{fill:!0,children:S?M({shouldShowItemEntryOptions:ue,hasItemEntry:w.length>0}).with({shouldShowItemEntryOptions:!0},()=>e(ze,{disabled:r,placeholder:c("pages.fulfillmentOrder.form.details.section.itemSelection.selectFromSpecificLot.placeholder"),options:w,value:i.inventoryItemReceivedEntryId??void 0,onChange:$})).with({hasItemEntry:!0}
2,()=>e(Ne,{label:c("pages.fulfillmentOrder.form.details.section.itemSelection.selectFromSpecificLot.label"),checked:!1,disabled:r,onChange:G})).with({hasItemEntry:!1},()=>T?null:e(Wt,{items:[{icon:$t,status:"warning",description:e(N,{as:"p",variant:"bodyMd",color:"warning",children:c("pages.fulfillmentOrder.form.details.section.itemSelection.error.noItemEntryRecord")})}]})).exhaustive():null})}),((se=z==null?void 0:z.error)==null?void 0:se.message)&&e(Qe,{message:z.error.message,fieldID:`lineItems.${s}.qty`})]})},li=()=>e(zt,{size:20}),ci=({index:s,isDisabled:r,item:i,orgWarehouse:d,allSelectedInventoryItemReceivedEntryIds:o,onEdit:a,onDelete:l})=>{const u=n.useCallback(()=>{l(s)},[s,l]),g=n.useCallback(p=>{a({index:s,inventoryItemReceivedEntryId:p.inventoryItemReceivedEntryId,qty:p.qty,unitValue:p.unitValue,currency:p.currency})},[s,a]);return f(q,{children:[s>0&&e(D,{heightSpace:"8"}),f(R,{vertical:!0,spacing:"none",children:[f(R,{vertical:!1,wrap:!1,children:[e(R.Item,{fill:!0,children:f(N,{variant:"headingSm",as:"p",children:[i.product.sku," ",` - ${le(i.product.name)?i.product.itemDescription:i.product.name}`]})}),!r&&e(R.Item,{children:e(ie,{plain:!0,size:"slim",icon:li,onClick:u})})]}),i.product.barcode&&e(N,{variant:"bodyMd",as:"p",color:"subdued",children:i.product.barcode}),e(D,{heightSpace:"4"}),e(ai,{index:s,isDisabled:r,lineItem:i,orgWarehouse:d,allSelectedInventoryItemReceivedEntryIds:o,onEdit:g})]})]})},di=U("span",{target:"e1jzn1pf1"})({name:"16x4uu8",styles:"color:var(--p-text-critical);margin:0 4px"}),ui=U("div",{target:"e1jzn1pf0"})({name:"89wn97",styles:"display:inline-block;vertical-align:bottom;line-height:1"}),mi=({value:s,isDisabled:r,onChange:i})=>{const{t:d}=B();return f(R,{vertical:!0,spacing:"tight",children:[f(It,{id:"productType",children:[e(N,{as:"span",variant:"bodyMd",children:d("pages.fulfillmentOrder.form.details.section.itemSelection.productType.label")}),e(di,{children:"*"}),e(be,{content:e(Le,{i18nKey:"pages.fulfillmentOrder.form.details.section.itemSelection.productType.helpText",components:{strong:e(N,{as:"span",variant:"bodyMd",fontWeight:"semibold",children:e("div",{})})}}),preferredPosition:"mostSpace",children:e(ui,{children:e(Te,{size:16,color:"var(--p-icon)"})})})]}),e(ze,{disabled:r,placeholder:d("pages.fulfillmentOrder.form.details.section.itemSelection.productType.placeholder"),options:[{value:We.sellable_product,label:d("pages.fulfillmentOrder.form.details.section.itemSelection.productType.sellableProduct.label")},{value:We.carton,label:d("pages.fulfillmentOrder.form.details.section.itemSelection.productType.carton.label")}],value:s,onChange:i})]})},pi=({isDisabled:s,lineItems:r,orgWarehouse:i,onItemAdded:d,onItemEdited:o,onRemove:a})=>{var C;const{t:l}=B(),[u,g]=n.useState(),p=Re(r,ge.map(I=>I.inventoryItemReceivedEntryId),ge.compact),h=n.useMemo(()=>Re(r,ge.map(I=>I.product.type),ge.uniqBy(I=>I)),[r]),b=n.useCallback(I=>{r.find(F=>F.product.id===I.productId&&F.inventoryItemReceivedEntryId===null)||d({product:{id:I.productId,type:I.product.type,name:I.product.name,sku:I.product.sku,barcode:I.product.barcode,itemDescription:I.product.itemDescription},inventoryItemReceivedEntryId:null,qty:1,connectedStoreExternalLineItemId:null,unitValue:null,currency:null})},[r,d]),{getFieldState:v}=Se(),c=v("lineItems");return n.useEffect(()=>{h.length===1&&g(h[0])},[h]),f(X,{title:l("pages.fulfillmentOrder.form.details.section.itemSelection.title"),children:[e(X.Section,{children:e(mi,{value:u,onChange:g,isDisabled:r.length>0})}),u&&r.length>0&&e(X.Section,{children:r.map((I,F)=>e(ci,{index:F,isDisabled:s,item:I,orgWarehouse:i,allSelectedInventoryItemReceivedEntryIds:p,onEdit:o,onDelete:a},F))}),!s&&u&&f(X.Section,{children:[e(ii,{label:l("pages.fulfillmentOrder.form.details.section.itemSelection.dropdownList.title",{warehouse:i.name}),orgWarehouse:i,productType:u,selectedProducts:r.map(I=>({productId:I.product.id,inventoryItemReceivedEntryId:I.inventoryItemReceivedEntryId})),onInventoryItemSelect:b}),e(D,{heightSpace:"4"}),r.length===0&&f(R,{vertical:!0,alignment:"center",children:[e(D,{heightSpace:"4"}),e(N,{variant:"headingLg",as:"p",alignment:"center",children:l(`pages.fulfillmentOrder.form.details.section.itemSelection.empty.${we(u)}.title`)}),e(N,{variant:"bodyMd",as:"p",children:l(`pages.fulfillmentOrder.form.details.section.itemSelection.empty.${we(u)}.desc`)}),e(D,{heightSpace:"8"})]}),((C=c.error)==null?void 0:C.message)&&e(Qe,{message:c.error.message,fieldID:"lineItems"})]})]})},hi=U("div",{target:"e3uzcdb1"})({name:"km0x55",styles:"display:inline-flex;align-items:center;gap:var(--p-space-1)"}),fi=U("div",{target:"e3uzcdb0"})({name:"5k3peh",styles:"display:inline-block;vertical-align:bottom;line-height:1;cursor:pointer"}),gi=({disabled:s=!1,fulfillmentOrder:r})=>{const{t:i}=B(),{control:d}=Se(),{userOrgConfigs:o}=Z(),a=(o==null?void 0:o.isAiAddressTranslationEnabled)??!1;return e(X,{title:i("form.valueAddedServices.title"),sectioned:!0,children:e(R,{vertical:!0,spacing:"tight",children:e(me,{name:"valueAddedServices",control:d,render:({field:l})=>{var p,h,b;const u=((h=(p=l.value)==null?void 0:p.signatureHandling)==null?void 0:h.type)===Ce.direct_signature_required,g=((b=l.value)==null?void 0:b.isAddressTranslationNeeded)??!1;return f(R,{vertical:!0,children:[e(Ne,{label:f(hi,{children:[e("span",{children:i("form.valueAddedServices.directSignatureDelivery")}),e(be,{content:i("form.valueAddedServices.directSignatureDeliveryHelpText"),preferredPosition:"mostSpace",children:e(fi,{children:e(Te,{size:16,color:"var(--p-icon)"})})})]}),checked:u,onChange:v=>{const c=v?{type:Ce.direct_signature_required}:void 0;l.onChange(v||g?{signatureHandling:c,isAddressTranslationNeeded:g?!0:void 0}:null),l.onBlur()},disabled:s}),a&&r.receiverAddress.isAddressTranslationSupported&&e(Ne,{label:i("form.valueAddedServices.addressTranslationNeeded"),checked:g,onChange:v=>{var C,I;const c=((I=(C=l.value)==null?void 0:C.signatureHandling)==null?void 0:I.type)===Ce.direct_signature_required;l.onChange(v||c?{isAddressTranslationNeeded:v?!0:void 0,signatureHandling:c?{type:Ce.direct_signature_required}:void 0}:null),l.onBlur()},disabled:s})]})}})})})},vi=U("p",{target:"e1ptefo0"})({name:"1qletdn",styles:"a{color:var(--p-text);}"}),Si=()=>{const{userOrganization:s}=Z(),{data:r,isLoading:i}=Ct(s.id);return i||r!=null&&r.length?null:e(Ue,{status:"warning",children:e(vi,{children:e(Le,{i18nKey:"shipment.shipmentDetails.sections.shipmentDetails.iossWarning",components:{settingsLink:e(Qt,{to:re.settings({tab:jt.TAXES})})}})})})},bi=({selectedId:s,placeholder:r,error:i,onSelect:d,disabled:o})=>{const{userOrganization:a}=Z(),{t:l}=B(),{data:u}=Ct(a.id),{value:g,setFalse:p,toggle:h}=_e(!1),b=n.useMemo(()=>(u==null?void 0:u.filter(({status:S})=>S===Ur.enabled))??[],[u]),[v,c]=n.useState(()=>b==null?void 0:b.find(({id:S})=>S===s)),C=n.useMemo(()=>b.find(({isDefault:S})=>!!S),[b]),I=e(ie,{onClick:h,disclosure:!0,fullWidth:!0,textAlign:"left",disabled:!!o,children:M(!!v).with(!0,()=>`IMâ¢â¢â¢â¢â¢â¢${v==null?void 0:v.iossNumberLast4}`).with(!1,()=>r??l("form.fields.taxTerm.ioss.placeholder")).exhaustive()}),F=n.useCallback(S=>{c(S),p();const y=b.find(({id:T})=>T===S.id);y&&d(y)},[d,b,p]);return n.useEffect(()=>{if(s){const S=b==null?void 0:b.find(({id:y})=>y===s);S&&c(S)}else C&&!v&&F(C)},[C,b,s,F,v]),f(q,{children:[e(Zt,{active:g,activator:I,onClose:p,fullWidth:!0,children:e(Wr,{items:b,renderItem:S=>{const{id:y,iossNumberLast4:T,name:t}=S;return f($r,{id:y,onClick:()=>F(S),persistActions:!0,children:[f("div",{children:["IMâ¢â¢â¢â¢â¢â¢",T]}),e(N,{variant:"bodyLg",as:"p",color:"subdued",children:t})]})}})}),i&&f(q,{children:[e(D,{heightSpace:"1"}),e(Qe,{message:i,fieldID:"option-list-select"})]})]})},yi=U("div",{target:"ewsbvof3"})({name:"5g75tq",styles:".Polaris-Label{width:100%;}"}),Ii=U("div",{target:"ewsbvof2"})({name:"zjik7",styles:"display:flex"}),Ci=U("div",{target:"ewsbvof1"})({name:"89wn97",styles:"display:inline-block;vertical-align:bottom;line-height:1"});var Ei={name:"gm9194",styles:"background:var(--p-surface-critical-subdued);border-color:var(--p-border-critical)"},Ri={name:"1hp0zu2",styles:"color:var(--p-text-subdued)"};const wi=U("div",{target:"ewsbvof0"})(".Polaris-Button__Content{",s=>!s.hasValue&&Ri,";}.Polaris-Button{",s=>s.hasError&&Ei,";}"),Ti=({receiverCountry:s,isIossEnabled:r})=>{const{t:i}=B(),{userOrgConfigs:d}=Z(),{shipmentPurposeOptions:o}=Dr(),{taxTermOptions:a}=Br({receiverCountry:s}),l=n.useMemo(()=>Hr.includes(s),[s]),{control:u,watch:g,formState:{errors:p}}=Se(),h=g("taxTerm"),b=g("iossNumberId");return f(X,{sectioned:!0,children:[e(N,{variant:"headingMd",as:"p",children:i("pages.fulfillmentOrder.form.details.customDeclaration.title")}),e(D,{heightSpace:"5"}),e(yi,{children:f(Be,{children:[e(Be.Group,{children:e(me,{control:u,name:"purpose",render:({field:v,fieldState:{error:c}})=>e(ze,{label:f(Ii,{children:[e("span",{children:i("pages.fulfillmentOrder.form.fields.shipmentPurpose.label")}),e(D,{widthSpace:"1"}),e(be,{content:i("pages.fulfillmentOrder.form.fields.shipmentPurpose.helpText"),preferredPosition:"mostSpace",children:e(Ci,{children:e(Te,{size:16,color:"var(--p-icon)"})})})]}),placeholder:i("pages.fulfillmentOrder.form.fields.shipmentPurpose.placeholder"),options:o,...v,error:c==null?void 0:c.message})})}),f(R,{spacing:"none",distribution:"equalSpacing",children:[e(R.Item,{fill:!0,children:e("span",{children:i("pages.fulfillmentOrder.form.fields.taxTerm.label")})}),e(R.Item,{children:e(Le,{i18nKey:"shipment.shipmentDetails.sections.shipmentDetails.ctaLink",components:{ctaLink:e(ie,{plain:!0,external:!0,url:i("shipment.shipmentDetails.sections.shipmentDetails.fields.taxHandling.supportUrl")})}})})]}
2),a.map(v=>e(me,{name:"taxTerm",control:u,render:({field:c})=>e(xe,{id:v.value,checked:h===v.value,label:i(`taxTerm.${v.value}.label`),...c,onChange:()=>{c.onChange(v.value)}})})),!a.some(v=>v.value===te.IOSS)&&h===te.IOSS&&e(xe,{disabled:!0,id:te.IOSS,checked:h===te.IOSS,label:i(`taxTerm.${te.IOSS}.label`)}),h===te.IOSS&&e(Be.Group,{children:e(wi,{hasValue:!!b,hasError:!!p.iossNumberId,children:e(me,{name:"iossNumberId",control:u,render:({field:v,fieldState:{error:c}})=>e(bi,{disabled:!a.some(C=>C.value===te.IOSS),error:c==null?void 0:c.message,selectedId:b??null,onSelect:C=>{v.onChange(C.id)}})})})}),!a.some(v=>v.value===h)&&h&&e(N,{as:"p",variant:"bodyMd",color:"critical",children:i("shipment.shipmentDetails.sections.shipmentDetails.fields.taxHandling.unsupportedTaxTerm")}),(d==null?void 0:d.isIossEnabled)&&l&&!r&&e(Si,{})]})})]})},Li=s=>{const{t:r}=B(),{isIossEnabledForCountry:i}=Tt();return n.useMemo(()=>{const d=A.object({carrierServiceId:A.string().uuid().nullable().optional(),orgCarrierAccountId:A.string().uuid().nullable().optional(),orderRef:A.string({required_error:r("form.validation.required",{fieldName:r("pages.fulfillmentOrder.form.fields.orderReference.label")})}).trim().max(vt,{message:r("form.validation.invalidMaxLength",{fieldName:r("pages.fulfillmentOrder.form.fields.orderReference.label"),maxLength:vt})}).optional(),purpose:A.nativeEnum(Gt).optional(),taxTerm:A.nativeEnum(te).refine(o=>o!==te.IOSS||i(s.receiverCountry),{message:r("form.validation.pleaseSelect",{fieldName:r("pages.fulfillmentOrder.form.fields.taxTerm.label")})}).optional(),iossNumberId:A.string({required_error:r("form.validation.pleaseSelect",{fieldName:r("form.fields.taxTerm.ioss.label")})}).trim().optional(),lineItems:A.array(A.object({product:A.object({id:A.string().uuid(),name:A.string().nullable(),sku:A.string(),barcode:A.string().nullable(),type:A.nativeEnum(We),itemDescription:A.string()}),inventoryItemReceivedEntryId:A.string().uuid().nullish(),connectedStoreExternalLineItemId:A.string().nullable().default(null),qty:A.number({invalid_type_error:r("form.validation.invalidNumber.greaterThanOrEqualTo",{fieldName:r("form.fields.quantity.label"),min:1}),required_error:r("form.validation.invalidNumber.greaterThanOrEqualTo",{fieldName:r("form.fields.quantity.label"),min:1})}).min(1,{message:r("form.validation.invalidNumber.greaterThanOrEqualTo",{fieldName:r("form.fields.quantity.label"),min:1})}).default(1),unitValue:A.number().nullable().optional(),currency:A.string().nullable().optional()})).min(1,{message:r("pages.fulfillmentOrder.form.details.section.itemSelection.empty.errors.missingLineItems")}),isCoverageEnabled:A.boolean(),isOfflineDelivery:A.boolean(),valueAddedServices:A.object({isAddressTranslationNeeded:A.boolean().nullable().optional(),signatureHandling:A.object({type:A.nativeEnum(Ce)}).nullable().optional()}).nullable().optional(),remarks:A.preprocess(o=>o===""?void 0:o,A.string().max(255).nullable().default(null))});return s.isInternational?d:d.partial({purpose:!0,taxTerm:!0,iossNumberId:!0})},[i,s.isInternational,s.receiverCountry,r])},Ai=({fulfillmentOrder:s,fulfillmentOrderDetails:r,receiverCountry:i,isInternational:d,shouldValidateOnLoad:o,isLoading:a,onSubmit:l,onBackClick:u})=>{const{t:g}=B(),{userOrgConfigs:p}=Z(),{isIossEnabled:h,isLoading:b}=Tt(),[v,c]=n.useState(!1),C=Li({isInternational:d,receiverCountry:i}),I=n.useMemo(()=>i===qr.CN&&!((p==null?void 0:p.isCnExportEnabled)??!1),[i,p==null?void 0:p.isCnExportEnabled]),F={...r,lineItems:r==null?void 0:r.lineItems,purpose:(r==null?void 0:r.purpose)??void 0,taxTerm:(r==null?void 0:r.taxTerm)??void 0,iossNumberId:(r==null?void 0:r.iossNumberId)??void 0,isCoverageEnabled:(r==null?void 0:r.isCoverageEnabled)??!1,isOfflineDelivery:(I||(r==null?void 0:r.isOfflineDelivery))??!1,valueAddedServices:(r==null?void 0:r.valueAddedServices)??null},S=n.useRef(!o),y=Kt({resolver:Yt(C),defaultValues:F}),{control:T,setValue:t,formState:{isDirty:L},handleSubmit:w,watch:$,trigger:de}=y,he=$("carrierServiceId"),ue=$("orgCarrierAccountId"),fe=$("isCoverageEnabled"),P=$("lineItems"),ne=$("isOfflineDelivery"),G=Pr({orgWarehouseId:s.orgWarehouse.id,lineItems:P}),K=n.useCallback(E=>{t("lineItems",E)},[t]),z=n.useCallback(E=>{const H=P.concat(E);K(H),de("lineItems")},[K,P,de]),Q=n.useCallback(E=>{const H=P.map((ye,Ie)=>Ie===E.index?{...ye,inventoryItemReceivedEntryId:E.inventoryItemReceivedEntryId,qty:E.qty,unitValue:E.unitValue,currency:E.currency}:ye);K(H)},[K,P]),se=n.useCallback(E=>{const H=P.filter((ye,Ie)=>Ie!==E);K(H)},[K,P]),k=n.useCallback(E=>{t("isOfflineDelivery",M(E).with(Ee.BY_SPACESHIP,()=>!1).with(Ee.OFFLINE_DELIVERY,()=>!0).exhaustive()),E===Ee.OFFLINE_DELIVERY&&(t("purpose",void 0),t("taxTerm",void 0),t("iossNumberId",void 0),t("carrierServiceId",void 0),t("orgCarrierAccountId",void 0),t("isCoverageEnabled",!1))},[t]),ce=n.useCallback(E=>{t("carrierServiceId",E?E.id:null)},[t]),oe=n.useCallback(E=>{t("orgCarrierAccountId",E)},[t]),Pe=n.useCallback(E=>{t("isCoverageEnabled",E,{shouldDirty:!0})},[t]),Ae=n.useCallback(async E=>{await l({...E,iossNumberId:E.taxTerm===te.IOSS?E.iossNumberId:void 0})},[l]);return n.useEffect(()=>{!S.current&&!b&&(w(Me)(),S.current=!0)},[w,b]),n.useEffect(()=>{if(G){k(Ee.OFFLINE_DELIVERY);return}t("isOfflineDelivery",(I||(r==null?void 0:r.isOfflineDelivery))??!1)},[r==null?void 0:r.isOfflineDelivery,I,G,k,t]),f(q,{children:[e(Sr,{isEnabled:L}),e(_r,{isEnabled:v,handleLeave:()=>{c(!1),u()},handleStay:()=>{c(!1)}}),f(Xt,{onSubmit:w(Ae),children:[e(X,{title:g("pages.fulfillmentOrder.form.fields.orderReference.label"),sectioned:!0,children:e(me,{name:"orderRef",control:T,render:({field:E,fieldState:{error:H}})=>e(pt,{autoFocus:!0,...E,label:"",type:"text",autoComplete:"off",error:H==null?void 0:H.message,value:E.value??void 0})})}),e(Oe,{...y,children:e(pi,{isDisabled:!s.canUpdateLineItem,lineItems:P,orgWarehouse:s.orgWarehouse,onItemAdded:z,onItemEdited:Q,onRemove:se})}),e(ri,{formMethods:y,onHandleMethodChange:k,disabled:I,isSelfArrangeRequired:G}),!ne&&!G&&f(q,{children:[d&&e(Oe,{...y,children:e(Ti,{receiverCountry:i,isIossEnabled:h})}),e(Oe,{...y,children:e(Xr,{fulfillmentOrderId:s.id,carrierServiceId:he,orgCarrierAccountId:ue,isGlobalEOrder:s.isGlobalEOrder,isInternational:d,onSelectedCarrierService:ce,onSelectedOrgCarrierAccount:oe})}),e(Oe,{...y,children:e(gi,{fulfillmentOrder:s})}),e(zr,{mode:"edit",isCoverageEnabled:fe,setIsCoverageEnabled:Pe})]}),e(X,{title:g("pages.fulfillmentOrder.form.fields.remarks.label"),sectioned:!0,children:e(me,{name:"remarks",control:T,render:({field:E,fieldState:{error:H}})=>e(pt,{multiline:!0,showCharacterCount:!0,maxLength:255,label:"",helpText:g("pages.fulfillmentOrder.form.fields.remarks.helpText"),placeholder:g("pages.fulfillmentOrder.form.fields.remarks.placeholder"),type:"text",autoComplete:"off",error:H==null?void 0:H.message,...E,value:E.value??void 0})})}),e(br,{isLoading:a,nextButtonText:M($e(s,["status","subStatus"])).with({status:Y.unfulfilled,subStatus:ve.created},{status:Y.failed},()=>
2g("common.next")).with({status:Y.unfulfilled,subStatus:ve.submitted},()=>g("common.submit")).otherwise(()=>{}),onBackClick:()=>{c(L),L||u()},onNextClick:w(Ae)})]})]})},ki="data:image/svg+xml,%3csvg%20width='61'%20height='60'%20viewBox='0%200%2061%2060'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='60'%20height='60'%20transform='translate(0.5)'%20fill='white'%20style='mix-blend-mode:multiply'/%3e%3cpath%20d='M30.5%203.75C25.3083%203.75%2020.2331%205.28954%2015.9163%208.17392C11.5995%2011.0583%208.23497%2015.158%206.24817%2019.9546C4.26137%2024.7511%203.74154%2030.0291%204.7544%2035.1211C5.76726%2040.2131%208.26733%2044.8904%2011.9385%2048.5616C15.6096%2052.2327%2020.2869%2054.7327%2025.3789%2055.7456C30.4709%2056.7585%2035.7489%2056.2386%2040.5455%2054.2518C45.342%2052.265%2049.4417%2048.9005%2052.3261%2044.5837C55.2105%2040.2669%2056.75%2035.1918%2056.75%2030C56.75%2023.0381%2053.9844%2016.3613%2049.0616%2011.4384C44.1387%206.51562%2037.4619%203.75%2030.5%203.75ZM26.75%2040.4827L17.375%2031.1077L20.3574%2028.125L26.75%2034.5173L40.6438%2020.625L43.6357%2023.5986L26.75%2040.4827Z'%20fill='%23007F5F'/%3e%3c/svg%3e",Oi=({data:s})=>{const{userOrganization:r}=Z();ae(r);const[i]=Et(),d=n.useMemo(()=>i.get("previousList"),[i]),{data:o}=Jt(r.id,{query:{enabled:d===j.UNFULFILLED}}),{data:a}=er(r.id,{query:{enabled:d===j.ACTION_REQUIRED}}),{t:l}=B(),u=Rt(),g=n.useMemo(()=>M(d).with(j.UNFULFILLED,()=>le(o==null?void 0:o.id)?void 0:{content:l("pages.fulfillmentOrder.submitResult.success.button.nextCreatedOrder"),onAction:()=>u(re.editFulfillmentOrder({id:pe(o==null?void 0:o.id),review:!0,previousList:d??void 0}))}).with(j.ACTION_REQUIRED,()=>le(a==null?void 0:a.id)?void 0:{content:l("pages.fulfillmentOrder.submitResult.success.button.nextActionRequiredOrder"),onAction:()=>u(re.editFulfillmentOrder({id:pe(a==null?void 0:a.id),review:!0,previousList:d??void 0}))}).with(j.ALL,O.nullish,()=>{}).exhaustive(),[a==null?void 0:a.id,o==null?void 0:o.id,u,d,l]),p=n.useMemo(()=>M(d).with(j.UNFULFILLED,O.nullish,()=>({content:l("pages.fulfillmentOrder.submitResult.success.button.viewUnfulfilledOrders"),onAction:()=>u(re.fulfillmentOrders({tab:Ve.UNFULFILLED}))})).with(j.ACTION_REQUIRED,()=>({content:l("pages.fulfillmentOrder.submitResult.success.button.viewActionRequiredOrders"),onAction:()=>u(re.fulfillmentActionRequired())})).with(j.ALL,()=>({content:l("pages.fulfillmentOrder.submitResult.success.button.viewAllOrders"),onAction:()=>u(re.fulfillmentOrders({tab:Ve.ALL}))})).exhaustive(),[u,d,l]);return e(Fe,{sectioned:!0,children:e(X,{sectioned:!0,children:f(tr,{image:ki,action:g,secondaryAction:p,children:[e(N,{as:"p",variant:"headingLg",children:l("pages.fulfillmentOrder.submitResult.success.title")}),e(D,{heightSpace:"4"}),e(D,{heightSpace:"4"}),e(N,{as:"p",variant:"bodyMd",color:"subdued",children:l("pages.fulfillmentOrder.submitResult.ssid",{ssid:s.ssid})}),s.orderRef&&e(N,{as:"p",variant:"bodyMd",color:"subdued",children:l("pages.fulfillmentOrder.submitResult.orderRef",{orderRef:s.orderRef})})]})})})},Fi=U("div",{target:"emwh71n0"})("@media (min-width: ",vr.breakpoints["breakpoints-sm"],"){&.Polaris-Page-Header{padding:0 0 var(--p-space-5);}}"),ns=()=>{var Xe,Je,et,tt,rt,it,nt;const{t:s}=B(),r=Rt(),i=rr(),{formatDateTime:d}=ir(),{userOrganization:o}=Z(),{fulfillmentOrderId:a}=nr();ae(a);const[l,u]=n.useState(null),[g,p]=n.useState(!1),{value:h,setTrue:b,setFalse:v}=_e(!1),[c]=Et(),C=n.useMemo(()=>!!c.get("fromCreate"),[c]),I=n.useMemo(()=>!!c.get("review"),[c]),F=n.useMemo(()=>c.get("previousList"),[c]),[S,y]=n.useState(M({isFromCreate:C,isReview:I}).with({isFromCreate:O.any,isReview:!0},()=>_.REVIEW).with({isFromCreate:!0,isReview:!1},()=>_.ORDER_DETAILS).with({isFromCreate:!1,isReview:!1},()=>_.ADDRESS_INFORMATION).exhaustive()),T=n.useMemo(()=>ee[S]===W.REVIEW,[S]),{data:t,isLoading:L,refetch:w}=sr((o==null?void 0:o.id)??"",a),{isSupportsResubmitSubmittedFulfillmentOrder:$}=yt((Xe=t==null?void 0:t.orgWarehouse)==null?void 0:Xe.id),{data:de,refetch:he}=or((o==null?void 0:o.id)??"",a),{mutateAsync:ue,isLoading:fe}=ar({mutation:{onSuccess:()=>{w()}}}),P=lr({mutation:{onSuccess:()=>{w()},onError:m=>{var V;if(m instanceof ht){const x=(V=m.response)==null?void 0:V.data;u(x.code),window.scrollTo(0,0)}}}}),{mutateAsync:ne,isLoading:G}=cr({mutation:{onError:m=>{var V;if(m instanceof ht){const x=(V=m.response)==null?void 0:V.data;u(x.code),window.scrollTo(0,0)}w(),he()}}}),{mutateAsync:K,isLoading:z}=dr(),Q=m=>le(m)?null:m,se=n.useMemo(()=>t?{orgWarehouseId:t.orgWarehouse.id,receiver:{name:t.receiverAddress.name,company:t.receiverAddress.company,addressLine1:t.receiverAddress.addressLine1,addressLine2:t.receiverAddress.addressLine2,countryLocationDetail
2s:{city:t.receiverAddress.city,country:t.receiverAddress.country,state:t.receiverAddress.state,postalCode:t.receiverAddress.postalCode},phone:t.receiverAddress.phone,phoneCountryCode:t.receiverAddress.phoneCountryCode,email:t.receiverAddress.email,isResidential:t.receiverAddress.isResidential},receiverTaxId:t.receiverTaxId}:{},[t]),k=n.useMemo(()=>{var m,V;return t?{orderRef:t.orderRef??void 0,taxTerm:t.taxTerm,iossNumberId:t.iossNumberId??void 0,purpose:t.purpose,carrierServiceId:((m=t.carrierService)==null?void 0:m.id)??void 0,orgCarrierAccountId:((V=t.orgCarrierAccount)==null?void 0:V.id)??void 0,isCoverageEnabled:t.isCoverageEnabled??!1,lineItems:t.lineItems.map(x=>({product:{id:x.productId,type:x.productType,name:x.name,sku:x.sku,barcode:x.barcode,itemDescription:x.itemDescription},inventoryItemReceivedEntryId:x.inventoryItemReceivedEntryId??void 0,qty:x.qty,connectedStoreExternalLineItemId:x.connectedStoreExternalLineItemId??null,unitValue:x.unitValue,currency:x.currency})),isOfflineDelivery:t.isOfflineDelivery??!1,valueAddedServices:t.valueAddedServices??null,remarks:t.remarks}:{}},[t]),ce=n.useMemo(()=>{var m,V;return xr(t==null?void 0:t.orgWarehouse.country,(V=(m=se.receiver)==null?void 0:m.countryLocationDetails)==null?void 0:V.country)},[(et=(Je=se.receiver)==null?void 0:Je.countryLocationDetails)==null?void 0:et.country,t==null?void 0:t.orgWarehouse.country]),oe=n.useCallback(m=>{u(null),y(m)},[]),Pe=n.useCallback(()=>{switch(u(null),S){case _.REVIEW:y(_.ORDER_DETAILS);break;case _.ORDER_DETAILS:case _.ORDER_RESULT_SUCCESS:y(_.ADDRESS_INFORMATION);break;case _.ADDRESS_INFORMATION:default:r(-1)}},[S,r]),Ae=n.useCallback(()=>{u(null)},[]),E=n.useMemo(()=>M(ee[S]).with(O.union(W.ADDRESS_INFORMATION,W.ORDER_DETAILS),m=>e(yr,{currentStep:m})).otherwise(()=>null),[S]),H=n.useCallback(async()=>{ae(t),ae(o),M(t.status).with(Y.unfulfilled,Y.failed,async()=>{await ne({orgId:o.id,fulfillmentOrderId:a}),oe(_.ORDER_RESULT_SUCCESS)}).otherwise(()=>Me)},[t,a,oe,ne,o]),ye=n.useCallback(async m=>{await ue({orgId:pe(o).id,fulfillmentOrderId:a,data:{orgWarehouseId:m.orgWarehouseId,receiverAddress:{email:Q(m.receiver.email),company:Q(m.receiver.company),name:m.receiver.name,phoneCountryCode:m.receiver.phoneCountryCode,phone:m.receiver.phone,addressLine1:m.receiver.addressLine1,addressLine2:Q(m.receiver.addressLine2),city:m.receiver.countryLocationDetails.city,state:Q(m.receiver.countryLocationDetails.state),postalCode:Q(m.receiver.countryLocationDetails.postalCode),country:m.receiver.countryLocationDetails.country,isResidential:m.receiver.isResidential},receiverTaxId:Q(m.receiverTaxId)}}),y(_.ORDER_DETAILS)},[a,ue,o]),Ie=n.useCallback(async m=>{var V,x;ae(o),ae(t),p(!0),await P.mutateAsync({orgId:o.id,fulfillmentOrderId:a,data:{orderRef:Q(m.orderRef),remarks:m.remarks,isOfflineDelivery:m.isOfflineDelivery,iossNumberId:m.iossNumberId,taxTerm:m.taxTerm,purpose:m.purpose,carrierServiceId:m.carrierServiceId,orgCarrierAccountId:m.orgCarrierAccountId,isCoverageEnabled:m.isCoverageEnabled,finalShippingValueAddedServices:(V=m.valueAddedServices)!=null&&V.signatureHandling||(x=m.valueAddedServices)!=null&&x.isAddressTranslationNeeded?{signatureHandling:m.valueAddedServices.signatureHandling??void 0,isAddressTranslationNeeded:m.valueAddedServices.isAddressTranslationNeeded??void 0}:null,lineItems:m.lineItems.map(J=>({productId:J.product.id,inventoryItemReceivedEntryId:J.inventoryItemReceivedEntryId??void 0,qty:J.qty,connectedStoreExternalLineItemId:J.connectedStoreExternalLineItemId??null,unitValue:J.unitValue,currency:J.currency}))}}),await w(),M({status:t.status,subStatus:t.subStatus}).with({status:Y.unfulfilled,subStatus:ve.submitted},async()=>{await ne({orgId:o.id,fulfillmentOrderId:a}),oe(_.ORDER_RESULT_SUCCESS)}).otherwise(()=>{y(_.REVIEW)})},[o,t,P,a,w,ne,oe]),{canCancelOrder:He,canDirectCancelOrder:Lt,isOrderSubmitted:At}=Zr({orgWarehouseId:(tt=t==null?void 0:t.orgWarehouse)==null?void 0:tt.id,status:t==null?void 0:t.status,subStatus:t==null?void 0:t.subStatus,hasSubmitted:t==null?void 0:t.hasSubmitted}),kt=n.useCallback(async()=>{ae(o),ae(t),He&&(await K({orgId:o.id,fulfillmentOrderId:a}),w(),v())},[o,t,He,w,v,K,a]),je=n.useMemo(()=>
2s("pages.fulfillmentOrder.editOrder.title"),[s]),Ze=Nr({status:t==null?void 0:t.status,subStatus:t==null?void 0:t.subStatus}),Ge=n.useMemo(()=>M(ee[S]).with(W.REVIEW,()=>f(R,{spacing:"tight",alignment:"center",children:[e("div",{children:le(t==null?void 0:t.orderRef)?"--":s("pages.fulfillmentOrder.title.orderRef",{orderRef:t==null?void 0:t.orderRef})}),e(ur,{...Ze,children:s(`pages.fulfillmentOrder.status.${we(t==null?void 0:t.status)}.${we(t==null?void 0:t.subStatus)}.badge`)})]})).with(W.ORDER_RESULT_SUCCESS,()=>null).otherwise(()=>je),[Ze,S,t,s,je]),Ot=n.useMemo(()=>{var st,ot,at,lt;if(!t)return null;const m=s("pages.shipments.subtitle.ssid",{ssid:t.ssid}),V=s("pages.fulfillmentOrder.subtitle.createTime",{createTime:d(mr.fromISO(t.createdAt))}),x=(lt=(at=(ot=(st=t.connectedStoreMetadata)==null?void 0:st.shopify)==null?void 0:ot.shippingLines)==null?void 0:at[0])==null?void 0:lt.title,J=s("pages.shipments.subtitle.orderRef",{ref:le(t.orderRef)?"--":t.orderRef});return M(ee[S]).with(W.REVIEW,()=>pr([V,x,m]).join(" ⢠")).with(W.ORDER_RESULT_SUCCESS,()=>null).otherwise(()=>`${m} ⢠${J}`)},[S,d,t,s]),Ke=St(l),Ye=St(((rt=t==null?void 0:t.validationErrors[0])==null?void 0:rt.code)??null),qe=n.useMemo(()=>g&&!l?null:M({errorDetails:Ke,shipmentInfo:de,validationError:Ye}).with({errorDetails:O.union(O.nullish,{code:O.union("unknown")}),shipmentInfo:{buyLabelErrors:O.not(O.nullish)}},{errorDetails:O.union(O.nullish,{code:O.union("unknown")}),validationError:O.not(O.nullish)},({shipmentInfo:m,validationError:V})=>{const x=[...(m==null?void 0:m.buyLabelErrors)??[],...V?[V.errorDesc]:[]];return f(q,{children:[e(ft,{title:s("pages.fulfillmentOrder.banner.buyLabelError.title"),message:e(R,{vertical:!0,spacing:"extraTight",children:x.map(J=>e(N,{as:"p",variant:"bodyMd",children:J}))})}),e(D,{heightSpace:"4"})]})}).with({errorDetails:O.not(O.nullish)},m=>f(q,{children:[e(ft,{title:m.errorDetails.errorTitle,message:m.errorDetails.errorDesc}),e(D,{heightSpace:"4"})]})).otherwise(()=>null),[g,l,Ke,de,s,Ye]);return n.useEffect(()=>{t&&(document.title=s("pageTitles.order.edit",{ssid:t.ssid}))},[t,s]),n.useEffect(()=>{window.scrollTo(0,0)},[S]),n.useEffect(()=>{a&&y(M({isFromCreate:C,isReview:I}).with({isFromCreate:O.any,isReview:!0},()=>_.REVIEW).with({isFromCreate:!0,isReview:!1},()=>_.ORDER_DETAILS).with({isFromCreate:!1,isReview:!1},()=>_.ADDRESS_INFORMATION).exhaustive())},[a,C,I]),n.useEffect(()=>{const m=M($e(t,"status","subStatus")).with({status:Y.unfulfilled,subStatus:ve.created},{status:Y.failed},()=>!0).with({status:Y.unfulfilled,subStatus:ve.submitted},()=>$).otherwise(()=>!1);t&&(m||r(re.viewFulfillmentOrder({id:t.id})))},[t,r,$]),!t||L?e(hr,{}):f(gr,{narrowWidth:![W.REVIEW].includes(ee[S]),children:[ee[S]!==W.ORDER_RESULT_SUCCESS&&f(Fi,{className:"Polaris-Page-Header Polaris-Page-Header--isSingleRow Polaris-Page-Header--hasNavigation Polaris-Page-Header--longTitle",children:[T&&f(q,{children:[e(ie,{plain:!0,monochrome:!0,removeUnderline:!0,icon:e(fr,{}),url:M(F).with(j.ACTION_REQUIRED,()=>re.fulfillmentActionRequired()).with(j.ALL,()=>re.fulfillmentOrders({tab:Ve.ALL})).otherwise(()=>re.fulfillmentOrders({tab:Ve.UNFULFILLED})),children:s(M(F).with(j.ACTION_REQUIRED,()=>"pages.fulfillmentOrder.button.backToActionRequiredOrder").with(j.ALL,()=>"pages.fulfillmentOrder.button.backToAllOrders").otherwise(()=>"pages.fulfillmentOrder.button.backToUnfulfilledOrder"))}),e(D,{heightSpace:"1"})]}),f("div",{className:"Polaris-Page-Header__Row",children:[f("div",{className:"Polaris-Page-Header__TitleWrapper",children:[e("h1",{className:"Polaris-Header-Title Polaris-Header-Title__TitleWithSubtitle",children:Ge}),e("div",{className:"Polaris-Header-Title__SubTitle",children:Ot})]}),e("div",{className:"Polaris-Page-Header__RightAlign",children:He&&S===_.REVIEW&&e(ie,{monochrome:!0,removeUnderline:!0,loading:z,onClick:b,children:M($e(t,"status","subStatus")).with({status:Y.unfulfilled,subStatus:ve.submitted},{status:Y.failed},()=>s("common.cancel")).otherwise(()=>s("common.intercept"))})})]})]}),E&&(i?e(jr,{title:Ge??"",children:E}):f(q,{children:[f(Fe,{children:[e(Fe.Section,{children:E}),e(Fe.Section,{secondary:!0})]}),e(D,{heightSpace:"5"})]})),ee[S]===W.ADDRESS_INFORMATION&&f(q,{children:[qe,e(Ir,{data:se,isLoading:L||fe,shouldValidateOnLoad:!C,fulfillmentOrderId:a,onSubmit:ye,onAddressValidated:async()=>{await w()}})]}),ee[S]===W.ORDER_DETAILS&&f(q,{children:[qe,e(Ai,{fulfillmentOrder:t,fulfillmentOrderDetails:k,receiverCountry:((nt=(it=se.receiver)==null?void 0:it.countryLocationDetail
2s)==null?void 0:nt.country)??"",isLoading:P.isLoading||G,isInternational:ce,shouldValidateOnLoad:!C,onSubmit:Ie,onBackClick:Pe})]}),ee[S]===W.REVIEW&&f(q,{children:[qe,e(Qr,{mode:"edit",fulfillmentOrder:t,onEditClick:oe,onOrderSubmitClicked:H,isSubmitting:G||G,refetchFulfillmentOrder:w,refetchOrderShipmentInfo:he,onBudgetControlApproved:Ae})]}),ee[S]===W.ORDER_RESULT_SUCCESS&&e(Oi,{data:t,isSuccess:!0}),e(Gr,{open:h,onClose:v,onConfirm:kt,loading:z,isOrderSubmitted:At,canDirectCancelOrder:Lt,orderRef:t==null?void 0:t.orderRef})]})};export{ns as EditFulfillmentOrder,ns as default}; 3//# debugId=14086f8c-8845-58e9-988b-e9442a278233 4//# sourceMappingURL=index-D1-hS3iH.js.map
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.