1/*! For license information please see 4457.5b540e21.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunk_vndr_ship_client=self.webpackChunk_vndr_ship_client||[]).push([[4457],{86840(e,t,l){l.r(t),l.d(t,{default:()=>bi});var i=l(98477),s=l(39698),n=l(67252),d=l(71288),o=l(43928),a=l(80763),r=l.n(a),c=l(33156),u=l(57863),v=l(97939),h=l(58072),m=l(14618),p=l(69185),w=l(67973),x=l(31338),g=l(18743),j=l(88493);const f=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isBatch,l=e.batchId;const o=(0,u.useHistory)(),a=(0,c.A)(),f=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),y=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.reloadOrders}),b=(0,d.useSelector)(e=>{var t,l;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading)||(null===e||void 0===e||null===(l=e.orders)||void 0===l?void 0:l.isUpdatingShipments)}),A=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.orders)||void 0===t||null===(l=t.orders)||void 0===l?void 0:l.length}),S=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.refreshPage)||void 0===l?void 0:l.orders}),N=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.gridApi}),C=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderModalActive}),k=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderRef}),I=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderIndexRef}),D=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.allFilterOrdersSelected}),E=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.reloadData)||void 0===l?void 0:l.orders}),O=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.restoreGrid}),R=(0,w.BW)().restoreGridState,P=(0,w.yK)(),F=P.getSelectedOrders,_=P.setSelectedOrders,T=P.getSelectedOrderShipmentCounts,W=P.deselectAllOrders,L=P.selectAllOrders,M=(0,p.A)(!0),U=M.handleCancelBatch,B=M.handleUpdateBatch,V=M.handleDeleteFromBatch,z=M.handleDownloadBatchLabels,$=M.batchPageData,Z=M.setBatchPageData,H=M.batchLoading,q=(0,d.useDispatch)(),G=(0,n.useState)(!1),K=(0,s.A)(G,2),Y=K[0],Q=K[1],X=(0,n.useState)(!1),J=(0,s.A)(X,2),ee=J[0],te=J[1],le=(0,n.useState)(!1),ie=(0,s.A)(le,2),se=ie[0],ne=ie[1],de=(0,n.useState)(!1),oe=(0,s.A)(de,2),ae=oe[0],re=oe[1],ce=(0,n.useState)(!1),ue=(0,s.A)(ce,2),ve=ue[0],he=ue[1],me=(0,v.Ay)({history:o}),pe=o.location.search,we=(null===me||void 0===me?void 0:me.order_filters)||(null===me||void 0===me?void 0:me.search_filters)||(null===me||void 0===me?void 0:me.order_number)||(null===me||void 0===me?void 0:me.custom_filters);(0,n.useEffect)(()=>{E&&(0,d.vA)(()=>{q((0,h.dk)()),q((0,h.$4)())})},[E]),(0,n.useEffect)(()=>{q((0,h.CW)({allSelectInProgress:(null===f||void 0===f?void 0:f.allSelectInProgress)||!1}))},[]),(0,n.useEffect)(()=>{let e,s=!1;!(0,g.Hx)(f)||t||we||null!==me&&void 0!==me&&me.shipmentStatus&&"holding"!==(null===me||void 0===me?void 0:me.shipmentStatus)||(async()=>{try{q((0,h.CW)({lateShipments:[]}));const e=(await m.Dp.get("/shipments/late-shipments/list?tz=".concat((0,x.oA)()))).data;q((0,h.CW)({lateShipments:e||[]}))}catch(e){console.log(e)}})();return!(0,g.dG)(f)||t||we||null!==me&&void 0!==me&&me.shipmentStatus&&"holding"!==(null===me||void 0===me?void 0:me.shipmentStatus)||(async()=>{try{q((0,h.CW)({sameRecipientOrders:[]}));const e=(await m.Dp.get("/orders/same-recipient")).data;q((0,h.CW)({sameRecipientOrders:e||{}}))}catch(e){console.log(e)}})(),(async()=>{s||q((0,h.CW)({loading:!0,totalLoading:!0,showLateShipments:!1,showSameRecipientOrders:!1}));try{O&&R(null===N||void 0===N?void 0:N());const n=(t?await(async()=>await m.Km.get("/batch-orders/list/".concat(l).concat(pe)))():await(async()=>{var t,l;e=F(),(0,j.os)("selectedOrdersShipments",e);let i=pe;return i?!!we||null!==me&&void 0!==me&&me.shipmentStatus||(i+="&shipmentStatus=holding"):i="?shipmentStatus=holding",null===(t=i)||void 0===t||!t.includes("Date")||null!==(l=i)&&void 0!==l&&l.includes("tz")||(i+="&custom_filters[tz]=".concat((0,x.oA)())),m.Dp.get("/orders/total".concat(i)).then(e=>{var t;q((0,h.CW)({total:(null===e||void 0===e||null===(t=e.data)||void 0===t?void 0:t.total)||0,totalLoading:!1}))}).catch(e=>{console.log(e)}),q((0,h.CW)({shipmentCountsLoading:!0})),m.Dp.get("/orders/shipment-counts").then(e=>{var t;null!==e&&void 0!==e&&null!==(t=e.data)&&void 0!==t&&t.shipmentCountsByStatus&&q((0,h.CW)({shipmentCountsByStatus:e.data.shipmentCountsByStatus,shipmentCountsLoading:!1}))}).catch(e=>{q((0,h.CW)({shipmentCountsLoading:!1})),console.log(e)}),await m.Dp.get("/orders/list".concat(i))})()).data;if(!s){const l=(null===n||void 0===n?void 0:n.orders)||[];(0,d.vA)(()=>
2{if(t&&(Z((0,i.A)((0,i.A)({},n.batch),{},{orders:l})),q((0,h.CW)({total:(null===n||void 0===n?void 0:n.total)||0,loading:!1,totalLoading:!1}))),q((0,h.CW)({orders:l,loading:!1,processedOrders:{},restoreGrid:!1})),C&&!k){var s;const e=l[I||0],t=null!==e&&void 0!==e&&null!==(s=e.shipments)&&void 0!==s&&s.length?e.shipments[0]:null,i=null===t||void 0===t?void 0:t.id;let n=[];Object.keys(me).forEach(e=>{"custom_filters"===e?n.push(r().stringify({custom_filters:me[e]})):n.push("".concat(e,"=").concat(encodeURIComponent(me[e])))}),q((0,h.ui)()),q((0,h.SN)({orderId:e._id,onComplete:()=>{o.push("".concat(o.location.pathname,"?").concat(n.join("&"),"#").concat(e._id).concat(i?"-".concat(i):""))}}))}S&&q((0,h.zC)({key:"orders",val:!1})),N&&setTimeout(()=>{var t,l,i,s;const n=[],d=[],o={opts:70,Actions:180};if(null===(t=N())||void 0===t||null===(l=t.getColumns())||void 0===l||l.forEach(e=>{const t=e.getId();["opts","Actions"].includes(t)?d.push({colId:t,width:o[t],key:e,newWidth:o[t]}):n.push(t)}),null===(i=N())||void 0===i||i.autoSizeColumns(n),setTimeout(()=>{var e;null===(e=N())||void 0===e||e.setColumnWidths(d)},300),D)L(),q((0,h.CW)({allFilterOrdersSelected:!0}));else if(null!==(s=Object.keys(e||{}))&&void 0!==s&&s.length){(0,j.os)("selectedOrdersShipments",e),_(e);const t=T(),l=t.totalSelectedOrders,i=t.totalSelectedShipments;q((0,h.CW)({totalSelectedOrders:l,totalSelectedShipments:i}))}else W()},100)})}}catch(n){console.log("ERROR fetchPaginatedOrders"),console.log(n),console.error((null===n||void 0===n?void 0:n.response)||n),s||(0,d.vA)(()=>{q((0,h.CW)({loading:!1,isUpdatingShipments:!1,orders:[],total:0,allSelected:!1,lastSelectedOrderIndex:-1,allFilterOrdersSelected:!1,allFilterOrdersSearch:null})),q((0,h.ui)())})}})(),()=>{s=!0}},[y,pe,t]);const xe=!(null===f||void 0===f||!f.hasOrder);(0,n.useEffect)(()=>{let e=!1;if(!xe&&A>0){(async()=>{try{await m.FH.post("/user/v1/company/edit",{hasOrder:!0}),e||q((0,h.QO)({user:{hasOrder:!0}}))}catch(t){console.log('error updating "hasOrder"'),console.log((null===t||void 0===t?void 0:t.response)||t)}})()}return()=>{e=!0}},[xe,A,q]);return{theme:a,search:pe,loading:b,userData:f,hasOrder:xe,showRefresh:S,batchLoading:H,ordersLength:A,hasAnyFilter:we,batchPageData:$,allQueryParams:me,showPickupModal:ee,reloadOrdersAuto:y,showBulkEditModal:Y,reloadOrdersManual:E,allFilterOrdersSelected:D,openBatchModal:se,openManifest:ae,searchPanelExpanded:ve,dispatch:q,handleUpdateBatch:B,handleCancelBatch:U,setShowPickupModal:te,setShowBulkEditModal:Q,handleDeleteFromBatch:V,handleDownloadBatchLabels:z,handleClosePickupModal:e=>{e.reset;te(!1)},handleCloseBulkEditModal:e=>{e.reset;Q(!1)},setOpenBatchModal:ne,setOpenManifest:re,setSearchPanelExpanded:he,setBatchPageData:Z}};var y=l(79121),b=l(27401),A=l(84489),S=l(45851),N=l(83336),C=l(87911);const k=(0,C.A)("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);var I=l(25330);const D=(0,C.A)("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),E=(0,C.A)("AreaChart",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M7 12v5h12V8l-5 5-4-4Z",key:"zxz28u"}]]),O=(0,C.A)("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]),R=(0,C.A)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),P=(0,C.A)("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}
2]]),F=(0,C.A)("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);var _=l(39484),T=l(843),W=l(97146),L=l(2583),M=l(68870),U=l(81627),B=l(16536),V=l(14725),z=l(94292),$=l(46559),Z=l(26600),H=l(76483),q=l(98529),G=l(41762),K=l(6407),Y=l(28872);const Q=e=>{let t=e.active,l=e.handleClose;const o=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),a=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.easypostCarrierAccounts}),r=(0,n.useState)(!1),c=(0,s.A)(r,2),u=c[0],v=c[1],h=(0,n.useState)(!1),p=(0,s.A)(h,2),w=p[0],x=p[1],j=(0,n.useState)(0),f=(0,s.A)(j,2),y=f[0],b=f[1],N=(0,n.useState)(!1),C=(0,s.A)(N,2),k=C[0],I=C[1],D=(0,n.useState)(null),E=(0,s.A)(D,2),O=E[0],R=E[1],P=(0,n.useState)([]),F=(0,s.A)(P,2),_=F[0],T=F[1],Q=(0,n.useState)([]),X=(0,s.A)(Q,2),J=X[0],ee=X[1],te=(0,n.useState)(!1),le=(0,s.A)(te,2),ie=le[0],se=le[1],ne=(0,g.Io)({user:o}),de=ne.weightUnit,oe=ne.dimensionUnit,ae="UPS";let re={shipFrom:"",shipTo:"",shipToCountry:"US",addressType:V.A.RESIDENTIAL,boxI
2d:"",dimensions:{length:"",width:"",height:"",units:oe,weight:{units:de,value:""}}};const ce=(0,n.useRef)(),ue=e=>{if("UPS - ShipFare Service Rate"===e)return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsxs)("span",{className:"tw-text-primary",children:["ShipFare",(0,Y.jsx)("span",{className:"tw-text-secondary",children:"+"})]}),(0,q.ZZ)({style:{width:"auto",height:40}}).ups]});if("FedEx - ShipFare Service Rate"===e)return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsxs)("span",{className:"tw-text-primary",children:["ShipFare",(0,Y.jsx)("span",{className:"tw-text-secondary",children:"+"})]}),(0,q.ZZ)({style:{width:"auto",height:32}}).fedex]});if("USPS - ShipFare Service Rate"===e)return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsxs)("span",{className:"tw-text-primary",children:["ShipFare",(0,Y.jsx)("span",{className:"tw-text-secondary",children:"+"})]}),(0,q.ZZ)({style:{width:"auto",height:32,padding:4}}).usps]});if("Local Couriers - ShipFare Service Rate"===e)return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsxs)("span",{className:"tw-text-primary",children:["ShipFare",(0,Y.jsx)("span",{className:"tw-text-secondary",children:"+"})]}),(0,q.ZZ)({style:{width:"auto",height:26,padding:4}})["local couriers"]]});if("UPSSurePost - ShipFare Service Rate"===e)return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsxs)("span",{className:"tw-text-primary",children:["ShipFare",(0,Y.jsx)("span",{className:"tw-text-secondary",children:"+"})]}),(0,q.ZZ)({style:{width:"auto",height:40}}).upssurepost]});const t=a.find(t=>{var l;const i=t.readable.toLowerCase(),s=q.Vg[i],n=t.id,d=(null===t||void 0===t||null===(l=t.credentials)||void 0===l?void 0:l.account_number)||(null===t||void 0===t?void 0:t.account_number);return e==="".concat(s," - ").concat(n)||e==="".concat(s," - ").concat(d)});if(t){var l;const e=t.readable.toLowerCase();return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsx)("span",{children:t.description||(null===t||void 0===t||null===(l=t.credentials)||void 0===l?void 0:l.account_number)||(null===t||void 0===t?void 0:t.account_number)}),(0,q.ZZ)({style:{width:"auto",height:e===q.Ay.ups?40:32,padding:e===q.Ay.usps?4:void 0}})[e]]})}return null===e||void 0===e?void 0:e.split("-")[0].trim()},ve=(e,t)=>((null===e||void 0===e?void 0:e.filter(e=>e.carrier===t||"UPSSurePost"===e.carrier&&t===ae))||[]).sort((e,t)=>{var l,i;return(0,g.W)(e)===(0,g.W)(t)?parseFloat(null===e||void 0===e||null===(l=e.markedUpRates)||void 0===l?void 0:l.rate)>parseFloat(null===t||void 0===t||null===(i=t.markedUpRates)||void 0===i?void 0:i.rate)?1:-1:(0,g.W)(e)>(0,g.W)(t)?1:-1}).map(e=>{var t;let l=(0,g.M)(null===e||void 0===e?void 0:e.service);return g.AS.includes(null===e||void 0===e?void 0:e.service)&&(l=Z.Tt),(0,Y.jsxs)(A.Hj,{children:[(0,Y.jsx)(A.m_,{title:(0,g.UX)({service:null===e||void 0===e?void 0:e.service}),children:(0,Y.jsxs)(A.nA,{children:[l,g.AS.includes(null===e||void 0===e?void 0:e.service)?(0,Y.jsx)($.A,{information:z.A.SURE_POST}):null,l.toLowerCase().includes("ground")?(0,Y.jsx)($.A,{information:z.A.GROUND_TRANSIT_DAYS}):null]})}),(0,Y.jsx)(A.nA,{className:"tw-text-center",children:(0,q.c$)(null===e||void 0===e?void 0:e.carrier)?"".concat(null===e||void 0===e?void 0:e.deliveryTimeInHrs," Hr"):(0,g.W)(e)}),(0,Y.jsx)(A.nA,{className:"tw-text-center",children:"$".concat(null===e||void 0===e||null===(t=e.markedUpRates)||void 0===t?void 0:t.rate)})]},e.id)}),he=(0,Y.jsx)(A.l1,{validationSchema:B.Tf,initialValues:(0,i.A)({},re),innerRef:ce,onSubmit:async e=>{v(!0),x(!0),I(!1),T([]),ee([]);try{let l=null,s=null,n=null;if(!e.hasOwnProperty("shipFrom")||""===(null===e||void 0===e?void 0:e.shipFrom))return v(!1),I(!0),void R("Ship From Zip Code is required");{var t;const i=null===o||void 0===o||null===(t=o.warehouses)||void 0===t?void 0:t.find(t=>(null===t||void 0===t?void 0:t.formattedAddress)===e.shipFrom);if(i)l=i.address.state,s=i.address.zipCode,n=i.address.city;else{const t=await(0,K.$)(e.shipFrom);if(null===t||void 0===t||!t.State)return v(!1),I(!0),void R("Invalid Ship From Zip code");l=t.State,s=e.shipFrom,n=t.City}}let d=null,a=null,r=null;if(e.hasOwnProperty("shipTo")&&""!==(null===e||void 0===e?void 0:e.shipTo)){const t=await(0,K.$)(e.shipTo);null!==t&&void 0!==t&&t.State&&(d=t.State,a=e.shipTo,r=t.City)}const c=(0,i.A)((0,i.A)({},e),{},{shipFromState:l,shipFromZip:s,shipFromCity:n,shipToState:d,shipToZip:a,shipToCity:r,residential:e.addressType===V.A.RESIDENTIAL,dimensions:(0,i.A)((0,i.A)({},e.dimensions),{},{length:parseFloat(e.dimensions.length||0),width:parseFloat(e.dimensions.width||0),height:parseFloat(e.dimensions.height||0),weight:(0,i.A)((0,i.A)({},e.dimensions.weight),{},{value:parseFloat(e.dimensions.weight.value||0)})})}),u=(await m.Km.post("/shipments/shipment/rates",{shipmentData:c})).data,h=u.carriers.reduce((e,t)=>
2{if("UPSSurePost"===t){if(!e.includes(ae))return[...e,ae]}else if(!e.includes(t))return[...e,t];return e},[]),p=u.rates.map(e=>{const t=e.carrier;let l=(0,i.A)({},e);if("UPSSurePost"===e.carrier){const e=(0,g.eQ)(u.rates);return!(0,g.D)(l)&&(0,g.D)(e)&&(l.shipBy=(0,g.D)(e)+1),l}return u.isInternationalOrder&&(l.service="Worldwide".concat(l.service)),(0,i.A)((0,i.A)({},l),{},{carrier:t})});T(h),ee(p),v(!1),x(!1),b(y+1)}catch(s){var l;I(!0),R(null===s||void 0===s||null===(l=s.response)||void 0===l?void 0:l.data),v(!1),x(!1)}},children:e=>{var t,l,i,s,n,d;let a=e.values,r=e.setFieldValue,c=e.errors;return(0,Y.jsx)(A.lV,{className:"tw-flex tw-flex-col tw-gap-4",children:(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 md:tw-col-span-6",children:(0,Y.jsx)(A.B0,{name:"shipFrom",component:U.A,creatable:!0,isRequired:!0,placeholder:"Ship From Zip",label:"Ship From Zip",autoComplete:"off",options:null===o||void 0===o||null===(t=o.warehouses)||void 0===t?void 0:t.map(e=>({label:e.formattedAddress,value:e.formattedAddress,zip:e.address.zipCode})),valueFormatter:e=>e.zip})}),(0,Y.jsx)("div",{className:"tw-col-span-12 md:tw-col-span-6",children:(0,Y.jsx)(A.B0,{name:"shipTo",label:"Ship To Zip",isRequired:!0,component:M.A,placeholder:"Ship To Zip",autoComplete:"off"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 md:tw-col-span-6",children:(0,Y.jsx)(A.B0,{name:"shipToCountry",isRequired:!0,label:(0,Y.jsx)("span",{className:"tw-truncate",children:"Ship To Country"}),component:U.A,options:H.A.map(e=>({label:e.name,value:e.code}))})}),(0,Y.jsx)("div",{className:"tw-col-span-12 md:tw-col-span-6",children:(0,Y.jsx)(A.B0,{name:"addressType",isRequired:!0,label:"Address Type",component:U.A,options:Object.values(V.A).map(e=>({label:e,value:e}))})}),null!==o&&void 0!==o&&null!==(l=o.boxes)&&void 0!==l&&l.length?(0,Y.jsx)("div",{className:"tw-col-span-12 md:tw-col-span-6",children:(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col tw-w-full",children:[(0,Y.jsx)(W.l6,{name:"Select Box",label:"Select Box",value:a.boxId,options:o.boxes.map(e=>({label:e.name,value:e.id})),className:"tw-mb-2",placeholder:"Select Box..",onChange:e=>{const t=o.boxes.find(t=>t.id===e.value);t&&(r("boxId",t.id),r("dimensions.length",t.dimensions.length),r("dimensions.width",t.dimensions.width),r("dimensions.height",t.dimensions.height),r("dimensions.units",t.dimensions.units))}}),(0,Y.jsx)("div",{className:"tw-text-center tw-font-bold tw-py-1",children:"Or"}),(0,Y.jsx)(G.A,{label:"Dimensions",required:!0,lengthName:"dimensions.length",widthName:"dimensions.width",heightName:"dimensions.height",unitsName:"dimensions.units",setFieldValue:r})]})}):(0,Y.jsx)("div",{className:"tw-col-span-12 md:tw-col-span-6",children:(0,Y.jsx)(G.A,{label:"Dimensions",required:!0,lengthName:"dimensions.length",widthName:"dimensions.width",heightName:"dimensions.height",unitsName:"dimensions.units",setFieldValue:r})}),(0,Y.jsx)("div",{className:"tw-col-span-12 md:tw-col-span-6",children:(0,Y.jsx)(A.$k,{fullWidth:!0,error:ie&&(null!==c&&void 0!==c&&null!==(i=c.dimensions)&&void 0!==i&&null!==(s=i.weight)&&void 0!==s&&s.value||null!==c&&void 0!==c&&null!==(n=c.dimensions)&&void 0!==n&&null!==(d=n.weight)&&void 0!==d&&d.units)?"Weight is required":null,label:"Weight",required:!0,inputProps:{name:"dimensions.weight.value",onCh
2ange:e=>{let t=parseFloat(e||"");t<0&&(t=0),r("dimensions.weight.value",t),ie||se(!0)},onBlur:()=>{var e;r("dimensions.weight.value",null!==(e=parseFloat(a.dimensions.weight.value))&&void 0!==e?e:""),ie||se(!0)},type:"number",value:null===a||void 0===a?void 0:a.dimensions.weight.value,label:"Weight"},selectProps:{options:Object.values(L.Ay).map(e=>({label:L.Ob[e],value:e})),onChange:e=>{r("dimensions.weight.units",e)},value:null===a||void 0===a?void 0:a.dimensions.weight.units,name:"dimensions.weight.units"}})})]})})}});return(0,Y.jsxs)(A.aF,{open:t,title:"Rates Calculator",maxWidth:"sm",handleClose:w?()=>{}:()=>{var e;null===(e=ce.current)||void 0===e||e.resetForm(),T([]),ee([]),I(!1),l(),se(!1)},actions:[{isPrimary:!0,onClick:()=>{ie||se(!0),ce.current&&ce.current.handleSubmit()},disabled:u,className:"tw-mx-auto",loading:u,label:"Check Rates"}],children:[he,w?(0,Y.jsxs)("div",{className:"tw-mt-4 tw-flex tw-flex-col tw-items-center tw-justify-center tw-min-h-[200px]",children:[(0,Y.jsx)(A.P,{size:"2em",color:"primary"}),(0,Y.jsx)(A.o5,{className:"tw-mt-4",children:"Checking Rates..."})]}):(null===_||void 0===_?void 0:_.length)>0&&(null===_||void 0===_?void 0:_.map(e=>(0,Y.jsxs)("div",{className:"flex flex-direction-column",style:{marginTop:"20px"},children:[ue(e),(0,Y.jsxs)(A.QT,{size:"small","aria-label":"Rates Dimensions Table",className:"tw-w-full",sx:{minWidth:100},children:[(0,Y.jsx)(A.A0,{children:(0,Y.jsxs)(A.Hj,{children:[(0,Y.jsx)(A.nd,{style:{height:"unset",padding:"0.25rem 1rem"},children:"Service"}),(0,Y.jsx)(A.nd,{className:"tw-text-center",style:{height:"unset",padding:"0.25rem 1rem"},children:"Transit Time"}),(0,Y.jsx)(A.nd,{className:"tw-text-center",style:{height:"unset",padding:"0.25rem 1rem"},children:"Rate"})]})}),(0,Y.jsx)(A.BF,{children:ve(J,e)})]})]},e))),(null===_||void 0===_?void 0:_.length)>0?(0,Y.jsxs)(A.o5,{style:{color:"gray",marginTop:15},children:[(0,Y.jsx)("b",{children:(0,Y.jsx)("i",{children:"CONFIDENTIAL: "})}),"The quotes provided above are intended only for"," ",(null===o||void 0===o?void 0:o.companyName)||(null===o||void 0===o?void 0:o.name),". If you are not the intended recipient of these quotes, be aware that any use, review, retransmission, distribution, reproduction or any action taken in reliance upon these quotes is strictly prohibited."]}):null,k?(0,Y.jsxs)("div",{className:"tw-px-2 tw-border tw-border-solid tw-border-red-600 tw-py-2 tw-text-red-600 tw-rounded-lg tw-mt-4 tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsx)(S.N5l,{className:"tw-mr-2"}),O]}):null]})};var X=l(99900),J=l(3860),ee=l(63096);const te=e=>{let t=e.loading,l=e.menuButton,i=void 0!==l&&l;const s=(0,u.useHistory)(),n=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.totalBatches});return(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(A.$n,{variant:i?"text":void 0,disabled:t,className:i?"!tw-px-2 !tw-py-1.5 tw-gap-2 !tw-h-auto tw-w-full !tw-text-start !tw-justify-start":"tw-flex tw-items-center tw-gap-1",onClick:()=>s.push("/batch"),children:[(0,Y.jsx)(S.sk7,{}),"Batches ",n?"(".concat(n,")"):""]})})};var le=l(21942),ie=l(76276);const se=(0,n.forwardRef)((e,t)=>{let l=e.trackingIds,o=void 0===l?"":l,a=e.isLoading,r=void 0!==a&&a,c=e.hideTrigger,u=void 0!==c&&c;const v=(0,n.useMemo)(()=>[{label:"Reattempt Delivery",value:"reattempt_delivery"},{label:"Change Delivery Address",value:"delivery_address"},{label:"Upgrade to Saturday Delivery",value:"saturday_delivery"}],[]),p=(0,n.useMemo)(()=>({requestType:v[0],orderTrackingIds:"",details:""}),[v]),w=(0,d.useDispatch)(),j=(0,ie.A)(),f=j.toastError,y=j.toastSuccess,b=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),N=(0,d.useSelector)(e=>{var t,l;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading)||(null===e||void 0===e||null===(l=e.orders)||void 0===l?void 0:l.isUpdatingShipments)})||r,C=(0,n.useState)(!1),k=(0,s.A)(C,2),I=k[0],D=k[1],E=(0,n.useState)(p),O=(0,s.A)(E,2),R=O[0],P=O[1],F=(0,n.useState)(!1),_=(0,s.A)(F,2),T=_[0],L=_[1],M=(0,n.use
2State)("request"),U=(0,s.A)(M,2),B=U[0],V=U[1],z=(0,n.useState)({}),$=(0,s.A)(z,2),Z=$[0],H=$[1];(0,n.useEffect)(()=>{var e;!I||null!==R&&void 0!==R&&null!==(e=R.orderTrackingIds)&&void 0!==e&&e.length||null===o||void 0===o||!o.length||P((0,i.A)((0,i.A)({},R),{},{orderTrackingIds:o}))},[I,o]);const q=(0,n.useCallback)(()=>D(!0),[]);(0,n.useImperativeHandle)(t,()=>({open:q}),[q]);const G=(0,n.useCallback)(()=>{D(!1),P(p),L(!1),V("request"),H({})},[p]),K=(0,n.useCallback)(async()=>{L(!0);try{const e=(await m.Dp.post("/orders/service-request?tz=".concat((0,x.oA)()),(0,i.A)((0,i.A)({},R),{},{verify:!0}))).data;(0,d.vA)(()=>{var t;null!==e&&void 0!==e&&e.message&&y(e.message),(0,g.Hx)(b)&&null!==e&&void 0!==e&&null!==(t=e.lateShipments)&&void 0!==t&&t.length&&w((0,h.CW)({lateShipments:e.lateShipments})),null===e||void 0===e||!e.hasShipFareCodes||null!==e&&void 0!==e&&e.hasNonShipFareCodes?null!==e&&void 0!==e&&e.hasNonShipFareCodes&&(H(e.nonShipFareCodeMap),V("email")):V("confirmation")})}catch(t){var e;f((null===t||void 0===t||null===(e=t.response)||void 0===e?void 0:e.data)||"Error submitting service request!")}L(!1)},[w,R]),Q=(0,n.useCallback)(async e=>{L(!0);try{const t=(await m.Dp.post("/orders/service-request?tz=".concat((0,x.oA)()),(0,i.A)((0,i.A)({},R),{},{orderTrackingIds:e.trackingCodes.join(","),forceNonShipFareEmail:!0,emailTo:e.email,firstEight:e.firstEight}))).data;null!==t&&void 0!==t&&t.message&&y(t.message),H((0,i.A)((0,i.A)({},Z),{},{[e.firstEight]:(0,i.A)((0,i.A)({},e),{},{emailSent:!0})}))}catch(l){var t;f((null===l||void 0===l||null===(t=l.response)||void 0===t?void 0:t.data)||"Error submitting service request!")}L(!1)},[w,R,f,y]),X=(0,n.useMemo)(()=>!(!N&&!T)||(!R.requestType.value||!R.orderTrackingIds.length),[T,N,R.orderTrackingIds.length,R.requestType.value]),J=5===(0,x.Ay)().tz("America/Los_Angeles").day()&&(0,x.Ay)().tz("America/Los_Angeles").hour()>=14,ee=(0,n.useMemo)(()=>"saturday_delivery"===R.requestType.value&&!!J,[R.requestType.value,J]),te={request:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{children:(0,Y.jsx)(W.l6,{options:v,placeholder:"Request Type",label:"Request Type",value:R.requestType,onChange:e=>{P((0,i.A)((0,i.A)({},R),{},{requestType:e}))}})}),"saturday_delivery"===R.requestType.value&&ee?(0,Y.jsx)("div",{className:"tw-mt-4 tw-font-bold tw-text-secondary",children:"Saturday Upgrades must be made by Friday 12pm PST."}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{style:{marginTop:10},children:(0,Y.jsx)(A.A_,{variant:"outlined",label:"Tracking IDs",placeholder:"Enter multiple Tracking IDs separated by commas whenever possible.",size:"small",style:{width:"100%",margin:0},value:R.orderTrackingIds,onChange:e=>{P((0,i.A)((0,i.A)({},R),{},{orderTrackingIds:e.target.value}))},multiline:!0,minRows:2})}),(0,Y.jsx)("div",{style:{marginTop:10},children:(0,Y.jsx)(A.A_,{variant:"outlined",label:"Comment",size:"small",style:{width:"100%",margin:0},value:R.details,onChange:e=>{P((0,i.A)((0,i.A)({},R),{},{details:e.target.value}))},multiline:!0,minRows:3})})]})]}),email:Object.keys(Z).length?(0,Y.jsx)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:Object.values(Z).map((e,t)=>{var l;return null!==e&&void 0!==e&&e.firstEight&&null!==e&&void 0!==e&&null!==(l=e.trackingCodes)&&void 0!==l&&l.length?(0,Y.jsxs)("div",{children:[(0,Y.jsx)(A.A_,{variant:"outlined",label:(0,Y.jsxs)("div",{children:[(0,Y.jsx)("b",{children:e.firstEight})," Rep Email"]}),size:"small",value:e.email,onChange:t=>{H((0,i.A)((0,i.A)({},Z),{},{[e.firstEight]:(0,i.A)((0,i.A)({},Z[e.firstEight]),{},{email:t.target.value})}))},disabled:e.emailSent,required:!0}),(0,Y.jsx)("div",{className:"tw-mt-2 tw-flex tw-justify-end",children:(0,Y.jsxs)(A.$n,{disabled:N||T||e.emailSent||!e.email,onClick:()=>Q(e),color:"secondary",variant:"contained",children:["Send (",e.trackingCodes.length,")"]})})]},t):null})}):null,confirmation:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-center tw-flex-col",children:[(0,Y.jsx)(S.xhr,{className:"tw-mx-auto tw-size-20 tw-fill-green-500"}),(0,Y.jsx)("div",{className:"tw-text-2xl tw-text-green-500 tw-font-bold",children:"Service Request Sent!"})]})};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A.aF,{title:"Shipment Service Request",open:I,handleClose:G,maxWidth:"xs",customWidth:"32rem",actionOverrideClasses:"email"===B&&"!tw-justify-start",actions:[{isClose:!0,label:"Back",show:"email"===B},{label:"Next",onClick:K,disabled:X,show:"request"===B}],children:te[B]}
2),u?null:(0,Y.jsx)("div",{children:(0,Y.jsx)(A.$n,{disabled:N||T,onClick:q,color:"secondary",variant:"contained",children:"Service Request"})})]})});var ne=l(35052);const de=e=>{var t,l,i;let d=e.isImporting,o=e.importProgress,a=e.user;const r=(0,n.useState)(d),c=(0,s.A)(r,2),u=c[0],v=c[1],h=Math.round((null===o||void 0===o?void 0:o.imported)/(null===o||void 0===o?void 0:o.total)*100)||0;(0,n.useEffect)(()=>{v(d)},[d]);if(null===o||void 0===o||!o.shopDomain||null===a||void 0===a||!a.syncOptions)return;const m=a.syncOptions[null===o||void 0===o?void 0:o.shopDomain],p=null===a||void 0===a||null===(t=a.shopDomains)||void 0===t?void 0:t.find(e=>(null===e||void 0===e?void 0:e.shop)===(null===o||void 0===o?void 0:o.shopDomain)),w=m&&"order"===(null===o||void 0===o?void 0:o.entity);return p?(0,Y.jsx)(A.aF,{open:u,title:"Importing Shipments",handleClose:()=>{v(!1)},hideActions:!0,children:(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col tw-mb-4",children:[w&&(0,Y.jsxs)("div",{children:["Importing orders from your store based on"," ",(0,Y.jsx)(ne.N_,{to:"/preset/stores",children:"Sync"})," configurations",(0,Y.jsxs)("ul",{children:[(0,Y.jsxs)("li",{children:["Created or updated in last"," ",(0,Y.jsxs)("strong",{children:[null!==(l=m.days)&&void 0!==l?l:(0,J.pb)(p)," days"]}),"."]}),(0,Y.jsxs)("li",{children:["Status:"," ",(null!==(i=m.statuses)&&void 0!==i?i:(0,J.jm)(p)).map(e=>e.label).join(", ")]})]})]}),(0,Y.jsxs)("div",{className:"tw-flex tw-gap-2 tw-justify-center tw-items-center",children:[(0,Y.jsx)(A.hZ,{variant:"determinate",value:h,className:"tw-w-full tw-bg-gray-200 tw-rounded-full tw-h-2.5"}),h,"%"]}),(null===o||void 0===o?void 0:o.total)>=0?(0,Y.jsxs)(Y.Fragment,{children:[null===o||void 0===o?void 0:o.imported," out of ",null===o||void 0===o?void 0:o.total]}):(0,Y.jsx)(A.P,{size:18})]})}):void 0};var oe=l(88116),ae=l(87831),re=l(66249),ce=l(3931),ue=l(94595);const ve=e=>{let t=e.active,l=e.handleClose,o=e.setError,a=e.isImporting,r=e.setIsManualImport;const c=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),u=(0,d.useDispatch)(),v=(0,n.useState)(!1),p=(0,s.A)(v,2),w=p[0],x=p[1],g=(0,n.useState)(!1),j=(0,s.A)(g,2),f=j[0],y=j[1],b=(0,n.useState)(null),N=(0,s.A)(b,2),C=N[0],k=N[1],I=(0,J.iz)({user:c,allowGrazeCart:!0}),D=(0,n.useState)(!I),E=(0,s.A)(D,2),O=E[0],R=E[1],P=(0,J.ZL)(c,"orders"),F=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{y(!0);const l=new FormData;e&&l.append("orderCSV",e,null===e||void 0===e?void 0:e.name),t&&l.append("options",JSON.stringify(t)),await m.Km.post("/orders/importCsv",l)}catch(x){var s,n;const e=null===x||void 0===x||null===(s=x.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.validationErrors;var d,o,a,r,c,v,p,w;if(null!==e&&void 0!==e&&e.length)k(e);else u((0,h.Gg)((0,i.A)((0,i.A)({},ee.Ay[null!==x&&void 0!==x&&null!==(d=x.response)&&void 0!==d&&null!==(o=d.data)&&void 0!==o&&o.status?null===x||void 0===x||null===(a=x.response)||void 0===a||null===(r=a.data)||void 0===r||null===(c=r.status)||void 0===c?void 0:c.toUpperCase():"ERROR"]),{},{notice:(null===x||void 0===x||null===(v=x.response)||void 0===v||null===(p=v.data)||void 0===p?void 0:p.message)||(null===x||void 0===x||null===(w=x.response)||void 0===w?void 0:w.data)||(null===x||void 0===x?void 0:x.message)||"Error Importing Orders"})))}finally{y(!1),l()}};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(A.aF,{open:t,hideActions:!0,title:O?"Sync From Store":"Upload CSV",handleClose:w?()=>{}:l,children:[!I&&(0,Y.jsxs)("div",{className:"tw-pb-4 tw-flex tw-flex-col sm:tw-flex-row tw-items-center tw-justify-center tw-gap-3",children:[(0,Y.jsxs)(A.$n,{onClick:()=>R(!0),variant:O?"contained":"outlined",color:O?"secondary":"inherit",children:[(0,Y.jsx)(S.an9,{className:"tw-mr-1"}),"Sync from Store"]}),(0,Y.jsxs)(A.$n,{onClick:()=>R(!1),variant:O?"outlined":"contained",color:O?"inherit":"secondary",children:[(0,Y.jsx)(S.lYe,{className:"tw-mr-1"}),"Upload CSV"]})]}),O?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(ue.A,{handleSubmit:e=>{r(!0),(async e=>{try{o(!1),x(!0),u((0,h.N6)({}));let t=e.shop;
2e.platformType===J.hb.shopify&&(t=(0,ce.w$)(e.shop),t="https://".concat(t,".myshopify.com")),await m.Km.post("/orders/import",{shopDomain:t,platformType:e.platformType})}catch(p){var t,s,n,d,a,r,c,v;let e=(null===p||void 0===p||null===(t=p.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.message)||(null===p||void 0===p||null===(n=p.response)||void 0===n?void 0:n.data)||(null===p||void 0===p?void 0:p.message)||"Error Importing Orders";"NO_BOX_FOUND_ERR"===e?e=(0,Y.jsxs)("span",{children:["Create a"," ",(0,Y.jsx)("a",{href:"".concat(Z.GG,"/preset/boxes"),children:(0,Y.jsx)("b",{children:"Box"})})," ","Before Syncing."]}):"NO_WAREHOUSE_FOUND_ERR"===e&&(e=(0,Y.jsxs)("span",{children:["Create a"," ",(0,Y.jsx)("a",{href:"".concat(Z.GG,"/preset/warehouses"),children:(0,Y.jsx)("b",{children:"Warehouse"})})," ","Before Syncing."]})),o(!0),u((0,h.Gg)((0,i.A)((0,i.A)({},ee.Ay[null!==p&&void 0!==p&&null!==(d=p.response)&&void 0!==d&&null!==(a=d.data)&&void 0!==a&&a.status?null===p||void 0===p||null===(r=p.response)||void 0===r||null===(c=r.data)||void 0===c||null===(v=c.status)||void 0===v?void 0:v.toUpperCase():"ERROR"]),{},{notice:e})))}finally{x(!1),l()}})(e)},from:"orders",hideOptionsIfOneShop:!0,initialSelectedShop:1===(null===P||void 0===P?void 0:P.length)?P[0]:null,noModalSubmitDisabled:(0,J.kU)({user:c,isImporting:f||a,allowGrazeCart:!0}),noModal:!0})}):(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(ae.A,{noModal:!0,handleSubmit:F,type:"orders"})})]}),(0,Y.jsx)(re.A,{open:!!C,onClose:()=>k(null),validationErrors:C})]})};var he=l(94256);const me=e=>{let t=e.open,l=e.handleClose,i=e.fetchTableViewPresets;const d=(0,ie.A)(),o=d.toastError,a=d.toastSuccess,r=(0,n.useState)(!1),c=(0,s.A)(r,2),u=c[0],v=c[1],h=(0,n.use
2State)(!1),p=(0,s.A)(h,2),w=p[0],x=p[1],g=(0,n.useState)(""),j=(0,s.A)(g,2),f=j[0],y=j[1],b=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];y(""),v(null),l(e)};return(0,Y.jsx)(A.aF,{title:"Add New Preset View",open:t,handleClose:()=>b(),actions:[{label:"Create",onClick:async()=>{const e=localStorage.getItem("tableView");if(f)if(e)try{x(!0),await m.Km.post("/table-view-preset/new",{name:f,tableView:JSON.parse(e)}),a("Successfully Created New View Preset"),i(),b(!0)}catch(l){var t;console.log("error",l),o((null===l||void 0===l||null===(t=l.response)||void 0===t?void 0:t.data)||(null===l||void 0===l?void 0:l.message)||"Something Went Wrong")}finally{x(!1)}else v("View is required");else v("Name is required")},disabled:w||!f}],maxWidth:"xs",titleClass:"!tw-items-start",PaperProps:{className:"tw-min-w-[520px]"},children:(0,Y.jsxs)("div",{className:"flex flex-direction-column tw-gap-2",children:[(0,Y.jsx)("div",{className:"tw-mb-2",children:"Save your exact column configuration in the Shipments table for the rest of your team to use. Naming it below will create the Preset in the arrangement you have now."}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)(A.A_,{label:"Name",required:!0,value:f,onChange:e=>y(e.currentTarget.value),variant:"outlined"}),u?(0,Y.jsx)(A.o5,{className:"tw-text-red-500 tw-text-sm",children:u}):null]})]})})};var pe=l(2446);const we="".concat(Z.nv,"/Assets/SHIPPING_Illustrations_v01.svg"),xe=e=>{let t=e.isBatch,l=(e.onOpenBatchModal,e.setOpenManifest),a=e.totalSelectedOrders,r=e.handleExclude,c=(e.handleCancelOpenBatch,e.onSchedulePickup);const x=(0,u.useParams)().id,j=(0,d.useDispatch)(),f=(0,ie.A)(),y=f.notifyWarning,b=f.toastError,C=f.toastSuccess,W=(0,u.useHistory)(),L=(0,n.useRef)(),M=(0,n.useRef)(null),U=(0,n.useRef)(null),B=(0,n.useState)(!1),V=(0,s.A)(B,2),z=V[0],$=V[1],H=(0,n.use
2State)(!0),G=(0,s.A)(H,2),K=G[0],ne=G[1],ae=(0,n.useState)([]),re=(0,s.A)(ae,2),ce=re[0],ue=re[1],xe=(0,n.useState)(null),ge=(0,s.A)(xe,2),je=ge[0],fe=ge[1],ye=(0,n.useState)(!1),be=(0,s.A)(ye,2),Ae=be[0],Se=be[1],Ne=(0,n.useState)(!1),Ce=(0,s.A)(Ne,2),ke=Ce[0],Ie=Ce[1],De=(0,p.A)().handleDownloadBatchLabels,Ee=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),Oe=(0,d.useSelector)(e=>{var t,l,i;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.progressReport)||void 0===l||null===(i=l.csvProgress)||void 0===i?void 0:i.find(e=>"orderImport"===e.entity)}),Re="processing"===(null===Oe||void 0===Oe?void 0:Oe.status),Pe=(0,d.useSelector)(e=>{var t,l,i;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.progressReport)||void 0===l||null===(i=l.importProgress)||void 0===i?void 0:i.find(e=>"order"===e.entity)}),Fe="processing"===(null===Pe||void 0===Pe?void 0:Pe.status)||z,_e=(0,d.useSelector)(e=>{var t,l;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading)||(null===e||void 0===e||null===(l=e.orders)||void 0===l?void 0:l.isUpdatingShipments)}),Te=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.orders}),We=(0,d.useSelector)(e=>{var t,l,i;return(null===e||void 0===e||null===(t=e.orders)||void 0===t||null===(l=t.lateShipments)||void 0===l||null===(i=l.filter(e=>{var t;return!(null===e||void 0===e||null===(t=e.lateShipmentStatuses)||void 0===t?void 0:t.find(e=>"Notified Customer"===e.name))}))||void 0===i?void 0:i.length)||0})||0,Le=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.allFilterOrdersSelected}),Me=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.total}),Ue=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.totalBatches}),Be=(0,d.useSelector)(e=>{var t,l;return(null===e||void 0===e||null===(t=e.orders)||void 0===t||null===(l=t.shipmentCountsByStatus)||void 0===l?void 0:l.processing_without_pickup)||0}),Ve=(0,d.useSelector)(e=>{var t;return Object.keys((null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.sameRecipientOrders)||{}).length}),ze=(0,n.useState)(!1),$e=(0,s.A)(ze,2),Ze=$e[0],He=$e[1],qe=(0,n.useState)(!1),Ge=(0,s.A)(qe,2),Ke=Ge[0],Ye=Ge[1],Qe=(0,n.useState)(!1),Xe=(0,s.A)(Qe,2),Je=Xe[0],et=Xe[1],tt=(0,n.useState)(!1),lt=(0,s.A)(tt,2),it=lt[0],st=lt[1],nt=(0,n.useState)(!1),dt=(0,s.A)(nt,2),ot=dt[0],at=dt[1],rt=(0,n.useState)(!1),ct=(0,s.A)(rt,2),ut=ct[0],vt=ct[1],ht=(0,n.useState)(!1),mt=(0,s.A)(ht,2),pt=mt[0],wt=mt[1],xt=(0,J.ZL)(Ee,"orders"),gt=(0,w.yK)().getSelectedOrders,jt=(0,v.Ay)({history:W}),ft=W.location.search,yt=(0,q.GL)(Ee);(0,n.useEffect)(()=>{"processing"===(null===Pe||void 0===Pe?void 0:Pe.status)&&$(!1)},[null===Pe||void 0===Pe?void 0:Pe.status]),(0,n.useEffect)(()=>{const e=new ResizeObserver(()=>{U.current=setTimeout(()=>{L.current&&(!ut&&L.current.clientWidth<1055?vt(!0):ut&&L.current.clientWidth>=1055&&vt(!1)),clearTimeout(U.current)},100)});return e.observe(L.current),()=>{e.disconnect(),clearTimeout(U.current)}},[ut]);const bt=e=>{j((0,h.CW)({newOrderRef:e?(0,i.A)({},(0,X.Zi)({user:Ee})):null,newOrderModalActive:!0}))},At=(0,g.Hx)(Ee)&&!t&&!!We,St=(0,g.dG)(Ee)&&!t&&!!Ve,Nt=!t&&Be>0,Ct=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var t;ne(!0);const l=(await m.Km.get("/table-view-preset")).data;ue(null===l||void 0===l?void 0:l.tableViewPresets),null!==l&&void 0!==l&&null!==(t=l.tableViewPresets)&&void 0!==t&&t.length||null===e||void 0===e||!e.checkCreateModal?null!==e&&void 0!==e&&e.showPresetModal&&Se(!0):Ie(!0),null!==e&&void 0!==e&&e.handleClose&&e.handleClose()}catch(it){console.log("error",it)}finally{ne(!1)}},kt=!(null===Ee||void 0===Ee||!Ee.hasOrder);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"tw-hidden md:tw-flex tw-justify-between tw-gap-4 tw-flex-wrap",ref:L,children:kt?(0,Y.jsxs)(Y.Fragment,{children:[t?null:(0,Y.jsx)("div",{className:"tw-flex tw-space-x-2 tw-items-center",children:(0,Y.jsxs)(A.$n,{onClick:()=>bt(!0),variant:"contained",className:"tw-gap-1",disabled:_e,"data-cy":"btn-header-create-order",children:[(0,Y.jsx)(S.OMN,{}),"Create a Label"]})}),At||St?(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[At?(0,Y.jsx)("div",{className:"tw-flex tw-space-x-2 tw-items-center",children:(0,Y.jsxs)(A.$n,{className:"tw-gap-1 tw-flex tw-items-center tw-bg-yellow-300 tw-border-none",onClick:()=>{j((0,h.CW)({showLateShipments:!0}))},children:[(0,Y.jsx)(oe.N5,{}),We," Potential Late Shipment",1!==We?"s":""]})}):null,St?(0,Y.jsx)("div",{className:"tw-flex tw-space-x-2 tw-items-center",children:(0,Y.jsxs)(A.$n,{className:"tw-gap-1 tw-flex tw-items-center !tw-bg-orange-200 tw-border-none",onClick:()=>{j((0,h.CW)({showSameRecipientOrders:!0}))},children:[(0,Y.jsx)(oe.Nn,{}),Ve," Combinable Order",1!==Ve?"s":""]})}):null]}):null,(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-space-x-2",children:[yt&&!t?(0,Y.jsx)(A.m_,{title:"Get a rate quote.",children:(0,Y.jsx)("div",{className:"tw-cursor-pointer tw-grid tw-place-items-center",onClick:()=>Ye(!0),children:(0,Y.jsx)(S.tEU,{})})}):null,t?null:(0,Y.jsx)(se,{ref:M,hideTrigger:!0}
2),t?null:(0,Y.jsx)(A.$n,{disabled:_e,onClick:()=>{var e;return null===(e=M.current)||void 0===e?void 0:e.open()},variant:"contained",color:"secondary",children:"Service Request"}),t?null:(0,Y.jsx)(te,{loading:_e}),!t&&(0,Y.jsx)(o.c7,{permissions:[o.I1.IMPORT_EXPORT_ORDERS],children:(0,Y.jsx)(A.$n,{disabled:Re||_e,onClick:()=>He(!0),children:(0,Y.jsx)(A.m_,{title:Re?null!==Oe&&void 0!==Oe&&Oe.total?"Imported ".concat(null===Oe||void 0===Oe?void 0:Oe.imported," out of ").concat(null===Oe||void 0===Oe?void 0:Oe.total," orders"):"Checking...":Fe?null!==Pe&&void 0!==Pe&&Pe.total?"Imported ".concat(null===Pe||void 0===Pe?void 0:Pe.imported," out of ").concat(null===Pe||void 0===Pe?void 0:Pe.total," orders"):"Checking...":"",children:(0,Y.jsxs)("span",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsx)(S.lYe,{}),"Import Orders"]})})})}),(0,Y.jsx)(A.ND,{buttonProps:{variant:"text",className:"!tw-px-3",disabled:_e,handleClick:()=>wt(e=>!e)},onClose:()=>wt(!1),noIcon:!0,buttonIcon:(0,Y.jsxs)("div",{className:"tw-relative",children:[(0,Y.jsx)(S.W1t,{className:"tw-size-6"}),Nt&&!pt&&(0,Y.jsx)("div",{className:"tw-size-2 tw-absolute -tw-top-1 tw-right-0 tw-rounded-full tw-bg-primary"})]}),renderMenu:e=>{let i=e.handleListKeyDown,s=e.open,n=e.handleClose;return(0,Y.jsxs)(A.cO,{className:"!tw-min-w-[10rem]",autoFocusItem:s,onKeyDown:i,children:[Nt&&(0,Y.jsxs)(A.Dr,{disabled:_e,onClick:()=>{et(!0),n()},children:[(0,Y.jsx)(N.A,{className:"tw-size-4",strokeWidth:1}),"Schedule Pickup",(0,Y.jsx)("div",{className:"tw-size-2 tw-rounded-full tw-bg-primary tw-ml-auto"})]}),!t&&(0,Y.jsxs)(A.Dr,{onClick:()=>{l(!0),n()},disabled:_e||Fe,children:[(0,Y.jsx)(S.MbM,{}),"Manifest"]}),!t&&(0,Y.jsx)(A.Dr,{className:"!tw-p-0",children:(0,Y.jsxs)(A.$n,{disabled:_e,variant:"text",className:"!tw-px-2 !tw-py-1.5 tw-gap-2 !tw-h-auto",onClick:()=>{n(),Ct({checkCreateModal:!0,handleClose:n,showPresetModal:!0})},children:[(0,Y.jsx)(S.QgE,{}),"Preset Views"]})}),!t&&(0,Y.jsx)(o.c7,{permissions:[o.I1.ORDERS,o.I1.VIEW_PRINT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:_e,onClick:()=>W.push("/bulk-stats"),children:[(0,Y.jsx)(S.j0T,{}),"Bulk Stats"]})}),!t&&(0,Y.jsx)(o.c7,{permissions:[o.I1.ORDERS,o.I1.VIEW_PRINT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:_e,onClick:()=>W.push("/pickups"),children:[(0,Y.jsx)(S.ISY,{}),"Pickups"]})}),(0,Y.jsx)(o.c7,{permissions:[o.I1.IMPORT_EXPORT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:Re||_e,onClick:()=>at(!0),children:[(0,Y.jsx)(S.lYe,{className:"tw-rotate-180"}),"Export"]})}),t&&(0,Y.jsx)(A.Dr,{className:"!tw-p-0",children:(0,Y.jsx)(A.ND,{buttonText:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Y.jsx)(S.lYe,{}),"Download"]}),btnIconSize:"default",buttonProps:{className:"!tw-px-2 !tw-py-1.5 tw-gap-2 !tw-h-auto",variant:"text"},renderMenu:e=>{let t=e.handleListKeyDown,l=e.open;return(0,Y.jsxs)(A.cO,{autoFocusItem:l,onKeyDown:t,children:[(0,Y.jsx)(A.Dr,{onClick:()=>De(x,he.UG.SLIP),children:"Packing Slips"}),(0,Y.jsx)(A.Dr,{onClick:()=>De(x,he.UG.PICK),children:"Pick List"}),(0,Y.jsx)(A.Dr,{onClick:()=>De(x,he.UG.LABEL),children:"Labels"}),(0,Y.jsx)(A.Dr,{onClick:()=>De(x,he.UG.ALL),children:"Packing Slips + Labels"})]})}})}),t&&a?(0,Y.jsx)(A.m_,{title:"Order".concat(a>1?"s":""," will not be deleted, only removed from the Batch."),children:(0,Y.jsxs)(A.Dr,{onClick:r,children:[(0,Y.jsx)(S.epd,{}),"Remove"]})}):null]})}})]})]}):null}),kt?(0,Y.jsxs)("div",{className:"md:tw-hidden",children:[At||St?(0,Y.jsxs)("div",{className:"tw-flex tw-flex-row tw-flex-wrap tw-justify-center tw-items-center tw-gap-2 tw-mb-4",children:[At?(0,Y.jsxs)(A.$n,{className:"tw-gap-1 tw-flex tw-items-center tw-bg-yellow-300 tw-border-none",onClick:()=>{j((0,h.CW)({showLateShipments:!0}))},children:[(0,Y.jsx)(oe.N5,{}),We," Potential Late Shipment",1!==We?"s":""]}):null,St?(0,Y.jsxs)(A.$n,{className:"tw-gap-1 tw-flex tw-items-center !tw-bg-orange-200 tw-border-none",onClick:()=>{j((0,h.CW)({showSameRecipientOrders:!0}))},children:[(0,Y.jsx)(oe.Nn,{}),Ve," Combinable Order",1!==Ve?"s":""]}):null]}):null,(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-items-center tw-gap-4",children:[t?(0,Y.jsx)("div",{}):(0,Y.jsxs)(A.$n,{onClick:()=>bt(!0),variant:"contained",className:"tw-gap-1",disabled:_e,children:[(0,Y.jsx)(S.OMN,{}),"Create a Label"]}),(0,Y.jsx)(A.ND,{placement:"bottom-end",buttonProps:{variant:"text",className:"!tw-px-2 !tw-min-w-0",disabled:_e,handleClick:()=>wt(e=>!e)},onClose:()=>wt(!1),noIcon:!0,buttonIcon:(0,Y.jsxs)("div",{className:"tw-relative",children:[(0,Y.jsx)(k,{className:"tw-size-6"}),Nt&&!pt&&(0,Y.jsx)("div",{className:"tw-size-3 tw-absolute -tw-top-1 tw-right-0 tw-rounded-full tw-bg-primary"})]}),paperProps:{className:"tw-w-56"},renderMenu:e=>{let i=e.handleListKeyDown,s=e.open,n=e.handleClose;return(0,Y.jsxs)(A.cO,{className:"!tw-py-1",autoFocusItem:s,onKeyDown:i,children:[Nt&&(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:_e,onClick:()=>{et(!0),n()},children:[(0,Y.jsx)(N.A,{className:"tw-size-4",strokeWidth:1}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Schedule Pickup"}),(0,Y.jsx)("div",{className:"tw-size-3 tw-rounded-full tw-bg-primary tw-ml-auto"})]}),!t&&(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:_e||Fe,onClick:()=>{l(!0),n()},children:[(0,Y.jsx)(I.A,{className:"tw-size-4",strokeWidth:1.5}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Manifest"})]}),!t&&(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:_e,onClick:()=>{Ct({checkCreateModal:!0,handleClose:n,showPresetModal:!0}),n()},children:[(0,Y.jsx)(D,{className:"tw-size-4",strokeWidth:1.5}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Preset Views"})]}),!t&&(0,Y.jsx)(o.c7,{permissions:[o.I1.ORDERS,o.I1.VIEW_PRINT_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:_e,onClick:()=>{W.push("/bulk-stats"),n()},children:[(0,Y.jsx)(E,{className:"tw-size-4",strokeWidth:1.5}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Bulk Stats"})]})}),!t&&(0,Y.jsx)(o.c7,{permissions:[o.I1.ORDERS,o.I1.VIEW_PRINT_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:_e,onClick:()=>{W.push("/pickups"),n()},children:[(0,Y.jsx)(S.ISY,{}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Pickups"})]})}),!t&&(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:_e,onClick:()=>{W.push("/batch"),n()},children:[(0,Y.jsx)(O,{className:"tw-size-4",strokeWidth:1.5}),(0,Y.jsxs)(A.o5,{className:"tw-text-sm",children:["Batches",Ue?" (".concat(Ue,")"):""]})]}),!t&&(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:_e,onClick:()=>{var e;null===(e=M.current)||void 0===e||e.open(),n()},children:[(0,Y.jsx)(R,{className:"tw-size-4",strokeWidth:1.5}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Service Request"})]}),yt&&!t?(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",onClick:()=>{Ye(!0),n()},children:[(0,Y.jsx)(P,{className:"tw-size-4",strokeWidth:1.5}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Check Rates"})]}):null,!t&&(0,Y.jsx)(o.c7,{permissions:[o.I1.IMPORT_EXPORT_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:Re||_e,onClick:()=>{He(!0),n()},children:[(0,Y.jsx)(F,{className:"tw-size-4",strokeWidth:1.5}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Import"})]})}),(0,Y.jsx)(o.c7,{permissions:[o.I1.IMPORT_EXPORT_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:Re||_e,onClick:()=>{at(!0),n()},children:[(0,Y.jsx)(F,{className:"tw-size-4 tw-rotate-180",strokeWidth:1.5}),(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Export"})]})})]})}})]})]}):null,kt?null:(0,Y.jsxs)(A.Zp,{className:"tw-mt-4 tw-max-w-[38rem] tw-gap-0",children:[(0,Y.jsx)("div",{className:"tw-text-2xl lg:tw-text-3xl tw-text-center tw-text-secondary",children:"No Orders Yet"}),(0,Y.jsx)("img",{src:we,alt:"Shipments",className:"tw-max-h-72 tw-mx-auto tw-mt-8 tw-mb-5"}),(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-4 tw-flex-wrap tw-justify-center",children:[(0,Y.jsxs)(A.$n,{onClick:()=>bt(!0),variant:"contained",color:"primary",className:"tw-gap-1",children:[(0,Y.jsx)(S.OMN,{}),"Create a Label"]}
2),!(null!==xt&&void 0!==xt&&xt.length)&&(0,Y.jsx)(A.$n,{onClick:()=>{W.push("/preset/stores?store-modal=open")},variant:"contained",color:"secondary",className:"tw-gap-1",children:"Connect a Store"}),!t&&(0,Y.jsx)(o.c7,{permissions:[o.I1.IMPORT_EXPORT_ORDERS],children:(0,Y.jsx)(A.m_,{title:Re?null!==Oe&&void 0!==Oe&&Oe.total?"Imported ".concat(null===Oe||void 0===Oe?void 0:Oe.imported," out of ").concat(null===Oe||void 0===Oe?void 0:Oe.total," orders"):"Checking...":"",children:(0,Y.jsxs)(A.$n,{color:it?"secondary":void 0,disabled:Re||_e,onClick:()=>He(!0),children:[(0,Y.jsx)(S.lYe,{className:"tw-mr-1"}),"Import Orders"]})})}),yt?(0,Y.jsx)(A.m_,{title:"Get a rate quote.",children:(0,Y.jsx)("div",{className:"tw-cursor-pointer tw-grid tw-place-items-center",onClick:()=>Ye(!0),children:(0,Y.jsx)(S.tEU,{})})}):null]})]}),(0,Y.jsx)(de,{isImporting:Fe,importProgress:Pe,user:Ee}),(0,Y.jsx)(T.A,{handleClose:()=>bt(!1)}),(0,Y.jsx)(ve,{active:Ze,handleClose:()=>He(!1),setError:st,isImporting:Fe,setIsManualImport:$}),(0,Y.jsx)(Q,{active:Ke,handleClose:()=>Ye(!1)}),(0,Y.jsx)(le.A,{show:ot,handleClose:()=>at(!1),entity:"orders",action:"export",handleExport:async e=>{let l=e.exportConfig,i=void 0===l?[]:l,s=e.exportOption,n=e.dateRange,d=void 0===n?{}:n,o=e.mergeBoxIntoSku,a=void 0!==o&&o;try{let e=null;"selected"===s?e=Object.keys(gt()):"page"===s&&(e=Te.map(e=>e._id));const l=!(null!==jt&&void 0!==jt&&jt.order_filters||null!==jt&&void 0!==jt&&jt.search_filters||null!==jt&&void 0!==jt&&jt.order_number||null!==jt&&void 0!==jt&&jt.custom_filters);let n=ft;n?!l||null!==jt&&void 0!==jt&&jt.shipmentStatus||(n+="&shipmentStatus=holding"):n="?shipmentStatus=holding",Z.D$||y(ee.lw.CSV_EXPORT,{toast:{mutableType:ee.Rf.ORDERS_EXPORTED.key}});const o=(await m.Km.post("/orders/export".concat(t?"?batchId=".concat(x):n),{selectedOrderIds:e,exportConfig:i,exportDateRange:"dateRange"===s?d:void 0,mergeBoxIntoSku:a})).data;Z.D$?C(o.message,{toast:{mutableType:ee.Rf.ORDERS_EXPORTED.key}}):(0,_.A)(o,"orders_data.csv")}catch(c){var r;b((null===c||void 0===c||null===(r=c.response)||void 0===r?void 0:r.data)||(null===c||void 0===c?void 0:c.message)||"Error Exporting Orders")}},totalSelected:ot?Le?Me:Object.keys(gt()).length||0:0,allFilterOrdersSelected:Le}),(0,Y.jsxs)(A.aF,{title:"Preset Views",open:Ae,handleClose:()=>Se(!1),maxWidth:"xs",hideActions:!0,children:[K?(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-justify-center",style:{minHeight:80},children:(0,Y.jsx)(A.P,{color:"primary",size:32})}):(0,Y.jsx)("ul",{className:"tw-list-none tw-p-0 tw-m-0 tw-space-y-4",children:null===ce||void 0===ce?void 0:ce.map(e=>(0,Y.jsxs)("li",{className:"tw-flex tw-justify-between tw-items-center",children:[(0,Y.jsx)("span",{className:"tw-font-bold",children:e.name}),(0,Y.jsxs)("div",{className:"tw-flex tw-gap-2 tw-items-center",children:[(0,Y.jsx)(A.$n,{size:"small",color:"secondary",variant:"contained",onClick:()=>(async e=>{try{ne(!0);const t=(0,v.Ay)({history:W}),l=(0,v.b7)(W.location.search,["limit","page","sort_by"]),i=(null===t||void 0===t?void 0:t.shipmentStatus)||(null!==l&&void 0!==l&&l.length?null:"holding");await m.Km.post("/table-view-preset/apply",{presetId:e._id,search:l,status:i}),C("Successfully Applied View Preset"),window.location.reload()}catch(l){var t;console.log("error",l),b((null===l||void 0===l||null===(t=l.response)||void 0===t?void 0:t.data)||(null===l||void 0===l?void 0:l.message)||"Something Went Wrong")}finally{ne(!1)}})(e),children:"Apply"}),(0,Y.jsx)(S.epd,{width:30,height:30,className:"tw-cursor-pointer",onClick:()=>fe(e)})]})]},e.name))}),(0,Y.jsx)("div",{className:"tw-mt-4",children:(0,Y.jsxs)(A.$n,{size:"small",className:"tw-gap-1 tw-font-medium",color:"primary",variant:"contained",onClick:()=>Ie(!0),children:[(0,Y.jsx)(S.OMN,{}),(0,Y.jsx)("span",{children:"Save Current View"})]})})]}),(0,Y.jsx)(A.aF,{title:"Delete Preset",open:!!je,handleClose:()=>fe(null),maxWidth:"xs",actions:[{label:"Delete",color:"error",onClick:async()=>{try{ne(!0),await m.Km.delete("/table-view-preset/".concat(je._id)),C("Successfully Deleted View Preset"),fe(null),Ct()}catch(t){var e;console.log("error",t),b((null===t||void 0===t||null===(e=t.response)||void 0===e?void 0:e.data)||(null===t||void 0===t?void 0:t.message)||"Something Went Wrong")}finally{ne(!1)}}}],children:(0,Y.jsxs)(A.o5,{children:['Are you sure you want to delete the preset "',null===je||void 0===je?void 0:je.name,'"?']})}),(0,Y.jsx)(me,{open:ke,handleClose:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&Se(!0),Ie(!1)},fetchTableViewPresets:Ct}),(0,Y.jsx)(pe.A,{open:Je,handleClose:()=>et(!1),onSchedule:e=>{et(!1),c(e)}})]})};var ge=l(37643),je=l(84980),fe=l(76459),ye=l(77334),be=l(46685),Ae=l(18914),Se=l(91028),Ne=l(80667),Ce=l(1790);const ke=(0,C.A)("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),Ie=(0,C.A)("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]),De=["sort_by"],Ee=n.memo(e=>
2{let t=e.displayName,l=e.column,i=e.enableSorting,d=e.progressSort,o=e.api,a=e.onChooseColumns,r=e.enableFilterButton,c=e.showFilter;const u=(0,n.useState)(l.getSort()),v=(0,s.A)(u,2),h=v[0],m=v[1],p=(0,n.useState)(l.isFilterActive()),w=(0,s.A)(p,2),x=w[0],g=w[1],j=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const e=()=>m(l.getSort());return l.addEventListener("sortChanged",e),()=>l.removeEventListener("sortChanged",e)},[l]),(0,n.useEffect)(()=>{const e=()=>g(l.isFilterActive());return l.addEventListener("filterChanged",e),()=>l.removeEventListener("filterChanged",e)},[l]),(0,Y.jsxs)("div",{style:{display:"flex",alignItems:"center",width:"100%",gap:4},children:[(0,Y.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:i?"pointer":"default"},onClick:()=>i&&d(),children:t}),i&&"asc"===h&&(0,Y.jsx)("span",{className:"ag-icon ag-icon-asc",role:"presentation",style:{display:"flex",alignItems:"center"}}),i&&"desc"===h&&(0,Y.jsx)("span",{className:"ag-icon ag-icon-desc",role:"presentation",style:{display:"flex",alignItems:"center"}}),r&&c&&(0,Y.jsx)("button",{ref:j,className:(0,Se.cn)("col-header-btn",x&&"filter-active"),onClick:e=>{e.stopPropagation(),c(j.current)},title:"Filter",children:(0,Y.jsx)(ke,{size:13})}),(0,Y.jsx)("button",{className:"col-header-btn",onClick:e=>{var t,i;e.stopPropagation();const s=null!==(t=null===l||void 0===l||null===(i=l.getGui)||void 0===i?void 0:i.call(l))&&void 0!==t?t:null;a(s,o)},title:"Choose Columns",children:(0,Y.jsx)(Ie,{size:13})})]})}),Oe=n.memo(e=>{var t;let l=e.searchPanelExpanded;const o=(0,d.useDispatch)(),a=(0,u.useHistory)(),c=null===a||void 0===a||null===(t=a.location)||void 0===t?void 0:t.search,m=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading}),p=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.total)||0}),g=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),f=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.orders}),y=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.progressReport}),b=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.processedOrders)||{}}),A=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.gridApi}),S=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.totalSelectedShipments}),N=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.customUI)||void 0===l?void 0:l.find(e=>e.type===ye.A.MAIN_HEADER&&!0===e.active)}),C=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.customUI)||void 0===l?void 0:l.find(e=>e.type===ye.A.SUB_HEADER&&!0===e.active)}),k=(0,n.useState)(!1),I=(0,s.A)(k,2),D=I[0],E=I[1],O=(0,n.useState)({}),R=(0,s.A)(O,2),P=R[0],F=R[1],_=(0,n.useState)(null),T=(0,s.A)(_,2),W=T[0],L=T[1],M=(0,n.useState)(null),U=(0,s.A)(M,2),B=U[0],V=U[1],z=(0,n.useCallback)(()=>{E(e=>!e)},[]),$=(0,w.BW)(),H=$.gridOptions,q=$.restoreGridState,G=$.saveGridState,K=$.cancelPendingUpdates,Q=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.restoreGrid}),X=(0,n.useRef)(!1);(0,n.useEffect)(()=>{const e=X.current;X.current=Q,e&&!Q&&K()},[Q]);const J=(0,w.yK)(),ee=J.getSelectedOrderShipmentCounts,te=J.getTotalExpandedShipmentRows,le=J.setSelectedOrders,ie=(0,v.Ay)({history:a}),se=(null===ie||void 0===ie?void 0:ie.limit)||100,ne=Math.ceil(p/parseInt(se||100))||1,de="isCancelled"===(null===ie||void 0===ie?void 0:ie.shipmentStatus);(0,n.useEffect)(()=>{const e=null===A||void 0===A?void 0:A();e&&(e.loading=!!m)},[A,m,null===f||void 0===f?void 0:f.length]);const oe=(0,n.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const l=(null===e||void 0===e?void 0:e.isCancelled)&&!de&&!m,i=(0,je.get)(y,["bulkEdit","orderDetails",e._id]),s=(0,je.get)(y,["bulkBuy","orderDetails",e._id]),n=(0,je.get)(y,["bulkRefund","orderDetails",e._id]),d=(0,je.get)(y,["bulkFulfill","orderDetails",e._id]),o=(0,je.get)(y,["bulkStatus","orderDetails",e._id]),a=!!(i||s||n||d||o),r=b[e._id]||l;
2let c,u,v,h,p,w;return null!==t&&void 0!==t&&t.id&&(c=(0,je.get)(i,[t.id]),u=(0,je.get)(s,[t.id]),v=(0,je.get)(n,[t.id]),h=(0,je.get)(d,[t.id]),p=(0,je.get)(o,[t.id]),w=!!(c||u||v||h||p)),{isAnyBulkOpInProgressOrder:a,orderProcessed:r,editInProcessOrder:i,buyInProcessOrder:s,refundInProcessOrder:n,fulfillInProcessOrder:d,updateStatusInProcessOrder:o,editInProcessShipment:c,buyInProcessShipment:u,refundInProcessShipment:v,fulfillInProcessShipment:h,updateStatusInProcessShipment:p,isAnyBulkOpInProgressShipment:w,isCancelledOrderNotInCancelledStatus:l}},[de,m,b,y]),ae=(0,w.rG)({getOrderProgressReportData:oe,handleRendererExpand:z,rerenderExpand:D,getSelectedOrderShipmentCounts:ee,nonEmptyCols:P}),re=ae.colDefs,ce=ae.detailCellRendererParams,ue=(0,n.useCallback)((e,t)=>{const l=ie.sort_by,i=(0,ge.A)(ie,De);let s="?";const n=[];Object.values(i).length&&Object.keys(i).forEach(e=>{"custom_filters"===e?n.push(r().stringify({custom_filters:ie[e]})):n.push("".concat(e,"=").concat(encodeURIComponent(ie[e])))});const d=!(null!==i&&void 0!==i&&i.order_filters||null!==i&&void 0!==i&&i.search_filters||null!==i&&void 0!==i&&i.order_number||null!==i&&void 0!==i&&i.custom_filters);var o;if(!i.shipmentStatus&&d&&n.push("shipmentStatus=holding"),s+=n.join("&"),e)if(null!==l&&void 0!==l&&null!==(o=l.trim())&&void 0!==o&&o.length)if(l.includes(e)){const i=l.split(",").map(l=>l.split("=")[0]===e?"asc"===l.split("=")[1]?"".concat(l.split("=")[0],"=").concat(t||"desc"):null:l).filter(e=>e).join(",");null!==i&&void 0!==i&&i.length&&(s+="&sort_by=".concat(i))}else s+="&sort_by=".concat(e.split("=")[0],"=").concat(t||"asc");else s+="&sort_by=".concat(e,"=").concat(t||"asc");a.push("".concat(a.location.pathname).concat(s))},[ie,a]),ve=(0,n.useCallback)(e=>{var t;if(!["uiColumnSorted","columnMenu"].includes(null===e||void 0===e?void 0:e.source))return;const l=e.api.getColumnState().find(e=>e.sort),i="Order #"===(null===l||void 0===l?void 0:l.colId)?"orderNumber":null===(t=fe.A.find(e=>e.name===(null===l||void 0===l?void 0:l.colId)))||void 0===t?void 0:t.filter;ue(i,null===l||void 0===l?void 0:l.sort)},[ue]),he=(0,n.useCallback)(e=>{var t;const l=[],i=[];e.eventPath.forEach(e=>{l.push(e.className),i.push(e.localName)}),l.includes("ag-center-cols-viewport")&&!i.includes("button")&&null!==e&&void 0!==e&&null!==(t=e.node)&&void 0!==t&&t.master&&e.api.setRowNodeExpanded(e.node,!e.node.expanded)},[]),me=(0,n.useCallback)(e=>{var t,l;if(e.master&&null!==e&&void 0!==e&&null!==(t=e.detailNode)&&void 0!==t&&null!==(l=t.detailGridInfo)&&void 0!==l&&l.api)if(e.__selected)e.detailNode.detailGridInfo.api.selectAll();else{let t=0,l=0;e.detailNode.detailGridInfo.api.forEachNode(e=>{l+=1,e.__selected&&(t+=1)}),t===l&&e.detailNode.detailGridInfo.api.deselectAll()}},[]),pe=(0,n.useCallback)(e=>{const t=(0,j.y1)("selectedOrdersShipments");let l=(0,i.A)({},t);e.api.forEachNode(e=>{const t=e.data.id;me(e),e.__selected||delete l[t]}),(0,j.os)("selectedOrdersShipments",l);const s=ee(),n=s.totalSelectedOrders,d={totalSelectedOrders:n,totalSelectedShipments:s.totalSelectedShipments};"uiSelectAll"===(null===e||void 0===e?void 0:e.source)&&(l={}),n<(null===f||void 0===f?void 0:f.length)&&"apiSelectAll"!==(null===e||void 0===e?void 0:e.source)&&(d.allFilterOrdersSelected=!1),o((0,h.CW)(d))},[o,ee,me,null===f||void 0===f?void 0:f.length]),we=(0,n.useCallback)(e=>{q(e.api),setTimeout(()=>{var t;const l=e.api,i=[],s=[],n=window.innerWidth<768,d={opts:n?50:70,Actions:n?40:180};null===l||void 0===l||null===(t=l.getColumns())||void 0===t||t.forEach(e=>{const t=e.getId();["opts","Actions"].includes(t)?s.push({colId:t,width:d[t],key:e,newWidth:d[t]}):i.push(t)}),null===l||void 0===l||l.autoSizeColumns(i),setTimeout(()=>{null===l||void 0===l||l.setColumnWidths(s)},300)},100),o((0,h.CW)({gridApi:()=>e.api}))},[o]),xe=(0,n.useCallback)(e=>{var t,l;if(!e.node.detail)return;return 80+42*((null===e||void 0===e||null===(t=e.data)||void 0===t||null===(l=t.shipments)||void 0===l?void 0:l.length)||0)},[]),ke=(0,n.useCallback)(e=>{const t=(0,j.y1)("selectedOrdersShipments");me(e.node);const l=ee(),i=l.totalSelectedOrders,s=l.totalSelectedShipments;o((0,h.CW)({totalSelectedOrders:i,totalSelectedShipments:s}
2)),E(!D),Object.keys(t).length&&le(t)},[o,ee,me,D]),Ie=(0,n.useCallback)(e=>{var t;return((null===e||void 0===e||null===(t=e.shipments)||void 0===t?void 0:t.length)||0)>1},[]),Oe=(0,n.useCallback)(e=>{var t,l;const i=oe(null!==(t=null===(l=e.data)||void 0===l?void 0:l["Order #"])&&void 0!==t?t:""),s=i.isAnyBulkOpInProgressOrder,n=i.orderProcessed;if(s||n)return"ag-row-inprogress"},[oe]),Re=(0,n.useMemo)(()=>{const e={[j.EZ.id]:1,[j.EZ.orderNumber]:1,[j.EZ.actions]:1,[j.EZ.shipments]:1},t=null===f||void 0===f?void 0:f.map(t=>{var l,s,n,d,o,a,r,c,u,v,h,m,p,w,f,y,b,A,S,N,C,k,I,D,E,O,R,P,F,_,T,W,L,M,U,B,V,z,$,Z,H,q,G,K,Y,Q,X,J,ee,te,le,ie,se,ne,de,oe,ae,re,ce,ue,ve,he,me,pe,we,xe,ge,je,fe,ye,Ae,Se,Ce,ke,Ie;const De={};De[j.EZ.id]=t._id,De[j.EZ.orderNumber]=t,De[j.EZ.actions]=t,De[j.EZ.orderDate]=(0,x.Ay)(t.createdAt).format(x.eU),t.createdAt&&(e[j.EZ.orderDate]=1),De[j.EZ.name]=null===(l=t.shippingAddress)||void 0===l?void 0:l.name,De[j.EZ.name]&&(e[j.EZ.name]=1),De[j.EZ.company]=null===(s=t.shippingAddress)||void 0===s?void 0:s.company,De[j.EZ.company]&&(e[j.EZ.company]=1),De[j.EZ.city]=null===(n=t.shippingAddress)||void 0===n?void 0:n.city,De[j.EZ.city]&&(e[j.EZ.city]=1),De[j.EZ.state]=null===(d=t.shippingAddress)||void 0===d?void 0:d.state,De[j.EZ.state]&&(e[j.EZ.state]=1),De[j.EZ.propertyType]=null===(o=t.shippingAddress)||void 0===o?void 0:o.isResidential,(De[j.EZ.propertyType]||!1===De[j.EZ.propertyType])&&(e[j.EZ.propertyType]=1),De[j.EZ.labelDate]=null!==t&&void 0!==t&&null!==(a=t.firstShipment)&&void 0!==a&&a.labelPurchaseDate?(0,x.Ay)(t.firstShipment.labelPurchaseDate).format(x.rb):null,De[j.EZ.labelDate]&&(e[j.EZ.labelDate]=1),De[j.EZ.estimatedTransitTime]=null===t||void 0===t||null===(r=t.firstShipment)||void 0===r?void 0:r.estimateTransitTime,De[j.EZ.estimatedTransitTime]&&(e[j.EZ.estimatedTransitTime]=1),null!==t&&void 0!==t&&t.errorsAndWarnings&&(t.errorsAndWarnings.orderError?(De[j.EZ.warnings]={title:t.errorsAndWarnings.orderError,val:t.errorsAndWarnings.orderErrorStep,className:"caption secondary-color"},e[j.EZ.warnings]=1):t.errorsAndWarnings.shipmentError?(De[j.EZ.warnings]={title:(0,Ne.DZ)(t.errorsAndWarnings.shipmentError),val:t.errorsAndWarnings.shipmentErrorStep,className:"caption secondary-color"},e[j.EZ.warnings]=1):t.errorsAndWarnings.addressWarning&&(De[j.EZ.warnings]={title:t.errorsAndWarnings.addressWarning,val:"address",className:"caption secondary-color"},e[j.EZ.warnings]=1)),null!==t&&void 0!==t&&null!==(c=t.firstShipment)&&void 0!==c&&c.pdfsPrinted&&(De[j.EZ.printed]=t.firstShipment.pdfsPrinted,e[j.EZ.printed]=1),De[j.EZ.fulfillment]=null===t||void 0===t||null===(u=t.firstShipment)||void 0===u?void 0:u.isFulfilled,De[j.EZ.fulfillment]&&(e[j.EZ.fulfillment]=1),De[j.EZ.printDate]=null!==t&&void 0!==t&&null!==(v=t.firstShipment)&&void 0!==v&&v.labelPrintDate?(0,x.Ay)(t.firstShipment.labelPrintDate).format(x.rb):null,De[j.EZ.printDate]&&(e[j.EZ.printDate]=1),De[j.EZ.lineItemsQty]=t.lineItems,null!==t&&void 0!==t&&null!==(h=t.lineItems)&&void 0!==h&&h.length&&(e[j.EZ.lineItemsQty]=1),De[j.EZ.tracking]=t.trackings,null!==t&&void 0!==t&&null!==(m=t.trackings)&&void 0!==m&&m.length&&(e[j.EZ.tracking]=1),De[j.EZ.deliveryDate]=t.deliveryDate?x.d4.utc(t.deliveryDate).format(x.eU):null,De[j.EZ.deliveryDate]&&(e[j.EZ.deliveryDate]=1),De[j.EZ.tags]=null===g||void 0===g||null===(p=g.tags)||void 0===p?void 0:p.filter(e=>{var l;return null===t||void 0===t||null===(l=t.tags)||void 0===l?void 0:l.includes(e.id)}),null!==t&&void 0!==t&&null!==(w=t.tags)&&void 0!==w&&w.length&&(e[j.EZ.tags]=1),De[j.EZ.saturdayDelivery]=null===t||void 0===t||null===(f=t.firstShipment)||void 0===f||null===(y=f.options)||void 0===y?void 0:y.saturdayDelivery,De[j.EZ.saturdayDelivery]&&(e[j.EZ.saturdayDelivery]=1),De[j.EZ.dryIce]=null===t||void 0===t||null===(b=t.firstShipment)||void 0===b||null===(A=b.options)||void 0===A?void 0:A.dryIce,De[j.EZ.dryIce]&&(e[j.EZ.dryIce]=1),De[j.EZ.warehouse]=null===t||void 0===t||null===(S=t.warehouse)||void 0===S?void 0:S.name,De[j.EZ.warehouse]&&(e[j.EZ.warehouse]=1),De[j.EZ.qtyOrdered]=(null===t||void 0===t||null===(N=t.totalAggregates)||void 0===N?void 0:N.totalQuantity)||0,(null!==t&&void 0!==t&&null!==(C=t.totalAggregates)&&void 0!==C&&C.totalQuantity||0===(null===t||void 0===t||null===(k=t.totalAggregates)||void 0===k?void 0:k.totalQuantity))&&(e[j.EZ.qtyOrdered]=1),De[j.EZ.insuredAmount]=(0,be.toCurrencyFormat)((null===t||void 0===t||null===(I=t.totalAggregates)||void 0===I?void 0:I.totalInsurance)||0),(null!==t&&void 0!==t&&null!==(D=t.totalAggregates)&&void 0!==D&&D.totalInsurance||0===(null===t||void 0===t||null===(E=t.totalAggregates)||void 0===E?void 0:E.totalInsurance))&&(e[j.EZ.insuredAmount]=1),De[j.EZ.weight]=(null===t||void 0===t||null===(O=t.totalAggregates)||void 0===O?void 0:O.totalWeight)||0,(null!==t&&void 0!==t&&null!==(R=t.totalAggregates)&&void 0!==R&&R.totalWeight||0===(null===t||void 0===t||null===(P=t.totalAggregates)||void 0===P?void 0:P.totalWeight))&&(e[j.EZ.weight]=1),De[j.EZ.shippingCost]={style:{fontWeight:"bold"},val:(0,be.toCurrencyFormat)((null===t||void 0===t||null===(F=t.totalAggregates)||void 0===F?void 0:F.totalShippingCost)||0)},(null!==t&&void 0!==t&&null!==(_=t.totalAggregates)&&void 0!==_&&_.totalShippingCost||0===(null===t||void 0===t||null===(T=t.totalAggregates)||void 0===T?void 0:T.totalShippingCost))&&(e[j.EZ.shippingCost]=1),De[j.EZ.box]=null===t||void 0===t||null===(W=t.firstShipment)||void 0===W||null===(L=W.box)||void 0===L?void 0:L.name,De[j.EZ.box]&&(e[j.EZ.box]=1),De[j.EZ.boxDims]=null===t||void 0===t||null===(M=t.firstShipment)||void 0===M||null===(U=M.box)||void 0===U?void 0:U.dims,De[j.EZ.boxDims]&&(e[j.EZ.boxDims]=1),De[j.EZ.service]={style:{color:null===t||void 0===t||null===(B=t.firstShipment)||void 0===B||null===(V=B.rateInfo)||void 0===V?void 0:V.serviceColorToShow,fontWeight:"bold"},val:null!==t&&void 0!==t&&null!==(z=t.firstShipment)&&void 0!==z&&null!==($=z.rateInfo)&&void 0!==$&&$.isLocalCourierRate?"Local Courier":null!==t&&void 0!==t&&null!==(Z=t.firstShipment)&&void 0!==Z&&null!==(H=Z.rateInfo)&&void 0!==H&&H.serviceToShow?"".concat(null===t||void 0===t||null===(q=t.firstShipment)||void 0===q||null===(G=q.rateInfo)||void 0===G?void 0:G.carrierToShow," ").concat(null===t||void 0===t||null===(K=t.firstShipment)||void 0===K||null===(Y=K.rateInfo)||void 0===Y?void 0:Y.serviceToShow):""},(null!==t&&void 0!==t&&null!==(Q=t.firstShipment)&&void 0!==Q&&null!==(X=Q.rateInfo)&&void 0!==X&&X.serviceToShow||null!==t&&void 0!==t&&null!==(J=t.firstShipment)&&void 0!==J&&null!==(ee=J.rateInfo)&&void 0!==ee&&ee.isLocalCourierRate)&&(e[j.EZ.service]=1),De[j.EZ.notes]={title:t.comment,val:t.comment},null!==t&&void 0!==t&&t.comment&&(e[j.EZ.notes]=1),null!==t&&void 0!==t&&null!==(te=t.firstShipment)&&void 0!==te&&te.pickupPrn&&(De[j.EZ.pickupPRN]=t.firstShipment.pickupPrn,e[j.EZ.pickupPRN]=1),null!==t&&void 0!==t&&null!==(le=t.firstShipment)&&void 0!==le&&le.holdDate&&(De[j.EZ.holdDate]=t.firstShipment.holdDate,e[j.EZ.holdDate]=1),null!==t&&void 0!==t&&null!==(ie=t.firstShipment)&&void 0!==ie&&ie.shipDate?(De[j.EZ.shipBy]={style:{fontWeight:"bold"},val:x.d4.utc(t.firstShipment.shipDate).format(x.eU)},e[j.EZ.shipBy]=1):!De[j.EZ.shipBy]&&null!==t&&void 0!==t&&null!==(se=t.firstShipment)&&void 0!==se&&null!==(ne=se.rateInfo)&&void 0!==ne&&ne.shipByDate?(De[j.EZ.shipBy]={style:{fontWeight:"bold"},val:(0,x.Ay)(t.firstShipment.rateInfo.shipByDate).format(x.eU)},e[j.EZ.shipBy]=1):!De[j.EZ.shipBy]&&null!==t&&void 0!==t&&null!==(de=t.firstShipment)&&void 0!==de&&de.holdDate&&(De[j.EZ.shipBy]={style:{fontWeight:"bold"},val:(0,x.Ay)(t.firstShipment.holdDate).hour(0).minute(0).second(0).millisecond(0).format(x.eU)},e[j.EZ.shipBy]=1),De[j.EZ.status]={className:"tw-rounded-full tw-p-1 tw-bg-".concat(null===t||void 0===t||null===(oe=t.firstShipment)||void 0===oe?void 0:oe.statusColumnColor," tw-w-fit !tw-text-xs tw-px-2 tw-text-black"),val:null===t||void 0===t||null===(ae=t.firstShipment)||void 0===ae?void 0:ae.status},null!==t&&void 0!==t&&null!==(re=t.firstShipment)&&void 0!==re&&re.status&&(e[j.EZ.status]=1),De[j.EZ.batchNumber]=t.batchNumber,De[j.EZ.batchNumber]&&(e[j.EZ.batchNumber]=1),De[j.EZ.orderColor]=null!==t&&void 0!==t&&t.orderColor&&!["#ffffff","black"].includes(t.orderColor.toLowerCase())?t.orderColor:null,De[j.EZ.orderColor]&&(e[j.EZ.orderColor]=1),De[j.EZ.deliveryDefense]=null!==t&&void 0!==t&&null!==(ce=t.shippingAddress)&&void 0!==ce&&null!==(ue=ce.deliveryDefense)&&void 0!==ue&&ue.score?{score:null===t||void 0===t||null===(ve=t.shippingAddress)||void 0===ve||null===(he=ve.deliveryDefense)||void 0===he?void 0:he.score,weatherData:(null===t||void 0===t?void 0:t.weatherData)||null,preferredRate:(null===t||void 0===t||null===(me=t.firstShipment)||void 0===me?void 0:me.rateInfo)||null,order:t}:null,De[j.EZ.deliveryDefense]&&(e[j.EZ.deliveryDefense]=1),De[j.EZ.weather]=null!==t&&void 0!==t&&null!==(pe=t.firstShipment)&&void 0!==pe&&null!==(we=pe.rateInfo)&&void 0!==we&&we.weather?{weather:null===t||void 0===t||null===(xe=t.firstShipment)||void 0===xe||null===(ge=xe.rateInfo)||void 0===ge?void 0:ge.weather,weatherData:(null===t||void 0===t?void 0:t.weatherData)||null,preferredRate:(null===t||void 0===t||null===(je=t.firstShipment)||void 0===je?void 0:je.rateInfo)||null,order:t}:null,null!==t&&void 0!==t&&null!==(fe=t.firstShipment)&&void 0!==fe&&null!==(ye=fe.rateInfo)&&void 0!==ye&&null!==(Ae=ye.weather)&&void 0!==Ae&&Ae.temp&&(e[j.EZ.weather]=1),De[j.EZ.deliveryMethod]=null===t||void 0===t?void 0:t.deliveryMethod,De[j.EZ.deliveryMethod]&&(e[j.EZ.deliveryMethod]=1),De[j.EZ.coolant]=null===t||void 0===t||null===(Se=t.firstShipment)||void 0===Se?void 0:Se.coolant,De[j.EZ.coolant]&&(e[j.EZ.coolant]=1),De[j.EZ.zip]=null===t||void 0===t||null===(Ce=t.shippingAddress)||void 0===Ce?void 0:Ce.zip,De[j.EZ.zip]&&(e[j.EZ.zip]=1);const Ee=(null===t||void 0===t||null===(ke=t.shipments)||void 0===ke?void 0:ke.length)||0;return De[j.EZ.shipments]=null===t||void 0===t||null===(Ie=t.shipments)||void 0===Ie?void 0:Ie.map((e,l)=>{var s,n;const d={};if(d["Shipment #"]=(0,i.A)((0,i.A)({},t),{},{index:l,shipment:e,totalShipments:Ee}),d.id=e.id,d["Line Items (Qty)"]=(null===e||void 0===e?void 0:e.products)||[],null!==e&&void 0!==e&&null!==(s=e.rateInfo)&&void 0!==s&&s.id){const t=e.estimateTransitTime;d["Rate Info"]="".concat(e.rateInfo.carrier," / ").concat(e.rateInfo.service,": $").concat(e.rateInfo.rate),t&&(d["Rate Info"]+=" - ".concat(t))}return d["Tracking ID"]=null!==e&&void 0!==e&&e.tracking?[e.tracking]:[],null!==e&&void 0!==e&&null!==(n=e.error)&&void 0!==n&&n.shipmentError&&(d.Warnings={title:e.error.shipmentError,val:e.error.shipmentErrorStep,className:"caption secondary-color"}),null!==e&&void 0!==e&&e.pdfsPrinted&&(d.Printed=e.pdfsPrinted),null!==e&&void 0!==e&&e.pickupPrn&&(d["Pickup (PRN)"]=e.pickupPrn),d}),De});return F(e),null!==t&&void 0!==t?t:[]},[f,null===g||void 0===g?void 0:g.tags]),Pe=(0,n.useRef)(null),Fe=(0,n.use
2State)(400),_e=(0,s.A)(Fe,2),Te=_e[0],We=_e[1],Le=(0,n.useState)(!1),Me=(0,s.A)(Le,2),Ue=Me[0],Be=Me[1];(0,n.useEffect)(()=>{const e=()=>{if(!Pe.current)return;const e=Pe.current.getBoundingClientRect(),t=S?64:0,l=ne>1?74:0,i=window.innerHeight-e.top-t-l-16,s=te(),n=s.totalExpandedOrders,d=s.totalExpandedShipments;let o=42*((null===Re||void 0===Re?void 0:Re.length)||1)+50+10;n&&(o+=85*n+42*d);const a=Math.min(o,i);We(Math.max(a,300)),Be(o>i)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[null===Re||void 0===Re?void 0:Re.length,l,S,D,ne,c,N,C]);const Ve=e=>{var t,l,i;return null===e.value||void 0===e.value?"":Array.isArray(e.value)?e.value.map(e=>{var t,l;return e&&Object.keys(e).length?null!==(t=null!==(l=e.val)&&void 0!==l?l:e.code)&&void 0!==t?t:e.name:e}).join(", "):Object.keys(e.value)?null!==(t=e.value.val)&&void 0!==t?t:e.value.orderNumber:null===(l=e.value)||void 0===l||null===(i=l.toString)||void 0===i?void 0:i.call(l)},ze=(0,n.useCallback)((e,t)=>{V(e),L(t)},[]),$e=(0,n.useMemo)(()=>(0,i.A)((0,i.A)({},null===H||void 0===H?void 0:H.defaultColDef),{},{suppressHeaderMenuButton:!0,suppressHeaderContextMenu:!0,headerComponent:Ee,headerComponentParams:{onChooseColumns:ze}}),[null===H||void 0===H?void 0:H.defaultColDef,ze]),Ze={processCellCallback:Ve};return(0,Y.jsxs)("div",{ref:Pe,className:(0,Se.cn)("orders-table",!Ue&&"no-vertical-scroll"),onContextMenu:e=>{e.target.closest(".ag-header")&&e.preventDefault()},children:[(0,Y.jsx)(n.Suspense,{fallback:(0,Y.jsx)("div",{children:"Loading..."}),children:(0,Y.jsx)(Ae.A,{rowData:Re,columnDefs:re,rowSelection:"multiple",height:Te,suppressRowClickSelection:!0,onRowClicked:he,onSelectionChanged:pe,gridOptions:H,defaultColDef:$e,getContextMenuItems:e=>{var t;return null===(t=e.defaultItems)||void 0===t?void 0:t.filter(e=>["copy","export"].includes(e))},suppressCellFocus:!0,suppressSetColumnStateEvents:!1,defaultExcelExportParams:Ze,defaultCsvExportParams:Ze,onGridReady:we,masterDetail:!0,isRowMaster:Ie,processCellForClipboard:Ve,detailCellRendererParams:ce,getRowHeight:xe,onRowGroupOpened:ke,getRowClass:Oe,debug:!Z.KV&&Z.us,suppressBrowserResizeObserver:!0,onSortChanged:ve,enableCellTextSelection:!0,ensureDomOrder:!0,noRowsOverlayComponent:e=>e.loading?null:(0,Y.jsx)("div",{style:{padding:20,textAlign:"center"},children:"No Orders To Show"}),noRowsOverlayComponentParams:{loading:m}})}),W&&(0,Y.jsx)(Ce.A,{gridApi:W,anchorEl:B,onColumnStateChange:G,onClose:()=>{L(null),V(null)}})]})}),Re=Oe;var Pe=l(1505),Fe=l(94332),_e=l(47876),Te=l(72040),We=l(78301),Le=l(4678);const Me=e=>{let t=e.handleSubmit,l=e.disabled,o=e.shipment,a=void 0===o?null:o,r=e.textProps,c=void 0===r?{}:r;const u=(0,n.useState)({custom:"",automatic:!1}),v=(0,s.A)(u,2),h=v[0],m=v[1],p=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user});(0,n.useEffect)(()=>{var e,t,l,i;let s=h.custom||(null!==p&&void 0!==p&&null!==(e=p.declaredValue)&&void 0!==e&&e.automatic||null===p||void 0===p||null===(t=p.declaredValue)||void 0===t||!t.custom?"":"".concat(p.declaredValue.custom));const n=h.automatic||!(null===p||void 0===p||null===(l=p.declaredValue)||void 0===l||!l.automatic);if(null!==a&&void 0!==a&&null!==(i=a.products)&&void 0!==i&&i.length){const e=(0,g.QB)(a.products,a);e&&(s=e)}m({custom:s,automatic:n})},[p,a]);const w=(0,Le.No)({user:p,feature:Le.cc.insurance});return!1===(null===p||void 0===p?void 0:p.overrideUpscInsurance)?null:(0,Y.jsx)(A.ND,{buttonText:"Add Full Coverage",buttonIcon:(0,Y.jsx)(S.ekZ,{className:"tw-mr-2"}),buttonProps:{variant:"text",disabled:l,className:"!tw-h-fit",style:{padding:0}},placement:"top-start",textProps:c,isPaywalled:w,renderMenu:e=>{let s=e.handleClose;return(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col tw-p-4",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-items-center",children:["Full Coverage",(0,Y.jsx)($.A,{information:z.A.INSURANCE})]}),(0,Y.jsx)("div",{className:"tw-my-2",children:(0,Y.jsx)(A.A_,{value:null===h||void 0===h?void 0:h.custom,type:"number",label:(0,Y.jsxs)("label",{className:"tw-leading-none peer-disabled:tw-cursor-not-allowed peer-disabled:tw-opacity-70 tw-block",children:["Declared Value ",(0,Y.jsx)("span",{className:"tw-text-red-500",children:"*"})]}),prefix:"$",style:{maxWidth:"200px",marginBottom:0},disabled:l||!(null===h||void 0===h||!h.automatic),min:1,max:g.xZ,step:1,onChange:e=>{const t=e.target.value;m((0,i.A)((0,i.A)({},h),{},{custom:t}))},labelClassName:"tw-text-sm",className:l||null!==h&&void 0!==h&&h.automatic?"!tw-bg-gray-200 tw-text-black":""})}),(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-space-x-2 tw-mt-1",children:(0,Y.jsx)(A.Sc,{checked:!(null===h||void 0===h||!h.automatic),disabled:l,labelPlacement:"end",label:"Auto-Calculate to Order Value",labelClassName:"tw-text-sm",onChange:()=>{var e;const t=!(null!==h&&void 0!==h&&h.automatic);let l="";if(t&&null!==a&&void 0!==a&&null!==(e=a.products)&&void 0!==e&&e.length){const e=(0,g.QB)(a.products,a);e&&(l=e)}l||(l=h.custom),m((0,i.A)((0,i.A)({},h),{},{automatic:t,custom:l}))},fullWidth:!1})}),(null===h||void 0===h||!h.automatic)&&parseFloat((null===h||void 0===h?void 0:h.custom)||0)>g.xZ?(0,Y.jsx)("p",{className:"tw-p-0 tw-m-0 tw-text-red-600 tw-text-sm",children:ee.lw.INSURANCE_AMOUNT_MAX_EXCEEDED}):null,(null===h||void 0===h||!h.automatic)&&parseFloat((null===h||void 0===h?void 0:h.custom)||0)<=0&&""!==(null===h||void 0===h?void 0:h.custom)?(0,Y.jsx)("p",{className:"tw-p-0 tw-m-0 tw-text-red-600 tw-text-sm",children:ee.lw.INSURANCE_AMOUNT_INVALID}):null,(0,Y.jsx)("div",{className:"tw-mt-4 tw-flex tw-justify-end",children:(0,Y.jsx)(A.$
2n,{color:"primary",onClick:()=>{t(h),s()},size:"small",variant:"contained",disabled:!(null!==h&&void 0!==h&&h.automatic)&&parseFloat((null===h||void 0===h?void 0:h.custom)||0)>g.xZ||!(null!==h&&void 0!==h&&h.automatic)&&!parseFloat((null===h||void 0===h?void 0:h.custom)||0),children:(0,Y.jsx)(S.Jlk,{fontSize:"small"})})})]})}})},Ue=e=>{const t=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user});return!1===(null===t||void 0===t?void 0:t.overrideUpscInsurance)?null:(0,Y.jsx)(Le.L0,{feature:Le.cc.insurance,isClickable:!0,children:(0,Y.jsx)(Me,(0,i.A)({},e))})};var Be=l(80705),Ve=l(71295),ze=l(70929),$e=l(50653);const Ze=e=>{var t;let l=e.active,o=e.handleClose,a=e.handleSubmit,r=e.user,c=e.submitting,u=e.previewData;const v=(0,n.useState)(""),h=(0,s.A)(v,2),p=h[0],w=h[1],x=(0,n.useState)(""),g=(0,s.A)(x,2),j=g[0],f=g[1],y=(0,n.useState)(!1),b=(0,s.A)(y,2),S=b[0],N=b[1],C=(0,n.useState)(!1),k=(0,s.A)(C,2),I=k[0],D=k[1],E=(0,n.useState)(!1),O=(0,s.A)(E,2),R=O[0],P=O[1],F=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.user)||void 0===l?void 0:l.notificationEmail}),_=(0,n.useCallback)(async()=>{D(!0);try{var e,t,l;const s=(await m.Km.get("/template-settings?type=".concat(Ve.I.email,"&statusType=late_shipment"))).data;let n=(0,i.A)({},ze.F4.LATE_SHIPMENT);null!==s&&void 0!==s&&null!==(e=s.templateSettings)&&void 0!==e&&e.length&&(n=(0,i.A)((0,i.A)({},n),s.templateSettings[0])),w(null===(t=n)||void 0===t?void 0:t.message),f(null===(l=n)||void 0===l?void 0:l.subject)}catch(s){console.error(s)}D(!1)},[]);(0,n.useEffect)(()=>{l&&(_(),N(!1))},[l,_]),(0,n.useEffect)(()=>{null!==F&&void 0!==F&&F.email&&null!==F&&void 0!==F&&F.valid&&P(!1)},[F]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A.aF,{open:l,maxWidth:"sm",handleClose:o,contentStyle:{background:"url(".concat(Z.nv,"/Assets/truck-pattern-primary.jpg) center center / cover")},hideActions:!0,hideTitleBar:!0,children:I?(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-justify-center tw-min-h-[600px]",children:(0,Y.jsx)(A.P,{})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-end",children:(0,Y.jsx)("span",{onClick:o,className:"tw-cursor-pointer tw-fill-secondary tw-z-50",children:(0,Y.jsx)(oe.bm,{})})}),(0,Y.jsx)("div",{className:"tw-flex tw-justify-center tw-mx-auto tw-mt-6",children:(0,Y.jsx)("img",{src:(null===r||void 0===r||null===(t=r.logo)||void 0===t?void 0:t.src)||Z.HX,alt:"logo",style:{height:"100%",objectFit:"scale-down",maxHeight:100,maxWidth:200}})}),S&&(0,Y.jsxs)("section",{className:"tw-max-w-md tw-mx-auto tw-w-full tw-mt-10 tw-space-y-4",children:[(0,Y.jsx)(A.A_,{variant:"outlined",value:j,onChange:e=>f(e.target.value),autoFocus:!0,disabled:c,label:"Subject Line",required:!0}),(0,Y.jsx)(A.A_,{variant:"outlined",value:p,onChange:e=>w(e.target.value),multiline:!0,rows:20,disabled:c,label:"Message",required:!0,className:"!tw-min-h-[250px]"}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("strong",{children:"Variables Available:"})," [order_id], [tracking_number_link], [planned_delivery_date], [expected_delivery_date], [customer_name], [company_name]"]})]}),!S&&(0,Y.jsxs)("section",{className:"tw-max-w-md tw-w-full tw-mx-auto tw-mt-6",children:[(0,Y.jsxs)("div",{children:["Subject: ",(0,Y.jsx)("strong",{children:j})]}),(0,Y.jsxs)("div",{className:"tw-bg-white tw-p-6 tw-border tw-border-solid tw-rounded-2xl tw-mt-4",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:j}),(0,Y.jsx)("div",{className:"tw-mt-4",dangerouslySetInnerHTML:{__html:(()=>{var e,t,l,i,s;const n=null===p||void 0===p||null===(e=p.replace(/\[order_id\]/g,u.order_id))||void 0===e||null===(t=e.replace(/\[tracking_number_link\]/g,u.tracking_number_link))||void 0===t||null===(l=t.replace(/\[planned_delivery_date\]/g,u.planned_delivery_date))||void 0===l||null===(i=l.replace(/\[expected_delivery_date\]/g,u.expected_delivery_date))||void 0===i||null===(s=i.replace(/\[company_name\]/g,null===r||void 0===r?void 0:r.companyName))||void 0===s?void 0:s.replace(/\[customer_name\]/g,(null===u||void 0===u?void 0:u.customer_name)||"Test Name");return'<div style="white-space: pre-wrap">'.concat(n,"</div>")})()}})]})]}),(0,Y.jsxs)("div",{className:"tw-max-w-md tw-mx-auto tw-justify-between tw-w-full tw-mt-6 tw-flex tw-mb-4",children:[(0,Y.jsx)(A.$
2n,{loading:c,disabled:c||!p||!j,onClick:()=>{N(!S)},children:S?"Preview":"Edit"}),(0,Y.jsx)(A.$n,{loading:c,disabled:c||!p||!j,onClick:()=>{null!==F&&void 0!==F&&F.email&&null!==F&&void 0!==F&&F.valid?a({notifyMessage:p,notifySubject:j}):P(!0)},variant:"contained",color:"primary",children:"Send"})]})]})}),(0,Y.jsxs)(A.aF,{open:R,maxWidth:"xs",title:"Sender Email Required",handleClose:()=>P(!1),actions:[{label:"Close",onClick:()=>P(!1),variant:"outlined",color:"inherit"}],children:[(0,Y.jsx)("div",{className:"tw-mb-4",children:"A verified sender email is required to send notifications."}),(0,Y.jsx)($e.A,{compact:!0})]})]})};var He=l(8364);const qe=n.memo(e=>{var t,l,a,r,c,p,g;let j=e.setShowBulkEditModal,f=e.handleDeleteFromBatch,y=e.setShowPickupModal,b=e.setOpenBatchModal,C=e.batchId,k=e.setOpenManifest,I=e.isFreight,D=e.theme,E=e.hasPurchaseableShipment;const O=(0,u.useHistory)(),R=(0,d.useDispatch)(),P=(0,ie.A)(),F=P.toastError,_=P.toastSuccess,T=P.toastWarning,W=(0,n.useState)(!1),L=(0,s.A)(W,2),M=L[0],U=L[1],B=(0,n.useState)(!1),V=(0,s.A)(B,2),H=V[0],q=V[1],G=(0,He.J1)().printWithDryIceLabelCheck,K=(0,w.yK)(),Q=K.deselectAllOrders,X=K.getSelectedOrders,J=K.selectAllOrders,te=O.location.search,le=O.location.pathname.includes("/batch"),se=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading}),ne=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),de=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.totalSelectedShipments}),oe=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.progressReport}),ae=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.total}),re=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.allSelectInProgress}),ce=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.allFilterOrdersSelected}),ue=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.orders}),ve=Object.keys((null===oe||void 0===oe||null===(t=oe.bulkEdit)||void 0===t?void 0:t.orderDetails)||{}).length,me=Object.keys((null===oe||void 0===oe||null===(l=oe.bulkBuy)||void 0===l?void 0:l.orderDetails)||{}).length,pe=Object.keys((null===oe||void 0===oe||null===(a=oe.bulkRefund)||void 0===a?void 0:a.orderDetails)||{}).length,we=Object.keys((null===oe||void 0===oe||null===(r=oe.bulkFulfill)||void 0===r?void 0:r.orderDetails)||{}).length,xe=Object.keys((null===oe||void 0===oe||null===(c=oe.bulkStatus)||void 0===c?void 0:c.orderDetails)||{}).length,ge=!!(ve||me||pe||we||xe),je=(0,v.Ay)({history:O}),fe=(null===je||void 0===je?void 0:je.shipmentStatus)||"holding",ye=(null===je||void 0===je?void 0:je.order_filters)||(null===je||void 0===je?void 0:je.search_filters)||(null===je||void 0===je?void 0:je.order_number)||(null===je||void 0===je?void 0:je.custom_filters),be=(0,Le.No)({user:ne,feature:Le.cc.pickup_account_connection}),Ae=(0,o.jL)(ne),Se=(0,o.T4)(null===Ae||void 0===Ae?void 0:Ae.permissionsKeys,[o.I1.PURCHASE_ORDERS]),Ne=(0,o.T4)(null===Ae||void 0===Ae?void 0:Ae.permissionsKeys,[o.I1.EDIT_ORDERS]),Ce=X(),ke=Object.keys(Ce||{});let Ie={order_id:"#1234",tracking_number_link:'<a className="tw-underline tw-text-secondary tw-font-bold" href=\''.concat(Z.GG,"/track?trackId=TEST' target='_blank'>TEST</a>"),planned_delivery_date:"01/24/2026",expected_delivery_date:"01/28/2026"};if(null!==ke&&void 0!==ke&&ke.length&&null!==ue&&void 0!==ue&&ue.length){const e=null===ue||void 0===ue?void 0:ue.find(e=>(null===e||void 0===e?void 0:e._id)===ke[0]);var De,Ee,Oe,Re;if(e)null!==e&&void 0!==e&&e.orderNumber&&(Ie.order_id=e.orderNumber),null!==e&&void 0!==e&&null!==(De=e.firstShipment)&&void 0!==De&&De.trackingCode&&(Ie.tracking_number_link='<a className="tw-underline tw-text-secondary tw-font-bold" href=\''.concat(Z.GG,"/track?trackId=").concat(e.firstShipment.trackingCode,"' target='_blank'>").concat(e.firstShipment.trackingCode,"</a>")),null!==e&&void 0!==e&&null!==(Ee=e.firstShipment)&&void 0!==Ee&&Ee.promisedDeliveryDate&&(Ie.planned_delivery_date=x.d4.utc(e.firstShipment.promisedDeliveryDate).format("MM/DD/YYYY")),null!==e&&void 0!==e&&null!==(Oe=e.firstShipment)&&void 0!==Oe&&Oe.deliveryDate&&(Ie.expected_delivery_date=x.d4.utc(e.firstShipment.deliveryDate).format("MM/DD/YYYY")),null!==e&&void 0!==e&&null!==(Re=e.shippingAddress)&&void 0!==Re&&Re.name&&(Ie.customer_name=e.shippingAddress.name)}const Me=e=>{const t=X(),l=Object.keys(t)||[];R((0,h.mE)({orderIds:l,status:e,onComplete:()=>{Q()}}))},Ve=()=>{const e=X();f(C,e?Object.keys(e):[])},ze=async()=>{try{const e=X();let t=e,l="/shipments/shipments/update-status";if(ce){R((0,h.CW)({allSelectInProgress:!0}));let e=te;e?ye||null!==je&&void 0!==je&&je.shipmentStatus||(e+="&shipmentStatus=holding"):e="?shipmentStatus=holding",l+="".concat(e,"&allFilterOrdersSelected=true")}const s=(await m.Km.post(l,t)).data;(0,d.vA)(()=>{R((0,h.Gg)((0,i.A)({notice:null===s||void 0===s?void 0:s.message},ee.Ay[null!==s&&void 0!==s&&s.status?s.status.toUpperCase():"INFO"]))),R((0,h.N6)(s.updatedProgressReportResult)),R((0,h.CW)({processedOrders:e})),Q()})}catch(e){console.error((null===e||void 0===e?void 0:e.response)||e)}},$e=async e=>{try{const t=X();let l={orderIds:t,fieldsToUpdate:{shouldUpdateInsurance:!0},valuesToUpdate:{selectedInsurance:{amount:null===e||void 0===e?void 0:e.custom,automatic:null===e||void 0===e?void 0:e.automatic}}},s="/orders/update/bulk";if(ce){R((0,h.CW)({allSelectInProgress:!0,loading:!0}));let e=te;e?ye||null!==je&&void 0!==je&&je.shipmentStatus||(e+="&shipmentStatus=holding"):e="?shipmentStatus=holding",s+=e,l.allFilterOrdersSelected=!0}const n=(await m.Dp.post(s,l)).data;(0,d.vA)(()=>{R((0,h.Gg)((0,i.A)({notice:null===n||void 0===n?void 0:n.message},ee.Ay[null!==n&&void 0!==n&&n.status?n.status.toUpperCase():"INFO"]))),R((0,h.N6)(n.updatedProgressReportResult)),R((0,h.CW)({processedOrders:t,loading:!1})),Q()})}catch(t){(0,d.vA)(()=>{var e,l,i;T(null!==(e=null===t||void 0===t||null===(l=t.response)||void 0===l||null===(i=l.data)||void 0===i?void 0:i.message)&&void 0!==e?e:"Failed to edit insurance"),R((0,h.CW)({allSelectInProgress:!0,loading:!1}))})}},qe=(0,n.useCallback)(async e=>{let t=e.notifyMessage,l=e.isPreview,i=void 0!==l&&l,s=e.notifySubject;q(!0);const n=X();try{const e=(await m.Dp.post("/shipments/general-shipments/notify",{selectedOrders:n,notifyMessage:t,findIntegration:!0,isPreview:i,notifySubject:s})).data;_(e.message),i||(Q(),U(!1))}catch(o){var d;F(null!==o&&void 0!==o&&null!==(d=o.response)&&void 0!==d&&d.data||i?"Failed to send test notification email!":"Failed to send notification emails to the customers!")}q(!1)},[X,Q,F,_]),Ge=e=>{const t=Object.keys(X()||{}),l=null===ue||void 0===ue?void 0:ue.filter(e=>t.includes(e._id));G(e,()=>Ke(e),l)},Ke=async e=>{let t=te;if(t?ye||null!==je&&void 0!==je&&je.shipmentStatus||(t+="&shipmentStatus=holding"):t="?shipmentStatus=holding",ce)(async(e,t)=>{try{const l=await m.Km.post("/print-history",{search:t,type:We.R.ORDERS_SERVER,method:We.t.CLIENT,create:e});(0,d.vA)(()=>{R((0,Pe.p8)(null===l||void 0===l?void 0:l.data)),R((0,h.CW)({allSelectInProgress:!0}))});const i=(await m.Km.post("/orders/generatePdf".concat(t))).data,s=Object.keys((null===i||void 0===i?void 0:i.selectedOrders)||{}).length;if(s)return void(0,d.vA)(()=>{R((0,h.CW)({selectedOrders:i.selectedOrders}));let t=0;for(;t<s;)window.open("/orders/orderbulk-pdf?create=".concat(e,"&isBulk=true&startInd=").concat(t,"&endInd=").concat(t+500),"_blank"),t+=
2500;R((0,h.CW)({allSelectInProgress:!1})),Q()});(0,d.vA)(()=>{T((null===i||void 0===i?void 0:i.message)||"No labels to print"),Q()})}catch(l){console.error((null===l||void 0===l?void 0:l.response)||l),(0,d.vA)(()=>{R((0,h.CW)({allSelectInProgress:!1})),F("Failed To Generate PDF"),Q()})}})(e,t);else{const l=X();R((0,h.CW)({selectedOrders:l})),await Fe.q.flush(),await(0,_e.yy)(500),t+="&create=".concat(e,"&isBulk=true"),window.open("/orders/orderbulk-pdf".concat(t),"_blank")}},Ye=()=>{if(ce)Q(),R((0,h.CW)({allFilterOrdersSearch:!1}));else{let e=te;e?ye||null!==je&&void 0!==je&&je.shipmentStatus||(e+="&shipmentStatus=holding"):e="?shipmentStatus=holding",R((0,h.CW)({allFilterOrdersSelected:!0,allFilterOrdersSearch:e})),J()}},Qe="pending"===fe,Xe=!fe||"holding"===fe,Je=Xe||Qe,et="isCancelled"===fe,tt="isDeleted"===fe,lt="archived"===fe||et||tt,it="processing"===fe,st="delivered"===fe,nt=se||re,dt=nt,ot=!le||E,at=!!(de>0||ce);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ze,{user:ne,active:M,handleClose:()=>U(!1),handleSubmit:qe,submitting:H,previewData:Ie}),(0,Y.jsx)(A._s,{anchor:"bottom",variant:"persistent",open:at,PaperProps:{style:{marginLeft:(null===D||void 0===D||null===(p=D.palette)||void 0===p||null===(g=p.appDrawer)||void 0===g?void 0:g.width)||0}},style:{height:at?50:0},children:(0,Y.jsxs)(A.M7,{className:"tw-gap-2",style:{height:"100%"},children:[(0,Y.jsxs)("div",{className:"flex align-items-center tw-gap-2",style:{flex:1},children:[(0,Y.jsx)(A.$n,{edge:"start",color:"error","aria-label":"close",iconButton:!0,onClick:Q,children:(0,Y.jsx)(S.bm,{})}),!ce&&Je&&(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsx)(A.o5,{style:{fontSize:14},children:(0,Y.jsxs)("b",{children:[de," ",1===de?"Shipment":"Shipments"," selected"]})})}),!ce&&!Je&&(0,Y.jsx)(A.o5,{style:{fontSize:14},children:(0,Y.jsxs)("b",{children:[de," ",1===de?"Shipment":"Shipments"," ready to Print"]})}),ce&&(0,Y.jsx)(A.o5,{style:{fontSize:14},children:(0,Y.jsxs)("b",{children:[ae," ",1===ae?"Order":"Orders"," selected"]})}),(0,Y.jsx)("span",{className:"tw-hidden md:tw-inline-flex",children:le?null:(0,Y.jsxs)(A.$n,{variant:"outlined",onClick:Ye,disabled:nt||ge,loading:re,children:[ce?"Deselect":"Select"," All ",ae," Orders"]})})]}),(0,Y.jsx)("div",{className:"md:tw-hidden",children:(0,Y.jsx)(Be.A,{breakAlways:!0,components:[{showCondition:!le,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",onClick:()=>{Ye(),t&&t()},disabled:nt||ge,loading:re,children:[ce?"Deselect":"Select"," All ",ae," Orders"]})})}},{showCondition:!lt&&(ye||Je)&&Se&&ot,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsx)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",onClick:()=>{R((0,h.MX)({showModal:!0})),t&&t()},disabled:dt,loading:se,children:ce?"Purchase Labels":"Purchase ".concat(de," ").concat(1===de?"Label":he.Y5.labels)})})}},{showCondition:it,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{be||y(!0),t&&t()},children:[(0,Y.jsx)(N.A,{className:"tw-size-4",strokeWidth:1})," Schedule Pickup"]})})}},{showCondition:lt&&!et&&!tt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",onClick:()=>{Me(!1),t&&t()},disabled:nt,loading:se,children:[(0,Y.jsx)(S.yKV,{})," Un-archive"]})})}},{showCondition:(ye||!Je)&&!lt,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",onClick:()=>{Ge(he.UG.ALL),t&&t()},disabled:nt,loading:se,children:[(0,Y.jsx)(S.VYo,{})," Download Labels"]})})}},{showCondition:!lt,render:()=>(0,Y.jsx)(A.o5,{className:"tw-px-2 tw-py-1.5 tw-font-semibold tw-text-secondary",children:"Print/Download"})},{showCondition:!lt&&(ye||!Je),render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{Ge(he.UG.LABEL),t&&t()},children:[(0,Y.jsx)(S.VYo,{})," Labels"]})})}},{showCondition:!lt,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{Ge(he.UG.SLIP),t&&t()},children:[(0,Y.jsx)(S.VYo,{})," Packing Slip",de>1?"s":""]})})}},{showCondition:!lt,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{Ge(he.UG.PICK),t&&t()},children:[(0,Y.jsx)(S.VYo,{})," Pick List"]})})}},{showCondition:!lt,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{k(!0),t&&t()},children:[(0,Y.jsx)(S.VYo,{})," Manifest"]})})}},{showCondition:!lt&&ye,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{Ge(he.UG.ALL),t&&t()},children:[(0,Y.jsx)(S.VYo,{})," Labels + Packing Slip",de>1?"s":""]})})}},{render:()=>(0,Y.jsx)(A.o5,{className:"tw-px-2 tw-py-1.5 tw-font-semibold tw-text-secondary",children:"Operations"})},{showCondition:!lt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.fulfill})),t&&t()},children:[(0,Y.jsx)(S.G4r,{})," Mark Fulfilled"]})})}},{showCondition:!lt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.unfulfill})),t&&t()},children:[(0,Y.jsx)(S.JKY,{})," Mark UnFulfilled"]})})}},{showCondition:!lt&&(ye||it)&&Se,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.refund})),t&&t()},children:[(0,Y.jsx)(S.cn_,{})," Cancel / Refund Label"]})})}},{showCondition:!lt&&(ye||!Je)&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{ze(),t&&t()},children:[(0,Y.jsx)(S.rx0,{})," Update Status"]})})}},{showCondition:(!lt||et)&&(ye||Je||et)&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{const e=X();R((0,h.xv)({payload:{renew:!0,orderIds:e,allFilterOrdersSelected:ce},search:te,hasAnyFilter:ye,allQueryParams:je,onComplete:()=>Q()})),t&&t()},children:[(0,Y.jsx)(S.C42,{})," Refresh Rates"]})})}},{showCondition:!lt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.duplicate})),t&&t()},children:[(0,Y.jsx)(S.PMT,{})," Duplicate Orders"]})})}},{showCondition:(!lt&&!Je&&!ye||ye)&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.return})),t&&t()},children:[(0,Y.jsx)(S.oMS,{})," Create Return"]})})}},{showCondition:(Je||ye||et)&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{j(!0),t&&t()},children:[(0,Y.jsx)(S.FkX,{})," Edit Shipments"]})})}},{showCondition:(Qe||ye)&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt||ye,onClick:()=>{R((0,h.py)({type:Te.P.hold,updateHoldDate:!0})),t&&t()},children:[(0,Y.jsx)(S.ZUc,{})," Change Hold Date"]})})}},{showCondition:(Xe||ye)&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt||ye,onClick:()=>{R((0,h.py)({type:Te.P.hold,forceHold:!0})),t&&t()},children:[(0,Y.jsx)(S.qgk,{})," Hold Orders"]})})}},{showCondition:!lt&&!tt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{Me(!0),t&&t()},children:[(0,Y.jsx)(S.Tde,{})," Archive"]})})}},{showCondition:!tt&&!et&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{Me(!1),t&&t()},children:[(0,Y.jsx)(S.yKV,{})," Un-archive"]})})}},{showCondition:(lt||Je&&!ye||st||ye)&&!tt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.delete})),t&&t()},children:[(0,Y.jsx)(S.epd,{})," Delete"]})})}},{showCondition:(lt||Je&&!ye||st||ye)&&tt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.restore})),t&&t()},children:[(0,Y.jsx)(S.epd,{})," Restore"]})})}},{showCondition:!le&&!I&&!tt&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{b(!0),t&&t()},children:[(0,Y.jsx)(S.sk7,{})," Add to Batch"]})})}},{showCondition:le&&!I&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{Ve(),t&&t()},children:[(0,Y.jsx)(S.oS0,{})," Remove from Batch"]})})}},{showCondition:!lt&&(ye||Je)&&Ne,render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsx)(Ue,{disabled:nt,handleSubmit:e=>{$e(e),t&&t()},textProps:{className:"!tw-text-base"}})})}},{render:e=>{let t=e.handleClose;return(0,Y.jsx)("div",{className:"tw-px-2 tw-py-1",children:(0,Y.jsxs)(A.$n,{variant:"text",className:"!tw-w-full !tw-justify-start tw-gap-1",disabled:nt,onClick:()=>{U(!0),t&&t()},children:[(0,Y.jsx)(S.Psq,{})," Send Late Notice"]})})}}]})}),(0,Y.jsxs)("div",{className:"tw-hidden md:tw-flex align-items-center tw-gap-2",style:{height:"100%"},children:[it&&(0,Y.jsx)(Le.L0,{feature:Le.cc.pickup_account_connection,isClickable:!0,children:(0,Y.jsxs)(A.$n,{color:"primary",variant:"contained",className:"tw-gap-1 tw-flex tw-items-center",onClick:()=>{be||y(!0)},disabled:nt,paywalledFeature:Le.cc.pickup_account_connection,children:[(0,Y.jsx)(N.A,{className:"tw-size-4",strokeWidth:1}),"Schedule Pickup"]})}),lt&&!et&&!tt&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.$
2n,{variant:"contained",color:"primary",onClick:()=>Me(!1),disabled:nt,loading:se,style:{minWidth:250,height:36,marginRight:20},children:"Un-archive"})}),(ye||!Je)&&!lt&&(0,Y.jsx)(A.$n,{variant:"contained",color:"secondary",onClick:()=>{Ge(he.UG.ALL)},disabled:nt,loading:se,children:"Download Labels & Packing Slips"}),(0,Y.jsx)(A.ND,{buttonText:"Bulk Actions",btnIconSize:"default",buttonProps:{variant:"outlined",color:"secondary"},renderMenu:e=>{let t=e.handleListKeyDown,l=e.open,i=e.handleClose;return(0,Y.jsxs)(A.cO,{autoFocusItem:l,onKeyDown:t,className:"tw-min-w-52 menu-list-max-height !tw-overflow-auto",children:[!lt&&(0,Y.jsx)(A.o5,{className:"tw-px-2 tw-py-1.5 tw-font-semibold tw-text-secondary",children:"Print/Download"}),!lt&&(ye||!Je)&&(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{Ge(he.UG.LABEL),i()},children:[(0,Y.jsx)(S.VYo,{}),(0,Y.jsx)(A.o5,{children:"Labels"})]}),!lt&&(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{Ge(he.UG.SLIP),i()},children:[(0,Y.jsx)(S.VYo,{}),(0,Y.jsxs)(A.o5,{children:["Packing Slip",de>1?"s":""]})]}),!lt&&(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{Ge(he.UG.PICK),i()},children:[(0,Y.jsx)(S.VYo,{}),(0,Y.jsx)(A.o5,{children:"Pick List"})]}),!lt&&(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{k(!0),i()},children:[(0,Y.jsx)(S.VYo,{}),(0,Y.jsx)(A.o5,{children:"Manifest"})]}),!lt&&ye&&(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{Ge(he.UG.ALL),i()},children:[(0,Y.jsx)(S.VYo,{}),(0,Y.jsxs)(A.o5,{children:["Labels + Packing Slip",de>1?"s":""]})]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)(A.o5,{className:"tw-px-2 tw-py-1.5 tw-font-semibold tw-text-secondary",children:"Operations"}),!lt&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.fulfill})),i()},children:[(0,Y.jsx)(S.G4r,{}),(0,Y.jsx)(A.o5,{children:"Mark Fulfilled"})]})}),!lt&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.unfulfill})),i()},children:[(0,Y.jsx)(S.JKY,{}),(0,Y.jsx)(A.o5,{children:"Mark UnFulfilled"})]})}),!lt&&(ye||it)&&(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.refund})),i()},children:[(0,Y.jsx)(S.cn_,{}),(0,Y.jsx)(A.o5,{children:"Cancel / Refund Label"})]})}),!lt&&(ye||!Je)&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{ze(),i()},children:[(0,Y.jsx)(S.rx0,{}),(0,Y.jsx)(A.o5,{children:"Update Status"})]})}),(!lt||et)&&(ye||Je||et)&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{const e=X();R((0,h.xv)({payload:{renew:!0,orderIds:e,allFilterOrdersSelected:ce},search:te,hasAnyFilter:ye,allQueryParams:je,onComplete:()=>Q()})),i()},children:[(0,Y.jsx)(S.C42,{}),(0,Y.jsx)(A.o5,{children:"Refresh Rates"})]})}),!lt&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.duplicate})),i()},children:[(0,Y.jsx)(S.PMT,{}),(0,Y.jsx)(A.o5,{children:"Duplicate Orders"})]})}),(!lt&&!Je&&!ye||ye)&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.return})),i()},children:[(0,Y.jsx)(S.oMS,{}),(0,Y.jsx)(A.o5,{children:"Create Return"})]})}),(Je||ye||et)&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)("div",{className:"flex",children:[(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{j(!0),i()},style:{width:"100%"},children:[(0,Y.jsx)(S.FkX,{}),(0,Y.jsx)(A.o5,{children:"Edit Shipments"})]}),ye?(0,Y.jsx)($.A,{information:z.A.NOT_ALLOWED_BULK_EDIT,style:{marginLeft:20}}):null]})}),Qe&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)("div",{className:"flex",children:[(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.hold,updateHoldDate:!0})),i()},style:{width:"100%"},children:[(0,Y.jsx)(S.ZUc,{}),(0,Y.jsx)(A.o5,{children:"Change Hold Date"})]}),ye?(0,Y.jsx)($.A,{information:z.A.NOT_ALLOWED_BULK_EDIT,style:{marginLeft:20}}):null]})}),Xe&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)("div",{className:"flex",children:[(0,Y.jsx)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.hold,forceHold:!0})),i()},style:{width:"100%"},children:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S.qgk,{}),(0,Y.jsx)(A.o5,{children:"Hold Orders"})]})}),ye?(0,Y.jsx)($.A,{information:z.A.NOT_ALLOWED_BULK_EDIT,style:{marginLeft:20}}):null]})}),!lt&&!tt&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{Me(!0),i()},children:[(0,Y.jsx)(S.Tde,{}),(0,Y.jsx)(A.o5,{children:"Archive"})]})}),!tt&&!et&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{Me(!1),i()},children:[(0,Y.jsx)(S.yKV,{}),(0,Y.jsx)(A.o5,{children:"Un-archive"})]})}),(lt||Je&&!ye||st||ye)&&!tt&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.delete})),i()},children:[(0,Y.jsx)(S.epd,{}),(0,Y.jsx)(A.o5,{children:"Delete"})]})}),(lt||Je&&!ye||st||ye)&&tt&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{R((0,h.py)({type:Te.P.restore})),i()},children:[(0,Y.jsx)(S.epd,{}),(0,Y.jsx)(A.o5,{children:"Restore"})]})}),it&&(0,Y.jsx)(Le.L0,{feature:Le.cc.pickup_account_connection,isClickable:!0,children:(0,Y.jsx)(A.Dr,{disabled:nt,onClick:()=>{be||(y(!0),i())},paywalledFeature:Le.cc.pickup_account_connection,children:(0,Y.jsxs)("div",{className:"tw-flex tw-gap-2 tw-items-center",children:[(0,Y.jsx)(N.A,{className:"tw-size-4",strokeWidth:1}),(0,Y.jsx)(A.o5,{children:"Schedule Pickup"})]})})}),le||I||tt?null:(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{b(!0),i()},children:[(0,Y.jsx)(S.sk7,{}),(0,Y.jsx)(A.o5,{children:"Add to Batch"})]})}),le&&!I?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>{Ve(),i()},children:[(0,Y.jsx)(S.oS0,{}),(0,Y.jsx)(A.o5,{children:"Remove from Batch"})]})}):null,!lt&&(ye||Je)&&(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.Dr,{disabled:nt,children:(0,Y.jsx)(Ue,{disabled:nt,handleSubmit:e=>{$e(e),i()},textProps:{className:"!tw-text-base"}})})}),(0,Y.jsxs)(A.Dr,{disabled:nt,onClick:()=>U(!0),children:[(0,Y.jsx)(S.Psq,{}),(0,Y.jsx)(A.o5,{children:"Send Late Notice"})]})]})]})}}),!lt&&(ye||Je)&&ot&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsx)(A.$
2n,{variant:"contained",onClick:()=>R((0,h.MX)({showModal:!0})),disabled:dt,loading:se,color:"success",children:ce?"Purchase Labels":"Purchase ".concat(de," ").concat(1===de?"Label":he.Y5.labels)})})})]})]})})]})},(e,t)=>e.theme.palette.type===t.theme.palette.type);var Ge=l(39348);const Ke=()=>{var e;const t=(0,d.useDispatch)(),l=(0,u.useHistory)(),i=(0,v.Ay)({history:l}),s=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.shipmentCountsByStatus)||{}}),n=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading}),o=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.shipmentCountsLoading}),a=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.gridApi}),r=(0,Ge.A)().width,c=[{shipmentStatus:"holding",text:"New",hide:!1,color:"blue",colorIntensity:200},{shipmentStatus:"pending",text:"On Hold",hide:r<385,color:"lime",colorIntensity:200},{shipmentStatus:"processing",text:"Awaiting Shipment",hide:r<500,color:"red",colorIntensity:200},{shipmentStatus:"in_transit",text:"In Transit",hide:r<640,color:"orange",colorIntensity:200},{shipmentStatus:"out_for_delivery",text:"Out for delivery",hide:r<680,color:"purple",colorIntensity:200},{shipmentStatus:"delivered",text:"Delivered",hide:r<990,color:"green",colorIntensity:200},{shipmentStatus:"error",text:"Error",hide:r<1050,color:"yellow",colorIntensity:200},{shipmentStatus:"archived",text:"Archived",hide:r<1160,color:"gray",colorIntensity:200},{shipmentStatus:"return_to_sender",text:"Returned",hide:!0,color:"red",colorIntensity:100},{shipmentStatus:"failure",text:"Failed to Deliver",hide:!0,color:"red",colorIntensity:300},{shipmentStatus:"isCancelled",text:"Canceled",hide:!0,color:"red",colorIntensity:400},{shipmentStatus:"isDeleted",text:"Deleted",hide:!0,color:"red",colorIntensity:500}],m=!(null===i||void 0===i||null===(e=i.custom_filters)||void 0===e||!e.deliveryStatus),p=(e,s,d)=>{var o,r,c,u;if(n)return;if(t((0,h.CW)({restoreGrid:!0})),e.preventDefault(),((null===i||void 0===i||!i.shipmentStatus)&&"holding"===s||d)&&!m)return;let v=[];
2Object.keys(i).forEach(e=>{["shipmentStatus","page","order_number","search_filters","order_filters","custom_filters"].includes(e)||v.push("".concat(e,"=").concat(encodeURIComponent(i[e])))}),v.push("shipmentStatus=".concat(encodeURIComponent(s))),v.push("page=1"),sessionStorage.setItem("resetGridFilters",!0),null===a||void 0===a||null===(o=a())||void 0===o||null===(r=o.setFilterModel)||void 0===r||r.call(o,{}),null===a||void 0===a||null===(c=a())||void 0===c||null===(u=c.onFilterChanged)||void 0===u||u.call(c),l.push("".concat(l.location.pathname,"?").concat(v.join("&")))},w=c.filter(e=>!e.hide),x=c.filter(e=>e.hide),g=x.reduce((e,t)=>e+(s[t.shipmentStatus]||0),0);return(0,Y.jsxs)("div",{className:"tw-flex tw-divide-x tw-divide-gray-200 tw-divide-solid tw-w-full ",children:[w.map((e,t)=>((e,t)=>{let l=e.shipmentStatus,n=e.text,d=e.color,a=e.colorIntensity;const r=s[l]||0,c=(!(null!==i&&void 0!==i&&i.shipmentStatus)&&"holding"===l||(null===i||void 0===i?void 0:i.shipmentStatus)===l)&&!m;return(0,Y.jsxs)("div",{className:"tw-px-4 tw-py-2 tw-flex tw-flex-col tw-justify-center tw-border-y-0\n tw-flex-auto tw-text-center tw-cursor-pointer tw-transition-colors tw-duration-300 hover:tw-bg-".concat(d,"-50\n ").concat(c?"tw-bg-".concat(d,"-50"):"","\n ").concat(0===t?"tw-rounded-tl-2xl":"","\n "),onClick:e=>p(e,l,c),children:[(0,Y.jsx)("div",{style:{fontSize:15},className:"tw-text-base",children:n}),(0,Y.jsx)("div",{className:"tw-mt-1 tw-flex tw-justify-center",children:(0,Y.jsx)("div",{className:"tw-rounded tw-p-1 !tw-text-xs tw-bg-".concat(d,"-").concat(a," tw-w-fit ").concat(o?"tw-animate-pulse tw-min-w-[24px]":""),children:o?"\xa0":(r||0).toLocaleString("en-US")})})]},l)})(e,t)),(0,Y.jsxs)("div",{className:"tw-px-4 tw-py-2 tw-flex tw-flex-col tw-justify-center tw-items-center tw-border-y-0 tw-flex-auto tw-text-center",children:[(0,Y.jsx)(A.ND,{buttonText:"More",paperProps:{className:"tw-rounded-2xl"},popperProps:{className:"tw-rounded-2xl"},buttonProps:{size:"small",disableTouchRipple:!0,variant:"text",className:"focus:!tw-border-none !tw-p-0 !tw-pb-1 hover:!tw-text-black !tw-gap-1",style:{backgroundColor:"#fff",boxShadow:"none",padding:"0 !important",width:50}},renderMenu:e=>{e.handleClose;return(0,Y.jsx)(A.cO,{className:"menu-list-max-height",children:x.map((e,t)=>(e=>{let t=e.shipmentStatus,l=e.text,n=e.color,d=e.colorIntensity;const a=s[t]||0,r=!(null!==i&&void 0!==i&&i.shipmentStatus)&&"holding"===t||(null===i||void 0===i?void 0:i.shipmentStatus)===t;return(0,Y.jsxs)(A.Dr,{className:"tw-justify-between tw-gap-2 ".concat(r?"!tw-bg-primary-light":""),onClick:e=>p(e,t,r),children:[(0,Y.jsx)(A.o5,{children:l}),(0,Y.jsx)("div",{className:"tw-rounded tw-px-2 tw-py-1 !tw-text-xs tw-bg-".concat(n,"-").concat(d," tw-w-fit ").concat(o?"tw-animate-pulse tw-min-w-[24px]":""),children:o?" ":(a||0).toLocaleString("en-US")})]},t)})(e))})}})," ",(0,Y.jsx)("div",{className:"tw-rounded tw-p-1 !tw-text-xs tw-bg-red-200 tw-w-fit ".concat(o?"tw-animate-pulse tw-min-w-[24px]":""),children:o?" ":(g||0).toLocaleString("en-US")})]})]})},Ye=()=>{const e=(0,n.useRef)(null),t=(0,n.useState)(!1),l=(0,s.A)(t,2),i=l[0],d=l[1];return(0,n.useEffect)(()=>{var t;i&&(null===(t=e.current)||void 0===t||t.focus(),d(!1))},[i]),(0,Y.jsx)("div",{children:(0,Y.jsx)("div",{className:"tw-flex tw-items-center",children:(0,Y.jsx)(Ke,{})})})};var Qe=l(11309),Xe=l(91631),Je=l(11582);const et=e=>{let t=e.stroke,l=void 0===t?"#fff":t,i=e.transform,s=void 0===i?"translate(0.000000,500.000000) scale(0.100000,-0.100000)":i,n=e.width,d=void 0===n?"500.000000pt":n,o=e.height,a=void 0===o?"500.000000pt":o,r=e.viewBox,u=void 0===r?"0 0 500.000000 500.000000":r,v=e.isDisabled,h=void 0!==v&&v;const m=(0,c.A)();let p=l;return"#fff"===l&&(p="light"===m.palette.type?"#373737":"#fff"),h&&(p="rgba(80, 87, 99, 0.4)"),(0,Y.jsx)("svg",{version:"1.0",xmlns:"http://www.w3.org/2000/svg",width:d,height:a,viewBox:u,preserveAspectRatio:"xMidYMid meet",children:(0,Y.jsxs)("g",{transform:s,fill:p,stroke:"none",children:[(0,Y.jsx)("path",{d:"M2915 4354 c-122 -22 -240 -61 -350 -116 -151 -76 -276 -172 -384\n-298 -54 -63 -59 -66 -87 -57 -16 6 -112 11 -214 11 -172 1 -192 -1 -283 -26\n-354 -99 -637 -363 -753 -701 -32 -93 -51 -191 -60 -310 l-7 -95 -41 -12 c-22\n-7 -75 -29 -117 -50 -313 -154 -529 -437 -600 -785 -16 -78 -16 -313 0 -390\n21 -104 61 -217 107 -306 157 -303 446 -516 782 -574 129 -23 2914 -22 3047 0\n252 43 473 156 662 338 183 177 305 401 359 662 23 110 23 352 0 460 -72 336\n-259 618 -529 799 l-81 54 3 139 c3 217 -37 400 -129 583 -183 362 -512 605\n-914 675 -109 19 -303 18 -411 -1z m423 -314 c348 -84 619 -356 703 -707 18\n-76 20 -109 16 -238 -4 -125 -9 -163 -31 -230 -14 -44 -22 -83 -18 -86 4 -4\n25 -12 47 -19 71 -22 208 -98 280 -155 472 -376 472 -1084 -1 -1465 -96 -76\n-233 -144 -358 -175 l-99 -25 -1444 0 c-1601 0 -1510 -4 -1661 66 -170 78\n-317 222 -390 384 -52 115 -66 189 -66 330 0 155 18 231 85 360 133 257 397\n420 679 420 l78 0 -18 49 c-121 317 -4 697 277 897 76 55 186 106 278 129 154\n39 362 16 507 -55 l59 -28 14 36 c29 68 124 197 197 268 125 121 256 196 423\n239 122 32 320 34 443 5z"}),(0,Y.jsx)("path",{d:"M2321 3105 c-196 -44 -335 -119 -473 -253 -153 -149 -252 -343 -273\n-539 -3 -32 -8 -73 -11 -90 l-5 -33 -150 0 c-90 0 -149 -4 -147 -9 2 -6 104\n-145 228 -310 210 -280 226 -299 242 -283 9 9 114 148 233 307 l217 290 -156\n3 c-179 3 -165 -8 -142 114 36 190 163 360 331 442 97 49 173 66 285 66 102 0\n191 -20 269 -59 23 -12 46 -21 51 -19 16 6 181 231 177 241 -6 19 -148 85\n-242 113 -113 33 -329 43 -434 19z"}
2),(0,Y.jsx)("path",{d:"M3048 2498 l-227 -303 156 -3 156 -3 -6 -52 c-19 -159 -73 -273 -182\n-383 -90 -91 -142 -125 -248 -161 -145 -49 -314 -39 -455 27 -36 17 -66 29\n-67 28 -1 -2 -43 -58 -93 -125 l-92 -122 32 -18 c95 -50 162 -77 248 -100 80\n-22 116 -26 230 -26 201 0 348 43 515 152 219 143 385 408 410 656 3 33 8 75\n11 92 l5 32 150 3 150 3 -227 303 c-124 166 -229 302 -233 302 -3 0 -108 -136\n-233 -302z"})]})})},tt=e=>{let t=e.stroke,l=void 0===t?"#fff":t,i=e.transform,s=void 0===i?"translate(0.000000,500.000000) scale(0.100000,-0.100000)":i,n=e.width,d=void 0===n?"500.000000pt":n,o=e.height,a=void 0===o?"500.000000pt":o,r=e.viewBox,u=void 0===r?"0 0 500.000000 500.000000":r,v=e.isDisabled,h=void 0!==v&&v;const m=(0,c.A)();let p=l;return"#fff"===l&&(p="light"===m.palette.type?"#373737":"#fff"),h&&(p="rgba(80, 87, 99, 0.4)"),(0,Y.jsx)("svg",{version:"1.0",xmlns:"http://www.w3.org/2000/svg",width:d,height:a,viewBox:u,preserveAspectRatio:"xMidYMid meet",children:(0,Y.jsxs)("g",{transform:s,fill:p,stroke:"none",children:[(0,Y.jsx)("path",{d:"M2915 4354 c-122 -22 -240 -61 -350 -116 -151 -76 -276 -172 -384\n-298 -54 -63 -59 -66 -87 -57 -16 6 -112 11 -214 11 -172 1 -192 -1 -283 -26\n-354 -99 -637 -363 -753 -701 -32 -93 -51 -191 -60 -310 l-7 -95 -41 -12 c-22\n-7 -75 -29 -117 -50 -313 -154 -529 -437 -600 -785 -16 -78 -16 -313 0 -390\n21 -104 61 -217 107 -306 157 -303 446 -516 782 -574 129 -23 2914 -22 3047 0\n252 43 473 156 662 338 183 177 305 401 359 662 23 110 23 352 0 460 -72 336\n-259 618 -529 799 l-81 54 3 139 c3 217 -37 400 -129 583 -183 362 -512 605\n-914 675 -109 19 -303 18 -411 -1z m423 -314 c348 -84 619 -356 703 -707 18\n-76 20 -109 16 -238 -4 -125 -9 -163 -31 -230 -14 -44 -22 -83 -18 -86 4 -4\n25 -12 47 -19 71 -22 208 -98 280 -155 472 -376 472 -1084 -1 -1465 -96 -76\n-233 -144 -358 -175 l-99 -25 -1444 0 c-1601 0 -1510 -4 -1661 66 -170 78\n-317 222 -390 384 -52 115 -66 189 -66 330 0 155 18 231 85 360 133 257 397\n420 679 420 l78 0 -18 49 c-121 317 -4 697 277 897 76 55 186 106 278 129 154\n39 362 16 507 -55 l59 -28 14 36 c29 68 124 197 197 268 125 121 256 196 423\n239 122 32 320 34 443 5z"}),(0,Y.jsx)("path",{d:"M1822 2887 c-67 -67 -112 -120 -112 -132 0 -13 104 -124 285 -305\nl285 -285 -285 -285 c-186 -185 -285 -292 -285 -305 0 -27 218 -245 245 -245\n13 0 123 102 305 285 l285 285 285 -285 c181 -181 293 -285 306 -285 26 0 244\n219 244 245 0 13 -101 121 -280 300 -154 154 -280 284 -280 290 0 6 126 136\n280 290 182 182 280 287 280 300 0 25 -218 245 -242 245 -9 0 -146 -128 -305\n-284 l-288 -285 -285 285 c-184 183 -292 284 -305 284 -13 0 -64 -44 -133\n-113z"})]})})},lt=e=>{var t,l,i,s,n;let a=e.curShipment,r=e.validateForm,c=e.submitForm,v=e.values,m=e.isLoading,p=e.isEdited,w=e.isEditable,x=e.setIsEdited,g=e.resetForm,j=e.setErrors,f=e.setCurrentShipmentIndex,y=e.editOrderPage,b=e.purchaseDisabled,N=e.isAnyShipmentPurchasable,C=e.isValidShippingAddress,k=e.setShowAddressConfirmationModal,I=e.setShowRatesModal,D=e.renderInMenu,E=void 0!==D&&D,O=e.onMenuItemClick;const R=(0,d.useDispatch)(),P=(0,u.useHistory)(),F=(0,Ge.A)().width<768,_=(0,He.J1)().printWithDryIceLabelCheck,T=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.originalEditOrderRef}),W=((null===v||void 0===v?void 0:v.shipments)||[]).some(e=>null===e||void 0===e?void 0:e.label),L=((null===v||void 0===v?void 0:v.shipments)||[]).some(e=>"On Hold"===(null===e||void 0===e?void 0:e.status)),M=((null===v||void 0===v?void 0:v.shipments)||[]).some(e=>{var t;return(null===e||void 0===e?void 0:e.isRefundable)&&(null===e||void 0===e||null===(t=e.label)||void 0===t?void 0:t.easyPostPurchase)}),U=e=>{_(e,()=>{window.open("/orders/orderbulk-pdf?orderIds=".concat(v._id,"&create=").concat(e),"_blank")},[v])},V=null!==a&&void 0!==a&&null!==(t=a.label)&&void 0!==t&&t.nashPurchase?"Confirmation":"Label",z=()=>null===O||void 0===O?void 0:O();var $,Z,H,q,G;return E?(0,Y.jsxs)(Y.Fragment,{children:[w?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-min-h-0","data-cy":"hold-order-menu-item",disabled:m||!w,onClick:()=>{R((0,h.py)({type:Te.P.hold,order:v,updateHoldDate:!0})),z()},children:L?"Change Hold Date":"Hold"})}):null,p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-min-h-0",disabled:m||!w,onClick:()=>{(()=>{var e;if(g(),x(!1),f(0),R((0,h.CW)({editOrderRef:T})),null!==v&&void 0!==v&&null!==(e=v.shipments)&&void 0!==e&&e.length){const e=v.shipments[0];if(e.id===(null===a||void 0===a?void 0:a.id))return;const t="".concat(P.location.pathname).concat(P.location.search);P.push("".concat(t,"#").concat(v._id).concat(null!==e&&void 0!==e&&e.id?"-".concat(e.id):""))}})(),z()},children:"Reset Changes"})}),(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-min-h-0",disabled:m||!w&&N,onClick:()=>{(()=>{var e;C?N||w||null!==v&&void 0!==v&&null!==(e=v.deletedShipments)&&void 0!==e&&e.length?r().then(e=>{(0,B.sq)(e,v,j,R)||c()}):R((0,h.CW)({editOrderPage:"rates",showSaturdayModal:!0})):k(!0)})(),z()},children:["Update Shipment",1!==(null===v||void 0===v||null===($=v.shipments)||void 0===$?void 0:$.length)?"s":""]})})]}):null,M?(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-min-h-0",disabled:m||p,onClick:()=>{R((0,h.py)({type:Te.P.refund,order:v})),z()},children:["Refund ",V,1!==(null===v||void 0===v||null===(Z=v.shipments)||void 0===Z?void 0:Z.length)?"s":""]})}):null,null!==a&&void 0!==a&&a.isFulfillable?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-min-h-0",disabled:m,onClick:()=>{R((0,h.py)({type:Te.P.fulfill,order:v})),z()},children:["Fulfill Shipment",1!==(null===v||void 0===v||null===(H=v.shipments)||void 0===H?void 0:H.length)?"s":""]})}):null,null!==a&&void 0!==a&&a.isUnFulfillable?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.Dr,{className:"!tw-py-1.5 !tw-min-h-0",disabled:m,onClick:()=>{R((0,h.py)({type:Te.P.unfulfill,order:v})),z()},children:["Unfulfill Shipment",1!==(null===v||void 0===v||null===(q=v.shipments)||void 0===q?void 0:q.length)?"s":""]})}):null,N&&"rates"===y?(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-min-h-0","data-cy":"purchase-label-menu-item",disabled:b,onClick:()=>{null!==a&&void 0!==a&&a.isFulfilledFromOutside?I(!0):R((0,h.MX)({showModal:!0,order:v,onComplete:()=>x(!1)})),z()},children:1!==(null===v||void 0===v||null===(G=v.shipments)||void 0===G?void 0:G.length)?"Purchase All Labels":"Purchase Label"})}):null]}):(0,Y.jsxs)("div",{className:"tw-flex tw-justify-center tw-items-center",children:[(0,Y.jsxs)("div",{className:"tw-hidden md:tw-flex md:tw-items-center",children:[w?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.$
2n,{onClick:()=>R((0,h.py)({type:Te.P.hold,order:v,updateHoldDate:!0})),disabled:m||!w,style:{marginRight:10},"data-cy":"hold-order-button",size:F?"small":"medium",children:L?"Change Hold Date":"Hold"})}):null,p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.$n,{size:F?"small":"medium",onClick:()=>{var e;if(g(),x(!1),f(0),R((0,h.CW)({editOrderRef:T})),null!==v&&void 0!==v&&null!==(e=v.shipments)&&void 0!==e&&e.length){const e=v.shipments[0];if(e.id===(null===a||void 0===a?void 0:a.id))return;const t="".concat(P.location.pathname).concat(P.location.search);P.push("".concat(t,"#").concat(v._id).concat(null!==e&&void 0!==e&&e.id?"-".concat(e.id):""))}},variant:"contained",color:"error",style:{marginRight:10},disabled:m||!w,children:"Reset Changes"})}),(()=>{var e;return(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.$n,{size:F?"small":"medium",onClick:()=>{var e;C?N||w||null!==v&&void 0!==v&&null!==(e=v.deletedShipments)&&void 0!==e&&e.length?r().then(e=>{(0,B.sq)(e,v,j,R)||c()}):R((0,h.CW)({editOrderPage:"rates",showSaturdayModal:!0})):k(!0)},variant:"contained",color:"primary",disabled:m||!w&&N,loading:m,style:{marginRight:10},children:[(0,Y.jsx)(S.C42,{style:{marginRight:5,fontSize:22}}),(0,Y.jsxs)("span",{className:"flex align-items-baseline",children:["Update Shipment",1!==(null===v||void 0===v||null===(e=v.shipments)||void 0===e?void 0:e.length)?"s":""]})]})})})()]}):null,M?(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsx)(A.$n,{size:F?"small":"medium",onClick:()=>R((0,h.py)({type:Te.P.refund,order:v})),disabled:m||p,style:{marginRight:10},variant:"outlined",color:"error",children:(0,Y.jsxs)("span",{className:"flex align-items-baseline",children:["Refund ",V,1!==(null===v||void 0===v||null===(l=v.shipments)||void 0===l?void 0:l.length)?"s":""]})})}):null,null!==a&&void 0!==a&&a.isFulfillable?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.$n,{onClick:()=>R((0,h.py)({type:Te.P.fulfill,order:v})),size:F?"small":"medium",disabled:m,style:{marginRight:10},variant:"outlined",color:"secondary",children:(0,Y.jsxs)("span",{className:"flex align-items-baseline",children:["Fulfill Shipment",1!==(null===v||void 0===v||null===(i=v.shipments)||void 0===i?void 0:i.length)?"s":""]})})}):null,null!==a&&void 0!==a&&a.isUnFulfillable?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.$n,{size:F?"small":"medium",onClick:()=>R((0,h.py)({type:Te.P.unfulfill,order:v})),disabled:m,style:{marginRight:10},variant:"outlined",color:"secondary",children:(0,Y.jsxs)("span",{className:"flex align-items-baseline",children:["Unfulfill Shipment",1!==(null===v||void 0===v||null===(s=v.shipments)||void 0===s?void 0:s.length)?"s":""]})})}):null,N&&"rates"===y?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsx)(A.$n,{onClick:()=>{null!==a&&void 0!==a&&a.isFulfilledFromOutside?I(!0):R((0,h.MX)({showModal:!0,order:v,onComplete:()=>x(!1)}))},size:F?"small":"medium",variant:"contained",disabled:b,color:"success","data-cy":"purchase-label-button",style:{marginRight:10},children:(0,Y.jsx)("span",{className:"flex align-items-baseline",children:1!==(null===v||void 0===v||null===(n=v.shipments)||void 0===n?void 0:n.length)?"Purchase All Labels":"Purchase Label"})})})}):null]}),W?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(A.ND,{buttonText:"Print",textStyle:{textTransform:"none"},textProps:{variant:"button"},disablePortal:!0,buttonProps:{disabled:m||p,className:"!tw-bg-lavender tw-mr-2"},renderMenu:e=>{var t,l,i,s,n,d,o,a;let r=e.handleListKeyDown,c=e.open;return(0,Y.jsxs)(A.cO,{autoFocusItem:c,onKeyDown:r,children:[(0,Y.jsx)(A.Dr,{onClick:()=>{U(he.UG.ALL)},disabled:!(null!==v&&void 0!==v&&null!==(t=v.shipments)&&void 0!==t&&t.length),children:(0,Y.jsxs)("span",{className:"flex align-items-baseline",children:[V,1!==(null===v||void 0===v||null===(l=v.shipments)||void 0===l?void 0:l.length)?"s":""," + Packing Slip",1!==(null===v||void 0===v||null===(i=v.shipments)||void 0===i?void 0:i.length)?"s":""]})}),(0,Y.jsx)(A.Dr,{onClick:()=>{U(he.UG.LABEL)},disabled:!(null!==v&&void 0!==v&&null!==(s=v.shipments)&&void 0!==s&&s.length),children:(0,Y.jsxs)("span",{className:"flex align-items-baseline",children:[V,1!==(null===v||void 0===v||null===(n=v.shipments)||void 0===n?void 0:n.length)?"s":""]})}),(0,Y.jsx)(A.Dr,{onClick:()=>{U(he.UG.SLIP)},disabled:!(null!==v&&void 0!==v&&null!==(d=v.shipments)&&void 0!==d&&d.length),children:(0,Y.jsxs)("span",{className:"flex align-items-baseline",children:["Packing Slip",1!==(null===v||void 0===v||null===(o=v.shipments)||void 0===o?void 0:o.length)?"s":""]})}),(0,Y.jsx)(A.Dr,{onClick:()=>{U(he.UG.PICK)},disabled:!(null!==v&&void 0!==v&&null!==(a=v.shipments)&&void 0!==a&&a.length),children:"Pick List"})]})}})}):null]})};var it=l(28849);const st=e=>{let t=e.isConnected,l=e.show,o=e.order,a=e.onClose;
2const r=(0,d.useDispatch)(),c=(0,n.useState)(!1),u=(0,s.A)(c,2),v=u[0],p=u[1];return(0,Y.jsxs)(A.aF,{open:l,maxWidth:"xs",title:"Confirm Order ".concat(t?"Disconnection":"Connection"," With Store"),handleClose:a,actions:[{isClose:!0,loading:v,disabled:v},{isPrimary:!0,onClick:async()=>{let e=o.shopDomain;o.platformType===J.hb.shopify&&(e=(0,ce.w$)(e),e="https://".concat(e,".myshopify.com"));try{p(!0);const l=(await m.Km.post("/orders/update/connection/".concat(o.orderId,"?orderTransformation=").concat(it.d4.BOTH),{shopDomain:e,platformType:o.platformType,shouldConnect:!t})).data;(0,d.vA)(()=>{r((0,h.CW)({editOrderRef:l.detailOrder})),r((0,h.j9)({order:l.listOrder}))})}catch(g){var l,s,n,c,u,v,w,x;r((0,h.Gg)((0,i.A)((0,i.A)({},ee.Ay[null!==g&&void 0!==g&&null!==(l=g.response)&&void 0!==l&&null!==(s=l.data)&&void 0!==s&&s.status?null===g||void 0===g||null===(n=g.response)||void 0===n||null===(c=n.data)||void 0===c||null===(u=c.status)||void 0===u?void 0:u.toUpperCase():"ERROR"]),{},{notice:(null===g||void 0===g||null===(v=g.response)||void 0===v||null===(w=v.data)||void 0===w?void 0:w.message)||(null===g||void 0===g||null===(x=g.response)||void 0===x?void 0:x.data)||(null===g||void 0===g?void 0:g.message)||"Error Importing Order"})))}finally{null===a||void 0===a||a(),p(!1)}},label:t?"Disconnect":"Connect",loading:v,disabled:v}],children:[(0,Y.jsxs)(A.o5,{children:["Are you sure you want to ",t?"disconnect":"connect"," with store?"]}),!t&&(0,Y.jsx)(A.o5,{children:"The current changes in order will be overwritten"})]})};var nt=l(76077);const dt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=[],l=new Set;return e.forEach(e=>{if(null!==e&&void 0!==e&&e.message)if(function(){return/invalid\s+(recipient\s+|sender\s+|shipping\s+|delivery\s+)?address/i.test(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}(e.message)){if(l.has(e.message))return;l.add(e.message),t.push({message:e.message,showCarrier:!1})}else t.push({message:e.message,carrier:e.carrier,showCarrier:!0})}),t},ot=e=>{let t=e.errorObject,l=e.isOrder,i=void 0===l?null:l,s=e.isShipment,d=void 0===s?null:s,o=e.isFromAddress,a=void 0===o?null:o,r=e.isToAddress,c=void 0===r?null:r,u=e.isWeight,v=void 0===u?null:u,h=e.className,m=void 0===h?"":h,p=e.shipment,w=e.shipmentErrors,x=void 0===w?[]:w,g=e.carrierErrors,j=void 0===g?[]:g,f=e.values,y=e.editOrderPage,b=void 0===y?"":y,A=e.hideSuggestions,N=void 0!==A&&A;const C=((e,t,l)=>{var i,s;return!!e.length&&(!(null===l||void 0===l||null===(i=l.shipments)||void 0===i?void 0:i.some(e=>{var t;return null===(t=e.label)||void 0===t?void 0:t.trackingCode}))&&(!!(null===l||void 0===l||null===(s=l.shipments)||void 0===s?void 0:s.some(e=>{var t;return!(null!==e&&void 0!==e&&null!==(t=e.allRates)&&void 0!==t&&t.length)}))||"rates"===t))})(j,b,f);if(null===t||void 0===t||!t.message){var k;if(i&&(null===x||void 0===x||null===(k=x.filter(e=>null===e||void 0===e?void 0:e.message))||void 0===k||!k.length)&&!C)return null;if(!i)return null}const I=(0,Ne.Ar)({errorObject:t,isOrder:i,isFromAddress:a,isToAddress:c,isWeight:v,isShipment:d});return I?I===Ne.LY.isOrder?(0,Y.jsxs)("div",{className:(0,Se.cn)("tw-py-2 tw-rounded-lg tw-text-red-600 tw-bg-red-200 tw-px-4 tw-flex tw-gap-6 tw-items-center",m),children:[(0,Y.jsx)("div",{children:(0,Y.jsx)(S.N5l,{className:"tw-fill-red-600",height:30,width:30})}),(0,Y.jsxs)("div",{className:"tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-lg tw-font-medium",children:Ne.HG[null===t||void 0===t?void 0:t.step]||"Errors"}),(0,Y.jsxs)("ul",{className:"tw-list-disc tw-list-inside tw-pl-0 tw-mt-0 tw-mb-0",children:[null!==t&&void 0!==t&&t.message?(0,Y.jsx)("li",{children:(0,Ne.QX)({errorObject:t})}):null,(null===x||void 0===x?void 0:x.length)>0&&!C?x.map((e,t)=>{if(null===e||void 0===e||!e.message)return null;const l=(0,Ne.Ar)({errorObject:e,isToAddress:!0}),i=(0,Ne.Ar)({errorObject:e,isFromAddress:!0});return(l||i)&&0!==t?null:(l||i)&&0===t?(0,Y.jsx)("li",{children:(0,Ne.QX)({errorObject:e})},t):"carrier_not_found"===(null===e||void 0===e?void 0:e.message)&&0===t?(0,Y.jsx)(n.Fragment,{children:(0,Ne.QX)({errorObject:e})},t):"carrier_not_found"!==(null===e||void 0===e?void 0:e.message)?(0,Y.jsxs)("li",{className:"tw-flex tw-items-center",children:["Shipment# ",t+1,":"," ",(0,Ne.QX)({errorObject:e})]},t):null}):null,C?dt(j).map((e,t)=>{const l=e.showCarrier?function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";
2return e?(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"").startsWith("FedEx:")?"":e.toUpperCase():""}(e.carrier,e.message):"";return l?(0,Y.jsxs)("li",{children:[l,": ",e.message]},t):(0,Y.jsx)("li",{children:e.message},t)}):null]}),!N&&(null===f||void 0===f||null===(D=f.shipments)||void 0===D?void 0:D.map(e=>(0,Ne.GN)({shipment:e})))]})]}):I===Ne.LY.isShipment?(0,Y.jsx)("div",{className:"tw-w-full tw-px-4 tw-pt-4",children:(0,Y.jsx)(nt.A,{renderMoreInfo:()=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("ul",{className:"tw-list-disc tw-list-inside tw-p-0 tw-m-0",children:null!==t&&void 0!==t&&t.message?(0,Y.jsx)("li",{className:"tw-flex tw-items-center",children:(0,Ne.QX)({errorObject:t})}):null}),!N&&(0,Ne.GN)({shipment:p})]}),className:"tw-flex tw-items-center"})}):(0,Y.jsx)(nt.A,{children:(0,Ne.QX)({errorObject:t})}):null;var D};var at=l(15579),rt=l(69840);const ct=e=>{var t;let l=e.values,i=e.user,s=e.className,d=void 0===s?"":s;const o=null!==(t=null===l||void 0===l?void 0:l.shipments)&&void 0!==t?t:[],a=o.some(e=>!!e.automationRuleApplied),r=(0,Le.No)({user:i,feature:Le.cc.automation_rules});if(!a||r)return null;const c=[...new Set(o.map(e=>{var t;return null!==(t=e.automationRulesApplied)&&void 0!==t?t:[]}).flat(1))];return(0,Y.jsxs)("div",{className:(0,Se.cn)("tw-py-2 tw-rounded-lg tw-bg-yellow-200 tw-text-yellow-600 tw-px-4 tw-flex tw-gap-6 tw-items-center",d),children:[(0,Y.jsx)("div",{children:(0,Y.jsx)(S.Vhy,{className:"tw-fill-yellow-600 tw-stroke-yellow-600 tw-mt-1",strokeWidth:32,height:30,width:30})}),(0,Y.jsxs)("div",{className:"tw-flex-1",children:[(0,Y.jsxs)("div",{className:"tw-text-lg tw-font-bold",children:["Automation",c.length>1?"s":""," Applied:"]}),c.map((e,t)=>{var l,s,d;const o=null===i||void 0===i||null===(l=i.automationRules)||void 0===l?void 0:l.find(t=>(0,at.isUUID)(e)?e===t.id:t.name===e);return(0,Y.jsxs)(n.Fragment,{children:[(0,Y.jsx)("div",{className:(0,Se.cn)("tw-font-bold tw-ml-2",t>0?"tw-mt-4":"tw-mt-0"),children:null!==(s=null===o||void 0===o?void 0:o.name)&&void 0!==s?s:e}),(0,Y.jsx)("ul",{className:(0,Se.cn)("tw-list-disc tw-list-inside tw-mt-0 tw-mb-0"),children:(null!==(d=null===o||void 0===o?void 0:o.actions)&&void 0!==d?d:[]).map((e,t)=>{const l=(0,rt.oB)(e,i),s=l.actionOnLabel,n=void 0===s?"":s,d=l.actionValue,o=void 0===d?"":d;return(0,Y.jsxs)("li",{children:[n," ",o]},t)})})]},e)})]})]})};var ut=l(34176),vt=l(86740);const ht=e=>{var t,l,i,s;let n=e.values,d=e.isLocalCourierShipment,o=e.setFieldValue,a=e.isLoading,r=e.isEditable;if(!d)return null;const c=(0,x.Ay)().toDate();return c.setHours(360),(0,Y.jsxs)("section",{className:"tw-mt-4 tw-space-y-4 tw-pl-4",children:[(0,Y.jsxs)("div",{className:"tw-grid lg:tw-grid-cols-3 tw-gap-4",children:[(0,Y.jsx)("div",{children:(0,Y.jsx)(A.D0,{name:"localCourierOptions.vehicleSize",component:U.A,margin:"dense",options:vt.j,disabled:a||!r,label:"Vehicle Size",handleChange:e=>o("localCourierOptions.vehicleSize",e)})}),(0,Y.jsx)("div",{children:(0,Y.jsx)(A.D0,{name:"localCourierOptions.deliverySchedule",component:U.A,margin:"dense",options:vt.v,label:"Pickup Time",disabled:a||!r,handleChange:e=>o("localCourierOptions.deliverySchedule",e)})}),(0,Y.jsx)("div",{children:(0,Y.jsx)(A.D0,{name:"localCourierOptions.declaredValue",component:M.A,type:"number",step:1,label:(0,Y.jsxs)(Y.Fragment,{children:["Declared Value",(0,Y.jsx)($.A,{information:z.A.LOCAL_COURIER_DECLARED_VALUE})]}),prefix:"$",min:0,disabled:a||!r,onChange:e=>{o("localCourierOptions.declaredValue",parseFloat(e))}})}),parseFloat((null===n||void 0===n||null===(t=n.localCourierOptions)||void 0===t?void 0:t.declaredValue)||0)>g.Im?(0,Y.jsx)("p",{className:"tw-p-0 tw-m-0 tw-text-primary tw-text-sm tw-font-medium lg:tw-col-span-3",children:ee.lw.LOCAL_COURIER_MAX_INSURANCE_AMOUNT}):null]}),"scheduled"===(null===n||void 0===n||null===(l=n.localCourierOptions)||void 0===l?void 0:l.deliverySchedule)?(0,Y.jsxs)("div",{className:"tw-max-w-60 tw-mt-2",children:[(0,Y.jsx)(A.o5,{children:"Schedule Time"}),(0,Y.jsx)(A.lr,{hourCycle:12,onChange:e=>o("localCourierOptions.pickupStartTime",(0,x.Ay)(e).toDate()),value:null!==n&&void 0!==n&&null!==(i=n.localCourierOptions)&&void 0!==i&&i.pickupStartTime?n.localCourierOptions.pickupStartTime:(0,x.Ay)(),disabledBefore:new Date,disabledAfter:c,type:"datetime",disabled:a||!r})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.D0,{component:M.A,name:"pickUpNotes",autoComplete:"pickUpNotes",value:n.pickUpNotes||"",label:"Pickup Notes",disabled:a||!r,onChange:()=>o(),multiline:!0,rows:2,maxLength:200,noErrMsg:!0,placeholder:"Pickup Notes"})}),(0,Y.jsx)("div",{children:(0,Y.jsx)(A.D0,{component:M.A,name:"dropOffNotes",autoComplete:"dropOffNotes",value:n.dropOffNotes||"",label:"Drop Off Notes",disabled:a||!r,onChange:()=>o(),multiline:!0,rows:2,maxLength:200,noErrMsg:!0,placeholder:"Drop Off Notes"})}),(0,Y.jsx)("div",{children:(0,Y.jsx)(A.D0,{name:"localCourierOptions.signatureRequired",value:null===n||void 0===n||null===(s=n.localCourierOptions)||void 0===s?void 0:s.signatureRequired,component:ut.A,label:(0,Y.jsxs)(Y.Fragment,{children:["Signature Required",(0,Y.jsx)($.A,{information:z.A.SIGNATURE_REQUIRED})]}),disabled:a||!r,labelPlacement:"left",className:"!tw-justify-start",onChange:e=>{o("localCourierOptions.signatureRequired",!n.localCourierOptions.signatureRequired),o("localCourierOptions.signatureRequiredDisabled",!e)}})})]})},mt=function(){var e,t,l,i;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=s.user,d=s.values,o=void 0===d?{}:d,a=s.setFieldValue,r=s.isLoading,c=s.isEditable,u=s.isLocalCourierShipment;const v=(null===n||void 0===n||null===(e=n.vndrRatesConfig)||void 0===e||null===(t=e.localCourier)||void 0===t?void 0:t.allowed)&&(null===n||void 0===n||null===(l=n.vndrRatesConfig)||void 0===l||null===(i=l.localCourier)||void 0===i?void 0:i.active);return(0,Y.jsxs)("div",{className:"tw-mt-4 tw-bg-white tw-rounded-2xl tw-p-4 tw-shadow-lg tw-border tw-border-gray-300 tw-border-solid",children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:"Shipment Type"})}),(0,Y.jsxs)("div",{className:"tw-flex tw-mt-2 tw-pt-0 tw-pl-4",children:[(0,Y.jsx)(A.$
2n,{onClick:()=>a("shipmentType",g.fB.Parcel),color:"secondary",variant:"".concat(o.shipmentType!==g.fB.LocalCourier?"contained":"outlined"),disabled:r||!c,className:"!tw-rounded-tr-none !tw-rounded-br-none",children:"Parcel"}),(0,Y.jsx)(A.m_,{title:v?"":"Local Carrier is not enabled in your Carrier settings",children:(0,Y.jsx)("span",{children:(0,Y.jsx)(A.$n,{onClick:()=>a("shipmentType",g.fB.LocalCourier),color:"secondary",variant:"".concat(o.shipmentType===g.fB.LocalCourier?"contained":"outlined"),disabled:r||!c||!v,className:"!tw-rounded-tl-none !tw-rounded-bl-none",children:"Local Courier"})})})]}),(0,Y.jsx)(ht,{values:o,isLocalCourierShipment:u,setFieldValue:a,isLoading:r,isEditable:c})]})};var pt=l(41),wt=l(88656),xt=l(80490);const gt={width:{xs:"calc(100vw - 32px)",sm:450},maxWidth:"calc(100vw - 32px)",border:"1px solid rgba(0, 0, 0, 0.12)",borderRadius:2},jt=e=>({background:e.palette.background.paper}),ft=e=>{let t=e.warehouse,l=e.isLoading,i=e.isEditable,o=e.isReturn,a=e.curShipment,r=e.setFieldValue,u=e.buttonClasses;
2const v=(0,d.useDispatch)(),h=(0,n.useState)(null),m=(0,s.A)(h,2),p=m[0],w=m[1],x=(0,n.useState)(null),g=(0,s.A)(x,2),j=g[0],f=g[1],y=(0,n.useState)(null),b=(0,s.A)(y,2),N=b[0],C=b[1],k=(0,n.useState)(!1),I=(0,s.A)(k,2),D=I[0],E=I[1],O=(0,n.useState)(!1),R=(0,s.A)(O,2),P=R[0],F=R[1],_=(0,c.A)(),T=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.user)||void 0===l?void 0:l.warehouses}),W=(0,xt.Xe)({warehouses:T});(0,n.useEffect)(()=>{const e=(null===t||void 0===t?void 0:t.id)||(null===W||void 0===W?void 0:W.id)||"";if(null===p||p!==e){const e=(null===t||void 0===t?void 0:t.id)||(null===W||void 0===W?void 0:W.id)||"";if(w(e),null!==t&&void 0!==t&&t.isCustom&&C(t),e){const l=null===T||void 0===T?void 0:T.find(t=>t.id===e);l&&(null===t||void 0===t?void 0:t.formattedAddress)!==(null===l||void 0===l?void 0:l.formattedAddress)&&r("warehouse",l,!0)}}},[t,W,T,v]);const L=e=>{let t=e.selectedWarehouseId,l=e.newWarehouse;l&&w(t);let i=l;i||(i=(null===N||void 0===N?void 0:N.id)===t?N:null),i||(i=null===T||void 0===T?void 0:T.find(e=>e.id===t)),i&&r("warehouse",i)},M=e=>{const t=e.target.value;t&&t!==p&&(w(t),"create-new-warehouse"!==t&&"custom-warehouse"!==t&&L({selectedWarehouseId:t}))},U=()=>{if(!i&&t)return(0,Y.jsx)(A.Dr,{value:t.id,sx:{overflow:"hidden"},children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-0 tw-w-full",children:[(0,Y.jsx)("div",{style:{marginRight:"15px",flexShrink:0},children:(0,Y.jsx)(pt.A,{})}),(0,Y.jsxs)("div",{className:"tw-min-w-0 tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:t.name}),(0,Y.jsx)("div",{className:"tw-truncate tw-text-xs tw-text-gray-600",children:t.formattedAddress})]})]})},t.id);let e=null===T||void 0===T?void 0:T.map(e=>(0,Y.jsx)(A.Dr,{value:e.id,sx:{overflow:"hidden"},children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-0 tw-w-full",children:[(0,Y.jsx)("div",{style:{marginRight:"15px",flexShrink:0},children:(0,Y.jsx)(pt.A,{})}),(0,Y.jsxs)("div",{className:"tw-min-w-0 tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:e.name}),(0,Y.jsx)("div",{className:"tw-truncate tw-text-xs tw-text-gray-600",children:e.formattedAddress})]})]})},e.id));return N&&(e=[(0,Y.jsx)(A.Dr,{value:null===N||void 0===N?void 0:N.id,sx:{overflow:"hidden"},children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-0 tw-w-full",children:[(0,Y.jsx)("div",{style:{marginRight:"15px",flexShrink:0},children:(0,Y.jsx)(pt.A,{})}),(0,Y.jsxs)("div",{className:"tw-min-w-0 tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:N.name}),(0,Y.jsx)("div",{className:"tw-truncate tw-text-xs tw-text-gray-600",children:N.formattedAddress})]})]})},null===N||void 0===N?void 0:N.id),...e||[]]),e};return(0,Y.jsxs)("div",{className:"tw-mt-4 tw-bg-white tw-rounded-2xl tw-p-4 tw-shadow-lg tw-border tw-border-gray-300 tw-border-solid tw-pb-2",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:o?"Recipient":"Warehouse"}),(0,Y.jsxs)(A.$n,{variant:"outlined",onClick:()=>M({target:{value:"create-new-warehouse"}}),disabled:D||l||!i,className:u.addButton,size:"small",children:[(0,Y.jsx)(S.OMN,{}),"Add Warehouse"]})]}),(0,Y.jsxs)("div",{className:"tw-pt-2 tw-pl-4",children:[(0,Y.jsx)(A.MJ,{sx:{minWidth:120,width:"100%",margin:"".concat(_.spacing(1)," 0")},margin:"dense",children:!i&&t?(0,Y.jsxs)(A.l6,{variant:"outlined",value:(null===t||void 0===t?void 0:t.id)||"",id:"select-warehouse",disabled:!0,MenuProps:{PaperProps:{sx:gt}},iconStyle:{top:void 0,marginTop:-5},children:[(0,Y.jsx)(A.a6,{sx:jt,children:(0,Y.jsx)("span",{style:{color:_.palette.primary.main},children:"Choose Warehouse"})}),U()]}):null!==T&&void 0!==T&&T.length?(0,Y.jsxs)(A.l6,{variant:"outlined",value:(null===t||void 0===t?void 0:t.id)||"",id:"select-warehouse",onChange:M,disabled:D||l||!i,open:P,onOpen:()=>F(!0),onClose:()=>F(!1),MenuProps:{PaperProps:{sx:gt}}
2,iconStyle:{top:void 0,marginTop:-5},children:[(0,Y.jsxs)(A.a6,{sx:jt,className:"tw-flex tw-justify-between tw-items-center",children:[(0,Y.jsx)("span",{style:{color:_.palette.primary.main},children:"Choose Warehouse"}),(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-ml-auto",children:(0,Y.jsx)(S.OMN,{className:"tw-cursor-pointer",onClick:()=>{w("create-new-warehouse"),F(!1)}})})]}),U()]}):null}),(0,Y.jsx)(ot,{errorObject:null===a||void 0===a?void 0:a.error,isFromAddress:!0,className:"tw-mt-2"})]}),(0,Y.jsx)(wt.A,{submittingWarehouse:e=>{E(e)},handleClose:e=>{let t=e.warehouse;t?(t.isCustom&&C(t),L({selectedWarehouseId:t.id,newWarehouse:t})):w((null===t||void 0===t?void 0:t.id)||(null===W||void 0===W?void 0:W.id)||""),f(null)},active:"create-new-warehouse"===p||"custom-warehouse"===p||!!j,submittingNewWarehouse:D,initialValues:null!==j&&void 0!==j?j:{},editWarehouse:j,setEditWarehouse:f,showSaveCheckbox:!0})]})};var yt=l(91127),bt=l(64248),At=l(19776),St=l(57349),Nt=l(53946),Ct=l(83408),kt=l(69416),It=l(24304);const Dt=e=>{let t=e.defenseData,l=e.className;const i=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),s=(0,Le.No)({user:i,feature:Le.cc.insurance}),n=(0,Le.No)({user:i,feature:Le.cc.confidence_score}),o=!1===(null===i||void 0===i?void 0:i.overrideUpscInsurance);if(s||o||n)return null;if(null===t||void 0===t||!t.score||0===(null===t||void 0===t?void 0:t.score))return null;const a=parseFloat((0,be.floatToTwo)(t.score/10)),r=(0,It.Op)(a),c=r.deliveryDefenseColor,u=r.deliveryDefenseMessage;return(0,Y.jsxs)("div",{id:"delivery-defense-score",className:"tw-mt-4 tw-border tw-border-primary tw-rounded-lg tw-p-4 tw-border-solid ".concat(l),children:[(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between",children:[(0,Y.jsx)(Le.zg,{feature:Le.cc.insurance,children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,Y.jsx)("span",{className:"tw-text-lg tw-font-bold tw-text-primary",children:"Confidence Score"}),(0,Y.jsx)($.A,{information:z.A.DELIVERY_DEFENSE})]})}),(0,Y.jsxs)("div",{className:"".concat(c," tw-text-xl tw-font-bold"),children:[a,"%"]})]}),(0,Y.jsx)("div",{className:"tw-flex tw-justify-between tw-gap-4",children:(0,Y.jsx)("div",{className:"tw-text-sm",children:u})})]})};var Et=l(60217),Ot=l(84608),Rt=l(99973);const Pt=e=>{var t,l,d,o,a,r,c,u,v,h,m,p,w,x,j,f;let y=e.editOrderRef,b=e.setFieldValue,N=e.showEditModal,C=e.setShowEditModal,k=e.shippingAddress,I=void 0===k?{}:k,D=e.isLoading,E=e.isEditable,O=e.errors,R=e.values,P=e.isReturn,F=e.validateForm,_=e.formikErrors,T=e.curShipment,W=e.setWeatherData,L=e.setDefenseData,B=e.showAddressError,V=void 0===B||B,z=e.user,$=e.hasShipfareProtection,Z=e.handleAddressUpdate,q=e.afterFormChange,G=e.setIsEdited,K=e.buttonClasses;const Q=(0,n.useState)(!1),X=(0,s.A)(Q,2),J=X[0],ee=X[1],te=(0,n.useState)(!1),le=(0,s.A)(te,2),ie=le[0],se=le[1],ne=(0,n.useState)(null===I||void 0===I?void 0:I.deliveryDefense),de=(0,s.A)(ne,2),oe=de[0],ae=de[1],re=(0,n.useState)(!1),ce=(0,s.A)(re,2),ue=ce[0],ve=ce[1],he=(0,n.useState)(!1),me=(0,s.A)(he,2),pe=me[0],we=me[1],xe=(0,n.useState)(!1),ge=(0,s.A)(xe,2),je=ge[0],fe=ge[1],ye=(0,n.useState)(null),be=(0,s.A)(ye,2),Ae=be[0],Se=be[1],Ne=(0,Et.A)({user:z,values:y,isEditable:E,setLoading:se}).getWeatherData;(0,n.useEffect)(()=>{var e;null!==I&&void 0!==I&&null!==(e=I.deliveryDefense)&&void 0!==e&&e.score&&!oe&&ae(I.deliveryDefense)},[null===I||void 0===I||null===(t=I.deliveryDefense)||void 0===t?void 0:t.score]),(0,n.useEffect)(()=>{null!==y&&void 0!==y&&y.shippingAddress&&Ne().then(e=>{null===W||void 0===W||W(e)})},[]),(0,n.useEffect)(()=>{!N||null!==Ae&&void 0!==Ae&&Ae.street1&&!(0,g.Uj)(I,Ae)||Se(I)},[N]);const Ce=(0,n.useCallback)(()=>{var e;return(null===(e=At.Ay[(null===I||void 0===I?void 0:I.country)||"US"])||void 0===e?void 0:e.map(e=>({label:e.name,value:e.abbreviation})))||[]},[I.country]),ke=(0,n.useCallback)(()=>{var e;return null===(e=At.Ay[(null===I||void 0===I?void 0:I.country)||"US"])||void 0===e?void 0:e.find(e=>{var t,l,i,s;return(null===e||void 0===e||null===(t=e.name)||void 0===t?void 0:t.toLowerCase())===(null===I||void 0===I||null===(l=I.state)||void 0===l?void 0:l.toLowerCase())||(null===e||void 0===e||null===(i=e.abbreviation)||void 0===i?void 0:i.toLowerCase())===(null===I||void 0===I||null===(s=I.state)||void 0===s?void 0:s.toLowerCase())})},[I.country,I.state])(),Ie=ke?[{label:ke.name,value:ke.abbreviation},...Ce().filter(e=>e.value!==ke.abbreviation)]:[{label:"Select State",value:null},...Ce()],De=e=>{ve(e);for(let n=0;n<(null===R||void 0===R||null===(t=R.shipments)||void 0===t?void 0:t.length);n++){var t,l,i;if(e)if(b("shipments[".concat(n,"].options.carrierInsuranceAmountActive"),!0),null!==z&&void 0!==z&&null!==(l=z.declaredValue)&&void 0!==l&&l.active&&null!==z&&void 0!==z&&null!==(i=z.declaredValue)&&void 0!==i&&i.custom)b("shipments[".concat(n,"].options.carrierInsuranceAmountAutomatic"),!1),b("shipments[".concat(n,"].options.carrierInsuranceAmount"),z.declaredValue.custom);else{var s;const e=(0,g.QB)(null===R||void 0===R||null===(s=R.shipments[n])||void 0===s?void 0:s.products,null===R||void 0===R?void 0:R.shipments[n]);b("shipments[".concat(n,"].options.carrierInsuranceAmountAutomatic"),!0),b("shipments[".concat(n,"].options.carrierInsuranceAmount"),e)}else b("shipments[".concat(n,"].options.carrierInsuranceAmountActive"),!1)}},Ee=!(null!==I&&void 0!==I&&null!==(l=I.verifications)&&void 0!==l&&null!==(d=l.delivery)&&void 0!==d&&d.success)&&!(null===I||void 0===I||null===(o=I.verifications)||void 0===o||!o.suggestedAddress)&&!(null!==I&&void 0!==I&&I.hasUsedSuggestedAddress),Oe=null===I||void 0===I||null===(a=I.verifications)||void 0===a?void 0:a.suggestedAddress;return(0,Y.jsxs)("div",{className:"tw-mt-4 tw-bg-white tw-rounded-2xl tw-p-4 tw-shadow-lg tw-border tw-border-gray-300 tw-border-solid",style:{borderColor:O?"#CA4941":"default"},children:[(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:P?"Warehouse":"Recipient"}),(0,Y.jsxs)(A.$n,{variant:"outlined",onClick:()=>{C(!0)},disabled:D||!E,"data-cy":"btn-edit-recipient-new-order",className:K.addButton,size:"small",children:[(0,Y.jsx)(S.ffu,{width:21,height:21}),"Edit"]})]}),(0,Y.jsxs)("div",{className:"tw-pt-2 tw-pl-4",children:[(0,Y.jsxs)("section",{children:[(0,Y.jsxs)("div",{className:"tw-grid tw-gri
2d-cols-1 lg:tw-grid-cols-2 tw-gap-4 tw-mt-2",children:[(0,Y.jsx)("div",{children:(0,Y.jsxs)("ul",{className:"tw-list-none tw-list-inside tw-border tw-border-transparent tw-pl-4 tw-pt-0 tw-rounded-lg -tw-ml-4 tw-mt-0 tw-mb-0 tw-break-words",children:[null!==I&&void 0!==I&&I.company?(0,Y.jsx)("li",{children:I.company}):null,null!==I&&void 0!==I&&I.email?(0,Y.jsx)("li",{children:(0,Y.jsx)("a",{className:"tw-break-words",href:"mailto: ".concat(I.email),children:I.email})}):null,(0,Y.jsx)("li",{children:(null===I||void 0===I?void 0:I.name)||""}),null!==I&&void 0!==I&&I.phone&&!["+","+1"].includes(I.phone)?(0,Y.jsx)("div",{children:(0,Je.av)(I.phone)}):null,(0,Y.jsxs)("li",{children:[null===I||void 0===I?void 0:I.address1," ",null!==I&&void 0!==I&&I.address2?", ".concat(I.address2):null]}),(0,Y.jsxs)("li",{children:[null===I||void 0===I?void 0:I.city,(0,St.nt)(I)||(0,St.fC)(I)||null===I||void 0===I||!I.state?null:", ".concat(I.state),null!==I&&void 0!==I&&I.zip?", ".concat(I.zip):null]}),(0,Y.jsx)("li",{children:["US","USA"].includes(null===I||void 0===I?void 0:I.country)?"":null===I||void 0===I?void 0:I.country}),(0,Y.jsx)("li",{children:null!==I&&void 0!==I&&I.residential?"Residential":"Commercial"})]})}),Ee&&(0,Y.jsxs)("ul",{className:"tw-list-none tw-list-inside tw-border tw-border-solid tw-border-secondary tw-p-4 tw-rounded-lg tw-mt-0 tw-mb-0 tw-break-words tw-overflow-hidden",children:[(0,Y.jsx)("li",{className:"tw-font-bold tw-text-secondary",children:"Recommended"}),(0,Y.jsx)("li",{children:(null===I||void 0===I?void 0:I.name)||""}),(0,Y.jsxs)("li",{children:[null===Oe||void 0===Oe?void 0:Oe.street1,null!==Oe&&void 0!==Oe&&Oe.street2?", ".concat(null===Oe||void 0===Oe?void 0:Oe.street2):""]}),(0,Y.jsxs)("li",{children:[null===Oe||void 0===Oe?void 0:Oe.city,", ",null===Oe||void 0===Oe?void 0:Oe.state,","," ",null===Oe||void 0===Oe?void 0:Oe.zip]}),(0,Y.jsx)("li",{children:null!==Oe&&void 0!==Oe&&Oe.residential?"Residential":"Commercial"}),(0,Y.jsx)("li",{className:"tw-mt-2",children:(0,Y.jsx)(A.$n,{variant:"contained",color:"secondary",onClick:()=>{const e=I.verifications.suggestedAddress,t=(0,i.A)((0,i.A)({},I),{},{address1:e.street1,address2:e.street2,city:e.city,state:e.state,zip:e.zip,country:e.country,residential:!!e.residential,verified:!0,isValid:!0,hasUsedSuggestedAddress:!0,hasUsedOriginalAddress:!1,originalAddress:{address1:I.address1,address2:I.address2,city:I.city,state:I.state,zip:I.zip,country:I.country,residential:!!I.residential}});"PR"!==(null===t||void 0===t?void 0:t.state)&&"PR"!==(null===t||void 0===t?void 0:t.country)||(t.state="PR",t.country="PR"),delete t.message,G(!0),b("isSuggestedAddressUpdate",!0),b("shippingAddress",t,!0),Z(!0),q()},disabled:D||!E||!(null===I||void 0===I||!I.hasUsedSuggestedAddress),children:"Use Recommended"})})]}),je&&(0,Y.jsxs)("ul",{className:"tw-list-none tw-list-inside tw-border tw-border-solid tw-border-secondary tw-p-4 tw-rounded-lg tw-mt-0 tw-mb-0 tw-break-words tw-overflow-hidden",children:[(0,Y.jsx)("li",{className:"tw-font-bold tw-text-secondary",children:"Original"}),(0,Y.jsx)("li",{children:(null===I||void 0===I?void 0:I.name)||""}),(0,Y.jsxs)("li",{children:[null===I||void 0===I||null===(r=I.originalAddress)||void 0===r?void 0:r.address1,null!==I&&void 0!==I&&null!==(c=I.originalAddress)&&void 0!==c&&c.address2?", ".concat(null===I||void 0===I||null===(u=I.originalAddress)||void 0===u?void 0:u.address2):""]}),(0,Y.jsxs)("li",{children:[null===I||void 0===I||null===(v=I.originalAddress)||void 0===v?void 0:v.city,","," ",null===I||void 0===I||null===(h=I.originalAddress)||void 0===h?void 0:h.state,","," ",null===I||void 0===I||null===(m=I.originalAddress)||void 0===m?void 0:m.zip]}),(0,Y.jsx)("li",{children:null!==I&&void 0!==I&&null!==(p=I.originalAddress)&&void 0!==p&&p.residential?"Residential":"Commercial"}),(0,Y.jsx)("li",{className:"tw-mt-2",children:(0,Y.jsx)(A.$n,{variant:"contained",color:"secondary",onClick:()=>{const e=I.originalAddress,t=(0,i.A)((0,i.A)({},I),{},{address1:e.address1,address2:e.address2,city:e.city,state:e.state,zip:e.zip,country:e.country,residential:!!e.residential,verified:!0,isValid:!0,hasUsedSuggestedAddress:!1,hasUsedOr
2iginalAddress:!0});G(!0),fe(!1),b("isSuggestedAddressUpdate",!0),b("shippingAddress",t,!0),Z(!0),q()},disabled:D||!E,children:"Use Original"})})]})]}),null===I||void 0===I||!I.originalAddress||null!==I&&void 0!==I&&I.hasUsedOriginalAddress||je?"":(0,Y.jsx)("div",{onClick:()=>fe(!0),children:(0,Y.jsxs)("span",{className:"tw-cursor-pointer tw-text-sm tw-italic",children:["* Recommended address was applied."," ",(0,Y.jsx)("b",{className:"tw-text-secondary",children:"View"})," the original address."]})})]}),V&&(0,Y.jsx)(kt.A,{address:I}),(0,Y.jsx)(ot,{errorObject:null===T||void 0===T?void 0:T.error,isToAddress:!0,className:"tw-mt-2"}),(0,Y.jsx)(Dt,{className:"-tw-ml-4",defenseData:oe,isActive:ue||!(null===T||void 0===T||null===(w=T.options)||void 0===w||!w.carrierInsuranceAmountActive),handleOrderInsuranceChange:De,isDisabled:D||!E||$,hasShipfareProtection:$})]}),(0,Y.jsxs)(A.aF,{open:N,title:"Edit Recipient Address",scroll:"paper",handleClose:()=>{null!==y&&void 0!==y&&y.shippingAddress&&b("shippingAddress",null===y||void 0===y?void 0:y.shippingAddress,!0),C(!1),we(!1)},actions:[{isPrimary:!0,onClick:()=>{if(ee(!0),!(0,St.FM)(I,null===R||void 0===R?void 0:R.warehouse))for(let t=0;t<(null===R||void 0===R||null===(e=R.shipments)||void 0===e?void 0:e.length);t++){var e;b("shipments[".concat(t,"].internationalSettings"),null)}F().then(async e=>{if(se(!0),null===e||void 0===e||!e.shippingAddress){const e=(0,i.A)({},I);if(fe(!1),null!==R&&void 0!==R&&R.saveCustomerAddress&&(0,g.E_)(e),(0,g.Uj)(e,Ae)){Ne(R).then(e=>{null===W||void 0===W||W(e)}),(0,It.xs)({deliveryDefenseReset:pe,setDeliveryDefense:e=>{ae(e),b("shippingAddress.deliveryDefense",e),null===L||void 0===L||L(e)},handleOrderInsuranceChange:De,user:z,values:R}),delete e.hasUsedOriginalAddress,delete e.hasUsedSuggestedAddress,delete e.originalAddress;const t=await(0,g.Wp)({shippingAddress:e,setFieldValue:b,setLastVerifiedAddress:Se});null!==t&&void 0!==t&&t.isValid||Z(!0,!0)}else b("shippingAddress",e);C(!1),we(!1)}se(!1)})},label:"Save",disabled:!(null===_||void 0===_||!_.shippingAddress)||ie,loading:ie}],children:[(0,Y.jsx)(A.D0,{id:"searchCustomers",name:"Search Customers",component:U.A,startAdornment:(0,Y.jsx)(S.vji,{}),hideSelected:!0,placeholder:"Search Customer Base",onChange:(e,t)=>
2{if(null!==t&&void 0!==t&&t.customer){var l,s;const e=t.customer;let n=null===e||void 0===e||null===(l=e.addressBook)||void 0===l?void 0:l.find(e=>e.default);n||(n=(null===e||void 0===e||null===(s=e.addressBook)||void 0===s?void 0:s.length)&&e.addressBook[0]);const d=(0,yt.jM)(I,t=>{var l,s,d,o,a,r,c,u,v,h,m;t.company=(null===(l=n)||void 0===l?void 0:l.company)||"",t.name=(null===e||void 0===e?void 0:e.name)||"",t.email=(null===e||void 0===e?void 0:e.email)||"",t.phone=(0,St.FM)((0,i.A)((0,i.A)({},I),{},{country:(null===(s=n)||void 0===s?void 0:s.country)||"US"}),null===R||void 0===R?void 0:R.warehouse)?(null===e||void 0===e?void 0:e.phone)||(null===(d=n)||void 0===d?void 0:d.phone)||"":(null===(o=(0,bt.E7)((0,Je.WA)((null===e||void 0===e?void 0:e.phone)||(null===(a=n)||void 0===a?void 0:a.phone)||""),(0,Je.Jd)(),{guide:!1}))||void 0===o?void 0:o.conformedValue)||"",t.residential=!("residential"in e)||!!e.residential,t.address1=(null===(r=n)||void 0===r?void 0:r.address1)||"",t.address2=(null===(c=n)||void 0===c?void 0:c.address2)||"",t.city=(null===(u=n)||void 0===u?void 0:u.city)||"",t.zip=(null===(v=n)||void 0===v?void 0:v.postcode)||"",t.state=(null===(h=n)||void 0===h?void 0:h.state)||"",t.country=(null===(m=n)||void 0===m?void 0:m.country)||"US",t.customerNotes=null===e||void 0===e?void 0:e.customerNotes,(0,St.nt)((0,i.A)({},t))?t.state="PR":(0,St.fC)((0,i.A)({},t))&&(t.state="UK")});b("shippingAddress",d,!0),we(!0)}},loadOptions:Nt.T8},"searchCustomers"),(0,Y.jsx)("div",{className:"tw-mt-2 tw-text-center tw-font-bold tw-mb-4",children:"or"}),(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-gap-4 tw-flex-col md:tw-flex-row",children:[(0,Y.jsx)("div",{className:"tw-flex-1",children:(0,Y.jsx)(A.D0,{label:"Name",placeholder:"Name",component:M.A,name:"shippingAddress.name",autoComplete:"name",value:(null===I||void 0===I?void 0:I.name)||"",isTouchedByDefault:J,isRequired:!0})}),(0,Y.jsx)("div",{className:"tw-flex-1",children:(0,Y.jsx)(A.D0,{type:"email",autoCapitalize:"off",autoComplete:"email",name:"shippingAddress.email",label:"Email",placeholder:"Email",component:M.A,value:(null===I||void 0===I?void 0:I.email)||"",isTouchedByDefault:J})}),(0,Y.jsx)("div",{className:"tw-flex-1",children:(0,Y.jsx)(A.D0,{name:"shippingAddress.phone",component:Je.Ay,isTouchedByDefault:!(null===_||void 0===_||null===(x=_.shippingAddress)||void 0===x||!x.phone)||J,isRequired:(0,St.FM)(I,null===R||void 0===R?void 0:R.warehouse),allowInternational:(0,St.FM)(I,null===R||void 0===R?void 0:R.warehouse)})})]}),(0,Y.jsx)(Ct.A,{label:"Street 1",placeholder:"Street 1",value:null===I||void 0===I?void 0:I.address1,errMsg:null!==_&&void 0!==_&&null!==(j=_.shippingAddress)&&void 0!==j&&j.address1?(0,Ot.u1)(null===_||void 0===_||null===(f=_.shippingAddress)||void 0===f?void 0:f.address1,"Street 1"):"",onChange:e=>{b("shippingAddress.address1",e,!0),we(!0)},setAutoCompleteAddress:e=>{const t=(0,i.A)((0,i.A)((0,i.A)({},R.shippingAddress),e),{},{address2:""});(0,St.nt)(t)?t.state="PR":(0,St.fC)(t)&&(t.state="UK"),b("shippingAddress",t,!0),we(!0)},isTouchedByDefault:J,isRequired:!0}),(0,Y.jsx)(A.D0,{label:"Street 2",placeholder:"Street 2",component:M.A,name:"shippingAddress.address2",autoComplete:"address-line2",value:(null===I||void 0===I?void 0:I.address2)||"",isTouchedByDefault:J}),(0,Y.jsxs)("div",{className:"tw-flex tw-gap-4 tw-flex-col md:tw-flex-row",children:[(0,Y.jsx)("div",{className:"tw-flex-1",children:(0,Y.jsx)(A.D0,{label:"City",placeholder:"City",component:M.A,onChange:()=>{b(),we(!0)},name:"shippingAddress.city",autoComplete:"address-level2",value:(null===I||void 0===I?void 0:I.city)||"",isTouchedByDefault:J,isRequired:!0})}),(0,St.nt)(I)||(0,St.fC)(I)?null:(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)("div",{className:"tw-flex-1",children:[(0,Y.jsx)(A.D0,{name:"shippingAddress.state",component:U.A,label:"State",handleChange:e=>{b("shippingAddress.state",e),we(!0)},options:Ie,autoComplete:"address-level1",isTouchedByDefault:J,isRequired:!0}),(0,Y.jsx)(Rt.A,{onChange:e=>{const t=Ie.find(t=>t.label===e);t&&(b("shippingAddress.state",null===t||void 0===t?void 0:t.value),we(!0))}})]})}),(0,Y.jsx)("div",{className:"tw-flex-1",children:(0,Y.jsx)(A.D0,{label:"Zip",placeholder:"Zip Code",component:M.A,onChange:()=>{b(),we(!0)},name:"shippingAddress.zip",autoComplete:"postal-code",value:(null===I||void 0===I?void 0:I.zip)||"",isTouchedByDefault:J,isRequired:!0})})]}),(0,Y.jsxs)("div",{className:"tw-flex tw-gap-4 tw-flex-col md:tw-flex-row",children:[(0,Y.jsx)("div",{className:"tw-flex-1",children:(0,Y.jsx)(A.D0,{name:"shippingAddress.country",value:(null===I||void 0===I?void 0:I.country)||"US",label:"Country",component:U.A,margin:"dense",options:H.A.map(e=>({label:e.name,value:e.code})),autoComplete:"country-name",isTouchedByDefault:J,isRequired:!0,handleChange:e=>{const t=(0,i.A)((0,i.A)({},I),{},{country:e,phone:(0,Je.Zb)((null===I||void 0===I?void 0:I.phone)||"")?I.phone:""});
2(0,St.nt)(t)?t.state="PR":(0,St.fC)(t)?t.state="UK":t.state="",b("shippingAddress",t)}})}),(0,Y.jsx)("div",{className:"tw-flex-1",children:(0,Y.jsx)(A.D0,{label:"Company",placeholder:"Company",component:M.A,name:"shippingAddress.company",autoComplete:"company",value:(null===I||void 0===I?void 0:I.company)||"",isTouchedByDefault:J})})]}),(0,Y.jsx)(A.D0,{name:"shippingAddress.customerNotes",component:M.A,label:"Notes",multiline:!0,minRows:2}),(0,Y.jsx)(A.D0,{component:ut.A,labelPlacement:"end",fullWidth:!1,name:"saveCustomerAddress",label:"Save Customer Address"}),(0,Y.jsx)(A.D0,{component:ut.A,labelPlacement:"end",fullWidth:!1,name:"shippingAddress.residential",label:"Residential Address"})]})]})]})},Ft=e=>{var t;let l=e.values,s=e.isLoading,n=e.isEditable,d=e.errors,o=e.user,a=e.curShipment,r=e.currentShipmentIndex,c=e.setCurrentShipmentIndex,v=e.setFieldValue;const h=(0,u.useHistory)(),m=(e,t)=>()=>{if(c(t),(null===a||void 0===a?void 0:a.id)===e)return;const i="".concat(h.location.pathname).concat(h.location.search);h.push("".concat(i,"#").concat(l._id).concat(e?"-".concat(e):""))};return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-divide-x tw-divide-gray-200 tw-divide-solid tw-cursor-pointer tw-text-center tw-overflow-x-auto",children:[null===l||void 0===l||null===(t=l.shipments)||void 0===t?void 0:t.map((e,t)=>{var i,n,o;const a=null===e||void 0===e?void 0:e.id,c=t===r;return(0,Y.jsxs)("div",{className:"tw-flex-none tw-px-2 tw-py-3 tw-border tw-text-secondary ".concat(0===t?"tw-rounded-tl-2xl":""," ").concat(t===(null===l||void 0===l||null===(i=l.shipments)||void 0===i?void 0:i.length)-1?"tw-rounded-tr-2xl":""," tw-border-indigo-200 tw-border-solid flex align-items-center"),style:{color:null!==(n=Object.values((null===d||void 0===d?void 0:d.products)||{}))&&void 0!==n&&n.length&&d.products[e.id]||null!==(o=Object.values((null===d||void 0===d?void 0:d.insurance)||{}))&&void 0!==o&&o.length&&d.insurance[e.id]?"#CA4941":c?"default":"black",backgroundColor:c?"#edebf8":"white",whiteSpace:"pre"},onClick:m(a,t),disabled:s,children:[(0,Y.jsxs)("div",{children:["Shipment ",t+1," of ",l.shipments.length]}),l.shipments.length>1&&(0,Y.jsx)(A.$n,{disabled:s||!(null!==e&&void 0!==e&&e.isEditable)||!(null!==e&&void 0!==e&&e.id),style:{color:"#CA4941",padding:0,marginLeft:5,border:0},iconButton:!0,size:"small",onClick:e=>{e.stopPropagation(),e.preventDefault(),(e=>{const t=[...l.shipments],i=t[e],s=[...l.deletedShipments,i.id];v("deletedShipments",s),t.splice(e,1),v("shipments",t),0!==e&&e===r&&m(t[e-1].id,e-1)(),r>=t.length&&m(t[r-1].id,r-1)()})(t)},children:(0,Y.jsx)(S.bm,{})})]},a)}),(0,Y.jsx)(A.$n,{style:{marginLeft:5,border:0},iconButton:!0,size:"small",onClick:()=>(()=>{const e=(0,i.A)({},(0,X.vA)({user:o,shippingAddress:l.shippingAddress,warehouse:l.warehouse,order:l}));v("shipments",[...l.shipments,e]),m(e.id,l.shipments.length)()})(),disabled:s||!n,children:(0,Y.jsx)(S.E6T,{})})]})};var _t=l(12334),Tt=l(67208),Wt=l(28087),Lt=l(59669),Mt=l(82453),Ut=l(79395),Bt=l(49427),Vt=l(98225),zt=l(32550);const $t=e=>{var t,l,d,o,a;let r=e.lineItems,c=e.setFieldValue,u=e.shipment,v=e.isLoading,h=e.isEditable,m=e.errors,p=e.formikErrors,w=e.user,x=e.values,j=e.currentShipmentIndex,f=e.setCurrentShipmentIndex,y=e.packItemsByAlgo,b=e.buttonClasses;const N=(0,n.useRef)(),C=(0,n.useRef)(),k=(0,n.useState)(!1),I=(0,s.A)(k,2),D=I[0],E=I[1],O=(0,n.useState)(null),R=(0,s.A)(O,2),P=R[0],F=R[1],_=(0,n.useState)(null),T=(0,s.A)(_,2),U=T[0],B=T[1],V=(0,n.useState)(""),Z=(0,s.A)(V,2),H=Z[0],q=Z[1],G=(0,Bt.A)({user:w,shopDomain:null===x||void 0===x?void 0:x.shopDomain,platformType:null===x||void 0===x?void 0:x.platformType}),K=(0,g.Io)({user:w,shop:G}).weightUnit,Q=!!(null!==x&&void 0!==x&&null!==(t=x.shippingAddress)&&void 0!==t&&t.address1&&null!==x&&void 0!==x&&null!==(l=x.shippingAddress)&&void 0!==l&&l.city&&null!==x&&void 0!==x&&null!==(d=x.shippingAddress)&&void 0!==d&&d.state&&null!==x&&void 0!==x&&null!==(o=x.shippingAddress)&&void 0!==o&&o.zip),X=(0,Le.No)({user:w,feature:Le.cc.box_packing_algo});(0,Mt.A)(C,()=>{q(null)});const J=e=>{q(e)},ee=e=>{let t=e.insuredValue,l=void 0===t?0:t;l>=100&&!x.localCourierOptions.signatureRequiredDisabled&&c("localCourierOptions.signatureRequired",!0),c("localCourierOptions.declaredValue",l>200?200:l)},te=async e=>{var t,l;let s=e.updatedProducts,n=e.box,d=e.weights,o=e.packagings,a=e.shipmentIndex,r=void 0===a?null:a,u=e.dryIce;const v=null!==r?r:j;if(c("shipments[".concat(v,"].products"),s),"product"===d.type){const e=(0,_t.A)({box:n,products:s,packagings:o,user:w,dryIce:u}),t=(0,i.A)((0,i.A)({},d),{},{calculatedValues:e});c("shipments[".concat(v,"].weights"),t)}const h=null===x||void 0===x?void 0:x.shipments[v],m=(0,g.QB)(s,h);null!==h&&void 0!==h&&null!==(t=h.options)&&void 0!==t&&t.carrierInsuranceAmountActive&&null!==h&&void 0!==h&&null!==(l=h.options)&&void 0!==l&&l.carrierInsuranceAmountAutomatic&&c("shipments[".concat(v,"].options.carrierInsuranceAmount"),m),ee({insuredValue:m})},le=async e=>{var t,l,s;let n=e.itemIndex,d=e.targetIndex,o=e.quantity,a=[...(0,je.cloneDeep)(u.products)];const r=(0,i.A)({},a[n]);o>=r.quantity?a=a.filter((e,t)=>
2t!==n):a[n].quantity=r.quantity-o;const v=x.shipments[d],h=null!==v&&void 0!==v&&null!==(t=v.products)&&void 0!==t&&t.length?[...v.products]:[];var m,p,y,b,A,S,N,C,k;(h.push((0,i.A)((0,i.A)({},r),{},{quantity:parseInt(o)})),null!==(l=a)&&void 0!==l&&l.length||null!==u&&void 0!==u&&null!==(s=u.packagings)&&void 0!==s&&s.length)?(te({weights:u.weights,box:u.box,updatedProducts:a,packagings:u.packagings,dryIce:{weight:null===u||void 0===u||null===(m=u.options)||void 0===m?void 0:m.dryIceWeight,unit:null===u||void 0===u||null===(p=u.options)||void 0===p?void 0:p.dryIceUnit,active:null===u||void 0===u||null===(y=u.options)||void 0===y?void 0:y.dryIceActive}}),te({weights:v.weights,box:v.box,updatedProducts:h,shipmentIndex:d,packagings:v.packagings,dryIce:{weight:null===v||void 0===v||null===(b=v.options)||void 0===b?void 0:b.dryIceWeight,unit:null===v||void 0===v||null===(A=v.options)||void 0===A?void 0:A.dryIceUnit,active:null===v||void 0===v||null===(S=v.options)||void 0===S?void 0:S.dryIceActive}})):(e=>{let t=e.index,l=e.products,s=e.weights,n=e.box,d=e.packagings,o=e.dryIce;const a=x.shipments.map((e,a)=>{const r=(0,i.A)({},e);if(a===t&&(r.products=l,"product"===s.type)){var c,u;const e=(0,_t.A)({box:n,products:l,packagings:d,user:w,dryIce:o}),t=(0,i.A)((0,i.A)({},s),{},{calculatedValues:e});if(r.weights=t,null!==r&&void 0!==r&&null!==(c=r.options)&&void 0!==c&&c.carrierInsuranceAmountActive&&null!==r&&void 0!==r&&null!==(u=r.options)&&void 0!==u&&u.carrierInsuranceAmountAutomatic){const e=(0,g.QB)(l,r);r.options=(0,i.A)({},r.options),r.options.carrierInsuranceAmount=e}}return r});a.splice(j,1),c("shipments",a),0!==j&&f(j-1)})({index:d,products:h,weights:v.weights,box:v.box,packagings:v.packagings,dryIce:{weight:null===v||void 0===v||null===(N=v.options)||void 0===N?void 0:N.dryIceWeight,unit:null===v||void 0===v||null===(C=v.options)||void 0===C?void 0:C.dryIceUnit,active:null===v||void 0===v||null===(k=v.options)||void 0===k?void 0:k.dryIceActive}})},ie=e=>{let t=e.product,l=e.prodIndex,i=e.index,s=e.isLast,n=e.hasBranchPackagings;return(0,Y.jsxs)("tr",{style:{backgroundColor:"rgb(231, 148, 47, 0.1)"},children:[(0,Y.jsx)("td",{style:{padding:"10px 0 10px 5px",borderBottomLeftRadius:s&&!n?8:"none"},children:t.title}),(0,Y.jsx)("td",{style:{padding:"10px 0 10px 20px"},children:t.quantity}),(0,Y.jsx)("td",{style:{padding:"10px 0 10px 30px"},children:(0,be.toCurrencyFormat)(t.price)}),(0,Y.jsxs)("td",{style:{padding:"10px 0 10px 25px"},children:[t.dimensions.weight.value,t.dimensions.weight.units]}),(0,Y.jsx)("td",{style:{borderBottomRightRadius:s&&!n?8:"none"}})]},"".concat(t.title,"-").concat(l,"-").concat(i))};return(0,Y.jsxs)("div",{className:"tw-p-4",style:{borderColor:Object.values(m).length&&m[null===u||void 0===u?void 0:u.id]?"#CA4941":"white"},children:[(0,Y.jsxs)("div",{className:"tw-flex tw-flex-wrap tw-justify-between tw-items-center tw-gap-2",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:"Products"}),(0,Y.jsx)($.A,{information:z.A.PRODUCT_INFO})]}),(0,Y.jsxs)("div",{className:"tw-flex tw-flex-wrap tw-items-center tw-gap-2",children:[null!==x&&void 0!==x&&x.isBoxPackingAlgoApplied?null:(0,Y.jsx)(Le.L0,{feature:Le.cc.box_packing_algo,isClickable:!0,children:(0,Y.jsx)(A.ND,{isPaywalled:X,buttonText:"Split Boxes By",textStyle:{textTransform:"none"},textProps:{variant:"button"},disablePortal:!0,buttonProps:{disabled:v||!h||!(null!==r&&void 0!==r&&r.length)||!Q||!(null!==x&&void 0!==x&&x.warehouse),variant:"outlined",color:"secondary",paywalledFeature:Le.cc.box_packing_algo,size:"small"},renderMenu:e=>{let t=e.handleListKeyDown,l=e.open,s=e.handleClose;return(0,Y.jsxs)(A.cO,{autoFocusItem:l,onKeyDown:t,children:[(0,Y.jsx)(A.Dr,{onClick:()=>{y((0,i.A)((0,i.A)({},x),{},{useBoxPackingAlgo:!0,useBoxPackingAlgoQuantity:!1,useBoxPackingAlgoWeight:!1})),s()},children:(0,Y.jsx)("span",{className:"flex align-items-baseline",children:"Product Dimensions"})}),(0,Y.jsx)(A.Dr,{onClick:()=>{y((0,i.A)((0,i.A)({},x),{},{useBoxPackingAlgo:!1,useBoxPackingAlgoQuantity:!0,useBoxPackingAlgoWeight:!1})),s()},children:(0,Y.jsx)("span",{className:"flex align-items-baseline",children:"Product Quantity"})}),(0,Y.jsx)(A.Dr,{onClick:()=>{y((0,i.A)((0,i.A)({},x),{},{useBoxPackingAlgo:!1,useBoxPackingAlgoQuantity:!1,useBoxPackingAlgoWeight:!0})),s()},children:(0,Y.jsx)("span",{className:"flex align-items-baseline",children:"Product Weight"})})]})}})}),(0,Y.jsxs)(A.$n,{"aria-label":"Add Product",disabled:v||!h||(null===u||void 0===u||null===(a=u.box)||void 0===a?void 0:a.id)===Wt.jy.id,variant:"outlined",onClick:()=>{F(null),E(!0)},className:b.addButton,size:"small",children:[(0,Y.jsx)(S.OMN,{}),"Add Product"]})]})]}),(0,Y.jsxs)(A.az,{sx:{maxWidth:"100%",overflow:"auto","&::-webkit-scrollbar":{height:3,width:3}},className:"tw-mt-4",children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-center tw-w-full tw-my-1",children:(0,Y.jsx)(W.l6,{name:"Search Products",placeholder:"Search Products",onChange:e=>{var t,l,s,n,d,o,a,r,v,h,m;const p=(0,i.A)((0,i.A)({},(null===e||void 0===e?void 0:e.product)||{}),{},{quantity:1,price:null===e||void 0===e||null===(t=e.product)||void 0===t?void 0:t.price}),w=(0,zt.v)({from:null!==(l=null===p||void 0===p||null===(s=p.dimensions)||void 0===s||null===(n=s.weight)||void 0===n?void 0:n.units)&&void 0!==l?l:L.Ay.POUNDS,value:parseFloat((null===p||void 0===p||null===(d=p.dimensions)||void 0===d||null===(o=d.weight)||void 0===o?void 0:o.value)||0)})[L.Ay.POUNDS];p.dimensions.weight={units:L.Ay.POUNDS,value:parseFloat((0,be.floatToTwo)(w))};const x=u.products,g=u.weights,f=u.box,y=u.packagings,b=[...x];b.push((0,i.A)({},p)),c("shipments[".concat(j,"].products"),[...b]);let A=[...y];null!==p&&void 0!==p&&p.kitting&&null!==p&&void 0!==p&&null!==(a=p.kitting)&&void 0!==a&&null!==(r=a.branchPackagings)&&void 0!==r&&r.length?(A=[],c("shipments[".concat(j,"].packagings"),A)):(A=[...y].filter(e=>![Vt.GX.LINER,Vt.GX.COOLANT].includes(null===e||void 0===e?void 0:e.packagingType)),null!==f&&void 0!==f&&f.hasLiner&&A.push(f.liner),null!==f&&void 0!==f&&f.hasIcePack&&A.push(f.coolant),c("shipments[".concat(j,"].packagings"),A)),te({updatedProducts:b,box:f,weights:g,packagings:A,dryIce:{weight:null===u||void 0===u||null===(v=u.options)||void 0===v?void 0:v.dryIceWeight,unit:null===u||void 0===u||null===(h=u.options)||void 0===h?void 0:h.dryIceUnit,active:null===u||void 0===u||null===(m=u.options)||void 0===m?void 0:m.dryIceActive}})},loadOptions:Nt.SA,hideSelected:!0,disabled:v||!h,className:"tw-relative tw-rounded-md tw-shadow-sm tw-max-w-md tw-ml-auto tw-mr-auto"})}),(0,Y.jsxs)("table",{className:"tw-mt-4 tw-pt-0 tw-pl-4",children:[(0,Y.jsx)("thead",{className:"tw-mb-2",children:(0,Y.jsx)("tr",{children:null!==r&&void 0!==r&&r.length?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("th",{scope:"col",align:"left",children:"Product"}),(0,Y.jsx)("th",{scope:"col",align:"left",style:{paddingLeft:10},children:"Qty."}),(0,Y.jsx)("th",{scope:"col",align:"left",style:{paddingLeft:10},children:"Price"}),(0,Y.jsx)("th",{scope:"col",align:"left",style:{paddingLeft:10},children:"Weight(lb)"}),(0,Y.jsx)("th",{scope:"col",align:"left"})]}):null})}),(0,Y.jsx)("tbody",{children:(0,Y.jsx)(A.ED,{name:"shipments[".concat(j,"].products"),render:e=>(0,Y.jsxs)(Y.Fragment,{children:[null===r||void 0===r?void 0:r.map((t,l)=>{var s,d,o,a,r,m,f,y,b,N,k,I,D,O,R,P,_,T,W,L,V,z,$,Z,q,G,K,Q,X,se;const ne=(null===p||void 0===p||null===(s=p.shipments)||void 0===s||null===(d=s[j])||void 0===d||null===(o=d.products)||void 0===o||null===(a=o[l])||void 0===a||null===(r=a.dimensions)||void 0===r||null===(m=r.weight)||void 0===m?void 0:m.value)||(null===p||void 0===p||null===(f=p.shipments)||void 0===f||null===(y=f[j])||void 0===y||null===(b=y.products)||void 0===b||null===(N=b[l])||void 0===N?void 0:N.price)||(null===p||void 0===p||null===(k=p.shipments)||void 0===k||null===(I=k[j])||void 0===I||null===(D=I.products)||void 0===D||null===(O=D[l])||void 0===O?void 0:O.quantity);return(0,Y.jsxs)(n.Fragment,{children:[(0,Y.jsxs)("tr",{className:"".concat(null!==t&&void 0!==t&&t.kitting?"tw-mb-2":"tw-mb-4"),children:[(0,Y.jsx)("td",{style:{width:"100%"},className:"tw-w-full lg:tw-flex-1 -tw-mb-2 lg:-tw-mb-0 ".concat(null!==t&&void 0!==t&&t.kitting?"tw-py-2":"tw-py-4"),children:null===t||void 0===t?void 0:t.t
2itle}),(0,Y.jsx)("td",{style:{minWidth:84,paddingLeft:10},className:"".concat(null!==t&&void 0!==t&&t.kitting?"tw-py-2":"tw-py-4"),children:(0,Y.jsx)(A.D0,{id:"shipments[".concat(j,"].products[").concat(l,"].quantity"),name:"shipments[".concat(j,"].products[").concat(l,"].quantity"),component:M.A,align:"right",type:"number",min:1,debounced:e=>{var t,s,n;const d=u.products,o=u.weights,a=u.box,r=u.packagings,c=[...d],v=(0,i.A)({},c[l]);v.quantity=e,c[l]=v,te({updatedProducts:c,box:a,weights:o,packagings:r,dryIce:{weight:null===u||void 0===u||null===(t=u.options)||void 0===t?void 0:t.dryIceWeight,unit:null===u||void 0===u||null===(s=u.options)||void 0===s?void 0:s.dryIceUnit,active:null===u||void 0===u||null===(n=u.options)||void 0===n?void 0:n.dryIceActive}})},disabled:v||!h,onChange:()=>c(),noErrMsg:!0,onFocus:e=>e.target.select(),isRequired:!0,className:"search-field"})}),(0,Y.jsx)("td",{style:{minWidth:100,paddingLeft:10},className:"".concat(null!==t&&void 0!==t&&t.kitting?"tw-py-2":"tw-py-4"),children:(0,Lt.JO)(w)&&t.kitting?(0,Y.jsx)(A.o5,{style:{marginLeft:15},children:(0,Lt.c4)(t)}):(0,Y.jsx)(A.D0,{id:"shipments[".concat(j,"].products[").concat(l,"].price"),name:"shipments[".concat(j,"].products[").concat(l,"].price"),component:M.A,align:"right",disabled:v||!h,onChange:()=>c(),noErrMsg:!0,prefix:"$",hideWebkitButton:!0,type:"number",onFocus:e=>e.target.select(),className:"search-field",debounced:e=>{var t,s;const n=[...u.products],d=(0,i.A)((0,i.A)({},n[l]),{},{price:e});n[l]=d;const o=(0,g.QB)(n,u);null!==u&&void 0!==u&&null!==(t=u.options)&&void 0!==t&&t.carrierInsuranceAmountActive&&null!==u&&void 0!==u&&null!==(s=u.options)&&void 0!==s&&s.carrierInsuranceAmountAutomatic&&c("shipments[".concat(j,"].options.carrierInsuranceAmount"),o),ee({insuredValue:o})}})}),(0,Y.jsx)("td",{style:{minWidth:80,paddingLeft:10},className:"".concat(null!==t&&void 0!==t&&t.kitting?"tw-py-2":"tw-py-4"),children:(0,Lt.JO)(w)&&t.kitting?(0,Y.jsx)(A.o5,{style:{marginLeft:15},children:(0,Lt.Dx)((0,i.A)((0,i.A)({},t.kitting),{},{user:w})).totalWeightInLb}):(0,Y.jsx)(A.D0,{id:"shipments[".concat(j,"].products[").concat(l,"].dimensions.weight.value"),name:"shipments[".concat(j,"].products[").concat(l,"].dimensions.weight.value"),component:M.A,align:"right",disabled:v||!h,onChange:()=>c(),debounced:e=>{var t,s,n;const d=u.products,o=u.weights,a=u.box,r=u.packagings,c=[...d],v=(0,i.A)((0,i.A)({},c[l]),{},{dimensions:(0,i.A)((0,i.A)({},c[l].dimensions),{},{weight:(0,i.A)((0,i.A)({},c[l].dimensions.weight),{},{value:e})})});c[l]=v,te({updatedProducts:c,box:a,weights:o,packagings:r,dryIce:{weight:null===u||void 0===u||null===(t=u.options)||void 0===t?void 0:t.dryIceWeight,unit:null===u||void 0===u||null===(s=u.options)||void 0===s?void 0:s.dryIceUnit,active:null===u||void 0===u||null===(n=u.options)||void 0===n?void 0:n.dryIceActive}})},noErrMsg:!0,type:"number",max:(0,Tt.k0)(null===u||void 0===u||null===(R=u.products[l])||void 0===R||null===(P=R.dimensions)||void 0===P||null===(_=P.weight)||void 0===_?void 0:_.units),onFocus:e=>e.target.select(),validate:"custom"!==(null===u||void 0===u||null===(T=u.weights)||void 0===T?void 0:T.type)?(0,Tt.mD)(null===u||void 0===u||null===(W=u.products[l])||void 0===W||null===(L=W.dimensions)||void 0===L||null===(V=L.weight)||void 0===V?void 0:V.units,!0):null,className:"search-field",suffix:"lb"})}),(0,Y.jsx)("td",{className:"".concat(null!==t&&void 0!==t&&t.kitting?"tw-py-2":"tw-py-4"),children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center",children:[(0,Lt.JO)(w)&&t.kitting?(0,Lt.v6)(t,w,{showKit:H,handleOnClickKit:J,kitRef:C,index:l}):null,(0,Y.jsx)(A.m_,{title:"Remove product",children:(0,Y.jsx)(A.$n,{iconButton:!0,"aria-label":"Remove",disabled:v||!h,variant:"text",style:{paddingLeft:5,paddingRight:0,paddingTop:0},onClick:()=>{var t,i,s;e.remove(l);const n=u.products,d=u.weights,o=u.box,a=u.packagings;let r=[...n];delete r[l],r=r.filter(e=>e),te({updatedProducts:r,box:o,weights:d,packagings:a,dryIce:{weight:null===u||void 0===u||null===(t=u.options)||void 0===t?void 0:t.dryIceWeight,unit:null===u||void 0===u||null===(i=u.options)||void 0===i?void 0:i.dryIceUnit,active:null===u||void 0===u||null===(s=u.options)||void 0===s?void 0:s.dryIceActive}})},children:(0,Y.jsx)(S.epd,{width:28,height:30,fill:"#5f6368"})})}
2),(0,Y.jsx)(A.m_,{title:"Edit product",children:(0,Y.jsx)(A.$n,{iconButton:!0,"aria-label":"Edit",disabled:v||!h,variant:"text",style:{paddingLeft:5,paddingRight:0,paddingTop:0},onClick:()=>{F({editableProduct:(0,i.A)({},t),callBackFunc:e=>{var s,n,d;const o=(0,i.A)((0,i.A)({},e||{}),{},{quantity:t.quantity}),a=u.products,r=u.weights,v=u.box,h=u.packagings,m=[...a];m[l]=(0,i.A)({},o),c("shipments[".concat(j,"].products"),m),te({updatedProducts:m,box:v,weights:r,packagings:h,dryIce:{weight:null===u||void 0===u||null===(s=u.options)||void 0===s?void 0:s.dryIceWeight,unit:null===u||void 0===u||null===(n=u.options)||void 0===n?void 0:n.dryIceUnit,active:null===u||void 0===u||null===(d=u.options)||void 0===d?void 0:d.dryIceActive}})}}),E(!0)},children:(0,Y.jsx)(S.iyF,{width:28,height:30,fill:"#5f6368"})})}),(null===x||void 0===x||null===(z=x.shipments)||void 0===z?void 0:z.length)>1&&(null===t||void 0===t||!t.kitting)?(0,Y.jsx)(A.ND,{icon:(0,Y.jsx)(A.m_,{title:"Move item to another shipment",children:(0,Y.jsx)("div",{className:"tw-flex tw-items-center",children:(0,Y.jsx)(S.rx0,{})})}),buttonProps:{variant:"text",size:"small",color:"default",iconButton:!0,style:{paddingLeft:5,paddingRight:0,paddingTop:0,display:"flex",alignItems:"center"},disabled:v||!h,disableToggle:2===(null===x||void 0===x||null===($=x.shipments)||void 0===$?void 0:$.length)&&1===parseInt((null===t||void 0===t?void 0:t.quantity)||0),handleClick:()=>{var i;if(2===(null===x||void 0===x||null===(i=x.shipments)||void 0===i?void 0:i.length)&&1===parseInt((null===t||void 0===t?void 0:t.quantity)||0)){e.remove(l);le({itemIndex:l,targetIndex:0===j?1:0,quantity:1})}else B(t.quantity)}},stopPropagation:2===(null===x||void 0===x||null===(Z=x.shipments)||void 0===Z?void 0:Z.length)&&1===parseInt((null===t||void 0===t?void 0:t.quantity)||0),renderMenu:i=>{let s=i.handleClose,n=i.handleListKeyDown;return(0,Y.jsxs)("div",{className:"tw-p-4 tw-min-w-48 tw-flex tw-flex-col tw-gap-2",children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)(A.o5,{variant:"caption",component:"div",children:(0,Y.jsx)("b",{children:"Quantity"})}),(0,Y.jsx)("div",{className:"tw-max-w-24",children:(0,Y.jsx)(A.A_,{type:"number",value:U,onChange:e=>B(e.target.value),variant:"outlined",margin:"dense",max:t.quantity,onFocus:e=>e.target.select(),style:{margin:0}})})]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)(A.o5,{variant:"caption",component:"div",children:(0,Y.jsx)("b",{children:"Select target shipment"})}),(0,Y.jsx)(A.cO,{onKeyDown:n,children:x.shipments.map((i,n)=>(null===i||void 0===i?void 0:i.id)===(null===u||void 0===u?void 0:u.id)?null:(0,Y.jsxs)(A.Dr,{onClick:()=>{let i=t.quantity;if(U)i=U;else if(0===U)return;e.remove(l);le({itemIndex:l,targetIndex:n,quantity:i}),s()},children:["Shipment ",n+1]},n))})]})]})}}):null]})})]},l),null!==(q=t.kitting)&&void 0!==q&&null!==(G=q.branchProducts)&&void 0!==G&&G.length?null===(K=t.kitting)||void 0===K?void 0:K.branchProducts.map((e,i)=>{var s,n,d,o;const a=null===(s=t.kitting)||void 0===s||null===(n=s.branchPackagings)||void 0===n?void 0:n.length,r=i+1===(null===(d=t.kitting)||void 0===d||null===(o=d.branchProducts)||void 0===o?void 0:o.length);return ie({product:e,prodIndex:i,index:l,isLast:r,hasBranchPackagings:a})}):null,null!==(Q=t.kitting)&&void 0!==Q&&null!==(X=Q.branchPackagings)&&void 0!==X&&X.length?null===(se=t.kitting)||void 0===se?void 0:se.branchPackagings.map((e,i)=>{var s,n;const d=i+1===(null===(s=t.kitting)||void 0===s||null===(n=s.branchPackagings)||void 0===n?void 0:n.length);return ie({product:e,prodIndex:i,index:l,isLast:d})}):null,ne?(0,Y.jsx)("tr",{children:(0,Y.jsx)("td",{colSpan:"5",className:"tw-p-0",children:(0,Y.jsx)(nt.A,{className:"tw-w-full",children:ne})})}):null]},l)}),(0,Y.jsx)("tr",{children:(0,Y.jsx)("td",{ref:N,onClick:()=>{e.push({quantity:"1",price:"0.00",dimensions:{weight:{units:K,value:0}}}),c()}})})]})})})]})]}),(0,Y.jsx)(Ut.A,{handleClose:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(e){var t,l,s;const n=(0,i.A)((0,i.A)({},e||{}),{},{price:(null===e||void 0===e?void 0:e.price)||"0.00",quantity:"1"}),d=u.products,o=u.weights,a=u.box,r=u.packagings,v=[...d,n];c("shipments[".concat(j,"].products"),v),te({updatedProducts:v,box:a,weights:o,packagings:r,dryIce:{weight:null===u||void 0===u||null===(t=u.options)||void 0===t?void 0:t.dryIceWeight,unit:null===u||void 0===u||null===(l=u.options)||void 0===l?void 0:l.dryIceUnit,active:null===u||void 0===u||null===(s=u.options)||void 0===s?void 0:s.dryIceActive}})}E(!1)},active:D,setRefreshCounter:()=>{},setEditableProduct:()=>{},setSelectedItems:()=>{},closeAfterSubmit:!0,editableProduct:null===P||void 0===P?void 0:P.editableProduct,callBackFunc:null===P||void 0===P?void 0:P.callBackFunc})]})};var Zt=l(57463),Ht=l(38262),qt=l(40673);const Gt={width:{xs:"calc(100vw - 32px)",sm:450},maxWidth:"calc(100vw - 32px)",border:"1px solid rgba(0, 0, 0, 0.12)",borderRadius:2,zIndex:999999},Kt=e=>({background:e.palette.background.paper}),Yt=e=>{let t=e.icon,l=e.logo,i=e.name,s=e.dimensions,n=e.weight,d=e.onClickEdit,o=e.showEditIcon,a=void 0===o||o,r=e.onOpen;return(0,Y.jsxs)("div",{className:"flex align-items-center !tw-pl-4 !tw-pr-8 !tw-pt-2 !tw-pb-2",onClick:r,children:[(0,Y.jsxs)("div",{className:"flex align-items-center tw-truncate",children:[t&&(0,Y.jsx)("div",{style:{marginRight:"15px"},children:t}),l&&(0,Y.jsx)("img",{src:l,alt:i,style:{marginRight:"15px",width:50,height:"auto"}}),(0,Y.jsxs)("div",{className:"tw-truncate",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:i}),(0,Y.jsxs)("div",{className:"tw-truncate",children:[s,n&&", ".concat(n.value," ").concat(n.units)]})]})]}),a&&(0,Y.jsx)("div",{className:"tw-ml-auto tw-flex tw-items-center tw-px-1",children:(0,Y.jsx)(S.ffu,{className:"tw-z-30",onClick:e=>{e.preventDefault(),e.stopPropagation(),d()}})})]})},Qt=e=>{var t,l,o,a;let r=e.boxValues,u=e.setFieldValue,v=e.weights,h=e.products,m=e.isLoading,p=e.isEditable,w=e.options,x=e.packagings,g=e.currentShipmentIndex,j=e.values,f=e.user,y=e.weatherData,b=e.defenseData,N=e.buttonClasse
2s;const C=(0,n.useState)(null),k=(0,s.A)(C,2),I=k[0],D=k[1],E=(0,n.useState)(null),O=(0,s.A)(E,2),R=O[0],P=O[1],F=(0,n.useState)(!1),_=(0,s.A)(F,2),T=_[0],W=_[1],M=(0,n.useState)(!1),U=(0,s.A)(M,2),B=U[0],V=U[1],Z=(0,c.A)(),H=(0,Et.A)({user:f,values:j}).renderWeather,G=(0,d.useSelector)(e=>{var t,l;return null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.user)||void 0===l?void 0:l.boxes}),K=(0,d.useSelector)(e=>{var t,l,i,s,n,d,o,a,r,c;return!(null===e||void 0===e||null===(t=e.auth)||void 0===t||null===(l=t.easypostCarrierAccounts)||void 0===l||!l.find(e=>"FedexAccount"===(null===e||void 0===e?void 0:e.type)))||!(null===e||void 0===e||null===(i=e.auth)||void 0===i||null===(s=i.user)||void 0===s||null===(n=s.vndrRatesConfig)||void 0===n||null===(d=n.fedex)||void 0===d||!d.active||null===e||void 0===e||null===(o=e.auth)||void 0===o||null===(a=o.user)||void 0===a||null===(r=a.vndrRatesConfig)||void 0===r||null===(c=r.fedex)||void 0===c||!c.allowed)}),Q=(0,xt.DT)({boxes:G}),X=!!Wt.ib.find(e=>e.id===(null===r||void 0===r?void 0:r.id));(0,n.useEffect)(()=>{const e=(null===r||void 0===r?void 0:r.id)||(null===Q||void 0===Q?void 0:Q.id)||"";null!==I&&I===e||(D(e),null!==r&&void 0!==r&&r.isCustom&&P(r))},[r,Q]);const J=e=>{var t,l,i,s;let n=e.selectedBoxId,d=e.newBox;d&&D(n);let o=d;o||(o=(null===R||void 0===R?void 0:R.id)===n?R:null),o||(o=(null===Wt.jy||void 0===Wt.jy?void 0:Wt.jy.id)===n?Wt.jy:null),o||(o=Wt.ib.find(e=>e.id===n)),o||(o=null===G||void 0===G?void 0:G.find(e=>e.id===n));const a={weight:w.dryIceWeight,unit:w.dryIceUnit,active:null===w||void 0===w?void 0:w.dryIceActive};null!==(t=o)&&void 0!==t&&t.hasDryIce?(u("shipments[".concat(g,"].options.dryIceActive"),!0),u("shipments[".concat(g,"].options.dryIceWeight"),o.dryIceWeight),u("shipments[".concat(g,"].options.dryIceUnit"),o.dryIceWeightUnit||(null===f||void 0===f?void 0:f.defaultWeightUnits)||L.Ay.POUNDS),a.weight=o.dryIceWeight,a.unit=o.dryIceWeightUnit||(null===f||void 0===f?void 0:f.defaultWeightUnits)||L.Ay.POUNDS,a.active=!0):(u("shipments[".concat(g,"].options.dryIceActive"),!1),u("shipments[".concat(g,"].options.dryIceWeight"),0),a.weight=0,a.unit=o.dryIceWeightUnit||(null===f||void 0===f?void 0:f.defaultWeightUnits)||L.Ay.POUNDS,a.active=!1);let r=[...x].filter(e=>![Vt.GX.LINER,Vt.GX.COOLANT].includes(null===e||void 0===e?void 0:e.packagingType));if(null!==(l=o)&&void 0!==l&&l.hasLiner&&r.push(o.liner),null!==(i=o)&&void 0!==i&&i.hasIcePack&&r.push(o.coolant),"product"===v.type||n===Wt.jy.id){let e=[...h];n===Wt.jy.id&&(e=[],r=[]);const t=(0,_t.A)({box:o,products:e,packagings:r,user:f,dryIce:a}),l=(0,yt.jM)(v,e=>{e.calculatedValues=t,n===Wt.jy.id&&(e.type="product")});u("shipments[".concat(g,"].weights"),l),u("shipments[".concat(g,"].box"),o),u("shipments[".concat(g,"].products"),e),u("shipments[".concat(g,"].packagings"),r)}else u("shipments[".concat(g,"].box"),o),u("shipments[".concat(g,"].packagings"),r);null!==(s=o)&&void 0!==s&&s.isUPSExpressLetter&&null!==w&&void 0!==w&&w.dry_ice_active&&u("shipments[".concat(g,"].options.dryIceActive"),!1)},ee=()=>{p&&D("edit-box")},te=()=>{p&&V(!0)};return(0,Y.jsxs)("div",{className:"tw-p-4 tw-pb-2",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:(0,Lt.JO)(f)?"Box":"Package"}),(0,Y.jsx)($.A,{information:z.A.SHIPMENT_BOX}),(0,Y.jsx)(qt.A,{weatherData:y,renderWeather:H,values:j,preferredRate:(null===j||void 0===j||null===(t=j.shipments)||void 0===t||null===(l=t[g])||void 0===l?void 0:l.preferredRate)||(null===f||void 0===f?void 0:f.defaultSelectedRate),defenseData:b})]}),(0,Y.jsxs)(A.$n,{variant:"outlined",onClick:()=>{D("create-new-box"),V(!1)},disabled:T||m||!p,className:null===N||void 0===N?void 0:N.addButton,size:"small",children:[(0,Y.jsx)(S.OMN,{}),"Add Box"]})]}),(0,Y.jsxs)("div",{className:"tw-pt-0 tw-pl-4 tw-pt-2",children:[(0,Y.jsx)(A.MJ,{sx:{minWidth:120,width:"100%",margin:"".concat(Z.spacing(1)," 0")},margin:"dense",children:(0,Y.jsxs)(A.l6,{variant:"outlined",value:(null===r||void 0===r?void 0:r.id)||"",id:"select-box",onChange:e=>{const t=e.target.value;t&&t!==I&&(D(t),"create-new-box"!==t&&"custom-dimensions"!==t&&"custom-box"!==t&&J({selectedBoxId:t}))},disabled:T||m||!p,open:B,onClose:()=>V(!1),renderValue:e=>{if(!e)return"Choose Box";if(r)return(0,Y.jsx)(Yt,{icon:(0,Y.jsx)(Zt.A,{}),onClickEdit:ee,onOpen:te,name:r.name,dimensions:(0,Vt.JD)(r),showEditIcon:p});if((null===Wt.jy||void 0===Wt.jy?void 0:Wt.jy.id)===e)return(0,Y.jsx)(Yt,{logo:Wt.jy.logo,name:Wt.jy.name,onOpen:te,onClickEdit:()=>D("edit-box"),dimensions:"".concat(Wt.jy.dimensions.length,'" x ').concat(Wt.jy.dimensions.width,'" x ').concat(Wt.jy.dimensions.height,'"'),weight:Wt.jy.weight,showEditIcon:p});const t=Wt.ib.find(t=>
2t.id===e);return t?(0,Y.jsx)(Yt,{logo:q.lY.fedex,name:t.name,onOpen:()=>V(!0),onClickEdit:te,dimensions:"".concat(t.dimensions.length,'" x ').concat(t.dimensions.width,'" x ').concat(t.dimensions.height,'"'),weight:t.weight,showEditIcon:p}):"Choose Box"},useDefaultPadding:!1,MenuProps:{PaperProps:{sx:Gt}},iconStyle:{top:void 0,marginTop:-5},children:[(0,Y.jsxs)(A.a6,{sx:Kt,className:"tw-flex tw-justify-between tw-items-center",children:[(0,Y.jsx)("span",{style:{color:Z.palette.primary.main},children:"Choose Box"}),(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-ml-auto",children:(0,Y.jsx)(S.OMN,{className:"tw-cursor-pointer",onClick:()=>{D("create-new-box"),V(!1)}})})]}),(()=>{let e=null===G||void 0===G?void 0:G.map(e=>(0,Y.jsx)(A.Dr,{value:null===e||void 0===e?void 0:e.id,sx:{overflow:"hidden"},children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-0 tw-w-full",children:[(0,Y.jsx)("div",{style:{marginRight:"15px",flexShrink:0},children:(0,Y.jsx)(Zt.A,{})}),(0,Y.jsxs)("div",{className:"tw-min-w-0 tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:null===e||void 0===e?void 0:e.name}),(0,Y.jsx)("div",{className:"tw-truncate tw-text-xs tw-text-gray-600",children:(0,Vt.JD)(e)})]})]})},null===e||void 0===e?void 0:e.id));var t,l,i,s,n;R&&(e=[(0,Y.jsx)(A.Dr,{value:null===R||void 0===R?void 0:R.id,sx:{overflow:"hidden"},children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-0 tw-w-full",children:[(0,Y.jsx)("div",{style:{marginRight:"15px",flexShrink:0},children:(0,Y.jsx)(Zt.A,{})}),(0,Y.jsxs)("div",{className:"tw-min-w-0 tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:R.name}),(0,Y.jsxs)("div",{className:"tw-truncate tw-text-xs tw-text-gray-600",children:[null===R||void 0===R||null===(t=R.dimensions)||void 0===t?void 0:t.length,'"'," x ",null===R||void 0===R||null===(l=R.dimensions)||void 0===l?void 0:l.width,'"'," x ",null===R||void 0===R||null===(i=R.dimensions)||void 0===i?void 0:i.height,'"',", ",null===R||void 0===R||null===(s=R.weight)||void 0===s?void 0:s.value," ",null===R||void 0===R||null===(n=R.weight)||void 0===n?void 0:n.units]})]})]})},null===R||void 0===R?void 0:R.id),...e||[]]);return e})(),(0,Y.jsx)(A.a6,{sx:Kt,children:(0,Y.jsx)("span",{style:{color:Z.palette.primary.main},children:"Letter"})}),(0,Y.jsx)(A.Dr,{value:Wt.jy.id,sx:{overflow:"hidden"},children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-0 tw-w-full",children:[(0,Y.jsx)("img",{src:Wt.jy.logo,alt:Wt.jy.name,style:{marginRight:"15px",width:50,height:"auto",flexShrink:0}}),(0,Y.jsxs)("div",{className:"tw-min-w-0 tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:Wt.jy.name}),(0,Y.jsxs)("div",{className:"tw-truncate tw-text-xs tw-text-gray-600",children:[null===(o=Wt.jy.dimensions)||void 0===o?void 0:o.length,'"'," x ",Wt.jy.dimensions.width,'"'," x ",Wt.jy.dimensions.height,'"',", ",Wt.jy.weight.value," ",Wt.jy.weight.units]})]})]})},Wt.jy.id),K?(0,Y.jsx)(A.a6,{sx:Kt,children:(0,Y.jsx)("span",{style:{color:Z.palette.primary.main},children:"FedEx Standard Boxes"})}):null,K?Wt.ib.map(e=>{var t;return(0,Y.jsx)(A.Dr,{value:e.id,sx:{overflow:"hidden"},children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-0 tw-w-full",children:[(0,Y.jsx)("img",{src:q.lY.fedex,alt:e.carrier,style:{marginRight:"15px",width:50,height:"auto",flexShrink:0}}),(0,Y.jsxs)("div",{className:"tw-min-w-0 tw-flex-1",children:[(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary tw-truncate",children:e.name}),(0,Y.jsxs)("div",{className:"tw-truncate tw-text-xs tw-text-gray-600",children:[null===(t=e.dimensions)||void 0===t?void 0:t.length,'"'," x ",e.dimensions.width,'"'," x ",e.dimensions.height,'"',", ",e.weight.value," ",e.weight.units]})]})]})},e.id)}):null]})}),X&&(null===v||void 0===v||null===(a=v.calculatedValues)||void 0===a?void 0:a.pounds)>=50?(0,Y.jsx)(A.o5,{color:"secondary",style:{fontSize:14},children:"You can only ship upto 50 lbs using FedEx Standard Boxes"}):null]}),(0,Y.jsx)(Ht.A,{initialValues:"edit-box"===I?(0,i.A)({},r):null,submittingBox:e=>{W(e)},handleClose:e=>{let t=e.box;t&&t.name?(t.isCustom&&P(t),J({selectedBoxId:t.id,newBox:t})):D((null===r||void 0===r?void 0:r.id)||(null===Q||void 0===Q?void 0:Q.id)||"")},active:["edit-box","create-new-box","custom-box"].includes(I),editBox:"edit-box"===I,preventCreateOrUpdate:"edit-box"===I,showSaveCheckbox:!0,submittingNewBox:T,packageEdit:!0})]})};var Xt=l(22261);const Jt=e=>{var t,l,o,a;let r=e.values,c=e.setFieldValue,u=e.isLoading,v=e.isEditable,h=e.shipment,m=e.errors,p=e.currentShipmentIndex,w=e.curShipment;const x=w.products,g=void 0===x?[]:x,j=w.weights,f=w.box,y=w.packagings,b=void 0===y?[]:y,S=w.options,N=(0,d.useSelector)(e=>e.auth.user),C=n.useState({}),k=(0,s.A)(C,2),I=k[0],D=k[1],E=(0,He.J1)().withDryIceTermsCheck,O=()=>{if(u||!v||null!==f&&void 0!==f&&f.isUPSExpressLetter)return;const e=!(null!==r&&void 0!==r&&r.dryIceActive);if(e)E(()=>
2{if(c("shipments[".concat(p,"].options.dryIceActive"),!0),null!==r&&void 0!==r&&r.dryIceUnit||c("shipments[".concat(p,"].options.dryIceUnit"),L.Ay.POUNDS),"product"===j.type){const e=(0,_t.A)({box:f,products:g,packagings:b,user:N,dryIce:{weight:null===S||void 0===S?void 0:S.dryIceWeight,unit:null===S||void 0===S?void 0:S.dryIceUnit,active:!0}});c("shipments[".concat(p,"].weights"),(0,i.A)((0,i.A)({},j),{},{calculatedValues:e}))}});else if(c("shipments[".concat(p,"].options.dryIceActive"),!1),c(),"product"===j.type){const t=(0,_t.A)({box:f,products:g,packagings:b,user:N,dryIce:{weight:null===S||void 0===S?void 0:S.dryIceWeight,unit:null===S||void 0===S?void 0:S.dryIceUnit,active:e}}),l=(0,i.A)((0,i.A)({},j),{},{calculatedValues:t});c("shipments[".concat(p,"].weights"),l)}};let R;if(null!==h&&void 0!==h&&null!==(t=h.options)&&void 0!==t&&t.dryIceActive){var P,F,_;const e=L.rY[(null===h||void 0===h||null===(P=h.options)||void 0===P?void 0:P.dryIceUnit)||L.Ay.POUNDS];parseFloat((null===h||void 0===h||null===(F=h.options)||void 0===F?void 0:F.dryIceWeight)||0)>(null===h||void 0===h||null===(_=h.weights)||void 0===_?void 0:_.calculatedValues[e])&&(R="Dry Ice weight cannot be greater than Package Weight")}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-between tw-items-center tw-gap-4 tw-mt-2",children:(0,Y.jsx)("div",{className:"flex align-items-center justify-content-space-between",style:{width:"100%"},children:(0,Y.jsx)(A.dO,{checked:null===r||void 0===r?void 0:r.dryIceActive,value:null===r||void 0===r?void 0:r.dryIceActive,onChange:O,disabled:u||!v||(null===f||void 0===f?void 0:f.isUPSExpressLetter),label:(0,Y.jsxs)("div",{className:"flex align-items-center tw-gap-1",children:[(0,Y.jsx)("div",{onClick:O,style:{color:Object.values(m).length&&m[null===h||void 0===h?void 0:h.id]||I[p]||R?"#CA4941":"#49629d",cursor:u||!v||null!==f&&void 0!==f&&f.isUPSExpressLetter?"default":"pointer"},disabled:u||!v||(null===f||void 0===f?void 0:f.isUPSExpressLetter),className:"tw-text-xl tw-font-bold tw-text-secondary",children:"Dry Ice"}),(0,Y.jsx)($.A,{information:z.A.DRY_ICE})]})})})}),(0,Y.jsx)(Xt.A,{isActive:null===r||void 0===r?void 0:r.dryIceActive,weight:null===r||void 0===r?void 0:r.dryIceWeight,unit:null===r||void 0===r?void 0:r.dryIceUnit,shipmentId:null===h||void 0===h?void 0:h.id,rates:null===h||void 0===h?void 0:h.rates}),(0,Y.jsx)(A.SD,{in:!(null===r||void 0===r||!r.dryIceActive),className:"tw-pl-4",children:(0,Y.jsx)(A.$k,{className:"tw-mt-4",error:Object.values(m).length&&m[h.id]||I[p]||R,inputProps:{name:"shipments[".concat(p,"].options.dryIceWeight"),onChange:e=>{if(c("shipments[".concat(p,"].options.dryIceWeight"),e),"product"===j.type){const t=(0,_t.A)({box:f,products:g,packagings:b,user:N,dryIce:{weight:e,unit:null===S||void 0===S?void 0:S.dryIceUnit,active:null===S||void 0===S?void 0:S.dryIceActive}}),l=(0,i.A)((0,i.A)({},j),{},{calculatedValues:t});c("shipments[".concat(p,"].weights"),l)}},disabled:u||!v,isRequired:!0,placeholder:"Weight",max:(0,Tt.k0)(null===h||void 0===h||null===(l=h.options)||void 0===l?void 0:l.dryIceUnit),value:null===h||void 0===h||null===(o=h.options)||void 0===o?void 0:o.dryIceWeight,validate:e=>{var t;const l=(0,Tt.mD)(null===h||void 0===h||null===(t=h.options)||void 0===t?void 0:t.dryIceUnit)(e);D(l?{[p]:l}:{})}},selectProps:{options:Object.values(L.Ay).map(e=>({label:L.Ob[e],value:e})),onChange:e=>{if(c("shipments[".concat(p,"].options.dryIceUnit"),e),"product"===j.type){const t=(0,_t.A)({box:f,products:g,packagings:b,user:N,dryIce:{weight:null===S||void 0===S?void 0:S.dryIceWeight,unit:e,active:null===S||void 0===S?void 0:S.dryIceActive}}),l=(0,i.A)((0,i.A)({},j),{},{calculatedValues:t});c("shipments[".concat(p,"].weights"),l)}},disabled:u||!v,value:null===h||void 0===h||null===(a=h.options)||void 0===a?void 0:a.dryIceUnit,name:"shipments[".concat(p,"].options.dryIceUnit")},forDryIce:!0})})]})},el=e=>{let t=e.values,l=e.setFieldValue,i=e.shipment,s=e.isLoading,n=e.isEditable,d=e.errors,o=e.currentShipmentIndex,a=e.curShipment;return(0,Y.jsx)("div",{className:"tw-p-4",style:{borderColor:Object.values(d).length&&d[null===i||void 0===i?void 0:i.id]?"#CA4941":"white"},children:(0,Y.jsx)(Jt,{values:t,setFieldValue:l,isLoading:s,isEditable:n,shipment:i,errors:(null===d||void 0===d?void 0:d.dryIce)||{},currentShipmentIndex:o,curShipment:a})})};var tl=l(41023),ll=l(18387);const il=e=>{var t,l,i,d,o,a,r,c,u,v,h,m,p,w,x,g,j;let f=e.setFieldValue,y=e.weights,b=e.values,S=e.box,N=e.products,C=e.isLoading,k=e.isEditable,I=e.errors,D=void 0===I?{}:I,E=e.curShipment,O=e.packagings,R=e.user,P=e.currentShipmentIndex;const F=n.useState({}),_=(0,s.A)(F,2),T=_[0],W=_[1],M=e=>{let t=null===e||void 0===e?void 0:e.value;t||0===t||(t=y.customWeight.value);let l=null===e||void 0===e?void 0:e.units;l||(l=y.customWeight.units);const i=(0,zt.v)({from:l,value:t}),s={pounds:parseFloat(tl.GP(".4f")(i[L.Ay.POUNDS])),kilograms:parseFloat(tl.GP(".4f")(i[L.Ay.KILOGRAMS])),grams:parseFloat(tl.GP(".4f")(i[L.Ay.GRAMS])),ounces:parseFloat(tl.GP(".4f")(i[L.Ay.OUNCES]))},n=(0,yt.jM)(y,e=>{e.type="custom",e.customWeight.units=l,e.customWeight.value=t,e.calculatedValues=s});f("shipments[".concat(P,"].weights"),n)},U=[{label:"Products + Box Weight + Coolant",value:"product",action:()=>{var e,t,l;const i=(0,_t.A)({box:S,products:[...N],packagings:[...O],user:R,dryIce:{weight:null===E||void 0===E||null===(e=E.options)||void 0===e?void 0:e.dryIceWeight,unit:null===E||void 0===E||null===(t=E.options)||void 0===t?void 0:t.dryIceUnit,active:null===E||void 0===E||null===(l=E.options)||void 0===l?void 0:l.dryIceActive}}),s=(0,yt.jM)(y,e=>{e.type="product",e.calculatedValues=i});f("shipments[".concat(P,"].weights"),s)}},{label:"Custom Weight",value:"custom",dataCy:"rad-custom-weight-new-order",action:M}],B="custom"===(null===y||void 0===y?void 0:y.type),V=B?null===y||void 0===y||null===(t=y.customWeight)||void 0===t?void 0:t.units:null===y||void 0===y?void 0:y.weightToShow,z=B?null===E||void 0===E||null===(l=E.weights)||void 0===l||null===(i=l.customWeight)||void 0===i?void 0:i.value:null===y||void 0===y||null===(d=y.calculatedValues)||void 0===d?void 0:d[null===L.rY||void 0===L.rY?void 0:L.rY[null===y||void 0===y?void 0:y.weightToShow]],$=(0,Tt.mD)(V,!0)(z),Z=Object.values(D).length&&(null===D||void 0===D?void 0:D[null===E||void 0===E?void 0:E.id])||T[P]||$;return(0,Y.jsxs)("div",{className:"tw-p-4",style:{borderColor:Object.values(D).length&&null!==D&&void 0!==D&&D[null===E||void 0===E?void 0:E.id]||T[P]?"#CA4941":"white"},children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-between tw-gap-x-2 tw-mb-2",children:(0,Y.jsx)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:"Weight"})})}),(0,Y.jsxs)("div",{className:"tw-pt-0 tw-pl-4",children:[(0,Y.jsx)("div",{className:"tw-flex tw-flex-col sm:tw-flex-row tw-mt-4 tw-gap-2 sm:tw-gap-0",children:U.map((e,t)=>{var l;
2return(0,Y.jsx)(A.$n,{onClick:()=>{f("shipments[".concat(P,"].weights.type"),e.value),e.action()},variant:(null===y||void 0===y?void 0:y.type)===e.value?"contained":"outlined",color:(null===y||void 0===y?void 0:y.type)===e.value?"secondary":"inherit",disabled:C||!k||(null===E||void 0===E||null===(l=E.box)||void 0===l?void 0:l.id)===Wt.jy.id,className:"!tw-w-full sm:!tw-w-auto ".concat(0===t?"sm:tw-rounded-tr-none sm:tw-rounded-br-none":"sm:tw-rounded-tl-none sm:tw-rounded-bl-none"),children:e.label},t)})}),(0,Y.jsx)("div",{className:"tw-mt-6",children:(0,Y.jsx)(A.$k,{error:Z,inputProps:{name:"shipments[".concat(P,"].weights.customWeight.value"),onChange:e=>{M({value:e?parseFloat(e||0):0})},disabled:C||!k||(null===E||void 0===E||null===(o=E.box)||void 0===o?void 0:o.id)===Wt.jy.id||"custom"!==(null===y||void 0===y?void 0:y.type),isRequired:!0,max:(0,Tt.k0)(null===y||void 0===y||null===(a=y.customWeight)||void 0===a?void 0:a.units),placeholder:"Weight",value:"custom"!==(null===y||void 0===y?void 0:y.type)?(0,be.floatToTwo)((null===y||void 0===y||null===(r=y.calculatedValues)||void 0===r?void 0:r[null===L.rY||void 0===L.rY?void 0:L.rY[y.weightToShow]])||0):(null===E||void 0===E||null===(c=E.weights)||void 0===c||null===(u=c.customWeight)||void 0===u?void 0:u.value)||"",validate:e=>{var t;const l=(0,Tt.mD)(null===y||void 0===y||null===(t=y.customWeight)||void 0===t?void 0:t.units)(e);W(l?{[P]:l}:{})}},selectProps:{options:Object.values(L.Ay).map(e=>({label:L.Ob[e],value:e})),onChange:e=>{"custom"===(null===y||void 0===y?void 0:y.type)&&M({units:e})},disabled:C||!k||(null===E||void 0===E||null===(v=E.box)||void 0===v?void 0:v.id)===Wt.jy.id||"custom"!==(null===y||void 0===y?void 0:y.type),value:"custom"!==(null===y||void 0===y?void 0:y.type)?null===b||void 0===b||null===(h=b.shipments)||void 0===h||null===(m=h[P])||void 0===m||null===(p=m.weights)||void 0===p?void 0:p.weightToShow:null===b||void 0===b||null===(w=b.shipments)||void 0===w||null===(x=w[P])||void 0===x||null===(g=x.weights)||void 0===g||null===(j=g.customWeight)||void 0===j?void 0:j.units,name:"shipments[".concat(P,"].weights.customWeight.units")}})}),(0,Y.jsx)(ll.A,{weight:z,unit:V,hasExistingError:!!$,className:"tw-mt-4"}),(0,Y.jsx)(ot,{errorObject:null===E||void 0===E?void 0:E.error,isWeight:!0,className:"tw-mt-4"}),T[P]||$?(0,Y.jsx)(nt.A,{className:"tw-mt-4",children:T[P]||$}):null]})]})};var sl=l(95421);const nl=e=>{var t,l,d,o,a,r,c,v,h,p,w,x;let j=e.internationalSettings,f=e.isLoading,y=e.isEditable,b=e.setFieldValue,N=e.user,C=e.lineItems,k=e.errors,I=e.formikErrors,D=e.values,E=e.currentShipmentIndex,O=e.buttonClasses;const R=(0,u.useHistory)(),P=(0,n.useState)([]),F=(0,s.A)(P,2),_=F[0],T=F[1],W=(0,n.useState)(!1),L=(0,s.A)(W,2),B=L[0],V=L[1],z=(0,n.useState)(!1),$=(0,s.A)(z,2),H=$[0],q=$[1],G=null===C||void 0===C?void 0:C.find(e=>null===e||void 0===e?void 0:e.htsCode),K=null===D||void 0===D||null===(t=D.shippingAddress)||void 0===t?void 0:t.country,Q=y?null===C||void 0===C?void 0:C.reduce((e,t)=>e+parseFloat((null===t||void 0===t?void 0:t.price)||0)*parseInt((null===t||void 0===t?void 0:t.quantity)||1),0):null===j||void 0===j?void 0:j.declaredValue,X=null===j||void 0===j||null===(l=j.htsCode)||void 0===l?void 0:l.value;if((0,n.useEffect)(()=>{var e;if(null!==D&&void 0!==D&&null!==(e=D.shipments)&&void 0!==e&&e.length)if((0,St.FM)(null===D||void 0===D?void 0:D.shippingAddress,null===D||void 0===D?void 0:D.warehouse)){const e=(0,i.A)({profileName:"",contentType:St.Ur[0].value,nonDelivery:St.AI[0].value,htsCode:(0,i.A)({description:"",value:"",label:""},(null===j||void 0===j?void 0:j.htsCode)||{}),declaredValue:Q,selectedProfile:(null===j||void 0===j?void 0:j.profileName)||""},j||{});b("shipments[".concat(E,"].internationalSettings"),e,!0)}else{const e=(0,i.A)({},D.shipments[E]);null!==e&&void 0!==e&&e.internationalSettings&&delete e.internationalSettings,b("shipments[".concat(E,"]"),e,!0)}},[K]),(0,n.useEffect)(()=>{const e={};X?e.query=X:G?e.query=G.htsCode:e.ignoreQuery=!0,(0,St.FM)(null===D||void 0===D?void 0:D.shippingAddress,null===D||void 0===D?void 0:D.warehouse)&&m.Km.post("/enums/hts-codes/search",e).then(e=>{var t,l,i;const s=null===e||void 0===e||null===(t=e.data)||void 0===t||null===(l=t.codes)||void 0===l?void 0:l.map(e=>({label:"".concat(e.code," - ").concat(e.description),value:e.code,description:e.description}));!G||null===s||void 0===s||!s.length||null!==j&&void 0!==j&&null!==(i=j.htsCode)&&void 0!==i&&i.value||b("shipments[".concat(E,"].internationalSettings.htsCode"),s[0],!0),T(s)}).catch(e=>T([]))},[G,X]),(0,n.useEffect)(()=>{(0,St.FM)(null===D||void 0===D?void 0:D.shippingAddress,null===D||void 0===D?void 0:D.warehouse)&&b("shipments[".concat(E,"].internationalSettings.declaredValue"),Q,!0)},[Q]),!(0,St.FM)(null===D||void 0===D?void 0:D.shippingAddress,null===D||void 0===D?void 0:D.warehouse))return null;let J=null;return null===I||void 0===I||null===(d=I.shipments)||void 0===d||!d.length||null===I||void 0===I||null===(o=I.shipments)||void 0===o||null===(a=o[E])||void 0===a||null===(r=a.internationalSettings)||void 0===r||null===(c=r.htsCode)||void 0===c||!c.value||null!==j&&void 0!==j&&null!==(v=j.htsCode)&&void 0!==v&&v.value||(J=I.shipments[E].internationalSettings.htsCode.value),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(sl.A,{setSubmittingNewProfile:e=>{q(e)},handleClose:e=>{let t=e.profile;t&&b("shipments[".concat(E,"].internationalSettings"),(0,i.A)((0,i.A)({},t),{},{selectedProfile:t.profileName})),V(!1)},active:B,submittingNewProfile:H}),(0,Y.jsxs)("div",{className:"tw-p-4",style:{borderColor:Object.values(k).length&&k[null===D||void 0===D||null===(h=D.shipment)||void 0===h?void 0:h.id]?"#CA4941":"white"},children:[(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:[(0,Y.jsx)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:"International Settings"})}),(0,Y.jsxs)("div",{className:"tw-flex tw-gap-2",children:[(0,Y.jsxs)(A.$n,{variant:"outlined",onClick:()=>R.push("/preset/options?filter=zone-mapping"),disabled:H||f||!y,className:O.addButton,size:"small",children:[(0,Y.jsx)(S.ffu,{width:21,height:21}),"Edit Profiles"]}),(0,Y.jsxs)(A.$n,{variant:"outlined",onClick:()=>V(!0),disabled:H||f||!y,className:O.addButton,size:"small",children:[(0,Y.jsx)(S.OMN,{}),"Add Profile"]})]})]}),(0,Y.jsxs)("div",{className:"tw-pt-2 tw-pl-4",children:[(0,Y.jsx)("div",{children:"Please assign proper customs information for your International Order"}),(0,Y.jsxs)("div",{className:"tw-grid lg:tw-grid-cols-2 tw-gap-4 tw-mt-4",children:[(0,Y.jsx)("div",{className:"tw-space-y-1",children:(0,Y.jsx)(A.D0,{name:"shipments[".concat(E,"].internationalSettings.selectedProfile"),label:"Select Profile",component:U.A,options:(null===N||void 0===N||null===(p=N.internationalSettings)||void 0===p?void 0:p.map(e=>({label:e.profileName,value:e.profileName,obj:e})))||[],placeholder:"Select Profile",onChange:(e,t)=>
2{const l=(0,i.A)((0,i.A)({},t.obj),{},{selectedProfile:t.obj.profileName,contentType:null===St.Ur||void 0===St.Ur?void 0:St.Ur.find(e=>e.value===t.obj.contentType).value,nonDelivery:null===St.AI||void 0===St.AI?void 0:St.AI.find(e=>e.value===t.obj.nonDelivery).value});b("shipments[".concat(E,"].internationalSettings"),l)},disabled:H||f||!y})}),(0,Y.jsx)("div",{className:"tw-space-y-1",children:(0,Y.jsx)(A.D0,{name:"shipments[".concat(E,"].internationalSettings.contentType"),label:"Content Type",component:U.A,options:St.Ur,className:"search-field",disabled:H||f||!y,handleChange:e=>b("shipments[".concat(E,"].internationalSettings.contentType"),e),isRequired:!0})}),(0,Y.jsx)("div",{className:"tw-space-y-1",children:(0,Y.jsx)(A.D0,{name:"shipments[".concat(E,"].internationalSettings.nonDelivery"),label:"Non-Delivery Option",component:U.A,options:St.AI,className:"search-field",disabled:H||f||!y,handleChange:e=>b("shipments[".concat(E,"].internationalSettings.nonDelivery"),e),isRequired:!0})}),(0,Y.jsxs)("div",{className:"tw-space-y-1",children:[(0,Y.jsx)(A.D0,{id:"searchHtsCode",component:U.A,name:"Code *",label:(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-w-full tw-gap-2 tw-flex-wrap",children:[(0,Y.jsxs)("span",{children:["Harmonization Code",(0,Y.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]}),(0,Y.jsx)("a",{href:"https://hts.usitc.gov",target:"_blank",className:"tw-text-xs tw-mt-0.5 tw-ml-auto tw-text-secondary",rel:"noopener noreferrer",children:"Code List"})]}),value:null!==j&&void 0!==j&&null!==(w=j.htsCode)&&void 0!==w&&w.value?(0,i.A)((0,i.A)({},j.htsCode),{},{value:j.htsCode.value}):null,placeholder:"Harmonization Code",hideSelected:!1,onChange:(e,t)=>
2{var l,i;e?(b("shipments[".concat(E,"].internationalSettings.htsCode.label"),t.label),b("shipments[".concat(E,"].internationalSettings.htsCode.value"),t.value),b("shipments[".concat(E,"].internationalSettings.htsCode.description"),null===(l=(null===t||void 0===t||null===(i=t.code)||void 0===i?void 0:i.description)||(null===t||void 0===t?void 0:t.description)||"")||void 0===l?void 0:l.slice(0,35))):(b("shipments[".concat(E,"].internationalSettings.htsCode.label"),""),b("shipments[".concat(E,"].internationalSettings.htsCode.value"),""),b("shipments[".concat(E,"].internationalSettings.htsCode.description"),""))},loadOptions:Nt.P1,disabled:H||f||!y,defaultOptions:_,hasError:J},"searchHtsCode"),J?(0,Y.jsx)(A.o5,{className:"tw-text-red-600 tw-text-sm",children:Ot.UU[J]||""}):null]}),(0,Y.jsx)("div",{className:"tw-space-y-1",children:(0,Y.jsx)(A.D0,{id:"shipments[".concat(E,"].internationalSettings.htsCode.description"),name:"shipments[".concat(E,"].internationalSettings.htsCode.description"),component:M.A,disabled:H||f||!y,onFocus:e=>e.target.select(),isRequired:!0,label:"Description",placeholder:"Description",value:null===j||void 0===j||null===(x=j.htsCode)||void 0===x?void 0:x.description,onChange:()=>b()})}),(0,Y.jsxs)("div",{className:"tw-space-y-1",children:[(0,Y.jsx)(A.D0,{id:"shipments[".concat(E,"].internationalSettings.declaredValue"),name:"shipments[".concat(E,"].internationalSettings.declaredValue"),component:M.A,type:"number",min:0,disabled:H||f||!y,noErrMsg:!0,onFocus:e=>e.target.select(),isRequired:!0,className:"search-field",label:"Declared Value",placeholder:"Declared Value",value:null===j||void 0===j?void 0:j.declaredValue,onChange:()=>b()}),Z.TL?null:(0,Y.jsxs)("div",{className:"tw-text-sm",children:["Projected Tax & Duty"," ",(0,Y.jsx)("b",{children:(0,be.toCurrencyFormat)((0,g.x7)(null===j||void 0===j?void 0:j.declaredValue))})]})]})]})]})]})]})},dl=e=>{let t=e.curOptions,l=e.setFieldValue,i=e.curShipment,s=e.isLoading,n=e.isEditable,d=e.hasShipfareProtection,o=e.user,a=e.currentShipmentIndex;e.orderValue;const r=(0,Le.No)({user:o,feature:Le.cc.insurance});if(!1===(null===o||void 0===o?void 0:o.overrideUpscInsurance))return null;let c="";const u=!(null===t||void 0===t||!t.carrierInsuranceAmountActive);u&&(c=null!==t&&void 0!==t&&t.carrierInsuranceAmountAutomatic?(0,g.QB)((null===i||void 0===i?void 0:i.products)||[],i):null===t||void 0===t?void 0:t.carrierInsuranceAmount);const v=!r&&u,h=s||!n;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"tw-mt-2",children:(0,Y.jsx)(A.dO,{checked:v,value:v,paywalledFeature:Le.cc.insurance,onChange:()=>{if(s||!n||r)return;l("shipments[".concat(a,"].options.carrierInsuranceAmountActive"),!u);let e=c;e||(e=(0,g.QB)((null===i||void 0===i?void 0:i.products)||[],i)),l("shipments[".concat(a,"].options.carrierInsuranceAmount"),e)},label:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center",children:["Full Coverage",(0,Y.jsx)($.A,{information:z.A.INSURANCE})]}),disabled:h})}),(0,Y.jsx)(A.SD,{in:!r&&!!t.carrierInsuranceAmountActive,children:(0,Y.jsxs)("div",{style:{marginLeft:20,marginRight:20},children:[(0,Y.jsx)("div",{className:"tw-my-2",children:(0,Y.jsx)(A.D0,{name:"shipments[".concat(a,"].options.carrierInsuranceAmount"),value:c,component:M.A,type:"number",step:1,label:(0,Y.jsxs)("label",{className:"tw-leading-none peer-disabled:tw-cursor-not-allowed peer-disabled:tw-opacity-70 tw-block",children:["Declared Value"," ",d&&(0,Y.jsx)("span",{className:"tw-text-sm tw-text-secondary",children:"(Order Protection Purchased)"})]}),prefix:"$",style:{maxWidth:"200px",marginBottom:0},disabled:h||!(null===t||void 0===t||!t.carrierInsuranceAmountAutomatic),onChange:()=>{r||l()},min:1,max:g.xZ,isPaywalled:r,labelClassName:"tw-text-sm",className:h||null!==t&&void 0!==t&&t.carrierInsuranceAmountAutomatic?"!tw-bg-gray-200 tw-text-black":"",isRequired:!t.carrierInsuranceAmountAutomatic})}),(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-space-x-2 tw-mt-1",children:(0,Y.jsx)(A.Sc,{checked:!r&&(null===t||void 0===t?void 0:t.carrierInsuranceAmountAutomatic),value:!r&&(null===t||void 0===t?void 0:t.carrierInsuranceAmountAutomatic),paywalledFeature:Le.cc.insurance,labelPlacement:"end",disabled:h,label:"Auto-Calculate to Order Value",labelClassName:"tw-text-sm",onChange:()=>{r||l("shipments[".concat(a,"].options.carrierInsuranceAmountAutomatic"),!(null!==t&&void 0!==t&&t.carrierInsuranceAmountAutomatic))},fullWidth:!1})}),u&&!parseFloat(c||0)?(0,Y.jsx)("p",{className:"tw-p-0 tw-m-0 tw-text-red-600 tw-text-sm",children:ee.lw.INSURANCE_AMOUNT_INVALID}):null,u&&parseFloat(c||0)>g.xZ?(0,Y.jsx)("p",{className:"tw-p-0 tw-m-0 tw-text-red-600 tw-text-sm",children:ee.lw.INSURANCE_AMOUNT_MAX_EXCEEDED}):null]})})]})},ol=e=>{var t;return!1===(null===e||void 0===e||null===(t=e.user)||void 0===t?void 0:t.overrideUpscInsurance)?null:(0,Y.jsx)(Le.L0,{feature:Le.cc.insurance,isClickable:!0,children:(0,Y.jsx)(dl,(0,i.A)({},e))})};var al=l(85975);const rl=e=>{let t=e.curOptions,l=e.setFieldValue,i=e.curShipment,s=e.isLoading,n=e.isEditable,d=e.hasShipfareProtection,o=e.errors,a=e.formikErrors,r=e.user,c=e.isLocalCourierShipment,u=e.currentShipmentIndex,v=e.orderValue;const h=[{name:"shipments[".concat(u,"].options.saturdayDelivery"),label:"Saturday Delivery",field:"saturdayDelivery",info:z.A.SATURDAY_DELIVERY},{name:"shipments[".concat(u,"].options.deliveryConfirmation"),label:"Signature Required",field:"deliveryConfirmation",info:z.A.SIGNATURE_REQUIRED},{name:"shipments[".concat(u,"].options.carbonNeutral"),label:"Carbon Neutral",field:"carbonNeutral",info:z.A.CARBON_NEUTRAL}];return c?null:(0,Y.jsxs)("div",{className:"tw-p-4",style:{borderColor:Object.values(o).length&&o[null===i||void 0===i?void 0:i.id]?"#CA4941":"white"},children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:(0,Y.jsx)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:"Options"})})}),(0,Y.jsxs)("div",{className:"tw-pt-0 tw-pl-4",children:[(0,Y.jsx)(ol,{curOptions:t,setFieldValue:l,curShipment:i,isLoading:s,isEditable:n,hasShipfareProtection:d,errors:(null===o||void 0===o?void 0:o.insurance)||{},user:r,currentShipmentIndex:u,orderValue:v}),h.map(e=>{var d,o;return(0,Y.jsxs)("div",{className:"tw-mt-2",children:[(0,Y.jsx)(A.dO,{"data-cy":"chk-saturday-delivery-options",checked:(0,je.get)(t,e.field)||!1,value:(0,je.get)(t,e.field)||!1,onChange:()=>!(s||!n)&&((e,t)=>{if(l(e,t),e===h[0].name&&t){const e=null===i||void 0===i?void 0:i.shipDate,t=(0,x.Ay)(e);(!t.isValid()||t.isBefore((0,x.Ay)(),"day")||t.isAfter((0,x.Ay)().add(6,"days"),"day"))&&l("shipments[".concat(u,"].shipDate"),new Date)}})(e.name,!(0,je.get)(t,e.field)||!1),label:(0,Y.jsxs)(Y.Fragment,{children:[e.label,(0,Y.jsx)($.A,{information:e.info,orderForm:!0})]}),disabled:s||!n}),"saturdayDelivery"===e.field?(0,Y.jsx)(A.SD,{in:!!(0,je.get)(t,e.field),children:(0,Y.jsx)("div",{style:{marginLeft:20,marginRight:20},children:(0,Y.jsx)("div",{className:"tw-my-2 tw-max-w-[200px]",children:(0,Y.jsx)(A.D0,{type:"date",variant:"outlined",label:"Ship Date",name:"shipments[".concat(u,"].shipDate"),component:al.A,margin:"dense",value:null===i||void 0===i?void 0:i.shipDate,disabled:s||!n,disabledBefore:new Date,disabledAfter:(0,x.Ay)().add(6,"days"),labelProps:{className:"tw-text-sm"},onChange:()=>l(),error:null===a||void 0===a||null===(d=a.shipments)||void 0===d||null===(o=d[u])||void 0===o?void 0:o.shipDate})})})}):null]},e.name)})]})]})};var cl=l(63474),ul=l(66904);const vl=(0,C.A)("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]),hl=(0,C.A)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
2y:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),ml=(0,C.A)("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]),pl=(0,C.A)("Signature",[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]]);var wl=l(20791),xl=l(69046);const gl=(0,C.A)("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]),jl=e=>{var t;let l=e.isLoading,a=e.isEditable,r=e.values,c=e.setFieldValue,u=e.shipment,v=e.shipmentIdx,m=e.isLocalCourierShipment,p=e.setErrors,w=e.isAnyShipmentPurchasable,x=e.validateForm,j=e.submitForm,f=e.purchaseDisabled,y=e.setIsEdited,b=e.rateHistoryShipmentId,N=e.setRateHistoryShipmentId,C=e.forceShowRates;const k=(0,d.useDispatch)(),I=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),D=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.easypostCarrierAccounts}),E=(0,n.useState)(!1),O=(0,s.A)(E,2),R=O[0],P=O[1],F=(0,n.useState)(null),_=(0,s.A)(F,2),T=_[0],W=_[1],L=(0,n.useRef)(null),M=u||{},U=M.vndrRates,V=void 0===U?{}:U,H=M.manualRates,G=void 0===H?{}:H,K=M.allRates,Q=void 0===K?[]:K,X=M.preferredRates,J=void 0===X?[]:X,ee=M.cheapestRate,te=void 0===ee?null:ee,le=M.fastestRate,ie=void 0===le?null:le,se=!!Q.length,ne=(null===r||void 0===r?void 0:r.checkoutSelectedService)&&!Q.some(e=>e.isCheckoutSelectedService),de=(0,St.FM)(null===r||void 0===r?void 0:r.shippingAddress,null===r||void 0===r?void 0:r.warehouse);let oe="";const ae=null!==(t=null===I||void 0===I?void 0:I.manualCarrierAccounts)&&void 0!==t?t:[];(0,n.useEffect)(()=>{null!==r&&void 0!==r&&r.autoUpdateOrderShipmentId&&null!==u&&void 0!==u&&u.id&&(null===u||void 0===u?void 0:u.id)===r.autoUpdateOrderShipmentId&&(c("isShipmentServiceUpdate",!0),(w||a)&&x().then(e=>{(0,B.sq)(e,r,p,k)||j()}))},[null===r||void 0===r?void 0:r.autoUpdateOrderShipmentId]),(0,n.useEffect)(()=>{if(!T)return;const e=e=>{L.current&&!L.current.contains(e.target)&&W(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[T]);const re=e=>{const t=ae.find(t=>((null===t||void 0===t?void 0:t.account_number)||"").trim()===e.carrierAccountId.trim());var l,i;if(t)return null!==t&&void 0!==t&&t.description?null===(l=t.description)||void 0===l?void 0:l.toUpperCase().trim():((null===t||void 0===t||null===(i=t.credentials)||void 0===i?void 0:i.account_number)||"").trim();const s=(D||[]).find(t=>(null===t||void 0===t?void 0:t.id)===e.carrierAccountId);return s?s.description||s.credentials.account_number.toUpperCase():""},ce=()=>{var e,t,i,s,n,d,a,c,v,m,p,w,x,j;if(b)return;let S="";var N;null!==u&&void 0!==u&&null!==(e=u.options)&&void 0!==e&&e.carrierInsuranceAmountActive&&(S=null!==u&&void 0!==u&&u.options.carrierInsuranceAmountAutomatic?(0,g.QB)((null===u||void 0===u?void 0:u.products)||[],u):null===u||void 0===u||null===(N=u.options)||void 0===N?void 0:N.carrierInsuranceAmount);return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,Y.jsxs)("section",{className:"tw-flex tw-gap-4 tw-items-center",children:[(0,Y.jsx)(A.m_,{title:null!==r&&void 0!==r&&null!==(t=r.shippingAddress)&&void 0!==t&&t.residential?"Residential":"Commercial",children:null!==r&&void 0!==r&&null!==(i=r.shippingAddress)&&void 0!==i&&i.residential?(0,Y.jsx)(cl.A,{className:"tw-text-secondary tw-size-7"}):(0,Y.jsx)(ul.A,{className:"tw-text-secondary tw-size-7"})}),(0,Y.jsx)(A.m_,{title:null!==u&&void 0!==u&&null!==(s=u.options)&&void 0!==s&&s.dryIceActive?"".concat(null===u||void 0===u||null===(n=u.options)||void 0===n?void 0:n.dryIceWeight).concat(null===u||void 0===u||null===(d=u.options)||void 0===d?void 0:d.dryIceUnit," of Dry Ice Included"):"Dry Ice Not Included",children:(0,Y.jsx)(vl,{className:(0,Se.cn)("tw-text-secondary tw-size-7",!(null!==u&&void 0!==u&&null!==(a=u.options)&&void 0!==a&&a.dryIceActive)&&"tw-opacity-30")})}),(0,Y.jsx)(A.m_,{title:null!==u&&void 0!==u&&null!==(c=u.options)&&void 0!==c&&c.carrierInsuranceAmountActive?"Full Coverage Enabled - $".concat(S," in Order Value"):"No Full Coverage",children:(0,Y.jsx)(hl,{className:(0,Se.cn)("tw-text-secondary tw-size-7",!(null!==u&&void 0!==u&&null!==(v=u.options)&&void 0!==v&&v.carrierInsuranceAmountActive)&&"tw-opacity-30")})}),(0,Y.jsx)(A.m_,{title:null!==u&&void 0!==u&&null!==(m=u.options)&&void 0!==m&&m.carbonNeutral?"Carbon Neutral Shipment":"Not Carbon Neutral",children:(0,Y.jsx)(ml,{className:(0,Se.cn)("tw-text-secondary tw-size-7",!(null!==u&&void 0!==u&&null!==(p=u.options)&&void 0!==p&&p.carbonNeutral)&&"tw-opacity-30")})}),(0,Y.jsx)(A.m_,{title:null!==u&&void 0!==u&&null!==(w=u.options)&&void 0!==w&&w.deliveryConfirmation?"Signature Required":"Signature Not Required",children:(0,Y.jsx)(pl,{className:(0,Se.cn)("tw-text-secondary tw-size-7",!(null!==u&&void 0!==u&&null!==(x=u.options)&&void 0!==x&&x.deliveryConfirmation)&&"tw-opacity-30")})})]}),(null===r||void 0===r||null===(j=r.shipments)||void 0===j?void 0:j.length)>1?(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsx)(A.$
2n,{onClick:()=>k((0,h.MX)({showModal:!0,order:r,shipment:u,onComplete:()=>y(!1)})),variant:"contained",disabled:f,loading:l,color:"success",className:"tw-w-fit",size:"small",children:(0,Y.jsx)("span",{className:"flex align-items-baseline",children:"Purchase Label"})})}):null]})},ue=()=>{const e=null===Q||void 0===Q?void 0:Q.find(e=>(0,q.c$)(null===e||void 0===e?void 0:e.carrier)),t=!r.shippingAddress.phone||""===r.shippingAddress.phone;return e?(0,Y.jsx)("div",{children:t?(0,Y.jsx)(A.o5,{color:"secondary",style:{margin:"5px 0",color:"#CA4941",fontWeight:"bold",fontSize:14},children:"Enter Recipient Phone which will be shared with Local Couriers during delivery."}):null}):null},ve=(e,t)=>{var l,i,s;const n=parseFloat(null!==(l=null===e||void 0===e?void 0:e.insuranceFee)&&void 0!==l?l:0),d=(0,be.floatToTwo)(parseFloat(null!==(i=null===e||void 0===e?void 0:e.shipmentCost)&&void 0!==i?i:0)),o="".concat(t,"-").concat(null===e||void 0===e?void 0:e.id),a=T===o,r=[{label:"Shipping Cost",value:d},{label:"Dry Ice",value:null===e||void 0===e?void 0:e.dryIceFee},{label:"Saturday Delivery",value:null===e||void 0===e?void 0:e.saturdayDeliveryFee},{label:"Signature Required",value:null===e||void 0===e?void 0:e.signatureRequiredFee},{label:"Carbon Neutral",value:null===e||void 0===e?void 0:e.carbonNeutralFee},{label:"Canada Import Fee",value:null===e||void 0===e?void 0:e.canadaImportFee}].filter(e=>{return!!(t=e.value)&&("string"===typeof t?"$0.00"!==t&&"0"!==t&&"0.00"!==t:parseFloat(t)>0);var t}),c=r.some(e=>"Shipping Cost"!==e.label);return(0,Y.jsxs)("div",{className:"tw-relative",ref:a?L:null,children:[(0,Y.jsx)(A.o5,{className:(0,Se.cn)(c&&"tw-cursor-pointer hover:tw-underline"),onClick:c?e=>{e.stopPropagation(),W(a?null:o)}:void 0,children:(0,be.toCurrencyFormat)((0,be.floatToTwo)(parseFloat(null!==(s=null===e||void 0===e?void 0:e.rate)&&void 0!==s?s:0)-n))}),a&&(0,Y.jsxs)("div",{className:"tw-absolute tw-right-0 tw-top-full tw-mt-1 tw-bg-white tw-border tw-border-gray-200 tw-rounded-lg tw-shadow-lg tw-p-3 tw-z-50 tw-whitespace-nowrap",children:[(0,Y.jsx)("div",{className:"tw-text-sm tw-font-bold tw-mb-2",children:"Rate Breakdown"}),r.map((e,t)=>{return(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-gap-4 tw-text-sm tw-py-1",children:[(0,Y.jsx)("span",{className:"tw-text-gray-600",children:e.label}),(0,Y.jsx)("span",{className:"tw-font-medium",children:(l=e.value,"string"===typeof l&&l.startsWith("$")?l:(0,be.toCurrencyFormat)((0,be.floatToTwo)(parseFloat(l))))})]},t);var l})]})]})},he=e=>{var t,l,i,s,n,d,o,a;return null!==e&&void 0!==e&&null!==(t=e.weather)&&void 0!==t&&t.icon||null!==e&&void 0!==e&&null!==(l=e.weather)&&void 0!==l&&l.temp?(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-min-w-fit",style:{gap:5},children:[null!==e&&void 0!==e&&null!==(i=e.weather)&&void 0!==i&&i.icon?(0,Y.jsx)(A.m_,{title:"".concat(null===e||void 0===e||null===(s=e.weather)||void 0===s?void 0:s.conditions," - ").concat(null===e||void 0===e||null===(n=e.weather)||void 0===n?void 0:n.description),children:(0,Y.jsx)("img",{src:"".concat(Z.Wb,"/").concat(null===e||void 0===e||null===(d=e.weather)||void 0===d?void 0:d.icon,".svg"),alt:null===e||void 0===e||null===(o=e.weather)||void 0===o?void 0:o.conditions,style:{width:"auto",height:18}})},null===e||void 0===e?void 0:e.id):null,(null===(a=e.weather)||void 0===a?void 0:a.temp)&&(0,Y.jsx)("span",{className:"tw-flex-none",children:"".concat(e.weather.temp," \xb0F")})]}):null},me=e=>(0,Le.No)({user:I,feature:Le.cc.weather})?null:null!==r&&void 0!==r&&r.weatherData||null===e||void 0===e||!e.weather?b?he(e):null!==r&&void 0!==r&&r.weatherData?(0,Y.jsx)(qt.A,{weatherData:r.weatherData,renderWeather:()=>he(e),values:r,preferredRate:e,handleClose:e=>{e.preventDefault(),e.stopPropagation()}}):null:he(e),pe=e=>{var t,s;let n=e.rate,d=e.surepostReqsNotMet,o=e.isNashCarrierSelectDisabled,h=e.showCarrierInCard,p=void 0!==h&&h,w=e.showCarrierAccountName,x=void 0!==w&&w,j=e.carrierAccountToShow,f=void 0===j?"":j,y=e.overrideCardOpts,b=void 0===y?{}:y,A=e.groupKey,N=void 0===A?"preferred":A,k=(null===n||void 0===n?void 0:n.service)||"";const I=(null===n||void 0===n?void 0:n.carrier)||"";de&&(k="Worldwide".concat(k));const D=((e,t)=>null!==t&&void 0!==t&&t.estDeliveryDays||null===t||void 0===t||!t.deliveryTimeInHrs?"":"".concat(t.deliveryTimeInHrs," ").concat(1!==(null===t||void 0===t?void 0:t.deliveryTimeInHrs)?"Hrs":"Hr"))(0,n),E=(null===u||void 0===u||null===(t=u.preferredRate)||void 0===t?void 0:t.id)===(null===n||void 0===n?void 0:n.id);!oe&&E&&ne&&(oe="".concat(N,"-").concat(n.id));const O=(0,g.Bg)(n),R=(0,g.M)(k);return(0,Y.jsxs)("div",{onClick:()=>{r.archived||l||!C&&!a||d||r.isCancelled||o||((e,t)=>{var l,s;if((null===u||void 0===u||null===(l=u.preferredRate)||void 0===l?void 0:l.id)===e)return;const n=null===u||void 0===u||null===(s=u.allRates)||void 0===s?void 0:s.find(t=>
2t.id===e);if(c("shipments[".concat(v,"].preferredRate"),(0,i.A)((0,i.A)({},n),{},{groupKey:t}),!0),m){if(!(null===Q||void 0===Q?void 0:Q.find(e=>(0,q.c$)(null===e||void 0===e?void 0:e.carrier))))return;r.shipments.forEach((e,l)=>{if(v!==l){var s;const d=null===e||void 0===e||null===(s=e.allRates)||void 0===s?void 0:s.find(e=>e.carrier===n.carrier&&e.service===n.service);c("shipments[".concat(l,"].preferredRate"),(0,i.A)((0,i.A)({},d),{},{groupKey:t}),!0)}})}c("autoUpdateOrderShipmentId",null===u||void 0===u?void 0:u.id)})(n.id,N)},className:(0,Se.cn)("service tw-border tw-rounded-lg tw-border-solid tw-flex tw-items-center tw-justify-between\n tw-px-4 tw-py-1 tw-cursor-pointer hover:tw-bg-primary-light\n hover:tw-border-primary tw-transition-colors tw-duration-300\n ",l&&"tw-opacity-50 tw-pointer-events-none",E?"!tw-border-primary !tw-bg-primary-light":""),children:[(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2 tw-min-h-[48px]",children:[(0,Y.jsx)("div",{className:"tw-w-12 tw-h-12 tw-flex-shrink-0 tw-flex tw-items-center tw-justify-center",children:"usps"===I.toLowerCase()?(0,q.ZZ)({className:"tw-text-secondary"}).usps:(0,Y.jsx)("img",{className:"tw-max-w-full tw-max-h-full tw-object-contain",src:q.kl[I.toLowerCase()]||null,alt:"logo"})}),(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-flex tw-flex-wrap tw-items-center",children:[p?(0,Y.jsxs)("div",{className:"tw-flex tw-items-center",children:[null===b||void 0===b||!b.isVndrRate||null!==n&&void 0!==n&&n.isManualCarrier?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"+"})]}),(0,Y.jsxs)("span",{className:(0,Se.cn)((null===b||void 0===b?void 0:b.isVndrRate)&&!(null!==n&&void 0!==n&&n.isManualCarrier)&&"tw-ml-1"),children:[q.Vg[I.toLowerCase()]||I,null!==b&&void 0!==b&&null!==(s=b.easypostCarrierAccount)&&void 0!==s&&s.description?" - ".concat((0,je.startCase)(b.easypostCarrierAccount.description)):""]})]}):null,p||null===b||void 0===b||!b.isVndrRate||null!==n&&void 0!==n&&n.isManualCarrier?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold tw-mr-2",children:"+"})]}),(null===b||void 0===b||!b.isVndrRate||null!==n&&void 0!==n&&n.isManualCarrier)&&x&&f?(0,Y.jsxs)("span",{className:"tw-text-secondary tw-font-bold tw-mr-2",children:[f," - "]}):null,(0,Y.jsxs)("div",{className:(0,Se.cn)("tw-flex tw-gap-1 tw-items-center",p&&"tw-ml-2"),children:[g.AS.includes(null===n||void 0===n?void 0:n.service)?Z.Tt:R,O?" - ".concat(O," ").concat(1!==O?"Days":"Day"):"",D?" - ".concat(D):null,g.AS.includes(null===n||void 0===n?void 0:n.service)?(0,Y.jsx)($.A,{information:z.A.SURE_POST}):null,p&&(0,q.c$)(I)?(0,Y.jsx)($.A,{information:z.A.LOCAL_COURIERS}):null,k.includes("Relay")?(0,Y.jsx)(S.bI0,{}):null,k.toLowerCase().includes("ground")?(0,Y.jsx)($.A,{information:z.A.GROUND_TRANSIT_DAYS}):null,(null===n||void 0===n?void 0:n.isSaturdayDeliveryRate)&&(0,Y.jsx)("span",{className:"tw-bg-green-200 tw-px-2 tw-py-0.5 tw-rounded-full tw-text-nowrap tw-text-xs tw-ml-2",children:"Saturday Delivery"})]})]}),(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col sm:tw-flex-row tw-gap-1",children:[me(n),(null===n||void 0===n?void 0:n.isCheckoutSelectedService)&&(0,Y.jsx)("div",{className:"tw-bg-lavender tw-px-4 tw-py-1 tw-rounded-full tw-text-xs tw-mt-1",children:"Selected by Customer"}),E&&ne&&oe==="".concat(N,"-").concat(n.id)&&(0,Y.jsxs)("div",{className:"tw-bg-lavender tw-px-4 tw-py-1 tw-rounded-full tw-text-xs tw-mt-1 tw-w-fit",children:["Your customer selected: ",r.checkoutSelectedService]})]})]})]}),(0,Y.jsx)("div",{className:"flex align-items-center",children:!(null!==r&&void 0!==r&&r.isVndrMktOrder)&&ve(n,N)})]},"".concat(N,"-").concat(null===n||void 0===n?void 0:n.id))},we=e=>{var t;let l=e.rates,i=e.isVndrRate,n=e.className,d=void 0===n?"":n,o=e.showCarrierAccountName,a=void 0!==o&&o;if(null===(t=Object.keys(l))||void 0===t||!t.length)return null;
2let c=(0,g.D9)(null===r||void 0===r?void 0:r.shippingAddress);c=c.toLowerCase();const h=c.includes("po box"),m=i&&(0,St.Tv)(null===r||void 0===r?void 0:r.shippingAddress);return(0,Y.jsxs)(Y.Fragment,{children:[h&&(0,Y.jsx)("div",{className:"secondary-color subtitle2",style:{margin:"5px 0",fontSize:16},children:"UPS does not deliver to PO Boxes"}),(0,Y.jsx)("div",{className:"tw-flex tw-flex-col tw-gap-6 ".concat(d),children:Object.entries(l).sort((e,t)=>{let l=(0,s.A)(e,1)[0],i=(0,s.A)(t,1)[0];const n="usps"===l.toLowerCase(),d="usps"===i.toLowerCase();return n&&!d?1:!n&&d?-1:0}).map(e=>{var t;let l=(0,s.A)(e,2),n=l[0],d=l[1];if(null===d||void 0===d||!d.length)return null;const o="upssurepost"===(null===n||void 0===n?void 0:n.toLowerCase()),r=o&&(null===d||void 0===d?void 0:d.length)&&(0,g.UX)({shipment:u,service:d[0].service});if(o&&r)return null;const c=!i&&(null===d||void 0===d?void 0:d.length)&&(null===D||void 0===D?void 0:D.find(e=>{var t;return e.id===(null===(t=d[0])||void 0===t?void 0:t.carrierAccountId)})),h=(0,q.c$)(n)&&v>0,p=re(d[0]);return(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"flex align-items-center justify-content-space-between",style:{fontSize:16,fontWeight:"bold",marginBottom:5},children:(0,Y.jsxs)("div",{className:"flex align-items-center",children:[!i||null!==(t=d[0])&&void 0!==t&&t.isManualCarrier?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold tw-ml-1",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"+"})]}),a&&p?(0,Y.jsx)("span",{className:"tw-text-lg tw-font-bold tw-text-secondary",children:p}):(0,Y.jsxs)("span",{className:"tw-ml-1",children:[q.Vg[n.toLowerCase()]||n,null!==c&&void 0!==c&&c.description?" - ".concat((0,je.startCase)(c.description)):""]}),(0,q.c$)(n)?(0,Y.jsx)($.A,{information:z.A.LOCAL_COURIERS,className:"tw-ml-2"}):null]})}),(0,Y.jsxs)("div",{children:[m?(0,Y.jsx)("div",{className:"subtitle2",style:{marginBottom:5,marginTop:-5,color:"green"},children:"Rate Includes $".concat(Z.kg.canadaImportFee," Canada Customs Import Fee")}):null,(0,Y.jsx)("div",{className:"tw-mt-2 tw-space-y-2",children:(0,je.map)(d,e=>pe({rate:e,surepostReqsNotMet:r,isNashCarrierSelectDisabled:h,groupKey:"other"}))}),i?ue():null]})]},n)})})]})},xe=e=>{let t=e.rates,l=e.title;return(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-font-bold tw-text-secondary tw-flex tw-items-center tw-gap-1",children:[l,"Cheapest"===l?(0,Y.jsx)("span",{children:"\ud83d\udcb5"}):null,"Fastest"===l?(0,Y.jsx)("span",{children:"\u26a1\ufe0f"}):null]}),(0,Y.jsx)("div",{className:"tw-mt-2 tw-space-y-2",children:(0,je.map)(t,e=>{var t;const i="upssurepost"===(null===e||void 0===e||null===(t=e.carrier)||void 0===t?void 0:t.toLowerCase()),s=i&&(0,g.UX)({shipment:u,service:null===e||void 0===e?void 0:e.service});if(i&&s)return null;const n=!(null!==e&&void 0!==e&&e.isVndrRate)&&(null===D||void 0===D?void 0:D.find(t=>t.id===(null===e||void 0===e?void 0:e.carrierAccountId))),d=(0,q.c$)(null===e||void 0===e?void 0:e.carrier)&&v>0;return pe({rate:e,surepostReqsNotMet:s,isNashCarrierSelectDisabled:d,showCarrierInCard:!1,showCarrierAccountName:!0,carrierAccountToShow:re(e),overrideCardOpts:{easypostCarrierAccount:n,isVndrRate:!(null===e||void 0===e||!e.isVndrRate)},groupKey:"Cheapest"===l?"cheapest":"Fastest"===l?"fastest":"preferred"})})})]})},ge=e=>{let t=e.expandAllRates,l=void 0!==t&&t;const i=Object.keys(V).length,s=Object.keys(G).length;return l?(0,Y.jsxs)(Y.Fragment,{children:[i?we({rates:V,isVndrRate:!0}):null,s?we({rates:G,showCarrierAccountName:!0}):null]}):(0,Y.jsxs)(Y.Fragment,{children:[i||s?(0,Y.jsxs)("div",{className:"tw-cursor-pointer tw-space-x-1 tw-font-bold tw-text-secondary tw-flex tw-items-center",onClick:()=>P(!R),children:[(0,Y.jsx)("span",{children:"Other Services"}),R?(0,Y.jsx)(wl.A,{width:20,height:20}):(0,Y.jsx)(xl.A,{width:20,height:20})]}):null,R?(0,Y.jsxs)(Y.Fragment,{children:[i?we({rates:V,isVndrRate:!0}):null,s?we({rates:G,showCarrierAccountName:!0}):null]}):null]})},fe=()=>{const e=null===J||void 0===J?void 0:J.length;return(0,Y.jsxs)("div",{className:"tw-mt-4 tw-flex tw-flex-col tw-gap-6",children:[e?xe({rates:J,title:"Preferred Services"}):ge({expandAllRates:!0}),te?xe({rates:[te],title:"Cheapest"}):null,ie?xe({rates:[ie],title:"Fastest"}):null,e?ge({expandAllRates:!1}):null,(0,Y.jsx)("div",{children:ce()})]})},ye=()=>{var e;if(null!==u&&void 0!==u&&u.label)return null;let t=(0,g.D9)(null===r||void 0===r?void 0:r.shippingAddress);t=t.toLowerCase();const l=t.includes("po box"),i=null===u||void 0===u||null===(e=u.options)||void 0===e?void 0:e.saturdayDelivery;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A.o5,{className:"tw-text-red-500 tw-pb-4",children:"No Rates Available"}),(i||l)&&(0,Y.jsxs)("div",{className:"tw-pb-4",children:[(0,Y.jsx)(A.o5,{variant:"subtitle2",children:"Suggestions:"}),(0,Y.jsxs)("ul",{children:[i&&(0,Y.jsx)("li",{children:"Try disabling Saturday delivery"}),l&&(0,Y.jsx)("li",{children:"PO Box addresses are not deliverable, try changing the destination of the order"})]})]})]})};if(b)return(0,Y.jsx)(A.aF,{maxWidth:"sm",title:"Rate History",open:!0,handleClose:()=>N(null),children:(0,Y.jsx)("section",{children:fe()})});const Ae=se&&!(null!==u&&void 0!==u&&u.label)&&(!!C||!(null!==u&&void 0!==u&&u.isFulfilledFromOutside)),Ne=!se;return m?v>0?null:(0,Y.jsxs)("div",{children:[Ae?(0,Y.jsxs)("section",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,Y.jsx)("div",{className:"tw-text-xl lg:tw-text-2xl tw-font-semibold tw-text-secondary tw-leading-none tw-tracking-tight",children:"Select Service"}),(0,Y.jsx)(A.m_,{title:"Refresh Rates",children:(0,Y.jsx)(gl,{className:(0,Se.cn)("tw-text-secondary tw-size-5",l?"tw-animate-spin tw-pointer-events-none tw-opacity-50":"tw-cursor-pointer"),onClick:()=>{c("forceRefresh",!0),setTimeout(()=>j(),0)}})})]}):null,Ae?fe():null,Ne?ye():null]}):(0,Y.jsxs)("div",{children:[Ae?(0,Y.jsxs)("section",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,Y.jsxs)("div",{className:"tw-text-xl lg:tw-text-2xl tw-font-semibold tw-text-secondary tw-leading-none tw-tracking-tight",children:["Shipment ",v+1,": Select Service"]}),(0,Y.jsx)(A.m_,{title:"Refresh Rates",children:(0,Y.jsx)(gl,{className:(0,Se.cn)("tw-text-secondary tw-size-5",l?"tw-animate-spin tw-pointer-events-none tw-opacity-50":"tw-cursor-pointer"),onClick:()=>{c("forceRefresh",!0),setTimeout(()=>j(),0)}})})]}):null,Ae?fe():null,Ne?ye():null]})},fl=e=>{let t=e.shipment;const l=null===t||void 0===t?void 0:t.forms;return l?(0,Y.jsxs)("div",{className:"tw-p-4",children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:(0,Y.jsx)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:"Forms"})})}),(0,Y.jsx)(A.o5,{style:{paddingTop:8},children:"Download forms by clicking on the links below:"}),(0,Y.jsx)("div",{style:{padding:"6px 10px 0px 10px"},children:l.map((e,t)=>(0,Y.jsx)("div",{style:{padding:"4px 0"},children:(0,Y.jsx)("a",{href:e.form_url,target:"_blank",rel:"noreferrer",style:{fontSize:18},children:(0,je.startCase)(e.form_type)})},t))})]}):null};var yl=l(37178);const bl=e=>{var t,l;let o=e.isLoading,a=e.setFieldValue,r=e.setIsLoading,c=e.values,u=e.buttonClasse
2s;const v=(0,d.useDispatch)(),p=(0,ie.A)().toastError,w=(0,n.useState)({}),x=(0,s.A)(w,2),g=x[0],j=x[1],f=(0,n.useState)(!1),y=(0,s.A)(f,2),b=y[0],N=y[1],C=(0,n.useState)(!1),k=(0,s.A)(C,2),I=k[0],D=k[1],E=(0,n.useRef)(),O=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user});(0,n.useEffect)(()=>{var e;let t={};var l;null!==c&&void 0!==c&&c._id&&null!==c&&void 0!==c&&null!==(e=c.tags)&&void 0!==e&&e.length&&(null===c||void 0===c||null===(l=c.tags)||void 0===l||l.forEach(e=>{t[e]?(t[e].count+=1,t[e].orders.push(c._id)):t[e]={count:1,orders:[c._id]}}));j(t),E.current=t},[c]);const R=e=>{(async e=>{try{var t;r(!0);const l=(await m.Km.post("/orders/tags/update?orderTransformation=".concat(it.d4.DETAIL_ORDER),e)).data;r(!1),null!==l&&void 0!==l&&null!==(t=l.detailOrder)&&void 0!==t&&t.tags&&(v((0,h.CW)({editOrderRef:(0,i.A)((0,i.A)({},c),{},{tags:l.detailOrder.tags})})),a("tags",l.detailOrder.tags,!0))}catch(d){var l,s,n;let e=(null===d||void 0===d||null===(l=d.response)||void 0===l||null===(s=l.data)||void 0===s?void 0:s.message)||(null===d||void 0===d||null===(n=d.response)||void 0===n?void 0:n.data)||(null===d||void 0===d?void 0:d.message)||"Something Went Wrong";r(!1),p(e)}})({selectedTags:null!==e&&void 0!==e?e:g,selectedOrders:[c._id],editingOrder:!0}),N(!0)};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(yl.A,{isOpen:I,selectedTags:g,isLoading:o,onClose:()=>{I&&!b&&j(E.current),D(!1),N(!1)},onSelectTag:e=>{var t,l;let s=(0,i.A)({},g);if(s[e.id]&&(null===(t=s[e.id])||void 0===t?void 0:t.count)===(null===(l=[c._id])||void 0===l?void 0:l.length))delete s[e.id];else{const t=[c._id];s[e.id]={count:t.length,orders:t}}j(s)},onSave:R}),(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,Y.jsx)("div",{children:"Tags"}),(0,Y.jsxs)(A.$n,{variant:"outlined",onClick:()=>D(!0),disabled:o,loading:o,className:u.addButton,size:"small",children:[(0,Y.jsx)(S.OMN,{}),"Add Tag"]})]}),null!==(t=Object.keys(g))&&void 0!==t&&t.length?(0,Y.jsx)("div",{className:"tw-w-full tw-text-sm tw-mt-1 tw-bg-white tw-flex tw-gap-2 tw-flex-wrap",children:null===(l=Object.keys(g))||void 0===l?void 0:l.map((e,t)=>((e,t)=>{var l;const s=null===O||void 0===O||null===(l=O.tags)||void 0===l?void 0:l.find(t=>t.id===e);return s?(0,Y.jsxs)("div",{className:"tw-rounded tw-bg-gray-200 tw-px-2 tw-py-0.5 tw-flex tw-gap-1 tw-items-center",children:[(0,Y.jsx)("span",{children:s.name}),(0,Y.jsx)(S.bm,{className:"tw-cursor-pointer",onClick:()=>{const t=(0,i.A)({},g);delete t[e],j(t),R(t)}})]},e||t):null})(e,t))}):null]})]})},Al=e=>{let t=e.isLoading,l=e.setFieldValue,i=e.setIsLoading,s=e.values,n=e.buttonClasses;return(0,Y.jsx)("div",{className:"tw-pt-0 tw-pl-4",children:(0,Y.jsx)(bl,{isLoading:t,setFieldValue:l,setIsLoading:i,values:s,buttonClasses:n})})},Sl=e=>{let t=e.isLocalCourierShipment,l=e.comment,i=e.setFieldValue,s=e.isLoading,n=e.isEditable;return t?null:(0,Y.jsx)("div",{className:"tw-pt-0 tw-pl-4",children:(0,Y.jsx)(A.D0,{component:M.A,name:"comment",autoComplete:"comment",value:l||"",disabled:s||!n,onChange:()=>i(),multiline:!0,rows:3,noErrMsg:!0,label:"Notes",placeholder:"Notes"})})};var Nl=l(99289),Cl=l(1915),kl=l(71837);const Il=(0,C.A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Dl=(0,C.A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),El=(0,C.A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),Ol=e=>{let t=e.values,l=e.errors,a=e.curShipment,r=e.isLoading,c=e.isEditable,v=e.currentShipmentIndex,p=e.setCurrentShipmentIndex,w=e.setFieldValue,j=e.setRateHistoryShipmentId;
2const f=(0,d.useDispatch)(),y=(0,u.useHistory)(),b=(0,n.useState)({}),N=(0,s.A)(b,2),C=N[0],k=N[1],I=(0,n.useState)(!1),D=(0,s.A)(I,2),E=D[0],O=D[1],R=(0,n.useState)({}),P=(0,s.A)(R,2),F=P[0],_=P[1],T=(0,n.useState)(!1),W=(0,s.A)(T,2),M=W[0],U=W[1],B=(0,n.useState)(!1),V=(0,s.A)(B,2),H=V[0],G=V[1],K=(0,n.useRef)(null),Q=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),X=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.easypostCarrierAccounts});if((0,n.useEffect)(()=>{const e=K.current;e&&G(e.scrollHeight>e.clientHeight)},[]),(0,n.useEffect)(()=>{var e;if(null!==t&&void 0!==t&&null!==(e=t.shipments)&&void 0!==e&&e.length){const e={};t.shipments.forEach(t=>{var l;(null!==t&&void 0!==t&&null!==(l=t.label)&&void 0!==l&&l.trackingCode||null!==t&&void 0!==t&&t.isFulfilled)&&(e[t.id]=1)}),k(e)}},[null===t||void 0===t?void 0:t.shipments]),!t)return null;const ee=async()=>{try{var e,l,i;O(!0);const s=null===t||void 0===t||null===(e=t.shipments)||void 0===e?void 0:e.map(e=>e.id),n={orderId:t._id,shipmentIds:s},d=(await m.Km.post("/shipments/shipment/update-status?orderTransformation=".concat(it.d4.DETAIL_ORDER),n)).data,o=null===d||void 0===d||null===(l=d.detailOrder)||void 0===l||null===(i=l.shipments)||void 0===i?void 0:i.find(e=>(null===e||void 0===e?void 0:e.id)===(null===a||void 0===a?void 0:a.id));o&&(w("shipments[".concat(v,"].status"),o.status,!0),w("shipments[".concat(v,"].statusColor"),o.statusColor,!0)),O(!1)}catch(s){console.log("ERROR"),console.error((null===s||void 0===s?void 0:s.response)||s),O(!1)}},te=(e,l)=>()=>{p(l),f((0,h.CW)({editOrderPage:"edit",showSaturdayModal:!1}));const i="".concat(y.location.pathname).concat(y.location.search);y.push("".concat(i,"#").concat(t._id).concat(e?"-".concat(e):""))},le=(e,t)=>null!==e&&void 0!==e&&e.label?(0,Y.jsxs)("div",{className:"tw-flex tw-flex-wrap tw-items-center tw-gap-2 tw-my-1 tw-mt-4",children:[null!==e&&void 0!==e&&e.isFulfilled?(0,Y.jsx)("span",{className:"tw-bg-blue-200 tw-px-2 tw-py-0.5 tw-rounded-full tw-text-nowrap tw-text-sm",children:"FulFilled"}):null,(0,Y.jsx)("span",{className:"tw-px-2 tw-py-0.5 tw-rounded-full tw-text-nowrap tw-text-sm",style:{backgroundColor:null===e||void 0===e?void 0:e.statusColor},children:null===e||void 0===e?void 0:e.status}),"Archived"===(null===e||void 0===e?void 0:e.status)&&e.isDelivered?(0,Y.jsx)("span",{className:"tw-px-2 tw-py-0.5 tw-rounded-full tw-text-nowrap tw-text-sm",style:{backgroundColor:"rgb(187, 247, 208)"},children:"Delivered"}):null,null!==e&&void 0!==e&&e.customLateShipmentFlag?(0,Y.jsx)("span",{className:"tw-px-2 tw-py-0.5 tw-rounded-full tw-text-nowrap tw-text-sm",style:{backgroundColor:"rgb(233 213 255)"},children:"GSR Filed"}):null,"Delivered"!==(null===e||void 0===e?void 0:e.status)?(0,Y.jsx)(A.m_,{title:"Update Status",children:(0,Y.jsx)(A.$n,{size:"small",disabled:E,loading:E,onClick:ee,className:"tw-flex tw-items-center tw-gap-1 tw-bg-white tw-border tw-border-gray-300 tw-px-2 tw-py-1 tw-rounded tw-text-sm hover:tw-border-gray-700 tw-transition-colors tw-duration-300",children:(0,Y.jsx)(S.C42,{width:20,height:20})})}):null,Ae(e,t)]}):null,ie=()=>{var e,i,s,n,d,o,a,r,c,u,v;return(0,Y.jsxs)("ul",{className:"tw-list-none tw-p-0 tw-m-0 lg:tw-text-right",children:[(0,Y.jsx)("li",{className:"tw-font-bold tw-text-lg ".concat(null!==l&&void 0!==l&&l.shippingAddress?"tw-text-red-600":""),children:"Recipient:"}),null!==t&&void 0!==t&&null!==(e=t.shippingAddress)&&void 0!==e&&e.company||null!==t&&void 0!==t&&null!==(i=t.shippingAddress)&&void 0!==i&&i.name?(0,Y.jsx)("li",{children:[...new Set([null===t||void 0===t||null===(s=t.shippingAddress)||void 0===s?void 0:s.company,null===t||void 0===t||null===(n=t.shippingAddress)||void 0===n?void 0:n.name].filter(e=>!!e))].join(", ")}):null,null!==t&&void 0!==t&&null!==(d=t.shippingAddress)&&void 0!==d&&d.address1||null!==t&&void 0!==t&&null!==(o=t.shippingAddress)&&void 0!==o&&o.address2?(0,Y.jsx)("li",{children:[null===t||void 0===t||null===(a=t.shippingAddress)||void 0===a?void 0:a.address1,null===t||void 0===t||null===(r=t.shippingAddress)||void 0===r?void 0:r.address2].filter(e=>!!e).join(", ")}):null,(0,Y.jsxs)("li",{children:[null===t||void 0===t||null===(c=t.shippingAddress)||void 0===c?void 0:c.city,", ",null===t||void 0===t||null===(u=t.shippingAddress)||void 0===u?void 0:u.state," ",null===t||void 0===t||null===(v=t.shippingAddress)||void 0===v?void 0:v.zip]})]})},se=()=>{var e,l,i,s,n,d,o,a,r,c,u,v,h,m,p,w,x,g,j,f;return(0,Y.jsxs)("ul",{className:"tw-list-none tw-p-0 tw-m-0",children:[(0,Y.jsx)("li",{className:"tw-font-bold tw-text-lg",children:"Ship From:"}),null!==t&&void 0!==t&&null!==(e=t.warehouse)&&void 0!==e&&null!==(l=e.address)&&void 0!==l&&l.companyName||null!==t&&void 0!==t&&null!==(i=t.warehouse)&&void 0!==i&&i.name?(0,Y.jsx)("li",{children:[...new Set([null===t||void 0===t||null===(s=t.warehouse)||void 0===s||null===(n=s.address)||void 0===n?void 0:n.companyName,null===t||void 0===t||null===(d=t.warehouse)||void 0===d?void 0:d.name].filter(e=>!!e))].join(", ")}):null,null!==t&&void 0!==t&&null!==(o=t.warehouse)&&void 0!==o&&null!==(a=o.address)&&void 0!==a&&a.street1||null!==t&&void 0!==t&&null!==(r=t.warehouse)&&void 0!==r&&null!==(c=r.address)&&void 0!==c&&c.street2?
2(0,Y.jsx)("li",{children:[null===t||void 0===t||null===(u=t.warehouse)||void 0===u||null===(v=u.address)||void 0===v?void 0:v.street1,null===t||void 0===t||null===(h=t.warehouse)||void 0===h||null===(m=h.address)||void 0===m?void 0:m.street2].filter(e=>!!e).join(", ")}):null,(0,Y.jsxs)("li",{children:[null===t||void 0===t||null===(p=t.warehouse)||void 0===p||null===(w=p.address)||void 0===w?void 0:w.city,", ",null===t||void 0===t||null===(x=t.warehouse)||void 0===x||null===(g=x.address)||void 0===g?void 0:g.state," ",null===t||void 0===t||null===(j=t.warehouse)||void 0===j||null===(f=j.address)||void 0===f?void 0:f.fullZipCode]})]})},ne=e=>{var t,i,s,n;const d=(null===(t=Object.keys((null===l||void 0===l?void 0:l.products)||{}))||void 0===t?void 0:t.length)&&!0===l.products[e.id],o=null===e||void 0===e||null===(i=e.products)||void 0===i?void 0:i.map((t,l)=>{var i;return(0,Y.jsxs)("span",{children:[t.title,(0,Y.jsxs)("span",{className:"tw-text-sm tw-pl-1",children:["(",t.quantity,")",t.kitting?" (Kit)":""]}),l<(null===e||void 0===e||null===(i=e.products)||void 0===i?void 0:i.length)-1?", ":""]},l)});return(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"".concat(d?"tw-text-red-600":""," tw-col-span-12 lg:tw-col-span-4"),children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Products:"})}),(0,Y.jsxs)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces",children:[(0,Y.jsx)("div",{ref:K,className:!M&&"tw-line-clamp-2",children:o}),(null===K||void 0===K||null===(s=K.current)||void 0===s?void 0:s.scrollHeight)>(null===K||void 0===K||null===(n=K.current)||void 0===n?void 0:n.clientHeight)||H?(0,Y.jsx)(A.$n,{variant:"text",color:"secondary",size:"small",onClick:()=>{U(!M),G(!0)},className:"tw-font-bold tw-flex tw-items-center !tw-p-0 tw-gap-1",children:M?(0,Y.jsxs)(Y.Fragment,{children:["Show Less ",(0,Y.jsx)(wl.A,{className:"tw-size-4"})]}):(0,Y.jsxs)(Y.Fragment,{children:["Show More ",(0,Y.jsx)(xl.A,{className:"tw-size-4"})]})}):null]})]})},de=e=>{var t,i,s,n,d,o;const a=e.weights,r=(null===(t=Object.keys((null===l||void 0===l?void 0:l.weights)||{}))||void 0===t?void 0:t.length)&&!0===l.weights[e.id],c=null===e||void 0===e?void 0:e.parcel;let u;const v=null===e||void 0===e||null===(i=e.preferredRate)||void 0===i||null===(s=i.carrier)||void 0===s?void 0:s.toLowerCase(),h=null===e||void 0===e||null===(n=e.preferredRate)||void 0===n?void 0:n.service;if(null!==e&&void 0!==e&&null!==(d=e.preferredRate)&&void 0!==d&&d.isVndrRate)if(v===q.Ay.ups)u=Z.Uo.ups;else if(v===q.Ay.fedex){u=["FEDEX_GROUND","GROUND_HOME_DELIVERY","SMART_POST"].includes(h)?Z.Uo.fedexGround:Z.Uo.fedexExpress}const m=u?Math.ceil((null===c||void 0===c?void 0:c.length)*(null===c||void 0===c?void 0:c.width)*(null===c||void 0===c?void 0:c.height)/u):0,p=Math.ceil(null===a||void 0===a||null===(o=a.calculatedValues)||void 0===o?void 0:o.pounds);return(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"".concat(r?"tw-text-red-600":""," tw-col-span-12 lg:tw-col-span-4"),children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Total Weight:"})}),(0,Y.jsxs)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-1 tw-items-center",children:[(0,be.floatToTwo)(a.calculatedValues[L.rY[a.weightToShow]]||0)," ",a.weightToShow,u&&m>p?(0,Y.jsx)($.A,{information:z.A.DIMENSIONAL_WEIGHT,dimensionalWeight:m,parcel:c,carrier:v,service:h}):null]})]})},ae=e=>{const t=(null===e||void 0===e?void 0:e.box)||{},l=t.dimensions,i=void 0===l?{}:l,s=t.name;return(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5 tw-items-center",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Box:"})}),(0,Y.jsxs)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces",children:[(0,Y.jsxs)("span",{className:"tw-inline-block tw-align-middle",children:[i.length," x ",i.width," x ",i.height," "]}),(0,Y.jsxs)("span",{className:"tw-inline-block tw-align-middle tw-text-sm",children:["(",i.units,")"]}),(0,Y.jsx)("span",{className:"tw-inline-block tw-align-middle tw-text-[22px] tw-scale-x-[0.73] tw-mx-1 tw-h-[24px] tw-mt-[-8px]",children:"|"}),(0,Y.jsx)("span",{className:"tw-inline-block tw-align-middle",children:s})]})]})},re=e=>{var i,s,n,d;const o=(null===(i=Object.keys((null===l||void 0===l?void 0:l.insurance)||{}))||void 0===i?void 0:i.length)&&!0===l.insurance[e.id],a=e.options,r="Local Couriers"===(null===e||void 0===e||null===(s=e.preferredRate)||void 0===s?void 0:s.carrier),c=[];if(null!==a&&void 0!==a&&a.dryIceActive&&null!==a&&void 0!==a&&a.dryIceWeight&&!r&&c.push((0,Y.jsxs)("span",{children:["Dry Ice: ",a.dryIceWeight||0," ",(0,Y.jsxs)("span",{className:"tw-text-sm",children:["(",a.dryIceUnit,")"]})]})),null!==a&&void 0!==a&&a.carrierInsuranceAmountActive&&!r){let t="";a.carrierInsuranceAmountActive&&(t=a.carrierInsuranceAmountAutomatic?(0,g.QB)((null===e||void 0===e?void 0:e.products)||[],e):a.carrierInsuranceAmount),t&&c.push((0,Y.jsxs)("span",{children:["Full Coverage: Declared Value = ",t?(0,be.toCurrencyFormat)(t):""]}))}if(r){const e=t.localCourierOptions.declaredValue;e&&c.push((0,Y.jsxs)("span",{children:["Shipment value: $",(0,be.floatToTwo)(e)]}))}return null!==a&&void 0!==a&&a.saturdayDelivery&&!r&&c.push((0,Y.jsx)("span",{children:"Saturday Delivery"})),null!==a&&void 0!==a&&a.deliveryConfirmation&&c.push((0,Y.jsx)("span",{children:"Signature Required"})),null!==a&&void 0!==a&&a.carbonNeutral&&[q.Ay.ups,q.Ay.usps].includes(null===e||void 0===e||null===(n=e.preferredRate)||void 0===n||null===(d=n.carrier)||void 0===d?void 0:d.toLowerCase())&&c.push((0,Y.jsx)("span",{children:"Carbon Neutral"})),null!==c&&void 0!==c&&c.length?(0,Y.jsxs)("div",{className:"tw-grid tw-gri
2d-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"".concat(o?"tw-text-red-600":""," tw-col-span-12 lg:tw-col-span-4"),children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Extra Services:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8",children:(0,Y.jsx)("ul",{className:"tw-list-none tw-p-0 tw-m-0",children:c.map((e,t)=>(0,Y.jsx)("li",{className:"tw-m-0 tw-p-0",children:e},t))})})]}):null},ce=e=>{if((null===t||void 0===t?void 0:t.shipmentType)===g.fB.LocalCourier)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Shipping Cost:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.shippingCost})})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-ml-4 tw-text-[15px]",children:"Tips:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.tipAmount})})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Signature Required:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.signatureRequiredFee})})]})]});const l=!1===(null===Q||void 0===Q?void 0:Q.overrideUpscInsurance);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Shipping Cost:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.shippingCost})})]}),l?null:(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Full Coverage:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.insuranceFee})})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Dry Ice:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.dryIceFee})})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Saturday Delivery:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.saturdayDeliveryFee})})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Signature Required:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.signatureRequiredFee})})]}
2),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Carbon Neutral:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.carbonNeutralFee})})]}),e.canadaImportFee&&"$0.00"!==e.canadaImportFee?(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-items-center lg:tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-7 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-medium tw-text-[15px] tw-ml-4",children:"Canada Import Fee:"})}),(0,Y.jsx)("div",{className:"tw-col-span-5 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("span",{className:"tw-ml-4 tw-text-[15px]",children:e.canadaImportFee})})]}):null]})},ue=e=>{const t=null===e||void 0===e?void 0:e.preferredRate;return!t||null!==e&&void 0!==e&&e.isFulfilledFromOutside?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Total Cost:"})}),(0,Y.jsxs)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center tw-justify-start tw-cursor-pointer",onClick:()=>{const t=(0,i.A)({},F);t[e.id]?delete t[e.id]:t[e.id]=1,_(t)},children:[(0,Y.jsx)(A.o5,{color:"primary",variant:"subtitle1",children:(0,Y.jsx)("b",{children:null!==t&&void 0!==t&&t.rate?"$".concat(t.rate):""})}
2),F[e.id]?(0,Y.jsx)(wl.A,{className:"tw-cursor-pointer tw-text-primary"}):(0,Y.jsx)(xl.A,{className:"tw-cursor-pointer tw-text-primary"})]})]}),(0,Y.jsx)(A.SD,{timeout:"auto",in:!!F[e.id],children:ce(e)})]})},ve=e=>(0,Y.jsxs)("div",{className:"tw-flex tw-items-center",children:[(0,Y.jsx)(A.m_,{title:"".concat(null===e||void 0===e?void 0:e.weather.conditions," - ").concat(null===e||void 0===e?void 0:e.weather.description),children:(0,Y.jsx)("img",{src:"".concat(Z.Wb,"/").concat(null===e||void 0===e?void 0:e.weather.icon,".svg"),alt:null===e||void 0===e?void 0:e.weather.conditions,className:"tw-h-[18px] tw-w-auto"})},null===e||void 0===e?void 0:e.id),(null===e||void 0===e?void 0:e.weather.temp)&&(0,Y.jsx)("span",{className:"tw-pl-2",children:"".concat(e.weather.temp," \xb0F on ").concat((0,x.Ay)(e.weather.datetime).format(x.vz))})]}),he=e=>{const l=null===e||void 0===e?void 0:e.preferredRate;return l&&null!==l&&void 0!==l&&l.weather?(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Weather:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8",children:null!==t&&void 0!==t&&t.weatherData?(0,Y.jsx)(qt.A,{weatherData:t.weatherData,renderWeather:()=>ve(l),values:t,preferredRate:l}):ve(l)})]}):null},me=e=>{const t=null===e||void 0===e?void 0:e.preferredRate;if(!t||null!==e&&void 0!==e&&e.isFulfilledFromOutside)return null;const l=!(null!==t&&void 0!==t&&t.isVndrRate)&&(null===X||void 0===X?void 0:X.find(e=>e.id===(null===t||void 0===t?void 0:t.carrierAccountId))),i=(0,g.Bg)(t);return(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Service:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:null===t||void 0===t||!t.isVndrRate||null!==t&&void 0!==t&&t.isManualCarrier?(0,Y.jsxs)("div",{children:[(null===l||void 0===l?void 0:l.description)&&(0,Y.jsxs)("span",{className:"tw-font-bold",children:[l.description," - "]}),null===t||void 0===t?void 0:t.carrier," - ",(0,g.M)(null===t||void 0===t?void 0:t.service),i?(0,Y.jsx)("span",{className:"tw-text-sm",children:" (".concat(i," ").concat(1!==i?"Days":"Day",")")}):""]}):(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"+"})," ",null===t||void 0===t?void 0:t.carrier," - ",(0,g.M)(null===t||void 0===t?void 0:t.service),i?(0,Y.jsx)("span",{className:"tw-text-sm",children:" (".concat(i," ").concat(1!==i?"Days":"Day",")")}):""]})})]})},pe=()=>{if((0,Le.No)({user:Q,feature:Le.cc.box_packing_algo}))return null;let e=null;return null!==t&&void 0!==t&&t.algoAppliedBy&&(e=(0,je.startCase)("by ".concat(t.algoAppliedBy))),e?(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Box Splitting Algo:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:e||"Not Applied"})]}):null},we=(e,t)=>{var l,i;if(null===e||void 0===e||null===(l=e.label)||void 0===l||!l.trackingCode)return null;const s=(0,Cl.G)({shipment:e,user:Q,orderId:t});return(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Tracking ID:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:(0,Y.jsx)("a",{className:"tw-w-fit tw-flex tw-items-center",target:"_blank",rel:"noopener noreferrer",href:s,children:(0,Y.jsx)("span",{className:"tw-flex tw-items-center",children:null===e||void 0===e||null===(i=e.label)||void 0===i?void 0:i.trackingCode})})})]})},xe=e=>null!==e&&void 0!==e&&e.deliveryDate?(0,Y.jsxs)("div",{className:"tw-grid tw-gri
2d-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Delivery Date:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:x.d4.utc(e.deliveryDate).format(x.vz)})]}):null,ge=e=>null!==e&&void 0!==e&&e.localCourierPhoneNumber?(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Courier Phone #:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:e.localCourierPhoneNumber})]}):null,fe=e=>{if(![J.hb.shopify,J.hb.woocommerce].includes(e.platformType)||!e.orderId)return e.orderNumber;const t=(0,kl.Fo)({platform:e.platformType,orderId:e.orderId,store:e.shopDomain});return(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1 tw-cursor-pointer",children:[(0,Y.jsx)("a",{target:"_blank",className:"tw-text-secondary tw-underline tw-cursor-pointer tw-text-xl",rel:"noopener noreferrer",href:t,children:e.orderNumber}),t&&(0,Y.jsx)(S.GrD,{className:"-tw-mt-2",height:18,width:18,onClick:()=>window.open(t,"_blank")})]})},ye=e=>{var l,i;const s=null===t||void 0===t||null===(l=t.shippingAddress)||void 0===l||null===(i=l.deliveryDefense)||void 0===i?void 0:i.score,n=s||0===s?parseFloat((0,be.floatToTwo)(s/10)):null;if(!n)return null;const d=(0,It.Op)(n).deliveryDefenseColor,o=null===e||void 0===e?void 0:e.preferredRate,a=(0,Y.jsxs)("div",{className:"".concat(d),children:[n,"%"]});return(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Confidence Score:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-flex tw-items-center",children:null!==t&&void 0!==t&&t.weatherData?(0,Y.jsx)(qt.A,{weatherData:t.weatherData,renderWeather:()=>a,values:t,preferredRate:o}):a})]})},Ae=(e,t)=>
2{var l,i;if(null!==e&&void 0!==e&&null!==(l=e.allRates)&&void 0!==l&&l.length&&null!==e&&void 0!==e&&e.label&&!("Local Couriers"===(null===e||void 0===e||null===(i=e.preferredRate)||void 0===i?void 0:i.carrier)&&t>0))return(0,Y.jsx)("div",{children:(0,Y.jsx)(A.$n,{variant:"outlined",onClick:()=>j(e.id),disabled:r,loading:r,size:"small",children:"Rate History"})})},Ne=e=>null!==e&&void 0!==e&&e.isFulfilledFromOutside?(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 lg:tw-gap-4 tw-mt-0.5",children:[(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-4",children:(0,Y.jsx)("span",{className:"tw-font-bold",children:"Fulfillment:"})}),(0,Y.jsx)("div",{className:"tw-col-span-12 lg:tw-col-span-8 tw-whitespace-break-spaces tw-flex tw-gap-2 tw-items-center",children:"Outside of ShipFare"})]}):null,Ce=e=>null!==e&&void 0!==e&&e.label||null!==e&&void 0!==e&&e.isFulfilledFromOutside||null===e||void 0===e||!e.isFulfilled?null:(0,Y.jsx)("div",{className:"tw-my-1 tw-mt-4",children:(0,Y.jsx)("span",{className:"tw-bg-blue-200 tw-px-2 tw-py-0.5 tw-rounded-full tw-text-nowrap tw-text-sm",children:"FulFilled"})});return(0,Y.jsx)("div",{className:"tw-p-4",style:{background:"#edebf8",borderTopLeftRadius:"1rem",borderTopRightRadius:"1rem"},children:(()=>{var e,s,n;return(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:(0,Se.cn)("tw-font-bold tw-text-xl tw-text-secondary tw-flex tw-items-center tw-gap-2",(null===l||void 0===l?void 0:l.orderNumber)&&"tw-text-red-500"),children:["Order: ",(0,Y.jsx)("span",{className:"tw-text-xl",children:fe(t)})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-2 tw-mt-2 tw-max-w-lg tw-mx-auto tw-divide-x tw-divide-secondary tw-divide-solid tw-divide-y-0",children:[(0,Y.jsx)("div",{className:"tw-pr-2",children:se()}),(0,Y.jsx)("div",{className:"tw-pl-2",children:ie()})]}),(0,Y.jsx)("div",{className:"tw-mt-4",children:null===t||void 0===t||null===(e=t.shipments)||void 0===e?void 0:e.map((e,l)=>{var s,n,d;let a=e;return null!==t&&void 0!==t&&null!==(s=t.shipments)&&void 0!==s&&s.length&&(null===e||void 0===e?void 0:e.id)===(null===(n=t.shipments[v])||void 0===n?void 0:n.id)&&(a=t.shipments[v]),null!==(d=a)&&void 0!==d&&d.id?(0,Y.jsxs)("div",{className:"tw-mt-2",children:[(0,Y.jsxs)("div",{className:"flex align-items-center justify-content-space-between",style:{marginBottom:5},children:[(0,Y.jsxs)("div",{style:{minWidth:200},className:"flex align-items-center pointer",onClick:()=>{const e=(0,i.A)({},C);e[a.id]?delete e[a.id]:e[a.id]=1,k(e),p(l)},children:[(0,Y.jsx)(oe.eM,{width:"32",height:"32"}),(0,Y.jsxs)(A.o5,{style:{fontSize:18,margin:"0 6px"},children:["Shipment ",l+1]}),C[a.id]?(0,Y.jsx)(wl.A,{className:"tw-cursor-pointer tw-text-primary"}):(0,Y.jsx)(xl.A,{className:"tw-cursor-pointer tw-text-primary"})]}),c?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)("div",{className:"tw-w-full tw-flex tw-justify-end tw-items-center tw-gap-2",children:[(0,Y.jsx)(A.m_,{title:"Duplicate",children:(0,Y.jsx)("span",{children:(0,Y.jsx)(A.$n,{onClick:()=>{const e=[...t.shipments],s=(0,i.A)((0,i.A)({},t.shipments[l]),{},{id:(0,Nl.A)()});e.push(s),w("shipments",e)},iconButton:!0,disabled:r,size:"small","aria-label":"Duplicate shipment",children:(0,Y.jsx)(Il,{className:"tw-size-4"})})})}),(0,Y.jsx)(A.m_,{title:"Edit",children:(0,Y.jsx)("span",{children:(0,Y.jsx)(A.$n,{onClick:te(a.id,l),iconButton:!0,disabled:r,size:"small","aria-label":"Edit shipment",children:(0,Y.jsx)(Dl,{className:"tw-size-4"})})})}),t.shipments.length>1?(0,Y.jsx)(A.m_,{title:"Remove",children:(0,Y.jsx)("span",{children:(0,Y.jsx)(A.$n,{onClick:()=>(e=>{const l=[...t.shipments],i=l[e],s=[...t.deletedShipments,i.id];w("deletedShipments",s),l.splice(e,1),w("shipments",l),0!==e&&e===v&&p(e-1),v>=l.length&&p(v-1)})(l),iconButton:!0,color:"error",disabled:r||(null===t||void 0===t?void 0:t.useBoxPackingAlgo),size:"small","aria-label":"Remove shipment",children:(0,Y.jsx)(El,{className:"tw-size-4"})})})}):null]})}):null]}),C[a.id]?(0,Y.jsxs)("div",{className:"tw-pl-10",children:[ue(a),me(a),we(a,null===t||void 0===t?void 0:t._id),xe(a),ge(a),ye(a),he(a),(0,Y.jsx)("div",{className:"tw-pt-3 tw-pb-2",children:(0,Y.jsx)(A.cG,{orientation:"horizontal"})}),ne(a),ae(a),pe(),re(a),de(a),Ne(a),le(a,l),Ce(a)]}):null]},a.id):null})}),null!==a&&void 0!==a&&null!==(s=a.label)&&void 0!==s&&s.easyPostPurchase?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsxs)(A.$n,{variant:"outlined",color:"primary",style:{marginTop:20},onClick:()=>f((0,h.py)({type:Te.P.return,order:t})),disabled:r,loading:r,size:"small",children:[(0,Y.jsx)(S.z4$,{style:{marginRight:5,fontSize:22}}),"Create Return"]})}):null,null!==a&&void 0!==a&&null!==(n=a.label)&&void 0!==n&&n.nashPurchase&&null!==a&&void 0!==a&&a.isRefundable?(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(A.$
2n,{variant:"outlined",color:"primary",style:{marginTop:20},onClick:()=>f((0,h.py)({type:Te.P.cancelShipment,order:t})),disabled:r,loading:r,children:"Cancel Shipment"})}):null]})})()})};var Rl=l(57018);const Pl=(0,n.forwardRef)((e,t)=>{let l=e.values,i=e.hideTrigger,d=void 0!==i&&i;const o=(0,n.useState)(!1),a=(0,s.A)(o,2),r=a[0],c=a[1],u=(0,n.useCallback)(()=>c(!0),[]);(0,n.useImperativeHandle)(t,()=>({open:u}),[u]);return(0,Y.jsxs)(Y.Fragment,{children:[d?null:(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-justify-center",children:(0,Y.jsx)(S.BZB,{onClick:u,className:"tw-cursor-pointer tw-text-secondary tw-mr-2",height:30,width:30})}),(0,Y.jsx)(A.aF,{customWidth:"672px",open:r,handleClose:()=>c(!1),title:"Order History",children:(()=>{const e=[...(null===l||void 0===l?void 0:l.orderActivity)||[]].reverse();return(0,Y.jsx)(Y.Fragment,{children:e.map((t,l)=>{const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[];return null!==e&&void 0!==e&&e.toAddress&&t.push("Recipient"),null!==e&&void 0!==e&&e.fromAddress&&t.push("Warehouse"),null!==e&&void 0!==e&&e.products&&t.push("Products"),null!==e&&void 0!==e&&e.box&&t.push("Package"),null!==e&&void 0!==e&&e.weight&&t.push("Weight"),null!==e&&void 0!==e&&e.options&&t.push("Shipment Options"),null!==e&&void 0!==e&&e.dryIce&&t.push("Dry Ice"),null!==e&&void 0!==e&&e.preferredRate&&t.push("Service"),null!==e&&void 0!==e&&e.webhook&&("created"===e.webhook?t.push("Shipment created via webhook"):t.push("Shipment updated via webhook")),t.join(", ")}(null===t||void 0===t?void 0:t.shipmentUpdates);return(0,Y.jsxs)(n.Fragment,{children:[(0,Y.jsxs)("ul",{className:"tw-list-none tw-pl-0 tw-m-0 tw-py-3 tw-space-y-0.5",children:[(0,Y.jsxs)("li",{children:[(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"Action:"}),(0,Y.jsx)("span",{className:"tw-ml-2",dangerouslySetInnerHTML:{__html:t.info}})]}),(0,Y.jsxs)("li",{children:[(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"By:"}),(0,Y.jsx)("span",{className:"tw-ml-2",children:t.name})]}),null!==i&&void 0!==i&&i.length?(0,Y.jsxs)("li",{children:[(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"Section Updated:"}),(0,Y.jsx)("span",{className:"tw-ml-2",children:i})]}):null,(0,Y.jsxs)("li",{children:[(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"Date:"}),(0,Y.jsxs)("span",{className:"tw-ml-2",children:[" ",(0,x.Ay)(t.updatedAt).format("dddd, MMMM DD, YYYY, hh:mm A")]})]})]}),l<e.length-1&&(0,Y.jsx)("div",{className:"tw-border-b tw-border-solid tw-border-t-0 tw-border-gray-300"})]},l)})})})()})]})}),Fl=Pl;var _l=l(94371);const Tl=e=>{var t,l,i;let d=e.isRatesPage,o=e.hasUnpurchasedRates,a=e.shipment,r=e.setFieldValue,c=e.submitForm,u=e.values,v=e.hideSuggestions;
2const h=(0,n.useState)(!1),m=(0,s.A)(h,2),p=m[0],w=m[1],x=null===a||void 0===a||null===(t=a.allRates)||void 0===t?void 0:t.find(e=>!(null===e||void 0===e||!e.isSaturdayDeliveryRate)),g=null===a||void 0===a||null===(l=a.options)||void 0===l?void 0:l.saturdayDelivery,j=!(v||!g||!d&&(d||null!==a&&void 0!==a&&null!==(i=a.allRates)&&void 0!==i&&i.length)||!o||x);return(0,n.useEffect)(()=>{j&&w(!1)},[j]),(0,n.useEffect)(()=>{w(!1)},[null===a||void 0===a?void 0:a.allRates]),(0,Y.jsx)(A.aF,{open:j&&!p,handleClose:()=>w(!0),title:"No Saturday Delivery",actionOverrideClasses:"tw-justify-between",actions:[{isClose:!0,label:"Back"},{label:"Continue",variant:"contained",color:"secondary",onClick:()=>{var e;null===u||void 0===u||null===(e=u.shipments)||void 0===e||e.forEach((e,t)=>{r("shipments[".concat(t,"].options.saturdayDelivery"),!1)}),c()}}],children:(0,Y.jsx)("div",{children:"Saturday Delivery is unavailable for this shipment. Click Continue to update the label without Saturday Delivery applied."})})},Wl=e=>{var t;let l=e.values;const i=(0,u.useHistory)(),s=(0,d.useDispatch)(),n=l||{},o=n.combinedOrderIds,a=n.combinedOrderNumbers,r=n.combinedOrderDetails;if((null===o||void 0===o||!o.length)&&(null===r||void 0===r||!r._id))return null;const c=async e=>{var t;let l=null===i||void 0===i||null===(t=i.location)||void 0===t?void 0:t.pathname;s((0,h.SN)({orderId:e,onComplete:()=>{var t;null!==(t=l)&&void 0!==t&&t.includes("/shipments")||(l="/shipments"),i.push("".concat(l).concat(i.location.search,"#").concat(e))}}))};return(0,Y.jsxs)("div",{className:"tw-py-2 tw-rounded-lg tw-bg-blue-200 tw-text-secondary tw-px-4 tw-flex tw-gap-6 tw-items-center",children:[null!==o&&void 0!==o&&o.length?(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Y.jsx)("div",{className:"tw-font-bold",children:"Includes Orders:"}),(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-gap-2",children:o.map((e,t)=>{var l;return(0,Y.jsx)(A.N_,{className:"tw-text-secondary !tw-cursor-pointer !tw-underline",onClick:()=>c(e),children:null!==(l=a[t])&&void 0!==l?l:""},t)})})]}):null,null!==r&&void 0!==r&&r._id?(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Y.jsx)("div",{className:"tw-font-bold",children:"Combined into Order:"}),(0,Y.jsx)("div",{children:(0,Y.jsx)(A.N_,{className:"tw-text-secondary !tw-cursor-pointer !tw-underline",onClick:()=>c(r._id),children:null!==(t=r.orderNumber)&&void 0!==t?t:""})})]}):null]})},Ll=n.memo(()=>{var e,t,l,a,c,m,p,w;const x=(0,u.useHistory)(),j=(0,n.useRef)(),f=(0,d.useDispatch)(),y=(0,Ge.A)().width<768,b=(0,n.useRef)(null),N=(0,n.useState)(!1),C=(0,s.A)(N,2),I=C[0],D=C[1],E=(0,n.useState)(0),O=(0,s.A)(E,2),R=O[0],P=O[1],F=(0,n.useState)(0),_=(0,s.A)(F,2),T=_[0],W=_[1],L=(0,n.useState)(!1),M=(0,s.A)(L,2),U=M[0],V=M[1],z=(0,n.useState)(!1),$=(0,s.A)(z,2),Z=$[0],H=$[1],q=(0,n.useState)(!1),G=(0,s.A)(q,2),K=G[0],Q=G[1],X=(0,n.useState)(null),ee=(0,s.A)(X,2),te=ee[0],le=ee[1],ie=(0,n.useState)(null),se=(0,s.A)(ie,2),ne=se[0],de=se[1],ae=(0,n.useState)(!1),re=(0,s.A)(ae,2),ce=re[0],ue=re[1],ve=(0,n.useState)(!1),he=(0,s.A)(ve,2),me=he[0],pe=he[1],we=(0,n.useState)(null),xe=(0,s.A)(we,2),ge=xe[0],fe=xe[1],ye=(0,n.useState)(!1),be=(0,s.A)(ye,2),Ae=be[0],Se=be[1],Ne=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),Ce=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading}),ke=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderRef)||{}}),Ie=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderErrors}),De=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.orders}),Ee=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.total}),Oe=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.lockedFilters}),Re=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.fetchingOrderDetails}),Pe=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderModalActive}),Fe=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderPage)||"edit"})||"edit",_e=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.editOrderRedirectFrom)||null}),We=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.showSaturdayModal)||!1}),Le=Z||Re||Ce,Me=x.location,Ue=Me.hash,Be=Me.search,Ve=Me.pathname,ze=(0,v.Ay)({history:x});let $e=!0,Ze=!0;const He=parseInt(null===ze||void 0===ze?void 0:ze.page)||1,qe=parseInt(null===ze||void 0===ze?void 0:ze.limit)||100,Ke=Math.ceil(Ee/qe);He<=1&&($e=!1),He>=Ke&&(Ze=!1);const Ye=0===R,it=(0,n.useCallback)(()=>{var e;null!==j&&void 0!==j&&null!==(e=j.current)&&void 0!==e&&e.values&&f((0,h.CW)({editOrderRef:(0,i.A)((0,i.A)({},j.current.values),{},{isEdited:U})}))},[f,U]);(0,n.useEffect)(()=>{!U&&null!==ke&&void 0!==ke&&ke.isEdited&&(V(!0),jt())},[null===ke||void 0===ke?void 0:ke.isEdited]),(0,n.useEffect)(()=>
2{if(Pe)return window.addEventListener("beforeunload",it),()=>{window.removeEventListener("beforeunload",it),Pe||f((0,h.CW)({currentOrderIndex:null}))};window.removeEventListener("beforeunload",it),Pe||f((0,h.CW)({currentOrderIndex:null}))},[f,Pe,it]),(0,n.useEffect)(()=>{if(Pe){let l=null;if(Ue.indexOf("-")>=0&&(l=Ue.substring(Ue.indexOf("-")+1)),null!==De&&void 0!==De&&De.length){const i=De.findIndex(e=>e._id===ke._id);if(i>-1&&W(i),l){var e,t;let i=(null===j||void 0===j||null===(e=j.current)||void 0===e?void 0:e.values)||ke;const s=null===i||void 0===i||null===(t=i.shipments)||void 0===t?void 0:t.findIndex(e=>e.id===l);s>=0&&P(s)}}}},[ke._id,Ue,De]),(0,n.useEffect)(()=>()=>{f((0,h.vt)())},[f]);const nt=()=>{f((0,h.vt)()),f((0,h.CW)({editOrderRef:null,originalEditOrderRef:null,editOrderErrors:{},editOrderModalActive:!1,editOrderIndexRef:null,editOrderPage:"edit",showSaturdayModal:!1,editOrderRedirectFrom:null,showAddressConfirmationModal:!1})),D(!1),P(0),W(0),V(!1),H(!1),le(null);let e=Be;null!==Oe&&void 0!==Oe&&Oe.length&&(e=Oe);let t="".concat(Ve).concat(e);null!==_e&&void 0!==_e&&_e.length&&(t=_e),x.push(t)},dt=e=>{try{const t=(0,i.A)((0,i.A)({},e),{},{manualUpdate:!0}),l=(0,i.A)({},t.shipments[R]),s=l.id,n=[];t.shipments.forEach(e=>{null!==e&&void 0!==e&&e.isEditable&&(e.id===s?n.push(...l.products||[]):n.push(...e.products||[]))}),l.products=n,t.shipments=[l],delete t.autoUpdateOrderShipmentId,V(!1),H(!1),f((0,h.OO)({updatedOrder:t,isEdited:!0,isPackItems:!0}))}catch(t){console.log(t)}},at=e=>f((0,h.CW)({editOrderErrors:e})),rt=e=>{let t=e.pageToSet,l=void 0===t?null:t,i=e.orderId,s=void 0===i?null:i,n=e.shipmentId,d=void 0===n?null:n,o=[];Object.keys(ze).forEach(e=>{["page"].includes(e)||("custom_filters"===e?o.push(r().stringify({custom_filters:ze[e]})):o.push("".concat(e,"=").concat(encodeURIComponent(ze[e]))))}),l?o.push("page=".concat(encodeURIComponent(l))):null!==ze&&void 0!==ze&&ze.page&&o.push("page=".concat(encodeURIComponent(He)));let a="".concat(x.location.pathname,"?").concat(o.join("&"));return s&&(a+="#".concat(s).concat(d?"-".concat(d):"")),x.push(a)},ut=e=>{if("next"===e){if(T<(null===De||void 0===De?void 0:De.length)-1){const e=De[T+1];return void f((0,h.SN)({orderId:e._id,onComplete:()=>{var t;W(T+1),rt({orderId:e._id,shipmentId:null===e||void 0===e||null===(t=e.shipments[0])||void 0===t?void 0:t.id})}}))}if(Ze)return f((0,h.CW)({editOrderRef:null,originalEditOrderRef:null,fetchingOrderDetails:!0,editOrderIndexRef:0})),W(0),void rt({pageToSet:He+1})}else{if(T>0){const e=De[T-1];return void f((0,h.SN)({orderId:e._id,onComplete:()=>{var t;W(T-1),rt({orderId:e._id,shipmentId:null===e||void 0===e||null===(t=e.shipments[0])||void 0===t?void 0:t.id})}}))}if($e)return f((0,h.CW)({editOrderRef:null,originalEditOrderRef:null,fetchingOrderDetails:!0,editOrderIndexRef:(null===De||void 0===De?void 0:De.length)-1})),W(0),void rt({pageToSet:He-1})}},vt=(null===ke||void 0===ke?void 0:ke.shopDomain)&&(null===ke||void 0===ke?void 0:ke.shopDomain)!==J.hb.custom,ht=(null===ke||void 0===ke?void 0:ke.manualUpdate)||!1,pt=e=>function(t,l){arguments.length>2&&void 0!==arguments[2]&&arguments[2]||U||jt(),U&&jt(),t&&e(t,l)},wt=(0,n.useCallback)(()=>{var e,t;return null===(e=At.Ay[(null===ke||void 0===ke||null===(t=ke.shippingAddress)||void 0===t?void 0:t.country)||"US"])||void 0===e?void 0:e.find(e=>{var t,l,i,s,n,d;return(null===e||void 0===e||null===(t=e.name)||void 0===t?void 0:t.toLowerCase())===(null===ke||void 0===ke||null===(l=ke.shippingAddress)||void 0===l||null===(i=l.state)||void 0===i?void 0:i.toLowerCase())||(null===e||void 0===e||null===(s=e.abbreviation)||void 0===s?void 0:s.toLowerCase())===(null===ke||void 0===ke||null===(n=ke.shippingAddress)||void 0===n||null===(d=n.state)||void 0===d?void 0:d.toLowerCase())})},[null===ke||void 0===ke||null===(e=ke.shippingAddress)||void 0===e?void 0:e.country,null===ke||void 0===ke||null===(t=ke.shippingAddress)||void 0===t?void 0:t.state])(),xt=e=>{le(e)},gt=e=>{de(e)};(0,n.useEffect)(()=>{var e;const t=null===ke||void 0===ke||null===(e=ke.shippingAddress)||void 0===e?void 0:e.deliveryDefense;null!==t&&void 0!==t&&t.score&&de(t)},[]);const jt=(0,je.debounce)(()=>{var e,t;if(null!==j&&void 0!==j&&null!==(e=j.current)&&void 0!==e&&e.initialValues&&null!==j&&void 0!==j&&null!==(t=j.current)&&void 0!==t&&t.values){const e=(0,g.me)(j.current.initialValues),t=(0,g.me)(j.current.values),l=(0,je.isEqualWith)(e,t,_l.s_);V(!l)}},100),yt=()=>{V(!1),H(!1)},bt={addButton:"tw-gap-1 tw-px-4 tw-py-1.5 tw-rounded-md tw-border tw-border-gray-300 tw-bg-white hover:tw-border-gray-700 tw-transition-colors tw-duration-300",addButtonPrimary:"tw-gap-1 tw-px-4 tw-py-1.5 tw-rounded-md tw-bg-primary tw-text-white hover:tw-bg-primary-dark tw-transition-colors tw-duration-300"},Nt=(0,n.useMemo)(()=>{var e;return null===ke||void 0===ke||null===(e=ke.shipments)||void 0===e?void 0:e.map(e=>{var t;return(0,i.A)((0,i.A)({},e),{},{shipDate:null===e||void 0===e||null===(t=e.options)||void 0===t||!t.saturdayDelivery||null!==e&&void 0!==e&&e.shipDate?null===e||void 0===e?void 0:e.shipDate:new Date})})},[null===ke||void 0===ke?void 0:ke.shipments]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(st,{onClose:()=>Q(!1),show:K,order:ke,isConnected:!ht}),(0,Y.jsx)(A.l1,{enableReinitialize:!0,validationSchema:B.SW,initialValues:(0,i.A)((0,i.A)({},ke),{},{shipments:Nt,useBoxPackingAlgo:!1,useBoxPackingAlgoQuantity:!1,useBoxPackingAlgoWeight:!1,shippingAddress:(0,i.A)((0,i.A)({},null===ke||void 0===ke?void 0:ke.shippingAddress),{},{city:(null===ke||void 0===ke||null===(l=ke.shippingAddress)||void 0===l?void 0:l.city)||"",country:(null===ke||void 0===ke||null===(a=ke.shippingAddress)||void 0===a?void 0:a.country)||"US",zip:(null===ke||void 0===ke||null===(c=ke.shippingAddress)||void 0===c?void 0:c.zip)||"",residential:!("residential"in((null===ke||void 0===ke?void 0:ke.shippingAddress)||{}))||!!ke.shippingAddress.residential,phone:(0,St.FM)(null===ke||void 0===ke?void 0:ke.shippingAddress,null===ke||void 0===ke?void 0:ke.warehouse)?(null===ke||void 0===ke||null===(m=ke.shippingAddress)||void 0===m?void 0:m.ph
2one)||"":(null===(p=(0,Qe.conformToMask)((0,Je.WA)((null===ke||void 0===ke||null===(w=ke.shippingAddress)||void 0===w?void 0:w.phone)||""),(0,Je.Jd)(),{guide:!1}))||void 0===p?void 0:p.conformedValue)||"",state:(Ct=ke.shippingAddress,((0,St.fC)(Ct)?"UK":(0,St.nt)(Ct)?"PR":null!==wt&&void 0!==wt&&wt.abbreviation?wt.abbreviation:null===Ct||void 0===Ct?void 0:Ct.state)||"")}),deletedShipments:[],saveCustomerAddress:!0}),innerRef:j,onSubmit:e=>{const t=!!e.isShipmentServiceUpdate,l=!!e.isSuggestedAddressUpdate,s=!!e.forceRefresh,n=(0,i.A)({},e);delete n.autoUpdateOrderShipmentId,delete n.isShipmentServiceUpdate,delete n.isSuggestedAddressUpdate,null===n||void 0===n||delete n.weatherData,null===n||void 0===n||delete n.saveCustomerAddress,delete n.forceRefresh,U&&!n.manualUpdate&&(n.manualUpdate=!0),f((0,h.OO)({updatedOrder:n,isEdited:U,disableGlobalLoader:!0,isShipmentServiceUpdate:t,isSuggestedAddressUpdate:l,forceRefresh:s,onComplete:yt}))},children:e=>{var t,l,i,s,n,d,a,r,c,u,v,m,p;let w=e.values,x=e.setFieldValue,j=e.validateForm,N=e.submitForm,C=e.setErrors,E=e.errors,O=e.resetForm;const F=!0===(null===w||void 0===w?void 0:w.isReturn),_=(null===w||void 0===w||null===(t=w.shipments)||void 0===t?void 0:t[R])||{},W=w.shipmentType===g.fB.LocalCourier,L=(null===_||void 0===_?void 0:_.isEditable)||!(null!==_&&void 0!==_&&_.id),M=!("isValid"in w.shippingAddress)||w.shippingAddress.isValid,z=w.hasShipfareProtection;null!==_&&void 0!==_&&_.internationalSettings&&!(0,St.FM)(null===w||void 0===w?void 0:w.shippingAddress,null===w||void 0===w?void 0:w.warehouse)&&delete _.internationalSettings;let $=!0,Z=!1,q=!1;null===w||void 0===w||null===(l=w.shipments)||void 0===l||l.forEach(e=>{var t;null!==e&&void 0!==e&&e.label||!$||($=!1),null!==e&&void 0!==e&&e.isPurchaseable&&null!==e&&void 0!==e&&e.preferredRate&&!Z&&(Z=!0),null!==e&&void 0!==e&&null!==(t=e.allRates)&&void 0!==t&&t.length&&!q&&(q=!0)});const G=Le||!Z,K=null===w||void 0===w||null===(i=w.shipments)||void 0===i?void 0:i.some(e=>!(null===e||void 0===e||!e.label)),X=null===w||void 0===w||null===(s=w.shipments)||void 0===s?void 0:s.some(e=>null===e||void 0===e?void 0:e.isFulfilledFromOutside),J=K||X||!(null===w||void 0===w||!w.archived),ee=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null!==_&&void 0!==_&&_.isFulfilledFromOutside)f((0,h.CW)({editOrderPage:"rates"}));else if(t)pe(!0);else if(null!==_&&void 0!==_&&_.isPurchaseable||L){if(!M&&!e)return void pe(!0);j().then(e=>{(0,B.sq)(e,w,at,f)||N()})}else f((0,h.CW)({editOrderPage:"rates",showSaturdayModal:!0}))},le=null===w||void 0===w||null===(n=w.shipments)||void 0===n?void 0:n.find(e=>(null===e||void 0===e?void 0:e.id)===ge),ie=null===w||void 0===w||null===(d=w.shipments)||void 0===d?void 0:d.findIndex(e=>(null===e||void 0===e?void 0:e.id)===ge);return(0,Y.jsxs)(A.lV,{onChange:jt,children:[(0,Y.jsxs)(A.aF,{open:Pe,scroll:"paper",fullScreen:!0,title:"Confirm Box Splitting Algorithm?",handleClose:nt,TransitionComponent:Xe.A,disableEnforceFocus:!0,hideTitleBar:!0,renderChildrenDirectly:!0,hideActions:!0,children:[(0,Y.jsx)(A.hw,{className:"tw-h-fit",sx:{position:"relative",backgroundColor:"white",color:"black"},children:(0,Y.jsxs)(A.M7,{className:"tw-px-4 tw-py-3 tw-flex tw-flex-wrap tw-items-center tw-justify-between tw-relative tw-mx-auto tw-container",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[L&&I?(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-justify-center tw-flex-col md:tw-flex-row",children:(0,Y.jsxs)("div",{className:"tw-flex",children:[(0,Y.jsx)(A.A_,{variant:"outlined",size:"small",defaultValue:null===w||void 0===w?void 0:w.orderNumber,style:{margin:0},onChange:e=>{x("orderNumber",e.target.value)},disabled:Le}),(0,Y.jsx)(A.$n,{iconButton:!0,onClick:()=>{D(!1),x("orderNumber",ke.orderNumber),jt()},color:"error",size:"small",disabled:Le,children:(0,Y.jsx)(S.bm,{})}),(0,Y.jsx)(A.$n,{iconButton:!0,onClick:()=>{D(!1),jt()},color:"inherit",size:"small",disabled:Le,children:(0,Y.jsx)(S.Jlk,{})})]})}):(0,Y.jsxs)(A.az,{display:"flex",alignItems:"center",children:[(0,Y.jsxs)(A.o5,{className:"tw-text-xl","data-cy":"order-details-text",children:[null===w||void 0===w?void 0:w.orderNumber," ",null!==w&&void 0!==w&&w.isVndrMktOrder?"(Shipfare MRKT)":""]}
2),L&&!Le?(0,Y.jsx)(A.$n,{iconButton:!0,onClick:()=>{D(!0)},color:"inherit",style:{marginLeft:10},size:"small",children:(0,Y.jsx)(oe.iy,{})}):null]}),(0,Y.jsxs)(A.az,{alignItems:"center",className:"tw-my-2 md:tw-my-0 tw-hidden md:tw-flex",children:[(0,Y.jsx)(A.m_,{title:"Duplicate Order",children:(0,Y.jsx)(A.$n,{iconButton:!0,onClick:()=>{f((0,h.py)({type:Te.P.duplicate,order:w}))},disabled:Le,color:"inherit",size:"small",children:(0,Y.jsx)(S.mJ3,{})})}),(0,Y.jsx)(A.$n,{iconButton:!0,onClick:()=>ut("prev"),disabled:Le||!$e&&T<=0,color:"inherit",size:"small",children:(0,Y.jsx)(S.v$n,{})}),(0,Y.jsx)(A.$n,{iconButton:!0,onClick:()=>ut("next"),disabled:Le||!Ze&&T>=(null===De||void 0===De?void 0:De.length)-1,color:"inherit",size:"small",children:(0,Y.jsx)(S.j0j,{})}),vt&&!(null!==w&&void 0!==w&&null!==(a=w.combinedOrderIds)&&void 0!==a&&a.length)&&(0,Y.jsx)("div",{className:"flex align-items-center justify-content-flex-end tw-ml-2",style:{flex:1},children:(0,Y.jsx)("span",{children:(0,Y.jsx)(A.m_,{title:ht?"Disconnected With Store":"Connected With Store",children:(0,Y.jsx)("span",{children:(0,Y.jsx)(A.$n,{iconButton:!0,onClick:()=>Q(!0),disabled:Le||(null===_||void 0===_||!_.isFulfilledFromOutside)&&!L,size:"small",children:ht?(0,Y.jsx)(tt,{height:28,width:28,stroke:"#D56D67",isDisabled:Le||(null===_||void 0===_||!_.isFulfilledFromOutside)&&!L}):(0,Y.jsx)(et,{height:28,width:28,stroke:"#33b550",isDisabled:Le||(null===_||void 0===_||!_.isFulfilledFromOutside)&&!L})})})})})})]})]}),(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-overflow-x-auto tw-overflow-y-hidden",children:[(0,Y.jsx)("div",{className:"tw-hidden md:tw-block",children:(0,Y.jsx)(Fl,{ref:b,values:w,isLoading:Le,isEditable:L,currentShipmentIndex:R,setCurrentShipmentIndex:P})}),(0,Y.jsx)(lt,{curShipment:_,validateForm:j,submitForm:N,resetForm:O,values:w,isLoading:Le,isEdited:U,isEditable:L,setIsEdited:V,setErrors:at,setCurrentShipmentIndex:P,editOrderPage:Fe,purchaseDisabled:G,isAnyShipmentPurchasable:Z,isValidShippingAddress:M,setShowAddressConfirmationModal:pe,setShowRatesModal:Se}),"edit"===Fe?(0,Y.jsx)(A.$n,{onClick:()=>ee(),style:{marginRight:"rates"!==Fe?10:0},disabled:Le||(null===_||void 0===_||!_.isFulfilledFromOutside)&&(!L&&(null===_||void 0===_?void 0:_.isPurchaseable))||U,loading:Le,color:"primary",size:y?"small":"medium",variant:"contained",className:bt.addButtonPrimary,children:"Next"}):null,(0,Y.jsx)("div",{className:"md:tw-hidden tw-mr-10 sm:tw-mr-0",children:(0,Y.jsx)(A.ND,{placement:"bottom-end",buttonProps:{variant:"text",className:"!tw-px-2 !tw-min-w-0"},noIcon:!0,buttonIcon:(0,Y.jsx)(k,{className:"tw-size-6"}),paperProps:{style:{width:175,maxWidth:"calc(100vw - 16px)"}},renderMenu:e=>{var t;let l=e.handleClose,i=e.open,s=e.handleListKeyDown;return(0,Y.jsxs)(A.cO,{className:"!tw-py-1",autoFocusItem:i,onKeyDown:s,children:[(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:Le,onClick:()=>{f((0,h.py)({type:Te.P.duplicate,order:w})),l()},children:(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Duplicate Order"})}),(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:Le||!$e&&T<=0,onClick:()=>{ut("prev"),l()},children:(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Previous Order"})}),(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:Le||!Ze&&T>=(null===De||void 0===De?void 0:De.length)-1,onClick:()=>{ut("next"),l()},children:(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Next Order"})}),!vt||null!==w&&void 0!==w&&null!==(t=w.combinedOrderIds)&&void 0!==t&&t.length?null:(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",disabled:Le||(null===_||void 0===_||!_.isFulfilledFromOutside)&&!L,onClick:()=>{Q(!0),l()},children:(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:ht?"Reconnect Store":"Store Connection"})}),(0,Y.jsx)(A.Dr,{className:"!tw-py-1.5 !tw-gap-2 !tw-min-h-0",onClick:()=>{var e;null===(e=b.current)||void 0===e||e.open(),l()},children:(0,Y.jsx)(A.o5,{className:"tw-text-sm",children:"Order History"})}),(0,Y.jsx)(lt,{renderInMenu:!0,onMenuItemClick:l,curShipment:_,validateForm:j,submitForm:N,resetForm:O,values:w,isLoading:Le,isEdited:U,isEditable:L,setIsEdited:V,setErrors:at,setCurrentShipmentIndex:P,editOrderPage:Fe,purchaseDisabled:G,isAnyS
2hipmentPurchasable:Z,isValidShippingAddress:M,setShowAddressConfirmationModal:pe,setShowRatesModal:Se})]})}})}),(0,Y.jsx)(A.$n,{edge:"start",color:"error","aria-label":"close",iconButton:!0,onClick:nt,className:"tw-absolute sm:tw-relative tw-right-2 tw-top-2 sm:tw-right-0 sm:tw-top-0","data-cy":"edit-order-close-button",children:(0,Y.jsx)(S.bm,{className:"tw-cursor-pointer tw-fill-secondary",width:30,height:30})})]})]})}),(0,Y.jsx)("div",{id:"orderModal",className:"tw-h-full !tw-overflow-auto",style:{background:"#f5f5f5",paddingTop:26,paddingBottom:26,overflow:"auto"},children:(0,Y.jsx)("div",{className:"tw-mx-auto tw-px-4 tw-max-w-2xl",children:Re?(0,Y.jsx)("div",{className:"flex align-items-center justify-content-center",style:{height:"90vh",width:"100%"},children:(0,Y.jsx)(A.P,{color:"primary",size:72})}):(0,Y.jsxs)("div",{children:[(0,Y.jsx)(ot,{errorObject:null===w||void 0===w?void 0:w.error,isOrder:!0,values:w,shipmentErrors:null===w||void 0===w||null===(r=w.shipments)||void 0===r?void 0:r.map(e=>null===e||void 0===e?void 0:e.error),carrierErrors:null===w||void 0===w||null===(c=w.shipments)||void 0===c?void 0:c.map(e=>null===e||void 0===e?void 0:e.carrierErrors).flat(1),editOrderPage:Fe,hideSuggestions:J}),"edit"===Fe?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("section",{className:"tw-mt-4 tw-max-w-2xl tw-mx-auto",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Y.jsx)(Wl,{values:w}),(0,Y.jsx)(ct,{values:w,user:Ne})]}),(0,Y.jsx)(mt,{values:w,user:Ne,isLocalCourierShipment:W,setFieldValue:pt(x),isLoading:Le,isEditable:L}),F?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ft,{warehouse:null===w||void 0===w?void 0:w.warehouse,isLoading:Le,isEditable:L,isReturn:F,curShipment:_,setFieldValue:pt(x),buttonClasses:bt}),(0,Y.jsx)(Pt,{showEditModal:ce,setShowEditModal:ue,editOrderRef:ke,shippingAddress:null===w||void 0===w?void 0:w.shippingAddress,setFieldValue:pt(x),isLoading:Le,isEditable:L,errors:(null===Ie||void 0===Ie?void 0:Ie.shippingAddress)||(null===Ie||void 0===Ie?void 0:Ie.recipientPhone),values:w,isReturn:F,setWeatherData:xt,setDefenseData:gt,formikErrors:E,validateForm:j,curShipment:_,showAddressError:!1,user:Ne,hasShipfareProtection:z,handleAddressUpdate:ee,afterFormChange:jt,setIsEdited:V,buttonClasses:bt})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Pt,{showEditModal:ce,setShowEditModal:ue,editOrderRef:ke,shippingAddress:null===w||void 0===w?void 0:w.shippingAddress,setFieldValue:pt(x),isLoading:Le,isEditable:L,setWeatherData:xt,setDefenseData:gt,errors:(null===Ie||void 0===Ie?void 0:Ie.shippingAddress)||(null===Ie||void 0===Ie?void 0:Ie.recipientPhone),values:w,isReturn:F,formikErrors:E,validateForm:j,curShipment:_,showAddressError:!0,user:Ne,hasShipfareProtection:z,handleAddressUpdate:ee,afterFormChange:jt,setIsEdited:V,buttonClasses:bt}),(0,Y.jsx)(ft,{warehouse:null===w||void 0===w?void 0:w.warehouse,isLoading:Le,isEditable:L,isReturn:F,curShipment:_,setFieldValue:pt(x),buttonClasses:bt})]})]}),(0,Y.jsxs)("section",{className:"tw-mt-6 tw-rounded-2xl",children:[(0,Y.jsx)(Ft,{values:w,isLoading:Le,isEditable:L,errors:Ie,hasOrderBeenEdited:U,user:Ne,curShipment:_,currentShipmentIndex:R,setCurrentShipmentIndex:P,setFieldValue:pt(x)}),(0,Y.jsxs)("div",{className:"tw-border tw-bg-white tw-shadow-lg tw-border-solid tw-border-gray-300 tw-rounded-b-2xl",children:[(0,Y.jsx)($t,{lineItems:null===_||void 0===_?void 0:_.products,setFieldValue:pt(x),shipment:_,isLoading:Le,isEditable:L,errors:(null===Ie||void 0===Ie?void 0:Ie.products)||{},user:Ne,formikErrors:E,values:w,currentShipmentIndex:R,setCurrentShipmentIndex:P,packItemsByAlgo:dt,buttonClasses:bt}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d",margin:0}}),(0,Y.jsx)(Qt,{boxValues:null===_||void 0===_?void 0:_.box,setFieldValue:pt(x),products:(null===_||void 0===_?void 0:_.products)||[],weights:null===_||void 0===_?void 0:_.weights,isLoading:Le,isEditable:L,options:null===_||void 0===_?void 0:_.options,packagings:(null===_||void 0===_?void 0:_.packagings)||[],currentShipmentIndex:R,values:w,user:Ne,weatherData:te,defenseData:ne,buttonClasse
2s:bt}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d",margin:0}}),W?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(el,{values:null===_||void 0===_?void 0:_.options,setFieldValue:pt(x),shipment:_,isLoading:Le,isEditable:L,errors:Ie||{},currentShipmentIndex:R,curShipment:_}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d",margin:0}})]}),(0,Y.jsx)(il,{setFieldValue:pt(x),weights:null===_||void 0===_?void 0:_.weights,box:null===_||void 0===_?void 0:_.box,setFormikErrors:C,values:w,products:(null===_||void 0===_?void 0:_.products)||[],isLoading:Le,isEditable:L,errors:null===Ie||void 0===Ie?void 0:Ie.weights,curShipment:_,packagings:(null===_||void 0===_?void 0:_.packagings)||[],user:Ne,currentShipmentIndex:R}),!W||(0,St.FM)(null===w||void 0===w?void 0:w.shippingAddress,null===w||void 0===w?void 0:w.warehouse)?(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d",margin:0}}):null,(0,St.FM)(null===w||void 0===w?void 0:w.shippingAddress,null===w||void 0===w?void 0:w.warehouse)?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(nl,{internationalSettings:(null===_||void 0===_?void 0:_.internationalSettings)||{},isLoading:Le,isEditable:L,setFieldValue:pt(x),user:Ne,lineItems:(null===_||void 0===_?void 0:_.products)||[],errors:(null===Ie||void 0===Ie?void 0:Ie.internationalSettings)||{},formikErrors:E,values:w,currentShipmentIndex:R,buttonClasses:bt}),W?null:(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d",margin:0}})]}):null,(0,Y.jsx)(rl,{curOptions:(null===_||void 0===_?void 0:_.options)||{},setFieldValue:pt(x),curShipment:_,isLoading:Le,isEditable:L,hasShipfareProtection:z,errors:Ie||{},formikErrors:E,user:Ne,isLocalCourierShipment:W,currentShipmentIndex:R,orderValue:w.orderValue}),null!==_&&void 0!==_&&_.forms?(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d",margin:0}}):null,(0,Y.jsx)(fl,{shipment:_})]})]}),(0,Y.jsxs)("section",{className:"tw-mt-4 tw-bg-white tw-rounded-2xl tw-p-4 tw-shadow-lg tw-border tw-border-gray-300 tw-border-solid tw-pb-2",children:[(0,Y.jsx)("div",{className:"tw-flex tw-justify-between tw-gap-x-2",children:(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-text-secondary",children:"Extra Info"})}),(0,Y.jsx)("div",{className:"tw-mt-4",children:(0,Y.jsx)(Sl,{comment:w.comment,isLocalCourierShipment:W,setFieldValue:pt(x),isLoading:Le,isEditable:L})}),(0,Y.jsx)("div",{className:"tw-mt-4 tw-mb-2",children:(0,Y.jsx)(Al,{isLoading:Le,setFieldValue:pt(x),setIsLoading:H,values:w,buttonClasses:bt})})]}),(0,Y.jsx)("section",{className:"tw-mt-4 tw-text-right",children:(0,Y.jsx)(A.$n,{onClick:()=>ee(),disabled:Le||(null===_||void 0===_||!_.isFulfilledFromOutside)&&(!L&&(null===_||void 0===_?void 0:_.isPurchaseable))||U,loading:Le,color:"primary",variant:"contained",className:"tw-bg-primary tw-text-white tw-px-4 tw-py-1.5 tw-rounded-md hover:tw-bg-primary-dark tw-transition-colors tw-duration-300",children:"Next"})})]}):null,"rates"===Fe?(0,Y.jsxs)("section",{className:"tw-mt-4",children:[(0,Y.jsx)(A.$n,{onClick:()=>{f((0,h.CW)({editOrderPage:"edit"}))},disabled:Le,loading:Le,children:null!==_&&void 0!==_&&null!==(u=_.label)&&void 0!==u&&u.trackingCode?"View Details":"Edit"}),(0,Y.jsxs)("div",{className:"tw-mt-4 tw-bg-white tw-rounded-2xl tw-shadow-lg tw-border tw-border-gray-300 tw-border-solid",children:[(0,Y.jsx)(Ol,{values:w,errors:Ie,curShipment:_,isLoading:Le,isEditable:L,currentShipmentIndex:R,setCurrentShipmentIndex:P,setFieldValue:pt(x),setRateHistoryShipmentId:fe}),q&&!$||!q&&!$?(0,Y.jsxs)("div",{className:"tw-p-4 tw-flex tw-flex-col tw-gap-4",children:[null!==_&&void 0!==_&&_.isFulfilledFromOutside?null:null===w||void 0===w||null===(v=w.shipments)||void 0===v?void 0:v.map((e,t)=>{var l;return null!==e&&void 0!==e&&e.isFulfilledFromOutside?null:(0,Y.jsx)(jl,{isLoading:Le,isEditable:(null===e||void 0===e?void 0:e.isEditable)||!(null!==e&&void 0!==e&&e.id),values:w,isFirstShipment:Ye,setFieldValue:pt(x),shipment:e,shipmentIdx:t,validateForm:j,submitForm:N,setErrors:at,isAnyShipmentPurchasable:Z,isLocalCourierShipment:W,purchaseDisabled:G,setIsEdited:V},null!==(l=null===e||void 0===e?void 0:e.id)&&void 0!==l?l:"new-".concat(t))}),q&&!G?(0,Y.jsx)(o.c7,{permissions:[o.I1.PURCHASE_ORDERS],children:(0,Y.jsx)(A.$
2n,{onClick:()=>{null!==_&&void 0!==_&&_.isFulfilledFromOutside?Se(!0):f((0,h.MX)({showModal:!0,order:w,onComplete:()=>V(!1)}))},variant:"contained",disabled:G,loading:Le,color:"success",className:"tw-w-fit",children:(0,Y.jsx)("span",{className:"flex align-items-baseline",children:1!==(null===w||void 0===w||null===(m=w.shipments)||void 0===m?void 0:m.length)?"Purchase All Labels":"Purchase Label"})})}):null]}):null,ge&&le?(0,Y.jsx)(jl,{isLoading:Le,isEditable:!1,values:w,isFirstShipment:!1,setFieldValue:pt(x),shipment:le,shipmentIdx:ie,isAnyShipmentPurchasable:!1,isLocalCourierShipment:W,purchaseDisabled:!0,rateHistoryShipmentId:ge,setRateHistoryShipmentId:fe}):null,Ae?(0,Y.jsx)(A.aF,{open:Ae,handleClose:()=>Se(!1),title:"Rates",actions:[{isClose:!0},{label:1!==(null===w||void 0===w||null===(p=w.shipments)||void 0===p?void 0:p.length)?"Purchase All Labels":"Purchase Label",onClick:()=>{f((0,h.MX)({showModal:!0,order:w,onComplete:()=>{Se(!1),V(!1)}}))},variant:"contained",color:"primary"}],children:(0,Y.jsx)(jl,{isLoading:Le,isEditable:(null===_||void 0===_?void 0:_.isEditable)||!(null!==_&&void 0!==_&&_.id),values:w,isFirstShipment:Ye,setFieldValue:pt(x),shipment:_,shipmentIdx:R,validateForm:j,submitForm:N,setErrors:at,isAnyShipmentPurchasable:Z,isLocalCourierShipment:W,purchaseDisabled:G,setIsEdited:V,forceShowRates:!0})}):null]})]}):null]})})})]}),(0,Y.jsx)(Rl.A,{open:me,setShowAddressConfirmationModal:pe,values:w,setFieldValue:x,onClose:()=>{pe(!1),f((0,h.CW)({showAddressWarningModal:!1}))},onProceedWithSelectedAddress:()=>{V(!0),jt(),pe(!1),N()},onReEnterAddress:()=>{pe(!1),ue(!0)}}),(0,Y.jsx)(Tl,{isRatesPage:"rates"===Fe,hasUnpurchasedRates:!U&&(q&&!$||!q&&We),shipment:_,setFieldValue:x,submitForm:N,values:w,hideSuggestions:J})]})}})]});var Ct}),Ml=Ll;var Ul=l(19139);const Bl=()=>{var e,t,l;const i=(0,d.useDispatch)(),o=(0,n.useState)(!1),a=(0,s.A)(o,1)[0],r=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.cancellationFeeData}),c=null===r||void 0===r?void 0:r.showModal;return(0,Y.jsxs)(A.aF,{open:c,maxWidth:"xs",title:"Shipment Cancellation Fee",handleClose:()=>{i((0,h.NY)())},actions:[{isClose:!0,loading:a,disabled:a}],children:[(0,Y.jsx)(A.o5,{children:"Cancellation Fee was applied for in transit shipments"}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-gap-0 tw-mt-4",children:[(0,Y.jsx)("div",{className:"tw-col-span-6",children:"Shipment Cost:"}),(0,Y.jsx)("div",{className:"tw-col-span-6",children:(0,be.centsToCurrencyFormat)(null===r||void 0===r||null===(e=r.order)||void 0===e?void 0:e.totalShipmentCost)})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-gap-0",children:[(0,Y.jsx)("div",{className:"tw-col-span-6",children:"Amount Refunded:"}),(0,Y.jsx)("div",{className:"tw-col-span-6",children:(0,be.centsToCurrencyFormat)(null===r||void 0===r||null===(t=r.order)||void 0===t?void 0:t.amountRefunded)})]}),(0,Y.jsxs)("div",{className:"tw-grid tw-grid-cols-12 tw-gap-0",children:[(0,Y.jsx)("div",{className:"tw-col-span-6",children:"Cancellation Fee:"}),(0,Y.jsx)("div",{className:"tw-col-span-6",children:(0,be.centsToCurrencyFormat)(null===r||void 0===r||null===(l=r.order)||void 0===l?void 0:l.totalCancellationFee)})]})]})};var Vl=l(86571),zl=l(45071);const $l=e=>{let t=e.batchPageData,l=e.setBatchPageData,o=e.id,a=e.hasOrder,r=e.renderActions,c=e.loading,v=e.batchLoading;const x=(0,u.useHistory)(),g=(0,d.useDispatch)(),j=(0,ie.A)(),f=j.toastError,y=j.toastSuccess,b=(0,p.A)(),N=b.handleCancelBatch,C=b.handleDeleteFromBatch,k=(0,w.yK)().getSelectedOrders,I=(0,n.useState)(!1),D=(0,s.A)(I,2),E=D[0],O=D[1],R=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.totalSelectedOrders}),P=(0,n.useState)((null===t||void 0===t?void 0:t.label)||(null===t||void 0===t?void 0:t.batchNumber)),F=(0,s.A)(P,2),_=F[0],T=F[1],W=(0,n.useState)(null===t||void 0===t?void 0:t.notes),L=(0,s.A)(W,2),M=L[0],U=L[1];(0,n.useEffect)(()=>{t&&(T((null===t||void 0===t?void 0:t.label)||(null===t||void 0===t?void 0:t.batchNumber)),U(null===t||void 0===t?void 0:t.notes))},[t]);const B=async()=>{await N(o),x.push("/batch")},V=()=>{const e=k();C(o,Object.keys(e))};return(0,Y.jsxs)(Y.Fragment,{children:[c?(0,Y.jsx)("div",{className:"flex align-items-center justify-content-center",children:(0,Y.jsx)(A.P,{size:"22px"})}):null,a||c?null:(0,Y.jsxs)("div",{className:"tw-max-w-lg tw-mx-auto",children:[(0,Y.jsx)(A.$
2n,{onClick:()=>x.goBack(),className:"tw-mb-4",children:"Back"}),(0,Y.jsxs)("div",{className:"tw-flex tw-flex-wrap tw-gap-4 tw-justify-between tw-items-center tw-mb-4",children:[(0,Y.jsx)("div",{className:"tw-text-xl lg:tw-text-2xl tw-font-semibold tw-text-secondary tw-leading-none tw-tracking-tight",children:(0,Y.jsxs)("div",{className:"tw-flex tw-gap-2 tw-items-center tw-flex-wrap",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:[(0,Y.jsxs)("span",{children:["Batch: ",_]}),(0,Y.jsx)(S.ffu,{className:"tw-cursor-pointer",onClick:()=>O(!0)})]}),null!==t&&void 0!==t&&t.notes?(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2 tw-mt-2 tw-text-sm tw-bg-blue-200 tw-text-gray-700 tw-px-4 tw-py-1 tw-rounded-2xl",children:[(0,Y.jsx)("strong",{children:"Notes:"}),(0,Y.jsx)("span",{className:"tw-break-all",children:t.notes})]}):null]})}),(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-gap-2",children:(0,Y.jsx)(S.epd,{onClick:()=>B(),height:30,width:30,className:"tw-cursor-pointer"})}),v?(0,Y.jsx)(A.P,{color:"primary",size:20}):null]}),(0,Y.jsxs)(A.Zp,{children:[(0,Y.jsxs)("div",{className:"tw-text-secondary tw-text-center tw-mt-4",children:[(0,Y.jsx)("div",{className:"tw-text-3xl",children:"\xaf\\_(\u30c4)_/\xaf"}),(0,Y.jsx)("div",{className:"tw-text-xl tw-font-bold tw-mt-2",children:"No Orders In This Batch"})]}),(0,Y.jsx)("div",{className:" tw-text-center",children:(0,Y.jsxs)(A.$n,{onClick:()=>x.push("/shipments?fromBatch=".concat(o,"&batchNumber=").concat(null===t||void 0===t?void 0:t.batchNumber,"&batchLabel=").concat(encodeURIComponent(_||""))),className:"tw-gap-2",variant:"contained",color:"secondary",children:[(0,Y.jsx)(S.OMN,{}),"Add to Batch"]})})]})]}),a&&!c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A.$n,{onClick:()=>x.goBack(),children:"Back"}),(0,Y.jsxs)("section",{className:"tw-flex tw-flex-col lg:tw-flex-row tw-gap-2 lg:tw-gap-4 tw-justify-between lg:tw-items-center tw-mt-4",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-justify-between tw-items-center",children:[(0,Y.jsx)("div",{className:"tw-text-xl lg:tw-text-2xl tw-font-semibold tw-text-secondary tw-leading-none tw-tracking-tight",children:(0,Y.jsxs)("div",{className:"tw-flex tw-gap-1 tw-items-center",children:[(0,Y.jsxs)("span",{children:["Batch: ",_]}),(0,Y.jsx)(S.ffu,{className:"tw-cursor-pointer",onClick:()=>O(!0)})]})}),(0,Y.jsx)("div",{className:"lg:tw-hidden",children:r({totalSelectedOrders:R,handleExclude:V,handleCancelOpenBatch:B})})]}),(0,Y.jsxs)("div",{className:"tw-flex-none tw-flex tw-items-center tw-gap-2",children:[(0,Y.jsx)(A.m_,{title:"Add another order to this batch",children:(0,Y.jsxs)(A.$n,{variant:"outlined",color:"secondary",onClick:()=>x.push("/shipments?fromBatch=".concat(o,"&batchNumber=").concat(null===t||void 0===t?void 0:t.batchNumber,"&batchLabel=").concat(encodeURIComponent(_||""))),children:[(0,Y.jsx)(S.OMN,{}),"Add to Batch"]})}),(null===t||void 0===t?void 0:t.hasPurchaseableShipment)&&(0,Y.jsx)(A.$n,{variant:"contained",color:"success",onClick:()=>g((0,h.MX)({showModal:!0,batchId:o,purchaseBatch:!0})),children:"Purchase Batch"}),(0,Y.jsx)("div",{className:"tw-hidden lg:tw-block",children:r({totalSelectedOrders:R,handleExclude:V,handleCancelOpenBatch:B})})]})]}),null!==t&&void 0!==t&&t.notes?(0,Y.jsx)("div",{className:"tw-mt-2 tw-text-sm",children:(0,Y.jsxs)("div",{className:"tw-bg-blue-200 tw-inline-block tw-px-4 tw-py-1 tw-rounded-lg lg:tw-rounded-full",children:[(0,Y.jsx)("strong",{children:"Notes:"})," ",(0,Y.jsx)("span",{className:"tw-break-all",children:t.notes})]})}):null,v?(0,Y.jsx)(A.P,{color:"primary",size:20}):null]}):null,(0,Y.jsx)(zl.A,{defaultLabel:_,open:E,edit:!0,defaultDescription:M,onClose:()=>O(!1),handleCancelBatch:B,onSubmit:e=>{var s;(async(e,t,s)=>{try{const n=(await m.Km.post("/batch-orders/update",(0,i.A)({batchId:e},t))).data;(0,d.vA)(()=>{var e;l((0,i.A)((0,i.A)({},n.updatedBatch),{},{orders:s})),y(null!==(e=n.message)&&void 0!==e?e:"Batch Updated Successfully")})}catch(n){(0,d.vA)(()=>{var e,t;f(null!==(e=null===n||void 0===n||null===(t=n.data)||void 0===t?void 0:t.message)&&void 0!==e?e:"Error Updating Batch")})}})(o,{label:e.label,notes:e.notes},null!==(s=null===t||void 0===t?void 0:t.orders)&&void 0!==s?s:[]),T(e.label),U(e.notes),O(!1)}})]})};
2var Zl=l(16364),Hl=l(51155),ql=l(6986),Gl=l(51787);const Kl={minWidth:120,width:"100%",margin:0},Yl=e=>{let t=e.handleChange,l=e.values,s=e.errors,n=e.setErrors,d=e.isSubmitting;const o=(0,He.J1)().withDryIceTermsCheck;return(0,Y.jsx)(A.MJ,{sx:Kl,margin:"dense",children:(0,Y.jsxs)("section",{children:[(0,Y.jsxs)(W.e2,{children:[(0,Y.jsx)(A.$n,{className:l.hasDryIce?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{o(()=>{t("hasDryIce",!0),t("hasIcePack",!1)})},size:"small",children:"Dry Ice"}),(0,Y.jsx)(A.$n,{className:l.hasIcePack?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{t("hasIcePack",!0),t("hasDryIce",!1)},size:"small",children:"Ice Packs"}),(0,Y.jsx)(A.$n,{className:l.hasDryIce||l.hasIcePack?"!tw-border-secondary":"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0",onClick:()=>{t("hasDryIce",!1),t("hasIcePack",!1)},size:"small",children:"No Coolant"})]}),(0,Y.jsxs)(A.SD,{in:l.hasDryIce,className:l.hasDryIce?"tw-mt-4":"",children:[(0,Y.jsx)(Xt.A,{className:"tw-mb-4",isActive:(null===l||void 0===l?void 0:l.hasDryIce)||"dryIce"===l.coolantType,weight:null===l||void 0===l?void 0:l.dryIceWeight,unit:null===l||void 0===l?void 0:l.dryIceWeightUnit}),(0,Y.jsxs)(A.JU,{className:"tw-mb-1.5 tw-text-sm",children:["Average Dry Ice Amount",(0,Y.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]}),(0,Y.jsx)(A.$k,{inputProps:{onChange:e=>{var d;const o=(0,Tt.mD)(null===l||void 0===l||null===(d=l.units)||void 0===d?void 0:d.value)(e),a=(0,i.A)({},s);o?a.dryIce=o:delete a.dryIce,n(a),t("dryIceWeight",e?parseFloat(e):"")},type:"number",disabled:d,max:(0,Tt.k0)(null===l||void 0===l?void 0:l.dryIceWeightUnit),value:null===l||void 0===l?void 0:l.dryIceWeight,error:!(null===s||void 0===s||!s.dryIce),helperText:null===s||void 0===s?void 0:s.dryIce},selectProps:{options:Object.values(L.Ay).map(e=>({label:L.Ob[e],value:e})),onChange:e=>{t("dryIceWeightUnit",e)},disabled:d,value:null===l||void 0===l?void 0:l.dryIceWeightUnit},forDryIce:!0})]}),(0,Y.jsx)(A.SD,{in:l.hasIcePack,className:l.hasIcePack?"tw-mt-4":"",children:(0,Y.jsxs)("div",{className:"tw-flex tw-gap-4",children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-flex tw-space-x-1 tw-items-center",children:(0,Y.jsxs)(A.JU,{className:"tw-mb-1.5 tw-text-sm",children:["Ice Pack Size",(0,Y.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]})}),(0,Y.jsxs)("div",{className:"tw-mt-1",children:[(0,Y.jsx)(W.l6,{value:l.coolant.sku||null,placeholder:"Select Size",options:ql.zd.map(e=>{let t=e.label;return{label:t,value:t}}),onChange:e=>(e=>{const s="Custom"===e?{length:0,width:0,height:0,ounces:0}:(0,ql.oT)(e),n=s.length,d=s.width,o=s.height,a=s.ounces,r=(0,zt.v)({from:L.Ay.OUNCES,value:a}),c=(0,i.A)((0,i.A)({},l.coolant),{},{sku:e,title:"Ice Pack - ".concat(e),dimensions:(0,i.A)((0,i.A)({},l.coolant.dimensions),{},{length:n,width:d,height:o,units:Gl.A.INCHES,weight:{value:parseFloat(parseFloat((r[L.Ay.POUNDS]||0).toFixed(2))),units:L.Ay.POUNDS}})});t("coolant",c)})(e.value),isRequired:!0}),"Custom"===l.coolant.sku&&(0,Y.jsxs)("div",{className:"tw-max-w-96 tw-mt-1",children:[(0,Y.jsx)(G.A,{hideLabel:!0,lengthName:"
2coolant.dimensions.length",widthName:"coolant.dimensions.width",heightName:"coolant.dimensions.height",unitsName:"coolant.dimensions.units",useWithoutFormik:!0,setFieldValue:t,values:l}),(0,Y.jsx)(A.rs,{className:"tw-mt-2",inputProps:{value:l.coolant.dimensions.weight.value,max:(0,Tt.k0)(L.Ay.OUNCES),validate:(0,Tt.mD)(L.Ay.OUNCES),onChange:e=>{t("coolant.dimensions.weight.value",e)}},weightUnitProps:{value:L.Ob[L.Ay.OUNCES]}})]})]})]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-flex tw-space-x-1 tw-items-center",children:(0,Y.jsxs)(A.JU,{className:"tw-mb-1.5 tw-text-sm",children:["Qty",(0,Y.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]})}),(0,Y.jsx)("div",{className:"tw-mt-1",children:(0,Y.jsx)(A.A_,{className:"tw-max-w-24",type:"number",onChange:e=>{t("coolant.quantity",e.target.value)},onFocus:e=>e.target.select(),min:1,step:1,value:l.coolant.quantity})})]})]})})]})})},Ql=e=>({minWidth:120,width:"100%",margin:"0 0 ".concat(e.spacing(1)," 0")}),Xl=e=>{let t=e.values,l=e.handleChange;const s=parseFloat((null===t||void 0===t?void 0:t.amount)||0),n=!(null!==t&&void 0!==t&&t.automatic)&&s>g.xZ,d=!(null!==t&&void 0!==t&&t.automatic)&&""!==(null===t||void 0===t?void 0:t.amount)&&s<=0;return(0,Y.jsxs)(A.MJ,{sx:Ql,margin:"dense",children:[(0,Y.jsx)(A.Sc,{value:"automatic",checked:t.automatic,onChange:()=>l((0,i.A)((0,i.A)({},t),{},{automatic:!t.automatic})),label:"Auto-Calculate to Order Value",labelPlacement:"end",fullWidth:!1}),null!==t&&void 0!==t&&t.automatic?null:(0,Y.jsxs)("div",{className:"tw-mt-2 tw-max-w-56",style:{marginLeft:24},children:[(0,Y.jsx)(A.A_,{name:"amount",type:"number",label:(0,Y.jsxs)("span",{children:["Custom Declared Value",(0,Y.jsx)("span",{style:{marginLeft:8,color:"#CA4941"},children:"*"})]}),variant:"outlined",margin:"dense",disabled:t.automatic,sx:{width:"100%",marginBottom:0},value:t.amount,min:1,max:g.xZ,step:1,onChange:e=>{l((0,i.A)((0,i.A)({},t),{},{amount:e.target.value}))},startAdornment:"$"}),n?(0,Y.jsx)("p",{className:"tw-p-0 tw-m-0 tw-text-red-600 tw-text-sm",children:ee.lw.INSURANCE_AMOUNT_MAX_EXCEEDED}):null,d?(0,Y.jsx)("p",{className:"tw-p-0 tw-m-0 tw-text-red-600 tw-text-sm",children:ee.lw.INSURANCE_AMOUNT_INVALID}):null]})]})},Jl={minWidth:120,width:"100%"},ei=e=>{var t,l;let s=e.values,n=e.handleChange,d=e.errors,o=e.setErrors,a=e.isSubmitting;return(0,Y.jsxs)(A.MJ,{sx:Jl,children:[(0,Y.jsxs)(A.e2,{children:[(0,Y.jsx)(A.$n,{className:"product"===s.type?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{n((0,i.A)((0,i.A)({},s),{},{type:"product"}))},size:"small",children:"Product + Box weight"}),(0,Y.jsx)(A.$n,{className:"custom"===s.type?"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0":"!tw-border-secondary",onClick:()=>{n((0,i.A)((0,i.A)({},s),{},{type:"custom"}))},size:"small",children:"Custom Weight"})]}),(0,Y.jsx)(A.SD,{in:"custom"===(null===s||void 0===s?void 0:s.type),children:(0,Y.jsx)("div",{className:"flex align-items-flex-end tw-gap-2 tw-mt-2",children:(0,Y.jsx)(A.$k,{inputProps:{onChange:e=>{var t,l;const a=(0,Tt.mD)(null===s||void 0===s||null===(t=s.customWeight)||void 0===t||null===(l=t.units)||void 0===l?void 0:l.value)(e),r=(0,i.A)({},d);a?r.weights=a:delete r.weights,o(r),n((0,i.A)((0,i.A)({},s),{},{customWeight:(0,i.A)((0,i.A)({},s.customWeight),{},{value:e})}))},type:"number",disabled:a,max:(0,Tt.k0)(null===s||void 0===s||null===(t=s.customWeight)||void 0===t||null===(l=t.units)||void 0===l?void 0:l.value),value:s.customWeight.value,error:!(null===d||void 0===d||!d.weights),helperText:null===d||void 0===d?void 0:d.weights},selectProps:{options:Object.values(L.Ay).map(e=>({label:L.Ob[e],value:e})),onChange:e=>{n((0,i.A)((0,i.A)({},s),{},{customWeight:(0,i.A)((0,i.A)({},s.customWeight),{},{units:e})}))},disabled:a,value:s.customWeight.units.value}})})})]})},ti={minWidth:120,width:"100%"},li=e=>{let t=e.values,l=e.handleChange;e.errors,e.setErrors;const s=(0,x.Ay)().toDate();return s.setHours(360),(0,Y.jsxs)(A.MJ,{sx:ti,children:[(0,Y.jsxs)(A.e2,{children:[(0,Y.jsx)(A.$n,{className:"now"===t.delivery_schedule?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{l((0,i.A)((0,i.A)({},t),{},{delivery_schedule:"now"}))},size:"small",children:"Now"}
2),(0,Y.jsx)(A.$n,{className:"scheduled"===t.delivery_schedule?"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0":"!tw-border-secondary",onClick:()=>{l((0,i.A)((0,i.A)({},t),{},{delivery_schedule:"scheduled"}))},size:"small",children:"Scheduled"})]}),(0,Y.jsx)(A.SD,{in:"scheduled"===(null===t||void 0===t?void 0:t.delivery_schedule),children:(0,Y.jsx)("div",{className:"tw-mt-2 tw-max-w-56",children:(0,Y.jsx)(A.lr,{onChange:e=>{l((0,i.A)((0,i.A)({},t),{},{pickupStartTime:(0,x.Ay)(e).toDate()}))},type:"datetime",value:t.pickupStartTime,disabledBefore:new Date,disabledAfter:s})})})]})},ii=e=>{let t=e.values,l=e.handleChange,o=e.disabled,a=void 0!==o&&o;const r=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),c=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.carriers}),u=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.services}),v=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.easypostCarrierAccounts}
2),h=(0,n.useState)([]),m=(0,s.A)(h,2),p=m[0],w=m[1],x=(0,n.useCallback)(e=>{var t;let l=e.carrier,i=e.isVndrRate,s=e.manualCarrier;if(null===u||void 0===u||null===(t=u[l])||void 0===t||!t.length)return[];return u[l].map(e=>{const t=c.find(e=>(null===e||void 0===e?void 0:e.carrierValue)===l);let n=t.carrierLabel;return i?n="ShipFare+ ".concat(n):null!==s&&void 0!==s&&s.description&&(n="".concat(n," - ").concat(s.description)),{label:(0,Y.jsx)(A.m_,{title:(0,g.UX)({service:e.serviceValue}),children:(0,Y.jsxs)("span",{className:"tw-flex tw-items-center tw-gap-2",children:[e.serviceLabel,g.AS.includes(e.serviceValue)?(0,Y.jsx)($.A,{information:z.A.SURE_POST}):null]})}),value:"".concat(null!==s&&void 0!==s&&s.id?s.id:"shipfare","-").concat(null===t||void 0===t?void 0:t.carrierValue,"-").concat(null===e||void 0===e?void 0:e.serviceValue),carrierObj:t,serviceObj:e,isVndrRate:i,carrierId:null!==s&&void 0!==s&&s.id?s.id:null,carrierLabel:n,serviceLabel:e.serviceLabel,carrierValue:null!==s&&void 0!==s&&s.id?"".concat(null===t||void 0===t?void 0:t.carrierValue,"/").concat(s.id):t.carrierValue,originalCarrier:null===t||void 0===t?void 0:t.carrierValue,serviceValue:e.serviceValue,carrier:null===t||void 0===t?void 0:t.carrierValue,service:e.serviceValue}})},[c,u]);return(0,n.useEffect)(()=>{var e,t,l,i,s,n,d,o,a;const u=[];let h;if(h=null!==r&&void 0!==r&&r.useDirectManualCarrierIntegration?v.filter(e=>{var t;return null===r||void 0===r||null===(t=r.manualCarrierAccounts)||void 0===t?void 0:t.find(t=>t.id===e.id)}):v.filter(e=>{var t;return null===r||void 0===r||null===(t=r.manualCarriers)||void 0===t?void 0:t.includes(e.id)}),null!==r&&void 0!==r&&null!==(e=r.vndrRatesConfig)&&void 0!==e&&null!==(t=e.usps)&&void 0!==t&&t.active){const e=null===c||void 0===c?void 0:c.find(e=>"usps"===(null===e||void 0===e?void 0:e.carrierValue));e&&u.push({label:(0,Y.jsxs)("h3",{className:"tw-mb-2 tw-mt-0 tw-text-[16
2px]",children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold tw-ml-1",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"+"}),(0,Y.jsx)("span",{className:"tw-font-normal",children:" USPS"})]}),services:x({carrier:e.carrierValue,isVndrRate:!0})})}if(null!==r&&void 0!==r&&null!==(l=r.vndrRatesConfig)&&void 0!==l&&null!==(i=l.fedex)&&void 0!==i&&i.active){const e=null===c||void 0===c?void 0:c.find(e=>"fedex"===(null===e||void 0===e?void 0:e.carrierValue));e&&u.push({label:(0,Y.jsxs)("h3",{className:"tw-mb-2 tw-mt-0 tw-text-[16px]",children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold tw-ml-1",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"+"}),(0,Y.jsx)("span",{className:"tw-font-normal",children:" FedEx"})]}),services:x({carrier:e.carrierValue,isVndrRate:!0})})}if(null!==r&&void 0!==r&&null!==(s=r.vndrRatesConfig)&&void 0!==s&&null!==(n=s.vndrRates)&&void 0!==n&&n.active){const e=null===c||void 0===c?void 0:c.find(e=>"ups"===(null===e||void 0===e?void 0:e.carrierValue));e&&u.push({label:(0,Y.jsxs)("h3",{className:"tw-mb-2 tw-mt-0 tw-text-[16
2px]",children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold tw-ml-1",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"+"}),(0,Y.jsx)("span",{className:"tw-font-normal",children:" UPS"})]}),services:x({carrier:e.carrierValue,isVndrRate:!0})})}if(null!==r&&void 0!==r&&null!==(d=r.vndrRatesConfig)&&void 0!==d&&null!==(o=d.localCourier)&&void 0!==o&&o.active){const e=null===c||void 0===c?void 0:c.find(e=>(0,q.c$)(null===e||void 0===e?void 0:e.carrierValue));e&&u.push({label:(0,Y.jsxs)("h3",{className:"tw-mb-2 tw-mt-0 tw-text-[16px]",children:[(0,Y.jsx)("span",{className:"tw-text-primary tw-font-bold tw-ml-1",children:"ShipFare"}),(0,Y.jsx)("span",{className:"tw-text-secondary tw-font-bold",children:"+"}),(0,Y.jsx)("span",{className:"tw-font-normal",children:" Local Courier"})]}),services:x({carrier:e.carrierValue,isVndrRate:!0})})}null!==(a=h)&&void 0!==a&&a.length&&h.forEach(e=>{const t=null===c||void 0===c?void 0:c.find(t=>(null===t||void 0===t?void 0:t.carrierValue)===e.readable.toLowerCase());t&&u.push({label:(0,Y.jsxs)("h3",{className:"tw-text-secondary tw-font-bold tw-mb-2 tw-mt-0 tw-text-[16
2px]",children:[t.carrierLabel," - ",e.description]}),services:x({carrier:t.carrierValue,manualCarrier:e})})}),w(u)},[c,v,u,r,x]),(0,Y.jsx)("div",{className:"tw-flex tw-flex-col tw-w-full",children:(0,Y.jsx)(A.ND,{buttonText:"Select Service",buttonProps:{variant:"contained",disabled:a,className:"tw-w-full !tw-text-black tw-bg-white tw-border tw-border-solid tw-border-gray-300 tw-flex tw-justify-between"},useLucideIcon:!0,renderMenu:e=>{let s=e.handleListKeyDown,n=e.open;return(0,Y.jsx)(A.cO,{autoFocusItem:n,onKeyDown:s,className:"tw-max-h-[400px] tw-min-w-[300px] tw-p-4 tw-flex tw-flex-col tw-gap-2 !tw-overflow-auto",children:p.map((e,s)=>(0,Y.jsxs)("section",{children:[e.label,e.services.map((e,s)=>{const n=null===t||void 0===t?void 0:t.find(t=>t.value===e.value);return(0,Y.jsxs)(A.Dr,{className:"tw-pl-1",onClick:()=>{let s;s=n?[...null!==t&&void 0!==t?t:[]].filter(t=>t.value!==e.value):[...null!==t&&void 0!==t?t:[],(0,i.A)((0,i.A)({},e),{},{label:e.labelValue})],l(s)},children:[(0,Y.jsx)(A.Sc,{checked:!!n}),e.label]},s)})]},s))})}})})},si={minWidth:120,width:"100%",margin:0},ni=e=>{var t,l,i,n,d;let o=e.handleChange,a=e.values,r=e.isSubmitting;const c=(e,t)=>{if("linerType"===e&&(o("liner.sku",t),o("liner.title",Vt.Ke[t])),"linerThickness"===e){o("liner.thickness",t);const e="N/A"!==t?parseFloat(t.replace("in","")):0;o("liner.dimensions.length",e),o("liner.dimensions.width",e),o("liner.dimensions.height",e),o("internalDimensions.manualDimensions",!1)}o("liner.dimensions.weight.manualWeight",!1)};return(0,Y.jsx)(A.MJ,{sx:si,margin:"dense",children:(0,Y.jsxs)("section",{children:[(0,Y.jsxs)(W.e2,{children:[(0,Y.jsx)(A.$n,{className:a.hasLiner?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{o("hasLiner",!0)},size:"small",children:"Liner"}),(0,Y.jsx)(A.$n,{className:a.hasLiner?"!tw-border-secondary":"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0",onClick:()=>{o("hasLiner",!1)},size:"small",children:"No Liner"})]}),(0,Y.jsxs)(A.SD,{in:a.hasLiner,className:null!==a&&void 0!==a&&a.hasLiner?"tw-mt-4":"",children:[(0,Y.jsxs)("div",{className:"input-group",children:[(0,Y.jsx)("div",{className:"tw-flex tw-space-x-1 tw-items-center",children:(0,Y.jsxs)(A.JU,{className:"tw-mb-1.5 tw-text-sm",children:["What type of insulating liner do you use for this box?",(0,Y.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]})}),(0,Y.jsx)(W.l6,{value:null===a||void 0===a||null===(t=a.liner)||void 0===t?void 0:t.sku,className:"tw-max-w-32",onChange:e=>{c("linerType",e.value)},options:Object.entries(Vt.Ke).map(e=>{let t=(0,s.A)(e,2),l=t[0];return{label:t[1],value:l}}),disabled:r})]}),(0,Y.jsxs)("div",{className:"input-group",children:[(0,Y.jsx)("div",{className:"tw-flex tw-space-x-1 tw-items-center",children:(0,Y.jsxs)(A.JU,{className:"tw-mb-1.5 tw-text-sm tw-mt-4",children:["Liner thickness?",(0,Y.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]})}),(0,Y.jsx)(W.l6,{value:null===a||void 0===a||null===(l=a.liner)||void 0===l?void 0:l.thickness,className:"tw-max-w-32",onChange:e=>{c("linerThickness",e.value)},options:Vt.tt.map(e=>({label:e,value:e})),disabled:r})]}),(0,Y.jsxs)("div",{className:"input-group",children:[(0,Y.jsx)("div",{className:"tw-flex tw-space-x-1 tw-items-center",children:(0,Y.jsxs)(A.JU,{className:"tw-mb-1.5 tw-text-sm tw-mt-4",children:["Estimated Weight",(0,Y.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]})}),(0,Y.jsx)(A.rs,{inputProps:{value:null===a||void 0===a||null===(i=a.liner)||void 0===i||null===(n=i.dimensions)||void 0===n||null===(d=n.weight)||void 0===d?void 0:d.value,onChange:e=>{o("liner.dimensions.weight.value",parseFloat(e)),o("liner.dimensions.weight.manualWeight",!0)},disabled:r},weightUnitProps:{name:"values.liner.dimensions.weight.units",value:L.Ob[L.Ay.POUNDS]}})]})]})]})})},di=e=>{var t,l,o,a,r,c,p,j,f,y,b,S;let N=e.handleClose,C=e.open;const k=(0,u.useHistory)(),I=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),D=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.allFilterOrdersSelected}),E=k.location.search,O=(0,v.Ay)({history:k}),R=(null===O||void 0===O?void 0:O.order_filters)||(null===O||void 0===O?void 0:O.search_filters)||(null===O||void 0===O?void 0:O.order_number)||(null===O||void 0===O?void 0:O.custom_filters),P=(0,w.yK)(),F=P.getSelectedOrders,_=P.deselectAllOrders,T=(0,d.useDispatch)(),M=(0,ie.A)().toastWarning,U=(0,Wt.LO)(),B=(0,n.use
2State)(!1),V=(0,s.A)(B,2),Z=V[0],H=V[1],q=(0,n.useState)(!1),G=(0,s.A)(q,2),K=G[0],Q=G[1],X=(0,n.useState)(!1),J=(0,s.A)(X,2),te=J[0],le=J[1],se=(0,n.useState)(!1),ne=(0,s.A)(se,2),de=ne[0],oe=ne[1],ae=(0,n.useState)(!1),re=(0,s.A)(ae,2),ce=re[0],ue=re[1],ve=(0,n.useState)(!1),he=(0,s.A)(ve,2),me=he[0],pe=he[1],we=(0,n.useState)(!1),xe=(0,s.A)(we,2),ge=xe[0],fe=xe[1],ye=(0,n.useState)(!1),be=(0,s.A)(ye,2),Ae=be[0],Se=be[1],Ne=(0,n.useState)(!1),Ce=(0,s.A)(Ne,2),ke=Ce[0],Ie=Ce[1],De=(0,n.useState)(!1),Ee=(0,s.A)(De,2),Oe=Ee[0],Re=Ee[1],Pe=(0,n.useState)(!1),Fe=(0,s.A)(Pe,2),_e=Fe[0],Te=Fe[1],We=(0,n.useState)(!1),Me=(0,s.A)(We,2),Ue=Me[0],Be=Me[1],Ve=(0,n.useState)(!1),ze=(0,s.A)(Ve,2),$e=ze[0],Ze=ze[1],qe=(0,n.useState)(!1),Ge=(0,s.A)(qe,2),Ke=Ge[0],Ye=Ge[1],Qe=(0,n.useState)(!1),Xe=(0,s.A)(Qe,2),Je=Xe[0],et=Xe[1],tt=(0,n.useState)({services:[],type:{label:"Cheapest",value:"cheapest"}}),lt=(0,s.A)(tt,2),it=lt[0],st=lt[1],nt=(0,n.useState)(null),dt=(0,s.A)(nt,2),ot=dt[0],at=dt[1],rt=(0,n.useState)(null),ct=(0,s.A)(rt,2),ut=ct[0],vt=ct[1],ht=(0,n.useState)(null),mt=(0,s.A)(ht,2),pt=mt[0],wt=mt[1],gt=(0,n.useState)({hasDryIce:!1,hasIcePack:!1,dryIceWeight:"",dryIceWeightUnit:L.Ay.POUNDS,coolant:(0,i.A)({},U.coolant)}),jt=(0,s.A)(gt,2),ft=jt[0],yt=jt[1],bt=(0,n.useState)({hasLiner:!1,liner:(0,i.A)({},U.liner)}),At=(0,s.A)(bt,2),St=At[0],Nt=At[1],Ct=(0,n.useState)({amount:null!==I&&void 0!==I&&null!==(t=I.declaredValue)&&void 0!==t&&t.automatic?"":"".concat(null===I||void 0===I||null===(l=I.declaredValue)||void 0===l?void 0:l.custom)||"",automatic:!(null===I||void 0===I||null===(o=I.declaredValue)||void 0===o||!o.automatic)}),kt=(0,s.A)(Ct,2),It=kt[0],Dt=kt[1],Et=(0,n.useState)(!!(0,xt.Pi)({user:I})),Ot=(0,s.A)(Et,2),Rt=Ot[0],Pt=Ot[1],Ft=(0,n.useState)(!(null===I||void 0===I||!I.deliveryConfirmation)),_t=(0,s.A)(Ft,2),Tt=_t[0],Lt=_t[1],Mt=(0,n.useState)({boxPackingAlgoActive:!!I.boxPackingAlgoActive,boxPackingAlgoQuantityActive:!!I.boxPackingAlgoQuantityActive,boxPackingAlgoWeightActive:!!I.boxPackingAlgoWeightActive}),Ut=(0,s.A)(Mt,2),Bt=Ut[0],Vt=Ut[1],zt=(0,n.useState)(!(null===I||void 0===I||!I.carbonNeutral)),$t=(0,s.A)(zt,2),Zt=$t[0],Ht=$t[1],qt=(0,n.useState)({type:(null===I||void 0===I||null===(a=I.shipmentWeights)||void 0===a?void 0:a.type)||"product",customWeight:{value:(null===I||void 0===I||null===(r=I.shipmentWeights)||void 0===r||null===(c=r.customWeight)||void 0===c?void 0:c.value)||"",units:"custom"===(null===I||void 0===I||null===(p=I.shipmentWeights)||void 0===p?void 0:p.type)?{label:(null===I||void 0===I||null===(j=I.shipmentWeights)||void 0===j||null===(f=j.customWeight)||void 0===f?void 0:f.units)||(null===I||void 0===I?void 0:I.defaultWeightUnits)||L.Ay.POUNDS,value:(null===I||void 0===I||null===(y=I.shipmentWeights)||void 0===y||null===(b=y.customWeight)||void 0===b?void 0:b.units)||(null===I||void 0===I?void 0:I.defaultWeightUnits)||L.Ay.POUNDS}:{label:(null===I||void 0===I?void 0:I.defaultWeightUnits)||L.Ay.POUNDS,value:(null===I||void 0===I?void 0:I.defaultWeightUnits)||L.Ay.POUNDS}}}),Gt=(0,s.A)(qt,2),Kt=Gt[0],Yt=Gt[1],Qt=(0,n.useState)({delivery_schedule:"now",pickupStartTime:(0,x.Ay)().toDate()}),Xt=(0,s.A)(Qt,2),Jt=Xt[0],el=Xt[1],tl=(0,n.useState)(null),ll=(0,s.A)(tl,2),il=ll[0],sl=ll[1],nl=(0,n.useState)(!1),dl=(0,s.A)(nl,2),ol=dl[0],al=dl[1],rl=(0,n.useState)(null),cl=(0,s.A)(rl,2),ul=cl[0],vl=cl[1],hl=(0,n.useState)({}),ml=(0,s.A)(hl,2),pl=ml[0],wl=ml[1],xl=(0,He.J1)().withDryIceTermsCheck,gl=null===I||void 0===I?void 0:I.internationalSettings,jl=(0,xt.DT)(I),fl=(0,xt.Xe)(I),yl=null!==gl&&void 0!==gl&&gl.length?(null===gl||void 0===gl?void 0:gl.find(e=>!!e.isDefault))||gl[0]:null;(0,n.useEffect)(()=>{jl&&!ot&&at(jl.id),fl&&!pt&&wt(fl.id),yl&&!ul&&vl(yl)},[ot,jl,pt,fl,ul,yl]);const bl=e=>{var t,l,s,n,d,o,a,r,c,u,v;N(e),Q(!1),le(!1),oe(!1),ue(!1),pe(!1),fe(!1),Se(!1),Ie(!1),Re(!1),Te(!1),Be(!1),Ze(!1),Ye(!1),et(!1),st({services:[],type:{label:"Cheapest",value:"cheapest"}}),at(null),vt(null),wt(null),yt({hasDryIce:!1,hasIcePack:!1,dryIceWeight:"",dryIceWeightUnit:L.Ay.POUNDS,coolant:(0,i.A)({},U.coolant)}),Nt({hasLiner:!1,liner:(0,i.A)({},U.liner)}),Dt({amount:null!==I&&void 0!==I&&null!==(t=I.declaredValue)&&void 0!==t&&t.automatic?""
2:"".concat(null===I||void 0===I||null===(l=I.declaredValue)||void 0===l?void 0:l.custom)||"",automatic:!(null===I||void 0===I||null===(s=I.declaredValue)||void 0===s||!s.automatic)}),Pt(!!(0,xt.Pi)({user:I})),Lt(!(null===I||void 0===I||!I.deliveryConfirmation)),Vt({boxPackingAlgoActive:!!I.boxPackingAlgoActive,boxPackingAlgoQuantityActive:!!I.boxPackingAlgoQuantityActive,boxPackingAlgoWeightActive:!!I.boxPackingAlgoWeightActive}),Ht(!(null===I||void 0===I||!I.carbonNeutral)),Yt({type:(null===I||void 0===I||null===(n=I.shipmentWeights)||void 0===n?void 0:n.type)||"product",customWeight:{value:(null===I||void 0===I||null===(d=I.shipmentWeights)||void 0===d||null===(o=d.customWeight)||void 0===o?void 0:o.value)||"",units:"custom"===(null===I||void 0===I||null===(a=I.shipmentWeights)||void 0===a?void 0:a.type)?{label:(null===I||void 0===I||null===(r=I.shipmentWeights)||void 0===r||null===(c=r.customWeight)||void 0===c?void 0:c.units)||(null===I||void 0===I?void 0:I.defaultWeightUnits),value:(null===I||void 0===I||null===(u=I.shipmentWeights)||void 0===u||null===(v=u.customWeight)||void 0===v?void 0:v.units)||(null===I||void 0===I?void 0:I.defaultWeightUnits)}:{label:null===I||void 0===I?void 0:I.defaultWeightUnits,value:null===I||void 0===I?void 0:I.defaultWeightUnits}}}),el({delivery_schedule:"now",pickupStartTime:(0,x.Ay)().toDate()}),vl(null),al(!1)},Al=(0,Le.No)({user:I,feature:Le.cc.box_packing_algo}),Sl=(0,Le.No)({user:I,feature:Le.cc.insurance}),Nl=!1===(null===I||void 0===I?void 0:I.overrideUpscInsurance),Cl=e=>{if(null===e||void 0===e||""===e)return!1;const t=parseFloat(e);return!isNaN(t)&&t>0},kl=K||te||de||ce||me||ge||Ae||ke||Oe||_e||Ue||$e||Ke||Je,Il=(e=>{if(de&&(null===it||void 0===it||null===(e=it.services)||void 0===e||!e.length))return!0;if(Je&&"scheduled"===(null===Jt||void 0===Jt?void 0:Jt.delivery_schedule)&&(null===Jt||void 0===Jt||!Jt.pickupStartTime))return!0;if(te&&!pt)return!0;if(K&&!ot)return!0;if(Oe&&!K&&!Ue&&(null===Bt||void 0===Bt||!Bt.boxPackingAlgoActive)&&(null===Bt||void 0===Bt||!Bt.boxPackingAlgoQuantityActive)&&(null===Bt||void 0===Bt||!Bt.boxPackingAlgoWeightActive))return!0;var t;if(Ue&&"custom"===(null===Kt||void 0===Kt?void 0:Kt.type)&&!Cl(null===Kt||void 0===Kt||null===(t=Kt.customWeight)||void 0===t?void 0:t.value))return!0;if(ce){if(null!==ft&&void 0!==ft&&ft.hasDryIce&&!Cl(null===ft||void 0===ft?void 0:ft.dryIceWeight))return!0;if(null!==ft&&void 0!==ft&&ft.hasIcePack){var l,i;if(null===ft||void 0===ft||null===(l=ft.coolant)||void 0===l||!l.sku)return!0;if(!Cl(null===ft||void 0===ft||null===(i=ft.coolant)||void 0===i?void 0:i.quantity))return!0}}if(me&&null!==St&&void 0!==St&&St.hasLiner){var s,n,d,o,a;if(null===St||void 0===St||null===(s=St.liner)||void 0===s||!s.sku)return!0;if(null===St||void 0===St||null===(n=St.liner)||void 0===n||!n.thickness)return!0;if(!Cl(null===St||void 0===St||null===(d=St.liner)||void 0===d||null===(o=d.dimensions)||void 0===o||null===(a=o.weight)||void 0===a?void 0:a.value))return!0}if(ge&&(null===It||void 0===It||!It.automatic)){const e=null===It||void 0===It?void 0:It.amount;if(""===e||null===e||void 0===e)return!0;const t=parseFloat(e);if(isNaN(t)||t<=0)return!0;if(t>g.xZ)return!0}return!(!$e||il)||!(!Ke||ul)})();return(0,Y.jsx)(A.aF,{open:C,title:"Bulk Edit Shipments",handleClose:Z?()=>{}:bl,actions:[{isClose:!0,disabled:Z},{isPrimary:!0,onClick:async()=>{try{const e=F(),t={orderIds:e,fieldsToUpdate:{shouldUpdateBoxPackingAlgo:Oe,shouldUpdateWarehouse:te,shouldUpdateDryIce:ce,shouldUpdateLiner:me,shouldUpdateBox:K,shouldUpdateShippingMethod:de,shouldUpdateInsurance:ge,shouldUpdateSaturdayDelivery:Ae,shouldUpdateDeliveryConfirmation:ke,shouldUpdateCarbonNeutral:_e,shouldUpdateWeights:Ue,shouldUpdateShipDate:$e,shouldUpdateInternationalSetting:Ke,shouldUpdatePickupSchedule:Je},valuesToUpdate:{selectedBoxPackingAlgo:Bt,selectedWarehouseId:pt,selectedDryIceWeight:ft,selectedLiner:St,selectedBoxId:ot,customDimensions:ut,selectedShippingMethod:(0,i.A)((0,i.A)({},it),{},{services:it.services.map(e=>({carrier:e.carrier,service:e.service,isVndrRate:e.isVndrRate,carrierId:e.carrierId}))}),selectedInsurance:It,selectedSaturdayDelivery:Rt,selectedDeliveryConfirmation:Tt,selectedCarbonNeutral:Zt,selectedWeights:Kt,shipDate:il,moveToHold:ol,selectedInternationalSetting:ul,selectedDeliverySchedule:Jt}};let l="/orders/update/bulk";if(D){T((0,h.CW)({allSelectInProgress:!0,loading:!0}));let e=E;e?R||null!==O&&void 0!==O&&O.shipmentStatus||(e+="&shipmentStatus=holding"):e="?shipmentStatus=holding",l+=e,t.allFilterOrdersSelected=!0}const s=(await m.Dp.post(l,t)).data;(0,d.vA)(()=>{T((0,h.Gg)((0,i.A)({notice:null===s||void 0===s?void 0:s.message},ee.Ay[null!==s&&void 0!==s&&s.status?s.status.toUpperCase():"INFO"]))),T((0,h.N6)(s.updatedProgressReportResult)),T((0,h.CW)({processedOrders:e,loading:!1})),_(),H(!1),bl({reset:!1})})}catch(e){(0,d.vA)(()=>{var t,l,i;M(null!==(t=null===e||void 0===e||null===(l=e.response)||void 0===l||null===(i=l.data)||void 0===i?void 0:i.message)&&void 0!==t?t:"Failed to edit orders"),T((0,h.CW)({allSelectInProgress:!1,loading:!1}))}),H(!1)}},label:"Confirm",disabled:!ot||Z||Il||!kl,loading:Z}],children:(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-2",children:[(0,Y.jsx)(A.o5,{color:"primary",children:(0,Y.jsx)("b",{children:"Changes will apply to all selected orders and shipments."})}),(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"shipping_method",checked:de,onCh
2ange:()=>oe(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Set Shipping Service",(0,Y.jsx)($.A,{information:z.A.SHIPPING_METHOD})]})})}),de?(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-mx-4 tw-flex tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-w-full tw-max-w-56",children:(0,Y.jsx)(ii,{values:it.services,handleChange:e=>{st((0,i.A)((0,i.A)({},it),{},{services:e}))}})}),(0,Y.jsx)("div",{className:"tw-w-full tw-max-w-56",children:(null===it||void 0===it||null===(S=it.services)||void 0===S?void 0:S.length)>1?(0,Y.jsx)(W.l6,{value:it.type,options:[{label:"Cheapest",value:"cheapest"},{label:"Fastest",value:"fastest"}],onChange:e=>{st((0,i.A)((0,i.A)({},it),{},{type:e}))}}):null})]}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"schedule_pickup",checked:Je,onChange:()=>et(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Schedule Local Courier Pickup",(0,Y.jsx)($.A,{information:z.A.SCHEDULE_PICKUP})]})})}),Je?(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-mx-4",children:(0,Y.jsx)(li,{handleChange:e=>{el(e)},values:Jt,errors:pl,setErrors:wl})}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"warehouse",checked:te,onChange:()=>le(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Change Warehouse",(0,Y.jsx)($.A,{information:z.A.WAREHOUSE})]})})}),te?(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-mx-4",children:(0,Y.jsx)(Hl.A,{handleBulk:e=>{wt(null===e||void 0===e?void 0:e.id)}})}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"package",checked:K,onChange:()=>Q(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Change Box",(0,Y.jsx)($.A,{information:z.A.BOX})]})})}),K?(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-mx-4",children:[(0,Y.jsx)(Zl.A,{handleBulk:e=>{e.isCustom&&vt(e),at(null===e||void 0===e?void 0:e.id)},isBulkEdit:!0}),(0,Y.jsx)("div",{className:"tw-mt-2 tw-text-sm tw-italic",children:"* Setting a custom Box disables Box Splitting Algo"})]}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(Le.L0,{feature:Le.cc.box_packing_algo,isClickable:!0,children:(0,Y.jsx)(A.dO,{paywalledFeature:Le.cc.box_packing_algo,value:"boxPackingAlgoActive",checked:Oe&&!K&&!Ue,onChange:()=>{Al||(Re(e=>!e),null!==Bt&&void 0!==Bt&&Bt.boxPackingAlgoActive||null!==Bt&&void 0!==Bt&&Bt.boxPackingAlgoQuantityActive||null!==Bt&&void 0!==Bt&&Bt.boxPackingAlgoWeightActive||Vt({boxPackingAlgoWeightActive:!0,boxPackingAlgoQuantityActive:!1,boxPackingAlgoActive:!1}))},color:"primary",disabled:K||Ue,label:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center",children:["Activate Box Splitting Algorithm",(0,Y.jsx)($.A,{information:z.A.BOX_PACKING_ALGO})]})})})}),!Oe||K||Ue?null:(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-mx-4",children:[(0,Y.jsxs)(W.e2,{children:[(0,Y.jsx)(A.$n,{className:Bt.boxPackingAlgoWeightActive?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{Al||Vt({boxPackingAlgoWeightActive:!0,boxPackingAlgoQuantityActive:!1,boxPackingAlgoActive:!1})},size:"small",children:"Weight"}),(0,Y.jsx)(A.$n,{className:Bt.boxPackingAlgoQuantityActive?"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0":"!tw-border-secondary",onClick:()=>{Al||Vt({boxPackingAlgoWeightActive:!1,boxPackingAlgoQuantityActive:!0,boxPackingAlgoActive:!1})},size:"small",children:"Quantity"}),(0,Y.jsx)(A.$n,{className:Bt.boxPackingAlgoActive?"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0":"!tw-border-secondary",onClick:()=>{Al||Vt({boxPackingAlgoWeightActive:!1,boxPackingAlgoQuantityActive:!1,boxPackingAlgoActive:!0})},size:"small",children:"Dimension"})]}),Oe&&(Bt.boxPackingAlgoActive||Bt.boxPackingAlgoQuantityActive||Bt.boxPackingAlgoWeightActive)?(0,Y.jsx)("div",{className:"tw-mt-2 tw-text-sm tw-italic",children:"* Activating the Box Splitting Algorithm will combine all Products into as few Boxes as possible based on the method chosen."}):null]}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}),(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"weights",checked:Ue,onChange:()=>Be(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Update Weights",(0,Y.jsx)($.A,{information:z.A.WEIGHTS})]})})}),Ue?(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-mx-4",children:[(0,Y.jsx)(ei,{handleChange:e=>{Yt(e)},values:Kt,errors:pl,setErrors:wl,isSubmitting:Z}),(0,Y.jsx)("div",{className:"tw-mt-2 tw-text-sm tw-italic",children:"* Updating weights disables Box Splitting Algo"})]}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"dryIce",checked:ce,onChange:()=>{ce?ue(!1):xl(()=>ue(!0))},label:(0,Y.jsxs)(Y.Fragment,{children:["Add/Remove Coolant",(0,Y.jsx)($.A,{information:z.A.DRY_ICE})]})})}),ce?(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-mx-4",children:(0,Y.jsx)(Yl,{handleChange:(e,t)=>
2{const l=(0,je.set)(ft,e,t);yt((0,i.A)({},l))},values:ft,errors:pl,setErrors:wl,isSubmitting:Z})}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"liner",checked:me,onChange:()=>pe(e=>!e),label:"Add/Remove Liner"})}),me?(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-mx-4",children:(0,Y.jsx)(ni,{handleChange:(e,t)=>{const l=(0,je.set)(St,e,t);Nt((0,i.A)({},l))},values:St,errors:pl,setErrors:wl,isSubmitting:Z})}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,Nl?null:(0,Y.jsx)("div",{children:(0,Y.jsx)(Le.L0,{feature:Le.cc.insurance,isClickable:!0,children:(0,Y.jsx)(A.dO,{value:"insurance",paywalledFeature:Le.cc.insurance,checked:ge,onChange:()=>{Sl||fe(e=>!e)},label:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center",children:["Add/Remove Full Coverage",(0,Y.jsx)($.A,{information:z.A.INSURANCE})]})})})}),ge?(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-mx-4",children:[(0,Y.jsx)(Xl,{handleChange:e=>{Dt(e)},values:It}),null!==It&&void 0!==It&&It.automatic?null:(0,Y.jsx)("div",{className:"tw-mt-2 tw-text-sm tw-italic",style:{marginLeft:24},children:"* Set value to 0 for removing Full Coverage from selected shipments"})]}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"saturdayDelivery",checked:Ae,onChange:()=>Se(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:[" ","Update Saturday Delivery",(0,Y.jsx)($.A,{information:z.A.SATURDAY_DELIVERY})]})})}),Ae?(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-mx-4",children:(0,Y.jsxs)(W.e2,{children:[(0,Y.jsx)(A.$n,{className:Rt?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{Pt(!0)},size:"small",children:"On"}),(0,Y.jsx)(A.$n,{className:Rt?"!tw-border-secondary":"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0",onClick:()=>{Pt(!1)},size:"small",children:"Off"})]})}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"deliveryConfirmation",checked:ke,onChange:()=>Ie(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Update Signature Required",(0,Y.jsx)($.A,{information:z.A.SIGNATURE_REQUIRED})]})})}),ke?(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-mx-4",children:(0,Y.jsxs)(W.e2,{children:[(0,Y.jsx)(A.$n,{className:Tt?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{Lt(!0)},size:"small",children:"On"}),(0,Y.jsx)(A.$n,{className:Tt?"!tw-border-secondary":"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0",onClick:()=>{Lt(!1)},size:"small",children:"Off"})]})}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"carbonNeutral",checked:_e,onChange:()=>Te(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Update Carbon Neutral",(0,Y.jsx)($.A,{information:z.A.CARBON_NEUTRAL})]})})}),_e?(0,Y.jsxs)("div",{children:[(0,Y.jsx)("div",{className:"tw-mx-4",children:(0,Y.jsxs)(W.e2,{children:[(0,Y.jsx)(A.$n,{className:Zt?"!tw-bg-secondary !tw-text-white":"!tw-border-secondary",onClick:()=>{Ht(!0)},size:"small",children:"On"}),(0,Y.jsx)(A.$n,{className:Zt?"!tw-border-secondary":"!tw-bg-secondary !tw-text-white tw-mt-2 md:tw-mt-0",onClick:()=>{Ht(!1)},size:"small",children:"Off"})]})}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"shipDate",checked:$e,onChange:()=>Ze(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Ship By Date",(0,Y.jsx)($.A,{information:z.A.SHIP_DATE})]})})}),$e?(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("div",{className:"tw-mx-4",children:[(0,Y.jsx)("div",{className:"flex align-items-center tw-max-w-56",children:(0,Y.jsx)(W.lr,{onChange:e=>sl(e||""),value:il,disabled:Z,disabledBefore:new Date})}),(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-gap-2 tw-mt-4",children:(0,Y.jsx)(A.Sc,{checked:ol,onChange:()=>al(e=>!e),disabled:Z,label:"Move to Hold",labelPlacement:"end",fullWidth:!1})})]}),(0,Y.jsx)("hr",{style:{borderColor:"#d1d5db2d"}})]}):null,null!==gl&&void 0!==gl&&gl.length?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{children:(0,Y.jsx)(A.dO,{value:"internationalProfile",checked:Ke,onChange:()=>Ye(e=>!e),label:(0,Y.jsxs)(Y.Fragment,{children:["Apply International Profile",(0,Y.jsx)($.A,{information:z.A.INTERNATIONAL_PROFILE})]})})}),Ke?(0,Y.jsx)("div",{className:"flex align-items-center tw-mb-2 tw-mx-4 tw-max-w-56",children:(0,Y.jsx)(W.l6,{value:(null===ul||void 0===ul?void 0:ul.profileName)||"",onChange:e=>{const t=null===gl||void 0===gl?void 0:gl.find(t=>t.profileName===e.value);vl((0,i.A)((0,i.A)({},t),{},{selectedProfile:t.profileName}))},options:gl.map(e=>({label:e.profileName,value:e.profileName}))})}):null]}):null]})})};var oi=l(97103);const ai=()=>{const e=(0,p.A)(),t=e.handleAddToBatch,l=e.batchLoading,i=e.validationData,s=e.resetValidationData;return(0,Y.jsx)(A.aF,{title:"Add to Batch Number ".concat(i.batchNumber),open:null===i||void 0===i?void 0:i.showModal,maxWidth:"sm",withCloseButton:!0,handleClose:s,actions:[{label:"Yes, move ".concat((null===i||void 0===i?void 0:i.ordersCount)>1?"these shipments":"this shipment"),loading:l,onClick:()=>(async e=>{await t(null===i||void 0===i?void 0:i.batchId,null===i||void 0===i?void 0:i.includeOrderIds,e),s()})(!0),color:"primary"},{label:"Cancel",loading:l,color:"default",disabled:l,onClick:()=>s()}],children:(0,Y.jsxs)(A.o5,{children:[null===i||void 0===i?void 0:i.ordersCount," ",(null===i||void 0===i?void 0:i.ordersCount)>1?"Shipments are":"Shipment is"," ","already in a different batch. Are you sure you want to move it to Batch:"," ",null===i||void 0===i?void 0:i.batchNumber," ?"]})})};var ri=l(5048);const ci=e=>{let t=e.open,l=e.onClose,i=e.batchNumber;const s=e.batchLabel||i||"";return(0,Y.jsx)(A.aF,{title:"Add Shipments to Batch",open:t,maxWidth:"xs",handleClose:l,withCloseButton:!0,actions:[{label:"Got it",color:"secondary",onClick:l}],children:(0,Y.jsxs)("div",{children:["Select and add shipments to batch"," ",(0,Y.jsx)("span",{className:"tw-font-bold",children:s}),"."]})})};
2var ui=l(72140),vi=l(3103);const hi=Object.values(vi.x).map(e=>({label:e,value:e})),mi=e=>{let t=e.currentPage,l=void 0===t?1:t,i=e.pageSize,s=void 0===i?20:i,n=e.totalItems,d=void 0===n?0:n,o=e.onPageChange,a=e.onPageSizeChange,r=e.loading,c=void 0!==r&&r,u=e.className,v=void 0===u?"":u;const h=Math.max(1,Math.ceil(d/s)),m=Math.min(Math.max(1,l),h),p=m>1,w=m<h,x=0===d?0:(m-1)*s+1,g=Math.min(m*s,d),j=e=>{e<1&&(e=1),e>h&&(e=h),o&&e!==l&&o(e)};return h<=1?null:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-center md:tw-justify-between tw-container tw-mx-auto tw-mt-4 ".concat(v),children:[(0,Y.jsx)("div",{className:"tw-hidden md:tw-block",children:d>0?"Row ".concat((0,be.thousandsFormat)(x)," to ").concat((0,be.thousandsFormat)(g)," of ").concat((0,be.thousandsFormat)(d)):"No items"}),(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col lg:tw-flex-row tw-gap-2 tw-items-center",children:[(0,Y.jsxs)("div",{className:"tw-hidden md:tw-flex tw-gap-1 tw-items-center tw-mr-4",children:[(0,Y.jsx)("span",{className:"tw-text-nowrap",children:"Items Per Page"}),(0,Y.jsx)(W.l6,{name:"recordsLimit",options:hi,value:{label:s,value:s},disabled:c,onChange:e=>{return t=null===e||void 0===e?void 0:e.value,void(a&&t!==s&&a(t));var t}})]}),(0,Y.jsxs)("div",{className:"tw-flex tw-gap-2 tw-items-center",children:[(0,Y.jsx)(A.$n,{size:"small",className:"!tw-p-0",disabled:!p||c,onClick:()=>j(m-1),children:(0,Y.jsx)(S.JGc,{className:"pointer tw-w-[34px] tw-h-[34px]"})}),(0,Y.jsxs)("div",{children:[(0,be.thousandsFormat)(m)," of ",(0,be.thousandsFormat)(h)]}),(0,Y.jsx)(A.$n,{className:"!tw-p-0",size:"small",disabled:!w||c,onClick:()=>j(m+1),children:(0,Y.jsx)(S.c_$,{className:"pointer tw-w-[34px] tw-h-[34px]"})})]})]})]})},pi=()=>{var e,t,l;const o=(0,d.useDispatch)(),a=(0,ie.A)(),r=a.toastError,c=a.toastSuccess,v=(0,u.useHistory)(),p=(0,n.use
2State)(!1),w=(0,s.A)(p,2),g=w[0],j=w[1],f=(0,n.useState)({}),y=(0,s.A)(f,2),b=y[0],N=y[1],C=(0,n.useState)(!1),k=(0,s.A)(C,2),I=k[0],D=k[1],E=(0,n.useState)([]),O=(0,s.A)(E,2),R=O[0],P=O[1],F=(0,n.useState)(1),_=(0,s.A)(F,2),T=_[0],W=_[1],L=(0,n.useState)(20),M=(0,s.A)(L,2),U=M[0],B=M[1],V=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.lateShipments)||[]}),z=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),$=(0,n.useMemo)(()=>{const e=(T-1)*U,t=e+U,l=Math.min(Math.max(0,e),V.length),i=Math.min(t,V.length);return V.slice(l,i)},[V,T,U]);(0,n.useEffect)(()=>{const e=Math.max(1,Math.ceil(V.length/U));T>e&&e>0&&W(e)},[V.length,U,T]);const H=null===(e=Object.values(b||{}))||void 0===e?void 0:e.filter(e=>{var t;return!(null===e||void 0===e||null===(t=e.lateShipmentStatuses)||void 0===t?void 0:t.find(e=>"Notified Customer"===e.name))&&(null===e||void 0===e?void 0:e.customerEmail)}),G=(null===H||void 0===H?void 0:H.length)||0,K=null===(t=Object.values(b||{}))||void 0===t?void 0:t.filter(e=>null===e||void 0===e?void 0:e.isVndrRate),Q=(null===K||void 0===K?void 0:K.length)||0,X=Object.keys(b).length,J=X===(null===$||void 0===$?void 0:$.length)&&$.length>0,ee=(0,n.useCallback)(async e=>{let t=e.notifyMessage,l=e.notifySubject,i=e.isPreview,s=void 0!==i&&i;j(!0);try{const e=(await m.Dp.post("/shipments/late-shipments/notify",{notifyShipments:R,notifyMessage:t,findIntegration:!0,isPreview:s,notifySubject:l})).data;(0,d.vA)(()=>{c(e.message),s||(o((0,h.CW)({lateShipments:e.lateShipments})),N({}),P([]),D(!1))})}catch(a){var n;r(null!==a&&void 0!==a&&null!==(n=a.response)&&void 0!==n&&n.data||s?"Failed to send test notification email!":"Failed to send notification emails to the customers!")}j(!1)},[o,R,r,c]),te=(0,n.useCallback)(async e=>{j(!0);const t=e?[e]:Object.values(b||{});try{const e=(await m.Dp.post("/shipments/late-shipments/dismiss",t)).data;(0,d.vA)(()=>{c(e.message),o((0,h.CW)({lateShipments:e.lateShipments}))}),N({})}catch(i){var l;r((null===i||void 0===i||null===(l=i.response)||void 0===l?void 0:l.data)||"Failed to dismiss late shipment notifications!")}j(!1)},[o,b,r,c]),le=(0,n.useCallback)(e=>{P(e?[e]:H),D(!0)},[H]),ne=(0,xt.A8)(z);let de={order_id:"#1234",tracking_number_link:'<a className="tw-underline tw-text-secondary tw-font-bold" href=\''.concat(Z.GG,"/track?trackId=TEST' target='_blank'>TEST</a>"),planned_delivery_date:"01/24/2026",expected_delivery_date:"01/28/2026"};if(null!==R&&void 0!==R&&R.length){const e=R[0];null!==e&&void 0!==e&&e.orderNumber&&(de.order_id=e.orderNumber),null!==e&&void 0!==e&&e.trackingCode&&(de.tracking_number_link='<a className="tw-underline tw-text-secondary tw-font-bold" href=\''.concat(Z.GG,"/track?trackId=").concat(e.trackingCode,"' target='_blank'>").concat(e.trackingCode,"</a>")),null!==e&&void 0!==e&&e.promisedDeliveryDate&&(de.planned_delivery_date=x.d4.utc(e.promisedDeliveryDate).format("MM/DD/YYYY")),null!==e&&void 0!==e&&e.deliveryDate&&(de.expected_delivery_date=x.d4.utc(e.deliveryDate).format("MM/DD/YYYY")),null!==e&&void 0!==e&&e.customerName&&(de.customer_name=e.customerName)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ze,{user:z,active:I,handleClose:()=>{P([]),D(!1)},handleSubmit:ee,submitting:g,isLateShipment:!0,previewData:de}),(0,Y.jsxs)("div",{className:"tw-max-w-6xl tw-mx-auto tw-flex tw-flex-col tw-gap-4",children:[(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between tw-gap-4 tw-flex-wrap",children:[(0,Y.jsx)(A.$n,{onClick:()=>{o((0,h.CW)({showLateShipments:!1}))},children:"Back"}),X&&(Q||G)?(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-space-x-2",children:[Q?(0,Y.jsx)(se,{trackingIds:null===K||void 0===K||null===(l=K.map(e=>null===e||void 0===e?void 0:e.trackingCode))||void 0===l?void 0:l.join(", "),isLoading:g}):null,G?(0,Y.jsxs)(A.$n,{onClick:()=>le(),disabled:g,children:["Notify (",G,")"]}):null,(0,Y.jsx)(A.$n,{onClick:()=>te(),disabled:g,variant:"contained",color:"error",children:"Dismiss"})]}):null]}),(0,Y.jsx)("h3",{className:"tw-subtitle !tw-text-xl tw-flex tw-items-center lg:!tw-text-2xl tw-p-0 tw-m-0",children:"Late Shipments"}),(0,Y.jsxs)("div",{children:[(0,Y.jsxs)(A.QT,{style:{minWidth:650},size:"small",children:[(0,Y.jsx)(A.A0,{children:(0,Y.jsxs)(A.Hj,{children:[(0,Y.jsx)(A.nd,{children:(0,Y.jsx)(A.Sc,{value:"select-all",disabled:g,checked:J,indeterminate:!!X&&!J,onCh
2ange:()=>{if(X)return N({});const e=(0,yt.jM)(b,e=>{$.forEach(t=>{e[t.shipmentId]=(0,i.A)({},t)})});N(e)}})}),(0,Y.jsx)(A.nd,{children:"Order ID"}),(0,Y.jsx)(A.nd,{width:200,children:"Tracking"}),(0,Y.jsx)(A.nd,{width:230,children:"Service Name"}),(0,Y.jsx)(A.nd,{width:200,children:"Promised Delivery Date"}),(0,Y.jsx)(A.nd,{width:200,children:"New Expected Delivery Date"}),ne?(0,Y.jsx)(A.nd,{width:230,children:"Service Requested"}):null,(0,Y.jsx)(A.nd,{})]})}),(0,Y.jsx)(A.BF,{children:$.map(e=>{var t,l,s,n,d;const a=null===e||void 0===e||null===(t=e.lateShipmentStatuses)||void 0===t?void 0:t.find(e=>"Notified Customer"===e.name),r=[...new Set(null===e||void 0===e||null===(l=e.lateShipmentStatuses)||void 0===l?void 0:l.map(e=>e.name))].filter(e=>"Notified Customer"!==e).join(", ");let c=q.v2[e.service];return c||(c=q.ZB[e.service]),c||(c=(0,je.startCase)(null!==(s=e.service)&&void 0!==s?s:"")),(0,Y.jsxs)(A.Hj,{children:[(0,Y.jsx)(A.nA,{children:(0,Y.jsx)(A.Sc,{checked:!!b[e.shipmentId],disabled:g,value:e.shipmentId,onChange:()=>{const t=(0,yt.jM)(b,t=>{b[e.shipmentId]?delete t[e.shipmentId]:t[e.shipmentId]=(0,i.A)({},e)});N(t)}})}),(0,Y.jsx)(A.nA,{children:(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-cursor-pointer tw-mb-1",children:(0,Y.jsxs)("div",{className:"tw-whitespace-nowrap tw-cursor-pointer tw-underline",style:{color:"#551A8B"},onClick:()=>{var t;o((0,h.SN)({orderId:e.orderId,onComplete:()=>{v.push("/shipments#".concat(e.orderId,"-").concat(e.shipmentId))},redirectFrom:(null===v||void 0===v||null===(t=v.location)||void 0===t?void 0:t.pathname)||null}))},children:[e.orderNumber,null!==e&&void 0!==e&&e.isMultiShipmentOrder&&null!==e&&void 0!==e&&e.shipmentIdx?" - ".concat(e.shipmentIdx):""]})})}),(0,Y.jsx)(A.nA,{children:(0,Y.jsx)("a",{href:(0,Cl.G)({shipment:{platformType:null===e||void 0===e?void 0:e.platformType,label:{trackingUrl:null===e||void 0===e?void 0:e.trackingUrl}},user:z,orderId:null===e||void 0===e?void 0:e.orderId}),target:"_blank",rel:"noreferrer",children:e.trackingCode})}),(0,Y.jsx)(A.nA,{children:c}),(0,Y.jsx)(A.nA,{children:null===(n=e.promisedDeliveryDate)||void 0===n?void 0:n.split("T")[0]}),(0,Y.jsx)(A.nA,{children:null===(d=e.deliveryDate)||void 0===d?void 0:d.split("T")[0]}),ne?(0,Y.jsx)(A.nA,{className:"tw-text-secondary",children:null!==r&&void 0!==r&&r.length?(0,Y.jsx)(A.m_,{title:r,children:(0,je.truncate)(r,{length:55})}):"None"}):null,(0,Y.jsx)(A.nA,{children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-end !tw-gap-1",children:[null!==e&&void 0!==e&&e.customerEmail?a?(0,Y.jsx)("div",{className:"tw-bg-green-200 tw-px-3 tw-py-1 tw-rounded-full",children:"Notified"}):(0,Y.jsx)(A.$n,{onClick:()=>le(e),disabled:g,size:"small",children:"Notify Customer"}):(0,Y.jsx)("div",{className:"tw-text-red-500 tw-font-bold",children:"Missing customer email"}),(0,Y.jsx)(A.m_,{title:"Dismiss",children:(0,Y.jsx)(A.$n,{iconButton:!0,disabled:g,onClick:()=>te(e),children:(0,Y.jsx)(S.epd,{})})})]})})]},e.shipmentId)})},"page-".concat(T,"-size-").concat(U))]}),V.length>0&&(0,Y.jsx)(mi,{currentPage:T,pageSize:U,totalItems:V.length,onPageChange:e=>{const t=parseInt(e,10);W(t),N({})},onPageSizeChange:e=>{const t=parseInt(e,10);B(t),W(1),N({})},loading:g,className:"tw-mt-4"})]})]})]})},wi=["children","style"],xi=e=>{var t,l,s;let o=e.order,a=(e.index,e.setSelectedItems),r=e.selectedItems,c=void 0===r?{}:r,v=e.submitting,m=e.currentRowId;const p=(0,u.useHistory)(),w=(0,d.useDispatch)(),x=(0,n.useCallback)(e=>{let t=e.children,l=e.style,s=void 0===l?{}:l,n=(0,ge.A)(e,wi);return(0,Y.jsx)(A.nA,(0,i.A)((0,i.A)({style:(0,i.A)({padding:10},s)},n),{},{children:t}))},[]),g={};o.selected&&(g.backgroundColor="#EFF6FF");const j=(0,n.useCallback)(()=>{var e;const t=[];return null===o||void 0===o||null===(e=o.shipments)||void 0===e||e.forEach(e=>{var l;null!==e&&void 0!==e&&null!==(l=e.products)&&void 0!==l&&l.length&&t.push(...e.products)}),t.length?(0,Y.jsx)(A.tH,{children:(0,Y.jsx)("ul",{className:"tw-list-none tw-pl-0 tw-m-0",children:t.map((e,t)=>(0,Y.jsxs)("li",{className:"tw-m-0 tw-p-0",children:[e.title," (",e.sku,") - ",e.quantity," ",e.kitting?"(Kit)":""]},t))})}):null},[null===o||void 0===o?void 0:o.shipments]);return(0,Y.jsx)(n.Fragment,{children:(0,Y.jsxs)(A.Hj,{style:g,children:[(0,Y.jsx)(x,{width:50,children:(0,Y.jsx)("div",{className:"tw-flex tw-items-center",children:(0,Y.jsx)(A.Sc,{checked:!(null===c||void 0===c||null===(t=c[m])||void 0===t||!t[o._id]),disabled:v,value:o._id,className:"tw-ml-4",onCh
2ange:()=>{const e=(0,yt.jM)(c,e=>{var t,l;null!==c&&void 0!==c&&null!==(t=c[m])&&void 0!==t&&t[o._id]?null===e||void 0===e||(null===(l=e[m])||void 0===l||delete l[o._id]):e[m]?e[m][o._id]=1:e[m]={[o._id]:1}});a(e)}})})}),(0,Y.jsx)(x,{children:(0,Y.jsx)(A.N_,{className:"tw-text-black !tw-cursor-pointer !tw-underline",onClick:()=>(async()=>{var e,t,l;let i=null===p||void 0===p||null===(e=p.location)||void 0===e?void 0:e.pathname;const s="".concat(i||"").concat((null===p||void 0===p||null===(t=p.location)||void 0===t?void 0:t.search)||"").concat((null===p||void 0===p||null===(l=p.location)||void 0===l?void 0:l.hash)||"");w((0,h.SN)({orderId:o._id,onComplete:()=>{var e;null!==(e=i)&&void 0!==e&&e.includes("/shipments")||(i="/shipments"),p.push("".concat(i,"?").concat(p.location.search,"#").concat(o._id))},redirectFrom:s}))})(),children:null!==(l=null===o||void 0===o?void 0:o.orderNumber)&&void 0!==l?l:""})}),(0,Y.jsx)(x,{children:null===o||void 0===o||null===(s=o.shipments)||void 0===s?void 0:s.length}),(0,Y.jsx)(x,{children:j()})]})},null===o||void 0===o?void 0:o._id)},gi=e=>{var t,l,s,n;let d=e.sameRecipientOrders,o=e.setSelectedItems,a=e.selectedItems,r=void 0===a?{}:a,c=e.submitting;if(null===d||void 0===d||null===(t=d.orders)||void 0===t||!t.length)return null;const u=null===d||void 0===d?void 0:d.recipientString,v=null===(l=Object.keys((null===r||void 0===r?void 0:r[u])||{}))||void 0===l?void 0:l.length,h=v&&v===(null===d||void 0===d||null===(s=d.orders)||void 0===s?void 0:s.length);return(0,Y.jsxs)(A.QT,{"aria-label":"same-recipient-orders-table",className:"tw-min-w-[650px] tw-w-full tw-whitespace-nowrap !tw-border-none",size:"small",children:[(0,Y.jsx)(A.A0,{children:(0,Y.jsxs)(A.Hj,{className:"shipment-table-head",children:[(0,Y.jsx)(A.nd,{width:50,style:{padding:10},children:(0,Y.jsx)("div",{className:"tw-flex tw-items-center",children:(0,Y.jsx)(A.Sc,{value:"select-all",disabled:c,checked:h,className:"tw-ml-4",indeterminate:!!v&&!h,onChange:()=>{if(v){const e=(0,i.A)({},r);return delete e[u],void o(e)}const e=(0,yt.jM)(r,e=>{e[u]={},d.orders.forEach(t=>{e[u][t._id]=1})});o(e)}})})}),(0,Y.jsx)(A.nd,{width:150,style:{padding:10},children:"Order #"}),(0,Y.jsx)(A.nd,{width:150,style:{padding:10},children:"Total Shipments"}),(0,Y.jsx)(A.nd,{style:{padding:10},children:"Products"})]})}),(0,Y.jsx)(A.BF,{children:null===d||void 0===d||null===(n=d.orders)||void 0===n?void 0:n.map((e,t)=>(0,Y.jsx)(xi,{order:e,index:t,setSelectedItems:o,selectedItems:r,submitting:c,currentRowId:u},t))})]})},ji=()=>{const e=(0,d.useDispatch)(),t=(0,ie.A)(),l=t.toastError,o=t.toastSuccess,a=(0,u.useHistory)(),r=(0,w.yK)().deselectAllOrders,c=(0,n.useState)(null),p=(0,s.A)(c,2),x=p[0],g=p[1],j=(0,n.useState)({}),f=(0,s.A)(j,2),y=f[0],b=f[1],N=(0,n.useState)(!1),C=(0,s.A)(N,2),k=C[0],I=C[1],D=(0,n.useState)(1),E=(0,s.A)(D,2),O=E[0],R=E[1],P=(0,n.useState)(20),F=(0,s.A)(P,2),_=F[0],T=F[1],W=(0,n.useState)(null),L=(0,s.A)(W,2),M=L[0],U=L[1],B=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.sameRecipientOrders)||[]}),V=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}),Z=(0,n.useMemo)(()=>{const e=(O-1)*_,t=e+_,l=Math.min(Math.max(0,e),B.length),i=Math.min(t,B.length);return B.slice(l,i)},[B,O,_]);(0,n.useEffect)(()=>{const e=Math.max(1,Math.ceil(B.length/_));O>e&&e>0&&R(e)},[B.length,_,O]);const H=(0,v.Ay)({history:a}),q=(null===H||void 0===H?void 0:H.shipmentStatus)||"holding",G=!q||"holding"===q,K=(0,n.useCallback)(async function(t){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];g(t.recipientString),U(null);try{var s;let l=Object.keys((null===y||void 0===y?void 0:y[null===t||void 0===t?void 0:t.recipientString])||{});null!==(s=l)&&void 0!==s&&s.length||(l=t.orders.map(e=>e._id));const n=(await m.Dp.post("/orders/same-recipient-orders/combine",{orderIds:l,bypassAlgo:i})).data;(0,d.vA)(()=>{var t;o(n.message);const l={sameRecipientOrders:n.sameRecipientOrders};null!==n&&void 0!==n&&null!==(t=n.sameRecipientOrders)&&void 0!==t&&t.length||(l.showSameRecipientOrders=!1,G&&e((0,h.dk)())),e((0,h.CW)(l))}),r(),b({})}catch(a){var n;l((null===a||void 0===a||null===(n=a.response)||void 0===n?void 0:n.data)||"Failed to combine orders!")}g(null)},[r,e,G,y,l,o]),Q=(0,n.useCallback)(async t=>{g(t.recipientString);try{var i;let l=Object.keys((null===y||void 0===y?void 0:y[null===t||void 0===t?void 0:t.recipientString])||{});null!==(i=l)&&void 0!==i&&i.length||(l=t.orders.map(e=>e._id));const s=(await m.Dp.post("/orders/same-recipient-orders/dismiss",l)).data;(0,d.vA)(()=>{var t;o(s.message);const l={sameRecipientOrders:s.sameRecipientOrders};null!==s&&void 0!==s&&null!==(t=s.sameRecipientOrders)&&void 0!==t&&t.length||(l.showSameRecipientOrders=!1),e((0,h.CW)(l))}),b({})}catch(n){var s;l((null===n||void 0===n||null===(s=n.response)||void 0===s?void 0:s.data)||"Failed to dismiss orders!")}g(null)},[e,y,l,o]),X=(0,n.useCallback)(async e=>{g(e.recipientString);try{var t;let l=Object.keys((null===y||void 0===y?void 0:y[null===e||void 0===e?void 0:e.recipientString])||{});null!==(t=l)&&void 0!==t&&t.length||(l=e.orders.map(e=>e._id));const i=(await m.Dp.post("/orders/same-recipient-orders/box-algo-dry-run",l)).data;null!==i&&void 0!==i&&i.totalAlgoShipments&&1!==(null===i||void 0===i?void 0:i.totalAlgoShipments)?(U({show:!0,totalAlgoShipments:i.totalAlgoShipments,row:e}),g(null)):K(e)}catch(s){var i;l((null===s||void 0===s||null===(i=s.response)||void 0===i?void 0:i.data)||"Something went wrong!"),g(null)}},[y,K,l]),J=e=>{const t=(e||"").split("|");return(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-gap-1",children:(0,Y.jsxs)("div",{children:[t[0]," - ",t[1]]})})};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"tw-max-w-6xl tw-mx-auto tw-flex tw-flex-col tw-gap-4",children:[(0,Y.jsx)("div",{className:"tw-flex tw-items-center tw-justify-between tw-gap-4 tw-flex-wrap",children:(0,Y.jsx)(A.$
2n,{onClick:()=>{(0,d.vA)(()=>{e((0,h.CW)({showSameRecipientOrders:!1})),e((0,h.dk)())})},children:"Back"})}),(0,Y.jsxs)("h3",{className:"tw-subtitle !tw-text-xl tw-flex tw-items-center lg:!tw-text-2xl tw-p-0 tw-m-0",children:["Combinable Orders",(0,Y.jsx)($.A,{information:z.A.COMBINE_SHIPMENTS})]}),(0,Y.jsxs)("div",{children:[(0,Y.jsxs)(A.QT,{className:"tw-min-w-[650px]",size:"small",children:[(0,Y.jsx)(A.A0,{children:(0,Y.jsxs)(A.Hj,{children:[(0,Y.jsx)(A.nd,{width:30,className:"tw-pr-0",children:(0,Y.jsx)("div",{className:"tw-flex tw-items-center",children:(0,Y.jsx)(A.m_,{title:k?"Collapse all":"Expand all",children:(0,Y.jsx)(A.$n,{iconButton:!0,"aria-label":"expand row",size:"small",onClick:()=>{const t=!k,l=B.map(e=>(0,i.A)((0,i.A)({},e),{},{expanded:t}));e((0,h.CW)({sameRecipientOrders:l})),I(t)},children:k?(0,Y.jsx)(S.w$n,{}):(0,Y.jsx)(S.VqP,{})})})})}),(0,Y.jsx)(A.nd,{children:"Recipient"}),(0,Y.jsx)(A.nd,{width:150,children:"Total Orders"}),(0,Y.jsx)(A.nd,{width:150})]})}),(0,Y.jsx)(A.BF,{children:Z.map((t,l)=>{var i,s;const d=Object.keys((null===y||void 0===y?void 0:y[t.recipientString])||{}).length,o=x===t.recipientString;return(0,Y.jsxs)(n.Fragment,{children:[(0,Y.jsxs)(A.Hj,{children:[(0,Y.jsx)(A.nA,{width:30,className:"tw-pr-0",children:(0,Y.jsx)("div",{className:"tw-flex tw-items-center",children:null!==t&&void 0!==t&&null!==(i=t.orders)&&void 0!==i&&i.length?(0,Y.jsx)(A.$n,{iconButton:!0,"aria-label":"exp
2and row",size:"small",onClick:()=>(t=>{const l=(0,yt.jM)(B,e=>{var l;e[t].expanded=!(null!==(l=e[t])&&void 0!==l&&l.expanded)});e((0,h.CW)({sameRecipientOrders:[...l]}))})(l),disabled:o,children:t.expanded?(0,Y.jsx)(S.w$n,{}):(0,Y.jsx)(S.VqP,{})}):null})}),(0,Y.jsx)(A.nA,{children:J(t.recipientString)}),(0,Y.jsx)(A.nA,{children:null===t||void 0===t||null===(s=t.orders)||void 0===s?void 0:s.length}),(0,Y.jsx)(A.nA,{children:(0,Y.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-end !tw-gap-1",children:[(0,Y.jsx)(A.$n,{onClick:()=>{null!==V&&void 0!==V&&V.boxPackingAlgoActive||null!==V&&void 0!==V&&V.boxPackingAlgoQuantityActive||null!==V&&void 0!==V&&V.boxPackingAlgoWeightActive?X(t):K(t)},disabled:o||d&&d<2,size:"small",variant:"contained",color:"secondary",loading:o,children:"Combine"}),(0,Y.jsx)(A.m_,{title:"Dismiss",children:(0,Y.jsx)(A.$n,{iconButton:!0,disabled:o,onClick:()=>Q(t),loading:o,color:"error",children:(0,Y.jsx)(S.epd,{})})})]})})]},t.recipientString),(0,Y.jsx)(A.Hj,{className:t.expanded?"":"tw-hidden",children:(0,Y.jsx)(A.nA,{style:{padding:0,left:0,position:"sticky"},colSpan:10,children:(0,Y.jsx)(A.SD,{in:t.expanded,timeout:"auto",unmountOnExit:!0,children:(0,Y.jsx)(gi,{sameRecipientOrders:t,setSelectedItems:b,selectedItems:y,submitting:o})})})})]},t.recipientString)})},"page-".concat(O,"-size-").concat(_))]}),B.length>0&&(0,Y.jsx)(mi,{currentPage:O,pageSize:_,totalItems:B.length,onPageChange:e=>{const t=parseInt(e,10);R(t),b({})},onPageSizeChange:e=>{const t=parseInt(e,10);T(t),R(1),b({})},loading:!!x,className:"tw-mt-4"})]})]}),(0,Y.jsxs)(A.aF,{title:"Multi Shipment Order Warning",open:null===M||void 0===M?void 0:M.show,handleClose:()=>U(null),actions:[{onClick:()=>K(null===M||void 0===M?void 0:M.row,!1),label:"Proceed with Algo",loading:!!x,disabled:!!x,variant:"outlined",color:"secondary"},{isPrimary:!0,onClick:()=>K(null===M||void 0===M?void 0:M.row),label:"Bypass Algo",loading:!!x,disabled:!!x}],children:["You have Box Splitting Algo by"," ",null!==V&&void 0!==V&&V.boxPackingAlgoActive?"Dimensions":null!==V&&void 0!==V&&V.boxPackingAlgoQuantityActive?"Quantity":"Weight"," ","Active. Combining these orders will create a new combined order with"," ",null===M||void 0===M?void 0:M.totalAlgoShipments," shipments. Do you want to proceed with the Algo or Bypass it?"]})]})};var fi=l(33763);const yi=()=>{var e;const t=(0,u.useParams)().id,l=(0,u.useHistory)(),i=(0,d.useDispatch)(),a=!!t&&l.location.pathname.includes("/batch"),r=(0,n.useState)(!1),c=(0,s.A)(r,2),m=c[0],p=c[1],x=(0,n.useState)({batchNumber:"",batchLabel:""}),g=(0,s.A)(x,2),j=g[0],S=g[1],N=f({isBatch:a,batchId:t}),C=N.theme,k=N.loading,I=N.hasOrder,D=N.showPickupModal,E=N.showBulkEditModal,O=N.openBatchModal,R=N.batchLoading,P=N.openManifest,F=N.batchPageData,_=N.searchPanelExpanded,W=N.setShowPickupModal,L=N.setShowBulkEditModal,M=N.handleClosePickupModal,U=N.handleCloseBulkEditModal,B=N.setOpenBatchModal,V=N.setOpenManifest,z=N.handleDeleteFromBatch,$=N.setSearchPanelExpanded,Z=N.setBatchPageData,H=(0,n.useState)(null),q=(0,s.A)(H,2),G=q[0],K=q[1],Q=(0,w.yK)().deselectAllOrders,X=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.showLateShipments}),J=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.showSameRecipientOrders}),ee=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.loading}),te=(0,d.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.totalLoading}),le=(0,d.useSelector)(e=>{var t;return(null===e||void 0===e||null===(t=e.orders)||void 0===t?void 0:t.total)||0}),ie=(0,v.Ay)({history:l}),se=(null===ie||void 0===ie?void 0:ie.page)||1,ne=(null===ie||void 0===ie?void 0:ie.limit)||100,de=a?(null===F||void 0===F||null===(e=F.orders)||void 0===e?void 0:e.length)&&!k:I;(0,n.useEffect)(()=>{const e=new URL(window.location.href),t=e.searchParams.get("showOrderDetails"),s=e.searchParams.get("fromBatch"),n=e.searchParams.get("batchNumber"),d=e.searchParams.get("batchLabel");if(t){const t=e.searchParams.get("orderId");i((0,h.SN)({orderId:t}))}if(s&&!a){S({batchNumber:n||"",batchLabel:d?decodeURIComponent(d):""}),p(!0);const e=new URL(window.location.href);e.searchParams.delete("fromBatch"),e.searchParams.delete("batchNumber"),e.searchParams.delete("batchLabel"),l.replace(e.pathname+e.search)}},[l.location.search,a]),(0,n.useEffect)(()=>{document.title="Shipments - ShipFare",Q()},[]);return(0,Y.jsxs)("div",{children:[(0,Y.jsx)(y.A,{show:k,fixedUnderHeader:!0}),ee?(0,Y.jsx)("div",{style:{position:"absolute",width:"78%",height:"90%",zIndex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:(0,Y.jsx)(A.P,{})}):null,(0,Y.jsx)(T.A,{}),(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(Ml,{})}),(0,Y.jsx)(Ul.A,{batchId:t,orderIds:null===F||void 0===F?void 0:F.orderIds}),(0,Y.jsx)(Bl,{}),(0,Y.jsx)(o.c7,{permissions:[o.I1.EDIT_ORDERS],children:(0,Y.jsx)(di,{open:E,handleClose:U})}),(0,Y.jsx)(b.A,{handleClose:e=>{M(e),K(null)},show:D,initialSelectedOrders:G}),(0,Y.jsx)(oi.A,{open:O,onClose:()=>B(!1)}),(0,Y.jsx)(ai,{}),(0,Y.jsx)(ri.A,{open:P,setOpen:V}),(0,Y.jsx)(Vl.A,{}),(0,Y.jsx)(ci,{open:m,onClose:()=>p(!1),batchNumber:j.batchNumber,batchLabel:j.batchLabel}),X?(0,Y.jsx)(A.tH,{children:(0,Y.jsx)(pi,{})}
2):J?(0,Y.jsx)(A.tH,{children:(0,Y.jsx)(ji,{})}):(0,Y.jsxs)(Y.Fragment,{children:[a?(0,Y.jsx)(A.tH,{children:(0,Y.jsx)($l,{id:t,loading:k,batchLoading:R,batchPageData:F,setBatchPageData:Z,hasOrder:de,renderActions:e=>{let t=e.totalSelectedOrders,l=e.handleExclude,i=e.handleCancelOpenBatch;return(0,Y.jsx)(xe,{isBatch:!0,totalSelectedOrders:t,handleExclude:l,handleCancelOpenBatch:i,onOpenBatchModal:()=>B(!0),setOpenManifest:V,onSchedulePickup:e=>{K(e),W(!0)}})}})}):(0,Y.jsx)(A.tH,{children:(0,Y.jsx)(xe,{onOpenBatchModal:()=>B(!0),setOpenManifest:V,onSchedulePickup:e=>{K(e),W(!0)}})}),de?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"tw-flex tw-flex-col tw-bg-white tw-rounded-2xl tw-w-full tw-drop-shadow-lg tw-pt-0 tw-border tw-border-gray-200 tw-border-solid tw-mt-5",children:[a?(0,Y.jsx)("div",{}):(0,Y.jsx)(A.tH,{children:(0,Y.jsx)(Ye,{searchPanelExpanded:_,setSearchPanelExpanded:$})}),(0,Y.jsx)(A.tH,{FallbackComponent:ui.A,children:(0,Y.jsx)(Re,{searchPanelExpanded:_})})]}),(0,Y.jsx)(A.tH,{FallbackComponent:ui.A,children:(0,Y.jsx)(fi.A,{page:se,limit:ne,total:le,history:l,loading:k||te})}),(0,Y.jsx)(A.tH,{children:(0,Y.jsx)(qe,{setShowBulkEditModal:L,setShowPickupModal:W,setOpenBatchModal:B,setOpenManifest:V,batchId:t,isBatch:a,theme:C,handleDeleteFromBatch:z,hasPurchaseableShipment:null===F||void 0===F?void 0:F.hasPurchaseableShipment})})]}):null]})]})},bi=e=>(0,Y.jsx)(o.c7,{permissions:[o.I1.ORDERS,o.I1.VIEW_PRINT_ORDERS],children:(0,Y.jsx)(A.tH,{FallbackComponent:ui.A,children:(0,Y.jsx)(yi,(0,i.A)({},e))})})},50653(e,t,l){l.d(t,{A:()=>y});var i=l(98477),s=l(39698),n=l(84489),d=l(16536),o=l(71288),a=l(14618),r=l(67252),c=l(58072),u=l(45851),v=l(68870),h=l(42229),m=l(38153),p=l(85053),w=l(16684),x=l(84980),g=l(28872);const j=e=>{let t=e.open,l=e.onClose,i=e.onConfirm,d=e.validationResults,o=e.loading,a=e.notificationEmail;const c=(0,r.useRef)(null),v=(0,r.useState)(""),j=(0,s.A)(v,2),f=j[0],y=j[1],b=null!==a&&void 0!==a&&a.dns?Object.entries(null===a||void 0===a?void 0:a.dns).map(e=>{var t,l,i;let n=(0,s.A)(e,2),o=n[0],a=n[1];var r,c;return"mail_cname"===o?{host:null===a||void 0===a||null===(r=a.host)||void 0===r||null===(c=r.split("."))||void 0===c?void 0:c[0],data:null===a||void 0===a?void 0:a.data,validation:null===d||void 0===d?void 0:d[(0,x.camelCase)(o)]}:{host:null===a||void 0===a||null===(t=a.host)||void 0===t||null===(l=t.split("."))||void 0===l||null===(i=l.slice(0,2))||void 0===i?void 0:i.join("."),data:null===a||void 0===a?void 0:a.data,validation:null===d||void 0===d?void 0:d[o]}}):[],A=e=>{var t;null!==(t=navigator)&&void 0!==t&&t.clipboard&&(navigator.clipboard.writeText(e),y(e),clearTimeout(c.current),c.current=setTimeout(()=>{y(null)},1500))};return(0,g.jsx)(n.aF,{open:t,title:"Verify Domain",handleClose:l,fullWidth:!0,maxWidth:"sm",actions:[{isClose:!0,label:"Cancel"},{label:"Verify",onClick:i,color:"primary",loading:o}],PaperProps:{className:"tw-max-w-[768px]"},children:(0,g.jsxs)("div",{className:w.A.container,children:[(0,g.jsx)(n.o5,{variant:"body1",children:"Sign in to your domain name provider (e.g. GoDaddy.com or Namecheap.com), navigate to the DNS settings, and add the CNAME records below to allow us to send emails on your behalf."}),(0,g.jsxs)(h.XI,{containerClassName:"tw-mt-4 tw-w-full",children:[(0,g.jsx)(h.A0,{children:(0,g.jsxs)(h.Hj,{children:[(0,g.jsx)(h.nd,{children:"Type"}),(0,g.jsx)(h.nd,{children:"Name"}),(0,g.jsx)(h.nd,{children:"Target"})]})}),(0,g.jsx)(h.BF,{children:b.map((e,t)=>{let l=e.host,i=e.data,s=e.validation;return(0,g.jsxs)(r.Fragment,{children:[(0,g.jsxs)(h.Hj,{className:!s||null!==s&&void 0!==s&&s.valid?"":"tw-border-b-0",children:[(0,g.jsx)(h.nA,{className:"tw-font-medium ".concat(!s||null!==s&&void 0!==s&&s.valid?"":"tw-pb-0"),children:"CNAME"}),(0,g.jsx)(h.nA,{className:!s||null!==s&&void 0!==s&&s.valid?"":"tw-pb-0",children:(0,g.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1 tw-cursor-pointer",onClick:()=>A(l),children:[(0,g.jsx)("span",{children:l}),f===l?(0,g.jsx)(m.A,{className:"tw-size-5 tw-text-primary",strokeWidth:1}):(0,g.jsx)(p.A,{className:"tw-size-5",strokeWidth:1})]})}),(0,g.jsx)(h.nA,{className:!s||null!==s&&void 0!==s&&s.valid?"":"tw-pb-0",children:(0,g.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1 tw-cursor-pointer",onClick:()=>A(i),children:[(0,g.jsx)("span",{className:"tw-break-all",children:i}),f===i?(0,g.jsx)(m.A,{className:"tw-size-5 tw-text-primary",strokeWidth:1}):(0,g.jsx)(p.A,{className:"tw-size-5",strokeWidth:1})]})})]}),!s||null!==s&&void 0!==s&&s.valid?null:(0,g.jsx)(h.Hj,{children:(0,g.jsx)(h.nA,{colSpan:3,className:"tw-p-0",children:(0,g.jsx)(n.SD,{in:!!s&&!(null!==s&&void 0!==s&&s.valid),collapsedSize:0,style:{width:"100%"},children:(0,g.jsxs)("div",{className:w.A.validation,children:[(0,g.jsx)(u.wF4,{fontSize:"small",htmlColor:"#B98901"}),(0,g.jsxs)("div",{className:w.A.validationText,children:[(0,g.jsx)("p",{children:"We received the following error when validating the record."}),(0,g.jsx)("p",{children:null===s||void 0===s?void 0:s.reason})]})]})})})},"".concat(l,"-validation"))]},l)})})]})]})})};var f=l(76276);const y=e=>{let t=e.compact;const l=(0,o.useDispatch)(),h=(0,f.A)(),m=h.toastError,p=h.toastSuccess,w=(0,o.useSelector)(e=>{var t;return null===e||void 0===e||null===(t=e.auth)||void 0===t?void 0:t.user}).notificationEmail,x=(0,r.useState)(!1),y=(0,s.A)(x,2),b=y[0],A=y[1],S=(0,r.useState)(!1),N=(0,s.A)(S,2),C=N[0],k=N[1],I=(0,r.useState)(null),D=(0,s.A)(I,2),E=D[0],O=D[1],R=async()=>{A(!0);try{const e=(await a.FH.delete("/user/v1/company/notification-email/delete")).data;(0,o.vA)(()=>
2{l((0,c.QO)({user:(0,i.A)((0,i.A)({},e),{},{notificationEmail:null})})),p(e.message||"Successfully Deleted")})}catch(n){var e,t,s;m((null===n||void 0===n||null===(e=n.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.message)||(null===n||void 0===n||null===(s=n.response)||void 0===s?void 0:s.data)||(null===n||void 0===n?void 0:n.message)||"Something Went Wrong")}finally{A(!1)}};return(0,g.jsxs)("div",{className:t?"":"tw-px-4",children:[!t&&(0,g.jsx)("div",{className:"tw-text-xl tw-font-medium tw-text-secondary",children:"Sender Email"}),w?t?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(n.A_,{variant:"outlined",value:null===w||void 0===w?void 0:w.email,label:"Sender Email",disabled:!0,fullWidth:!0,margin:"dense"}),(0,g.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2 tw-mt-2",children:[!(null!==w&&void 0!==w&&w.valid)&&(0,g.jsx)(n.$n,{size:"small",onClick:()=>k(!0),loading:b,disabled:b,children:"Verify domain"}),(0,g.jsx)(n.$n,{size:"small",loading:b,disabled:b,onClick:R,color:"error",children:"Delete"})]})]}):(0,g.jsxs)("div",{className:"tw-flex tw-justify-between tw-items-center tw-mt-1",children:[(0,g.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,g.jsx)("span",{children:null===w||void 0===w?void 0:w.email}),null!==w&&void 0!==w&&w.valid?(0,g.jsx)("span",{className:"tw-bg-green-200 tw-px-2 tw-py-0.5 tw-rounded-full tw-text-sm tw-w-fit",children:"Verified"}):null]}),(0,g.jsx)("div",{className:"tw-flex tw-items-center tw-gap-2",children:(0,g.jsxs)(g.Fragment,{children:[null!==w&&void 0!==w&&w.valid?null:(0,g.jsx)("div",{children:(0,g.jsx)(n.$n,{size:"small",onClick:()=>k(!0),loading:b,disabled:b,children:"Verify domain"})}),(0,g.jsx)(n.m_,{title:"Delete",children:(0,g.jsx)(n.$n,{iconButton:!0,size:"small",loading:b,disabled:b,className:"tw-cursor-pointer tw-flex tw-items-center max-sm:-tw-mr-2",onClick:R,children:(0,g.jsx)(u.epd,{})})})]})})]}):(0,g.jsx)(n.l1,{enableReinitialize:!0,validationSchema:d.SI,initialValues:{email:(null===w||void 0===w?void 0:w.email)||""},onSubmit:async e=>{let t=e.email;try{A(!0);const e=(await a.FH.post("/user/v1/company/notification-email",{email:t,userNotificationEmail:w})).data;(0,o.vA)(()=>{l((0,c.QO)({user:e})),p(e.message)}),k(!0)}catch(d){var i,s,n;m((null===d||void 0===d||null===(i=d.response)||void 0===i||null===(s=i.data)||void 0===s?void 0:s.message)||(null===d||void 0===d||null===(n=d.response)||void 0===n?void 0:n.data)||(null===d||void 0===d?void 0:d.message)||"Something Went Wrong")}finally{A(!1)}},children:e=>{let l=e.submitForm,i=e.values,s=e.errors;return(0,g.jsx)(n.lV,{children:(0,g.jsxs)("div",{className:"tw-mt-2",children:[(0,g.jsx)(n.B0,{name:"email",component:v.A,label:t?"Sender Email":(0,g.jsxs)("span",{children:["Verify your email to enable delivery notifications via ShipFare.",(0,g.jsx)("span",{className:"tw-text-red-600 tw-pl-1",children:"*"})]}),type:"email"}),(0,g.jsx)(n.$n,{variant:"contained",color:"primary",onClick:l,className:"tw-mt-2",disabled:!(null!==i&&void 0!==i&&i.email)||(null===s||void 0===s?void 0:s.email)||b,loading:b,children:"Verify"})]})})}}),(0,g.jsx)(j,{open:C,onConfirm:async()=>{try{A(!0);const e=(await a.FH.get("/user/v1/company/notification-email/validate")).data;if((null===w||void 0===w?void 0:w.valid)!==(null===e||void 0===e?void 0:e.valid)&&l((0,c.QO)({user:{notificationEmail:(0,i.A)((0,i.A)({},w),{},{valid:e.valid})}})),null!==e&&void 0!==e&&e.valid)return p("Email Successfully Verified!"),void k(!1);O(e)}catch(n){var e,t,s;m((null===n||void 0===n||null===(e=n.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.message)||(null===n||void 0===n||null===(s=n.response)||void 0===s?void 0:s.data)||(null===n||void 0===n?void 0:n.message)||"Something Went Wrong")}finally{A(!1)}},validationResults:null===E||void 0===E?void 0:E.validationResults,notificationEmail:w,loading:b,onClose:()=>{O(null),k(!1)}})]})}},66904(e,t,l){l.d(t,{A:()=>i});const i=(0,l(87911).A)("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]])},38153(e,t,l){l.d(t,{A:()=>i});
2const i=(0,l(87911).A)("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]])},65572(e,t,l){l.d(t,{A:()=>i});const i=(0,l(87911).A)("Grip",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]])},63474(e,t,l){l.d(t,{A:()=>i});const i=(0,l(87911).A)("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]])}}]);
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.