@shipengine/elements 0.32.2 → 0.33.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/index.cjs CHANGED
@@ -16,7 +16,6 @@ var gigerTheme = require('@packlink/giger-theme');
16
16
  var react = require('@emotion/react');
17
17
  var humps = require('humps');
18
18
  var reactDom = require('react-dom');
19
- var brands = require('@packlink/brands');
20
19
  var reactQuery = require('react-query');
21
20
  var reactHookForm = require('react-hook-form');
22
21
  var ReactDatePicker = require('react-datepicker');
@@ -4505,6 +4504,66 @@ const useAddressValidation = () => {
4505
4504
  };
4506
4505
  };
4507
4506
 
4507
+ /*
4508
+ * ****** WARNING *******
4509
+ * This hook was designed with the intention of only being used within the onboarding flow during carrier registration and carrier recovery and as such is not intended to be used elsewhere.
4510
+ * There is a chance that more than one script will be mounted if this hook is used elsewhere.
4511
+ */
4512
+ /**
4513
+ * Creates an encoded device fingerprint string - aka black box - containing information about the end-user's computing device such as OS, browser, etc.
4514
+ * https://developer.bazaarvoice.com/conversations-api/deprecations/iovation-web#snare_js_only
4515
+ */
4516
+ const useBlackboxDetection = ({
4517
+ onSuccess,
4518
+ onError
4519
+ }) => {
4520
+ React.useEffect(() => {
4521
+ // basic configurations must be on page before snare.js is loaded
4522
+ global.window.io_install_stm = false; // do not install Active X
4523
+ global.window.io_exclude_stm = 12; // do not run Active X
4524
+ global.window.io_install_flash = false; // do not install Flash
4525
+ global.window.io_enable_rip = true; // collect Real IP information
4526
+ const pollBlackBox = () => {
4527
+ try {
4528
+ if (typeof ioGetBlackbox !== "function") {
4529
+ return;
4530
+ }
4531
+ // eslint-disable-next-line
4532
+ const blackboxInfo = ioGetBlackbox();
4533
+ // Each call to ioGetBlackbox() returns a JavaScript object with information about the current state of the black box and eventually the black box string itself
4534
+ if (blackboxInfo.finished) {
4535
+ clearTimeout(intervalId);
4536
+ onSuccess(blackboxInfo.blackbox);
4537
+ }
4538
+ } catch (_e) {
4539
+ onError();
4540
+ }
4541
+ };
4542
+ const intervalId = setInterval(pollBlackBox, 500);
4543
+ // attach script to DOM
4544
+ const script = global.document.createElement("script");
4545
+ script.type = "text/javascript";
4546
+ script.async = true;
4547
+ script.src = "https://mpsnare.iesnare.com/snare.js";
4548
+ script.addEventListener("error", _e => {
4549
+ if (typeof ioGetBlackbox !== "function") {
4550
+ onError();
4551
+ }
4552
+ });
4553
+ global.document.head.appendChild(script);
4554
+ return () => {
4555
+ if (intervalId) {
4556
+ clearTimeout(intervalId);
4557
+ }
4558
+ delete global.window.io_install_stm;
4559
+ delete global.window.io_exclude_stm;
4560
+ delete global.window.io_install_flash;
4561
+ delete global.window.io_enable_rip;
4562
+ global.document.head.removeChild(script);
4563
+ };
4564
+ }, [onSuccess, onError]);
4565
+ };
4566
+
4508
4567
  const useListConnectedCarriers = () => {
4509
4568
  const {
4510
4569
  data: carriers,
@@ -6887,7 +6946,7 @@ const LabelLayoutSettings = ({
6887
6946
  }, {
6888
6947
  children: [labelLayout === "letter" && jsxRuntime.jsx(giger.Icon, {
6889
6948
  css: styles$p.icon,
6890
- name: brands.IconNames.CHECK_FILLED
6949
+ name: gigerTheme.IconNames.CHECK_FILLED
6891
6950
  }), jsxRuntime.jsx("div", Object.assign({
6892
6951
  css: styles$p.letterInner
6893
6952
  }, {
@@ -6919,7 +6978,7 @@ const LabelLayoutSettings = ({
6919
6978
  }, {
6920
6979
  children: [labelLayout === "4x6" && jsxRuntime.jsx(giger.Icon, {
6921
6980
  css: styles$p.icon,
6922
- name: brands.IconNames.CHECK_FILLED
6981
+ name: gigerTheme.IconNames.CHECK_FILLED
6923
6982
  }), jsxRuntime.jsx("div", Object.assign({
6924
6983
  css: styles$p.thermalInner
6925
6984
  }, {
@@ -9033,7 +9092,7 @@ const InlineLabel = ({
9033
9092
 
9034
9093
  const styles$l = createStyles({
9035
9094
  getBalanceText: balance => theme => ({
9036
- color: balance === undefined ? theme.palette.alert.main : balance >= 0 ? theme.palette.secondary.dark : theme.palette.error.main
9095
+ color: balance === undefined ? theme.palette.gray.main : balance >= 0 ? theme.palette.secondary.dark : theme.palette.error.main
9037
9096
  })
9038
9097
  });
9039
9098
 
@@ -9058,7 +9117,7 @@ const CarrierBalance = ({
9058
9117
  bold: true,
9059
9118
  css: styles$l.getBalanceText(carrierBalance)
9060
9119
  }, {
9061
- children: carrierBalance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
9120
+ children: carrierBalance === undefined ? "----" : formatMoney({
9062
9121
  amount: carrierBalance,
9063
9122
  currency: alchemy.SE.Currency.USD
9064
9123
  })
@@ -9342,19 +9401,6 @@ const AddressFields = ({
9342
9401
  });
9343
9402
  };
9344
9403
 
9345
- /* eslint-disable @typescript-eslint/no-unused-vars -- Allow unused generics in ZodObject interface overload */
9346
- function nullishDefault(defaultValue) {
9347
- return this.nullish().transform(v => v !== null && v !== void 0 ? v : defaultValue);
9348
- }
9349
- /**
9350
- * @category Form Validation
9351
- */
9352
- const extendZod = () => {
9353
- zod.z.ZodString.prototype.nullishDefault = nullishDefault;
9354
- zod.z.ZodNumber.prototype.nullishDefault = nullishDefault;
9355
- zod.z.ZodObject.prototype.nullishDefault = nullishDefault;
9356
- };
9357
-
9358
9404
  var call = functionCall;
9359
9405
  var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
9360
9406
  var anObject = anObject$f;
@@ -9403,8 +9449,20 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
9403
9449
  ];
9404
9450
  });
9405
9451
 
9452
+ /* eslint-disable @typescript-eslint/no-unused-vars -- Allow unused generics in ZodObject interface overload */
9453
+ function nullishDefault(defaultValue) {
9454
+ return this.nullish().transform(v => v !== null && v !== void 0 ? v : defaultValue);
9455
+ }
9456
+ /**
9457
+ * @category Form Validation
9458
+ */
9459
+ const extendZod = () => {
9460
+ zod.z.ZodString.prototype.nullishDefault = nullishDefault;
9461
+ zod.z.ZodNumber.prototype.nullishDefault = nullishDefault;
9462
+ zod.z.ZodObject.prototype.nullishDefault = nullishDefault;
9463
+ };
9464
+
9406
9465
  extendZod();
9407
- const refineName = n => n.match(/^[a-zA-Z']{2,} [a-zA-Z']{2,}/);
9408
9466
  const addressLine1Schema = zod.z.string().trim().min(1);
9409
9467
  const addressLine2Schema = zod.z.string().trim().nullishDefault(undefined);
9410
9468
  const companyNameSchema = zod.z.string().trim().min(2).max(40).nullishDefault(undefined).or(zod.z.literal("")).transform(companyName => companyName || undefined);
@@ -9414,7 +9472,7 @@ const addressSchema = zod.z.object({
9414
9472
  cityLocality: zod.z.string().trim().min(1),
9415
9473
  companyName: companyNameSchema,
9416
9474
  countryCode: zod.z.enum(countryCodes),
9417
- name: zod.z.string().trim().min(1).refine(refineName, "schemaErrors.invalidAddressName"),
9475
+ name: zod.z.string().trim().min(1),
9418
9476
  phone: zod.z.string().trim().nullishDefault(""),
9419
9477
  postalCode: zod.z.string().trim(),
9420
9478
  stateProvince: zod.z.string().trim().nullishDefault("")
@@ -9422,7 +9480,14 @@ const addressSchema = zod.z.object({
9422
9480
 
9423
9481
  extendZod();
9424
9482
  const postalCodeRegex$2 = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
9425
- const addressFormSchema = addressSchema.refine(schema => !schema.phone || min$3.isValidPhoneNumber(schema.phone, schema.countryCode), {
9483
+ const refineName = n => n.match(/^[a-zA-Z']/);
9484
+ const refineNameStrict = n => n.match(/^[a-zA-Z']{2,} [a-zA-Z']{2,}/);
9485
+ const shipToAddressSchema = addressSchema.refine(schema => {
9486
+ return refineName(schema.name);
9487
+ }, {
9488
+ message: "schemaErrors.invalidAddressName",
9489
+ path: ["name"]
9490
+ }).refine(schema => !schema.phone || min$3.isValidPhoneNumber(schema.phone, schema.countryCode), {
9426
9491
  message: "schemaErrors.notAValidPhoneNumber",
9427
9492
  path: ["phone"]
9428
9493
  }).refine(schema => {
@@ -9442,11 +9507,18 @@ const addressFormSchema = addressSchema.refine(schema => !schema.phone || min$3.
9442
9507
  message: "schemaErrors.invalidPostalCode",
9443
9508
  path: ["postalCode"]
9444
9509
  });
9510
+ const addressFormSchema = shipToAddressSchema.refine(schema => {
9511
+ return refineNameStrict(schema.name);
9512
+ }, {
9513
+ message: "schemaErrors.invalidAddressNameStrict",
9514
+ path: ["name"]
9515
+ });
9445
9516
 
9446
9517
  const AddressForm = ({
9447
9518
  address,
9448
9519
  domestic,
9449
9520
  formId,
9521
+ isShipToForm,
9450
9522
  onCancel,
9451
9523
  onCancelParse,
9452
9524
  onSubmit,
@@ -9460,7 +9532,7 @@ const AddressForm = ({
9460
9532
  } = reactI18next.useTranslation();
9461
9533
  const form = reactHookForm.useForm({
9462
9534
  defaultValues: Object.assign({}, address && address),
9463
- resolver: validationResolver(addressFormSchema)
9535
+ resolver: validationResolver(isShipToForm ? shipToAddressSchema : addressFormSchema)
9464
9536
  });
9465
9537
  const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
9466
9538
  const payload = __rest(values, []);
@@ -10045,7 +10117,8 @@ const creditCardSchema = zod.z.object({
10045
10117
  });
10046
10118
  const walletSchema = zod.z.object({
10047
10119
  address: billingAddressSchema,
10048
- creditCard: creditCardSchema
10120
+ creditCard: creditCardSchema,
10121
+ iovationBlackbox: zod.z.string().trim().min(1)
10049
10122
  });
10050
10123
 
10051
10124
  const EditWalletAddressForm = ({
@@ -10131,6 +10204,7 @@ const WalletForm = ({
10131
10204
  const {
10132
10205
  validateAddress
10133
10206
  } = useAddressPreference();
10207
+ const [codedErrors, setCodedErrors] = React.useState(errors);
10134
10208
  const form = reactHookForm.useForm({
10135
10209
  defaultValues:
10136
10210
  // If the warehouse address is a PO Box they cannot use it as their billing address
@@ -10145,6 +10219,23 @@ const WalletForm = ({
10145
10219
  },
10146
10220
  resolver: validationResolver(walletSchema)
10147
10221
  });
10222
+ useBlackboxDetection({
10223
+ onError: () => {
10224
+ setCodedErrors(errors => {
10225
+ const blackBoxError = {
10226
+ errorCode: "unspecified",
10227
+ errorSource: "client",
10228
+ errorType: "unknown",
10229
+ message: t("register-wallet:sections.notifications.blackBox.description")
10230
+ };
10231
+ return [...(errors !== null && errors !== void 0 ? errors : []), blackBoxError];
10232
+ });
10233
+ },
10234
+ onSuccess: bb => {
10235
+ console.log("bb", bb);
10236
+ form.setValue("iovationBlackbox", bb);
10237
+ }
10238
+ });
10148
10239
  const watchAddress = form.watch("address");
10149
10240
  const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
10150
10241
  const payload = __rest(values, []);
@@ -10158,7 +10249,8 @@ const WalletForm = ({
10158
10249
  onValid: validatedAddressesPayload => __awaiter(void 0, void 0, void 0, function* () {
10159
10250
  yield onSubmit({
10160
10251
  address: validatedAddressesPayload.originAddress,
10161
- creditCard: payload.creditCard
10252
+ creditCard: payload.creditCard,
10253
+ iovationBlackbox: payload.iovationBlackbox
10162
10254
  });
10163
10255
  })
10164
10256
  });
@@ -10181,11 +10273,11 @@ const WalletForm = ({
10181
10273
  children: [jsxRuntime.jsx(giger.GridChild, Object.assign({
10182
10274
  colSpan: 12
10183
10275
  }, {
10184
- children: (errors === null || errors === void 0 ? void 0 : errors.length) && jsxRuntime.jsx(giger.InlineNotification, Object.assign({
10276
+ children: !!(codedErrors === null || codedErrors === void 0 ? void 0 : codedErrors.length) && jsxRuntime.jsx(giger.InlineNotification, Object.assign({
10185
10277
  title: t("register-wallet:sections.notifications.error.title"),
10186
10278
  type: giger.NotificationType.ERROR
10187
10279
  }, {
10188
- children: errors.map(({
10280
+ children: codedErrors.map(({
10189
10281
  message
10190
10282
  }) => message).join(" ")
10191
10283
  }))
@@ -11179,10 +11271,10 @@ const AddressPreferenceDisplay = ({
11179
11271
  children: [jsxRuntime.jsx(giger.Button, Object.assign({
11180
11272
  bold: false,
11181
11273
  isFullWidth: true,
11182
- onClick: () => {
11183
- handleChangePreference();
11274
+ onClick: () => __awaiter(void 0, void 0, void 0, function* () {
11275
+ yield handleChangePreference();
11184
11276
  toggleDisclosure();
11185
- },
11277
+ }),
11186
11278
  type: "button",
11187
11279
  variant: giger.ButtonVariant.OUTLINED
11188
11280
  }, {
@@ -11227,7 +11319,8 @@ const baseSchema = addressSchema.extend({
11227
11319
  path: ["postalCode"]
11228
11320
  });
11229
11321
  const getCarrierRecoverySchema = requiresAddress => zod.z.object({
11230
- address: requiresAddress ? baseSchema : baseSchema.optional()
11322
+ address: requiresAddress ? baseSchema : baseSchema.optional(),
11323
+ iovationBlackbox: zod.z.string().trim().min(1)
11231
11324
  });
11232
11325
 
11233
11326
  const styles$c = createStyles({
@@ -11254,6 +11347,7 @@ const CarrierRecoveryForm = ({
11254
11347
  const {
11255
11348
  t
11256
11349
  } = reactI18next.useTranslation();
11350
+ const [codedErrors, setCodedErrors] = React.useState(errors);
11257
11351
  const metadata = useCarrierMetadata();
11258
11352
  const carrier = metadata.find(m => m.carrierCode === carrierCode);
11259
11353
  const carrierFriendlyName = (_a = carrier === null || carrier === void 0 ? void 0 : carrier.shortname) !== null && _a !== void 0 ? _a : "your carrier";
@@ -11266,6 +11360,22 @@ const CarrierRecoveryForm = ({
11266
11360
  }),
11267
11361
  resolver: validationResolver(getCarrierRecoverySchema(requiresAddress))
11268
11362
  });
11363
+ useBlackboxDetection({
11364
+ onError: () => {
11365
+ setCodedErrors(errors => {
11366
+ const blackBoxError = {
11367
+ errorCode: "unspecified",
11368
+ errorSource: "client",
11369
+ errorType: "unknown",
11370
+ message: t("register-wallet:sections.notifications.blackBox.description")
11371
+ };
11372
+ return [...(errors !== null && errors !== void 0 ? errors : []), blackBoxError];
11373
+ });
11374
+ },
11375
+ onSuccess: bb => {
11376
+ form.setValue("iovationBlackbox", bb);
11377
+ }
11378
+ });
11269
11379
  const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
11270
11380
  yield onSubmit(fundingSourceId, values);
11271
11381
  }));
@@ -11297,7 +11407,7 @@ const CarrierRecoveryForm = ({
11297
11407
  children: t("register-wallet:sections.carriers.subtitle")
11298
11408
  }))
11299
11409
  }))]
11300
- }), !!(errors === null || errors === void 0 ? void 0 : errors.length) && jsxRuntime.jsx(giger.GridChild, Object.assign({
11410
+ }), !!(codedErrors === null || codedErrors === void 0 ? void 0 : codedErrors.length) && jsxRuntime.jsx(giger.GridChild, Object.assign({
11301
11411
  colSpan: 12
11302
11412
  }, {
11303
11413
  children: jsxRuntime.jsx(giger.InlineNotification, Object.assign({
@@ -11306,7 +11416,7 @@ const CarrierRecoveryForm = ({
11306
11416
  }),
11307
11417
  type: giger.NotificationType.ERROR
11308
11418
  }, {
11309
- children: errors.map(({
11419
+ children: codedErrors.map(({
11310
11420
  message
11311
11421
  }) => message).join(" ")
11312
11422
  }))
@@ -11852,7 +11962,6 @@ const LandingPageForm = ({
11852
11962
  alwaysRequireValidity: true,
11853
11963
  control: form.control,
11854
11964
  "data-testid": "onboarding:landing.action",
11855
- form: "landing-page-form",
11856
11965
  variant: giger.ButtonVariant.FILLED
11857
11966
  }, {
11858
11967
  children: t("onboarding:landing.action")
@@ -12613,6 +12722,7 @@ const Onboarding = ({
12613
12722
  createWarehouse,
12614
12723
  features,
12615
12724
  fundingSources,
12725
+ isRegisteringCarriers,
12616
12726
  onCarrierCreated,
12617
12727
  onCompleteOnboarding,
12618
12728
  onFundingSourceCreated,
@@ -12679,8 +12789,9 @@ const Onboarding = ({
12679
12789
  return [];
12680
12790
  };
12681
12791
  const handleWalletRegistrationSuccess = (fundingSourceId, {
12682
- address
12683
- } = {}) => __awaiter(void 0, void 0, void 0, function* () {
12792
+ address,
12793
+ iovationBlackbox
12794
+ }) => __awaiter(void 0, void 0, void 0, function* () {
12684
12795
  const addressToRegister = address !== null && address !== void 0 ? address : defaultWarehouse.originAddress;
12685
12796
  const pickupAddress = Object.assign(Object.assign({}, addressToRegister), {
12686
12797
  company: addressToRegister.companyName || "",
@@ -12697,6 +12808,7 @@ const Onboarding = ({
12697
12808
  agreeToTerms: true,
12698
12809
  carrierCode: "ups_walleted",
12699
12810
  fundingSourceId: fundingSourceId,
12811
+ iovationBlackBox: iovationBlackbox,
12700
12812
  pickupAddress: pickupAddress
12701
12813
  });
12702
12814
  }
@@ -12705,7 +12817,8 @@ const Onboarding = ({
12705
12817
  acceptedTerms: getTerms("dhl_express_walleted"),
12706
12818
  agreeToTerms: true,
12707
12819
  carrierCode: "dhl_express_worldwide",
12708
- fundingSourceId: fundingSourceId
12820
+ fundingSourceId: fundingSourceId,
12821
+ iovationBlackBox: iovationBlackbox
12709
12822
  });
12710
12823
  }
12711
12824
  return {
@@ -12726,7 +12839,8 @@ const Onboarding = ({
12726
12839
  });
12727
12840
  const handleWalletRegistration = ({
12728
12841
  address,
12729
- creditCard
12842
+ creditCard,
12843
+ iovationBlackbox
12730
12844
  }) => __awaiter(void 0, void 0, void 0, function* () {
12731
12845
  setHasCompletedBilling(true);
12732
12846
  const billingInfo = Object.assign(Object.assign({}, address), {
@@ -12739,11 +12853,14 @@ const Onboarding = ({
12739
12853
  acceptedTerms: getTerms("stamps_com"),
12740
12854
  agreeToTerms: agreedToTerms,
12741
12855
  billingInfo: billingInfo,
12856
+ iovationBlackBox: iovationBlackbox,
12742
12857
  paymentMethod: {
12743
12858
  creditCardInfo: Object.assign({}, creditCard)
12744
12859
  }
12745
12860
  });
12746
- yield handleWalletRegistrationSuccess(fundingSource.fundingSource.fundingSourceId);
12861
+ yield handleWalletRegistrationSuccess(fundingSource.fundingSource.fundingSourceId, {
12862
+ iovationBlackbox
12863
+ });
12747
12864
  } catch (_e) {
12748
12865
  setHasCompletedBilling(false);
12749
12866
  }
@@ -12893,6 +13010,11 @@ const Onboarding = ({
12893
13010
  });
12894
13011
  }
12895
13012
  }
13013
+ if (isRegisteringCarriers || currentStep === 4) {
13014
+ return jsxRuntime.jsx(Loader, {
13015
+ message: t("loading.connectingCarriers")
13016
+ });
13017
+ }
12896
13018
  return jsxRuntime.jsx(Loader, {
12897
13019
  message: t("loading.onboarding")
12898
13020
  });
@@ -14327,6 +14449,7 @@ const ShipmentForm = ({
14327
14449
  const [editShipToForm, isEditShipFormToOpen, toggleIsEditShipFormToOpen] = useNestedForm(AddressForm, {
14328
14450
  address: (_b = (_a = addressPreference === null || addressPreference === void 0 ? void 0 : addressPreference.selection) !== null && _a !== void 0 ? _a : shipment === null || shipment === void 0 ? void 0 : shipment.shipTo) !== null && _b !== void 0 ? _b : salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.shipTo,
14329
14451
  formId: "edit-ship-to-form",
14452
+ isShipToForm: true,
14330
14453
  onSubmit: handleSubmitEditShipTo,
14331
14454
  onSubmitParse: onSubmitParseShipTo,
14332
14455
  parseAddressErrors,
@@ -14554,6 +14677,7 @@ const ShipmentForm = ({
14554
14677
  })), jsxRuntime.jsx(giger.DropdownOptionList, Object.assign({
14555
14678
  "data-id": "dropdown",
14556
14679
  dropdownWidth: "400px",
14680
+ hideWhenReferenceNotVisible: true,
14557
14681
  isOpen: showApplyPreset,
14558
14682
  onChange: () => setShowApplyPreset(false),
14559
14683
  onClickAway: e => {
@@ -15061,6 +15185,7 @@ var index = /*#__PURE__*/Object.freeze({
15061
15185
  addCarrierSchema: addCarrierSchema,
15062
15186
  AddressDisplay: AddressDisplay,
15063
15187
  AddressForm: AddressForm,
15188
+ shipToAddressSchema: shipToAddressSchema,
15064
15189
  addressFormSchema: addressFormSchema,
15065
15190
  AddressFields: AddressFields,
15066
15191
  addressLine1Schema: addressLine1Schema,
@@ -15124,7 +15249,7 @@ const DateRangeSelect = ({
15124
15249
  "data-testid": "date-range-select",
15125
15250
  label: t("wallet-history:dateRange"),
15126
15251
  leftContent: jsxRuntime.jsx(giger.Icon, {
15127
- name: brands.IconNames.FILTER
15252
+ name: gigerTheme.IconNames.FILTER
15128
15253
  }),
15129
15254
  name: "date-range-select",
15130
15255
  onChange: handleChange,
@@ -15439,6 +15564,7 @@ var common = {
15439
15564
  accountSettings: "Loading account settings...",
15440
15565
  carrier: "Loading carrier...",
15441
15566
  carriers: "Loading carriers...",
15567
+ connectingCarriers: "Connecting carriers...",
15442
15568
  data: "Loading...",
15443
15569
  importingSalesOrder: "Importing order...",
15444
15570
  label: "Loading label...",
@@ -15478,7 +15604,8 @@ var common = {
15478
15604
  group: {
15479
15605
  allMeasurementsOrNone: "All measurements must be provided when entering {{fieldLabel}}"
15480
15606
  },
15481
- invalidAddressName: "Recipient Name must have two characters in First and Last Name.",
15607
+ invalidAddressName: "Invalid recipient name.",
15608
+ invalidAddressNameStrict: "Recipient Name must have two characters in First and Last Name.",
15482
15609
  invalidAddressPoBox: "A physical address is required for wallet registration. You can add a PO Box as a Ship From address.",
15483
15610
  invalidCreditCardType: "Card type must be Visa, Mastercard, American Express, or Discover",
15484
15611
  invalidExpiration: "Invalid Expiration Date",
@@ -15825,6 +15952,9 @@ var registerWallet = {
15825
15952
  title: "There was an error connecting {{carrierFriendlyName}}",
15826
15953
  confirmAddress: "Confirm your address details and try again.",
15827
15954
  description: "You can also skip this step for now and connect {{carrierFriendlyName}} in your Account Settings later."
15955
+ },
15956
+ blackBox: {
15957
+ description: "Please turn off all tracking add-ons like ad-blockers; they restrict our ability to confirm your activity is valid so we can more effectively prevent fraud."
15828
15958
  }
15829
15959
  }
15830
15960
  },
@@ -15966,6 +16096,7 @@ const Component$3 = ({
15966
16096
  } = alchemy.useListCarriers();
15967
16097
  const {
15968
16098
  error: createFundingSourceErrors,
16099
+ isLoading: creatingFundingSource,
15969
16100
  mutateAsync: createFundingSource
15970
16101
  } = alchemy.useCreateFundingSource();
15971
16102
  const {
@@ -15974,7 +16105,8 @@ const Component$3 = ({
15974
16105
  } = alchemy.useListFundingSources();
15975
16106
  const {
15976
16107
  error: registerCarrierErrors,
15977
- mutateAsync: registerCarrier
16108
+ mutateAsync: registerCarrier,
16109
+ isLoading: registeringCarriers
15978
16110
  } = alchemy.useRegisterCarrier();
15979
16111
  const onWarehouseCreated = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
15980
16112
  yield refetchWarehouses();
@@ -15998,6 +16130,7 @@ const Component$3 = ({
15998
16130
  createWarehouse: createWarehouse,
15999
16131
  features: features,
16000
16132
  fundingSources: fundingSources,
16133
+ isRegisteringCarriers: registeringCarriers || creatingFundingSource,
16001
16134
  onCarrierCreated: onCarrierCreated,
16002
16135
  onCompleteOnboarding: onCompleteOnboarding,
16003
16136
  onFundingSourceCreated: onFundingSourceCreated,
@@ -16115,7 +16248,6 @@ const useAddress = ({
16115
16248
  return parseResult;
16116
16249
  });
16117
16250
  const handleValidateAddress = React.useCallback((address, fallbackAddress) => __awaiter(void 0, void 0, void 0, function* () {
16118
- setAddressPreference(undefined);
16119
16251
  if (compatibleCountryCodes && !compatibleCountryCodes.includes(address.countryCode)) {
16120
16252
  resetAddressPreference({
16121
16253
  messages: [],
@@ -16129,6 +16261,7 @@ const useAddress = ({
16129
16261
  if (addressValidation) {
16130
16262
  const updatedAddressPreference = resetAddressPreference(addressValidation, fallbackAddress);
16131
16263
  yield onValidation === null || onValidation === void 0 ? void 0 : onValidation(updatedAddressPreference);
16264
+ return updatedAddressPreference;
16132
16265
  } else {
16133
16266
  // validate_and_clean failure is preventing the address preference object
16134
16267
  // from being refreshed. Manualy set the address preference to an error state.
@@ -16139,20 +16272,23 @@ const useAddress = ({
16139
16272
  originalAddress: address,
16140
16273
  status: "error"
16141
16274
  });
16275
+ return;
16142
16276
  }
16143
- }), [compatibleCountryCodes, onValidation, resetAddressPreference, validateAddresses]);
16277
+ }), [compatibleCountryCodes, onValidation, resetAddressPreference, setAddressPreference, validateAddresses]);
16144
16278
  const handleChangeAddress = React.useCallback((shipTo, {
16145
16279
  shouldValidate
16146
16280
  }) => __awaiter(void 0, void 0, void 0, function* () {
16281
+ var _a;
16147
16282
  if (!shipment) throw new Error("shipment not found");
16283
+ let updatedAddressPreference;
16284
+ if (shouldValidate) {
16285
+ updatedAddressPreference = yield handleValidateAddress(shipTo);
16286
+ }
16148
16287
  const updatedShipment = yield updateShipment(Object.assign(Object.assign({}, shipment), {
16149
16288
  shipDate: isNowOrInTheFuture(shipment.shipDate) ? shipment.shipDate : undefined,
16150
- shipTo
16289
+ shipTo: (_a = updatedAddressPreference === null || updatedAddressPreference === void 0 ? void 0 : updatedAddressPreference.selection) !== null && _a !== void 0 ? _a : shipTo
16151
16290
  }));
16152
16291
  yield onChange === null || onChange === void 0 ? void 0 : onChange(shipment, updatedShipment);
16153
- if (shouldValidate) {
16154
- yield handleValidateAddress(shipTo);
16155
- }
16156
16292
  return updatedShipment;
16157
16293
  }), [handleValidateAddress, onChange, shipment, updateShipment]);
16158
16294
  React.useEffect(() => {
@@ -17491,6 +17627,7 @@ exports.usCities = usCities;
17491
17627
  exports.usStateCodes = usStateCodes;
17492
17628
  exports.usStates = usStates;
17493
17629
  exports.useAddressValidation = useAddressValidation;
17630
+ exports.useBlackboxDetection = useBlackboxDetection;
17494
17631
  exports.useCarrierMetadata = useCarrierMetadata;
17495
17632
  exports.useConfirmationOptions = useConfirmationOptions;
17496
17633
  exports.useCountryCodeOptions = useCountryCodeOptions;