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] = "0b89c1a7-9c8f-491c-b941-76798487619c", e._sentryDebugIdIdentifier = "sentry-dbid-0b89c1a7-9c8f-491c-b941-76798487619c");
} catch (e) {}
import { i as Typography, n as addResourceBundles, r as useTranslation } from "./translation-Br5wIPO-.js";
import { r as Loader, t as Button } from "./Button-BDEdGXnd.js";
import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-Dm6g0wmt.js";
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-CCXvMgfE.js";
import { t as TaskTypes } from "./taskTypes-DWaxzvnQ.js";
import { t as useAnalyticsContext } from "./useAnalyticsContext-DfTXpZbA.js";
import { n as useLegalEntityType, t as useCanSeeIntroduction } from "./useCanSeeIntroduction-Dj1tjCk3.js";
import { t as useTaskLandedEvent } from "./useTaskLandedEvent-DCdJo64z.js";
import { useMemo } from "preact/compat";
import { useEffect as useEffect$1, useState as useState$1 } from "preact/hooks";
import cx from "classnames";
import { Fragment as Fragment$1, jsx, jsxs } from "preact/jsx-runtime";
//#region src/utils/range.ts
/**
* Create a range of numbers
* @param {number} start The first number in the range
* @param {number} stop The last number in the range
* @param {number} step The step between each number in the range
* @returns {number[]} A range of numbers
*/
var range = (stop, start = 0, step = 1) => Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step);
var StepProgressIndicator_module_default = {
	"progress-bar": "adyen-kyc-progress-bar",
	progressBar: "adyen-kyc-progress-bar",
	"progress-bar-thick": "adyen-kyc-progress-bar-thick",
	progressBarThick: "adyen-kyc-progress-bar-thick",
	"progress-step": "adyen-kyc-progress-step",
	progressStep: "adyen-kyc-progress-step",
	"progress-step-active": "adyen-kyc-progress-step-active",
	progressStepActive: "adyen-kyc-progress-step-active",
	"progress-bar-circles": "adyen-kyc-progress-bar-circles",
	progressBarCircles: "adyen-kyc-progress-bar-circles"
};
//#endregion
//#region src/components/ui/atoms/StepProgressIndicator/StepProgressIndicator.tsx
var shouldHighlight = (active, current, fillBefore) => !fillBefore ? active === current : active >= current;
/**
* Progress indicator showing step progession in a process
*
* @param activeStepIndex - zero based index for active steps, add 1 to make it human-readable
* @param stepsCount - total number of steps
* @param fillBefore - fills everything between 0 and activeStepIndex, not just last step
* @param thick - makes the bar thicker
*/
/** @deprecated do not use in new code */
var StepProgressIndicator = ({ activeStepIndex, stepsCount, fillBefore, thick, circles }) => {
	const { t } = useTranslation("ui");
	if (stepsCount === 0 || stepsCount > 10) return /* @__PURE__ */ jsx(Typography, {
		variant: "caption",
		children: t(($) => $["XOfYSteps"], {
			currentStep: activeStepIndex,
			totalSteps: stepsCount
		})
	});
	return /* @__PURE__ */ jsx("div", {
		"aria-label": t(($) => $["stepXofY"], {
			currentStep: activeStepIndex,
			totalSteps: stepsCount
		}),
		className: StepProgressIndicator_module_default.progress,
		role: "group",
		children: /* @__PURE__ */ jsx("ol", {
			className: cx(StepProgressIndicator_module_default.progressBar, {
				[StepProgressIndicator_module_default.progressBarThick]: thick,
				[StepProgressIndicator_module_default.progressBarCircles]: circles
			}),
			children: range(stepsCount).map((stepNumber) => {
				const isHighlighted = shouldHighlight(activeStepIndex, stepNumber, fillBefore);
				return /* @__PURE__ */ jsx("li", {
					"aria-current": isHighlighted ? "step" : void 0,
					className: cx(StepProgressIndicator_module_default.progressStep, { [StepProgressIndicator_module_default.progressStepActive]: isHighlighted }),
					children: /* @__PURE__ */ jsx("span", {
						className: "u-screen-reader-only",
						children: t(($) => $["stepNumberStatus"], {
							stepNumber,
							status: t(($) => $[stepNumber < activeStepIndex ? "completed" : "notCompleted"])
						})
					})
				}, stepNumber);
			})
		})
	});
};
//#endregion
//#region src/components/Shared/Introduction/types.ts
var IntroductionScreens = {
	PROLOGUE: "PROLOGUE",
	INDIVIDUAL: TaskTypes.INDIVIDUAL,
	DECISION_MAKER: TaskTypes.DECISION_MAKER,
	SOLE_PROPRIETOR_COMPANY: TaskTypes.SOLE_PROPRIETOR_COMPANY,
	TRUST: TaskTypes.TRUST,
	TRUST_MEMBER: TaskTypes.TRUST_MEMBER,
	ACCOUNT: "ACCOUNT",
	EPILOGUE: "EPILOGUE"
};
//#endregion
//#region src/components/Shared/Introduction/constants.ts
var introductionScreensByLegalEntityType = {
	[LegalEntityTypes.INDIVIDUAL]: [
		IntroductionScreens.PROLOGUE,
		IntroductionScreens.INDIVIDUAL,
		IntroductionScreens.ACCOUNT,
		IntroductionScreens.EPILOGUE
	],
	[LegalEntityTypes.ORGANIZATION]: [
		IntroductionScreens.PROLOGUE,
		IntroductionScreens.DECISION_MAKER,
		IntroductionScreens.ACCOUNT,
		IntroductionScreens.EPILOGUE
	],
	[LegalEntityTypes.SOLE_PROPRIETORSHIP]: [
		IntroductionScreens.PROLOGUE,
		IntroductionScreens.INDIVIDUAL,
		IntroductionScreens.SOLE_PROPRIETOR_COMPANY,
		IntroductionScreens.ACCOUNT,
		IntroductionScreens.EPILOGUE
	],
	[LegalEntityTypes.TRUST]: [
		IntroductionScreens.PROLOGUE,
		IntroductionScreens.INDIVIDUAL,
		IntroductionScreens.DECISION_MAKER,
		IntroductionScreens.TRUST,
		IntroductionScreens.TRUST_MEMBER,
		IntroductionScreens.ACCOUNT,
		IntroductionScreens.EPILOGUE
	],
	[LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]: [
		IntroductionScreens.PROLOGUE,
		IntroductionScreens.INDIVIDUAL,
		IntroductionScreens.DECISION_MAKER,
		IntroductionScreens.TRUST,
		IntroductionScreens.TRUST_MEMBER,
		IntroductionScreens.ACCOUNT,
		IntroductionScreens.EPILOGUE
	]
};
//#endregion
//#region src/hooks/introduction/useIntroductionScreens.ts
var useIntroductionScreens = ({ legalEntity, tasks }) => {
	const canSeeIntroduction = useCanSeeIntroduction({ legalEntity });
	const legalEntityType = useLegalEntityType({ legalEntity });
	const introductionScreens = useMemo(() => legalEntityType ? introductionScreensByLegalEntityType[legalEntityType].filter((screen) => {
		const isAccountScreen = screen === IntroductionScreens.ACCOUNT;
		const hasAccountTask = tasks.includes(TaskTypes.PAYIN) || tasks.includes(TaskTypes.PAYOUT);
		const isSoleProprietorScreen = screen === IntroductionScreens.SOLE_PROPRIETOR_COMPANY;
		const isSoleProprietor = legalEntityType === LegalEntityTypes.SOLE_PROPRIETORSHIP;
		const isTrustScreen = screen === IntroductionScreens.TRUST || screen === IntroductionScreens.TRUST_MEMBER;
		const isTrust = legalEntityType === LegalEntityTypes.TRUST;
		if (isAccountScreen) return hasAccountTask;
		if (isSoleProprietorScreen) return isSoleProprietor;
		if (isTrustScreen) return isTrust;
		return tasks.some((task) => screen === task);
	}) : [], [legalEntityType, tasks]);
	return canSeeIntroduction && introductionScreens?.length > 0 ? [
		IntroductionScreens.PROLOGUE,
		...introductionScreens,
		IntroductionScreens.EPILOGUE
	] : void 0;
};
//#endregion
//#region src/utils/toCapitalized.ts
var toCapitalized = (s) => `${s[0].toUpperCase()}${s.slice(1).toLowerCase()}`;
//#endregion
//#region src/utils/toPascalCase.ts
var toPascalCase = (s) => s.split(/[^A-Za-z]/).map((word) => toCapitalized(word)).join("");
//#endregion
//#region src/components/Shared/Introduction/copy.tsx
var IntroductionScreenTranslationKeyElements = {
	ListItem: "LI",
	Paragraph: "P"
};
var getIntroductionScreenTranslationKeys = (factors, i18n) => {
	const introductionStrings = i18n.getResourceBundle(i18n.language, "introduction");
	if (!introductionStrings || !factors.legalEntityType) return;
	const elForKey = (factors.elementType || "").toUpperCase();
	const lForKey = toPascalCase(factors.legalEntityType || "");
	const iForKey = toPascalCase(factors.introductionScreen);
	const keyPrefix = `introductionScreen${iForKey}Description${elForKey}`;
	const keyPrefixWithL = `introductionScreen${iForKey}${lForKey}Description${elForKey}`;
	const keys = Object.keys(introductionStrings).filter((key) => key.startsWith(keyPrefix));
	const keysWithL = Object.keys(introductionStrings).filter((key) => key.startsWith(keyPrefixWithL));
	return (keysWithL.length ? keysWithL : keys).sort((a, b) => Number(a.at(-1)) - Number(b.at(-1)));
};
//#endregion
//#region src/components/Shared/Introduction/IntroductionScreen.tsx
var IntroductionScreen = ({ introductionScreen, legalEntity, number }) => {
	const { t, i18n } = useTranslation("introduction");
	const legalEntityType = useLegalEntityType({ legalEntity });
	const paragraphKeys = getIntroductionScreenTranslationKeys({
		introductionScreen,
		legalEntityType,
		elementType: IntroductionScreenTranslationKeyElements.Paragraph
	}, i18n);
	const listItemKeys = getIntroductionScreenTranslationKeys({
		introductionScreen,
		legalEntityType,
		elementType: IntroductionScreenTranslationKeyElements.ListItem
	}, i18n);
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [
		/* @__PURE__ */ jsx("div", {
			className: "adyen-kyc-introduction__number",
			children: number
		}),
		/* @__PURE__ */ jsx("div", {
			className: "adyen-kyc-introduction__title",
			children: t(($) => $[`introductionScreen${toPascalCase(introductionScreen)}Title`])
		}),
		/* @__PURE__ */ jsxs("div", {
			className: "adyen-kyc-introduction__description",
			children: [!!paragraphKeys?.length && paragraphKeys.map((key) => /* @__PURE__ */ jsx("p", { children: t(($) => $[key]) }, key)), !!listItemKeys?.length && /* @__PURE__ */ jsx("ul", { children: listItemKeys.map((key) => /* @__PURE__ */ jsx("li", { children: t(($) => $[key]) }, key)) })]
		})
	] });
};
//#endregion
//#region src/components/Shared/Introduction/Introduction.tsx
function Introduction({ onExitIntroduction, tasks }) {
	const { data: rootLe, isLoading } = useLegalEntity(ROOT_LE);
	const { i18n } = useTranslation();
	addResourceBundles(i18n, [{
		ns: "introduction",
		importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
			"../language/introduction/bg-BG.json": () => import("./bg-BG-QlxmGEZL.js"),
			"../language/introduction/cs-CZ.json": () => import("./cs-CZ-BObx8NMb.js"),
			"../language/introduction/da-DK.json": () => import("./da-DK-BDachfZH.js"),
			"../language/introduction/de-DE.json": () => import("./de-DE-DstHFxVG.js"),
			"../language/introduction/el-GR.json": () => import("./el-GR-BRFvZNGC.js"),
			"../language/introduction/en-US.json": () => import("./en-US-_D_BTN1a.js"),
			"../language/introduction/es-ES.json": () => import("./es-ES-0O9y1_Bc.js"),
			"../language/introduction/et-EE.json": () => import("./et-EE-30-8FeA2.js"),
			"../language/introduction/fi-FI.json": () => import("./fi-FI-BrmYMDbY.js"),
			"../language/introduction/fr-FR.json": () => import("./fr-FR-CYRsfbyW.js"),
			"../language/introduction/hr-HR.json": () => import("./hr-HR-DTIXBOS5.js"),
			"../language/introduction/hu-HU.json": () => import("./hu-HU-DIgxSbaT.js"),
			"../language/introduction/it-IT.json": () => import("./it-IT-kER7OY9Z.js"),
			"../language/introduction/ja-JP.json": () => import("./ja-JP-D6OZ6CvT.js"),
			"../language/introduction/lt-LT.json": () => import("./lt-LT-DX-73rzB.js"),
			"../language/introduction/lv-LV.json": () => import("./lv-LV-D0EFr0dt.js"),
			"../language/introduction/nl-NL.json": () => import("./nl-NL-D16qC_X6.js"),
			"../language/introduction/no-NO.json": () => import("./no-NO-ByxOHA9n.js"),
			"../language/introduction/pl-PL.json": () => import("./pl-PL-aWhB1xes.js"),
			"../language/introduction/pt-BR.json": () => import("./pt-BR-7FV4JArc.js"),
			"../language/introduction/pt-PT.json": () => import("./pt-PT-D9QbJxzN.js"),
			"../language/introduction/ro-RO.json": () => import("./ro-RO-BCHziTju.js"),
			"../language/introduction/sk-SK.json": () => import("./sk-SK-xqB2A84D.js"),
			"../language/introduction/sl-SI.json": () => import("./sl-SI-PsgMnJ-h.js"),
			"../language/introduction/sv-SE.json": () => import("./sv-SE-Dsrb2FFw.js")
		}), `../language/introduction/${lang}.json`, 4)
	}]);
	if (isLoading || !rootLe) return /* @__PURE__ */ jsx(Loader, { size: "large" });
	return /* @__PURE__ */ jsx(IntroductionInner, {
		legalEntity: rootLe,
		onExitIntroduction,
		tasks
	});
}
var IntroductionInner = ({ legalEntity, onExitIntroduction, tasks }) => {
	const { t } = useTranslation(["common", "introduction"]);
	const userEvents = useAnalyticsContext();
	const introductionScreens = useIntroductionScreens({
		legalEntity,
		tasks
	});
	const [activeIndex, setActiveIndex] = useState$1(0);
	const pageEventDetails = { page: introductionScreens?.length ? introductionScreens[activeIndex] : void 0 };
	/**
	* Analytics
	*/
	useTaskLandedEvent("INTRODUCTION");
	useEffect$1(() => {
		if (!introductionScreens?.length) onExitIntroduction();
	}, [introductionScreens, onExitIntroduction]);
	return introductionScreens?.length ? /* @__PURE__ */ jsxs("div", {
		className: "adyen-kyc-introduction",
		children: [
			/* @__PURE__ */ jsx(StepProgressIndicator, {
				activeStepIndex: activeIndex + 1,
				stepsCount: introductionScreens.length
			}),
			/* @__PURE__ */ jsx("div", {
				className: "adyen-kyc-introduction__skip",
				children: /* @__PURE__ */ jsx(Button, {
					onClick: () => {
						userEvents.addPageEvent("Clicked button", {
							...pageEventDetails,
							actionType: "skip",
							label: "goToOverviewFromIntroduction"
						});
						onExitIntroduction();
					},
					variant: "link",
					children: t(($) => $["goToOverviewFromIntroduction"], { ns: "introduction" })
				})
			}),
			/* @__PURE__ */ jsx(IntroductionScreen, {
				introductionScreen: introductionScreens[activeIndex],
				legalEntity,
				number: activeIndex > 0 && activeIndex < introductionScreens.length - 1 ? activeIndex : void 0
			}, introductionScreens[activeIndex]),
			/* @__PURE__ */ jsxs("div", {
				className: "adyen-kyc-introduction__nav",
				children: [/* @__PURE__ */ jsx(Button, {
					disabled: activeIndex === 0,
					onClick: () => {
						userEvents.addPageEvent("Clicked button", {
							...pageEventDetails,
							actionType: "back",
							label: "back"
						});
						setActiveIndex((currentValue) => currentValue - 1);
					},
					variant: "secondary",
					children: t(($) => $["back"])
				}), activeIndex + 1 === introductionScreens.length ? /* @__PURE__ */ jsx(Button, {
					onClick: () => {
						userEvents.addTaskEvent("Success", {
							actionType: "submit",
							label: "start"
						});
						onExitIntroduction();
					},
					children: t(($) => $["start"])
				}) : /* @__PURE__ */ jsx(Button, {
					onClick: () => {
						userEvents.addPageEvent("Clicked button", {
							...pageEventDetails,
							actionType: "next",
							label: "next"
						});
						setActiveIndex((currentValue) => currentValue + 1);
					},
					children: t(($) => $["continue"])
				})]
			})
		]
	}) : null;
};
//#endregion
export { Introduction };
