@seliseblocks/genesis-os 4.3.5 → 4.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/{chunk-WBSWAHS6.js → chunk-46ZGVJEX.js} +98 -17
  2. package/dist/chunk-46ZGVJEX.js.map +1 -0
  3. package/dist/{chunk-FKFBYT22.cjs → chunk-4QKE3WAW.cjs} +103 -18
  4. package/dist/chunk-4QKE3WAW.cjs.map +1 -0
  5. package/dist/{chunk-3VNGGYRG.cjs → chunk-4QN4CYSC.cjs} +26 -7
  6. package/dist/chunk-4QN4CYSC.cjs.map +1 -0
  7. package/dist/{chunk-ENK42YC4.js → chunk-4UHGGHI6.js} +17 -3
  8. package/dist/chunk-4UHGGHI6.js.map +1 -0
  9. package/dist/{chunk-VAKGHXK6.cjs → chunk-6GCU5LM7.cjs} +17 -3
  10. package/dist/chunk-6GCU5LM7.cjs.map +1 -0
  11. package/dist/{chunk-NF54AHIF.js → chunk-AHCHUUXM.js} +2 -2
  12. package/dist/{chunk-NF54AHIF.js.map → chunk-AHCHUUXM.js.map} +1 -1
  13. package/dist/{chunk-Q7Y32IBM.cjs → chunk-BPJM3L7O.cjs} +2 -2
  14. package/dist/{chunk-Q7Y32IBM.cjs.map → chunk-BPJM3L7O.cjs.map} +1 -1
  15. package/dist/{chunk-H47HQ5UX.js → chunk-CBQL2T6H.js} +209 -6
  16. package/dist/chunk-CBQL2T6H.js.map +1 -0
  17. package/dist/{chunk-ZVGCCTNK.cjs → chunk-IJMKS4XG.cjs} +12 -12
  18. package/dist/{chunk-ZVGCCTNK.cjs.map → chunk-IJMKS4XG.cjs.map} +1 -1
  19. package/dist/{chunk-6WBFAHAO.js → chunk-JITR3QYC.js} +24 -5
  20. package/dist/chunk-JITR3QYC.js.map +1 -0
  21. package/dist/{chunk-TE3SKUL4.js → chunk-JSXAKNHQ.js} +3 -3
  22. package/dist/{chunk-TE3SKUL4.js.map → chunk-JSXAKNHQ.js.map} +1 -1
  23. package/dist/{chunk-VTOD5ZQU.cjs → chunk-QTSTAWK3.cjs} +3 -3
  24. package/dist/{chunk-VTOD5ZQU.cjs.map → chunk-QTSTAWK3.cjs.map} +1 -1
  25. package/dist/{chunk-XALNVJQU.cjs → chunk-SXEXXJHL.cjs} +236 -21
  26. package/dist/{chunk-H47HQ5UX.js.map → chunk-SXEXXJHL.cjs.map} +1 -1
  27. package/dist/{chunk-IWWGJQGJ.js → chunk-X7X4QYK4.js} +458 -13
  28. package/dist/chunk-X7X4QYK4.js.map +1 -0
  29. package/dist/{chunk-WIY77276.js → chunk-XRAO7JBH.js} +5 -5
  30. package/dist/{chunk-WIY77276.js.map → chunk-XRAO7JBH.js.map} +1 -1
  31. package/dist/{chunk-6DQTH7RD.cjs → chunk-YFTRLNLF.cjs} +611 -159
  32. package/dist/chunk-YFTRLNLF.cjs.map +1 -0
  33. package/dist/components/index.cjs +359 -361
  34. package/dist/components/index.js +9 -11
  35. package/dist/guards/index.cjs +315 -11
  36. package/dist/guards/index.d.cts +3 -1
  37. package/dist/guards/index.d.ts +3 -1
  38. package/dist/guards/index.js +309 -5
  39. package/dist/hooks/index.cjs +92 -93
  40. package/dist/hooks/index.js +6 -7
  41. package/dist/index.cjs +625 -611
  42. package/dist/index.d.cts +2 -2
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.js +9 -11
  45. package/dist/layouts/index.cjs +16 -18
  46. package/dist/layouts/index.js +9 -11
  47. package/dist/lib/index.cjs +33 -17
  48. package/dist/lib/index.d.cts +57 -2
  49. package/dist/lib/index.d.ts +57 -2
  50. package/dist/lib/index.js +2 -2
  51. package/dist/pages/index.cjs +14 -16
  52. package/dist/pages/index.js +9 -11
  53. package/dist/providers/index.cjs +8 -8
  54. package/dist/providers/index.js +4 -4
  55. package/dist/store/index.cjs +10 -10
  56. package/dist/store/index.d.cts +31 -3
  57. package/dist/store/index.d.ts +31 -3
  58. package/dist/store/index.js +2 -2
  59. package/dist/utils/index.cjs +72 -72
  60. package/dist/utils/index.js +4 -4
  61. package/package.json +1 -1
  62. package/dist/chunk-25L7I5C7.js +0 -265
  63. package/dist/chunk-25L7I5C7.js.map +0 -1
  64. package/dist/chunk-3VNGGYRG.cjs.map +0 -1
  65. package/dist/chunk-6DQTH7RD.cjs.map +0 -1
  66. package/dist/chunk-6WBFAHAO.js.map +0 -1
  67. package/dist/chunk-ENK42YC4.js.map +0 -1
  68. package/dist/chunk-FKFBYT22.cjs.map +0 -1
  69. package/dist/chunk-HS6F65WY.cjs +0 -273
  70. package/dist/chunk-HS6F65WY.cjs.map +0 -1
  71. package/dist/chunk-IICIA5RV.js +0 -212
  72. package/dist/chunk-IICIA5RV.js.map +0 -1
  73. package/dist/chunk-IWWGJQGJ.js.map +0 -1
  74. package/dist/chunk-UVMFL4UV.cjs +0 -225
  75. package/dist/chunk-UVMFL4UV.cjs.map +0 -1
  76. package/dist/chunk-VAKGHXK6.cjs.map +0 -1
  77. package/dist/chunk-WBSWAHS6.js.map +0 -1
  78. package/dist/chunk-XALNVJQU.cjs.map +0 -1
@@ -1,16 +1,14 @@
1
1
  import { refractor } from './chunk-FGY7QM3Y.js';
2
- import { useKeyboardShortcut, usePopoverWidth, useBlocksAppConfigStore, useTheme, useLogout, useGetMyOrganizations, useLanguageSwitcher, useGetBlocksNotificationConfig, notificationService, useLogo, useLogin, useSignUpAffordance, useSignUpRedirect, useInitiateRedirect, useIcon, initiateService, useGetNotifications, useMarkAsRead, useMarkAllAsRead, useDebouncedFuseFilter, usePrefetchRedirect } from './chunk-H47HQ5UX.js';
3
- import { showErrorToast, createStorage, getForwardedToPath, debounce, formatFullDate, formatDate, deepEqual, showSuccessToast, isErrorWithErrors, getServiceBaseUrl, getServiceSwaggerUrl } from './chunk-TE3SKUL4.js';
4
- import { defaultRightSidePanelContextValue, RightSidePanelContext, SidebarContext, DashboardLayoutProvider } from './chunk-WIY77276.js';
5
- import { useIsMobile, useIsActiveMenu, useFilteredMenus } from './chunk-NF54AHIF.js';
6
- import { PublicGuard, ImpersonationChecker, ImpersonationTerminator, ImpersonationSynchronizer } from './chunk-25L7I5C7.js';
7
- import { useStartImpersonation, useGetProjects, useGetProject, useGetEnvRepositories, useUpdateTenantGroup, useDisableProject, useUpdateRepositories } from './chunk-IICIA5RV.js';
8
- import { fadeTransition, fadeInUp, staggerContainer, staggerItem, fadeInScale, iamClient, PROFILE_ENDPOINTS } from './chunk-WBSWAHS6.js';
9
- import { getRuntimeEnv } from './chunk-JUVLHPQI.js';
2
+ import { useKeyboardShortcut, usePopoverWidth, useBlocksAppConfigStore, useTheme, useLogout, useGetMyOrganizations, useLanguageSwitcher, useGetBlocksNotificationConfig, notificationService, useLogo, useStartImpersonation, useGetProjects, useGetProject, useImpersonationStatusChecker, useStopImpersonation, useLogin, useSignUpAffordance, useSignUpRedirect, useInitiateRedirect, useGetEnvRepositories, useUpdateTenantGroup, useIcon, useDisableProject, projectService, initiateService, useGetNotifications, useMarkAsRead, useMarkAllAsRead, useDebouncedFuseFilter, useUpdateRepositories, usePrefetchRedirect } from './chunk-CBQL2T6H.js';
3
+ import { showErrorToast, createStorage, getForwardedToPath, debounce, formatFullDate, formatDate, deepEqual, showSuccessToast, isErrorWithErrors, getServiceBaseUrl, getServiceSwaggerUrl } from './chunk-JSXAKNHQ.js';
4
+ import { fadeTransition, fadeInUp, staggerContainer, staggerItem, fadeInScale, readCurrentOwner, TAB_ID, subscribeToTenantClaims, claimTenant, iamClient, AUTH_ENDPOINTS, PROFILE_ENDPOINTS } from './chunk-46ZGVJEX.js';
5
+ import { getRuntimeEnv, HttpError } from './chunk-JUVLHPQI.js';
6
+ import { defaultRightSidePanelContextValue, RightSidePanelContext, SidebarContext, DashboardLayoutProvider } from './chunk-XRAO7JBH.js';
7
+ import { useIsMobile, useIsActiveMenu, useFilteredMenus } from './chunk-AHCHUUXM.js';
10
8
  import { cn } from './chunk-3MLPBMH2.js';
11
9
  import { getQueryClient } from './chunk-BRHE44FE.js';
12
- import { useLayoutSettingsStore, useLanguageViewStore, useUserStore } from './chunk-6WBFAHAO.js';
13
- import { CookieStorage, useProjectStore, useAuthStore } from './chunk-ENK42YC4.js';
10
+ import { useLayoutSettingsStore, useLanguageViewStore, useImpersonateStore, useUserStore } from './chunk-JITR3QYC.js';
11
+ import { CookieStorage, useProjectStore, useAuthStore } from './chunk-4UHGGHI6.js';
14
12
  import { __commonJS, __toESM } from './chunk-PL4HS6R6.js';
15
13
  import * as React8 from 'react';
16
14
  import React8__default, { createContext, forwardRef, useState, useCallback, useEffect, useRef, useContext, useMemo, Suspense, Fragment as Fragment$1, Component, createElement as createElement$1, isValidElement } from 'react';
@@ -7680,6 +7678,453 @@ function SelectedProject() {
7680
7678
  /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: projectName })
7681
7679
  ] });
7682
7680
  }
7681
+ function ProtectedGuard({
7682
+ children,
7683
+ defaultPublicPath = "/login"
7684
+ }) {
7685
+ const { isAuthenticated } = useAuthStore();
7686
+ const navigate = useNavigate();
7687
+ useEffect(() => {
7688
+ if (!isAuthenticated) navigate(defaultPublicPath);
7689
+ }, [isAuthenticated, defaultPublicPath, navigate]);
7690
+ return /* @__PURE__ */ jsx(Fragment, { children });
7691
+ }
7692
+ var useAppState = () => {
7693
+ const [isMounted, setIsMounted] = useState(false);
7694
+ useEffect(() => {
7695
+ setIsMounted(true);
7696
+ }, []);
7697
+ return { isMounted };
7698
+ };
7699
+ function PublicGuard({
7700
+ children,
7701
+ defaultProtectedPath = "/app/console"
7702
+ }) {
7703
+ const { isAuthenticated } = useAuthStore();
7704
+ const { isMounted } = useAppState();
7705
+ const navigate = useNavigate();
7706
+ useEffect(() => {
7707
+ if (!isMounted) return;
7708
+ if (isAuthenticated) navigate(defaultProtectedPath, { replace: true });
7709
+ }, [isAuthenticated, isMounted, navigate, defaultProtectedPath]);
7710
+ if (!isMounted) return null;
7711
+ return /* @__PURE__ */ jsx(Fragment, { children });
7712
+ }
7713
+ function AuthResolver({ children }) {
7714
+ const { setUser, setAuthenticated, setUnAuthenticated } = useAuthStore();
7715
+ const hasResolved = useRef(false);
7716
+ useEffect(() => {
7717
+ if (hasResolved.current) return;
7718
+ hasResolved.current = true;
7719
+ async function resolve() {
7720
+ try {
7721
+ const res = await iamClient.get(`${AUTH_ENDPOINTS.ME}`);
7722
+ setUser(res);
7723
+ setAuthenticated();
7724
+ } catch {
7725
+ setUnAuthenticated();
7726
+ }
7727
+ }
7728
+ resolve();
7729
+ }, [setAuthenticated, setUnAuthenticated, setUser]);
7730
+ return /* @__PURE__ */ jsx(Fragment, { children });
7731
+ }
7732
+ var BlocksIcon = ({ size }) => /* @__PURE__ */ jsxs(
7733
+ "svg",
7734
+ {
7735
+ width: size,
7736
+ height: size,
7737
+ viewBox: "0 0 246 360",
7738
+ fill: "none",
7739
+ xmlns: "http://www.w3.org/2000/svg",
7740
+ children: [
7741
+ /* @__PURE__ */ jsx(
7742
+ "path",
7743
+ {
7744
+ d: "M245.455 68.1627V129.877L168.982 156.67V93.9638L245.455 68.1627Z",
7745
+ fill: "#2D86C7"
7746
+ }
7747
+ ),
7748
+ /* @__PURE__ */ jsx(
7749
+ "path",
7750
+ {
7751
+ d: "M240.389 62.3805L165.49 87.6573L5.30933 24.2563L85.3314 0L240.389 62.3805Z",
7752
+ fill: "#2D86C7"
7753
+ }
7754
+ ),
7755
+ /* @__PURE__ */ jsx(
7756
+ "path",
7757
+ {
7758
+ d: "M161.797 93.8295V156.43L81.1141 122.607V188.07L0 152.738V29.6846L161.797 93.8295Z",
7759
+ fill: "#2D86C7"
7760
+ }
7761
+ ),
7762
+ /* @__PURE__ */ jsx(
7763
+ "path",
7764
+ {
7765
+ d: "M76.4728 266.036L0 291.837V230.123L76.4728 203.329V266.036Z",
7766
+ fill: "#2D86C7"
7767
+ }
7768
+ ),
7769
+ /* @__PURE__ */ jsx(
7770
+ "path",
7771
+ {
7772
+ d: "M160.123 360L5.07178 297.619L79.964 272.343L240.145 335.744L160.123 360Z",
7773
+ fill: "#2D86C7"
7774
+ }
7775
+ ),
7776
+ /* @__PURE__ */ jsx(
7777
+ "path",
7778
+ {
7779
+ d: "M245.454 330.315L83.657 266.17V203.57L164.34 237.393V171.93L245.454 207.262V330.315Z",
7780
+ fill: "#2D86C7"
7781
+ }
7782
+ )
7783
+ ]
7784
+ }
7785
+ );
7786
+ var AppLoadingSpinner = ({ size = 64 }) => /* @__PURE__ */ jsxs(Fragment, { children: [
7787
+ /* @__PURE__ */ jsx("style", { children: `
7788
+ @keyframes breathe {
7789
+ 0%, 100% { transform: scaleY(1); }
7790
+ 50% { transform: scaleY(0.85); }
7791
+
7792
+ }
7793
+ .animate-breathe {
7794
+ animation: breathe 2s ease-in-out infinite;
7795
+ transform-origin: center;
7796
+ }
7797
+ ` }),
7798
+ /* @__PURE__ */ jsx("div", { className: "bg-background fixed inset-0 z-50 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "animate-breathe", children: /* @__PURE__ */ jsx(BlocksIcon, { size }) }) })
7799
+ ] });
7800
+ var projectNameFor = (projects, tenantId) => tenantId && projects.find((p) => p.tenantId === tenantId)?.name || null;
7801
+ var ImpersonationChecker = ({
7802
+ children
7803
+ }) => {
7804
+ const { data, isLoading, isSuccess } = useImpersonationStatusChecker();
7805
+ const { setImpersonation, isInitialized, setInitialized } = useImpersonateStore();
7806
+ useEffect(() => {
7807
+ if (!data) return;
7808
+ setImpersonation(
7809
+ data.impersonated,
7810
+ data.originalTenantId,
7811
+ data.impersonated ? data.impersonatedTenantId : null
7812
+ );
7813
+ setInitialized(true);
7814
+ }, [data, setImpersonation, setInitialized]);
7815
+ if (isLoading || !isSuccess || !isInitialized) return null;
7816
+ return /* @__PURE__ */ jsx(Fragment, { children });
7817
+ };
7818
+ function ImpersonationBlocked({
7819
+ title,
7820
+ description,
7821
+ primaryLabel,
7822
+ onPrimary,
7823
+ consolePath
7824
+ }) {
7825
+ const navigate = useNavigate();
7826
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-[320px] w-full flex-col items-center justify-center gap-4 p-8 text-center", children: [
7827
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
7828
+ /* @__PURE__ */ jsx("h2", { className: "text-base font-semibold", children: title }),
7829
+ /* @__PURE__ */ jsx("p", { className: "max-w-md text-sm text-muted-foreground", children: description })
7830
+ ] }),
7831
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-2", children: [
7832
+ primaryLabel && onPrimary && /* @__PURE__ */ jsx(Button, { onClick: onPrimary, children: primaryLabel }),
7833
+ consolePath && /* @__PURE__ */ jsx(
7834
+ Button,
7835
+ {
7836
+ variant: primaryLabel && onPrimary ? "outline" : "default",
7837
+ onClick: () => navigate(consolePath),
7838
+ children: "Go to console"
7839
+ }
7840
+ )
7841
+ ] })
7842
+ ] });
7843
+ }
7844
+ function ImpersonationWaiting({ label }) {
7845
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-[320px] w-full flex-col items-center justify-center gap-3", children: [
7846
+ /* @__PURE__ */ jsx(AppLoadingSpinner, {}),
7847
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: label })
7848
+ ] });
7849
+ }
7850
+ function ImpersonationTerminator({
7851
+ children
7852
+ }) {
7853
+ const {
7854
+ terminate,
7855
+ isImpersonated,
7856
+ detachedReason,
7857
+ detachedTenantId,
7858
+ setDetached
7859
+ } = useImpersonateStore();
7860
+ const { mutateAsync } = useStopImpersonation();
7861
+ const { projects } = useProjectStore();
7862
+ const isTriggering = useRef(false);
7863
+ const [isTerminating, setIsTerminating] = useState(false);
7864
+ const rootTenantId = window.process?.env.BLOCKS_X_BLOCKS_KEY || "";
7865
+ useEffect(() => {
7866
+ if (!rootTenantId) return;
7867
+ const owner = readCurrentOwner();
7868
+ if (owner && owner.tabId !== TAB_ID && owner.tenantId !== rootTenantId) {
7869
+ setDetached("another-project", owner.tenantId);
7870
+ }
7871
+ return subscribeToTenantClaims((claim) => {
7872
+ if (claim.tenantId === rootTenantId) {
7873
+ setDetached(null);
7874
+ return;
7875
+ }
7876
+ setDetached("another-project", claim.tenantId);
7877
+ });
7878
+ }, [rootTenantId, setDetached]);
7879
+ useEffect(() => {
7880
+ if (isTriggering.current || !isImpersonated) return;
7881
+ if (detachedReason) return;
7882
+ isTriggering.current = true;
7883
+ setIsTerminating(true);
7884
+ const stopImpersonation = async () => {
7885
+ let sessionIsRootScoped = false;
7886
+ try {
7887
+ await mutateAsync(void 0);
7888
+ sessionIsRootScoped = true;
7889
+ } catch (error) {
7890
+ if (!(error instanceof HttpError) || error.status !== 401) {
7891
+ console.error("Error stopping impersonation:", error);
7892
+ }
7893
+ sessionIsRootScoped = error instanceof HttpError && error.status === 401;
7894
+ } finally {
7895
+ terminate(rootTenantId);
7896
+ if (sessionIsRootScoped && rootTenantId) claimTenant(rootTenantId);
7897
+ isTriggering.current = false;
7898
+ setIsTerminating(false);
7899
+ }
7900
+ };
7901
+ void stopImpersonation();
7902
+ }, [mutateAsync, terminate, isImpersonated, detachedReason, rootTenantId]);
7903
+ if (detachedReason) {
7904
+ const name = projectNameFor(projects, detachedTenantId);
7905
+ return /* @__PURE__ */ jsx(
7906
+ ImpersonationBlocked,
7907
+ {
7908
+ title: name ? `Your session is in ${name}` : "Your session is in a project",
7909
+ description: "The project is open in another window. A session can only be in one place at a time.",
7910
+ primaryLabel: name ? `Leave ${name}` : "Leave the project",
7911
+ onPrimary: () => setDetached(null)
7912
+ }
7913
+ );
7914
+ }
7915
+ if (isImpersonated || isTerminating) {
7916
+ return /* @__PURE__ */ jsx(ImpersonationWaiting, { label: "Returning to the console\u2026" });
7917
+ }
7918
+ return /* @__PURE__ */ jsx(Fragment, { children });
7919
+ }
7920
+ function ImpersonationSynchronizer({
7921
+ children,
7922
+ consolePath = "/app/console"
7923
+ }) {
7924
+ const {
7925
+ impersonate,
7926
+ isImpersonated,
7927
+ impersonatedTenantId,
7928
+ impersonationError,
7929
+ detachedReason,
7930
+ detachedTenantId,
7931
+ setImpersonationError,
7932
+ setDetached
7933
+ } = useImpersonateStore();
7934
+ const { mutateAsync } = useStartImpersonation();
7935
+ const { data: _data } = useGetProjects({ enabled: true });
7936
+ const { selectedProject, setSelectedProject, projects, setTenantGroup } = useProjectStore();
7937
+ const isTriggering = useRef(false);
7938
+ const [isImpersonating, setIsImpersonating] = useState(false);
7939
+ const { itemId } = useParams();
7940
+ const rootTenantId = window.process?.env.BLOCKS_X_BLOCKS_KEY || "";
7941
+ const routeTenantId = useMemo(() => {
7942
+ if (!itemId) return null;
7943
+ return projects.find((p) => p.itemId === itemId)?.tenantId ?? null;
7944
+ }, [itemId, projects]);
7945
+ const impersonatedTenantIdRef = useRef(impersonatedTenantId);
7946
+ const selectedProjectRef = useRef(selectedProject);
7947
+ const projectsRef = useRef(projects);
7948
+ const routeTenantIdRef = useRef(routeTenantId);
7949
+ impersonatedTenantIdRef.current = impersonatedTenantId;
7950
+ selectedProjectRef.current = selectedProject;
7951
+ projectsRef.current = projects;
7952
+ routeTenantIdRef.current = routeTenantId;
7953
+ useEffect(() => {
7954
+ if (!itemId || !projects.length) return;
7955
+ if (selectedProject?.itemId === itemId) return;
7956
+ const match = projects.find((p) => p.itemId === itemId);
7957
+ if (match) {
7958
+ setSelectedProject(match);
7959
+ setTenantGroup(match.tenantGroupId);
7960
+ }
7961
+ }, [
7962
+ itemId,
7963
+ selectedProject?.itemId,
7964
+ projects,
7965
+ setSelectedProject,
7966
+ setTenantGroup
7967
+ ]);
7968
+ const getImpersonatedProject = async () => {
7969
+ try {
7970
+ const res = projectService.getProject();
7971
+ return (await res).data;
7972
+ } catch (error) {
7973
+ console.error("Error fetching projects:", error);
7974
+ }
7975
+ };
7976
+ const runImpersonation = useCallback(async () => {
7977
+ const targetTenantId = routeTenantIdRef.current;
7978
+ const currentTenantId = impersonatedTenantIdRef.current;
7979
+ const knownProjects = projectsRef.current;
7980
+ isTriggering.current = true;
7981
+ setIsImpersonating(true);
7982
+ try {
7983
+ if (!targetTenantId) {
7984
+ if (currentTenantId && !selectedProjectRef.current) {
7985
+ const project2 = knownProjects.find((p) => p.tenantId === currentTenantId) ?? await getImpersonatedProject();
7986
+ if (project2) {
7987
+ setSelectedProject(project2);
7988
+ setTenantGroup(project2.tenantGroupId);
7989
+ }
7990
+ }
7991
+ return;
7992
+ }
7993
+ await mutateAsync({ targeted_tenant_id: targetTenantId });
7994
+ impersonate(targetTenantId, rootTenantId);
7995
+ claimTenant(targetTenantId);
7996
+ const project = knownProjects.find((p) => p.tenantId === targetTenantId);
7997
+ if (project) {
7998
+ setSelectedProject(project);
7999
+ setTenantGroup(project.tenantGroupId);
8000
+ }
8001
+ } catch (error) {
8002
+ setImpersonationError(error);
8003
+ } finally {
8004
+ isTriggering.current = false;
8005
+ setIsImpersonating(false);
8006
+ }
8007
+ }, [
8008
+ mutateAsync,
8009
+ impersonate,
8010
+ rootTenantId,
8011
+ setSelectedProject,
8012
+ setTenantGroup,
8013
+ setImpersonationError
8014
+ ]);
8015
+ const takeSession = useCallback(() => {
8016
+ setImpersonationError(null);
8017
+ setDetached(null);
8018
+ void runImpersonation();
8019
+ }, [runImpersonation, setImpersonationError, setDetached]);
8020
+ useEffect(() => {
8021
+ const owner = readCurrentOwner();
8022
+ if (owner && owner.tabId !== TAB_ID && routeTenantId && owner.tenantId !== routeTenantId) {
8023
+ setDetached(
8024
+ owner.tenantId === rootTenantId ? "console" : "another-project",
8025
+ owner.tenantId
8026
+ );
8027
+ }
8028
+ return subscribeToTenantClaims((claim) => {
8029
+ const mine = routeTenantIdRef.current;
8030
+ if (!mine) return;
8031
+ if (claim.tenantId === mine) {
8032
+ setDetached(null);
8033
+ return;
8034
+ }
8035
+ setDetached(
8036
+ claim.tenantId === rootTenantId ? "console" : "another-project",
8037
+ claim.tenantId
8038
+ );
8039
+ });
8040
+ }, [routeTenantId, rootTenantId, setDetached]);
8041
+ useEffect(() => {
8042
+ if (!itemId) return;
8043
+ if (isTriggering.current) return;
8044
+ if (impersonationError || detachedReason) return;
8045
+ const needsColdStart = !routeTenantId && !!impersonatedTenantId && !selectedProject;
8046
+ const needsRetarget = !!routeTenantId && routeTenantId !== impersonatedTenantId;
8047
+ if (!needsColdStart && !needsRetarget) return;
8048
+ void runImpersonation();
8049
+ }, [
8050
+ itemId,
8051
+ routeTenantId,
8052
+ impersonatedTenantId,
8053
+ selectedProject,
8054
+ impersonationError,
8055
+ detachedReason,
8056
+ runImpersonation
8057
+ ]);
8058
+ const thisProjectName = projectNameFor(projects, routeTenantId);
8059
+ if (isImpersonating) {
8060
+ return /* @__PURE__ */ jsx(
8061
+ ImpersonationWaiting,
8062
+ {
8063
+ label: thisProjectName ? `Opening ${thisProjectName}\u2026` : "Opening project\u2026"
8064
+ }
8065
+ );
8066
+ }
8067
+ if (!itemId) {
8068
+ if (!isImpersonated || isTriggering.current) return null;
8069
+ return /* @__PURE__ */ jsx(Fragment, { children });
8070
+ }
8071
+ if (impersonationError) {
8072
+ const accessDenied = impersonationError instanceof HttpError && impersonationError.status === 403;
8073
+ return accessDenied ? /* @__PURE__ */ jsx(
8074
+ ImpersonationBlocked,
8075
+ {
8076
+ title: thisProjectName ? `You don't have access to ${thisProjectName}` : "You don't have access to this project",
8077
+ description: "Your access to this project may have been removed. Pick another project from the console.",
8078
+ consolePath
8079
+ }
8080
+ ) : /* @__PURE__ */ jsx(
8081
+ ImpersonationBlocked,
8082
+ {
8083
+ title: thisProjectName ? `Couldn't open ${thisProjectName}` : "Couldn't open this project",
8084
+ description: "Something went wrong switching to this project. Try again, or pick a different one from the console.",
8085
+ primaryLabel: "Try again",
8086
+ onPrimary: takeSession,
8087
+ consolePath
8088
+ }
8089
+ );
8090
+ }
8091
+ if (detachedReason === "console") {
8092
+ return /* @__PURE__ */ jsx(
8093
+ ImpersonationBlocked,
8094
+ {
8095
+ title: "Your session returned to the console",
8096
+ description: thisProjectName ? `You went back to the console in another window, so ${thisProjectName} is no longer open here.` : "You went back to the console in another window, so this project is no longer open here.",
8097
+ primaryLabel: thisProjectName ? `Reopen ${thisProjectName}` : "Reopen this project",
8098
+ onPrimary: takeSession,
8099
+ consolePath
8100
+ }
8101
+ );
8102
+ }
8103
+ if (detachedReason === "another-project") {
8104
+ const otherName = projectNameFor(projects, detachedTenantId);
8105
+ return /* @__PURE__ */ jsx(
8106
+ ImpersonationBlocked,
8107
+ {
8108
+ title: "Another project is open in this browser",
8109
+ description: otherName ? `Your session moved to ${otherName} in another window. A session can only be in one project at a time.` : "Your session moved to another project in a different window. A session can only be in one project at a time.",
8110
+ primaryLabel: thisProjectName ? `Continue in ${thisProjectName}` : "Continue in this project",
8111
+ onPrimary: takeSession,
8112
+ consolePath
8113
+ }
8114
+ );
8115
+ }
8116
+ if (!routeTenantId)
8117
+ return /* @__PURE__ */ jsx(ImpersonationWaiting, { label: "Loading your projects\u2026" });
8118
+ if (routeTenantId !== impersonatedTenantId) {
8119
+ return /* @__PURE__ */ jsx(
8120
+ ImpersonationWaiting,
8121
+ {
8122
+ label: thisProjectName ? `Switching to ${thisProjectName}\u2026` : "Switching projects\u2026"
8123
+ }
8124
+ );
8125
+ }
8126
+ return /* @__PURE__ */ jsx(Fragment, { children });
8127
+ }
7683
8128
  function PublicLayout({ children }) {
7684
8129
  return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(PublicGuard, { children }) });
7685
8130
  }
@@ -12882,6 +13327,6 @@ var TablePagination2 = React8.forwardRef(
12882
13327
  );
12883
13328
  TablePagination2.displayName = "TablePagination";
12884
13329
 
12885
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppSwitcher, ArchiveProject, AspectRatio, AuthLayout, Avatar, AvatarFallback, AvatarImage, BackToConsoleNavigator, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, CallbackPage, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ConfirmationModal, ConsoleHeader, ConsoleLayout, ConsolePage, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyToClipboardButton, CopyableSnippet, DEFAULT_KANBAN_COLUMNS, DashboardHeader, DashboardLayout, DashboardOverview, DashboardRoute, DashboardSectionCard, DataTable, DataTableHeaderCell, DateRangePicker, DesktopMenuItem, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditProject, EditProjectDialog, EditProjectForm, EnvironmentCard, EnvironmentList, ErrorBoundary, ErrorDisplay, ErrorDisplayWithCard, FileInput, FileUploader, FileUploaderContent, FileUploaderItem, FilterControls, FilterToolBarMobileView, FilterToolbar, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, HoverCardTrigger, ImportFileModalContent, InfiniteScroll, InfiniteScroller, InfoTooltip, Input, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, KanbanBoard, KanbanBoardColumn, KanbanBoardContainer, KanbanTaskCard, Label, LanguageSelector, LoadingButton, LoginPage, Logo, MaskedText, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MobileMenuItem, MultiSelect, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Notification, OidcLayout, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, Popover, PopoverContent, PopoverTrigger, ProfilePage, Progress, ProjectActions, ProjectCardLoadingSkeleton, ProjectDetail, ProjectList2 as ProjectList, ProjectListRowLoadingSkeleton, ProjectOverview, ProjectRepoList, PublicLayout, RadioGroup4 as RadioGroup, RadioGroupItem, RenderAlternatively, RenderConditionally, ResizableHandle, ResizablePanel, ResizablePanelGroup, RightSidePanel, RightSidePanelBody, RightSidePanelClose, RightSidePanelDescription, RightSidePanelFooter, RightSidePanelHeader, RightSidePanelProvider, RightSidePanelTitle, RightSidePanelTrigger, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectedEnvironment, SelectedProject, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarCollapsedTooltip, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuDesktop, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarMobileView, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableLoadingSkeleton, TablePagination2 as TablePagination, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeSwitcher, Timeline, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UserDropdownMenu, WizardHorizontalTrackBar, WizardStepContent, WizardStepIndicator, WizardStepViewport, WizardStepperProvider, WizardVerticalTrackBar, badgeVariants, buttonVariants, editProjectFormDefaultValues, editProjectFormSchema, filteredAppSwitcherData, hasDraggableData, kanbanKeyboardCoordinateGetter, navigationMenuTriggerStyle, paginationQueryParsers, sidebarCollapsedTooltipClass, sortQueryParsers, spinnerVariants, toggleVariants, useFileUpload, useFormField, useNotificationSocket, useOidcContext, usePaginationQueryParams, useRightSidePanel, useSortQueryParams, useWizardStepper };
12886
- //# sourceMappingURL=chunk-IWWGJQGJ.js.map
12887
- //# sourceMappingURL=chunk-IWWGJQGJ.js.map
13330
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppLoadingSpinner, AppSwitcher, ArchiveProject, AspectRatio, AuthLayout, AuthResolver, Avatar, AvatarFallback, AvatarImage, BackToConsoleNavigator, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, CallbackPage, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ConfirmationModal, ConsoleHeader, ConsoleLayout, ConsolePage, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyToClipboardButton, CopyableSnippet, DEFAULT_KANBAN_COLUMNS, DashboardHeader, DashboardLayout, DashboardOverview, DashboardRoute, DashboardSectionCard, DataTable, DataTableHeaderCell, DateRangePicker, DesktopMenuItem, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditProject, EditProjectDialog, EditProjectForm, EnvironmentCard, EnvironmentList, ErrorBoundary, ErrorDisplay, ErrorDisplayWithCard, FileInput, FileUploader, FileUploaderContent, FileUploaderItem, FilterControls, FilterToolBarMobileView, FilterToolbar, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, HoverCardTrigger, ImpersonationChecker, ImpersonationSynchronizer, ImpersonationTerminator, ImportFileModalContent, InfiniteScroll, InfiniteScroller, InfoTooltip, Input, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, KanbanBoard, KanbanBoardColumn, KanbanBoardContainer, KanbanTaskCard, Label, LanguageSelector, LoadingButton, LoginPage, Logo, MaskedText, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MobileMenuItem, MultiSelect, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Notification, OidcLayout, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, Popover, PopoverContent, PopoverTrigger, ProfilePage, Progress, ProjectActions, ProjectCardLoadingSkeleton, ProjectDetail, ProjectList2 as ProjectList, ProjectListRowLoadingSkeleton, ProjectOverview, ProjectRepoList, ProtectedGuard, PublicGuard, PublicLayout, RadioGroup4 as RadioGroup, RadioGroupItem, RenderAlternatively, RenderConditionally, ResizableHandle, ResizablePanel, ResizablePanelGroup, RightSidePanel, RightSidePanelBody, RightSidePanelClose, RightSidePanelDescription, RightSidePanelFooter, RightSidePanelHeader, RightSidePanelProvider, RightSidePanelTitle, RightSidePanelTrigger, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectedEnvironment, SelectedProject, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarCollapsedTooltip, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuDesktop, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarMobileView, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableLoadingSkeleton, TablePagination2 as TablePagination, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeSwitcher, Timeline, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UserDropdownMenu, WizardHorizontalTrackBar, WizardStepContent, WizardStepIndicator, WizardStepViewport, WizardStepperProvider, WizardVerticalTrackBar, badgeVariants, buttonVariants, editProjectFormDefaultValues, editProjectFormSchema, filteredAppSwitcherData, hasDraggableData, kanbanKeyboardCoordinateGetter, navigationMenuTriggerStyle, paginationQueryParsers, sidebarCollapsedTooltipClass, sortQueryParsers, spinnerVariants, toggleVariants, useFileUpload, useFormField, useNotificationSocket, useOidcContext, usePaginationQueryParams, useRightSidePanel, useSortQueryParams, useWizardStepper };
13331
+ //# sourceMappingURL=chunk-X7X4QYK4.js.map
13332
+ //# sourceMappingURL=chunk-X7X4QYK4.js.map