import { localizationKeys } from "../../localization/localizationKeys.js";
import { ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID } from "../../constants.js";
import { useProtect } from "../../common/Gate.js";
import { useOrganizationProfileContext } from "../../contexts/components/OrganizationProfile.js";
import { NavBar, NavbarContextProvider } from "../../elements/Navbar.js";
import React from "react";
import { useOrganization } from "@clerk/shared/react";
import { jsx, jsxs } from "@emotion/react/jsx-runtime";

//#region src/components/OrganizationProfile/OrganizationProfileNavbar.tsx
const OrganizationProfileNavbar = (props) => {
	const { organization } = useOrganization();
	const { apiKeysProps, pages } = useOrganizationProfileContext();
	const allowMembersRoute = useProtect((has) => has({ permission: "org:sys_memberships:read" }) || has({ permission: "org:sys_memberships:manage" }));
	const allowBillingRoutes = useProtect((has) => has({ permission: "org:sys_billing:read" }) || has({ permission: "org:sys_billing:manage" }));
	const routes = pages.routes.filter((r) => r.id !== ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.MEMBERS || r.id === ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.MEMBERS && allowMembersRoute).filter((r) => r.id !== ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.BILLING || r.id === ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.BILLING && allowBillingRoutes).filter((r) => r.id !== ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.API_KEYS || !apiKeysProps?.hide);
	if (!organization) return null;
	return /* @__PURE__ */ jsxs(NavbarContextProvider, {
		contentRef: props.contentRef,
		children: [/* @__PURE__ */ jsx(NavBar, {
			title: localizationKeys("organizationProfile.navbar.title"),
			description: localizationKeys("organizationProfile.navbar.description"),
			routes,
			contentRef: props.contentRef
		}), props.children]
	});
};

//#endregion
export { OrganizationProfileNavbar };
//# sourceMappingURL=OrganizationProfileNavbar.js.map