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] = "c29ec463-f262-49a7-8764-01b1bea7cce6", e._sentryDebugIdIdentifier = "sentry-dbid-c29ec463-f262-49a7-8764-01b1bea7cce6");
} catch (e) {}
import { 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 } from "./useLegalEntity-Dm6g0wmt.js";
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { y as isEmpty } from "./validatorUtils-Dz6AklT-.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-CCXvMgfE.js";
import { t as Header } from "./Header-B_MIsVov.js";
import { t as UnincorporatedPartnershipMemberTypes } from "./unincorporated-partnership-CtwHVLzp.js";
import { t as createFormUtils } from "./formUtils-DERTAXyh.js";
import { t as Field } from "./Field-BEqknhTe.js";
import { t as TileGroup } from "./TileGroup-COge4hw4.js";
import { t as useForm } from "./useForm-DzG9tJAE.js";
import { t as RadioGroup } from "./RadioGroup-XuCtbRrH.js";
import { t as FormNavigation } from "./FormNavigation-Btkou5O7.js";
import { t as useUnincorporatedPartnershipMembers } from "./useUnincorporatedPartnershipMembers-D7U6aM_k.js";
import { a as trustMemberLegalEntityTypes } from "./types-BvdB7N_Z.js";
import { useState } from "preact/hooks";
import { jsx, jsxs } from "preact/jsx-runtime";
import { skipToken } from "@tanstack/preact-query";
import { useParams } from "wouter-preact";
var UnincorporatedPartnershipRoleAndType_module_default = {
	"adyen-kyc-role-and-type-container": "adyen-kyc-adyen-kyc-role-and-type-container",
	adyenKycRoleAndTypeContainer: "adyen-kyc-adyen-kyc-role-and-type-container",
	"adyen-kyc-role-and-type-action-bar": "adyen-kyc-adyen-kyc-role-and-type-action-bar",
	adyenKycRoleAndTypeActionBar: "adyen-kyc-adyen-kyc-role-and-type-action-bar",
	"inline-radio-group": "adyen-kyc-inline-radio-group",
	inlineRadioGroup: "adyen-kyc-inline-radio-group",
	"input-wrapper": "adyen-kyc-input-wrapper",
	inputWrapper: "adyen-kyc-input-wrapper",
	"input-radio__content": "adyen-kyc-input-radio__content",
	inputRadioContent: "adyen-kyc-input-radio__content",
	"error-text": "adyen-kyc-error-text",
	errorText: "adyen-kyc-error-text"
};
//#endregion
//#region src/components/UnincorporatedPartnership/tasks/UnincorporatedPartnershipRoleAndType/UnincorporatedPartnershipRadioGroup.tsx
var UnincorporatedPartnershipRadioGroup = ({ memberType, errorMessage, handleChangeFor, value }) => {
	const { t } = useTranslation("unincorpPartnership");
	return /* @__PURE__ */ jsx(Field, {
		el: "fieldset",
		name: memberType,
		label: t(($) => $[memberType === UnincorporatedPartnershipMemberTypes.OWNER ? "ownerDescriptionAsPartner" : "controllerDescriptionAsPartner"]),
		className: UnincorporatedPartnershipRoleAndType_module_default.inlineRadioGroup,
		errorMessage,
		children: (childProps) => /* @__PURE__ */ jsx(RadioGroup, {
			...childProps,
			name: memberType,
			items: [{
				id: "yes",
				name: "yes"
			}, {
				id: "no",
				name: "no"
			}],
			value,
			onChange: (id) => handleChangeFor(memberType)(id),
			horizontal: true
		})
	});
};
//#endregion
//#region src/components/UnincorporatedPartnership/tasks/UnincorporatedPartnershipRoleAndType/validate.ts
var unincorporatedPartnershipRoleAndTypeValidationRules = {
	entityType: {
		modes: ["blur"],
		validate: (entityType) => !isEmpty(entityType),
		errorMessage: "fieldIsRequired"
	},
	uboThroughControl: {
		modes: ["blur"],
		validate: (value) => !!value,
		errorMessage: "fieldIsRequired"
	},
	uboThroughOwnership: {
		modes: ["blur"],
		validate: (value) => !!value,
		errorMessage: "fieldIsRequired"
	}
};
//#endregion
//#region src/components/UnincorporatedPartnership/tasks/UnincorporatedPartnershipRoleAndType/UnincorporatedPartnershipRoleAndType.tsx
var regularForms = {
	roleAndEntityType: {
		formId: "roleAndEntityType",
		formName: "roleAndEntityType",
		fields: ["role", "entityType"]
	},
	memberDetails: {
		formId: "memberDetails",
		formName: "memberDetails"
	}
};
var leTypeCardDetails = {
	[LegalEntityTypes.INDIVIDUAL]: {
		id: "individual",
		name: "individualMember",
		description: "partnerNotABusiness"
	},
	[LegalEntityTypes.ORGANIZATION]: {
		id: "organization",
		name: "companyMember",
		description: "partnerIsABusiness"
	}
};
function getUboStatus(roles, roleType, existingMember) {
	if (!existingMember) return;
	return roles?.includes(roleType) ? "yes" : "no";
}
/**
* Component to render member selection type for Unincorporated Partnership.
* Types are 'secondaryPartner', 'uboThrouhControl' and 'uboThroughOwnership'
* @param onNavigateToMember callback function to navigate to Individual/Business dropin dependending on member and role selected
* @param activeMember member that is currently selected. May be undefined if creating a new member
*/
function UnincorporatedPartnershipRoleAndTypeDropin({ onNavigateToMember, activeMember }) {
	const { t } = useTranslation(["common"]);
	const { t: unincorpPartnershipT } = useTranslation(["unincorpPartnership"]);
	const [shouldValidate, setShouldValidate] = useState(false);
	const activeForm = regularForms.roleAndEntityType;
	const formUtils = createFormUtils({}, t);
	const formsWithValidity = Object.values(regularForms).map((form) => ({
		formId: form.formId,
		formName: form.formName,
		isValid: false
	}));
	const existingMember = activeMember?.legalEntityId;
	const defaultData = {
		entityType: activeMember?.legalEntityType,
		uboThroughControl: getUboStatus(activeMember?.roles, UnincorporatedPartnershipMemberTypes.CONTROLLING_PERSON, existingMember),
		uboThroughOwnership: getUboStatus(activeMember?.roles, UnincorporatedPartnershipMemberTypes.OWNER, existingMember)
	};
	const decideFields = (data) => {
		if (data.entityType === LegalEntityTypes.INDIVIDUAL) return [
			"entityType",
			"uboThroughControl",
			"uboThroughOwnership"
		];
		return ["entityType"];
	};
	const { data, schema, errors, fieldProblems, handleChangeFor } = useForm({
		schema: decideFields,
		rules: unincorporatedPartnershipRoleAndTypeValidationRules,
		defaultData,
		shouldValidate
	});
	const onNextClick = () => {
		if (Object.values(data).some((fieldValue) => !fieldValue) && data.entityType !== LegalEntityTypes.ORGANIZATION) {
			setShouldValidate(true);
			return;
		}
		const selectedRoles = [UnincorporatedPartnershipMemberTypes.SECONDARY_PARTNER];
		if (data.entityType === LegalEntityTypes.INDIVIDUAL) {
			if (data.uboThroughControl === "yes") selectedRoles.push(UnincorporatedPartnershipMemberTypes.CONTROLLING_PERSON);
			if (data.uboThroughOwnership === "yes") selectedRoles.push(UnincorporatedPartnershipMemberTypes.OWNER);
		}
		onNavigateToMember({
			selectedMember: activeMember,
			selectedRoles,
			selectedEntityType: data.entityType
		});
	};
	return /* @__PURE__ */ jsxs("div", {
		className: UnincorporatedPartnershipRoleAndType_module_default.adyenKycRoleAndTypeContainer,
		children: [/* @__PURE__ */ jsx("div", {
			className: "adyen-kyc-dropin__sidebar-wrapper",
			children: /* @__PURE__ */ jsx(FormNavigation, {
				forms: formsWithValidity,
				activeForm: formsWithValidity.find((form) => form.formId === activeForm.formId) || formsWithValidity?.[0],
				taskName: "unincorporatedPartnershipMembers",
				gotoForm: () => {}
			})
		}), /* @__PURE__ */ jsxs("div", {
			className: "adyen-kyc-form-container",
			children: [/* @__PURE__ */ jsx("div", {
				className: activeForm.formId !== "roleAndEntityType" ? "adyen-kyc-form-wrapper--hidden" : "",
				children: /* @__PURE__ */ jsxs("form", {
					className: "u-width-full",
					children: [
						/* @__PURE__ */ jsx(Header, {
							title: t(($) => $["roleAndEntityType"]),
							description: unincorpPartnershipT(($) => $["partnerRoleDescription"])
						}),
						/* @__PURE__ */ jsx(Field, {
							el: "fieldset",
							name: "entityType",
							label: formUtils.getLabel("entityType", "whatTypeOfEntityIsPartner"),
							errorMessage: formUtils.getErrorMessage("entityType", errors, fieldProblems),
							children: (childProps) => /* @__PURE__ */ jsx(TileGroup, {
								...childProps,
								name: "entityType",
								tiles: trustMemberLegalEntityTypes.map((option) => ({
									value: option,
									label: unincorpPartnershipT(($) => $[leTypeCardDetails[option].name]),
									subTitle: unincorpPartnershipT(($) => $[leTypeCardDetails[option].description])
								})),
								selected: data?.entityType ?? "",
								onChange: (value) => handleChangeFor("entityType")(value),
								isHorizontal: true,
								"aria-required": true
							})
						}),
						schema.includes("uboThroughOwnership") && /* @__PURE__ */ jsx(UnincorporatedPartnershipRadioGroup, {
							memberType: UnincorporatedPartnershipMemberTypes.OWNER,
							handleChangeFor,
							errorMessage: formUtils.getErrorMessage(UnincorporatedPartnershipMemberTypes.OWNER, errors, fieldProblems),
							value: data?.uboThroughOwnership
						}),
						schema.includes("uboThroughControl") && /* @__PURE__ */ jsx(UnincorporatedPartnershipRadioGroup, {
							memberType: UnincorporatedPartnershipMemberTypes.CONTROLLING_PERSON,
							handleChangeFor,
							errorMessage: formUtils.getErrorMessage(UnincorporatedPartnershipMemberTypes.CONTROLLING_PERSON, errors, fieldProblems),
							value: data?.uboThroughControl
						})
					]
				})
			}), /* @__PURE__ */ jsx("div", {
				className: UnincorporatedPartnershipRoleAndType_module_default.adyenKycRoleAndTypeActionBar,
				children: /* @__PURE__ */ jsx(Button, {
					onClick: onNextClick,
					children: t(($) => $["continue"])
				})
			})]
		})]
	});
}
//#endregion
//#region src/components/UnincorporatedPartnership/pages/UnincorporatedPartnershipMemberRoleAndTypePage.tsx
function UnincorporatedPartnershipMemberRoleAndTypePage({ memberId: memberIdProp, onNavigateToMember, navigateBack }) {
	const routeParams = useParams();
	const memberId = memberIdProp ?? routeParams.memberId;
	const { i18n } = useTranslation();
	const { data: memberLe } = useLegalEntity(memberId || skipToken);
	const unincorporatedPartnershipMembers = useUnincorporatedPartnershipMembers();
	addResourceBundles(i18n, [{
		ns: "unincorpPartnership",
		importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
			"../language/bg-BG.json": () => import("./bg-BG-BNqOiDw9.js"),
			"../language/cs-CZ.json": () => import("./cs-CZ-DNvBXQqI.js"),
			"../language/da-DK.json": () => import("./da-DK-LXurZBZ8.js"),
			"../language/de-DE.json": () => import("./de-DE-apC2os2u.js"),
			"../language/el-GR.json": () => import("./el-GR-CiverXpL.js"),
			"../language/en-US.json": () => import("./en-US-Cd8cLmVX.js"),
			"../language/es-ES.json": () => import("./es-ES-DFg_LlqD.js"),
			"../language/et-EE.json": () => import("./et-EE-DJWVyTVM.js"),
			"../language/fi-FI.json": () => import("./fi-FI-DZyEs_5S.js"),
			"../language/fr-FR.json": () => import("./fr-FR-CsoVB-yq.js"),
			"../language/hr-HR.json": () => import("./hr-HR-DpQuBztk.js"),
			"../language/hu-HU.json": () => import("./hu-HU-BED5SDWE.js"),
			"../language/it-IT.json": () => import("./it-IT-CCtD36Df.js"),
			"../language/ja-JP.json": () => import("./ja-JP-tHJpSXnY.js"),
			"../language/lt-LT.json": () => import("./lt-LT-CpQj1HiE.js"),
			"../language/lv-LV.json": () => import("./lv-LV-BGMkr0W_.js"),
			"../language/nl-NL.json": () => import("./nl-NL-BtwZkAPX.js"),
			"../language/no-NO.json": () => import("./no-NO-YjH9dIrD.js"),
			"../language/pl-PL.json": () => import("./pl-PL-x6CltZUu.js"),
			"../language/pt-BR.json": () => import("./pt-BR-B0zBNcPy.js"),
			"../language/pt-PT.json": () => import("./pt-PT-C0GJNK9V.js"),
			"../language/ro-RO.json": () => import("./ro-RO-B3hA8dZo.js"),
			"../language/sk-SK.json": () => import("./sk-SK-DwG8xkcP.js"),
			"../language/sl-SI.json": () => import("./sl-SI-DnpKMUhR.js"),
			"../language/sv-SE.json": () => import("./sv-SE-D3hPP-Mp.js")
		}), `../language/${lang}.json`, 3)
	}]);
	if (memberId && !memberLe) return /* @__PURE__ */ jsx(Loader, {});
	return /* @__PURE__ */ jsx(UnincorporatedPartnershipRoleAndTypeDropin, {
		activeMember: memberId ? unincorporatedPartnershipMembers.find((tm) => tm.legalEntityId === memberId) : void 0,
		onNavigateToMember,
		navigateBack
	});
}
//#endregion
export { UnincorporatedPartnershipMemberRoleAndTypePage };
