@adyen/kyc-components 3.67.2 → 3.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/AcceptTermsOfServiceComponent-yutCVhdr.js +1717 -0
  2. package/dist/{AccountSetupRejected-B9suPrnb.js → AccountSetupRejected-Bp9MbaZF.js} +3 -2
  3. package/dist/{BusinessTypeSelection-CmgDrnn_.js → BusinessTypeSelection-Bda3HjOy.js} +16 -16
  4. package/dist/{CXEL7IU7-Bl38-ki-.js → CXEL7IU7-DIlmKme0.js} +3 -3
  5. package/dist/CreateIndividualComponent-wIMjaodd.js +3798 -0
  6. package/dist/{CustomerSupport-BErKvR_1.js → CustomerSupport-BBpiWDZu.js} +4 -3
  7. package/dist/{DebugModal-DnMcr979.js → DebugModal-Chl6VeCw.js} +8 -9
  8. package/dist/{DecisionMakers-BYdR4dJE.js → DecisionMakers-91Uxeb4Z.js} +4 -2
  9. package/dist/EmbedShell-BgnrqkKO.js +60 -0
  10. package/dist/{core-BWGTBj-n.js → EventEmitter-MB52FRnR.js} +1221 -23636
  11. package/dist/{HASRA6WW-D6q3dmDB.js → HASRA6WW-CYutWFzS.js} +2 -2
  12. package/dist/{I3HPI4QX-CHpmX5kE.js → I3HPI4QX-h-J4eisw.js} +3 -3
  13. package/dist/{Introduction-C9e9nPsU.js → Introduction-Cn5uh084.js} +3 -2
  14. package/dist/{Review-DCfr7FXV.js → Review-BITkfvbx.js} +3 -2
  15. package/dist/{SingpassSelection-D-eeDYTK.js → SingpassSelection-BPrfSrSw.js} +3 -3
  16. package/dist/{TaxReportingDropin-CstiU-PL.js → TaxReportingDropin-DZLUs3Hb.js} +47 -16
  17. package/dist/adyen-kyc-components.js +1 -1
  18. package/dist/adyenConfig.js +3 -13
  19. package/dist/core-DnQST_lN.js +18040 -0
  20. package/dist/{css-A-fQe3zo.js → css-ChtZI8YA.js} +2 -2
  21. package/dist/individual.js +35 -19
  22. package/dist/{json-D5BHs1fv.js → json-CY-QM445.js} +2 -2
  23. package/dist/listToRecord-CogvyLiD.js +160 -0
  24. package/dist/{plaintext-C745dc26.js → plaintext-BzvCXlZZ.js} +2 -2
  25. package/dist/style.css +948 -377
  26. package/dist/styles-CLV89_hH.js +6142 -0
  27. package/dist/terms-of-service-preact.js +15 -0
  28. package/dist/terms-of-service-react.js +15 -0
  29. package/dist/terms-of-service.js +55 -0
  30. package/dist/types/api/configurations/useScenarios.d.ts +180 -0
  31. package/dist/types/api/configurations/useTaskTypes.d.ts +5 -0
  32. package/dist/types/api/pciTemplate/usePciQuestionnaireList.d.ts +5 -2
  33. package/dist/types/api/pciTemplate/usePciStatus.d.ts +4 -2
  34. package/dist/types/api/pciTemplate/usePciTemplate.d.ts +4 -2
  35. package/dist/types/api/pciTemplate/useSignPci.d.ts +4 -1
  36. package/dist/types/api/termsOfService/useAcceptTermsOfService.d.ts +4 -1
  37. package/dist/types/api/termsOfService/useAcceptedTermsOfService.d.ts +5 -2
  38. package/dist/types/api/termsOfService/useTermsOfService.d.ts +5 -2
  39. package/dist/types/api/termsOfService/useTermsOfServiceAcceptanceInfos.d.ts +4 -1
  40. package/dist/types/api/termsOfService/useTermsOfServiceStatus.d.ts +5 -2
  41. package/dist/types/api/types.d.ts +14 -0
  42. package/dist/types/api/validation/useValidateAccountIdentification.d.ts +6 -2
  43. package/dist/types/api/validation/useValidatePhoneNumber.d.ts +14 -0
  44. package/dist/types/components/BankAccount/hooks/useAsyncAccountDetailsValidationRules.d.ts +1 -1
  45. package/dist/types/components/BankAccount/mapping/payoutKeyMappings.d.ts +1 -1
  46. package/dist/types/components/Business/tasks/BusinessDetailsDropin/BusinessDetailsDropin.d.ts +1 -1
  47. package/dist/types/components/EFP/tasks/HighExposureDropin/types.d.ts +0 -2
  48. package/dist/types/components/EFP/tasks/TaxReportingDropin/utils.d.ts +2 -1
  49. package/dist/types/components/EmbeddedDropins/OnboardingDropinComponent/DropinComposer/DropinComposer.d.ts +1 -1
  50. package/dist/types/components/EmbeddedDropins/OnboardingDropinComponent/DropinComposer/types.d.ts +2 -8
  51. package/dist/types/components/Individual/forms/Individual/IdDocumentUpload/types.d.ts +4 -3
  52. package/dist/types/components/Individual/forms/Individual/IdDocumentUpload/utils.d.ts +3 -0
  53. package/dist/types/components/Individual/forms/IndividualOnfido/BasicDetails/BasicDetails.types.d.ts +0 -5
  54. package/dist/types/components/Individual/forms/IndividualOnfido/IndividualOnfido.types.d.ts +2 -4
  55. package/dist/types/components/Individual/tasks/IndividualDropin/IndividualDropin.d.ts +1 -1
  56. package/dist/types/components/Individual/tasks/IndividualOnfidoDropin/IndividualOnfidoDropin.d.ts +1 -1
  57. package/dist/types/components/Shared/fields/IdFieldTypeSelector/countryIdNumberTypes.d.ts +10 -0
  58. package/dist/types/components/Shared/fields/PhoneField/fieldConfig.d.ts +2 -2
  59. package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
  60. package/dist/types/components/Shared/forms/BusinessTypeSelection/types.d.ts +2 -2
  61. package/dist/types/components/Shared/tasks/TaskList/TaskList.d.ts +1 -1
  62. package/dist/types/components/Shared/tasks/TaskList/types.d.ts +0 -3
  63. package/dist/types/components/Trust/forms/Trust/types.d.ts +2 -2
  64. package/dist/types/components/Trust/hooks/useTrustMemberNavigation.hook.d.ts +30 -0
  65. package/dist/types/components/Trust/tasks/TrustDropin/TrustDropin.d.ts +1 -1
  66. package/dist/types/components/Trust/tasks/TrustMembers/TrustMembersOverview.d.ts +6 -3
  67. package/dist/types/components/Trust/utils/addOrUpdateAssociatedTrustMember.d.ts +4 -4
  68. package/dist/types/components/Trust/utils/addOrUpdateUndefinedBeneficiary.d.ts +2 -2
  69. package/dist/types/components/Trust/utils/updateExemptSettlorName.d.ts +4 -4
  70. package/dist/types/components/UnincorporatedPartnership/utils/unincorporatedPartnershipMembers.d.ts +2 -2
  71. package/dist/types/components/ui/atoms/Checkbox/Checkbox.d.ts +3 -3
  72. package/dist/types/components/ui/atoms/Field/Field.d.ts +26 -7
  73. package/dist/types/components/ui/atoms/Field/Field.types.d.ts +4 -2
  74. package/dist/types/components/ui/atoms/InputBase/InputBase.d.ts +2 -6
  75. package/dist/types/components/ui/atoms/Select/Select.d.ts +1 -1
  76. package/dist/types/components/ui/atoms/Select/Select.types.d.ts +3 -3
  77. package/dist/types/components/ui/atoms/SelectButton/SelectButton.d.ts +1 -2
  78. package/dist/types/components/ui/atoms/SelectButton/SelectButton.types.d.ts +3 -2
  79. package/dist/types/components/ui/molecules/Dropzone/FilePicker.d.ts +4 -2
  80. package/dist/types/context/ExperimentContext/types.d.ts +0 -10
  81. package/dist/types/context/SettingsContext/types.d.ts +3 -1
  82. package/dist/types/core/EmbedShell/EmbedShell.d.ts +26 -0
  83. package/dist/types/core/models/errors/validation-error.d.ts +1 -9
  84. package/dist/types/core/services/http.d.ts +3 -3
  85. package/dist/types/core/services/types.d.ts +2 -2
  86. package/dist/types/embeds/individual/individual.types.d.ts +5 -1
  87. package/dist/types/embeds/individual/preact/Individual.d.ts +3 -3
  88. package/dist/types/embeds/individual/react/Individual.d.ts +3 -3
  89. package/dist/types/embeds/individual/vue/individual.types.d.ts +3 -3
  90. package/dist/types/embeds/terms-of-service/adyen-terms-of-service.d.ts +1 -0
  91. package/dist/types/embeds/terms-of-service/preact/TermsOfService.d.ts +10 -0
  92. package/dist/types/embeds/terms-of-service/react/TermsOfService.d.ts +20 -0
  93. package/dist/types/embeds/terms-of-service/terms-of-service.types.d.ts +8 -0
  94. package/dist/types/embeds/utils.d.ts +4 -0
  95. package/dist/types/hooks/useScenarioConfiguration.d.ts +11 -4
  96. package/dist/types/utils/api/processValidationErrors.d.ts +5 -1
  97. package/dist/types/utils/entityStatusUtil.d.ts +1 -1
  98. package/dist/utils-Do7EwrWz.js +24 -0
  99. package/dist/{yaml-DgFkwyjb.js → yaml-CFgf8XoZ.js} +2 -2
  100. package/package.json +16 -1
  101. package/dist/types/context/ConfigurationApiContext/ConfigurationApiContext.d.ts +0 -7
  102. package/dist/types/context/ConfigurationApiContext/ConfigurationApiProvider.d.ts +0 -7
  103. package/dist/types/context/ConfigurationApiContext/getEmbeddedApi.d.ts +0 -5
  104. package/dist/types/context/ConfigurationApiContext/useConfigurationApi.d.ts +0 -2
  105. package/dist/types/core/models/api/get-configuration.d.ts +0 -17
  106. package/dist/types/core/models/api/get-tasks.d.ts +0 -2
  107. package/dist/types/core/services/componentApi/get-scenarios.d.ts +0 -4
  108. package/dist/types/core/services/componentApi/get-tasks.d.ts +0 -3
  109. package/dist/types/core/services/componentApi/update-legal-entity.d.ts +0 -3
  110. package/dist/types/core/services/componentApi/validate-phone-number.d.ts +0 -3
  111. package/dist/types/hooks/useComponentApi.d.ts +0 -10
@@ -0,0 +1,1717 @@
1
+ ;
2
+ {
3
+ try {
4
+ let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "940ec023-4741-4054-8ac7-2305621c1bce", e._sentryDebugIdIdentifier = "sentry-dbid-940ec023-4741-4054-8ac7-2305621c1bce");
6
+ } catch (e) {
7
+ }
8
+ }
9
+ ;
10
+ import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
11
+ import { useRef, useState, useEffect, useCallback } from "preact/hooks";
12
+ import { a as useApiContext, f as useQueryClient, d as useMutation, h as httpPost, b as useQuery, e as httpGet, dU as skipToken, Q as Icon, dV as AlertIcon, c as createLogger, i as useI18nContext, j as useAnalyticsContext, l as useToastContext, n as useExperimentsContext, bi as useForm, U as Alert, G as Button, b7 as localizeDateString, L as LoaderWrapper, b8 as Field, b9 as Select, d0 as Checkbox, cG as ActionBar, c$ as MaybeModal, D as ModalContent, F as ModalFooter, dD as StepProgressIndicator, X as Spacer, J as LegalEntityType, aj as getOwnSignatories, a3 as doesLegalEntityRequiresLegalRepresentative, a2 as getLegalRepresentative, cE as FormNavigation, I as useCoreContext, u as useLegalEntity, K as Loader, T as TaskTypes } from "./EventEmitter-MB52FRnR.js";
13
+ import cx from "classnames";
14
+ import { defineSlots } from "named-slots";
15
+ const acceptTermsOfService = async (legalEntityId, url, termsOfServiceDocumentId, data) => {
16
+ return httpPost(
17
+ {
18
+ loadingContext: url,
19
+ errorLevel: "warn",
20
+ errorMessage: `Failed to accept Terms of service`,
21
+ path: `legalEntities/${legalEntityId}/termsOfService/accept`,
22
+ authentication: "jwt",
23
+ headers: {
24
+ "Content-Type": "application/json"
25
+ }
26
+ },
27
+ {
28
+ ...data,
29
+ legalEntityReference: legalEntityId,
30
+ termsOfServiceDocumentId
31
+ }
32
+ );
33
+ };
34
+ const useAcceptTermsOfService = (options) => {
35
+ const { legalEntityId, baseUrl } = useApiContext();
36
+ const queryClient = useQueryClient();
37
+ return useMutation({
38
+ mutationFn: (data) => acceptTermsOfService(legalEntityId.value, baseUrl.value, data.termsOfServiceDocumentId, data),
39
+ onSuccess: async () => {
40
+ queryClient.invalidateQueries({
41
+ queryKey: ["legalEntity", legalEntityId.value]
42
+ });
43
+ queryClient.invalidateQueries({
44
+ queryKey: ["termsOfServiceStatus", legalEntityId.value]
45
+ });
46
+ queryClient.invalidateQueries({
47
+ queryKey: ["termsOfServiceAcceptanceInfos", legalEntityId.value]
48
+ });
49
+ },
50
+ ...options
51
+ });
52
+ };
53
+ const getTermsOfServiceAcceptanceInfos = async (legalEntityId, url) => {
54
+ return httpGet({
55
+ loadingContext: url,
56
+ errorLevel: "warn",
57
+ errorMessage: `Failed to get terms of service acceptance info`,
58
+ path: `legalEntities/${legalEntityId}/termsOfService/termsOfServiceAcceptanceInfos`,
59
+ authentication: "jwt",
60
+ headers: {
61
+ "Content-Type": "application/json"
62
+ }
63
+ });
64
+ };
65
+ const useTermsOfServiceAcceptanceInfos = (options) => {
66
+ const { legalEntityId, baseUrl } = useApiContext();
67
+ return useQuery({
68
+ queryKey: ["termsOfServiceAcceptanceInfos", legalEntityId.value, baseUrl.value],
69
+ queryFn: () => getTermsOfServiceAcceptanceInfos(legalEntityId.value, baseUrl.value),
70
+ ...options
71
+ });
72
+ };
73
+ const getTermsOfServiceStatus = async (legalEntityId, url) => {
74
+ return httpGet({
75
+ loadingContext: url,
76
+ errorLevel: "warn",
77
+ errorMessage: `Failed to get terms of service status`,
78
+ path: `legalEntities/${legalEntityId}/termsOfService/termsOfServiceStatus`,
79
+ authentication: "jwt",
80
+ headers: {
81
+ "Content-Type": "application/json"
82
+ }
83
+ });
84
+ };
85
+ const useTermsOfServiceStatus = (options) => {
86
+ const { legalEntityId, baseUrl } = useApiContext();
87
+ return useQuery({
88
+ queryKey: ["termsOfServiceStatus", legalEntityId.value, baseUrl.value],
89
+ queryFn: () => getTermsOfServiceStatus(legalEntityId.value, baseUrl.value),
90
+ ...options
91
+ });
92
+ };
93
+ const getAcceptedTermsOfService = async (legalEntityId, url, termsOfServiceAcceptanceReference, documentFormat) => {
94
+ return httpGet({
95
+ loadingContext: url,
96
+ errorLevel: "warn",
97
+ errorMessage: `Failed to get accepted service agreement`,
98
+ path: `legalEntities/${legalEntityId}/termsOfService/acceptedTermsOfServiceDocument/${termsOfServiceAcceptanceReference}?documentformat=${documentFormat} `,
99
+ authentication: "jwt",
100
+ headers: {
101
+ "Content-Type": "application/json"
102
+ }
103
+ });
104
+ };
105
+ const useAcceptedTermsOfService = (termsOfServiceAcceptanceReference, documentFormat, options) => {
106
+ const { legalEntityId, baseUrl } = useApiContext();
107
+ return useQuery({
108
+ queryKey: [
109
+ "acceptedTermsOfService",
110
+ termsOfServiceAcceptanceReference,
111
+ documentFormat,
112
+ legalEntityId.value,
113
+ baseUrl.value
114
+ ],
115
+ queryFn: termsOfServiceAcceptanceReference ? () => getAcceptedTermsOfService(
116
+ legalEntityId.value,
117
+ baseUrl.value,
118
+ termsOfServiceAcceptanceReference,
119
+ documentFormat
120
+ ) : skipToken,
121
+ ...options
122
+ });
123
+ };
124
+ const getTermsOfService = async (legalEntityId, url, data) => {
125
+ return httpPost(
126
+ {
127
+ loadingContext: url,
128
+ errorLevel: "warn",
129
+ errorMessage: `Failed to get terms of service`,
130
+ path: `legalEntities/${legalEntityId}/termsOfService`,
131
+ authentication: "jwt",
132
+ headers: {
133
+ "Content-Type": "application/json"
134
+ }
135
+ },
136
+ data
137
+ );
138
+ };
139
+ const useTermsOfService = (data, options) => {
140
+ const { legalEntityId, baseUrl } = useApiContext();
141
+ return useQuery({
142
+ queryKey: ["termsOfService", legalEntityId.value, baseUrl.value, data],
143
+ queryFn: () => getTermsOfService(legalEntityId.value, baseUrl.value, data),
144
+ ...options
145
+ });
146
+ };
147
+ const outlinedIcon = "adyen-kyc-outlined-icon";
148
+ const styles = {
149
+ outlinedIcon
150
+ };
151
+ const OutlinedIcon = ({ name }) => /* @__PURE__ */ jsx("div", { className: styles.outlinedIcon, children: /* @__PURE__ */ jsx(Icon, { name }) });
152
+ const FormEndState = ({ variant = "success", children, className }) => {
153
+ const Slot = defineSlots(children, ["title", "content", "icon", "actions"]);
154
+ return /* @__PURE__ */ jsxs(
155
+ "div",
156
+ {
157
+ className: cx("adyen-form-end-state", `adyen-form-end-state__icon--${variant}`, className),
158
+ role: "alert",
159
+ children: [
160
+ /* @__PURE__ */ jsx(Slot, { name: "icon", children: variant === "success" ? /* @__PURE__ */ jsx(Icon, { name: "checkmark" }) : /* @__PURE__ */ jsx(AlertIcon, { variant }) }),
161
+ /* @__PURE__ */ jsx("span", { className: "adyen-form-end-state__title", children: /* @__PURE__ */ jsx(Slot, { name: "title" }) }),
162
+ /* @__PURE__ */ jsx("div", { className: "adyen-form-end-state__description", children: /* @__PURE__ */ jsx(Slot, { name: "content" }) }),
163
+ /* @__PURE__ */ jsx("div", { className: "adyen-form-end-state__actions", children: /* @__PURE__ */ jsx(Slot, { name: "actions" }) })
164
+ ]
165
+ }
166
+ );
167
+ };
168
+ const downloadFile = async (base64, filename) => {
169
+ saveBlobAsFile(base64ToBlob(base64), filename);
170
+ };
171
+ const base64ToBlob = (base64, mimeType = "application/octet-stream") => {
172
+ const bytes = window.atob(base64);
173
+ const amount = bytes.length;
174
+ const byteArray = new Array(amount);
175
+ for (let i = 0; i < amount; i += 1) {
176
+ byteArray[i] = bytes.charCodeAt(i);
177
+ }
178
+ return new Blob([new Uint8Array(byteArray)], { type: mimeType });
179
+ };
180
+ const saveBlobAsFile = (fileData, filename) => {
181
+ if ("msSaveBlob" in window.navigator && typeof window.navigator.msSaveBlob === "function") {
182
+ window.navigator.msSaveBlob(fileData, filename);
183
+ } else {
184
+ const blobUrl = window.URL.createObjectURL(fileData);
185
+ const link = document.createElement("a");
186
+ link.style.display = "none";
187
+ link.href = blobUrl;
188
+ link.setAttribute("download", filename);
189
+ if (typeof link.download === "undefined") {
190
+ link.setAttribute("target", "_blank");
191
+ }
192
+ document.body.appendChild(link);
193
+ link.click();
194
+ document.body.removeChild(link);
195
+ window.URL.revokeObjectURL(blobUrl);
196
+ }
197
+ };
198
+ var G, d, xe, E, le, $e, X, Ce, D = {}, Se = [], Ye = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, re = Array.isArray;
199
+ function C(e, t) {
200
+ for (var n in t)
201
+ e[n] = t[n];
202
+ return e;
203
+ }
204
+ function Ee(e) {
205
+ var t = e.parentNode;
206
+ t && t.removeChild(e);
207
+ }
208
+ function Pe(e, t, n) {
209
+ var o, _, r, c = {};
210
+ for (r in t)
211
+ r == "key" ? o = t[r] : r == "ref" ? _ = t[r] : c[r] = t[r];
212
+ if (arguments.length > 2 && (c.children = arguments.length > 3 ? G.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null)
213
+ for (r in e.defaultProps)
214
+ c[r] === void 0 && (c[r] = e.defaultProps[r]);
215
+ return M(e, c, o, _, null);
216
+ }
217
+ function M(e, t, n, o, _) {
218
+ var r = { type: e, props: t, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: _ ?? ++xe, __i: -1, __u: 0 };
219
+ return _ == null && d.vnode != null && d.vnode(r), r;
220
+ }
221
+ function Y(e) {
222
+ return e.children;
223
+ }
224
+ function W(e, t) {
225
+ this.props = e, this.context = t;
226
+ }
227
+ function L(e, t) {
228
+ if (t == null)
229
+ return e.__ ? L(e.__, e.__i + 1) : null;
230
+ for (var n; t < e.__k.length; t++)
231
+ if ((n = e.__k[t]) != null && n.__e != null)
232
+ return n.__e;
233
+ return typeof e.type == "function" ? L(e) : null;
234
+ }
235
+ function He(e) {
236
+ var t, n;
237
+ if ((e = e.__) != null && e.__c != null) {
238
+ for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++)
239
+ if ((n = e.__k[t]) != null && n.__e != null) {
240
+ e.__e = e.__c.base = n.__e;
241
+ break;
242
+ }
243
+ return He(e);
244
+ }
245
+ }
246
+ function Z(e) {
247
+ (!e.__d && (e.__d = true) && E.push(e) && !q.__r++ || le !== d.debounceRendering) && ((le = d.debounceRendering) || $e)(q);
248
+ }
249
+ function q() {
250
+ var e, t, n, o, _, r, c, s, a;
251
+ for (E.sort(X); e = E.shift(); )
252
+ e.__d && (t = E.length, o = void 0, r = (_ = (n = e).__v).__e, s = [], a = [], (c = n.__P) && ((o = C({}, _)).__v = _.__v + 1, d.vnode && d.vnode(o), _e(c, o, _, n.__n, c.ownerSVGElement !== void 0, 32 & _.__u ? [r] : null, s, r ?? L(_), !!(32 & _.__u), a), o.__.__k[o.__i] = o, Te(s, o, a), o.__e != r && He(o)), E.length > t && E.sort(X));
253
+ q.__r = 0;
254
+ }
255
+ function Le(e, t, n, o, _, r, c, s, a, l, p) {
256
+ var i, h, f, v, w, b = o && o.__k || Se, m = t.length;
257
+ for (n.__d = a, Ke(n, t, b), a = n.__d, i = 0; i < m; i++)
258
+ (f = n.__k[i]) != null && typeof f != "boolean" && typeof f != "function" && (h = f.__i === -1 ? D : b[f.__i] || D, f.__i = i, _e(e, f, h, _, r, c, s, a, l, p), v = f.__e, f.ref && h.ref != f.ref && (h.ref && ie(h.ref, null, f), p.push(f.ref, f.__c || v, f)), w == null && v != null && (w = v), 65536 & f.__u || h.__k === f.__k ? a = Ie(f, a, e) : typeof f.type == "function" && f.__d !== void 0 ? a = f.__d : v && (a = v.nextSibling), f.__d = void 0, f.__u &= -196609);
259
+ n.__d = a, n.__e = w;
260
+ }
261
+ function Ke(e, t, n) {
262
+ var o, _, r, c, s, a = t.length, l = n.length, p = l, i = 0;
263
+ for (e.__k = [], o = 0; o < a; o++)
264
+ (_ = e.__k[o] = (_ = t[o]) == null || typeof _ == "boolean" || typeof _ == "function" ? null : typeof _ == "string" || typeof _ == "number" || typeof _ == "bigint" || _.constructor == String ? M(null, _, null, null, _) : re(_) ? M(Y, { children: _ }, null, null, null) : _.constructor === void 0 && _.__b > 0 ? M(_.type, _.props, _.key, _.ref ? _.ref : null, _.__v) : _) != null ? (_.__ = e, _.__b = e.__b + 1, s = Je(_, n, c = o + i, p), _.__i = s, r = null, s !== -1 && (p--, (r = n[s]) && (r.__u |= 131072)), r == null || r.__v === null ? (s == -1 && i--, typeof _.type != "function" && (_.__u |= 65536)) : s !== c && (s === c + 1 ? i++ : s > c ? p > a - c ? i += s - c : i-- : i = s < c && s == c - 1 ? s - c : 0, s !== o + i && (_.__u |= 65536))) : (r = n[o]) && r.key == null && r.__e && (r.__e == e.__d && (e.__d = L(r)), ee(r, r, false), n[o] = null, p--);
265
+ if (p)
266
+ for (o = 0; o < l; o++)
267
+ (r = n[o]) != null && !(131072 & r.__u) && (r.__e == e.__d && (e.__d = L(r)), ee(r, r));
268
+ }
269
+ function Ie(e, t, n) {
270
+ var o, _;
271
+ if (typeof e.type == "function") {
272
+ for (o = e.__k, _ = 0; o && _ < o.length; _++)
273
+ o[_] && (o[_].__ = e, t = Ie(o[_], t, n));
274
+ return t;
275
+ }
276
+ return e.__e != t && (n.insertBefore(e.__e, t || null), t = e.__e), t && t.nextSibling;
277
+ }
278
+ function Je(e, t, n, o) {
279
+ var _ = e.key, r = e.type, c = n - 1, s = n + 1, a = t[n];
280
+ if (a === null || a && _ == a.key && r === a.type)
281
+ return n;
282
+ if (o > (a != null && !(131072 & a.__u) ? 1 : 0))
283
+ for (; c >= 0 || s < t.length; ) {
284
+ if (c >= 0) {
285
+ if ((a = t[c]) && !(131072 & a.__u) && _ == a.key && r === a.type)
286
+ return c;
287
+ c--;
288
+ }
289
+ if (s < t.length) {
290
+ if ((a = t[s]) && !(131072 & a.__u) && _ == a.key && r === a.type)
291
+ return s;
292
+ s++;
293
+ }
294
+ }
295
+ return -1;
296
+ }
297
+ function ae(e, t, n) {
298
+ t[0] === "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || Ye.test(t) ? n : n + "px";
299
+ }
300
+ function V(e, t, n, o, _) {
301
+ var r;
302
+ e:
303
+ if (t === "style")
304
+ if (typeof n == "string")
305
+ e.style.cssText = n;
306
+ else {
307
+ if (typeof o == "string" && (e.style.cssText = o = ""), o)
308
+ for (t in o)
309
+ n && t in n || ae(e.style, t, "");
310
+ if (n)
311
+ for (t in n)
312
+ o && n[t] === o[t] || ae(e.style, t, n[t]);
313
+ }
314
+ else if (t[0] === "o" && t[1] === "n")
315
+ r = t !== (t = t.replace(/(PointerCapture)$|Capture$/, "$1")), t = t.toLowerCase() in e ? t.toLowerCase().slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + r] = n, n ? o ? n.u = o.u : (n.u = Date.now(), e.addEventListener(t, r ? fe : ue, r)) : e.removeEventListener(t, r ? fe : ue, r);
316
+ else {
317
+ if (_)
318
+ t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
319
+ else if (t !== "width" && t !== "height" && t !== "href" && t !== "list" && t !== "form" && t !== "tabIndex" && t !== "download" && t !== "rowSpan" && t !== "colSpan" && t !== "role" && t in e)
320
+ try {
321
+ e[t] = n ?? "";
322
+ break e;
323
+ } catch {
324
+ }
325
+ typeof n == "function" || (n == null || n === false && t[4] !== "-" ? e.removeAttribute(t) : e.setAttribute(t, n));
326
+ }
327
+ }
328
+ function ue(e) {
329
+ var t = this.l[e.type + false];
330
+ if (e.t) {
331
+ if (e.t <= t.u)
332
+ return;
333
+ } else
334
+ e.t = Date.now();
335
+ return t(d.event ? d.event(e) : e);
336
+ }
337
+ function fe(e) {
338
+ return this.l[e.type + true](d.event ? d.event(e) : e);
339
+ }
340
+ function _e(e, t, n, o, _, r, c, s, a, l) {
341
+ var p, i, h, f, v, w, b, m, g, $, R, A, se, U, J, k = t.type;
342
+ if (t.constructor !== void 0)
343
+ return null;
344
+ 128 & n.__u && (a = !!(32 & n.__u), r = [s = t.__e = n.__e]), (p = d.__b) && p(t);
345
+ e:
346
+ if (typeof k == "function")
347
+ try {
348
+ if (m = t.props, g = (p = k.contextType) && o[p.__c], $ = p ? g ? g.props.value : p.__ : o, n.__c ? b = (i = t.__c = n.__c).__ = i.__E : ("prototype" in k && k.prototype.render ? t.__c = i = new k(m, $) : (t.__c = i = new W(m, $), i.constructor = k, i.render = Xe), g && g.sub(i), i.props = m, i.state || (i.state = {}), i.context = $, i.__n = o, h = i.__d = true, i.__h = [], i._sb = []), i.__s == null && (i.__s = i.state), k.getDerivedStateFromProps != null && (i.__s == i.state && (i.__s = C({}, i.__s)), C(i.__s, k.getDerivedStateFromProps(m, i.__s))), f = i.props, v = i.state, i.__v = t, h)
349
+ k.getDerivedStateFromProps == null && i.componentWillMount != null && i.componentWillMount(), i.componentDidMount != null && i.__h.push(i.componentDidMount);
350
+ else {
351
+ if (k.getDerivedStateFromProps == null && m !== f && i.componentWillReceiveProps != null && i.componentWillReceiveProps(m, $), !i.__e && (i.shouldComponentUpdate != null && i.shouldComponentUpdate(m, i.__s, $) === false || t.__v === n.__v)) {
352
+ for (t.__v !== n.__v && (i.props = m, i.state = i.__s, i.__d = false), t.__e = n.__e, t.__k = n.__k, t.__k.forEach(function(O) {
353
+ O && (O.__ = t);
354
+ }), R = 0; R < i._sb.length; R++)
355
+ i.__h.push(i._sb[R]);
356
+ i._sb = [], i.__h.length && c.push(i);
357
+ break e;
358
+ }
359
+ i.componentWillUpdate != null && i.componentWillUpdate(m, i.__s, $), i.componentDidUpdate != null && i.__h.push(function() {
360
+ i.componentDidUpdate(f, v, w);
361
+ });
362
+ }
363
+ if (i.context = $, i.props = m, i.__P = e, i.__e = false, A = d.__r, se = 0, "prototype" in k && k.prototype.render) {
364
+ for (i.state = i.__s, i.__d = false, A && A(t), p = i.render(i.props, i.state, i.context), U = 0; U < i._sb.length; U++)
365
+ i.__h.push(i._sb[U]);
366
+ i._sb = [];
367
+ } else
368
+ do
369
+ i.__d = false, A && A(t), p = i.render(i.props, i.state, i.context), i.state = i.__s;
370
+ while (i.__d && ++se < 25);
371
+ i.state = i.__s, i.getChildContext != null && (o = C(C({}, o), i.getChildContext())), h || i.getSnapshotBeforeUpdate == null || (w = i.getSnapshotBeforeUpdate(f, v)), Le(e, re(J = p != null && p.type === Y && p.key == null ? p.props.children : p) ? J : [J], t, n, o, _, r, c, s, a, l), i.base = t.__e, t.__u &= -161, i.__h.length && c.push(i), b && (i.__E = i.__ = null);
372
+ } catch (O) {
373
+ t.__v = null, a || r != null ? (t.__e = s, t.__u |= a ? 160 : 32, r[r.indexOf(s)] = null) : (t.__e = n.__e, t.__k = n.__k), d.__e(O, t, n);
374
+ }
375
+ else
376
+ r == null && t.__v === n.__v ? (t.__k = n.__k, t.__e = n.__e) : t.__e = Qe(n.__e, t, n, o, _, r, c, a, l);
377
+ (p = d.diffed) && p(t);
378
+ }
379
+ function Te(e, t, n) {
380
+ t.__d = void 0;
381
+ for (var o = 0; o < n.length; o++)
382
+ ie(n[o], n[++o], n[++o]);
383
+ d.__c && d.__c(t, e), e.some(function(_) {
384
+ try {
385
+ e = _.__h, _.__h = [], e.some(function(r) {
386
+ r.call(_);
387
+ });
388
+ } catch (r) {
389
+ d.__e(r, _.__v);
390
+ }
391
+ });
392
+ }
393
+ function Qe(e, t, n, o, _, r, c, s, a) {
394
+ var l, p, i, h, f, v, w, b = n.props, m = t.props, g = t.type;
395
+ if (g === "svg" && (_ = true), r != null) {
396
+ for (l = 0; l < r.length; l++)
397
+ if ((f = r[l]) && "setAttribute" in f == !!g && (g ? f.localName === g : f.nodeType === 3)) {
398
+ e = f, r[l] = null;
399
+ break;
400
+ }
401
+ }
402
+ if (e == null) {
403
+ if (g === null)
404
+ return document.createTextNode(m);
405
+ e = _ ? document.createElementNS("http://www.w3.org/2000/svg", g) : document.createElement(g, m.is && m), r = null, s = false;
406
+ }
407
+ if (g === null)
408
+ b === m || s && e.data === m || (e.data = m);
409
+ else {
410
+ if (r = r && G.call(e.childNodes), b = n.props || D, !s && r != null)
411
+ for (b = {}, l = 0; l < e.attributes.length; l++)
412
+ b[(f = e.attributes[l]).name] = f.value;
413
+ for (l in b)
414
+ f = b[l], l == "children" || (l == "dangerouslySetInnerHTML" ? i = f : l === "key" || l in m || V(e, l, null, f, _));
415
+ for (l in m)
416
+ f = m[l], l == "children" ? h = f : l == "dangerouslySetInnerHTML" ? p = f : l == "value" ? v = f : l == "checked" ? w = f : l === "key" || s && typeof f != "function" || b[l] === f || V(e, l, f, b[l], _);
417
+ if (p)
418
+ s || i && (p.__html === i.__html || p.__html === e.innerHTML) || (e.innerHTML = p.__html), t.__k = [];
419
+ else if (i && (e.innerHTML = ""), Le(e, re(h) ? h : [h], t, n, o, _ && g !== "foreignObject", r, c, r ? r[0] : n.__k && L(n, 0), s, a), r != null)
420
+ for (l = r.length; l--; )
421
+ r[l] != null && Ee(r[l]);
422
+ s || (l = "value", v !== void 0 && (v !== e[l] || g === "progress" && !v || g === "option" && v !== b[l]) && V(e, l, v, b[l], false), l = "checked", w !== void 0 && w !== e[l] && V(e, l, w, b[l], false));
423
+ }
424
+ return e;
425
+ }
426
+ function ie(e, t, n) {
427
+ try {
428
+ typeof e == "function" ? e(t) : e.current = t;
429
+ } catch (o) {
430
+ d.__e(o, n);
431
+ }
432
+ }
433
+ function ee(e, t, n) {
434
+ var o, _;
435
+ if (d.unmount && d.unmount(e), (o = e.ref) && (o.current && o.current !== e.__e || ie(o, null, t)), (o = e.__c) != null) {
436
+ if (o.componentWillUnmount)
437
+ try {
438
+ o.componentWillUnmount();
439
+ } catch (r) {
440
+ d.__e(r, t);
441
+ }
442
+ o.base = o.__P = null, e.__c = void 0;
443
+ }
444
+ if (o = e.__k)
445
+ for (_ = 0; _ < o.length; _++)
446
+ o[_] && ee(o[_], t, n || typeof e.type != "function");
447
+ n || e.__e == null || Ee(e.__e), e.__ = e.__e = e.__d = void 0;
448
+ }
449
+ function Xe(e, t, n) {
450
+ return this.constructor(e, n);
451
+ }
452
+ function Ze(e, t, n) {
453
+ var o, _, r, c;
454
+ d.__ && d.__(e, t), _ = (o = false) ? null : t.__k, r = [], c = [], _e(t, e = t.__k = Pe(Y, null, [e]), _ || D, D, t.ownerSVGElement !== void 0, _ ? null : t.firstChild ? G.call(t.childNodes) : null, r, _ ? _.__e : t.firstChild, o, c), Te(r, e, c);
455
+ }
456
+ function Ae(e, t) {
457
+ var n = { __c: t = "__cC" + Ce++, __: e, Consumer: function(o, _) {
458
+ return o.children(_);
459
+ }, Provider: function(o) {
460
+ var _, r;
461
+ return this.getChildContext || (_ = [], (r = {})[t] = this, this.getChildContext = function() {
462
+ return r;
463
+ }, this.shouldComponentUpdate = function(c) {
464
+ this.props.value !== c.value && _.some(function(s) {
465
+ s.__e = true, Z(s);
466
+ });
467
+ }, this.sub = function(c) {
468
+ _.push(c);
469
+ var s = c.componentWillUnmount;
470
+ c.componentWillUnmount = function() {
471
+ _.splice(_.indexOf(c), 1), s && s.call(c);
472
+ };
473
+ }), o.children;
474
+ } };
475
+ return n.Provider.__ = n.Consumer.contextType = n;
476
+ }
477
+ G = Se.slice, d = { __e: function(e, t, n, o) {
478
+ for (var _, r, c; t = t.__; )
479
+ if ((_ = t.__c) && !_.__)
480
+ try {
481
+ if ((r = _.constructor) && r.getDerivedStateFromError != null && (_.setState(r.getDerivedStateFromError(e)), c = _.__d), _.componentDidCatch != null && (_.componentDidCatch(e, o || {}), c = _.__d), c)
482
+ return _.__E = _;
483
+ } catch (s) {
484
+ e = s;
485
+ }
486
+ throw e;
487
+ } }, xe = 0, W.prototype.setState = function(e, t) {
488
+ var n;
489
+ n = this.__s != null && this.__s !== this.state ? this.__s : this.__s = C({}, this.state), typeof e == "function" && (e = e(C({}, n), this.props)), e && C(n, e), e != null && this.__v && (t && this._sb.push(t), Z(this));
490
+ }, W.prototype.forceUpdate = function(e) {
491
+ this.__v && (this.__e = true, e && this.__h.push(e), Z(this));
492
+ }, W.prototype.render = Y, E = [], $e = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, X = function(e, t) {
493
+ return e.__v.__b - t.__v.__b;
494
+ }, q.__r = 0, Ce = 0;
495
+ var et = 0;
496
+ function u(e, t, n, o, _, r) {
497
+ var c, s, a = {};
498
+ for (s in t)
499
+ s == "ref" ? c = t[s] : a[s] = t[s];
500
+ var l = { type: e, props: a, key: n, ref: c, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --et, __i: -1, __u: 0, __source: _, __self: r };
501
+ if (typeof e == "function" && (c = e.defaultProps))
502
+ for (s in c)
503
+ a[s] === void 0 && (a[s] = c[s]);
504
+ return d.vnode && d.vnode(l), l;
505
+ }
506
+ function tt(e) {
507
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
508
+ }
509
+ var De = { exports: {} };
510
+ /*!
511
+ Copyright (c) 2018 Jed Watson.
512
+ Licensed under the MIT License (MIT), see
513
+ http://jedwatson.github.io/classnames
514
+ */
515
+ (function(e) {
516
+ (function() {
517
+ var t = {}.hasOwnProperty;
518
+ function n() {
519
+ for (var r = "", c = 0; c < arguments.length; c++) {
520
+ var s = arguments[c];
521
+ s && (r = _(r, o(s)));
522
+ }
523
+ return r;
524
+ }
525
+ function o(r) {
526
+ if (typeof r == "string" || typeof r == "number")
527
+ return r;
528
+ if (typeof r != "object")
529
+ return "";
530
+ if (Array.isArray(r))
531
+ return n.apply(null, r);
532
+ if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
533
+ return r.toString();
534
+ var c = "";
535
+ for (var s in r)
536
+ t.call(r, s) && r[s] && (c = _(c, s));
537
+ return c;
538
+ }
539
+ function _(r, c) {
540
+ return c ? r ? r + " " + c : r + c : r;
541
+ }
542
+ e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
543
+ })();
544
+ })(De);
545
+ var nt = De.exports;
546
+ const x = /* @__PURE__ */ tt(nt);
547
+ var N = /* @__PURE__ */ ((e) => (e.Chapter = "chapter", e.Section = "section", e.Paragraph = "paragraph", e.Text = "text", e.Weblink = "weblink", e.List = "list", e.Table = "table", e.InternalReference = "internalReference", e))(N || {}), te = /* @__PURE__ */ ((e) => (e.Bold = "BOLD", e.Italic = "ITALIC", e))(te || {});
548
+ let de = Date.now();
549
+ const Re = (e = "id") => (de += 1, `${e}-${de}`);
550
+ var I, y, Q, pe, z = 0, Ue = [], F = [], he = d.__b, ve = d.__r, me = d.diffed, ye = d.__c, be = d.unmount;
551
+ function K(e, t) {
552
+ d.__h && d.__h(y, e, z || t), z = 0;
553
+ var n = y.__H || (y.__H = { __: [], __h: [] });
554
+ return e >= n.__.length && n.__.push({ __V: F }), n.__[e];
555
+ }
556
+ function T(e) {
557
+ return z = 1, ot(We, e);
558
+ }
559
+ function ot(e, t, n) {
560
+ var o = K(I++, 2);
561
+ if (o.t = e, !o.__c && (o.__ = [We(void 0, t), function(s) {
562
+ var a = o.__N ? o.__N[0] : o.__[0], l = o.t(a, s);
563
+ a !== l && (o.__N = [l, o.__[1]], o.__c.setState({}));
564
+ }], o.__c = y, !y.u)) {
565
+ var _ = function(s, a, l) {
566
+ if (!o.__c.__H)
567
+ return true;
568
+ var p = o.__c.__H.__.filter(function(h) {
569
+ return h.__c;
570
+ });
571
+ if (p.every(function(h) {
572
+ return !h.__N;
573
+ }))
574
+ return !r || r.call(this, s, a, l);
575
+ var i = false;
576
+ return p.forEach(function(h) {
577
+ if (h.__N) {
578
+ var f = h.__[0];
579
+ h.__ = h.__N, h.__N = void 0, f !== h.__[0] && (i = true);
580
+ }
581
+ }), !(!i && o.__c.props === s) && (!r || r.call(this, s, a, l));
582
+ };
583
+ y.u = true;
584
+ var r = y.shouldComponentUpdate, c = y.componentWillUpdate;
585
+ y.componentWillUpdate = function(s, a, l) {
586
+ if (this.__e) {
587
+ var p = r;
588
+ r = void 0, _(s, a, l), r = p;
589
+ }
590
+ c && c.call(this, s, a, l);
591
+ }, y.shouldComponentUpdate = _;
592
+ }
593
+ return o.__N || o.__;
594
+ }
595
+ function H(e, t) {
596
+ var n = K(I++, 3);
597
+ !d.__s && Me(n.__H, t) && (n.__ = e, n.i = t, y.__H.__h.push(n));
598
+ }
599
+ function rt(e) {
600
+ return z = 5, Oe(function() {
601
+ return { current: e };
602
+ }, []);
603
+ }
604
+ function Oe(e, t) {
605
+ var n = K(I++, 7);
606
+ return Me(n.__H, t) ? (n.__V = e(), n.i = t, n.__h = e, n.__V) : n.__;
607
+ }
608
+ function Ve(e) {
609
+ var t = y.context[e.__c], n = K(I++, 9);
610
+ return n.c = e, t ? (n.__ == null && (n.__ = true, t.sub(y)), t.props.value) : e.__;
611
+ }
612
+ function _t() {
613
+ for (var e; e = Ue.shift(); )
614
+ if (e.__P && e.__H)
615
+ try {
616
+ e.__H.__h.forEach(B), e.__H.__h.forEach(ne), e.__H.__h = [];
617
+ } catch (t) {
618
+ e.__H.__h = [], d.__e(t, e.__v);
619
+ }
620
+ }
621
+ d.__b = function(e) {
622
+ y = null, he && he(e);
623
+ }, d.__r = function(e) {
624
+ ve && ve(e), I = 0;
625
+ var t = (y = e.__c).__H;
626
+ t && (Q === y ? (t.__h = [], y.__h = [], t.__.forEach(function(n) {
627
+ n.__N && (n.__ = n.__N), n.__V = F, n.__N = n.i = void 0;
628
+ })) : (t.__h.forEach(B), t.__h.forEach(ne), t.__h = [], I = 0)), Q = y;
629
+ }, d.diffed = function(e) {
630
+ me && me(e);
631
+ var t = e.__c;
632
+ t && t.__H && (t.__H.__h.length && (Ue.push(t) !== 1 && pe === d.requestAnimationFrame || ((pe = d.requestAnimationFrame) || it)(_t)), t.__H.__.forEach(function(n) {
633
+ n.i && (n.__H = n.i), n.__V !== F && (n.__ = n.__V), n.i = void 0, n.__V = F;
634
+ })), Q = y = null;
635
+ }, d.__c = function(e, t) {
636
+ t.some(function(n) {
637
+ try {
638
+ n.__h.forEach(B), n.__h = n.__h.filter(function(o) {
639
+ return !o.__ || ne(o);
640
+ });
641
+ } catch (o) {
642
+ t.some(function(_) {
643
+ _.__h && (_.__h = []);
644
+ }), t = [], d.__e(o, n.__v);
645
+ }
646
+ }), ye && ye(e, t);
647
+ }, d.unmount = function(e) {
648
+ be && be(e);
649
+ var t, n = e.__c;
650
+ n && n.__H && (n.__H.__.forEach(function(o) {
651
+ try {
652
+ B(o);
653
+ } catch (_) {
654
+ t = _;
655
+ }
656
+ }), n.__H = void 0, t && d.__e(t, n.__v));
657
+ };
658
+ var ge = typeof requestAnimationFrame == "function";
659
+ function it(e) {
660
+ var t, n = function() {
661
+ clearTimeout(o), ge && cancelAnimationFrame(t), setTimeout(e);
662
+ }, o = setTimeout(n, 100);
663
+ ge && (t = requestAnimationFrame(n));
664
+ }
665
+ function B(e) {
666
+ var t = y, n = e.__c;
667
+ typeof n == "function" && (e.__c = void 0, n()), y = t;
668
+ }
669
+ function ne(e) {
670
+ var t = y;
671
+ e.__c = e.__(), y = t;
672
+ }
673
+ function Me(e, t) {
674
+ return !e || e.length !== t.length || t.some(function(n, o) {
675
+ return n !== e[o];
676
+ });
677
+ }
678
+ function We(e, t) {
679
+ return typeof t == "function" ? t(e) : t;
680
+ }
681
+ const Fe = Ae(null);
682
+ function ct({
683
+ children: e,
684
+ className: t,
685
+ expand: n = false,
686
+ type: o,
687
+ onExpandSection: _
688
+ }) {
689
+ const [r, c] = T([]), s = x("adv-accordion", t, {
690
+ "adv-accordion--container": o === "container"
691
+ });
692
+ return /* @__PURE__ */ u(Fe.Provider, { value: { expand: n, items: r, setItems: c, onExpandSection: _ }, children: /* @__PURE__ */ u("div", { className: s, children: e }) });
693
+ }
694
+ const we = {
695
+ 1: "h1",
696
+ 2: "h2"
697
+ };
698
+ function ce({ className: e, level: t, children: n }) {
699
+ const o = we[t] || we[1], _ = x("adv-heading", `adv-heading--${t}`, e);
700
+ return Pe(o, { className: _ }, n);
701
+ }
702
+ function P({ content: e, styles: t }) {
703
+ const n = x({
704
+ "adv-u-font-weight-semi-bold": t == null ? void 0 : t.includes(te.Bold),
705
+ "adv-u-font-italic": t == null ? void 0 : t.includes(te.Italic)
706
+ });
707
+ return /* @__PURE__ */ u("span", { className: n, children: e });
708
+ }
709
+ function st({ title: e, contentElements: t }) {
710
+ return /* @__PURE__ */ u("section", { className: "adv-u-margin-bottom-48", children: [
711
+ /* @__PURE__ */ u(ce, { level: 2, className: "adv-u-margin-top-24 adv-u-margin-bottom-16", children: /* @__PURE__ */ u(P, { content: e.content, styles: e.styles }) }),
712
+ /* @__PURE__ */ u(S, { contentElements: t, isTopLevel: true })
713
+ ] });
714
+ }
715
+ const Be = Ae({
716
+ references: {},
717
+ addReference: () => {
718
+ }
719
+ });
720
+ function qe() {
721
+ const e = Ve(Be);
722
+ if (e === void 0)
723
+ throw new Error("useReferenceContext must be used within a ReferenceProvider");
724
+ return e;
725
+ }
726
+ const lt = (e) => new Promise((t) => {
727
+ setTimeout(t, e);
728
+ }), j = (e) => e ? `adyen-document-viewer-${e.replace(/[^\w-]/g, "").slice(0, 32)}` : void 0, ze = (e) => {
729
+ if (!e)
730
+ return null;
731
+ const t = e instanceof HTMLElement, n = t && window.getComputedStyle(e).overflowY;
732
+ return t && (n !== "visible" && n !== "hidden") ? e : ze(e.parentNode) ?? document.body;
733
+ };
734
+ const at = ({ onClick: e, label: t }) => /* @__PURE__ */ u("button", { className: "adv-link", type: "button", onClick: e, title: t, children: t });
735
+ function ut({
736
+ referencedLabel: e,
737
+ displayText: t
738
+ }) {
739
+ const n = t ? t.content : e, o = j(e) ?? "", { references: _ } = qe();
740
+ return /* @__PURE__ */ u(at, { onClick: async () => {
741
+ _ && o && _[o] && (_[o].openSection(), await lt(150));
742
+ const c = ze(document.getElementById(o)), s = c == null ? void 0 : c.querySelector(`#${o}`);
743
+ s == null || s.scrollIntoView({ behavior: "smooth" });
744
+ }, label: n });
745
+ }
746
+ function ft({ className: e, nested: t, ordered: n, noMarkers: o, children: _ }) {
747
+ const r = x([
748
+ "adv-list",
749
+ t && "adv-list--nested",
750
+ n && "adv-list--ordered",
751
+ o && "adv-list--no-markers",
752
+ e
753
+ ]);
754
+ return /* @__PURE__ */ u("ul", { className: r, children: _ });
755
+ }
756
+ function dt({ className: e, children: t, noMarkers: n }) {
757
+ const o = x(["adv-list__item", n && "adv-list__item--no-markers", e]);
758
+ return /* @__PURE__ */ u("li", { className: o, children: t });
759
+ }
760
+ function je({ items: e, style: t }) {
761
+ return /* @__PURE__ */ u(ft, { ordered: t.ordered, children: e.map((n, o) => /* @__PURE__ */ u(dt, { children: [
762
+ /* @__PURE__ */ u(S, { contentElements: n.content }),
763
+ n.subList && /* @__PURE__ */ u(je, { style: n.subList.style, items: n.subList.items })
764
+ ] }, o)) });
765
+ }
766
+ function pt({ isTopLevel: e, contentElements: t }) {
767
+ const n = x("adv-paragraph", {
768
+ "adv-u-margin-bottom-16": e
769
+ });
770
+ return /* @__PURE__ */ u("p", { className: n, children: /* @__PURE__ */ u(S, { contentElements: t }) });
771
+ }
772
+ function ht({
773
+ children: e,
774
+ collapsed: t = false
775
+ }) {
776
+ const n = rt(null), [o, _] = T(t ? 0 : void 0);
777
+ return H(() => {
778
+ var r;
779
+ _(t ? 0 : (r = n.current) == null ? void 0 : r.scrollHeight);
780
+ }, [t]), /* @__PURE__ */ u(
781
+ "div",
782
+ {
783
+ className: "adv-collapsible-container",
784
+ "aria-hidden": t,
785
+ ref: n,
786
+ style: { height: o },
787
+ children: e
788
+ }
789
+ );
790
+ }
791
+ const vt = ({ className: e = "", name: t }) => {
792
+ const n = {
793
+ "chevron-up": /* @__PURE__ */ u("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 15 15", width: "15", height: "15", children: /* @__PURE__ */ u(
794
+ "path",
795
+ {
796
+ fillRule: "evenodd",
797
+ d: "M13 10a1 1 0 0 1-1.743.669L7.5 6.495 3.743 10.67a1 1 0 0 1-1.486-1.338l4.5-5a1 1 0 0 1 1.486 0l4.5 5a.998.998 0 0 1 .257.67z"
798
+ }
799
+ ) }),
800
+ "chevron-down": /* @__PURE__ */ u("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 15 15", width: "15", height: "15", children: /* @__PURE__ */ u(
801
+ "path",
802
+ {
803
+ fillRule: "evenodd",
804
+ d: "M2 5a1 1 0 0 1 1.743-.669L7.5 8.505l3.757-4.174a1 1 0 0 1 1.486 1.338l-4.5 5a1 1 0 0 1-1.486 0l-4.5-5A.998.998 0 0 1 2 4.999z"
805
+ }
806
+ ) })
807
+ };
808
+ return /* @__PURE__ */ u("i", { className: x("adv-icon", e), role: "img", "aria-hidden": true, children: n[t] });
809
+ };
810
+ function mt() {
811
+ return Ve(Fe);
812
+ }
813
+ function yt({
814
+ children: e,
815
+ open: t = false,
816
+ title: n = "",
817
+ onOpen: o = () => {
818
+ },
819
+ onClose: _ = () => {
820
+ }
821
+ }) {
822
+ const { expand: r, items: c, setItems: s, onExpandSection: a } = mt(), [l, p] = T(t), [i] = T(Re), h = () => {
823
+ const f = !l, v = [...c];
824
+ r ? (v.find((w) => w.id === i).isOpen = f, s(v)) : s(v.map((w) => ({ ...w, isOpen: w.id === i ? f : false })));
825
+ };
826
+ return H(() => {
827
+ s((f) => [...f, { id: i, isOpen: l }]);
828
+ }, []), H(() => {
829
+ p(t);
830
+ }, [t]), H(() => {
831
+ var f;
832
+ p(((f = c.find((v) => v.id === i)) == null ? void 0 : f.isOpen) ?? false);
833
+ }, [c]), H(() => {
834
+ l ? (a == null || a(n), o()) : _();
835
+ }, [l]), /* @__PURE__ */ u("div", { className: "adv-accordion__item", children: [
836
+ /* @__PURE__ */ u("div", { role: "button", className: "adv-accordion__header", tabIndex: 0, onClick: h, children: [
837
+ /* @__PURE__ */ u(vt, { name: l ? "chevron-up" : "chevron-down", className: "adv-accordion__toggle" }),
838
+ /* @__PURE__ */ u("div", { className: "adv-accordion__title-wrapper", children: /* @__PURE__ */ u("div", { className: "adv-accordion__title", children: n }) })
839
+ ] }),
840
+ /* @__PURE__ */ u(ht, { collapsed: !l, children: /* @__PURE__ */ u("div", { className: "adv-accordion__content", children: e }) })
841
+ ] });
842
+ }
843
+ const Ge = (e) => {
844
+ if (typeof e != "object" || e === null)
845
+ return [];
846
+ const t = [];
847
+ "label" in e && typeof e.label == "string" && e.label !== "" && t.push(e.label);
848
+ for (const n in e) {
849
+ const o = e[n];
850
+ (Array.isArray(o) || typeof o == "object" && o !== null) && t.push(...Ge(o));
851
+ }
852
+ return t;
853
+ };
854
+ function bt({
855
+ title: e,
856
+ label: t,
857
+ isTopLevel: n,
858
+ contentElements: o
859
+ }) {
860
+ const [_, r] = T(false), { addReference: c } = qe(), s = j(t);
861
+ return H(() => {
862
+ if (n) {
863
+ const a = Ge(o).map(j);
864
+ s && a.push(s), a.length && a.forEach((l) => {
865
+ c({ [l]: { openSection: () => r(true) } });
866
+ });
867
+ }
868
+ }, []), n ? /* @__PURE__ */ u(
869
+ yt,
870
+ {
871
+ title: e.content,
872
+ open: _,
873
+ onOpen: () => {
874
+ r(true);
875
+ },
876
+ onClose: () => {
877
+ r(false);
878
+ },
879
+ children: /* @__PURE__ */ u("section", { className: "adv-section-box", id: s, children: /* @__PURE__ */ u(S, { contentElements: o }) })
880
+ }
881
+ ) : /* @__PURE__ */ u("section", { id: s, children: [
882
+ /* @__PURE__ */ u(ce, { level: 2, className: "adv-u-margin-top-24 adv-u-margin-bottom-16", children: /* @__PURE__ */ u(P, { content: e.content, styles: e.styles }) }),
883
+ /* @__PURE__ */ u(S, { contentElements: o })
884
+ ] });
885
+ }
886
+ function gt({
887
+ rows: e,
888
+ label: t,
889
+ captions: n,
890
+ titlePrefix: o,
891
+ title: _
892
+ }) {
893
+ const r = j(t);
894
+ return /* @__PURE__ */ u("div", { id: r, children: [
895
+ /* @__PURE__ */ u("div", { className: "adv-u-margin-y-8 adv-u-text-align-center", children: [
896
+ o && /* @__PURE__ */ u(P, { ...o }),
897
+ o && _ && " ",
898
+ _ && /* @__PURE__ */ u(P, { ..._ })
899
+ ] }),
900
+ /* @__PURE__ */ u("table", { className: "adv-table adv-table--condensed", children: [
901
+ n && /* @__PURE__ */ u("caption", { children: /* @__PURE__ */ u(S, { contentElements: n }) }),
902
+ /* @__PURE__ */ u("tbody", { className: "adv-table__body", children: e.map((c, s) => /* @__PURE__ */ u("tr", { className: "adv-table__row", children: c.map((a, l) => /* @__PURE__ */ u("td", { className: "adv-table__cell", children: /* @__PURE__ */ u(S, { contentElements: a.elements }) }, l)) }, s)) })
903
+ ] })
904
+ ] });
905
+ }
906
+ const wt = ({
907
+ className: e,
908
+ children: t,
909
+ href: n,
910
+ underline: o,
911
+ inheritStyles: _,
912
+ onClick: r
913
+ }) => {
914
+ const c = x("adv-link", e, {
915
+ "adv-link--underline": o,
916
+ "adv-link--inherit": _
917
+ });
918
+ return /* @__PURE__ */ u(
919
+ "a",
920
+ {
921
+ href: n,
922
+ className: c,
923
+ target: "_blank",
924
+ rel: "noopener noreferrer",
925
+ onClick: r,
926
+ children: /* @__PURE__ */ u("span", { className: "adv-link__text", children: t })
927
+ }
928
+ );
929
+ }, kt = ({ url: e, displayText: t }) => /* @__PURE__ */ u(wt, { href: e, children: t ? /* @__PURE__ */ u(P, { ...t }) : e }), Nt = {
930
+ chapter: st,
931
+ section: bt,
932
+ paragraph: pt,
933
+ text: P,
934
+ weblink: kt,
935
+ list: je,
936
+ table: gt,
937
+ internalReference: ut,
938
+ breakline: "br"
939
+ }, xt = (e) => `key-${e}-${Re()}`, $t = (e, t) => {
940
+ if (!("type" in e))
941
+ return null;
942
+ switch (e.type) {
943
+ case N.Chapter:
944
+ return {
945
+ title: e.title,
946
+ contentElements: e.contentElements
947
+ };
948
+ case N.Section:
949
+ return {
950
+ isTopLevel: t,
951
+ title: e.title,
952
+ label: e.label,
953
+ contentElements: e.contentElements
954
+ };
955
+ case N.Paragraph:
956
+ return {
957
+ isTopLevel: t,
958
+ contentElements: e.contentElements
959
+ };
960
+ case N.Text:
961
+ return {
962
+ content: e.content,
963
+ styles: e.styles
964
+ };
965
+ case N.Weblink:
966
+ return {
967
+ url: e.url,
968
+ displayText: e.displayText
969
+ };
970
+ case N.List:
971
+ return {
972
+ items: e.items,
973
+ style: e.style
974
+ };
975
+ case N.Table:
976
+ return {
977
+ rows: e.rows,
978
+ label: e.label,
979
+ captions: e.captions,
980
+ titlePrefix: e.titlePrefix,
981
+ title: e.title
982
+ };
983
+ case N.InternalReference:
984
+ return {
985
+ referencedLabel: e.referencedLabel,
986
+ displayText: e.displayText
987
+ };
988
+ default:
989
+ return null;
990
+ }
991
+ };
992
+ function S({
993
+ contentElements: e,
994
+ isTopLevel: t = false,
995
+ onExpandSection: n,
996
+ multiple: o
997
+ }) {
998
+ const _ = e.map((r) => {
999
+ if (!("type" in r))
1000
+ return null;
1001
+ const c = Nt[r.type];
1002
+ return /* @__PURE__ */ u(c, { ...$t(r, t) }, xt(r.type));
1003
+ });
1004
+ return t ? /* @__PURE__ */ u(ct, { onExpandSection: n, expand: o, children: _ }) : /* @__PURE__ */ u("span", { children: _ });
1005
+ }
1006
+ function Ct({ children: e }) {
1007
+ const [t, n] = T({}), o = Oe(
1008
+ () => ({
1009
+ addReference: (_) => {
1010
+ n((r) => ({
1011
+ ...r,
1012
+ ..._
1013
+ }));
1014
+ },
1015
+ references: t
1016
+ }),
1017
+ [t, n]
1018
+ );
1019
+ return /* @__PURE__ */ u(Be.Provider, { value: o, children: e });
1020
+ }
1021
+ function St({
1022
+ document: e,
1023
+ className: t,
1024
+ onExpandSection: n,
1025
+ multiple: o
1026
+ }) {
1027
+ const _ = x("adyen-document-viewer", t);
1028
+ return /* @__PURE__ */ u(Ct, { children: /* @__PURE__ */ u("div", { className: _, children: [
1029
+ /* @__PURE__ */ u(ce, { level: 1, className: "adv-u-margin-top-24 adv-u-margin-bottom-16", children: /* @__PURE__ */ u(P, { content: e.title.content, styles: e.title.styles }) }),
1030
+ /* @__PURE__ */ u(
1031
+ S,
1032
+ {
1033
+ contentElements: e.contentElements,
1034
+ onExpandSection: n,
1035
+ multiple: o,
1036
+ isTopLevel: true
1037
+ }
1038
+ )
1039
+ ] }) });
1040
+ }
1041
+ function ke(e) {
1042
+ return "type" in e && e.type === N.Section;
1043
+ }
1044
+ function Ne(e) {
1045
+ return "contentElements" in e && Array.isArray(e.contentElements);
1046
+ }
1047
+ function Et(e) {
1048
+ return e.isTopLevel ? `${e.counter}` : `${e.prefix}${e.counter}`;
1049
+ }
1050
+ function Pt(e, t) {
1051
+ return `${e} ${t}`;
1052
+ }
1053
+ function oe(e, t) {
1054
+ if (ke(e)) {
1055
+ const n = Et(t), o = {
1056
+ ...e,
1057
+ title: {
1058
+ ...e.title,
1059
+ content: Pt(n, e.title.content)
1060
+ }
1061
+ };
1062
+ if (t.counter += 1, Ne(e)) {
1063
+ let _ = 1;
1064
+ o.contentElements = e.contentElements.map((r) => {
1065
+ if (ke(r)) {
1066
+ const c = {
1067
+ prefix: `${n}.`,
1068
+ counter: _,
1069
+ isTopLevel: false
1070
+ };
1071
+ return _ += 1, oe(r, c);
1072
+ }
1073
+ return r;
1074
+ });
1075
+ }
1076
+ return o;
1077
+ }
1078
+ return Ne(e) ? {
1079
+ ...e,
1080
+ contentElements: e.contentElements.map(
1081
+ (n) => oe(n, t)
1082
+ )
1083
+ } : e;
1084
+ }
1085
+ function Ht(e) {
1086
+ const t = { prefix: "", counter: 1, isTopLevel: true };
1087
+ return {
1088
+ ...e,
1089
+ contentElements: e.contentElements.map(
1090
+ (n) => oe(n, t)
1091
+ )
1092
+ };
1093
+ }
1094
+ class Lt {
1095
+ /**
1096
+ * Initializes the library
1097
+ * @param target - The target element (HTMLElement or querySelector string)
1098
+ * @param options - Configuration options for AdyenDocumentViewer
1099
+ */
1100
+ constructor(t, n = {}) {
1101
+ if (typeof t == "object" && "nodeType" in t)
1102
+ this.target = t;
1103
+ else {
1104
+ const o = window.document.querySelector(t);
1105
+ if (o instanceof HTMLElement)
1106
+ this.target = o;
1107
+ else
1108
+ throw new Error("Target element was not found");
1109
+ }
1110
+ this.options = {
1111
+ onExpandSection: n.onExpandSection ?? void 0,
1112
+ multiple: n.multiple ?? false,
1113
+ showSectionNumbering: n.showSectionNumbering ?? false
1114
+ };
1115
+ }
1116
+ /**
1117
+ * Renders the document
1118
+ * @param document - The JSON document
1119
+ */
1120
+ render(t) {
1121
+ const n = this.options.showSectionNumbering ? Ht(t) : t;
1122
+ Ze(
1123
+ /* @__PURE__ */ u(
1124
+ St,
1125
+ {
1126
+ document: n,
1127
+ onExpandSection: this.options.onExpandSection,
1128
+ multiple: this.options.multiple
1129
+ }
1130
+ ),
1131
+ this.target
1132
+ );
1133
+ }
1134
+ }
1135
+ function ContractViewer({
1136
+ contract,
1137
+ className,
1138
+ onExpandSection,
1139
+ showSectionNumbering
1140
+ }) {
1141
+ const classNames = cx("adyen-contract-viewer", className);
1142
+ const container = useRef(null);
1143
+ const [adyenDocumentViewer, setAdyenDocumentViewer] = useState(null);
1144
+ useEffect(() => {
1145
+ if (container.current && !adyenDocumentViewer) {
1146
+ setAdyenDocumentViewer(
1147
+ new Lt(container.current, { onExpandSection, showSectionNumbering })
1148
+ );
1149
+ }
1150
+ if (adyenDocumentViewer && contract) {
1151
+ adyenDocumentViewer.render(contract);
1152
+ }
1153
+ }, [contract, adyenDocumentViewer, onExpandSection, showSectionNumbering]);
1154
+ return /* @__PURE__ */ jsx("div", { ref: container, className: classNames });
1155
+ }
1156
+ const logger$1 = createLogger();
1157
+ const FALLBACK_LANGUAGE_CODE$1 = "en";
1158
+ const useServiceAgreement = ({
1159
+ handleServiceAgreementIsNotAvailableInThatLanguage,
1160
+ acceptanceId,
1161
+ serviceAgreementType,
1162
+ language
1163
+ }) => {
1164
+ const [agreementLanguage, setAgreementLanguage] = useState(language);
1165
+ useEffect(() => {
1166
+ if (agreementLanguage !== language) {
1167
+ setAgreementLanguage(language);
1168
+ }
1169
+ }, [language]);
1170
+ const {
1171
+ data: unAcceptedServiceAgreement,
1172
+ isSuccess: isUnAcceptedServiceAgreementSuccess,
1173
+ isError,
1174
+ error
1175
+ } = useTermsOfService(
1176
+ {
1177
+ language: agreementLanguage,
1178
+ type: serviceAgreementType,
1179
+ termsOfServiceDocumentFormat: "JSON"
1180
+ },
1181
+ { enabled: !acceptanceId }
1182
+ );
1183
+ const { data: acceptedServiceAgreement, isSuccess: isAcceptedServiceAgreementSuccess } = useAcceptedTermsOfService(acceptanceId, "JSON");
1184
+ if (isUnAcceptedServiceAgreementSuccess || isAcceptedServiceAgreementSuccess) {
1185
+ const termsOfService = unAcceptedServiceAgreement ?? acceptedServiceAgreement;
1186
+ const documentId = (unAcceptedServiceAgreement == null ? void 0 : unAcceptedServiceAgreement.termsOfServiceDocumentId) ?? (acceptedServiceAgreement == null ? void 0 : acceptedServiceAgreement.termsOfServiceAcceptanceReference);
1187
+ if ((termsOfService == null ? void 0 : termsOfService.document) && documentId) {
1188
+ const contract = JSON.parse(decodeURIComponent(escape(window.atob(termsOfService.document))));
1189
+ return {
1190
+ loading: "success",
1191
+ serviceAgreement: {
1192
+ id: documentId,
1193
+ contract
1194
+ }
1195
+ };
1196
+ }
1197
+ }
1198
+ if (isError) {
1199
+ if (agreementLanguage !== FALLBACK_LANGUAGE_CODE$1) {
1200
+ handleServiceAgreementIsNotAvailableInThatLanguage();
1201
+ setAgreementLanguage(FALLBACK_LANGUAGE_CODE$1);
1202
+ } else {
1203
+ logger$1.error(error);
1204
+ }
1205
+ return {
1206
+ loading: "success",
1207
+ serviceAgreement: void 0
1208
+ };
1209
+ }
1210
+ return {
1211
+ loading: "loading",
1212
+ serviceAgreement: void 0
1213
+ };
1214
+ };
1215
+ const serviceAgreementValidationRules = {
1216
+ signer: { modes: ["blur"], validate: (signer) => !!signer, errorMessage: "fieldIsRequired" },
1217
+ acceptServiceAgreement: {
1218
+ modes: ["blur"],
1219
+ validate: (acceptServiceAgreement) => !!acceptServiceAgreement,
1220
+ errorMessage: "fieldIsRequired"
1221
+ }
1222
+ };
1223
+ const serviceAgreementTypesTranslationMapping = {
1224
+ adyenForPlatformsManage: "paymentProcessingTerms",
1225
+ adyenIssuing: "accountHolderTerms",
1226
+ adyenForPlatformsAdvanced: "paymentProcessingTerms",
1227
+ adyenCapital: "capitalUserTerms",
1228
+ adyenAccount: "businessAccountTerms",
1229
+ adyenCard: "cardUserTerms",
1230
+ adyenFranchisee: "franchiseesTAndCs",
1231
+ adyenPccr: "pccr",
1232
+ adyenChargeCard: "chargeCardUserAgreement"
1233
+ };
1234
+ const logger = createLogger();
1235
+ const FALLBACK_LANGUAGE_CODE = "en";
1236
+ function ServiceAgreementDropin({
1237
+ legalEntityResponse,
1238
+ handleHomeClick,
1239
+ handleAddSigner,
1240
+ handleSign,
1241
+ serviceAgreementTypes,
1242
+ serviceAgreementAcceptanceInfos,
1243
+ asEmbedded = false,
1244
+ asModal = false,
1245
+ handleCloseClick
1246
+ }) {
1247
+ var _a, _b;
1248
+ const { i18n } = useI18nContext();
1249
+ const userEvents = useAnalyticsContext();
1250
+ const { showToast } = useToastContext();
1251
+ const { isExperimentEnabled } = useExperimentsContext();
1252
+ const isAgeVerificationEnabled = isExperimentEnabled("EnableAgeVerification");
1253
+ const { legalEntityId, baseUrl } = useApiContext();
1254
+ const [loadingStatus, setLoadingStatus] = useState();
1255
+ const signedForms = serviceAgreementAcceptanceInfos.map((serviceAgreementAcceptanceInfo) => ({
1256
+ formId: serviceAgreementAcceptanceInfo.id,
1257
+ serviceAgreementType: serviceAgreementAcceptanceInfo.type,
1258
+ acceptanceId: serviceAgreementAcceptanceInfo.id,
1259
+ createdAt: serviceAgreementAcceptanceInfo.createdAt,
1260
+ formName: serviceAgreementTypesTranslationMapping[serviceAgreementAcceptanceInfo.type],
1261
+ isValid: true
1262
+ }));
1263
+ const formsToBeSigned = serviceAgreementTypes.map((serviceAgreementType) => ({
1264
+ formId: serviceAgreementType,
1265
+ serviceAgreementType,
1266
+ formName: serviceAgreementTypesTranslationMapping[serviceAgreementType],
1267
+ isValid: false
1268
+ }));
1269
+ const forms = [...signedForms, ...formsToBeSigned];
1270
+ const [activeFormIndex, setActiveFormIndex] = useState(0);
1271
+ const [activeForm, setActiveForm] = useState(forms[activeFormIndex]);
1272
+ const [hasFinished, setHasFinished] = useState(false);
1273
+ const canSign = (serviceAgreementTypes == null ? void 0 : serviceAgreementTypes.includes(activeForm == null ? void 0 : activeForm.serviceAgreementType)) && !(activeForm == null ? void 0 : activeForm.acceptanceId);
1274
+ const isLastStep = activeFormIndex === forms.length - 1;
1275
+ const showSignedAlert = !!(activeForm == null ? void 0 : activeForm.acceptanceId);
1276
+ const translationKeys = {
1277
+ home: "goToOverview",
1278
+ next: canSign ? "sign" : "next"
1279
+ };
1280
+ const { refetch: downloadAcceptedTermsAsPdf } = useAcceptedTermsOfService(
1281
+ activeForm == null ? void 0 : activeForm.acceptanceId,
1282
+ "PDF",
1283
+ {
1284
+ enabled: false
1285
+ }
1286
+ );
1287
+ const handleServiceAgreementIsNotAvailableInThatLanguage = useCallback(() => {
1288
+ showToast({
1289
+ label: i18n.get("failedToGetServiceAgreementInSelectedLanguageFallbackToEn"),
1290
+ variant: "error"
1291
+ });
1292
+ }, [i18n, showToast]);
1293
+ const { loading: contractLoadingStatus, serviceAgreement } = useServiceAgreement({
1294
+ handleServiceAgreementIsNotAvailableInThatLanguage,
1295
+ acceptanceId: activeForm == null ? void 0 : activeForm.acceptanceId,
1296
+ serviceAgreementType: activeForm == null ? void 0 : activeForm.serviceAgreementType,
1297
+ language: i18n.languageCode
1298
+ });
1299
+ const { handleChangeFor, triggerValidation, data, valid, isValid, errors } = useForm({
1300
+ schema: ["signer", "acceptServiceAgreement"],
1301
+ rules: serviceAgreementValidationRules
1302
+ });
1303
+ const getSigners = () => {
1304
+ var _a2, _b2;
1305
+ if (legalEntityResponse.type === LegalEntityType.ORGANIZATION) {
1306
+ return getOwnSignatories(legalEntityResponse).map(({ legalEntityId: id, name }) => ({
1307
+ id: id ?? "",
1308
+ name: name ?? ""
1309
+ }));
1310
+ }
1311
+ if (isAgeVerificationEnabled && doesLegalEntityRequiresLegalRepresentative(legalEntityResponse)) {
1312
+ const legalRepresentative = getLegalRepresentative(legalEntityResponse);
1313
+ return legalRepresentative ? [{ id: legalRepresentative.legalEntityId, name: legalRepresentative.name }] : [];
1314
+ }
1315
+ return [
1316
+ {
1317
+ id: legalEntityResponse == null ? void 0 : legalEntityResponse.id,
1318
+ name: `${(_a2 = legalEntityResponse == null ? void 0 : legalEntityResponse.individual) == null ? void 0 : _a2.name.firstName} ${(_b2 = legalEntityResponse == null ? void 0 : legalEntityResponse.individual) == null ? void 0 : _b2.name.lastName}`
1319
+ }
1320
+ ];
1321
+ };
1322
+ const signers = getSigners();
1323
+ const handleSignClick = async () => {
1324
+ const baseTracking = {
1325
+ actionType: "sign"
1326
+ };
1327
+ triggerValidation();
1328
+ if (loadingStatus === "loading" || !serviceAgreement || !data.signer) return;
1329
+ if (isValid) {
1330
+ try {
1331
+ setLoadingStatus("loading");
1332
+ await handleSign(legalEntityResponse.id, serviceAgreement.id, { acceptedBy: data.signer });
1333
+ setLoadingStatus("success");
1334
+ showToast({
1335
+ label: i18n.get("serviceAgreementSignedSuccessfully"),
1336
+ variant: "success"
1337
+ });
1338
+ userEvents.addTaskEvent("Success", baseTracking);
1339
+ data.acceptServiceAgreement = false;
1340
+ data.signer = void 0;
1341
+ } catch (e) {
1342
+ setLoadingStatus("success");
1343
+ showToast({ label: i18n.get("serviceAgreementSignFailed"), variant: "error" });
1344
+ userEvents.addTaskEvent("Encountered error", {
1345
+ ...baseTracking,
1346
+ returnType: (e == null ? void 0 : e.errorCode) || "backend",
1347
+ returnValue: (e == null ? void 0 : e.title) ?? (e == null ? void 0 : e.message)
1348
+ });
1349
+ }
1350
+ } else {
1351
+ userEvents.addTaskEvent("Encountered error", {
1352
+ ...baseTracking,
1353
+ returnType: "validation",
1354
+ returnValue: Object.entries(valid).filter(([, value]) => !value).map(([key]) => key)
1355
+ });
1356
+ }
1357
+ };
1358
+ const goHome = () => {
1359
+ userEvents.addPageEvent("Clicked button", {
1360
+ actionType: "back",
1361
+ label: translationKeys.home
1362
+ });
1363
+ handleHomeClick();
1364
+ };
1365
+ const handleExpandSection = useCallback((title) => {
1366
+ userEvents.addFieldEvent("Clicked accordion", {
1367
+ actionType: "open",
1368
+ field: title
1369
+ });
1370
+ }, []);
1371
+ useEffect(() => {
1372
+ if (!serviceAgreementAcceptanceInfos.length) return;
1373
+ gotoForm(serviceAgreementAcceptanceInfos.length - 1);
1374
+ }, [serviceAgreementAcceptanceInfos]);
1375
+ useEffect(() => {
1376
+ userEvents.addTaskEvent("Landed on page", {
1377
+ actionType: "start"
1378
+ });
1379
+ const initialFormIndex = forms.length === signedForms.length ? 0 : signedForms.length;
1380
+ gotoForm(initialFormIndex);
1381
+ }, []);
1382
+ useEffect(() => {
1383
+ userEvents.updateSharedEventProperties({ page: activeForm == null ? void 0 : activeForm.formName });
1384
+ }, [activeForm]);
1385
+ const gotoForm = (index) => {
1386
+ setActiveForm(forms[index]);
1387
+ setActiveFormIndex(index);
1388
+ };
1389
+ const onDownloadAcceptedTermsOfServiceDocument = async () => {
1390
+ const { isError, isSuccess, data: data2 } = await downloadAcceptedTermsAsPdf();
1391
+ if (isSuccess && (data2 == null ? void 0 : data2.document)) {
1392
+ await downloadFile(data2.document, `${i18n.get(activeForm.formName)}.pdf`);
1393
+ }
1394
+ if (isError) {
1395
+ showToast({
1396
+ label: i18n.get("failedToDownloadAcceptedServiceAgreementDocument"),
1397
+ variant: "error"
1398
+ });
1399
+ }
1400
+ };
1401
+ const onDownloadUnacceptedTermsOfServiceDocument = async () => {
1402
+ const requestAndDownload = async (languageCode) => {
1403
+ const response = await getTermsOfService(legalEntityId.value, baseUrl.value, {
1404
+ type: activeForm.serviceAgreementType,
1405
+ language: languageCode,
1406
+ termsOfServiceDocumentFormat: "PDF"
1407
+ });
1408
+ if (!(response == null ? void 0 : response.document)) {
1409
+ throw new Error(`No terms Of service document found in response`);
1410
+ }
1411
+ await downloadFile(response.document, `${i18n.get(activeForm.formName)}.pdf`);
1412
+ };
1413
+ try {
1414
+ await requestAndDownload(i18n.languageCode);
1415
+ } catch {
1416
+ if (i18n.languageCode !== FALLBACK_LANGUAGE_CODE) {
1417
+ await requestAndDownload(FALLBACK_LANGUAGE_CODE).catch(logger.error);
1418
+ return;
1419
+ }
1420
+ showToast({
1421
+ label: i18n.get("failedToDownloadServiceAgreementDocument"),
1422
+ variant: "error"
1423
+ });
1424
+ }
1425
+ };
1426
+ const isIndividual = legalEntityResponse.type === "individual";
1427
+ const addSignerAlert = handleAddSigner && /* @__PURE__ */ jsx(
1428
+ Alert,
1429
+ {
1430
+ variant: signers.length ? "info" : "warning",
1431
+ className: "adyen-kyc-u-margin-top-16",
1432
+ title: i18n.get(signers.length ? "isYourNameMissingFromSigners" : "thereAreNoSigners"),
1433
+ children: /* @__PURE__ */ jsx(Button, { onClick: handleAddSigner, variant: "link", children: i18n.get("addYourselfAsSigner") })
1434
+ }
1435
+ );
1436
+ const getSignedName = (acceptanceId) => {
1437
+ var _a2, _b2, _c;
1438
+ if (!acceptanceId) return "";
1439
+ if (legalEntityResponse.type === LegalEntityType.INDIVIDUAL) {
1440
+ const name = (_a2 = legalEntityResponse.individual) == null ? void 0 : _a2.name;
1441
+ return `${(name == null ? void 0 : name.firstName) ?? ""} ${(name == null ? void 0 : name.lastName) ?? ""}`;
1442
+ }
1443
+ const signatory = serviceAgreementAcceptanceInfos.find((info) => info.id === acceptanceId);
1444
+ return ((_c = (_b2 = legalEntityResponse.entityAssociations) == null ? void 0 : _b2.find(
1445
+ (entity) => entity.legalEntityId === (signatory == null ? void 0 : signatory.acceptedBy)
1446
+ )) == null ? void 0 : _c.name) ?? "";
1447
+ };
1448
+ const signedAlert = showSignedAlert && /* @__PURE__ */ jsx(
1449
+ Alert,
1450
+ {
1451
+ variant: "success",
1452
+ className: "adyen-kyc-signed-alert",
1453
+ title: i18n.get("signedByOn", {
1454
+ values: {
1455
+ date: localizeDateString(activeForm.createdAt, i18n.locale) ?? "",
1456
+ signer: getSignedName(activeForm.acceptanceId)
1457
+ }
1458
+ })
1459
+ }
1460
+ );
1461
+ const sidebar = /* @__PURE__ */ jsx(
1462
+ LoaderWrapper,
1463
+ {
1464
+ status: loadingStatus,
1465
+ formOpacityWhenLoading: 0.3,
1466
+ showSpinner: false,
1467
+ className: "adyen-kyc-dropin__sidebar-wrapper",
1468
+ children: /* @__PURE__ */ jsx(
1469
+ FormNavigation,
1470
+ {
1471
+ forms,
1472
+ activeForm,
1473
+ gotoForm,
1474
+ taskName: "signServiceAgreement",
1475
+ className: "adyen-kyc-u-margin-bottom-24"
1476
+ }
1477
+ )
1478
+ }
1479
+ );
1480
+ const content = /* @__PURE__ */ jsxs(
1481
+ LoaderWrapper,
1482
+ {
1483
+ status: loadingStatus,
1484
+ formOpacityWhenLoading: 0.3,
1485
+ showSpinner: false,
1486
+ className: "adyen-kyc-form-container",
1487
+ children: [
1488
+ /* @__PURE__ */ jsxs(
1489
+ LoaderWrapper,
1490
+ {
1491
+ status: contractLoadingStatus,
1492
+ formOpacityWhenLoading: 0.3,
1493
+ showSpinner: false,
1494
+ children: [
1495
+ serviceAgreement && /* @__PURE__ */ jsxs(Fragment, { children: [
1496
+ signedAlert,
1497
+ /* @__PURE__ */ jsx(
1498
+ ContractViewer,
1499
+ {
1500
+ contract: serviceAgreement.contract,
1501
+ onExpandSection: handleExpandSection,
1502
+ showSectionNumbering: true
1503
+ }
1504
+ ),
1505
+ signedAlert,
1506
+ /* @__PURE__ */ jsx("div", { className: "adyen-kyc-u-margin-top-16", children: /* @__PURE__ */ jsx(
1507
+ Button,
1508
+ {
1509
+ variant: "secondary",
1510
+ onClick: (activeForm == null ? void 0 : activeForm.acceptanceId) ? onDownloadAcceptedTermsOfServiceDocument : onDownloadUnacceptedTermsOfServiceDocument,
1511
+ icon: "download",
1512
+ children: i18n.get("downloadAsPdf")
1513
+ }
1514
+ ) })
1515
+ ] }),
1516
+ !forms.length && /* @__PURE__ */ jsx(Alert, { variant: "info", title: i18n.get("nothingNeedsToBeSigned") })
1517
+ ]
1518
+ }
1519
+ ),
1520
+ canSign && /* @__PURE__ */ jsxs(Fragment, { children: [
1521
+ !!signers.length && /* @__PURE__ */ jsx(
1522
+ Field,
1523
+ {
1524
+ name: "signer",
1525
+ label: i18n.get("signer"),
1526
+ classNameModifiers: ["col-50"],
1527
+ className: "adyen-kyc-u-margin-top-32",
1528
+ errorMessage: (_a = errors.signer) == null ? void 0 : _a.errorMessage,
1529
+ isValid: valid.signer,
1530
+ children: (childProps) => /* @__PURE__ */ jsx(
1531
+ Select,
1532
+ {
1533
+ ...childProps,
1534
+ onChange: handleChangeFor("signer", "blur"),
1535
+ name: "signer",
1536
+ placeholder: i18n.get("selectSigner"),
1537
+ selected: data.signer,
1538
+ items: signers
1539
+ }
1540
+ )
1541
+ }
1542
+ ),
1543
+ !isIndividual && addSignerAlert,
1544
+ /* @__PURE__ */ jsx(
1545
+ Field,
1546
+ {
1547
+ el: "fieldset",
1548
+ name: "acceptServiceAgreement",
1549
+ className: "adyen-kyc-u-margin-top-16",
1550
+ errorMessage: (_b = errors.acceptServiceAgreement) == null ? void 0 : _b.errorMessage,
1551
+ isValid: valid.acceptServiceAgreement,
1552
+ children: (childProps) => /* @__PURE__ */ jsx(
1553
+ Checkbox,
1554
+ {
1555
+ ...childProps,
1556
+ label: i18n.get("iHaveReadAndIAcceptTheseTerms"),
1557
+ checked: data.acceptServiceAgreement ?? false,
1558
+ name: "acceptServiceAgreement",
1559
+ onChange: handleChangeFor("acceptServiceAgreement")
1560
+ }
1561
+ )
1562
+ }
1563
+ )
1564
+ ] }),
1565
+ !asEmbedded && /* @__PURE__ */ jsx(
1566
+ ActionBar,
1567
+ {
1568
+ onHome: goHome,
1569
+ homeButtonLabel: i18n.get(translationKeys.home),
1570
+ onNext: canSign ? handleSignClick : () => gotoForm(activeFormIndex + 1),
1571
+ nextButtonLabel: i18n.get(translationKeys.next),
1572
+ nextButtonDisabled: forms.length === 0 || !canSign && isLastStep,
1573
+ onBack: () => gotoForm(activeFormIndex - 1),
1574
+ hideBackButton: activeFormIndex === 0,
1575
+ backButtonLabel: i18n.get("previous")
1576
+ }
1577
+ )
1578
+ ]
1579
+ }
1580
+ );
1581
+ const currentStep = signedForms.length;
1582
+ const totalSteps = forms.length;
1583
+ const handleClick = async () => {
1584
+ if (canSign) {
1585
+ await handleSignClick();
1586
+ } else if (!isLastStep) {
1587
+ gotoForm(activeFormIndex + 1);
1588
+ } else {
1589
+ setHasFinished(true);
1590
+ }
1591
+ };
1592
+ const endScreen = hasFinished && /* @__PURE__ */ jsxs(FormEndState, { children: [
1593
+ /* @__PURE__ */ jsx("template", { slot: "title", children: i18n.get("serviceAgreementSignedAndDated") }),
1594
+ /* @__PURE__ */ jsx(OutlinedIcon, { slot: "icon", name: "check" }),
1595
+ /* @__PURE__ */ jsx("div", { slot: "content", children: /* @__PURE__ */ jsx(Button, { onClick: () => handleCloseClick, children: i18n.get("finish") }) })
1596
+ ] });
1597
+ return /* @__PURE__ */ jsx(MaybeModal, { inline: !asModal, onClose: handleCloseClick, children: /* @__PURE__ */ jsxs(ModalContent, { children: [
1598
+ /* @__PURE__ */ jsxs("article", { className: "adyen-kyc-service-agreement-content", children: [
1599
+ !asEmbedded && sidebar,
1600
+ endScreen || content
1601
+ ] }),
1602
+ asEmbedded && /* @__PURE__ */ jsxs(ModalFooter, { children: [
1603
+ "...",
1604
+ /* @__PURE__ */ jsx(
1605
+ StepProgressIndicator,
1606
+ {
1607
+ activeStepIndex: currentStep ?? 0,
1608
+ stepsCount: totalSteps ?? 3,
1609
+ circles: true,
1610
+ thick: true
1611
+ }
1612
+ ),
1613
+ /* @__PURE__ */ jsx(Spacer, {}),
1614
+ !asModal && /* @__PURE__ */ jsx(
1615
+ Button,
1616
+ {
1617
+ icon: "chevron-left",
1618
+ onClick: () => gotoForm(activeFormIndex - 1),
1619
+ variant: "secondary",
1620
+ children: i18n.get("back")
1621
+ }
1622
+ ),
1623
+ /* @__PURE__ */ jsx(Button, { variant: canSign ? "primary" : "secondary", onClick: handleClick, children: i18n.get(canSign ? "signAndContinue" : "next") })
1624
+ ] })
1625
+ ] }) });
1626
+ }
1627
+ function AcceptTermsOfServiceComponent({
1628
+ legalEntityId,
1629
+ modalView,
1630
+ asEmbedded = true,
1631
+ /* triggered when X button clicked, or at the end, on Finish button click */
1632
+ onClose,
1633
+ onUnmount,
1634
+ /* triggered on every document signed, typically multiple times */
1635
+ onAccept,
1636
+ handleAddSigner
1637
+ }) {
1638
+ const { isModalView, setIsModalView } = useCoreContext();
1639
+ if (!legalEntityId) {
1640
+ throw new Error("Must provide at-least a legalEntityId");
1641
+ }
1642
+ const [stepsData, setStepsData] = useState({
1643
+ unAcceptedTermsOfServiceTypes: [],
1644
+ acceptedTermsOfServices: []
1645
+ });
1646
+ const { data: legalEntity } = useLegalEntity();
1647
+ const { data: serviceAgreementStatus, isLoading: isStatusLoading } = useTermsOfServiceStatus();
1648
+ const { data: serviceAgreementAcceptanceInfos, isLoading: isAcceptanceInfoLoading } = useTermsOfServiceAcceptanceInfos();
1649
+ const { mutateAsync: acceptTermsOfService2 } = useAcceptTermsOfService();
1650
+ if (modalView) {
1651
+ setIsModalView(true);
1652
+ }
1653
+ const handleOnClose = () => {
1654
+ if (modalView) {
1655
+ onUnmount == null ? void 0 : onUnmount();
1656
+ }
1657
+ onClose == null ? void 0 : onClose();
1658
+ };
1659
+ const handleSign = useCallback(
1660
+ async (legalEntityId2, termsOfServiceDocumentId, signedBy) => {
1661
+ var _a;
1662
+ const acceptedTermsOfService = await acceptTermsOfService2({
1663
+ acceptedBy: signedBy.acceptedBy,
1664
+ legalEntityReference: legalEntityId2,
1665
+ termsOfServiceDocumentId
1666
+ });
1667
+ const paramAllowList = {
1668
+ type: acceptedTermsOfService.type,
1669
+ acceptedBy: acceptedTermsOfService.acceptedBy,
1670
+ id: acceptedTermsOfService.id,
1671
+ language: acceptedTermsOfService.language,
1672
+ termsOfServiceDocumentId: acceptedTermsOfService.termsOfServiceDocumentId
1673
+ };
1674
+ const { acceptedTermsOfServices } = stepsData;
1675
+ acceptedTermsOfServices.push(paramAllowList);
1676
+ const unAcceptedTos = ((_a = serviceAgreementStatus == null ? void 0 : serviceAgreementStatus.termsOfServiceTypes) == null ? void 0 : _a.filter(
1677
+ (tosType) => tosType !== acceptedTermsOfService.type
1678
+ )) ?? [];
1679
+ const newStepsData = {
1680
+ unAcceptedTermsOfServiceTypes: unAcceptedTos,
1681
+ acceptedTermsOfServices
1682
+ };
1683
+ setStepsData(newStepsData);
1684
+ onAccept == null ? void 0 : onAccept(newStepsData);
1685
+ },
1686
+ [onAccept, stepsData, acceptTermsOfService2, serviceAgreementStatus == null ? void 0 : serviceAgreementStatus.termsOfServiceTypes]
1687
+ );
1688
+ return isStatusLoading || isAcceptanceInfoLoading || !legalEntity ? /* @__PURE__ */ jsx(Loader, { size: "medium" }) : /* @__PURE__ */ jsx(
1689
+ ServiceAgreementDropin,
1690
+ {
1691
+ taskType: TaskTypes.SERVICE_AGREEMENT,
1692
+ legalEntityResponse: legalEntity,
1693
+ serviceAgreementTypes: (serviceAgreementStatus == null ? void 0 : serviceAgreementStatus.termsOfServiceTypes) ?? [],
1694
+ serviceAgreementAcceptanceInfos: (serviceAgreementAcceptanceInfos == null ? void 0 : serviceAgreementAcceptanceInfos.data) ?? [],
1695
+ handleHomeClick: handleOnClose,
1696
+ handleSign,
1697
+ asEmbedded,
1698
+ asModal: isModalView,
1699
+ handleCloseClick: handleOnClose,
1700
+ handleAddSigner
1701
+ }
1702
+ );
1703
+ }
1704
+ const AcceptTermsOfServiceComponent$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1705
+ __proto__: null,
1706
+ AcceptTermsOfServiceComponent
1707
+ }, Symbol.toStringTag, { value: "Module" }));
1708
+ export {
1709
+ AcceptTermsOfServiceComponent as A,
1710
+ ContractViewer as C,
1711
+ FormEndState as F,
1712
+ OutlinedIcon as O,
1713
+ useTermsOfServiceStatus as a,
1714
+ AcceptTermsOfServiceComponent$1 as b,
1715
+ downloadFile as d,
1716
+ useTermsOfServiceAcceptanceInfos as u
1717
+ };