//#region ../core/src/member-permissions.ts
/**
* Whether the current member has the given capability.
*
* Prefers the native `member_type_detail.permissions` map. When no detail
* is present yet (backfill gap), falls back to the legacy binary type:
* `rep_eligible` is granted to reps and denied to customers, preserving
* today's behavior. Unknown keys deny by default.
*/
function hasMemberPermission(account, key) {
	if (!account) return false;
	const permissions = account.member_type_detail?.permissions;
	if (permissions) {
		const requested = permissions[key];
		if (requested !== void 0) return requested === true;
		if (key === "rep_eligible") return permissions.search_enabled === true;
		if (key === "search_enabled") return permissions.rep_eligible === true;
		return false;
	}
	if (key === "rep_eligible" || key === "search_enabled") return account.member_type !== "customer";
	return false;
}
/**
* Whether the current member may access rep-only portal surfaces
* (Messages, My Site, and any rep-gated custom screen). This is the single
* gate the shell should consult instead of `member_type === "customer"`.
*/
function canAccessRepSurfaces(account) {
	return hasMemberPermission(account, "rep_eligible");
}
/**
* Whether the member is KNOWN to lack rep access — true only once a loaded
* account resolves to no rep-eligibility. An unresolved (loading) or absent
* account is NOT treated as denied, so shell gating stays permissive while
* the account query is in flight. This matches the pre-migration behavior
* (which defaulted an unknown member to rep) and avoids briefly filtering a
* rep's own navigation — which, combined with the root-path redirect, could
* otherwise misroute a rep whose first item is rep-only. Use this for
* gating; use `canAccessRepSurfaces` for a positive capability check on an
* already-loaded account.
*/
function deniesRepSurfaces(account) {
	return Boolean(account) && !canAccessRepSurfaces(account);
}
/**
* The real per-company member-type slug (`rep`, `customer`, or a custom
* slug like `affiliate`). Falls back to the binary `member_type` when no
* detail is present.
*/
function memberTypeSlug(account) {
	if (!account) return null;
	return account.member_type_detail?.slug ?? account.member_type;
}
/**
* The admin-facing display label for the member type (e.g. "Affiliate").
* Null when no detail is present — callers should not fabricate a label
* from the binary type.
*/
function memberTypeName(account) {
	return account?.member_type_detail?.name ?? null;
}
//#endregion
Object.defineProperty(exports, "canAccessRepSurfaces", {
	enumerable: true,
	get: function() {
		return canAccessRepSurfaces;
	}
});
Object.defineProperty(exports, "deniesRepSurfaces", {
	enumerable: true,
	get: function() {
		return deniesRepSurfaces;
	}
});
Object.defineProperty(exports, "hasMemberPermission", {
	enumerable: true,
	get: function() {
		return hasMemberPermission;
	}
});
Object.defineProperty(exports, "memberTypeName", {
	enumerable: true,
	get: function() {
		return memberTypeName;
	}
});
Object.defineProperty(exports, "memberTypeSlug", {
	enumerable: true,
	get: function() {
		return memberTypeSlug;
	}
});

//# sourceMappingURL=member-permissions-DjM_MJxs.cjs.map