@wise/dynamic-flow-client-internal 5.17.0 → 5.18.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.mjs CHANGED
@@ -123,7 +123,7 @@ import { useDynamicFlow } from "@wise/dynamic-flow-client";
123
123
  // src/dynamicFlow/telemetry/app-version.ts
124
124
  var appVersion = (
125
125
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
126
- typeof process !== "undefined" ? "5.17.0" : "0.0.0"
126
+ typeof process !== "undefined" ? "5.18.1" : "0.0.0"
127
127
  );
128
128
 
129
129
  // src/dynamicFlow/context-menu/useContextMenu.tsx
@@ -208,27 +208,29 @@ var useDFContextMenu = (controller) => {
208
208
  }
209
209
  },
210
210
  {
211
- label: "Open in Sandbox",
211
+ label: "Copy step JSON",
212
212
  onClick: () => {
213
- openInSandbox(getEncodedCurrentStep());
213
+ copyToClipboard(getCurrentStep());
214
214
  }
215
215
  },
216
216
  {
217
- label: "Open in Sandbox (with model)",
217
+ label: "Open in Studio (experimental)",
218
218
  onClick: () => {
219
- void getEncodedCurrentStepWithModel().then(openInSandbox);
219
+ openIn("studio", getEncodedCurrentStep());
220
220
  }
221
221
  },
222
222
  {
223
- label: "Copy step JSON",
223
+ label: "Open in Sandbox",
224
224
  onClick: () => {
225
- copyToClipboard(getCurrentStep());
225
+ openIn("sandbox", getEncodedCurrentStep());
226
226
  }
227
227
  },
228
228
  {
229
- label: "Copy step JSON (with model)",
229
+ label: "Open in Sandbox (with model)",
230
230
  onClick: () => {
231
- void getCurrentStepWithModel().then(copyToClipboard);
231
+ void getEncodedCurrentStepWithModel().then(
232
+ (base64Step) => openIn("sandbox", base64Step)
233
+ );
232
234
  }
233
235
  }
234
236
  ] : []
@@ -239,9 +241,9 @@ var toBase64 = (str) => {
239
241
  const binString = Array.from(bytes, (b) => String.fromCharCode(b)).join("");
240
242
  return btoa(binString);
241
243
  };
242
- var openInSandbox = (base64Step) => {
244
+ var openIn = (editor, base64Step) => {
243
245
  if (base64Step) {
244
- window.open(`https://df.wise.com/sandbox#${base64Step}`, "_blank", "noopener,noreferrer");
246
+ window.open(`https://df.wise.com/${editor}#${base64Step}`, "_blank", "noopener,noreferrer");
245
247
  }
246
248
  };
247
249
  var openVersionPage = (version) => {
@@ -307,54 +309,8 @@ var recursivelyRemoveNullish = (element) => {
307
309
  // src/dynamicFlow/useWiseToCoreProps.tsx
308
310
  import { useMemo as useMemo2 } from "react";
309
311
 
310
- // src/dynamicFlow/telemetry/getLogEvent.ts
311
- var getLogEvent = (onLog) => (level, message, extra) => {
312
- const extraWithVersion = __spreadProps(__spreadValues({}, extra), {
313
- dfWiseVersion: appVersion
314
- });
315
- if (level !== "info" && onLog) {
316
- if (onLog) {
317
- onLog(level, message, extraWithVersion);
318
- } else {
319
- logToRollbar(level, message, extraWithVersion);
320
- }
321
- }
322
- };
323
- var logToRollbar = (level, message, extra) => {
324
- try {
325
- const rollbar = typeof window.Rollbar !== "undefined" ? window.Rollbar : void 0;
326
- rollbar == null ? void 0 : rollbar[level](message, extra);
327
- } catch (error) {
328
- console.error("Failed to log to Rollbar", error);
329
- }
330
- };
331
-
332
- // src/dynamicFlow/telemetry/getTrackEvent.ts
333
- import { eventNames } from "@wise/dynamic-flow-client";
334
- var prefix = "Dynamic Flow - ";
335
- var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
336
- onEvent == null ? void 0 : onEvent(name, properties);
337
- if (includeInAnalytics(name)) {
338
- onAnalytics == null ? void 0 : onAnalytics(name, properties);
339
- }
340
- };
341
- var includeInAnalytics = (name) => {
342
- const eventName = name.startsWith(prefix) ? name.slice(prefix.length) : name;
343
- if (isCoreEventName(eventName)) {
344
- return true;
345
- }
346
- if (eventName in customEventsToAnalytics) {
347
- return customEventsToAnalytics[eventName];
348
- }
349
- return true;
350
- };
351
- var isCoreEventName = (eventName) => {
352
- return eventNames.includes(eventName);
353
- };
354
- var customEventsToAnalytics = {
355
- "Theme Required": false
356
- // Excluded from analytics
357
- };
312
+ // src/dynamicFlow/getMergedRenderers.tsx
313
+ import { getDynamicSubflowRenderer } from "@wise/dynamic-flow-client";
358
314
 
359
315
  // ../renderers/src/AlertRenderer.tsx
360
316
  import { Alert } from "@transferwise/components";
@@ -893,6 +849,18 @@ var getPriority = (control, tags) => {
893
849
 
894
850
  // ../renderers/src/components/FieldInput.tsx
895
851
  import { Field } from "@transferwise/components";
852
+ import { useEffect as useEffect4, useRef } from "react";
853
+
854
+ // ../renderers/src/utils/scroll-to-if-not-visible.ts
855
+ var scrollToIfNotVisible = (ref) => {
856
+ const rect = ref == null ? void 0 : ref.getBoundingClientRect();
857
+ if (!ref || !rect) {
858
+ return;
859
+ }
860
+ if (rect.bottom > window.innerHeight || rect.top < 0) {
861
+ ref.scrollIntoView({ behavior: "smooth" });
862
+ }
863
+ };
896
864
 
897
865
  // ../renderers/src/components/Help.tsx
898
866
  import { Info, Markdown } from "@transferwise/components";
@@ -936,28 +904,47 @@ function LabelContentWithHelp({ text, help }) {
936
904
 
937
905
  // ../renderers/src/components/FieldInput.tsx
938
906
  import { jsx as jsx19 } from "react/jsx-runtime";
939
- function FieldInput({ id, children, label, validation, description, help }) {
907
+ function FieldInput({
908
+ id,
909
+ children,
910
+ label,
911
+ validation,
912
+ description,
913
+ help,
914
+ loadingState = "idle",
915
+ inlineAlert
916
+ }) {
940
917
  const labelContent = label && help ? /* @__PURE__ */ jsx19(LabelContentWithHelp, { text: label, help }) : label;
941
- return /* @__PURE__ */ jsx19(
918
+ const message = validation == null ? void 0 : validation.message;
919
+ const ref = useRef(null);
920
+ useEffect4(() => {
921
+ if (message) {
922
+ scrollToIfNotVisible(ref.current);
923
+ }
924
+ }, [message]);
925
+ return /* @__PURE__ */ jsx19("div", { ref, children: /* @__PURE__ */ jsx19(
942
926
  Field,
943
927
  {
944
928
  id,
945
929
  label: labelContent,
946
930
  description,
947
- message: validation == null ? void 0 : validation.message,
948
- sentiment: mapStatusToSentiment(validation),
931
+ message: message != null ? message : inlineAlert == null ? void 0 : inlineAlert.content,
932
+ messageLoading: loadingState !== "idle",
933
+ sentiment: mapStatusToSentiment(validation, inlineAlert == null ? void 0 : inlineAlert.context),
949
934
  children
950
935
  }
951
- );
936
+ ) });
952
937
  }
953
- var mapStatusToSentiment = (validation) => {
954
- if (validation) {
955
- if (validation.status === "valid") {
956
- return "positive";
938
+ var mapStatusToSentiment = (validation, defaultContext) => {
939
+ if (validation == null ? void 0 : validation.message) {
940
+ switch (validation.status) {
941
+ case "valid":
942
+ return "positive";
943
+ case "invalid":
944
+ return "negative";
957
945
  }
958
- return "negative";
959
946
  }
960
- return void 0;
947
+ return defaultContext;
961
948
  };
962
949
  var FieldInput_default = FieldInput;
963
950
 
@@ -1025,7 +1012,19 @@ var CheckboxComponent = (props) => {
1025
1012
  "value"
1026
1013
  ]);
1027
1014
  const checkboxProps = __spreadProps(__spreadValues({}, rest), { label: title, secondary: description, checked: value });
1028
- return /* @__PURE__ */ jsx23(FieldInput_default, { id, label: "", description: "", validation: validationState, help, children: /* @__PURE__ */ jsx23(Checkbox, __spreadValues({ id }, checkboxProps)) });
1015
+ return /* @__PURE__ */ jsx23(
1016
+ FieldInput_default,
1017
+ {
1018
+ id,
1019
+ label: "",
1020
+ description: "",
1021
+ validation: validationState,
1022
+ help,
1023
+ inlineAlert: rest.inlineAlert,
1024
+ loadingState: rest.fieldLoadingState,
1025
+ children: /* @__PURE__ */ jsx23(Checkbox, __spreadValues({ id }, checkboxProps))
1026
+ }
1027
+ );
1029
1028
  };
1030
1029
  var CheckboxItemComponent = (props) => {
1031
1030
  const {
@@ -1080,7 +1079,7 @@ var SwitchItemComponent = (props) => {
1080
1079
  );
1081
1080
  };
1082
1081
  var getInlineAlertOrValidation = (validationState, inlineAlert) => {
1083
- if (validationState && validationState.status === "invalid") {
1082
+ if ((validationState == null ? void 0 : validationState.status) === "invalid") {
1084
1083
  return /* @__PURE__ */ jsx23(ListItem3.Prompt, { sentiment: "negative", children: validationState.message });
1085
1084
  }
1086
1085
  return getInlineAlert(inlineAlert);
@@ -1217,6 +1216,8 @@ var DateInputRenderer = {
1217
1216
  label: title,
1218
1217
  description,
1219
1218
  validation: validationState,
1219
+ inlineAlert: props.inlineAlert,
1220
+ loadingState: props.fieldLoadingState,
1220
1221
  help,
1221
1222
  children: /* @__PURE__ */ jsx26(VariableDateInput_default, { control, inputProps })
1222
1223
  }
@@ -1523,7 +1524,7 @@ var external_confirmation_messages_default = defineMessages5({
1523
1524
 
1524
1525
  // ../renderers/src/ExternalConfirmationRenderer.tsx
1525
1526
  import { useIntl as useIntl5 } from "react-intl";
1526
- import { useEffect as useEffect4 } from "react";
1527
+ import { useEffect as useEffect5 } from "react";
1527
1528
  import { Fragment as Fragment4, jsx as jsx32, jsxs as jsxs7 } from "react/jsx-runtime";
1528
1529
  var ExternalConfirmationRenderer = {
1529
1530
  canRenderType: "external-confirmation",
@@ -1536,7 +1537,7 @@ function ExternalConfirmationRendererComponent({
1536
1537
  onCancel
1537
1538
  }) {
1538
1539
  const { formatMessage } = useIntl5();
1539
- useEffect4(() => {
1540
+ useEffect5(() => {
1540
1541
  open();
1541
1542
  }, []);
1542
1543
  return /* @__PURE__ */ jsx32(
@@ -1650,7 +1651,7 @@ var HeadingRenderer_default = HeadingRenderer;
1650
1651
 
1651
1652
  // ../renderers/src/ImageRenderer/UrlImage.tsx
1652
1653
  import { Image } from "@transferwise/components";
1653
- import { useEffect as useEffect5, useState as useState5 } from "react";
1654
+ import { useEffect as useEffect6, useState as useState5 } from "react";
1654
1655
 
1655
1656
  // ../renderers/src/utils/api-utils.ts
1656
1657
  function isRelativePath(url = "") {
@@ -1670,7 +1671,7 @@ function UrlImage({
1670
1671
  httpClient
1671
1672
  }) {
1672
1673
  const [imageSource, setImageSource] = useState5("");
1673
- useEffect5(() => {
1674
+ useEffect6(() => {
1674
1675
  if (!uri.startsWith("urn:")) {
1675
1676
  void getImageSource(httpClient, uri).then(setImageSource);
1676
1677
  }
@@ -1909,6 +1910,8 @@ var IntegerInputRenderer = {
1909
1910
  label: title,
1910
1911
  description,
1911
1912
  validation: validationState,
1913
+ inlineAlert: props.inlineAlert,
1914
+ loadingState: props.fieldLoadingState,
1912
1915
  help,
1913
1916
  children: /* @__PURE__ */ jsx43(InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx43(
1914
1917
  Input,
@@ -2162,7 +2165,7 @@ var ModalRenderer = {
2162
2165
 
2163
2166
  // ../renderers/src/MoneyInputRenderer.tsx
2164
2167
  import { MoneyInput } from "@transferwise/components";
2165
- import { useEffect as useEffect6 } from "react";
2168
+ import { useEffect as useEffect7 } from "react";
2166
2169
  import { useIntl as useIntl6 } from "react-intl";
2167
2170
  import { jsx as jsx52 } from "react/jsx-runtime";
2168
2171
  var groupingTags2 = Object.keys(group_messages_default).filter((key) => key !== "all");
@@ -2185,7 +2188,7 @@ function MoneyInputRendererComponent(props) {
2185
2188
  onAmountChange,
2186
2189
  onCurrencyChange
2187
2190
  } = props;
2188
- useEffect6(() => {
2191
+ useEffect7(() => {
2189
2192
  if (!isValidIndex(selectedCurrencyIndex, currencies.length)) {
2190
2193
  onCurrencyChange(0);
2191
2194
  }
@@ -2503,6 +2506,7 @@ import { Status, UploadInput } from "@transferwise/components";
2503
2506
 
2504
2507
  // ../renderers/src/components/UploadFieldInput.tsx
2505
2508
  var import_classnames4 = __toESM(require_classnames());
2509
+ import { useEffect as useEffect8, useRef as useRef2 } from "react";
2506
2510
  import { InlineAlert as InlineAlert2 } from "@transferwise/components";
2507
2511
  import { jsx as jsx57, jsxs as jsxs12 } from "react/jsx-runtime";
2508
2512
  function UploadFieldInput({
@@ -2515,9 +2519,17 @@ function UploadFieldInput({
2515
2519
  }) {
2516
2520
  const labelContent = label && help ? /* @__PURE__ */ jsx57(LabelContentWithHelp, { text: label, help }) : label;
2517
2521
  const descriptionId = description ? `${id}-description` : void 0;
2522
+ const message = validation == null ? void 0 : validation.message;
2523
+ const ref = useRef2(null);
2524
+ useEffect8(() => {
2525
+ if (message) {
2526
+ scrollToIfNotVisible(ref.current);
2527
+ }
2528
+ }, [message]);
2518
2529
  return /* @__PURE__ */ jsxs12(
2519
2530
  "div",
2520
2531
  {
2532
+ ref,
2521
2533
  className: (0, import_classnames4.default)("form-group d-block", {
2522
2534
  "has-error": (validation == null ? void 0 : validation.status) === "invalid"
2523
2535
  }),
@@ -2642,6 +2654,8 @@ var NumberInputRenderer = {
2642
2654
  label: title,
2643
2655
  description,
2644
2656
  validation: validationState,
2657
+ inlineAlert: props.inlineAlert,
2658
+ loadingState: props.fieldLoadingState,
2645
2659
  help,
2646
2660
  children: /* @__PURE__ */ jsx59(InputGroup2, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx59(
2647
2661
  Input2,
@@ -3348,7 +3362,7 @@ function RadioInputRendererComponent(props) {
3348
3362
 
3349
3363
  // ../renderers/src/SelectInputRenderer/TabInputRendererComponent.tsx
3350
3364
  import { Tabs } from "@transferwise/components";
3351
- import { useEffect as useEffect7 } from "react";
3365
+ import { useEffect as useEffect9 } from "react";
3352
3366
  import { Fragment as Fragment9, jsx as jsx71, jsxs as jsxs21 } from "react/jsx-runtime";
3353
3367
  function TabInputRendererComponent(props) {
3354
3368
  const {
@@ -3363,7 +3377,7 @@ function TabInputRendererComponent(props) {
3363
3377
  validationState,
3364
3378
  onSelect
3365
3379
  } = props;
3366
- useEffect7(() => {
3380
+ useEffect9(() => {
3367
3381
  if (!isValidIndex2(selectedIndex, options.length)) {
3368
3382
  onSelect(0);
3369
3383
  }
@@ -3476,7 +3490,7 @@ function SelectInputRendererComponent(props) {
3476
3490
  }
3477
3491
 
3478
3492
  // ../renderers/src/SelectInputRenderer/SegmentedInputRendererComponent.tsx
3479
- import { useEffect as useEffect8 } from "react";
3493
+ import { useEffect as useEffect10 } from "react";
3480
3494
  import { SegmentedControl } from "@transferwise/components";
3481
3495
  import { Fragment as Fragment11, jsx as jsx73, jsxs as jsxs23 } from "react/jsx-runtime";
3482
3496
  function SegmentedInputRendererComponent(props) {
@@ -3491,7 +3505,7 @@ function SegmentedInputRendererComponent(props) {
3491
3505
  validationState,
3492
3506
  onSelect
3493
3507
  } = props;
3494
- useEffect8(() => {
3508
+ useEffect10(() => {
3495
3509
  if (!isValidIndex3(selectedIndex, options.length)) {
3496
3510
  onSelect(0);
3497
3511
  }
@@ -3659,12 +3673,12 @@ var StatusListRenderer_default = StatusListRenderer;
3659
3673
 
3660
3674
  // ../renderers/src/utils/useCustomTheme.ts
3661
3675
  import { useTheme } from "@wise/components-theming";
3662
- import { useEffect as useEffect9, useMemo } from "react";
3676
+ import { useEffect as useEffect11, useMemo } from "react";
3663
3677
  var ThemeRequiredEventName = "Theme Required";
3664
3678
  var useCustomTheme = (theme, trackEvent) => {
3665
3679
  const theming = useTheme();
3666
3680
  const previousTheme = useMemo(() => theming.theme, []);
3667
- useEffect9(() => {
3681
+ useEffect11(() => {
3668
3682
  theming.setTheme(theme);
3669
3683
  trackEvent(ThemeRequiredEventName, { theme });
3670
3684
  return theme !== previousTheme ? () => {
@@ -3677,7 +3691,7 @@ var useCustomTheme = (theme, trackEvent) => {
3677
3691
 
3678
3692
  // ../renderers/src/step/StepFooter.tsx
3679
3693
  import { Button as Button7 } from "@transferwise/components";
3680
- import { useEffect as useEffect10, useRef, useState as useState12 } from "react";
3694
+ import { useEffect as useEffect12, useRef as useRef3, useState as useState12 } from "react";
3681
3695
  import { useIntl as useIntl14 } from "react-intl";
3682
3696
 
3683
3697
  // ../renderers/src/messages/step.messages.ts
@@ -3705,7 +3719,7 @@ var DefaultFooter = ({ footer }) => {
3705
3719
  };
3706
3720
  var FooterWithScrollButton = ({ footer }) => {
3707
3721
  const { formatMessage } = useIntl14();
3708
- const endOfLayoutRef = useRef(null);
3722
+ const endOfLayoutRef = useRef3(null);
3709
3723
  const isElementVisible = useIsElementVisible(endOfLayoutRef);
3710
3724
  const scrollButton = /* @__PURE__ */ jsx77(
3711
3725
  Button7,
@@ -3735,7 +3749,7 @@ var FooterWithScrollButton = ({ footer }) => {
3735
3749
  };
3736
3750
  var useIsElementVisible = (elementRef) => {
3737
3751
  const [isVisible, setIsVisible] = useState12(false);
3738
- useEffect10(() => {
3752
+ useEffect12(() => {
3739
3753
  const element = elementRef.current;
3740
3754
  if (!element) return;
3741
3755
  const observer = new IntersectionObserver(([entry]) => {
@@ -4095,6 +4109,8 @@ var TextInputRenderer = {
4095
4109
  label: title,
4096
4110
  description,
4097
4111
  validation: validationState,
4112
+ inlineAlert: props.inlineAlert,
4113
+ loadingState: props.fieldLoadingState,
4098
4114
  help,
4099
4115
  children: /* @__PURE__ */ jsx87(InputGroup4, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx87(VariableTextInput, __spreadValues({}, inputProps)) })
4100
4116
  }
@@ -4373,6 +4389,102 @@ var InitialLoadingStateRenderer = {
4373
4389
  )
4374
4390
  };
4375
4391
 
4392
+ // src/dynamicFlow/DynamicFlowModal.tsx
4393
+ import { useDynamicFlowModal } from "@wise/dynamic-flow-client";
4394
+ import { Modal as Modal5 } from "@transferwise/components";
4395
+ import { jsx as jsx92 } from "react/jsx-runtime";
4396
+ function DynamicFlowModal(props) {
4397
+ const _a = props, { className = "" } = _a, rest = __objRest(_a, ["className"]);
4398
+ const dfProps = useWiseToCoreProps(rest);
4399
+ const df = useDynamicFlowModal(dfProps);
4400
+ return /* @__PURE__ */ jsx92(
4401
+ Modal5,
4402
+ __spreadProps(__spreadValues({
4403
+ className: `dynamic-flow-modal ${className}`,
4404
+ disableDimmerClickToClose: true
4405
+ }, df.modal), {
4406
+ body: /* @__PURE__ */ jsx92("div", { className: "dynamic-flow-modal", children: df.modal.body })
4407
+ })
4408
+ );
4409
+ }
4410
+
4411
+ // src/dynamicFlow/getMergedRenderers.tsx
4412
+ import { jsx as jsx93 } from "react/jsx-runtime";
4413
+ var wiseRenderers = getWiseRenderers();
4414
+ var getMergedRenderers = (props) => {
4415
+ var _d, _e;
4416
+ const _a = props, { initialAction, initialStep } = _a, restProps = __objRest(_a, ["initialAction", "initialStep"]);
4417
+ const subflowFeatures = __spreadProps(__spreadValues({}, props.features), { nativeBack: true });
4418
+ const subflowRenderer = getDynamicSubflowRenderer({
4419
+ Component: (_b) => {
4420
+ var _c = _b, { presentation, initialRequest } = _c, rest = __objRest(_c, ["presentation", "initialRequest"]);
4421
+ const action = {
4422
+ url: initialRequest.url,
4423
+ method: initialRequest.method,
4424
+ data: initialRequest.body
4425
+ };
4426
+ return presentation.type === "push" ? /* @__PURE__ */ jsx93(DynamicFlow, __spreadProps(__spreadValues(__spreadValues({}, restProps), rest), { features: subflowFeatures, initialAction: action })) : /* @__PURE__ */ jsx93(
4427
+ DynamicFlowModal,
4428
+ __spreadProps(__spreadValues(__spreadValues({}, restProps), rest), {
4429
+ features: subflowFeatures,
4430
+ initialAction: action
4431
+ })
4432
+ );
4433
+ }
4434
+ });
4435
+ const loadingStateRenderer = ((_d = props.features) == null ? void 0 : _d.initialLoader) ? [InitialLoadingStateRenderer] : [];
4436
+ return [...(_e = props.renderers) != null ? _e : [], subflowRenderer, ...loadingStateRenderer, ...wiseRenderers];
4437
+ };
4438
+
4439
+ // src/dynamicFlow/telemetry/getLogEvent.ts
4440
+ var getLogEvent = (onLog) => (level, message, extra) => {
4441
+ const extraWithVersion = __spreadProps(__spreadValues({}, extra), {
4442
+ dfWiseVersion: appVersion
4443
+ });
4444
+ if (level !== "info" && onLog) {
4445
+ if (onLog) {
4446
+ onLog(level, message, extraWithVersion);
4447
+ } else {
4448
+ logToRollbar(level, message, extraWithVersion);
4449
+ }
4450
+ }
4451
+ };
4452
+ var logToRollbar = (level, message, extra) => {
4453
+ try {
4454
+ const rollbar = typeof window.Rollbar !== "undefined" ? window.Rollbar : void 0;
4455
+ rollbar == null ? void 0 : rollbar[level](message, extra);
4456
+ } catch (error) {
4457
+ console.error("Failed to log to Rollbar", error);
4458
+ }
4459
+ };
4460
+
4461
+ // src/dynamicFlow/telemetry/getTrackEvent.ts
4462
+ import { eventNames } from "@wise/dynamic-flow-client";
4463
+ var prefix = "Dynamic Flow - ";
4464
+ var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
4465
+ onEvent == null ? void 0 : onEvent(name, properties);
4466
+ if (includeInAnalytics(name)) {
4467
+ onAnalytics == null ? void 0 : onAnalytics(name, properties);
4468
+ }
4469
+ };
4470
+ var includeInAnalytics = (name) => {
4471
+ const eventName = name.startsWith(prefix) ? name.slice(prefix.length) : name;
4472
+ if (isCoreEventName(eventName)) {
4473
+ return true;
4474
+ }
4475
+ if (eventName in customEventsToAnalytics) {
4476
+ return customEventsToAnalytics[eventName];
4477
+ }
4478
+ return true;
4479
+ };
4480
+ var isCoreEventName = (eventName) => {
4481
+ return eventNames.includes(eventName);
4482
+ };
4483
+ var customEventsToAnalytics = {
4484
+ "Theme Required": false
4485
+ // Excluded from analytics
4486
+ };
4487
+
4376
4488
  // src/dynamicFlow/useOnCopy.tsx
4377
4489
  import { useCallback as useCallback2 } from "react";
4378
4490
  import { useIntl as useIntl16 } from "react-intl";
@@ -4434,54 +4546,10 @@ var handleRejection = (error) => {
4434
4546
  throw error;
4435
4547
  };
4436
4548
 
4437
- // src/dynamicFlow/getMergedRenderers.tsx
4438
- import { getDynamicSubflowRenderer } from "@wise/dynamic-flow-client";
4439
-
4440
- // src/dynamicFlow/DynamicFlowModal.tsx
4441
- import { useDynamicFlowModal } from "@wise/dynamic-flow-client";
4442
- import { Modal as Modal5 } from "@transferwise/components";
4443
- import { jsx as jsx92 } from "react/jsx-runtime";
4444
- function DynamicFlowModal(props) {
4445
- const _a = props, { className = "" } = _a, rest = __objRest(_a, ["className"]);
4446
- const dfProps = useWiseToCoreProps(rest);
4447
- const df = useDynamicFlowModal(dfProps);
4448
- return /* @__PURE__ */ jsx92(
4449
- Modal5,
4450
- __spreadProps(__spreadValues({
4451
- className: `dynamic-flow-modal ${className}`,
4452
- disableDimmerClickToClose: true
4453
- }, df.modal), {
4454
- body: /* @__PURE__ */ jsx92("div", { className: "dynamic-flow-modal", children: df.modal.body })
4455
- })
4456
- );
4457
- }
4458
-
4459
- // src/dynamicFlow/getMergedRenderers.tsx
4460
- import { jsx as jsx93 } from "react/jsx-runtime";
4461
- var wiseRenderers = getWiseRenderers();
4462
- var getMergedRenderers = (props) => {
4463
- var _d, _e;
4464
- const _a = props, { initialAction, initialStep } = _a, restProps = __objRest(_a, ["initialAction", "initialStep"]);
4465
- const subflowFeatures = __spreadProps(__spreadValues({}, props.features), { nativeBack: true });
4466
- const subflowRenderer = getDynamicSubflowRenderer({
4467
- Component: (_b) => {
4468
- var _c = _b, { presentation, initialRequest } = _c, rest = __objRest(_c, ["presentation", "initialRequest"]);
4469
- const action = {
4470
- url: initialRequest.url,
4471
- method: initialRequest.method,
4472
- data: initialRequest.body
4473
- };
4474
- return presentation.type === "push" ? /* @__PURE__ */ jsx93(DynamicFlow, __spreadProps(__spreadValues(__spreadValues({}, restProps), rest), { features: subflowFeatures, initialAction: action })) : /* @__PURE__ */ jsx93(
4475
- DynamicFlowModal,
4476
- __spreadProps(__spreadValues(__spreadValues({}, restProps), rest), {
4477
- features: subflowFeatures,
4478
- initialAction: action
4479
- })
4480
- );
4481
- }
4482
- });
4483
- const loadingStateRenderer = ((_d = props.features) == null ? void 0 : _d.initialLoader) ? [InitialLoadingStateRenderer] : [];
4484
- return [...(_e = props.renderers) != null ? _e : [], subflowRenderer, ...loadingStateRenderer, ...wiseRenderers];
4549
+ // src/dynamicFlow/useCreateSnackBar.tsx
4550
+ var useCreateSnackBar = () => {
4551
+ const createSnackBar = useSnackBarIfAvailable();
4552
+ return createSnackBar;
4485
4553
  };
4486
4554
 
4487
4555
  // src/dynamicFlow/useWiseToCoreProps.tsx
@@ -4494,10 +4562,12 @@ var useWiseToCoreProps = (props) => {
4494
4562
  onAnalytics,
4495
4563
  onEvent,
4496
4564
  onLink = openLinkInNewTab,
4565
+ onNotification,
4497
4566
  onLog
4498
4567
  } = props;
4499
4568
  const httpClient = useWiseHttpClient(customFetch);
4500
4569
  const mergedRenderers = useMemo2(() => getMergedRenderers(props), [renderers]);
4570
+ const createSnackBar = useCreateSnackBar();
4501
4571
  const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
4502
4572
  const trackEvent = useMemo2(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
4503
4573
  const onCopy = useOnCopy();
@@ -4508,6 +4578,7 @@ var useWiseToCoreProps = (props) => {
4508
4578
  onEvent: trackEvent,
4509
4579
  onLog: logEvent,
4510
4580
  onCopy,
4581
+ onNotification: onNotification != null ? onNotification : createSnackBar,
4511
4582
  onLink
4512
4583
  });
4513
4584
  };