react-semaphor 0.1.313 → 0.1.314

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 (37) hide show
  1. package/dist/brand-studio/index.js +4 -4
  2. package/dist/chunks/{braces-raPCNcS4.js → braces-CWi8x9ww.js} +1 -1
  3. package/dist/chunks/calendar-preferences-dialog-BzpQ5u4h.js +1 -0
  4. package/dist/chunks/calendar-preferences-dialog-D70CuT-1.js +456 -0
  5. package/dist/chunks/{chevrons-up-down-BYzO4q5w.js → chevrons-up-down-B2viXO2I.js} +1 -1
  6. package/dist/chunks/dashboard-controls-BS_aZcxs.js +57 -0
  7. package/dist/chunks/{dashboard-controls-DMsmUQkB.js → dashboard-controls-DbKtbw1V.js} +501 -523
  8. package/dist/chunks/{dashboard-filter-controls-launcher-CqXgWEa1.js → dashboard-filter-controls-launcher-C8Wm2Smj.js} +39 -39
  9. package/dist/chunks/{dashboard-filter-controls-launcher-DBmNn4EY.js → dashboard-filter-controls-launcher-CMXpudFJ.js} +1 -1
  10. package/dist/chunks/{dashboard-json-CHoCrAp0.js → dashboard-json-CJCAen1R.js} +2 -2
  11. package/dist/chunks/{dashboard-json-DMFZLkws.js → dashboard-json-v2C6Tmqf.js} +1 -1
  12. package/dist/chunks/{edit-dashboard-visual-B0Ae_O25.js → edit-dashboard-visual-DljWvnMy.js} +419 -419
  13. package/dist/chunks/{edit-dashboard-visual-CIP9G-Bu.js → edit-dashboard-visual-lRn3FeaP.js} +1 -1
  14. package/dist/chunks/{index-D7e2Eyp_.js → index-P5hPTTzm.js} +15127 -15106
  15. package/dist/chunks/{index-DjZqoaV5.js → index-XYIIY48z.js} +193 -193
  16. package/dist/chunks/{palette-7yJYVEvk.js → palette-CIuwlEiG.js} +1 -1
  17. package/dist/chunks/{resource-management-panel-B1mhnY97.js → resource-management-panel-CAxXzMdi.js} +1 -1
  18. package/dist/chunks/{resource-management-panel-CSkNW3es.js → resource-management-panel-Dk0DzgVm.js} +18 -18
  19. package/dist/chunks/{save-DDX_vrED.js → save-_ALpoMy6.js} +1 -1
  20. package/dist/chunks/{switch-DEPWsRhf.js → switch-B6fh8nb-.js} +25 -25
  21. package/dist/chunks/{use-create-flow-overlay-state-BHQjJwik.js → use-create-flow-overlay-state-Cqf7GaFm.js} +4 -4
  22. package/dist/chunks/{use-create-flow-overlay-state-7LiC_vaL.js → use-create-flow-overlay-state-DMZTflFt.js} +1 -1
  23. package/dist/chunks/{use-visual-utils-Dw-uLgop.js → use-visual-utils-CPMQLBYR.js} +12 -12
  24. package/dist/chunks/{use-visual-utils-Bz7kjSrk.js → use-visual-utils-CQQ3jvDn.js} +1 -1
  25. package/dist/dashboard/index.cjs +1 -1
  26. package/dist/dashboard/index.js +1 -1
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.js +69 -70
  29. package/dist/style.css +1 -1
  30. package/dist/surfboard/index.cjs +1 -1
  31. package/dist/surfboard/index.js +7 -8
  32. package/dist/types/main.d.ts +0 -11
  33. package/dist/types/surfboard.d.ts +0 -10
  34. package/package.json +1 -1
  35. package/dist/chunks/dashboard-controls-wPVXTTiH.js +0 -57
  36. package/dist/chunks/dashboard-summary-settings-dialog-CZkn4rtm.js +0 -545
  37. package/dist/chunks/dashboard-summary-settings-dialog-DoxcpXjk.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-DjZqoaV5.js"),e=require("../chunks/common-types-C73-Ud1-.js"),r=require("../chunks/dashboard-summary-settings-dialog-DoxcpXjk.js");exports.Surfboard=a.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=r.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=r.DashboardSummarySettingsDialog;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-XYIIY48z.js"),e=require("../chunks/common-types-C73-Ud1-.js"),a=require("../chunks/calendar-preferences-dialog-BzpQ5u4h.js");exports.Surfboard=r.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=a.CalendarPreferencesDialog;
@@ -1,10 +1,9 @@
1
- import { a as o } from "../chunks/index-D7e2Eyp_.js";
2
- import { C as s, E as C } from "../chunks/common-types-4bjoIgvm.js";
3
- import { C as E, D as f } from "../chunks/dashboard-summary-settings-dialog-CZkn4rtm.js";
1
+ import { a as e } from "../chunks/index-P5hPTTzm.js";
2
+ import { C, E } from "../chunks/common-types-4bjoIgvm.js";
3
+ import { C as s } from "../chunks/calendar-preferences-dialog-D70CuT-1.js";
4
4
  export {
5
- s as CONTROL_CARD_DEFAULT_VALUE,
6
- E as CalendarPreferencesDialog,
7
- f as DashboardSummarySettingsDialog,
8
- C as EMPTY_SELECTION,
9
- o as Surfboard
5
+ C as CONTROL_CARD_DEFAULT_VALUE,
6
+ s as CalendarPreferencesDialog,
7
+ E as EMPTY_SELECTION,
8
+ e as Surfboard
10
9
  };
@@ -1930,16 +1930,6 @@ export declare type DashboardStore = {
1930
1930
  actions: Actions_2;
1931
1931
  };
1932
1932
 
1933
- export declare function DashboardSummarySettingsDialog({ open, onOpenChange, dashboard, onApply, disabled, }: DashboardSummarySettingsDialogProps): JSX.Element;
1934
-
1935
- declare type DashboardSummarySettingsDialogProps = {
1936
- open: boolean;
1937
- onOpenChange: (open: boolean) => void;
1938
- dashboard: TDashboard;
1939
- onApply: (summary: NonNullable<TDashboard['summary']>) => void;
1940
- disabled?: boolean;
1941
- };
1942
-
1943
1933
  export declare const DashboardWC: CustomElementConstructor;
1944
1934
 
1945
1935
  export declare interface DatabaseEntityReference {
@@ -6077,7 +6067,6 @@ export declare function useDashboardSummary(): {
6077
6067
  isRefreshing: boolean;
6078
6068
  applyAction: (action: SummaryAction) => Promise<void>;
6079
6069
  enabled: boolean;
6080
- maxItems: number;
6081
6070
  };
6082
6071
 
6083
6072
  export declare function useDataColumns(token?: AuthToken): {
@@ -798,16 +798,6 @@ export declare type DashboardProps = {
798
798
  preferences?: DashboardPreferences;
799
799
  };
800
800
 
801
- export declare function DashboardSummarySettingsDialog({ open, onOpenChange, dashboard, onApply, disabled, }: DashboardSummarySettingsDialogProps): JSX.Element;
802
-
803
- declare type DashboardSummarySettingsDialogProps = {
804
- open: boolean;
805
- onOpenChange: (open: boolean) => void;
806
- dashboard: TDashboard;
807
- onApply: (summary: NonNullable<TDashboard['summary']>) => void;
808
- disabled?: boolean;
809
- };
810
-
811
801
  declare interface DatabaseEntityReference {
812
802
  connectionId: string;
813
803
  connectionType: ConnectionType;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.313",
8
+ "version": "0.1.314",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,57 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-DPaKnsb8.js"),s=require("./index-DjZqoaV5.js"),b=require("react");require("./index-DRlMUglg.js");require("react-dom");const G=require("./dashboard-filter-controls-launcher-DBmNn4EY.js"),Zs=require("./index-D7KJindZ.js"),ds=require("./dashboard-summary-settings-dialog-DoxcpXjk.js"),et=require("./use-debounced-dirty-check-XHSwAefL.js"),Oe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),us=require("./save-B8x5Vi0W.js"),st=require("./palette-CJTdBzJB.js"),tt=require("./braces-NfG5hX2c.js");function at(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const L=at(b);/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const rt=o.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const nt=o.createLucideIcon("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const ot=o.createLucideIcon("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const it=o.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const ct=o.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
27
- * @license lucide-react v0.453.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const lt=o.createLucideIcon("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
32
- * @license lucide-react v0.453.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const dt=o.createLucideIcon("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
37
- * @license lucide-react v0.453.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Ue=o.createLucideIcon("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);var _e={exports:{}},Te={};/**
42
- * @license React
43
- * use-sync-external-store-shim.production.js
44
- *
45
- * Copyright (c) Meta Platforms, Inc. and affiliates.
46
- *
47
- * This source code is licensed under the MIT license found in the
48
- * LICENSE file in the root directory of this source tree.
49
- */var ms;function ut(){if(ms)return Te;ms=1;var t=b;function n(x,p){return x===p&&(x!==0||1/x===1/p)||x!==x&&p!==p}var r=typeof Object.is=="function"?Object.is:n,a=t.useState,c=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function m(x,p){var f=p(),i=a({inst:{value:f,getSnapshot:p}}),S=i[0].inst,D=i[1];return u(function(){S.value=f,S.getSnapshot=p,g(S)&&D({inst:S})},[x,f,p]),c(function(){return g(S)&&D({inst:S}),x(function(){g(S)&&D({inst:S})})},[x]),d(f),f}function g(x){var p=x.getSnapshot;x=x.value;try{var f=p();return!r(x,f)}catch{return!0}}function y(x,p){return p()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:m;return Te.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Te}var Pe={};/**
50
- * @license React
51
- * use-sync-external-store-shim.development.js
52
- *
53
- * Copyright (c) Meta Platforms, Inc. and affiliates.
54
- *
55
- * This source code is licensed under the MIT license found in the
56
- * LICENSE file in the root directory of this source tree.
57
- */var hs;function mt(){return hs||(hs=1,process.env.NODE_ENV!=="production"&&function(){function t(f,i){return f===i&&(f!==0||1/f===1/i)||f!==f&&i!==i}function n(f,i){h||c.startTransition===void 0||(h=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var S=i();if(!x){var D=i();u(S,D)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),x=!0)}D=d({inst:{value:S,getSnapshot:i}});var w=D[0].inst,j=D[1];return g(function(){w.value=S,w.getSnapshot=i,r(w)&&j({inst:w})},[f,S,i]),m(function(){return r(w)&&j({inst:w}),f(function(){r(w)&&j({inst:w})})},[f]),y(S),S}function r(f){var i=f.getSnapshot;f=f.value;try{var S=i();return!u(f,S)}catch{return!0}}function a(f,i){return i()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var c=b,u=typeof Object.is=="function"?Object.is:t,d=c.useState,m=c.useEffect,g=c.useLayoutEffect,y=c.useDebugValue,h=!1,x=!1,p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:n;Pe.useSyncExternalStore=c.useSyncExternalStore!==void 0?c.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Pe}process.env.NODE_ENV==="production"?_e.exports=ut():_e.exports=mt();var ht=_e.exports;const ye=["light","dark","system"];function pt(){const{theme:t,setTheme:n}=s.useTheme(),r=o.useDashboardStore(d=>d.actions.setDashboardTheme);function a(){const d=ye.includes(t)?t:"system",m=ye[(ye.indexOf(d)+1)%ye.length];n(m),r(m)}const c=t==="light"?lt:t==="dark"?it:ot,u=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(o.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":u,title:u,children:e.jsx(c,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function xt(t,n,r,a,c){if(!c)return null;const u=JSON.stringify(r),d=`${t}/v1/lens`;return await o.postRequest(d,c,{name:n,template:u,filterValues:a,operation:"create"})}async function Re(t,n,r){if(!r)return null;const{id:a,template:c,filterValues:u,isDefault:d,shared:m}=n,g=`${t}/v1/lens`;return await o.postRequest(g,r,{lensId:a,template:c,filterValues:u,isDefault:d,shared:m,operation:"update"})}async function ft(t,n,r){if(!r)return null;const a=`${t}/v1/lens`;return await o.postRequest(a,r,{operation:"delete",lensId:n})}const gt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function bt({open:t,onOpenChange:n}={}){const[r,a]=b.useState(""),[c,u]=b.useState(!1),d=o.useDashboardStore(C=>C.lenses),{setLenses:m,setSelectedLensId:g}=o.useDashboardActions(),[y,h]=b.useState(!1),[x,p]=b.useState(!1),f=t!==void 0,i=f?t:x,S=C=>{f||p(C),n==null||n(C)},D=o.useDashboardStore(C=>C.dashboard),w=o.useDashboardStore(C=>C.filterValues),{authToken:j,tokenProps:N}=s.useSemaphorContext();async function A(){h(!0);const C=await xt(N.apiServiceUrl,r,D,w,j==null?void 0:j.accessToken);C&&(m([...d||[],C]),g(C.id),S(!1)),h(!1)}return e.jsxs(s.Dialog,{open:i,onOpenChange:S,children:[f?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(o.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Lenses are private by default and are only visible to you."})]}),e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(o.Label,{htmlFor:"lens-name",className:gt,children:"Name"}),e.jsx(o.Input,{id:"lens-name",size:"xs",value:r,placeholder:"Monthly review, West region, …",onChange:C=>a(C.target.value)}),c&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(o.Button,{variant:"outline",size:"xs",onClick:()=>S(!1),children:"Cancel"}),e.jsx(o.Button,{size:"xs",type:"submit",onClick:A,disabled:y||!r.trim(),children:y?"Creating…":"Create"})]})]})]})}function vt({includeLabel:t=!1}={}){const n=o.useDashboardStore(h=>h.lenses),r=o.useDashboardStore(h=>h.selectedLensId),{setLenses:a,setSelectedLensId:c}=o.useDashboardActions(),{authToken:u,tokenProps:d}=s.useSemaphorContext();async function m(h){c(h)}async function g(h){if(await ft(d.apiServiceUrl,h,u==null?void 0:u.accessToken)){const p=n==null?void 0:n.filter(f=>f.id!==h);a(p||[]),c("original")}}async function y(h){const x=n==null?void 0:n.map(i=>i.id===h.id?{...i,isDefault:!h.isDefault}:{...i,isDefault:!1});a(x||[]);const p={...h,isDefault:!h.isDefault};await Re(d.apiServiceUrl,p,u==null?void 0:u.accessToken);const f=n==null?void 0:n.find(i=>i.isDefault);if(f&&f.id!==h.id){const i={...f,isDefault:!1};await Re(d.apiServiceUrl,i,u==null?void 0:u.accessToken)}}return e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{})]}):null,e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:m,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(h=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:h.id,children:[e.jsx("p",{children:h.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:x=>{x.preventDefault(),y(h)},className:o.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!h.isDefault,"text-green-500":h.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:x=>{x.preventDefault(),g(h.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},h.id))]})]})}function yt(){const{displayPreferences:t,shouldShowElement:n}=s.useDisplayPreferences(),{currentUser:r,userContext:a}=s.useCurrentUserInfo(),c=b.useMemo(()=>s.getRoleBasedDisplayOverrides(r),[r]),u=b.useMemo(()=>m=>c&&c[m]!==void 0&&c[m]===!1?!1:n(m),[c,n,t]),d=b.useMemo(()=>{var m,g,y,h,x;return{canEdit:((m=a==null?void 0:a.permissions)==null?void 0:m.canEdit)??s.canUserEdit(r),canUseFilters:((g=a==null?void 0:a.permissions)==null?void 0:g.canEdit)??s.canUserUseFilters(r),canManageDashboards:((y=a==null?void 0:a.permissions)==null?void 0:y.canCreateDashboard)??s.canUserManageDashboards(r),canCreateDashboards:((h=a==null?void 0:a.permissions)==null?void 0:h.canCreateDashboard)??s.canUserCreateDashboards(r),canAccessVisuals:((x=a==null?void 0:a.permissions)==null?void 0:x.canEdit)??s.canUserAccessVisuals(r)}},[r,a]);return{displayPreferences:t,shouldShowElement:u,permissions:d,currentUser:r}}const St=async(t,n,r)=>{const a=`${t}/management/v1/groups`;return await o.postRequestRegular(a,n,r)},jt=async(t,n,r)=>{const a=`${t}/management/v1/groups/${r}`;await o.requestJsonRegular(a,n,"DELETE")},Dt=async(t,n,r,a)=>{const c=`${t}/management/v1/groups/${r}/members`;return await o.postRequestRegular(c,n,a)},wt=async(t,n,r,a)=>{const c=`${t}/management/v1/groups/${r}/members`;await o.requestJsonRegular(c,n,"DELETE",a)};function Nt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>St(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:()=>{r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:a=>{console.error("Failed to create group:",a),s.ue.error("Failed to create group",{description:o.getRequestErrorMessage(a,"Failed to create group")})}})}function Ct(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>jt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:(a,c)=>{r.invalidateQueries({queryKey:["groups"]}),r.removeQueries({queryKey:["group",c]}),s.ue.success("Group deleted successfully")},onError:a=>{console.error("Failed to delete group:",a),s.ue.error("Failed to delete group",{description:o.getRequestErrorMessage(a,"Failed to delete group")})}})}function Mt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:c})=>Dt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,c),onSuccess:(a,c)=>{r.invalidateQueries({queryKey:["group",c.groupId]}),r.invalidateQueries({queryKey:["group-members",c.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:a=>{console.error("Failed to add group members:",a),s.ue.error("Failed to add members",{description:o.getRequestErrorMessage(a,"Failed to add members")})}})}function Lt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:c})=>wt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,c),onSuccess:(a,c)=>{r.invalidateQueries({queryKey:["group",c.groupId]}),r.invalidateQueries({queryKey:["group-members",c.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:a=>{console.error("Failed to remove group members:",a),s.ue.error("Failed to remove members",{description:o.getRequestErrorMessage(a,"Failed to remove members")})}})}const ps="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Et({onSuccess:t,tenantId:n,isTenantUser:r}){const[a,c]=b.useState(""),[u,d]=b.useState(""),[m,g]=b.useState({}),y=Nt(),h=()=>{const p={};return a.trim()?a.length<3?p.name="Group name must be at least 3 characters":a.length>50&&(p.name="Group name must be less than 50 characters"):p.name="Group name is required",u&&u.length>200&&(p.description="Description must be less than 200 characters"),g(p),Object.keys(p).length===0},x=async p=>{if(p.preventDefault(),!h())return;const f={name:a.trim(),description:u.trim()||void 0,type:r?"TENANT_GROUP":"ORG_GROUP",...r&&n?{tenantId:n}:{}};try{await y.mutateAsync(f),c(""),d(""),g({}),t()}catch(i){console.error("Failed to create group:",i)}};return e.jsxs("form",{onSubmit:x,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(o.Label,{htmlFor:"group-name",className:ps,children:["Group name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(o.Input,{id:"group-name",size:"xs",placeholder:"e.g., Marketing Team, Engineering Squad",value:a,onChange:p=>{c(p.target.value),m.name&&g(f=>({...f,name:""}))},className:m.name?"border-destructive":"",disabled:y.isPending}),m.name&&e.jsx("p",{className:"text-[12px] text-destructive",children:m.name})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{htmlFor:"group-description",className:ps,children:"Description (optional)"}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group…",value:u,onChange:p=>{d(p.target.value),m.description&&g(f=>({...f,description:""}))},className:`text-[13px] ${m.description?"border-destructive":""}`,disabled:y.isPending,rows:3}),m.description?e.jsx("p",{className:"text-[12px] text-destructive",children:m.description}):e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[u.length,"/200"]})]}),e.jsxs("div",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[e.jsx(o.Info,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),e.jsx("p",{children:"This group will be accessible to users in your workspace. You can add members after creating it."})]}),e.jsxs("div",{className:"flex justify-end gap-1.5 pt-1",children:[e.jsx(o.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>{c(""),d(""),g({})},disabled:y.isPending,children:"Clear"}),e.jsx(o.Button,{type:"submit",size:"xs",disabled:y.isPending||!a.trim(),children:y.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating…"]}):"Create group"})]})]})}function It(t,n=[]){let r=[];function a(u,d){const m=L.createContext(d);m.displayName=u+"Context";const g=r.length;r=[...r,d];const y=x=>{var w;const{scope:p,children:f,...i}=x,S=((w=p==null?void 0:p[t])==null?void 0:w[g])||m,D=L.useMemo(()=>i,Object.values(i));return e.jsx(S.Provider,{value:D,children:f})};y.displayName=u+"Provider";function h(x,p){var S;const f=((S=p==null?void 0:p[t])==null?void 0:S[g])||m,i=L.useContext(f);if(i)return i;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${u}\``)}return[y,h]}const c=()=>{const u=r.map(d=>L.createContext(d));return function(m){const g=(m==null?void 0:m[t])||u;return L.useMemo(()=>({[`__scope${t}`]:{...m,[t]:g}}),[m,g])}};return c.scopeName=t,[a,At(c,...n)]}function At(...t){const n=t[0];if(t.length===1)return n;const r=()=>{const a=t.map(c=>({useScope:c(),scopeName:c.scopeName}));return function(u){const d=a.reduce((m,{useScope:g,scopeName:y})=>{const x=g(u)[`__scope${y}`];return{...m,...x}},{});return L.useMemo(()=>({[`__scope${n.scopeName}`]:d}),[d])}};return r.scopeName=n.scopeName,r}var kt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fe=kt.reduce((t,n)=>{const r=o.createSlot(`Primitive.${n}`),a=L.forwardRef((c,u)=>{const{asChild:d,...m}=c,g=d?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(g,{...m,ref:u})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{});function Ot(){return ht.useSyncExternalStore(Tt,()=>!0,()=>!1)}function Tt(){return()=>{}}var Ge="Avatar",[Pt]=It(Ge),[Ut,gs]=Pt(Ge),bs=L.forwardRef((t,n)=>{const{__scopeAvatar:r,...a}=t,[c,u]=L.useState("idle");return e.jsx(Ut,{scope:r,imageLoadingStatus:c,onImageLoadingStatusChange:u,children:e.jsx(Fe.span,{...a,ref:n})})});bs.displayName=Ge;var vs="AvatarImage",ys=L.forwardRef((t,n)=>{const{__scopeAvatar:r,src:a,onLoadingStatusChange:c=()=>{},...u}=t,d=gs(vs,r),m=_t(a,u),g=o.useCallbackRef(y=>{c(y),d.onImageLoadingStatusChange(y)});return o.useLayoutEffect2(()=>{m!=="idle"&&g(m)},[m,g]),m==="loaded"?e.jsx(Fe.img,{...u,ref:n,src:a}):null});ys.displayName=vs;var Ss="AvatarFallback",js=L.forwardRef((t,n)=>{const{__scopeAvatar:r,delayMs:a,...c}=t,u=gs(Ss,r),[d,m]=L.useState(a===void 0);return L.useEffect(()=>{if(a!==void 0){const g=window.setTimeout(()=>m(!0),a);return()=>window.clearTimeout(g)}},[a]),d&&u.imageLoadingStatus!=="loaded"?e.jsx(Fe.span,{...c,ref:n}):null});js.displayName=Ss;function xs(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function _t(t,{referrerPolicy:n,crossOrigin:r}){const a=Ot(),c=L.useRef(null),u=a?(c.current||(c.current=new window.Image),c.current):null,[d,m]=L.useState(()=>xs(u,t));return o.useLayoutEffect2(()=>{m(xs(u,t))},[u,t]),o.useLayoutEffect2(()=>{const g=x=>()=>{m(x)};if(!u)return;const y=g("loaded"),h=g("error");return u.addEventListener("load",y),u.addEventListener("error",h),n&&(u.referrerPolicy=n),typeof r=="string"&&(u.crossOrigin=r),()=>{u.removeEventListener("load",y),u.removeEventListener("error",h)}},[u,r,n]),d}var Ds=bs,ws=ys,Ns=js;const $e=L.forwardRef(({className:t,...n},r)=>e.jsx(Ds,{ref:r,className:o.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));$e.displayName=Ds.displayName;const Rt=L.forwardRef(({className:t,...n},r)=>e.jsx(ws,{ref:r,className:o.cn("aspect-square h-full w-full",t),...n}));Rt.displayName=ws.displayName;const qe=L.forwardRef(({className:t,...n},r)=>e.jsx(Ns,{ref:r,className:o.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));qe.displayName=Ns.displayName;function Ft({open:t,onOpenChange:n,group:r,onUpdate:a}){const[c,u]=b.useState("members"),[d,m]=b.useState(""),[g,y]=b.useState([]),[h,x]=b.useState([]),{data:p,isLoading:f,refetch:i}=s.useGroupMembers(r.id),S=r.type==="TENANT_GROUP"?"tenant":"organization",{users:D,isLoading:w}=s.useUnifiedUsers({type:S,tenantId:r.tenantId||void 0,active:!0,limit:100}),j=Mt(),N=Lt(),A=(p==null?void 0:p.members)||[],C=b.useMemo(()=>new Set(A.map(v=>v.userId)),[A]),U=b.useMemo(()=>D.filter(v=>!C.has(v.id)),[D,C]),$=b.useMemo(()=>{if(!d)return U;const v=d.toLowerCase();return U.filter(E=>{var P,R;return((P=E.name)==null?void 0:P.toLowerCase().includes(v))||((R=E.email)==null?void 0:R.toLowerCase().includes(v))})},[U,d]),M=b.useMemo(()=>{if(!d)return A;const v=d.toLowerCase();return A.filter(E=>{var P,R,te,V;return((R=(P=E.user)==null?void 0:P.name)==null?void 0:R.toLowerCase().includes(v))||((V=(te=E.user)==null?void 0:te.email)==null?void 0:V.toLowerCase().includes(v))})},[A,d]),q=async()=>{if(g.length!==0)try{await j.mutateAsync({groupId:r.id,data:{userIds:g,userType:S==="tenant"?"tenant":"org"}}),y([]),u("members"),i(),a==null||a()}catch(v){console.error("Failed to add members:",v)}},se=async()=>{if(h.length!==0)try{await N.mutateAsync({groupId:r.id,data:{userIds:h}}),x([]),i(),a==null||a()}catch(v){console.error("Failed to remove members:",v)}},z=v=>{y(E=>E.includes(v)?E.filter(P=>P!==v):[...E,v])},H=v=>{x(E=>E.includes(v)?E.filter(P=>P!==v):[...E,v])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-3xl max-h-[80vh]","aria-describedby":"group-members-description",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:r.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A.length," ",A.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",r.name," group"]})]}),e.jsxs(o.Tabs,{value:c,onValueChange:v=>{u(v),m(""),x([])},className:"mt-4",children:[e.jsxs(o.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(o.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(o.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(o.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{placeholder:"Search members...",value:d,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:h.length>0?"h-[300px]":"h-[350px]",children:f?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):M.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:d?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:d?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:M.map(v=>e.jsx(Gt,{member:v,selected:h.includes(v.userId),onToggle:()=>H(v.userId)},v.id))})}),h.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h.length," member",h.length!==1?"s":""," selected"]}),e.jsx(o.Button,{variant:"destructive",size:"sm",onClick:se,disabled:N.isPending,children:N.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(o.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{placeholder:"Search users to add...",value:d,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:"h-[300px]",children:w?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):$.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(Ue,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:d?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:$.map(v=>e.jsx($t,{user:v,selected:g.includes(v.id),onToggle:()=>z(v.id)},v.id))})}),g.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[g.length," user",g.length!==1?"s":""," selected"]}),e.jsx(o.Button,{onClick:q,disabled:j.isPending,children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function Gt({member:t,selected:n,onToggle:r}){var c,u,d,m;const a=((u=(c=t.user)==null?void 0:c.name)==null?void 0:u.split(" ").map(g=>g[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx($e,{className:"h-8 w-8",children:e.jsx(qe,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((d=t.user)==null?void 0:d.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(m=t.user)==null?void 0:m.email})]})]})}function $t({user:t,selected:n,onToggle:r}){var c;const a=((c=t.name)==null?void 0:c.split(" ").map(u=>u[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx($e,{className:"h-8 w-8",children:e.jsx(qe,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.email})]})]})}function qt({open:t,onOpenChange:n}){const[r,a]=b.useState("groups"),[c,u]=b.useState(""),[d,m]=b.useState(null),[g,y]=b.useState(!1),[h,x]=b.useState(null),{tokenProps:p}=s.useSemaphorContext(),{currentUser:f}=s.useCurrentUserInfo(),i=Ct(),S=(f==null?void 0:f.type)==="tenant",D=p==null?void 0:p.tenantId,{groups:w,isLoading:j,refetch:N}=s.useGroups({type:S?"TENANT_GROUP":"all",tenantId:S?D:void 0,includeMembers:!1}),A=w.filter(M=>{var q;return M.name.toLowerCase().includes(c.toLowerCase())||((q=M.description)==null?void 0:q.toLowerCase().includes(c.toLowerCase()))}),C=async()=>{if(h)try{await i.mutateAsync(h.id),x(null),N()}catch(M){console.error("Failed to delete group:",M)}},U=M=>{m(M),y(!0)},$=()=>{a("groups"),N()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-h-[80vh] max-w-3xl rounded-[6px] border-border/60 sm:rounded-[6px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Group management"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Manage groups, create new ones, and control membership."})]}),e.jsxs(o.Tabs,{value:r,onValueChange:a,className:"mt-2",children:[e.jsxs(o.TabsList,{className:"h-8 w-full justify-start gap-1 bg-transparent p-0 border-b border-border/60 rounded-none",children:[e.jsx(o.TabsTrigger,{value:"groups",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Groups"}),e.jsx(o.TabsTrigger,{value:"create",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Create group"})]}),e.jsx(o.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{size:"xs",placeholder:"Search groups…",value:c,onChange:M=>u(M.target.value),className:"pl-7"})]}),e.jsx(o.ScrollArea,{className:"h-[400px]",children:j?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(M=>e.jsx(s.Skeleton,{className:"h-16 w-full rounded-[6px]"},M))}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx("p",{className:"text-[13px]",children:"No groups found."}),e.jsx("p",{className:"mt-1 text-[12px]",children:c?"Try a different search.":"Create your first group to get started."})]}):e.jsx("div",{className:"space-y-2 pr-2",children:A.map(M=>e.jsx(Bt,{group:M,onManageMembers:()=>U(M),onDelete:()=>x(M),currentUserId:f==null?void 0:f.id},M.id))})})]})}),e.jsx(o.TabsContent,{value:"create",className:"mt-4",children:e.jsx(Et,{onSuccess:$,tenantId:D,isTenantUser:S})})]})]})}),d&&e.jsx(Ft,{open:g,onOpenChange:y,group:d,onUpdate:()=>N()}),e.jsx(s.AlertDialog,{open:!!h,onOpenChange:()=>x(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete group"}),e.jsxs(s.AlertDialogDescription,{children:['Delete "',h==null?void 0:h.name,`"? This removes all members and can't be undone.`]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:C,disabled:i.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete group"})]})]})})]})}function Bt({group:t,onManageMembers:n,onDelete:r,currentUserId:a}){const c=t.createdBy===a;return e.jsx("div",{className:"rounded-[6px] border border-border/60 bg-card px-3 py-2.5 transition-colors hover:bg-muted/30",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:t.name}),t.description&&e.jsx("p",{className:"text-[12px] text-muted-foreground",children:t.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(s.Users,{className:"h-3 w-3"}),t.memberCount," ",t.memberCount===1?"member":"members"]}),e.jsxs("span",{children:["Created ",Zs.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(o.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:n,title:"Manage members","aria-label":"Manage members",children:e.jsx(Ue,{className:"h-3.5 w-3.5"})}),c&&e.jsx(o.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:r,title:"Delete group","aria-label":"Delete group",children:e.jsx(s.Trash2,{className:"h-3.5 w-3.5"})})]})]})})}function Z(t,n,r){var u,d;const a=(t.controls||[]).find(m=>m.id===r);if(a)return a.label;const c=(d=(u=o.findCardById(t,n))==null?void 0:u.controls)==null?void 0:d.find(m=>m.id===r);return(c==null?void 0:c.label)||r}function ee(t,n){var r;return((r=o.findCardById(t,n))==null?void 0:r.title)||n}function zt(t){const{errors:n,dashboard:r}=t;if(!r)return n;const a=new Map;for(const c of n){const u=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(u){const[,h,x]=u,p=`${h}:${x}:missing-metric`;a.has(p)||a.set(p,`"${ee(r,h)}" has an outdated "${Z(r,h,x)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const d=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(d){const[,h,x]=d,p=`${h}:${x}:missing-group-by`;a.has(p)||a.set(p,`"${ee(r,h)}" has an outdated "${Z(r,h,x)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const m=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(m){const[,h,x]=m,p=`${h}:${x}:invalid-metric`;a.has(p)||a.set(p,`"${ee(r,h)}" has an invalid "${Z(r,h,x)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const g=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(g){const[,h,x]=g,p=`${h}:${x}:invalid-group-by`;a.has(p)||a.set(p,`"${ee(r,h)}" has an invalid "${Z(r,h,x)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const y=c.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(y){const[,h,x]=y,p=`${h}:${x}:missing-temporal-group-by`;a.has(p)||a.set(p,`"${ee(r,h)}" can no longer use "${Z(r,h,x)}" for time grain because the card does not currently group by a date field.`);continue}a.set(c,c)}return Array.from(a.values())}function fs(t,n){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(n)}}function Ht(){var as,rs,ns,os,is,cs;G.useExportRecovery(),G.useExportPolling();const{authToken:t,tokenProps:n,id:r}=s.useSemaphorContext(),{isLocalDev:a}=s.useDashboardPreferences(),{openBrandStudioPreview:c}=s.useBrandStudioPreview(),{permissions:u}=yt(),d=s.useHasDashboardId(),{isLoading:m}=s.useDashboardQuery(),g=o.useDashboardStore(l=>l.theme),y=o.useDashboardStore(l=>l.isDownloadingPdf),h=o.useDashboardStore(l=>l.dashboardAssistantDraftScopeKey),x=o.useDashboardStore(l=>l.lenses),p=o.useDashboardStore(l=>l.selectedLensId),f=x==null?void 0:x.find(l=>l.id===p),i=o.useDashboardStore(l=>l.dashboard),S=o.useDashboardStore(l=>l.selectedSheetId),D=(as=i==null?void 0:i.sheets)==null?void 0:as.find(l=>l.id===S),w=o.isDocumentSheet(D),j=w?(rs=D==null?void 0:D.document)==null?void 0:rs.page:void 0,N=o.useDashboardStore(l=>l.isDashboardEditing),{setDashboardTitle:A}=o.useDashboardStore(l=>l.actions),[C,U]=b.useState(!1),[$,M]=b.useState(!1),[q,se]=b.useState(!1),[z,H]=b.useState(!1),[v,E]=b.useState(!1),[P,R]=b.useState(!1),[te,V]=b.useState(!1),[Cs,Be]=b.useState(!1),[Ms,ae]=b.useState(!1),[re,ne]=b.useState(null),[ze,oe]=b.useState([]),[He,ie]=b.useState(!1),Ls=o.useDashboardStore(l=>l.isDashboardPanelOpen),Es=o.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),Is=o.useDashboardStore(l=>l.filterValues),O=o.useDashboardStore(l=>l.isVisualEditing);o.useEditorStore(l=>l.card);const K=s.useManagementStore(l=>l.selectedDashboard),ce=s.useManagementStore(l=>l.initialDashboard);s.useManagementStore(l=>l.selectedVisual),o.useDashboardStore(l=>l.selectedFrameId),o.useEditorStore(l=>l.frame);const le=K?(os=K==null?void 0:K.permissions)==null?void 0:os.canEdit:(ns=ce==null?void 0:ce.permissions)==null?void 0:ns.canEdit,Ve=o.useDashboardStore(l=>l.showDashboardJSON),Se=o.useDashboardStore(l=>l.onSaveFunction),{setIsDashboardEditing:Ke,setShowDashboardJSON:Qe}=o.useDashboardStore(l=>l.actions),{setInitialDashboard:We,clearSelectedDashboard:je}=s.useManagementStore(l=>l.actions),{resources:de}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:De}=s.useUserPreferences(),As=((is=De==null?void 0:De.preference)==null?void 0:is.defaultDashboardId)||null,{mutate:ks,isPending:Os}=s.useDefaultDashboardMutation(),{currentUser:Ts}=s.useCurrentUserInfo(),Ps=s.canUserManageGroups(Ts),B=K||ce,Je=B?{id:B.id,title:(i==null?void 0:i.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:Us}=s.useAddNewFrame(),[we,Ne]=b.useState(!1),[_s,Q]=b.useState(!1),[Ce,ue]=b.useState("close"),W=s.useUpdateResource(s.ResourceType.DASHBOARD),[T,me]=b.useState(null),Rs=async(l,I)=>{if(!(i!=null&&i.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:i.id,newTitle:l,previousTitle:I}),W.mutate({resourceId:i.id,data:{title:l}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:_=>{console.error("Failed to update dashboard title:",_),s.ue.error("Failed to update dashboard title"),A(I)}})};b.useEffect(()=>{if(de&&de.length>0){const l=i==null?void 0:i.id;if(l){const I=de.find(_=>_.id===l);I&&We(I)}}},[de,i==null?void 0:i.id,We]);const J=n.orgUserId||n.tenantId,Me=b.useMemo(()=>Vt({accessToken:t==null?void 0:t.accessToken,dashboardId:(i==null?void 0:i.id)||r||n.dashboard_id,selectedSheetId:w?S:void 0,pageSize:j==null?void 0:j.size,orientation:j==null?void 0:j.orientation,theme:g}),[t==null?void 0:t.accessToken,r,i==null?void 0:i.id,w,j==null?void 0:j.orientation,j==null?void 0:j.size,S,g,n.dashboard_id]),Ye=N&&!O&&J&&le,{setDashboard:Le}=o.useDashboardStore(l=>l.actions),Ee=o.useDashboardStore(l=>l.semanticExecutionPayload),Fs=()=>{Ke(!0)},Ie=()=>{Ke(!1),Qe(!1),me(null)};b.useEffect(()=>{if(!N){T&&me(null);return}T||!i||m||me(fs(i,Ee))},[i,T,N,m,Ee]);const he=(T==null?void 0:T.dashboard)??null,{isDirty:Xe,isDirtyPending:Gs,resetDirty:pe}=et.useDebouncedDirtyCheck(i,he,300,1e3,Oe.serializeDashboardForDirtyCheck),Ze=b.useCallback(()=>he?Oe.serializeDashboardForDirtyCheck(i)!==Oe.serializeDashboardForDirtyCheck(he):!1,[i,he]),es=Xe||Gs,xe=we||W.isPending,$s=()=>{Ze()?(ue("close"),Q(!0)):(Ie(),pe())},qs=async()=>{await Ae({closeAfterSave:!0,navigateHomeAfterSave:Ce==="home"})},Bs=()=>{T&&Le(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),Ie(),Ce==="home"&&je(),ue("close"),Q(!1),pe()},zs=()=>{T&&(Le(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),pe())},Hs=()=>{if(N&&Ze()){ue("home"),Q(!0);return}je()};async function Ae(l){const I=o.useDashboardStore.getState().dashboard;if(!I)return;const _=(l==null?void 0:l.closeAfterSave)??He,Js=(l==null?void 0:l.navigateHomeAfterSave)??!1;ie(_),_&&Q(!1);const Ys=s.cloneDeep(I);ae(!0),ne(null),oe([]),Ne(!0);const Xs={template:I};W.mutate({resourceId:I.id,data:Xs},{onSuccess:k=>{var ge,be,ls;const F=(k==null?void 0:k.id)||((ge=k==null?void 0:k.dashboard)==null?void 0:ge.id)||((be=k==null?void 0:k.resource)==null?void 0:be.id)||((ls=k==null?void 0:k.template)==null?void 0:ls.id)||null;if(!I.id&&F){const ke=o.useAIInteractionStore.getState(),ve=ke.pendingDashboardDraftMigration;(ve==null?void 0:ve.scopeKey)===h?ke.actions.setPendingDashboardDraftMigrationExpectedDashboardId(F):ve&&ke.actions.clearPendingDashboardDraftMigration()}Ne(!1),s.ue.success("Dashboard saved!"),me(fs(Ys,o.useDashboardStore.getState().semanticExecutionPayload)),ae(!1),ie(!1),_&&(Ie(),pe(),Js&&je()),ue("close")},onError:k=>{Ne(!1),ne("Failed to save dashboard. Please try again.");const F=k.details,ge=Array.isArray(F==null?void 0:F.errors)?(F.errors||[]).filter(be=>typeof be=="string"):[];oe(zt({errors:ge,dashboard:I||void 0})),s.ue.error("Failed to save dashboard")}})}async function Vs(){if(U(!0),!p||!f)return;const l=o.useDashboardStore.getState().dashboard;if(!l){U(!1);return}const I=JSON.stringify(l),_={...f,template:I,filterValues:Is};await Re(n.apiServiceUrl,_,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Se==null||Se(l),U(!1)}const ss=(f==null?void 0:f.name)||i.title,Y=!!(i!=null&&i.id);W.isPending&&console.log("Title during update:",{title:ss,dashboardStateTitle:i.title,dashboardId:i==null?void 0:i.id,currentLensName:f==null?void 0:f.name});const ts=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,Ks=!!ts&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl);b.useEffect(()=>{!Y&&z&&H(!1)},[Y,z]);const Qs=d,X=(i==null?void 0:i.id)||null,fe=!!X&&As===X,Ws=()=>{X&&ks({dashboardId:fe?null:X})};return e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[ts&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{Es(!Ls)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(nt,{className:"h-3.5 w-3.5"})}),Qs&&!O&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Hs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!O&&d&&(m?e.jsx("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","aria-label":"Loading dashboard title",role:"status",children:e.jsx("span",{className:"sr-only",children:"Loading dashboard title"})}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:ss||"Untitled Dashboard",onSave:l=>{console.log("EditableText onSave called:",{newTitle:l,canEditDashboard:le,dashboardId:i==null?void 0:i.id});const I=(i==null?void 0:i.title)||"";A(l),Rs(l,I)},isEditable:le&&!f,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:W.isPending}),Ks&&X&&e.jsx(o.TooltipProvider,{children:e.jsxs(o.Tooltip,{children:[e.jsx(o.TooltipTrigger,{asChild:!0,children:e.jsx(o.Button,{variant:"ghost",size:"xs",onClick:Ws,disabled:Os||!(t!=null&&t.accessToken)||!(n!=null&&n.apiServiceUrl),className:"w-7 px-0","aria-label":fe?"Remove as default dashboard":"Make this a default dashboard",children:e.jsx(s.Star,{className:o.cn("h-3.5 w-3.5 transition-colors",fe?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(o.TooltipContent,{children:e.jsx("p",{children:fe?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[O&&e.jsxs(e.Fragment,{children:[e.jsx(G.AdvancedModeToggle,{}),e.jsx(G.VisualEditingControls,{})]}),!O&&d&&((cs=B==null?void 0:B.permissions)==null?void 0:cs.canShare)&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:()=>M(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!O&&N&&u.canUseFilters&&d&&e.jsx(G.DashboardFilterControlsLauncher,{}),N&&!O&&J&&f&&a&&d&&e.jsxs(o.Button,{variant:"secondary",size:"xs",disabled:C,onClick:Vs,children:[e.jsx(us.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),N&&!O&&d&&!w&&e.jsxs(o.Button,{variant:"outline",size:"xs",disabled:!N,onClick:()=>Us(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!O&&!N&&le&&d&&e.jsxs(o.Button,{size:"xs",onClick:Fs,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Ye&&d&&Xe&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:zs,disabled:xe,children:[e.jsx(dt,{className:"h-3.5 w-3.5"}),"Undo"]}),Ye&&d&&e.jsxs(o.Button,{size:"xs",className:o.cn(!es&&"opacity-60"),disabled:xe||!es,onClick:()=>Ae(),children:[xe?e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(us.Save,{className:"h-3.5 w-3.5"}),xe?"Saving...":"Save"]}),N&&!O&&d&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:$s,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!O&&d&&e.jsx("div",{className:"ml-2",children:e.jsx(G.NotificationBell,{})}),!O&&a&&e.jsx(pt,{}),!O&&d&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:y,onSelect:()=>Be(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsxs(s.DropdownMenuItem,{disabled:!Y,onSelect:()=>{Y&&H(!0)},children:[e.jsx(s.Clock,{className:"h-3.5 w-3.5"}),"Schedule"]}),e.jsx(s.DropdownMenuSeparator,{}),Ps&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>se(!0),children:[e.jsx(s.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>E(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>R(!0),children:[e.jsx(s.FileText,{className:"h-3.5 w-3.5"}),"Summary Settings"]}),a&&d&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var l;t!=null&&t.accessToken&&((l=navigator==null?void 0:navigator.clipboard)!=null&&l.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),w&&e.jsxs(s.DropdownMenuItem,{disabled:!Me,onSelect:()=>{var l;if(!Me){s.ue.error("Open a document sheet with a token to copy the local PDF URL");return}(l=navigator==null?void 0:navigator.clipboard)!=null&&l.writeText?navigator.clipboard.writeText(Me).then(()=>s.ue.success("Local document PDF URL copied to clipboard")).catch(()=>s.ue.error("Unable to copy local document PDF URL")):s.ue.error("Clipboard not available")},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>o.invalidateToken(n.apiServiceUrl),children:[e.jsx(ct,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:c,children:[e.jsx(st.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Qe(!Ve),children:[e.jsx(tt.Braces,{className:"h-3.5 w-3.5"}),Ve?"Hide dashboard JSON":"Show dashboard JSON"]}),J&&N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>V(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),J&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(rt,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(vt,{})})]})]})]})]}),$&&Je&&e.jsx(s.ShareDialog,{resource:Je,resourceType:s.ResourceType.DASHBOARD,onClose:()=>M(!1)}),e.jsx(qt,{open:q,onOpenChange:se}),Y&&(i==null?void 0:i.id)&&e.jsx(s.EmailScheduleDialog,{open:z,onOpenChange:H,dashboardId:i.id,dashboardName:i==null?void 0:i.title}),e.jsx(ds.CalendarPreferencesDialog,{open:v,onOpenChange:E}),e.jsx(ds.DashboardSummarySettingsDialog,{open:P,onOpenChange:R,dashboard:i,disabled:!N,onApply:l=>Le({...i,summary:l},{semanticExecutionPayload:Ee})}),a&&J&&d&&e.jsx(bt,{open:te,onOpenChange:V}),d&&e.jsx(s.DownloadPdf,{open:Cs,onOpenChange:Be}),e.jsx(s.AlertDialog,{open:Ms,onOpenChange:l=>{!l&&we&&!re||(ae(l),l||(ne(null),oe([]),ie(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:re?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:re?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),ze.length>0&&e.jsxs("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:ze.slice(0,5).map(l=>e.jsx("li",{children:l},l))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:re?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{ae(!1),ne(null),oe([]),ie(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Ae({closeAfterSave:He,navigateHomeAfterSave:Ce==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(G.UnsavedChangesAlert,{open:_s,onOpenChange:l=>{Q(l)},onSave:qs,onDiscard:Bs,isSaving:we,saveLabel:"Save",discardLabel:"Discard"})]})]})}function Vt({accessToken:t,dashboardId:n,selectedSheetId:r,pageSize:a,orientation:c,theme:u}){if(!t||!r)return null;const d=new URL("http://localhost:5173/print-document");d.searchParams.set("token",t),n&&d.searchParams.set("dashboardId",n),d.searchParams.set("selectedSheetId",r),u&&d.searchParams.set("theme",u);const m=new URL("http://127.0.0.1:3002/");return m.searchParams.set("pdfMode","document"),m.searchParams.set("pageSize",a||"letter"),m.searchParams.set("orientation",c||"portrait"),m.searchParams.set("url",d.toString()),m.toString()}exports.default=Ht;