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] = "d20bfcc7-e80b-4914-8bf8-92f2c2f4b6b9", e._sentryDebugIdIdentifier = "sentry-dbid-d20bfcc7-e80b-4914-8bf8-92f2c2f4b6b9");
} catch (e) {}
import { t as TaskTypes } from "./taskTypes-DWaxzvnQ.js";
import { i as getDirectEntityAssociations } from "./entityAssociationUtil-C0gX4Ewv.js";
import { t as DecisionMakerTypes } from "./decision-maker-type-DHBYiKIe.js";
import { r as getDecisionMakerRequirements } from "./decisionMaker-BKR5Dau-.js";
//#region src/utils/decisionMakerRoles.ts
var getOwnDecisionMakers = (rootLegalEntity) => {
	if (!rootLegalEntity?.entityAssociations) return [];
	return rootLegalEntity.entityAssociations.filter((entityAssociation) => Object.values(DecisionMakerTypes).includes(entityAssociation.type) && entityAssociation.associatorId === rootLegalEntity.id);
};
var getDecisionMakers = (rootLegalEntity, companyLegalEntityId) => getDirectEntityAssociations(rootLegalEntity, companyLegalEntityId).filter((association) => Object.values(DecisionMakerTypes).includes(association.type));
var getOwnSignatories = (rootLegalEntity) => getOwnDecisionMakers(rootLegalEntity).filter((decisionMaker) => decisionMaker.type === DecisionMakerTypes.SIGNATORY);
var getOwnDecisionMakersLegalEntityIds = (rootLegalEntity) => getOwnDecisionMakers(rootLegalEntity).map((ea) => ea.legalEntityId).filter((id) => id !== void 0);
var getDecisionMakerCount = (rootLegalEntity) => {
	return getOwnDecisionMakers(rootLegalEntity).reduce((decisionMakerCount, decisionMaker) => {
		decisionMakerCount[decisionMaker.type] = (decisionMakerCount[decisionMaker.type] ?? 0) + 1;
		return decisionMakerCount;
	}, {});
};
var getAllowedDecisionMakerRoles = (rootLegalEntity, taskType, scenarios) => {
	if (taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER) return [DecisionMakerTypes.OWNER];
	const existingDecisionMakerCount = getDecisionMakerCount(rootLegalEntity);
	const registeredCountry = rootLegalEntity?.organization?.registeredAddress?.country;
	const allowedRoles = getDecisionMakerRequirements(registeredCountry, scenarios).reduce((acc, requirements) => {
		const { roleTypes, max } = requirements;
		if (roleTypes.length === 1) {
			const role = roleTypes[0];
			if ((existingDecisionMakerCount?.[role] ?? 0) < max) acc.push(role);
		}
		return acc;
	}, []);
	return [...new Set(allowedRoles)];
};
var hasMinRequiredDecisionMakerCount = (rootLegalEntity) => {
	const existingDecisionMakerCount = getDecisionMakerCount(rootLegalEntity);
	const registeredCountry = rootLegalEntity?.organization?.registeredAddress?.country;
	return getDecisionMakerRequirements(registeredCountry).every((requirements) => {
		const { roleTypes, min } = requirements;
		return roleTypes.some((role) => min ? existingDecisionMakerCount?.[role] ?? min <= 0 : true);
	});
};
//#endregion
export { getOwnSignatories as a, getOwnDecisionMakersLegalEntityIds as i, getDecisionMakers as n, hasMinRequiredDecisionMakerCount as o, getOwnDecisionMakers as r, getAllowedDecisionMakerRoles as t };
