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] = "6abbfc70-4888-4f5c-8872-aefdfd2f64b6", e._sentryDebugIdIdentifier = "sentry-dbid-6abbfc70-4888-4f5c-8872-aefdfd2f64b6");
} catch (e) {}
import { r as useTranslation } from "./translation-Br5wIPO-.js";
import { n as IconButton, t as Button } from "./Button-BDEdGXnd.js";
import { t as TaskVerificationStatus } from "./TaskVerificationStatus-jBBIJN_A.js";
import { i as TaskStatuses } from "./taskStatus-CvMqhrOK.js";
import { t as Card } from "./Card-DXdUqwyQ.js";
import { t as VerificationErrorAlert } from "./VerificationErrorAlert-x74LQ1wJ.js";
import { t as Confirm } from "./Confirm-BqhBxIWm.js";
import { n as getRoleTagVariant, t as getRoleName } from "./roleMetadata-Dt8-oMGP.js";
import { t as Tag } from "./Tag-BTQ4nyKS.js";
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { jsx, jsxs } from "preact/jsx-runtime";
//#region src/hooks/useClickAwayListener.tsx
function useClickAwayListener(ref, onClickAway) {
	const handleClickAway = useCallback((event) => {
		if (ref.current && !event.composedPath().includes(ref.current)) onClickAway();
	}, [ref, onClickAway]);
	useEffect(() => {
		document.addEventListener("mousedown", handleClickAway);
		return () => {
			document.removeEventListener("mousedown", handleClickAway);
		};
	}, [handleClickAway]);
}
var ClickAwayWrapper = ({ children, onClickAway, ...divProps }) => {
	const ref = useRef(null);
	useClickAwayListener(ref, onClickAway);
	return /* @__PURE__ */ jsx("div", {
		ref,
		...divProps,
		children
	});
};
var ActionsMenu_module_default = {
	"actions-menu": "adyen-kyc-actions-menu",
	actionsMenu: "adyen-kyc-actions-menu",
	"actions-menu-option": "adyen-kyc-actions-menu-option",
	actionsMenuOption: "adyen-kyc-actions-menu-option"
};
//#endregion
//#region src/components/ui/atoms/ActionsMenu/ActionsMenu.tsx
var ActionsMenu = ({ options, open, setOpen }) => {
	const menuItems = options.map(({ label, onSelect, icon }) => /* @__PURE__ */ jsx(Button, {
		onClick: (event) => {
			event.stopPropagation();
			setOpen(false);
			onSelect();
		},
		variant: "tertiary",
		icon,
		children: label
	}, label));
	return open ? /* @__PURE__ */ jsx(ClickAwayWrapper, {
		onClickAway: () => {
			setOpen(false);
		},
		className: ActionsMenu_module_default.actionsMenu,
		role: "menu",
		children: menuItems
	}) : null;
};
var EntityAssociation_module_default = {
	"entity-association-wrapper": "adyen-kyc-entity-association-wrapper",
	entityAssociationWrapper: "adyen-kyc-entity-association-wrapper",
	"entity-association": "adyen-kyc-entity-association",
	entityAssociation: "adyen-kyc-entity-association",
	"entity-association-top": "adyen-kyc-entity-association-top",
	entityAssociationTop: "adyen-kyc-entity-association-top",
	"entity-association-title": "adyen-kyc-entity-association-title",
	entityAssociationTitle: "adyen-kyc-entity-association-title",
	"entity-association-info": "adyen-kyc-entity-association-info",
	entityAssociationInfo: "adyen-kyc-entity-association-info",
	"entity-association-tag": "adyen-kyc-entity-association-tag",
	entityAssociationTag: "adyen-kyc-entity-association-tag",
	"entity-association-actions": "adyen-kyc-entity-association-actions",
	entityAssociationActions: "adyen-kyc-entity-association-actions",
	"entity-association-alert": "adyen-kyc-entity-association-alert",
	entityAssociationAlert: "adyen-kyc-entity-association-alert",
	card: "adyen-kyc-card"
};
//#endregion
//#region src/components/Shared/EntityAssociation/EntityAssociation.tsx
var EntityAssociation = ({ name, types, status, actions, problems, infoContent, onNavigateToEntity, deleteEntity, isDeleteDisabled }) => {
	const { t } = useTranslation("common");
	const [showingActions, setShowingActions] = useState(false);
	const [isConfirmShown, setIsConfirmShown] = useState(false);
	const isDeletable = !!deleteEntity;
	const handleRemoveIntent = (event) => {
		event.stopPropagation();
		setIsConfirmShown(true);
	};
	const dismissConfirm = () => {
		setIsConfirmShown(false);
	};
	return /* @__PURE__ */ jsxs("div", {
		className: EntityAssociation_module_default.entityAssociationWrapper,
		children: [/* @__PURE__ */ jsx(Card, {
			onClick: onNavigateToEntity,
			children: /* @__PURE__ */ jsxs("div", {
				className: EntityAssociation_module_default.entityAssociation,
				children: [
					/* @__PURE__ */ jsxs("div", {
						className: EntityAssociation_module_default.entityAssociationTop,
						children: [/* @__PURE__ */ jsx("h3", {
							className: EntityAssociation_module_default.entityAssociationTitle,
							children: name
						}), /* @__PURE__ */ jsxs("div", {
							className: EntityAssociation_module_default.entityAssociationInfo,
							children: [
								/* @__PURE__ */ jsx(TaskVerificationStatus, { status }),
								actions && /* @__PURE__ */ jsxs("div", {
									className: EntityAssociation_module_default.entityAssociationActions,
									children: [/* @__PURE__ */ jsx(IconButton, {
										variant: "tertiary",
										icon: "more-horiz",
										onClick: (event) => {
											event.stopPropagation();
											setShowingActions(!showingActions);
										},
										ariaLabel: t(($) => $["toggleAssociationMenu"], { name })
									}), /* @__PURE__ */ jsx(ActionsMenu, {
										options: actions,
										open: showingActions,
										setOpen: setShowingActions
									})]
								}),
								isDeletable && /* @__PURE__ */ jsx(IconButton, {
									ariaLabel: t(($) => $["delete"]),
									icon: "bin",
									variant: "tertiary",
									onClick: handleRemoveIntent,
									disabled: isConfirmShown || isDeleteDisabled
								})
							]
						})]
					}),
					/* @__PURE__ */ jsx("div", { children: types.map((type) => /* @__PURE__ */ jsx(Tag, {
						className: EntityAssociation_module_default.entityAssociationTag,
						variant: getRoleTagVariant(type),
						children: t(($) => $[getRoleName(type)])
					}, type)) }),
					status === TaskStatuses.ERROR && /* @__PURE__ */ jsx(VerificationErrorAlert, {
						className: EntityAssociation_module_default.entityAssociationAlert,
						problems
					}),
					infoContent
				]
			})
		}), isConfirmShown && isDeletable && /* @__PURE__ */ jsx(Confirm, {
			title: t(($) => $["deleteItem"], { item: name }),
			description: t(($) => $["thisActionIsPermanent"]),
			onConfirm: deleteEntity,
			confirmText: t(($) => $["delete"]),
			onCancel: dismissConfirm,
			critical: true
		})]
	});
};
//#endregion
export { EntityAssociation as t };
