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] = "1b8b48aa-84f1-4aac-884a-07de1638f791", e._sentryDebugIdIdentifier = "sentry-dbid-1b8b48aa-84f1-4aac-884a-07de1638f791");
} catch (e) {}
import { i as Typography, r as useTranslation } from "./translation-Br5wIPO-.js";
import { t as Button } from "./Button-BDEdGXnd.js";
import { r as httpPost, s as useApiContext } from "./http-CHTzpXCd.js";
import { t as CountryCodes } from "./country-code-D3oCpE4i.js";
import { c as individualBaseMapping, y as reverseMapping } from "./processCapabilities-CDSEJpB8.js";
import { o as getNomineeFromAssociation } from "./entityAssociationUtil-C0gX4Ewv.js";
import { t as DecisionMakerTypes } from "./decision-maker-type-DHBYiKIe.js";
import { t as useAnalyticsContext } from "./useAnalyticsContext-DfTXpZbA.js";
import { r as formatObject } from "./utils--gwzjjeS.js";
import { t as Field } from "./Field-BEqknhTe.js";
import { t as TileGroup } from "./TileGroup-COge4hw4.js";
import { n as mapApiScriptLocalizationToSchemaFields, t as mapAddressLocalizationToJpAddressSchema } from "./mapAddressLocalizationToJpAddressSchema-CbGZXKK3.js";
import { jsx, jsxs } from "preact/jsx-runtime";
import { signal } from "@preact/signals";
import { useMutation } from "@tanstack/preact-query";
//#region src/api/invitations/useCreateInvitation.ts
var createInvitation = async (baseUrl, organizationLegalEntityId, inviteeLegalEntityId, data) => {
	return httpPost({
		baseUrl,
		path: `legalEntities/${organizationLegalEntityId}/invitations/associations/${inviteeLegalEntityId}`
	}, data);
};
var useCreateInvitation = (options) => {
	const { baseUrl } = useApiContext();
	return useMutation({
		mutationFn: ({ organizationLegalEntityId, inviteeLegalEntityId, data }) => {
			return createInvitation(baseUrl.value, organizationLegalEntityId, inviteeLegalEntityId, data);
		},
		...options
	});
};
//#endregion
//#region src/stores/formState.ts
var individualFormDefaultData = signal(null);
var shouldNavigateToAdditionalPersonalDetailsForMissingData = signal(false);
var GuidanceQuestion_module_default = {
	"guidance-question": "adyen-kyc-guidance-question",
	guidanceQuestion: "adyen-kyc-guidance-question",
	options: "adyen-kyc-options"
};
//#endregion
//#region src/components/Individual/forms/GuidanceQuestion/GuidanceQuestion.tsx
var GuidanceQuestionValues = {
	YES: "Yes",
	NO: "No"
};
var GuidanceQuestion = (props) => {
	const { descriptionLinkText, errorMessage, name, noLabel, onChange, onDescriptionLinkClick, question, value, yesLabel } = props;
	const { t } = useTranslation("common");
	const userEvents = useAnalyticsContext();
	const handleChange = (selectedValue) => {
		userEvents.addFieldEvent("Interacted with form field", {
			actionType: "select",
			field: name,
			returnValue: selectedValue
		});
		onChange(selectedValue || null);
	};
	const yesTileLabel = yesLabel ?? t(($) => $["yes"]);
	const noTileLabel = noLabel ?? t(($) => $["no"]);
	return /* @__PURE__ */ jsxs("div", {
		className: GuidanceQuestion_module_default.guidanceQuestion,
		children: [
			/* @__PURE__ */ jsx(Typography, {
				variant: "body",
				el: "p",
				id: `${name}-question`,
				children: question
			}),
			descriptionLinkText && onDescriptionLinkClick && /* @__PURE__ */ jsx(Button, {
				variant: "link",
				onClick: onDescriptionLinkClick,
				children: descriptionLinkText
			}),
			/* @__PURE__ */ jsx("div", {
				role: "group",
				"aria-labelledby": `${name}-question`,
				children: /* @__PURE__ */ jsx(Field, {
					name,
					className: GuidanceQuestion_module_default.options,
					children: () => /* @__PURE__ */ jsx(TileGroup, {
						allowMultiple: false,
						errorMessage,
						isHorizontal: true,
						maxSelected: 1,
						name,
						onChange: handleChange,
						selected: value || "",
						tiles: [{
							label: yesTileLabel,
							value: GuidanceQuestionValues.YES
						}, {
							label: noTileLabel,
							value: GuidanceQuestionValues.NO
						}]
					})
				})
			})
		]
	});
};
//#endregion
//#region src/components/Individual/mapping/getOnfidoIdentityTypeToApiIdentityTypeMap.ts
var getOnfidoIdentityTypeToApiIdentityTypeMap = (data) => {
	const { country } = data;
	switch (country) {
		case CountryCodes.HongKong: return {
			passport: "passport",
			driversLicense: "driversLicense",
			proofOfIdentityCard: "nationalIdNumber"
		};
		default: return {
			nationalIdNumber: "nationalIdNumber",
			passport: "passport",
			driversLicense: "driversLicense",
			proofOfIdentityCard: "identityCard"
		};
	}
};
//#endregion
//#region src/components/Individual/mapping/mapLegalEntityToIndividualSchema.ts
var getIndividualSchemaFromAPI = { ...individualBaseMapping };
var mapLegalEntityToIndividualSchema = (legalEntity, isChangingType, isRoleFieldNeeded, parentLegalEntity) => {
	let individual = { ...formatObject(legalEntity, getIndividualSchemaFromAPI) };
	individual = {
		...individual,
		basicDetails: {
			...individual?.basicDetails,
			...isChangingType && {
				firstName: "",
				lastName: "",
				localization: {}
			}
		},
		signatoryQuestionnaire: { isSignatory: isChangingType ? null : individual.signatoryQuestionnaire?.isSignatory ?? null },
		uboQuestionnaire: isChangingType ? {
			isOwner: null,
			isControllingPerson: null,
			isDirector: null,
			isNomineeShareholder: null,
			isNomineeDirector: null
		} : {
			isOwner: individual.uboQuestionnaire?.isOwner ?? null,
			isControllingPerson: individual.uboQuestionnaire?.isControllingPerson ?? null,
			isDirector: individual.uboQuestionnaire?.isDirector ?? null,
			isNomineeDirector: individual.uboQuestionnaire?.isNomineeDirector ?? null,
			isNomineeShareholder: individual.uboQuestionnaire?.isNomineeShareholder ?? null
		}
	};
	if (legalEntity?.documentDetails?.length) individual = {
		...individual,
		idVerificationMethod: {
			idVerificationMethod: "existingDocument",
			idDocument: mapDocumentDetailToIdDocument(legalEntity.documentDetails)
		}
	};
	if (legalEntity.individual?.identificationData?.type && individual.additionalPersonalDetails) {
		const apiIdentityTypeToIdentityTypeMap = reverseMapping(getOnfidoIdentityTypeToApiIdentityTypeMap(individual.additionalPersonalDetails));
		individual.additionalPersonalDetails.typeOfIdentity = apiIdentityTypeToIdentityTypeMap[legalEntity.individual.identificationData.type];
	}
	if (legalEntity.individual?.name?.localization) for (const scriptLoc of legalEntity.individual.name.localization) individual.basicDetails = {
		...individual.basicDetails,
		...mapApiScriptLocalizationToSchemaFields(scriptLoc)
	};
	if (legalEntity.individual?.residentialAddress?.localization) individual.additionalPersonalDetails = {
		...individual.additionalPersonalDetails,
		...mapAddressLocalizationToJpAddressSchema(legalEntity.individual.residentialAddress.localization)
	};
	/**
	* Map association details of individual to personal
	* details from parentLegalEntity. role, jobTitle, relationship, nomineeShareholder,
	* nomineeDirector are not part of individual legalEntity but part of entityAssociations
	* in parentLegalEntity
	* **/
	if (!parentLegalEntity?.entityAssociations) return individual;
	const associations = parentLegalEntity?.entityAssociations?.filter((ea) => ea.legalEntityId === legalEntity?.id) ?? [];
	if (isRoleFieldNeeded && individual.basicDetails) {
		individual.basicDetails.role = associations.map((ea) => ea.type);
		individual.basicDetails.jobTitle = associations.find(({ jobTitle }) => Boolean(jobTitle))?.jobTitle;
	}
	if (isRoleFieldNeeded && individual.signatoryQuestionnaire && individual.uboQuestionnaire) {
		const associationTypes = new Set(associations.map((ea) => ea.type));
		const hasAssociation = (type) => associationTypes.has(type) ? GuidanceQuestionValues.YES : GuidanceQuestionValues.NO;
		individual.signatoryQuestionnaire.isSignatory = hasAssociation(DecisionMakerTypes.SIGNATORY);
		individual.uboQuestionnaire.isOwner = hasAssociation(DecisionMakerTypes.OWNER);
		individual.uboQuestionnaire.isControllingPerson = hasAssociation(DecisionMakerTypes.CONTROLLING_PERSON);
		individual.uboQuestionnaire.isDirector = hasAssociation(DecisionMakerTypes.DIRECTOR);
		const hasNomineeAssociation = (type) => associations.some((ea) => ea.type === type && ea.nominee) ? GuidanceQuestionValues.YES : GuidanceQuestionValues.NO;
		individual.uboQuestionnaire.isNomineeDirector = hasNomineeAssociation(DecisionMakerTypes.DIRECTOR);
		individual.uboQuestionnaire.isNomineeShareholder = hasNomineeAssociation(DecisionMakerTypes.OWNER);
	}
	individual.basicDetails = getNomineeFromAssociation(associations, individual.basicDetails);
	return individual;
};
var mapDocumentDetailToIdDocument = (documents) => {
	const activeDocument = documents.find((document) => document.active);
	return activeDocument ? {
		idDocumentType: activeDocument.type,
		modificationDate: activeDocument.modificationDate
	} : void 0;
};
//#endregion
export { individualFormDefaultData as a, GuidanceQuestionValues as i, getOnfidoIdentityTypeToApiIdentityTypeMap as n, shouldNavigateToAdditionalPersonalDetailsForMissingData as o, GuidanceQuestion as r, useCreateInvitation as s, mapLegalEntityToIndividualSchema as t };
