@shipengine/elements 2.17.0 → 2.19.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/actions-menu.js +5 -5
- package/components.js +1 -1
- package/elements.js +1 -1
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/package.json +4 -12
- package/src/components/add-funds-form/add-funds-form.d.ts +3 -9
- package/src/components/button-group/button-group.d.ts +4 -1
- package/src/components/date-range-combo/date-range-combo.d.ts +1 -1
- package/src/components/field/select/select-with-categories.d.ts +1 -0
- package/src/components/fund-and-purchase/fund-and-purchase.d.ts +6 -7
- package/src/components/grid-controller/grid-controller.d.ts +6 -2
- package/src/components/grid-controller/index.d.ts +1 -0
- package/src/components/grid-controller/sortable-header.d.ts +20 -0
- package/src/components/grid-filters/components/index.d.ts +1 -0
- package/src/components/grid-filters/components/tracking-status-filter/index.d.ts +1 -0
- package/src/components/grid-filters/components/tracking-status-filter/tracking-status-filter-schema.d.ts +21 -0
- package/src/components/grid-filters/components/tracking-status-filter/tracking-status-filter.d.ts +23 -0
- package/src/components/grid-filters/components/tracking-status-filter/tracking-status-filter.styles.d.ts +13 -0
- package/src/components/grid-filters/grid-filters.d.ts +4 -1
- package/src/components/history/history-card/history-card.styles.d.ts +1 -1
- package/src/components/ship-from-address-form/ship-from-address-form.d.ts +2 -1
- package/src/components/templates/connect-external-carrier-form/connect-external-carrier-form.d.ts +3 -1
- package/src/components/templates/connect-external-carrier-form/custom-forms/custom-external-carrier-form.d.ts +10 -0
- package/src/components/templates/connect-external-carrier-form/custom-forms/custom-form-fedex.d.ts +6 -0
- package/src/components/templates/connect-external-carrier-form/custom-forms/eula-clickwrap.d.ts +11 -0
- package/src/components/templates/connect-external-carrier-form/custom-forms/eula-clickwrap.styles.d.ts +20 -0
- package/src/components/templates/connect-external-carrier-form/custom-forms/index.d.ts +1 -0
- package/src/components/templates/connect-external-carrier-form/index.d.ts +1 -0
- package/src/components/templates/rate-form/rate-form.d.ts +4 -2
- package/src/components/templates/shipment-form/shipment-form.d.ts +2 -1
- package/src/components/templates/theme-creator/theme-creator.d.ts +3 -2
- package/src/create-element/element/index.d.ts +0 -1
- package/src/elements/labels-grid/hooks/use-labels-grid.d.ts +12 -51
- package/src/elements/labels-grid/labels-grid.d.ts +50 -34
- package/src/elements/manage-carriers/manage-carriers.d.ts +49 -49
- package/src/elements/manage-external-carriers/manage-external-carriers.d.ts +43 -0
- package/src/elements/manage-funding/manage-funding-element.d.ts +24 -2
- package/src/elements/manage-warehouses/manage-warehouses.d.ts +21 -0
- package/src/elements/payment-method-settings/payment-method-settings-element.d.ts +21 -0
- package/src/elements/purchase-label/hooks/use-rates-form.d.ts +1 -0
- package/src/elements/purchase-label/hooks/use-shipment-form.d.ts +4 -4
- package/src/elements/purchase-label/purchase-label.d.ts +26 -5
- package/src/elements/select-label-layout/select-label-layout-element.d.ts +21 -0
- package/src/elements/shipment-summary/shipment-summary.d.ts +31 -36
- package/src/elements/shipments-grid/shipments-grid.d.ts +25 -36
- package/src/elements/theme-creator/theme-creator.d.ts +25 -15
- package/src/elements/transaction-history/transaction-history-element.d.ts +21 -0
- package/src/elements/unit-settings/unit-settings-element.d.ts +21 -0
- package/src/elements/vat-settings/vat-settings-element.d.ts +21 -0
- package/src/elements/void-label/void-label.d.ts +50 -9
- package/src/elements-provider/elements-context-provider.d.ts +2 -2
- package/src/elements-provider/elements-provider.d.ts +1 -2
- package/src/features/manage-carriers/manage-carriers.d.ts +6 -8
- package/src/features/manage-carriers/use-manage-carriers.d.ts +4 -7
- package/src/features/manage-funding/manage-funding.d.ts +4 -9
- package/src/hooks/index.d.ts +1 -0
- package/src/hooks/insurance/use-manage-funding-source-insurance.d.ts +1 -0
- package/src/hooks/options/use-date-range-options.d.ts +4 -1
- package/src/hooks/options/use-rate-options.d.ts +2 -1
- package/src/hooks/use-balance-services.d.ts +22 -0
- package/src/hooks/use-helpers.d.ts +4 -0
- package/src/locales/en/index.d.ts +21 -0
- package/src/utilities/feature-flags/types.d.ts +5 -1
- package/src/utilities/shipengine/address.d.ts +1 -1
- package/src/utilities/storybook-local-storage-config.d.ts +12 -0
- package/src/utilities/validation.d.ts +19 -0
- package/src/workflows/account-settings/account-settings.d.ts +21 -0
- package/src/workflows/carrier-services/carrier-services.d.ts +22 -27
- package/src/workflows/connect-external-carrier/connect-external-carrier.d.ts +31 -24
- package/src/workflows/label-workflow/label-workflow.d.ts +21 -0
- package/src/workflows/onboarding/components/onboarding-wizard/onboarding-wizard.d.ts +2 -1
- package/src/workflows/onboarding/onboarding.d.ts +67 -84
- package/styles.js +1 -0
- package/suspend-text.js +1 -1
- package/transaction-history-element.js +1 -1
- package/use-balance-services.js +1 -0
- package/use-configure-shipment.js +1 -1
- package/use-page-layout.js +1 -1
- package/use-unit-settings.js +1 -1
- package/usePager.js +1 -1
- package/utilities.js +1 -1
- package/validation.js +1 -1
- package/wallet-form.js +1 -1
- package/warehouses.js +1 -1
- package/workflows.js +1 -1
- package/carrier.js +0 -1
- package/src/create-element/element/utils/get-emotion-cache.d.ts +0 -2
- package/src/create-element/element/utils/index.d.ts +0 -1
- package/use-toggle.js +0 -1
|
@@ -14,6 +14,8 @@ export type ComponentProps = {
|
|
|
14
14
|
onComplete: () => void;
|
|
15
15
|
/** Invoked when the final ShipEngine modifications for the seller are complete */
|
|
16
16
|
onSellerOnboarded?: () => void;
|
|
17
|
+
/** If true, the welcome page will be skipped and the Onboarding Element will load on Step 1 */
|
|
18
|
+
skipWelcomePage?: boolean;
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* # Onboarding Component
|
|
@@ -48,7 +50,7 @@ export type ComponentProps = {
|
|
|
48
50
|
*
|
|
49
51
|
* @see {@link Onboarding.Element | The **Element** created to render `<Onboarding />`}
|
|
50
52
|
*/
|
|
51
|
-
export declare const Component: ({ defaultShipFromAddress, onComplete, onSellerOnboarded, }: ComponentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare const Component: ({ defaultShipFromAddress, onComplete, onSellerOnboarded, skipWelcomePage, }: ComponentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
52
54
|
/**
|
|
53
55
|
* # Registered Onboarding Element
|
|
54
56
|
*
|
|
@@ -93,6 +95,9 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
93
95
|
thisMonth: string;
|
|
94
96
|
lastMonth: string;
|
|
95
97
|
};
|
|
98
|
+
category: {
|
|
99
|
+
fundsAdded: string;
|
|
100
|
+
};
|
|
96
101
|
};
|
|
97
102
|
"void-label": {
|
|
98
103
|
title: string;
|
|
@@ -187,40 +192,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
187
192
|
issuingAuthorityPlaceholder: string;
|
|
188
193
|
issuingAuthorityFieldLabel: string;
|
|
189
194
|
vatFormErrors: {
|
|
190
|
-
invalidFieldValue: string;
|
|
191
|
-
/**
|
|
192
|
-
* # Onboarding Component
|
|
193
|
-
*
|
|
194
|
-
* - The `<Onboarding />` component is used to onboard a new user to the ShipEngine platform. This
|
|
195
|
-
* component will allow the user to create a warehouse, register a carrier, and create a funding
|
|
196
|
-
* source for their account. This is everything a user needs to begin fulfilling their shipments
|
|
197
|
-
* using the ShipEngine Platform.
|
|
198
|
-
*
|
|
199
|
-
* @param ComponentProps The base props that will be passed into the `<Onboarding />` component.
|
|
200
|
-
*
|
|
201
|
-
* @returns Element An EmotionJSX.Element that will render the `<Onboarding />` component
|
|
202
|
-
* with all the appropriate wrappers.
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* You can see how the `<Component />` is used in the `createElement` function call below.
|
|
206
|
-
* ```tsx
|
|
207
|
-
* export const Element = createElement(Component, ErrorFallback, {
|
|
208
|
-
* css: {
|
|
209
|
-
* height: "100%",
|
|
210
|
-
* maxWidth: "800px",
|
|
211
|
-
* minWidth: "375px",
|
|
212
|
-
* overflow: "auto",
|
|
213
|
-
* scrollbarGutter: "stable both-edges",
|
|
214
|
-
* width: "100%",
|
|
215
|
-
* },
|
|
216
|
-
* resources: { en },
|
|
217
|
-
* });
|
|
218
|
-
* ```
|
|
219
|
-
*
|
|
220
|
-
* <br />
|
|
221
|
-
*
|
|
222
|
-
* @see {@link Onboarding.Element | The **Element** created to render `<Onboarding />`}
|
|
223
|
-
*/
|
|
195
|
+
invalidFieldValue: string; /** If true, the welcome page will be skipped and the Onboarding Element will load on Step 1 */
|
|
224
196
|
verificationFailure: string;
|
|
225
197
|
forbidden: string;
|
|
226
198
|
connectionNotSupported: string;
|
|
@@ -596,6 +568,39 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
596
568
|
addFunds: {
|
|
597
569
|
custom: string;
|
|
598
570
|
error: {
|
|
571
|
+
/**
|
|
572
|
+
* # Onboarding Component
|
|
573
|
+
*
|
|
574
|
+
* - The `<Onboarding />` component is used to onboard a new user to the ShipEngine platform. This
|
|
575
|
+
* component will allow the user to create a warehouse, register a carrier, and create a funding
|
|
576
|
+
* source for their account. This is everything a user needs to begin fulfilling their shipments
|
|
577
|
+
* using the ShipEngine Platform.
|
|
578
|
+
*
|
|
579
|
+
* @param ComponentProps The base props that will be passed into the `<Onboarding />` component.
|
|
580
|
+
*
|
|
581
|
+
* @returns Element An EmotionJSX.Element that will render the `<Onboarding />` component
|
|
582
|
+
* with all the appropriate wrappers.
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* You can see how the `<Component />` is used in the `createElement` function call below.
|
|
586
|
+
* ```tsx
|
|
587
|
+
* export const Element = createElement(Component, ErrorFallback, {
|
|
588
|
+
* css: {
|
|
589
|
+
* height: "100%",
|
|
590
|
+
* maxWidth: "800px",
|
|
591
|
+
* minWidth: "375px",
|
|
592
|
+
* overflow: "auto",
|
|
593
|
+
* scrollbarGutter: "stable both-edges",
|
|
594
|
+
* width: "100%",
|
|
595
|
+
* },
|
|
596
|
+
* resources: { en },
|
|
597
|
+
* });
|
|
598
|
+
* ```
|
|
599
|
+
*
|
|
600
|
+
* <br />
|
|
601
|
+
*
|
|
602
|
+
* @see {@link Onboarding.Element | The **Element** created to render `<Onboarding />`}
|
|
603
|
+
*/
|
|
599
604
|
title: string;
|
|
600
605
|
message: string;
|
|
601
606
|
};
|
|
@@ -729,8 +734,10 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
729
734
|
trackingStatus: {
|
|
730
735
|
unknown: string;
|
|
731
736
|
inTransit: string;
|
|
737
|
+
in_transit: string;
|
|
732
738
|
delivered: string;
|
|
733
739
|
error: string;
|
|
740
|
+
voided: string;
|
|
734
741
|
};
|
|
735
742
|
actions: {
|
|
736
743
|
title: string;
|
|
@@ -750,17 +757,21 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
750
757
|
connectCarriers: string;
|
|
751
758
|
disconnect: string;
|
|
752
759
|
disconnectCarrier: string;
|
|
760
|
+
downloadEula: string;
|
|
761
|
+
};
|
|
762
|
+
customForms: {
|
|
763
|
+
fedex: {
|
|
764
|
+
eulaName: string;
|
|
765
|
+
disclaimerFooter: string;
|
|
766
|
+
};
|
|
767
|
+
};
|
|
768
|
+
eula: {
|
|
769
|
+
toContinue: string;
|
|
770
|
+
iAgree: string;
|
|
753
771
|
};
|
|
754
|
-
/**
|
|
755
|
-
* # Onboarding Component Props
|
|
756
|
-
*
|
|
757
|
-
* - These are the base props that will be passed into the `<Onboarding />` component.
|
|
758
|
-
*
|
|
759
|
-
* @see {@link Onboarding.Component | This prop types usage in the `<Onboarding />` component}
|
|
760
|
-
*/
|
|
761
772
|
noCarriersDescription: string;
|
|
762
773
|
registrationForm: {
|
|
763
|
-
error: string;
|
|
774
|
+
error: string;
|
|
764
775
|
title: string;
|
|
765
776
|
betaWarning: string;
|
|
766
777
|
};
|
|
@@ -803,48 +814,17 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
803
814
|
address: {
|
|
804
815
|
fields: {
|
|
805
816
|
name: string;
|
|
817
|
+
fullName: string;
|
|
806
818
|
company: string;
|
|
807
819
|
county: string;
|
|
808
820
|
countryCode: string;
|
|
809
821
|
addressLine1: string;
|
|
810
|
-
addressLine2: string;
|
|
811
|
-
cityLocality: string;
|
|
822
|
+
addressLine2: string; /** Invoked when the final ShipEngine modifications for the seller are complete */
|
|
823
|
+
cityLocality: string;
|
|
812
824
|
stateProvince: string;
|
|
813
825
|
postalCode: string;
|
|
814
826
|
phone: string;
|
|
815
|
-
email: string;
|
|
816
|
-
* # Onboarding Component
|
|
817
|
-
*
|
|
818
|
-
* - The `<Onboarding />` component is used to onboard a new user to the ShipEngine platform. This
|
|
819
|
-
* component will allow the user to create a warehouse, register a carrier, and create a funding
|
|
820
|
-
* source for their account. This is everything a user needs to begin fulfilling their shipments
|
|
821
|
-
* using the ShipEngine Platform.
|
|
822
|
-
*
|
|
823
|
-
* @param ComponentProps The base props that will be passed into the `<Onboarding />` component.
|
|
824
|
-
*
|
|
825
|
-
* @returns Element An EmotionJSX.Element that will render the `<Onboarding />` component
|
|
826
|
-
* with all the appropriate wrappers.
|
|
827
|
-
*
|
|
828
|
-
* @example
|
|
829
|
-
* You can see how the `<Component />` is used in the `createElement` function call below.
|
|
830
|
-
* ```tsx
|
|
831
|
-
* export const Element = createElement(Component, ErrorFallback, {
|
|
832
|
-
* css: {
|
|
833
|
-
* height: "100%",
|
|
834
|
-
* maxWidth: "800px",
|
|
835
|
-
* minWidth: "375px",
|
|
836
|
-
* overflow: "auto",
|
|
837
|
-
* scrollbarGutter: "stable both-edges",
|
|
838
|
-
* width: "100%",
|
|
839
|
-
* },
|
|
840
|
-
* resources: { en },
|
|
841
|
-
* });
|
|
842
|
-
* ```
|
|
843
|
-
*
|
|
844
|
-
* <br />
|
|
845
|
-
*
|
|
846
|
-
* @see {@link Onboarding.Element | The **Element** created to render `<Onboarding />`}
|
|
847
|
-
*/
|
|
827
|
+
email: string;
|
|
848
828
|
addressResidentialIndicator: string;
|
|
849
829
|
};
|
|
850
830
|
noResults: string;
|
|
@@ -910,16 +890,15 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
910
890
|
directSignature: string;
|
|
911
891
|
none: string;
|
|
912
892
|
signature: string;
|
|
913
|
-
/**
|
|
914
|
-
* # Onboarding Element Props
|
|
915
|
-
*
|
|
916
|
-
* @see {@link Onboarding.Element | See the full type that `typeof Element` will return}
|
|
917
|
-
*/
|
|
918
893
|
verbalConfirmation: string;
|
|
919
894
|
};
|
|
920
895
|
customs: {
|
|
921
896
|
addDeclaration: string;
|
|
922
|
-
noResults: string;
|
|
897
|
+
noResults: string; /**
|
|
898
|
+
* # Onboarding Element Props
|
|
899
|
+
*
|
|
900
|
+
* @see {@link Onboarding.Element | See the full type that `typeof Element` will return}
|
|
901
|
+
*/
|
|
923
902
|
contents: {
|
|
924
903
|
documents: string;
|
|
925
904
|
gift: string;
|
|
@@ -1002,6 +981,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
1002
981
|
unknown: string;
|
|
1003
982
|
noRatesAvailable: string;
|
|
1004
983
|
refreshAndTryAgain: string;
|
|
984
|
+
updateShipFromAddress: string;
|
|
1005
985
|
windsorFramework: {
|
|
1006
986
|
doNotConform: string;
|
|
1007
987
|
pleaseAddTheFollowingTaxIds: string;
|
|
@@ -1020,6 +1000,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
1020
1000
|
saveRate: string;
|
|
1021
1001
|
security: string;
|
|
1022
1002
|
shipmentStatus: string;
|
|
1003
|
+
shipFromAddress: string;
|
|
1023
1004
|
system: string;
|
|
1024
1005
|
unknown: string;
|
|
1025
1006
|
validation: string;
|
|
@@ -1033,6 +1014,8 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
|
|
|
1033
1014
|
shipmentId: string;
|
|
1034
1015
|
labelId: string;
|
|
1035
1016
|
labelIdFilter: string;
|
|
1017
|
+
filteredTrackingStatus: string;
|
|
1018
|
+
more: string;
|
|
1036
1019
|
createdDate: string;
|
|
1037
1020
|
shipmentIdFilter: string;
|
|
1038
1021
|
createdDateFilter: string;
|
package/styles.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{THEME_ID as t}from"@shipengine/giger";const a=t=>"string"==typeof t,e=t=>t.reduce(((t,a)=>{const e=t.findIndex((t=>{var e,i,r,u;return t.rateDetailType===a.rateDetailType&&(null===(e=t.rateDetailAttributes)||void 0===e?void 0:e.taxPercentage)===(null===(i=a.rateDetailAttributes)||void 0===i?void 0:i.taxPercentage)&&(null===(r=t.rateDetailAttributes)||void 0===r?void 0:r.taxType)===(null===(u=a.rateDetailAttributes)||void 0===u?void 0:u.taxType)}));return e<0?t.push({amount:a.amount.amount,currency:a.amount.currency,rateDetailAttributes:a.rateDetailAttributes,rateDetailType:a.rateDetailType}):t[e].amount+=a.amount.amount,t}),[]),i=t=>t.reduce(((t,a)=>(t.total+=a.amount,t.subtotal+=a.amount,"tax"===a.rateDetailType?(t.hasTax=!0,t.subtotal-=a.amount,t.tax.push(a)):t.items.push(a),t)),{hasTax:!1,items:[],subtotal:0,tax:[],total:0}),r=t=>t,u=a=>a&&t in a?a[t]:a;export{e as a,r as b,i as c,a as i,u as s};
|
package/suspend-text.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{J as e,K as t,M as n,N as a,O as i,Q as o,U as r,X as s,Y as c,Z as l,_ as p,$ as d,G as g,a0 as h,a1 as m,z as u,t as b}from"./actions-menu.js";import{jsxs as y,jsx as f,Fragment as C}from"@emotion/react/jsx-runtime";import{useState as w,useRef as O,useCallback as x}from"react";import{useTranslation as v,Trans as j}from"react-i18next";import{Divider as T,Typography as S,Icon as I,Button as k,ButtonVariant as E,IconSize as D,DropdownOptionList as P,Option as _,Pagination as R,Skeleton as M,SkeletonAnimation as W,SkeletonVariant as z}from"@shipengine/giger";import{IconNames as A}from"@shipengine/giger-theme";import{b as B,s as N}from"./styles.js";var H=Object.freeze({__proto__:null,CheckboxInput:e,CreditCardInput:t,DatePicker:n,ExpirationInput:a,InputGroup:i,transform:o,MoneyInput:r,NumberInput:s,RateSelect:c,SelectAutoComplete:l,Select:p,SelectWithCategories:d,SubmitButton:g,Switch:h,TextArea:m,TextInput:u});const V=B({chevronTypography:e=>({color:N(e).palette.secondary.main}),detailsBottomContainer:e=>({backgroundColor:N(e).palette.white,padding:"8px"}),detailsRow:{display:"flex",justifyContent:"space-between"},detailsTypography:e=>({color:N(e).palette.black}),headingContainer:{alignItems:"center",display:"flex",justifyContent:"space-between"},loadingStateContainer:e=>({display:"flex",flexDirection:"column",rowGap:N(e).spacing(2)})}),X=({transactionDetails:e})=>{const{t:t}=v(),[n,a]=w(!1);return y("div",{children:[f(b,{multiplier:2}),f(T,{}),f(b,{multiplier:1}),y("div",{children:[y("div",Object.assign({css:V.headingContainer},{children:[f(S,Object.assign({css:V.detailsTypography},{children:t("wallet-history:details.inaccurateWeight")})),f("div",Object.assign({onClick:()=>a(!n),onKeyDown:e=>{"Enter"===e.key&&a(!n)},role:"button",tabIndex:0},{children:f(I,n?{css:V.chevronTypography,name:A.CHEVRON_TOP}:{css:V.chevronTypography,name:A.CHEVRON_BOTTOM})}))]})),n&&f(b,{multiplier:1}),n&&f(S,Object.assign({css:V.detailsTypography},{children:e}))]})]})},G=B({footer:{"> *":{borderTop:"0 !important"},alignItems:"center",display:"flex",justifyContent:"space-between",width:"100%"},leftFooter:e=>({display:"flex",margin:N(e).spacing(2),span:{fontWeight:N(e).typography.fontWeight.bold}}),rowCount:e=>({alignItems:"center",display:"flex",marginRight:N(e).spacing(4),whiteSpace:"pre"}),rowCountDropDown:{"> * > *":{justifyContent:"center !important"}},rowsActions:e=>({"#selected-row":{":hover":{backgroundColor:"transparent"},borderRadius:N(e).borderRadius.XS,color:N(e).palette.black,padding:N(e).spacing(1),paddingRight:N(e).spacing(.5)},alignItems:"baseline",display:"flex",span:{alignSelf:"center"}})}),K=[5,10,25,50],U=({currentPageSize:e,pagingData:t,rowCountSelection:n=K,onPageSelect:a,onPageSizeSelect:i})=>{const[o,r]=w(!1),s=O(null),{t:c}=v(),l=x((()=>r((e=>!e))),[]);return y("div",Object.assign({css:G.footer},{children:[y("div",Object.assign({css:G.leftFooter},{children:[f("div",Object.assign({css:G.rowCount},{children:f(j,{components:[f("b",{style:{fontWeight:"bold"}},"1")],count:t.total,i18nKey:"common:grid.row-count",values:{firstIndex:0!==t.total?1+(t.page-1)*e:0,lastIndex:Math.min(t.total,t.page*e)}})})),y("div",Object.assign({css:G.rowsActions},{children:[c("common:grid.rows"),f(k,Object.assign({id:"selected-row",onClick:()=>l(),ref:s,variant:E.TEXT},{children:e})),f(I,o?{name:A.CHEVRON_TOP,onClick:()=>l(),size:D.SIZE_MEDIUM}:{name:A.CHEVRON_BOTTOM,onClick:()=>l(),size:D.SIZE_MEDIUM}),f(P,Object.assign({css:G.rowCountDropDown,dropdownWidth:"max-content",isOpen:o,onChange:()=>l(),onClickAway:e=>{var t;(null===(t=s.current)||void 0===t?void 0:t.contains(e.target))||l()},placement:"bottom",reference:s.current},{children:n.map((e=>f(_,Object.assign({onClick:()=>i(e),value:String(e)},{children:e}),e)))}))]}))]})),f("div",{children:f(R,{boundaryPagesToShow:5,currentPage:t.page,onPageChange:a,totalPages:t.pages})})]}))},Z=({children:e,notes:t})=>y(C,{children:[y("div",Object.assign({css:()=>({backgroundColor:"lightsteelblue",marginBottom:"16px",padding:"16px",paddingLeft:"32px"})},{children:[f(S,Object.assign({variant:"heading5"},{children:"Story notes:"})),f("ul",Object.assign({css:e=>({"> li":{marginTop:N(e).spacing(1)}})},{children:t.map((e=>f("li",{children:e},e)))}))]})),f("hr",{css:()=>({backgroundColor:"transparent",borderTop:"1px dotted lightgrey",marginBottom:"16px"})}),e]}),F=({children:e,loading:t})=>t?f(M,{animation:W.WAVE,variant:z.TEXT}):f("span",{children:e});export{X as H,U as P,Z as S,F as a,H as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as n}from"@emotion/react/jsx-runtime";import{S as a,c as r,e as i,u as o,M as s,d as l,C as d,f as c,E as p,g,h,U as u,i as b,j as m,k as f,P as v,T as C}from"./use-unit-settings.js";import{T as x,u as S,B as y,h as O,l as j,q as w,x as I,P as F,y as k}from"./actions-menu.js";import{t as E,a1 as L,x as A,v as D,D as z,_}from"./carrier.js";import{useState as T,useCallback as P,useMemo as R,useRef as W,useEffect as B,useContext as N,createContext as X}from"react";import{useListFundingSources as $,useGetAccountSettings as M,useGetInsuranceAccount as H,SE as U,useListLabels as V,useGetLabel as G,useListShipments as q,useGetShipment as K,useGetSalesOrderShipment as J,useGetSalesOrder as Z,useListWarehouses as Y,useListCarriers as Q}from"@shipengine/react-api";import{r as ee}from"./use-configure-shipment.js";import{useTranslation as te}from"react-i18next";import{Icon as ne,IconSize as ae,Select as re,Option as ie,Input as oe,Popover as se,Typography as le,Button as de,ButtonVariant as ce,TagColor as pe,Next as ge,Tag as he,TagVariant as ue,EmptyState as be}from"@shipengine/giger";import{u as me}from"./use-get-service-name.js";import{D as fe,u as ve,C as Ce,E as xe,G as Se,b as ye,a as Oe}from"./usePager.js";import{b as je,s as we}from"./validation.js";import{f as Ie,g as Fe}from"./use-toggle.js";import{formatISO as ke}from"date-fns/formatISO";import{isSameDay as Ee}from"date-fns/isSameDay";import{isWithinInterval as Le}from"date-fns/isWithinInterval";import{setHours as Ae}from"date-fns/setHours";import{setMinutes as De}from"date-fns/setMinutes";import{IconNames as ze}from"@shipengine/giger-theme";var _e={auctane:{components:{Typography:{body1:{fontSize:"14px",fontWeight:400},body2:{fontSize:"14px",fontWeight:400},heading3:{fontSize:"24px",fontWeight:700},heading4:{fontSize:"20px",fontWeight:700},heading5:{fontSize:"18px",fontWeight:700},heading6:{fontSize:"16px",fontWeight:700},small:{fontSize:"12px",fontWeight:400},subtitle1:{fontSize:"16px",fontWeight:600},subtitle2:{fontSize:"14px",fontWeight:600}}},palette:{alert:{light:"#FFF6EB",main:"#BD6E00"},error:{light:"#FDF7F7",main:"#A91919"},gray:{dark:"#0F0F10",light:"#CFD1D3",main:"#56595D",megaLight:"#E4E5E7",ultraLight:"#F1F2F3"},info:{light:"#E5EBFF",main:"#002CCC"},primary:{dark:"#1E0257",light:"#9D96FF",main:"#11003A",ultraLight:"#F1F2F3"},secondary:{dark:"#002199",light:"#E5EBFF",main:"#1448FF",ultraLight:"#E5EBFF"},success:{light:"#EBFFF5",main:"#00572B"}}},fallback:{borderRadius:{L:"16px",M:"8px",S:"4px",XL:"32px",XS:"2px"},breakPoints:{desktop:1280,mobileLarge:480,tablet:768,tabletLarge:960},card:{borderRadius:{desktop:"8px",mobile:"4px",tablet:"8px"}},components:{Button:{borderRadius:"4px"},Checkbox:{borderRadius:"2px",square:!1},Chip:{backgroundColor:"#f4f4f4",border:"none",borderRadius:"16px",color:"#706f6f",fontWeight:600,isSelected:{backgroundColor:"#EDEDED",border:"none",color:"#7A7A7A"},padding:"4px 16px"},Dialog:{action:{justifyContent:"center"},content:{padding:24,textAlign:"center"},dialog:{backgroundColor:"rgba(0, 0, 0, 0.26)",borderRadius:"4px"},header:{borderBottom:"2px solid #d3d3d3",padding:24,titleColor:"#616161"}},Field:{color:"#373737",fontWeight:700,placeholder:{fontWeight:700}},FieldContainer:{borderRadius:"4px"},Link:{activeColor:"#787878",defaultColor:"#616161",hoverColor:"#303030",isDark:{activeColor:"#787878",defaultColor:"#fff",hoverColor:"#fff",visitedColor:"#fff"},visitedColor:"#303030"},Table:{border:"none",borderRadius:"4px",boxShadow:"0 0 12px rgba(0, 0, 0, 0.1)"},Typography:{body1:{fontSize:"16px",fontWeight:400,letterSpacing:0,lineHeight:"24px"},body2:{fontSize:"14px",fontWeight:400,letterSpacing:3,lineHeight:"20px"},heading1:{fontSize:"48px",fontWeight:700,letterSpacing:0,lineHeight:"72px"},heading2:{fontSize:"32px",fontWeight:700,letterSpacing:1,lineHeight:"48px"},heading3:{fontSize:"24px",fontWeight:700,letterSpacing:3,lineHeight:"48px"},heading4:{fontSize:"20px",fontWeight:700,letterSpacing:3,lineHeight:"32px"},heading5:{fontSize:"18px",fontWeight:700,letterSpacing:3,lineHeight:"28px"},heading6:{fontSize:"16px",fontWeight:700,letterSpacing:3,lineHeight:"24px"},small:{fontSize:"12px",fontWeight:400,letterSpacing:5,lineHeight:"20px"},subtitle1:{fontSize:"16px",fontWeight:600,letterSpacing:3,lineHeight:"24px"},subtitle2:{fontSize:"14px",fontWeight:600,letterSpacing:5,lineHeight:"20px"}}},defaultFontFamily:"Arial",elevations:{above:{boxShadow:"0 0 12px rgba(0, 0, 0, 0.1)",zIndex:1e3},backdrop:{boxShadow:"none",zIndex:1007},flat1:{boxShadow:"0 2px 2px rgba(0, 0, 0, 0.1)",zIndex:1},flat2:{boxShadow:"0 2px 2px rgba(0, 0, 0, 0.1)",zIndex:1e3},overlay1:{boxShadow:"0 0 24px rgba(0, 0, 0, 0.1)",zIndex:1006},overlay2:{boxShadow:"0 0 24px rgba(0, 0, 0, 0.1)",zIndex:1008},popout1:{boxShadow:"0 4px 16px rgba(0, 0, 0, 0.1)",zIndex:1004},popout2:{boxShadow:"0 4px 16px rgba(0, 0, 0, 0.1)",zIndex:1005},raised:{boxShadow:"0 8px 8px rgba(0, 0, 0, 0.1)",zIndex:1002},raisedInverted1:{boxShadow:"0 -8px 8px rgba(0, 0, 0, 0.1)",zIndex:1002},raisedInverted2:{boxShadow:"0 -8px 8px rgba(0, 0, 0, 0.1)",zIndex:1003},sticky:{boxShadow:"none",zIndex:1001}},fontFaces:[],grid:{desktop:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24},desktopLarge:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24},mobile:{columns:4,gutter:16,horizontalSpace:16,verticalSpace:16},mobileLarge:{columns:4,gutter:16,horizontalSpace:16,verticalSpace:16},tablet:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24},tabletLarge:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24}},iconSize:{extra_large:"48px",large:"32px",medium:"20px",regular:"24px",small:"16px"},palette:{alert:{light:"#ffe7ca",main:"#725200"},black:"#000",dataVisualization:{highContrast:{blue:"#3970C1",blueDark:"#002039",coral:"#F95D6A",cyan:"#45CEE0",green:"#B3D849",orange:"#FFA600",orangeDark:"#FF7C43",pink:"#D12771",purple:"#A05195",purpleDark:"#665191"},lowContrast:{blue:"#96B3DE",blueDark:"#5283AB",coral:"#FCA6AD",cyan:"#BAE6FF",green:"#DEF895",orange:"#FDDFA5",orangeDark:"#FCC2A9",pink:"#E995BA",purple:"#D4BBFF",purpleDark:"#B1A2D0"}},error:{light:"#fee5e4",main:"#a72514"},gray:{dark:"#373737",light:"#d3d3d3",main:"#706f6f",megaLight:"#f4f4f4",ultraLight:"#f4f4f4"},info:{light:"#dbedfd",main:"#195f7f"},primary:{dark:"#626262",light:"#D6D6D6",main:"#7A7A7A",ultraLight:"#EDEDED"},secondary:{dark:"#303030",light:"#787878",main:"#616161",ultraLight:"#F4F4F4"},success:{light:"#dcfddb",main:"#286327"},white:"#fff"},spacingBase:8,typography:{fontSize:{L:"18px",M:"16px",S:"14px",XL:"20px",XS:"12px",XXL:"24px",XXS:"10px",XXXL:"32px",XXXXL:"48px"},fontWeight:{bold:700,light:200,normal:400,semibold:600},letterSpacing:{L:3,M:1,S:0,XL:5,XXL:8,XXXL:12},lineHeight:{L:"28px",M:"24px",S:"20px",XL:"32px",XXL:"48px",XXXL:"72px"}}}};const Te=je({category:{alignItems:"center",cursor:"pointer",display:"flex",flexDirection:"row",justifyContent:"space-between"},colorPicker:e=>({"&::-webkit-color-swatch":{border:`1px solid ${we(e).palette.gray.light}`,borderRadius:"4px",padding:0},"&::-webkit-color-swatch-wrapper":{padding:0},alignSelf:"center",appearance:"none",background:"none",border:0,cursor:"pointer",height:we(e).spacing(4.25),outline:"none",width:we(e).spacing(4.25)}),container:e=>({marginBottom:we(e).spacing(2)}),input:e=>({border:`1px solid ${we(e).palette.gray.light}`,borderRadius:"4px",color:we(e).palette.gray.main,fontSize:"14px",padding:we(e).spacing(1)}),inputContainer:e=>({alignItems:"center",display:"flex",flexDirection:"row",justifyContent:"space-between",padding:`${we(e).spacing(2)}px 0`}),wrapper:e=>({display:"flex",gap:we(e).spacing(1)})}),Pe=({paletteConfig:n,onUpdatePaletteConfig:a,formatKey:r})=>{const[i,o]=T(new Set),s=e=>{o((t=>{const n=new Set(t);return n.has(e)?new Set([...n].filter((t=>t!==e))):new Set([...n,e])}))},l=P(((e,t,r)=>{const i=(e=>{if(e)return e.match(/^#[0-9A-Fa-f]{0,6}$/)?e:e.match(/^[0-9A-Fa-f]{6}$/)?`#${e}`:void 0})(r),o=Object.assign(Object.assign({},n||{}),{[e]:Object.assign(Object.assign({},(null==n?void 0:n[e])||{}),{[t]:i})});a(o)}),[a,n]);return e("div",Object.assign({"data-test-id":"color-palette-editor"},{children:n&&Object.keys(n).sort().map((a=>t("div",Object.assign({css:Te.container,id:a},{children:[t("div",Object.assign({"aria-expanded":i.has(a),css:Te.category,onClick:e=>{e.preventDefault(),s(a)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),s(a))},role:"button",tabIndex:0},{children:[e("p",{children:E(a)}),e(ne,{name:i.has(a)?ze.CHEVRON_TOP:ze.CHEVRON_BOTTOM,size:ae.SIZE_REGULAR})]})),i.has(a)&&Object.keys(n[a]).map((i=>t("div",Object.assign({css:Te.inputContainer,id:"input-container"},{children:[e("label",Object.assign({css:{fontWeight:"bold"},htmlFor:`${a}.${i}`},{children:r(i)})),t("form",Object.assign({css:Te.wrapper},{children:[e("input",{css:Te.input,onChange:e=>{e.preventDefault(),l(a,i,e.target.value)},onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},type:"text",value:n[a][i]}),e("input",{css:Te.colorPicker,onChange:e=>l(a,i,e.target.value),type:"color",value:n[a][i]})]}))]}),i)))]}),a)))}))},Re=je({input:e=>({border:`1px solid ${we(e).palette.gray.light}`,borderRadius:"4px",color:we(e).palette.gray.main,fontSize:"14px",maxWidth:we(e).spacing(16),padding:0}),keys:{fontSize:"16px",fontWeight:"bold",marginTop:"8px"},section:e=>({"& > div:first-child":{flexGrow:3},"& > div:last-child":{flexShrink:1},display:"flex",gap:we(e).spacing(1),justifyContent:"space-between"}),sectionContainer:e=>({marginBottom:we(e).spacing(4)}),select:e=>({border:`1px solid ${we(e).palette.gray.light}`,borderRadius:"4px",color:we(e).palette.gray.main,fontSize:"14px"})}),We=({onUpdateTypographyConfig:a,typographyConfig:r,formatKey:i})=>{const o=P(((e,t,n)=>{const i=Object.assign(Object.assign({},r||{}),{[e]:Object.assign(Object.assign({},(null==r?void 0:r[e])||{}),{[t]:n})});a(i)}),[a,r]),s=P(((e,t)=>{if(e)return e[t]}),[]),l=(t,n)=>{var a;const i=[{label:"Normal",value:"400"},{label:"Semi Bold",value:"600"},{label:"Bold",value:"700"}],l=null===(a=s(r,t))||void 0===a?void 0:a.fontWeight.toString(),d=void 0!==l?i.find((e=>e.value===l)):void 0;return e(re,Object.assign({css:Re.select,label:"Font Weight",name:"font-weight",onChange:(e,a)=>o(t,n,null==a?void 0:a.value),value:d},{children:i.map((t=>e(ie,Object.assign({value:t.value},{children:t.label}),t.value)))}))},d=(t,n)=>{var a;const i=null===(a=s(r,t))||void 0===a?void 0:a.fontSize.replace("px","");return e(oe,{"aria-labelledby":`${t}.${n}`,css:Re.input,label:"Font Size(px)",onChange:e=>{e.target.value.match(/^\d{0,2}$/)&&o(t,n,`${e.target.value}px`)},value:i})},c=(t,a)=>{switch(a){case"fontWeight":return e(n,{children:l(t,a)});case"fontSize":return e(n,{children:d(t,a)});default:return null}};return e("div",{children:r&&Object.keys(r).sort().map((n=>t("div",Object.assign({css:Re.sectionContainer},{children:[e("p",Object.assign({css:Re.keys,id:n},{children:i(n)})),e("section",Object.assign({css:Re.section},{children:Object.keys(r[n]).sort(((e,t)=>"fontWeight"===e?-1:1)).map((t=>e("div",Object.assign({id:`${n}.${t}`},{children:c(n,t)}),t)))}))]}),n)))})},Be=je({container:e=>({color:we(e).palette.gray.dark,display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",position:"relative"}),content:e=>({display:"flex",flexDirection:"column",gap:we(e).spacing(3),padding:we(e).spacing(3)}),copy:e=>({backgroundColor:we(e).palette.white,borderRadius:"4px",padding:we(e).spacing(.5)}),drawerHeader:e=>({alignItems:"center",display:"flex",gap:we(e).spacing(2),justifyContent:"end",width:"50%"}),drawerWrapper:{display:"flex",justifyContent:"space-between",position:"relative"},getApplyButtonStyles:e=>t=>({"&:hover":{backgroundColor:e?we(t).palette.gray.light:"#11003A"},backgroundColor:e?we(t).palette.gray.light:"#11003A",borderRadius:we(t).spacing(.5),color:"white",cursor:e?"not-allowed":"pointer",fontSize:"14px",justifyContent:"center",padding:we(t).spacing(1),textAlign:"center"}),header:e=>({alignItems:"center",display:"flex",gap:we(e).spacing(2),justifyContent:"space-between"}),inputForm:e=>({display:"flex",flexDirection:"column",padding:`${we(e).spacing(0)}px ${we(e).spacing(1)}px`,width:we(e).spacing(30)}),popoverWrapper:e=>({display:"flex",flexDirection:"column",width:we(e).spacing(30)}),pre:e=>({backgroundColor:"#FFFFFF66",borderRadius:"8px",fontSize:"14px",padding:we(e).spacing(.3)}),presetListItem:e=>({alignItems:"center",display:"flex",height:we(e).spacing(6),justifyContent:"space-between",padding:we(e).spacing(1),width:"100%"}),presetOption:e=>({"&:hover":{backgroundColor:"scopeTheme(theme).palette.gray.ultraLight"},backgroundColor:"transparent",borderRadius:"4px",color:we(e).palette.gray.dark,fontSize:"14px",fontWeight:"normal",padding:we(e).spacing(.5),width:"100%"}),presetsButton:e=>({"&:hover":{backgroundColor:"#d1d4d7"},backgroundColor:"#E4E5E7",borderRadius:"4px",cursor:"pointer",display:"flex",fontSize:we(e).typography.fontSize.S,gap:we(e).spacing(.5),justifyContent:"center",padding:`${we(e).spacing(.5)}px ${we(e).spacing(1)}px`,width:"100%"}),textArea:e=>({fontSize:we(e).typography.fontSize.S,minHeight:we(e).spacing(24),width:"100%"})}),Ne=({themeConfig:n,onUpdateThemeConfig:a,presets:r,showDrawer:i})=>{const[o,s]=T(!1),l=Object.keys(n),d=R((()=>{const{palette:e,components:t}=_e.fallback,{Typography:n}=t||{},a=L(e||{},["black","white","dataVisualization"]);return{components:{Typography:n},palette:Object.assign({},a)}}),[]),c=l.flatMap((e=>{if("components"===e&&n[e]&&"object"==typeof n[e]){return Object.keys(n[e])}return[e]})).map((e=>"palette"===e?{label:"Color Palette",value:"Color Palette"}:{label:E(e),value:E(e)})).sort(((e,t)=>e.label.localeCompare(t.label))),[p,g]=T(c[0].value),h=e=>A(D(e)),u=W(null),[b,m]=Ie(!1),f=[{presetName:"Default",themeConfig:d},{presetName:"Auctane",themeConfig:_e.auctane},...r||[]],[v,C]=Ie(!1),[j,w]=T(""),[I,F]=T(),k=P((()=>{C(),w(""),F("")}),[C]);return t("div",Object.assign({"aria-label":"Theme Creator",css:Be.container,"data-testid":"theme-creator",role:"region"},{children:[t("div",Object.assign({css:Be.content},{children:[t("div",Object.assign({css:Be.header},{children:[e("div",Object.assign({css:{overflow:"scroll",width:"100%"}},{children:e(x,{onSelectTab:e=>{g(e)},selectedTab:p,tabs:c})})),t("div",{children:[t("button",Object.assign({"aria-controls":"presets-popover","aria-expanded":b,css:Be.presetsButton,onClick:e=>{e.preventDefault(),m()},ref:u},{children:["Presets",e(ne,{name:ze.CARET_BOTTOM,size:ae.SIZE_SMALL})]})),e(se,Object.assign({container:document.querySelector("#theme-creator"),isOpen:b,onClickAway:()=>m(),placement:"bottom-end",reference:u.current},{children:e("div",Object.assign({css:Be.popoverWrapper},{children:v?t("form",Object.assign({css:Be.inputForm,onSubmit:e=>{e.preventDefault();const t=j.replace(/([a-zA-Z0-9_]+)(?=:)/g,'"$1"').replace(/,\s*(}|\])/g,"$1").replace(/;$/,"");try{const e=JSON.parse(t),r=Object.assign(Object.assign({},n),{components:Object.assign(Object.assign({},n.components),e.components),palette:Object.assign(Object.assign({},n.palette),e.palette)});a(r),k(),m()}catch(e){F("Error parsing input."),console.error("Error parsing input",e)}}},{children:[e(le,Object.assign({variant:"small"},{children:"*Must be in JavaScript object format"})),e("textarea",{css:Be.textArea,disabled:!v,onChange:e=>w(e.target.value),placeholder:JSON.stringify({palette:{primary:{dark:"#1E0257",light:"#9D96FF",main:"#11003A",ultraLight:"#F1F2F3"}},components:{Typography:{heading3:{fontSize:"24px",fontWeight:700}}}},null,2).replace(/"([^"]+)":/g,"$1:"),required:!0,value:j}),I?e(le,Object.assign({css:{color:"red"},variant:"small"},{children:I})):e(S,{multiplier:2}),t(y,Object.assign({justify:"end"},{children:[e(de,Object.assign({onClick:k,variant:ce.TEXT},{children:"Cancel"})),e(de,Object.assign({css:Be.getApplyButtonStyles(!j),disabled:!j,type:"submit"},{children:"Apply"}))]}))]})):t("ul",Object.assign({css:{listStyle:"none"}},{children:[f.map(((n,r)=>t("li",Object.assign({css:Be.presetListItem},{children:[e(le,{children:n.presetName}),e(de,Object.assign({"aria-label":`Set ${n.presetName} Theme`,css:Be.getApplyButtonStyles(),onClick:e=>{var t;e.preventDefault(),m(),t=n.themeConfig,a(t),g("Color Palette")}},{children:"Apply"}),n.presetName)]}),r))),e("li",Object.assign({css:Be.presetListItem},{children:e("button",Object.assign({css:Be.presetsButton,onClick:()=>{C()}},{children:"Input Custom Theme"}))}))]}))}))}))]})]})),e(le,Object.assign({role:"heading",variant:"heading4"},{children:`${p} Editor`})),((n,r)=>{var i;switch(r){case"Color Palette":return e(Pe,{formatKey:h,onUpdatePaletteConfig:e=>{a(Object.assign(Object.assign({},n),{palette:e}))},paletteConfig:n.palette});case"Typography":return e(We,{formatKey:h,onUpdateTypographyConfig:e=>{a(Object.assign(Object.assign({},n),{components:Object.assign(Object.assign({},n.components),{Typography:e})}))},typographyConfig:null===(i=n.components)||void 0===i?void 0:i.Typography});default:return t("div",{children:["Editor for ",r," is not implemented yet."]})}})(n,p)]})),i&&e(fe,Object.assign({"aria-label":"Show themeConfig.js Code Drawer",headerContent:t("div",Object.assign({css:Be.drawerHeader},{children:[e("pre",Object.assign({css:Be.pre},{children:"themeConfig.js"})),i.copyToClipboardText&&e("div",Object.assign({css:Be.copy},{children:e(O,{content:i.copyToClipboardText})}))]})),isOpen:o,toggleDrawer:()=>s(!o)},{children:i.content}))]}))},Xe=({onRedirectToOnboarding:t})=>e(a,{onRedirectToOnboarding:t}),$e=r(Xe,j,{resources:{en:i}});var Me=Object.freeze({__proto__:null,Component:Xe,Element:$e});const He=()=>{const t=L(o(),[]);return e(s,Object.assign({},t))},Ue=r(He,j,{resources:{en:i}});var Ve=Object.freeze({__proto__:null,Component:He,Element:Ue});const Ge=t=>{var n,a,{features:r,externalOrderId:i,externalOrderNumber:o,externalShipmentId:s,onLoad:c,onShipmentUpdated:p,orderSourceCode:g,salesOrderId:h,shipFromAddresses:u,warehouseId:b,shipmentId:m,printLabelLayout:f,currency:v}=t,C=L(t,["features","externalOrderId","externalOrderNumber","externalShipmentId","onLoad","onShipmentUpdated","orderSourceCode","salesOrderId","shipFromAddresses","warehouseId","shipmentId","printLabelLayout","currency"]);const{data:x}=$(),{data:S}=M(),{shipment:y,salesOrder:O,refetchPendingSalesOrderShipments:j,isLoading:w,errors:I}=ee({errorWhenShipmentCancelled:null==r?void 0:r.enableErrorWhenShipmentCancelled,externalOrderId:i,externalOrderNumber:o,externalShipmentId:s,onLoad:c,onShipmentUpdated:p,orderSourceCode:g,salesOrderId:h,shipFromAddresses:u,shipmentId:m,useWarehouses:null===(n=null==r?void 0:r.shipmentForm)||void 0===n?void 0:n.useWarehouses,warehouseId:b}),{data:F,isInitialLoading:k}=H((null==y?void 0:y.insuranceProvider)===U.InsuranceProviderType.SHIPSURANCE?U.InsuranceProviderType.SHIPSURANCE:void 0),E=null!=v?v:z(null===(a=null==x?void 0:x[0])||void 0===a?void 0:a.currencyCode),A=P((e=>_(void 0,void 0,void 0,(function*(){yield j(),yield null==p?void 0:p(e)}))),[p,j]);return e(l,Object.assign({data:y||O,errors:I,isLoading:w||k},{children:e(d,Object.assign({currency:E,features:r,insuranceAccount:F,isLoading:w||k,onShipmentUpdated:A,printLabelLayout:null!=f?f:null==S?void 0:S.defaultLabelLayout,salesOrder:O,shipFromAddresses:u,shipment:y},C))}))},qe=r(Ge,j,{resources:{en:i}});var Ke=Object.freeze({__proto__:null,Component:Ge,Element:qe});const Je=({isModalFullScreen:t})=>{const n=L(c(),[]);return e(p,Object.assign({isModalFullScreen:t},n))},Ze=r(Je,j,{resources:{en:i}});var Ye=Object.freeze({__proto__:null,Component:Je,Element:Ze});const Qe=je({errorState:e=>Object.assign({backgroundColor:we(e).palette.white},we(e).getComponentOverride("Table")),tableParagraph:{margin:0}}),et=({labelStatus:a,features:r,onClickPrintLabel:i,onClickVoidLabel:o,onClickPrintForms:s,onClickViewDetails:l,onRowClick:d,onClickExternalOrderId:c,onClickExternalShipmentId:p})=>{var g,h;const{t:u}=te(["common","list-labels"]),{globalFeatures:b,getFeatures:m}=Fe(),f=m("labelsGridFeatures"),v=W(a);r=Object.assign(Object.assign({},f),null!=r?r:{});const C=R((()=>{var e;return null===(e=null==r?void 0:r.columns)||void 0===e?void 0:e.find((e=>"labelId"===e.name))}),[r]),x=R((()=>{var e;return null===(e=null==r?void 0:r.columns)||void 0===e?void 0:e.find((e=>"shipmentId"===e.name))}),[r]),y=C&&(null===(g=C.allowFilter)||void 0===g||g),O=x&&(null===(h=x.allowFilter)||void 0===h||h),{labels:j,getGridData:E,isError:L,isLoading:A,filters:D,setFilters:z,pageConfig:_,isAnyFilterActive:P,shouldShowFilters:N,clearAllFilters:X}=(({labelStatus:e,showShipmentIdFilter:t,showLabelIdFilter:n})=>{var a,r;const i={labelId:{enabled:!!n,value:""},shipmentId:{enabled:!!t,value:""}},{getServiceName:o}=me(),{page:s,pageSize:l,pagerProps:d}=ve(20),[c,p]=T(i),g=Object.keys(c).some((e=>{const t=c[e];return(null==t?void 0:t.enabled)&&t.value})),h=Object.keys(c).some((e=>{const t=c[e];return null==t?void 0:t.enabled}));B((()=>{p({labelId:{enabled:!!n,value:""},shipmentId:{enabled:!!t,value:""}})}),[n,t]);const{data:u,isLoading:b,isError:m}=V({queryFnParams:{labelStatus:e,page:s,pageSize:l,shipmentId:c.shipmentId.value||void 0,sortBy:"modified_at",sortDir:"desc"}}),f=R((()=>(null==u?void 0:u.labels.map((e=>Object.assign(Object.assign({},e),{serviceName:o(e)}))))||[]),[null==u?void 0:u.labels,o]),v=h&&(g||Boolean(null==f?void 0:f.length)),{data:C,isError:x,isInitialLoading:S}=G((null===(a=c.labelId)||void 0===a?void 0:a.value)||void 0),y=null===(r=c.labelId)||void 0===r?void 0:r.value,O=(t=>{if(y&&!x){let n=!0;return e&&e!==(null==t?void 0:t.status)&&(n=!1),""!==(null==c?void 0:c.shipmentId.value)&&(null==c?void 0:c.shipmentId.value)!==(null==t?void 0:t.shipmentId)&&(n=!1),n?t:void 0}})(C),j=y&&(x||!O);return{clearAllFilters:()=>{p(i)},filters:c,getGridData:()=>O?[Object.assign(Object.assign({},O),{serviceName:o(O)})]:j?[]:f||[],isAnyFilterActive:g,isError:m,isLoading:b||S,labels:f,pageConfig:{currentPage:O?1:(null==u?void 0:u.page)||0,pagerProps:d,pagesAmount:(null==u?void 0:u.pages)||0,pageSize:l,showPagination:!O&&((null==u?void 0:u.total)||0)>l,totalElements:O?1:(null==u?void 0:u.total)||0},setFilters:e=>{d.onPageSelect(1),p(e)},shouldShowFilters:v}})({labelStatus:a,showLabelIdFilter:y,showShipmentIdFilter:O});B((()=>{v.current!==a&&_.pagerProps.resetCurrentPage(),v.current=a}),[a,_.pagerProps]);const $=R((()=>({labelId:Object.assign(Object.assign({},D.labelId),{nickname:null==C?void 0:C.nickname}),shipmentId:Object.assign(Object.assign({},D.shipmentId),{nickname:null==x?void 0:x.nickname})})),[D,C,x]),M=R((()=>{var a;const i={completed:{color:pe.SUCCESS,text:u("list-labels:status.completed")},error:{color:pe.ERROR,text:u("list-labels:status.error")},processing:{color:pe.INFO,text:u("list-labels:status.processing")},voided:{color:pe.INFO,text:u("list-labels:status.voided")}},o={delivered:{color:pe.SUCCESS,text:u("list-labels:trackingStatus.delivered")},error:{color:pe.ERROR,text:u("list-labels:trackingStatus.error")},in_transit:{color:pe.GRAY,text:u("list-labels:trackingStatus.inTransit")},unknown:{color:pe.ALERT,text:u("list-labels:trackingStatus.unknown")}},s={createdDate:{headerContent:u("list-labels:headers.created"),renderCellContent:t=>e(Ce,{date:t.createdAt,short:!0})},externalOrderId:{headerContent:u("list-labels:headers.externalOrderId"),renderCellContent:t=>t.externalOrderId&&c?e(ge.Link,Object.assign({bold:!1,onClick:()=>{var e;return null==c?void 0:c(null!==(e=t.externalOrderId)&&void 0!==e?e:void 0)}},{children:t.externalOrderId})):e(le,Object.assign({component:"span",variant:"body2"},{children:t.externalOrderId}))},externalShipmentId:{headerContent:u("list-labels:headers.externalShipmentId"),renderCellContent:t=>t.externalShipmentId&&p?e(ge.Link,Object.assign({bold:!1,onClick:()=>{var e;return null==p?void 0:p(null!==(e=t.externalShipmentId)&&void 0!==e?e:void 0)}},{children:t.externalShipmentId})):e(le,Object.assign({component:"span",variant:"body2"},{children:t.externalShipmentId}))},labelId:{headerContent:u("list-labels:headers.labelId"),renderCellContent:t=>e(le,Object.assign({component:"span",variant:"body2"},{children:t.labelId}))},packages:{headerContent:u("list-labels:headers.parcels"),renderCellContent:t=>e(le,Object.assign({component:"span",variant:"body2"},{children:t.packages.length}))},recipient:{headerContent:u("list-labels:headers.recipient"),renderCellContent:a=>t(n,{children:[e(le,Object.assign({component:"p",css:Qe.tableParagraph,variant:"body2"},{children:a.shipTo.name})),t(le,Object.assign({component:"p",css:Qe.tableParagraph,variant:"body2"},{children:[a.shipTo.postalCode,", ",a.shipTo.cityLocality]}))]})},shipDate:{headerContent:u("list-labels:headers.shipDate"),renderCellContent:t=>e(Ce,{date:t.shipDate,short:!0})},shipmentId:{headerContent:u("list-labels:headers.shipmentId"),renderCellContent:t=>e(le,Object.assign({component:"span",variant:"body2"},{children:t.shipmentId}))},shippingService:{headerContent:u("list-labels:headers.shipping"),renderCellContent:a=>t(n,{children:[e(le,Object.assign({component:"p",css:Qe.tableParagraph,variant:"body2"},{children:a.serviceName||a.serviceCode})),a.trackable&&e(ge.Link,Object.assign({bold:!1,href:a.trackingUrl,isExternal:!0,target:"_blank"},{children:a.trackingNumber}))]})},status:{headerContent:u("list-labels:headers.status"),renderCellContent:t=>e(he,Object.assign({color:i[t.status].color,variant:ue.LINEAL_FILLED},{children:i[t.status].text}))},trackingStatus:{headerContent:u("list-labels:headers.trackingStatus"),renderCellContent:t=>e(he,Object.assign({color:o[t.trackingStatus].color,variant:ue.LINEAL_FILLED},{children:o[t.trackingStatus].text}))}},l=[];return null===(a=null==r?void 0:r.columns)||void 0===a||a.forEach((e=>{s[e.name]&&(e.nickname?l.push(Object.assign(Object.assign({},s[e.name]),{headerContent:e.nickname})):l.push(s[e.name]))})),l}),[r,u,c,p]);if(A)return e(w,{message:u("loading.labels")});if(L)return e(xe,{css:Qe.errorState,subtitle:[u("list-labels:errorMessages.subtitle"),u("errorMessages.refreshAndTryAgain")],title:u("list-labels:errorMessages.title")});const H=(e,t)=>{e===k.PRINT_LABEL&&(e=>{null==i||i(),window.open(e.labelDownload.href,"_blank","noopener, noreferrer")})(t),e===k.VOID_LABEL&&(null==o||o(t)),e===k.PRINT_FORMS&&(e=>{null==s||s(),window.open(e.formDownload.href,"_blank","noopener, noreferrer")})(t),e===k.VIEW_DETAILS&&(null==l||l(t))};return(null==r?void 0:r.showActions)&&j.some((e=>"completed"===e.status))&&M.push({headerContent:"",renderCellContent:t=>{var n,a;const r=!!(null===(n=t.labelDownload)||void 0===n?void 0:n.href)&&"completed"===t.status,i=!!o&&"completed"===t.status,s=!!(null===(a=t.formDownload)||void 0===a?void 0:a.href)&&"completed"===t.status,d=!!l;if(!(r||i||s||d))return null;const c=[...d?[k.VIEW_DETAILS]:[],...r?[k.PRINT_LABEL]:[],...i?[k.VOID_LABEL]:[],...s?[k.PRINT_FORMS]:[]];return e(I,{allowedActions:c,onActionClick:e=>H(e,t)})}}),t(n,{children:[e(Se,{columns:M,data:E(),emptyContent:e(be,P?Object.assign({isElevated:!1,subtitle:u("list-labels:emptyWithFilters.subtitle"),title:u("list-labels:emptyWithFilters.title")},{children:e(de,Object.assign({onClick:X},{children:u("list-labels:emptyWithFilters.button")}))}):{isElevated:!1,subtitle:u("list-labels:empty.subtitle"),title:u("list-labels:empty.title")}),filters:N&&e(ye,{filters:$,onClearAllFilters:X,onFiltersUpdated:z}),footerContent:e(Oe,{onPageChange:_.pagerProps.onPageSelect,page:_.currentPage,pages:_.pagesAmount,pageSize:_.pageSize,showPagination:_.showPagination,total:_.totalElements}),onRowClick:d}),b.poweredByShipEngine&&t(n,{children:[e(S,{}),e(F,{})]})]})},tt=r(et,j,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:i}});var nt=Object.freeze({__proto__:null,Component:et,Element:tt});const at=(e,t)=>({end:Ae(De(t,59),23),start:Ae(De(e,0),0)}),rt=(e,t)=>({createdDate:{enabled:t,value:null},shipmentId:{enabled:e,value:""}}),it=({shipmentStatus:e,showShipmentIdFilter:t=!0,showCreatedDateFilter:n=!0})=>{var a,r,i,o;const s=rt(t,n),{getServiceName:l}=me(),{page:d,pageSize:c,pagerProps:p}=ve(20),[g,h]=T(s),u=Object.keys(g).some((e=>{const t=g[e];return(null==t?void 0:t.enabled)&&t.value})),b=Object.keys(g).some((e=>{const t=g[e];return null==t?void 0:t.enabled}));B((()=>{const e=rt(t,n);h(e)}),[n,t]);const{data:m,isLoading:f,isError:v}=q(Object.assign({page:d,pageSize:c,shipmentStatus:e,sortBy:"modified_at",sortDir:"desc"},((e,t)=>{if(!e||!t)return{};const n=at(e,t);return{createdAtEnd:ke(n.end),createdAtStart:ke(n.start)}})(null===(r=null===(a=g.createdDate)||void 0===a?void 0:a.value)||void 0===r?void 0:r.start,null===(o=null===(i=g.createdDate)||void 0===i?void 0:i.value)||void 0===o?void 0:o.end))),C=R((()=>null==m?void 0:m.shipments.map((e=>Object.assign(Object.assign({},e),{serviceName:l(e)})))),[null==m?void 0:m.shipments,l]),x=b&&(u||Boolean(null==C?void 0:C.length)),{data:S,error:y,isInitialLoading:O}=K({queryFnParams:{shipmentId:g.shipmentId.value||void 0},retry:!1}),j=g.shipmentId.value,w=(t=>{var n,a,r,i;if(j&&!y){let o=!0;e&&(null==t?void 0:t.shipmentStatus)!==e&&(o=!1);const s=null===(n=g.createdDate)||void 0===n?void 0:n.value;return(null==s?void 0:s.start)&&s.end&&(null==t?void 0:t.createdAt)&&(a=s.start,r=s.end,i=t.createdAt,Ee(a,r)&&Ee(a,new Date(i))||Le(new Date(i),at(a,r))||(o=!1)),o?t:void 0}})(S),I=j&&(y||!w);return{clearAllFilters:()=>{h(s)},filters:g,getGridData:()=>w?[Object.assign(Object.assign({},w),{serviceName:l(w)})]:I?[]:C||[],isAnyFilterActive:u,isError:v,isLoading:f||O,pageConfig:{currentPage:w?1:(null==m?void 0:m.page)||0,pagerProps:p,pagesAmount:(null==m?void 0:m.pages)||0,pageSize:c,showPagination:!w&&((null==m?void 0:m.total)||0)>c,totalElements:w?1:(null==m?void 0:m.total)||0},setFilters:e=>{p.onPageSelect(1),h(e)},shipments:C,shouldShowFilters:x}},ot=je({errorState:e=>Object.assign({backgroundColor:we(e).palette.white},we(e).getComponentOverride("Table")),tableParagraph:{margin:0}}),st=({onRowClick:a,onClickCancelShipment:r,shipmentStatus:i,showShipmentIdFilter:o=!0,showCreatedDateFilter:s=!0})=>{const{t:l}=te(["common","list-shipments"]),{globalFeatures:d}=Fe(),{isLoading:c,isError:p,filters:g,setFilters:h,pageConfig:u,getGridData:b,isAnyFilterActive:m,shouldShowFilters:f,clearAllFilters:v}=it({shipmentStatus:i,showCreatedDateFilter:s,showShipmentIdFilter:o});if(c)return e(w,{message:l("loading.shipments")});if(p)return e(xe,{css:ot.errorState,subtitle:[l("list-shipments:errorMessages.subtitle"),l("errorMessages.refreshAndTryAgain")],title:l("list-shipments:errorMessages.title")});const C={cancelled:{color:pe.ALERT,text:l("list-shipments:status.cancelled")},label_purchased:{color:pe.SUCCESS,text:l("list-shipments:status.purchased")},pending:{color:pe.SUCCESS,text:l("list-shipments:status.readyToBuy")},processing:{color:pe.INFO,text:l("list-shipments:status.processing")}},x=[{headerContent:l("list-shipments:headers.shipmentId"),renderCellContent:t=>e(le,Object.assign({component:"p",css:ot.tableParagraph,variant:"body2"},{children:t.shipmentId}))},{headerContent:l("list-shipments:headers.parcels"),renderCellContent:t=>e(le,Object.assign({component:"p",css:ot.tableParagraph,variant:"body2"},{children:t.packages.length}))},{headerContent:l("list-shipments:headers.recipient"),renderCellContent:a=>{const r=!!(a.shipTo.name||a.shipTo.postalCode||a.shipTo.cityLocality),i=!(!a.shipTo.postalCode&&!a.shipTo.cityLocality);return r?t(n,{children:[e(le,Object.assign({component:"p",css:ot.tableParagraph,variant:"body2"},{children:a.shipTo.name})),i&&e(le,Object.assign({component:"p",css:ot.tableParagraph,variant:"body2"},{children:[a.shipTo.postalCode,a.shipTo.cityLocality].filter(Boolean).join(", ")}))]}):"--"}},{headerContent:l("list-shipments:headers.shipping"),renderCellContent:t=>e(le,Object.assign({component:"p",css:ot.tableParagraph,variant:"body2"},{children:t.serviceName||l("list-shipments:none")}))},{headerContent:l("list-shipments:headers.created"),renderCellContent:t=>e(Ce,{date:t.createdAt,short:!0})},{headerContent:l("list-shipments:headers.modified"),renderCellContent:t=>e(Ce,{date:t.modifiedAt,short:!0})},{headerContent:l("list-shipments:headers.status"),renderCellContent:t=>e(he,Object.assign({color:C[t.shipmentStatus].color,variant:ue.LINEAL_FILLED},{children:C[t.shipmentStatus].text}))},{headerContent:"",renderCellContent:t=>{const n=[...!!r&&"pending"===t.shipmentStatus?[k.CANCEL_SHIPMENT]:[]];return n.length>0&&e(I,{allowedActions:n,onActionClick:e=>((e,t)=>{e===k.CANCEL_SHIPMENT&&(null==r||r(t))})(e,t)})}}];return t(n,{children:[e(Se,{columns:x,data:b(),emptyContent:e(be,m?Object.assign({isElevated:!1,subtitle:l("list-shipments:emptyState.filtersSubtitle"),title:l("list-shipments:emptyState.filtersTitle")},{children:e(de,Object.assign({onClick:v},{children:l("list-shipments:emptyState.viewAll")}))}):{isElevated:!1,subtitle:l("list-shipments:emptyState.subtitle"),title:l("list-shipments:emptyState.title")}),filters:f&&e(ye,{filters:g,onClearAllFilters:v,onFiltersUpdated:h}),footerContent:e(Oe,{onPageChange:u.pagerProps.onPageSelect,page:u.currentPage,pages:u.pagesAmount,pageSize:u.pageSize,showPagination:u.showPagination,total:u.totalElements}),onRowClick:a}),d.poweredByShipEngine&&t(n,{children:[e(S,{}),e(F,{})]})]})},lt=r(st,j,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:i}});var dt=Object.freeze({__proto__:null,Component:st,Element:lt});const ct=X(void 0),pt=({children:t,editableTheme:n})=>{const[a,r]=T(n);return e(ct.Provider,Object.assign({value:{setThemeConfig:r,themeConfig:a}},{children:t}))},gt=()=>{const e=N(ct);if(!e)throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");return e},ht=t=>{var n=L(t,[]);return e(Ne,Object.assign({},n))},ut=r(ht,j,{resources:{en:i}});var bt=Object.freeze({__proto__:null,Component:ht,Element:ut});const mt=({features:t,onClickPrintLabel:n,onClickPurchaseLabel:a,onClickVoidLabel:r,shipmentId:i})=>{var o,s,l;const{t:d}=te(["common","view-shipment"]),c=J(i),{data:{labels:p=[]}={}}=V({queryFnParams:{shipmentId:i}}),h=Z(null===(s=null===(o=c.data)||void 0===o?void 0:o.salesOrderIds)||void 0===s?void 0:s[0]),u=Y(),b=Q();if(c.isInitialLoading)return e(w,{message:d("loading.shipment")});if(c.error)throw new Error(c.error.map((e=>e.message)).join(", "));if(!c.data)throw new Error("errorMessages.unableToLoad.shipment");const m=null===(l=u.data)||void 0===l?void 0:l.find((e=>{var t;return e.warehouseId===(null===(t=c.data)||void 0===t?void 0:t.warehouseId)}));return e(g,{carriers:b.data,features:t,labels:p,onClickPrintLabel:n,onClickPurchaseLabel:a,onClickVoidLabel:r,salesOrder:h.data,shipment:c.data,warehouse:m})},ft=r(mt,j,{resources:{en:i}});var vt=Object.freeze({__proto__:null,Component:mt,Element:ft});const Ct=()=>{const t=L(h(),[]);return e(u,Object.assign({},t))},xt=r(Ct,j,{resources:{en:i}});var St=Object.freeze({__proto__:null,Component:Ct,Element:xt});const yt=({onRedirectToOnboarding:t})=>e(b,{onRedirectToOnboarding:t}),Ot=r(yt,j,{resources:{en:i}});var jt=Object.freeze({__proto__:null,Component:yt,Element:Ot});const wt=()=>{const t=L(m(),[]);return e(f,Object.assign({},t))},It=r(wt,j,{resources:{en:i}});var Ft=Object.freeze({__proto__:null,Component:wt,Element:It});const kt=({onRedirectToOnboarding:t})=>e(v,{onRedirectToOnboarding:t}),Et=r(kt,j,{resources:{en:i}});var Lt=Object.freeze({__proto__:null,Component:kt,Element:Et});const At=()=>e(C,{}),Dt=r(At,j,{resources:{en:i}});var zt=Object.freeze({__proto__:null,Component:At,Element:Dt});export{pt as T,Ve as a,Ye as b,bt as c,vt as d,St as e,jt as f,Ft as g,Lt as h,zt as i,nt as l,Me as m,Ke as p,dt as s,_e as t,gt as u};
|
|
1
|
+
import{u as e,a5 as t,y as n,w as a,_ as r,E as i}from"./validation.js";import{jsx as o,jsxs as s,Fragment as l}from"@emotion/react/jsx-runtime";import{useState as d,useCallback as c,useMemo as p,useRef as g,useEffect as u,useContext as h,createContext as b}from"react";import{useFundingSourcesAddFunds as m,useListFundingSources as v,useGetAccountSettings as f,useGetInsuranceAccount as S,SE as C,useListLabels as x,useGetLabel as y,useListShipments as O,useGetShipment as j,useGetSalesOrderShipment as k,useGetSalesOrder as w,useListWarehouses as F,useListCarriers as I}from"@shipengine/react-api";import{S as E,c as L,e as A,u as D,M as z,d as T,C as _,f as P,E as R,g as W,h as B,U as N,i as X,j as $,k as M,P as H,T as U}from"./use-unit-settings.js";import{T as V,t as G,B as q,h as K,l as J,w as Z,x as Y,p as Q,P as ee}from"./actions-menu.js";import{r as te}from"./use-configure-shipment.js";import{useTranslation as ne}from"react-i18next";import{Icon as ae,IconSize as re,Select as ie,Option as oe,Input as se,Popover as le,Typography as de,Button as ce,ButtonVariant as pe,TagColor as ge,Next as ue,Tag as he,TagVariant as be,EmptyState as me}from"@shipengine/giger";import{useTheme as ve}from"@emotion/react";import{u as fe}from"./use-get-service-name.js";import{D as Se,u as Ce,S as xe,C as ye,E as Oe,G as je,b as ke,a as we}from"./usePager.js";import{b as Fe,s as Ie}from"./styles.js";import{f as Ee,h as Le}from"./use-balance-services.js";import{formatISO as Ae}from"date-fns/formatISO";import{isSameDay as De}from"date-fns/isSameDay";import{isWithinInterval as ze}from"date-fns/isWithinInterval";import{setHours as Te}from"date-fns/setHours";import{setMinutes as _e}from"date-fns/setMinutes";import{IconNames as Pe}from"@shipengine/giger-theme";var Re={auctane:{components:{Typography:{body1:{fontSize:"14px",fontWeight:400},body2:{fontSize:"14px",fontWeight:400},heading3:{fontSize:"24px",fontWeight:700},heading4:{fontSize:"20px",fontWeight:700},heading5:{fontSize:"18px",fontWeight:700},heading6:{fontSize:"16px",fontWeight:700},small:{fontSize:"12px",fontWeight:400},subtitle1:{fontSize:"16px",fontWeight:600},subtitle2:{fontSize:"14px",fontWeight:600}}},palette:{alert:{light:"#FFF6EB",main:"#BD6E00"},error:{light:"#FDF7F7",main:"#A91919"},gray:{dark:"#0F0F10",light:"#CFD1D3",main:"#56595D",megaLight:"#E4E5E7",ultraLight:"#F1F2F3"},info:{light:"#E5EBFF",main:"#002CCC"},primary:{dark:"#1E0257",light:"#9D96FF",main:"#11003A",ultraLight:"#F1F2F3"},secondary:{dark:"#002199",light:"#E5EBFF",main:"#1448FF",ultraLight:"#E5EBFF"},success:{light:"#EBFFF5",main:"#00572B"}}},fallback:{borderRadius:{L:"16px",M:"8px",S:"4px",XL:"32px",XS:"2px"},breakPoints:{desktop:1280,mobileLarge:480,tablet:768,tabletLarge:960},card:{borderRadius:{desktop:"8px",mobile:"4px",tablet:"8px"}},components:{Button:{borderRadius:"4px"},Checkbox:{borderRadius:"2px",square:!1},Chip:{backgroundColor:"#f4f4f4",border:"none",borderRadius:"16px",color:"#706f6f",fontWeight:600,isSelected:{backgroundColor:"#EDEDED",border:"none",color:"#7A7A7A"},padding:"4px 16px"},Dialog:{action:{justifyContent:"center"},content:{padding:24,textAlign:"center"},dialog:{backgroundColor:"rgba(0, 0, 0, 0.26)",borderRadius:"4px"},header:{borderBottom:"2px solid #d3d3d3",padding:24,titleColor:"#616161"}},Field:{color:"#373737",fontWeight:700,placeholder:{fontWeight:700}},FieldContainer:{borderRadius:"4px"},Link:{activeColor:"#787878",defaultColor:"#616161",hoverColor:"#303030",isDark:{activeColor:"#787878",defaultColor:"#fff",hoverColor:"#fff",visitedColor:"#fff"},visitedColor:"#303030"},Table:{border:"none",borderRadius:"4px",boxShadow:"0 0 12px rgba(0, 0, 0, 0.1)"},Typography:{body1:{fontSize:"16px",fontWeight:400,letterSpacing:0,lineHeight:"24px"},body2:{fontSize:"14px",fontWeight:400,letterSpacing:3,lineHeight:"20px"},heading1:{fontSize:"48px",fontWeight:700,letterSpacing:0,lineHeight:"72px"},heading2:{fontSize:"32px",fontWeight:700,letterSpacing:1,lineHeight:"48px"},heading3:{fontSize:"24px",fontWeight:700,letterSpacing:3,lineHeight:"48px"},heading4:{fontSize:"20px",fontWeight:700,letterSpacing:3,lineHeight:"32px"},heading5:{fontSize:"18px",fontWeight:700,letterSpacing:3,lineHeight:"28px"},heading6:{fontSize:"16px",fontWeight:700,letterSpacing:3,lineHeight:"24px"},small:{fontSize:"12px",fontWeight:400,letterSpacing:5,lineHeight:"20px"},subtitle1:{fontSize:"16px",fontWeight:600,letterSpacing:3,lineHeight:"24px"},subtitle2:{fontSize:"14px",fontWeight:600,letterSpacing:5,lineHeight:"20px"}}},defaultFontFamily:"Arial",elevations:{above:{boxShadow:"0 0 12px rgba(0, 0, 0, 0.1)",zIndex:1e3},backdrop:{boxShadow:"none",zIndex:1007},flat1:{boxShadow:"0 2px 2px rgba(0, 0, 0, 0.1)",zIndex:1},flat2:{boxShadow:"0 2px 2px rgba(0, 0, 0, 0.1)",zIndex:1e3},overlay1:{boxShadow:"0 0 24px rgba(0, 0, 0, 0.1)",zIndex:1006},overlay2:{boxShadow:"0 0 24px rgba(0, 0, 0, 0.1)",zIndex:1008},popout1:{boxShadow:"0 4px 16px rgba(0, 0, 0, 0.1)",zIndex:1004},popout2:{boxShadow:"0 4px 16px rgba(0, 0, 0, 0.1)",zIndex:1005},raised:{boxShadow:"0 8px 8px rgba(0, 0, 0, 0.1)",zIndex:1002},raisedInverted1:{boxShadow:"0 -8px 8px rgba(0, 0, 0, 0.1)",zIndex:1002},raisedInverted2:{boxShadow:"0 -8px 8px rgba(0, 0, 0, 0.1)",zIndex:1003},sticky:{boxShadow:"none",zIndex:1001}},fontFaces:[],grid:{desktop:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24},desktopLarge:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24},mobile:{columns:4,gutter:16,horizontalSpace:16,verticalSpace:16},mobileLarge:{columns:4,gutter:16,horizontalSpace:16,verticalSpace:16},tablet:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24},tabletLarge:{columns:12,gutter:24,horizontalSpace:16,verticalSpace:24}},iconSize:{extra_large:"48px",large:"32px",medium:"20px",regular:"24px",small:"16px"},palette:{alert:{light:"#ffe7ca",main:"#725200"},black:"#000",dataVisualization:{highContrast:{blue:"#3970C1",blueDark:"#002039",coral:"#F95D6A",cyan:"#45CEE0",green:"#B3D849",orange:"#FFA600",orangeDark:"#FF7C43",pink:"#D12771",purple:"#A05195",purpleDark:"#665191"},lowContrast:{blue:"#96B3DE",blueDark:"#5283AB",coral:"#FCA6AD",cyan:"#BAE6FF",green:"#DEF895",orange:"#FDDFA5",orangeDark:"#FCC2A9",pink:"#E995BA",purple:"#D4BBFF",purpleDark:"#B1A2D0"}},error:{light:"#fee5e4",main:"#a72514"},gray:{dark:"#373737",light:"#d3d3d3",main:"#706f6f",megaLight:"#f4f4f4",ultraLight:"#f4f4f4"},info:{light:"#dbedfd",main:"#195f7f"},primary:{dark:"#626262",light:"#D6D6D6",main:"#7A7A7A",ultraLight:"#EDEDED"},secondary:{dark:"#303030",light:"#787878",main:"#616161",ultraLight:"#F4F4F4"},success:{light:"#dcfddb",main:"#286327"},white:"#fff"},spacingBase:8,typography:{fontSize:{L:"18px",M:"16px",S:"14px",XL:"20px",XS:"12px",XXL:"24px",XXS:"10px",XXXL:"32px",XXXXL:"48px"},fontWeight:{bold:700,light:200,normal:400,semibold:600},letterSpacing:{L:3,M:1,S:0,XL:5,XXL:8,XXXL:12},lineHeight:{L:"28px",M:"24px",S:"20px",XL:"32px",XXL:"48px",XXXL:"72px"}}}};const We=Fe({category:{alignItems:"center",cursor:"pointer",display:"flex",flexDirection:"row",justifyContent:"space-between"},colorPicker:e=>({"&::-webkit-color-swatch":{border:`1px solid ${Ie(e).palette.gray.light}`,borderRadius:"4px",padding:0},"&::-webkit-color-swatch-wrapper":{padding:0},alignSelf:"center",appearance:"none",background:"none",border:0,cursor:"pointer",height:Ie(e).spacing(4.25),outline:"none",width:Ie(e).spacing(4.25)}),container:e=>({marginBottom:Ie(e).spacing(2)}),input:e=>({border:`1px solid ${Ie(e).palette.gray.light}`,borderRadius:"4px",color:Ie(e).palette.gray.main,fontSize:"14px",padding:Ie(e).spacing(1)}),inputContainer:e=>({alignItems:"center",display:"flex",flexDirection:"row",justifyContent:"space-between",padding:`${Ie(e).spacing(2)}px 0`}),wrapper:e=>({display:"flex",gap:Ie(e).spacing(1)})}),Be=({paletteConfig:t,onUpdatePaletteConfig:n,formatKey:a})=>{const[r,i]=d(new Set),l=e=>{i((t=>{const n=new Set(t);return n.has(e)?new Set([...n].filter((t=>t!==e))):new Set([...n,e])}))},p=c(((e,a,r)=>{const i=(e=>{if(e)return e.match(/^#[0-9A-Fa-f]{0,6}$/)?e:e.match(/^[0-9A-Fa-f]{6}$/)?`#${e}`:void 0})(r),o=Object.assign(Object.assign({},t||{}),{[e]:Object.assign(Object.assign({},(null==t?void 0:t[e])||{}),{[a]:i})});n(o)}),[n,t]);return o("div",Object.assign({"data-test-id":"color-palette-editor"},{children:t&&Object.keys(t).sort().map((n=>s("div",Object.assign({css:We.container,id:n},{children:[s("div",Object.assign({"aria-expanded":r.has(n),css:We.category,onClick:e=>{e.preventDefault(),l(n)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l(n))},role:"button",tabIndex:0},{children:[o("p",{children:e(n)}),o(ae,{name:r.has(n)?Pe.CHEVRON_TOP:Pe.CHEVRON_BOTTOM,size:re.SIZE_REGULAR})]})),r.has(n)&&Object.keys(t[n]).map((e=>s("div",Object.assign({css:We.inputContainer,id:"input-container"},{children:[o("label",Object.assign({css:{fontWeight:"bold"},htmlFor:`${n}.${e}`},{children:a(e)})),s("form",Object.assign({css:We.wrapper},{children:[o("input",{css:We.input,onChange:t=>{t.preventDefault(),p(n,e,t.target.value)},onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},type:"text",value:t[n][e]}),o("input",{css:We.colorPicker,onChange:t=>p(n,e,t.target.value),type:"color",value:t[n][e]})]}))]}),e)))]}),n)))}))},Ne=Fe({input:e=>({border:`1px solid ${Ie(e).palette.gray.light}`,borderRadius:"4px",color:Ie(e).palette.gray.main,fontSize:"14px",maxWidth:Ie(e).spacing(16),padding:0}),keys:{fontSize:"16px",fontWeight:"bold",marginTop:"8px"},section:e=>({"& > div:first-child":{flexGrow:3},"& > div:last-child":{flexShrink:1},display:"flex",gap:Ie(e).spacing(1),justifyContent:"space-between"}),sectionContainer:e=>({marginBottom:Ie(e).spacing(4)}),select:e=>({border:`1px solid ${Ie(e).palette.gray.light}`,borderRadius:"4px",color:Ie(e).palette.gray.main,fontSize:"14px"})}),Xe=({onUpdateTypographyConfig:e,typographyConfig:t,formatKey:n})=>{const a=c(((n,a,r)=>{const i=Object.assign(Object.assign({},t||{}),{[n]:Object.assign(Object.assign({},(null==t?void 0:t[n])||{}),{[a]:r})});e(i)}),[e,t]),r=c(((e,t)=>{if(e)return e[t]}),[]),i=(e,n)=>{var i;const s=[{label:"Normal",value:"400"},{label:"Semi Bold",value:"600"},{label:"Bold",value:"700"}],l=null===(i=r(t,e))||void 0===i?void 0:i.fontWeight.toString(),d=void 0!==l?s.find((e=>e.value===l)):void 0;return o(ie,Object.assign({css:Ne.select,label:"Font Weight",name:"font-weight",onChange:(t,r)=>a(e,n,null==r?void 0:r.value),value:d},{children:s.map((e=>o(oe,Object.assign({value:e.value},{children:e.label}),e.value)))}))},d=(e,n)=>{var i;const s=null===(i=r(t,e))||void 0===i?void 0:i.fontSize.replace("px","");return o(se,{"aria-labelledby":`${e}.${n}`,css:Ne.input,label:"Font Size(px)",onChange:t=>{t.target.value.match(/^\d{0,2}$/)&&a(e,n,`${t.target.value}px`)},value:s})},p=(e,t)=>{switch(t){case"fontWeight":return o(l,{children:i(e,t)});case"fontSize":return o(l,{children:d(e,t)});default:return null}};return o("div",{children:t&&Object.keys(t).sort().map((e=>s("div",Object.assign({css:Ne.sectionContainer},{children:[o("p",Object.assign({css:Ne.keys,id:e},{children:n(e)})),o("section",Object.assign({css:Ne.section},{children:Object.keys(t[e]).sort(((e,t)=>"fontWeight"===e?-1:1)).map((t=>o("div",Object.assign({id:`${e}.${t}`},{children:p(e,t)}),t)))}))]}),e)))})},$e=Fe({container:e=>({color:Ie(e).palette.gray.dark,display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",position:"relative"}),content:e=>({display:"flex",flexDirection:"column",gap:Ie(e).spacing(3),padding:Ie(e).spacing(3)}),copy:e=>({backgroundColor:Ie(e).palette.white,borderRadius:"4px",padding:Ie(e).spacing(.5)}),drawerHeader:e=>({alignItems:"center",display:"flex",gap:Ie(e).spacing(2),justifyContent:"end",width:"50%"}),drawerWrapper:{display:"flex",justifyContent:"space-between",position:"relative"},getApplyButtonStyles:e=>t=>({"&:hover":{backgroundColor:e?Ie(t).palette.gray.light:"#11003A"},backgroundColor:e?Ie(t).palette.gray.light:"#11003A",borderRadius:Ie(t).spacing(.5),color:"white",cursor:e?"not-allowed":"pointer",fontSize:"14px",justifyContent:"center",padding:Ie(t).spacing(1),textAlign:"center"}),header:e=>({alignItems:"center",display:"flex",gap:Ie(e).spacing(2),justifyContent:"space-between"}),inputForm:e=>({display:"flex",flexDirection:"column",padding:`${Ie(e).spacing(0)}px ${Ie(e).spacing(1)}px`,width:Ie(e).spacing(30)}),popoverWrapper:e=>({display:"flex",flexDirection:"column",width:Ie(e).spacing(30)}),pre:e=>({backgroundColor:"#FFFFFF66",borderRadius:"8px",fontSize:"14px",padding:Ie(e).spacing(.3)}),presetListItem:e=>({alignItems:"center",display:"flex",height:Ie(e).spacing(6),justifyContent:"space-between",padding:Ie(e).spacing(1),width:"100%"}),presetOption:e=>({"&:hover":{backgroundColor:"scopeTheme(theme).palette.gray.ultraLight"},backgroundColor:"transparent",borderRadius:"4px",color:Ie(e).palette.gray.dark,fontSize:"14px",fontWeight:"normal",padding:Ie(e).spacing(.5),width:"100%"}),presetsButton:e=>({"&:hover":{backgroundColor:"#d1d4d7"},backgroundColor:"#E4E5E7",borderRadius:"4px",cursor:"pointer",display:"flex",fontSize:Ie(e).typography.fontSize.S,gap:Ie(e).spacing(.5),justifyContent:"center",padding:`${Ie(e).spacing(.5)}px ${Ie(e).spacing(1)}px`,width:"100%"}),textArea:e=>({fontSize:Ie(e).typography.fontSize.S,minHeight:Ie(e).spacing(24),width:"100%"})}),Me=({themeConfig:r,onUpdateThemeConfig:i,presets:l,showDrawer:u})=>{const[h,b]=d(!1),m=Object.keys(r),v=p((()=>{const{palette:e,components:n}=Re.fallback,{Typography:a}=n||{},r=t(e||{},["black","white","dataVisualization"]);return{components:{Typography:a},palette:Object.assign({},r)}}),[]),f=m.flatMap((e=>{if("components"===e&&r[e]&&"object"==typeof r[e]){return Object.keys(r[e])}return[e]})).map((t=>"palette"===t?{label:"Color Palette",value:"Color Palette"}:{label:e(t),value:e(t)})).sort(((e,t)=>e.label.localeCompare(t.label))),[S,C]=d(f[0].value),x=e=>n(a(e)),y=g(null),[O,j]=Ee(!1),k=[{presetName:"Default",themeConfig:v},{presetName:"Auctane",themeConfig:Re.auctane},...l||[]],[w,F]=Ee(!1),[I,E]=d(""),[L,A]=d(),D=c((()=>{F(),E(""),A("")}),[F]);return s("div",Object.assign({"aria-label":"Theme Creator",css:$e.container,"data-testid":"theme-creator",role:"region"},{children:[s("div",Object.assign({css:$e.content},{children:[s("div",Object.assign({css:$e.header},{children:[o("div",Object.assign({css:{overflow:"scroll",width:"100%"}},{children:o(V,{onSelectTab:e=>{C(e)},selectedTab:S,tabs:f})})),s("div",{children:[s("button",Object.assign({"aria-controls":"presets-popover","aria-expanded":O,css:$e.presetsButton,onClick:e=>{e.preventDefault(),j()},ref:y},{children:["Presets",o(ae,{name:Pe.CARET_BOTTOM,size:re.SIZE_SMALL})]})),o(le,Object.assign({container:document.querySelector("#theme-creator"),isOpen:O,onClickAway:()=>j(),placement:"bottom-end",reference:y.current},{children:o("div",Object.assign({css:$e.popoverWrapper},{children:w?s("form",Object.assign({css:$e.inputForm,onSubmit:e=>{e.preventDefault();const t=I.replace(/([a-zA-Z0-9_]+)(?=:)/g,'"$1"').replace(/,\s*(}|\])/g,"$1").replace(/;$/,"");try{const e=JSON.parse(t),n=Object.assign(Object.assign({},r),{components:Object.assign(Object.assign({},r.components),e.components),palette:Object.assign(Object.assign({},r.palette),e.palette)});i(n),D(),j()}catch(e){A("Error parsing input."),console.error("Error parsing input",e)}}},{children:[o(de,Object.assign({variant:"small"},{children:"*Must be in JavaScript object format"})),o("textarea",{css:$e.textArea,disabled:!w,onChange:e=>E(e.target.value),placeholder:JSON.stringify({palette:{primary:{dark:"#1E0257",light:"#9D96FF",main:"#11003A",ultraLight:"#F1F2F3"}},components:{Typography:{heading3:{fontSize:"24px",fontWeight:700}}}},null,2).replace(/"([^"]+)":/g,"$1:"),required:!0,value:I}),L?o(de,Object.assign({css:{color:"red"},variant:"small"},{children:L})):o(G,{multiplier:2}),s(q,Object.assign({justify:"end"},{children:[o(ce,Object.assign({onClick:D,variant:pe.TEXT},{children:"Cancel"})),o(ce,Object.assign({css:$e.getApplyButtonStyles(!I),disabled:!I,type:"submit"},{children:"Apply"}))]}))]})):s("ul",Object.assign({css:{listStyle:"none"}},{children:[k.map(((e,t)=>s("li",Object.assign({css:$e.presetListItem},{children:[o(de,{children:e.presetName}),o(ce,Object.assign({"aria-label":`Set ${e.presetName} Theme`,css:$e.getApplyButtonStyles(),onClick:t=>{var n;t.preventDefault(),j(),n=e.themeConfig,i(n),C("Color Palette")}},{children:"Apply"}),e.presetName)]}),t))),o("li",Object.assign({css:$e.presetListItem},{children:o("button",Object.assign({css:$e.presetsButton,onClick:()=>{F()}},{children:"Input Custom Theme"}))}))]}))}))}))]})]})),o(de,Object.assign({role:"heading",variant:"heading4"},{children:`${S} Editor`})),((e,t)=>{var n;switch(t){case"Color Palette":return o(Be,{formatKey:x,onUpdatePaletteConfig:t=>{i(Object.assign(Object.assign({},e),{palette:t}))},paletteConfig:e.palette});case"Typography":return o(Xe,{formatKey:x,onUpdateTypographyConfig:t=>{i(Object.assign(Object.assign({},e),{components:Object.assign(Object.assign({},e.components),{Typography:t})}))},typographyConfig:null===(n=e.components)||void 0===n?void 0:n.Typography});default:return s("div",{children:["Editor for ",t," is not implemented yet."]})}})(r,S)]})),u&&o(Se,Object.assign({"aria-label":"Show themeConfig.js Code Drawer",headerContent:s("div",Object.assign({css:$e.drawerHeader},{children:[o("pre",Object.assign({css:$e.pre},{children:"themeConfig.js"})),u.copyToClipboardText&&o("div",Object.assign({css:$e.copy},{children:o(K,{content:u.copyToClipboardText})}))]})),isOpen:h,toggleDrawer:()=>b(!h)},{children:u.content()}))]}))},He=({onRedirectToOnboarding:e,showFunds:t})=>{const{mutateAsync:n,error:a}=m(),i=c((e=>r(void 0,void 0,void 0,(function*(){try{yield n(e)}catch(e){console.log(e)}}))),[n]);return o(E,{addFunds:i,addFundsError:a,onRedirectToOnboarding:e,showFunds:t})},Ue=L(He,J,{resources:{en:A}});var Ve=Object.freeze({__proto__:null,Component:He,Element:Ue});const Ge=()=>{const e=t(D(),[]);return o(z,Object.assign({},e))},qe=L(Ge,J,{resources:{en:A}});var Ke=Object.freeze({__proto__:null,Component:Ge,Element:qe});const Je=e=>{var n,a,{features:s,externalOrderId:l,externalOrderNumber:d,externalShipmentId:p,onLoad:g,onShipmentUpdated:u,orderSourceCode:h,salesOrderId:b,shipFromAddresses:m,warehouseId:x,shipmentId:y,printLabelLayout:O,currency:j}=e,k=t(e,["features","externalOrderId","externalOrderNumber","externalShipmentId","onLoad","onShipmentUpdated","orderSourceCode","salesOrderId","shipFromAddresses","warehouseId","shipmentId","printLabelLayout","currency"]);const{data:w}=v(),{data:F}=f(),{shipment:I,salesOrder:E,refetchPendingSalesOrderShipments:L,isLoading:A,errors:D}=te({errorWhenShipmentCancelled:null==s?void 0:s.enableErrorWhenShipmentCancelled,externalOrderId:l,externalOrderNumber:d,externalShipmentId:p,onLoad:g,onShipmentUpdated:u,orderSourceCode:h,salesOrderId:b,shipFromAddresses:m,shipmentId:y,useWarehouses:null===(n=null==s?void 0:s.shipmentForm)||void 0===n?void 0:n.useWarehouses,warehouseId:x}),{data:z,isInitialLoading:P}=S((null==I?void 0:I.insuranceProvider)===C.InsuranceProviderType.SHIPSURANCE?C.InsuranceProviderType.SHIPSURANCE:void 0),R=null!=j?j:i(null===(a=null==w?void 0:w[0])||void 0===a?void 0:a.currencyCode),W=c((e=>r(void 0,void 0,void 0,(function*(){yield L(),yield null==u?void 0:u(e)}))),[u,L]);return o(T,Object.assign({data:I||E,errors:D,isLoading:A||P},{children:o(_,Object.assign({currency:R,features:s,insuranceAccount:z,isLoading:A||P,onShipmentUpdated:W,printLabelLayout:null!=O?O:null==F?void 0:F.defaultLabelLayout,salesOrder:E,shipFromAddresses:m,shipment:I},k))}))},Ze=L(Je,J,{resources:{en:A}});var Ye=Object.freeze({__proto__:null,Component:Je,Element:Ze});const Qe=({isModalFullScreen:e})=>{const n=t(P(),[]);return o(R,Object.assign({isModalFullScreen:e},n))},et=L(Qe,J,{resources:{en:A}});var tt=Object.freeze({__proto__:null,Component:Qe,Element:et});const nt=Fe({errorState:e=>Object.assign({backgroundColor:Ie(e).palette.white},Ie(e).getComponentOverride("Table")),tableParagraph:{margin:0}}),at=({labelStatus:e,features:t,onClickPrintLabel:n,onClickVoidLabel:a,onClickPrintForms:r,onClickViewDetails:i,onRowClick:h,onClickExternalOrderId:b,onClickExternalShipmentId:m})=>{var v,f,S;const{t:C}=ne(["common","list-labels"]),{globalFeatures:O,getFeatures:j}=Le(),k=j("labelsGridFeatures"),w=g(e),[F,I]=d("desc");t=Object.assign(Object.assign({},k),null!=t?t:{});const E=p((()=>{var e;return null===(e=null==t?void 0:t.columns)||void 0===e?void 0:e.find((e=>"labelId"===e.name))}),[t]),L=p((()=>{var e;return null===(e=null==t?void 0:t.columns)||void 0===e?void 0:e.find((e=>"shipmentId"===e.name))}),[t]),A=p((()=>{var e;return null===(e=null==t?void 0:t.columns)||void 0===e?void 0:e.find((e=>"trackingStatus"===e.name))}),[t]),D=E&&(null===(v=E.allowFilter)||void 0===v||v),z=L&&(null===(f=L.allowFilter)||void 0===f||f),T=A&&(null===(S=A.allowFilter)||void 0===S||S),{labels:_,getGridData:P,isError:R,isLoading:W,filters:B,setFilters:N,pageConfig:X,isAnyFilterActive:$,shouldShowFilters:M,clearAllFilters:H}=(({createdDateSortBy:e,labelStatus:t,showShipmentIdFilter:n,showLabelIdFilter:a,showTrackingStatusFilter:r})=>{var i,o,s;const l={labelId:{enabled:!!a,value:""},shipmentId:{enabled:!!n,value:""},trackingStatus:{enabled:!!r,value:[]}},c=ve(),{getServiceName:g}=fe(),{page:h,pageSize:b,pagerProps:m}=Ce(20),[v,f]=d(l),S=Object.keys(v).some((e=>{const t=v[e];return(null==t?void 0:t.enabled)&&t.value})),C=Object.keys(v).some((e=>{const t=v[e];return null==t?void 0:t.enabled}));u((()=>{f({labelId:{enabled:!!a,value:""},shipmentId:{enabled:!!n,value:""},trackingStatus:{enabled:!!r,value:[]}})}),[a,n,r]);const{data:O,isLoading:j,isError:k}=x({queryFnParams:{labelStatus:t,page:h,pageSize:b,shipmentId:v.shipmentId.value||void 0,sortDir:null!=e?e:"desc"}}),w=p((()=>(null==O?void 0:O.labels)?O.labels.filter((e=>{var t,n,a,r;return!(null===(n=null===(t=null==v?void 0:v.trackingStatus)||void 0===t?void 0:t.value)||void 0===n?void 0:n.length)||"voided"!==e.status&&(null===(a=null==v?void 0:v.trackingStatus)||void 0===a?void 0:a.value.includes(e.trackingStatus))||"voided"===e.status&&(null===(r=null==v?void 0:v.trackingStatus)||void 0===r?void 0:r.value.includes(e.status))})).map((e=>Object.assign(Object.assign({},e),{bodyCellStyles:{color:"voided"===e.status?c.palette.gray[400]:void 0},serviceName:g(e)}))):[]),[null==O?void 0:O.labels,null===(i=null==v?void 0:v.trackingStatus)||void 0===i?void 0:i.value,c.palette.gray,g]),F=C&&(S||Boolean(null==w?void 0:w.length)),{data:I,isError:E,isInitialLoading:L}=y((null===(o=v.labelId)||void 0===o?void 0:o.value)||void 0),A=null===(s=v.labelId)||void 0===s?void 0:s.value,D=(e,t)=>(null==t?void 0:t.length)&&!t.includes(e),z=(e=>{var n,a;if(A&&!E){let r=!0;return t&&t!==(null==e?void 0:e.status)&&(r=!1),""!==(null==v?void 0:v.shipmentId.value)&&(null==v?void 0:v.shipmentId.value)!==(null==e?void 0:e.shipmentId)&&(r=!1),("voided"===(null==e?void 0:e.status)&&D("voided",null===(n=v.trackingStatus)||void 0===n?void 0:n.value)||"voided"!==(null==e?void 0:e.status)&&(null==e?void 0:e.trackingStatus)&&D(e.trackingStatus,null===(a=v.trackingStatus)||void 0===a?void 0:a.value))&&(r=!1),r?e:void 0}})(I),T=A&&(E||!z);return{clearAllFilters:()=>{f(l)},filters:v,getGridData:()=>z?[Object.assign(Object.assign({},z),{bodyCellStyles:{color:"voided"===z.status?c.palette.gray[400]:void 0},serviceName:g(z)})]:T?[]:w||[],isAnyFilterActive:S,isError:k,isLoading:j||L,labels:w,pageConfig:{currentPage:z?1:(null==O?void 0:O.page)||0,pagerProps:m,pagesAmount:(null==O?void 0:O.pages)||0,pageSize:b,showPagination:!z&&((null==O?void 0:O.total)||0)>b,totalElements:z?1:(null==O?void 0:O.total)||0},setFilters:e=>{m.onPageSelect(1),f(e)},shouldShowFilters:F}})({createdDateSortBy:F,labelStatus:e,showLabelIdFilter:D,showShipmentIdFilter:z,showTrackingStatusFilter:T});u((()=>{w.current!==e&&X.pagerProps.resetCurrentPage(),w.current=e}),[e,X.pagerProps]);const U=p((()=>({labelId:Object.assign(Object.assign({},B.labelId),{nickname:null==E?void 0:E.nickname}),shipmentId:Object.assign(Object.assign({},B.shipmentId),{nickname:null==L?void 0:L.nickname}),trackingStatus:Object.assign(Object.assign({},B.trackingStatus),{nickname:null==A?void 0:A.nickname})})),[B,E,L,A]),V=c((()=>{I("desc"===F?"asc":"desc")}),[F]),q=p((()=>{var e;const d={completed:{color:ge.SUCCESS,text:C("list-labels:status.completed")},error:{color:ge.ERROR,text:C("list-labels:status.error")},processing:{color:ge.INFO,text:C("list-labels:status.processing")},voided:{color:ge.INFO,text:C("list-labels:status.voided")}},c={delivered:{color:ge.SUCCESS,text:C("list-labels:trackingStatus.delivered")},error:{color:ge.ERROR,text:C("list-labels:trackingStatus.error")},in_transit:{color:ge.GRAY,text:C("list-labels:trackingStatus.inTransit")},unknown:{color:ge.ALERT,text:C("list-labels:trackingStatus.unknown")}},p={createdDate:{headerContent:o(xe,{headerText:C("list-labels:headers.created"),onToggleSort:V,sortDirection:F}),renderCellContent:e=>o(ye,{date:e.createdAt,short:!0})},externalOrderId:{headerContent:C("list-labels:headers.externalOrderId"),renderCellContent:e=>e.externalOrderId&&b?o(ue.Link,Object.assign({bold:!1,onClick:()=>{var t;return null==b?void 0:b(null!==(t=e.externalOrderId)&&void 0!==t?t:void 0)}},{children:e.externalOrderId})):o(de,Object.assign({component:"span",variant:"body2"},{children:e.externalOrderId}))},externalShipmentId:{headerContent:C("list-labels:headers.externalShipmentId"),renderCellContent:e=>e.externalShipmentId&&m?o(ue.Link,Object.assign({bold:!1,onClick:()=>{var t;return null==m?void 0:m(null!==(t=e.externalShipmentId)&&void 0!==t?t:void 0)}},{children:e.externalShipmentId})):o(de,Object.assign({component:"span",variant:"body2"},{children:e.externalShipmentId}))},labelId:{headerContent:C("list-labels:headers.labelId"),renderCellContent:e=>o(de,Object.assign({component:"span",variant:"body2"},{children:e.labelId}))},packages:{headerContent:C("list-labels:headers.parcels"),renderCellContent:e=>o(de,Object.assign({component:"span",variant:"body2"},{children:e.packages.length}))},recipient:{headerContent:C("list-labels:headers.recipient"),renderCellContent:e=>s(l,{children:[o(de,Object.assign({component:"p",css:nt.tableParagraph,variant:"body2"},{children:e.shipTo.name})),s(de,Object.assign({component:"p",css:nt.tableParagraph,variant:"body2"},{children:[e.shipTo.postalCode,", ",e.shipTo.cityLocality]}))]})},shipDate:{headerContent:C("list-labels:headers.shipDate"),renderCellContent:e=>o(ye,{date:e.shipDate,short:!0})},shipmentId:{headerContent:C("list-labels:headers.shipmentId"),renderCellContent:e=>o(de,Object.assign({component:"span",variant:"body2"},{children:e.shipmentId}))},shippingService:{headerContent:C("list-labels:headers.shipping"),renderCellContent:e=>s(l,{children:[o(de,Object.assign({component:"p",css:nt.tableParagraph,variant:"body2"},{children:e.serviceName||e.serviceCode})),e.trackable&&o(ue.Link,Object.assign({bold:!1,href:e.trackingUrl,isExternal:!0,target:"_blank"},{children:e.trackingNumber}))]})},status:{headerContent:C("list-labels:headers.status"),renderCellContent:e=>o(he,Object.assign({color:d[e.status].color,variant:be.LINEAL_FILLED},{children:d[e.status].text}))},trackingStatus:{headerContent:C("list-labels:headers.trackingStatus"),renderCellContent:e=>"voided"===e.status?s(l,{children:[C("list-labels:status.voided")+" ",o(ye,{date:e.createdAt,short:!0})]}):o(he,Object.assign({color:c[e.trackingStatus].color,variant:be.LINEAL_FILLED},{children:c[e.trackingStatus].text}))}},g=[];return null===(e=null==t?void 0:t.columns)||void 0===e||e.forEach((e=>{p[e.name]&&(e.nickname?g.push(Object.assign(Object.assign({},p[e.name]),{headerContent:e.nickname})):g.push(p[e.name]))})),(null==t?void 0:t.showActions)&&_.some((e=>"completed"===e.status))&&g.push({headerContent:"",renderCellContent:e=>{var t,s;const l=!!(null===(t=e.labelDownload)||void 0===t?void 0:t.href)&&"completed"===e.status,d=!!a&&"completed"===e.status,c=!!(null===(s=e.formDownload)||void 0===s?void 0:s.href)&&"completed"===e.status,p=!!i;if(!(l||d||c||p))return null;const g=[...p?[Y.VIEW_DETAILS]:[],...l?[Y.PRINT_LABEL]:[],...d?[Y.VOID_LABEL]:[],...c?[Y.PRINT_FORMS]:[]];return o(Z,{allowedActions:g,onActionClick:t=>{t===Y.PRINT_LABEL&&(null==n||n(),window.open(e.labelDownload.href,"_blank","noopener, noreferrer")),t===Y.VOID_LABEL&&(null==a||a(e)),t===Y.PRINT_FORMS&&(null==r||r(),window.open(e.formDownload.href,"_blank","noopener, noreferrer")),t===Y.VIEW_DETAILS&&(null==i||i(e))}})}}),g}),[C,V,F,null==t?void 0:t.columns,null==t?void 0:t.showActions,_,b,m,i,a,n,r]);return W?o(Q,{message:C("loading.labels")}):R?o(Oe,{css:nt.errorState,subtitle:[C("list-labels:errorMessages.subtitle"),C("errorMessages.refreshAndTryAgain")],title:C("list-labels:errorMessages.title")}):s(l,{children:[o(je,{columns:q,data:P(),emptyContent:o(me,$?Object.assign({isElevated:!1,subtitle:C("list-labels:emptyWithFilters.subtitle"),title:C("list-labels:emptyWithFilters.title")},{children:o(ce,Object.assign({onClick:H},{children:C("list-labels:emptyWithFilters.button")}))}):{isElevated:!1,subtitle:C("list-labels:empty.subtitle"),title:C("list-labels:empty.title")}),filters:M&&o(ke,{filters:U,onClearAllFilters:H,onFiltersUpdated:N}),footerContent:o(we,{onPageChange:X.pagerProps.onPageSelect,page:X.currentPage,pages:X.pagesAmount,pageSize:X.pageSize,showPagination:X.showPagination,total:X.totalElements}),onRowClick:h}),O.poweredByShipEngine&&s(l,{children:[o(G,{}),o(ee,{})]})]})},rt=L(at,J,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:A}});var it=Object.freeze({__proto__:null,Component:at,Element:rt});const ot=(e,t)=>({end:Te(_e(t,59),23),start:Te(_e(e,0),0)}),st=(e,t)=>({createdDate:{enabled:t,value:null},shipmentId:{enabled:e,value:""}}),lt=({shipmentStatus:e,showShipmentIdFilter:t=!0,showCreatedDateFilter:n=!0})=>{var a,r,i,o;const s=st(t,n),{getServiceName:l}=fe(),{page:c,pageSize:g,pagerProps:h}=Ce(20),[b,m]=d(s),v=Object.keys(b).some((e=>{const t=b[e];return(null==t?void 0:t.enabled)&&t.value})),f=Object.keys(b).some((e=>{const t=b[e];return null==t?void 0:t.enabled}));u((()=>{const e=st(t,n);m(e)}),[n,t]);const{data:S,isLoading:C,isError:x}=O(Object.assign({page:c,pageSize:g,shipmentStatus:e,sortBy:"modified_at",sortDir:"desc"},((e,t)=>{if(!e||!t)return{};const n=ot(e,t);return{createdAtEnd:Ae(n.end),createdAtStart:Ae(n.start)}})(null===(r=null===(a=b.createdDate)||void 0===a?void 0:a.value)||void 0===r?void 0:r.start,null===(o=null===(i=b.createdDate)||void 0===i?void 0:i.value)||void 0===o?void 0:o.end))),y=p((()=>null==S?void 0:S.shipments.map((e=>Object.assign(Object.assign({},e),{serviceName:l(e)})))),[null==S?void 0:S.shipments,l]),k=f&&(v||Boolean(null==y?void 0:y.length)),{data:w,error:F,isInitialLoading:I}=j({queryFnParams:{shipmentId:b.shipmentId.value||void 0},retry:!1}),E=b.shipmentId.value,L=(t=>{var n,a,r,i;if(E&&!F){let o=!0;e&&(null==t?void 0:t.shipmentStatus)!==e&&(o=!1);const s=null===(n=b.createdDate)||void 0===n?void 0:n.value;return(null==s?void 0:s.start)&&s.end&&(null==t?void 0:t.createdAt)&&(a=s.start,r=s.end,i=t.createdAt,De(a,r)&&De(a,new Date(i))||ze(new Date(i),ot(a,r))||(o=!1)),o?t:void 0}})(w),A=E&&(F||!L);return{clearAllFilters:()=>{m(s)},filters:b,getGridData:()=>L?[Object.assign(Object.assign({},L),{serviceName:l(L)})]:A?[]:y||[],isAnyFilterActive:v,isError:x,isLoading:C||I,pageConfig:{currentPage:L?1:(null==S?void 0:S.page)||0,pagerProps:h,pagesAmount:(null==S?void 0:S.pages)||0,pageSize:g,showPagination:!L&&((null==S?void 0:S.total)||0)>g,totalElements:L?1:(null==S?void 0:S.total)||0},setFilters:e=>{h.onPageSelect(1),m(e)},shipments:y,shouldShowFilters:k}},dt=Fe({errorState:e=>Object.assign({backgroundColor:Ie(e).palette.white},Ie(e).getComponentOverride("Table")),tableParagraph:{margin:0}}),ct=({onRowClick:e,onClickCancelShipment:t,shipmentStatus:n,showShipmentIdFilter:a=!0,showCreatedDateFilter:r=!0})=>{const{t:i}=ne(["common","list-shipments"]),{globalFeatures:d}=Le(),{isLoading:c,isError:p,filters:g,setFilters:u,pageConfig:h,getGridData:b,isAnyFilterActive:m,shouldShowFilters:v,clearAllFilters:f}=lt({shipmentStatus:n,showCreatedDateFilter:r,showShipmentIdFilter:a});if(c)return o(Q,{message:i("loading.shipments")});if(p)return o(Oe,{css:dt.errorState,subtitle:[i("list-shipments:errorMessages.subtitle"),i("errorMessages.refreshAndTryAgain")],title:i("list-shipments:errorMessages.title")});const S={cancelled:{color:ge.ALERT,text:i("list-shipments:status.cancelled")},label_purchased:{color:ge.SUCCESS,text:i("list-shipments:status.purchased")},pending:{color:ge.SUCCESS,text:i("list-shipments:status.readyToBuy")},processing:{color:ge.INFO,text:i("list-shipments:status.processing")}},C=[{headerContent:i("list-shipments:headers.shipmentId"),renderCellContent:e=>o(de,Object.assign({component:"p",css:dt.tableParagraph,variant:"body2"},{children:e.shipmentId}))},{headerContent:i("list-shipments:headers.parcels"),renderCellContent:e=>o(de,Object.assign({component:"p",css:dt.tableParagraph,variant:"body2"},{children:e.packages.length}))},{headerContent:i("list-shipments:headers.recipient"),renderCellContent:e=>{const t=!!(e.shipTo.name||e.shipTo.postalCode||e.shipTo.cityLocality),n=!(!e.shipTo.postalCode&&!e.shipTo.cityLocality);return t?s(l,{children:[o(de,Object.assign({component:"p",css:dt.tableParagraph,variant:"body2"},{children:e.shipTo.name})),n&&o(de,Object.assign({component:"p",css:dt.tableParagraph,variant:"body2"},{children:[e.shipTo.postalCode,e.shipTo.cityLocality].filter(Boolean).join(", ")}))]}):"--"}},{headerContent:i("list-shipments:headers.shipping"),renderCellContent:e=>o(de,Object.assign({component:"p",css:dt.tableParagraph,variant:"body2"},{children:e.serviceName||i("list-shipments:none")}))},{headerContent:i("list-shipments:headers.created"),renderCellContent:e=>o(ye,{date:e.createdAt,short:!0})},{headerContent:i("list-shipments:headers.modified"),renderCellContent:e=>o(ye,{date:e.modifiedAt,short:!0})},{headerContent:i("list-shipments:headers.status"),renderCellContent:e=>o(he,Object.assign({color:S[e.shipmentStatus].color,variant:be.LINEAL_FILLED},{children:S[e.shipmentStatus].text}))},{headerContent:"",renderCellContent:e=>{const n=[...!!t&&"pending"===e.shipmentStatus?[Y.CANCEL_SHIPMENT]:[]];return n.length>0&&o(Z,{allowedActions:n,onActionClick:n=>((e,n)=>{e===Y.CANCEL_SHIPMENT&&(null==t||t(n))})(n,e)})}}];return s(l,{children:[o(je,{columns:C,data:b(),emptyContent:o(me,m?Object.assign({isElevated:!1,subtitle:i("list-shipments:emptyState.filtersSubtitle"),title:i("list-shipments:emptyState.filtersTitle")},{children:o(ce,Object.assign({onClick:f},{children:i("list-shipments:emptyState.viewAll")}))}):{isElevated:!1,subtitle:i("list-shipments:emptyState.subtitle"),title:i("list-shipments:emptyState.title")}),filters:v&&o(ke,{filters:g,onClearAllFilters:f,onFiltersUpdated:u}),footerContent:o(we,{onPageChange:h.pagerProps.onPageSelect,page:h.currentPage,pages:h.pagesAmount,pageSize:h.pageSize,showPagination:h.showPagination,total:h.totalElements}),onRowClick:e}),d.poweredByShipEngine&&s(l,{children:[o(G,{}),o(ee,{})]})]})},pt=L(ct,J,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:A}});var gt=Object.freeze({__proto__:null,Component:ct,Element:pt});const ut=b(void 0),ht=({children:e,editableTheme:t})=>{const[n,a]=d(t);return o(ut.Provider,Object.assign({value:{setThemeConfig:a,themeConfig:n}},{children:e}))},bt=()=>{const e=h(ut);if(!e)throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");return e},mt=e=>{var n=t(e,[]);return o(Me,Object.assign({},n))},vt=L(mt,J,{resources:{en:A}});var ft=Object.freeze({__proto__:null,Component:mt,Element:vt});const St=({features:e,onClickPrintLabel:t,onClickPurchaseLabel:n,onClickVoidLabel:a,shipmentId:r})=>{var i,s,l;const{t:d}=ne(["common","view-shipment"]),c=k(r),{data:{labels:p=[]}={}}=x({queryFnParams:{shipmentId:r}}),g=w(null===(s=null===(i=c.data)||void 0===i?void 0:i.salesOrderIds)||void 0===s?void 0:s[0]),u=F(),h=I();if(c.isInitialLoading)return o(Q,{message:d("loading.shipment")});if(c.error)throw new Error(c.error.map((e=>e.message)).join(", "));if(!c.data)throw new Error("errorMessages.unableToLoad.shipment");const b=null===(l=u.data)||void 0===l?void 0:l.find((e=>{var t;return e.warehouseId===(null===(t=c.data)||void 0===t?void 0:t.warehouseId)}));return o(W,{carriers:h.data,features:e,labels:p,onClickPrintLabel:t,onClickPurchaseLabel:n,onClickVoidLabel:a,salesOrder:g.data,shipment:c.data,warehouse:b})},Ct=L(St,J,{resources:{en:A}});var xt=Object.freeze({__proto__:null,Component:St,Element:Ct});const yt=()=>{const e=t(B(),[]);return o(N,Object.assign({},e))},Ot=L(yt,J,{resources:{en:A}});var jt=Object.freeze({__proto__:null,Component:yt,Element:Ot});const kt=({onRedirectToOnboarding:e})=>{const{t:t}=ne(["common","purchase-label"]),{data:n,refetch:a,isInitialLoading:i,isFetching:s,isStale:l}=v(),{mutateAsync:d,error:p}=m(),g=c((e=>r(void 0,void 0,void 0,(function*(){try{if(!n||!n.length)throw new Error("No Funding Source found");yield d({fundingSourceId:n[0].fundingSourceId,funds:e}),yield a()}catch(e){console.log(e)}}))),[d,n,a]);if(i||s&&l)return o(Q,{message:t("loading.carriers")});if(!n||!n.length)throw new Error("errorMessages.unableToLoad.shipment");return o(X,{addFunds:g,addFundsError:p,fundingSource:n[0],onRedirectToOnboarding:e})},wt=L(kt,J,{resources:{en:A}});var Ft=Object.freeze({__proto__:null,Component:kt,Element:wt});const It=()=>{const e=t($(),[]);return o(M,Object.assign({},e))},Et=L(It,J,{resources:{en:A}});var Lt=Object.freeze({__proto__:null,Component:It,Element:Et});const At=({onRedirectToOnboarding:e})=>o(H,{onRedirectToOnboarding:e}),Dt=L(At,J,{resources:{en:A}});var zt=Object.freeze({__proto__:null,Component:At,Element:Dt});const Tt=()=>o(U,{}),_t=L(Tt,J,{resources:{en:A}});var Pt=Object.freeze({__proto__:null,Component:Tt,Element:_t});export{ht as T,Ke as a,tt as b,ft as c,xt as d,jt as e,Ft as f,Lt as g,zt as h,Pt as i,it as l,Ve as m,Ye as p,gt as s,Re as t,bt as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r,Fragment as n}from"@emotion/react/jsx-runtime";import{createContext as o,useContext as t,useMemo as d,useState as i,useCallback as a,useReducer as s,createElement as l}from"react";import{g as c,d as u,_ as m,Q as v,E as f}from"./validation.js";import{useGetFundingSourceMetadata as g,useValidateAddresses as p,useFundingSourcesAddFunds as h,useAddFunds as A,useListCarriers as y,useListFundingSources as b,SE as C,CodedError as R}from"@shipengine/react-api";import{c as E,u as O}from"./address.js";import w from"lodash/isEqual.js";import L from"lodash/omit.js";import{createPortal as j}from"react-dom";const S="en-US",P=o(void 0),T=({baseURL:r="https://elements.shipengine.com",cdnURL:n="https://cdn.packlink.com",children:o,container:t,features:d,getToken:i,locale:a,onError:s=(()=>{}),scope:l="lmnt",theme:m,emotionCacheShadowRootContainer:v})=>{var f;const g=a||(()=>{var e;return"undefined"==typeof window?S:null!==(e=null===navigator||void 0===navigator?void 0:navigator.language)&&void 0!==e?e:S})(),p=c(["globalFeatures"]),h={baseURL:r,cdnURL:n,container:t,emotionCacheShadowRootContainer:v,getFeatures:e=>{var r;return u(null!==(r=c([e]))&&void 0!==r?r:{},null==d?void 0:d[e])},getToken:i,globalFeatures:Object.assign(Object.assign({},p),null!==(f=null==d?void 0:d.globalFeatures)&&void 0!==f?f:{}),locale:g,onError:s,scope:l,theme:m};return e(P.Provider,Object.assign({value:h},{children:o}))},I=()=>{const e=t(P);if(!e)throw new Error("useElements must be called from within the scope of ElementsProvider");return e},F=()=>{var e,r;const n=g(),o=null===(r=null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.defaultRegionProfile)||void 0===r?void 0:r.countryCode,t=d((()=>E.flatMap((e=>({label:e.name,value:e.code})))),[]),i=d((()=>{const e=(new Intl.NumberFormat).resolvedOptions().locale,r=null!=o?o:e.split("-")[1];return t.find((e=>e.value===r))}),[t,o]);return{countryCodeOptions:t,defaultCountryCodeOption:i}},U=()=>d((()=>O.flatMap((e=>({label:`${e.code} - ${e.name}`,value:e.code})))),[]),M=()=>{const[e,r]=i(),{error:n,mutateAsync:o}=p(),t=a(((e,r)=>{if(void 0===e||void 0===r)return!1;const n=Object.fromEntries(Object.entries(r).map((([e,r])=>[e,"string"==typeof r?r.toLowerCase():r]))),o=Object.fromEntries(Object.entries(e).map((([e,r])=>[e,"string"==typeof r?r.toLowerCase():r])));return""===o.addressLine2&&(o.addressLine2=null),!!w(L(o,["postalCode","addressResidentialIndicator"]),L(n,["postalCode","addressResidentialIndicator"]))}),[]),d=a(((e,r)=>void 0!==e&&void 0!==r&&(e===r||e.includes(r))),[]),s=a((e=>{var r;return"error"===e.status?{validation:e,validationType:"ERROR"}:e.matchedAddress&&e.matchedAddress.name===e.originalAddress.name&&e.matchedAddress.companyName===e.originalAddress.companyName&&e.matchedAddress.addressLine1===e.originalAddress.addressLine1&&e.matchedAddress.addressLine2===e.originalAddress.addressLine2&&e.matchedAddress.cityLocality===e.originalAddress.cityLocality&&e.matchedAddress.stateProvince===e.originalAddress.stateProvince&&e.matchedAddress.postalCode===e.originalAddress.postalCode&&e.matchedAddress.countryCode===e.originalAddress.countryCode?{address:e.originalAddress,validationType:"EXACT"}:e.matchedAddress&&t(e.matchedAddress,e.originalAddress)&&d(null===(r=e.matchedAddress)||void 0===r?void 0:r.postalCode,e.originalAddress.postalCode)?{address:e.matchedAddress,validationType:"SOFT"}:e.matchedAddress?{validation:e,validationType:"SUGGESTED"}:{validation:e,validationType:"ERROR"}}),[t,d]),l=a((e=>m(void 0,void 0,void 0,(function*(){var n;const t=yield o([e.originAddress,...e.returnAddress?[e.returnAddress]:[]]),[d,i]=t,a=s(v(d,e.originAddress.email)),l=i&&s(v(i,null===(n=e.returnAddress)||void 0===n?void 0:n.email));return r({originAddress:a,returnAddress:l}),{originAddress:a,returnAddress:l}}))),[s,o]);return{errors:n,setValidationPreference:r,validate:l,validationPreference:e}},N=({children:e,target:r})=>{if(r){if(r instanceof HTMLElement||r instanceof ShadowRoot)return j(e,r);if(r.current)return j(e,r.current)}return null},k=o(void 0);k.displayName="RootPortalContext";const x=({children:r,emotionCacheShadowRootContainer:n})=>{const o=d((()=>{if(n)return n;{let e=document.getElementById("root-portal");return e||(e=document.createElement("div"),e.setAttribute("id","root-portal"),document.body.appendChild(e)),e}}),[n]);return e(k.Provider,Object.assign({value:o},{children:r}))},B=()=>{const e=t(k);if(!e)throw new Error("useRootPortal must be called from within the scope of RootPortalProvider");return e},_=(o,t,d={})=>{const{initialOpenState:c=!1}=d,{onSubmit:u,onCancel:v}=t,f=B(),[g,p]=i(null),[h,A]=s((e=>!e),c),y=a((()=>{null==v||v(),A()}),[A,v]),b=a((e=>m(void 0,void 0,void 0,(function*(){const r=yield null==u?void 0:u(e);return!(!1===(null==r?void 0:r.isSuccessful))&&A(),r}))),[A,u]),C=a((e=>{e&&p(e)}),[]);return[r(n,{children:[h&&e(N,Object.assign({target:f},{children:l(o,Object.assign(Object.assign({},t),{onCancel:y,onSubmit:b,portalRef:g}))})),e("div",{css:{width:"100%"},id:t.formId+"-interface",ref:C})]}),h,A]},q=(e=!1)=>s(((e,r)=>void 0!==r&&"object"!=typeof r?r:!e),e),D=()=>{const{mutateAsync:e,error:r,reset:n}=h(),{error:o,mutateAsync:t,reset:s}=A(),{data:l,error:c,isInitialLoading:u}=y(),{data:v,error:g,isInitialLoading:p}=b(),[E,O]=i(null),w=d((()=>0===(null==v?void 0:v.length)),[v]),L=d((()=>{if(w&&(null==l?void 0:l.length)){const e=l.find((e=>e.requiresFundedAmount));if(e)return{balance:e.balance,currency:C.Currency.USD,id:e.carrierId}}else if(null==v?void 0:v.length){const e=v[0];if(e)return{balance:e.balance,currency:f(e.currencyCode),id:e.fundingSourceId}}}),[l,v,w]),j=a((r=>m(void 0,void 0,void 0,(function*(){try{if(!L)throw new R("No funding origin",{errorCode:"invalid_status",errorSource:"elements",errorType:"business_rules"});w?yield t({carrierId:L.id,funds:r}):yield e({fundingSourceId:L.id,funds:r})}catch(e){null===E&&e instanceof R&&O(e)}}))),[t,e,L,E,w]),S=a((()=>{s(),n(),O(null)}),[s,n]),P=d((()=>u||p),[u,p]),T=d((()=>{if(g||c)return[...null!=g?g:[],...null!=c?c:[]]}),[c,g]);return{addFundsMutation:j,errors:{addFundsErrors:d((()=>{if(o||r||E)return[...null!=o?o:[],...null!=r?r:[],...E?[E]:[]]}),[o,r,E]),fetchBalanceErrors:T},fundingOrigin:L,isLoadingBalance:P,resetAddFundsMutationState:S}};export{T as E,N as P,x as R,P as a,U as b,M as c,_ as d,B as e,q as f,D as g,I as h,F as u};
|