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] = "c13d1ea3-e933-459f-95ba-f8ccc3a42166", e._sentryDebugIdIdentifier = "sentry-dbid-c13d1ea3-e933-459f-95ba-f8ccc3a42166");
} catch (e) {}
import { a as Icon, c as __exportAll, i as Typography, n as addResourceBundles, o as createLogger, r as useTranslation } from "./translation-Br5wIPO-.js";
import { n as IconButton, r as Loader, t as Button } from "./Button-BDEdGXnd.js";
import { n as httpGet, r as httpPost, s as useApiContext } from "./http-CHTzpXCd.js";
import { n as useLegalEntities, r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-Dm6g0wmt.js";
import { t as getLegalEntityCountry } from "./getLegalEntityCountry-C6bSV6sB.js";
import { o as objectsDeepEqual } from "./AnalyticsContext-C0HNdPss.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-CCXvMgfE.js";
import { t as StackLayout } from "./StackLayout-BMQXXBDb.js";
import { n as TASK_STATUS_POLLING_INTERVAL_MS } from "./taskStatus-CvMqhrOK.js";
import { t as Header } from "./Header-B_MIsVov.js";
import { t as Alert } from "./Alert-CjZYipjN.js";
import { C as EntityTypes } from "./processCapabilities-CDSEJpB8.js";
import { t as TaskTypes } from "./taskTypes-DWaxzvnQ.js";
import { t as useBusinessLines } from "./useBusinessLines-BJV9biUj.js";
import { t as Card } from "./Card-DXdUqwyQ.js";
import { t as useAnalyticsContext } from "./useAnalyticsContext-DfTXpZbA.js";
import { t as useToastContext } from "./useToastContext-CK7UoZ5Z.js";
import { n as useCapabilityProblems, t as getProblemsForEntity } from "./getProblemsForEntity-COcJt47f.js";
import { t as useInvalidateRootLegalEntity } from "./invalidateRootLegalEntity-BHyct4ev.js";
import { t as Avatar } from "./Avatar-4gshS6xA.js";
import { t as Modal } from "./Modal-DOC6JgPI.js";
import { t as Confirm } from "./Confirm-BqhBxIWm.js";
import { t as Image } from "./Image-BPAtdM5Y.js";
import { n as translateTranslatable } from "./utils-g_Wl4-9Z.js";
import { t as useCreateLegalEntity } from "./useCreateLegalEntity-C149Z7Xu.js";
import { t as useUpdateLegalEntity } from "./useUpdateLegalEntity-CUs6TYPF.js";
import { i as FormFlow, n as addValidityToForms, o as useFormComposer, r as getRequiredForms, s as FormContextProvider, t as useFormContext } from "./useFormContext-Cu4dKSCy.js";
import { t as StructuredList } from "./StructuredList-S4LIZQiJ.js";
import { t as ErrorPanel } from "./ErrorPanel-5g1eTEVD.js";
import { t as createFormUtils } from "./formUtils-DERTAXyh.js";
import { t as useMultiForm } from "./useMultiForm-tpVMuqHM.js";
import { t as useTaskLandedEvent } from "./useTaskLandedEvent-DCdJo64z.js";
import { o as createDocumentRequest, s as documentApiUtils } from "./validate-DlG5LXuM.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 { t as LandingLayout } from "./LandingLayout-C9eryD6V.js";
import { t as Select } from "./Select-CMFHti4N.js";
import { t as Checkbox } from "./Checkbox-BJJIXNHL.js";
import { t as TextArea } from "./TextArea-qzKHJyZG.js";
import { t as Dropzone } from "./Dropzone-D8gz-OLM.js";
import { t as InputText } from "./InputText-CadVntiC.js";
import { t as InputDate } from "./InputDate-DsEAx7kx.js";
import { n as CountryField } from "./CountryField-B-JxQ6z9.js";
import { t as RadioGroup } from "./RadioGroup-XuCtbRrH.js";
import { t as InputGroup } from "./InputGroup-B8AaetlI.js";
import { t as isEmpty } from "./isEmpty-Cf1sv6Wg.js";
import { n as validateDateNotInTheFuture } from "./validate-_5wbUbU9.js";
import { t as useTaskStatus } from "./useTaskStatus-DzJWcN_l.js";
import { C as getSourceOfFundsRequiredForms, D as parseSofOriginatorPayload, E as parseSOFDocumentDescription, O as sofCategoryItemMapper, S as getSourceOfFundsRequiredFields, T as parseOriginatorDetails, _ as getServiceTranslation, a as allowedCurrencies, b as getSofCardDetails, c as getAdditionalDataForOriginator, d as getDocumentLists, f as getDocumentRequirements, g as getRelevantErrors, h as getPageHeadings, i as TODAY_DATE, k as formatAmountWithCurrency, l as getAdditionalDataSchemaKeys, m as getInputErrors, o as areSourceOfFundsEqual, p as getGettingStartedCardDetails, r as SOF_INVALID_INPUT_ERROR_CODES, s as formatDateForInput, t as ALLOWED_SOF_SERVICES, u as getApplicableBusinessLines, v as getServiceTranslationKey, w as getUniqueRemediationActions, x as getSourceOfFundsPayload, y as getServiceTranslationSelectTitle } from "./utils-eDM77TZ4.js";
import { lazy } from "preact/compat";
import { useCallback as useCallback$1, useEffect as useEffect$1, useMemo as useMemo$1, useState as useState$1 } from "preact/hooks";
import { Fragment as Fragment$1, jsx, jsxs } from "preact/jsx-runtime";
import { signal } from "@preact/signals";
import { useMutation, useQuery, useQueryClient } from "@tanstack/preact-query";
//#region src/api/businessLines/useUpdateSourceOfFunds.ts
var updateSourceOfFunds = async (businessLineId, legalEntityId, baseUrl, data) => {
	return httpPost({
		baseUrl,
		path: `legalEntities/${legalEntityId}/businessLines/${businessLineId}/sourceOfFunds`
	}, data);
};
var useUpdateSourceOfFunds = (options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
	return useMutation({
		mutationFn: ({ businessLineId, ...requestData }) => updateSourceOfFunds(businessLineId, rootLegalEntityId.value, baseUrl.value, requestData),
		onSuccess: async () => {
			await invalidateRootLegalEntity();
		},
		...options
	});
};
var sourceOfFundsComponentsKeyMapping = {
	"sourceOfFundsType.type": "sourceOfFunds.type",
	"additionalData.description": "sourceOfFunds.description",
	"additionalData.amount": "sourceOfFunds.amount",
	"additionalData.dateOfFundsReceived": "sourceOfFunds.dateOfFundsReceived",
	"additionalData.purpose": "sourceOfFunds.purpose",
	"additionalData.relationship": "sourceOfFunds.relationship",
	"additionalData.originatorLegalEntityId": "sourceOfFunds.originatorLegalEntityId",
	"additionalData.financiers": "sourceOfFunds.financiers",
	"additionalData.cryptocurrencyExchange": "sourceOfFunds.cryptocurrencyExchange",
	"additionalData.dateOfSourceEvent": "sourceOfFunds.dateOfSourceEvent",
	"additionalData.website": "sourceOfFunds.website",
	"additionalData.legalName": "sourceOfFunds.legalName",
	"additionalData.firstName": "sourceOfFunds.firstName",
	"additionalData.lastName": "sourceOfFunds.lastName",
	"additionalData.country": "sourceOfFunds.country",
	"additionalData.originatorType": "sourceOfFunds.originatorType"
};
//#endregion
//#region src/components/EFP/mapping/mapSourceOfFundToSourceOfFundsSchema.ts
var mapSourceOfFundToSourceOfFundsSchema = (businessLine) => formatObject(businessLine, sourceOfFundsComponentsKeyMapping);
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/sofStore.ts
var sofErrorMessage = signal(void 0);
var setSofErrorMessage = (message) => {
	sofErrorMessage.value = message;
};
var clearSofErrorMessage = () => {
	sofErrorMessage.value = void 0;
};
//#endregion
//#region src/api/datasets/useSourceOfFundsTypes.ts
var getSourceOfFundsTypes = async (baseUrl) => {
	return httpGet({
		baseUrl,
		path: `datasets/sourceOfFundsTypes`
	});
};
var useSourceOfFundsTypes = (options) => {
	const { baseUrl } = useApiContext();
	return useQuery({
		queryKey: ["sourceOfFundsTypes"],
		queryFn: () => getSourceOfFundsTypes(baseUrl.value),
		...options
	});
};
var SourceOfFunds_module_default = {
	"source-of-funds": "adyen-kyc-source-of-funds",
	sourceOfFunds: "adyen-kyc-source-of-funds",
	"source-of-funds-awe": "adyen-kyc-source-of-funds-awe",
	sourceOfFundsAwe: "adyen-kyc-source-of-funds-awe",
	"source-of-funds-wrapper-loading": "adyen-kyc-source-of-funds-wrapper-loading",
	sourceOfFundsWrapperLoading: "adyen-kyc-source-of-funds-wrapper-loading",
	"source-of-funds-wrapper-heading": "adyen-kyc-source-of-funds-wrapper-heading",
	sourceOfFundsWrapperHeading: "adyen-kyc-source-of-funds-wrapper-heading",
	"source-of-funds-wrapper-description": "adyen-kyc-source-of-funds-wrapper-description",
	sourceOfFundsWrapperDescription: "adyen-kyc-source-of-funds-wrapper-description",
	"source-of-funds-same-as-checkbox": "adyen-kyc-source-of-funds-same-as-checkbox",
	sourceOfFundsSameAsCheckbox: "adyen-kyc-source-of-funds-same-as-checkbox",
	"source-of-funds-getting-started": "adyen-kyc-source-of-funds-getting-started",
	sourceOfFundsGettingStarted: "adyen-kyc-source-of-funds-getting-started",
	"source-of-funds-getting-started-awe": "adyen-kyc-source-of-funds-getting-started-awe",
	sourceOfFundsGettingStartedAwe: "adyen-kyc-source-of-funds-getting-started-awe",
	"source-of-funds-getting-started-heading": "adyen-kyc-source-of-funds-getting-started-heading",
	sourceOfFundsGettingStartedHeading: "adyen-kyc-source-of-funds-getting-started-heading",
	"source-of-funds-getting-started-body": "adyen-kyc-source-of-funds-getting-started-body",
	sourceOfFundsGettingStartedBody: "adyen-kyc-source-of-funds-getting-started-body",
	"source-of-funds-getting-started-error": "adyen-kyc-source-of-funds-getting-started-error",
	sourceOfFundsGettingStartedError: "adyen-kyc-source-of-funds-getting-started-error",
	"source-of-funds-getting-started-error-actions": "adyen-kyc-source-of-funds-getting-started-error-actions",
	sourceOfFundsGettingStartedErrorActions: "adyen-kyc-source-of-funds-getting-started-error-actions",
	"source-of-funds-getting-started-cards": "adyen-kyc-source-of-funds-getting-started-cards",
	sourceOfFundsGettingStartedCards: "adyen-kyc-source-of-funds-getting-started-cards",
	"source-of-funds-getting-started-cards-card": "adyen-kyc-source-of-funds-getting-started-cards-card",
	sourceOfFundsGettingStartedCardsCard: "adyen-kyc-source-of-funds-getting-started-cards-card",
	"source-of-funds-getting-started-cards-card-header": "adyen-kyc-source-of-funds-getting-started-cards-card-header",
	sourceOfFundsGettingStartedCardsCardHeader: "adyen-kyc-source-of-funds-getting-started-cards-card-header",
	"source-of-funds-getting-started-cards-card-body": "adyen-kyc-source-of-funds-getting-started-cards-card-body",
	sourceOfFundsGettingStartedCardsCardBody: "adyen-kyc-source-of-funds-getting-started-cards-card-body",
	"source-of-funds-getting-started-actions": "adyen-kyc-source-of-funds-getting-started-actions",
	sourceOfFundsGettingStartedActions: "adyen-kyc-source-of-funds-getting-started-actions",
	"source-of-funds-additional-data-form": "adyen-kyc-source-of-funds-additional-data-form",
	sourceOfFundsAdditionalDataForm: "adyen-kyc-source-of-funds-additional-data-form",
	"source-of-funds-third-party-funding-financier-group": "adyen-kyc-source-of-funds-third-party-funding-financier-group",
	sourceOfFundsThirdPartyFundingFinancierGroup: "adyen-kyc-source-of-funds-third-party-funding-financier-group",
	"source-of-funds-third-party-funding-name-avatar-group": "adyen-kyc-source-of-funds-third-party-funding-name-avatar-group",
	sourceOfFundsThirdPartyFundingNameAvatarGroup: "adyen-kyc-source-of-funds-third-party-funding-name-avatar-group",
	"source-of-funds-third-party-funding-name-address-group": "adyen-kyc-source-of-funds-third-party-funding-name-address-group",
	sourceOfFundsThirdPartyFundingNameAddressGroup: "adyen-kyc-source-of-funds-third-party-funding-name-address-group",
	"source-of-funds-sof-financier-form-error": "adyen-kyc-source-of-funds-sof-financier-form-error",
	sourceOfFundsSofFinancierFormError: "adyen-kyc-source-of-funds-sof-financier-form-error",
	"source-of-funds-sof-financier-form-name-group": "adyen-kyc-source-of-funds-sof-financier-form-name-group",
	sourceOfFundsSofFinancierFormNameGroup: "adyen-kyc-source-of-funds-sof-financier-form-name-group",
	"source-of-funds-financier-footer": "adyen-kyc-source-of-funds-financier-footer",
	sourceOfFundsFinancierFooter: "adyen-kyc-source-of-funds-financier-footer",
	"source-of-funds-grid-container": "adyen-kyc-source-of-funds-grid-container",
	sourceOfFundsGridContainer: "adyen-kyc-source-of-funds-grid-container",
	"source-of-funds-sub-heading": "adyen-kyc-source-of-funds-sub-heading",
	sourceOfFundsSubHeading: "adyen-kyc-source-of-funds-sub-heading",
	"source-of-funds-upload-modal-content-field": "adyen-kyc-source-of-funds-upload-modal-content-field",
	sourceOfFundsUploadModalContentField: "adyen-kyc-source-of-funds-upload-modal-content-field",
	"source-of-funds-upload-modal-content-field-radio-group": "adyen-kyc-source-of-funds-upload-modal-content-field-radio-group",
	sourceOfFundsUploadModalContentFieldRadioGroup: "adyen-kyc-source-of-funds-upload-modal-content-field-radio-group",
	"source-of-funds-upload-modal-content-requirements-container": "adyen-kyc-source-of-funds-upload-modal-content-requirements-container",
	sourceOfFundsUploadModalContentRequirementsContainer: "adyen-kyc-source-of-funds-upload-modal-content-requirements-container",
	"source-of-funds-upload-list-heading": "adyen-kyc-source-of-funds-upload-list-heading",
	sourceOfFundsUploadListHeading: "adyen-kyc-source-of-funds-upload-list-heading",
	"source-of-funds-modal": "adyen-kyc-source-of-funds-modal",
	sourceOfFundsModal: "adyen-kyc-source-of-funds-modal"
};
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataForAssetSale.tsx
function AdditionalDataForAssetSale(props) {
	const [isFocused, setIsFocused] = useState$1(false);
	const { formUtils, data, errors, valid, fieldProblems, handleChangeFor, handleAmountChange } = props;
	const { t: commonT } = useTranslation("common");
	const handleOnAmountBlur = () => {
		setIsFocused(false);
		handleAmountChange("amount");
	};
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
		className: SourceOfFunds_module_default.sourceOfFundsGridContainer,
		children: [/* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "amount",
			label: formUtils.getLabel("amount", "saleAmount"),
			errorMessage: formUtils.getErrorMessage("amount", errors, fieldProblems),
			children: (childProps) => /* @__PURE__ */ jsxs(InputGroup, {
				...childProps,
				id: "currencyGroup",
				isFocused,
				isInvalid: Boolean(!valid.amount && errors.amount),
				children: [/* @__PURE__ */ jsx(Select, {
					name: "currency",
					"aria-label": commonT(($) => $["currency"]),
					isMulti: false,
					items: allowedCurrencies,
					selected: data.amount?.currency,
					placeholder: commonT(($) => $["select"]),
					onChange: handleAmountChange("currency"),
					minimal: true
				}), /* @__PURE__ */ jsx(InputText, {
					...childProps,
					name: "amount",
					value: data.amount?.value,
					readonly: formUtils.isReadOnly("amount"),
					onInput: handleAmountChange("amount"),
					onBlur: handleOnAmountBlur,
					"aria-required": true,
					"aria-invalid": !valid.amount,
					isValid: valid.amount,
					onFocusHandler: () => setIsFocused(true)
				})]
			})
		}), /* @__PURE__ */ jsx(Field, {
			name: "dateOfSourceEvent",
			label: formUtils.getLabel("dateOfSourceEvent", "dateOfSale"),
			errorMessage: formUtils.getErrorMessage("dateOfSourceEvent", errors, fieldProblems),
			isValid: valid.dateOfSourceEvent,
			children: (childProps) => /* @__PURE__ */ jsx(InputDate, {
				...childProps,
				name: "dateOfSourceEvent",
				value: formatDateForInput(data.dateOfSourceEvent),
				onInput: handleChangeFor("dateOfSourceEvent", "input"),
				onBlur: handleChangeFor("dateOfSourceEvent", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.dateOfSourceEvent,
				max: TODAY_DATE
			})
		})]
	}), /* @__PURE__ */ jsx(Field, {
		name: "description",
		label: formUtils.getLabel("description", "propertyDescription"),
		errorMessage: formUtils.getErrorMessage("description", errors, fieldProblems),
		isValid: valid.description,
		children: (childProps) => /* @__PURE__ */ jsx(TextArea, {
			...childProps,
			name: "description",
			value: data.description,
			maxLength: 200,
			onInput: handleChangeFor("description"),
			onBlur: handleChangeFor("description"),
			"aria-invalid": !valid.description
		})
	})] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataForBusiness.tsx
function AdditionalDataForBusiness(props) {
	const [isFocused, setIsFocused] = useState$1(false);
	const { formUtils, data, errors, valid, fieldProblems, handleChangeFor, handleAmountChange } = props;
	const { t: commonT } = useTranslation("common");
	const handleOnAmountBlur = () => {
		setIsFocused(false);
		handleAmountChange("amount");
	};
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Field, {
		el: "fieldset",
		name: "amount",
		label: formUtils.getLabel("amount", "annualTurnover"),
		errorMessage: formUtils.getErrorMessage("amount", errors, fieldProblems),
		helper: commonT(($) => $["useFiguresFromTheMostRecentYearAvailable"]),
		helperPosition: "below",
		children: (childProps) => /* @__PURE__ */ jsxs(InputGroup, {
			...childProps,
			id: "currencyGroup",
			isFocused,
			isInvalid: Boolean(!valid.amount && errors.amount),
			children: [/* @__PURE__ */ jsx(Select, {
				name: "currency",
				"aria-label": commonT(($) => $["currency"]),
				isMulti: false,
				items: allowedCurrencies,
				selected: data.amount?.currency,
				placeholder: commonT(($) => $["select"]),
				onChange: handleAmountChange("currency"),
				minimal: true
			}), /* @__PURE__ */ jsx(InputText, {
				...childProps,
				name: "amount",
				value: data.amount?.value,
				readonly: formUtils.isReadOnly("amount"),
				onInput: handleAmountChange("amount"),
				onBlur: handleOnAmountBlur,
				"aria-required": true,
				"aria-invalid": !valid.amount,
				isValid: valid.amount,
				onFocusHandler: () => setIsFocused(true)
			})]
		})
	}), /* @__PURE__ */ jsx(Field, {
		name: "description",
		label: formUtils.getLabel("description", "businessDescription"),
		errorMessage: formUtils.getErrorMessage("description", errors, fieldProblems),
		isValid: valid.description,
		children: (childProps) => /* @__PURE__ */ jsx(TextArea, {
			...childProps,
			name: "description",
			value: data.description,
			maxLength: 200,
			onInput: handleChangeFor("description"),
			onBlur: handleChangeFor("description"),
			"aria-invalid": !valid.description
		})
	})] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataForCryptocurrency.tsx
function AdditionalDataForCryptocurrency(props) {
	const { t: sofT } = useTranslation("sof");
	const { formUtils, data, errors, valid, fieldProblems, handleChangeFor } = props;
	return /* @__PURE__ */ jsx(Field, {
		name: "cryptocurrencyExchange",
		label: formUtils.getLabel("cryptocurrencyExchange", "cryptocurrencyExchange"),
		errorMessage: formUtils.getErrorMessage("cryptocurrencyExchange", errors, fieldProblems),
		isValid: valid.cryptocurrencyExchange,
		helper: sofT(($) => $["nameOfTheExchangeWhereTheCryptocurrencyWasHeldPriorToSale"]),
		helperPosition: "below",
		children: (childProps) => /* @__PURE__ */ jsx(InputText, {
			...childProps,
			name: "cryptocurrencyExchange",
			value: data.cryptocurrencyExchange,
			readonly: formUtils.isReadOnly("cryptocurrencyExchange"),
			onInput: handleChangeFor("cryptocurrencyExchange", "input"),
			onBlur: handleChangeFor("cryptocurrencyExchange", "blur"),
			"aria-required": true,
			"aria-invalid": !valid.cryptocurrencyExchange,
			isValid: valid.cryptocurrencyExchange
		})
	});
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataOriginatorLegalEntity.tsx
var radioItems = [{
	id: "individual",
	name: "individual"
}, {
	id: "organization",
	name: "organization"
}];
function AdditionalDataOriginatorLegalEntity(props) {
	const { t: sofT } = useTranslation("sof");
	const { formUtils, data, errors, valid, fieldProblems, handleChangeFor, sourceOfFundsType } = props;
	const isDonations = sourceOfFundsType === "donations";
	const countryTranslationKey = isDonations && data?.originatorType === "individual" ? "donorsCountryOfResidence" : data?.originatorType === "organization" ? "organizationsCountryOfOperation" : "decedentsCountryOfDeath";
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [
		/* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "originatorType",
			className: SourceOfFunds_module_default.sourceOfFundsUploadModalContentField,
			label: sofT(($) => $[isDonations ? "whereDidThisGiftOrDonationComeFrom" : "whereDidThisInheritanceComeFrom"]),
			errorMessage: formUtils.getErrorMessage("originatorType", errors, fieldProblems),
			isValid: valid.originatorType,
			children: (childProps) => /* @__PURE__ */ jsx(RadioGroup, {
				...childProps,
				name: "originatorType",
				className: SourceOfFunds_module_default.sourceOfFundsUploadModalContentFieldRadioGroup,
				items: radioItems,
				value: data.originatorType,
				disabled: false,
				onChange: handleChangeFor("originatorType", "input"),
				"aria-required": true
			})
		}),
		data?.originatorType === "organization" && /* @__PURE__ */ jsx(Field, {
			name: "legalName",
			label: formUtils.getLabel("legalName", "organizationsLegalName"),
			errorMessage: formUtils.getErrorMessage("legalName", errors, fieldProblems),
			isValid: valid.legalName,
			children: (childProps) => /* @__PURE__ */ jsx(InputText, {
				...childProps,
				name: "legalName",
				value: data.legalName,
				readonly: formUtils.isReadOnly("legalName"),
				onInput: handleChangeFor("legalName", "input"),
				onBlur: handleChangeFor("legalName", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.legalName,
				isValid: valid.legalName
			})
		}),
		data?.originatorType === "individual" && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Field, {
			name: "firstName",
			label: formUtils.getLabel("firstName", isDonations ? "donorsLegalFirstName" : "decedentsLegalFirstName"),
			errorMessage: formUtils.getErrorMessage("firstName", errors, fieldProblems),
			isValid: valid.firstName,
			children: (childProps) => /* @__PURE__ */ jsx(InputText, {
				...childProps,
				name: "firstName",
				value: data.firstName,
				readonly: formUtils.isReadOnly("firstName"),
				onInput: handleChangeFor("firstName", "input"),
				onBlur: handleChangeFor("firstName", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.firstName,
				isValid: valid.firstName
			})
		}), /* @__PURE__ */ jsx(Field, {
			name: "lastName",
			label: formUtils.getLabel("lastName", isDonations ? "donorsLegalLastName" : "decedentsLegalLastName"),
			errorMessage: formUtils.getErrorMessage("lastName", errors, fieldProblems),
			isValid: valid.lastName,
			children: (childProps) => /* @__PURE__ */ jsx(InputText, {
				...childProps,
				name: "lastName",
				value: data.lastName,
				readonly: formUtils.isReadOnly("lastName"),
				onInput: handleChangeFor("lastName", "input"),
				onBlur: handleChangeFor("lastName", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.lastName,
				isValid: valid.lastName
			})
		})] }),
		data?.originatorType && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Field, {
			name: "relationship",
			label: formUtils.getLabel("relationship", isDonations && data?.originatorType === "individual" ? "yourRelationshipToDonor" : data?.originatorType === "organization" ? "yourRelationshipToOrganization" : "yourRelationshipToDecedent"),
			errorMessage: formUtils.getErrorMessage("relationship", errors, fieldProblems),
			isValid: valid.relationship,
			children: (childProps) => /* @__PURE__ */ jsx(InputText, {
				...childProps,
				name: "relationship",
				value: data.relationship,
				readonly: formUtils.isReadOnly("relationship"),
				onInput: handleChangeFor("relationship", "input"),
				onBlur: handleChangeFor("relationship", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.relationship,
				isValid: valid.relationship
			})
		}), /* @__PURE__ */ jsx(CountryField, {
			data: { country: data.country },
			valid: { country: valid.country },
			errors: { country: formUtils.getErrorMessage("country", errors, fieldProblems) },
			labels: { country: sofT(($) => $[countryTranslationKey]) },
			readonly: formUtils.isReadOnly("country"),
			handleChangeFor
		})] })
	] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataForDonation.tsx
function AdditionalDataForDonation(props) {
	const { formUtils, data, errors, valid, fieldProblems, handleChangeFor } = props;
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AdditionalDataOriginatorLegalEntity, {
		formUtils,
		handleChangeFor,
		data,
		errors,
		valid,
		fieldProblems,
		sourceOfFundsType: "donations"
	}), /* @__PURE__ */ jsxs("div", {
		className: SourceOfFunds_module_default.sourceOfFundsGridContainer,
		children: [/* @__PURE__ */ jsx(Field, {
			name: "purpose",
			label: formUtils.getLabel("purpose", "reason"),
			errorMessage: formUtils.getErrorMessage("purpose", errors, fieldProblems),
			isValid: valid.purpose,
			children: (childProps) => /* @__PURE__ */ jsx(InputText, {
				...childProps,
				name: "purpose",
				value: data.purpose,
				readonly: formUtils.isReadOnly("purpose"),
				onInput: handleChangeFor("purpose", "input"),
				onBlur: handleChangeFor("purpose", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.purpose,
				isValid: valid.purpose
			})
		}), /* @__PURE__ */ jsx(Field, {
			name: "dateOfFundsReceived",
			label: formUtils.getLabel("dateOfFundsReceived", "date"),
			errorMessage: formUtils.getErrorMessage("dateOfFundsReceived", errors, fieldProblems),
			isValid: valid.dateOfFundsReceived,
			children: (childProps) => /* @__PURE__ */ jsx(InputDate, {
				...childProps,
				name: "dateOfFundsReceived",
				value: formatDateForInput(data.dateOfFundsReceived),
				onInput: handleChangeFor("dateOfFundsReceived", "input"),
				onBlur: handleChangeFor("dateOfFundsReceived", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.dateOfFundsReceived,
				max: TODAY_DATE
			})
		})]
	})] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataForGambling.tsx
function AdditionalDataForGambling(props) {
	const { t: commonT } = useTranslation("common");
	const [focusedInput, setFocusedInput] = useState$1();
	const { formUtils, data, errors, valid, fieldProblems, handleChangeFor, handleAmountChange } = props;
	const handleOnAmountBlur = () => {
		setFocusedInput(void 0);
		handleAmountChange("amount");
	};
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [
		/* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "amount",
			label: formUtils.getLabel("amount", "totalAmountWon"),
			errorMessage: formUtils.getErrorMessage("amount", errors, fieldProblems),
			children: (childProps) => /* @__PURE__ */ jsxs(InputGroup, {
				...childProps,
				id: "currencyGroup",
				isFocused: focusedInput === "amount",
				isInvalid: Boolean(!valid.amount && errors.amount),
				children: [/* @__PURE__ */ jsx(Select, {
					name: "currency",
					"aria-label": commonT(($) => $["currency"]),
					isMulti: false,
					items: allowedCurrencies,
					selected: data.amount?.currency,
					placeholder: commonT(($) => $["select"]),
					onChange: handleAmountChange("currency"),
					minimal: true
				}), /* @__PURE__ */ jsx(InputText, {
					...childProps,
					name: "amount",
					value: data.amount?.value,
					readonly: formUtils.isReadOnly("amount"),
					onInput: handleAmountChange("amount"),
					onBlur: handleOnAmountBlur,
					"aria-required": true,
					"aria-invalid": !valid.amount,
					isValid: valid.amount,
					onFocusHandler: () => setFocusedInput("amount")
				})]
			})
		}),
		/* @__PURE__ */ jsx(Field, {
			name: "dateOfSourceEvent",
			label: formUtils.getLabel("dateOfSourceEvent", "dateOfWinning"),
			errorMessage: formUtils.getErrorMessage("dateOfSourceEvent", errors, fieldProblems),
			isValid: valid.dateOfSourceEvent,
			children: (childProps) => /* @__PURE__ */ jsx(InputDate, {
				...childProps,
				name: "dateOfSourceEvent",
				value: formatDateForInput(data.dateOfSourceEvent),
				onInput: handleChangeFor("dateOfSourceEvent", "input"),
				onBlur: handleChangeFor("dateOfSourceEvent", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.dateOfSourceEvent,
				max: TODAY_DATE
			})
		}),
		/* @__PURE__ */ jsx(Field, {
			name: "website",
			label: formUtils.getLabel("website", "gamblingEstablishmentWebsite"),
			errorMessage: formUtils.getErrorMessage("website", errors, fieldProblems),
			children: (childProps) => /* @__PURE__ */ jsx(InputGroup, {
				...childProps,
				id: "websiteGroup",
				isFocused: focusedInput === "website",
				isInvalid: Boolean(!valid.website && errors.website),
				children: /* @__PURE__ */ jsx(InputText, {
					...childProps,
					placeholder: "https://",
					name: "website",
					value: data.website,
					readonly: formUtils.isReadOnly("website"),
					onInput: handleChangeFor("website", "input"),
					onBlur: handleChangeFor("website", "blur"),
					"aria-required": true,
					"aria-invalid": !valid.website,
					isValid: valid.website,
					onFocusHandler: () => setFocusedInput("website")
				})
			})
		})
	] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataForInheritance.tsx
function AdditionalDataForInheritance(props) {
	const [isFocused, setIsFocused] = useState$1(false);
	const { formUtils, data, errors, valid, fieldProblems, handleChangeFor, handleAmountChange } = props;
	const { t: commonT } = useTranslation("common");
	const handleOnAmountBlur = () => {
		setIsFocused(false);
		handleAmountChange("amount");
	};
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AdditionalDataOriginatorLegalEntity, {
		formUtils,
		handleChangeFor,
		data,
		errors,
		valid,
		fieldProblems,
		sourceOfFundsType: "inheritance"
	}), /* @__PURE__ */ jsxs("div", {
		className: SourceOfFunds_module_default.sourceOfFundsGridContainer,
		children: [/* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "amount",
			label: formUtils.getLabel("amount", "inheritanceAmount"),
			errorMessage: formUtils.getErrorMessage("amount", errors, fieldProblems),
			children: (childProps) => /* @__PURE__ */ jsxs(InputGroup, {
				...childProps,
				id: "currencyGroup",
				isFocused,
				isInvalid: Boolean(!valid.amount && errors.amount),
				children: [/* @__PURE__ */ jsx(Select, {
					name: "currency",
					"aria-label": commonT(($) => $["currency"]),
					isMulti: false,
					items: allowedCurrencies ?? [],
					selected: data.amount?.currency,
					placeholder: commonT(($) => $["select"]),
					onChange: handleAmountChange("currency"),
					minimal: true
				}), /* @__PURE__ */ jsx(InputText, {
					...childProps,
					name: "amount",
					value: data.amount?.value,
					readonly: formUtils.isReadOnly("amount"),
					onInput: handleAmountChange("amount"),
					onBlur: handleOnAmountBlur,
					"aria-required": true,
					"aria-invalid": !valid.amount,
					isValid: valid.amount,
					onFocusHandler: () => setIsFocused(true)
				})]
			})
		}), /* @__PURE__ */ jsx(Field, {
			name: "dateOfFundsReceived",
			label: formUtils.getLabel("dateOfFundsReceived", "inheritanceReceivedOn"),
			errorMessage: formUtils.getErrorMessage("dateOfFundsReceived", errors, fieldProblems),
			isValid: valid.dateOfFundsReceived,
			children: (childProps) => /* @__PURE__ */ jsx(InputDate, {
				...childProps,
				name: "dateOfFundsReceived",
				value: formatDateForInput(data.dateOfFundsReceived),
				onInput: handleChangeFor("dateOfFundsReceived", "input"),
				onBlur: handleChangeFor("dateOfFundsReceived", "blur"),
				"aria-required": true,
				"aria-invalid": !valid.dateOfFundsReceived,
				max: TODAY_DATE
			})
		})]
	})] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/SOFFinancierModal.tsx
var SOFFinancierModal = (props) => {
	const { t: sofT } = useTranslation("sof");
	const { t: commonT } = useTranslation("common");
	const { financier, handleModalClose, indexNumber, handleFinancierUpdate } = props;
	const [formData, setFormData] = useState$1(financier);
	const [formErrors, setFormErrors] = useState$1({});
	const [confirmOpen, setConfirmOpen] = useState$1(false);
	const [isFocused, setIsFocused] = useState$1(false);
	const [errorMessage, setErrorMessage] = useState$1("");
	const handleInputUpdate = (key, e) => {
		const inputEl = e.target;
		setErrorMessage("");
		const value = inputEl?.value;
		let inputData = { [key]: value };
		if (["amount", "currency"].includes(key)) inputData = { amount: {
			currency: key === "currency" ? value : formData?.amount?.currency,
			value: key === "currency" ? formData?.amount?.value : value
		} };
		const data = {
			...formData,
			...inputData
		};
		setFormData(data);
		setFormErrors(getInputErrors({
			formErrors,
			data,
			key,
			value
		}));
	};
	const handleOnAmountBlur = () => {
		setIsFocused(false);
		setFormErrors(getInputErrors({
			formErrors,
			data: formData,
			key: "amount",
			value: formData?.amount?.value
		}));
	};
	const allFieldsFilled = (data) => {
		return data?.firstName && data?.lastName && data?.location && data?.amount?.currency && !Number.isNaN(Number(data?.amount?.value));
	};
	const handleFinancierSave = () => {
		if (formData && allFieldsFilled(formData)) {
			handleFinancierUpdate({
				formData,
				indexNumber
			});
			handleModalClose();
		} else {
			setFormErrors([
				"firstName",
				"lastName",
				"location",
				"amount"
			].reduce((acc, key) => {
				const value = key === "amount" ? formData?.amount?.value : formData?.[key];
				return {
					...acc,
					...getInputErrors({
						formErrors: void 0,
						data: formData,
						key,
						value
					})
				};
			}, {}));
			setErrorMessage(sofT(($) => $["pleaseFillInAllFields"]));
		}
	};
	const handleFinancierDelete = async () => {
		handleFinancierUpdate({ indexNumber });
		handleModalClose();
	};
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Modal, {
		onClose: handleModalClose,
		ariaLabel: sofT(($) => $["investorDetails"]),
		inset: true,
		children: /* @__PURE__ */ jsxs("div", {
			className: SourceOfFunds_module_default.sourceOfFundsModal,
			children: [
				/* @__PURE__ */ jsx(Typography, {
					variant: "title-l",
					el: "h3",
					className: SourceOfFunds_module_default.sourceOfFundsGettingStartedHelpHeader,
					children: sofT(($) => $["investorDetails"])
				}),
				/* @__PURE__ */ jsxs("div", {
					className: SourceOfFunds_module_default.sourceOfFundsSofFinancierForm,
					children: [
						errorMessage && /* @__PURE__ */ jsx(Alert, {
							title: sofT(($) => $["errorSubmittingData"]),
							variant: "error",
							className: SourceOfFunds_module_default.sourceOfFundsSofFinancierFormError,
							children: errorMessage
						}),
						/* @__PURE__ */ jsxs("div", {
							className: SourceOfFunds_module_default.sourceOfFundsSofFinancierFormNameGroup,
							children: [/* @__PURE__ */ jsx(Field, {
								name: "firstName",
								label: commonT(($) => $["firstName"]),
								errorMessage: formErrors.firstName,
								isValid: !formErrors.firstName,
								children: (childProps) => /* @__PURE__ */ jsx(InputText, {
									...childProps,
									name: "firstName",
									value: formData?.firstName,
									onInput: (e) => handleInputUpdate("firstName", e),
									onBlur: (e) => handleInputUpdate("firstName", e),
									"aria-required": true,
									"aria-invalid": Boolean(formErrors.firstName),
									isValid: !formErrors.firstName
								})
							}), /* @__PURE__ */ jsx(Field, {
								name: "lastName",
								label: commonT(($) => $["lastName"]),
								errorMessage: formErrors.lastName,
								isValid: !formErrors.lastName,
								children: (childProps) => /* @__PURE__ */ jsx(InputText, {
									...childProps,
									name: "lastName",
									value: formData?.lastName,
									onInput: (e) => handleInputUpdate("lastName", e),
									onBlur: (e) => handleInputUpdate("lastName", e),
									"aria-required": true,
									"aria-invalid": Boolean(formErrors.lastName),
									isValid: !formErrors.lastName
								})
							})]
						}),
						/* @__PURE__ */ jsx(Field, {
							name: "location",
							label: sofT(($) => $["investorLocation"]),
							errorMessage: formErrors.location,
							isValid: !formErrors.location,
							helperPosition: "below",
							showErrorIconBottom: true,
							helper: sofT(($) => $["theCityAndCountryRegion"]),
							children: (childProps) => /* @__PURE__ */ jsx(InputText, {
								...childProps,
								name: "location",
								value: formData?.location,
								onInput: (e) => handleInputUpdate("location", e),
								onBlur: (e) => handleInputUpdate("location", e),
								"aria-required": true,
								"aria-invalid": Boolean(formErrors.location),
								isValid: !formErrors.location
							})
						}),
						/* @__PURE__ */ jsx(Field, {
							el: "fieldset",
							name: "amount",
							label: sofT(($) => $["investmentAmount"]),
							errorMessage: formErrors.amount,
							isValid: !formErrors.amount,
							children: (childProps) => /* @__PURE__ */ jsxs(InputGroup, {
								...childProps,
								id: "currencyGroup",
								isFocused,
								children: [/* @__PURE__ */ jsx(Select, {
									minimal: true,
									name: "currency",
									"aria-label": commonT(($) => $["currency"]),
									isMulti: false,
									items: allowedCurrencies,
									selected: formData?.amount?.currency,
									placeholder: commonT(($) => $["select"]),
									onChange: (e) => handleInputUpdate("currency", e)
								}), /* @__PURE__ */ jsx(InputText, {
									...childProps,
									name: "amount",
									value: formData?.amount?.value,
									onInput: (e) => handleInputUpdate("amount", e),
									onBlur: handleOnAmountBlur,
									"aria-required": true,
									onFocusHandler: () => setIsFocused(true)
								})]
							})
						})
					]
				}),
				/* @__PURE__ */ jsxs("div", {
					className: SourceOfFunds_module_default.sourceOfFundsFinancierFooter,
					children: [/* @__PURE__ */ jsx(Button, {
						onClick: handleFinancierSave,
						children: commonT(($) => $["save"])
					}), Number.isFinite(indexNumber) && /* @__PURE__ */ jsx(Button, {
						variant: "tertiary",
						onClick: () => setConfirmOpen(true),
						children: sofT(($) => $["deleteInvestorDetails"])
					})]
				})
			]
		})
	}), confirmOpen && /* @__PURE__ */ jsx(Confirm, {
		title: sofT(($) => $["areYouSureYouWantToDeleteThisInvestorDetails"]),
		confirmText: commonT(($) => $["delete"]),
		onConfirm: handleFinancierDelete,
		onCancel: () => setConfirmOpen(false),
		critical: true
	})] });
};
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SOFAdditionalData/AdditionalDataForThirdParty.tsx
function AdditionalDataForThirdParty(props) {
	const [showFinancierModal, setShowFinancierModal] = useState$1(false);
	const [activeFinancier, setActiveFinancier] = useState$1();
	const [activeIndex, setActiveIndex] = useState$1();
	const { data, fieldProblems, errors, handleChangeFor, formUtils, valid } = props;
	const { t: commonT } = useTranslation("common");
	const { t: sofT } = useTranslation("sof");
	const handleToggleFinancierModal = () => {
		setActiveFinancier(void 0);
		setActiveIndex(void 0);
		setShowFinancierModal((prev) => !prev);
	};
	const handleShowUpdateFinancierModal = (index) => {
		if (!data.financiers) return;
		const financier = data.financiers[index];
		setActiveFinancier(financier);
		setActiveIndex(index);
		setShowFinancierModal(true);
	};
	const handleFinancierUpdate = ({ formData, indexNumber }) => {
		const existingFinanciers = data.financiers || [];
		let newFinanciers = [];
		if (!formData) {
			if (indexNumber !== void 0) newFinanciers = existingFinanciers.filter((_, index) => index !== indexNumber);
		} else {
			newFinanciers = [...existingFinanciers, formData];
			if (Number.isFinite(indexNumber)) newFinanciers = existingFinanciers.map((existingFinancier, i) => i === indexNumber ? formData : existingFinancier);
		}
		const financierEvent = { target: {
			name: "financiers",
			value: newFinanciers
		} };
		handleChangeFor("financiers")(financierEvent);
	};
	const errorMessage = formUtils.getErrorMessage("financiers", errors, fieldProblems);
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [
		errors.financiers && !valid.financiers && /* @__PURE__ */ jsx(Alert, {
			title: typeof errorMessage == "boolean" ? void 0 : translateTranslatable(commonT, errorMessage),
			variant: "error",
			className: SourceOfFunds_module_default.sourceOfFundsSofFinancierFormError,
			children: sofT(($) => $["addAtLeastOneInvestor"])
		}),
		data.financiers?.map((financier, index) => /* @__PURE__ */ jsxs("button", {
			type: "button",
			onClick: () => handleShowUpdateFinancierModal(index),
			className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingFinancierGroup,
			children: [/* @__PURE__ */ jsxs("div", {
				className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingNameAvatarGroup,
				children: [/* @__PURE__ */ jsx(Avatar, {
					iconName: "user",
					circle: true
				}), /* @__PURE__ */ jsxs("div", {
					className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingNameAddressGroup,
					children: [/* @__PURE__ */ jsxs(Typography, {
						el: "div",
						variant: "body-strongest",
						children: [
							financier.firstName,
							" ",
							financier.lastName
						]
					}), /* @__PURE__ */ jsx(Typography, {
						el: "div",
						variant: "caption",
						children: financier.location
					})]
				})]
			}), /* @__PURE__ */ jsx("div", { children: financier.amount?.currency && financier.amount?.value ? formatAmountWithCurrency(financier.amount.value, financier.amount?.currency) : "" })]
		}, index)),
		/* @__PURE__ */ jsx("button", {
			type: "button",
			className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingFinancierGroup,
			onClick: handleToggleFinancierModal,
			children: /* @__PURE__ */ jsxs("div", {
				className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingNameAvatarGroup,
				children: [/* @__PURE__ */ jsx(Avatar, {
					iconName: "plus",
					variant: "tertiary",
					circle: true
				}), /* @__PURE__ */ jsx(Typography, {
					el: "div",
					variant: "body-strongest",
					children: sofT(($) => $["addInvestor"])
				})]
			})
		}),
		showFinancierModal && /* @__PURE__ */ jsx(SOFFinancierModal, {
			financier: activeFinancier,
			indexNumber: activeIndex,
			handleModalClose: handleToggleFinancierModal,
			handleFinancierUpdate
		})
	] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFundsAdditionalData.tsx
function SourceOfFundsAdditionalData(props) {
	const { t } = useTranslation("common");
	const { form } = useFormContext();
	const { handleChangeFor: multiFormHandleChangeFor, data: { additionalData: data, sourceOfFundsType }, errors: { additionalData: errors }, valid: { additionalData: valid }, fieldProblems: { additionalData: fieldProblems } } = form;
	const handleChangeFor = useMemo$1(() => (key, mode) => multiFormHandleChangeFor(key, "additionalData", mode), [multiFormHandleChangeFor]);
	const handleAmountChange = (key) => (e) => {
		const rawValue = e.target.value;
		const updatedAmount = {
			...data?.amount,
			...key === "currency" ? { currency: rawValue } : { value: rawValue === "" ? void 0 : Number(rawValue) }
		};
		handleChangeFor("amount")({ target: {
			name: "amount",
			value: updatedAmount
		} });
	};
	const formUtils = createFormUtils(props, t);
	const additionalDataProps = {
		formUtils,
		handleChangeFor,
		data,
		errors,
		valid,
		fieldProblems,
		handleAmountChange
	};
	const renderSubForms = () => {
		switch (sourceOfFundsType?.type) {
			case "gamblingWinnings": return /* @__PURE__ */ jsx(AdditionalDataForGambling, { ...additionalDataProps });
			case "cryptocurrencyIncome": return /* @__PURE__ */ jsx(AdditionalDataForCryptocurrency, { ...additionalDataProps });
			case "business": return /* @__PURE__ */ jsx(AdditionalDataForBusiness, { ...additionalDataProps });
			case "assetSale": return /* @__PURE__ */ jsx(AdditionalDataForAssetSale, { ...additionalDataProps });
			case "thirdPartyFunding": return /* @__PURE__ */ jsx(AdditionalDataForThirdParty, { ...additionalDataProps });
			case "inheritance": return /* @__PURE__ */ jsx(AdditionalDataForInheritance, { ...additionalDataProps });
			case "donations": return /* @__PURE__ */ jsx(AdditionalDataForDonation, { ...additionalDataProps });
			default: return null;
		}
	};
	return /* @__PURE__ */ jsxs("form", {
		className: SourceOfFunds_module_default.sourceOfFundsAdditionalDataForm,
		children: [/* @__PURE__ */ jsx(ErrorPanel, {
			verificationErrors: props?.formVerificationErrors,
			validationErrors: props?.fieldValidationErrors,
			formUtils,
			id: "ariaErrorField"
		}), renderSubForms()]
	});
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFundsType.tsx
function SourceOfFundsType(props) {
	const { t } = useTranslation(["common", "sof"]);
	const { data: formData, categories, errors: formErrors, fieldValidationErrors: formFieldProblems, sameAsOption, useSameAs, onUseSameAsChange } = props;
	const { form } = useFormContext();
	const { handleChangeFor } = form;
	const handleFieldChange = (fieldName, mode) => handleChangeFor(fieldName, "sourceOfFundsType", mode);
	const handleUseSameAsChange = (isChecked) => {
		onUseSameAsChange?.(isChecked);
	};
	const formUtils = createFormUtils(props, t);
	const categoryItems = [{
		value: "adyen",
		label: t(($) => $["transactionsOnThisPlatform"], { ns: "sof" }),
		icon: getIconById("adyen")
	}, ...categories?.map((item) => ({
		value: item.id,
		label: t(($) => $[sofCategoryItemMapper[item.name]], { ns: "sof" }),
		icon: getIconById(item.id)
	})) ?? []];
	const errorMessage = formUtils.getErrorMessage("type", formErrors, formFieldProblems);
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [sameAsOption && /* @__PURE__ */ jsx("div", {
		className: SourceOfFunds_module_default.sourceOfFundsSameAsCheckbox,
		children: /* @__PURE__ */ jsx(Field, {
			name: "useSameAs",
			children: (childProps) => /* @__PURE__ */ jsx(Checkbox, {
				...childProps,
				"aria-required": false,
				"aria-invalid": false,
				name: "useSameAs",
				label: t(($) => $["useSameFundingSourceAndDetails"], { ns: "sof" }),
				checked: Boolean(useSameAs),
				onChange: handleUseSameAsChange
			})
		})
	}), /* @__PURE__ */ jsx(Field, {
		el: "fieldset",
		name: "type",
		children: () => /* @__PURE__ */ jsx(TileGroup, {
			name: "type",
			tiles: categoryItems,
			errorMessage: typeof errorMessage !== "boolean" ? translateTranslatable(t, errorMessage) : void 0,
			selected: formData?.type ? formData.type : [],
			onChange: handleFieldChange("type", "input")
		})
	})] });
}
function getIconById(id) {
	switch (id) {
		case "adyen": return "store";
		case "business": return "revenue-accelerate";
		case "assetSale": return "house";
		case "dividendIncome": return "graph-up";
		case "thirdPartyFunding": return "graph";
		case "employment": return "headquarter";
		case "donations": return "gift";
		case "inheritance": return "certificate";
		case "financialAid": return "capital";
		case "rentalIncome": return "house";
		case "royaltyIncome": return "cash-stack";
		case "pensionIncome": return "bank";
		case "insuranceSettlement": return "funds-in";
		case "cryptocurrencyIncome": return "coins";
		case "loans": return "capital";
		case "gamblingWinnings": return "cash-stack";
		default: return "contract";
	}
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFunds.tsx
function SourceOfFunds(props) {
	const { activeForm, activeBusinessLine, sourceOfFundsType, sameAsOption, useSameAs, onUseSameAsChange } = props;
	const { form } = useFormContext();
	const { data: formData, errors, valid, fieldProblems: fieldValidationErrors } = form;
	const { data: sourceOfFundsTypesData, isLoading } = useSourceOfFundsTypes();
	const { t: sofT } = useTranslation("sof");
	const pageHeadings = useMemo$1(() => getPageHeadings(sourceOfFundsType ?? "adyen"), [sourceOfFundsType]);
	return isLoading || !activeBusinessLine ? /* @__PURE__ */ jsx("div", {
		className: SourceOfFunds_module_default.sourceOfFundsWrapperLoading,
		children: /* @__PURE__ */ jsx(Loader, {})
	}) : /* @__PURE__ */ jsxs("div", { children: [
		/* @__PURE__ */ jsxs("div", {
			className: SourceOfFunds_module_default.sourceOfFundsWrapperHeading,
			children: [/* @__PURE__ */ jsx(Typography, {
				el: "h1",
				variant: "title-l",
				children: activeForm?.formId === "additionalData" ? sofT(($) => $[pageHeadings.heading]) : sofT(($) => $["selectASourceOfFunding"], { type: getServiceTranslationSelectTitle(sofT, activeBusinessLine?.service || "").toLowerCase() })
			}), /* @__PURE__ */ jsxs(Typography, {
				className: SourceOfFunds_module_default.sourceOfFundsWrapperDescription,
				children: [activeForm?.formId === "additionalData" && pageHeadings.description && sofT(($) => $[pageHeadings.description]), sourceOfFundsTypesData?.length === 0 && sofT(($) => $["noCategoriesAvailable"])]
			})]
		}),
		sofErrorMessage.value && /* @__PURE__ */ jsxs(Typography, {
			variant: "caption",
			color: "critical",
			"aria-live": "polite",
			className: "u-justify-content-center u-display-flex",
			children: [/* @__PURE__ */ jsx(Icon, {
				name: "field-error",
				className: "u-margin-right-2"
			}), /* @__PURE__ */ jsx("span", { children: sofErrorMessage.value })]
		}),
		activeForm?.formId === "sourceOfFundsType" && /* @__PURE__ */ jsx(SourceOfFundsType, {
			categories: sourceOfFundsTypesData,
			data: formData?.sourceOfFundsType,
			errors: errors?.sourceOfFundsType,
			valid: valid?.sourceOfFundsType,
			fieldValidationErrors: fieldValidationErrors?.sourceOfFundsType,
			sameAsOption,
			useSameAs,
			onUseSameAsChange
		}),
		activeForm?.formId === "additionalData" && /* @__PURE__ */ jsx(SourceOfFundsAdditionalData, { fieldValidationErrors: fieldValidationErrors?.additionalData }),
		activeForm?.formId === "companySourceOfFunds" && /* @__PURE__ */ jsx("div", { children: sofT(($) => $["uploadADocument"]) })
	] });
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFundsGettingStarted/SourceOfFundsGettingStartedCard.tsx
function SourceOfFundsGettingStartedCard(props) {
	const { id, title, onClick, isEdit, meta } = props;
	const { t: commonT } = useTranslation("common");
	return /* @__PURE__ */ jsxs(Card, {
		variant: "secondary",
		children: [/* @__PURE__ */ jsxs("div", {
			className: SourceOfFunds_module_default.sourceOfFundsGettingStartedCardsCardHeader,
			children: [/* @__PURE__ */ jsx(Typography, {
				el: "h3",
				variant: "title",
				children: title
			}), isEdit ? /* @__PURE__ */ jsx(IconButton, {
				ariaLabel: "edit",
				icon: "edit",
				onClick,
				variant: "tertiary"
			}) : /* @__PURE__ */ jsx(Button, {
				variant: "primary",
				testId: "source-of-funds-getting-card-secondary-button",
				onClick,
				children: commonT(($) => $["start"])
			})]
		}), isEdit && meta?.length && /* @__PURE__ */ jsx("div", {
			className: SourceOfFunds_module_default.sourceOfFundsGettingStartedCardsCardBody,
			children: /* @__PURE__ */ jsx(StructuredList, {
				className: SourceOfFunds_module_default.sourceOfFundsGettingStartedCardsCardDescription,
				items: meta
			})
		})]
	}, id);
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFundsGettingStarted/SourceOfFundsGettingStarted.tsx
var digitalWallet = lazy(() => import("./digital-wallet-s7FKhVg9.js"));
var SourceOfFundsGettingStarted = ({ handleGettingStartedClick, handleCancelClick, handleSourceOfFundsClick, businessLines, handleNavigateToUploadPage, problems, legalEntity, asAwe, isSoFDocumentMissing }) => {
	const { t: sofT } = useTranslation("sof");
	const { t: commonT } = useTranslation("common");
	const hasSourceOfFunds = businessLines?.some((businessLine) => !isEmpty(businessLine.sourceOfFunds));
	const { data: taskStatusResponse } = useTaskStatus(TaskTypes.SOURCE_OF_FUNDS, { refetchInterval: TASK_STATUS_POLLING_INTERVAL_MS });
	const sofDocuments = useMemo$1(() => legalEntity?.documentDetails?.filter((doc) => doc.type === "proofOfFundingOrWealthSource") ?? [], [legalEntity]);
	const mapBusinessLines = useCallback$1((lines) => {
		const completedBusinessLines = businessLines.every((line) => line?.sourceOfFunds?.type);
		const cards = lines.map((line) => {
			const SoF = mapSourceOfFundToSourceOfFundsSchema(line);
			return {
				title: getServiceTranslation(sofT, line.service || ""),
				type: line?.sourceOfFunds?.type,
				isEdit: !!line?.sourceOfFunds?.type || !!line?.sourceOfFunds?.adyenProcessedFunds,
				onClick: () => handleSourceOfFundsClick(SoF, line),
				meta: [{
					term: sofT(($) => $["sourceOfFunds"]),
					details: getSofCardDetails(sofT, line?.sourceOfFunds)
				}, ...getGettingStartedCardDetails(getAdditionalDataSchemaKeys(line?.sourceOfFunds?.type || "adyen", line?.sourceOfFunds?.originatorType), sofT, line?.sourceOfFunds)]
			};
		}).sort((a) => a?.type ? 1 : -1);
		const uploadCard = {
			title: getServiceTranslation(sofT),
			type: "",
			isEdit: !!sofDocuments?.length,
			onClick: handleNavigateToUploadPage,
			meta: sofDocuments?.length ? sofDocuments.map((doc) => ({
				term: sofT(($) => $["fileName"]),
				details: [doc?.fileName, /* @__PURE__ */ jsx(Typography, {
					color: "secondary",
					children: parseSOFDocumentDescription(sofT, doc?.description) || ""
				}, "docDescription")]
			})) : []
		};
		if (completedBusinessLines && (isSoFDocumentMissing || sofDocuments?.length)) if (uploadCard.meta?.length) cards.push(uploadCard);
		else cards.unshift(uploadCard);
		return cards.map((item, index) => {
			return /* @__PURE__ */ jsx(SourceOfFundsGettingStartedCard, {
				id: index,
				isEdit: !!item.isEdit,
				title: item.title,
				onClick: item.onClick,
				meta: item.meta
			}, index);
		});
	}, [handleSourceOfFundsClick, sofDocuments]);
	const errorObjects = useMemo$1(() => getRelevantErrors(problems, SOF_INVALID_INPUT_ERROR_CODES), [problems]);
	return /* @__PURE__ */ jsxs("div", {
		className: asAwe ? SourceOfFunds_module_default.sourceOfFundsGettingStartedAwe : SourceOfFunds_module_default.sourceOfFundsGettingStarted,
		"data-testid": "source-of-funds-getting-started",
		children: [!hasSourceOfFunds && /* @__PURE__ */ jsx(LandingLayout, {
			media: /* @__PURE__ */ jsx(Image, { lazyLoadedImage: digitalWallet }),
			title: sofT(($) => $["fundingSourcesForFinancialProducts"]),
			description: sofT(($) => $["inTheNextStepWellCollectInformation"]),
			actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
				fullWidth: true,
				testId: "source-of-funds-getting-primary-button",
				onClick: handleGettingStartedClick,
				children: commonT(($) => $["getStarted"])
			}), handleCancelClick && /* @__PURE__ */ jsx(Button, {
				variant: "tertiary",
				fullWidth: true,
				testId: "source-of-funds-getting-cancel-button",
				onClick: handleCancelClick,
				children: commonT(($) => $["backToTaskList"])
			})] })
		}), hasSourceOfFunds && /* @__PURE__ */ jsxs(Fragment$1, { children: [
			/* @__PURE__ */ jsx(Header, {
				title: sofT(($) => $["fundingSourcesForFinancialProducts"]),
				description: sofT(($) => $["addAllSourcesOfFundsBeingUsed"]),
				status: asAwe ? void 0 : taskStatusResponse?.status,
				align: "center"
			}),
			errorObjects && errorObjects.map((errorObj, index) => {
				const uniqueActions = getUniqueRemediationActions(errorObj);
				const errorItems = errorObj.subErrors?.map((subError) => subError.message) || [];
				return /* @__PURE__ */ jsxs(Alert, {
					title: errorObj.message,
					className: SourceOfFunds_module_default.sourceOfFundsGettingStartedError,
					variant: "error",
					children: [errorObj?.subErrors?.length && /* @__PURE__ */ jsx("ul", { children: errorItems.map((item, i) => /* @__PURE__ */ jsx("li", { children: item }, i)) }), uniqueActions.length > 0 && /* @__PURE__ */ jsx("div", {
						className: SourceOfFunds_module_default.sourceOfFundsGettingStartedErrorActions,
						children: uniqueActions.filter((action) => action.code !== "1_519").map((action, i) => /* @__PURE__ */ jsx(Button, {
							variant: "tertiary",
							testId: `remediate-action-${i}`,
							onClick: handleNavigateToUploadPage,
							children: action.message
						}, `action-${i}`))
					})]
				}, `error-${index}`);
			}),
			/* @__PURE__ */ jsx("div", {
				className: SourceOfFunds_module_default.sourceOfFundsGettingStartedCards,
				children: /* @__PURE__ */ jsx(StackLayout, { children: mapBusinessLines(businessLines) })
			}),
			handleCancelClick && /* @__PURE__ */ jsx(Button, {
				variant: "secondary",
				testId: "source-of-funds-getting-return-button",
				onClick: handleCancelClick,
				children: commonT(($) => $["backToTaskList"])
			})
		] })]
	});
};
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFundsUploader/SOFUploadModal.tsx
var SOFUploadModal = (props) => {
	const { showToast } = useToastContext();
	const logger = createLogger();
	const { t: sofT } = useTranslation("sof");
	const { t: commonT } = useTranslation("common");
	const { businessLines, handleModalClose, documentUtils } = props;
	const [selectedService, setSelectedService] = useState$1(businessLines?.length === 1 ? businessLines?.[0]?.service : void 0);
	const [documentType, setDocumentType] = useState$1();
	const onRadioChange = (selectedId) => {
		setSelectedService(selectedId);
		setDocumentType(void 0);
	};
	const onDocumentTypeChange = (e) => {
		setDocumentType(e.target.value);
	};
	const serviceRadioItems = useMemo$1(() => {
		return Array.from(new Map(businessLines.map((businessLine) => [businessLine.service, businessLine])).values()).map((businessLine) => ({
			id: businessLine.service,
			name: sofT(($) => $[getServiceTranslationKey(businessLine?.service || "")])
		}));
	}, [businessLines, sofT]);
	const canUpload = useMemo$1(() => selectedService && documentType, [selectedService, documentType]);
	const selectedBusinessLineId = businessLines?.find((businessLine) => businessLine.service === selectedService)?.id || "";
	const documentLists = useMemo$1(() => {
		const selectedType = businessLines?.find((businessLine) => businessLine.service === selectedService)?.sourceOfFunds?.type;
		if (selectedType) return getDocumentLists(selectedType).map((list) => ({
			id: list,
			name: sofT(($) => $[list])
		}));
		return [];
	}, [
		businessLines,
		sofT,
		selectedService
	]);
	const documentRequirements = useMemo$1(() => {
		return documentType ? getDocumentRequirements[documentType] : [];
	}, [documentType]);
	const onFileUpload = async (files) => {
		if (!canUpload) {
			showToast({
				label: sofT(($) => $["unableToUploadDocument"]),
				variant: "error"
			});
			return;
		}
		const formattedDocument = await createDocumentRequest({
			entityId: selectedBusinessLineId,
			entityType: "businessLine",
			documentType: "proofOfFundingOrWealthSource",
			page1: files[0],
			description: `$SERVICE_NAME:${selectedService}--TYPE_NAME:${documentType}`
		});
		if (formattedDocument) try {
			await documentUtils.uploadDocuments([formattedDocument], selectedBusinessLineId);
			showToast({
				label: sofT(($) => $["documentUploadedSuccessfully"]),
				variant: "success",
				duration: 1e4
			});
			handleModalClose();
		} catch (e) {
			logger.log(e);
			showToast({
				label: sofT(($) => $["unableToUploadDocument"]),
				variant: "error"
			});
		}
	};
	return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Modal, {
		onClose: handleModalClose,
		ariaLabel: sofT(($) => $["uploadASupportingDocument"]),
		inset: true,
		children: /* @__PURE__ */ jsxs("div", {
			className: SourceOfFunds_module_default.sourceOfFundsModal,
			children: [/* @__PURE__ */ jsx(Typography, {
				variant: "title-l",
				el: "h2",
				children: sofT(($) => $["uploadASupportingDocument"])
			}), /* @__PURE__ */ jsxs("div", {
				className: SourceOfFunds_module_default.sourceOfFundsUploadModalContent,
				children: [
					businessLines?.length > 1 ? /* @__PURE__ */ jsx(Field, {
						el: "fieldset",
						name: "service",
						className: SourceOfFunds_module_default.sourceOfFundsUploadModalContentField,
						label: sofT(($) => $["whatFinancialProductIsThisFor"]),
						children: (childProps) => /* @__PURE__ */ jsx(RadioGroup, {
							...childProps,
							name: "service",
							className: SourceOfFunds_module_default.sourceOfFundsUploadModalContentFieldRadioGroup,
							items: serviceRadioItems,
							value: selectedService,
							disabled: false,
							onChange: onRadioChange,
							"aria-required": true
						})
					}) : null,
					selectedService && /* @__PURE__ */ jsx(Field, {
						name: "documentType",
						label: commonT(($) => $["documentType"]),
						"data-testid": "documentType",
						className: SourceOfFunds_module_default.sourceOfFundsUploadModalContentField,
						children: (childProps) => /* @__PURE__ */ jsx(Select, {
							...childProps,
							name: "documentType",
							placeholder: commonT(($) => $["selectOne"]),
							selected: documentType,
							items: documentLists,
							onChange: onDocumentTypeChange
						})
					}),
					documentRequirements?.length ? /* @__PURE__ */ jsxs("div", {
						className: SourceOfFunds_module_default.sourceOfFundsUploadModalContentRequirementsContainer,
						children: [/* @__PURE__ */ jsx(Typography, {
							variant: "body-strongest",
							el: "div",
							children: sofT(($) => $["documentShouldShow"])
						}), /* @__PURE__ */ jsx("ul", { children: documentRequirements?.map((requirement) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Typography, {
							variant: "body-stronger",
							el: "div",
							children: sofT(($) => $[requirement])
						}) }, requirement)) })]
					}) : null,
					canUpload && /* @__PURE__ */ jsx(Dropzone, {
						disabled: !canUpload,
						onChange: onFileUpload,
						showMinimal: true,
						hidePageCount: true,
						maxSize: 4194304,
						enableTracking: true,
						name: "documentField",
						allowedFileTypes: [
							"JPG",
							"JPEG",
							"PNG",
							"PDF"
						]
					})
				]
			})]
		})
	}) });
};
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFundsUploader/SourceOfFundsUpload.tsx
var SourceOfFundsUpload = ({ businessLines, documentUtils, legalEntity, handleNavigateToSummary }) => {
	const [showUploadModal, setShowUploadModal] = useState$1(false);
	const [docToDelete, setDocToDelete] = useState$1(void 0);
	const { showToast } = useToastContext();
	const logger = createLogger();
	const queryClient = useQueryClient();
	const { t: sofT } = useTranslation("sof");
	const { t: commonT } = useTranslation("common");
	const handleModalClose = async () => {
		setShowUploadModal(false);
		await queryClient.invalidateQueries({ queryKey: ["legalEntity", legalEntity.id] });
	};
	const openUploadModal = () => {
		setShowUploadModal(true);
	};
	const documents = useMemo$1(() => legalEntity.documentDetails?.filter((doc) => doc.type === "proofOfFundingOrWealthSource") ?? [], [legalEntity]);
	const sourceOfFundsCategories = businessLines?.map((line) => line.sourceOfFunds?.type)?.filter(Boolean);
	const getTranslatedCategoryName = (categoryKey) => {
		const translationKey = sofCategoryItemMapper[categoryKey];
		if (!categoryKey || !translationKey) return "";
		return sofT(($) => $[translationKey]).toLowerCase();
	};
	let translationKey;
	let translationParams;
	if (sourceOfFundsCategories?.length > 1) {
		translationKey = "weNeedProofOfFundingForMultipleCategories";
		translationParams = {
			category1_name: getTranslatedCategoryName(sourceOfFundsCategories[0]),
			category2_name: getTranslatedCategoryName(sourceOfFundsCategories[1])
		};
	} else if (sourceOfFundsCategories?.length === 1) {
		translationKey = "weNeedProofOfFunding";
		translationParams = { category_name: getTranslatedCategoryName(sourceOfFundsCategories[0]) };
	} else translationKey = "weNeedProofOfFundingForNoCategory";
	const handleFileDelete = async (documentId) => {
		if (documentUtils.deleteDocument) try {
			await documentUtils.deleteDocument(documentId, legalEntity.id);
			await queryClient.invalidateQueries({ queryKey: ["legalEntity", legalEntity.id] });
			showToast({
				label: sofT(($) => $["documentDeletedSuccessfully"]),
				variant: "success",
				duration: 1e4
			});
		} catch (e) {
			logger.log(e);
			showToast({
				label: sofT(($) => $["unableToDeleteDocument"]),
				variant: "error"
			});
		}
	};
	return /* @__PURE__ */ jsxs("div", {
		className: SourceOfFunds_module_default.sourceOfFundsUploadList,
		children: [
			/* @__PURE__ */ jsxs("div", {
				className: SourceOfFunds_module_default.sourceOfFundsUploadListHeading,
				children: [/* @__PURE__ */ jsx(Typography, {
					el: "h1",
					variant: "title-l",
					children: sofT(($) => $["supportingDocuments"])
				}), /* @__PURE__ */ jsx(Typography, {
					className: SourceOfFunds_module_default.sourceOfFundsWrapperDescription,
					children: sofT(($) => $[translationKey], translationParams)
				})]
			}),
			documents?.map((document) => /* @__PURE__ */ jsxs("div", {
				className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingFinancierGroup,
				children: [/* @__PURE__ */ jsxs("div", {
					className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingNameAvatarGroup,
					children: [/* @__PURE__ */ jsx(Avatar, {
						iconName: "document",
						circle: true
					}), /* @__PURE__ */ jsxs("div", {
						className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingNameAddressGroup,
						children: [/* @__PURE__ */ jsx(Typography, {
							el: "div",
							variant: "body-strongest",
							children: document.fileName
						}), /* @__PURE__ */ jsx(Typography, {
							el: "div",
							variant: "caption",
							children: parseSOFDocumentDescription(sofT, document.description)
						})]
					})]
				}), /* @__PURE__ */ jsx(IconButton, {
					ariaLabel: commonT(($) => $["deleteDocument"]),
					variant: "tertiary",
					icon: "cross",
					onClick: () => setDocToDelete(document),
					testId: "source-of-funds-remove-button"
				})]
			}, document.id)),
			/* @__PURE__ */ jsx("button", {
				type: "button",
				className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingFinancierGroup,
				onClick: openUploadModal,
				"data-testId": "source-of-funds-upload-button",
				children: /* @__PURE__ */ jsxs("div", {
					className: SourceOfFunds_module_default.sourceOfFundsThirdPartyFundingNameAvatarGroup,
					children: [/* @__PURE__ */ jsx(Avatar, {
						label: sofT(($) => $["addDocument"]),
						iconName: "plus",
						circle: true
					}), /* @__PURE__ */ jsx(Typography, {
						el: "div",
						variant: "body-strongest",
						children: sofT(($) => $["addDocument"])
					})]
				})
			}),
			handleNavigateToSummary && /* @__PURE__ */ jsx("div", {
				className: SourceOfFunds_module_default.sourceOfFundsGettingStartedActions,
				children: /* @__PURE__ */ jsx(Button, {
					variant: "secondary",
					onClick: handleNavigateToSummary,
					children: documents?.length > 0 ? commonT(($) => $["finish"]) : commonT(($) => $["cancel"])
				})
			}),
			!!docToDelete && /* @__PURE__ */ jsx(Confirm, {
				title: sofT(($) => $["areYouSureYouWantToDeleteThisDocument"], { documentName: docToDelete?.fileName || "" }),
				confirmText: commonT(($) => $["delete"]),
				onConfirm: () => handleFileDelete(docToDelete?.id),
				onCancel: () => setDocToDelete(void 0),
				critical: true
			}),
			showUploadModal && /* @__PURE__ */ jsx(SOFUploadModal, {
				documentUtils,
				handleModalClose,
				businessLines
			})
		]
	});
};
//#endregion
//#region src/utils/urlUtils.ts
function canParseUrl(url) {
	if (URL.canParse) return URL.canParse(url);
	try {
		new URL(url);
		return true;
	} catch {
		return false;
	}
}
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/validate.ts
var sourceOfFundsTypeValidations = {};
var HAS_PROTOCOL_REGEX = /^https?:\/\//i;
var sourceOfFundsAdditionalDataValidations = {
	website: {
		modes: ["blur"],
		validate: (val) => !!val && canParseUrl(val),
		errorMessage: (val) => {
			if (val && !HAS_PROTOCOL_REGEX.test(val)) return "validationUrlMustStartWithHttpOrHttps";
			return "validationPleaseEnterAValidUrl";
		}
	},
	amount: {
		modes: ["blur"],
		validate: (amount) => amount?.value != null && !Number.isNaN(Number(amount.value)),
		errorMessage: "pleaseEnterAValidAmount"
	},
	dateOfSourceEvent: {
		modes: ["blur"],
		validate: (dateOfSourceEvent) => validateDateNotInTheFuture(dateOfSourceEvent),
		errorMessage: "dateCannotBeInTheFuture"
	},
	dateOfFundsReceived: {
		modes: ["blur"],
		validate: (dateOfFundsReceived) => validateDateNotInTheFuture(dateOfFundsReceived),
		errorMessage: "dateCannotBeInTheFuture"
	}
};
//#endregion
//#region src/components/EFP/tasks/SourceOfFundsDropin/SourceOfFundsDropin.tsx
var logger = createLogger();
function SourceOfFundsDropin({ country, problems, handleHomeClick, asAwe }) {
	const { data: legalEntity, isLoading: isLoadingRootLegalEntity } = useLegalEntity(ROOT_LE);
	const [loadingStatus, setLoadingStatus] = useState$1("success");
	const [activeBusinessLine, setActiveBusinessLine] = useState$1();
	const [activeSourceOfFund, setActiveSourceOfFund] = useState$1({
		sourceOfFundsType: {},
		additionalData: {}
	});
	const [allBusinessLines, setAllBusinessLines] = useState$1([]);
	const [gettingStarted, setGettingStarted] = useState$1(true);
	const [showUploadPage, setShowUploadPage] = useState$1(false);
	const [loading, setLoading] = useState$1(false);
	const [useSameAs, setUseSameAs] = useState$1(false);
	const { baseUrl, rootLegalEntityId } = useApiContext();
	const { t: sofT } = useTranslation("sof");
	const userEvents = useAnalyticsContext();
	const { showToast } = useToastContext();
	const { data: sofBusinessLines, isLoading: isLoadingBusinessLines } = useBusinessLines(ALLOWED_SOF_SERVICES);
	const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
	const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
	const { mutateAsync: updateSoFMutation } = useUpdateSourceOfFunds();
	const form = useMultiForm({
		requiredFields: getSourceOfFundsRequiredFields,
		rules: {
			sourceOfFundsType: sourceOfFundsTypeValidations,
			additionalData: sourceOfFundsAdditionalDataValidations
		},
		defaultData: activeSourceOfFund
	});
	const { data = activeSourceOfFund, setFormData, setData, requiredFields, isValid, triggerValidation } = form;
	const isSoFDocumentMissing = useMemo$1(() => legalEntity?.problems?.some((problem) => problem?.verificationErrors?.some((verificationError) => verificationError?.code === "2_8224")) ?? false, [legalEntity?.problems]);
	const legalEntityResults = useLegalEntities(sofBusinessLines?.map((businessLine) => businessLine.sourceOfFunds?.originatorLegalEntityId).filter((id) => Boolean(id)) ?? [], { staleTime: 300 * 1e3 });
	const areLegalEntitiesLoading = legalEntityResults.some((result) => result.isLoading);
	const normalizedBusinessLines = useMemo$1(() => {
		if (!sofBusinessLines) return null;
		return sofBusinessLines.map((businessLine, index) => {
			const result = legalEntityResults[index];
			let updatedBusinessLine = { ...businessLine };
			if (result && result.data) updatedBusinessLine = parseOriginatorDetails(result.data, updatedBusinessLine);
			else if (result && result.isError) {
				logger.error(`Error fetching legal entity for BL ${businessLine.id}:`, result.error);
				showToast({
					label: sofT(($) => $["unableToLoadRelatedEntity"]),
					variant: "error"
				});
			}
			if (updatedBusinessLine.sourceOfFunds?.adyenProcessedFunds) updatedBusinessLine.sourceOfFunds.type = "adyen";
			return updatedBusinessLine;
		});
	}, [sofBusinessLines, JSON.stringify(legalEntityResults.map((r) => ({
		data: r.data,
		isError: r.isError,
		error: r.error,
		isLoading: r.isLoading
	})))]);
	useEffect$1(() => {
		if (sofBusinessLines && !areLegalEntitiesLoading && normalizedBusinessLines) {
			clearSofErrorMessage();
			setLoading(true);
			try {
				if (normalizedBusinessLines.length) {
					setAllBusinessLines((prev) => objectsDeepEqual(prev, normalizedBusinessLines) ? prev : normalizedBusinessLines);
					if (!activeBusinessLine) {
						const firstBusinessLine = normalizedBusinessLines[0];
						if (firstBusinessLine) {
							const mappedSof = mapSourceOfFundToSourceOfFundsSchema(firstBusinessLine);
							setActiveBusinessLine(firstBusinessLine);
							setActiveSourceOfFund(mappedSof);
							if (mappedSof?.sourceOfFundsType) setFormData("sourceOfFundsType", mappedSof.sourceOfFundsType);
							if (mappedSof?.additionalData) setFormData("additionalData", mappedSof.additionalData);
						}
					}
				}
			} catch (error) {
				showToast({
					label: sofT(($) => $["unableToLoadRelatedEntity"]),
					variant: "error"
				});
				logger.error(error);
			} finally {
				setLoading(false);
			}
		}
	}, [
		sofBusinessLines,
		areLegalEntitiesLoading,
		normalizedBusinessLines,
		activeBusinessLine,
		sofT,
		logger
	]);
	/**
	* Analytics
	*/
	useTaskLandedEvent("SOURCE_OF_FUNDS");
	useEffect$1(() => {
		if (!gettingStarted && activeBusinessLine && allBusinessLines.length > 1) {
			const applicableBusinessLines = getApplicableBusinessLines(allBusinessLines);
			if (applicableBusinessLines.length > 1) {
				if (applicableBusinessLines.every((bl) => bl.sourceOfFunds?.type)) {
					const currentSoF = mapSourceOfFundToSourceOfFundsSchema(activeBusinessLine);
					setUseSameAs(applicableBusinessLines.filter((bl) => bl.id !== activeBusinessLine.id).every((bl) => {
						return areSourceOfFundsEqual(currentSoF, mapSourceOfFundToSourceOfFundsSchema(bl));
					}));
				}
			}
		}
	}, [
		gettingStarted,
		activeBusinessLine,
		allBusinessLines
	]);
	const sourceOfFundsRequiredForms = useMemo$1(() => getSourceOfFundsRequiredForms(data?.sourceOfFundsType), [data?.sourceOfFundsType]);
	const forms = useMemo$1(() => {
		return addValidityToForms(getRequiredForms(sourceOfFundsRequiredForms, requiredFields, void 0, true), isValid, problems);
	}, [
		sourceOfFundsRequiredForms,
		requiredFields,
		isValid,
		problems
	]);
	const createOrUpdateOriginator = async (additionalData, prevAdditionalData) => {
		let originatorLegalEntityId;
		const sofOriginator = parseSofOriginatorPayload(additionalData);
		if (additionalData?.originatorLegalEntityId && additionalData?.originatorType === prevAdditionalData?.originatorType) try {
			sofOriginator.id = additionalData?.originatorLegalEntityId;
			if (sofOriginator.type) delete sofOriginator.type;
			originatorLegalEntityId = (await updateLegalEntity({
				...sofOriginator,
				id: sofOriginator.id
			}))?.id;
		} catch (e) {
			logger.log("Error updating  originator legal entity", e);
		}
		else try {
			originatorLegalEntityId = (await createLegalEntity(sofOriginator))?.id;
		} catch (e) {
			logger.log("Error creating  originator legal entity", e);
		}
		return originatorLegalEntityId;
	};
	const handleSubmit = useCallback$1(async () => {
		const sofData = { ...data };
		const sofType = sofData?.sourceOfFundsType?.type;
		if (!sofType || !activeBusinessLine?.id) return;
		const eventsAdditionalData = {};
		setLoadingStatus("loading");
		const { additionalData } = sofData;
		const sofPayload = getSourceOfFundsPayload(sofType, additionalData);
		if (sofType === "thirdPartyFunding") eventsAdditionalData.financiers = `${additionalData?.financiers?.length || 0} investor(s)`;
		if (sofType === "donations" || sofType === "inheritance") eventsAdditionalData.originatorType = additionalData?.originatorType ?? "";
		const targetBusinessLines = useSameAs ? getApplicableBusinessLines(allBusinessLines) : [activeBusinessLine];
		const savePromises = targetBusinessLines.filter((bl) => bl.id).map(async (bl) => {
			const payload = { ...sofPayload };
			if (sofType === "donations" || sofType === "inheritance") try {
				const blAdditionalData = mapSourceOfFundToSourceOfFundsSchema(bl)?.additionalData;
				payload.originatorLegalEntityId = await createOrUpdateOriginator(useSameAs ? {
					...additionalData,
					originatorLegalEntityId: blAdditionalData?.originatorLegalEntityId
				} : getAdditionalDataForOriginator(additionalData, activeSourceOfFund?.additionalData, useSameAs), blAdditionalData);
			} catch (e) {
				logger.log("Error creating originator legal entity for business line", e);
				throw e;
			}
			return updateSoFMutation({
				...payload,
				businessLineId: bl.id
			});
		});
		try {
			const results = await Promise.allSettled(savePromises);
			const failures = results.filter((r) => r.status === "rejected");
			if (failures.length > 0) {
				setSofErrorMessage(sofT(($) => $["errorUpdatingMultipleSourceOfFunds"], { count: failures.length }));
				logger.error("Failed to update SoF for some business lines", failures);
			}
			const successes = results.filter((r) => r.status === "fulfilled");
			if (successes.length > 0) {
				userEvents.addTaskEvent("Success", {
					actionType: "submit",
					returnValue: sofType,
					additionalData: {
						...eventsAdditionalData,
						appliedToMultiple: useSameAs,
						successCount: successes.length,
						failureCount: failures.length,
						businessLinesCount: allBusinessLines.length,
						activeBusinessLineType: activeBusinessLine?.service,
						activeBusinessLineCode: activeBusinessLine?.industryCode
					}
				});
				setGettingStarted(true);
				setShowUploadPage(false);
				setActiveSourceOfFund({
					sourceOfFundsType: {},
					additionalData: {}
				});
				gotoFormByFormIndex(0);
				setUseSameAs(false);
				if (failures.length === 0) {
					showToast({
						label: sofT(($) => $["successAddedFundingSources"]),
						variant: "success"
					});
					setSofErrorMessage("");
				} else showToast({
					label: sofT(($) => $["successAddedFundingSources"]),
					variant: "success"
				});
				if (useSameAs) {} else {
					const applicableBusinessLines = getApplicableBusinessLines(allBusinessLines);
					if (applicableBusinessLines.filter((bl) => {
						return targetBusinessLines.some((target) => target.id === bl.id) || !isEmpty(bl.sourceOfFunds);
					}).length === applicableBusinessLines.length) handleHomeClick?.();
				}
			} else setSofErrorMessage(sofT(($) => $["errorUpdatingSourceOfFunds"]));
		} catch (e) {
			setSofErrorMessage(sofT(($) => $["errorUpdatingSourceOfFunds"]));
			logger.log("Error updating source of funds", e);
		}
		setLoadingStatus("success");
	}, [
		data,
		activeSourceOfFund,
		activeBusinessLine,
		allBusinessLines,
		useSameAs,
		updateSoFMutation,
		createOrUpdateOriginator,
		userEvents,
		showToast,
		sofT,
		logger
	]);
	const handleGettingStarted = useCallback$1(() => {
		setGettingStarted(!gettingStarted);
	}, [gettingStarted]);
	const handleSourceOfFundsClick = (SoF, businessLine) => {
		setActiveBusinessLine(businessLine);
		setActiveSourceOfFund(SoF);
		setGettingStarted(false);
		setUseSameAs(false);
	};
	const sameAsOption = useMemo$1(() => {
		if (!activeBusinessLine || !allBusinessLines.length) return;
		if (getApplicableBusinessLines(allBusinessLines).length <= 1) return;
		return {
			businessLineId: "",
			productName: sofT(($) => $["useSameFundingSourceAndDetails"]),
			sourceOfFunds: activeSourceOfFund
		};
	}, [
		activeBusinessLine,
		allBusinessLines,
		activeSourceOfFund,
		sofT
	]);
	const setAdditionalDataFields = useCallback$1((additionalData) => {
		if (!additionalData) return;
		Object.keys(additionalData).forEach((key) => {
			const fieldKey = key;
			const value = additionalData[fieldKey];
			if (value !== void 0) setData(fieldKey, value, "additionalData");
		});
	}, [setData]);
	const handleUseSameAsChange = useCallback$1((checked) => {
		setUseSameAs(checked);
		if (checked && sameAsOption) {
			const { sourceOfFunds } = sameAsOption;
			setActiveSourceOfFund(sourceOfFunds);
			setFormData("sourceOfFundsType", sourceOfFunds.sourceOfFundsType);
			setAdditionalDataFields(sourceOfFunds.additionalData);
		} else if (!checked && activeBusinessLine) {
			const currentSoF = mapSourceOfFundToSourceOfFundsSchema(activeBusinessLine);
			setActiveSourceOfFund(currentSoF);
			setFormData("sourceOfFundsType", currentSoF.sourceOfFundsType);
			setAdditionalDataFields(currentSoF.additionalData);
		}
	}, [
		sameAsOption,
		activeBusinessLine,
		setFormData,
		setAdditionalDataFields
	]);
	const { handleNextClick, activeForm, gotoFormByFormIndex, gotoFormByFormId, steps, handleBackClick } = useFormComposer({
		problems,
		forms,
		onSubmit: handleSubmit,
		triggerValidation
	});
	const documentUtils = documentApiUtils({
		baseUrl: baseUrl.value,
		rootLegalEntityId: rootLegalEntityId.value
	});
	const handleNavigateToSummary = async () => {
		setShowUploadPage(false);
		setGettingStarted(true);
	};
	const handleNavigateToUploadPage = () => {
		setShowUploadPage(true);
	};
	return /* @__PURE__ */ jsx("div", {
		className: asAwe ? SourceOfFunds_module_default.sourceOfFundsAwe : SourceOfFunds_module_default.sourceOfFunds,
		children: loading || isLoadingRootLegalEntity || isLoadingBusinessLines || areLegalEntitiesLoading ? /* @__PURE__ */ jsx(Loader, {}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
			gettingStarted && !showUploadPage && legalEntity && /* @__PURE__ */ jsx(SourceOfFundsGettingStarted, {
				asAwe,
				handleCancelClick: handleHomeClick,
				handleGettingStartedClick: handleGettingStarted,
				businessLines: allBusinessLines,
				problems: legalEntity?.problems,
				handleSourceOfFundsClick,
				handleNavigateToUploadPage,
				legalEntity,
				isSoFDocumentMissing
			}),
			showUploadPage && legalEntity && /* @__PURE__ */ jsx(SourceOfFundsUpload, {
				businessLines: allBusinessLines,
				documentUtils,
				legalEntity,
				handleNavigateToSummary
			}),
			!gettingStarted && !showUploadPage && /* @__PURE__ */ jsx(FormContextProvider, {
				form,
				children: /* @__PURE__ */ jsx(FormFlow, {
					forms,
					disableNextButton: !activeForm.isValid,
					activeForm,
					gotoFormByFormIndex,
					gotoFormByFormId,
					handleBackClick: steps.current === 0 ? handleGettingStarted : handleBackClick,
					handleCancelClick: handleHomeClick,
					handleNextClick,
					loadingStatus,
					currentStep: steps.current,
					totalSteps: steps.total,
					children: /* @__PURE__ */ jsx(SourceOfFunds, {
						country,
						activeForm,
						activeBusinessLine,
						sourceOfFundsType: data?.sourceOfFundsType?.type,
						data: activeSourceOfFund,
						sameAsOption,
						useSameAs,
						onUseSameAsChange: handleUseSameAsChange
					})
				})
			})
		] })
	});
}
//#endregion
//#region src/components/EFP/pages/SourceOfFundsPage.tsx
var SourceOfFundsPage_exports = /* @__PURE__ */ __exportAll({ SourceOfFundsPage: () => SourceOfFundsPage });
var SourceOfFundsPage = ({ onSubmit, handleHomeClick, asAwe }) => {
	const { data: rootLe } = useLegalEntity(ROOT_LE);
	const capabilityProblems = useCapabilityProblems();
	const { i18n } = useTranslation();
	addResourceBundles(i18n, [{
		ns: "sof",
		importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
			"../tasks/SourceOfFundsDropin/language/bg-BG.json": () => import("./bg-BG-CCGIvlIM.js"),
			"../tasks/SourceOfFundsDropin/language/cs-CZ.json": () => import("./cs-CZ-Bx41zbEp.js"),
			"../tasks/SourceOfFundsDropin/language/da-DK.json": () => import("./da-DK-dLxEveOJ.js"),
			"../tasks/SourceOfFundsDropin/language/de-DE.json": () => import("./de-DE-DzLYNbSo.js"),
			"../tasks/SourceOfFundsDropin/language/el-GR.json": () => import("./el-GR-C6MVbJAv.js"),
			"../tasks/SourceOfFundsDropin/language/en-US.json": () => import("./en-US-B3wlE1pH.js"),
			"../tasks/SourceOfFundsDropin/language/es-ES.json": () => import("./es-ES-zeUfuQRw.js"),
			"../tasks/SourceOfFundsDropin/language/et-EE.json": () => import("./et-EE-M5V-MgVM.js"),
			"../tasks/SourceOfFundsDropin/language/fi-FI.json": () => import("./fi-FI-wRYER_Hf.js"),
			"../tasks/SourceOfFundsDropin/language/fr-FR.json": () => import("./fr-FR-DEdpJMql.js"),
			"../tasks/SourceOfFundsDropin/language/hr-HR.json": () => import("./hr-HR-CN-cMu-7.js"),
			"../tasks/SourceOfFundsDropin/language/hu-HU.json": () => import("./hu-HU-gRTFw9Qg.js"),
			"../tasks/SourceOfFundsDropin/language/it-IT.json": () => import("./it-IT-5sFxcqYj.js"),
			"../tasks/SourceOfFundsDropin/language/ja-JP.json": () => import("./ja-JP-BaYWre19.js"),
			"../tasks/SourceOfFundsDropin/language/lt-LT.json": () => import("./lt-LT-CYhgjOkW.js"),
			"../tasks/SourceOfFundsDropin/language/lv-LV.json": () => import("./lv-LV-KCxxzpdw.js"),
			"../tasks/SourceOfFundsDropin/language/nl-NL.json": () => import("./nl-NL-BQYwAxdm.js"),
			"../tasks/SourceOfFundsDropin/language/no-NO.json": () => import("./no-NO-BQ0yU2Fq.js"),
			"../tasks/SourceOfFundsDropin/language/pl-PL.json": () => import("./pl-PL-DvZBOEKI.js"),
			"../tasks/SourceOfFundsDropin/language/pt-BR.json": () => import("./pt-BR-DKqiUfwf.js"),
			"../tasks/SourceOfFundsDropin/language/pt-PT.json": () => import("./pt-PT-CXRUusv_.js"),
			"../tasks/SourceOfFundsDropin/language/ro-RO.json": () => import("./ro-RO-BHOTFHon.js"),
			"../tasks/SourceOfFundsDropin/language/sk-SK.json": () => import("./sk-SK-BlhtDQel.js"),
			"../tasks/SourceOfFundsDropin/language/sl-SI.json": () => import("./sl-SI-qFjMTfKg2.js"),
			"../tasks/SourceOfFundsDropin/language/sv-SE.json": () => import("./sv-SE-BDo_8Bf92.js")
		}), `../tasks/SourceOfFundsDropin/language/${lang}.json`, 5)
	}]);
	if (!rootLe) return /* @__PURE__ */ jsx(Loader, {});
	const problems = capabilityProblems ? getProblemsForEntity(capabilityProblems, EntityTypes.LEGAL_ENTITY, rootLe.id) : void 0;
	return /* @__PURE__ */ jsx(SourceOfFundsDropin, {
		legalEntityResponse: rootLe,
		country: getLegalEntityCountry(rootLe),
		problems,
		asAwe,
		onSubmit,
		handleHomeClick
	});
};
//#endregion
export { SourceOfFundsPage_exports as n, SourceOfFundsPage as t };
