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] = "8daf6bb8-041e-46f9-a42f-b3ac71ae9a55", e._sentryDebugIdIdentifier = "sentry-dbid-8daf6bb8-041e-46f9-a42f-b3ac71ae9a55");
} catch (e) {}
import { n as addResourceBundles, r as useTranslation } from "./translation-Br5wIPO-.js";
import { r as Loader, t as Button } from "./Button-BDEdGXnd.js";
import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-Dm6g0wmt.js";
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-CCXvMgfE.js";
import { t as StackLayout } from "./StackLayout-BMQXXBDb.js";
import { t as Header } from "./Header-B_MIsVov.js";
import { t as Alert } from "./Alert-CjZYipjN.js";
import { t as TaskTypes } from "./taskTypes-DWaxzvnQ.js";
import { i as useGlobalStore, r as useGetTaskStatus } from "./globalStore-D0yv1fc_.js";
import { t as useAssociatedLegalEntity } from "./useAssociatedLegalEntity-CYu0lsaE.js";
import { t as useUpdateLegalEntity } from "./useUpdateLegalEntity-CUs6TYPF.js";
import { t as Spacer } from "./Spacer-D1yp_1Io.js";
import { n as deleteUnincorporatedPartnershipMember, t as useUnincorporatedPartnershipMembers } from "./useUnincorporatedPartnershipMembers-D7U6aM_k.js";
import { t as EntityAssociation } from "./EntityAssociation-inLOmBfG.js";
import { useEffect } from "preact/hooks";
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
var UnincorporatedPartnershipMembersOverview_module_default = {
	"entity-association": "adyen-kyc-entity-association",
	entityAssociation: "adyen-kyc-entity-association",
	alert: "adyen-kyc-alert",
	"alert-header": "adyen-kyc-alert-header",
	alertHeader: "adyen-kyc-alert-header"
};
//#endregion
//#region src/components/UnincorporatedPartnership/tasks/UnincorporatedPartnershipMembers/UnincorporatedPartnershipMembersOverview.tsx
var isPrimaryPartner = (member) => member?.roles?.includes("primaryPartner");
var isMemberMissingOwner = (member) => {
	return !isPrimaryPartner(member) && member.legalEntityType === LegalEntityTypes.ORGANIZATION && !member.ownerId;
};
var UnincorporatedPartnershipMembersOverview = ({ navigateBackToTaskList, navigateToEditMember, navigateToEditMemberOwner }) => {
	const { t, i18n } = useTranslation(["unincorpPartnership", "common"]);
	const { data: rootLe } = useLegalEntity(ROOT_LE);
	const { data: partnershipLe, refetch: refetchPartnership } = useAssociatedLegalEntity(rootLe, LegalEntityTypes.UNINCORPORATED_PARTNERSHIP);
	const partnershipMembers = useUnincorporatedPartnershipMembers();
	const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
	const { setUnincorporatedPartnershipMembers } = useGlobalStore();
	addResourceBundles(i18n, [{
		ns: "unincorpPartnership",
		importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
			"../../language/bg-BG.json": () => import("./bg-BG-BNqOiDw9.js"),
			"../../language/cs-CZ.json": () => import("./cs-CZ-DNvBXQqI.js"),
			"../../language/da-DK.json": () => import("./da-DK-LXurZBZ8.js"),
			"../../language/de-DE.json": () => import("./de-DE-apC2os2u.js"),
			"../../language/el-GR.json": () => import("./el-GR-CiverXpL.js"),
			"../../language/en-US.json": () => import("./en-US-Cd8cLmVX.js"),
			"../../language/es-ES.json": () => import("./es-ES-DFg_LlqD.js"),
			"../../language/et-EE.json": () => import("./et-EE-DJWVyTVM.js"),
			"../../language/fi-FI.json": () => import("./fi-FI-DZyEs_5S.js"),
			"../../language/fr-FR.json": () => import("./fr-FR-CsoVB-yq.js"),
			"../../language/hr-HR.json": () => import("./hr-HR-DpQuBztk.js"),
			"../../language/hu-HU.json": () => import("./hu-HU-BED5SDWE.js"),
			"../../language/it-IT.json": () => import("./it-IT-CCtD36Df.js"),
			"../../language/ja-JP.json": () => import("./ja-JP-tHJpSXnY.js"),
			"../../language/lt-LT.json": () => import("./lt-LT-CpQj1HiE.js"),
			"../../language/lv-LV.json": () => import("./lv-LV-BGMkr0W_.js"),
			"../../language/nl-NL.json": () => import("./nl-NL-BtwZkAPX.js"),
			"../../language/no-NO.json": () => import("./no-NO-YjH9dIrD.js"),
			"../../language/pl-PL.json": () => import("./pl-PL-x6CltZUu.js"),
			"../../language/pt-BR.json": () => import("./pt-BR-B0zBNcPy.js"),
			"../../language/pt-PT.json": () => import("./pt-PT-C0GJNK9V.js"),
			"../../language/ro-RO.json": () => import("./ro-RO-B3hA8dZo.js"),
			"../../language/sk-SK.json": () => import("./sk-SK-DwG8xkcP.js"),
			"../../language/sl-SI.json": () => import("./sl-SI-DnpKMUhR.js"),
			"../../language/sv-SE.json": () => import("./sv-SE-D3hPP-Mp.js")
		}), `../../language/${lang}.json`, 4)
	}]);
	useEffect(() => setUnincorporatedPartnershipMembers(partnershipMembers), [partnershipMembers, setUnincorporatedPartnershipMembers]);
	const getTaskStatus = useGetTaskStatus();
	if (!rootLe || !partnershipLe) return /* @__PURE__ */ jsx(Loader, { size: "large" });
	const deleteMember = async (member) => {
		try {
			await deleteUnincorporatedPartnershipMember({
				associatedMember: member,
				unincorporatedPartnership: partnershipLe,
				updateLegalEntity
			});
			await refetchPartnership();
		} catch (error) {
			console.error(error);
		}
	};
	const getActions = (member) => {
		const baseActions = [{
			icon: "edit",
			onSelect: () => navigateToEditMember(member),
			label: t(($) => $["editTrustMember"], { trustMember: member.name })
		}];
		if (member.legalEntityType === LegalEntityTypes.ORGANIZATION && !isPrimaryPartner(member)) {
			const missingOwner = isMemberMissingOwner(member);
			baseActions.push({
				icon: missingOwner ? "plus" : "edit",
				onSelect: () => navigateToEditMemberOwner(member?.ownerId, member?.legalEntityId),
				label: t(($) => $[missingOwner ? "addOwnerToTrustMember" : "editOwnerOfTrustMember"], { trustMember: member.name })
			});
		}
		if (!isPrimaryPartner(member)) baseActions.push({
			icon: "bin",
			onSelect: () => deleteMember(member),
			label: t(($) => $["removeTrustMember"], { trustMember: member.name })
		});
		return baseActions;
	};
	const infoContent = (member) => /* @__PURE__ */ jsx(Alert, {
		className: UnincorporatedPartnershipMembersOverview_module_default.alertHeader,
		title: /* @__PURE__ */ jsxs(Fragment, { children: [
			t(($) => $["helpUsVerifyCompany"], { ns: "common" }),
			" ",
			/* @__PURE__ */ jsx(Button, {
				onClick: (e) => {
					e.preventDefault();
					e.stopPropagation();
					navigateToEditMemberOwner(member?.ownerId, member?.legalEntityId);
				},
				variant: "link",
				children: t(($) => $["providePersonalDetailsOfOwner"])
			})
		] })
	});
	return /* @__PURE__ */ jsxs("div", {
		className: "u-margin-32",
		children: [
			/* @__PURE__ */ jsx(Header, {
				title: t(($) => $["partnershipMembers"]),
				description: t(($) => $["partnershipMembersDescription"])
			}),
			/* @__PURE__ */ jsxs(StackLayout, { children: [partnershipMembers.map((member) => {
				return /* @__PURE__ */ jsx(EntityAssociation, {
					types: member.roles,
					name: member.name,
					status: getTaskStatus(member.legalEntityType === LegalEntityTypes.INDIVIDUAL ? TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_INDIVIDUAL : TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY, member.legalEntityId),
					actions: getActions(member),
					onNavigateToEntity: () => navigateToEditMember(member),
					infoContent: isMemberMissingOwner(member) ? infoContent(member) : void 0
				}, member.legalEntityId);
			}), /* @__PURE__ */ jsx(Button, {
				variant: "secondary",
				icon: "plus",
				onClick: () => navigateToEditMember(void 0),
				fullWidth: true,
				children: t(($) => $["addPartner"])
			})] }),
			/* @__PURE__ */ jsxs("div", {
				class: "u-display-flex u-margin-top-48",
				children: [/* @__PURE__ */ jsx(Spacer, {}), /* @__PURE__ */ jsx(Button, {
					variant: "secondary",
					onClick: navigateBackToTaskList,
					children: t(($) => $["saveAndGoToOverview"], { ns: "common" })
				})]
			})
		]
	});
};
//#endregion
export { UnincorporatedPartnershipMembersOverview };
