react-semaphor 0.1.376 → 0.1.377
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.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +47 -43
- package/dist/brand-studio/index.cjs +4 -4
- package/dist/brand-studio/index.js +10 -8
- package/dist/chunks/braces-C2uBgj3t.js +6 -0
- package/dist/chunks/braces-CkXyWzRh.js +23 -0
- package/dist/chunks/{calendar-preferences-dialog-B6fsethx.js → calendar-preferences-dialog-C55VOTIy.js} +6 -5
- package/dist/chunks/calendar-preferences-dialog-DAukJOaP.js +1 -0
- package/dist/chunks/catalog-field-grounding-BGW0hnB9.js +1 -0
- package/dist/chunks/catalog-field-grounding-DHXEI7cW.js +199 -0
- package/dist/chunks/{chevrons-up-down-lahj6tQy.js → chevrons-up-down-BnzChFLU.js} +1 -1
- package/dist/chunks/{chevrons-up-down-D2fZD4N_.js → chevrons-up-down-W0nzHzx0.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-BKCRO7Qw.js → dashboard-briefing-launcher-CUyeiL_T.js} +3153 -2392
- package/dist/chunks/dashboard-briefing-launcher-DMKfG_z3.js +111 -0
- package/dist/chunks/dashboard-controls-B4hxFc3Q.js +2279 -0
- package/dist/chunks/dashboard-controls-D4vI0wvU.js +52 -0
- package/dist/chunks/dashboard-json-DQnm6daE.js +1 -0
- package/dist/chunks/{dashboard-json-QT0T2ad_.js → dashboard-json-pl1_mFqJ.js} +14 -13
- package/dist/chunks/{edit-dashboard-visual-kNoMQRmH.js → edit-dashboard-visual-CF4aSsav.js} +1489 -1488
- package/dist/chunks/{edit-dashboard-visual-DNzPgXMh.js → edit-dashboard-visual-CjTXY51a.js} +1 -1
- package/dist/chunks/{index-CPpqPJba.js → index-B2kPleRS.js} +4 -4
- package/dist/chunks/{index-DX_0OcRv.js → index-Bn866BBY.js} +67 -67
- package/dist/chunks/layout-grid-BFmJ7vmH.js +16 -0
- package/dist/chunks/layout-grid-CTOW9oTg.js +6 -0
- package/dist/chunks/{palette-BcHHAmOU.js → palette-DrhPeer-.js} +1 -1
- package/dist/chunks/{palette-2HWSR5wb.js → palette-OFaniMPn.js} +1 -1
- package/dist/chunks/{save-MoF1T13_.js → save-BxWBiQv1.js} +1 -1
- package/dist/chunks/{save-B-YfAPhu.js → save-Dh6gSC4x.js} +1 -1
- package/dist/chunks/{switch-DmE_MY3L.js → switch-C-fGjxjY.js} +1 -1
- package/dist/chunks/{switch-CmHP5dT7.js → switch-D5xopzFD.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-BLPQgGuz.js → use-create-flow-overlay-state-Dg2ffpCE.js} +2 -2
- package/dist/chunks/{use-create-flow-overlay-state-D_Ntx-_C.js → use-create-flow-overlay-state-DrKP0jWE.js} +113 -112
- package/dist/chunks/{validation-1V7bWmYw.js → validation-BHFaWDU-.js} +1 -1
- package/dist/chunks/{validation-DlrTIf1N.js → validation-bMedDBOo.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +22 -21
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +127 -125
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +84 -0
- package/dist/types/main.d.ts +7 -0
- package/package.json +1 -1
- package/dist/chunks/calendar-preferences-dialog-Dh1b0ytN.js +0 -1
- package/dist/chunks/catalog-field-grounding-DoEBOXQd.js +0 -100
- package/dist/chunks/catalog-field-grounding-Du6mKDcF.js +0 -1
- package/dist/chunks/dashboard-briefing-launcher-Gv1cwT0I.js +0 -111
- package/dist/chunks/dashboard-controls-BDJZarV7.js +0 -52
- package/dist/chunks/dashboard-controls-CchLBVDv.js +0 -3037
- package/dist/chunks/dashboard-json-ZhIEMXN0.js +0 -1
- package/dist/chunks/layout-grid-BOTLt36V.js +0 -36
- package/dist/chunks/layout-grid-CS6BSCJF.js +0 -11
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./switch-CmHP5dT7.js"),s=require("./index-CPpqPJba.js");require("./index-BxM99sFL.js");const j=require("react");require("./index-DRlMUglg.js");const ns=require("react-dom"),$=require("./dashboard-briefing-launcher-Gv1cwT0I.js"),yt=require("./index-D7KJindZ.js"),as=require("./calendar-preferences-dialog-Dh1b0ytN.js"),os=require("./use-debounced-dirty-check-XHSwAefL.js"),qe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),_e=require("./layout-grid-CS6BSCJF.js"),is=require("./use-create-flow-overlay-state-BLPQgGuz.js"),xt=require("./save-MoF1T13_.js"),ls=require("./palette-BcHHAmOU.js");function ds(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(r,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return r.default=t,Object.freeze(r)}const A=ds(j);/**
|
|
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 cs=i.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 us=i.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"}]]);/**
|
|
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 ms=i.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
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 hs=i.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"}]]);/**
|
|
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 xs=i.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"}]]);/**
|
|
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 ps=i.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"}]]);/**
|
|
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 jt=i.createLucideIcon("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var Ke={exports:{}},Ge={};/**
|
|
37
|
-
* @license React
|
|
38
|
-
* use-sync-external-store-shim.production.js
|
|
39
|
-
*
|
|
40
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
41
|
-
*
|
|
42
|
-
* This source code is licensed under the MIT license found in the
|
|
43
|
-
* LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/var pt;function fs(){if(pt)return Ge;pt=1;var t=j;function r(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var a=typeof Object.is=="function"?Object.is:r,n=t.useState,o=t.useEffect,u=t.useLayoutEffect,p=t.useDebugValue;function c(m,g){var h=g(),f=n({inst:{value:h,getSnapshot:g}}),d=f[0].inst,S=f[1];return u(function(){d.value=h,d.getSnapshot=g,b(d)&&S({inst:d})},[m,h,g]),o(function(){return b(d)&&S({inst:d}),m(function(){b(d)&&S({inst:d})})},[m]),p(h),h}function b(m){var g=m.getSnapshot;m=m.value;try{var h=g();return!a(m,h)}catch{return!0}}function v(m,g){return g()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:c;return Ge.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,Ge}var He={};/**
|
|
45
|
-
* @license React
|
|
46
|
-
* use-sync-external-store-shim.development.js
|
|
47
|
-
*
|
|
48
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
49
|
-
*
|
|
50
|
-
* This source code is licensed under the MIT license found in the
|
|
51
|
-
* LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/var ft;function gs(){return ft||(ft=1,process.env.NODE_ENV!=="production"&&function(){function t(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}function r(h,f){l||o.startTransition===void 0||(l=!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 d=f();if(!m){var S=f();u(d,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}S=p({inst:{value:d,getSnapshot:f}});var N=S[0].inst,k=S[1];return b(function(){N.value=d,N.getSnapshot=f,a(N)&&k({inst:N})},[h,d,f]),c(function(){return a(N)&&k({inst:N}),h(function(){a(N)&&k({inst:N})})},[h]),v(d),d}function a(h){var f=h.getSnapshot;h=h.value;try{var d=f();return!u(h,d)}catch{return!0}}function n(h,f){return f()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=j,u=typeof Object.is=="function"?Object.is:t,p=o.useState,c=o.useEffect,b=o.useLayoutEffect,v=o.useDebugValue,l=!1,m=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;He.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:g,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),He}process.env.NODE_ENV==="production"?Ke.exports=fs():Ke.exports=gs();var bs=Ke.exports;const Re=["light","dark","system"];function vs(){const{theme:t,setTheme:r}=s.useTheme(),a=i.useDashboardStore(p=>p.actions.setDashboardTheme);function n(){const p=Re.includes(t)?t:"system",c=Re[(Re.indexOf(p)+1)%Re.length];r(c),a(c)}const o=t==="light"?xs:t==="dark"?ms:us,u=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(i.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:n,"aria-label":u,title:u,children:e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function ys(t,r,a,n,o){if(!o)return null;const u=JSON.stringify(a),p=`${t}/v1/lens`;return await i.postRequest(p,o,{name:r,template:u,filterValues:n,operation:"create"})}async function Qe(t,r,a){if(!a)return null;const{id:n,template:o,filterValues:u,isDefault:p,shared:c}=r,b=`${t}/v1/lens`;return await i.postRequest(b,a,{lensId:n,template:o,filterValues:u,isDefault:p,shared:c,operation:"update"})}async function js(t,r,a){if(!a)return null;const n=`${t}/v1/lens`;return await i.postRequest(n,a,{operation:"delete",lensId:r})}const ws="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Ss({open:t,onOpenChange:r}={}){const[a,n]=j.useState(""),[o,u]=j.useState(!1),p=i.useDashboardStore(D=>D.lenses),{setLenses:c,setSelectedLensId:b}=i.useDashboardActions(),[v,l]=j.useState(!1),[m,g]=j.useState(!1),h=t!==void 0,f=h?t:m,d=D=>{h||g(D),r==null||r(D)},S=i.useDashboardStore(D=>D.dashboard),N=i.useDashboardStore(D=>D.filterValues),{authToken:k,tokenProps:E}=s.useSemaphorContext();async function L(){l(!0);const D=await ys(E.apiServiceUrl,a,S,N,k==null?void 0:k.accessToken);D&&(c([...p||[],D]),b(D.id),d(!1)),l(!1)}return e.jsxs(s.Dialog,{open:f,onOpenChange:d,children:[h?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(i.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(i.Label,{htmlFor:"lens-name",className:ws,children:"Name"}),e.jsx(i.Input,{id:"lens-name",size:"xs",value:a,placeholder:"Monthly review, West region, …",onChange:D=>n(D.target.value)}),o&&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(i.Button,{variant:"outline",size:"xs",onClick:()=>d(!1),children:"Cancel"}),e.jsx(i.Button,{size:"xs",type:"submit",onClick:L,disabled:v||!a.trim(),children:v?"Creating…":"Create"})]})]})]})}function Ns({includeLabel:t=!1}={}){const r=i.useDashboardStore(l=>l.lenses),a=i.useDashboardStore(l=>l.selectedLensId),{setLenses:n,setSelectedLensId:o}=i.useDashboardActions(),{authToken:u,tokenProps:p}=s.useSemaphorContext();async function c(l){o(l)}async function b(l){if(await js(p.apiServiceUrl,l,u==null?void 0:u.accessToken)){const g=r==null?void 0:r.filter(h=>h.id!==l);n(g||[]),o("original")}}async function v(l){const m=r==null?void 0:r.map(f=>f.id===l.id?{...f,isDefault:!l.isDefault}:{...f,isDefault:!1});n(m||[]);const g={...l,isDefault:!l.isDefault};await Qe(p.apiServiceUrl,g,u==null?void 0:u.accessToken);const h=r==null?void 0:r.find(f=>f.isDefault);if(h&&h.id!==l.id){const f={...h,isDefault:!1};await Qe(p.apiServiceUrl,f,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:a,onValueChange:c,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),r==null?void 0:r.map(l=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:l.id,children:[e.jsx("p",{children:l.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:m=>{m.preventDefault(),v(l)},className:i.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!l.isDefault,"text-green-500":l.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:m=>{m.preventDefault(),b(l.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},l.id))]})]})}function Ds(){const{displayPreferences:t,shouldShowElement:r}=s.useDisplayPreferences(),{currentUser:a,userContext:n}=s.useCurrentUserInfo(),o=j.useMemo(()=>s.getRoleBasedDisplayOverrides(a),[a]),u=j.useMemo(()=>c=>o&&o[c]!==void 0&&o[c]===!1?!1:r(c),[o,r,t]),p=j.useMemo(()=>{var c,b,v,l,m;return{canEdit:((c=n==null?void 0:n.permissions)==null?void 0:c.canEdit)??s.canUserEdit(a),canUseFilters:((b=n==null?void 0:n.permissions)==null?void 0:b.canEdit)??s.canUserUseFilters(a),canManageDashboards:((v=n==null?void 0:n.permissions)==null?void 0:v.canCreateDashboard)??s.canUserManageDashboards(a),canCreateDashboards:((l=n==null?void 0:n.permissions)==null?void 0:l.canCreateDashboard)??s.canUserCreateDashboards(a),canAccessVisuals:((m=n==null?void 0:n.permissions)==null?void 0:m.canEdit)??s.canUserAccessVisuals(a)}},[a,n]);return{displayPreferences:t,shouldShowElement:u,permissions:p,currentUser:a}}function Cs(t,r=[]){let a=[];function n(u,p){const c=A.createContext(p);c.displayName=u+"Context";const b=a.length;a=[...a,p];const v=m=>{var N;const{scope:g,children:h,...f}=m,d=((N=g==null?void 0:g[t])==null?void 0:N[b])||c,S=A.useMemo(()=>f,Object.values(f));return e.jsx(d.Provider,{value:S,children:h})};v.displayName=u+"Provider";function l(m,g){var d;const h=((d=g==null?void 0:g[t])==null?void 0:d[b])||c,f=A.useContext(h);if(f)return f;if(p!==void 0)return p;throw new Error(`\`${m}\` must be used within \`${u}\``)}return[v,l]}const o=()=>{const u=a.map(p=>A.createContext(p));return function(c){const b=(c==null?void 0:c[t])||u;return A.useMemo(()=>({[`__scope${t}`]:{...c,[t]:b}}),[c,b])}};return o.scopeName=t,[n,ks(o,...r)]}function ks(...t){const r=t[0];if(t.length===1)return r;const a=()=>{const n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(u){const p=n.reduce((c,{useScope:b,scopeName:v})=>{const m=b(u)[`__scope${v}`];return{...c,...m}},{});return A.useMemo(()=>({[`__scope${r.scopeName}`]:p}),[p])}};return a.scopeName=r.scopeName,a}var Es=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=Es.reduce((t,r)=>{const a=i.createSlot(`Primitive.${r}`),n=A.forwardRef((o,u)=>{const{asChild:p,...c}=o,b=p?a:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(b,{...c,ref:u})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});function Ls(){return bs.useSyncExternalStore(Ms,()=>!0,()=>!1)}function Ms(){return()=>{}}var Je="Avatar",[Is]=Cs(Je),[As,wt]=Is(Je),St=A.forwardRef((t,r)=>{const{__scopeAvatar:a,...n}=t,[o,u]=A.useState("idle");return e.jsx(As,{scope:a,imageLoadingStatus:o,onImageLoadingStatusChange:u,children:e.jsx(We.span,{...n,ref:r})})});St.displayName=Je;var Nt="AvatarImage",Dt=A.forwardRef((t,r)=>{const{__scopeAvatar:a,src:n,onLoadingStatusChange:o=()=>{},...u}=t,p=wt(Nt,a),c=Ps(n,u),b=i.useCallbackRef(v=>{o(v),p.onImageLoadingStatusChange(v)});return i.useLayoutEffect2(()=>{c!=="idle"&&b(c)},[c,b]),c==="loaded"?e.jsx(We.img,{...u,ref:r,src:n}):null});Dt.displayName=Nt;var Ct="AvatarFallback",kt=A.forwardRef((t,r)=>{const{__scopeAvatar:a,delayMs:n,...o}=t,u=wt(Ct,a),[p,c]=A.useState(n===void 0);return A.useEffect(()=>{if(n!==void 0){const b=window.setTimeout(()=>c(!0),n);return()=>window.clearTimeout(b)}},[n]),p&&u.imageLoadingStatus!=="loaded"?e.jsx(We.span,{...o,ref:r}):null});kt.displayName=Ct;function gt(t,r){return t?r?(t.src!==r&&(t.src=r),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Ps(t,{referrerPolicy:r,crossOrigin:a}){const n=Ls(),o=A.useRef(null),u=n?(o.current||(o.current=new window.Image),o.current):null,[p,c]=A.useState(()=>gt(u,t));return i.useLayoutEffect2(()=>{c(gt(u,t))},[u,t]),i.useLayoutEffect2(()=>{const b=m=>()=>{c(m)};if(!u)return;const v=b("loaded"),l=b("error");return u.addEventListener("load",v),u.addEventListener("error",l),r&&(u.referrerPolicy=r),typeof a=="string"&&(u.crossOrigin=a),()=>{u.removeEventListener("load",v),u.removeEventListener("error",l)}},[u,a,r]),p}var Et=St,Lt=Dt,Mt=kt;const It=A.forwardRef(({className:t,...r},a)=>e.jsx(Et,{ref:a,className:i.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...r}));It.displayName=Et.displayName;const Os=A.forwardRef(({className:t,...r},a)=>e.jsx(Lt,{ref:a,className:i.cn("aspect-square h-full w-full",t),...r}));Os.displayName=Lt.displayName;const At=A.forwardRef(({className:t,...r},a)=>e.jsx(Mt,{ref:a,className:i.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...r}));At.displayName=Mt.displayName;const Rs=async(t,r,a)=>{const n=`${t}/management/v1/groups`;return await i.postRequestRegular(n,r,a)},_s=async(t,r,a,n)=>{const o=`${t}/management/v1/groups/${a}`;return i.requestJsonRegular(o,r,"PATCH",n)},Ts=async(t,r,a)=>{const n=`${t}/management/v1/groups/${a}`;await i.requestJsonRegular(n,r,"DELETE")},Us=async(t,r,a,n)=>{const o=`${t}/management/v1/groups/${a}/members`;return await i.postRequestRegular(o,r,n)},Fs=async(t,r,a,n)=>{const o=`${t}/management/v1/groups/${a}/members`;await i.requestJsonRegular(o,r,"DELETE",n)};function Bs(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:n=>Rs(r.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:n=>{console.error("Failed to create group:",n),s.ue.error("Failed to create group",{description:i.getRequestErrorMessage(n,"Failed to create group")})}})}function Vs(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>_s(r.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group updated successfully")},onError:n=>{console.error("Failed to update group:",n),s.ue.error("Failed to update group",{description:i.getRequestErrorMessage(n,"Failed to update group")})}})}function zs(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:n=>Ts(r.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n),onSuccess:(n,o)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",o]}),s.ue.success("Group deleted successfully")},onError:n=>{console.error("Failed to delete group:",n),s.ue.error("Failed to delete group",{description:i.getRequestErrorMessage(n,"Failed to delete group")})}})}function $s(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>Us(r.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["group-members",o.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:n=>{console.error("Failed to add group members:",n),s.ue.error("Failed to add members",{description:i.getRequestErrorMessage(n,"Failed to add members")})}})}function qs(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>Fs(r.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["group-members",o.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:n=>{console.error("Failed to remove group members:",n),s.ue.error("Failed to remove members",{description:i.getRequestErrorMessage(n,"Failed to remove members")})}})}const Gs=[];function Hs({open:t,onOpenChange:r}){var k,E,L;const{tokenProps:a}=s.useSemaphorContext(),{currentUser:n}=s.useCurrentUserInfo(),o=(n==null?void 0:n.type)==="tenant",u=a==null?void 0:a.tenantId,{groups:p,isLoading:c,error:b,refetch:v}=s.useGroups({type:o?"TENANT_GROUP":"all",tenantId:o?u:void 0,includeMembers:!1}),l=b?Pt(b,"Unable to load groups."):null,[m,g]=j.useState({kind:"list"}),[h,f]=j.useState(null),d=zs();j.useEffect(()=>{t||(g({kind:"list"}),f(null))},[t]);const S=m.kind==="members"&&p.find(D=>D.id===m.groupId)||null,N=async()=>{if(h)try{await d.mutateAsync(h.id),f(null),g({kind:"list"}),v()}catch{}};return e.jsx(s.Dialog,{open:t,onOpenChange:r,children:e.jsxs(s.DialogContent,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[m.kind==="list"?e.jsxs("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[e.jsx(s.DialogTitle,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),e.jsx(s.DialogDescription,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):m.kind==="create"?e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("button",{type:"button",onClick:()=>g({kind:"list"}),"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium",children:"New group"}),e.jsx(s.DialogDescription,{className:"sr-only",children:"Create a new group to organize members."})]}):null,m.kind==="list"&&e.jsx(Ks,{groups:p,isLoading:c,errorMessage:l,onRetry:()=>v(),currentUserId:n==null?void 0:n.id,onOpenGroup:D=>g({kind:"members",groupId:D}),onCreate:()=>g({kind:"create"}),onDeleteRequest:D=>f(D)}),m.kind==="members"&&S&&e.jsx(Js,{group:S,isTenantViewer:o,canEdit:((k=S.permissions)==null?void 0:k.canEdit)??S.createdBy===(n==null?void 0:n.id),canDelete:((E=S.permissions)==null?void 0:E.canDelete)??S.createdBy===(n==null?void 0:n.id),canManageMembers:((L=S.permissions)==null?void 0:L.canManageMembers)??S.createdBy===(n==null?void 0:n.id),onBack:()=>g({kind:"list"}),onMembersChanged:v,onUpdated:v,onRequestDelete:()=>f(S)},S.id),m.kind==="create"&&e.jsx(Xs,{isTenantUser:o,tenantId:u,onCancel:()=>g({kind:"list"}),onCreated:D=>{v(),g({kind:"members",groupId:D})}}),h&&e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[e.jsxs("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",e.jsx("span",{className:"font-medium",children:h.name}),"?",e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>f(null),disabled:d.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:N,disabled:d.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",children:[d.isPending?e.jsx(i.LoaderCircle,{className:"h-3 w-3 animate-spin"}):e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})]})]})]})})}function Ks({groups:t,isLoading:r,errorMessage:a,onRetry:n,currentUserId:o,onOpenGroup:u,onCreate:p,onDeleteRequest:c}){const[b,v]=j.useState(""),l=j.useMemo(()=>t.filter(m=>!b.trim()||m.name.toLowerCase().includes(b.toLowerCase())||(m.description||"").toLowerCase().includes(b.toLowerCase())),[t,b]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(s.Search,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:b,onChange:m=>v(m.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),b&&e.jsx("button",{type:"button",onClick:()=>v(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(i.X,{className:"h-2.5 w-2.5"})})]}),e.jsxs("button",{type:"button",onClick:p,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:r?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(m=>e.jsx("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},m))}):a?e.jsx(Ot,{title:"Can't load groups",message:a,onRetry:n}):l.length===0&&t.length===0?e.jsx(Ws,{onCreate:p}):l.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsxs("div",{className:"text-[12px] text-foreground",children:['No groups match "',b,'"']}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):l.map(m=>{var g;return e.jsx(Qs,{group:m,canDelete:((g=m.permissions)==null?void 0:g.canDelete)??m.createdBy===o,onClick:()=>u(m.id),onDelete:()=>c(m)},m.id)})})]})}function Qs({group:t,canDelete:r,onClick:a,onDelete:n}){let o="";try{o=yt.format(new Date(t.createdAt),"MMM d, yyyy")}catch{o=""}return e.jsxs("button",{type:"button",onClick:a,className:"group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:e.jsx($.UsersRound,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(jt,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-2.5 w-2.5"}),o]})]}),t.description&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[r&&e.jsx("span",{role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),n()},onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),u.stopPropagation(),n())},"aria-label":`Delete ${t.name}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.Trash2,{className:"h-3 w-3"})}),e.jsx(s.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]})}function Ws({onCreate:t}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:e.jsx(s.Users,{className:"h-4 w-4"})}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),e.jsx("div",{className:"max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground",children:"Groups let you grant shared access to dashboards. Create one and add members."}),e.jsxs("button",{type:"button",onClick:t,className:"mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]})}function Js({group:t,isTenantViewer:r,canEdit:a,canDelete:n,canManageMembers:o,onBack:u,onMembersChanged:p,onUpdated:c,onRequestDelete:b}){const{data:v,isLoading:l,error:m,refetch:g}=s.useGroupMembers(t.id),h=(v==null?void 0:v.members)??Gs,f=m?Pt(m,"Unable to load members for this group."):null,d=t.type==="TENANT_GROUP"?"tenant":"organization",{users:S}=s.useUnifiedUsers({type:d,tenantId:t.tenantId||void 0,active:!0,limit:200}),N=j.useMemo(()=>new Set(h.map(w=>w.userId)),[h]),k=$s(),E=qs(),L=Vs(),[D,Q]=j.useState(!1),[W,te]=j.useState(t.name),[le,J]=j.useState(!1),[X,Y]=j.useState(t.description||""),[Z,de]=j.useState(""),[ce,B]=j.useState(!1),ue=j.useMemo(()=>{const w=Z.trim().toLowerCase();return S.filter(U=>!N.has(U.id)).filter(U=>!w||(U.name||"").toLowerCase().includes(w)||(U.email||"").toLowerCase().includes(w)).slice(0,50)},[S,N,Z]),se=async()=>{const w=W.trim();if(Q(!1),w.length>=3&&w!==t.name)try{await L.mutateAsync({groupId:t.id,data:{name:w}}),c()}catch{}},q=async()=>{const w=X.trim();if(J(!1),w!==(t.description||""))try{await L.mutateAsync({groupId:t.id,data:{description:w}}),c()}catch{}},T=async w=>{if(o){de(""),B(!1);try{await k.mutateAsync({groupId:t.id,data:{userIds:[w.id],userType:d==="tenant"?"tenant":"org"}}),g(),p()}catch{}}},O=async w=>{if(o)try{await E.mutateAsync({groupId:t.id,data:{userIds:[w]}}),g(),p()}catch{}};let R="";try{R=yt.format(new Date(t.createdAt),"MMM d, yyyy")}catch{R=""}return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("button",{type:"button",onClick:u,"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),D?e.jsx("input",{autoFocus:!0,value:W,onChange:w=>te(w.target.value),onBlur:se,onKeyDown:w=>{w.key==="Enter"&&se(),w.key==="Escape"&&(te(t.name),Q(!1))},className:"h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"}):e.jsx("button",{type:"button",onClick:()=>{a&&(te(t.name),Q(!0))},title:a?"Click to rename":t.name,disabled:!a,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),e.jsxs("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[e.jsx(jt,{className:"h-2.5 w-2.5"}),h.length," member",h.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:le?e.jsxs("div",{children:[e.jsx("textarea",{autoFocus:!0,rows:2,value:X,onChange:w=>Y(w.target.value),maxLength:200,onKeyDown:w=>{w.key==="Escape"&&(Y(t.description||""),J(!1)),w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&q()},placeholder:"What is this group for?",className:"block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10.5px] text-muted-foreground",children:[X.length,"/200 · Esc to cancel · ⌘↩ to save"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{Y(t.description||""),J(!1)},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:q,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):e.jsxs("button",{type:"button",onClick:()=>{a&&(Y(t.description||""),J(!0))},disabled:!a,title:a?"Click to edit description":void 0,className:"block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",children:[t.description?e.jsx("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):e.jsx("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:a?"Add a description…":"No description"}),e.jsxs("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[R?`Created ${R}`:"Recently created",a?" · You can edit this group":""]})]})}),o&&e.jsx(Ys,{query:Z,setQuery:de,open:ce,setOpen:B,candidates:ue,showKindChip:!r,onAdd:T,busy:k.isPending}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:l?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(w=>e.jsx("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},w))}):f?e.jsx(Ot,{title:"Can't load members",message:f,onRetry:()=>g()}):h.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsx("div",{className:"text-[12px] text-foreground",children:"No members yet"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:o?"Search above to add people to this group.":"This group does not have any members."})]}):h.map(w=>{var U,V,me,re,he,M;return e.jsxs("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[e.jsx(Rt,{name:((U=w.user)==null?void 0:U.name)||((V=w.user)==null?void 0:V.email)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((me=w.user)==null?void 0:me.name)||((re=w.user)==null?void 0:re.email)||"Unknown"}),((he=w.user)==null?void 0:he.email)&&w.user.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:w.user.email})]}),!r&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:w.userType}),e.jsx("button",{type:"button",onClick:()=>O(w.userId),disabled:!o||E.isPending,"aria-label":`Remove ${((M=w.user)==null?void 0:M.name)||"member"}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",children:e.jsx(i.X,{className:"h-3 w-3"})})]},w.id)})}),n&&e.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:e.jsxs("button",{type:"button",onClick:b,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",children:[e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})})]})}function Xs({isTenantUser:t,tenantId:r,onCancel:a,onCreated:n}){const[o,u]=j.useState(""),[p,c]=j.useState(""),[b,v]=j.useState(null),l=Bs(),m=o.trim().length>=3&&o.trim().length<=50,g=async()=>{if(!m)return;v(null);const h={name:o.trim(),description:p.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...t&&r?{tenantId:r}:{}};try{const f=await l.mutateAsync(h),d=f==null?void 0:f.id;d?n(d):a()}catch(f){v(f instanceof Error?f.message:"Failed to create group")}};return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.jsx(bt,{children:"Name"}),e.jsx("input",{autoFocus:!0,value:o,onChange:h=>u(h.target.value),placeholder:"Marketing leads, North America sales, …",maxLength:50,className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsx("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),e.jsxs("div",{className:"mt-4",children:[e.jsx(bt,{children:"Description (optional)"}),e.jsx("textarea",{rows:2,value:p,onChange:h=>c(h.target.value),maxLength:200,placeholder:"What is this group for?",className:"mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsxs("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[p.length,"/200"]})]}),b&&e.jsx("div",{className:"mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300",children:b})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:[e.jsx("button",{type:"button",onClick:a,disabled:l.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:g,disabled:!m||l.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:l.isPending?e.jsxs(e.Fragment,{children:[e.jsx(i.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"Create group"]})})]})]})}function Ys({query:t,setQuery:r,open:a,setOpen:n,candidates:o,showKindChip:u,onAdd:p,busy:c}){const b=j.useRef(null),v=j.useRef(null),[l,m]=j.useState(null);j.useLayoutEffect(()=>{if(!a){m(null);return}const h=()=>{const f=b.current;if(!f)return;const d=f.getBoundingClientRect(),S=240,k=window.innerHeight-d.bottom<S+16&&d.top>S;m({left:d.left,top:k?d.top-6:d.bottom+6,width:d.width,above:k})};return h(),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[a,o.length]),j.useEffect(()=>{if(!a)return;const h=f=>{var S,N;const d=f.target;(S=b.current)!=null&&S.contains(d)||(N=v.current)!=null&&N.contains(d)||n(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[a,n]);const g=a&&o.length>0&&l;return e.jsxs("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(ps,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:t,onChange:h=>{r(h.target.value),n(!0)},onFocus:()=>n(!0),placeholder:"Add a member by name or email…",disabled:c,className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"})]}),g&&typeof document<"u"&&ns.createPortal(e.jsx("div",{ref:v,style:{position:"fixed",left:l.left,top:l.top,width:l.width,transform:l.above?"translateY(-100%)":void 0},className:"z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",children:o.map(h=>e.jsxs("button",{type:"button",onClick:()=>p(h),className:"flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",children:[e.jsx(Rt,{name:h.name||h.email||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:h.name||h.email||"Unknown"}),h.email&&h.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:h.email})]}),u&&h.type&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:h.type==="tenant"?"tenant":"org"})]},h.id))}),document.body)]})}function Pt(t,r){if(!t)return r;if(t instanceof Error){const a=t.message||"",n=a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return n?n[1]:a||r}return typeof t=="string"?t:r}function Ot({title:t,message:r,onRetry:a}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[e.jsx("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),e.jsx("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:r}),a&&e.jsx("button",{type:"button",onClick:a,className:"mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",children:"Try again"})]})}function bt({children:t}){return e.jsx("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t})}function Rt({name:t}){const r=t.split(" ").map(a=>a[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return e.jsx(It,{className:"h-6 w-6 shrink-0",children:e.jsx(At,{className:"text-[9px] font-semibold",children:r||"?"})})}function je(t,r,a){var u,p;const n=(t.controls||[]).find(c=>c.id===a);if(n)return n.label;const o=(p=(u=i.findCardById(t,r))==null?void 0:u.controls)==null?void 0:p.find(c=>c.id===a);return(o==null?void 0:o.label)||a}function we(t,r){var a;return((a=i.findCardById(t,r))==null?void 0:a.title)||r}function Zs(t){const{errors:r,dashboard:a}=t;if(!a)return r;const n=new Map;for(const o of r){const u=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(u){const[,l,m]=u,g=`${l}:${m}:missing-metric`;n.has(g)||n.set(g,`"${we(a,l)}" has an outdated "${je(a,l,m)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const p=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(p){const[,l,m]=p,g=`${l}:${m}:missing-group-by`;n.has(g)||n.set(g,`"${we(a,l)}" has an outdated "${je(a,l,m)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const c=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(c){const[,l,m]=c,g=`${l}:${m}:invalid-metric`;n.has(g)||n.set(g,`"${we(a,l)}" has an invalid "${je(a,l,m)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const b=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(b){const[,l,m]=b,g=`${l}:${m}:invalid-group-by`;n.has(g)||n.set(g,`"${we(a,l)}" has an invalid "${je(a,l,m)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const v=o.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(v){const[,l,m]=v,g=`${l}:${m}:missing-temporal-group-by`;n.has(g)||n.set(g,`"${we(a,l)}" can no longer use "${je(a,l,m)}" for time grain because the card does not currently group by a date field.`);continue}n.set(o,o)}return Array.from(n.values())}function er(t,r){return typeof t=="boolean"?t:typeof r=="boolean"?r:!0}function tr(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((t,r)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},r))})}function sr({open:t,onOpenChange:r,onSubmit:a,isCreating:n}){const[o,u]=j.useState(""),[p,c]=j.useState("");j.useEffect(()=>{t||(u(""),c(""))},[t]);const b=()=>{o.trim()&&a({title:o,description:p})},v=l=>{r(l)};return e.jsx(s.Dialog,{open:t,onOpenChange:v,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(_e.LayoutGrid,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"New library visual"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Visual"})]})]}),e.jsx(i.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>v(!1),"aria-label":"Close",disabled:n,children:e.jsx(i.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-3 px-4 py-3",children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Create a saved visual that can be reused across dashboards."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(i.Label,{htmlFor:"visual-title",className:"text-[12px]",children:"Name"}),e.jsx(i.Input,{id:"visual-title",size:"sm",placeholder:"Untitled visual",value:o,onChange:l=>u(l.target.value),disabled:n,onKeyDown:l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),b())}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(i.Label,{htmlFor:"visual-description",className:"text-[12px]",children:"Description"}),e.jsx(i.Input,{id:"visual-description",size:"sm",placeholder:"Optional",value:p,onChange:l=>c(l.target.value),disabled:n})]})]}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5",children:[e.jsx(i.Button,{size:"xs",variant:"outline",onClick:()=>v(!1),disabled:n,children:"Cancel"}),e.jsx(i.Button,{size:"xs",onClick:b,disabled:!o.trim()||n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating..."]}):"Create library visual"})]})]})})}function _t(t){return t?new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Unknown"}function Tt(t,r){var n;const a=(n=t.ownership.createdBy)==null?void 0:n.type;return a==="tenant"||a==="organization"&&r}function Xe(t,r){var a,n;return Tt(t,r)?((a=t.ownership.createdBy)==null?void 0:a.name)||((n=t.createdByTenantUserRel)==null?void 0:n.name)||t.lastModifiedBy||"Unknown":"Organization"}function rr(t,r){return Xe(t,r).split(/\s+/).filter(Boolean).slice(0,2).map(n=>n.charAt(0).toUpperCase()).join("")||"?"}function nr(t){const r=(t||"").toLowerCase();return r.includes("table")?i.Table2:r.includes("pie")||r.includes("donut")?s.ChartPie:r.includes("line")?s.ChartLine:r.includes("bar")?i.ChartColumn:_e.LayoutGrid}function ar({visual:t}){const r=t.ownership.status==="public"?"Public":t.ownership.status==="shared"||t.ownership.sharedCount>0?"Shared":"Private";return e.jsx("span",{className:"inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground",children:r})}function or({open:t,onOpenChange:r}){const[a,n]=j.useState(""),[o,u]=j.useState(new Set),[p,c]=j.useState(!1),[b,v]=j.useState(null),[l,m]=j.useState(null),[g,h]=j.useState(!1),[f,d]=j.useState(null),[S,N]=j.useState(null),k=()=>{u(new Set),v(null),m(null),h(!1),d(null)},E=()=>{r(!1),k()},{selectVisual:L}=s.useManagementActions(),{handleAddLibraryVisual:D,handleEditLibraryVisual:Q}=is.useVisualUtils(),{isConsoleMode:W}=s.useDashboardPreferences(),{resources:te,isLoading:le,isError:J,createResource:X,updateResource:Y,deleteResourceAsync:Z,duplicateResource:de,isCreating:ce,isDeleting:B}=s.useVisualManagement(void 0,y=>{c(!1),y&&(L(y),Q(y),E())}),{startUpdating:ue,stopUpdating:se,isUpdating:q}=s.useResourceUpdateState(),T=te,O=j.useMemo(()=>{const y=a.trim().toLowerCase();return y?T.filter(C=>{var I,z,ee;return((I=C.title)==null?void 0:I.toLowerCase().includes(y))||((z=C.description)==null?void 0:z.toLowerCase().includes(y))||((ee=C.kind)==null?void 0:ee.toLowerCase().includes(y))}):T},[a,T]),R=j.useMemo(()=>T.filter(y=>o.has(y.id)),[o,T]),w=R.filter(y=>y.permissions.canDelete),U=R.filter(y=>y.permissions.canShare),V=O.length>0&&O.every(y=>o.has(y.id)),me=O.some(y=>o.has(y.id)),re=y=>{const C=new Set(o);y(C),u(C)},he=y=>{re(C=>{C.has(y)?C.delete(y):C.add(y)})},M=()=>{u(y=>{const C=new Set(y);return V?O.forEach(I=>C.delete(I.id)):O.forEach(I=>C.add(I.id)),C})},ne=async y=>{(await D(y)).success&&E()},xe=async()=>{const y=R;if(y.length===0)return;let C=!1;for(const I of y)if(!(await D(I)).success){C=!0;break}C||E()},pe=y=>{Q(y),E()},Se=y=>{N(y),de(y,{onSettled:()=>N(null)})},fe=()=>{if(w.length===0){s.ue.error("Select a visual you can delete");return}d(null),h(!0)},Ne=async()=>{const y=f?[f]:w;try{for(const C of y)await Z(C.id);u(C=>{const I=new Set(C);return y.forEach(z=>I.delete(z.id)),I}),h(!1),d(null)}catch{}},De=()=>{if(R.length!==1){s.ue.error("Select one visual to share");return}const[y]=R;if(!y.permissions.canShare){s.ue.error("You do not have permission to share this visual");return}v(y)},Ce=({title:y,description:C})=>{if(!l)return;const I={};if(y!==l.title&&(I.title=y),(l.description||"")!==C&&(I.description=C),Object.keys(I).length===0){m(null);return}const z=Object.keys(I),ee=z.length===1?z[0]:void 0;ue(l.id,ee),Y({resourceId:l.id,data:I},{onSuccess:()=>{se(l.id,ee),m(null)},onError:()=>{se(l.id,ee)}})},ae=y=>{r(y),y||k()},G=f?1:w.length;return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:ae,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(i.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"Visuals library"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Add to dashboard"})]})]}),e.jsx(i.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>ae(!1),"aria-label":"Close visuals library",children:"×"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"relative min-w-[12rem] flex-1 md:max-w-md",children:[e.jsx(s.Search,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:a,onChange:y=>n(y.target.value),placeholder:"Search visuals...",className:"h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none","aria-label":"Search visuals"})]}),e.jsxs(i.Button,{size:"xs",variant:"outline",className:"ml-auto",onClick:()=>c(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"New library visual"]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:le?e.jsx("div",{className:"p-3",children:e.jsx(tr,{})}):J?e.jsx("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:e.jsx("p",{className:"text-[13px] text-destructive",children:"Failed to load visuals"})}):O.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:[e.jsx(_e.LayoutGrid,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("p",{className:"text-[13px] font-medium",children:a?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:a?"Try a different search.":"Create a saved visual to add it here."})]}):e.jsx(ir,{visuals:O,selectedIds:o,allFilteredSelected:V,someFilteredSelected:me,onSelectAll:M,onToggleSelection:he,onAddVisual:ne,onOpenVisual:pe,onEditDetails:m,onShareVisual:v,onDeleteVisual:y=>{d(y),h(!0)},onDuplicateVisual:Se,duplicatingId:S,isDeleting:B,isConsoleMode:W})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:o.size>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[e.jsx("span",{className:"font-medium tabular-nums text-foreground",children:o.size})," ","selected"]}),e.jsx(i.Button,{size:"xs",variant:"ghost",onClick:()=>u(new Set),children:"Clear"}),e.jsxs(i.Button,{size:"xs",variant:"outline",onClick:De,disabled:R.length!==1||U.length!==1,children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsxs(i.Button,{size:"xs",variant:"outline",className:"text-destructive hover:text-destructive",onClick:fe,disabled:w.length===0,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),"Delete ",w.length||o.size]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Button,{size:"xs",variant:"outline",onClick:()=>ae(!1),children:"Close"}),e.jsxs(i.Button,{size:"xs",onClick:xe,disabled:o.size===0,children:[e.jsx(i.Check,{className:"h-3.5 w-3.5"}),o.size===0?"Add to dashboard":`Add ${o.size} visual${o.size===1?"":"s"}`]})]})]})]})}),e.jsx(sr,{open:p,onOpenChange:c,onSubmit:X,isCreating:ce}),b&&e.jsx(s.ShareDialog,{resource:b,resourceType:s.ResourceType.VISUAL,onClose:()=>v(null)}),l&&e.jsx(s.ResourceEditDialog,{open:!!l,resourceLabel:"Visual",initialTitle:l.title||"",initialDescription:l.description||"",onClose:()=>m(null),onSave:Ce,isSaving:q(l.id)}),e.jsx(s.AlertDialog,{open:g,onOpenChange:y=>{!y&&B||(h(y),y||d(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs(s.AlertDialogTitle,{children:["Delete ",G," visual",G===1?"":"s","?"]}),e.jsx(s.AlertDialogDescription,{children:"This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately."})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:B,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:y=>{y.preventDefault(),Ne()},disabled:B||G===0,children:[B?e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),B?"Deleting...":"Delete"]})]})]})})]})}function ir({visuals:t,selectedIds:r,allFilteredSelected:a,someFilteredSelected:n,onSelectAll:o,onToggleSelection:u,onAddVisual:p,onOpenVisual:c,onEditDetails:b,onShareVisual:v,onDeleteVisual:l,onDuplicateVisual:m,duplicatingId:g,isDeleting:h,isConsoleMode:f}){return e.jsxs("div",{className:"min-w-[48rem]",children:[e.jsxs("div",{className:"grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[e.jsx(s.Checkbox,{checked:a?!0:n?"indeterminate":!1,onCheckedChange:o,"aria-label":"Select all visuals"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Created by"}),e.jsx("span",{children:"Updated"}),e.jsx("span",{children:"Visibility"}),e.jsx("span",{className:"text-right",children:"Shared"}),e.jsx("span",{className:"text-right",children:"Actions"})]}),t.map(d=>e.jsx(lr,{visual:d,selected:r.has(d.id),onToggleSelection:u,onAddVisual:p,onOpenVisual:c,onEditDetails:b,onShareVisual:v,onDeleteVisual:l,onDuplicateVisual:m,duplicatingId:g,isDeleting:h,isConsoleMode:f},d.id))]})}function lr({visual:t,selected:r,onToggleSelection:a,onAddVisual:n,onOpenVisual:o,onEditDetails:u,onShareVisual:p,onDeleteVisual:c,onDuplicateVisual:b,duplicatingId:v,isDeleting:l,isConsoleMode:m}){var f;const g=nr(t.kind),h=()=>{n(t)};return e.jsxs("div",{className:i.cn("group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",r&&"bg-muted/70"),children:[e.jsx("div",{children:e.jsx(s.Checkbox,{checked:r,onCheckedChange:()=>a(t.id),"aria-label":`Select ${t.title||"visual"}`})}),e.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:h,"aria-label":`Add ${t.title||"visual"} to dashboard`,children:[e.jsx(g,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-foreground",title:t.title||"Untitled Visual",children:t.title||"Untitled Visual"}),((f=t.description)==null?void 0:f.trim())&&e.jsx("div",{className:"truncate text-[11px] text-muted-foreground",title:t.description,children:t.description})]})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground",children:rr(t,m)}),e.jsx("span",{className:"truncate text-muted-foreground",children:Xe(t,m)})]}),e.jsx("span",{className:"text-muted-foreground",children:_t(t.updatedAt)}),e.jsx(ar,{visual:t}),e.jsx("span",{className:"text-right tabular-nums text-muted-foreground",children:t.ownership.sharedCount>0?t.ownership.sharedCount:"—"}),e.jsx(dr,{visual:t,onOpenVisual:o,onEditDetails:u,onShareVisual:p,onDeleteVisual:c,onDuplicateVisual:b,duplicatingId:v,isDeleting:l,isConsoleMode:m})]})}function dr({visual:t,onOpenVisual:r,onEditDetails:a,onShareVisual:n,onDeleteVisual:o,onDuplicateVisual:u,duplicatingId:p,isDeleting:c,isConsoleMode:b}){return e.jsxs("div",{className:"flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",onClick:v=>v.stopPropagation(),children:[e.jsx(i.Button,{size:"xs",variant:"ghost",className:"w-7 px-0",onClick:()=>r(t),"aria-label":"Edit visual",children:e.jsx(s.PenLine,{className:"h-3.5 w-3.5"})}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(i.Button,{size:"xs",variant:"ghost",className:"w-7 px-0","aria-label":"More actions",children:e.jsx(s.Ellipsis,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",children:[e.jsxs(s.DropdownMenuItem,{onClick:()=>r(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>u(t.id),disabled:p===t.id,children:[p===t.id?e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),p===t.id?"Duplicating...":"Duplicate"]}),t.permissions.canEdit&&e.jsxs(s.DropdownMenuItem,{onClick:()=>a(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit details"]}),t.permissions.canShare&&e.jsxs(s.DropdownMenuItem,{onClick:()=>n(t),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),t.permissions.canDelete&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>o(t),disabled:c,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),c?"Deleting...":"Delete"]})]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[Tt(t,b)&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Xe(t,b)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:_t(t.updatedAt)})]})]})]})]})]})}function vt(t,r){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(r)}}function cr(){var ot,it,lt,dt,ct,ut,mt;$.useExportRecovery(),$.useExportPolling();const{authToken:t,tokenProps:r,id:a,showBriefings:n}=s.useSemaphorContext(),{isLocalDev:o}=s.useDashboardPreferences(),{openBrandStudioPreview:u}=s.useBrandStudioPreview(),{permissions:p}=Ds(),c=s.useHasDashboardId(),{isLoading:b}=s.useDashboardQuery(),v=i.useDashboardStore(x=>x.theme),l=i.useDashboardStore(x=>x.isDownloadingPdf),m=i.useDashboardStore(x=>x.dashboardAssistantDraftScopeKey),g=i.useDashboardStore(x=>x.lenses),h=i.useDashboardStore(x=>x.selectedLensId),f=g==null?void 0:g.find(x=>x.id===h),d=i.useDashboardStore(x=>x.dashboard),S=i.useDashboardStore(x=>x.selectedSheetId),N=(ot=d==null?void 0:d.sheets)==null?void 0:ot.find(x=>x.id===S),k=i.isDocumentSheet(N),E=k?(it=N==null?void 0:N.document)==null?void 0:it.page:void 0,L=i.useDashboardStore(x=>x.isDashboardEditing),{setDashboardTitle:D}=i.useDashboardStore(x=>x.actions),[Q,W]=j.useState(!1),[te,le]=j.useState(!1),[J,X]=j.useState(!1),[Y,Z]=j.useState(!1),[de,ce]=j.useState(!1),[B,ue]=j.useState(!1),[se,q]=j.useState(!1),[T,O]=j.useState(null),[R,w]=j.useState([]),[U,V]=j.useState(!1),[me,re]=j.useState(!1),he=i.useDashboardStore(x=>x.filterValues),M=i.useDashboardStore(x=>x.isVisualEditing);i.useEditorStore(x=>x.card);const ne=s.useManagementStore(x=>x.selectedDashboard),xe=s.useManagementStore(x=>x.initialDashboard);s.useManagementStore(x=>x.selectedVisual),i.useDashboardStore(x=>x.selectedFrameId),i.useEditorStore(x=>x.frame);const pe=ne?(dt=ne==null?void 0:ne.permissions)==null?void 0:dt.canEdit:(lt=xe==null?void 0:xe.permissions)==null?void 0:lt.canEdit,Se=i.useDashboardStore(x=>x.showDashboardJSON),fe=i.useDashboardStore(x=>x.onSaveFunction),{setIsDashboardEditing:Ne,setShowDashboardJSON:De}=i.useDashboardStore(x=>x.actions),{setInitialDashboard:Ce,clearSelectedDashboard:ae}=s.useManagementStore(x=>x.actions),G=!!r.orgUserId||!!(r.tenantId&&r.endUserId&&r.endUserEmail),{resources:y}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:C}=s.useUserPreferences(),I=((ct=C==null?void 0:C.preference)==null?void 0:ct.defaultDashboardId)||null,{mutate:z,isPending:ee}=s.useDefaultDashboardMutation(),{currentUser:Ut}=s.useCurrentUserInfo(),Ft=s.canUserManageGroups(Ut),H=ne||xe,Ye=H?{id:H.id,title:(d==null?void 0:d.title)||H.title||"Dashboard"}:null,{handleAddNewFrame:Bt}=s.useAddNewFrame(),[Te,Ue]=j.useState(!1),[Vt,ge]=j.useState(!1),[Fe,ke]=j.useState("close"),be=s.useUpdateResource(s.ResourceType.DASHBOARD),[F,Ee]=j.useState(null),zt=async(x,P)=>{if(!(d!=null&&d.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:d.id,newTitle:x,previousTitle:P}),be.mutate({resourceId:d.id,data:{title:x}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:K=>{console.error("Failed to update dashboard title:",K),s.ue.error("Failed to update dashboard title"),D(P)}})};j.useEffect(()=>{if(y&&y.length>0){const x=d==null?void 0:d.id;if(x){const P=y.find(K=>K.id===x);P&&Ce(P)}}},[y,d==null?void 0:d.id,Ce]);const ve=r.orgUserId||r.tenantId,Be=j.useMemo(()=>ur({accessToken:t==null?void 0:t.accessToken,dashboardId:(d==null?void 0:d.id)||a||r.dashboard_id,selectedSheetId:k?S:void 0,pageSize:E==null?void 0:E.size,orientation:E==null?void 0:E.orientation,theme:v}),[t==null?void 0:t.accessToken,a,d==null?void 0:d.id,k,E==null?void 0:E.orientation,E==null?void 0:E.size,S,v,r.dashboard_id]),Ze=L&&!M&&ve&&pe,{setDashboard:et}=i.useDashboardStore(x=>x.actions),tt=i.useDashboardStore(x=>x.semanticExecutionPayload),$t=()=>{Ne(!0)},Ve=()=>{Ne(!1),De(!1),Ee(null)};j.useEffect(()=>{if(!L){F&&Ee(null);return}F||!d||b||Ee(vt(d,tt))},[d,F,L,b,tt]);const Le=(F==null?void 0:F.dashboard)??null,{isDirty:st,isDirtyPending:qt,resetDirty:Me}=os.useDebouncedDirtyCheck(d,Le,300,1e3,qe.serializeDashboardForDirtyCheck),rt=j.useCallback(()=>Le?qe.serializeDashboardForDirtyCheck(d)!==qe.serializeDashboardForDirtyCheck(Le):!1,[d,Le]),nt=st||qt,Ie=Te||be.isPending,Gt=()=>{rt()?(ke("close"),ge(!0)):(Ve(),Me())},Ht=async()=>{await ze({closeAfterSave:!0,navigateHomeAfterSave:Fe==="home"})},Kt=()=>{const x=Fe==="home"&&!!G;F&&et(F.dashboard,{semanticExecutionPayload:F.semanticExecutionPayload}),Ve(),x&&ae(),ke("close"),ge(!1),Me()},Qt=()=>{F&&(et(F.dashboard,{semanticExecutionPayload:F.semanticExecutionPayload}),Me())},Wt=()=>{if(G){if(L&&rt()){ke("home"),ge(!0);return}ae()}};async function ze(x){const P=i.useDashboardStore.getState().dashboard;if(!P)return;const K=(x==null?void 0:x.closeAfterSave)??U,ts=(x==null?void 0:x.navigateHomeAfterSave)??!1;V(K),K&&ge(!1);const ss=s.cloneDeep(P);q(!0),O(null),w([]),Ue(!0);const rs={template:P};be.mutate({resourceId:P.id,data:rs},{onSuccess:_=>{var Ae,Pe,ht;const ie=(_==null?void 0:_.id)||((Ae=_==null?void 0:_.dashboard)==null?void 0:Ae.id)||((Pe=_==null?void 0:_.resource)==null?void 0:Pe.id)||((ht=_==null?void 0:_.template)==null?void 0:ht.id)||null;if(!P.id&&ie){const $e=i.useAIInteractionStore.getState(),Oe=$e.pendingDashboardDraftMigration;(Oe==null?void 0:Oe.scopeKey)===m?$e.actions.setPendingDashboardDraftMigrationExpectedDashboardId(ie):Oe&&$e.actions.clearPendingDashboardDraftMigration()}Ue(!1),s.ue.success("Dashboard saved!"),Ee(vt(ss,i.useDashboardStore.getState().semanticExecutionPayload)),q(!1),V(!1),K&&(Ve(),Me(),ts&&G&&ae()),ke("close")},onError:_=>{Ue(!1),O("Failed to save dashboard. Please try again.");const ie=_.details,Ae=Array.isArray(ie==null?void 0:ie.errors)?(ie.errors||[]).filter(Pe=>typeof Pe=="string"):[];w(Zs({errors:Ae,dashboard:P||void 0})),s.ue.error("Failed to save dashboard")}})}async function Jt(){if(W(!0),!h||!f)return;const x=i.useDashboardStore.getState().dashboard;if(!x){W(!1);return}const P=JSON.stringify(x),K={...f,template:P,filterValues:he};await Qe(r.apiServiceUrl,K,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),fe==null||fe(x),W(!1)}const at=(f==null?void 0:f.name)||d.title;be.isPending&&console.log("Title during update:",{title:at,dashboardStateTitle:d.title,dashboardId:d==null?void 0:d.id,currentLensName:f==null?void 0:f.name});const Xt=G&&!!(t!=null&&t.accessToken)&&!!(r!=null&&r.apiServiceUrl),Yt=c&&G,oe=(d==null?void 0:d.id)||null,Zt=er((ut=r.config)==null?void 0:ut.showBriefings,n),ye=!!oe&&I===oe,es=()=>{oe&&z({dashboardId:ye?null:oe})};return!c&&!M?null: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:[Yt&&!M&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Wt,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})}),!M&&c&&(b?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:at||"Untitled Dashboard",onSave:x=>{console.log("EditableText onSave called:",{newTitle:x,canEditDashboard:pe,dashboardId:d==null?void 0:d.id});const P=(d==null?void 0:d.title)||"";D(x),zt(x,P)},isEditable:pe&&!f,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:be.isPending}),ye&&e.jsx("span",{className:"shrink-0 rounded-[4px] border border-border/60 px-1.5 py-px text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",title:"Default dashboard",children:"Default"}),Xt&&oe&&e.jsx(i.TooltipProvider,{children:e.jsxs(i.Tooltip,{children:[e.jsx(i.TooltipTrigger,{asChild:!0,children:e.jsx(i.Button,{variant:"ghost",size:"xs",onClick:es,disabled:ee||!(t!=null&&t.accessToken)||!(r!=null&&r.apiServiceUrl),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":ye?"Clear default dashboard":"Set as default dashboard",children:ye?e.jsx(s.PinOff,{className:"h-3.5 w-3.5"}):e.jsx(s.Pin,{className:"h-3.5 w-3.5"})})}),e.jsx(i.TooltipContent,{children:e.jsx("p",{children:ye?"Clear default":"Set as default"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M&&e.jsxs(e.Fragment,{children:[e.jsx($.AdvancedModeToggle,{}),e.jsx($.VisualEditingControls,{})]}),!M&&c&&((mt=H==null?void 0:H.permissions)==null?void 0:mt.canShare)&&e.jsxs(i.Button,{variant:"outline",size:"xs",onClick:()=>le(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!M&&!L&&c&&oe&&Zt&&e.jsx($.DashboardBriefingLauncher,{dashboardId:oe,dashboardTitle:(d==null?void 0:d.title)||(H==null?void 0:H.title)}),!M&&L&&p.canUseFilters&&c&&e.jsx($.DashboardFilterControlsLauncher,{}),L&&!M&&ve&&f&&o&&c&&e.jsxs(i.Button,{variant:"secondary",size:"xs",disabled:Q,onClick:Jt,children:[e.jsx(xt.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),L&&!M&&c&&!k&&e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[e.jsxs(i.Button,{variant:"ghost",size:"xs",disabled:!L,onClick:()=>void Bt(),className:"h-full rounded-none border-0 shadow-none hover:bg-accent",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(i.Button,{variant:"ghost",size:"xs",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent","aria-label":"Open visual options",disabled:!L,children:e.jsx(i.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(s.DropdownMenuContent,{align:"end",className:"z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>re(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),e.jsx(or,{open:me,onOpenChange:re})]}),!M&&!L&&pe&&c&&e.jsxs(i.Button,{size:"xs",onClick:$t,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Ze&&c&&st&&e.jsxs(i.Button,{variant:"outline",size:"xs",onClick:Qt,disabled:Ie,children:[e.jsx($.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),Ze&&c&&e.jsxs(i.Button,{size:"xs",className:i.cn(!nt&&"opacity-60"),disabled:Ie||!nt,onClick:()=>ze(),children:[Ie?e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xt.Save,{className:"h-3.5 w-3.5"}),Ie?"Saving...":"Save"]}),L&&!M&&c&&e.jsxs(i.Button,{variant:"outline",size:"xs",onClick:Gt,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!M&&c&&e.jsx("div",{className:"ml-2",children:e.jsx($.NotificationBell,{})}),!M&&o&&e.jsx(vs,{}),!M&&c&&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:l,onSelect:()=>ue(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsx(s.DropdownMenuSeparator,{}),Ft&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>X(!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:()=>Z(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),o&&c&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var x;t!=null&&t.accessToken&&((x=navigator==null?void 0:navigator.clipboard)!=null&&x.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"]}),k&&e.jsxs(s.DropdownMenuItem,{disabled:!Be,onSelect:()=>{var x;if(!Be){s.ue.error("Open a document sheet with a token to copy the local PDF URL");return}(x=navigator==null?void 0:navigator.clipboard)!=null&&x.writeText?navigator.clipboard.writeText(Be).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:()=>i.invalidateToken(r.apiServiceUrl),children:[e.jsx(hs,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:u,children:[e.jsx(ls.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),L&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>De(!Se),children:[e.jsx(_e.Braces,{className:"h-3.5 w-3.5"}),Se?"Hide dashboard JSON":"Show dashboard JSON"]}),ve&&L&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>ce(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),ve&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(cs,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(Ns,{})})]})]})]})]}),te&&Ye&&e.jsx(s.ShareDialog,{resource:Ye,resourceType:s.ResourceType.DASHBOARD,onClose:()=>le(!1)}),e.jsx(Hs,{open:J,onOpenChange:X}),e.jsx(as.CalendarPreferencesDialog,{open:Y,onOpenChange:Z}),o&&ve&&c&&e.jsx(Ss,{open:de,onOpenChange:ce}),c&&e.jsx(s.DownloadPdf,{open:B,onOpenChange:ue}),e.jsx(s.AlertDialog,{open:se,onOpenChange:x=>{!x&&Te&&!T||(q(x),x||(O(null),w([]),V(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:T?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:T?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),R.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:R.slice(0,5).map(x=>e.jsx("li",{children:x},x))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:T?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{q(!1),O(null),w([]),V(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>ze({closeAfterSave:U,navigateHomeAfterSave:Fe==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(i.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx($.UnsavedChangesAlert,{open:Vt,onOpenChange:x=>{ge(x)},onSave:Ht,onDiscard:Kt,isSaving:Te,saveLabel:"Save",discardLabel:"Discard"})]})]})}function ur({accessToken:t,dashboardId:r,selectedSheetId:a,pageSize:n,orientation:o,theme:u}){if(!t||!a)return null;const p=new URL("http://localhost:5173/print-document");p.searchParams.set("token",t),r&&p.searchParams.set("dashboardId",r),p.searchParams.set("selectedSheetId",a),u&&p.searchParams.set("theme",u);const c=new URL("http://127.0.0.1:3002/");return c.searchParams.set("pdfMode","document"),c.searchParams.set("pageSize",n||"letter"),c.searchParams.set("orientation",o||"portrait"),c.searchParams.set("url",p.toString()),c.toString()}exports.default=cr;
|