@wise/dynamic-flow-client 1.2.0 → 1.2.1

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/build/main.js CHANGED
@@ -839,7 +839,7 @@ function isReference(block) {
839
839
  }
840
840
 
841
841
  // src/dynamicFlow/DynamicFlow.tsx
842
- var import_react35 = require("react");
842
+ var import_react38 = require("react");
843
843
  var import_react_intl28 = require("react-intl");
844
844
 
845
845
  // src/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
@@ -1821,7 +1821,7 @@ function useExternalStepPolling(polling, onAction) {
1821
1821
  }
1822
1822
 
1823
1823
  // src/common/hooks/usePersistAsync/usePersistAsync.ts
1824
- var import_react23 = require("react");
1824
+ var import_react26 = require("react");
1825
1825
  var import_react_intl16 = require("react-intl");
1826
1826
 
1827
1827
  // src/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js
@@ -1835,7 +1835,7 @@ var PersistAsyncSchema_messages_default = (0, import_react_intl.defineMessages)(
1835
1835
  });
1836
1836
 
1837
1837
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
1838
- var import_react22 = require("react");
1838
+ var import_react25 = require("react");
1839
1839
  var import_react_intl15 = require("react-intl");
1840
1840
 
1841
1841
  // src/fixtures/jsonSchemaForm/allOf.ts
@@ -1961,7 +1961,7 @@ var allOf_default = schema;
1961
1961
 
1962
1962
  // src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
1963
1963
  var import_classnames6 = __toESM(require_classnames());
1964
- var import_react21 = require("react");
1964
+ var import_react24 = require("react");
1965
1965
 
1966
1966
  // src/layout/alert/DynamicAlert.tsx
1967
1967
  var import_components = require("@transferwise/components");
@@ -2292,6 +2292,9 @@ var DynamicExternal = ({ component, onAction }) => {
2292
2292
  };
2293
2293
  var DynamicExternal_default = DynamicExternal;
2294
2294
 
2295
+ // src/jsonSchemaForm/genericSchema/GenericSchema.tsx
2296
+ var import_react20 = require("react");
2297
+
2295
2298
  // src/jsonSchemaForm/allOfSchema/AllOfSchema.tsx
2296
2299
  var import_classnames = __toESM(require_classnames());
2297
2300
  var import_react10 = require("react");
@@ -2786,7 +2789,7 @@ var ObjectSchema_default = ObjectSchema3;
2786
2789
 
2787
2790
  // src/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
2788
2791
  var import_classnames4 = __toESM(require_classnames());
2789
- var import_react14 = require("react");
2792
+ var import_react15 = require("react");
2790
2793
 
2791
2794
  // src/jsonSchemaForm/help/Help.tsx
2792
2795
  var import_components7 = require("@transferwise/components");
@@ -2819,6 +2822,9 @@ var Help = (props) => {
2819
2822
  };
2820
2823
  var Help_default = Help;
2821
2824
 
2825
+ // src/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
2826
+ var import_react14 = require("react");
2827
+
2822
2828
  // src/formControl/FormControl.tsx
2823
2829
  var import_components8 = require("@transferwise/components");
2824
2830
  var import_react13 = require("react");
@@ -3521,16 +3527,12 @@ var import_jsx_runtime24 = require("react/jsx-runtime");
3521
3527
  var isNativeInput = (propsSchemaType) => {
3522
3528
  return propsSchemaType === "string" || propsSchemaType === "number";
3523
3529
  };
3524
- var getControlType = (schema2, log) => {
3530
+ var getControlType = (schema2) => {
3525
3531
  if (isOneOfSchema(schema2)) {
3526
3532
  if (schema2.control === FormControlType.TAB && schema2.oneOf.length > 3) {
3527
3533
  return FormControlType.SELECT;
3528
3534
  }
3529
3535
  if (schema2.oneOf.length === 2 && !schema2.control) {
3530
- log.warning(
3531
- "Deprecation warning",
3532
- 'A oneOf schema with 2 options and no control type currently renders as a "radio" but will be changed to render as a "select". Please specify control radio to retain the existing behaviour.'
3533
- );
3534
3536
  return FormControlType.RADIO;
3535
3537
  }
3536
3538
  return schema2.control || FormControlType.SELECT;
@@ -3567,40 +3569,35 @@ var getOptions = (schema2, controlType) => {
3567
3569
  return null;
3568
3570
  };
3569
3571
  var SchemaFormControl = (props) => {
3572
+ const { id, schema: schema2, value, disabled, onChange, onFocus, onBlur, onSearchChange } = props;
3570
3573
  const log = useLogger();
3571
- const getSanitisedValue = (value) => isNativeInput(props.schema.type) && (isNull(value) || isUndefined(value)) ? "" : value;
3572
- const onChange = (value, type) => {
3573
- props.onChange(getValidBasicModelOrNull(value, props.schema), type);
3574
+ const getSanitisedValue = (value2) => isNativeInput(schema2.type) && (isNull(value2) || isUndefined(value2)) ? "" : value2;
3575
+ const onModelChange = (value2, type) => {
3576
+ onChange(getValidBasicModelOrNull(value2, schema2), type);
3574
3577
  };
3575
- const controlType = getControlType(props.schema, log);
3576
- if (controlType === "file") {
3577
- log.warning(
3578
- "Deprecation warning",
3579
- "Please use a persist-async blob schema instead of string with base64url for file uploads. The base64url does not perform well on low end devices. Support for this schema will be removed in a later release."
3580
- );
3581
- }
3582
- if (props.schema.values) {
3583
- log.error("Deprecated schema", "Schema.values is a legacy approach. Please use oneOf.");
3584
- }
3585
- const options = props.schema.values || getOptions(props.schema, controlType);
3578
+ const controlType = getControlType(schema2);
3579
+ (0, import_react14.useEffect)(() => {
3580
+ warnIfInvalidSchema(schema2, log, controlType);
3581
+ }, [schema2, log, controlType]);
3582
+ const options = schema2.values || getOptions(schema2, controlType);
3586
3583
  const events = {
3587
- onFocus: props.onFocus,
3588
- onBlur: props.onBlur,
3589
- onSearchChange: props.onSearchChange,
3590
- onChange
3584
+ onFocus,
3585
+ onBlur,
3586
+ onSearchChange,
3587
+ onChange: onModelChange
3591
3588
  };
3592
- const safeValue = getSanitisedValue(props.value);
3589
+ const safeValue = getSanitisedValue(value);
3593
3590
  const controlProps = {
3594
- id: props.id,
3595
- name: props.id,
3596
- label: props.schema.title,
3591
+ id,
3592
+ name: id,
3593
+ label: schema2.title,
3597
3594
  options: options || [],
3598
- placeholder: props.schema.placeholder,
3599
- autoComplete: !props.schema.help,
3600
- disabled: props.disabled || props.schema.disabled,
3601
- displayPattern: props.schema.displayFormat,
3595
+ placeholder: schema2.placeholder,
3596
+ autoComplete: !schema2.help,
3597
+ disabled: disabled || schema2.disabled,
3598
+ displayPattern: schema2.displayFormat,
3602
3599
  // TODO: LOW avoid type assertion below
3603
- uploadProps: mapSchemaToUploadOptions(props.schema)
3600
+ uploadProps: mapSchemaToUploadOptions(schema2)
3604
3601
  };
3605
3602
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps));
3606
3603
  };
@@ -3611,6 +3608,23 @@ SchemaFormControl.defaultProps = {
3611
3608
  onSearchChange: null,
3612
3609
  disabled: false
3613
3610
  };
3611
+ var warnIfInvalidSchema = (schema2, log, controlType) => {
3612
+ if (isOneOfSchema(schema2) && schema2.oneOf.length === 2 && !schema2.control) {
3613
+ log.warning(
3614
+ "Deprecation warning",
3615
+ 'A oneOf schema with 2 options and no control type currently renders as a "radio" but will be changed to render as a "select". Please specify control radio to retain the existing behaviour.'
3616
+ );
3617
+ }
3618
+ if (controlType === "file") {
3619
+ log.warning(
3620
+ "Deprecation warning",
3621
+ "Please use a persist-async blob schema instead of string with base64url for file uploads. The base64url does not perform well on low end devices. Support for this schema will be removed in a later release."
3622
+ );
3623
+ }
3624
+ if (schema2.values) {
3625
+ log.warning("Deprecated schema", "Schema.values is a legacy approach. Please use oneOf.");
3626
+ }
3627
+ };
3614
3628
  var SchemaFormControl_default = SchemaFormControl;
3615
3629
 
3616
3630
  // src/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.ts
@@ -3676,14 +3690,14 @@ function getSchemaProperties(childSchema) {
3676
3690
  var import_jsx_runtime25 = require("react/jsx-runtime");
3677
3691
  var OneOfSchema5 = (props) => {
3678
3692
  const onEvent = useEventDispatcher();
3679
- const [changed, setChanged] = (0, import_react14.useState)(false);
3680
- const [focused, setFocused] = (0, import_react14.useState)(false);
3681
- const [blurred, setBlurred] = (0, import_react14.useState)(false);
3682
- const id = (0, import_react14.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
3683
- const [schemaIndex, setSchemaIndex] = (0, import_react14.useState)(
3693
+ const [changed, setChanged] = (0, import_react15.useState)(false);
3694
+ const [focused, setFocused] = (0, import_react15.useState)(false);
3695
+ const [blurred, setBlurred] = (0, import_react15.useState)(false);
3696
+ const id = (0, import_react15.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
3697
+ const [schemaIndex, setSchemaIndex] = (0, import_react15.useState)(
3684
3698
  getActiveSchemaIndex(props.schema, props.model)
3685
3699
  );
3686
- const [models, setModels] = (0, import_react14.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
3700
+ const [models, setModels] = (0, import_react15.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
3687
3701
  const debouncedTrackEvent = useDebouncedFunction(onEvent, 200);
3688
3702
  const onSearchChange = (searchValue) => {
3689
3703
  debouncedTrackEvent("Dynamic Flow - OneOf Searched", {
@@ -3691,7 +3705,7 @@ var OneOfSchema5 = (props) => {
3691
3705
  searchValueLength: searchValue.length
3692
3706
  });
3693
3707
  };
3694
- (0, import_react14.useEffect)(() => {
3708
+ (0, import_react15.useEffect)(() => {
3695
3709
  const modelIndex = getValidIndexFromValue(props.schema, props.model);
3696
3710
  const defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
3697
3711
  if (modelIndex === -1 && defaultIndex >= 0) {
@@ -3841,11 +3855,11 @@ var OneOfSchema_default = OneOfSchema5;
3841
3855
 
3842
3856
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
3843
3857
  var import_classnames5 = __toESM(require_classnames());
3844
- var import_react16 = require("react");
3858
+ var import_react17 = require("react");
3845
3859
 
3846
3860
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
3847
3861
  var import_components10 = require("@transferwise/components");
3848
- var import_react15 = require("react");
3862
+ var import_react16 = require("react");
3849
3863
  var import_jsx_runtime26 = require("react/jsx-runtime");
3850
3864
  var UploadInputAdapter = (props) => {
3851
3865
  const {
@@ -3862,7 +3876,7 @@ var UploadInputAdapter = (props) => {
3862
3876
  onCancel
3863
3877
  } = props;
3864
3878
  const onEvent = useEventDispatcher();
3865
- const files = (0, import_react15.useMemo)(() => fileId ? [{ id: fileId, status: import_components10.Status.SUCCEEDED }] : [], [fileId]);
3879
+ const files = (0, import_react16.useMemo)(() => fileId ? [{ id: fileId, status: import_components10.Status.SUCCEEDED }] : [], [fileId]);
3866
3880
  const uploadFile = (formData) => {
3867
3881
  onEvent("Dynamic Flow - PersistAsync", { status: "pending", schemaId: id });
3868
3882
  return httpClient(`${httpOptions.url}`, {
@@ -3902,10 +3916,10 @@ var UploadInputAdapter = (props) => {
3902
3916
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
3903
3917
  var import_jsx_runtime27 = require("react/jsx-runtime");
3904
3918
  var PersistAsyncBlobSchema = (props) => {
3905
- const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react16.useState)({});
3906
- const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react16.useState)(null);
3907
- const [validations, setValidations] = (0, import_react16.useState)([]);
3908
- const [changed, setChanged] = (0, import_react16.useState)(false);
3919
+ const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react17.useState)({});
3920
+ const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react17.useState)(null);
3921
+ const [validations, setValidations] = (0, import_react17.useState)([]);
3922
+ const [changed, setChanged] = (0, import_react17.useState)(false);
3909
3923
  const httpClient = useHttpClient();
3910
3924
  const onEvent = useEventDispatcher();
3911
3925
  const refreshValidations = () => {
@@ -3913,7 +3927,7 @@ var PersistAsyncBlobSchema = (props) => {
3913
3927
  setValidations(getValidationFailures(props.model, props.schema, !!props.required));
3914
3928
  }
3915
3929
  };
3916
- (0, import_react16.useEffect)(refreshValidations, [props.model, props.submitted]);
3930
+ (0, import_react17.useEffect)(refreshValidations, [props.model, props.submitted]);
3917
3931
  const onSuccess = async (httpResponse, _fileName) => {
3918
3932
  const jsonResponse = await httpResponse.json();
3919
3933
  const id = getIdFromResponse(props.schema.persistAsync.idProperty, jsonResponse);
@@ -4002,7 +4016,7 @@ PersistAsyncSchema.defaultProps = {
4002
4016
  var PersistAsyncSchema_default = PersistAsyncSchema;
4003
4017
 
4004
4018
  // src/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.tsx
4005
- var import_react17 = require("react");
4019
+ var import_react18 = require("react");
4006
4020
 
4007
4021
  // src/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.ts
4008
4022
  var getSelectionFromModel = (schema2, model) => {
@@ -4093,7 +4107,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
4093
4107
  var isPromoted = (schema2) => schema2.promoted === true;
4094
4108
  var PromotedOneOfSchema = (props) => {
4095
4109
  var _a;
4096
- const [selection, setSelection] = (0, import_react17.useState)(
4110
+ const [selection, setSelection] = (0, import_react18.useState)(
4097
4111
  getSelectionFromModel(props.schema, props.model) || ((_a = props.schema.promotion) == null ? void 0 : _a.default) || "promoted"
4098
4112
  );
4099
4113
  const promotedAlert = props.schema.alert;
@@ -4209,32 +4223,35 @@ function getValueFromOption(option) {
4209
4223
  }
4210
4224
 
4211
4225
  // src/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.tsx
4212
- var import_react18 = require("react");
4226
+ var import_react19 = require("react");
4213
4227
  var import_jsx_runtime34 = require("react/jsx-runtime");
4214
4228
  var ValidationAsyncSchema = (props) => {
4215
- const [validationAsyncModel, setValidationAsyncModel] = (0, import_react18.useState)(props.model);
4216
- const previousRequestedModelReference = (0, import_react18.useRef)(null);
4217
- const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, import_react18.useState)(
4229
+ const { schema: schema2, model, required, submitted, errors, onChange } = props;
4230
+ const [validationAsyncModel, setValidationAsyncModel] = (0, import_react19.useState)(model);
4231
+ const previousRequestedModelReference = (0, import_react19.useRef)(null);
4232
+ const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, import_react19.useState)(
4218
4233
  null
4219
4234
  );
4220
- const [validationAsyncErrors, setValidationAsyncErrors] = (0, import_react18.useState)(null);
4221
- const [fieldSubmitted, setFieldSubmitted] = (0, import_react18.useState)(false);
4222
- const [abortController, setAbortController] = (0, import_react18.useState)(null);
4235
+ const [validationAsyncErrors, setValidationAsyncErrors] = (0, import_react19.useState)(null);
4236
+ const [fieldSubmitted, setFieldSubmitted] = (0, import_react19.useState)(false);
4237
+ const [abortController, setAbortController] = (0, import_react19.useState)(null);
4223
4238
  const httpClient = useHttpClient();
4224
4239
  const onEvent = useEventDispatcher();
4225
- const logger = useLogger();
4226
- const getValidationAsyncResponse = async (currentValidationAsyncModel, validationAsyncSpec) => {
4227
- const signal = abortCurrentRequestAndGetNewAbortSignal();
4228
- const requestBody = { [validationAsyncSpec.param]: currentValidationAsyncModel };
4229
- previousRequestedModelReference.current = currentValidationAsyncModel;
4230
- setFieldSubmitted(true);
4231
- if (!validationAsyncSpec.method) {
4232
- logger.warning(
4240
+ const log = useLogger();
4241
+ (0, import_react19.useEffect)(() => {
4242
+ if (!schema2.validationAsync.method) {
4243
+ log.warning(
4233
4244
  "Invalid schema or model",
4234
4245
  'ValidationAsyncSchema without a "method" property would have defaulted to "GET" in previous versions. Now defaults to "POST".',
4235
4246
  {}
4236
4247
  );
4237
4248
  }
4249
+ }, [log, schema2.validationAsync.method]);
4250
+ const getValidationAsyncResponse = async (currentValidationAsyncModel, validationAsyncSpec) => {
4251
+ const signal = abortCurrentRequestAndGetNewAbortSignal();
4252
+ const requestBody = { [validationAsyncSpec.param]: currentValidationAsyncModel };
4253
+ previousRequestedModelReference.current = currentValidationAsyncModel;
4254
+ setFieldSubmitted(true);
4238
4255
  onEvent("Dynamic Flow - ValidationAsync", { status: "pending" });
4239
4256
  const response = await httpClient(validationAsyncSpec.url, {
4240
4257
  method: validationAsyncSpec.method || "POST",
@@ -4269,29 +4286,29 @@ var ValidationAsyncSchema = (props) => {
4269
4286
  };
4270
4287
  const onBlur = () => {
4271
4288
  if (!isNull(validationAsyncModel) && !isEqual(validationAsyncModel, previousRequestedModelReference.current)) {
4272
- void getValidationAsyncResponse(validationAsyncModel, props.schema.validationAsync);
4289
+ void getValidationAsyncResponse(validationAsyncModel, schema2.validationAsync);
4273
4290
  }
4274
4291
  };
4275
- const validationAsyncOnChange = (parameters) => {
4276
- props.onChange(__spreadProps(__spreadValues({}, parameters), {
4277
- triggerSchema: props.schema,
4292
+ const onValidationAsyncChange = (parameters) => {
4293
+ onChange(__spreadProps(__spreadValues({}, parameters), {
4294
+ triggerSchema: schema2,
4278
4295
  triggerModel: parameters.model
4279
4296
  }));
4280
4297
  setValidationAsyncErrors(null);
4281
4298
  setValidationAsyncSuccessMessage(null);
4282
- if (isValidSchema(parameters.model, props.schema)) {
4299
+ if (isValidSchema(parameters.model, schema2)) {
4283
4300
  setValidationAsyncModel(parameters.model);
4284
4301
  }
4285
4302
  };
4286
4303
  const basicTypeSchemaProps = {
4287
- required: props.required,
4288
- submitted: props.submitted || fieldSubmitted,
4289
- schema: props.schema,
4304
+ submitted: submitted || fieldSubmitted,
4290
4305
  model: validationAsyncModel,
4291
- errors: validationAsyncErrors || props.errors,
4292
- onChange: validationAsyncOnChange,
4306
+ errors: validationAsyncErrors || errors,
4307
+ infoMessage: validationAsyncSuccessMessage,
4308
+ onChange: onValidationAsyncChange,
4293
4309
  onBlur,
4294
- infoMessage: validationAsyncSuccessMessage
4310
+ required,
4311
+ schema: schema2
4295
4312
  };
4296
4313
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeSchemaProps));
4297
4314
  };
@@ -4300,100 +4317,67 @@ var ValidationAsyncSchema_default = ValidationAsyncSchema;
4300
4317
 
4301
4318
  // src/jsonSchemaForm/genericSchema/GenericSchema.tsx
4302
4319
  var import_jsx_runtime35 = require("react/jsx-runtime");
4320
+ var import_react21 = require("react");
4303
4321
  var GenericSchemaForm = (props) => {
4304
4322
  const { schema: schema2, model = null, errors = null, hideTitle = false, disabled = false } = props;
4305
4323
  const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
4306
4324
  const type = getSchemaType(schema2);
4307
4325
  const log = useLogger();
4308
- const logInvalidSchemaWarning = () => log.error(
4309
- "Invalid schema or model",
4310
- `Schema of type ${type || "undefined"} requested, but schema did not pass validation.`
4311
- );
4326
+ (0, import_react20.useEffect)(() => {
4327
+ if (!isValidGenericSchema(schema2, model, errors)) {
4328
+ log.error(
4329
+ "Invalid schema or model",
4330
+ `Schema of type ${type || "undefined"} requested, but schema did not pass validation.`
4331
+ );
4332
+ }
4333
+ }, [schema2, model, errors, type, log]);
4312
4334
  switch (type) {
4313
4335
  case "readOnly":
4314
4336
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ReadOnlySchema_default, __spreadValues({}, schemaProps));
4315
4337
  case "persistAsync":
4316
- if (isPersistAsyncSchema(schema2) && isNullableStringModel(model) && isBasicError(errors)) {
4317
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4318
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PersistAsyncSchema_default, __spreadValues({}, filteredProps));
4319
- } else {
4320
- logInvalidSchemaWarning();
4321
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PersistAsyncSchema_default, __spreadValues({}, props));
4322
- }
4338
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PersistAsyncSchema_default, __spreadValues({}, schemaProps));
4323
4339
  case "validationAsync":
4324
- if (isValidationAsyncSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors)) {
4325
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4326
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ValidationAsyncSchema_default, __spreadValues({}, filteredProps));
4327
- } else {
4328
- logInvalidSchemaWarning();
4329
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ValidationAsyncSchema_default, __spreadValues({}, props));
4330
- }
4340
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ValidationAsyncSchema_default, __spreadValues({}, schemaProps));
4331
4341
  case "basic": {
4332
- if (isBasicSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors)) {
4333
- const filteredProps = __spreadProps(__spreadValues({
4334
- infoMessage: null
4335
- }, schemaProps), {
4336
- schema: schema2,
4337
- model,
4338
- errors
4339
- });
4340
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BasicTypeSchema_default, __spreadValues({}, filteredProps));
4341
- } else {
4342
- const filteredProps = __spreadProps(__spreadValues({
4343
- infoMessage: null
4344
- }, schemaProps), {
4345
- schema: schema2,
4346
- model,
4347
- errors
4348
- });
4349
- logInvalidSchemaWarning();
4350
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BasicTypeSchema_default, __spreadValues({}, filteredProps));
4351
- }
4342
+ const basicTypeProps = __spreadValues({ infoMessage: null }, schemaProps);
4343
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeProps));
4352
4344
  }
4353
4345
  case "object":
4354
- if (isObjectSchema(schema2) && isNullableObjectModel(model)) {
4355
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4356
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ObjectSchema_default, __spreadValues({}, filteredProps), JSON.stringify(schema2));
4357
- } else {
4358
- logInvalidSchemaWarning();
4359
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ObjectSchema_default, __spreadValues({}, props));
4360
- }
4346
+ return /* @__PURE__ */ (0, import_react21.createElement)(ObjectSchema_default, __spreadProps(__spreadValues({}, schemaProps), { key: JSON.stringify(schema2) }));
4361
4347
  case "array":
4362
- if (isArraySchema(schema2) && isNullableArrayModel(model) && isBasicError(errors)) {
4363
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4364
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ArraySchema_default, __spreadValues({}, filteredProps));
4365
- } else {
4366
- logInvalidSchemaWarning();
4367
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ArraySchema_default, __spreadValues({}, props));
4368
- }
4348
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ArraySchema_default, __spreadValues({}, schemaProps));
4369
4349
  case "promotedOneOf":
4370
- if (isOneOfObjectSchema(schema2) && isNullableObjectModel(model)) {
4371
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4372
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfSchema_default, __spreadValues({}, filteredProps));
4373
- } else {
4374
- logInvalidSchemaWarning();
4375
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfSchema_default, __spreadValues({}, props));
4376
- }
4350
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfSchema_default, __spreadValues({}, schemaProps));
4377
4351
  case "oneOf":
4378
- if (isOneOfSchema(schema2)) {
4379
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4380
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(OneOfSchema_default, __spreadValues({}, filteredProps));
4381
- } else {
4382
- logInvalidSchemaWarning();
4383
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(OneOfSchema_default, __spreadValues({}, props));
4384
- }
4352
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(OneOfSchema_default, __spreadValues({}, schemaProps));
4385
4353
  case "allOf":
4386
- if (isAllOfSchema(schema2) && isObjectModel(model)) {
4387
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4388
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AllOfSchema_default, __spreadValues({}, filteredProps));
4389
- } else {
4390
- logInvalidSchemaWarning();
4391
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AllOfSchema_default, __spreadValues({}, props));
4392
- }
4354
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AllOfSchema_default, __spreadValues({}, schemaProps));
4393
4355
  }
4394
4356
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, {});
4395
4357
  };
4396
4358
  var GenericSchema_default = GenericSchemaForm;
4359
+ var isValidGenericSchema = (schema2, model, errors) => {
4360
+ const type = getSchemaType(schema2);
4361
+ switch (type) {
4362
+ case "persistAsync":
4363
+ return isPersistAsyncSchema(schema2) && isNullableStringModel(model) && isBasicError(errors);
4364
+ case "validationAsync":
4365
+ return isValidationAsyncSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors);
4366
+ case "basic":
4367
+ return isBasicSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors);
4368
+ case "object":
4369
+ return isObjectSchema(schema2) && isNullableObjectModel(model);
4370
+ case "array":
4371
+ return isArraySchema(schema2) && isNullableArrayModel(model) && isBasicError(errors);
4372
+ case "promotedOneOf":
4373
+ return isOneOfObjectSchema(schema2) && isNullableObjectModel(model);
4374
+ case "oneOf":
4375
+ return isOneOfSchema(schema2);
4376
+ case "allOf":
4377
+ return isAllOfSchema(schema2) && isObjectModel(model);
4378
+ }
4379
+ return false;
4380
+ };
4397
4381
 
4398
4382
  // src/jsonSchemaForm/JsonSchemaForm.tsx
4399
4383
  var import_jsx_runtime36 = require("react/jsx-runtime");
@@ -4486,13 +4470,13 @@ var DynamicInfo = ({ component }) => {
4486
4470
 
4487
4471
  // src/layout/image/DynamicImage.tsx
4488
4472
  var import_components15 = require("@transferwise/components");
4489
- var import_react19 = require("react");
4473
+ var import_react22 = require("react");
4490
4474
  var import_jsx_runtime40 = require("react/jsx-runtime");
4491
4475
  var DynamicImage = ({ component: image }) => {
4492
4476
  const { url, size, text, margin } = image;
4493
4477
  const httpClient = useHttpClient();
4494
- const [imageSource, setImageSource] = (0, import_react19.useState)("");
4495
- (0, import_react19.useEffect)(() => {
4478
+ const [imageSource, setImageSource] = (0, import_react22.useState)("");
4479
+ (0, import_react22.useEffect)(() => {
4496
4480
  void getImageSource(httpClient, url).then(setImageSource);
4497
4481
  }, [url, httpClient]);
4498
4482
  const imageProps = {
@@ -4689,9 +4673,9 @@ var DynamicParagraph_messages_default = (0, import_react_intl13.defineMessages)(
4689
4673
 
4690
4674
  // src/layout/paragraph/useSnackBarIfAvailable.ts
4691
4675
  var import_components18 = require("@transferwise/components");
4692
- var import_react20 = require("react");
4676
+ var import_react23 = require("react");
4693
4677
  function useSnackBarIfAvailable() {
4694
- const context = (0, import_react20.useContext)(import_components18.SnackbarContext);
4678
+ const context = (0, import_react23.useContext)(import_components18.SnackbarContext);
4695
4679
  return context ? context.createSnackbar : noop3;
4696
4680
  }
4697
4681
  function noop3() {
@@ -4813,13 +4797,13 @@ var BasicTypeSchema = (props) => {
4813
4797
  props.onBlur();
4814
4798
  }
4815
4799
  };
4816
- const [model, setModel] = (0, import_react21.useState)((_a = props.model) != null ? _a : null);
4817
- const [lastModel, setLastModel] = (0, import_react21.useState)((_b = props.model) != null ? _b : null);
4818
- const [changed, setChanged] = (0, import_react21.useState)(false);
4819
- const [focused, setFocused] = (0, import_react21.useState)(false);
4820
- const [blurred, setBlurred] = (0, import_react21.useState)(false);
4821
- const [validations, setValidations] = (0, import_react21.useState)([]);
4822
- const id = (0, import_react21.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
4800
+ const [model, setModel] = (0, import_react24.useState)((_a = props.model) != null ? _a : null);
4801
+ const [lastModel, setLastModel] = (0, import_react24.useState)((_b = props.model) != null ? _b : null);
4802
+ const [changed, setChanged] = (0, import_react24.useState)(false);
4803
+ const [focused, setFocused] = (0, import_react24.useState)(false);
4804
+ const [blurred, setBlurred] = (0, import_react24.useState)(false);
4805
+ const [validations, setValidations] = (0, import_react24.useState)([]);
4806
+ const id = (0, import_react24.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
4823
4807
  const onSchemaChange = () => {
4824
4808
  const defaultValue = getDefaultValue(props.schema);
4825
4809
  if (isNullish(model) && !isNullish(defaultValue)) {
@@ -4834,9 +4818,9 @@ var BasicTypeSchema = (props) => {
4834
4818
  };
4835
4819
  const isConst = props.schema.const;
4836
4820
  const isHidden = props.schema.hidden || isConst;
4837
- (0, import_react21.useEffect)(refreshValidations, [props.model, props.submitted]);
4838
- (0, import_react21.useEffect)(onSchemaChange, [props.schema]);
4839
- (0, import_react21.useEffect)(() => {
4821
+ (0, import_react24.useEffect)(refreshValidations, [props.model, props.submitted]);
4822
+ (0, import_react24.useEffect)(onSchemaChange, [props.schema]);
4823
+ (0, import_react24.useEffect)(() => {
4840
4824
  var _a2;
4841
4825
  const newModel = (_a2 = props.model) != null ? _a2 : null;
4842
4826
  if (newModel !== model) {
@@ -4913,16 +4897,15 @@ var PersistAsyncBasicSchema = (props) => {
4913
4897
  const intl = (0, import_react_intl15.useIntl)();
4914
4898
  const httpClient = useHttpClient();
4915
4899
  const onEvent = useEventDispatcher();
4916
- const [persistAsyncModel, setPersistAsyncModel] = (0, import_react22.useState)(null);
4900
+ const [persistAsyncModel, setPersistAsyncModel] = (0, import_react25.useState)(null);
4917
4901
  const previousPersistAsyncModel = usePrevious(persistAsyncModel);
4918
- const [persistAsyncError, setPersistAsyncError] = (0, import_react22.useState)(null);
4919
- const [fieldSubmitted, setFieldSubmitted] = (0, import_react22.useState)(false);
4920
- const [abortController, setAbortController] = (0, import_react22.useState)(null);
4921
- const log = useLogger();
4922
- (0, import_react22.useEffect)(() => {
4902
+ const [persistAsyncError, setPersistAsyncError] = (0, import_react25.useState)(null);
4903
+ const [fieldSubmitted, setFieldSubmitted] = (0, import_react25.useState)(false);
4904
+ const [abortController, setAbortController] = (0, import_react25.useState)(null);
4905
+ (0, import_react25.useEffect)(() => {
4923
4906
  if (controlTypesWithPersistOnChange.has(
4924
4907
  // TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
4925
- getControlType(props.schema.persistAsync.schema, log)
4908
+ getControlType(props.schema.persistAsync.schema)
4926
4909
  )) {
4927
4910
  persistAsyncIfValid();
4928
4911
  }
@@ -5007,7 +4990,7 @@ var PersistAsyncBasicSchema_default = PersistAsyncBasicSchema;
5007
4990
 
5008
4991
  // src/common/hooks/usePersistAsync/usePersistAsync.ts
5009
4992
  var usePersistAsync = (persistAsync) => {
5010
- const [abortController, setAbortController] = (0, import_react23.useState)(null);
4993
+ const [abortController, setAbortController] = (0, import_react26.useState)(null);
5011
4994
  const httpClient = useHttpClient();
5012
4995
  const intl = (0, import_react_intl16.useIntl)();
5013
4996
  const { schema: schema2 } = persistAsync;
@@ -5086,7 +5069,7 @@ function hasStringMessage(value) {
5086
5069
  }
5087
5070
 
5088
5071
  // src/common/hooks/usePolling/usePolling.tsx
5089
- var import_react24 = require("react");
5072
+ var import_react27 = require("react");
5090
5073
  function usePolling({
5091
5074
  asyncFn,
5092
5075
  interval,
@@ -5095,9 +5078,9 @@ function usePolling({
5095
5078
  onPollingResponse,
5096
5079
  onFailure
5097
5080
  }) {
5098
- const onPollingResponseReference = (0, import_react24.useRef)(onPollingResponse);
5099
- const onFailureReference = (0, import_react24.useRef)(onFailure);
5100
- const poll = (0, import_react24.useMemo)(
5081
+ const onPollingResponseReference = (0, import_react27.useRef)(onPollingResponse);
5082
+ const onFailureReference = (0, import_react27.useRef)(onFailure);
5083
+ const poll = (0, import_react27.useMemo)(
5101
5084
  () => createPollingClosure(
5102
5085
  asyncFn,
5103
5086
  maxAttempts,
@@ -5107,7 +5090,7 @@ function usePolling({
5107
5090
  ),
5108
5091
  [asyncFn, maxAttempts, maxConsecutiveFails]
5109
5092
  );
5110
- (0, import_react24.useEffect)(() => {
5093
+ (0, import_react27.useEffect)(() => {
5111
5094
  if (interval > 0) {
5112
5095
  const intervalReference = setInterval(() => {
5113
5096
  poll();
@@ -5115,7 +5098,7 @@ function usePolling({
5115
5098
  return () => clearInterval(intervalReference);
5116
5099
  }
5117
5100
  }, [poll, interval]);
5118
- (0, import_react24.useEffect)(() => {
5101
+ (0, import_react27.useEffect)(() => {
5119
5102
  onPollingResponseReference.current = onPollingResponse;
5120
5103
  onFailureReference.current = onFailure;
5121
5104
  }, [onPollingResponse, onFailure]);
@@ -5144,20 +5127,20 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
5144
5127
  }
5145
5128
 
5146
5129
  // src/common/hooks/usePrevious/usePrevious.js
5147
- var import_react25 = require("react");
5130
+ var import_react28 = require("react");
5148
5131
  var usePrevious = (value) => {
5149
- const reference = (0, import_react25.useRef)();
5150
- (0, import_react25.useEffect)(() => {
5132
+ const reference = (0, import_react28.useRef)();
5133
+ (0, import_react28.useEffect)(() => {
5151
5134
  reference.current = value;
5152
5135
  }, [value]);
5153
5136
  return reference.current;
5154
5137
  };
5155
5138
 
5156
5139
  // src/common/hooks/useStepPolling/useStepPolling.tsx
5157
- var import_react26 = require("react");
5140
+ var import_react29 = require("react");
5158
5141
  function useStepPolling(polling, onAction) {
5159
5142
  const httpClient = useHttpClient();
5160
- const asyncFn = (0, import_react26.useMemo)(() => {
5143
+ const asyncFn = (0, import_react29.useMemo)(() => {
5161
5144
  if (polling) {
5162
5145
  return () => {
5163
5146
  return httpClient(polling.url).then((response) => {
@@ -5172,7 +5155,7 @@ function useStepPolling(polling, onAction) {
5172
5155
  return void 0;
5173
5156
  }
5174
5157
  }, [polling, httpClient]);
5175
- const onPollingResponse = (0, import_react26.useCallback)(
5158
+ const onPollingResponse = (0, import_react29.useCallback)(
5176
5159
  (pollingResponse) => {
5177
5160
  if (pollingResponse == null ? void 0 : pollingResponse.action) {
5178
5161
  onAction(pollingResponse.action);
@@ -5188,7 +5171,7 @@ function useStepPolling(polling, onAction) {
5188
5171
  maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
5189
5172
  maxConsecutiveFails: 1,
5190
5173
  onPollingResponse,
5191
- onFailure: (0, import_react26.useCallback)(() => {
5174
+ onFailure: (0, import_react29.useCallback)(() => {
5192
5175
  if (polling) {
5193
5176
  onAction(polling.onError.action);
5194
5177
  }
@@ -5236,10 +5219,10 @@ var LayoutStep = (props) => {
5236
5219
  var LayoutStep_default = LayoutStep;
5237
5220
 
5238
5221
  // src/step/cameraStep/CameraStep.tsx
5239
- var import_react30 = require("react");
5222
+ var import_react33 = require("react");
5240
5223
 
5241
5224
  // src/step/cameraStep/cameraCapture/CameraCapture.tsx
5242
- var import_react29 = require("react");
5225
+ var import_react32 = require("react");
5243
5226
  var import_react_intl23 = require("react-intl");
5244
5227
  var import_react_webcam = __toESM(require_react_webcam());
5245
5228
 
@@ -5311,7 +5294,7 @@ var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0, import_jsx_runtime49.js
5311
5294
  );
5312
5295
 
5313
5296
  // src/step/cameraStep/cameraCapture/hooks/index.ts
5314
- var import_react27 = require("react");
5297
+ var import_react30 = require("react");
5315
5298
 
5316
5299
  // src/step/cameraStep/cameraCapture/utils/index.ts
5317
5300
  var isSelfieCamera = (stream) => {
@@ -5359,7 +5342,7 @@ var getVideoCapabilities = (videoStream) => {
5359
5342
 
5360
5343
  // src/step/cameraStep/cameraCapture/hooks/index.ts
5361
5344
  var useVideoConstraints = (direction) => {
5362
- const [videoConstraints, setVideoConstraints] = (0, import_react27.useState)();
5345
+ const [videoConstraints, setVideoConstraints] = (0, import_react30.useState)();
5363
5346
  const defaultVideoConstraints = {
5364
5347
  facingMode: direction === "front" ? "user" : "environment",
5365
5348
  height: { min: 480, max: 1080, ideal: 720 },
@@ -5367,7 +5350,7 @@ var useVideoConstraints = (direction) => {
5367
5350
  frameRate: 30,
5368
5351
  aspectRatio: 16 / 9
5369
5352
  };
5370
- (0, import_react27.useEffect)(() => {
5353
+ (0, import_react30.useEffect)(() => {
5371
5354
  void getVideoConstraints(direction).then(setVideoConstraints);
5372
5355
  }, [direction]);
5373
5356
  const getVideoConstraints = async (direction2) => {
@@ -5385,7 +5368,7 @@ var useVideoConstraints = (direction) => {
5385
5368
  };
5386
5369
 
5387
5370
  // src/step/cameraStep/cameraCapture/overlay/Overlay.tsx
5388
- var import_react28 = require("react");
5371
+ var import_react31 = require("react");
5389
5372
  var import_jsx_runtime50 = require("react/jsx-runtime");
5390
5373
  var captureButtonHeight = 92;
5391
5374
  var reviewButtonsHeight = 120;
@@ -5402,8 +5385,8 @@ var Overlay = ({
5402
5385
  instructions,
5403
5386
  reviewInstructions
5404
5387
  }) => {
5405
- const svgReference = (0, import_react28.useRef)(null);
5406
- (0, import_react28.useEffect)(() => {
5388
+ const svgReference = (0, import_react31.useRef)(null);
5389
+ (0, import_react31.useEffect)(() => {
5407
5390
  const listener = debounce(() => {
5408
5391
  var _a;
5409
5392
  if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
@@ -5553,14 +5536,14 @@ var CameraCapture = ({
5553
5536
  onCapture,
5554
5537
  onEvent
5555
5538
  }) => {
5556
- const [mode, setMode] = (0, import_react29.useState)("CAPTURE");
5557
- const [isVideoMirrored, setIsVideoMirrored] = (0, import_react29.useState)(false);
5558
- const [ready, setReady] = (0, import_react29.useState)(false);
5559
- const [reviewImage, setReviewImage] = (0, import_react29.useState)();
5560
- const webcamReference = (0, import_react29.useRef)(null);
5539
+ const [mode, setMode] = (0, import_react32.useState)("CAPTURE");
5540
+ const [isVideoMirrored, setIsVideoMirrored] = (0, import_react32.useState)(false);
5541
+ const [ready, setReady] = (0, import_react32.useState)(false);
5542
+ const [reviewImage, setReviewImage] = (0, import_react32.useState)();
5543
+ const webcamReference = (0, import_react32.useRef)(null);
5561
5544
  const { videoConstraints } = useVideoConstraints(direction);
5562
5545
  const intl = (0, import_react_intl23.useIntl)();
5563
- const handleCapture = (0, import_react29.useCallback)(async () => {
5546
+ const handleCapture = (0, import_react32.useCallback)(async () => {
5564
5547
  var _a, _b, _c, _d, _e, _f;
5565
5548
  if (((_a = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _a.video) && ((_c = (_b = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _b.video) == null ? void 0 : _c.readyState) >= 3) {
5566
5549
  (_e = (_d = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _d.video) == null ? void 0 : _e.pause();
@@ -5582,7 +5565,7 @@ var CameraCapture = ({
5582
5565
  );
5583
5566
  }
5584
5567
  }, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
5585
- const handleUserMediaError = (0, import_react29.useCallback)(
5568
+ const handleUserMediaError = (0, import_react32.useCallback)(
5586
5569
  (error) => {
5587
5570
  if (error instanceof DOMException && (error == null ? void 0 : error.name) === "NotAllowedError") {
5588
5571
  setMode("NO_CAMERA_ACCESS");
@@ -5594,7 +5577,7 @@ var CameraCapture = ({
5594
5577
  },
5595
5578
  [setMode, onEvent]
5596
5579
  );
5597
- const handleUserMedia = (0, import_react29.useCallback)(
5580
+ const handleUserMedia = (0, import_react32.useCallback)(
5598
5581
  (stream) => {
5599
5582
  setReady(true);
5600
5583
  setIsVideoMirrored(isSelfieCamera(stream));
@@ -5676,8 +5659,8 @@ var CameraStep = (props) => {
5676
5659
  const { assets, direction, instructions } = cameraConfig || {};
5677
5660
  const { overlay, outline } = assets || {};
5678
5661
  const { url: imageUrl } = image || {};
5679
- const [captureClicked, setCaptureClicked] = (0, import_react30.useState)(false);
5680
- (0, import_react30.useEffect)(() => {
5662
+ const [captureClicked, setCaptureClicked] = (0, import_react33.useState)(false);
5663
+ (0, import_react33.useEffect)(() => {
5681
5664
  if (captureClicked) {
5682
5665
  onAction(action2);
5683
5666
  }
@@ -5865,10 +5848,10 @@ var DynamicFlowStep = (props) => {
5865
5848
  };
5866
5849
 
5867
5850
  // src/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.ts
5868
- var import_react31 = require("react");
5851
+ var import_react34 = require("react");
5869
5852
  var DEBOUNCE_DELAY = 1e3;
5870
5853
  function useDebouncedRefresh(fetchRefresh) {
5871
- const map = (0, import_react31.useRef)(/* @__PURE__ */ new Map());
5854
+ const map = (0, import_react34.useRef)(/* @__PURE__ */ new Map());
5872
5855
  const retrieveOrCreate = (key) => {
5873
5856
  if (map.current.has(key)) {
5874
5857
  return map.current.get(key);
@@ -5890,7 +5873,7 @@ function useDebouncedRefresh(fetchRefresh) {
5890
5873
  }
5891
5874
 
5892
5875
  // src/dynamicFlow/utils/useDynamicFlowState.ts
5893
- var import_react32 = require("react");
5876
+ var import_react35 = require("react");
5894
5877
 
5895
5878
  // src/dynamicFlow/DynamicFlowTypes.ts
5896
5879
  function isSchema(schema2) {
@@ -5900,9 +5883,9 @@ function isSchema(schema2) {
5900
5883
  // src/dynamicFlow/utils/useDynamicFlowState.ts
5901
5884
  var useDynamicFlowState = (initialStep) => {
5902
5885
  var _a, _b;
5903
- const [formErrors, setFormErrors] = (0, import_react32.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
5904
- const [globalError, setGlobalError] = (0, import_react32.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
5905
- const [stepAndModels, setStepAndModels] = (0, import_react32.useState)({
5886
+ const [formErrors, setFormErrors] = (0, import_react35.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
5887
+ const [globalError, setGlobalError] = (0, import_react35.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
5888
+ const [stepAndModels, setStepAndModels] = (0, import_react35.useState)({
5906
5889
  step: initialStep || void 0,
5907
5890
  models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
5908
5891
  etag: void 0
@@ -5932,7 +5915,7 @@ var useDynamicFlowState = (initialStep) => {
5932
5915
  return updatedState;
5933
5916
  });
5934
5917
  };
5935
- const modelIsValid = (0, import_react32.useMemo)(() => areModelsValid(models, getAllSchemas(step35)), [models, step35]);
5918
+ const modelIsValid = (0, import_react35.useMemo)(() => areModelsValid(models, getAllSchemas(step35)), [models, step35]);
5936
5919
  return {
5937
5920
  formErrors,
5938
5921
  globalError,
@@ -5983,7 +5966,7 @@ var areModelsValid = (formModels, schemas = []) => {
5983
5966
 
5984
5967
  // src/dynamicFlow/utils/useLoader.tsx
5985
5968
  var import_components24 = require("@transferwise/components");
5986
- var import_react33 = require("react");
5969
+ var import_react36 = require("react");
5987
5970
  var import_jsx_runtime57 = require("react/jsx-runtime");
5988
5971
  function useLoader(loaderConfig, initialState) {
5989
5972
  const config = __spreadValues({
@@ -5991,7 +5974,7 @@ function useLoader(loaderConfig, initialState) {
5991
5974
  initial: true,
5992
5975
  submission: false
5993
5976
  }, loaderConfig);
5994
- const [loadingState, setLoadingState] = (0, import_react33.useState)(initialState);
5977
+ const [loadingState, setLoadingState] = (0, import_react36.useState)(initialState);
5995
5978
  const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
5996
5979
  const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
5997
5980
  import_components24.Loader,
@@ -6005,7 +5988,7 @@ function useLoader(loaderConfig, initialState) {
6005
5988
  }
6006
5989
 
6007
5990
  // src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
6008
- var import_react34 = require("react");
5991
+ var import_react37 = require("react");
6009
5992
 
6010
5993
  // src/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.tsx
6011
5994
  var import_components25 = require("@transferwise/components");
@@ -6049,7 +6032,7 @@ var ErrorBoundaryAlert = ({ onDismiss }) => {
6049
6032
  var import_jsx_runtime59 = require("react/jsx-runtime");
6050
6033
  var noop6 = () => {
6051
6034
  };
6052
- var ErrorBoundary = class extends import_react34.Component {
6035
+ var ErrorBoundary = class extends import_react37.Component {
6053
6036
  constructor(props) {
6054
6037
  super(props);
6055
6038
  this.handleErrorReset = () => {
@@ -6197,24 +6180,24 @@ var DynamicFlowComponent = ({
6197
6180
  setStepAndEtag,
6198
6181
  setSchemaModel
6199
6182
  } = useDynamicFlowState(initialStep);
6200
- const [submitted, setSubmitted] = (0, import_react35.useState)(false);
6183
+ const [submitted, setSubmitted] = (0, import_react38.useState)(false);
6201
6184
  const { isLoading, loader, setLoadingState } = useLoader(
6202
6185
  loaderConfig,
6203
6186
  initialStep ? "idle" : "initial"
6204
6187
  );
6205
6188
  const logCritical = getLogger("critical", onLog, flowId, (step35 == null ? void 0 : step35.id) || (step35 == null ? void 0 : step35.key));
6206
- const analyticsMetadata = (0, import_react35.useMemo)(
6189
+ const analyticsMetadata = (0, import_react38.useMemo)(
6207
6190
  () => {
6208
6191
  var _a;
6209
6192
  return __spreadValues({ flowId, stepId: (step35 == null ? void 0 : step35.id) || (step35 == null ? void 0 : step35.key) }, (_a = step35 == null ? void 0 : step35.analytics) != null ? _a : {});
6210
6193
  },
6211
6194
  [flowId, step35]
6212
6195
  );
6213
- const dispatchEvent = (0, import_react35.useMemo)(
6196
+ const dispatchEvent = (0, import_react38.useMemo)(
6214
6197
  () => getEventDispatcher(onEvent, analyticsMetadata),
6215
6198
  [onEvent, analyticsMetadata]
6216
6199
  );
6217
- const dfHttpClient = (0, import_react35.useCallback)(
6200
+ const dfHttpClient = (0, import_react38.useCallback)(
6218
6201
  ({ action: action2, data, etag: etag2 }) => {
6219
6202
  const { url, method = "POST" } = action2;
6220
6203
  return httpClient(url != null ? url : "", {
@@ -6264,17 +6247,17 @@ var DynamicFlowComponent = ({
6264
6247
  dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
6265
6248
  };
6266
6249
  const debouncedRefresh = useDebouncedRefresh(performRefresh);
6267
- const dispatchEventAndComplete = (0, import_react35.useCallback)(
6250
+ const dispatchEventAndComplete = (0, import_react38.useCallback)(
6268
6251
  (result) => {
6269
6252
  dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
6270
6253
  onCompletion(result);
6271
6254
  },
6272
6255
  [onCompletion, dispatchEvent]
6273
6256
  );
6274
- (0, import_react35.useEffect)(() => {
6257
+ (0, import_react38.useEffect)(() => {
6275
6258
  dispatchEvent("Dynamic Flow - Flow Started", {});
6276
6259
  }, []);
6277
- (0, import_react35.useEffect)(() => {
6260
+ (0, import_react38.useEffect)(() => {
6278
6261
  if (!initialStep) {
6279
6262
  const action2 = __spreadValues({
6280
6263
  $id: "#initial-step-request",