@wise/dynamic-flow-client-internal 4.27.0-experimental-renderer-utils-876fd4f → 4.27.0-experimental-f4fee36

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
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
8
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -20,40 +22,3517 @@ var __spreadValues = (a, b) => {
20
22
  return a;
21
23
  };
22
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
23
37
  var __export = (target, all) => {
24
38
  for (var name in all)
25
39
  __defProp(target, name, { get: all[name], enumerable: true });
26
40
  };
27
- var __copyProps = (to, from, except, desc) => {
28
- if (from && typeof from === "object" || typeof from === "function") {
29
- for (let key of __getOwnPropNames(from))
30
- if (!__hasOwnProp.call(to, key) && key !== except)
31
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+
59
+ // src/index.ts
60
+ var index_exports = {};
61
+ __export(index_exports, {
62
+ DynamicFlowLegacy: () => DynamicFlowLegacy,
63
+ DynamicFlowRevamp: () => DynamicFlowRevamp,
64
+ DynamicForm: () => DynamicForm,
65
+ Header: () => Header11,
66
+ JsonSchemaForm: () => import_dynamic_flow_client4.JsonSchemaForm,
67
+ Media: () => Media2,
68
+ findRendererPropsByType: () => import_dynamic_flow_client4.findRendererPropsByType,
69
+ getButtonV2Renderers: () => getButtonV2Renderers2,
70
+ getListItemRenderers: () => getListItemRenderers2,
71
+ getMargin: () => getMargin2,
72
+ isValidSchema: () => import_dynamic_flow_client4.isValidSchema,
73
+ makeCustomFetch: () => import_dynamic_flow_client3.makeHttpClient,
74
+ translations: () => i18n_default
75
+ });
76
+ module.exports = __toCommonJS(index_exports);
77
+ var import_dynamic_flow_client3 = require("@wise/dynamic-flow-client");
78
+ var import_dynamic_flow_client4 = require("@wise/dynamic-flow-client");
79
+
80
+ // ../renderers/src/AlertRenderer.tsx
81
+ var import_components = require("@transferwise/components");
82
+
83
+ // ../renderers/src/utils/layout-utils.ts
84
+ var getMargin = (size) => {
85
+ switch (size) {
86
+ case "xs":
87
+ return "m-b-0";
88
+ case "sm":
89
+ return "m-b-1";
90
+ case "md":
91
+ return "m-b-2";
92
+ case "lg":
93
+ return "m-b-3";
94
+ case "xl":
95
+ return "m-b-5";
96
+ default:
97
+ return "";
98
+ }
99
+ };
100
+ var getTextAlignment = (align) => {
101
+ switch (align) {
102
+ case "end":
103
+ return "text-xs-right";
104
+ case "center":
105
+ return "text-xs-center";
106
+ case "start":
107
+ default:
108
+ return "";
109
+ }
110
+ };
111
+ var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${getMargin(component.margin)}`;
112
+
113
+ // ../renderers/src/AlertRenderer.tsx
114
+ var import_jsx_runtime = require("react/jsx-runtime");
115
+ var AlertRenderer = {
116
+ canRenderType: "alert",
117
+ render: ({ context, markdown, margin, callToAction }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
118
+ import_components.Alert,
119
+ {
120
+ type: context,
121
+ className: getMargin(margin),
122
+ message: markdown,
123
+ action: mapCtaToAlertAction(callToAction)
124
+ }
125
+ )
126
+ };
127
+ var mapCtaToAlertAction = (callToAction) => {
128
+ if (callToAction) {
129
+ return __spreadValues(__spreadValues({
130
+ text: callToAction.title,
131
+ "aria-label": callToAction.accessibilityDescription
132
+ }, "onClick" in callToAction ? { onClick: callToAction.onClick } : {}), callToAction.type === "link" ? { href: callToAction.href, target: "_blank" } : {});
133
+ }
134
+ return void 0;
135
+ };
136
+ var AlertRenderer_default = AlertRenderer;
137
+
138
+ // ../renderers/src/BoxRenderer.tsx
139
+ var import_classnames = __toESM(require("classnames"));
140
+ var import_jsx_runtime2 = require("react/jsx-runtime");
141
+ var BoxRenderer = {
142
+ canRenderType: "box",
143
+ render: ({ children, control, margin, width }) => {
144
+ const hasFixedWidth = width !== "xl";
145
+ const hasBorder = control === "bordered" || control === "bordered-web";
146
+ const contents = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
147
+ "div",
148
+ {
149
+ className: (0, import_classnames.default)({
150
+ "df-box-renderer-border": hasBorder,
151
+ [`df-box-renderer-width-${width}`]: hasFixedWidth,
152
+ [getMargin(margin)]: !hasFixedWidth
153
+ }),
154
+ children
155
+ }
156
+ );
157
+ return hasFixedWidth ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: (0, import_classnames.default)("df-box-renderer-fixed-width", getMargin(margin)), children: contents }) : contents;
158
+ }
159
+ };
160
+ var BoxRenderer_default = BoxRenderer;
161
+
162
+ // ../renderers/src/ButtonRenderer/AddressValidationButtonRenderer.tsx
163
+ var import_components2 = require("@transferwise/components");
164
+ var import_react_intl2 = require("react-intl");
165
+
166
+ // ../renderers/src/messages/loading-button.messages.ts
167
+ var import_react_intl = require("react-intl");
168
+ var loading_button_messages_default = (0, import_react_intl.defineMessages)({
169
+ buttonLoadingMessage: {
170
+ id: "df.wise.ButtonLayout.buttonLoadingMessage",
171
+ defaultMessage: "This might take a few seconds",
172
+ description: "Message displayed below a button when it is in a loading state."
173
+ }
174
+ });
175
+
176
+ // ../renderers/src/ButtonRenderer/AddressValidationButtonRenderer.tsx
177
+ var import_react = require("react");
178
+ var import_jsx_runtime3 = require("react/jsx-runtime");
179
+ var AddressValidationButtonRenderer = {
180
+ canRenderType: "button",
181
+ canRender: ({ control }) => control === "address-validation",
182
+ render: AddressValidationButtonComponent
183
+ };
184
+ function AddressValidationButtonComponent(props) {
185
+ const { disabled, margin, title, stepLoadingState, onClick } = props;
186
+ const { formatMessage } = (0, import_react_intl2.useIntl)();
187
+ const [spinny, setSpinny] = (0, import_react.useState)(false);
188
+ (0, import_react.useEffect)(() => {
189
+ if (stepLoadingState === "idle") {
190
+ setSpinny(false);
191
+ }
192
+ }, [stepLoadingState]);
193
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `d-flex flex-column ${getMargin(margin)}`, children: [
194
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
195
+ import_components2.Button,
196
+ {
197
+ v2: true,
198
+ block: true,
199
+ disabled,
200
+ priority: "primary",
201
+ size: "md",
202
+ loading: spinny,
203
+ onClick: () => {
204
+ setSpinny(true);
205
+ onClick();
206
+ },
207
+ children: title
208
+ }
209
+ ),
210
+ spinny && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_components2.InlineAlert, { type: "warning", className: "m-x-auto", children: formatMessage(loading_button_messages_default.buttonLoadingMessage) })
211
+ ] });
212
+ }
213
+ var AddressValidationButtonRenderer_default = AddressValidationButtonRenderer;
214
+
215
+ // ../renderers/src/ButtonRenderer/ButtonRenderer.tsx
216
+ var import_components3 = require("@transferwise/components");
217
+ var import_react2 = require("react");
218
+
219
+ // ../renderers/src/ButtonRenderer/mapButtonSize.tsx
220
+ var mapButtonSize = (size) => {
221
+ if (!size) {
222
+ return void 0;
223
+ }
224
+ switch (size) {
225
+ case "xs":
226
+ case "sm":
227
+ return "sm";
228
+ case "lg":
229
+ case "xl":
230
+ return "lg";
231
+ case "md":
232
+ default:
233
+ return "md";
234
+ }
235
+ };
236
+
237
+ // ../renderers/src/ButtonRenderer/ButtonRenderer.tsx
238
+ var import_jsx_runtime4 = require("react/jsx-runtime");
239
+ var ButtonRenderer = {
240
+ canRenderType: "button",
241
+ render: ButtonComponent
242
+ };
243
+ function ButtonComponent(props) {
244
+ const { control, context, disabled, margin, title, size, stepLoadingState, onClick } = props;
245
+ const [spinny, setSpinny] = (0, import_react2.useState)(false);
246
+ (0, import_react2.useEffect)(() => {
247
+ if (stepLoadingState === "idle") {
248
+ setSpinny(false);
249
+ }
250
+ }, [stepLoadingState]);
251
+ const priority = getPriority(control);
252
+ const type = getButtonType(context, priority);
253
+ const loading = spinny && stepLoadingState !== "idle";
254
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
255
+ import_components3.Button,
256
+ {
257
+ block: true,
258
+ className: getMargin(margin),
259
+ disabled,
260
+ priority,
261
+ size: mapButtonSize(size),
262
+ loading,
263
+ type,
264
+ onClick: () => {
265
+ setSpinny(true);
266
+ onClick();
267
+ },
268
+ children: title
269
+ }
270
+ );
271
+ }
272
+ var getPriority = (control) => {
273
+ switch (control) {
274
+ case "primary":
275
+ case "tertiary":
276
+ return control;
277
+ default:
278
+ return "secondary";
279
+ }
280
+ };
281
+ var getButtonType = (context, priority) => {
282
+ if (priority === "tertiary") {
283
+ return void 0;
284
+ }
285
+ switch (context) {
286
+ case "neutral":
287
+ case "warning":
288
+ return "accent";
289
+ default:
290
+ return context;
291
+ }
292
+ };
293
+
294
+ // ../renderers/src/components/FieldInput.tsx
295
+ var import_components5 = require("@transferwise/components");
296
+
297
+ // ../renderers/src/components/Help.tsx
298
+ var import_components4 = require("@transferwise/components");
299
+ var import_react_intl4 = require("react-intl");
300
+
301
+ // ../renderers/src/messages/help.messages.ts
302
+ var import_react_intl3 = require("react-intl");
303
+ var help_messages_default = (0, import_react_intl3.defineMessages)({
304
+ helpAria: {
305
+ id: "df.wise.Help.ariaLabel",
306
+ defaultMessage: "Click here for more info.",
307
+ description: "Aria label for help."
308
+ }
309
+ });
310
+
311
+ // ../renderers/src/components/Help.tsx
312
+ var import_jsx_runtime5 = require("react/jsx-runtime");
313
+ function Help({ help, onClick }) {
314
+ const intl = (0, import_react_intl4.useIntl)();
315
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
316
+ import_components4.Info,
317
+ {
318
+ content: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_components4.Markdown, { config: { link: { target: "_blank" } }, children: help }),
319
+ presentation: "POPOVER",
320
+ size: "sm",
321
+ "aria-label": intl.formatMessage(help_messages_default.helpAria),
322
+ onClick
323
+ }
324
+ );
325
+ }
326
+ var Help_default = Help;
327
+
328
+ // ../renderers/src/components/LabelContentWithHelp.tsx
329
+ var import_jsx_runtime6 = require("react/jsx-runtime");
330
+ function LabelContentWithHelp({ text, help }) {
331
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
332
+ text,
333
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Help_default, { help })
334
+ ] });
335
+ }
336
+
337
+ // ../renderers/src/components/FieldInput.tsx
338
+ var import_jsx_runtime7 = require("react/jsx-runtime");
339
+ function FieldInput({ id, children, label, validation, description, help }) {
340
+ const labelContent = label && help ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LabelContentWithHelp, { text: label, help }) : label;
341
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
342
+ import_components5.Field,
343
+ {
344
+ id,
345
+ label: labelContent,
346
+ description,
347
+ message: validation == null ? void 0 : validation.message,
348
+ sentiment: mapStatusToSentiment(validation),
349
+ children
350
+ }
351
+ );
352
+ }
353
+ var mapStatusToSentiment = (validation) => {
354
+ if (validation) {
355
+ if (validation.status === "valid") {
356
+ return "positive";
357
+ }
358
+ return "negative";
359
+ }
360
+ return void 0;
361
+ };
362
+ var FieldInput_default = FieldInput;
363
+
364
+ // ../renderers/src/CheckboxInputRenderer.tsx
365
+ var import_components9 = require("@transferwise/components");
366
+
367
+ // ../renderers/src/utils/UrnFlag.tsx
368
+ var import_art = require("@wise/art");
369
+ var import_jsx_runtime8 = require("react/jsx-runtime");
370
+ var countryUrnPrefix = "urn:wise:countries:";
371
+ var currencyUrnPrefix = "urn:wise:currencies:";
372
+ var isUrnFlag = (uri) => uri.startsWith(countryUrnPrefix) || uri.startsWith(currencyUrnPrefix);
373
+ function UrnFlag({ size, urn }) {
374
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_art.Flag, { code: getCode(urn), intrinsicSize: size });
375
+ }
376
+ var getCode = (urn) => {
377
+ return urn.replace(countryUrnPrefix, "").replace(currencyUrnPrefix, "").replace(":image", "").split("?")[0];
378
+ };
379
+
380
+ // ../renderers/src/components/icon/FlagIcon.tsx
381
+ var import_art2 = require("@wise/art");
382
+ var import_jsx_runtime9 = require("react/jsx-runtime");
383
+ var isFlagIcon = (name) => name.startsWith("flag-");
384
+ function FlagIcon({ name }) {
385
+ if (!isFlagIcon(name)) {
386
+ return null;
387
+ }
388
+ const code = name.substring(5);
389
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_art2.Flag, { code, intrinsicSize: 24 });
390
+ }
391
+
392
+ // ../renderers/src/components/icon/NamedIcon.tsx
393
+ var icons = __toESM(require("@transferwise/icons"));
394
+ var import_jsx_runtime10 = require("react/jsx-runtime");
395
+ var isNamedIcon = (name) => {
396
+ const iconName = toCapitalisedCamelCase(name);
397
+ return Object.keys(icons).includes(iconName);
398
+ };
399
+ function NamedIcon({ name }) {
400
+ if (!isNamedIcon(name)) {
401
+ return null;
402
+ }
403
+ const iconName = toCapitalisedCamelCase(name);
404
+ const Icon = icons[iconName];
405
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { size: 24 });
406
+ }
407
+ var toCapitalisedCamelCase = (value) => value.split("-").map(capitaliseFirstChar).join("");
408
+ var capitaliseFirstChar = (value) => `${value[0].toUpperCase()}${value.slice(1)}`;
409
+
410
+ // ../renderers/src/components/icon/DynamicIcon.tsx
411
+ var import_jsx_runtime11 = require("react/jsx-runtime");
412
+ function DynamicIcon({ name }) {
413
+ if (isFlagIcon(name)) {
414
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FlagIcon, { name });
415
+ }
416
+ if (isNamedIcon(name)) {
417
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NamedIcon, { name });
418
+ }
419
+ return null;
420
+ }
421
+ function isValidIconName(name) {
422
+ return isNamedIcon(name) || isFlagIcon(name);
423
+ }
424
+ function isValidIconUrn(uri) {
425
+ if (!uri.startsWith("urn:wise:icons:")) {
426
+ return false;
427
+ }
428
+ const name = uri.replace("urn:wise:icons:", "").split("?")[0];
429
+ return isValidIconName(name);
430
+ }
431
+ var DynamicIcon_default = DynamicIcon;
432
+
433
+ // ../renderers/src/components/Media/stringToURN.ts
434
+ var stringToURN = (uri) => {
435
+ var _a, _b, _c;
436
+ const [nameWithRQComponents, _] = uri.split("#");
437
+ const [nameWithRComponent, qComponent] = nameWithRQComponents.split("?=");
438
+ const [name, rComponent] = (_a = nameWithRComponent == null ? void 0 : nameWithRComponent.split("?+")) != null ? _a : ["", ""];
439
+ const rComponents = rComponent ? (_b = decodeURIComponent(rComponent)) == null ? void 0 : _b.split("&").map((c) => c.split("=")).map(([a, b]) => [a, b]) : void 0;
440
+ const qComponents = qComponent ? (_c = decodeURIComponent(qComponent)) == null ? void 0 : _c.split("&").map((c) => c.split("=")).map(([a, b]) => [a, b]) : void 0;
441
+ return {
442
+ name,
443
+ rComponents,
444
+ qComponents
445
+ };
446
+ };
447
+
448
+ // ../renderers/src/components/Media/resolveMediaFromUri.tsx
449
+ var import_jsx_runtime12 = require("react/jsx-runtime");
450
+ var resolveMediaFromUri = (uri, size) => {
451
+ var _a, _b;
452
+ const { name, qComponents = [] } = stringToURN(uri);
453
+ if (isValidIconUrn(name)) {
454
+ const icon = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DynamicIcon_default, { name: name.replace("urn:wise:icons:", "") });
455
+ return {
456
+ icon,
457
+ backgroundColor: formatColor((_a = qComponents.find(([key]) => key === "background-color")) == null ? void 0 : _a[1])
458
+ };
459
+ }
460
+ if (isUrnFlag(name)) {
461
+ return {
462
+ asset: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(UrnFlag, { urn: name, size })
463
+ };
464
+ }
465
+ if (name.startsWith("data:text/plain,")) {
466
+ const text = decodeURI(name.replace("data:text/plain,", ""));
467
+ return {
468
+ asset: text,
469
+ backgroundColor: formatColor((_b = qComponents.find(([key]) => key === "background-color")) == null ? void 0 : _b[1])
470
+ };
471
+ }
472
+ if (!uri.startsWith("urn:")) {
473
+ return { asset: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: uri, alt: "", width: `${size}px` }) };
474
+ }
475
+ return { asset: void 0 };
476
+ };
477
+ var formatColor = (color) => {
478
+ if (!color) {
479
+ return void 0;
480
+ }
481
+ if (color.startsWith("#")) {
482
+ return color;
483
+ }
484
+ return `var(--color-${color.replace(/^base-|brand-/, "")})`;
485
+ };
486
+
487
+ // ../renderers/src/components/Media/AvatarMedia.tsx
488
+ var import_components6 = require("@transferwise/components");
489
+ var import_jsx_runtime13 = require("react/jsx-runtime");
490
+ var AvatarMedia = ({
491
+ accessibilityDescription,
492
+ content,
493
+ size
494
+ }) => {
495
+ const getRenderableAvatar = (avatar) => {
496
+ if (avatar.type === "text") {
497
+ return { asset: avatar.text };
498
+ }
499
+ return __spreadProps(__spreadValues({}, resolveMediaFromUri(avatar.uri, size)), {
500
+ badge: avatar.badgeUri ? resolveMediaFromUri(avatar.badgeUri, 16) : void 0
501
+ });
502
+ };
503
+ const avatars = content.map(getRenderableAvatar);
504
+ if (avatars.length === 1) {
505
+ const { badge, backgroundColor, asset, icon } = avatars[0];
506
+ if (!asset && !icon) {
507
+ return null;
508
+ }
509
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
510
+ import_components6.AvatarView,
511
+ {
512
+ "aria-label": accessibilityDescription,
513
+ size,
514
+ badge: badge ? __spreadProps(__spreadValues({}, badge), {
515
+ type: "reference"
516
+ }) : void 0,
517
+ style: { backgroundColor },
518
+ children: icon != null ? icon : asset
519
+ }
520
+ );
521
+ }
522
+ const avatarsWithoutBadges = avatars.filter(({ asset }) => asset).slice(0, 2).map((_a) => {
523
+ var _b = _a, { badge } = _b, rest = __objRest(_b, ["badge"]);
524
+ return __spreadValues({}, rest);
525
+ });
526
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
527
+ import_components6.AvatarLayout,
528
+ {
529
+ "aria-label": accessibilityDescription,
530
+ size,
531
+ orientation: "diagonal",
532
+ avatars: avatarsWithoutBadges
533
+ }
534
+ );
535
+ };
536
+
537
+ // ../renderers/src/utils/image-utils.tsx
538
+ var import_components7 = require("@transferwise/components");
539
+ var import_jsx_runtime14 = require("react/jsx-runtime");
540
+ var getBadgedMedia = (iconNode, imageNode, size) => {
541
+ if (iconNode && imageNode) {
542
+ if (imageNode && iconNode) {
543
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_components7.AvatarView, { size, badge: { asset: iconNode, type: "reference" }, children: imageNode });
544
+ }
545
+ }
546
+ return null;
547
+ };
548
+ var getIconNode = (icon) => {
549
+ if (icon) {
550
+ if ("name" in icon) {
551
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DynamicIcon_default, { name: icon.name });
552
+ }
553
+ if (icon.text) {
554
+ return icon.text;
555
+ }
556
+ }
557
+ return null;
558
+ };
559
+ var getImageNode = (image, size) => {
560
+ if (image) {
561
+ const { accessibilityDescription, uri } = image;
562
+ if (!uri.startsWith("urn:")) {
563
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: uri, alt: accessibilityDescription, width: `${size}px` });
564
+ }
565
+ if (isUrnFlag(uri)) {
566
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(UrnFlag, { urn: uri, accessibilityDescription, size });
567
+ }
568
+ }
569
+ return null;
570
+ };
571
+
572
+ // ../renderers/src/components/Media/LegacyMedia.tsx
573
+ var import_components8 = require("@transferwise/components");
574
+ var import_jsx_runtime15 = require("react/jsx-runtime");
575
+ var LegacyMedia = ({ image, icon, preferAvatar, size }) => {
576
+ const imageNode = getImageNode(image, size);
577
+ const iconNode = getIconNode(icon);
578
+ const badge = getBadgedMedia(iconNode, imageNode, size);
579
+ if (badge) {
580
+ return badge;
581
+ }
582
+ if (imageNode) {
583
+ return preferAvatar ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_components8.AvatarView, { children: imageNode }) : imageNode;
584
+ }
585
+ if (iconNode && icon) {
586
+ if ("text" in icon || size === 48) {
587
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_components8.AvatarView, { size, children: iconNode });
588
+ }
589
+ return iconNode;
590
+ }
591
+ return null;
592
+ };
593
+
594
+ // ../renderers/src/components/Media/Media.tsx
595
+ var import_jsx_runtime16 = require("react/jsx-runtime");
596
+ var Media = ({ media, preferAvatar, size }) => {
597
+ switch (media == null ? void 0 : media.type) {
598
+ case "avatar":
599
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AvatarMedia, __spreadProps(__spreadValues({}, media), { size }));
600
+ case "image": {
601
+ const { asset, icon } = resolveMediaFromUri(media.uri, size);
602
+ return icon != null ? icon : asset;
603
+ }
604
+ case "legacy": {
605
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LegacyMedia, __spreadProps(__spreadValues({}, media), { preferAvatar, size }));
606
+ }
607
+ default:
608
+ return null;
609
+ }
610
+ };
611
+
612
+ // ../renderers/src/components/Media/OptionMedia.tsx
613
+ var import_jsx_runtime17 = require("react/jsx-runtime");
614
+ var mediaSize = 48;
615
+ function OptionMedia(props) {
616
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Media, __spreadProps(__spreadValues({}, props), { size: mediaSize }));
617
+ }
618
+
619
+ // ../renderers/src/components/Media/getInlineMedia.tsx
620
+ var import_jsx_runtime18 = require("react/jsx-runtime");
621
+ var getInlineMedia = (media) => media ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Media, { media, preferAvatar: false, size: 24 }) : null;
622
+
623
+ // ../renderers/src/NewListItem/getMedia.tsx
624
+ var import_jsx_runtime19 = require("react/jsx-runtime");
625
+ var getMedia = (media, preferAvatar) => media ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionMedia, { media, preferAvatar }) : void 0;
626
+
627
+ // ../renderers/src/CheckboxInputRenderer.tsx
628
+ var import_jsx_runtime20 = require("react/jsx-runtime");
629
+ var CheckboxInputRenderer = {
630
+ canRenderType: "input-checkbox",
631
+ render: (props) => props.control === "switch-item" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SwitchComponent, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CheckboxComponent, __spreadValues({}, props))
632
+ };
633
+ var CheckboxComponent = (props) => {
634
+ const _a = props, {
635
+ id,
636
+ control,
637
+ title = "",
638
+ description,
639
+ help,
640
+ type,
641
+ validationState,
642
+ value
643
+ } = _a, rest = __objRest(_a, [
644
+ "id",
645
+ "control",
646
+ "title",
647
+ "description",
648
+ "help",
649
+ "type",
650
+ "validationState",
651
+ "value"
652
+ ]);
653
+ const checkboxProps = __spreadProps(__spreadValues({}, rest), { label: title, secondary: description, checked: value });
654
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(FieldInput_default, { id, label: "", description: "", validation: validationState, help, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components9.Checkbox, __spreadValues({ id }, checkboxProps)) });
655
+ };
656
+ var SwitchComponent = (props) => {
657
+ const { title, description, disabled, media, validationState, value, onChange } = props;
658
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
659
+ import_components9.ListItem,
660
+ {
661
+ title,
662
+ subtitle: description,
663
+ media: getMedia(media, false),
664
+ disabled,
665
+ prompt: validationState && validationState.status === "invalid" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components9.ListItem.Prompt, { sentiment: "negative", children: validationState.message }) : void 0,
666
+ control: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components9.ListItem.Switch, { checked: value, onClick: () => onChange(!value) })
667
+ }
668
+ );
669
+ };
670
+ var CheckboxInputRenderer_default = CheckboxInputRenderer;
671
+
672
+ // ../renderers/src/ColumnsRenderer.tsx
673
+ var import_classnames2 = __toESM(require("classnames"));
674
+ var import_jsx_runtime21 = require("react/jsx-runtime");
675
+ var ColumnsRenderer = {
676
+ canRenderType: "columns",
677
+ render: ({ bias, margin, startChildren, endChildren }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
678
+ "div",
679
+ {
680
+ className: (0, import_classnames2.default)("df-columns-renderer-container", getMargin(margin), {
681
+ "df-columns-renderer-bias-start": bias === "start",
682
+ "df-columns-renderer-bias-end": bias === "end"
683
+ }),
684
+ children: [
685
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "df-columns-renderer-column", children: startChildren }),
686
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "df-columns-renderer-column", children: endChildren })
687
+ ]
688
+ }
689
+ )
690
+ };
691
+ var ColumnsRenderer_default = ColumnsRenderer;
692
+
693
+ // ../renderers/src/components/VariableDateInput.tsx
694
+ var import_components10 = require("@transferwise/components");
695
+
696
+ // ../renderers/src/validators/type-validators.ts
697
+ var isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
698
+
699
+ // ../renderers/src/utils/value-utils.ts
700
+ var dateStringToDateOrNull = (dateString) => {
701
+ if (!dateString) {
702
+ return null;
703
+ }
704
+ const [year, month, date] = dateString.split("-").map((number) => Number.parseInt(number, 10));
705
+ if (!isNumber(year) || !isNumber(month) || !isNumber(date)) {
706
+ return null;
707
+ }
708
+ return new Date(year, month - 1, date);
709
+ };
710
+ var dateToDateString = (date) => {
711
+ const d = new Date(date);
712
+ const month = String(d.getMonth() + 1);
713
+ const day = String(d.getDate());
714
+ const year = d.getFullYear();
715
+ const formattedMonth = month.length < 2 ? `0${month}` : month;
716
+ const formattedDay = day.length < 2 ? `0${day}` : day;
717
+ return [year, formattedMonth, formattedDay].join("-");
718
+ };
719
+
720
+ // ../renderers/src/components/VariableDateInput.tsx
721
+ var import_jsx_runtime22 = require("react/jsx-runtime");
722
+ function VariableDateInput({
723
+ control,
724
+ inputProps
725
+ }) {
726
+ const {
727
+ autoComplete,
728
+ minimumDate,
729
+ maximumDate,
730
+ placeholder,
731
+ disabled,
732
+ onBlur,
733
+ onChange,
734
+ onFocus
735
+ } = inputProps;
736
+ if (control === "date-lookup") {
737
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
738
+ import_components10.DateLookup,
739
+ {
740
+ value: dateStringToDateOrNull(inputProps.value),
741
+ min: dateStringToDateOrNull(minimumDate),
742
+ max: dateStringToDateOrNull(maximumDate),
743
+ placeholder,
744
+ disabled,
745
+ onChange: (date) => {
746
+ onChange(date !== null ? dateToDateString(date) : null);
747
+ },
748
+ onBlur,
749
+ onFocus
750
+ }
751
+ );
752
+ }
753
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
754
+ import_components10.DateInput,
755
+ __spreadProps(__spreadValues({}, inputProps), {
756
+ dayAutoComplete: getAutocompleteString(autoComplete, "day"),
757
+ yearAutoComplete: getAutocompleteString(autoComplete, "year")
758
+ })
759
+ );
760
+ }
761
+ var getAutocompleteString = (value, suffix) => {
762
+ if (value === "bday") {
763
+ return `${value}-${suffix}`;
764
+ }
765
+ return void 0;
766
+ };
767
+ var VariableDateInput_default = VariableDateInput;
768
+
769
+ // ../renderers/src/DateInputRenderer.tsx
770
+ var import_jsx_runtime23 = require("react/jsx-runtime");
771
+ var DateInputRenderer = {
772
+ canRenderType: "input-date",
773
+ render: (props) => {
774
+ const _a = props, {
775
+ id,
776
+ control,
777
+ description,
778
+ type,
779
+ help,
780
+ title,
781
+ validationState,
782
+ value: initialValue
783
+ } = _a, rest = __objRest(_a, [
784
+ "id",
785
+ "control",
786
+ "description",
787
+ "type",
788
+ "help",
789
+ "title",
790
+ "validationState",
791
+ "value"
792
+ ]);
793
+ const value = initialValue != null ? initialValue : "";
794
+ const inputProps = __spreadProps(__spreadValues({}, rest), { value, id });
795
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
796
+ FieldInput_default,
797
+ {
798
+ id,
799
+ label: title,
800
+ description,
801
+ validation: validationState,
802
+ help,
803
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(VariableDateInput_default, { control, inputProps })
804
+ }
805
+ );
806
+ }
807
+ };
808
+ var DateInputRenderer_default = DateInputRenderer;
809
+
810
+ // ../renderers/src/DecisionRenderer/DecisionRenderer.tsx
811
+ var import_components13 = require("@transferwise/components");
812
+
813
+ // ../renderers/src/DecisionRenderer/DecisionList.tsx
814
+ var import_components12 = require("@transferwise/components");
815
+
816
+ // ../renderers/src/DecisionRenderer/GroupedList.tsx
817
+ var import_components11 = require("@transferwise/components");
818
+ var import_react_intl6 = require("react-intl");
819
+
820
+ // ../renderers/src/messages/decision.messages.ts
821
+ var import_react_intl5 = require("react-intl");
822
+ var decision_messages_default = (0, import_react_intl5.defineMessages)({
823
+ all: {
824
+ id: "df.wise.Decision.all",
825
+ defaultMessage: "All",
826
+ description: "Label for the group of options that encompasses all options"
827
+ },
828
+ popular: {
829
+ id: "df.wise.Decision.popular",
830
+ defaultMessage: "Popular",
831
+ description: "Label for the group of options that are tagged as popular"
832
+ },
833
+ recent: {
834
+ id: "df.wise.Decision.recent",
835
+ defaultMessage: "Recent",
836
+ description: "Label for the group of options that are tagged as recent"
837
+ },
838
+ currenciesWithAccountDetails: {
839
+ id: "df.wise.Decision.currenciesWithAccountDetails",
840
+ defaultMessage: "Currencies with account details",
841
+ description: "Label for the group of options that are tagged as currencies with account details"
842
+ },
843
+ filterPlaceholder: {
844
+ id: "df.wise.Decision.filterPlaceholder",
845
+ defaultMessage: "Start typing to search",
846
+ description: "Placeholder for the filter input"
847
+ },
848
+ results: {
849
+ id: "df.wise.Decision.results",
850
+ defaultMessage: "Search results",
851
+ description: "Label for the results section"
852
+ },
853
+ noResults: {
854
+ id: "df.wise.Decision.noResults",
855
+ defaultMessage: "No results",
856
+ description: "Message for if there are no results"
857
+ }
858
+ });
859
+
860
+ // ../renderers/src/DecisionRenderer/GroupedList.tsx
861
+ var import_jsx_runtime24 = require("react/jsx-runtime");
862
+ var OPTION_GROUPS = {
863
+ popular: "popular",
864
+ recent: "recent",
865
+ currencyWithAccountDetails: "currencies-with-account-details"
866
+ };
867
+ var GroupedList = (_a) => {
868
+ var _b = _a, { renderDecisionList: renderDecisionList3 } = _b, rest = __objRest(_b, ["renderDecisionList"]);
869
+ const { formatMessage } = (0, import_react_intl6.useIntl)();
870
+ const { options } = rest;
871
+ const popularOptions = options.filter((option) => option.tag === OPTION_GROUPS.popular);
872
+ const recentOptions = options.filter((option) => option.tag === OPTION_GROUPS.recent);
873
+ const currencyWithAccountDetailsOptions = options.filter(
874
+ (option) => option.tag === OPTION_GROUPS.currencyWithAccountDetails
875
+ );
876
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
877
+ popularOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
878
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.popular) }),
879
+ renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: popularOptions }))
880
+ ] }) : null,
881
+ recentOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
882
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.recent) }),
883
+ renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: recentOptions }))
884
+ ] }) : null,
885
+ currencyWithAccountDetailsOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
886
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.currenciesWithAccountDetails) }),
887
+ renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: currencyWithAccountDetailsOptions }))
888
+ ] }) : null,
889
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
890
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.all) }),
891
+ renderDecisionList3(rest)
892
+ ] })
893
+ ] });
894
+ };
895
+ var isGroupedDecision = (options) => {
896
+ const possibleGroups = Object.values(OPTION_GROUPS);
897
+ return options.some(({ tag }) => tag && possibleGroups.includes(tag));
898
+ };
899
+
900
+ // ../renderers/src/DecisionRenderer/DecisionList.tsx
901
+ var import_react_intl7 = require("react-intl");
902
+ var import_react3 = require("react");
903
+
904
+ // ../renderers/src/DecisionRenderer/filter-and-sort-decision-options.ts
905
+ function filterAndSortDecisionOptions(selectOptions, query) {
906
+ const upperQuery = query.toUpperCase().trim();
907
+ const filteredItems = selectOptions.filter((option) => {
908
+ var _a, _b, _c, _d;
909
+ const searchableWords = [
910
+ option.title,
911
+ option.description,
912
+ option.additionalText,
913
+ (_a = option.supportingValues) == null ? void 0 : _a.value,
914
+ (_b = option.supportingValues) == null ? void 0 : _b.subvalue,
915
+ ...(_c = option.keywords) != null ? _c : []
916
+ ];
917
+ return (_d = searchableWords.some((word) => word == null ? void 0 : word.toUpperCase().includes(upperQuery))) != null ? _d : false;
918
+ });
919
+ return [...filteredItems].sort((a, b) => {
920
+ const aTitleUpper = a.title.toUpperCase();
921
+ const bTitleUpper = b.title.toUpperCase();
922
+ const aTitleStarts = aTitleUpper.startsWith(upperQuery);
923
+ const bTitleStarts = bTitleUpper.startsWith(upperQuery);
924
+ if (aTitleStarts && !bTitleStarts) {
925
+ return -1;
926
+ }
927
+ if (!aTitleStarts && bTitleStarts) {
928
+ return 1;
929
+ }
930
+ const aWordStarts = aTitleUpper.split(" ").some((word) => word.startsWith(upperQuery));
931
+ const bWordStarts = bTitleUpper.split(" ").some((word) => word.startsWith(upperQuery));
932
+ if (aWordStarts && !bWordStarts) {
933
+ return -1;
934
+ }
935
+ if (!aWordStarts && bWordStarts) {
936
+ return 1;
937
+ }
938
+ return a.title.localeCompare(b.title);
939
+ });
940
+ }
941
+
942
+ // ../renderers/src/DecisionRenderer/DecisionList.tsx
943
+ var import_jsx_runtime25 = require("react/jsx-runtime");
944
+ var DecisionWrapper = (props) => {
945
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getMargin(props.margin), children: [
946
+ props.title && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components12.Header, { as: "h2", title: props.title }),
947
+ props.control === "filtered" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FilteredDecisionList, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UnfilteredDecisionList, __spreadValues({}, props))
948
+ ] });
949
+ };
950
+ var UnfilteredDecisionList = (_a) => {
951
+ var _b = _a, { renderDecisionList: renderDecisionList3 } = _b, rest = __objRest(_b, ["renderDecisionList"]);
952
+ return isGroupedDecision(rest.options) ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(GroupedList, __spreadProps(__spreadValues({}, rest), { renderDecisionList: renderDecisionList3 })) : renderDecisionList3(rest);
953
+ };
954
+ var FilteredDecisionList = (props) => {
955
+ const { formatMessage } = (0, import_react_intl7.useIntl)();
956
+ const [query, setQuery] = (0, import_react3.useState)("");
957
+ const { control, options, renderDecisionList: renderDecisionList3 } = props;
958
+ const filteredOptions = filterAndSortDecisionOptions(options, query);
959
+ const isGrouped = isGroupedDecision(options);
960
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
961
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
962
+ import_components12.SearchInput,
963
+ {
964
+ placeholder: formatMessage(decision_messages_default.filterPlaceholder),
965
+ value: query,
966
+ onChange: (e) => {
967
+ var _a;
968
+ return setQuery((_a = e.target.value) != null ? _a : "");
969
+ }
970
+ }
971
+ ),
972
+ isGrouped && query.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(GroupedList, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
973
+ query.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components12.Header, { as: "h2", title: formatMessage(decision_messages_default.results), className: "m-t-4" }),
974
+ filteredOptions.length > 0 ? renderDecisionList3({
975
+ control,
976
+ className: query.length === 0 ? "m-t-3" : "",
977
+ options: filteredOptions
978
+ }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { children: formatMessage(decision_messages_default.noResults) })
979
+ ] })
980
+ ] });
981
+ };
982
+
983
+ // ../renderers/src/DecisionRenderer/DecisionRenderer.tsx
984
+ var import_jsx_runtime26 = require("react/jsx-runtime");
985
+ var DecisionRenderer = {
986
+ canRenderType: "decision",
987
+ render: (props) => {
988
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DecisionWrapper, __spreadProps(__spreadValues({}, props), { renderDecisionList }));
989
+ }
990
+ };
991
+ var renderDecisionList = ({ options, className, control }) => {
992
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components13.NavigationOptionsList, { children: options.map((option) => {
993
+ const { description, disabled, media, title: itemTitle, tag, onClick } = option;
994
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
995
+ import_components13.NavigationOption,
996
+ {
997
+ title: itemTitle,
998
+ content: description,
999
+ disabled,
1000
+ media: media ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1001
+ OptionMedia,
1002
+ {
1003
+ media,
1004
+ preferAvatar: control === "with-avatar" || tag === "with-avatar"
1005
+ }
1006
+ ) : null,
1007
+ showMediaCircle: false,
1008
+ showMediaAtAllSizes: true,
1009
+ onClick
1010
+ },
1011
+ JSON.stringify(option)
1012
+ );
1013
+ }) }) });
1014
+ };
1015
+ var DecisionRenderer_default = DecisionRenderer;
1016
+
1017
+ // ../renderers/src/DividerRenderer.tsx
1018
+ var import_components14 = require("@transferwise/components");
1019
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1020
+ var mapControlToLevel = (control) => {
1021
+ switch (control) {
1022
+ case "section":
1023
+ return "section";
1024
+ case "content":
1025
+ return "content";
1026
+ default:
1027
+ return "subsection";
1028
+ }
1029
+ };
1030
+ var DividerRenderer = {
1031
+ canRenderType: "divider",
1032
+ render: ({ margin, control }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components14.Divider, { className: `m-t-0 d-block ${getMargin(margin)}`, level: mapControlToLevel(control) })
1033
+ };
1034
+ var DividerRenderer_default = DividerRenderer;
1035
+
1036
+ // ../renderers/src/ExternalConfirmationRenderer.tsx
1037
+ var import_components15 = require("@transferwise/components");
1038
+
1039
+ // ../renderers/src/messages/external-confirmation.messages.ts
1040
+ var import_react_intl8 = require("react-intl");
1041
+ var external_confirmation_messages_default = (0, import_react_intl8.defineMessages)({
1042
+ title: {
1043
+ id: "df.wise.ExternalConfirmation.title",
1044
+ defaultMessage: "Please confirm",
1045
+ description: "Heading for the confirmation screen."
1046
+ },
1047
+ description: {
1048
+ id: "df.wise.ExternalConfirmation.description",
1049
+ defaultMessage: "Please confirm you want to open **{origin}** in a new browser tab.",
1050
+ description: "Description for the confirmation screen."
1051
+ },
1052
+ open: {
1053
+ id: "df.wise.ExternalConfirmation.open",
1054
+ defaultMessage: "Open in new tab",
1055
+ description: "Button text confirming opening a new browser tab."
1056
+ },
1057
+ cancel: {
1058
+ id: "df.wise.ExternalConfirmation.cancel",
1059
+ defaultMessage: "Cancel",
1060
+ description: "Button text rejecting opening a new browser tab."
1061
+ }
1062
+ });
1063
+
1064
+ // ../renderers/src/ExternalConfirmationRenderer.tsx
1065
+ var import_react_intl9 = require("react-intl");
1066
+ var import_react4 = require("react");
1067
+ var import_jsx_runtime28 = require("react/jsx-runtime");
1068
+ var ExternalConfirmationRenderer = {
1069
+ canRenderType: "external-confirmation",
1070
+ render: ExternalConfirmationRendererComponent
1071
+ };
1072
+ function ExternalConfirmationRendererComponent({
1073
+ url,
1074
+ status,
1075
+ onSuccess,
1076
+ onFailure,
1077
+ onCancel
1078
+ }) {
1079
+ const { formatMessage } = (0, import_react_intl9.useIntl)();
1080
+ (0, import_react4.useEffect)(() => {
1081
+ if (url) {
1082
+ const w = window.open(url, "_blank");
1083
+ if (w) {
1084
+ onSuccess();
1085
+ } else {
1086
+ onFailure();
1087
+ }
1088
+ }
1089
+ }, []);
1090
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1091
+ import_components15.Modal,
1092
+ {
1093
+ open: status === "failure",
1094
+ title: formatMessage(external_confirmation_messages_default.title),
1095
+ body: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
1096
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_components15.Markdown, { config: { link: { target: "_blank" } }, className: "text-xs-center m-b-5", children: formatMessage(external_confirmation_messages_default.description, { origin: getOrigin(url) }) }),
1097
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "df-box-renderer-fixed-width", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "df-box-renderer-width-lg", children: [
1098
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1099
+ import_components15.Button,
1100
+ {
1101
+ v2: true,
1102
+ block: true,
1103
+ className: "m-b-2",
1104
+ priority: "primary",
1105
+ size: "md",
1106
+ onClick: () => {
1107
+ window.open(url);
1108
+ onCancel();
1109
+ },
1110
+ children: formatMessage(external_confirmation_messages_default.open)
1111
+ }
1112
+ ),
1113
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_components15.Button, { v2: true, block: true, className: "m-b-2", priority: "tertiary", size: "md", onClick: onCancel, children: formatMessage(external_confirmation_messages_default.cancel) })
1114
+ ] }) })
1115
+ ] }),
1116
+ onClose: onCancel
1117
+ }
1118
+ );
1119
+ }
1120
+ function getOrigin(url) {
1121
+ try {
1122
+ return new URL(url).origin;
1123
+ } catch (e) {
1124
+ return url;
1125
+ }
1126
+ }
1127
+ var ExternalConfirmationRenderer_default = ExternalConfirmationRenderer;
1128
+
1129
+ // ../renderers/src/FormRenderer.tsx
1130
+ var import_jsx_runtime29 = require("react/jsx-runtime");
1131
+ var FormRenderer = {
1132
+ canRenderType: "form",
1133
+ render: ({ children, margin }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getMargin(margin), children })
1134
+ };
1135
+ var FormRenderer_default = FormRenderer;
1136
+
1137
+ // ../renderers/src/FormSectionRenderer.tsx
1138
+ var import_components16 = require("@transferwise/components");
1139
+ var import_jsx_runtime30 = require("react/jsx-runtime");
1140
+ var FormSectionRenderer = {
1141
+ canRenderType: "form-section",
1142
+ render: ({ title, description, children }) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("fieldset", { children: [
1143
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1144
+ import_components16.Header,
1145
+ {
1146
+ as: "h2",
1147
+ title
1148
+ }
1149
+ ),
1150
+ description && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { children: description }),
1151
+ children
1152
+ ] })
1153
+ };
1154
+ var FormSectionRenderer_default = FormSectionRenderer;
1155
+
1156
+ // ../renderers/src/HeadingRenderer.tsx
1157
+ var import_components17 = require("@transferwise/components");
1158
+ var import_jsx_runtime31 = require("react/jsx-runtime");
1159
+ var HeadingRenderer = {
1160
+ canRenderType: "heading",
1161
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Heading, __spreadValues({}, props))
1162
+ };
1163
+ function Heading(props) {
1164
+ const { text, size, align, margin, control } = props;
1165
+ const className = getTextAlignmentAndMargin({ align, margin });
1166
+ return control === "display" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DisplayHeading, { size, text, className }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(StandardHeading, { size, text, className });
1167
+ }
1168
+ function DisplayHeading({ size, text, className }) {
1169
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components17.Display, { type: getDisplayType(size), className, children: text });
1170
+ }
1171
+ var getDisplayType = (size) => {
1172
+ switch (size) {
1173
+ case "xs":
1174
+ case "sm":
1175
+ return "display-small";
1176
+ case "xl":
1177
+ case "lg":
1178
+ return "display-large";
1179
+ case "md":
1180
+ default:
1181
+ return "display-medium";
1182
+ }
1183
+ };
1184
+ function StandardHeading({ size, text, className }) {
1185
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components17.Title, { type: getTitleTypeBySize(size), className, children: text });
1186
+ }
1187
+ var getTitleTypeBySize = (size) => {
1188
+ var _a;
1189
+ const titleTypes = {
1190
+ xs: "title-group",
1191
+ sm: "title-body",
1192
+ md: "title-subsection",
1193
+ lg: "title-section",
1194
+ xl: "title-screen"
1195
+ };
1196
+ return (_a = titleTypes[size]) != null ? _a : "title-subsection";
1197
+ };
1198
+ var HeadingRenderer_default = HeadingRenderer;
1199
+
1200
+ // ../renderers/src/ImageRenderer/UrlImage.tsx
1201
+ var import_components18 = require("@transferwise/components");
1202
+ var import_react5 = require("react");
1203
+
1204
+ // ../renderers/src/utils/api-utils.ts
1205
+ function isRelativePath(url = "") {
1206
+ return !["https://", "http://", "data:"].some(
1207
+ (prefix) => url.startsWith(prefix) && url.length > prefix.length
1208
+ );
1209
+ }
1210
+
1211
+ // ../renderers/src/ImageRenderer/UrlImage.tsx
1212
+ var import_jsx_runtime32 = require("react/jsx-runtime");
1213
+ function UrlImage({
1214
+ accessibilityDescription,
1215
+ align,
1216
+ margin,
1217
+ size,
1218
+ uri,
1219
+ httpClient
1220
+ }) {
1221
+ const [imageSource, setImageSource] = (0, import_react5.useState)("");
1222
+ (0, import_react5.useEffect)(() => {
1223
+ if (!uri.startsWith("urn:")) {
1224
+ void getImageSource(httpClient, uri).then(setImageSource);
1225
+ }
1226
+ }, [uri, httpClient]);
1227
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: `df-image ${align} ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1228
+ import_components18.Image,
1229
+ {
1230
+ className: `img-responsive ${getMargin(margin)}`,
1231
+ alt: accessibilityDescription != null ? accessibilityDescription : "",
1232
+ src: imageSource,
1233
+ stretch: true,
1234
+ shrink: true
1235
+ }
1236
+ ) });
1237
+ }
1238
+ var readImageBlobAsDataURL = async (imageBlob) => (
1239
+ // we can safely assume the type of reader.result is string
1240
+ // because we're calling reader.readAsDataURL
1241
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
1242
+ new Promise((resolve, reject) => {
1243
+ const reader = new FileReader();
1244
+ reader.addEventListener("loadend", () => resolve(reader.result));
1245
+ reader.addEventListener("error", reject);
1246
+ reader.readAsDataURL(imageBlob);
1247
+ })
1248
+ );
1249
+ var getImageSource = async (httpClient, imageUrl) => {
1250
+ var _a;
1251
+ try {
1252
+ if (isRelativePath(imageUrl) || (imageUrl == null ? void 0 : imageUrl.startsWith(`${(_a = window == null ? void 0 : window.location) == null ? void 0 : _a.origin}/`))) {
1253
+ return await httpClient(imageUrl, {
1254
+ method: "GET",
1255
+ headers: { "Content-Type": "image/image" },
1256
+ credentials: "same-origin"
1257
+ }).then(async (response) => {
1258
+ if (response.ok) {
1259
+ return response.blob();
1260
+ }
1261
+ throw new Error("Image fetching failed");
1262
+ }).then(readImageBlobAsDataURL).catch(() => imageUrl);
1263
+ }
1264
+ return imageUrl;
1265
+ } catch (e) {
1266
+ return imageUrl;
1267
+ }
1268
+ };
1269
+
1270
+ // ../renderers/src/ImageRenderer/UrnFlagImage.tsx
1271
+ var import_jsx_runtime33 = require("react/jsx-runtime");
1272
+ var maxFlagSize = 600;
1273
+ function UrnFlagImage({
1274
+ accessibilityDescription,
1275
+ align,
1276
+ margin,
1277
+ size,
1278
+ uri
1279
+ }) {
1280
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `df-image ${align} ${size || "md"} ${getMargin(margin)}`, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(UrnFlag, { size: maxFlagSize, urn: uri, accessibilityDescription }) });
1281
+ }
1282
+
1283
+ // ../renderers/src/ImageRenderer/UrnIllustration.tsx
1284
+ var import_art4 = require("@wise/art");
1285
+ var import_react7 = require("react");
1286
+
1287
+ // ../renderers/src/ImageRenderer/isAnimated.ts
1288
+ var isAnimated = (uri) => {
1289
+ var _a;
1290
+ const { rComponents } = stringToURN(uri);
1291
+ return (_a = rComponents == null ? void 0 : rComponents.some(([key, value]) => key === "type" && value === "animated")) != null ? _a : false;
1292
+ };
1293
+
1294
+ // ../renderers/src/ImageRenderer/SafeIllustration3D.tsx
1295
+ var import_art3 = require("@wise/art");
1296
+ var import_react6 = require("react");
1297
+ var import_jsx_runtime34 = require("react/jsx-runtime");
1298
+ var Illustration3DErrorBoundary = class extends import_react6.Component {
1299
+ constructor(props) {
1300
+ super(props);
1301
+ this.state = { hasError: false };
1302
+ }
1303
+ static getDerivedStateFromError() {
1304
+ return { hasError: true };
1305
+ }
1306
+ componentDidCatch() {
1307
+ this.props.onError();
1308
+ }
1309
+ render() {
1310
+ if (this.state.hasError) {
1311
+ return null;
1312
+ }
1313
+ return this.props.children;
1314
+ }
1315
+ };
1316
+ var SafeIllustration3D = ({
1317
+ name,
1318
+ size,
1319
+ onError
1320
+ }) => {
1321
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Illustration3DErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_art3.Illustration3D, { name, size }) });
1322
+ };
1323
+ var SafeIllustration3D_default = SafeIllustration3D;
1324
+
1325
+ // ../renderers/src/ImageRenderer/UrnIllustration.tsx
1326
+ var import_jsx_runtime35 = require("react/jsx-runtime");
1327
+ var urnPrefix = "urn:wise:illustrations:";
1328
+ var isUrnIllustration = (uri) => uri.startsWith(urnPrefix);
1329
+ function UrnIllustration({
1330
+ accessibilityDescription,
1331
+ align,
1332
+ margin,
1333
+ size,
1334
+ uri
1335
+ }) {
1336
+ const [has3DFailed, setHas3DFailed] = (0, import_react7.useState)(false);
1337
+ const illustrationSize = getIllustrationSize(size);
1338
+ const illustrationName = getIllustrationName(uri);
1339
+ const illustration3DName = getIllustration3DName(uri);
1340
+ if (illustration3DName && isAnimated(uri) && !has3DFailed) {
1341
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: `df-image ${align} ${getMargin(margin)}`, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1342
+ SafeIllustration3D_default,
1343
+ {
1344
+ name: illustration3DName,
1345
+ size: illustrationSize,
1346
+ onError: () => setHas3DFailed(true)
1347
+ }
1348
+ ) });
1349
+ }
1350
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: `df-image ${align} ${getMargin(margin)}`, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1351
+ import_art4.Illustration,
1352
+ {
1353
+ className: "df-illustration",
1354
+ name: illustrationName,
1355
+ size: illustrationSize,
1356
+ alt: accessibilityDescription
1357
+ }
1358
+ ) });
1359
+ }
1360
+ var getIllustrationSize = (size) => ({ xs: "small", sm: "small", md: "medium", lg: "large", xl: "large" })[size] || "medium";
1361
+ var getIllustrationName = (uri) => {
1362
+ return uri.replace(urnPrefix, "").split("?")[0];
1363
+ };
1364
+ var getIllustration3DName = (uri) => {
1365
+ const illustrationName = getIllustrationName(uri);
1366
+ return (0, import_art4.isIllustrationSupport3D)(illustrationName) ? illustrationName : null;
1367
+ };
1368
+
1369
+ // ../renderers/src/ImageRenderer/UrnImage.tsx
1370
+ var import_jsx_runtime36 = require("react/jsx-runtime");
1371
+ var isUrnImage = (uri) => uri.startsWith("urn:");
1372
+ function UrnImage(props) {
1373
+ const { uri } = props;
1374
+ if (isUrnIllustration(uri)) {
1375
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UrnIllustration, __spreadValues({}, props));
1376
+ }
1377
+ if (isUrnFlag(uri)) {
1378
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UrnFlagImage, __spreadValues({}, props));
1379
+ }
1380
+ return null;
1381
+ }
1382
+
1383
+ // ../renderers/src/ImageRenderer/ImageRenderer.tsx
1384
+ var import_jsx_runtime37 = require("react/jsx-runtime");
1385
+ var ImageRenderer = {
1386
+ canRenderType: "image",
1387
+ render: (props) => isUrnImage(props.uri) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(UrnImage, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(UrlImage, __spreadValues({}, props))
1388
+ };
1389
+
1390
+ // ../renderers/src/ImageRenderer/index.tsx
1391
+ var ImageRenderer_default = ImageRenderer;
1392
+
1393
+ // ../renderers/src/InstructionsRenderer.tsx
1394
+ var import_components19 = require("@transferwise/components");
1395
+ var import_jsx_runtime38 = require("react/jsx-runtime");
1396
+ var doContext = ["positive", "neutral"];
1397
+ var dontContext = ["warning", "negative"];
1398
+ var InstructionsRenderer = {
1399
+ canRenderType: "instructions",
1400
+ render: ({ items, margin, title }) => {
1401
+ const dos = items.filter((item) => doContext.includes(item.context)).map(({ text }) => text);
1402
+ const donts = items.filter((item) => dontContext.includes(item.context)).map(({ text }) => text);
1403
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getMargin(margin), children: [
1404
+ title ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components19.Header, { title }) : null,
1405
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components19.InstructionsList, { dos, donts })
1406
+ ] });
1407
+ }
1408
+ };
1409
+ var InstructionsRenderer_default = InstructionsRenderer;
1410
+
1411
+ // ../renderers/src/IntegerInputRenderer.tsx
1412
+ var import_components20 = require("@transferwise/components");
1413
+
1414
+ // ../renderers/src/utils/input-utils.ts
1415
+ var onWheel = (event) => {
1416
+ if (event.target instanceof HTMLElement) {
1417
+ event.target.blur();
1418
+ }
1419
+ };
1420
+
1421
+ // ../renderers/src/utils/getInputGroupAddonStart.tsx
1422
+ var getInputGroupAddonStart = (media) => {
1423
+ const content = getInlineMedia(media);
1424
+ return content ? { content } : void 0;
1425
+ };
1426
+
1427
+ // ../renderers/src/utils/pick.ts
1428
+ function pick(obj, ...keys) {
1429
+ const result = {};
1430
+ keys.forEach((key) => {
1431
+ result[key] = obj[key];
1432
+ });
1433
+ return result;
1434
+ }
1435
+
1436
+ // ../renderers/src/IntegerInputRenderer.tsx
1437
+ var import_jsx_runtime39 = require("react/jsx-runtime");
1438
+ var IntegerInputRenderer = {
1439
+ canRenderType: "input-integer",
1440
+ render: (props) => {
1441
+ const { id, title, description, help, media, validationState, value, onChange } = props;
1442
+ const commonProps = pick(
1443
+ props,
1444
+ "autoComplete",
1445
+ "disabled",
1446
+ "onBlur",
1447
+ "onFocus",
1448
+ "placeholder",
1449
+ "maximum",
1450
+ "minimum"
1451
+ );
1452
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
1453
+ FieldInput_default,
1454
+ {
1455
+ id,
1456
+ label: title,
1457
+ description,
1458
+ validation: validationState,
1459
+ help,
1460
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components20.InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
1461
+ import_components20.Input,
1462
+ __spreadValues({
1463
+ id,
1464
+ name: id,
1465
+ type: "number",
1466
+ step: "1",
1467
+ pattern: "\\d+",
1468
+ value: value != null ? value : "",
1469
+ onChange: ({ target: { value: newValue } }) => {
1470
+ const parsedValue = Number.parseInt(newValue, 10);
1471
+ onChange(Number.isNaN(parsedValue) ? null : parsedValue);
1472
+ },
1473
+ onWheel
1474
+ }, commonProps)
1475
+ ) })
1476
+ }
1477
+ );
1478
+ }
1479
+ };
1480
+ var IntegerInputRenderer_default = IntegerInputRenderer;
1481
+
1482
+ // ../renderers/src/ListRenderer.tsx
1483
+ var import_components21 = require("@transferwise/components");
1484
+ var import_classnames3 = __toESM(require("classnames"));
1485
+ var import_jsx_runtime40 = require("react/jsx-runtime");
1486
+ var ListRenderer = {
1487
+ canRenderType: "list",
1488
+ render: ({ callToAction, control, margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getMargin(margin), children: [
1489
+ (title || callToAction) && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components21.Header, { as: "h2", title: title != null ? title : "", action: getListAction(callToAction) }),
1490
+ items.map((props) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DesignSystemListItem, __spreadProps(__spreadValues({}, props), { control }), props.title))
1491
+ ] })
1492
+ };
1493
+ var DesignSystemListItem = ({
1494
+ title,
1495
+ description,
1496
+ supportingValues,
1497
+ icon,
1498
+ image,
1499
+ media,
1500
+ control,
1501
+ tag
1502
+ }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
1503
+ "label",
1504
+ {
1505
+ className: (0, import_classnames3.default)("np-option p-a-2", {
1506
+ "np-option__sm-media": true,
1507
+ "np-option__container-aligned": true
1508
+ }),
1509
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "media", children: [
1510
+ icon || image || media ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "media-left", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
1511
+ ListItemMedia,
1512
+ {
1513
+ icon,
1514
+ media,
1515
+ preferAvatar: control === "with-avatar" || tag === "with-avatar"
1516
+ }
1517
+ ) }) : null,
1518
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "media-body", children: [
1519
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "d-flex justify-content-between", children: [
1520
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h4", { className: "np-text-body-large-bold text-primary np-option__title", children: title }),
1521
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h4", { className: "np-text-body-large-bold text-primary np-option__title", children: supportingValues == null ? void 0 : supportingValues.value })
1522
+ ] }),
1523
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "d-flex justify-content-between", children: [
1524
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components21.Body, { className: "d-block np-option__body", children: description }),
1525
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components21.Body, { className: "d-block np-option__body", children: supportingValues == null ? void 0 : supportingValues.subvalue })
1526
+ ] })
1527
+ ] })
1528
+ ] })
1529
+ },
1530
+ title
1531
+ );
1532
+ var ListItemMedia = ({
1533
+ icon,
1534
+ media,
1535
+ preferAvatar
1536
+ }) => {
1537
+ if (icon) {
1538
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "circle circle-sm text-primary circle-inverse", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OptionMedia, { media, preferAvatar }) });
1539
+ }
1540
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "np-option__no-media-circle", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OptionMedia, { media, preferAvatar }) });
1541
+ };
1542
+ var getListAction = (callToAction) => {
1543
+ if (callToAction) {
1544
+ return __spreadValues({
1545
+ "aria-label": callToAction.accessibilityDescription,
1546
+ text: callToAction.title,
1547
+ onClick: callToAction.onClick
1548
+ }, callToAction.type === "link" ? { href: callToAction.href, target: "_blank" } : {});
1549
+ }
1550
+ return void 0;
1551
+ };
1552
+ var ListRenderer_default = ListRenderer;
1553
+
1554
+ // ../renderers/src/LoadingIndicatorRenderer.tsx
1555
+ var import_components22 = require("@transferwise/components");
1556
+ var import_jsx_runtime41 = require("react/jsx-runtime");
1557
+ var LoadingIndicatorRenderer = {
1558
+ canRenderType: "loading-indicator",
1559
+ render: ({ margin, size }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
1560
+ import_components22.Loader,
1561
+ {
1562
+ size,
1563
+ classNames: { "tw-loader": `tw-loader m-x-auto ${getMargin(margin)}` },
1564
+ "data-testid": "loading-indicator"
1565
+ }
1566
+ )
1567
+ };
1568
+ var LoadingIndicatorRenderer_default = LoadingIndicatorRenderer;
1569
+
1570
+ // ../renderers/src/MarkdownRenderer.tsx
1571
+ var import_components23 = require("@transferwise/components");
1572
+ var import_jsx_runtime42 = require("react/jsx-runtime");
1573
+ var MarkdownRenderer = {
1574
+ canRenderType: "markdown",
1575
+ render: ({ content, align, margin }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getTextAlignmentAndMargin({ align, margin }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components23.Markdown, { className: "np-text-body-large", config: { link: { target: "_blank" } }, children: content }) })
1576
+ };
1577
+ var MarkdownRenderer_default = MarkdownRenderer;
1578
+
1579
+ // ../renderers/src/ModalLayoutRenderer.tsx
1580
+ var import_components24 = require("@transferwise/components");
1581
+ var import_react8 = require("react");
1582
+ var import_jsx_runtime43 = require("react/jsx-runtime");
1583
+ var ModalLayoutRenderer = {
1584
+ canRenderType: "modal-layout",
1585
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(DFModal, __spreadValues({}, props))
1586
+ };
1587
+ var ModalLayoutRenderer_default = ModalLayoutRenderer;
1588
+ function DFModal({ content, margin, trigger }) {
1589
+ const [visible, setVisible] = (0, import_react8.useState)(false);
1590
+ const { children, title } = content;
1591
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getMargin(margin), children: [
1592
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components24.Button, { v2: true, priority: "tertiary", block: true, onClick: () => setVisible(true), children: trigger.title }),
1593
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
1594
+ import_components24.Modal,
1595
+ {
1596
+ scroll: "content",
1597
+ open: visible,
1598
+ size: "lg",
1599
+ title,
1600
+ body: children,
1601
+ onClose: () => setVisible(false)
1602
+ }
1603
+ )
1604
+ ] });
1605
+ }
1606
+
1607
+ // ../renderers/src/ModalRenderer.tsx
1608
+ var import_components25 = require("@transferwise/components");
1609
+ var import_jsx_runtime44 = require("react/jsx-runtime");
1610
+ var ModalRenderer = {
1611
+ canRenderType: "modal",
1612
+ render: ({ title, children, open, onClose }) => {
1613
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components25.Modal, { open, title, body: children, onClose });
1614
+ }
1615
+ };
1616
+
1617
+ // ../renderers/src/MultiSelectInputRenderer.tsx
1618
+ var import_components26 = require("@transferwise/components");
1619
+ var import_react9 = require("react");
1620
+ var import_react_intl11 = require("react-intl");
1621
+
1622
+ // ../renderers/src/messages/multi-select.messages.ts
1623
+ var import_react_intl10 = require("react-intl");
1624
+ var multi_select_messages_default = (0, import_react_intl10.defineMessages)({
1625
+ summary: {
1626
+ id: "df.wise.MultiSelect.summary",
1627
+ defaultMessage: "{first} and {count} more",
1628
+ description: "A summary of the multiple items selected. Showing the title of the first selected item, and the number of other items that have been selected."
1629
+ }
1630
+ });
1631
+
1632
+ // ../renderers/src/MultiSelectInputRenderer.tsx
1633
+ var import_jsx_runtime45 = require("react/jsx-runtime");
1634
+ var MultiSelectInputRenderer = {
1635
+ canRenderType: "input-multi-select",
1636
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(MultiSelectInputRendererComponent, __spreadValues({}, props))
1637
+ };
1638
+ function MultiSelectInputRendererComponent(props) {
1639
+ const { formatMessage } = (0, import_react_intl11.useIntl)();
1640
+ const [stagedIndices, setStagedIndices] = (0, import_react9.useState)();
1641
+ const {
1642
+ id,
1643
+ autoComplete,
1644
+ description,
1645
+ disabled,
1646
+ help,
1647
+ options,
1648
+ placeholder,
1649
+ selectedIndices,
1650
+ title,
1651
+ validationState,
1652
+ onSelect
1653
+ } = props;
1654
+ const mergedIndices = stagedIndices != null ? stagedIndices : selectedIndices;
1655
+ const getFormattedMessage = () => {
1656
+ if (mergedIndices.length > 0) {
1657
+ if (mergedIndices.length > 1) {
1658
+ return formatMessage(multi_select_messages_default.summary, {
1659
+ first: options[mergedIndices[0]].title,
1660
+ count: mergedIndices.length - 1
1661
+ });
1662
+ }
1663
+ return options[mergedIndices[0]].title;
1664
+ }
1665
+ return void 0;
1666
+ };
1667
+ const renderValue = (index, withinTrigger) => {
1668
+ const option = index >= 0 ? options[index] : null;
1669
+ if (option === null) {
1670
+ return null;
1671
+ }
1672
+ if (withinTrigger) {
1673
+ return index === mergedIndices[0] ? getFormattedMessage() : void 0;
1674
+ }
1675
+ const contentProps = {
1676
+ title: option.title,
1677
+ description: option.description,
1678
+ icon: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionMedia, { media: option.media, preferAvatar: false })
1679
+ };
1680
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_components26.SelectInputOptionContent, __spreadValues({}, contentProps));
1681
+ };
1682
+ const extraProps = { autoComplete };
1683
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
1684
+ FieldInput_default,
1685
+ {
1686
+ id,
1687
+ label: title,
1688
+ help,
1689
+ description,
1690
+ validation: validationState,
1691
+ children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
1692
+ import_components26.SelectInput,
1693
+ __spreadValues({
1694
+ id,
1695
+ items: options.map((option, index) => {
1696
+ var _a, _b, _c;
1697
+ return {
1698
+ type: "option",
1699
+ value: index,
1700
+ filterMatchers: [
1701
+ ...(_a = option.keywords) != null ? _a : [],
1702
+ (_b = option.title) != null ? _b : "",
1703
+ (_c = option.description) != null ? _c : ""
1704
+ ],
1705
+ disabled: option.disabled
1706
+ };
1707
+ }),
1708
+ disabled,
1709
+ placeholder,
1710
+ value: mergedIndices,
1711
+ renderValue,
1712
+ multiple: true,
1713
+ filterable: options.length >= 8,
1714
+ onChange: (values) => {
1715
+ setStagedIndices(values);
1716
+ },
1717
+ onClose: () => {
1718
+ if (stagedIndices) {
1719
+ onSelect(stagedIndices);
1720
+ setStagedIndices(void 0);
1721
+ }
1722
+ }
1723
+ }, extraProps)
1724
+ )
1725
+ }
1726
+ );
1727
+ }
1728
+ var MultiSelectInputRenderer_default = MultiSelectInputRenderer;
1729
+
1730
+ // ../renderers/src/MultiUploadInputRenderer.tsx
1731
+ var import_components28 = require("@transferwise/components");
1732
+
1733
+ // ../renderers/src/components/UploadFieldInput.tsx
1734
+ var import_components27 = require("@transferwise/components");
1735
+ var import_classnames4 = __toESM(require("classnames"));
1736
+ var import_jsx_runtime46 = require("react/jsx-runtime");
1737
+ function UploadFieldInput({
1738
+ id,
1739
+ children,
1740
+ label,
1741
+ description,
1742
+ help,
1743
+ validation
1744
+ }) {
1745
+ const labelContent = label && help ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(LabelContentWithHelp, { text: label, help }) : label;
1746
+ const descriptionId = description ? `${id}-description` : void 0;
1747
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
1748
+ "div",
1749
+ {
1750
+ className: (0, import_classnames4.default)("form-group d-block", {
1751
+ "has-error": (validation == null ? void 0 : validation.status) === "invalid"
1752
+ }),
1753
+ children: [
1754
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("label", { htmlFor: id, className: "control-label", children: labelContent }),
1755
+ children,
1756
+ (validation == null ? void 0 : validation.status) === "invalid" && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components27.InlineAlert, { type: "negative", id: descriptionId, children: validation.message })
1757
+ ]
1758
+ }
1759
+ );
1760
+ }
1761
+ var UploadFieldInput_default = UploadFieldInput;
1762
+
1763
+ // ../renderers/src/utils/file-utils.ts
1764
+ var acceptsToFileTypes = (accepts) => Array.isArray(accepts) && accepts.length >= 1 ? accepts : "*";
1765
+ var toKilobytes = (sizeInBytes) => {
1766
+ const ONE_KB_IN_BYTES = 1024;
1767
+ return Math.floor(sizeInBytes / ONE_KB_IN_BYTES);
1768
+ };
1769
+ var toFile = async (base64Url, name) => {
1770
+ const type = getFileType(base64Url);
1771
+ const blob = await toBlob(base64Url);
1772
+ return new File([blob], name, { type });
1773
+ };
1774
+ var toBlob = async (base64Url) => (await fetch(base64Url)).blob();
1775
+ var getFileType = (base64Url) => {
1776
+ const contentTypeRegex = /^data:(.+);/;
1777
+ const matches = contentTypeRegex.exec(base64Url);
1778
+ if (matches && matches.length > 1) {
1779
+ return matches[1];
1780
+ }
1781
+ return void 0;
1782
+ };
1783
+ var getSizeLimit = (maxSize) => {
1784
+ if (maxSize === void 0) {
1785
+ return null;
1786
+ }
1787
+ return toKilobytes(maxSize);
1788
+ };
1789
+
1790
+ // ../renderers/src/MultiUploadInputRenderer.tsx
1791
+ var import_jsx_runtime47 = require("react/jsx-runtime");
1792
+ var MultiUploadInputRenderer = {
1793
+ canRenderType: "input-upload-multi",
1794
+ render: (props) => {
1795
+ const {
1796
+ id,
1797
+ accepts,
1798
+ help,
1799
+ title,
1800
+ description,
1801
+ disabled,
1802
+ maxSize,
1803
+ maxItems,
1804
+ uploadLabel,
1805
+ validationState,
1806
+ value,
1807
+ onInsertFile,
1808
+ onRemoveFile
1809
+ } = props;
1810
+ const onUploadFile = async (formData) => {
1811
+ const file = formData.get("file");
1812
+ return onInsertFile(value.length, file).then((newId) => ({ id: newId }));
1813
+ };
1814
+ const onDeleteFile = async (fileId) => onRemoveFile(value.findIndex((file) => file.id === fileId));
1815
+ const descriptionId = description ? `${id}-description` : void 0;
1816
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
1817
+ UploadFieldInput_default,
1818
+ {
1819
+ id,
1820
+ label: title,
1821
+ description,
1822
+ validation: validationState,
1823
+ help,
1824
+ children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
1825
+ import_components28.UploadInput,
1826
+ {
1827
+ id,
1828
+ "aria-describedby": descriptionId,
1829
+ description,
1830
+ disabled,
1831
+ fileTypes: acceptsToFileTypes(accepts),
1832
+ maxFiles: maxItems,
1833
+ multiple: true,
1834
+ sizeLimit: getSizeLimit(maxSize),
1835
+ uploadButtonTitle: uploadLabel,
1836
+ onDeleteFile,
1837
+ onUploadFile
1838
+ }
1839
+ )
1840
+ }
1841
+ );
1842
+ }
1843
+ };
1844
+ var MultiUploadInputRenderer_default = MultiUploadInputRenderer;
1845
+
1846
+ // ../renderers/src/NumberInputRenderer.tsx
1847
+ var import_components29 = require("@transferwise/components");
1848
+ var import_jsx_runtime48 = require("react/jsx-runtime");
1849
+ var NumberInputRenderer = {
1850
+ canRenderType: "input-number",
1851
+ render: (props) => {
1852
+ const { id, title, description, help, media, validationState, value, onChange } = props;
1853
+ const commonProps = pick(
1854
+ props,
1855
+ "disabled",
1856
+ "onBlur",
1857
+ "onFocus",
1858
+ "placeholder",
1859
+ "maximum",
1860
+ "minimum"
1861
+ );
1862
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
1863
+ FieldInput_default,
1864
+ {
1865
+ id,
1866
+ label: title,
1867
+ description,
1868
+ validation: validationState,
1869
+ help,
1870
+ children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components29.InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
1871
+ import_components29.Input,
1872
+ __spreadValues({
1873
+ id,
1874
+ name: id,
1875
+ type: "number",
1876
+ value: value != null ? value : "",
1877
+ onChange: ({ target: { value: newValue } }) => {
1878
+ const parsedValue = Number.parseFloat(newValue);
1879
+ onChange(Number.isNaN(parsedValue) ? null : parsedValue);
1880
+ },
1881
+ onWheel
1882
+ }, commonProps)
1883
+ ) })
1884
+ }
1885
+ );
32
1886
  }
33
- return to;
34
1887
  };
35
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1888
+ var NumberInputRenderer_default = NumberInputRenderer;
36
1889
 
37
- // src/index.ts
38
- var index_exports = {};
39
- __export(index_exports, {
40
- DynamicFlowLegacy: () => DynamicFlowLegacy,
41
- DynamicFlowRevamp: () => DynamicFlowRevamp,
42
- DynamicForm: () => DynamicForm,
43
- Header: () => import_dynamic_flow_renderers3.Header,
44
- JsonSchemaForm: () => import_dynamic_flow_client4.JsonSchemaForm,
45
- findRendererPropsByType: () => import_dynamic_flow_client4.findRendererPropsByType,
46
- getButtonV2Renderers: () => import_dynamic_flow_renderers3.getButtonV2Renderers,
47
- getListItemRenderers: () => import_dynamic_flow_renderers3.getListItemRenderers,
48
- getMargin: () => import_dynamic_flow_renderers3.getMargin,
49
- isValidSchema: () => import_dynamic_flow_client4.isValidSchema,
50
- makeCustomFetch: () => import_dynamic_flow_client3.makeHttpClient,
51
- translations: () => i18n_default
1890
+ // ../renderers/src/ParagraphRenderer.tsx
1891
+ var import_react_intl13 = require("react-intl");
1892
+
1893
+ // ../renderers/src/hooks/useSnackBarIfAvailable.ts
1894
+ var import_components30 = require("@transferwise/components");
1895
+ var import_react10 = require("react");
1896
+ function useSnackBarIfAvailable() {
1897
+ const context = (0, import_react10.useContext)(import_components30.SnackbarContext);
1898
+ return context ? context.createSnackbar : () => {
1899
+ };
1900
+ }
1901
+
1902
+ // ../renderers/src/ParagraphRenderer.tsx
1903
+ var import_components31 = require("@transferwise/components");
1904
+ var import_classnames5 = __toESM(require("classnames"));
1905
+
1906
+ // ../renderers/src/messages/paragraph.messages.ts
1907
+ var import_react_intl12 = require("react-intl");
1908
+ var paragraph_messages_default = (0, import_react_intl12.defineMessages)({
1909
+ copy: {
1910
+ id: "df.wise.DynamicParagraph.copy",
1911
+ defaultMessage: "Copy",
1912
+ description: "Copy to clipboard button label."
1913
+ },
1914
+ copied: {
1915
+ id: "df.wise.DynamicParagraph.copied",
1916
+ defaultMessage: "Copied to clipboard",
1917
+ description: "Appears in a snackbar when the copy operation succeeds."
1918
+ }
52
1919
  });
53
- module.exports = __toCommonJS(index_exports);
54
- var import_dynamic_flow_client3 = require("@wise/dynamic-flow-client");
55
- var import_dynamic_flow_client4 = require("@wise/dynamic-flow-client");
56
- var import_dynamic_flow_renderers3 = require("@wise/dynamic-flow-renderers");
1920
+
1921
+ // ../renderers/src/ParagraphRenderer.tsx
1922
+ var import_jsx_runtime49 = require("react/jsx-runtime");
1923
+ var ParagraphRenderer = {
1924
+ canRenderType: "paragraph",
1925
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Paragraph, __spreadValues({}, props))
1926
+ };
1927
+ function Paragraph({ align, control, margin, text }) {
1928
+ const className = getTextAlignmentAndMargin({ align, margin });
1929
+ return control === "copyable" ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(CopyableParagraph, { className, align, text }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(StandardParagraph, { className, text });
1930
+ }
1931
+ function StandardParagraph({ text, className }) {
1932
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: `np-text-body-large ${className}`, children: text });
1933
+ }
1934
+ function CopyableParagraph({
1935
+ text,
1936
+ align,
1937
+ className
1938
+ }) {
1939
+ const { formatMessage } = (0, import_react_intl13.useIntl)();
1940
+ const createSnackbar = useSnackBarIfAvailable();
1941
+ const copy = () => {
1942
+ navigator.clipboard.writeText(text).then(() => createSnackbar({ text: formatMessage(paragraph_messages_default.copied) })).catch(() => {
1943
+ });
1944
+ };
1945
+ const inputAlignmentClasses = getTextAlignmentAndMargin({ align, margin: "sm" });
1946
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className, children: [
1947
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
1948
+ import_components31.Input,
1949
+ {
1950
+ type: "text",
1951
+ value: text,
1952
+ readOnly: true,
1953
+ className: (0, import_classnames5.default)("text-ellipsis", inputAlignmentClasses)
1954
+ }
1955
+ ),
1956
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components31.Button, { v2: true, block: true, onClick: copy, children: formatMessage(paragraph_messages_default.copy) })
1957
+ ] });
1958
+ }
1959
+ var ParagraphRenderer_default = ParagraphRenderer;
1960
+
1961
+ // ../renderers/src/RepeatableRenderer.tsx
1962
+ var import_components32 = require("@transferwise/components");
1963
+ var import_icons = require("@transferwise/icons");
1964
+ var import_classnames6 = __toESM(require("classnames"));
1965
+ var import_react11 = require("react");
1966
+ var import_react_intl15 = require("react-intl");
1967
+
1968
+ // ../renderers/src/messages/repeatable.messages.ts
1969
+ var import_react_intl14 = require("react-intl");
1970
+ var repeatable_messages_default = (0, import_react_intl14.defineMessages)({
1971
+ addItemTitle: {
1972
+ id: "df.wise.ArraySchema.addItemTitle",
1973
+ defaultMessage: "Add Item",
1974
+ description: "Label on the button used to open a form to add an item"
1975
+ },
1976
+ addItem: {
1977
+ id: "df.wise.ArraySchema.addItem",
1978
+ defaultMessage: "Save",
1979
+ description: "Label on the add button used to submit a form that adds an item"
1980
+ },
1981
+ editItem: {
1982
+ id: "df.wise.ArraySchema.editItem",
1983
+ defaultMessage: "Save",
1984
+ description: "Label on the edit button used to submit a form that edits an item"
1985
+ },
1986
+ removeItem: {
1987
+ id: "df.wise.ArraySchema.removeItem",
1988
+ defaultMessage: "Remove",
1989
+ description: "Label on the remove button used to confirm deletion of an item"
1990
+ }
1991
+ });
1992
+
1993
+ // ../renderers/src/RepeatableRenderer.tsx
1994
+ var import_jsx_runtime50 = require("react/jsx-runtime");
1995
+ var RepeatableRenderer = {
1996
+ canRenderType: "repeatable",
1997
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Repeatable, __spreadValues({}, props))
1998
+ };
1999
+ function Repeatable(props) {
2000
+ const {
2001
+ addItemTitle,
2002
+ description,
2003
+ editableItem,
2004
+ editItemTitle,
2005
+ items,
2006
+ title,
2007
+ validationState,
2008
+ onEdit,
2009
+ onAdd,
2010
+ onSave,
2011
+ onRemove
2012
+ } = props;
2013
+ const { formatMessage } = (0, import_react_intl15.useIntl)();
2014
+ const [openModalType, setOpenModalType] = (0, import_react11.useState)(null);
2015
+ const onAddItem = () => {
2016
+ onAdd();
2017
+ setOpenModalType("add");
2018
+ };
2019
+ const onEditItem = (itemIndex) => {
2020
+ onEdit(itemIndex);
2021
+ setOpenModalType("edit");
2022
+ };
2023
+ const onSaveItem = () => {
2024
+ const saveSuccessful = onSave();
2025
+ if (saveSuccessful) {
2026
+ setOpenModalType(null);
2027
+ }
2028
+ };
2029
+ const onRemoveItem = () => {
2030
+ onRemove();
2031
+ setOpenModalType(null);
2032
+ };
2033
+ const onCancelEdit = () => {
2034
+ setOpenModalType(null);
2035
+ };
2036
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
2037
+ title && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components32.Header, { title }),
2038
+ description && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { children: description }),
2039
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
2040
+ "div",
2041
+ {
2042
+ className: (0, import_classnames6.default)("form-group", {
2043
+ "has-error": (validationState == null ? void 0 : validationState.status) === "invalid"
2044
+ }),
2045
+ children: [
2046
+ items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ItemSummaryOption, { item, onClick: () => onEditItem(index) }, item.id)),
2047
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
2048
+ import_components32.NavigationOption,
2049
+ {
2050
+ media: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_icons.Plus, {}),
2051
+ title: addItemTitle || formatMessage(repeatable_messages_default.addItemTitle),
2052
+ showMediaAtAllSizes: true,
2053
+ onClick: () => onAddItem()
2054
+ }
2055
+ ),
2056
+ (validationState == null ? void 0 : validationState.status) === "invalid" && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components32.InlineAlert, { type: "negative", children: validationState.message })
2057
+ ]
2058
+ }
2059
+ ),
2060
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
2061
+ import_components32.Modal,
2062
+ {
2063
+ open: openModalType !== null,
2064
+ title: (openModalType === "add" ? addItemTitle : editItemTitle) || formatMessage(repeatable_messages_default.addItemTitle),
2065
+ body: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
2066
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "m-b-2", children: editableItem }),
2067
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { children: [
2068
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components32.Button, { priority: "primary", block: true, className: "m-b-2", onClick: () => onSaveItem(), children: formatMessage(repeatable_messages_default.addItem) }),
2069
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
2070
+ import_components32.Button,
2071
+ {
2072
+ v2: true,
2073
+ priority: "secondary",
2074
+ sentiment: "negative",
2075
+ block: true,
2076
+ onClick: () => onRemoveItem(),
2077
+ children: formatMessage(repeatable_messages_default.removeItem)
2078
+ }
2079
+ )
2080
+ ] })
2081
+ ] }),
2082
+ onClose: () => onCancelEdit()
2083
+ }
2084
+ )
2085
+ ] });
2086
+ }
2087
+ function ItemSummaryOption({
2088
+ item,
2089
+ onClick
2090
+ }) {
2091
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
2092
+ import_components32.NavigationOption,
2093
+ {
2094
+ media: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(OptionMedia, { media: item.media, preferAvatar: false }),
2095
+ title: item.title,
2096
+ content: item.description,
2097
+ showMediaAtAllSizes: true,
2098
+ onClick
2099
+ }
2100
+ );
2101
+ }
2102
+ var RepeatableRenderer_default = RepeatableRenderer;
2103
+
2104
+ // ../renderers/src/ReviewRenderer.tsx
2105
+ var import_components34 = require("@transferwise/components");
2106
+
2107
+ // ../renderers/src/components/Header.tsx
2108
+ var import_components33 = require("@transferwise/components");
2109
+ var import_jsx_runtime51 = require("react/jsx-runtime");
2110
+ var Header7 = ({ title, callToAction }) => (title || callToAction) && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components33.Header, { title: title != null ? title : "", action: getHeaderAction(callToAction) });
2111
+ var getHeaderAction = (callToAction) => {
2112
+ if (!callToAction) {
2113
+ return void 0;
2114
+ }
2115
+ const { accessibilityDescription, href, title, onClick } = callToAction;
2116
+ return href ? {
2117
+ "aria-label": accessibilityDescription,
2118
+ text: title,
2119
+ href,
2120
+ target: "_blank"
2121
+ } : {
2122
+ "aria-label": accessibilityDescription,
2123
+ text: title,
2124
+ onClick: (event) => {
2125
+ event.preventDefault();
2126
+ onClick();
2127
+ }
2128
+ };
2129
+ };
2130
+
2131
+ // ../renderers/src/ReviewRenderer.tsx
2132
+ var import_jsx_runtime52 = require("react/jsx-runtime");
2133
+ var ReviewRenderer = {
2134
+ canRenderType: "review",
2135
+ render: ({ callToAction, control, fields, margin, title, trackEvent }) => {
2136
+ const orientation = mapControlToDefinitionListLayout(control);
2137
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: getMargin(margin), children: [
2138
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Header7, { title, callToAction }),
2139
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: margin, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
2140
+ import_components34.DefinitionList,
2141
+ {
2142
+ layout: orientation,
2143
+ definitions: fields.map(
2144
+ ({ label, value, help, analyticsId: fieldAnalyticsId }, index) => ({
2145
+ key: String(index),
2146
+ value,
2147
+ title: getFieldLabel(
2148
+ label,
2149
+ help,
2150
+ () => trackEvent("Help Pressed", { layoutItemId: fieldAnalyticsId })
2151
+ )
2152
+ })
2153
+ )
2154
+ }
2155
+ ) })
2156
+ ] });
2157
+ }
2158
+ };
2159
+ var ReviewRenderer_default = ReviewRenderer;
2160
+ var mapControlToDefinitionListLayout = (control) => {
2161
+ switch (control) {
2162
+ case "horizontal":
2163
+ case "horizontal-end-aligned":
2164
+ return "HORIZONTAL_RIGHT_ALIGNED";
2165
+ case "horizontal-start-aligned":
2166
+ return "HORIZONTAL_LEFT_ALIGNED";
2167
+ case "vertical-two-column":
2168
+ return "VERTICAL_TWO_COLUMN";
2169
+ case "vertical":
2170
+ case "vertical-one-column":
2171
+ default:
2172
+ return "VERTICAL_ONE_COLUMN";
2173
+ }
2174
+ };
2175
+ var getFieldLabel = (label, help, onClick) => {
2176
+ if (help) {
2177
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
2178
+ label,
2179
+ " ",
2180
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Help_default, { help, onClick })
2181
+ ] });
2182
+ }
2183
+ return label;
2184
+ };
2185
+
2186
+ // ../renderers/src/SearchRenderer/BlockSearchRendererComponent.tsx
2187
+ var import_components36 = require("@transferwise/components");
2188
+ var import_react12 = require("react");
2189
+ var import_react_intl19 = require("react-intl");
2190
+
2191
+ // ../renderers/src/messages/search.messages.ts
2192
+ var import_react_intl16 = require("react-intl");
2193
+ var search_messages_default = (0, import_react_intl16.defineMessages)({
2194
+ loading: {
2195
+ id: "df.wise.SearchLayout.loading",
2196
+ defaultMessage: "Loading...",
2197
+ description: "A message shown to the user while their search is being processed, before results appear."
2198
+ }
2199
+ });
2200
+
2201
+ // ../renderers/src/SearchRenderer/ErrorResult.tsx
2202
+ var import_react_intl18 = require("react-intl");
2203
+
2204
+ // ../renderers/src/messages/generic-error.messages.ts
2205
+ var import_react_intl17 = require("react-intl");
2206
+ var generic_error_messages_default = (0, import_react_intl17.defineMessages)({
2207
+ genericErrorRetryHint: {
2208
+ id: "df.wise.PersistAsyncSchema.genericError",
2209
+ defaultMessage: "Something went wrong, please try again.",
2210
+ description: "Generic error message for persist async schema"
2211
+ },
2212
+ genericError: {
2213
+ id: "df.wise.ErrorBoundary.errorAlert",
2214
+ defaultMessage: "Something went wrong.",
2215
+ description: "Generic error message for when something has gone wrong."
2216
+ },
2217
+ retry: {
2218
+ id: "df.wise.ErrorBoundary.retry",
2219
+ defaultMessage: "Retry",
2220
+ description: "Usually this follows the generic error and contains a link."
2221
+ }
2222
+ });
2223
+
2224
+ // ../renderers/src/SearchRenderer/ErrorResult.tsx
2225
+ var import_components35 = require("@transferwise/components");
2226
+ var import_jsx_runtime53 = require("react/jsx-runtime");
2227
+ function ErrorResult({ state }) {
2228
+ const intl = (0, import_react_intl18.useIntl)();
2229
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("p", { className: "m-t-2", children: [
2230
+ intl.formatMessage(generic_error_messages_default.genericError),
2231
+ "\xA0",
2232
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components35.Link, { onClick: () => state.onRetry(), children: intl.formatMessage(generic_error_messages_default.retry) })
2233
+ ] });
2234
+ }
2235
+
2236
+ // ../renderers/src/SearchRenderer/BlockSearchRendererComponent.tsx
2237
+ var import_jsx_runtime54 = require("react/jsx-runtime");
2238
+ function BlockSearchRendererComponent({
2239
+ id,
2240
+ isLoading,
2241
+ margin,
2242
+ query,
2243
+ state,
2244
+ title,
2245
+ trackEvent,
2246
+ onChange
2247
+ }) {
2248
+ const [hasSearched, setHasSearched] = (0, import_react12.useState)(false);
2249
+ const { formatMessage } = (0, import_react_intl19.useIntl)();
2250
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: getMargin(margin), children: [
2251
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
2252
+ import_components36.Input,
2253
+ {
2254
+ id,
2255
+ name: id,
2256
+ type: "text",
2257
+ value: query,
2258
+ className: "m-t-1",
2259
+ onChange: ({ currentTarget: { value } }) => {
2260
+ if (!hasSearched) {
2261
+ setHasSearched(true);
2262
+ trackEvent("Search Started");
2263
+ }
2264
+ onChange(value);
2265
+ }
2266
+ }
2267
+ ) }),
2268
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_jsx_runtime54.Fragment, { children: formatMessage(search_messages_default.loading) }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SearchResultContent, { state, trackEvent })
2269
+ ] });
2270
+ }
2271
+ function SearchResultContent({
2272
+ state,
2273
+ trackEvent
2274
+ }) {
2275
+ switch (state.type) {
2276
+ case "error":
2277
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ErrorResult, { state });
2278
+ case "results":
2279
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SearchResults, { state, trackEvent });
2280
+ case "noResults":
2281
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(EmptySearchResult, { state });
2282
+ case "pending":
2283
+ default:
2284
+ return null;
2285
+ }
2286
+ }
2287
+ function EmptySearchResult({ state }) {
2288
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components36.Markdown, { className: "m-t-2", config: { link: { target: "_blank" } }, children: state.message });
2289
+ }
2290
+ function SearchResults({
2291
+ state,
2292
+ trackEvent
2293
+ }) {
2294
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components36.NavigationOptionsList, { children: state.results.map((result) => {
2295
+ const { media } = result;
2296
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
2297
+ import_components36.NavigationOption,
2298
+ {
2299
+ title: result.title,
2300
+ content: result.description,
2301
+ media: media ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(OptionMedia, { media, preferAvatar: false }) : void 0,
2302
+ showMediaCircle: false,
2303
+ showMediaAtAllSizes: true,
2304
+ onClick: () => {
2305
+ trackEvent("Search Result Selected", __spreadValues({
2306
+ type: result.type
2307
+ }, result.type === "action" ? { actionId: result.id } : {}));
2308
+ result.onClick();
2309
+ }
2310
+ },
2311
+ JSON.stringify(result)
2312
+ );
2313
+ }) });
2314
+ }
2315
+ var BlockSearchRendererComponent_default = BlockSearchRendererComponent;
2316
+
2317
+ // ../renderers/src/SearchRenderer/InlineSearchRendererComponent.tsx
2318
+ var import_components37 = require("@transferwise/components");
2319
+ var import_icons2 = require("@transferwise/icons");
2320
+ var import_react13 = require("react");
2321
+ var import_react_intl20 = require("react-intl");
2322
+ var import_jsx_runtime55 = require("react/jsx-runtime");
2323
+ function InlineSearchRenderer({
2324
+ id,
2325
+ isLoading,
2326
+ margin,
2327
+ onChange,
2328
+ state,
2329
+ title,
2330
+ trackEvent
2331
+ }) {
2332
+ const [hasSearched, setHasSearched] = (0, import_react13.useState)(false);
2333
+ const intl = (0, import_react_intl20.useIntl)();
2334
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: getMargin(margin), children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
2335
+ import_components37.Typeahead,
2336
+ {
2337
+ id: "typeahead-input-id",
2338
+ intl,
2339
+ name: "typeahead-input-name",
2340
+ size: "md",
2341
+ maxHeight: 100,
2342
+ footer: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(TypeaheadFooter, { state, isLoading }),
2343
+ multiple: false,
2344
+ clearable: false,
2345
+ addon: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_icons2.Search, { size: 24 }),
2346
+ options: state.type === "results" ? state.results.map(mapResultToTypeaheadOption) : [],
2347
+ minQueryLength: 1,
2348
+ onChange: (values) => {
2349
+ if (values.length > 0) {
2350
+ const [updatedValue] = values;
2351
+ const { value: result } = updatedValue;
2352
+ if (result) {
2353
+ trackEvent("Search Result Selected", __spreadValues({
2354
+ type: result.type
2355
+ }, result.type === "action" ? { actionId: result.id } : {}));
2356
+ result.onClick();
2357
+ }
2358
+ }
2359
+ },
2360
+ onInputChange: (query) => {
2361
+ if (!hasSearched) {
2362
+ setHasSearched(true);
2363
+ trackEvent("Search Started");
2364
+ }
2365
+ onChange(query);
2366
+ }
2367
+ }
2368
+ ) }) });
2369
+ }
2370
+ function mapResultToTypeaheadOption(result) {
2371
+ return {
2372
+ label: result.title,
2373
+ secondary: result.description,
2374
+ value: result,
2375
+ clearQueryOnSelect: result.type === "action",
2376
+ keepFocusOnSelect: result.type === "search"
2377
+ };
2378
+ }
2379
+ function TypeaheadFooter({ state, isLoading }) {
2380
+ const { formatMessage } = (0, import_react_intl20.useIntl)();
2381
+ if (state.type === "noResults") {
2382
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components37.Markdown, { className: "m-t-2 m-x-2", config: { link: { target: "_blank" } }, children: state.message });
2383
+ }
2384
+ if (state.type === "error") {
2385
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "m-t-2 m-x-2", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ErrorResult, { state }) });
2386
+ }
2387
+ if (state.type === "pending" || isLoading) {
2388
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "m-t-2 m-x-2", children: formatMessage(search_messages_default.loading) });
2389
+ }
2390
+ return null;
2391
+ }
2392
+ var InlineSearchRendererComponent_default = InlineSearchRenderer;
2393
+
2394
+ // ../renderers/src/SearchRenderer/SearchRenderer.tsx
2395
+ var import_jsx_runtime56 = require("react/jsx-runtime");
2396
+ var SearchRenderer = {
2397
+ canRenderType: "search",
2398
+ render: (props) => props.control === "inline" ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(InlineSearchRendererComponent_default, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(BlockSearchRendererComponent_default, __spreadValues({}, props))
2399
+ };
2400
+ var SearchRenderer_default = SearchRenderer;
2401
+
2402
+ // ../renderers/src/SectionRenderer.tsx
2403
+ var import_components38 = require("@transferwise/components");
2404
+
2405
+ // ../renderers/src/utils/getHeaderAction.tsx
2406
+ var getHeaderAction2 = (callToAction) => {
2407
+ if (!callToAction) {
2408
+ return void 0;
2409
+ }
2410
+ const { accessibilityDescription, href, title, onClick } = callToAction;
2411
+ return href ? {
2412
+ "aria-label": accessibilityDescription,
2413
+ text: title,
2414
+ href,
2415
+ target: "_blank"
2416
+ } : {
2417
+ "aria-label": accessibilityDescription,
2418
+ text: title,
2419
+ onClick: (event) => {
2420
+ event.preventDefault();
2421
+ onClick();
2422
+ }
2423
+ };
2424
+ };
2425
+
2426
+ // ../renderers/src/SectionRenderer.tsx
2427
+ var import_jsx_runtime57 = require("react/jsx-runtime");
2428
+ var SectionRenderer = {
2429
+ canRenderType: "section",
2430
+ render: ({ children, callToAction, margin, title }) => {
2431
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("section", { className: getMargin(margin), children: [
2432
+ (title || callToAction) && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components38.Header, { title: title != null ? title : "", action: getHeaderAction2(callToAction) }),
2433
+ children
2434
+ ] });
2435
+ }
2436
+ };
2437
+ var SectionRenderer_default = SectionRenderer;
2438
+
2439
+ // ../renderers/src/SelectInputRenderer/RadioInputRendererComponent.tsx
2440
+ var import_components39 = require("@transferwise/components");
2441
+ var import_jsx_runtime58 = require("react/jsx-runtime");
2442
+ function RadioInputRendererComponent(props) {
2443
+ const {
2444
+ id,
2445
+ children,
2446
+ description,
2447
+ disabled,
2448
+ help,
2449
+ title,
2450
+ options,
2451
+ selectedIndex,
2452
+ validationState,
2453
+ onSelect
2454
+ } = props;
2455
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
2456
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
2457
+ FieldInput_default,
2458
+ {
2459
+ id,
2460
+ label: title,
2461
+ help,
2462
+ description,
2463
+ validation: validationState,
2464
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
2465
+ import_components39.RadioGroup,
2466
+ {
2467
+ name: id,
2468
+ radios: options.map((option, index) => ({
2469
+ label: option.title,
2470
+ value: index,
2471
+ secondary: option.description,
2472
+ disabled: option.disabled || disabled,
2473
+ avatar: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(OptionMedia, { media: option.media, preferAvatar: false })
2474
+ })),
2475
+ selectedValue: selectedIndex != null ? selectedIndex : void 0,
2476
+ onChange: onSelect
2477
+ },
2478
+ `${id}-${selectedIndex}`
2479
+ ) })
2480
+ }
2481
+ ),
2482
+ children
2483
+ ] });
2484
+ }
2485
+
2486
+ // ../renderers/src/SelectInputRenderer/TabInputRendererComponent.tsx
2487
+ var import_components40 = require("@transferwise/components");
2488
+ var import_react14 = require("react");
2489
+ var import_jsx_runtime59 = require("react/jsx-runtime");
2490
+ function TabInputRendererComponent(props) {
2491
+ const {
2492
+ id,
2493
+ children,
2494
+ description,
2495
+ disabled,
2496
+ help,
2497
+ title,
2498
+ options,
2499
+ selectedIndex,
2500
+ validationState,
2501
+ onSelect
2502
+ } = props;
2503
+ (0, import_react14.useEffect)(() => {
2504
+ if (!isValidIndex(selectedIndex, options.length)) {
2505
+ onSelect(0);
2506
+ }
2507
+ }, [selectedIndex, onSelect, options.length]);
2508
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
2509
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
2510
+ FieldInput_default,
2511
+ {
2512
+ id,
2513
+ label: title,
2514
+ help,
2515
+ description,
2516
+ validation: validationState,
2517
+ children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
2518
+ import_components40.Tabs,
2519
+ {
2520
+ name: id,
2521
+ selected: selectedIndex != null ? selectedIndex : 0,
2522
+ tabs: options.map((option) => ({
2523
+ title: option.title,
2524
+ // if we pass null, we get some props-types console errors
2525
+ // eslint-disable-next-line react/jsx-no-useless-fragment
2526
+ content: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_jsx_runtime59.Fragment, {}),
2527
+ disabled: option.disabled || disabled
2528
+ })),
2529
+ onTabSelect: onSelect
2530
+ }
2531
+ )
2532
+ }
2533
+ ),
2534
+ children
2535
+ ] });
2536
+ }
2537
+ var isValidIndex = (index, options) => index !== null && index >= 0 && index < options;
2538
+
2539
+ // ../renderers/src/SelectInputRenderer/SelectInputRendererComponent.tsx
2540
+ var import_components41 = require("@transferwise/components");
2541
+ var import_jsx_runtime60 = require("react/jsx-runtime");
2542
+ function SelectInputRendererComponent(props) {
2543
+ const {
2544
+ id,
2545
+ autoComplete,
2546
+ children,
2547
+ description,
2548
+ disabled,
2549
+ help,
2550
+ title,
2551
+ options,
2552
+ placeholder,
2553
+ required,
2554
+ selectedIndex,
2555
+ validationState,
2556
+ onSelect
2557
+ } = props;
2558
+ const items = options.map(
2559
+ (option, index) => {
2560
+ var _a, _b, _c;
2561
+ return {
2562
+ type: "option",
2563
+ value: index,
2564
+ filterMatchers: [...(_a = option.keywords) != null ? _a : [], (_b = option.title) != null ? _b : "", (_c = option.description) != null ? _c : ""],
2565
+ disabled: option.disabled
2566
+ };
2567
+ }
2568
+ );
2569
+ const renderValue = (index, withinTrigger) => {
2570
+ const option = index >= 0 ? options[index] : null;
2571
+ if (option === null) {
2572
+ return null;
2573
+ }
2574
+ const contentProps = withinTrigger ? {
2575
+ title: option.title,
2576
+ note: option.description,
2577
+ icon: getInlineMedia(option.media)
2578
+ } : {
2579
+ title: option.title,
2580
+ description: option.description,
2581
+ icon: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(OptionMedia, { media: option.media, preferAvatar: false })
2582
+ };
2583
+ return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components41.SelectInputOptionContent, __spreadValues({}, contentProps));
2584
+ };
2585
+ const extraProps = { autoComplete };
2586
+ return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
2587
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
2588
+ FieldInput_default,
2589
+ {
2590
+ id,
2591
+ label: title,
2592
+ help,
2593
+ description,
2594
+ validation: validationState,
2595
+ children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
2596
+ import_components41.SelectInput,
2597
+ __spreadValues({
2598
+ name: id,
2599
+ placeholder,
2600
+ items,
2601
+ disabled,
2602
+ value: selectedIndex,
2603
+ renderValue,
2604
+ filterable: items.length >= 8,
2605
+ onChange: onSelect,
2606
+ onClear: required ? void 0 : () => onSelect(null)
2607
+ }, extraProps)
2608
+ )
2609
+ }
2610
+ ),
2611
+ children
2612
+ ] });
2613
+ }
2614
+
2615
+ // ../renderers/src/SelectInputRenderer/SegmentedInputRendererComponent.tsx
2616
+ var import_react15 = require("react");
2617
+ var import_components42 = require("@transferwise/components");
2618
+ var import_jsx_runtime61 = require("react/jsx-runtime");
2619
+ function SegmentedInputRendererComponent(props) {
2620
+ const {
2621
+ id,
2622
+ children,
2623
+ description,
2624
+ help,
2625
+ title,
2626
+ options,
2627
+ selectedIndex,
2628
+ validationState,
2629
+ onSelect
2630
+ } = props;
2631
+ (0, import_react15.useEffect)(() => {
2632
+ if (!isValidIndex2(selectedIndex, options.length)) {
2633
+ onSelect(0);
2634
+ }
2635
+ }, [selectedIndex, onSelect, options.length]);
2636
+ return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
2637
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
2638
+ FieldInput_default,
2639
+ {
2640
+ id,
2641
+ label: title,
2642
+ help,
2643
+ description,
2644
+ validation: validationState,
2645
+ children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
2646
+ import_components42.SegmentedControl,
2647
+ {
2648
+ name: `${id}-segmented-control`,
2649
+ value: String(selectedIndex),
2650
+ mode: "view",
2651
+ segments: options.map((option, index) => ({
2652
+ id: String(index),
2653
+ value: String(index),
2654
+ label: option.title,
2655
+ controls: `${id}-children`
2656
+ })),
2657
+ onChange: (value) => onSelect(Number(value))
2658
+ }
2659
+ )
2660
+ }
2661
+ ),
2662
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { id: `${id}-children`, children })
2663
+ ] });
2664
+ }
2665
+ var isValidIndex2 = (index, options) => index !== null && index >= 0 && index < options;
2666
+
2667
+ // ../renderers/src/SelectInputRenderer/SelectInputRenderer.tsx
2668
+ var import_jsx_runtime62 = require("react/jsx-runtime");
2669
+ var SelectInputRenderer = {
2670
+ canRenderType: "input-select",
2671
+ render: (props) => {
2672
+ switch (props.control) {
2673
+ case "radio":
2674
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(RadioInputRendererComponent, __spreadValues({}, props));
2675
+ case "tab":
2676
+ return props.options.length > 3 ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SelectInputRendererComponent, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(TabInputRendererComponent, __spreadValues({}, props));
2677
+ case "segmented":
2678
+ return props.options.length > 3 ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SelectInputRendererComponent, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SegmentedInputRendererComponent, __spreadValues({}, props));
2679
+ case "select":
2680
+ default:
2681
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SelectInputRendererComponent, __spreadValues({}, props));
2682
+ }
2683
+ }
2684
+ };
2685
+ var SelectInputRenderer_default = SelectInputRenderer;
2686
+
2687
+ // ../renderers/src/StatusListRenderer.tsx
2688
+ var import_components43 = require("@transferwise/components");
2689
+ var import_jsx_runtime63 = require("react/jsx-runtime");
2690
+ var StatusListRenderer = {
2691
+ canRenderType: "status-list",
2692
+ render: ({ margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: getMargin(margin), children: [
2693
+ title ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components43.Header, { title, className: "m-b-2" }) : null,
2694
+ items.map(({ callToAction, description, icon, status, title: itemTitle }) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
2695
+ import_components43.Summary,
2696
+ {
2697
+ title: itemTitle,
2698
+ description,
2699
+ icon: icon && "name" in icon ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DynamicIcon_default, { name: icon.name }) : null,
2700
+ status: mapStatus(status),
2701
+ action: getSummaryAction(callToAction)
2702
+ },
2703
+ `${itemTitle}/${description || ""}`
2704
+ ))
2705
+ ] })
2706
+ };
2707
+ var StatusListRenderer_default = StatusListRenderer;
2708
+ var getSummaryAction = (callToAction) => {
2709
+ if (!callToAction) {
2710
+ return void 0;
2711
+ }
2712
+ const { accessibilityDescription, href, title, onClick } = callToAction;
2713
+ if (!href) {
2714
+ return {
2715
+ "aria-label": accessibilityDescription,
2716
+ text: title,
2717
+ onClick
2718
+ };
2719
+ }
2720
+ return {
2721
+ "aria-label": accessibilityDescription,
2722
+ href,
2723
+ target: "_blank",
2724
+ text: title
2725
+ };
2726
+ };
2727
+ var mapStatus = (status) => {
2728
+ if (status === "not-done") {
2729
+ return "notDone";
2730
+ }
2731
+ return status;
2732
+ };
2733
+
2734
+ // ../renderers/src/utils/useCustomTheme.ts
2735
+ var import_components_theming = require("@wise/components-theming");
2736
+ var import_react16 = require("react");
2737
+ var ThemeRequiredEventName = "Theme Required";
2738
+ var useCustomTheme = (theme, trackEvent) => {
2739
+ const previousThemeHookValue = (0, import_components_theming.useTheme)();
2740
+ const previousTheme = (0, import_react16.useMemo)(() => previousThemeHookValue.theme, []);
2741
+ (0, import_react16.useEffect)(() => {
2742
+ trackEvent(ThemeRequiredEventName, { theme });
2743
+ return theme !== previousTheme ? () => {
2744
+ trackEvent(ThemeRequiredEventName, { theme: previousTheme });
2745
+ } : () => {
2746
+ };
2747
+ }, []);
2748
+ };
2749
+
2750
+ // ../renderers/src/step/topbar/BackButton.tsx
2751
+ var import_components44 = require("@transferwise/components");
2752
+ var import_icons3 = require("@transferwise/icons");
2753
+ var import_jsx_runtime64 = require("react/jsx-runtime");
2754
+ function BackButton({ title, onClick }) {
2755
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_components44.IconButton, { priority: "tertiary", onClick, children: [
2756
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "sr-only", children: title }),
2757
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_icons3.ArrowLeft, {})
2758
+ ] });
2759
+ }
2760
+
2761
+ // ../renderers/src/step/topbar/Toolbar.tsx
2762
+ var import_components45 = require("@transferwise/components");
2763
+ var import_jsx_runtime65 = require("react/jsx-runtime");
2764
+ var Toolbar = ({ items }) => {
2765
+ return (items == null ? void 0 : items.length) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "df-toolbar", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ToolbarButton, __spreadValues({}, item), `${item.type}-${index}-${item.title}`)) }) : null;
2766
+ };
2767
+ function ToolbarButton(props) {
2768
+ return prefersMedia(props.control) ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(MediaToolbarButton, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(TextToolbarButton, __spreadValues({}, props));
2769
+ }
2770
+ function MediaToolbarButton(props) {
2771
+ var _a;
2772
+ const { context, control, media, accessibilityDescription, disabled, onClick } = props;
2773
+ const priority = getIconButtonPriority(control);
2774
+ const type = getSentiment(context);
2775
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
2776
+ import_components45.IconButton,
2777
+ {
2778
+ className: "df-toolbar-button",
2779
+ disabled,
2780
+ priority,
2781
+ size: 32,
2782
+ type,
2783
+ onClick,
2784
+ children: [
2785
+ accessibilityDescription ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "sr-only", children: accessibilityDescription }) : null,
2786
+ media ? (_a = getAddonStart(media)) == null ? void 0 : _a.value : null
2787
+ ]
2788
+ }
2789
+ );
2790
+ }
2791
+ function TextToolbarButton(props) {
2792
+ const { context, control, title, media, disabled, onClick } = props;
2793
+ const addonStart = media ? getAddonStart(media) : void 0;
2794
+ const priority = getPriority2(control);
2795
+ const sentiment = getSentiment(context);
2796
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
2797
+ import_components45.Button,
2798
+ {
2799
+ v2: true,
2800
+ size: "sm",
2801
+ className: "df-toolbar-button",
2802
+ disabled,
2803
+ priority,
2804
+ addonStart,
2805
+ sentiment,
2806
+ onClick,
2807
+ children: title
2808
+ }
2809
+ );
2810
+ }
2811
+ var getAddonStart = (media) => {
2812
+ if (media.type === "avatar") {
2813
+ if (media.content.length > 0 && media.content[0].type === "uri" && isValidIconUrn(media.content[0].uri)) {
2814
+ return {
2815
+ type: "icon",
2816
+ value: getInlineMedia({
2817
+ type: "image",
2818
+ uri: media.content[0].uri
2819
+ })
2820
+ };
2821
+ }
2822
+ return void 0;
2823
+ }
2824
+ return { type: "icon", value: getInlineMedia(media) };
2825
+ };
2826
+ var getPriority2 = (control) => isKnownControl(control) ? control : "secondary";
2827
+ var prefersMedia = (control) => {
2828
+ return false;
2829
+ };
2830
+ var knownControls = ["primary", "secondary", "secondary-neutral"];
2831
+ var isKnownControl = (control) => control !== void 0 && knownControls.includes(control);
2832
+ var getSentiment = (context) => {
2833
+ return "default";
2834
+ };
2835
+ var getIconButtonPriority = (control) => {
2836
+ const priority = getPriority2(control);
2837
+ return priority === "secondary-neutral" ? "tertiary" : priority;
2838
+ };
2839
+
2840
+ // ../renderers/src/step/topbar/TopBar.tsx
2841
+ var import_jsx_runtime66 = require("react/jsx-runtime");
2842
+ function TopBar({ back, toolbar }) {
2843
+ return back || toolbar ? /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "d-flex m-b-2", children: [
2844
+ back ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(BackButton, __spreadValues({}, back)) : null,
2845
+ toolbar ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Toolbar, __spreadValues({}, toolbar)) : null
2846
+ ] }) : null;
2847
+ }
2848
+
2849
+ // ../renderers/src/step/SplashCelebrationStepRenderer.tsx
2850
+ var import_jsx_runtime67 = require("react/jsx-runtime");
2851
+ var SplashCelebrationStepRenderer = {
2852
+ canRenderType: "step",
2853
+ canRender: ({ control }) => control === "splash-celebration",
2854
+ render: SplashCelebrationStepRendererComponent
2855
+ };
2856
+ function SplashCelebrationStepRendererComponent(props) {
2857
+ const { back, toolbar, children, trackEvent } = props;
2858
+ useCustomTheme("forest-green", trackEvent);
2859
+ return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "splash-screen m-t-5", children: [
2860
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(TopBar, { back, toolbar }),
2861
+ children
2862
+ ] });
2863
+ }
2864
+
2865
+ // ../renderers/src/step/SplashStepRenderer.tsx
2866
+ var import_jsx_runtime68 = require("react/jsx-runtime");
2867
+ var SplashStepRenderer = {
2868
+ canRenderType: "step",
2869
+ canRender: ({ control }) => control === "splash",
2870
+ render: SplashStepRendererComponent
2871
+ };
2872
+ function SplashStepRendererComponent(props) {
2873
+ const { back, toolbar, children } = props;
2874
+ return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "splash-screen m-t-5", children: [
2875
+ /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(TopBar, { back, toolbar }),
2876
+ children
2877
+ ] });
2878
+ }
2879
+
2880
+ // ../renderers/src/step/StepRenderer.tsx
2881
+ var import_components46 = require("@transferwise/components");
2882
+ var import_jsx_runtime69 = require("react/jsx-runtime");
2883
+ var StepRenderer = {
2884
+ canRenderType: "step",
2885
+ render: StepRendererComponent
2886
+ };
2887
+ function StepRendererComponent(props) {
2888
+ const { back, description, error, title, children, toolbar } = props;
2889
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
2890
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(TopBar, { back, toolbar }),
2891
+ title || description ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "m-b-4", children: [
2892
+ title ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components46.Title, { as: "h1", type: "title-section", className: "text-xs-center m-b-2", children: title }) : void 0,
2893
+ description ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { className: "text-xs-center np-text-body-large", children: description }) : void 0
2894
+ ] }) : void 0,
2895
+ error ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components46.Alert, { type: "negative", className: "m-b-2", message: error }) : void 0,
2896
+ children
2897
+ ] });
2898
+ }
2899
+
2900
+ // ../renderers/src/TabsRenderer.tsx
2901
+ var import_components47 = require("@transferwise/components");
2902
+ var import_react17 = require("react");
2903
+ var import_jsx_runtime70 = require("react/jsx-runtime");
2904
+ var TabsRenderer = {
2905
+ canRenderType: "tabs",
2906
+ render: (props) => {
2907
+ switch (props.control) {
2908
+ case "segmented":
2909
+ if (props.tabs.length > 3) {
2910
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(TabsRendererComponent, __spreadValues({}, props));
2911
+ }
2912
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SegmentedTabsRendererComponent, __spreadValues({}, props));
2913
+ case "chips":
2914
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChipsTabsRendererComponent, __spreadValues({}, props));
2915
+ default:
2916
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(TabsRendererComponent, __spreadValues({}, props));
2917
+ }
2918
+ }
2919
+ };
2920
+ function TabsRendererComponent({ uid, margin, tabs }) {
2921
+ const [selectedIndex, setSelectedIndex] = (0, import_react17.useState)(0);
2922
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: getMargin(margin), children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
2923
+ import_components47.Tabs,
2924
+ {
2925
+ name: uid,
2926
+ selected: selectedIndex != null ? selectedIndex : 0,
2927
+ tabs: tabs.map((option) => ({
2928
+ title: option.title,
2929
+ disabled: false,
2930
+ content: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "m-t-2", children: [
2931
+ " ",
2932
+ option.children,
2933
+ " "
2934
+ ] })
2935
+ })),
2936
+ onTabSelect: setSelectedIndex
2937
+ }
2938
+ ) });
2939
+ }
2940
+ function SegmentedTabsRendererComponent({ uid, margin, tabs }) {
2941
+ var _a;
2942
+ const [selectedIndex, setSelectedIndex] = (0, import_react17.useState)(0);
2943
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: getMargin(margin), children: [
2944
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
2945
+ import_components47.SegmentedControl,
2946
+ {
2947
+ name: uid,
2948
+ value: String(selectedIndex),
2949
+ mode: "view",
2950
+ segments: tabs.map((tab, index) => ({
2951
+ id: String(index),
2952
+ value: String(index),
2953
+ label: tab.title,
2954
+ controls: `${uid}-children`
2955
+ })),
2956
+ onChange: (value) => setSelectedIndex(Number(value))
2957
+ }
2958
+ ),
2959
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { id: `${uid}-children`, className: "m-t-2", children: (_a = tabs[selectedIndex]) == null ? void 0 : _a.children })
2960
+ ] });
2961
+ }
2962
+ function ChipsTabsRendererComponent({ margin, tabs }) {
2963
+ var _a;
2964
+ const [selectedIndex, setSelectedIndex] = (0, import_react17.useState)(0);
2965
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: getMargin(margin), children: [
2966
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "chips-container", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
2967
+ import_components47.Chips,
2968
+ {
2969
+ chips: tabs.map((tab, index) => ({ label: tab.title, value: index })),
2970
+ selected: selectedIndex,
2971
+ onChange: ({ selectedValue }) => setSelectedIndex(Number(selectedValue))
2972
+ }
2973
+ ) }),
2974
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "m-t-2", children: (_a = tabs[selectedIndex]) == null ? void 0 : _a.children })
2975
+ ] });
2976
+ }
2977
+
2978
+ // ../renderers/src/TextInputRenderer.tsx
2979
+ var import_components49 = require("@transferwise/components");
2980
+
2981
+ // ../renderers/src/components/VariableTextInput.tsx
2982
+ var import_components48 = require("@transferwise/components");
2983
+ var import_jsx_runtime71 = require("react/jsx-runtime");
2984
+ var commonKeys = [
2985
+ "autoComplete",
2986
+ "autoCapitalize",
2987
+ "placeholder",
2988
+ "control",
2989
+ "disabled",
2990
+ "displayFormat",
2991
+ "id",
2992
+ "onBlur",
2993
+ "onFocus",
2994
+ "placeholder",
2995
+ "value"
2996
+ ];
2997
+ function VariableTextInput(inputProps) {
2998
+ const { id, value, control, onChange } = inputProps;
2999
+ const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
3000
+ switch (control) {
3001
+ case "email":
3002
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "email", onChange }));
3003
+ case "password":
3004
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "password", onChange }));
3005
+ case "numeric": {
3006
+ const numericProps = __spreadProps(__spreadValues({}, commonProps), { type: "number", onWheel });
3007
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
3008
+ TextInput,
3009
+ __spreadProps(__spreadValues({}, numericProps), {
3010
+ onChange: (newValue) => {
3011
+ const numericValueOrNull = !Number.isNaN(Number.parseFloat(newValue)) ? newValue : null;
3012
+ onChange(numericValueOrNull);
3013
+ }
3014
+ })
3015
+ );
3016
+ }
3017
+ case "phone-number":
3018
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components48.PhoneNumberInput, __spreadProps(__spreadValues({ initialValue: value }, commonProps), { onChange }));
3019
+ default: {
3020
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "text", onChange }));
3021
+ }
3022
+ }
3023
+ }
3024
+ function TextInput(props) {
3025
+ const _a = props, { control, displayFormat, onChange } = _a, commonProps = __objRest(_a, ["control", "displayFormat", "onChange"]);
3026
+ const InputWithPattern = control === "textarea" ? import_components48.TextareaWithDisplayFormat : import_components48.InputWithDisplayFormat;
3027
+ const InputWithoutPattern = control === "textarea" ? import_components48.TextArea : import_components48.Input;
3028
+ return displayFormat ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), { onChange: (e) => onChange(e.target.value) }));
3029
+ }
3030
+
3031
+ // ../renderers/src/TextInputRenderer.tsx
3032
+ var import_jsx_runtime72 = require("react/jsx-runtime");
3033
+ var TextInputRenderer = {
3034
+ canRenderType: "input-text",
3035
+ render: (props) => {
3036
+ const _a = props, {
3037
+ id,
3038
+ title,
3039
+ description,
3040
+ help,
3041
+ media,
3042
+ validationState,
3043
+ value: initialValue,
3044
+ onChange
3045
+ } = _a, rest = __objRest(_a, [
3046
+ "id",
3047
+ "title",
3048
+ "description",
3049
+ "help",
3050
+ "media",
3051
+ "validationState",
3052
+ "value",
3053
+ "onChange"
3054
+ ]);
3055
+ const value = initialValue != null ? initialValue : "";
3056
+ const inputProps = __spreadProps(__spreadValues({}, rest), {
3057
+ value,
3058
+ id,
3059
+ onChange: (newValue) => {
3060
+ if ((value != null ? value : "") !== (newValue != null ? newValue : "")) {
3061
+ onChange(newValue);
3062
+ }
3063
+ }
3064
+ });
3065
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
3066
+ FieldInput_default,
3067
+ {
3068
+ id,
3069
+ label: title,
3070
+ description,
3071
+ validation: validationState,
3072
+ help,
3073
+ children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components49.InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(VariableTextInput, __spreadValues({}, inputProps)) })
3074
+ }
3075
+ );
3076
+ }
3077
+ };
3078
+ var TextInputRenderer_default = TextInputRenderer;
3079
+
3080
+ // ../renderers/src/UploadInputRenderer.tsx
3081
+ var import_components50 = require("@transferwise/components");
3082
+
3083
+ // ../renderers/src/utils/getRandomId.ts
3084
+ var getRandomId = () => Math.random().toString(36).substring(2);
3085
+
3086
+ // ../renderers/src/UploadInputRenderer.tsx
3087
+ var import_jsx_runtime73 = require("react/jsx-runtime");
3088
+ var UploadInputRenderer = {
3089
+ canRenderType: "input-upload",
3090
+ render: (props) => {
3091
+ const { id, accepts, title, description, disabled, maxSize, validationState, onUpload } = props;
3092
+ const onUploadFile = async (formData) => {
3093
+ const file = formData.get("file");
3094
+ return onUpload(file).then(() => ({
3095
+ id: getRandomId()
3096
+ }));
3097
+ };
3098
+ const onDeleteFile = async () => {
3099
+ await onUpload(null);
3100
+ };
3101
+ return (
3102
+ // We don't pass help here as there is no sensible place to display it
3103
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
3104
+ UploadFieldInput_default,
3105
+ {
3106
+ id,
3107
+ label: void 0,
3108
+ description: void 0,
3109
+ validation: validationState,
3110
+ children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
3111
+ import_components50.UploadInput,
3112
+ {
3113
+ id,
3114
+ description,
3115
+ disabled,
3116
+ sizeLimit: getSizeLimit(maxSize),
3117
+ fileTypes: acceptsToFileTypes(accepts),
3118
+ uploadButtonTitle: title,
3119
+ onDeleteFile,
3120
+ onUploadFile
3121
+ }
3122
+ )
3123
+ }
3124
+ )
3125
+ );
3126
+ }
3127
+ };
3128
+ var LargeUploadRenderer = {
3129
+ canRenderType: "input-upload",
3130
+ canRender: (props) => props.control === "upload-large",
3131
+ render: (props) => {
3132
+ const _a = props, {
3133
+ id,
3134
+ accepts,
3135
+ control,
3136
+ title,
3137
+ description,
3138
+ disabled,
3139
+ help,
3140
+ type,
3141
+ validationState,
3142
+ maxSize = null,
3143
+ onUpload
3144
+ } = _a, rest = __objRest(_a, [
3145
+ "id",
3146
+ "accepts",
3147
+ "control",
3148
+ "title",
3149
+ "description",
3150
+ "disabled",
3151
+ "help",
3152
+ "type",
3153
+ "validationState",
3154
+ "maxSize",
3155
+ "onUpload"
3156
+ ]);
3157
+ const uploadProps = __spreadProps(__spreadValues({}, rest), { id, name: id, maxSize });
3158
+ const onUploadFile = async (file, fileName) => {
3159
+ try {
3160
+ const convertedFile = file ? await toFile(file, fileName) : null;
3161
+ await onUpload(convertedFile);
3162
+ } catch (e) {
3163
+ await onUpload(null);
3164
+ throw e;
3165
+ }
3166
+ };
3167
+ const filetypes = acceptsToFileTypes(accepts);
3168
+ const usAccept = filetypes === "*" ? "*" : filetypes.join(",");
3169
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
3170
+ FieldInput_default,
3171
+ {
3172
+ id,
3173
+ label: title,
3174
+ description,
3175
+ validation: validationState,
3176
+ help,
3177
+ children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
3178
+ import_components50.Upload,
3179
+ __spreadProps(__spreadValues({}, uploadProps), {
3180
+ usAccept,
3181
+ usDisabled: disabled,
3182
+ onSuccess: onUploadFile,
3183
+ onFailure: async () => onUpload(null),
3184
+ onCancel: async () => onUpload(null)
3185
+ })
3186
+ )
3187
+ }
3188
+ );
3189
+ }
3190
+ };
3191
+
3192
+ // ../renderers/src/NewListItem/NewDecisionRenderer.tsx
3193
+ var import_components53 = require("@transferwise/components");
3194
+
3195
+ // ../renderers/src/NewListItem/getInlineAlert.tsx
3196
+ var import_components51 = require("@transferwise/components");
3197
+ var import_jsx_runtime74 = require("react/jsx-runtime");
3198
+ var getInlineAlert = (inlineAlert) => inlineAlert ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components51.ListItem.Prompt, { sentiment: inlineAlert == null ? void 0 : inlineAlert.context, children: inlineAlert.content }) : void 0;
3199
+
3200
+ // ../renderers/src/NewListItem/getAdditionalInfo.tsx
3201
+ var import_components52 = require("@transferwise/components");
3202
+ var import_jsx_runtime75 = require("react/jsx-runtime");
3203
+ var getAdditionalInfo = (additionalInfo) => {
3204
+ if (!additionalInfo) {
3205
+ return void 0;
3206
+ }
3207
+ const { href, text, onClick } = additionalInfo;
3208
+ if (href || onClick) {
3209
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
3210
+ import_components52.ListItem.AdditionalInfo,
3211
+ {
3212
+ action: {
3213
+ label: text,
3214
+ href,
3215
+ onClick,
3216
+ target: "_blank"
3217
+ }
3218
+ }
3219
+ );
3220
+ }
3221
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components52.ListItem.AdditionalInfo, { children: additionalInfo == null ? void 0 : additionalInfo.text });
3222
+ };
3223
+
3224
+ // ../renderers/src/NewListItem/NewDecisionRenderer.tsx
3225
+ var import_jsx_runtime76 = require("react/jsx-runtime");
3226
+ var DecisionRenderer2 = {
3227
+ canRenderType: "decision",
3228
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(DecisionWrapper, __spreadProps(__spreadValues({}, props), { renderDecisionList: renderDecisionList2 }))
3229
+ };
3230
+ var renderDecisionList2 = ({ options, control }) => {
3231
+ return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_jsx_runtime76.Fragment, { children: options.map((option) => {
3232
+ const {
3233
+ description,
3234
+ disabled,
3235
+ media,
3236
+ title: itemTitle,
3237
+ tag,
3238
+ href,
3239
+ additionalText,
3240
+ inlineAlert,
3241
+ supportingValues,
3242
+ onClick
3243
+ } = option;
3244
+ return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
3245
+ import_components53.ListItem,
3246
+ {
3247
+ title: itemTitle,
3248
+ subtitle: description,
3249
+ spotlight: control === "spotlight" ? tag === "spotlight-active" ? "active" : "inactive" : void 0,
3250
+ disabled,
3251
+ valueTitle: supportingValues == null ? void 0 : supportingValues.value,
3252
+ valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
3253
+ media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
3254
+ prompt: getInlineAlert(inlineAlert),
3255
+ additionalInfo: additionalText ? getAdditionalInfo({ text: additionalText }) : void 0,
3256
+ control: href ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components53.ListItem.Navigation, { href, target: "_blank" }) : /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components53.ListItem.Navigation, { onClick })
3257
+ },
3258
+ JSON.stringify(option)
3259
+ );
3260
+ }) });
3261
+ };
3262
+ var NewDecisionRenderer_default = DecisionRenderer2;
3263
+
3264
+ // ../renderers/src/NewListItem/NewListRenderer.tsx
3265
+ var import_components54 = require("@transferwise/components");
3266
+ var import_jsx_runtime77 = require("react/jsx-runtime");
3267
+ var ListRenderer2 = {
3268
+ canRenderType: "list",
3269
+ render: ({ callToAction, control, margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: getMargin(margin), children: [
3270
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Header7, { title, callToAction }),
3271
+ items.map((item) => {
3272
+ const {
3273
+ title: itemTitle,
3274
+ description,
3275
+ supportingValues,
3276
+ media,
3277
+ tag,
3278
+ additionalInfo,
3279
+ inlineAlert
3280
+ } = item;
3281
+ return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
3282
+ import_components54.ListItem,
3283
+ {
3284
+ title: itemTitle,
3285
+ subtitle: description,
3286
+ valueTitle: supportingValues == null ? void 0 : supportingValues.value,
3287
+ valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
3288
+ media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
3289
+ prompt: getInlineAlert(inlineAlert),
3290
+ additionalInfo: getAdditionalInfo(additionalInfo)
3291
+ },
3292
+ itemTitle
3293
+ );
3294
+ })
3295
+ ] })
3296
+ };
3297
+ var NewListRenderer_default = ListRenderer2;
3298
+
3299
+ // ../renderers/src/NewListItem/NewReviewRenderer.tsx
3300
+ var import_components55 = require("@transferwise/components");
3301
+ var import_icons4 = require("@transferwise/icons");
3302
+ var import_jsx_runtime78 = require("react/jsx-runtime");
3303
+ var IGNORED_CONTROLS = [
3304
+ "horizontal",
3305
+ "horizontal-end-aligned",
3306
+ "horizontal-start-aligned",
3307
+ "vertical-two-column"
3308
+ ];
3309
+ var ReviewRenderer2 = {
3310
+ canRenderType: "review",
3311
+ canRender: ({ control }) => control ? !IGNORED_CONTROLS.includes(control) : true,
3312
+ render: ({ callToAction, control, margin, fields, title }) => /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: getMargin(margin), children: [
3313
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Header7, { title, callToAction }),
3314
+ fields.map((field) => {
3315
+ var _a;
3316
+ const {
3317
+ label,
3318
+ value,
3319
+ media,
3320
+ tag,
3321
+ additionalInfo,
3322
+ inlineAlert,
3323
+ help,
3324
+ callToAction: itemCallToAction
3325
+ } = field;
3326
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
3327
+ import_components55.ListItem,
3328
+ {
3329
+ title: value,
3330
+ subtitle: label,
3331
+ inverted: true,
3332
+ media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
3333
+ control: (_a = getCTAControl(itemCallToAction)) != null ? _a : getHelpControl(help),
3334
+ prompt: getInlineAlert(inlineAlert),
3335
+ additionalInfo: getAdditionalInfo(additionalInfo)
3336
+ },
3337
+ JSON.stringify(field)
3338
+ );
3339
+ })
3340
+ ] })
3341
+ };
3342
+ var getCTAControl = (callToAction) => {
3343
+ if (!callToAction) {
3344
+ return void 0;
3345
+ }
3346
+ const { accessibilityDescription, href, title, onClick } = callToAction;
3347
+ if (href) {
3348
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components55.ListItem.Button, { href, partiallyInteractive: true, "aria-description": accessibilityDescription, children: title });
3349
+ }
3350
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
3351
+ import_components55.ListItem.Button,
3352
+ {
3353
+ "aria-description": accessibilityDescription,
3354
+ partiallyInteractive: true,
3355
+ onClick,
3356
+ children: title
3357
+ }
3358
+ );
3359
+ };
3360
+ var getHelpControl = (help) => {
3361
+ if (!help) {
3362
+ return void 0;
3363
+ }
3364
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components55.Popover, { content: help, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components55.ListItem.IconButton, { partiallyInteractive: true, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_icons4.QuestionMarkCircle, {}) }) });
3365
+ };
3366
+ var NewReviewRenderer_default = ReviewRenderer2;
3367
+
3368
+ // ../renderers/src/NewListItem/NewStatusListRenderer.tsx
3369
+ var import_components56 = require("@transferwise/components");
3370
+ var import_jsx_runtime79 = require("react/jsx-runtime");
3371
+ var NewStatusListRenderer = {
3372
+ canRenderType: "status-list",
3373
+ render: ({ margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: getMargin(margin), children: [
3374
+ title ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components56.Header, { title, className: "m-b-2" }) : null,
3375
+ items.map((item) => {
3376
+ const { callToAction, description, icon, status, title: itemTitle } = item;
3377
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
3378
+ import_components56.ListItem,
3379
+ {
3380
+ title: itemTitle,
3381
+ subtitle: description,
3382
+ media: icon && "name" in icon ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components56.AvatarView, { badge: { status: mapStatus2(status) }, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(DynamicIcon_default, { name: icon.name }) }) : void 0,
3383
+ additionalInfo: callToAction ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
3384
+ import_components56.ListItem.AdditionalInfo,
3385
+ {
3386
+ action: {
3387
+ href: callToAction.href,
3388
+ onClick: callToAction.href ? void 0 : callToAction.onClick,
3389
+ label: callToAction.title,
3390
+ target: "_blank"
3391
+ }
3392
+ }
3393
+ ) : void 0
3394
+ },
3395
+ JSON.stringify(item)
3396
+ );
3397
+ })
3398
+ ] })
3399
+ };
3400
+ var mapStatus2 = (status) => {
3401
+ switch (status) {
3402
+ case "done":
3403
+ return "positive";
3404
+ case "pending":
3405
+ return "pending";
3406
+ default:
3407
+ return void 0;
3408
+ }
3409
+ };
3410
+ var NewStatusListRenderer_default = NewStatusListRenderer;
3411
+
3412
+ // ../renderers/src/ButtonRenderer/ButtonRendererV2.tsx
3413
+ var import_components57 = require("@transferwise/components");
3414
+
3415
+ // ../renderers/src/utils/isButtonPriority.ts
3416
+ var validPriorities = ["primary", "secondary", "secondary-neutral", "tertiary"];
3417
+ var isButtonPriority = (control) => validPriorities.includes(control);
3418
+
3419
+ // ../renderers/src/ButtonRenderer/ButtonRendererV2.tsx
3420
+ var import_react18 = require("react");
3421
+ var import_jsx_runtime80 = require("react/jsx-runtime");
3422
+ var ButtonRendererV2 = {
3423
+ canRenderType: "button",
3424
+ render: ButtonComponent2
3425
+ };
3426
+ function ButtonComponent2(props) {
3427
+ const { control, context, disabled, margin, title, size, stepLoadingState, onClick } = props;
3428
+ const [spinny, setSpinny] = (0, import_react18.useState)(false);
3429
+ (0, import_react18.useEffect)(() => {
3430
+ if (stepLoadingState === "idle") {
3431
+ setSpinny(false);
3432
+ }
3433
+ }, [stepLoadingState]);
3434
+ const loading = spinny && stepLoadingState !== "idle";
3435
+ return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
3436
+ import_components57.Button,
3437
+ {
3438
+ v2: true,
3439
+ block: true,
3440
+ className: getMargin(margin),
3441
+ disabled,
3442
+ priority: getPriority3(control),
3443
+ loading,
3444
+ size: mapButtonSize(size),
3445
+ sentiment: getSentiment2(context),
3446
+ onClick: () => {
3447
+ setSpinny(true);
3448
+ onClick();
3449
+ },
3450
+ children: title
3451
+ }
3452
+ );
3453
+ }
3454
+ var getSentiment2 = (context) => context === "negative" ? "negative" : "default";
3455
+ var getPriority3 = (control) => control && isButtonPriority(control) ? control : "secondary";
3456
+
3457
+ // ../renderers/src/ProgressRenderer.tsx
3458
+ var import_components58 = require("@transferwise/components");
3459
+ var import_jsx_runtime81 = require("react/jsx-runtime");
3460
+ var ProgressRenderer = {
3461
+ canRenderType: "progress",
3462
+ render: ({ uid, title, help, progress, progressText, margin, description }) => {
3463
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
3464
+ import_components58.ProgressBar,
3465
+ {
3466
+ id: uid,
3467
+ className: getMargin(margin),
3468
+ title: title && help ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(LabelContentWithHelp, { text: title, help }) : title,
3469
+ description,
3470
+ progress: {
3471
+ max: 1,
3472
+ value: progress
3473
+ },
3474
+ textEnd: progressText
3475
+ }
3476
+ );
3477
+ }
3478
+ };
3479
+
3480
+ // ../renderers/src/getWiseRenderers.ts
3481
+ var getListItemRenderers = () => [
3482
+ NewDecisionRenderer_default,
3483
+ NewListRenderer_default,
3484
+ NewReviewRenderer_default,
3485
+ NewStatusListRenderer_default
3486
+ ];
3487
+ var getButtonV2Renderers = () => [ButtonRendererV2];
3488
+ var getWiseRenderers = () => [
3489
+ AddressValidationButtonRenderer_default,
3490
+ AlertRenderer_default,
3491
+ CheckboxInputRenderer_default,
3492
+ BoxRenderer_default,
3493
+ ButtonRenderer,
3494
+ ColumnsRenderer_default,
3495
+ DateInputRenderer_default,
3496
+ DecisionRenderer_default,
3497
+ DividerRenderer_default,
3498
+ ExternalConfirmationRenderer_default,
3499
+ FormRenderer_default,
3500
+ FormSectionRenderer_default,
3501
+ HeadingRenderer_default,
3502
+ ImageRenderer_default,
3503
+ InstructionsRenderer_default,
3504
+ IntegerInputRenderer_default,
3505
+ LargeUploadRenderer,
3506
+ ListRenderer_default,
3507
+ LoadingIndicatorRenderer_default,
3508
+ MarkdownRenderer_default,
3509
+ ModalRenderer,
3510
+ ModalLayoutRenderer_default,
3511
+ MultiSelectInputRenderer_default,
3512
+ MultiUploadInputRenderer_default,
3513
+ NumberInputRenderer_default,
3514
+ ParagraphRenderer_default,
3515
+ ProgressRenderer,
3516
+ RepeatableRenderer_default,
3517
+ ReviewRenderer_default,
3518
+ SearchRenderer_default,
3519
+ SelectInputRenderer_default,
3520
+ SectionRenderer_default,
3521
+ StatusListRenderer_default,
3522
+ TabsRenderer,
3523
+ TextInputRenderer_default,
3524
+ UploadInputRenderer,
3525
+ SplashStepRenderer,
3526
+ SplashCelebrationStepRenderer,
3527
+ StepRenderer
3528
+ ];
3529
+
3530
+ // src/dynamicFlow/renderers.ts
3531
+ var Header11 = Header7;
3532
+ var Media2 = Media;
3533
+ var getMargin2 = getMargin;
3534
+ var getListItemRenderers2 = getListItemRenderers;
3535
+ var getButtonV2Renderers2 = getButtonV2Renderers;
57
3536
 
58
3537
  // src/i18n/index.ts
59
3538
  var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
@@ -900,10 +4379,9 @@ var translations = languages.reduce(
900
4379
  var i18n_default = translations;
901
4380
 
902
4381
  // src/dynamicFlow/DynamicFlow.tsx
903
- var import_react = require("react");
904
- var import_react_intl2 = require("react-intl");
4382
+ var import_react19 = require("react");
4383
+ var import_react_intl22 = require("react-intl");
905
4384
  var import_dynamic_flow_client2 = require("@wise/dynamic-flow-client");
906
- var import_dynamic_flow_renderers2 = require("@wise/dynamic-flow-renderers");
907
4385
 
908
4386
  // src/dynamicFlow/telemetry/app-version.ts
909
4387
  var appVersion = (
@@ -934,13 +4412,12 @@ var logToRollbar = (level, message, extra) => {
934
4412
  };
935
4413
 
936
4414
  // src/dynamicFlow/telemetry/getTrackEvent.ts
937
- var import_components_theming = require("@wise/components-theming");
938
- var import_dynamic_flow_renderers = require("@wise/dynamic-flow-renderers");
4415
+ var import_components_theming2 = require("@wise/components-theming");
939
4416
  var getTrackEvent = (onEvent, onAnalytics, onThemeChange) => (name, properties) => {
940
4417
  onEvent == null ? void 0 : onEvent(name, properties);
941
- if (name.includes(import_dynamic_flow_renderers.ThemeRequiredEventName)) {
4418
+ if (name.includes(ThemeRequiredEventName)) {
942
4419
  const { theme } = properties != null ? properties : { theme: "personal" };
943
- if (theme && (0, import_components_theming.isThemeModern)(theme)) {
4420
+ if (theme && (0, import_components_theming2.isThemeModern)(theme)) {
944
4421
  onThemeChange == null ? void 0 : onThemeChange(theme);
945
4422
  }
946
4423
  } else {
@@ -949,8 +4426,8 @@ var getTrackEvent = (onEvent, onAnalytics, onThemeChange) => (name, properties)
949
4426
  };
950
4427
 
951
4428
  // src/dynamicFlow/messages.ts
952
- var import_react_intl = require("react-intl");
953
- var messages_default = (0, import_react_intl.defineMessages)({
4429
+ var import_react_intl21 = require("react-intl");
4430
+ var messages_default = (0, import_react_intl21.defineMessages)({
954
4431
  copied: {
955
4432
  id: "df.wise.CopyFeedback.copy",
956
4433
  defaultMessage: "Copied to clipboard",
@@ -964,12 +4441,12 @@ var messages_default = (0, import_react_intl.defineMessages)({
964
4441
  });
965
4442
 
966
4443
  // src/dynamicFlow/DynamicFlow.tsx
967
- var import_jsx_runtime = require("react/jsx-runtime");
968
- var wiseRenderers = (0, import_dynamic_flow_renderers2.getWiseRenderers)();
4444
+ var import_jsx_runtime82 = require("react/jsx-runtime");
4445
+ var wiseRenderers = getWiseRenderers();
969
4446
  function DynamicFlowLegacy(props) {
970
4447
  const { customFetch = globalThis.fetch } = props;
971
4448
  const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
972
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client2.DynamicFlow, __spreadValues({}, coreProps));
4449
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client2.DynamicFlow, __spreadValues({}, coreProps));
973
4450
  }
974
4451
  function DynamicFlowRevamp(props) {
975
4452
  const {
@@ -982,12 +4459,12 @@ function DynamicFlowRevamp(props) {
982
4459
  onLink = openLinkInNewTab,
983
4460
  onThemeChange
984
4461
  } = props;
985
- const { formatMessage } = (0, import_react_intl2.useIntl)();
986
- const createSnackBar = (0, import_dynamic_flow_renderers2.useSnackBarIfAvailable)();
4462
+ const { formatMessage } = (0, import_react_intl22.useIntl)();
4463
+ const createSnackBar = useSnackBarIfAvailable();
987
4464
  const httpClient = useWiseHttpClient(customFetch);
988
- const mergedRenderers = (0, import_react.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
989
- const logEvent = (0, import_react.useMemo)(() => getLogEvent(onLog), [onLog]);
990
- const trackEvent = (0, import_react.useMemo)(
4465
+ const mergedRenderers = (0, import_react19.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
4466
+ const logEvent = (0, import_react19.useMemo)(() => getLogEvent(onLog), [onLog]);
4467
+ const trackEvent = (0, import_react19.useMemo)(
991
4468
  () => getTrackEvent(onEvent, onAnalytics, onThemeChange),
992
4469
  [onEvent, onAnalytics, onThemeChange]
993
4470
  );
@@ -1006,9 +4483,9 @@ function DynamicFlowRevamp(props) {
1006
4483
  onLink,
1007
4484
  onCopy
1008
4485
  });
1009
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client2.DynamicFlowCoreRevamp, __spreadValues({}, coreProps)) });
4486
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client2.DynamicFlowCoreRevamp, __spreadValues({}, coreProps)) });
1010
4487
  }
1011
- var DynamicForm = (0, import_react.forwardRef)(function DynamicForm2(props, ref) {
4488
+ var DynamicForm = (0, import_react19.forwardRef)(function DynamicForm2(props, ref) {
1012
4489
  const {
1013
4490
  className = "",
1014
4491
  customFetch = globalThis.fetch,
@@ -1019,12 +4496,12 @@ var DynamicForm = (0, import_react.forwardRef)(function DynamicForm2(props, ref)
1019
4496
  onLink = openLinkInNewTab,
1020
4497
  onThemeChange
1021
4498
  } = props;
1022
- const { formatMessage } = (0, import_react_intl2.useIntl)();
1023
- const createSnackBar = (0, import_dynamic_flow_renderers2.useSnackBarIfAvailable)();
4499
+ const { formatMessage } = (0, import_react_intl22.useIntl)();
4500
+ const createSnackBar = useSnackBarIfAvailable();
1024
4501
  const httpClient = useWiseHttpClient(customFetch);
1025
- const mergedRenderers = (0, import_react.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
1026
- const logEvent = (0, import_react.useMemo)(() => getLogEvent(onLog), [onLog]);
1027
- const trackEvent = (0, import_react.useMemo)(
4502
+ const mergedRenderers = (0, import_react19.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
4503
+ const logEvent = (0, import_react19.useMemo)(() => getLogEvent(onLog), [onLog]);
4504
+ const trackEvent = (0, import_react19.useMemo)(
1028
4505
  () => getTrackEvent(onEvent, onAnalytics, onThemeChange),
1029
4506
  [onEvent, onAnalytics, onThemeChange]
1030
4507
  );
@@ -1043,11 +4520,11 @@ var DynamicForm = (0, import_react.forwardRef)(function DynamicForm2(props, ref)
1043
4520
  onLink,
1044
4521
  onCopy
1045
4522
  });
1046
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client2.DynamicFormCore, __spreadProps(__spreadValues({}, coreProps), { ref })) });
4523
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client2.DynamicFormCore, __spreadProps(__spreadValues({}, coreProps), { ref })) });
1047
4524
  });
1048
4525
  var useWiseHttpClient = (httpClient) => {
1049
- const { locale } = (0, import_react_intl2.useIntl)();
1050
- return (0, import_react.useCallback)(
4526
+ const { locale } = (0, import_react_intl22.useIntl)();
4527
+ return (0, import_react19.useCallback)(
1051
4528
  async (input, init = {}) => {
1052
4529
  const headers = new Headers(init.headers);
1053
4530
  headers.set("accept-language", locale);