@shipengine/elements 2.16.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/carrier.js CHANGED
@@ -1 +1 @@
1
- import{format as e}from"date-fns/format";import{ca as r,de as a,enAU as s,enGB as t,enUS as n,es as i,fr as l,it as o,pt as c}from"date-fns/locale";import{parse as d}from"date-fns/parse";import u from"lodash/get.js";import m from"humps";import{SE as p}from"@shipengine/react-api";import g from"lodash/isEqual.js";import h from"lodash/isNil.js";import v from"lodash/omit.js";import f from"lodash/omitBy.js";import{c as y,u as w,f as b}from"./address.js";function D(e,r){var a={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&r.indexOf(s)<0&&(a[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(s=Object.getOwnPropertySymbols(e);t<s.length;t++)r.indexOf(s[t])<0&&Object.prototype.propertyIsEnumerable.call(e,s[t])&&(a[s[t]]=e[s[t]])}return a}function C(e,r,a,s){return new(a||(a=Promise))((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function l(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a((function(e){e(r)}))).then(i,l)}o((s=s.apply(e,r||[])).next())}))}const L=(e,r="en-US")=>new Date(e).toLocaleDateString(r,{day:"numeric",month:"long",year:"numeric"}),S=(e="en-US")=>{const d=e.replaceAll("-",""),u=e.split("-")[0],m={ca:r,de:a,enAU:s,enGB:t,enUS:n,es:i,fr:l,it:o,pt:c};return m[d in m?d:u]},A=(r,a="en-US",s)=>{const t=S(a),n=j(a);return e(r,null!=s?s:n,{locale:t})},M=(e,r="en-US",a="P")=>{const s=S(r);return d(e,a,new Date,{locale:s})},U=(e,r="en-US")=>new Date(e).toLocaleDateString(r,{day:"2-digit",month:"2-digit",year:"2-digit"}),O=(e,r="en-US")=>new Date(e).toLocaleDateString(r,{day:"2-digit",month:"2-digit",year:"numeric"}),j=(e="en-US")=>{var r;return null===(r=(S(e)||S("en-US")).formatLong)||void 0===r?void 0:r.date({width:"short"})},F=(e,r=new Date)=>((r=new Date(r)).setDate(r.getDate()+e),r),z=(e,r=new Date)=>r.getHours()>=e?F(1,new Date(r)):new Date(r),I=(...e)=>new Date(Math.max(...e.map(Number))),P=e=>{const r=e?new Date(e):new Date;return new Date(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())},_=e=>{const r=(new Date).getFullYear(),a=[];for(let s=0;s<e;s++)a.push(`${r+s}`);return a},x=(e,r,a="desc")=>{const[s,t]="asc"===a?[e,r]:[r,e];return new Date(s.createdAt).getTime()-new Date(t.createdAt).getTime()},E=e=>!!e&&("string"==typeof e?new Date(e):e)>=new Date,k=e=>{const r=null!=e?e:new Date;return{firstDayOfMonth:new Date(r.getFullYear(),r.getMonth(),1),lastDayOfTheMonth:new Date(r.getFullYear(),r.getMonth()+1,0),origin:r,previousMonthFirstDay:new Date(r.getFullYear(),r.getMonth()-1,1),previousMonthLastDay:new Date(r.getFullYear(),r.getMonth()-1+1,0),thirtyDaysAgo:new Date((new Date).setDate(r.getDate()-30))}},B={accountSettingsFeatures:{showCarrierServices:!0,showExternalCarriers:!1,showLabelLayout:!0,showManageWarehouses:!0,showUnitSettings:!0,showVatSettings:!0},globalFeatures:{enableParcelGuard:!0,isSandbox:!1,poweredByShipEngine:!0,showVatSettings:!1},labelsGridFeatures:{columns:[{allowFilter:!0,name:"labelId"},{name:"recipient"},{name:"shippingService"},{name:"createdDate"},{name:"trackingStatus"}],showActions:!0},purchaseLabelFeatures:{betaEnableWindsorFramework:!1,compatibleCountryCodes:["AU","CA","FR","DE","GB","IL","IT","NO","ES","SE","US"],enableErrorWhenShipmentCancelled:!1,partnerMessages:{incompleteLabelPurchaseRequirements:void 0},rateForm:{enableFunding:!0,enableGlobalPostFiltering:!1,enablePudoUI:!1,labelLayout:!1,nicknameRate:!0,requireDhlTermsAcknowledgement:!1,saveRate:!0},shipmentForm:{addOns:!0,browseRates:!0,includeCarrierInsurance:!1,includeShipsuranceInsurance:!0,includeThirdPartyInsurance:!1,selectService:!0,shippingPresets:!1,useWarehouses:!0}},shipmentSummaryFeatures:{schedulePickup:!0}},T=e=>{var r;return null!==(r={PurchaseLabel:"ConfigureSalesOrderShipment"}[e])&&void 0!==r?r:""},V=e=>e.map((e=>u(B,e))).reduce(((e,r)=>Object.assign(e,r))),R=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);function $(e,r){const a=Object.assign({},e);return R(e)&&R(r)&&Object.keys(r).forEach((e=>{R(r[e])?(a[e]||Object.assign(a,{[e]:{}}),a[e]=$(a[e],r[e])):Object.assign(a,{[e]:r[e]})})),a}const Z=e=>e.slice(0,1).toUpperCase()+e.slice(1),G=e=>e.split(" ").map((e=>Z(e.toLowerCase()))).join(" "),q=e=>m.pascalize(e),N=e=>null==e?void 0:e.replace(/\s+/g,"-").toLowerCase(),Y=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/(?<=[a-zA-Z])(\d)/g," $1").trim(),H={aud:"$",cad:"$",eur:"€",gbp:"£",nzd:"$",usd:"$"},W=(e,r="en-US")=>Intl.NumberFormat(r,{currency:e.currency,style:"currency"}).format(e.amount),J=(...e)=>e.reduce(((e,r)=>{var a;return r?e+(null!==(a=r.amount)&&void 0!==a?a:0):e}),0),K=e=>[e.substring(0,4),e.substring(4,8),e.substring(8,12),e.substring(12)].join(" ").trim(),Q=e=>{const r=e.replace(/\//g,"");return r.length>2?[r.substring(0,2),r.substring(2,6)].join("/").trim():r},X=e=>{switch(null==e?void 0:e.toLowerCase()){case"usd":default:return p.Currency.USD;case"cad":return p.Currency.CAD;case"aud":return p.Currency.AUD;case"gbp":return p.Currency.GBP;case"eur":return p.Currency.EUR;case"nzd":return p.Currency.NZD}},ee=e=>{let r;switch(e){case p.Currency.USD:case p.Currency.CAD:case p.Currency.AUD:case p.Currency.NZD:r="$";break;case p.Currency.GBP:r="£‎";break;case p.Currency.EUR:r="€"}return r},re=(e,r,a)=>{switch(e){case"usps_media_mail":return!0;case"usps_first_class_mail":return"large_envelope_or_flat"===r;case"dhl_express_worldwide":return a;default:return!1}},ae=(e={})=>J(...Object.values(e)),se=(e,r)=>r[e]||e,te=e=>{var r;return"US"===e.countryCode||(null===(r=y.find((r=>r.code===e.countryCode)))||void 0===r?void 0:r.isUnitedStatesTerritory)},ne=e=>{var r,a;return!(!(null===(r=w.find((r=>r.code===e.stateProvince)))||void 0===r?void 0:r.isMilitary)&&!(null===(a=b.find((r=>r.code===e.cityLocality)))||void 0===a?void 0:a.isMilitary))},ie=e=>{var r,a;return!(!(null===(r=y.find((r=>r.code===e.countryCode)))||void 0===r?void 0:r.isUnitedStatesTerritory)&&!(null===(a=w.find((r=>r.code===e.stateProvince)))||void 0===a?void 0:a.isUnitedStatesTerritory))},le=e=>{var r;return!!(null===(r=y.find((r=>r.code===e.countryCode)))||void 0===r?void 0:r.isUnsupportedByUps)},oe=/^(((p[\s\.\'\,]?[o\s][\.\'\,]?)\s?)|(post\s?office\s?))((box|bin|bo|b\.?)?\s?(num|number|#)?\s?\d+)/i,ce=e=>oe.test(e),de=e=>!!(ce(e.addressLine1)||e.addressLine2&&ce(e.addressLine2)),ue=e=>!e||Object.entries(e).every((([e,r])=>"countryCode"===e||[null,"","unknown"].includes(r))),me=(e,r)=>Object.assign(Object.assign(Object.assign({},e),e.matchedAddress&&{matchedAddress:Object.assign(Object.assign({},e.matchedAddress),{email:r})}),{originalAddress:Object.assign(Object.assign({},e.originalAddress),{email:r})}),pe=e=>{var r;if(e)return null!==(r=e.find((e=>e.isDefault)))&&void 0!==r?r:e[0]},ge=(e,r)=>{if(!e&&!r)return;const a={originAddress:f(v(null==e?void 0:e.shipFrom,["addressResidentialIndicator"]),h),returnAddress:f(v(null==e?void 0:e.returnTo,["addressResidentialIndicator"]),h)},s=null==r?void 0:r.find((e=>g(a,v(Object.assign(Object.assign({},e),void 0===e.returnAddress&&{returnAddress:e.originAddress}),["addressId","name","isDefault"]))));return(null==s?void 0:s.addressId)||"custom-shipment-address"},he=(e,r)=>{if(!e||!r)return;const a={originAddress:f(v(null==e?void 0:e.shipFrom,["addressResidentialIndicator"]),h),returnAddress:f(v(null==e?void 0:e.returnTo,["addressResidentialIndicator"]),h)};return null==r?void 0:r.some((e=>g(a,v(Object.assign(Object.assign({},e),void 0===e.returnAddress&&{returnAddress:e.originAddress}),["addressId","name","isDefault"]))))};const ve=["usps","stamps_com"],fe=e=>ve.includes(e),ye=e=>"ups"===e,we=e=>e.includes("yodel"),be=e=>"hermes"===e,De=(e=[],r)=>{const a=e.find((e=>e.carrierCode===r));return null==a?void 0:a.carrierId},Ce=(e,r)=>{var a;if("parcelguard"===e)return"logo"===r?"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='55' height='55' fill='none'%3e%3cmask id='a' width='55' height='55' x='0' y='0' maskUnits='userSpaceOnUse' style='mask-type:alpha'%3e%3cpath fill='%23FFFFFE' fill-rule='evenodd' d='M55 0H0v55h55zM32.238 10.76H24.39V7.997h7.847zM2.39 40.477l48.324-6.693V12.967L2.39 19.618z' clip-rule='evenodd'/%3e%3c/mask%3e%3cg fill-rule='evenodd' clip-rule='evenodd' mask='url(%23a)'%3e%3cpath fill='%23BBAE92' d='M10.136 9.38v31.096l17.726 10.908 18.03-10.908V9.456z'/%3e%3cpath fill='%23343534' d='M8.087 6.742c.49-.271 1.111-.413 1.751-.413H46.19c.64 0 1.26.142 1.75.413.462.255.99.742.99 1.477v32.75c0 .602-.342 1.13-.691 1.496-.354.37-.823.693-1.342.902L30.024 53.77a1 1 0 0 1-.144.07c-.556.21-1.232.3-1.867.3-.634 0-1.31-.09-1.867-.3a1 1 0 0 1-.143-.07L9.13 43.367a3.9 3.9 0 0 1-1.34-.902c-.35-.366-.692-.894-.692-1.496V8.219c0-.735.528-1.222.99-1.477m.663 1.577.006-.009zm.023-.026a.7.7 0 0 1 .125-.085c.198-.11.529-.204.94-.204H46.19c.41 0 .742.094.94.204a.7.7 0 0 1 .125.085v32.676q0-.006-.002.002c-.008.025-.046.148-.227.338a2.2 2.2 0 0 1-.8.522 1 1 0 0 0-.144.07L29.22 52.298c-.308.103-.74.167-1.206.167s-.897-.064-1.205-.167L9.945 41.902a1 1 0 0 0-.143-.07 2.2 2.2 0 0 1-.8-.523c-.182-.19-.22-.313-.227-.337q-.003-.009-.002-.003zm38.505.026-.006-.009q.007.01.006.01'/%3e%3cpath fill='%23343534' d='M32.81 1.106a.84.84 0 0 1 1.1-.44l13.887 5.946a.838.838 0 1 1-.66 1.54L33.252 2.206a.84.84 0 0 1-.44-1.1M26.343 3.567a.84.84 0 0 1-.643.994L9.327 8.075a.838.838 0 0 1-.351-1.638l16.373-3.514a.84.84 0 0 1 .994.644M22.73 7.25c0-.463.375-.838.838-.838h9.51c.462 0 .837.375.837.838v4.26a.84.84 0 0 1-.837.838h-9.51a.84.84 0 0 1-.838-.838zm1.675.838v2.584h7.835V8.088z'/%3e%3c/g%3e%3cpath fill='%23343534' fill-rule='evenodd' d='M9.36 22.741c-.144-.233-.375-.323-.777-.268l-1.944.267.02 1.841 1.915-.263c.461-.064.69-.247.808-.486.068-.15.087-.306.084-.538-.003-.253-.035-.451-.107-.553m2.001 2.187c-.455.6-1.214.957-2.196 1.113-.3.05-2.455.326-2.455.326l.028 2.5-2.456.337-.089-7.992 4.901-.673c.962-.133 1.646-.014 2.092.38.466.342.724.996.735 1.987.01.89-.174 1.543-.56 2.022M15.859 22.324l-.168-.645-.153.71-.68 1.977 1.673-.23zm-2.186 5.59-2.526.346 3.018-8.418 3.117-.428 2.995 7.592-2.566.352-.6-1.62-2.836.39zM25.765 20.467c-.123-.237-.364-.284-.715-.236l-2.055.282.018 1.629 2.105-.29c.3-.041.56-.147.648-.352.059-.15.087-.367.085-.528-.002-.182-.024-.392-.086-.506m2.135 1.53c-.246.46-.604.761-.974.893l1.9 2.941-2.736.376-1.433-2.508-1.644.226.03 2.7-2.405.331-.09-7.991 5.042-.693c1.062-.146 1.757.062 2.164.543.315.362.471.878.48 1.627.007.647-.128 1.171-.334 1.555M36.824 23.03c-.538 1.26-1.643 2.04-3.778 2.333-1.473.202-2.55.026-3.248-.567-.67-.577-1.001-1.554-1.017-2.971-.014-1.274.275-2.297.87-3.057.692-.866 1.78-1.41 3.354-1.627 2.425-.333 3.497.432 3.86 1.506.156.445.213.995.216 1.308l-2.475.34a1.6 1.6 0 0 0-.22-.8c-.235-.373-.608-.525-1.39-.417-.662.09-1.08.33-1.346.752-.247.379-.331.948-.323 1.676.01.84.135 1.339.4 1.637.305.353.787.418 1.339.342.72-.098 1.11-.375 1.317-.697.187-.28.244-.56.26-.897l2.476-.34c-.016.326-.05.959-.295 1.479M37.965 24.575l-.089-7.991 6.765-.93.021 1.882-4.37.6.014 1.163 4.209-.578.02 1.901-4.208.579.013 1.183 4.42-.607.02 1.862zM45.913 23.483l-.09-7.991 2.476-.34.067 6.018 3.818-.525.023 1.973zM12.535 37.45l-.108-.654c-.505.597-1.264.964-2.356 1.114-1.443.199-2.542-.167-3.154-1.025-.377-.506-.628-1.444-.64-2.557-.012-1.001.149-1.935.612-2.708.561-.948 1.636-1.765 3.5-2.02 2.055-.283 3.175.272 3.648 1.261.164.332.26.846.264 1.19l-2.365.325c-.002-.203-.116-.45-.288-.62-.233-.23-.636-.338-1.147-.267-.621.085-1.051.276-1.328.668-.267.361-.4.937-.39 1.888.01.88.166 1.365.36 1.652.244.311.688.524 1.5.412.822-.113 1.438-.613 1.512-1.2l-.005-.426-1.984.273-.019-1.719 4.22-.58s.022 2.094.028 2.54c.01.98.033 2.142.034 2.193zM19.07 36.664c-2.185.3-3.858-.301-3.881-2.385l-.058-5.19 2.456-.337.057 5.088c.007.698.543 1.04 1.455.915.862-.119 1.418-.64 1.41-1.299 0-.151-.056-5.098-.056-5.098l2.445-.336.06 5.351c.02 1.862-1.613 2.978-3.888 3.29M27.9 30.05l-.169-.645-.152.71-.681 1.978 1.674-.23zm-2.187 5.59-2.526.346 3.018-8.418 3.117-.428 2.996 7.592-2.566.352-.6-1.62-2.836.39zM38.006 28.165c-.123-.236-.365-.284-.716-.236l-2.054.282.018 1.63 2.105-.29c.3-.041.56-.148.648-.353.059-.15.087-.366.085-.528-.002-.182-.025-.392-.086-.505m2.135 1.53c-.246.46-.604.762-.974.894l1.9 2.94-2.736.377-1.433-2.509-1.644.226.03 2.701-2.405.33-.09-7.99 5.042-.694c1.062-.145 1.757.063 2.164.544.315.362.471.877.48 1.626.007.648-.128 1.172-.334 1.555M47.074 28.55c-.007-.576-.075-1.306-.279-1.501-.314-.302-.605-.353-1.207-.27l-1.533.21.047 4.239 1.534-.21c.621-.086.95-.263 1.217-.624.208-.282.228-1.196.22-1.844m-.886 4.276-4.49.617-.09-7.992 4.37-.6c1.444-.198 2.34.033 2.838.653.499.61.596 1.266.613 2.722.018 1.7-.084 2.342-.518 3.07-.473.805-1.29 1.333-2.723 1.53' clip-rule='evenodd'/%3e%3cpath fill='%231A1919' fill-rule='evenodd' d='m50.974 40.244.198.625.195-.625h.45v1.086h-.288v-.786l-.236.786h-.245l-.236-.784v.784h-.288v-1.086zm-1.506.261v-.26h.959v.26h-.323v.825h-.317v-.825z' clip-rule='evenodd'/%3e%3c/svg%3e":"data:image/svg+xml,%3csvg width='21' height='20' viewBox='0 0 21 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M2.16675 3.33342V15.6721L9.969 19.7591C10.2574 19.9102 10.6014 19.9114 10.8909 19.7623L18.8334 15.6721V3.33343L2.16675 3.33342Z' fill='%23343534'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M8.58857 0.731017C8.7832 1.14808 8.60288 1.64395 8.18582 1.83857L2.93582 4.92191L2.16675 3.33342L7.48101 0.328269C7.89807 0.133641 8.39394 0.313958 8.58857 0.731017Z' fill='%23343534'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.4734 0.371172C11.7287 -0.0117689 12.2461 -0.115247 12.629 0.140047L18.8334 3.33343L17.9545 4.86013L11.7045 1.5268C11.3216 1.2715 11.2181 0.754112 11.4734 0.371172Z' fill='%23343534'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M3.83325 5V14.8709L10.4431 18.3333L17.1666 14.8709V5.02448L3.83325 5Z' fill='%23F9FAFB'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M3.8335 4.8335V14.8277L10.4432 18.3334L17.1665 14.8277V4.85828L3.8335 4.8335Z' fill='%23BBAE92'/%3e%3c/svg%3e";return`https://logos.shipstation.com/ipaas/carriers/${null!==(a={stamps_com:"stamps_com_wl",usps:"stamps_com_wl"}[e])&&void 0!==a?a:e}/${r}.svg`},Le=e=>!!e&&["GB","CA","US"].includes(e),Se=e=>"AU"===e,Ae=(e,r)=>null==e?void 0:e.filter((e=>"globalpost"===e.carrierCode?Le(r):"sendle_walleted"!==e.carrierCode||Se(r)));export{Se as $,J as A,K as B,Q as C,X as D,ee as E,re as F,ae as G,se as H,te as I,ne as J,ie as K,le as L,ce as M,de as N,ue as O,me as P,pe as Q,ge as R,he as S,fe as T,ye as U,we as V,be as W,De as X,Ce as Y,Le as Z,C as _,S as a,Ae as a0,D as a1,A as b,U as c,$ as d,O as e,L as f,V as g,j as h,F as i,_ as j,E as k,k as l,I as m,z as n,P as o,M as p,T as q,R as r,x as s,Z as t,G as u,q as v,N as w,Y as x,H as y,W as z};
1
+ import{format as e}from"date-fns/format";import{ca as r,de as a,enAU as s,enGB as t,enUS as n,es as i,fr as l,it as o,pt as c}from"date-fns/locale";import{parse as d}from"date-fns/parse";import u from"lodash/get.js";import m from"humps";import{SE as p}from"@shipengine/react-api";import g from"lodash/isEqual.js";import h from"lodash/isNil.js";import v from"lodash/omit.js";import f from"lodash/omitBy.js";import{c as y,u as w,f as b}from"./address.js";function D(e,r){var a={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&r.indexOf(s)<0&&(a[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(s=Object.getOwnPropertySymbols(e);t<s.length;t++)r.indexOf(s[t])<0&&Object.prototype.propertyIsEnumerable.call(e,s[t])&&(a[s[t]]=e[s[t]])}return a}function C(e,r,a,s){return new(a||(a=Promise))((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function l(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a((function(e){e(r)}))).then(i,l)}o((s=s.apply(e,r||[])).next())}))}const L=(e,r="en-US")=>new Date(e).toLocaleDateString(r,{day:"numeric",month:"long",year:"numeric"}),S=(e="en-US")=>{const d=e.replaceAll("-",""),u=e.split("-")[0],m={ca:r,de:a,enAU:s,enGB:t,enUS:n,es:i,fr:l,it:o,pt:c};return m[d in m?d:u]},A=(r,a="en-US",s)=>{const t=S(a),n=j(a);return e(r,null!=s?s:n,{locale:t})},M=(e,r="en-US",a="P")=>{const s=S(r);return d(e,a,new Date,{locale:s})},U=(e,r="en-US")=>new Date(e).toLocaleDateString(r,{day:"2-digit",month:"2-digit",year:"2-digit"}),O=(e,r="en-US")=>new Date(e).toLocaleDateString(r,{day:"2-digit",month:"2-digit",year:"numeric"}),j=(e="en-US")=>{var r;return null===(r=(S(e)||S("en-US")).formatLong)||void 0===r?void 0:r.date({width:"short"})},F=(e,r=new Date)=>((r=new Date(r)).setDate(r.getDate()+e),r),z=(e,r=new Date)=>r.getHours()>=e?F(1,new Date(r)):new Date(r),I=(...e)=>new Date(Math.max(...e.map(Number))),_=e=>{const r=e?new Date(e):new Date;return new Date(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())},x=e=>{const r=(new Date).getFullYear(),a=[];for(let s=0;s<e;s++)a.push(`${r+s}`);return a},P=(e,r,a="desc")=>{const[s,t]="asc"===a?[e,r]:[r,e];return new Date(s.createdAt).getTime()-new Date(t.createdAt).getTime()},E=e=>!!e&&("string"==typeof e?new Date(e):e)>=new Date,k=e=>{const r=null!=e?e:new Date;return{firstDayOfMonth:new Date(r.getFullYear(),r.getMonth(),1),lastDayOfTheMonth:new Date(r.getFullYear(),r.getMonth()+1,0),origin:r,previousMonthFirstDay:new Date(r.getFullYear(),r.getMonth()-1,1),previousMonthLastDay:new Date(r.getFullYear(),r.getMonth()-1+1,0),thirtyDaysAgo:new Date((new Date).setDate(r.getDate()-30))}},B={accountSettingsFeatures:{showCarrierServices:!0,showExternalCarriers:!1,showLabelLayout:!0,showManageWarehouses:!0,showUnitSettings:!0,showVatSettings:!0},globalFeatures:{enableParcelGuard:!0,isSandbox:!1,poweredByShipEngine:!0,showVatSettings:!1},labelsGridFeatures:{columns:[{allowFilter:!0,name:"labelId"},{name:"recipient"},{name:"shippingService"},{name:"createdDate"},{name:"trackingStatus"}],showActions:!0},purchaseLabelFeatures:{betaEnableWindsorFramework:!1,compatibleCountryCodes:["AU","CA","FR","DE","GB","IL","IT","NO","ES","SE","US"],enableErrorWhenShipmentCancelled:!1,partnerMessages:{incompleteLabelPurchaseRequirements:void 0},rateForm:{enableFunding:!0,enablePudoUI:!1,labelLayout:!1,nicknameRate:!0,requireDhlTermsAcknowledgement:!1,saveRate:!0},shipmentForm:{addOns:!0,browseRates:!0,includeCarrierInsurance:!1,includeShipsuranceInsurance:!0,includeThirdPartyInsurance:!1,selectService:!0,shippingPresets:!1,useWarehouses:!0}},shipmentSummaryFeatures:{schedulePickup:!0}},T=e=>{var r;return null!==(r={PurchaseLabel:"ConfigureSalesOrderShipment"}[e])&&void 0!==r?r:""},V=e=>e.map((e=>u(B,e))).reduce(((e,r)=>Object.assign(e,r))),R=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);function $(e,r){const a=Object.assign({},e);return R(e)&&R(r)&&Object.keys(r).forEach((e=>{R(r[e])?(a[e]||Object.assign(a,{[e]:{}}),a[e]=$(a[e],r[e])):Object.assign(a,{[e]:r[e]})})),a}const Z=e=>e.slice(0,1).toUpperCase()+e.slice(1),G=e=>e.split(" ").map((e=>Z(e.toLowerCase()))).join(" "),q=e=>m.pascalize(e),N=e=>null==e?void 0:e.replace(/\s+/g,"-").toLowerCase(),Y=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/(?<=[a-zA-Z])(\d)/g," $1").trim(),H={aud:"$",cad:"$",eur:"€",gbp:"£",nzd:"$",usd:"$"},W=(e,r="en-US")=>Intl.NumberFormat(r,{currency:e.currency,style:"currency"}).format(e.amount),J=(...e)=>e.reduce(((e,r)=>{var a;return r?e+(null!==(a=r.amount)&&void 0!==a?a:0):e}),0),K=e=>[e.substring(0,4),e.substring(4,8),e.substring(8,12),e.substring(12)].join(" ").trim(),Q=e=>{const r=e.replace(/\//g,"");return r.length>2?[r.substring(0,2),r.substring(2,6)].join("/").trim():r},X=e=>{switch(null==e?void 0:e.toLowerCase()){case"usd":default:return p.Currency.USD;case"cad":return p.Currency.CAD;case"aud":return p.Currency.AUD;case"gbp":return p.Currency.GBP;case"eur":return p.Currency.EUR;case"nzd":return p.Currency.NZD}},ee=e=>{let r;switch(e){case p.Currency.USD:case p.Currency.CAD:case p.Currency.AUD:case p.Currency.NZD:r="$";break;case p.Currency.GBP:r="£‎";break;case p.Currency.EUR:r="€"}return r},re=(e,r,a)=>{switch(e){case"usps_media_mail":return!0;case"usps_first_class_mail":return"large_envelope_or_flat"===r;case"dhl_express_worldwide":return a;default:return!1}},ae=(e={})=>J(...Object.values(e)),se=(e,r)=>r[e]||e,te=e=>{var r;return"US"===e.countryCode||(null===(r=y.find((r=>r.code===e.countryCode)))||void 0===r?void 0:r.isUnitedStatesTerritory)},ne=e=>{var r,a;return!(!(null===(r=w.find((r=>r.code===e.stateProvince)))||void 0===r?void 0:r.isMilitary)&&!(null===(a=b.find((r=>r.code===e.cityLocality)))||void 0===a?void 0:a.isMilitary))},ie=e=>{var r,a;return!(!(null===(r=y.find((r=>r.code===e.countryCode)))||void 0===r?void 0:r.isUnitedStatesTerritory)&&!(null===(a=w.find((r=>r.code===e.stateProvince)))||void 0===a?void 0:a.isUnitedStatesTerritory))},le=e=>{var r;return!!(null===(r=y.find((r=>r.code===e.countryCode)))||void 0===r?void 0:r.isUnsupportedByUps)},oe=/^(((p[\s\.\'\,]?[o\s][\.\'\,]?)\s?)|(post\s?office\s?))((box|bin|bo|b\.?)?\s?(num|number|#)?\s?\d+)/i,ce=e=>oe.test(e),de=e=>!!(ce(e.addressLine1)||e.addressLine2&&ce(e.addressLine2)),ue=e=>!e||Object.entries(e).every((([e,r])=>"countryCode"===e||[null,"","unknown"].includes(r))),me=(e,r)=>Object.assign(Object.assign(Object.assign({},e),e.matchedAddress&&{matchedAddress:Object.assign(Object.assign({},e.matchedAddress),{email:r})}),{originalAddress:Object.assign(Object.assign({},e.originalAddress),{email:r})}),pe=e=>{var r;if(e)return null!==(r=e.find((e=>e.isDefault)))&&void 0!==r?r:e[0]},ge=(e,r)=>{if(!e&&!r)return;const a={originAddress:f(v(null==e?void 0:e.shipFrom,["addressResidentialIndicator"]),h),returnAddress:f(v(null==e?void 0:e.returnTo,["addressResidentialIndicator"]),h)},s=null==r?void 0:r.find((e=>g(a,v(Object.assign(Object.assign({},e),void 0===e.returnAddress&&{returnAddress:e.originAddress}),["addressId","name","isDefault"]))));return(null==s?void 0:s.addressId)||"custom-shipment-address"},he=(e,r)=>{if(!e||!r)return;const a={originAddress:f(v(null==e?void 0:e.shipFrom,["addressResidentialIndicator"]),h),returnAddress:f(v(null==e?void 0:e.returnTo,["addressResidentialIndicator"]),h)};return null==r?void 0:r.some((e=>g(a,v(Object.assign(Object.assign({},e),void 0===e.returnAddress&&{returnAddress:e.originAddress}),["addressId","name","isDefault"]))))};const ve=["usps","stamps_com"],fe=e=>ve.includes(e),ye=e=>"ups"===e,we=e=>e.includes("yodel"),be=e=>"hermes"===e,De=(e=[],r)=>{const a=e.find((e=>e.carrierCode===r));return null==a?void 0:a.carrierId},Ce=(e,r)=>{var a;if("parcelguard"===e)return"logo"===r?"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='55' height='55' fill='none'%3e%3cmask id='a' width='55' height='55' x='0' y='0' maskUnits='userSpaceOnUse' style='mask-type:alpha'%3e%3cpath fill='%23FFFFFE' fill-rule='evenodd' d='M55 0H0v55h55zM32.238 10.76H24.39V7.997h7.847zM2.39 40.477l48.324-6.693V12.967L2.39 19.618z' clip-rule='evenodd'/%3e%3c/mask%3e%3cg fill-rule='evenodd' clip-rule='evenodd' mask='url(%23a)'%3e%3cpath fill='%23BBAE92' d='M10.136 9.38v31.096l17.726 10.908 18.03-10.908V9.456z'/%3e%3cpath fill='%23343534' d='M8.087 6.742c.49-.271 1.111-.413 1.751-.413H46.19c.64 0 1.26.142 1.75.413.462.255.99.742.99 1.477v32.75c0 .602-.342 1.13-.691 1.496-.354.37-.823.693-1.342.902L30.024 53.77a1 1 0 0 1-.144.07c-.556.21-1.232.3-1.867.3-.634 0-1.31-.09-1.867-.3a1 1 0 0 1-.143-.07L9.13 43.367a3.9 3.9 0 0 1-1.34-.902c-.35-.366-.692-.894-.692-1.496V8.219c0-.735.528-1.222.99-1.477m.663 1.577.006-.009zm.023-.026a.7.7 0 0 1 .125-.085c.198-.11.529-.204.94-.204H46.19c.41 0 .742.094.94.204a.7.7 0 0 1 .125.085v32.676q0-.006-.002.002c-.008.025-.046.148-.227.338a2.2 2.2 0 0 1-.8.522 1 1 0 0 0-.144.07L29.22 52.298c-.308.103-.74.167-1.206.167s-.897-.064-1.205-.167L9.945 41.902a1 1 0 0 0-.143-.07 2.2 2.2 0 0 1-.8-.523c-.182-.19-.22-.313-.227-.337q-.003-.009-.002-.003zm38.505.026-.006-.009q.007.01.006.01'/%3e%3cpath fill='%23343534' d='M32.81 1.106a.84.84 0 0 1 1.1-.44l13.887 5.946a.838.838 0 1 1-.66 1.54L33.252 2.206a.84.84 0 0 1-.44-1.1M26.343 3.567a.84.84 0 0 1-.643.994L9.327 8.075a.838.838 0 0 1-.351-1.638l16.373-3.514a.84.84 0 0 1 .994.644M22.73 7.25c0-.463.375-.838.838-.838h9.51c.462 0 .837.375.837.838v4.26a.84.84 0 0 1-.837.838h-9.51a.84.84 0 0 1-.838-.838zm1.675.838v2.584h7.835V8.088z'/%3e%3c/g%3e%3cpath fill='%23343534' fill-rule='evenodd' d='M9.36 22.741c-.144-.233-.375-.323-.777-.268l-1.944.267.02 1.841 1.915-.263c.461-.064.69-.247.808-.486.068-.15.087-.306.084-.538-.003-.253-.035-.451-.107-.553m2.001 2.187c-.455.6-1.214.957-2.196 1.113-.3.05-2.455.326-2.455.326l.028 2.5-2.456.337-.089-7.992 4.901-.673c.962-.133 1.646-.014 2.092.38.466.342.724.996.735 1.987.01.89-.174 1.543-.56 2.022M15.859 22.324l-.168-.645-.153.71-.68 1.977 1.673-.23zm-2.186 5.59-2.526.346 3.018-8.418 3.117-.428 2.995 7.592-2.566.352-.6-1.62-2.836.39zM25.765 20.467c-.123-.237-.364-.284-.715-.236l-2.055.282.018 1.629 2.105-.29c.3-.041.56-.147.648-.352.059-.15.087-.367.085-.528-.002-.182-.024-.392-.086-.506m2.135 1.53c-.246.46-.604.761-.974.893l1.9 2.941-2.736.376-1.433-2.508-1.644.226.03 2.7-2.405.331-.09-7.991 5.042-.693c1.062-.146 1.757.062 2.164.543.315.362.471.878.48 1.627.007.647-.128 1.171-.334 1.555M36.824 23.03c-.538 1.26-1.643 2.04-3.778 2.333-1.473.202-2.55.026-3.248-.567-.67-.577-1.001-1.554-1.017-2.971-.014-1.274.275-2.297.87-3.057.692-.866 1.78-1.41 3.354-1.627 2.425-.333 3.497.432 3.86 1.506.156.445.213.995.216 1.308l-2.475.34a1.6 1.6 0 0 0-.22-.8c-.235-.373-.608-.525-1.39-.417-.662.09-1.08.33-1.346.752-.247.379-.331.948-.323 1.676.01.84.135 1.339.4 1.637.305.353.787.418 1.339.342.72-.098 1.11-.375 1.317-.697.187-.28.244-.56.26-.897l2.476-.34c-.016.326-.05.959-.295 1.479M37.965 24.575l-.089-7.991 6.765-.93.021 1.882-4.37.6.014 1.163 4.209-.578.02 1.901-4.208.579.013 1.183 4.42-.607.02 1.862zM45.913 23.483l-.09-7.991 2.476-.34.067 6.018 3.818-.525.023 1.973zM12.535 37.45l-.108-.654c-.505.597-1.264.964-2.356 1.114-1.443.199-2.542-.167-3.154-1.025-.377-.506-.628-1.444-.64-2.557-.012-1.001.149-1.935.612-2.708.561-.948 1.636-1.765 3.5-2.02 2.055-.283 3.175.272 3.648 1.261.164.332.26.846.264 1.19l-2.365.325c-.002-.203-.116-.45-.288-.62-.233-.23-.636-.338-1.147-.267-.621.085-1.051.276-1.328.668-.267.361-.4.937-.39 1.888.01.88.166 1.365.36 1.652.244.311.688.524 1.5.412.822-.113 1.438-.613 1.512-1.2l-.005-.426-1.984.273-.019-1.719 4.22-.58s.022 2.094.028 2.54c.01.98.033 2.142.034 2.193zM19.07 36.664c-2.185.3-3.858-.301-3.881-2.385l-.058-5.19 2.456-.337.057 5.088c.007.698.543 1.04 1.455.915.862-.119 1.418-.64 1.41-1.299 0-.151-.056-5.098-.056-5.098l2.445-.336.06 5.351c.02 1.862-1.613 2.978-3.888 3.29M27.9 30.05l-.169-.645-.152.71-.681 1.978 1.674-.23zm-2.187 5.59-2.526.346 3.018-8.418 3.117-.428 2.996 7.592-2.566.352-.6-1.62-2.836.39zM38.006 28.165c-.123-.236-.365-.284-.716-.236l-2.054.282.018 1.63 2.105-.29c.3-.041.56-.148.648-.353.059-.15.087-.366.085-.528-.002-.182-.025-.392-.086-.505m2.135 1.53c-.246.46-.604.762-.974.894l1.9 2.94-2.736.377-1.433-2.509-1.644.226.03 2.701-2.405.33-.09-7.99 5.042-.694c1.062-.145 1.757.063 2.164.544.315.362.471.877.48 1.626.007.648-.128 1.172-.334 1.555M47.074 28.55c-.007-.576-.075-1.306-.279-1.501-.314-.302-.605-.353-1.207-.27l-1.533.21.047 4.239 1.534-.21c.621-.086.95-.263 1.217-.624.208-.282.228-1.196.22-1.844m-.886 4.276-4.49.617-.09-7.992 4.37-.6c1.444-.198 2.34.033 2.838.653.499.61.596 1.266.613 2.722.018 1.7-.084 2.342-.518 3.07-.473.805-1.29 1.333-2.723 1.53' clip-rule='evenodd'/%3e%3cpath fill='%231A1919' fill-rule='evenodd' d='m50.974 40.244.198.625.195-.625h.45v1.086h-.288v-.786l-.236.786h-.245l-.236-.784v.784h-.288v-1.086zm-1.506.261v-.26h.959v.26h-.323v.825h-.317v-.825z' clip-rule='evenodd'/%3e%3c/svg%3e":"data:image/svg+xml,%3csvg width='21' height='20' viewBox='0 0 21 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M2.16675 3.33342V15.6721L9.969 19.7591C10.2574 19.9102 10.6014 19.9114 10.8909 19.7623L18.8334 15.6721V3.33343L2.16675 3.33342Z' fill='%23343534'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M8.58857 0.731017C8.7832 1.14808 8.60288 1.64395 8.18582 1.83857L2.93582 4.92191L2.16675 3.33342L7.48101 0.328269C7.89807 0.133641 8.39394 0.313958 8.58857 0.731017Z' fill='%23343534'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.4734 0.371172C11.7287 -0.0117689 12.2461 -0.115247 12.629 0.140047L18.8334 3.33343L17.9545 4.86013L11.7045 1.5268C11.3216 1.2715 11.2181 0.754112 11.4734 0.371172Z' fill='%23343534'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M3.83325 5V14.8709L10.4431 18.3333L17.1666 14.8709V5.02448L3.83325 5Z' fill='%23F9FAFB'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M3.8335 4.8335V14.8277L10.4432 18.3334L17.1665 14.8277V4.85828L3.8335 4.8335Z' fill='%23BBAE92'/%3e%3c/svg%3e";return`https://logos.shipstation.com/ipaas/carriers/${null!==(a={stamps_com:"stamps_com_wl",usps:"stamps_com_wl"}[e])&&void 0!==a?a:e}/${r}.svg`},Le=e=>!!e&&["GB","CA","US"].includes(e),Se=e=>"AU"===e,Ae=(e,r)=>null==e?void 0:e.filter((e=>"globalpost"===e.carrierCode?Le(r):"sendle_walleted"!==e.carrierCode||Se(r)));export{Se as $,J as A,K as B,Q as C,X as D,ee as E,re as F,ae as G,se as H,te as I,ne as J,ie as K,le as L,ce as M,de as N,ue as O,me as P,pe as Q,ge as R,he as S,fe as T,ye as U,we as V,be as W,De as X,Ce as Y,Le as Z,C as _,S as a,Ae as a0,D as a1,A as b,U as c,$ as d,O as e,L as f,V as g,j as h,F as i,x as j,E as k,k as l,I as m,z as n,_ as o,M as p,T as q,R as r,P as s,Z as t,G as u,q as v,N as w,Y as x,H as y,W as z};
package/index.js CHANGED
@@ -1 +1 @@
1
- import{ShipEngine as _}from"@shipengine/react-api";export*from"@shipengine/react-api";export{y as Actions,x as ActionsMenu,A as AddFundsForm,a as AutoFundingForm,B as ButtonGroup,C as CarrierBalance,c as CarrierConnectionCard,d as CarrierIcon,e as CarrierLogo,f as CollapsiblePanel,h as CopyButton,i as Cube,D as DateRangeCombo,j as DateRangeSelect,k as DisplayTerm,E as EditBillingForm,l as ErrorFallback,F as FieldLabel,m as FormPortal,n as FundAndPurchase,H as HistoryCard,o as HistoryCardExtension,I as InlineLabel,p as ItemsBreakdown,L as LinkAction,q as Loader,P as PoweredByShipEngine,R as RateDetails,S as Section,r as SettingsCard,z as ShipFromAddressForm,t as SkeletonCarrierRow,u as Spacer,v as Spread,T as Tabs,V as VatForm,W as WalletCard,w as WarehouseForm,b as autoFundingSchema,g as getAddFundsSchema,s as styles}from"./actions-menu.js";export{C as CellFormattedDate,D as Drawer,E as ErrorState,G as GridController,b as GridFilters,a as GridFooter,u as usePager}from"./usePager.js";export{f as Field,P as Pager,S as StoryNotes,a as SuspendText}from"./suspend-text.js";import{E as ee,R as se,a as ae}from"./use-toggle.js";export{a as ElementsContext,E as ElementsContextProvider,P as Portal,R as RootPortalProvider,c as useAddressValidation,u as useCountryCodeOptions,g as useElements,d as useNestedForm,e as useRootPortal,b as useStateCodeOptions,f as useToggle}from"./use-toggle.js";export{C as Country,U as UsState,d as UsaCity,c as countries,a as countryCodes,e as euCountryCodes,p as postalCodeRegex,f as usCities,b as usStateCodes,u as usStates}from"./address.js";export{a as CarrierServices,b as ConnectExternalCarrier,v as VoidLabel,c as createElement}from"./use-unit-settings.js";import{t as re}from"./transaction-history-element.js";export{l as LabelsGrid,m as ManageCarriers,b as ManageExternalCarriers,f as ManageFunding,a as ManageWarehouses,h as PaymentMethodSettings,p as PurchaseLabel,g as SelectLabelLayout,d as ShipmentSummary,s as ShipmentsGrid,c as ThemeCreator,T as ThemeCreatorProvider,i as TransactionHistory,e as UnitSettings,u as useThemeCreator}from"./transaction-history-element.js";export{e as extendZod}from"./zod.js";export{P as PudoType,p as useBlackboxDetection,r as useConfigureShipment,u as useConfirmationOptions,a as useCustomsContentsOptions,b as useCustomsNonDeliveryOptions,c as useDateRangeOptions,n as useGetFundingSourceInsuranceProvider,s as useImportSalesOrder,d as useInsuranceProviderOptions,o as useManageFundingSourceInsurance,e as useMovementIndicatorOptions,f as usePackageOptions,g as useRateOptions,q as useScrubErrors,h as useServiceCodeOptions,l as useServicePoints,k as useShipFromAddressOptions,i as useShipmentMetadata,j as useShippingPresetsOptions,m as useWindsorFramework}from"./use-configure-shipment.js";export{P as PageLayoutProvider,u as useExpirationMonthOptions,a as useHelpers,b as usePageLayout}from"./use-page-layout.js";export{u as useGetServiceName}from"./use-get-service-name.js";export{u as useRunOnceOnTrue}from"./use-run-once-on-true.js";export{m as moneySchema}from"./money.js";export{p as phoneSchema,a as phoneSchemaUnvalidated}from"./phone.js";export{C as CanadaDeliveredDutyOptions}from"./canada-ddp.js";export{a as assert,r as raise}from"./assertions.js";export{g as getSellerIdFromToken,i as isOnboarded}from"./checks.js";export{b as convertDimensions,c as createDictionary,f as formatDimensions,m as getCancelledShipment,g as getCustomsFromSalesOrder,p as getDefaultWarehouse,d as getIsCustomsRequiredForSalesOrder,k as getIsCustomsRequiredForShipment,j as getIsInternationalShipment,l as getPendingShipment,e as getRequestedServices,h as getSalesOrderItemsFromSalesOrderOrShipment,n as getShipmentByStatus,q as getWarehouseById,a as isCollectionService,i as isPudoEligibleRate,o as moveCustomsItemsToProducts}from"./warehouses.js";import{_ as te,g as oe,d as ie}from"./carrier.js";export{P as addEmailToValidation,x as addSpaceBetweenWords,A as calculateTotal,t as capitalizeFirstLetter,u as capitalizeFirstLetterOfEachWord,y as currencySymbol,i as daysAfter,d as deepMergeFeatures,q as featureFlagComponentNameLookup,a0 as filterFundingSourceCarriers,a as findDateLocale,b as formatByDateAndLocale,B as formatCreditCardNumber,f as formatDate,c as formatDateDDMMYY,e as formatDateDDMMYYYY,C as formatExpiration,z as formatMoney,X as getCarrierIdByCarrierCode,D as getCurrencyFromString,E as getCurrencySymbolFromString,g as getDefaultFeatures,Q as getDefaultShipFromAddress,j as getExpirationYears,S as getIsShipmentUsingSavedShipFromAddress,Y as getLogoOrIconByCarrierCode,F as getRateRequiresAcknowledgement,l as getRelativeDates,R as getSavedShipFromAddressId,G as getTotalRateAmount,h as getlocaleDateStringFormat,I as isDomesticAddress,O as isEmptyAddress,W as isEvriCarrier,Z as isGlobalPostEligible,J as isMilitaryAddress,k as isNowOrInTheFuture,r as isObject,M as isPoBox,N as isPoBoxAddress,$ as isSendleEligible,K as isUnitedStatesTerritory,L as isUnsupportedByUps,U as isUpsCarrier,T as isUspsCarrier,V as isYodelCarrier,m as mostRecent,n as nextDayCutoff,o as omitTime,H as overrideCarrierCodes,p as parseLocaleDate,v as pascalize,w as replaceSpacesWithDashes,s as sortByCreationDate}from"./carrier.js";export{N as NO_VAT_COUNTRIES,f as convertDecimalWeightToFractionalWeight,e as convertFractionalWeightToDecimalWeight,d as convertPoundsAndOuncesToOunces,g as convertWeight,c as createCodedErrors,h as formatFractionalWeight,n as formatTrackingNumber,k as getInsuranceProviderWithFriendlyName,l as getIsInsuraceProviderAccepted,o as getIsVatRequired,b as isDecimalWeight,j as isFlatRatePackageCode,i as isMetricWeightUnit,a as throwAny,t as throwJoinedMessages,m as trackingStatusFormatter}from"./vat.js";export{a as aggregateRateDetailItems,c as calculateRateDetailBreakdown,b as createStyles,e as errorMap,f as formLogger,i as isString,s as scopeTheme,v as validationResolver}from"./validation.js";export{a as AccountSettings,l as LabelWorkflow,o as Onboarding}from"./wallet-form.js";import{jsx as ne}from"@emotion/react/jsx-runtime";import{useCallback as me,useMemo as de}from"react";import{THEME_ID as le,GigerProvider as ce,GigerTestProvider as pe}from"@shipengine/giger";import{Theme as ue}from"@shipengine/giger-theme";import ge from"axios";import"date-fns/isToday";import"@emotion/react";import"react-i18next";import"lodash/isEqual.js";import"react-hook-form";import"zod";import"copy-to-clipboard";import"js-base64";import"libphonenumber-js/min";import"lodash/omit.js";import"card-validator";import"react-use";import"date-fns/subDays";import"react-dom";import"humps";import"lodash/merge.js";import"@tanstack/react-query";import"lodash/mergeWith.js";import"@shipengine/js-api";import"@rjsf/core";import"@rjsf/validator-ajv8";import"lodash/camelCase.js";import"use-debounce";import"classnames";import"i18next";import"i18next-browser-languagedetector";import"@emotion/cache";import"stylis";import"date-fns/formatISO";import"date-fns/isSameDay";import"date-fns/isWithinInterval";import"date-fns/setHours";import"date-fns/setMinutes";import"lodash/orderBy.js";import"jwt-decode";import"date-fns/format";import"date-fns/locale";import"date-fns/parse";import"lodash/get.js";import"lodash/isNil.js";import"lodash/omitBy.js";import"@hookform/resolvers/zod";const he=({baseURL:e="https://elements.shipengine.com",cdnURL:s="https://cdn.packlink.com",children:a,container:r,features:t,getToken:o,headers:i,locale:n,onApiError:m,onError:d=(()=>{}),scope:l="lmnt",themeConfig:c,defaultQueryClientOptions:p,emotionCacheShadowRootContainer:u})=>{const g=(({cdnURL:e})=>me((s=>te(void 0,void 0,void 0,(function*(){return(yield ge.get(`/brand/fallback/icons/${s.toLowerCase()}.svg`,{baseURL:e,responseType:"text"})).data}))),[e]))({cdnURL:s}),h=de((()=>{var e;const s=new ue(null!==(e=c&&le in c?c[le]:c)&&void 0!==e?e:re.fallback);return c&&le in c?{[le]:s}:s}),[c]),f={baseURL:e,cdnURL:s,container:r,emotionCacheShadowRootContainer:u,features:t,getToken:o,locale:n,onError:d,scope:l,theme:h};return ne(ee,Object.assign({},f,{children:ne(ce,Object.assign({cdnUrl:s,emotionCacheShadowRootContainer:u,reference:u||l||void 0,resolveIcon:g,theme:h},{children:ne(_,Object.assign({baseURL:e,defaultQueryClientOptions:p,getToken:o,headers:i,onApiError:m},{children:ne(se,Object.assign({emotionCacheShadowRootContainer:u},{children:a}))}))}))}))},fe=({baseURL:e,children:s,features:a})=>{const r=de((()=>new ue),[]),t=oe(["globalFeatures"]),o=me((()=>"none"),[]),i={baseURL:e,cdnURL:"mockCdnUrl",getFeatures:e=>{var s;return ie(null!==(s=oe([e]))&&void 0!==s?s:{},null==a?void 0:a[e])},getToken:o,globalFeatures:Object.assign(Object.assign({enabledExternalCarriers:["apc","asendia","better_trucks","canpar","chronopost","couriers_please","courierpost","dpd","hermes_germany","intelliquick_delivery","lso","ontrac","seko","ups","yodel"]},t),a.globalFeatures),onError:()=>{},scope:"lmnt",theme:r};return ne(ae.Provider,Object.assign({value:i},{children:ne(pe,Object.assign({theme:r},{children:ne(_,Object.assign({baseURL:e,getToken:o},{children:s}))}))}))};export{he as ElementsProvider,fe as ElementsTestProvider};
1
+ import{ShipEngine as _}from"@shipengine/react-api";export*from"@shipengine/react-api";export{y as Actions,x as ActionsMenu,A as AddFundsForm,a as AutoFundingForm,B as ButtonGroup,C as CarrierBalance,c as CarrierConnectionCard,d as CarrierIcon,e as CarrierLogo,f as CollapsiblePanel,h as CopyButton,i as Cube,D as DateRangeCombo,j as DateRangeSelect,k as DisplayTerm,E as EditBillingForm,l as ErrorFallback,F as FieldLabel,m as FormPortal,n as FundAndPurchase,H as HistoryCard,o as HistoryCardExtension,I as InlineLabel,p as ItemsBreakdown,L as LinkAction,q as Loader,P as PoweredByShipEngine,R as RateDetails,S as Section,r as SettingsCard,z as ShipFromAddressForm,t as SkeletonCarrierRow,u as Spacer,v as Spread,T as Tabs,V as VatForm,W as WalletCard,w as WarehouseForm,b as autoFundingSchema,g as getAddFundsSchema,s as styles}from"./actions-menu.js";export{C as CellFormattedDate,D as Drawer,E as ErrorState,G as GridController,b as GridFilters,a as GridFooter,u as usePager}from"./usePager.js";export{f as Field,P as Pager,S as StoryNotes,a as SuspendText}from"./suspend-text.js";import{E as ee,R as se,a as ae}from"./use-toggle.js";export{a as ElementsContext,E as ElementsContextProvider,P as Portal,R as RootPortalProvider,c as useAddressValidation,u as useCountryCodeOptions,g as useElements,d as useNestedForm,e as useRootPortal,b as useStateCodeOptions,f as useToggle}from"./use-toggle.js";export{C as Country,U as UsState,d as UsaCity,c as countries,a as countryCodes,e as euCountryCodes,p as postalCodeRegex,f as usCities,b as usStateCodes,u as usStates}from"./address.js";export{a as CarrierServices,b as ConnectExternalCarrier,v as VoidLabel,c as createElement}from"./use-unit-settings.js";import{t as re}from"./transaction-history-element.js";export{l as LabelsGrid,m as ManageCarriers,b as ManageExternalCarriers,f as ManageFunding,a as ManageWarehouses,h as PaymentMethodSettings,p as PurchaseLabel,g as SelectLabelLayout,d as ShipmentSummary,s as ShipmentsGrid,c as ThemeCreator,T as ThemeCreatorProvider,i as TransactionHistory,e as UnitSettings,u as useThemeCreator}from"./transaction-history-element.js";export{e as extendZod}from"./zod.js";export{P as PudoType,p as useBlackboxDetection,r as useConfigureShipment,u as useConfirmationOptions,a as useCustomsContentsOptions,b as useCustomsNonDeliveryOptions,c as useDateRangeOptions,n as useGetFundingSourceInsuranceProvider,s as useImportSalesOrder,d as useInsuranceProviderOptions,o as useManageFundingSourceInsurance,e as useMovementIndicatorOptions,f as usePackageOptions,g as useRateOptions,q as useScrubErrors,h as useServiceCodeOptions,l as useServicePoints,k as useShipFromAddressOptions,i as useShipmentMetadata,j as useShippingPresetsOptions,m as useWindsorFramework}from"./use-configure-shipment.js";export{P as PageLayoutProvider,u as useExpirationMonthOptions,a as useHelpers,b as usePageLayout}from"./use-page-layout.js";export{u as useGetServiceName}from"./use-get-service-name.js";export{u as useRunOnceOnTrue}from"./use-run-once-on-true.js";export{m as moneySchema}from"./money.js";export{p as phoneSchema,a as phoneSchemaUnvalidated}from"./phone.js";export{C as CanadaDeliveredDutyOptions}from"./canada-ddp.js";export{a as assert,r as raise}from"./assertions.js";export{g as getSellerIdFromToken,i as isOnboarded}from"./checks.js";export{d as convertDimensions,c as createDictionary,f as formatDimensions,n as getCancelledShipment,g as getCustomsFromSalesOrder,q as getDefaultWarehouse,e as getIsCustomsRequiredForSalesOrder,l as getIsCustomsRequiredForShipment,k as getIsInternationalShipment,m as getPendingShipment,h as getRequestedServices,j as getSalesOrderItemsFromSalesOrderOrShipment,o as getShipmentByStatus,r as getWarehouseById,b as isCollectionService,a as isPudoEligibleRate,i as isShippingServiceServiceDisabled,p as moveCustomsItemsToProducts}from"./warehouses.js";import{_ as te,g as oe,d as ie}from"./carrier.js";export{P as addEmailToValidation,x as addSpaceBetweenWords,A as calculateTotal,t as capitalizeFirstLetter,u as capitalizeFirstLetterOfEachWord,y as currencySymbol,i as daysAfter,d as deepMergeFeatures,q as featureFlagComponentNameLookup,a0 as filterFundingSourceCarriers,a as findDateLocale,b as formatByDateAndLocale,B as formatCreditCardNumber,f as formatDate,c as formatDateDDMMYY,e as formatDateDDMMYYYY,C as formatExpiration,z as formatMoney,X as getCarrierIdByCarrierCode,D as getCurrencyFromString,E as getCurrencySymbolFromString,g as getDefaultFeatures,Q as getDefaultShipFromAddress,j as getExpirationYears,S as getIsShipmentUsingSavedShipFromAddress,Y as getLogoOrIconByCarrierCode,F as getRateRequiresAcknowledgement,l as getRelativeDates,R as getSavedShipFromAddressId,G as getTotalRateAmount,h as getlocaleDateStringFormat,I as isDomesticAddress,O as isEmptyAddress,W as isEvriCarrier,Z as isGlobalPostEligible,J as isMilitaryAddress,k as isNowOrInTheFuture,r as isObject,M as isPoBox,N as isPoBoxAddress,$ as isSendleEligible,K as isUnitedStatesTerritory,L as isUnsupportedByUps,U as isUpsCarrier,T as isUspsCarrier,V as isYodelCarrier,m as mostRecent,n as nextDayCutoff,o as omitTime,H as overrideCarrierCodes,p as parseLocaleDate,v as pascalize,w as replaceSpacesWithDashes,s as sortByCreationDate}from"./carrier.js";export{N as NO_VAT_COUNTRIES,f as convertDecimalWeightToFractionalWeight,e as convertFractionalWeightToDecimalWeight,d as convertPoundsAndOuncesToOunces,g as convertWeight,c as createCodedErrors,h as formatFractionalWeight,n as formatTrackingNumber,k as getInsuranceProviderWithFriendlyName,l as getIsInsuraceProviderAccepted,o as getIsVatRequired,b as isDecimalWeight,j as isFlatRatePackageCode,i as isMetricWeightUnit,a as throwAny,t as throwJoinedMessages,m as trackingStatusFormatter}from"./vat.js";export{a as aggregateRateDetailItems,c as calculateRateDetailBreakdown,b as createStyles,e as errorMap,f as formLogger,i as isString,s as scopeTheme,v as validationResolver}from"./validation.js";export{a as AccountSettings,l as LabelWorkflow,o as Onboarding}from"./wallet-form.js";import{jsx as ne}from"@emotion/react/jsx-runtime";import{useCallback as me,useMemo as de}from"react";import{THEME_ID as le,GigerProvider as ce,GigerTestProvider as pe}from"@shipengine/giger";import{Theme as ue}from"@shipengine/giger-theme";import ge from"axios";import"date-fns/isToday";import"@emotion/react";import"react-i18next";import"lodash/isEqual.js";import"react-hook-form";import"zod";import"copy-to-clipboard";import"js-base64";import"libphonenumber-js/min";import"lodash/omit.js";import"card-validator";import"react-use";import"date-fns/subDays";import"react-dom";import"humps";import"lodash/merge.js";import"@tanstack/react-query";import"lodash/mergeWith.js";import"@shipengine/js-api";import"@rjsf/core";import"@rjsf/validator-ajv8";import"lodash/camelCase.js";import"use-debounce";import"classnames";import"i18next";import"i18next-browser-languagedetector";import"@emotion/cache";import"stylis";import"date-fns/formatISO";import"date-fns/isSameDay";import"date-fns/isWithinInterval";import"date-fns/setHours";import"date-fns/setMinutes";import"lodash/orderBy.js";import"jwt-decode";import"date-fns/format";import"date-fns/locale";import"date-fns/parse";import"lodash/get.js";import"lodash/isNil.js";import"lodash/omitBy.js";import"@hookform/resolvers/zod";const he=({baseURL:e="https://elements.shipengine.com",cdnURL:s="https://cdn.packlink.com",children:a,container:r,features:t,getToken:o,headers:i,locale:n,onApiError:m,onError:d=(()=>{}),scope:l="lmnt",themeConfig:c,defaultQueryClientOptions:p,emotionCacheShadowRootContainer:u})=>{const g=(({cdnURL:e})=>me((s=>te(void 0,void 0,void 0,(function*(){return(yield ge.get(`/brand/fallback/icons/${s.toLowerCase()}.svg`,{baseURL:e,responseType:"text"})).data}))),[e]))({cdnURL:s}),h=de((()=>{var e;const s=new ue(null!==(e=c&&le in c?c[le]:c)&&void 0!==e?e:re.fallback);return c&&le in c?{[le]:s}:s}),[c]),f={baseURL:e,cdnURL:s,container:r,emotionCacheShadowRootContainer:u,features:t,getToken:o,locale:n,onError:d,scope:l,theme:h};return ne(ee,Object.assign({},f,{children:ne(ce,Object.assign({cdnUrl:s,emotionCacheShadowRootContainer:u,reference:u||l||void 0,resolveIcon:g,theme:h},{children:ne(_,Object.assign({baseURL:e,defaultQueryClientOptions:p,getToken:o,headers:i,onApiError:m},{children:ne(se,Object.assign({emotionCacheShadowRootContainer:u},{children:a}))}))}))}))},fe=({baseURL:e,children:s,features:a})=>{const r=de((()=>new ue),[]),t=oe(["globalFeatures"]),o=me((()=>"none"),[]),i={baseURL:e,cdnURL:"mockCdnUrl",getFeatures:e=>{var s;return ie(null!==(s=oe([e]))&&void 0!==s?s:{},null==a?void 0:a[e])},getToken:o,globalFeatures:Object.assign(Object.assign({enabledExternalCarriers:["apc","asendia","better_trucks","canpar","chronopost","couriers_please","courierpost","dpd","hermes_germany","intelliquick_delivery","lso","ontrac","seko","ups","yodel"]},t),a.globalFeatures),onError:()=>{},scope:"lmnt",theme:r};return ne(ae.Provider,Object.assign({value:i},{children:ne(pe,Object.assign({theme:r},{children:ne(_,Object.assign({baseURL:e,getToken:o},{children:s}))}))}))};export{he as ElementsProvider,fe as ElementsTestProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/elements",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "peerDependencies": {
5
5
  "@emotion/react": "11.x",
6
6
  "react-i18next": "11.x",
@@ -38,10 +38,10 @@
38
38
  "@rjsf/core": "5.16.1",
39
39
  "@rjsf/utils": "5.16.1",
40
40
  "@rjsf/validator-ajv8": "5.16.1",
41
- "@shipengine/giger": "1.20.2",
42
- "@shipengine/giger-theme": "1.7.0",
43
- "@shipengine/js-api": "3.0.0",
44
- "@shipengine/react-api": "3.8.0",
41
+ "@shipengine/giger": "1.20.8",
42
+ "@shipengine/giger-theme": "1.7.1",
43
+ "@shipengine/js-api": "3.2.0",
44
+ "@shipengine/react-api": "3.8.3",
45
45
  "@storybook/addons": "6.5.16",
46
46
  "@storybook/api": "6.5.16",
47
47
  "@storybook/components": "7.0.0-rc.1",
@@ -1,4 +1,4 @@
1
- import { SE } from "@shipengine/react-api";
1
+ import { Currency } from "@shipengine/react-api";
2
2
  /**
3
3
  * @internal
4
4
  *
@@ -11,11 +11,8 @@ export type CarrierBalanceProps = {
11
11
  * `balance` is the current balance for the carrier if there is one.
12
12
  */
13
13
  balance?: number;
14
- /**
15
- * `carrierId` is the unique identifier for the carrier provider you wish to get the balance for.
16
- */
17
- carrierId?: string;
18
- currency: SE.Currency;
14
+ currency: Currency;
15
+ isLoading?: boolean;
19
16
  };
20
17
  /**
21
18
  * @internal
@@ -27,4 +24,4 @@ export type CarrierBalanceProps = {
27
24
  *
28
25
  * @see {@link CarrierBalanceProps | The props for the `<CarrierBalance />` component}
29
26
  */
30
- export declare const CarrierBalance: ({ balance, carrierId, currency }: CarrierBalanceProps) => import("@emotion/react/jsx-runtime").JSX.Element;
27
+ export declare const CarrierBalance: ({ balance, isLoading, currency }: CarrierBalanceProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -8,7 +8,6 @@ import { SE } from "@shipengine/react-api";
8
8
  * @see {@link FundAndPurchase | The `<FundAndPurchase />` component using these props}
9
9
  */
10
10
  export type FundAndPurchaseProps = {
11
- balance?: number;
12
11
  carrierId?: string;
13
12
  className?: string;
14
13
  control: Control<any, any>;
@@ -37,4 +36,4 @@ export type FundAndPurchaseProps = {
37
36
  *
38
37
  * @see {@link FundAndPurchaseProps | The props that are passed into the `<FundAndPurchase />` component}
39
38
  */
40
- export declare const FundAndPurchase: ({ balance: uspsBalance, carrierId, control, currency, disabled, isFundingEnabled, isFundingRequired, isPreferredRate, nickname, purchaseAmount, showVatSettings, rateDetails, onSave, onPurchase, onVatRegistrationComplete, isInvalidatedByError, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
39
+ export declare const FundAndPurchase: ({ carrierId, control, currency, disabled, isFundingEnabled, isFundingRequired, isPreferredRate, nickname, purchaseAmount, showVatSettings, rateDetails, onSave, onPurchase, onVatRegistrationComplete, isInvalidatedByError, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,4 +1,10 @@
1
1
  export declare const styles: {
2
+ dialog: () => {
3
+ maxHeight: string;
4
+ overlay: {
5
+ position: "absolute";
6
+ };
7
+ };
2
8
  header: () => {
3
9
  alignContent: "center";
4
10
  alignItems: "left";
@@ -18,6 +18,7 @@ export type ShipmentFormProps = {
18
18
  currency: SE.Currency;
19
19
  customPackageTypes?: SE.CustomPackage[];
20
20
  defaultFeatures?: PurchaseLabelFeatures;
21
+ disabledShippingServices?: PurchaseLabelFeatures["disabledShippingServices"];
21
22
  errors?: SE.CodedError[];
22
23
  features?: ShipmentFormFeatures;
23
24
  harmonizedTariffCodes?: HarmonizedTariffCode[];
@@ -56,4 +57,4 @@ export type CharsetWarning = {
56
57
  message: string;
57
58
  title?: string;
58
59
  };
59
- export declare const ShipmentForm: ({ accountSettings, addressLoading, shipToAddressPreference, charsetWarning, carriers, customPackageTypes, currency, defaultFeatures, features, harmonizedTariffCodes, hydrateRef, insuranceAccount, isLoading, onApplyPreset, onChangeAddress, onChangeMode, onChangeShipFromAddress, onDirty, onSubmit, onSubmitParseAddress, onToggleAddressPreferenceDisclosure, onUpdateCustoms, onUpdateTaxableIds, parseAddressErrors, resetParseAddress, salesOrder, shipment, shipFromAddresses, shippingPresets, warehouseId, warehouses, }: ShipmentFormProps) => import("@emotion/react/jsx-runtime").JSX.Element;
60
+ export declare const ShipmentForm: ({ accountSettings, addressLoading, shipToAddressPreference, charsetWarning, carriers, customPackageTypes, currency, defaultFeatures, disabledShippingServices, features, harmonizedTariffCodes, hydrateRef, insuranceAccount, isLoading, onApplyPreset, onChangeAddress, onChangeMode, onChangeShipFromAddress, onDirty, onSubmit, onSubmitParseAddress, onToggleAddressPreferenceDisclosure, onUpdateCustoms, onUpdateTaxableIds, parseAddressErrors, resetParseAddress, salesOrder, shipment, shipFromAddresses, shippingPresets, warehouseId, warehouses, }: ShipmentFormProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,6 +1,8 @@
1
1
  import { SE } from "@shipengine/react-api";
2
+ import { PurchaseLabelFeatures } from "../../../utilities";
2
3
  import { UseRatesWithCacheProps } from "./use-rates-with-cache";
3
4
  export type UseRatesFormProps = {
5
+ disabledShippingServices?: PurchaseLabelFeatures["disabledShippingServices"];
4
6
  getPreferredRates?: UseRatesWithCacheProps["getPreferredRates"];
5
7
  onBeforeLabelCreate?: (rate: SE.Rate, shipment: SE.SalesOrderShipment) => Promise<void> | Promise<{
6
8
  error?: SE.CodedError;
@@ -21,7 +23,7 @@ export type UseRatesFormProps = {
21
23
  printLabelLayout?: SE.LabelLayout;
22
24
  shipment?: SE.SalesOrderShipment;
23
25
  };
24
- export declare const useRatesForm: ({ getPreferredRates, onBeforeRateSaved, onBeforeLabelCreate, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, shipment, }: UseRatesFormProps) => {
26
+ export declare const useRatesForm: ({ getPreferredRates, disabledShippingServices, onBeforeRateSaved, onBeforeLabelCreate, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, shipment, }: UseRatesFormProps) => {
25
27
  carriers: SE.Carrier[] | undefined;
26
28
  displayableRateErrors: string[] | undefined;
27
29
  errors: SE.CodedError[] | undefined;
@@ -1,6 +1,8 @@
1
1
  import { SE } from "@shipengine/react-api";
2
+ import { PurchaseLabelFeatures } from "../../../utilities";
2
3
  import { UseRequestRatesProps } from "./use-request-rates";
3
4
  export type UseRatesWithCacheProps = {
5
+ disabledShippingServices?: PurchaseLabelFeatures["disabledShippingServices"];
4
6
  getPreferredRates?: UseRequestRatesProps["getPreferredRates"];
5
7
  onRatesCalculated: UseRequestRatesProps["onRatesCalculated"];
6
8
  shipment?: SE.SalesOrderShipment;
@@ -14,7 +16,7 @@ export type UseRatesWithCacheProps = {
14
16
  * It also intercepts the resetRates function from useRequestRates to set a flag to ignore this caching.
15
17
  * (this transparently returns the behaviors to the default useRequestRates behavior)
16
18
  */
17
- export declare const useRatesWithCache: ({ shipment, onRatesCalculated, getPreferredRates, }: UseRatesWithCacheProps) => {
19
+ export declare const useRatesWithCache: ({ disabledShippingServices, onRatesCalculated, getPreferredRates, shipment, }: UseRatesWithCacheProps) => {
18
20
  preferredRatesResponse: import("../../..").PreferredRatesResponse | undefined;
19
21
  ratesCalculating: boolean;
20
22
  ratesErrors: SE.CodedError[] | null;
@@ -1,11 +1,13 @@
1
1
  import { SE } from "@shipengine/react-api";
2
2
  import { PreferredRatesResponse } from "../../../types";
3
+ import { PurchaseLabelFeatures } from "../../../utilities";
3
4
  import { ConfigureShipmentProps } from "../configure-shipment";
4
5
  export type UseRequestRatesProps = {
6
+ disabledShippingServices?: PurchaseLabelFeatures["disabledShippingServices"];
5
7
  getPreferredRates?: ConfigureShipmentProps["getPreferredRates"];
6
8
  onRatesCalculated?: (rates: SE.Rate[], shipment: SE.SalesOrderShipment) => Promise<void> | void;
7
9
  };
8
- export declare const useRequestRates: ({ onRatesCalculated, getPreferredRates }: UseRequestRatesProps) => {
10
+ export declare const useRequestRates: ({ disabledShippingServices, onRatesCalculated, getPreferredRates, }: UseRequestRatesProps) => {
9
11
  isCalculating: boolean;
10
12
  preferredRatesResponse: PreferredRatesResponse | undefined;
11
13
  ratesErrors: SE.CodedError[] | null;
@@ -0,0 +1,2 @@
1
+ import { SE } from "@shipengine/js-api";
2
+ export declare const formatCarrierLabel: (carriers: SE.Carrier[], carrier: SE.Carrier) => string;
@@ -32,4 +32,4 @@ export type RateOption = Omit<SE.Rate, "warningMessages"> & {
32
32
  *
33
33
  * # Rate Options Hook
34
34
  */
35
- export declare const useRateOptions: (rates?: SE.Rate[], preferredRates?: PreferredRatesResponse, carriers?: SE.Carrier[], shipment?: SE.SalesOrderShipment, servicePoints?: SE.ServicePoint[], enableGlobalPostFiltering?: boolean, requireDhlTermsAcknowledgement?: boolean, windsorFrameworkEnabled?: boolean) => RateOption[];
35
+ export declare const useRateOptions: (rates?: SE.Rate[], preferredRates?: PreferredRatesResponse, carriers?: SE.Carrier[], shipment?: SE.SalesOrderShipment, servicePoints?: SE.ServicePoint[], requireDhlTermsAcknowledgement?: boolean, windsorFrameworkEnabled?: boolean) => RateOption[];
@@ -1,5 +1,6 @@
1
1
  import { SE } from "@shipengine/react-api";
2
2
  import { SelectCategory } from "../../components/field/select";
3
+ import { PurchaseLabelFeatures } from "../../utilities";
3
4
  /**
4
5
  * @internal
5
6
  *
@@ -7,4 +8,4 @@ import { SelectCategory } from "../../components/field/select";
7
8
  *
8
9
  * @category Hooks
9
10
  */
10
- export declare const useServiceCodeOptions: (carriers?: SE.Carrier[], shipment?: SE.SalesOrderShipment) => SelectCategory[];
11
+ export declare const useServiceCodeOptions: (carriers?: SE.Carrier[], shipment?: SE.SalesOrderShipment, disabledShippingServices?: PurchaseLabelFeatures["disabledShippingServices"]) => SelectCategory[];
@@ -1,2 +1,3 @@
1
1
  export * from "./feature-flags";
2
2
  export * from "./types";
3
+ export * from "./utils";
@@ -6,10 +6,6 @@ export type RateFormFeatures = {
6
6
  * Enables the `funding` section of the rate form.
7
7
  */
8
8
  enableFunding?: boolean;
9
- /**
10
- * Enables the `global post filtering` on all rates fetched in the rates form.
11
- */
12
- enableGlobalPostFiltering?: boolean;
13
9
  /**
14
10
  * Enables the Pick Up/Drop Off tabs UI in the Rate Form to separate rates with PUDO capability by type.
15
11
  */
@@ -80,6 +76,11 @@ export type PurchaseLabelFeatures = {
80
76
  * List of all supported `countries` available in ShipEngine Elements.
81
77
  */
82
78
  compatibleCountryCodes?: CountryCode[];
79
+ /**
80
+ * Rates for any service codes included here will not be available for purchase.
81
+ * The property should be of the form { "carrier_code": ["service_code1", "service_code2"] }
82
+ */
83
+ disabledShippingServices?: Record<string, string[]>;
83
84
  /**
84
85
  * When enabled will modify the default behavior of creating a new shipment for a salesorder to throwing an error
85
86
  */
@@ -0,0 +1,2 @@
1
+ import { CarrierService, Rate } from "@shipengine/react-api";
2
+ export declare const isShippingServiceServiceDisabled: (service: CarrierService | Rate, disabledShippingServices?: Record<string, string[]>) => boolean;
@@ -1 +1 @@
1
- import{camelize as e}from"humps";import{useMemo as n,useCallback as i,useState as l,useEffect as r}from"react";import{useTranslation as o}from"react-i18next";import{SE as s,useGetInsuranceFundingSourceAcceptedTerms as a,useListFundingSources as c,useGetFundingSourceMetadata as d,useRegisterCarrier as t,useListServicePoints as u,useListSalesOrders as g,useGetSalesOrder as p,useListOrderSources as b,useRefreshOrderSource as m,useListCarriers as I,useListWarehouses as v,useUpdateSalesOrderShipment as h,useCreateShipment as y,useGetShipmentByExternalId as Z,useListSalesOrderShipments as X,useCreateSalesOrderShipment as G,CodedError as C}from"@shipengine/react-api";import{l as W,_ as N,N as x,L as A,T as B,U as H,V as w,W as F,F as V,G as S,S as J,u as L,Q as f}from"./carrier.js";import{c as T,j as k,k as R,f as O,i as Y,a as j,n as U,p as z,o as P,q as D,d as M,g as _}from"./warehouses.js";import{g as Q}from"./use-toggle.js";import{C as E}from"./canada-ddp.js";import K from"lodash/orderBy.js";import{jsx as $,jsxs as q}from"@emotion/react/jsx-runtime";import{InlineNotification as ee,NotificationType as ne}from"@shipengine/giger";import{css as ie}from"@emotion/react";import{encode as le}from"js-base64";import{useQueryClient as re}from"@tanstack/react-query";const oe=()=>{const{t:i}=o("common");return n((()=>Object.values(s.ConfirmationType).filter((e=>e!==s.ConfirmationType.DELIVERY_MAILED&&e!==s.ConfirmationType.DIRECT_SIGNATURE&&e!==s.ConfirmationType.VERBAL_CONFIRMATION)).flatMap((n=>"none"===n?[]:{label:i(`confirmationTypes.${e(n)}`),value:n}))),[i])},se=()=>{const{t:i}=o("common");return n((()=>Object.values(s.CustomsContentsType).flatMap((n=>({label:i(`customs.contents.${e(n)}`),value:n})))),[i])},ae=()=>{const{t:i}=o("common");return n((()=>Object.values(s.CustomsNonDeliveryType).flatMap((n=>({label:i(`customs.nonDelivery.${e(n)}`),value:n})))),[i])},ce=()=>{const{t:e}=o(),i=n((()=>W()),[]),l=n((()=>[{label:e("wallet-history:historyOptions.custom"),range:void 0,value:"custom"},{label:e("wallet-history:historyOptions.last30days"),range:[i.thirtyDaysAgo,i.origin],value:"last30days"},{label:e("wallet-history:historyOptions.thisMonth"),range:[i.firstDayOfMonth,i.lastDayOfTheMonth],value:"thisMonth"},{label:e("wallet-history:historyOptions.lastMonth"),range:[i.previousMonthFirstDay,i.previousMonthLastDay],value:"lastMonth"}]),[i,e]);return[l,T(l,(e=>({[e.value]:e})))]},de=()=>{const{globalFeatures:{enableParcelGuard:e}}=Q(),{data:i,refetch:l}=a({enabled:e});return{fundingSourceInsuranceProvider:n((()=>{var n;let l;return null===(n=null==i?void 0:i.acceptedTerms)||void 0===n||n.forEach((n=>{e&&"parcelguard_terms"===n.termType&&(l="parcelguard")})),l}),[i,e]),refetchInsuranceAcceptedTerms:l}},te=()=>{const{globalFeatures:{enableParcelGuard:e}}=Q(),{data:l,isLoading:r}=c(),o=d(),{data:s,isLoading:u}=a({enabled:e}),g=n((()=>{var e;return null===(e=null==o?void 0:o.data)||void 0===e?void 0:e.defaultFundingSourceProfile.optionalTerms.map((e=>{const n={parcelguard_terms:"parcelguard"}[e.termType];return{friendlyName:{parcelguard_terms:"ParcelGuard"}[e.termType],provider:n,terms:e}}))}),[o]),{mutateAsync:p}=t(),b=i((()=>N(void 0,void 0,void 0,(function*(){var e,n;if(!l||!g)return{isSuccessful:!1};try{return(null===(n=(yield p({insuranceProviders:[{acceptedTerms:null==g?void 0:g.flatMap((e=>e.terms)).map((e=>({termType:e.termType,version:e.version}))),agreeToTerms:!0,fundingSourceId:null===(e=null==l?void 0:l[0])||void 0===e?void 0:e.fundingSourceId,provider:g[0].provider}]})).insuranceProviderAttachmentResults)||void 0===n?void 0:n[0].isSuccessful)?{isSuccessful:!0}:{isSuccessful:!1}}catch(e){return console.error(e),{isSuccessful:!1}}}))),[l,g,p]);return{hasInsuranceToRegister:n((()=>e&&!!(null==g?void 0:g.length)&&0===(null==s?void 0:s.acceptedTerms.length)&&!!(null==l?void 0:l.length)),[e,null==g?void 0:g.length,null==s?void 0:s.acceptedTerms.length,null==l?void 0:l.length]),insuranceAcceptedTerms:null==s?void 0:s.acceptedTerms,insuranceProviderProfiles:g,loading:r||u,registerInsuranceProvider:b}},ue=(i,l)=>{const{t:r}=o("common"),{globalFeatures:a}=Q(),{fundingSourceInsuranceProvider:c,refetchInsuranceAcceptedTerms:d}=de(),t=n((()=>Object.values(s.InsuranceProviderType).flatMap((n=>"none"===n||"funding_source"===n||"parcelguard"===n&&(n!==c||!a.enableParcelGuard)||"x_cover"===n&&n!==c||"carrier"===n&&!(null==l?void 0:l.includeCarrierInsurance)||"third_party"===n&&!(null==l?void 0:l.includeThirdPartyInsurance)||"shipsurance"===n&&(!(null==i?void 0:i.amount)||!(null==l?void 0:l.includeShipsuranceInsurance))?[]:{label:r(`insuranceProviders.${e(n)}`),value:n}))),[c,a.enableParcelGuard,l,null==i?void 0:i.amount,r]);return{fundingSourceInsuranceProvider:c,insuranceProviderOptions:t,refetchInsuranceAcceptedTerms:d}},ge=()=>{const{t:e}=o("purchase-label");return n((()=>Object.values(s.MovementIndicator).flatMap((n=>({label:e(`windsorFramework.movementIndicators.${n}`),value:n})))),[e])},pe=e=>{const i=n((()=>!!e&&k(e)),[e]),l=n((()=>(null==e?void 0:e.shipTo)&&x(e.shipTo)),[null==e?void 0:e.shipTo]),r=n((()=>(null==e?void 0:e.shipTo)&&A(e.shipTo)),[null==e?void 0:e.shipTo]),o=n((()=>!!e&&R(e)),[e]),s=n((()=>{var n;return e&&"MX"===(null===(n=e.shipFrom)||void 0===n?void 0:n.countryCode)||"MX"===(null==e?void 0:e.shipTo.countryCode)}),[e]),a=n((()=>{var n,i;return"CA"===(null===(n=null==e?void 0:e.shipTo)||void 0===n?void 0:n.countryCode)&&"US"===(null===(i=null==e?void 0:e.shipFrom)||void 0===i?void 0:i.countryCode)}),[e]),c=n((()=>{const n=null==e?void 0:e.packages[0].dimensions,i=null==e?void 0:e.packages[0].weight;return{hasAllZeroMeasurements:[null==n?void 0:n.height,null==n?void 0:n.length,null==n?void 0:n.width,null==i?void 0:i.value].every((e=>0===e))}}),[e]);return Object.assign({isCanadaDeliveredDutyEligible:a,isContentDescriptionRequired:s,isCustomsRequired:o,isInternational:i,isPoBox:l,isUnsupportedUpsCountry:r},c)};let be,me=e=>e;const Ie=(e,i,l)=>{const{t:r}=o("common"),{isPoBox:s,isUnsupportedUpsCountry:a}=pe(l);return n((()=>{if(!e)return;const n=T(e,((e,n)=>({[e.carrierCode]:void 0===n[e.carrierCode]}))),l=(e=>{const n=e.find((e=>e.packages.some((e=>"package"===e.packageCode))));return null==n?void 0:n.packages.find((e=>"package"===e.packageCode))})(e),o=l?[{label:r("packageCodes.package"),value:{code:"package"}}]:[],c=[{label:r(be||(be=me`packageCategories.customPackages`)),options:[...o,...i?i.sort(((e,n)=>e.name.localeCompare(n.name))).map((({dimensions:e,name:n,packageId:i,packageCode:l})=>({label:`${n}${e?` - ${O(e)}`:""}`,value:{code:l,packageId:i}}))):[]]}];return e.reduce(((e,i)=>0===i.packages.length||!B(i.carrierCode)&&s||H(i.carrierCode)&&a?e:[...e,{label:n[i.carrierCode]?i.friendlyName:i.nickname,options:i.packages.filter((e=>!["cubic","letter","package","regional_rate_box_a","regional_rate_box_b"].includes(e.packageCode))).sort(((e,n)=>e.name.localeCompare(n.name))).map((e=>({label:e.name,value:{carrierId:i.carrierId,code:e.packageCode}}))),value:i.carrierId}]),c)}),[e,i,s,a,r])},ve=(e,i)=>{const l=n((()=>{var n,i;return null===(i=null===(n=null==e?void 0:e.advancedOptions)||void 0===n?void 0:n.windsorFrameworkDetails)||void 0===i?void 0:i.movementIndicator}),[e]),r=n((()=>{var n,i;if(!e)return!1;const l=null===(n=e.shipFrom)||void 0===n?void 0:n.countryCode,r=e.shipTo.countryCode,o=null===(i=e.shipFrom)||void 0===i?void 0:i.postalCode.includes("BT"),s=e.shipTo.postalCode.includes("BT");return"GB"===l&&"GB"===r&&s&&!o}),[e]),o=n((()=>{var n;const l=null===(n=null==e?void 0:e.advancedOptions)||void 0===n?void 0:n.windsorFrameworkDetails;if(!l||!i)return{isInvalid:!1};const{movementIndicator:r}=l;if("b2b"===r){const n=e.taxIdentifiers;if(!n)return{isInvalid:!0,messages:["shipperEori","recipientEori","ukims"]};const i=n.reduce(((e,n)=>{switch(n.identifierType){case"eori":e[`${n.taxableEntityType}Eori`]=!0;break;case"ukims":e.ukims=!0}return e}),{recipientEori:!1,shipperEori:!1,ukims:!1}),l=[];return i.shipperEori||l.push("shipperEori"),i.recipientEori||l.push("recipientEori"),i.ukims||l.push("ukims"),0===l.length?{isInvalid:!1}:{isInvalid:!0,messages:l}}return{isInvalid:!1}}),[i,e]);return{isWindsorFrameworkInvalid:o,movementIndicator:l,requiresWindsorFramework:r&&i}};var he;!function(e){e.PICKUP="pick_up",e.DROPOFF="drop_off"}(he||(he={}));const ye=(e,l,r,s,a,c,d,t)=>{var u;const{t:g}=o(),p=n((()=>T(r,(e=>({[e.carrierId]:e})))),[r]),{isInternational:b,isPoBox:m,isUnsupportedUpsCountry:I}=pe(s),{requiresWindsorFramework:v,movementIndicator:h}=ve(s,t),y=n((()=>{var e;return(null===(e=null==s?void 0:s.advancedOptions)||void 0===e?void 0:e.canadaDeliveredDuty)===E.SENDER_PREPAY}),[null===(u=null==s?void 0:s.advancedOptions)||void 0===u?void 0:u.canadaDeliveredDuty]),Z=i((e=>(B(e)||!y)&&(B(e)||!m)&&(!H(e)||!I)&&(!w(e)||!(v&&"b2b"===h))&&(!F(e)||!(v&&"b2b"===h))),[m,I,h,v,y]),X=n((()=>(null!=l?l:[]).filter((e=>Z(e.rate.carrierCode))).map((e=>Object.assign(Object.assign({},e.rate),{balance:void 0,messages:e.rate.warningMessages,rateAcknowledgementMessage:e.rateAcknowledgementMessage,requiresAcknowledgement:!!e.rateAcknowledgementMessage,requiresFundedAmount:!1})))),[l,Z]),G=g("purchase-label:rates.noRateService"),C=n((()=>(null!=e?e:[]).filter((e=>{const n=p[e.carrierId],i=null==n?void 0:n.services.find((n=>n.serviceCode===e.serviceCode));return Z(e.carrierCode)&&(null==i?void 0:i.domestic)===!b&&(!c||!e.serviceCode.includes("globalpost_"))})).map((e=>{var n,i;const l=null===(n=p[e.carrierId])||void 0===n?void 0:n.balance,r=null===(i=p[e.carrierId])||void 0===i?void 0:i.requiresFundedAmount,o=Object.assign(Object.assign({},e),{balance:l,messages:e.warningMessages,requiresAcknowledgement:V(e.serviceCode,e.packageType,!!d),requiresFundedAmount:r});return 0!==e.shippingAmount.amount||e.warningMessages.includes(G)||o.messages.push(G),Y(e)?j(e.carrierCode,e.serviceCode)?Object.assign(Object.assign({},o),{pudoType:he.PICKUP}):Object.assign(Object.assign({},o),{pudoType:he.DROPOFF,servicePoints:null==a?void 0:a.filter((n=>{const i=n.carrierCode===e.carrierCode,l=n.serviceCodes.includes(e.serviceCode);if("dpdwallet"===n.carrierCode)return i&&l;const r=!n.features||0===n.features.length||n.features.includes("drop_off_point");return i&&l&&r}))}):o}))),[p,c,b,e,d,Z,a,G]);return n((()=>[...X,...C].sort(((e,n)=>0===e.shippingAmount.amount&&0===n.shippingAmount.amount?e.deliveryDays-n.deliveryDays:0===e.shippingAmount.amount?1:0===n.shippingAmount.amount?-1:S(e)-S(n)))),[X,C])},Ze=(e,i)=>{const{isInternational:l,isPoBox:r,isUnsupportedUpsCountry:o}=pe(i);return n((()=>{const n=T(e,((e,n)=>({[e.carrierCode]:void 0===n[e.carrierCode]})));return(null!=e?e:[]).reduce(((i,s)=>{if(!B(s.carrierCode)&&r||H(s.carrierCode)&&o)return i;const a=s.services.filter((e=>e.domestic===!l&&!e.serviceCode.includes("globalpost_")));if(0===a.length)return i;const c=K(a,"name","asc");return[...i,{label:((e,i)=>n[i.carrierCode]?i.friendlyName:`${i.friendlyName} - ${i.nickname} ${((e,n)=>e.filter((e=>e.carrierCode===n.carrierCode)).reduce(((e,n)=>(e[n.nickname]=void 0===e[n.nickname],e)),{}))(e,i)[i.nickname]?"":`(${i.carrierId})`}`)(e||[],s),options:c.map((e=>({label:e.name,value:{carrierId:s.carrierId,serviceCode:e.serviceCode}}))),value:s.carrierId}]}),[])}),[e,l,r,o])},Xe=e=>ie({display:"flex",flexDirection:"column",height:"100%",paddingTop:e.spacing(.5),width:"max-content"},"production"===process.env.NODE_ENV?"":";label:getContainerStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDNkMiLCJmaWxlIjoicHJlc2V0LWRlc2NyaXB0b3Iuc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL3JlYWN0XCI7XHJcbmV4cG9ydCBjb25zdCBnZXRDb250YWluZXJTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBkaXNwbGF5OiBcImZsZXhcIixcclxuICAgIGZsZXhEaXJlY3Rpb246IFwiY29sdW1uXCIsXHJcbiAgICBoZWlnaHQ6IFwiMTAwJVwiLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygwLjUpLFxyXG4gICAgd2lkdGg6IFwibWF4LWNvbnRlbnRcIixcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXREaW1lbnNpb25TdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBjb2xvcjogdGhlbWUucGFsZXR0ZS5ncmF5Lm1haW4sXHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXRTZXJ2aWNlTmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhYUyxcclxuICAgIGxpbmVIZWlnaHQ6IDAsXHJcbiAgICBwYWRkaW5nVG9wOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0UHJlc2V0TmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhTLFxyXG4gICAgZm9udFdlaWdodDogdGhlbWUudHlwb2dyYXBoeS5mb250V2VpZ2h0LmJvbGQsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0V2FybmluZ1N0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGJhY2tncm91bmQ6IFwibm9uZVwiLFxyXG4gICAgbWFyZ2luTGVmdDogXCJhdXRvXCIsXHJcbiAgICBtYXJnaW5SaWdodDogdGhlbWUuc3BhY2luZygtMyksXHJcbiAgICBtYXJnaW5Ub3A6IHRoZW1lLnNwYWNpbmcoLTUpLFxyXG4gICAgd2lkdGg6IHRoZW1lLnNwYWNpbmcoKSxcclxufSk7XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy5qcy5tYXAiXX0= */"),Ge=e=>ie({color:e.palette.gray.main,fontSize:e.typography.fontSize.XS},"production"===process.env.NODE_ENV?"":";label:getDimensionStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFRNkMiLCJmaWxlIjoicHJlc2V0LWRlc2NyaXB0b3Iuc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL3JlYWN0XCI7XHJcbmV4cG9ydCBjb25zdCBnZXRDb250YWluZXJTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBkaXNwbGF5OiBcImZsZXhcIixcclxuICAgIGZsZXhEaXJlY3Rpb246IFwiY29sdW1uXCIsXHJcbiAgICBoZWlnaHQ6IFwiMTAwJVwiLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygwLjUpLFxyXG4gICAgd2lkdGg6IFwibWF4LWNvbnRlbnRcIixcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXREaW1lbnNpb25TdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBjb2xvcjogdGhlbWUucGFsZXR0ZS5ncmF5Lm1haW4sXHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXRTZXJ2aWNlTmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhYUyxcclxuICAgIGxpbmVIZWlnaHQ6IDAsXHJcbiAgICBwYWRkaW5nVG9wOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0UHJlc2V0TmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhTLFxyXG4gICAgZm9udFdlaWdodDogdGhlbWUudHlwb2dyYXBoeS5mb250V2VpZ2h0LmJvbGQsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0V2FybmluZ1N0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGJhY2tncm91bmQ6IFwibm9uZVwiLFxyXG4gICAgbWFyZ2luTGVmdDogXCJhdXRvXCIsXHJcbiAgICBtYXJnaW5SaWdodDogdGhlbWUuc3BhY2luZygtMyksXHJcbiAgICBtYXJnaW5Ub3A6IHRoZW1lLnNwYWNpbmcoLTUpLFxyXG4gICAgd2lkdGg6IHRoZW1lLnNwYWNpbmcoKSxcclxufSk7XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy5qcy5tYXAiXX0= */"),Ce=e=>ie({fontSize:e.typography.fontSize.XXS,lineHeight:0,paddingTop:e.spacing()},"production"===process.env.NODE_ENV?"":";label:getServiceNameStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFZK0MiLCJmaWxlIjoicHJlc2V0LWRlc2NyaXB0b3Iuc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL3JlYWN0XCI7XHJcbmV4cG9ydCBjb25zdCBnZXRDb250YWluZXJTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBkaXNwbGF5OiBcImZsZXhcIixcclxuICAgIGZsZXhEaXJlY3Rpb246IFwiY29sdW1uXCIsXHJcbiAgICBoZWlnaHQ6IFwiMTAwJVwiLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygwLjUpLFxyXG4gICAgd2lkdGg6IFwibWF4LWNvbnRlbnRcIixcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXREaW1lbnNpb25TdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBjb2xvcjogdGhlbWUucGFsZXR0ZS5ncmF5Lm1haW4sXHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXRTZXJ2aWNlTmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhYUyxcclxuICAgIGxpbmVIZWlnaHQ6IDAsXHJcbiAgICBwYWRkaW5nVG9wOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0UHJlc2V0TmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhTLFxyXG4gICAgZm9udFdlaWdodDogdGhlbWUudHlwb2dyYXBoeS5mb250V2VpZ2h0LmJvbGQsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0V2FybmluZ1N0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGJhY2tncm91bmQ6IFwibm9uZVwiLFxyXG4gICAgbWFyZ2luTGVmdDogXCJhdXRvXCIsXHJcbiAgICBtYXJnaW5SaWdodDogdGhlbWUuc3BhY2luZygtMyksXHJcbiAgICBtYXJnaW5Ub3A6IHRoZW1lLnNwYWNpbmcoLTUpLFxyXG4gICAgd2lkdGg6IHRoZW1lLnNwYWNpbmcoKSxcclxufSk7XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy5qcy5tYXAiXX0= */"),We=e=>ie({fontSize:e.typography.fontSize.XS,fontWeight:e.typography.fontWeight.bold},"production"===process.env.NODE_ENV?"":";label:getPresetNameStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpQjhDIiwiZmlsZSI6InByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gXCJAZW1vdGlvbi9yZWFjdFwiO1xyXG5leHBvcnQgY29uc3QgZ2V0Q29udGFpbmVyU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgZGlzcGxheTogXCJmbGV4XCIsXHJcbiAgICBmbGV4RGlyZWN0aW9uOiBcImNvbHVtblwiLFxyXG4gICAgaGVpZ2h0OiBcIjEwMCVcIixcclxuICAgIHBhZGRpbmdUb3A6IHRoZW1lLnNwYWNpbmcoMC41KSxcclxuICAgIHdpZHRoOiBcIm1heC1jb250ZW50XCIsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0RGltZW5zaW9uU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgY29sb3I6IHRoZW1lLnBhbGV0dGUuZ3JheS5tYWluLFxyXG4gICAgZm9udFNpemU6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFNpemUuWFMsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0U2VydmljZU5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YWFMsXHJcbiAgICBsaW5lSGVpZ2h0OiAwLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygpLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFByZXNldE5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxuICAgIGZvbnRXZWlnaHQ6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFdlaWdodC5ib2xkLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFdhcm5pbmdTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBiYWNrZ3JvdW5kOiBcIm5vbmVcIixcclxuICAgIG1hcmdpbkxlZnQ6IFwiYXV0b1wiLFxyXG4gICAgbWFyZ2luUmlnaHQ6IHRoZW1lLnNwYWNpbmcoLTMpLFxyXG4gICAgbWFyZ2luVG9wOiB0aGVtZS5zcGFjaW5nKC01KSxcclxuICAgIHdpZHRoOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1wcmVzZXQtZGVzY3JpcHRvci5zdHlsZXMuanMubWFwIl19 */"),Ne=e=>ie({background:"none",marginLeft:"auto",marginRight:e.spacing(-3),marginTop:e.spacing(-5),width:e.spacing()},"production"===process.env.NODE_ENV?"":";label:getWarningStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFxQjJDIiwiZmlsZSI6InByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gXCJAZW1vdGlvbi9yZWFjdFwiO1xyXG5leHBvcnQgY29uc3QgZ2V0Q29udGFpbmVyU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgZGlzcGxheTogXCJmbGV4XCIsXHJcbiAgICBmbGV4RGlyZWN0aW9uOiBcImNvbHVtblwiLFxyXG4gICAgaGVpZ2h0OiBcIjEwMCVcIixcclxuICAgIHBhZGRpbmdUb3A6IHRoZW1lLnNwYWNpbmcoMC41KSxcclxuICAgIHdpZHRoOiBcIm1heC1jb250ZW50XCIsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0RGltZW5zaW9uU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgY29sb3I6IHRoZW1lLnBhbGV0dGUuZ3JheS5tYWluLFxyXG4gICAgZm9udFNpemU6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFNpemUuWFMsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0U2VydmljZU5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YWFMsXHJcbiAgICBsaW5lSGVpZ2h0OiAwLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygpLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFByZXNldE5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxuICAgIGZvbnRXZWlnaHQ6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFdlaWdodC5ib2xkLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFdhcm5pbmdTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBiYWNrZ3JvdW5kOiBcIm5vbmVcIixcclxuICAgIG1hcmdpbkxlZnQ6IFwiYXV0b1wiLFxyXG4gICAgbWFyZ2luUmlnaHQ6IHRoZW1lLnNwYWNpbmcoLTMpLFxyXG4gICAgbWFyZ2luVG9wOiB0aGVtZS5zcGFjaW5nKC01KSxcclxuICAgIHdpZHRoOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1wcmVzZXQtZGVzY3JpcHRvci5zdHlsZXMuanMubWFwIl19 */"),xe=e=>{const{t:n}=o();return $("div",Object.assign({css:Xe},{children:q("div",{children:[q("div",{children:[$("span",Object.assign({css:We},{children:e.name})),$("span",Object.assign({css:Ge},{children:(e.dimensions||e.weight)&&" - "})),e.dimensions&&$("span",Object.assign({css:Ge},{children:`${O(e.dimensions)} `+n(`units.${e.dimensions.unit}`)}))]}),$("div",Object.assign({css:Ce},{children:e.serviceName&&e.serviceName})),e.serviceName&&["USPS Parcel Select Ground","USPS First Class Mail"].includes(e.serviceName)&&$(ee,{css:Ne,type:ne.ALERT})]})}))},Ae=(e,n)=>n?[{categoryName:e,options:n.map((e=>({description:$(xe,Object.assign({},e)),displayName:e.name,value:e})))}]:[],Be=({platform:e,user:i}={},l)=>{const{t:r}=o(),{isInternational:s}=pe(l);return n((()=>[...Ae(r("shippingPresets.user"),s?null==i?void 0:i.international:null==i?void 0:i.domestic),...Ae(r("shippingPresets.platform"),s?null==e?void 0:e.international:null==e?void 0:e.domestic)]),[s,e,r,i])},He=(e,i,l)=>n((()=>{var n,r,o,s,a;if(!e&&!i&&!l)return;const c=!!(null==l?void 0:l.warehouseId),d=J(l,i),t={label:null!==(r=null===(n=null==l?void 0:l.shipFrom)||void 0===n?void 0:n.addressLine1)&&void 0!==r?r:"",subLabel:`${L(null!==(s=null===(o=null==l?void 0:l.shipFrom)||void 0===o?void 0:o.cityLocality)&&void 0!==s?s:"")}, ${null===(a=null==l?void 0:l.shipFrom)||void 0===a?void 0:a.stateProvince} `,value:"custom-shipment-address"},u=null==e?void 0:e.map((e=>({label:e.name,subLabel:`${L(e.originAddress.addressLine1)}. ${L(e.originAddress.cityLocality)}, ${e.originAddress.stateProvince} `,value:e.warehouseId}))),g=null==i?void 0:i.map((e=>{var n;return{label:null!==(n=e.name)&&void 0!==n?n:e.originAddress.addressLine1,subLabel:e.name?`${L(e.originAddress.addressLine1)}. ${L(e.originAddress.cityLocality)}, ${e.originAddress.stateProvince} `:`${L(e.originAddress.cityLocality)}, ${e.originAddress.stateProvince} `,value:e.addressId}}));return[...c||d?[]:[{label:"Shipment Address",options:[t]}],...(null==g?void 0:g.length)||(null==u?void 0:u.length)?[{label:"Saved Ship From Locations",options:[...null!=g?g:[],...null!=u?u:[]]}]:[]]}),[i,l,e]),we=(e,o)=>{var s;const[a,c]=l(null===(s=null==o?void 0:o.shipFrom)||void 0===s?void 0:s.postalCode),d=n((()=>({addressQuery:a,maxResults:50,providers:[]})),[a]),t=n((()=>{const n=(null==e?void 0:e.filter((e=>Y(e))))||[],i=Array.from(new Set(n.map((e=>e.carrierId)))).map((e=>({carrierId:e,serviceCode:n.filter((n=>n.carrierId===e)).map((e=>e.serviceCode))})));return Object.assign(Object.assign({},d),{providers:i})}),[e,d]),[g,p]=l();r((()=>{t.providers.length>0&&p(t)}),[t]);const{data:b,isFetching:m,error:I}=u(null!=g?g:d);return{fetchServicePoints:i((e=>{c(e)}),[]),listServicePointsErrors:I,nestedServicePointErrors:null==b?void 0:b.errors,servicePointSearchQuery:a,servicePointsFetching:m,servicePointsResponse:b}},Fe=({onSuccess:e,onError:n})=>{r((()=>{window.io_install_stm=!1,window.io_exclude_stm=12,window.io_install_flash=!1,window.io_enable_rip=!0;const i=setInterval((()=>{try{if("function"!=typeof ioGetBlackbox)return;const n=ioGetBlackbox();n.finished&&(clearTimeout(i),e(n.blackbox))}catch(e){n()}}),500),l=document.createElement("script");return l.type="text/javascript",l.async=!0,l.src="https://mpsnare.iesnare.com/snare.js",l.addEventListener("error",(e=>{"function"!=typeof ioGetBlackbox&&n()})),document.head.appendChild(l),()=>{i&&clearTimeout(i),delete window.io_install_stm,delete window.io_exclude_stm,delete window.io_install_flash,delete window.io_enable_rip,document.head.removeChild(l)}}),[e,n])},Ve=({scrubber:e,errors:i,predicate:l})=>{const{t:r}=o();return n((()=>null==i?void 0:i.map((n=>r(le(n.message),{defaultValue:!l||l(n)?r(e(n)):Se(n)})))),[i,l,e,r])},Se=e=>e.message.replaceAll(/Invalid rate\. Invalid rate\./g,"Invalid rate."),Je=({enabled:e,externalOrderId:n,externalOrderNumber:i,orderSourceCode:o,salesOrderId:s})=>{const[a,c]=l(!1),{data:d,error:t,isFetching:u,isInitialLoading:I,refetch:v}=g({externalOrderId:n,externalOrderNumber:i}),{data:h,error:y,isFetching:Z,isInitialLoading:X,refetch:G}=p(null!=s?s:d&&d[0]?d[0].salesOrderId:void 0),{data:C,error:W}=b({enabled:e}),{data:x,error:A,isLoading:B,mutateAsync:H}=m();r((()=>{N(void 0,void 0,void 0,(function*(){const n=o?null==C?void 0:C.filter((e=>e.orderSourceCode.includes(o)&&e.active)):C;!e||!n||h||Z||u||a||(yield Promise.all(n.map((e=>H(e.orderSourceId)))),yield s?G():v(),c(!0))}))}),[e,a,Z,u,o,C,G,v,H,x,h,s]);const w=[...null!=W?W:[],...null!=t?t:[],...null!=y?y:[],...null!=A?A:[]];return{errors:w.length>0?w:void 0,isLoading:X||I||B||!a&&!h&&0===(null==d?void 0:d.length)&&0===w.length,salesOrder:h}},Le=({onShipmentUpdated:e,onLoad:l,errorWhenShipmentCancelled:o=!1,externalOrderId:s,externalOrderNumber:a,externalShipmentId:c,orderSourceCode:d,salesOrderId:t,shipFromAddresses:u,shipmentId:g,warehouseId:p,useWarehouses:b=!0})=>{const m=re(),W=n((()=>[]),[]),{data:x,isInitialLoading:A,isFetching:B}=I(),{data:H,error:w,isInitialLoading:F,isFetching:V}=v({enabled:b}),{salesOrder:S,errors:J,isLoading:L}=Je({enabled:!!(a||d||t||s),externalOrderId:s,externalOrderNumber:a,orderSourceCode:d,salesOrderId:t}),{error:T,mutate:k}=h(),{data:R,mutateAsync:O,isLoading:Y,isSuccess:j,error:Q}=y(),{data:E,error:K,isInitialLoading:$,isFetching:q}=Z({enabled:!!c&&!g,queryFnParams:{externalId:null!=c?c:""}}),{data:ee,error:ne,refetch:ie,isInitialLoading:le,isFetching:oe}=X({salesOrderIds:t?[t]:S?[S.salesOrderId]:void 0,shipmentIds:g?[g]:E?[E.shipmentId]:R?[R.shipments[0].shipmentId]:void 0}),{error:se,mutateAsync:ae,isLoading:ce,isSuccess:de}=G(),te=U("pending",ee),ue=U("label_purchased",ee),ge=U("cancelled",ee),pe=z(H),be=f(u),me=i((()=>N(void 0,void 0,void 0,(function*(){var e,n,i;if(le||oe||q||$||ce||de||Y||j||F||V||te||ue)return;const l=!(null==u?void 0:u.length),r=!(null==H?void 0:H.length);if(b||!l)if(l&&r&&!p)W.push("no_warehouses");else{if(S){const l=null!==(i=null!==(e=null==be?void 0:be.originAddress)&&void 0!==e?e:null===(n=D(p,H))||void 0===n?void 0:n.originAddress)&&void 0!==i?i:null==pe?void 0:pe.originAddress,r=M(S,l),o=_(S,l);(yield ae(Object.assign(Object.assign(Object.assign({salesOrderId:S.salesOrderId},(null==be?void 0:be.originAddress)?{shipFrom:be.originAddress}:{warehouseId:p||(null==pe?void 0:pe.warehouseId)}),r&&{customs:o.customs}),{packages:[Object.assign(Object.assign({packageCode:"package"},r&&{products:o.products}),{weight:{unit:"pound",value:0}})]})))&&(yield ie())}if(!(t||s||a||d||g||c)){(yield O(Object.assign({},(null==be?void 0:be.originAddress)?{shipFrom:be.originAddress}:{warehouseId:p||pe.warehouseId})))&&(yield ie())}}else W.push("no_warehouses")}))),[ae,O,ce,Y,be,pe,s,a,c,W,q,$,V,F,ue,le,oe,d,te,ie,S,t,de,null==u?void 0:u.length,g,b,j,p,H]),Ie=i((n=>{const i=P(n);k(i,{onSuccess(n){null==e||e(n),m.invalidateQueries(["useListSalesOrderShipments",{shipmentId:n.shipmentId}],{exact:!1})}})}),[e,m,k]),ve=i((()=>N(void 0,void 0,void 0,(function*(){const{data:e}=yield ie();return U("pending",e)}))),[ie]);r((()=>{N(void 0,void 0,void 0,(function*(){yield me()}))}),[g,c,t,S,H,p,me]),r((()=>{var e,n;(null===(n=null===(e=null==te?void 0:te.customs)||void 0===e?void 0:e.customsItems)||void 0===n?void 0:n.length)&&Ie(te)}),[Ie,te]),r((()=>{(null==ee?void 0:ee.length)&&ee.every((e=>"label_purchased"===e.shipmentStatus))&&(null==l||l(ee,S,te))}),[l,te,S,ee]),r((()=>{A||B||0===(null==x?void 0:x.length)&&W.push("no_carriers")}),[x,W,B,A]);const he=[...null!=w?w:[],...null!=se?se:[],...null!=Q?Q:[],...null!=ne?ne:[],...null!=K?K:[],...null!=J?J:[],...null!=T?T:[],...o&&ge?[new C("shipment_cancelled",{errorCode:"invalid_status",errorSource:"elements",errorType:"business_rules"})]:[],...ue?[new C("label_purchased",{errorCode:"invalid_status",errorSource:"elements",errorType:"business_rules"})]:[],...W.length>0?[new C(W.length>1?"no_carriers_and_warehouses":W[0],{errorCode:"unknown",errorSource:"elements",errorType:"business_rules"})]:[]];return{carriers:x,errors:he.length>0?he:void 0,isLoading:(L||!(null==ee?void 0:ee.length)||ce)&&0===he.length,refetchPendingSalesOrderShipments:ve,salesOrder:S,shipment:null!=te?te:ue,warehouses:H}};export{he as P,se as a,ae as b,ce as c,ue as d,ge as e,Ie as f,ye as g,Ze as h,pe as i,Be as j,He as k,we as l,ve as m,de as n,te as o,Fe as p,Ve as q,Le as r,Je as s,oe as u};
1
+ import{camelize as e}from"humps";import{useMemo as n,useCallback as i,useState as l,useEffect as r}from"react";import{useTranslation as s}from"react-i18next";import{SE as o,useGetInsuranceFundingSourceAcceptedTerms as a,useListFundingSources as c,useGetFundingSourceMetadata as d,useRegisterCarrier as t,useListServicePoints as u,useListSalesOrders as g,useGetSalesOrder as p,useListOrderSources as b,useRefreshOrderSource as m,useListCarriers as I,useListWarehouses as v,useUpdateSalesOrderShipment as h,useCreateShipment as y,useGetShipmentByExternalId as Z,useListSalesOrderShipments as X,useCreateSalesOrderShipment as G,CodedError as C}from"@shipengine/react-api";import{l as W,_ as N,N as x,L as A,T as B,U as H,V as w,W as F,F as V,G as S,S as J,u as L,Q as f}from"./carrier.js";import{c as T,k,l as R,f as O,a as Y,b as j,i as U,o as z,q as P,p as D,r as M,e as _,g as Q}from"./warehouses.js";import{g as E}from"./use-toggle.js";import{C as K}from"./canada-ddp.js";import $ from"lodash/orderBy.js";import{jsx as q,jsxs as ee}from"@emotion/react/jsx-runtime";import{InlineNotification as ne,NotificationType as ie}from"@shipengine/giger";import{css as le}from"@emotion/react";import{encode as re}from"js-base64";import{useQueryClient as se}from"@tanstack/react-query";const oe=()=>{const{t:i}=s("common");return n((()=>Object.values(o.ConfirmationType).filter((e=>e!==o.ConfirmationType.DELIVERY_MAILED&&e!==o.ConfirmationType.DIRECT_SIGNATURE&&e!==o.ConfirmationType.VERBAL_CONFIRMATION)).flatMap((n=>"none"===n?[]:{label:i(`confirmationTypes.${e(n)}`),value:n}))),[i])},ae=()=>{const{t:i}=s("common");return n((()=>Object.values(o.CustomsContentsType).flatMap((n=>({label:i(`customs.contents.${e(n)}`),value:n})))),[i])},ce=()=>{const{t:i}=s("common");return n((()=>Object.values(o.CustomsNonDeliveryType).flatMap((n=>({label:i(`customs.nonDelivery.${e(n)}`),value:n})))),[i])},de=()=>{const{t:e}=s(),i=n((()=>W()),[]),l=n((()=>[{label:e("wallet-history:historyOptions.custom"),range:void 0,value:"custom"},{label:e("wallet-history:historyOptions.last30days"),range:[i.thirtyDaysAgo,i.origin],value:"last30days"},{label:e("wallet-history:historyOptions.thisMonth"),range:[i.firstDayOfMonth,i.lastDayOfTheMonth],value:"thisMonth"},{label:e("wallet-history:historyOptions.lastMonth"),range:[i.previousMonthFirstDay,i.previousMonthLastDay],value:"lastMonth"}]),[i,e]);return[l,T(l,(e=>({[e.value]:e})))]},te=()=>{const{globalFeatures:{enableParcelGuard:e}}=E(),{data:i,refetch:l}=a({enabled:e});return{fundingSourceInsuranceProvider:n((()=>{var n;let l;return null===(n=null==i?void 0:i.acceptedTerms)||void 0===n||n.forEach((n=>{e&&"parcelguard_terms"===n.termType&&(l="parcelguard")})),l}),[i,e]),refetchInsuranceAcceptedTerms:l}},ue=()=>{const{globalFeatures:{enableParcelGuard:e}}=E(),{data:l,isLoading:r}=c(),s=d(),{data:o,isLoading:u}=a({enabled:e}),g=n((()=>{var e;return null===(e=null==s?void 0:s.data)||void 0===e?void 0:e.defaultFundingSourceProfile.optionalTerms.map((e=>{const n={parcelguard_terms:"parcelguard"}[e.termType];return{friendlyName:{parcelguard_terms:"ParcelGuard"}[e.termType],provider:n,terms:e}}))}),[s]),{mutateAsync:p}=t(),b=i((()=>N(void 0,void 0,void 0,(function*(){var e,n;if(!l||!g)return{isSuccessful:!1};try{return(null===(n=(yield p({insuranceProviders:[{acceptedTerms:null==g?void 0:g.flatMap((e=>e.terms)).map((e=>({termType:e.termType,version:e.version}))),agreeToTerms:!0,fundingSourceId:null===(e=null==l?void 0:l[0])||void 0===e?void 0:e.fundingSourceId,provider:g[0].provider}]})).insuranceProviderAttachmentResults)||void 0===n?void 0:n[0].isSuccessful)?{isSuccessful:!0}:{isSuccessful:!1}}catch(e){return console.error(e),{isSuccessful:!1}}}))),[l,g,p]);return{hasInsuranceToRegister:n((()=>e&&!!(null==g?void 0:g.length)&&0===(null==o?void 0:o.acceptedTerms.length)&&!!(null==l?void 0:l.length)),[e,null==g?void 0:g.length,null==o?void 0:o.acceptedTerms.length,null==l?void 0:l.length]),insuranceAcceptedTerms:null==o?void 0:o.acceptedTerms,insuranceProviderProfiles:g,loading:r||u,registerInsuranceProvider:b}},ge=(i,l)=>{const{t:r}=s("common"),{globalFeatures:a}=E(),{fundingSourceInsuranceProvider:c,refetchInsuranceAcceptedTerms:d}=te(),t=n((()=>Object.values(o.InsuranceProviderType).flatMap((n=>"none"===n||"funding_source"===n||"parcelguard"===n&&(n!==c||!a.enableParcelGuard)||"x_cover"===n&&n!==c||"carrier"===n&&!(null==l?void 0:l.includeCarrierInsurance)||"third_party"===n&&!(null==l?void 0:l.includeThirdPartyInsurance)||"shipsurance"===n&&(!(null==i?void 0:i.amount)||!(null==l?void 0:l.includeShipsuranceInsurance))?[]:{label:r(`insuranceProviders.${e(n)}`),value:n}))),[c,a.enableParcelGuard,l,null==i?void 0:i.amount,r]);return{fundingSourceInsuranceProvider:c,insuranceProviderOptions:t,refetchInsuranceAcceptedTerms:d}},pe=()=>{const{t:e}=s("purchase-label");return n((()=>Object.values(o.MovementIndicator).flatMap((n=>({label:e(`windsorFramework.movementIndicators.${n}`),value:n})))),[e])},be=(e,n)=>{if(T(e,((e,n)=>({[e.carrierCode]:void 0===n[e.carrierCode]})))[n.carrierCode])return n.friendlyName;const i=((e,n)=>e.filter((e=>e.carrierCode===n.carrierCode)).reduce(((e,n)=>(e[n.nickname]=void 0===e[n.nickname],e)),{}))(e,n)[n.nickname];return n.nickname&&i?`${n.friendlyName} - ${n.nickname}`:`${n.friendlyName} - (${n.carrierId})`},me=e=>{const i=n((()=>!!e&&k(e)),[e]),l=n((()=>(null==e?void 0:e.shipTo)&&x(e.shipTo)),[null==e?void 0:e.shipTo]),r=n((()=>(null==e?void 0:e.shipTo)&&A(e.shipTo)),[null==e?void 0:e.shipTo]),s=n((()=>!!e&&R(e)),[e]),o=n((()=>{var n;return e&&"MX"===(null===(n=e.shipFrom)||void 0===n?void 0:n.countryCode)||"MX"===(null==e?void 0:e.shipTo.countryCode)}),[e]),a=n((()=>{var n,i;return"CA"===(null===(n=null==e?void 0:e.shipTo)||void 0===n?void 0:n.countryCode)&&"US"===(null===(i=null==e?void 0:e.shipFrom)||void 0===i?void 0:i.countryCode)}),[e]),c=n((()=>{const n=null==e?void 0:e.packages[0].dimensions,i=null==e?void 0:e.packages[0].weight;return{hasAllZeroMeasurements:[null==n?void 0:n.height,null==n?void 0:n.length,null==n?void 0:n.width,null==i?void 0:i.value].every((e=>0===e))}}),[e]);return Object.assign({isCanadaDeliveredDutyEligible:a,isContentDescriptionRequired:o,isCustomsRequired:s,isInternational:i,isPoBox:l,isUnsupportedUpsCountry:r},c)};let Ie,ve=e=>e;const he=(e,i,l)=>{const{t:r}=s("common"),{isPoBox:o,isUnsupportedUpsCountry:a}=me(l);return n((()=>{if(!e)return;const n=(e=>{const n=e.find((e=>e.packages.some((e=>"package"===e.packageCode))));return null==n?void 0:n.packages.find((e=>"package"===e.packageCode))})(e),l=n?[{label:r("packageCodes.package"),value:{code:"package"}}]:[],s=[{label:r(Ie||(Ie=ve`packageCategories.customPackages`)),options:[...l,...i?i.sort(((e,n)=>e.name.localeCompare(n.name))).map((({dimensions:e,name:n,packageId:i,packageCode:l})=>({label:`${n}${e?` - ${O(e)}`:""}`,value:{code:l,packageId:i}}))):[]]}];return e.reduce(((n,i)=>0===i.packages.length||!B(i.carrierCode)&&o||H(i.carrierCode)&&a?n:[...n,{label:be(e,i),options:i.packages.filter((e=>!["cubic","letter","package","regional_rate_box_a","regional_rate_box_b"].includes(e.packageCode))).sort(((e,n)=>e.name.localeCompare(n.name))).map((e=>({label:e.name,value:{carrierId:i.carrierId,code:e.packageCode}}))),value:i.carrierId}]),s)}),[e,i,o,a,r])},ye=(e,i)=>{const l=n((()=>{var n,i;return null===(i=null===(n=null==e?void 0:e.advancedOptions)||void 0===n?void 0:n.windsorFrameworkDetails)||void 0===i?void 0:i.movementIndicator}),[e]),r=n((()=>{var n,i;if(!e)return!1;const l=null===(n=e.shipFrom)||void 0===n?void 0:n.countryCode,r=e.shipTo.countryCode,s=null===(i=e.shipFrom)||void 0===i?void 0:i.postalCode.includes("BT"),o=e.shipTo.postalCode.includes("BT");return"GB"===l&&"GB"===r&&o&&!s}),[e]),s=n((()=>{var n;const l=null===(n=null==e?void 0:e.advancedOptions)||void 0===n?void 0:n.windsorFrameworkDetails;if(!l||!i)return{isInvalid:!1};const{movementIndicator:r}=l;if("b2b"===r){const n=e.taxIdentifiers;if(!n)return{isInvalid:!0,messages:["shipperEori","recipientEori","ukims"]};const i=n.reduce(((e,n)=>{switch(n.identifierType){case"eori":e[`${n.taxableEntityType}Eori`]=!0;break;case"ukims":e.ukims=!0}return e}),{recipientEori:!1,shipperEori:!1,ukims:!1}),l=[];return i.shipperEori||l.push("shipperEori"),i.recipientEori||l.push("recipientEori"),i.ukims||l.push("ukims"),0===l.length?{isInvalid:!1}:{isInvalid:!0,messages:l}}return{isInvalid:!1}}),[i,e]);return{isWindsorFrameworkInvalid:s,movementIndicator:l,requiresWindsorFramework:r&&i}};var Ze;!function(e){e.PICKUP="pick_up",e.DROPOFF="drop_off"}(Ze||(Ze={}));const Xe=(e,l,r,o,a,c,d)=>{var t;const{t:u}=s(),g=n((()=>T(r,(e=>({[e.carrierId]:e})))),[r]),{isInternational:p,isPoBox:b,isUnsupportedUpsCountry:m}=me(o),{requiresWindsorFramework:I,movementIndicator:v}=ye(o,d),h=n((()=>{var e;return(null===(e=null==o?void 0:o.advancedOptions)||void 0===e?void 0:e.canadaDeliveredDuty)===K.SENDER_PREPAY}),[null===(t=null==o?void 0:o.advancedOptions)||void 0===t?void 0:t.canadaDeliveredDuty]),y=i((e=>(B(e)||!h)&&(B(e)||!b)&&(!H(e)||!m)&&(!w(e)||!(I&&"b2b"===v))&&(!F(e)||!(I&&"b2b"===v))),[b,m,v,I,h]),Z=n((()=>(null!=l?l:[]).filter((e=>y(e.rate.carrierCode))).map((e=>Object.assign(Object.assign({},e.rate),{balance:void 0,messages:e.rate.warningMessages,rateAcknowledgementMessage:e.rateAcknowledgementMessage,requiresAcknowledgement:!!e.rateAcknowledgementMessage,requiresFundedAmount:!1})))),[l,y]),X=u("purchase-label:rates.noRateService"),G=n((()=>(null!=e?e:[]).filter((e=>{const n=g[e.carrierId],i=null==n?void 0:n.services.find((n=>n.serviceCode===e.serviceCode));return y(e.carrierCode)&&(null==i?void 0:i.domestic)===!p})).map((e=>{var n,i;const l=null===(n=g[e.carrierId])||void 0===n?void 0:n.balance,r=null===(i=g[e.carrierId])||void 0===i?void 0:i.requiresFundedAmount,s=Object.assign(Object.assign({},e),{balance:l,messages:e.warningMessages,requiresAcknowledgement:V(e.serviceCode,e.packageType,!!c),requiresFundedAmount:r});return 0!==e.shippingAmount.amount||e.warningMessages.includes(X)||s.messages.push(X),Y(e)?j(e.carrierCode,e.serviceCode)?Object.assign(Object.assign({},s),{pudoType:Ze.PICKUP}):Object.assign(Object.assign({},s),{pudoType:Ze.DROPOFF,servicePoints:null==a?void 0:a.filter((n=>{const i=n.carrierCode===e.carrierCode,l=n.serviceCodes.includes(e.serviceCode);if("dpdwallet"===n.carrierCode)return i&&l;const r=!n.features||0===n.features.length||n.features.includes("drop_off_point");return i&&l&&r}))}):s}))),[g,p,e,c,y,a,X]);return n((()=>[...Z,...G].sort(((e,n)=>0===e.shippingAmount.amount&&0===n.shippingAmount.amount?e.deliveryDays-n.deliveryDays:0===e.shippingAmount.amount?1:0===n.shippingAmount.amount?-1:S(e)-S(n)))),[Z,G])},Ge=(e,i,l)=>{const{isInternational:r,isPoBox:s,isUnsupportedUpsCountry:o}=me(i);return n((()=>(null!=e?e:[]).reduce(((n,i)=>{if(!B(i.carrierCode)&&s||H(i.carrierCode)&&o)return n;const a=i.services.filter((e=>e.domestic===!r&&!U(e,l)));if(0===a.length)return n;const c=$(a,"name","asc");return[...n,{label:be(e||[],i),options:c.map((e=>({label:e.name,value:{carrierId:i.carrierId,serviceCode:e.serviceCode}}))),value:i.carrierId}]}),[])),[e,s,o,r,l])},Ce=e=>le({display:"flex",flexDirection:"column",height:"100%",paddingTop:e.spacing(.5),width:"max-content"},"production"===process.env.NODE_ENV?"":";label:getContainerStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDNkMiLCJmaWxlIjoicHJlc2V0LWRlc2NyaXB0b3Iuc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL3JlYWN0XCI7XHJcbmV4cG9ydCBjb25zdCBnZXRDb250YWluZXJTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBkaXNwbGF5OiBcImZsZXhcIixcclxuICAgIGZsZXhEaXJlY3Rpb246IFwiY29sdW1uXCIsXHJcbiAgICBoZWlnaHQ6IFwiMTAwJVwiLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygwLjUpLFxyXG4gICAgd2lkdGg6IFwibWF4LWNvbnRlbnRcIixcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXREaW1lbnNpb25TdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBjb2xvcjogdGhlbWUucGFsZXR0ZS5ncmF5Lm1haW4sXHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXRTZXJ2aWNlTmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhYUyxcclxuICAgIGxpbmVIZWlnaHQ6IDAsXHJcbiAgICBwYWRkaW5nVG9wOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0UHJlc2V0TmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhTLFxyXG4gICAgZm9udFdlaWdodDogdGhlbWUudHlwb2dyYXBoeS5mb250V2VpZ2h0LmJvbGQsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0V2FybmluZ1N0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGJhY2tncm91bmQ6IFwibm9uZVwiLFxyXG4gICAgbWFyZ2luTGVmdDogXCJhdXRvXCIsXHJcbiAgICBtYXJnaW5SaWdodDogdGhlbWUuc3BhY2luZygtMyksXHJcbiAgICBtYXJnaW5Ub3A6IHRoZW1lLnNwYWNpbmcoLTUpLFxyXG4gICAgd2lkdGg6IHRoZW1lLnNwYWNpbmcoKSxcclxufSk7XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy5qcy5tYXAiXX0= */"),We=e=>le({color:e.palette.gray.main,fontSize:e.typography.fontSize.XS},"production"===process.env.NODE_ENV?"":";label:getDimensionStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFRNkMiLCJmaWxlIjoicHJlc2V0LWRlc2NyaXB0b3Iuc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL3JlYWN0XCI7XHJcbmV4cG9ydCBjb25zdCBnZXRDb250YWluZXJTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBkaXNwbGF5OiBcImZsZXhcIixcclxuICAgIGZsZXhEaXJlY3Rpb246IFwiY29sdW1uXCIsXHJcbiAgICBoZWlnaHQ6IFwiMTAwJVwiLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygwLjUpLFxyXG4gICAgd2lkdGg6IFwibWF4LWNvbnRlbnRcIixcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXREaW1lbnNpb25TdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBjb2xvcjogdGhlbWUucGFsZXR0ZS5ncmF5Lm1haW4sXHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXRTZXJ2aWNlTmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhYUyxcclxuICAgIGxpbmVIZWlnaHQ6IDAsXHJcbiAgICBwYWRkaW5nVG9wOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0UHJlc2V0TmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhTLFxyXG4gICAgZm9udFdlaWdodDogdGhlbWUudHlwb2dyYXBoeS5mb250V2VpZ2h0LmJvbGQsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0V2FybmluZ1N0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGJhY2tncm91bmQ6IFwibm9uZVwiLFxyXG4gICAgbWFyZ2luTGVmdDogXCJhdXRvXCIsXHJcbiAgICBtYXJnaW5SaWdodDogdGhlbWUuc3BhY2luZygtMyksXHJcbiAgICBtYXJnaW5Ub3A6IHRoZW1lLnNwYWNpbmcoLTUpLFxyXG4gICAgd2lkdGg6IHRoZW1lLnNwYWNpbmcoKSxcclxufSk7XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy5qcy5tYXAiXX0= */"),Ne=e=>le({fontSize:e.typography.fontSize.XXS,lineHeight:0,paddingTop:e.spacing()},"production"===process.env.NODE_ENV?"":";label:getServiceNameStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFZK0MiLCJmaWxlIjoicHJlc2V0LWRlc2NyaXB0b3Iuc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL3JlYWN0XCI7XHJcbmV4cG9ydCBjb25zdCBnZXRDb250YWluZXJTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBkaXNwbGF5OiBcImZsZXhcIixcclxuICAgIGZsZXhEaXJlY3Rpb246IFwiY29sdW1uXCIsXHJcbiAgICBoZWlnaHQ6IFwiMTAwJVwiLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygwLjUpLFxyXG4gICAgd2lkdGg6IFwibWF4LWNvbnRlbnRcIixcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXREaW1lbnNpb25TdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBjb2xvcjogdGhlbWUucGFsZXR0ZS5ncmF5Lm1haW4sXHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxufSk7XHJcbmV4cG9ydCBjb25zdCBnZXRTZXJ2aWNlTmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhYUyxcclxuICAgIGxpbmVIZWlnaHQ6IDAsXHJcbiAgICBwYWRkaW5nVG9wOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0UHJlc2V0TmFtZVN0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGZvbnRTaXplOiB0aGVtZS50eXBvZ3JhcGh5LmZvbnRTaXplLlhTLFxyXG4gICAgZm9udFdlaWdodDogdGhlbWUudHlwb2dyYXBoeS5mb250V2VpZ2h0LmJvbGQsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0V2FybmluZ1N0eWxlcyA9ICh0aGVtZSkgPT4gY3NzKHtcclxuICAgIGJhY2tncm91bmQ6IFwibm9uZVwiLFxyXG4gICAgbWFyZ2luTGVmdDogXCJhdXRvXCIsXHJcbiAgICBtYXJnaW5SaWdodDogdGhlbWUuc3BhY2luZygtMyksXHJcbiAgICBtYXJnaW5Ub3A6IHRoZW1lLnNwYWNpbmcoLTUpLFxyXG4gICAgd2lkdGg6IHRoZW1lLnNwYWNpbmcoKSxcclxufSk7XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy5qcy5tYXAiXX0= */"),xe=e=>le({fontSize:e.typography.fontSize.XS,fontWeight:e.typography.fontWeight.bold},"production"===process.env.NODE_ENV?"":";label:getPresetNameStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpQjhDIiwiZmlsZSI6InByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gXCJAZW1vdGlvbi9yZWFjdFwiO1xyXG5leHBvcnQgY29uc3QgZ2V0Q29udGFpbmVyU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgZGlzcGxheTogXCJmbGV4XCIsXHJcbiAgICBmbGV4RGlyZWN0aW9uOiBcImNvbHVtblwiLFxyXG4gICAgaGVpZ2h0OiBcIjEwMCVcIixcclxuICAgIHBhZGRpbmdUb3A6IHRoZW1lLnNwYWNpbmcoMC41KSxcclxuICAgIHdpZHRoOiBcIm1heC1jb250ZW50XCIsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0RGltZW5zaW9uU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgY29sb3I6IHRoZW1lLnBhbGV0dGUuZ3JheS5tYWluLFxyXG4gICAgZm9udFNpemU6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFNpemUuWFMsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0U2VydmljZU5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YWFMsXHJcbiAgICBsaW5lSGVpZ2h0OiAwLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygpLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFByZXNldE5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxuICAgIGZvbnRXZWlnaHQ6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFdlaWdodC5ib2xkLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFdhcm5pbmdTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBiYWNrZ3JvdW5kOiBcIm5vbmVcIixcclxuICAgIG1hcmdpbkxlZnQ6IFwiYXV0b1wiLFxyXG4gICAgbWFyZ2luUmlnaHQ6IHRoZW1lLnNwYWNpbmcoLTMpLFxyXG4gICAgbWFyZ2luVG9wOiB0aGVtZS5zcGFjaW5nKC01KSxcclxuICAgIHdpZHRoOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1wcmVzZXQtZGVzY3JpcHRvci5zdHlsZXMuanMubWFwIl19 */"),Ae=e=>le({background:"none",marginLeft:"auto",marginRight:e.spacing(-3),marginTop:e.spacing(-5),width:e.spacing()},"production"===process.env.NODE_ENV?"":";label:getWarningStyles;","production"===process.env.NODE_ENV?"":"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFxQjJDIiwiZmlsZSI6InByZXNldC1kZXNjcmlwdG9yLnN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gXCJAZW1vdGlvbi9yZWFjdFwiO1xyXG5leHBvcnQgY29uc3QgZ2V0Q29udGFpbmVyU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgZGlzcGxheTogXCJmbGV4XCIsXHJcbiAgICBmbGV4RGlyZWN0aW9uOiBcImNvbHVtblwiLFxyXG4gICAgaGVpZ2h0OiBcIjEwMCVcIixcclxuICAgIHBhZGRpbmdUb3A6IHRoZW1lLnNwYWNpbmcoMC41KSxcclxuICAgIHdpZHRoOiBcIm1heC1jb250ZW50XCIsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0RGltZW5zaW9uU3R5bGVzID0gKHRoZW1lKSA9PiBjc3Moe1xyXG4gICAgY29sb3I6IHRoZW1lLnBhbGV0dGUuZ3JheS5tYWluLFxyXG4gICAgZm9udFNpemU6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFNpemUuWFMsXHJcbn0pO1xyXG5leHBvcnQgY29uc3QgZ2V0U2VydmljZU5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YWFMsXHJcbiAgICBsaW5lSGVpZ2h0OiAwLFxyXG4gICAgcGFkZGluZ1RvcDogdGhlbWUuc3BhY2luZygpLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFByZXNldE5hbWVTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBmb250U2l6ZTogdGhlbWUudHlwb2dyYXBoeS5mb250U2l6ZS5YUyxcclxuICAgIGZvbnRXZWlnaHQ6IHRoZW1lLnR5cG9ncmFwaHkuZm9udFdlaWdodC5ib2xkLFxyXG59KTtcclxuZXhwb3J0IGNvbnN0IGdldFdhcm5pbmdTdHlsZXMgPSAodGhlbWUpID0+IGNzcyh7XHJcbiAgICBiYWNrZ3JvdW5kOiBcIm5vbmVcIixcclxuICAgIG1hcmdpbkxlZnQ6IFwiYXV0b1wiLFxyXG4gICAgbWFyZ2luUmlnaHQ6IHRoZW1lLnNwYWNpbmcoLTMpLFxyXG4gICAgbWFyZ2luVG9wOiB0aGVtZS5zcGFjaW5nKC01KSxcclxuICAgIHdpZHRoOiB0aGVtZS5zcGFjaW5nKCksXHJcbn0pO1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1wcmVzZXQtZGVzY3JpcHRvci5zdHlsZXMuanMubWFwIl19 */"),Be=e=>{const{t:n}=s();return q("div",Object.assign({css:Ce},{children:ee("div",{children:[ee("div",{children:[q("span",Object.assign({css:xe},{children:e.name})),q("span",Object.assign({css:We},{children:(e.dimensions||e.weight)&&" - "})),e.dimensions&&q("span",Object.assign({css:We},{children:`${O(e.dimensions)} `+n(`units.${e.dimensions.unit}`)}))]}),q("div",Object.assign({css:Ne},{children:e.serviceName&&e.serviceName})),e.serviceName&&["USPS Parcel Select Ground","USPS First Class Mail"].includes(e.serviceName)&&q(ne,{css:Ae,type:ie.ALERT})]})}))},He=(e,n)=>n?[{categoryName:e,options:n.map((e=>({description:q(Be,Object.assign({},e)),displayName:e.name,value:e})))}]:[],we=({platform:e,user:i}={},l)=>{const{t:r}=s(),{isInternational:o}=me(l);return n((()=>[...He(r("shippingPresets.user"),o?null==i?void 0:i.international:null==i?void 0:i.domestic),...He(r("shippingPresets.platform"),o?null==e?void 0:e.international:null==e?void 0:e.domestic)]),[o,e,r,i])},Fe=(e,i,l)=>n((()=>{var n,r,s,o,a;if(!e&&!i&&!l)return;const c=!!(null==l?void 0:l.warehouseId),d=J(l,i),t={label:null!==(r=null===(n=null==l?void 0:l.shipFrom)||void 0===n?void 0:n.addressLine1)&&void 0!==r?r:"",subLabel:`${L(null!==(o=null===(s=null==l?void 0:l.shipFrom)||void 0===s?void 0:s.cityLocality)&&void 0!==o?o:"")}, ${null===(a=null==l?void 0:l.shipFrom)||void 0===a?void 0:a.stateProvince} `,value:"custom-shipment-address"},u=null==e?void 0:e.map((e=>({label:e.name,subLabel:`${L(e.originAddress.addressLine1)}. ${L(e.originAddress.cityLocality)}, ${e.originAddress.stateProvince} `,value:e.warehouseId}))),g=null==i?void 0:i.map((e=>{var n;return{label:null!==(n=e.name)&&void 0!==n?n:e.originAddress.addressLine1,subLabel:e.name?`${L(e.originAddress.addressLine1)}. ${L(e.originAddress.cityLocality)}, ${e.originAddress.stateProvince} `:`${L(e.originAddress.cityLocality)}, ${e.originAddress.stateProvince} `,value:e.addressId}}));return[...c||d?[]:[{label:"Shipment Address",options:[t]}],...(null==g?void 0:g.length)||(null==u?void 0:u.length)?[{label:"Saved Ship From Locations",options:[...null!=g?g:[],...null!=u?u:[]]}]:[]]}),[i,l,e]),Ve=(e,s)=>{var o;const[a,c]=l(null===(o=null==s?void 0:s.shipFrom)||void 0===o?void 0:o.postalCode),d=n((()=>({addressQuery:a,maxResults:50,providers:[]})),[a]),t=n((()=>{const n=(null==e?void 0:e.filter((e=>Y(e))))||[],i=Array.from(new Set(n.map((e=>e.carrierId)))).map((e=>({carrierId:e,serviceCode:n.filter((n=>n.carrierId===e)).map((e=>e.serviceCode))})));return Object.assign(Object.assign({},d),{providers:i})}),[e,d]),[g,p]=l();r((()=>{t.providers.length>0&&p(t)}),[t]);const{data:b,isFetching:m,error:I}=u(null!=g?g:d);return{fetchServicePoints:i((e=>{c(e)}),[]),listServicePointsErrors:I,nestedServicePointErrors:null==b?void 0:b.errors,servicePointSearchQuery:a,servicePointsFetching:m,servicePointsResponse:b}},Se=({onSuccess:e,onError:n})=>{r((()=>{window.io_install_stm=!1,window.io_exclude_stm=12,window.io_install_flash=!1,window.io_enable_rip=!0;const i=setInterval((()=>{try{if("function"!=typeof ioGetBlackbox)return;const n=ioGetBlackbox();n.finished&&(clearTimeout(i),e(n.blackbox))}catch(e){n()}}),500),l=document.createElement("script");return l.type="text/javascript",l.async=!0,l.src="https://mpsnare.iesnare.com/snare.js",l.addEventListener("error",(e=>{"function"!=typeof ioGetBlackbox&&n()})),document.head.appendChild(l),()=>{i&&clearTimeout(i),delete window.io_install_stm,delete window.io_exclude_stm,delete window.io_install_flash,delete window.io_enable_rip,document.head.removeChild(l)}}),[e,n])},Je=({scrubber:e,errors:i,predicate:l})=>{const{t:r}=s();return n((()=>null==i?void 0:i.map((n=>r(re(n.message),{defaultValue:!l||l(n)?r(e(n)):Le(n)})))),[i,l,e,r])},Le=e=>e.message.replaceAll(/Invalid rate\. Invalid rate\./g,"Invalid rate."),fe=({enabled:e,externalOrderId:n,externalOrderNumber:i,orderSourceCode:s,salesOrderId:o})=>{const[a,c]=l(!1),{data:d,error:t,isFetching:u,isInitialLoading:I,refetch:v}=g({externalOrderId:n,externalOrderNumber:i}),{data:h,error:y,isFetching:Z,isInitialLoading:X,refetch:G}=p(null!=o?o:d&&d[0]?d[0].salesOrderId:void 0),{data:C,error:W}=b({enabled:e}),{data:x,error:A,isLoading:B,mutateAsync:H}=m();r((()=>{N(void 0,void 0,void 0,(function*(){const n=s?null==C?void 0:C.filter((e=>e.orderSourceCode.includes(s)&&e.active)):C;!e||!n||h||Z||u||a||(yield Promise.all(n.map((e=>H(e.orderSourceId)))),yield o?G():v(),c(!0))}))}),[e,a,Z,u,s,C,G,v,H,x,h,o]);const w=[...null!=W?W:[],...null!=t?t:[],...null!=y?y:[],...null!=A?A:[]];return{errors:w.length>0?w:void 0,isLoading:X||I||B||!a&&!h&&0===(null==d?void 0:d.length)&&0===w.length,salesOrder:h}},Te=({onShipmentUpdated:e,onLoad:l,errorWhenShipmentCancelled:s=!1,externalOrderId:o,externalOrderNumber:a,externalShipmentId:c,orderSourceCode:d,salesOrderId:t,shipFromAddresses:u,shipmentId:g,warehouseId:p,useWarehouses:b=!0})=>{const m=se(),W=n((()=>[]),[]),{data:x,isInitialLoading:A,isFetching:B}=I(),{data:H,error:w,isInitialLoading:F,isFetching:V}=v({enabled:b}),{salesOrder:S,errors:J,isLoading:L}=fe({enabled:!!(a||d||t||o),externalOrderId:o,externalOrderNumber:a,orderSourceCode:d,salesOrderId:t}),{error:T,mutate:k}=h(),{data:R,mutateAsync:O,isLoading:Y,isSuccess:j,error:U}=y(),{data:E,error:K,isInitialLoading:$,isFetching:q}=Z({enabled:!!c&&!g,queryFnParams:{externalId:null!=c?c:""}}),{data:ee,error:ne,refetch:ie,isInitialLoading:le,isFetching:re}=X({salesOrderIds:t?[t]:S?[S.salesOrderId]:void 0,shipmentIds:g?[g]:E?[E.shipmentId]:R?[R.shipments[0].shipmentId]:void 0}),{error:oe,mutateAsync:ae,isLoading:ce,isSuccess:de}=G(),te=z("pending",ee),ue=z("label_purchased",ee),ge=z("cancelled",ee),pe=P(H),be=f(u),me=i((()=>N(void 0,void 0,void 0,(function*(){var e,n,i;if(le||re||q||$||ce||de||Y||j||F||V||te||ue)return;const l=!(null==u?void 0:u.length),r=!(null==H?void 0:H.length);if(b||!l)if(l&&r&&!p)W.push("no_warehouses");else{if(S){const l=null!==(i=null!==(e=null==be?void 0:be.originAddress)&&void 0!==e?e:null===(n=M(p,H))||void 0===n?void 0:n.originAddress)&&void 0!==i?i:null==pe?void 0:pe.originAddress,r=_(S,l),s=Q(S,l);(yield ae(Object.assign(Object.assign(Object.assign({salesOrderId:S.salesOrderId},(null==be?void 0:be.originAddress)?{shipFrom:be.originAddress}:{warehouseId:p||(null==pe?void 0:pe.warehouseId)}),r&&{customs:s.customs}),{packages:[Object.assign(Object.assign({packageCode:"package"},r&&{products:s.products}),{weight:{unit:"pound",value:0}})]})))&&(yield ie())}if(!(t||o||a||d||g||c)){(yield O(Object.assign({},(null==be?void 0:be.originAddress)?{shipFrom:be.originAddress}:{warehouseId:p||pe.warehouseId})))&&(yield ie())}}else W.push("no_warehouses")}))),[ae,O,ce,Y,be,pe,o,a,c,W,q,$,V,F,ue,le,re,d,te,ie,S,t,de,null==u?void 0:u.length,g,b,j,p,H]),Ie=i((n=>{const i=D(n);k(i,{onSuccess(n){null==e||e(n),m.invalidateQueries(["useListSalesOrderShipments",{shipmentId:n.shipmentId}],{exact:!1})}})}),[e,m,k]),ve=i((()=>N(void 0,void 0,void 0,(function*(){const{data:e}=yield ie();return z("pending",e)}))),[ie]);r((()=>{N(void 0,void 0,void 0,(function*(){yield me()}))}),[g,c,t,S,H,p,me]),r((()=>{var e,n;(null===(n=null===(e=null==te?void 0:te.customs)||void 0===e?void 0:e.customsItems)||void 0===n?void 0:n.length)&&Ie(te)}),[Ie,te]),r((()=>{(null==ee?void 0:ee.length)&&ee.every((e=>"label_purchased"===e.shipmentStatus))&&(null==l||l(ee,S,te))}),[l,te,S,ee]),r((()=>{A||B||0===(null==x?void 0:x.length)&&W.push("no_carriers")}),[x,W,B,A]);const he=[...null!=w?w:[],...null!=oe?oe:[],...null!=U?U:[],...null!=ne?ne:[],...null!=K?K:[],...null!=J?J:[],...null!=T?T:[],...s&&ge?[new C("shipment_cancelled",{errorCode:"invalid_status",errorSource:"elements",errorType:"business_rules"})]:[],...ue?[new C("label_purchased",{errorCode:"invalid_status",errorSource:"elements",errorType:"business_rules"})]:[],...W.length>0?[new C(W.length>1?"no_carriers_and_warehouses":W[0],{errorCode:"unknown",errorSource:"elements",errorType:"business_rules"})]:[]];return{carriers:x,errors:he.length>0?he:void 0,isLoading:(L||!(null==ee?void 0:ee.length)||ce)&&0===he.length,refetchPendingSalesOrderShipments:ve,salesOrder:S,shipment:null!=te?te:ue,warehouses:H}};export{Ze as P,ae as a,ce as b,de as c,ge as d,pe as e,he as f,Xe as g,Ge as h,me as i,we as j,Fe as k,Ve as l,ye as m,te as n,ue as o,Se as p,Je as q,Te as r,fe as s,oe as u};