@adyen/kyc-components
Version:
This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.
1,443 lines • 96.4 kB
JavaScript
try {
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "a22a1875-14b5-4ace-9f6f-1d0ab4af553f", e._sentryDebugIdIdentifier = "sentry-dbid-a22a1875-14b5-4ace-9f6f-1d0ab4af553f");
} catch (e) {}
import { a as Icon, i as Typography, n as addResourceBundles, o as createLogger, r as useTranslation, s as initReactI18next } from "./translation-BYvhW5zA.js";
import { n as IconButton, r as Loader, t as Button } from "./Button-i8I2dHP8.js";
import { a as setSdkTokenHandler, i as refreshSession, n as httpGet, o as ApiProvider, r as httpPost, s as useApiContext } from "./http-8qgzqVqk.js";
import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-CtlUQv_J.js";
import { t as LegalEntityTypes } from "./legal-entity-type-0MfCGzUf.js";
import { t as getLegalEntityCountry } from "./getLegalEntityCountry-BHh7Ux8v.js";
import { n as SettingsContext, t as useSettingsContext } from "./useSettingsContext-Bpf4UqRT.js";
import { a as noop, c as entriesOf, l as keysOf, n as cloneObject, t as AnalyticsContext, u as valuesOf } from "./AnalyticsContext-BFrJmsp0.js";
import { t as StackLayout } from "./StackLayout-IUdNMDgW.js";
import { t as TaskVerificationStatus } from "./TaskVerificationStatus-CKHPTEpH.js";
import { i as TaskStatuses, r as TASK_STATUS_PRIORITY } from "./taskStatus-BtekPA8E.js";
import { t as CountryCodes } from "./country-code-CJk2hdPu.js";
import { n as Skeleton, t as Accordion } from "./Accordion-IXKjwyLD.js";
import { C as EntityTypes, n as getCapabilityProblems, t as getCapabilities, w as CUSTOMER_SUPPORT_DATA_MISSING_ERROR_CODES } from "./processCapabilities-fPuXc9gL.js";
import { t as TaskTypes } from "./taskTypes-NawDTp5n.js";
import { a as getLegalRepresentative, i as getDirectEntityAssociations, l as getOwnSoleProprietorshipIdArray } from "./entityAssociationUtil-C-wflW8q.js";
import { i as getOwnDecisionMakersLegalEntityIds, n as getDecisionMakers, o as hasMinRequiredDecisionMakerCount } from "./decisionMakerRoles-DIG8zo1C.js";
import { n as TrustMemberGuidanceLabels, r as TrustMemberTypes } from "./trustMemberGuidance-CgdU2v0j.js";
import { t as getNestedPropertyKeys } from "./getNestedPropertyKeys-Cd8HKupP.js";
import { n as isEuCountry, r as isHkSgCountry } from "./country-BxigZW1s.js";
import i18n from "i18next";
import { Suspense, lazy } from "preact/compat";
import { useCallback as useCallback$1, useContext as useContext$1, useEffect as useEffect$1, useMemo as useMemo$1, useReducer, useRef as useRef$1, useState as useState$1 } from "preact/hooks";
import cx from "classnames";
import { Fragment as Fragment$1, jsx, jsxs } from "preact/jsx-runtime";
import { computed, signal } from "@preact/signals";
import { QueryCache, QueryClient, QueryClientProvider, useMutation, useQuery } from "@tanstack/preact-query";
import { createContext as createContext$1, isValidElement as isValidElement$1 } from "preact";
import { defineSlots } from "named-slots";
//#region node_modules/.pnpm/vite-plugin-shadow-styles@0.0.3_vite@8.0.14_@types+node@25.9.2_esbuild@0.27.7_jiti@2.7.0_sass@1.99.0_/node_modules/vite-plugin-shadow-styles/dist/stylesheets.js
var sheet = new CSSStyleSheet();
var stylesheets = [sheet];
import("./styles-DYaAeu4q.js").then(({ css }) => {
sheet.replaceSync(css);
}).catch((err) => console.error("Error loading styles", err));
//#endregion
//#region src/language/i18n.ts
/**
* Initializes i18next and defines configurations
* i18next-resources-to-backend is a simple plugin used for the lazy loading of translation resources
*/
i18n.use(initReactI18next).init({
defaultNS: false,
fallbackLng: "en-US",
load: "currentOnly",
resources: {},
showSupportNotice: false,
react: {
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: [
"strong",
"i",
"em"
],
bindI18n: "languageChanged",
bindI18nStore: "added"
},
interpolation: {
prefix: "%{",
suffix: "}"
}
});
//#endregion
//#region src/api/configurations/useVersionConfiguration.ts
/**
* Retrieves information about the onboarding version and version-specific features to enable
* linked to the legalEntityId
*/
var getVersionConfiguration = async (legalEntityId, baseUrl) => {
return httpGet({
baseUrl,
path: `legalEntities/${legalEntityId}/configurations/version`
});
};
var useVersionConfiguration = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useQuery({
queryKey: ["versionConfiguration"],
queryFn: () => getVersionConfiguration(rootLegalEntityId.value, baseUrl.value),
...options
});
};
//#endregion
//#region src/api/uiAnalytics/useAnalyticsSession.ts
/**
* @description Request to get an analytics session ID and fire an "Initiate session" event on Mixpanel
* @param data.userData Sets user profile properties on Mixpanel
* @returns a session id that is sent with every subsequent log event request
*/
var getAnalyticsSession = async (baseUrl, data) => {
return httpPost({
baseUrl,
path: `analytics/ui`
}, data);
};
var useAnalyticsSession = (sessionData, onboardingVersion, options) => {
const { baseUrl } = useApiContext();
return useQuery({
queryKey: ["analyticsSession", onboardingVersion],
queryFn: () => getAnalyticsSession(baseUrl.value, sessionData),
enabled: Boolean(onboardingVersion),
...options
});
};
//#endregion
//#region src/core/user-events.ts
var UserEvents = class {
queue = [];
subscriptions = /* @__PURE__ */ new Set();
/** payload of commmon props sent in every event */
baseTrackingPayload;
/** properties not set with every event but that may be shared between some events
* ex. `page` value for `Interacted with form field` events
*/
sharedEventProperties;
constructor() {
this.baseTrackingPayload = {
category: "onboarding",
subCategory: "hosted onboarding"
};
this.sharedEventProperties = {};
}
add(...args) {
this.queue.push(...args);
}
notifySubscribers() {
while (this.queue.length > 0) {
const lastEvent = this.queue.pop();
this.subscriptions.forEach((callback) => callback(lastEvent));
}
}
/**
* Adds an analytics event with all base event properties.
*/
addEvent(eventName, properties) {
const completeEvent = {
...this.baseTrackingPayload,
...properties
};
this.add({
type: "add_event",
name: eventName,
properties: completeEvent
});
this.notifySubscribers();
}
/**
* Adds an event with context specific to journey-related events
*/
addJourneyEvent(eventName, properties) {
this.addEvent(eventName, {
actionLevel: "journey",
...properties
});
}
/**
* Adds an event with context specific to task-related events
*/
addTaskEvent(eventName, properties) {
this.addEvent(eventName, {
actionLevel: "task",
...properties
});
}
/**
* Adds an event with context specific to page-related events
*/
addPageEvent(eventName, properties) {
this.addEvent(eventName, {
actionLevel: "page",
page: this.sharedEventProperties.page,
...properties
});
}
/**
* Adds an event with context specific to field-related events
*/
addFieldEvent(eventName, properties) {
this.addEvent(eventName, {
actionLevel: "field",
page: this.sharedEventProperties.page,
...properties
});
}
/**
* Tracks an experiment for Mixpanel experiment reporting
*/
trackExperiment({ name, variant }) {
this.add({
type: "add_event",
name: "$experiment_started",
properties: {
...this.baseTrackingPayload,
"Experiment name": name,
"Variant name": variant
}
});
}
/**
* Subscribes a callback to analytics events. It gets called every time
* one of the above public methods get called, and the event data is passed back as an array.
* The callback must have a single argument which is an array of [eventName, eventPayload?].
* @example
* ```js
* const callback = ([eventName, eventPayload]) => console.log(eventName, eventPayload);
* this.subscribe(callback);
*
* const exampleEventPayload = { count: 1, segmentation: { foo: 'bar' } };
* this.addEvent('exampleEventDidOccur', exampleEventPayload);
*
* // `callback` will get called with `['exampleEventDidOccur', exampleEventPayload]`
* ```
*/
subscribe(callback) {
this.subscriptions.add(callback);
}
/**
* Sets params that are sent on every event
* */
updateBaseTrackingPayload(baseTrackingPayload) {
this.baseTrackingPayload = {
...this.baseTrackingPayload,
...baseTrackingPayload
};
}
/**
* Sets params that may be shared between events
* */
updateSharedEventProperties = (props) => {
this.sharedEventProperties = {
...this.sharedEventProperties,
...props
};
};
/**
* Removes a subscribed callback
*/
unsubscribe(callback) {
if (this.subscriptions.has(callback)) this.subscriptions.delete(callback);
}
};
var createUserEvents = () => {
return new UserEvents();
};
//#endregion
//#region src/api/uiAnalytics/usePushAnalyticEvent.ts
var pushAnalyticEvent = async (baseUrl, sessionId, data) => {
return httpPost({
baseUrl,
path: `analytics/ui/${sessionId}`
}, data);
};
var usePushAnalyticEvent = (sessionId, options) => {
const { baseUrl } = useApiContext();
return useMutation({
mutationFn: (data) => pushAnalyticEvent(baseUrl.value, sessionId, data),
...options
});
};
//#endregion
//#region src/utils/analytics/convertToEmbeddedEvent.ts
var convertToEmbeddedEvent = (eventQueueItem, sessionData) => {
const { type, name, properties } = eventQueueItem;
return {
eventName: name,
eventType: type,
eventData: properties || {},
legalEntityId: sessionData.legalEntityId,
userAgent: sessionData.userAgent,
componentName: sessionData.componentName,
sdkVersion: sessionData.sdkVersion
};
};
//#endregion
//#region src/utils/analytics/getAnalyticsAssociatedEntityDetails.ts
/**
* Gets associated legal entity type and ID for the base tracking payload
* Based on selected account holder type
*/
var getAnalyticsAssociatedEntityDetails = (rootLegalEntity, accountHolderType) => {
let associatedLegalEntityType;
switch (accountHolderType) {
case "aTrust":
associatedLegalEntityType = "trust";
break;
case "mySoleProprietorName":
associatedLegalEntityType = "soleProprietorship";
break;
case "anUnincorporatedPartnership":
associatedLegalEntityType = "unincorporatedPartnership";
break;
default: associatedLegalEntityType = void 0;
}
const associatedLegalEntity = rootLegalEntity.entityAssociations?.find((ea) => ea.type === associatedLegalEntityType);
return {
associatedLegalEntityType,
associatedLegalEntityId: associatedLegalEntity?.legalEntityId
};
};
//#endregion
//#region src/utils/testing/ignoreLocalStorage.tsx
var IgnoreLocalStorageContext = createContext$1(false);
var useIgnoreLocalStorage = () => useContext$1(IgnoreLocalStorageContext);
//#endregion
//#region src/hooks/useLocalStorage.ts
var logger$4 = createLogger();
var useLocalStorage = (key, defaultValue, options) => {
const { serializer, parser, syncData } = useMemo$1(() => ({
serializer: JSON.stringify,
parser: JSON.parse,
syncData: true,
...options
}), [options]);
const ignoreLocalStorage = useIgnoreLocalStorage() || typeof window === "undefined";
const rawValueRef = useRef$1(null);
const [value, setValue] = useState$1(() => {
if (ignoreLocalStorage) return defaultValue;
try {
rawValueRef.current = window.localStorage.getItem(key);
return rawValueRef.current ? parser(rawValueRef.current) : defaultValue;
} catch (err) {
logger$4.error(err);
return defaultValue;
}
});
useEffect$1(() => {
if (ignoreLocalStorage) return;
const updateLocalStorage = () => {
if (value !== void 0) {
const newValue = serializer(value);
const oldValue = rawValueRef.current;
rawValueRef.current = newValue;
window.localStorage.setItem(key, newValue);
window.dispatchEvent(new StorageEvent("storage", {
storageArea: window.localStorage,
url: window.location.href,
key,
newValue,
oldValue
}));
} else {
window.localStorage.removeItem(key);
window.dispatchEvent(new StorageEvent("storage", {
storageArea: window.localStorage,
url: window.location.href,
key
}));
}
};
try {
updateLocalStorage();
} catch (err) {
logger$4.error(err);
}
}, [value, ignoreLocalStorage]);
useEffect$1(() => {
if (!syncData) return;
const handleStorageChange = (event) => {
if (event.key !== key || event.storageArea !== window.localStorage) return;
try {
if (event.newValue !== rawValueRef.current) {
rawValueRef.current = event.newValue;
setValue(event.newValue ? parser(event.newValue) : void 0);
}
} catch (err) {
logger$4.error(err);
}
};
if (ignoreLocalStorage) return;
window.addEventListener("storage", handleStorageChange);
return () => {
window.removeEventListener("storage", handleStorageChange);
};
}, [
key,
syncData,
ignoreLocalStorage
]);
return [value, setValue];
};
//#endregion
//#region src/hooks/useAccountHolder.ts
var getAccountHolderStorageKey = (legalEntityId) => `ACCOUNT_HOLDER-${legalEntityId}`;
var useAccountHolder = () => {
const { rootLegalEntityId } = useApiContext();
const [accountHolderFromLocalStorage, setAccountHolderIntoLocalStorage] = useLocalStorage(getAccountHolderStorageKey(rootLegalEntityId.value), void 0);
return {
accountHolder: accountHolderFromLocalStorage,
setAccountHolder: setAccountHolderIntoLocalStorage
};
};
//#endregion
//#region src/hooks/useAnalytics/useAnalytics.ts
var useAnalytics = ({ userEvents, sessionId, sessionData }) => {
const sdkVersion = "4.16.0";
const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
const { mutateAsync } = usePushAnalyticEvent(sessionId ?? "");
const { accountHolder } = useAccountHolder();
useEffect$1(() => {
if (!rootLegalEntity) return;
const countryCode = getLegalEntityCountry(rootLegalEntity);
const capabilities = Object.keys(rootLegalEntity?.capabilities ?? {});
userEvents.updateBaseTrackingPayload({
entityType: rootLegalEntity.type,
countryCode,
capabilities,
sdkVersion,
componentName: sessionData.componentName,
userAgent: navigator.userAgent,
...getAnalyticsAssociatedEntityDetails(rootLegalEntity, accountHolder)
});
}, [
rootLegalEntity,
accountHolder,
sdkVersion,
sessionData.componentName,
userEvents
]);
const pushEvents = useCallback$1((data) => {
mutateAsync(convertToEmbeddedEvent(data, sessionData));
}, [mutateAsync, sessionData]);
useEffect$1(() => {
if (!sessionId) return;
userEvents.subscribe(pushEvents);
return () => {
userEvents.unsubscribe(pushEvents);
};
}, [
sessionId,
mutateAsync,
userEvents,
sessionData,
pushEvents
]);
};
//#endregion
//#region src/utils/analytics/getPrefilledDetails.ts
var getOrganizationPrefilledFields = (organization) => {
const { dateOfIncorporation, financialReports, registeredAddress, registrationNumber, support, taxInformation, type, vatNumber } = organization;
const financialReport = financialReports?.[0];
return {
dateOfIncorporation: !!dateOfIncorporation,
financialReport: {
annualTurnover: !!financialReport?.annualTurnover,
balanceSheetTotal: !!financialReport?.balanceSheetTotal,
dateOfFinancialData: !!financialReport?.dateOfFinancialData,
employeeCount: !!financialReport?.employeeCount
},
registeredAddress: {
city: !!registeredAddress?.city,
postalCode: !!registeredAddress?.postalCode,
stateOrProvince: !!registeredAddress?.stateOrProvince,
street: !!registeredAddress?.street
},
registrationNumber: !!registrationNumber,
support: {
email: !!support?.email,
phone: !!support?.phone
},
taxInformation: !!taxInformation?.some((taxInfo) => taxInfo.country && taxInfo.number),
type: !!type,
vatNumber: !!vatNumber
};
};
var getPrefilledDetails = (legalEntity) => {
if (!legalEntity) return;
const { organization, transferInstruments, entityAssociations } = legalEntity;
return {
transferInstrumentCount: transferInstruments?.length || 0,
entityAssociations: entityAssociations?.map((entity) => entity.type) || [],
organization: organization && getOrganizationPrefilledFields(organization)
};
};
//#endregion
//#region src/context/AnalyticsContext/AnalyticsProvider.tsx
/**
* The provider exists to scope analytics to one application instance.
* This would otherwise be problematic when a consumer might have several
* instantiations of a embedded Component for instance on the same page
*/
var AnalyticsProvider = ({ componentName, children, rootLegalEntityId, locale }) => {
const { settings } = useSettingsContext();
const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
const { data: versionData, isError, isLoading } = useVersionConfiguration();
const userEvents = useMemo$1(() => createUserEvents(), []);
const onboardingVersion = isLoading ? void 0 : isError ? 1 : versionData?.version;
const capabilities = rootLegalEntity?.capabilities && Object.keys(rootLegalEntity.capabilities);
const shouldTrackPrefilledDetails = capabilities?.includes("receivePayments") && onboardingVersion && onboardingVersion > 1;
const sessionData = {
sdkVersion: "4.16.0",
componentName,
userAgent: navigator.userAgent,
legalEntityId: rootLegalEntityId,
capabilities,
entityType: rootLegalEntity?.type,
eventData: shouldTrackPrefilledDetails ? getPrefilledDetails(rootLegalEntity) : void 0,
userData: {
onboardingVersion,
isDirectMerchant: settings.merchantType === "direct",
settings,
country: rootLegalEntity && getLegalEntityCountry(rootLegalEntity)
}
};
const { data } = useAnalyticsSession(sessionData, onboardingVersion);
userEvents.updateBaseTrackingPayload({ locale });
useAnalytics({
userEvents,
sessionId: data?.id,
sessionData
});
return /* @__PURE__ */ jsx(AnalyticsContext.Provider, {
value: userEvents,
children
});
};
//#endregion
//#region src/context/QueryContext/QueryClient.ts
var QueryClient$1 = new QueryClient({
defaultOptions: {
queries: {
staleTime: 300 * 1e3,
refetchOnWindowFocus: false,
refetchOnReconnect: true,
refetchOnMount: true,
retry: 2
},
mutations: { retry: 1 }
},
queryCache: new QueryCache({
onSuccess: (data, query) => {
if (query.meta?.onSuccess && typeof query.meta.onSuccess === "function") query.meta.onSuccess(data);
},
onError: (data, query) => {
if (query.meta?.onError && typeof query.meta.onError === "function") query.meta.onError(data);
}
})
});
//#endregion
//#region src/context/QueryContext/QueryClientProvider.tsx
/** Standard tanstack query provider, needed for it to work */
var QueryClientProvider$1 = ({ children }) => /* @__PURE__ */ jsx(QueryClientProvider, {
client: QueryClient$1,
children
});
//#endregion
//#region src/context/SettingsContext/SettingsProvider.tsx
var settingsDefaults = {
acceptedCountries: void 0,
allowBankAccountFormatSelection: false,
allowDebugUi: false,
allowIntraRegionCrossBorderPayout: false,
changeLegalEntityType: true,
editPrefilledCountry: true,
requirePciSignEcomMoto: false,
requirePciSignEcommerce: false,
requirePciSignPos: false,
requirePciSignPosMoto: false,
hideOnboardingIntroductionIndividual: true,
hideOnboardingIntroductionOrganization: true,
hideOnboardingIntroductionTrust: true,
hideOnboardingIntroductionSoleProprietor: true,
viewOnboardingGuidance: false,
transferInstrumentLimit: 0,
instantBankVerification: true,
showServiceAgreementsFirst: false,
showBusinessFinancingFirst: false,
enforceLegalAge: false,
merchantType: void 0,
allowBusinessLines: false,
allowCrossBorderPayout: false
};
/**
* Consumers can pass settings @see settingsDefaults, which can alter on runtime
* the behaviour of our library
* The settings are dynamically passed during SDK initialization (same as legalEntityId)
* @param settings - dictionary of type Settings
*/
function SettingsProvider({ children, settings }) {
const mergedSettings = {
...settingsDefaults,
...settings
};
const contextValue = useMemo$1(() => ({
isSettingEnabled: (settingName) => mergedSettings[settingName],
getSetting: (settingName) => mergedSettings[settingName],
settings: mergedSettings
}), [settings]);
return /* @__PURE__ */ jsx(SettingsContext.Provider, {
value: contextValue,
children
});
}
//#endregion
//#region src/context/StateContext/StateContext.ts
var StateContext = createContext$1(null);
//#endregion
//#region src/utils/validatorUtils.ts
var MAX_LENGTH = 30;
var getMaxLengthByFieldAndCountry = (formattingRules, field, country, ignoreIfFormatterExists) => {
if (!country) return void 0;
if (ignoreIfFormatterExists && formattingRules[country]?.[field]?.formatter) return;
return formattingRules[country]?.[field]?.maxlength || MAX_LENGTH;
};
var isUndefinedOrNull = (input) => input === void 0 || input === null;
var isEmpty = (input) => isUndefinedOrNull(input) || typeof input === "object" && Object.keys(input).length === 0 || typeof input === "string" && /^\s*$/.test(input);
var hasEmptyFields = (input) => input !== void 0 && (Object.keys(input).length === 0 || Object.values(input).some((value) => value === void 0 || value === null || value === ""));
var isAccountIdentifierObscured = (payload) => {
const accountIdentifier = payload?.type === "iban" ? payload.iban : payload?.accountNumber;
return Boolean(accountIdentifier) && accountIdentifier.includes("*");
};
var extractFieldName = (inputString) => {
const fieldNames = inputString?.split(".");
return fieldNames?.length > 0 ? fieldNames[fieldNames.length - 1] : "";
};
var concatenateFieldNames = (fieldNames) => fieldNames?.join(", ");
var isString = (input) => typeof input === "string" || input instanceof String;
var hasText = (input) => isString(input) && !isEmpty(input);
var SPECIAL_CHARS = "?\\-\\+_=!@#$%^&*(){}~<>\\[\\]\\/\\\\";
var getFormattingRegEx = (specChars, flags = "g") => new RegExp(`[${specChars}]`, flags);
var trimValWithOneSpace = (val) => val.trimStart().replace(/\s+/g, " ");
var EMOJI_REGEX = /(\p{Emoji}\uFE0F|\p{Emoji_Presentation}|\p{Extended_Pictographic})/gu;
var NO_ALPHABET_REGEX = /^[^a-zA-Z]*$/;
var NO_ALPHABET_UNICODE_REGEX = /^[^\p{L}]*$/u;
var INDIVIDUAL_VALID_CHAR_REGEX = /^[\p{L}\p{M}\d\s\-—./']*$/u;
var ADDRESS_VALID_CHAR_REGEX = /^[\p{L}\p{M}\d\s\-—.,/']*$/u;
var OTHER_ENTITIES_VALID_CHAR_REGEX = /^[\w\s,.;:\-—&!?@()"'/\\+\p{L}\p{M}]+$/u;
var LATIN_SPACE_MARK_PUNCTUATION_NUMBERS_REGEX = /^[\p{sc=Latin}\p{Zs}\p{M}\p{Punctuation}\p{N}]+$/u;
var matchesRegex = (regex, input) => isString(input) && regex.test(input ?? "");
var hasRepeatedCharacters = (input) => !isEmpty(input) && input.length > 1 && new Set(input.toLowerCase()).size === 1;
var hasMaximumTwoRepeatedCharacters = (input) => !isEmpty(input) && input.length > 2 && new Set(input.toLowerCase()).size === 1;
var isValidMinLength = (input, minLength = 1) => !isEmpty(input) && input.length >= minLength;
var isInvalidName = (input) => {
return new Set([
"John Doe",
"Jane Doe",
"ABCD",
"ABCDE",
"ABCDEF",
"ABCDEFG",
"My Customer",
"An other",
"n/a",
"not applicable",
"n/A",
"N/A",
"N/a",
"N\\ /A",
"not app",
"null"
]).has(input || "");
};
var standardKanjiValidator = (input) => {
const regex = /* @__PURE__ */ new RegExp("^[一-鿿㐀-䶿豈-ぁ-ゖァ-ヺー-ヿ0-9A-Za-z・ー‐-−’,.& Ⅰ-Ⅺ・-゚A-Za-z0-9,.& ]+$");
return !isEmpty(input) && regex.test(input);
};
var standardKatakanaValidator = (input) => {
const regex = /* @__PURE__ */ new RegExp("^[ァ-ヶㇰ-ㇿA-Za-z0-9・ー‐-−’,.& Ⅰ-Ⅺ・-゚A-Za-z0-9 ,.& へべぺ]+$");
return !isEmpty(input) && regex.test(input);
};
var chomeAndBanchiValidator = (input) => {
const regex = /* @__PURE__ */ new RegExp("^([0-9]{1,4}-[0-9]{1,4}|[0-9]{1,4}-[0-9]{1,4}-[0-9]{1,4}|[0-9]{1,4}-[0-9]{1,4}-[0-9]{1,4}-[0-9]{1,4})$");
return !isEmpty(input) && regex.test(input);
};
function assertString(input) {
if (input === void 0 || input === null) throw new TypeError(`Expected a string but received a ${input}`);
if (input.constructor.name !== "String") throw new TypeError(`Expected a string but received a ${input.constructor.name}`);
}
var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
function isISIN(str) {
assertString(str);
if (!isin.test(str)) return false;
let double = true;
let sum = 0;
for (let i = str.length - 2; i >= 0; i--) {
const char = str[i];
if (char >= "A" && char <= "Z") {
const value = char.charCodeAt(0) - 55;
const lo = value % 10;
const hi = Math.trunc(value / 10);
for (const digit of [lo, hi]) {
if (double) if (digit >= 5) sum += 1 + (digit - 5) * 2;
else sum += digit * 2;
else sum += digit;
double = !double;
}
} else {
const digit = parseInt(char, 10);
if (double) if (digit >= 5) sum += 1 + (digit - 5) * 2;
else sum += digit * 2;
else sum += digit;
double = !double;
}
}
const check = Math.trunc((sum + 9) / 10) * 10 - sum;
const lastChar = str[str.length - 1];
if (lastChar === void 0 || isNaN(parseInt(lastChar, 10))) return false;
return parseInt(lastChar, 10) === check;
}
//#endregion
//#region src/utils/removeObjectEmptyValues.ts
function removeObjectPropsWithEmptyValues(obj) {
keysOf(obj).forEach((key) => {
if (obj[key] === null || isEmpty(obj[key])) delete obj[key];
});
return obj;
}
//#endregion
//#region src/context/StateContext/StateReducer.ts
var INITIAL_STATE = {
data: {},
allData: {},
initialData: {},
errors: {},
valid: {},
fieldProblems: {},
isValid: false,
allValid: false
};
var logger$3 = createLogger();
function StateReducer() {
const [schemas, setSchemas] = useState$1({});
const [activeForms, setActiveForms] = useState$1([]);
const setCurrentForms = (forms) => {
setActiveForms(forms);
};
function reducer({ currentState: currState, prevState }, action) {
switch (action.type) {
case "addToState": {
if (!action.value.dataStoreId) {
logger$3.warn("No dataStoreId provided, hence no update can be done");
return {
currentState: currState,
prevState
};
}
const dataStoreId = action.value.dataStoreId;
const state = structuredClone(currState);
const schema = action.value.schema || null;
const schemaHasChanged = schema && schemas?.[dataStoreId]?.toString() !== schema.toString();
const mergedState = {
...state,
data: {
...state.data,
[dataStoreId]: {
...state.data[dataStoreId],
...action.value.data
}
},
allData: {
...state.allData,
[dataStoreId]: {
...state.allData[dataStoreId],
...removeObjectPropsWithEmptyValues(action.value.data)
}
},
errors: {
...state.errors,
[dataStoreId]: {
...state.errors[dataStoreId],
...action.value.errors
}
},
valid: {
...state.valid,
[dataStoreId]: {
...state.valid[dataStoreId],
...action.value.valid
}
},
fieldProblems: {
...state.fieldProblems,
[dataStoreId]: {
...state.fieldProblems[dataStoreId],
...action.value.fieldProblems
}
}
};
/**
* Some components e.g. personalDetails, are parents for other components and the data from these children is collected
* under the parent's id (aka dataStoreId) i.e. 'personalDetails.
*
* With these parents sometimes their schema for their useForm implementation updates at run time - so this fny checks
* if a schema has changed and if so ensures that the keys output in the data, valid, errors, fieldProblems objects
* match those of the parent schema
*/
if (schemaHasChanged) {
setSchemas({
...schemas,
[dataStoreId]: schema
});
const processedBySchema = schema.reduce((acc, fieldKey) => {
const dataObjByFormId = mergedState.data[dataStoreId];
const allDataObjByFormId = mergedState.allData[dataStoreId];
const validObjByFormId = mergedState.valid[dataStoreId];
const errorsObjByFormId = mergedState.errors[dataStoreId];
const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
return {
data: {
...acc.data,
[fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
},
valid: {
...acc.valid,
[fieldKey]: validObjByFormId[fieldKey]
},
errors: {
...acc.errors,
[fieldKey]: errorsObjByFormId[fieldKey]
},
fieldProblems: {
...acc.fieldProblems,
[fieldKey]: fieldProblemsObjByFormId[fieldKey]
}
};
}, {
data: {},
valid: {},
errors: {},
fieldProblems: {}
});
mergedState.data[dataStoreId] = processedBySchema.data;
mergedState.valid[dataStoreId] = processedBySchema.valid;
mergedState.errors[dataStoreId] = processedBySchema.errors;
mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
}
mergedState.validityByForm = {
...mergedState.validityByForm,
[dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
};
mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm?.[item]);
mergedState.initialData = structuredClone(state.initialData);
return {
currentState: mergedState,
prevState: state
};
}
case "removeFromState": {
if (!action.value.dataStoreId) {
logger$3.warn("No dataStoreId provided, hence no update can be done");
return {
currentState: currState,
prevState
};
}
const dataStoreId = action.value.dataStoreId;
const state = structuredClone(currState);
const mergedState = {
...state,
data: {
...state.data,
[dataStoreId]: {}
},
allData: {
...state.allData,
[dataStoreId]: {}
},
errors: {
...state.errors,
[dataStoreId]: {}
},
valid: {
...state.valid,
[dataStoreId]: false
},
fieldProblems: {
...state.fieldProblems,
[dataStoreId]: {}
}
};
mergedState.validityByForm = {
...mergedState.validityByForm,
[dataStoreId]: false
};
mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm?.[item]);
mergedState.initialData = structuredClone(state.initialData);
return {
currentState: mergedState,
prevState: state
};
}
case "resetState": return {
currentState: INITIAL_STATE,
prevState: currState
};
default: throw new Error(`Unhandled action type: ${action.type}`);
}
}
return {
reducer,
setCurrentForms
};
}
//#endregion
//#region src/context/StateContext/StateProvider.tsx
function StateProvider({ defaultData = {}, children }) {
const defaultState = {
currentState: {
data: defaultData,
allData: defaultData,
valid: {},
errors: {},
fieldProblems: {},
validityByForm: {},
initialData: defaultData
},
prevState: {}
};
const reducerObj = StateReducer();
const [state, dispatch] = useReducer(reducerObj.reducer, defaultState);
/**
* Create an object from the returned reducer props
* - the state property in this object will be available to any handler functions set on StateContextWatcher
* - the dispatch property is made available to the StateContextSetter
*/
const contextValue = useMemo$1(() => ({
state,
dispatch,
setActiveForms: reducerObj.setCurrentForms,
getData: () => state?.currentState?.data ?? {},
getState: () => state?.currentState
}), [reducerObj, state]);
return /* @__PURE__ */ jsx(StateContext.Provider, {
value: contextValue,
children
});
}
var Toast_module_default = {
toast: "_toast_5bwuk_1",
"present-toast": "_present-toast_5bwuk_1",
presentToast: "_present-toast_5bwuk_1",
"toast-image": "_toast-image_5bwuk_22",
toastImage: "_toast-image_5bwuk_22",
"toast-image-success": "_toast-image-success_5bwuk_32",
toastImageSuccess: "_toast-image-success_5bwuk_32",
"toast-image-error": "_toast-image-error_5bwuk_37",
toastImageError: "_toast-image-error_5bwuk_37",
"toast-label": "_toast-label_5bwuk_42",
toastLabel: "_toast-label_5bwuk_42",
"toast-actions": "_toast-actions_5bwuk_55",
toastActions: "_toast-actions_5bwuk_55",
"toast-action-close": "_toast-action-close_5bwuk_64",
toastActionClose: "_toast-action-close_5bwuk_64"
};
//#endregion
//#region src/components/ui/molecules/Toast/Toast.tsx
var Toast = ({ action, duration = 1e4, label, onDismiss, variant = "info" }) => {
const hasIcon = variant === "success" || variant === "error";
const hasAction = action !== void 0;
const role = hasAction ? "alertdialog" : "alert";
const iconNames = {
error: "field-error",
success: "checkmark"
};
const imageClassname = cx(Toast_module_default.toastImage, {
[Toast_module_default.toastImageSuccess]: variant === "success",
[Toast_module_default.toastImageError]: variant === "error"
});
useEffect$1(() => {
let dismissToastTimer;
if (duration !== "indefinite") dismissToastTimer = setTimeout(() => {
onDismiss();
}, duration);
return () => {
clearTimeout(dismissToastTimer);
};
}, [duration, onDismiss]);
return /* @__PURE__ */ jsxs("div", {
"aria-label": label,
className: Toast_module_default.toast,
role,
children: [/* @__PURE__ */ jsxs("div", {
className: Toast_module_default.toastLabel,
children: [hasIcon && /* @__PURE__ */ jsx("div", {
className: imageClassname,
"data-testId": iconNames[variant],
children: /* @__PURE__ */ jsx(Icon, { name: iconNames[variant] })
}), label]
}), /* @__PURE__ */ jsxs("div", {
className: Toast_module_default.toastActions,
children: [hasAction && /* @__PURE__ */ jsx(Button, {
onClick: action.onClick,
children: action.label
}), /* @__PURE__ */ jsx("div", {
className: Toast_module_default.toastActionClose,
children: /* @__PURE__ */ jsx(IconButton, {
icon: "cross",
ariaLabel: "Close",
onClick: onDismiss
})
})]
})]
});
};
//#endregion
//#region src/context/ToastContext/ToastContext.ts
var ToastContext = createContext$1({
showToast: noop,
clearToasts: noop
});
//#endregion
//#region src/context/ToastContext/ToastContextProvider.tsx
function ToastContextProvider({ children }) {
const [toastOptions, setToastOptions] = useState$1();
const clearToasts = () => {
setToastOptions(void 0);
};
const contextValue = useMemo$1(() => ({
showToast: (options) => {
setToastOptions(options);
},
clearToasts
}), []);
return /* @__PURE__ */ jsxs(ToastContext.Provider, {
value: contextValue,
children: [!!toastOptions && /* @__PURE__ */ jsx(Toast, {
label: toastOptions.label,
variant: toastOptions.variant,
action: toastOptions.action,
duration: toastOptions.duration,
onDismiss: clearToasts
}), children]
});
}
//#endregion
//#region src/api/toggles/useToggles.ts
/**
* Retrieves experiments and onboardingcomponents-specific feature flags
* as defined in `OnboardingcomponentsFeatures.java` linked to the legalEntityId
*/
var getToggles = async (legalEntityId, baseUrl) => {
const { experiments, features } = await httpGet({
baseUrl,
path: `legalEntities/${legalEntityId}/flags`
});
return {
experiments: experiments ? Object.values(experiments).reduce((acc, val) => {
return {
...acc,
[val]: true
};
}, {}) : {},
features
};
};
var useToggles = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useQuery({
queryKey: ["toggles"],
queryFn: () => getToggles(rootLegalEntityId.value, baseUrl.value),
...options
});
};
//#endregion
//#region src/utils/listToRecord.ts
var listToRecord = (list, getValue) => list.reduce((acc, k) => ({
...acc,
[k]: getValue(k)
}), {});
//#endregion
//#region src/context/ToggleContext/ToggleContext.tsx
var ToggleContext = createContext$1({
features: {},
isFeatureEnabled: () => false,
experiments: {},
isExperimentEnabled: () => false,
refreshExperiments: () => {}
});
//#endregion
//#region src/context/ToggleContext/types.ts
/**
* Features which are passed into our SDK via a prop (ex. `adyen-onboarding.tsx` or `UIElement.tsx`)
* These are enabled/disabled via our feature framework and are intended to be short-lived. Used for feature rollout purposes.
*/
var PropFeatureNames = {
/**
* Passed in from uo sdk, TODO: move to settings
*/
EnableEInvoicingCodeField: "EnableEInvoicingCodeField",
HidePayoutAccountTask: "HidePayoutAccountTask",
ShowExtraTaxExemptionReasons: "ShowExtraTaxExemptionReasons",
/**
* Old features
*/
AllowMoreRolesForMainRootTrustee: "AllowMoreRolesForMainRootTrustee",
EnablePhoneFieldScenario: "EnablePhoneFieldScenario",
ShowUnsupportedEntityType: "ShowUnsupportedEntityType"
};
/**
* Features which are returned from a call made to onboardingcomponents for feature flags and experiments (see `useToggles`).
* These are enabled/disabled via our feature framework and are intended to be short-lived. Used for feature rollout purposes.
* Defined in the BE (`OnboardingcomponentsFeatures.java`).
*/
var FeatureFrameworkFeatureNames = {
/**
* OXP-6596: Enable Bank Document Classification in HO
*/
EnableBankDocumentClassification: "EnableBankDocumentClassification",
/**
* OXP-6596: Enable Bank Document Classification in ShadowMode in HO
*/
EnableBankDocumentClassificationShadowMode: "EnableBankDocumentClassificationShadowMode",
/**
* SOE-4062: Enable cross border payouts configuration for Bank Account task
*/
EnableCrossBorderPayouts: "EnableCrossBorderPayouts",
/**
* OXP-6032: Enable editing a single business line
*/
EnableDeleteBusinessLines: "EnableDeleteBusinessLines",
/**
* OXP-6799: Enable limit to a single business line
*/
EnableLimitToSingleBusinessLine: "EnableLimitToSingleBusinessLine",
/**
* Enable in-memory routing (wouter-preact memoryLocation) instead of state-based navigation.
* When both EnableURLRouterForHostedOnboarding and EnableMemoryRouterForHostedOnboarding are on, memory router takes precedence.
*/
EnableMemoryRouterForHostedOnboarding: "EnableMemoryRouterForHostedOnboarding",
/**
* OXP-6032: Enable editing a single business line
*/
EnableModifyBusinessLines: "EnableModifyBusinessLines",
/**
* Enable URL-based routing (wouter-preact) instead of state-based navigation
*/
EnableURLRouterForHostedOnboarding: "EnableURLRouterForHostedOnboarding",
/**
* Enable "Verify by Invite" flow for decision makers in Identity Verification
*/
EnableVerifyByInvite: "EnableVerifyByInvite",
/**
* Use the status calculated on the backend for the payout task.
* If false, instead compute the status from capabilities and problems on the root LE.
*/
UseTaskStatusApiForPayout: "UseTaskStatusApiForPayout",
/**
OXP-6566: Create new payout intro screen
*/
EnableBankAccountDetailsLandingPage: "EnableBankAccountDetailsLandingPage",
/**
Enable AWE generated UI for PoC
*/
EnableAdaptivePoc: "EnableAdaptivePoc",
/**
* OXP-7774: Enable LEI field in Business Details Task
*/
EnableLegalEntityIdentifierField: "EnableLegalEntityIdentifierField"
};
/**
* Features which are returned from a call made to onboardingcomponents for version-specific features. (see `useVersions`).
* Version specific features are tied to the specific onboarding/LEM version (ex. v4-specific features) rather than for feature rollout purposes.
* Defined in the BE (`VersionSpecificToggle.java`).
*/
var VersionFeatureNames = {
/**
*
*/
EnableAgeVerification: "EnableAgeVerification",
/**
* Allows users to specify a 'Country of Governing Law' for UK companies
* within Business Details Task
*/
EnableCountryOfGoverningLawForUKCompanies: "EnableCountryOfGoverningLawForUKCompanies",
/**
*
*/
EnableDoingBusinessAsNameV4: "EnableDoingBusinessAsNameV4",
/**
*
*/
EnableFinancialInformationComponentV4: "EnableFinancialInformationComponentV4",
/**
* Enables localization for Japan
*/
EnableJapanLocalization: "EnableJapanLocalization",
/**
* Enables LatAm Spanish locale
*/
EnableLatAmSpanish: "EnableLatAmSpanish",
/**
*
*/
EnableNationalitySGHK: "EnableNationalitySGHK",
/**
*
*/
EnableRegistrationAndTaxAbsentStatesV4: "EnableRegistrationAndTaxAbsentStatesV4",
/**
*
*/
ShowCustomerSupportV4: "ShowCustomerSupportV4",
/**
*
*/
StrictNameAndAddressValidationV4: "StrictNameAndAddressValidationV4"
};
/**
* Experiments which are returned from a call made to onboardingcomponents for feature flags and experiments (see `useToggles`).
* Experiments are used to toggle behavior for A/B testing purposes.
* Defined using the Experimentation Platform in BO.
*
* Naming convention: `${ExperimentName}_${TreatmentGroupNameOrControl}` ex. `BankingVerificationExperiment_Treatment1` or `BusinessSearchExperiment_control`
*/
var ExperimentNames = {
/**
* OXP-7319: Experiment with Forced Manual Payout Flow
*/
BankingPayoutFlow_ForcedManualVerification: "BankingPayoutFlow_ForcedManualVerification" };
var FeatureNames = {
...PropFeatureNames,
...FeatureFrameworkFeatureNames,
...VersionFeatureNames
};
//#endregion
//#region src/context/ToggleContext/ToggleContextProvider.tsx
/**
* To manage accessing non-production-ready features of SDK
* or features under active experimentation/testing.
* @param children - components rendered
* @param features - dictionary of type Features
* @param refreshExperiments - handler to refresh experiments for the legal entity
*/
function ToggleContextProvider({ children, features: propFeatures, refreshExperiments }) {
const { data: toggleData } = useToggles();
const { data: versionData } = useVersionConfiguration();
const features = useMemo$1(() => ({
...toggleData?.features,
...propFeatures,
...listToRecord(versionData?.features ?? [], () => true)
}), [
versionData,
propFeatures,
toggleData?.features
]);
const experiments = useMemo$1(() => ({
...toggleData?.experiments,
...listToRecord(valuesOf(ExperimentNames), (experiment) => propFeatures[experiment] ?? false)
}), [propFeatures, toggleData?.experiments]);
const contextValue = useMemo$1(() => ({
features,
isFeatureEnabled: (feature) => features[feature] ?? false,
experiments,
isExperimentEnabled: (experiment) => experiments[experiment] ?? false,
refreshExperiments
}), [
features,
experiments,
refreshExperiments
]);
return /* @__PURE__ */ jsx(ToggleContext.Provider, {
value: contextValue,
children
});
}
//#endregion
//#region src/context/ToggleContext/useToggleContext.ts
function useToggleContext() {
return useContext$1(ToggleContext);
}
//#endregion
//#region \0rolldown_dynamic_import_helper.js
var _rolldown_dynamic_import_helper_default = (glob, path, segments) => {
const query = path.lastIndexOf("?");
const v = glob[query === -1 || query < path.lastIndexOf("/") ? path : path.slice(0, query)];
if (v) return typeof v === "function" ? v() : Promise.resolve(v);
return new Promise((_, reject) => {
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + path + (path.split("/").length !== segments ? ". Note that variables only represent file names one level deep." : ""))));
});
};
var Header_module_default = {
header: "_header_15umz_1",
"header-margin": "_header-margin_15umz_7",
headerMargin: "_header-margin_15umz_7",
"header-margin-secondary": "_header-margin-secondary_15umz_11",
headerMarginSecondary: "_header-margin-secondary_15umz_11",
"header-left": "_header-left_15umz_15",
headerLeft: "_header-left_15umz_15",
"header-center": "_header-center_15umz_20",
headerCenter: "_header-center_15umz_20",
"header-right": "_header-right_15umz_25",
headerRight: "_header-right_15umz_25",
"header-content": "_header-content_15umz_30",
headerContent: "_header-content_15umz_30",
"header-actions": "_header-actions_15umz_36",
headerActions: "_header-actions_15umz_36",
"header-title": "_header-title_15umz_40",
headerTitle: "_header-title_15umz_40",
"header-title-primary": "_header-title-primary_15umz_45",
headerTitlePrimary: "_header-title-primary_15umz_45",
"header-title-secondary": "_header-title-secondary_15umz_52",
headerTitleSecondary: "_header-title-secondary_15umz_52",
"header-description": "_header-description_15umz_58",
headerDescription: "_header-description_15umz_58",
"header-description-primary": "_header-description-primary_15umz_65",
headerDescriptionPrimary: "_header-description-primary_15umz_65",
"header-description-secondary": "_header-description-secondary_15umz_69",
headerDescriptionSecondary: "_header-description-secondary_15umz_69"
};
//#endregion
//#region src/components/ui/atoms/Header/Header.tsx
var alignmentStyles = {
left: Header_module_default.headerLeft,
center: Header_module_default.headerCenter,
right: Header_module_default.headerRight
};
var Header = ({ align = "left", children, description, secondary = false, status, title }) => {
const { Slot, hasSlot } = defineSlots(children ?? [], ["actions", "description"]);
const HeadingElement = secondary ? "h2" : "h1";
const rootClassname = cx(Header_module_default.header, alignmentStyles[align], {
[Header_module_default.headerMargin]: !secondary,
[Header_module_default.headerMarginSecondary]: secondary
});
const titleClassname = cx(Header_module_default.headerTitle, {
[Header_module_default.headerTitlePrimary]: !secondary,
[Header_module_default.headerTitleSecondary]: secondary
});
const descriptionClassname = cx(Header_module_default.headerDescription, {
[Header_module_default.headerDescriptionPrimary]: !secondary,
[Header_module_default.headerDescriptionSecondary]: secondary
});
return /* @__PURE__ */ jsxs("header", {
className: rootClassname,
children: [
status && /* @__PURE__ */ jsx(TaskVerificationStatus, {
status,
responsive: false
}),
/* @__PURE__ */ jsxs("div", {
className: Header_module_default.headerContent,
children: [/* @__PURE__ */ jsx(HeadingElement, {
className: titleClassname,
children: title
}), (hasSlot("description") || description) && /* @__PURE__ */ jsx("div", {
className: descriptionClassname,
children: /* @__PURE__ */ jsx(Slot, {
name: "description",
children: description
})
})]
}),
hasSlot("actions") && /* @__PURE__ */ jsx("div", {
className: Header_module_default.headerActions,
children: /* @__PURE__ */ jsx(StackLayout, {
gap: "small",
horizontal: true,
children: /* @__PURE__ */ jsx(Slot, { name: "actions" })
})
})
]
});
};
//#endregion
//#region src/api/configurations/useSupportedCountries.ts
/**
* Retrieves from the backend information about supported countries
* linked to the legalEntityId
*
* @param id legalEntityId
* @param options additional options passed to Tanstack Query, eg; refetchInterval for polling
*/
var getSupportedCountries = async (legalEntityId, baseUrl) => {
return httpGet({
baseUrl,
path: `legalEntities/${legalEntityId}/configurations/supportedCountries`
});
};
var useSupportedCountries = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useQuery({
queryKey: ["supportedCountries"],
queryFn: () => getSupportedCountries(rootLegalEntityId.value, baseUrl.value),
...options
});
};
//#endregion
//#region src/context/SettingsContext/useSetting.ts
var useSetting = (settingName) => {
const { getSetting } = useContext$1(SettingsContext);
return getSetting(settingName);
};
//#endregion
//#region src/utils/api/useCapabilities.ts
var useCapabilities = () => {
const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
return rootLegalEntity?.capabilities;
};
//#endregion
//#region src/hooks/useAllowedCountries.ts
var businessAccountCountries = [
CountryCodes.Austria,
CountryCodes.Belgium,
CountryCodes.Croatia,
CountryCodes.Cyprus,
CountryCodes.Estonia,
CountryCodes.Finland,
CountryCodes.France,
CountryCodes.Germany,
CountryCodes.Greece,
CountryCodes.Ireland,
CountryCodes.Italy,
CountryCodes.Latvia,
CountryCodes.Lithuania,
CountryCodes.Luxembourg,
CountryCodes.Malta,
CountryCodes.Netherlands,
CountryCodes.Portugal,
CountryCodes.Slovakia,
CountryCodes.Slovenia,
CountryCodes.Spain,
CountryCodes.UnitedKingdom,
CountryCodes.UnitedStates
];
var useAllowedCountries = () => {
const isLimitCountryBusinessAccountCustomersEnabled = Object.keys(useCapabilities() ?? {}).includes("issueBankAccount");
const acceptedCountriesSetting = useSetting("acceptedCountries");
const { data } = useSupportedCountries({ enabled: !acceptedCountriesSetting });
const allowedCountries = acceptedCountriesSetting ?? data?.countries;
if (!allowedCountries) return;
return isLimitCountryBusinessAccountCustomersEnabled ? businessAccountCountries.filter((country) => allowedCountries.includes(country)) : allowedCountries;
};
//#endregion
//#region src/datasets/generators/loadCountries.ts
var logger$2 = createLogger();
var countriesImports = /* @__PURE__ */ Object.assign({
"../countries/de-DE.json": () => import("./de-DE-w4l6boYT.js"),
"../countries/el-GR.json": () => import("./el-GR-DqTetsjB.js"),
"../countries/en-US.json": () => import("./en-US-B82BbZaB.js"),
"../countries/es-ES.json": () => import("./es-ES-C14ZT-97.js"),
"../countries/fr-FR.json": () => import("./fr-FR-8a-RK9xd.js"),
"../countries/it-IT.json": () => import("./it-IT-DIIRAF4_.js"),
"../countries/ja-JP.json": () => import("./ja-JP-CyXnoIu3.js"),
"../countries/nl-NL.json": () => import("./nl-NL-BWGCqpWp.js"),
"../countries/pt-PT.json": () => import("./pt-PT-IPhkbQvT.js"),
"../countries/sv-SE.json": () => import("./sv-SE-IBYnJfbW.js")
});
var loadCountriesDataset = async (locale) => {
const importForLocale = co