react-semaphor 0.1.421 → 0.1.423

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 (67) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +2 -2
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +2 -2
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +913 -712
  7. package/dist/chunks/{analyze-result-contract-sWcmvBOA.js → analyze-result-contract-D7pjjYPy.js} +45 -46
  8. package/dist/chunks/{analyze-result-contract-B5Eeu7vD.js → analyze-result-contract-DpDcImgk.js} +1 -1
  9. package/dist/chunks/{calendar-preferences-dialog-CscmhyuZ.js → calendar-preferences-dialog-CTmeASaM.js} +1 -1
  10. package/dist/chunks/{calendar-preferences-dialog-cN3_2C-u.js → calendar-preferences-dialog-t5ET6MON.js} +3 -3
  11. package/dist/chunks/card-config-utils-15sRtebL.js +1 -0
  12. package/dist/chunks/card-config-utils-BYZ5MJOh.js +16 -0
  13. package/dist/chunks/dashboard-briefing-launcher-Cavd0QJb.js +3401 -0
  14. package/dist/chunks/dashboard-briefing-launcher-S2akO-ub.js +26 -0
  15. package/dist/chunks/dashboard-controls-BJLrErjW.js +2322 -0
  16. package/dist/chunks/dashboard-controls-DzbP8AXA.js +52 -0
  17. package/dist/chunks/dashboard-json-5tWb5KD6.js +1 -0
  18. package/dist/chunks/{dashboard-json-Cxhw2TZc.js → dashboard-json-Do2-pdPZ.js} +12 -11
  19. package/dist/chunks/{edit-dashboard-visual-BigSJ3-x.js → edit-dashboard-visual-Cw6bq4_w.js} +7058 -6989
  20. package/dist/chunks/edit-dashboard-visual-Yh5YFgMF.js +178 -0
  21. package/dist/chunks/index-BPM3gDRw.js +1406 -0
  22. package/dist/chunks/{index-CH2ZzQo4.js → index-yHe0SeLO.js} +81534 -75430
  23. package/dist/chunks/{switch-TbCsyhv9.js → switch-2bh3Hka1.js} +620 -633
  24. package/dist/chunks/{switch-CiOjVyVI.js → switch-DMT7qf_R.js} +24 -24
  25. package/dist/chunks/{update-policy-2MZ-Vf7v.js → update-policy-BCJc0oI5.js} +1 -1
  26. package/dist/chunks/{update-policy-qpyAkOyO.js → update-policy-C1pmhLz9.js} +1 -1
  27. package/dist/chunks/{use-create-flow-overlay-state-BzcJWNzh.js → use-create-flow-overlay-state-5MDbZcs1.js} +515 -544
  28. package/dist/chunks/use-create-flow-overlay-state-BNczg9Gj.js +11 -0
  29. package/dist/chunks/{validators-Dj1Y-46V.js → validators-DMlVbd1p.js} +1 -1
  30. package/dist/chunks/{validators-D0pfj3jJ.js → validators-PXkij33j.js} +1 -1
  31. package/dist/dashboard/index.cjs +1 -1
  32. package/dist/dashboard/index.js +1 -1
  33. package/dist/dashboard-authoring/index.cjs +1 -1
  34. package/dist/dashboard-authoring/index.js +2 -2
  35. package/dist/data-app-builder/index.cjs +1 -1
  36. package/dist/data-app-builder/index.js +108 -108
  37. package/dist/data-app-codegen/index.cjs +1 -1
  38. package/dist/data-app-codegen/index.js +2 -2
  39. package/dist/data-app-codegen-node/index.cjs +165 -340
  40. package/dist/data-app-codegen-node/index.js +761 -952
  41. package/dist/data-app-sdk/index.cjs +2 -2
  42. package/dist/data-app-sdk/index.js +91 -95
  43. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  44. package/dist/data-app-sdk-adapters/index.js +1 -1
  45. package/dist/data-app-sdk-validation/index.cjs +1 -1
  46. package/dist/data-app-sdk-validation/index.js +2 -2
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.js +168 -164
  49. package/dist/style.css +1 -1
  50. package/dist/surfboard/index.cjs +1 -1
  51. package/dist/surfboard/index.js +2 -2
  52. package/dist/types/analytics-protocol.d.ts +0 -4
  53. package/dist/types/briefings.d.ts +2388 -7
  54. package/dist/types/dashboard-assistant.d.ts +0 -1
  55. package/dist/types/data-app-sdk-validation.d.ts +0 -1
  56. package/dist/types/data-app-sdk.d.ts +0 -2
  57. package/dist/types/main.d.ts +70 -10
  58. package/dist/types/types.d.ts +4 -8
  59. package/package.json +1 -1
  60. package/dist/chunks/dashboard-briefing-launcher-BYTBNetR.js +0 -9077
  61. package/dist/chunks/dashboard-briefing-launcher-DmZkzIC3.js +0 -80
  62. package/dist/chunks/dashboard-controls-9DFeKIP4.js +0 -52
  63. package/dist/chunks/dashboard-controls-PhzuaTBj.js +0 -2280
  64. package/dist/chunks/dashboard-json-DyRHI3mL.js +0 -1
  65. package/dist/chunks/edit-dashboard-visual-3_jiBXsu.js +0 -178
  66. package/dist/chunks/index-BKDQw0aK.js +0 -1346
  67. package/dist/chunks/use-create-flow-overlay-state-DUQmgb9H.js +0 -21
@@ -0,0 +1,52 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./switch-DMT7qf_R.js"),s=require("./index-BPM3gDRw.js"),O=require("./x-B6ghREd2.js");require("./analyze-result-contract-DpDcImgk.js");const y=require("react");require("./index-DRlMUglg.js");const as=require("react-dom");require("../briefings/index.cjs");const F=require("./dashboard-briefing-launcher-S2akO-ub.js"),vt=require("./search-DNCejM7Z.js"),yt=require("./index-D7KJindZ.js"),os=require("./calendar-preferences-dialog-CTmeASaM.js"),is=require("./use-debounced-dirty-check-XHSwAefL.js"),Te=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),pt=require("./save-C__QggEE.js"),ds=require("./palette-C4KTXOug.js"),cs=require("./braces-D2tStQjF.js");function ls(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(a,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return a.default=t,Object.freeze(a)}const k=ls(y);/**
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 us=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 ms=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"}]]);/**
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 ps=O.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=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"}]]);/**
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=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"}]]);/**
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 fs=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"}]]);/**
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=O.createLucideIcon("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var qe={exports:{}},Fe={};/**
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 ht;function gs(){if(ht)return Fe;ht=1;var t=y;function a(c,g){return c===g&&(c!==0||1/c===1/g)||c!==c&&g!==g}var r=typeof Object.is=="function"?Object.is:a,n=t.useState,o=t.useEffect,d=t.useLayoutEffect,f=t.useDebugValue;function x(c,g){var l=g(),b=n({inst:{value:l,getSnapshot:g}}),v=b[0].inst,p=b[1];return d(function(){v.value=l,v.getSnapshot=g,h(v)&&p({inst:v})},[c,l,g]),o(function(){return h(v)&&p({inst:v}),c(function(){h(v)&&p({inst:v})})},[c]),f(l),l}function h(c){var g=c.getSnapshot;c=c.value;try{var l=g();return!r(c,l)}catch{return!0}}function j(c,g){return g()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?j:x;return Fe.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Fe}var Be={};/**
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 xt;function bs(){return xt||(xt=1,process.env.NODE_ENV!=="production"&&function(){function t(l,b){return l===b&&(l!==0||1/l===1/b)||l!==l&&b!==b}function a(l,b){u||o.startTransition===void 0||(u=!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 v=b();if(!c){var p=b();d(v,p)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}p=f({inst:{value:v,getSnapshot:b}});var D=p[0].inst,N=p[1];return h(function(){D.value=v,D.getSnapshot=b,r(D)&&N({inst:D})},[l,v,b]),x(function(){return r(D)&&N({inst:D}),l(function(){r(D)&&N({inst:D})})},[l]),j(v),v}function r(l){var b=l.getSnapshot;l=l.value;try{var v=b();return!d(l,v)}catch{return!0}}function n(l,b){return b()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=y,d=typeof Object.is=="function"?Object.is:t,f=o.useState,x=o.useEffect,h=o.useLayoutEffect,j=o.useDebugValue,u=!1,c=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:a;Be.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())}()),Be}process.env.NODE_ENV==="production"?qe.exports=gs():qe.exports=bs();var vs=qe.exports;const De=["light","dark","system"];function ys(){const{theme:t,setTheme:a}=s.useTheme(),r=m.useDashboardStore(f=>f.actions.setDashboardTheme);function n(){const f=De.includes(t)?t:"system",x=De[(De.indexOf(f)+1)%De.length];a(x),r(x)}const o=t==="light"?xs:t==="dark"?ps:ms,d=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(m.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:n,"aria-label":d,title:d,children:e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function js(t,a,r,n,o){if(!o)return null;const d=JSON.stringify(r),f=`${t}/v1/lens`;return await m.postRequest(f,o,{name:a,template:d,filterValues:n,operation:"create"})}async function $e(t,a,r){if(!r)return null;const{id:n,template:o,filterValues:d,isDefault:f,shared:x}=a,h=`${t}/v1/lens`;return await m.postRequest(h,r,{lensId:n,template:o,filterValues:d,isDefault:f,shared:x,operation:"update"})}async function ws(t,a,r){if(!r)return null;const n=`${t}/v1/lens`;return await m.postRequest(n,r,{operation:"delete",lensId:a})}const Ss="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Ds({open:t,onOpenChange:a}={}){const[r,n]=y.useState(""),[o,d]=y.useState(!1),f=m.useDashboardStore(S=>S.lenses),{setLenses:x,setSelectedLensId:h}=m.useDashboardActions(),[j,u]=y.useState(!1),[c,g]=y.useState(!1),l=t!==void 0,b=l?t:c,v=S=>{l||g(S),a==null||a(S)},p=m.useDashboardStore(S=>S.dashboard),D=m.useDashboardStore(S=>S.filterValues),{authToken:N,tokenProps:I}=s.useSemaphorContext();async function C(){u(!0);const S=await js(I.apiServiceUrl,r,p,D,N==null?void 0:N.accessToken);S&&(x([...f||[],S]),h(S.id),v(!1)),u(!1)}return e.jsxs(s.Dialog,{open:b,onOpenChange:v,children:[l?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(m.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(m.Label,{htmlFor:"lens-name",className:Ss,children:"Name"}),e.jsx(m.Input,{id:"lens-name",size:"xs",value:r,placeholder:"Monthly review, West region, …",onChange:S=>n(S.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(m.Button,{variant:"outline",size:"xs",onClick:()=>v(!1),children:"Cancel"}),e.jsx(m.Button,{size:"xs",type:"submit",onClick:C,disabled:j||!r.trim(),children:j?"Creating…":"Create"})]})]})]})}function Ns({includeLabel:t=!1}={}){const a=m.useDashboardStore(u=>u.lenses),r=m.useDashboardStore(u=>u.selectedLensId),{setLenses:n,setSelectedLensId:o}=m.useDashboardActions(),{authToken:d,tokenProps:f}=s.useSemaphorContext();async function x(u){o(u)}async function h(u){if(await ws(f.apiServiceUrl,u,d==null?void 0:d.accessToken)){const g=a==null?void 0:a.filter(l=>l.id!==u);n(g||[]),o("original")}}async function j(u){const c=a==null?void 0:a.map(b=>b.id===u.id?{...b,isDefault:!u.isDefault}:{...b,isDefault:!1});n(c||[]);const g={...u,isDefault:!u.isDefault};await $e(f.apiServiceUrl,g,d==null?void 0:d.accessToken);const l=a==null?void 0:a.find(b=>b.isDefault);if(l&&l.id!==u.id){const b={...l,isDefault:!1};await $e(f.apiServiceUrl,b,d==null?void 0:d.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:x,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(u=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:u.id,children:[e.jsx("p",{children:u.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:c=>{c.preventDefault(),j(u)},className:m.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!u.isDefault,"text-green-500":u.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:c=>{c.preventDefault(),h(u.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},u.id))]})]})}function Cs(){const{displayPreferences:t,shouldShowElement:a}=s.useDisplayPreferences(),{currentUser:r,userContext:n}=s.useCurrentUserInfo(),o=y.useMemo(()=>s.getRoleBasedDisplayOverrides(r),[r]),d=y.useMemo(()=>x=>o&&o[x]!==void 0&&o[x]===!1?!1:a(x),[o,a,t]),f=y.useMemo(()=>{var x,h,j,u,c;return{canEdit:((x=n==null?void 0:n.permissions)==null?void 0:x.canEdit)??s.canUserEdit(r),canUseFilters:((h=n==null?void 0:n.permissions)==null?void 0:h.canEdit)??s.canUserUseFilters(r),canManageDashboards:((j=n==null?void 0:n.permissions)==null?void 0:j.canCreateDashboard)??s.canUserManageDashboards(r),canCreateDashboards:((u=n==null?void 0:n.permissions)==null?void 0:u.canCreateDashboard)??s.canUserCreateDashboards(r),canAccessVisuals:((c=n==null?void 0:n.permissions)==null?void 0:c.canEdit)??s.canUserAccessVisuals(r)}},[r,n]);return{displayPreferences:t,shouldShowElement:d,permissions:f,currentUser:r}}function ks(t,a=[]){let r=[];function n(d,f){const x=k.createContext(f);x.displayName=d+"Context";const h=r.length;r=[...r,f];const j=c=>{var D;const{scope:g,children:l,...b}=c,v=((D=g==null?void 0:g[t])==null?void 0:D[h])||x,p=k.useMemo(()=>b,Object.values(b));return e.jsx(v.Provider,{value:p,children:l})};j.displayName=d+"Provider";function u(c,g){var v;const l=((v=g==null?void 0:g[t])==null?void 0:v[h])||x,b=k.useContext(l);if(b)return b;if(f!==void 0)return f;throw new Error(`\`${c}\` must be used within \`${d}\``)}return[j,u]}const o=()=>{const d=r.map(f=>k.createContext(f));return function(x){const h=(x==null?void 0:x[t])||d;return k.useMemo(()=>({[`__scope${t}`]:{...x,[t]:h}}),[x,h])}};return o.scopeName=t,[n,Es(o,...a)]}function Es(...t){const a=t[0];if(t.length===1)return a;const r=()=>{const n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(d){const f=n.reduce((x,{useScope:h,scopeName:j})=>{const c=h(d)[`__scope${j}`];return{...x,...c}},{});return k.useMemo(()=>({[`__scope${a.scopeName}`]:f}),[f])}};return r.scopeName=a.scopeName,r}var Ls=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ge=Ls.reduce((t,a)=>{const r=m.createSlot(`Primitive.${a}`),n=k.forwardRef((o,d)=>{const{asChild:f,...x}=o,h=f?r:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(h,{...x,ref:d})});return n.displayName=`Primitive.${a}`,{...t,[a]:n}},{});function Ms(){return vs.useSyncExternalStore(Is,()=>!0,()=>!1)}function Is(){return()=>{}}var ze="Avatar",[As]=ks(ze),[Ps,wt]=As(ze),St=k.forwardRef((t,a)=>{const{__scopeAvatar:r,...n}=t,[o,d]=k.useState("idle");return e.jsx(Ps,{scope:r,imageLoadingStatus:o,onImageLoadingStatusChange:d,children:e.jsx(Ge.span,{...n,ref:a})})});St.displayName=ze;var Dt="AvatarImage",Nt=k.forwardRef((t,a)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:o=()=>{},...d}=t,f=wt(Dt,r),x=Os(n,d),h=m.useCallbackRef(j=>{o(j),f.onImageLoadingStatusChange(j)});return m.useLayoutEffect2(()=>{x!=="idle"&&h(x)},[x,h]),x==="loaded"?e.jsx(Ge.img,{...d,ref:a,src:n}):null});Nt.displayName=Dt;var Ct="AvatarFallback",kt=k.forwardRef((t,a)=>{const{__scopeAvatar:r,delayMs:n,...o}=t,d=wt(Ct,r),[f,x]=k.useState(n===void 0);return k.useEffect(()=>{if(n!==void 0){const h=window.setTimeout(()=>x(!0),n);return()=>window.clearTimeout(h)}},[n]),f&&d.imageLoadingStatus!=="loaded"?e.jsx(Ge.span,{...o,ref:a}):null});kt.displayName=Ct;function ft(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Os(t,{referrerPolicy:a,crossOrigin:r}){const n=Ms(),o=k.useRef(null),d=n?(o.current||(o.current=new window.Image),o.current):null,[f,x]=k.useState(()=>ft(d,t));return m.useLayoutEffect2(()=>{x(ft(d,t))},[d,t]),m.useLayoutEffect2(()=>{const h=c=>()=>{x(c)};if(!d)return;const j=h("loaded"),u=h("error");return d.addEventListener("load",j),d.addEventListener("error",u),a&&(d.referrerPolicy=a),typeof r=="string"&&(d.crossOrigin=r),()=>{d.removeEventListener("load",j),d.removeEventListener("error",u)}},[d,r,a]),f}var Et=St,Lt=Nt,Mt=kt;const It=k.forwardRef(({className:t,...a},r)=>e.jsx(Et,{ref:r,className:m.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));It.displayName=Et.displayName;const Rs=k.forwardRef(({className:t,...a},r)=>e.jsx(Lt,{ref:r,className:m.cn("aspect-square h-full w-full",t),...a}));Rs.displayName=Lt.displayName;const At=k.forwardRef(({className:t,...a},r)=>e.jsx(Mt,{ref:r,className:m.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));At.displayName=Mt.displayName;const _s=async(t,a,r)=>{const n=`${t}/management/v1/groups`;return await m.postRequestRegular(n,a,r)},Us=async(t,a,r,n)=>{const o=`${t}/management/v1/groups/${r}`;return m.requestJsonRegular(o,a,"PATCH",n)},Ts=async(t,a,r)=>{const n=`${t}/management/v1/groups/${r}`;await m.requestJsonRegular(n,a,"DELETE")},Fs=async(t,a,r,n)=>{const o=`${t}/management/v1/groups/${r}/members`;return await m.postRequestRegular(o,a,n)},Bs=async(t,a,r,n)=>{const o=`${t}/management/v1/groups/${r}/members`;await m.requestJsonRegular(o,a,"DELETE",n)};function qs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:n=>_s(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n),onSuccess:()=>{r.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:m.getRequestErrorMessage(n,"Failed to create group")})}})}function $s(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>Us(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["group",o.groupId]}),r.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:m.getRequestErrorMessage(n,"Failed to update group")})}})}function Gs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:n=>Ts(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["groups"]}),r.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:m.getRequestErrorMessage(n,"Failed to delete group")})}})}function zs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>Fs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["group",o.groupId]}),r.invalidateQueries({queryKey:["group-members",o.groupId]}),r.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:m.getRequestErrorMessage(n,"Failed to add members")})}})}function Vs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>Bs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["group",o.groupId]}),r.invalidateQueries({queryKey:["group-members",o.groupId]}),r.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:m.getRequestErrorMessage(n,"Failed to remove members")})}})}const Hs=[];function Ks({open:t,onOpenChange:a}){var N,I,C;const{tokenProps:r}=s.useSemaphorContext(),{currentUser:n}=s.useCurrentUserInfo(),o=(n==null?void 0:n.type)==="tenant",d=r==null?void 0:r.tenantId,{groups:f,isLoading:x,error:h,refetch:j}=s.useGroups({type:o?"TENANT_GROUP":"all",tenantId:o?d:void 0,includeMembers:!1}),u=h?Pt(h,"Unable to load groups."):null,[c,g]=y.useState({kind:"list"}),[l,b]=y.useState(null),v=Gs();y.useEffect(()=>{t||(g({kind:"list"}),b(null))},[t]);const p=c.kind==="members"&&f.find(S=>S.id===c.groupId)||null,D=async()=>{if(l)try{await v.mutateAsync(l.id),b(null),g({kind:"list"}),j()}catch{}};return e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[c.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."})]}):c.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,c.kind==="list"&&e.jsx(Qs,{groups:f,isLoading:x,errorMessage:u,onRetry:()=>j(),currentUserId:n==null?void 0:n.id,onOpenGroup:S=>g({kind:"members",groupId:S}),onCreate:()=>g({kind:"create"}),onDeleteRequest:S=>b(S)}),c.kind==="members"&&p&&e.jsx(Xs,{group:p,isTenantViewer:o,canEdit:((N=p.permissions)==null?void 0:N.canEdit)??p.createdBy===(n==null?void 0:n.id),canDelete:((I=p.permissions)==null?void 0:I.canDelete)??p.createdBy===(n==null?void 0:n.id),canManageMembers:((C=p.permissions)==null?void 0:C.canManageMembers)??p.createdBy===(n==null?void 0:n.id),onBack:()=>g({kind:"list"}),onMembersChanged:j,onUpdated:j,onRequestDelete:()=>b(p)},p.id),c.kind==="create"&&e.jsx(Ys,{isTenantUser:o,tenantId:d,onCancel:()=>g({kind:"list"}),onCreated:S=>{j(),g({kind:"members",groupId:S})}}),l&&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:l.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:()=>b(null),disabled:v.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:D,disabled:v.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:[v.isPending?e.jsx(m.LoaderCircle,{className:"h-3 w-3 animate-spin"}):e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})]})]})]})})}function Qs({groups:t,isLoading:a,errorMessage:r,onRetry:n,currentUserId:o,onOpenGroup:d,onCreate:f,onDeleteRequest:x}){const[h,j]=y.useState(""),u=y.useMemo(()=>t.filter(c=>!h.trim()||c.name.toLowerCase().includes(h.toLowerCase())||(c.description||"").toLowerCase().includes(h.toLowerCase())),[t,h]);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(vt.Search,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:h,onChange:c=>j(c.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),h&&e.jsx("button",{type:"button",onClick:()=>j(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(O.X,{className:"h-2.5 w-2.5"})})]}),e.jsxs("button",{type:"button",onClick:f,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:a?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(c=>e.jsx("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},c))}):r?e.jsx(Ot,{title:"Can't load groups",message:r,onRetry:n}):u.length===0&&t.length===0?e.jsx(Js,{onCreate:f}):u.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 "',h,'"']}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):u.map(c=>{var g;return e.jsx(Ws,{group:c,canDelete:((g=c.permissions)==null?void 0:g.canDelete)??c.createdBy===o,onClick:()=>d(c.id),onDelete:()=>x(c)},c.id)})})]})}function Ws({group:t,canDelete:a,onClick:r,onDelete:n}){let o="";try{o=yt.format(new Date(t.createdAt),"MMM d, yyyy")}catch{o=""}return e.jsxs("button",{type:"button",onClick:r,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(s.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:[a&&e.jsx("span",{role:"button",tabIndex:0,onClick:d=>{d.stopPropagation(),n()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.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(vt.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]})}function Js({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 Xs({group:t,isTenantViewer:a,canEdit:r,canDelete:n,canManageMembers:o,onBack:d,onMembersChanged:f,onUpdated:x,onRequestDelete:h}){const{data:j,isLoading:u,error:c,refetch:g}=s.useGroupMembers(t.id),l=(j==null?void 0:j.members)??Hs,b=c?Pt(c,"Unable to load members for this group."):null,v=t.type==="TENANT_GROUP"?"tenant":"organization",{users:p}=s.useUnifiedUsers({type:v,tenantId:t.tenantId||void 0,active:!0,limit:200}),D=y.useMemo(()=>new Set(l.map(w=>w.userId)),[l]),N=zs(),I=Vs(),C=$s(),[S,H]=y.useState(!1),[de,B]=y.useState(t.name),[Ne,q]=y.useState(!1),[Q,$]=y.useState(t.description||""),[W,J]=y.useState(""),[ce,K]=y.useState(!1),Ce=y.useMemo(()=>{const w=W.trim().toLowerCase();return p.filter(A=>!D.has(A.id)).filter(A=>!w||(A.name||"").toLowerCase().includes(w)||(A.email||"").toLowerCase().includes(w)).slice(0,50)},[p,D,W]),X=async()=>{const w=de.trim();if(H(!1),w.length>=3&&w!==t.name)try{await C.mutateAsync({groupId:t.id,data:{name:w}}),x()}catch{}},le=async()=>{const w=Q.trim();if(q(!1),w!==(t.description||""))try{await C.mutateAsync({groupId:t.id,data:{description:w}}),x()}catch{}},ue=async w=>{if(o){J(""),K(!1);try{await N.mutateAsync({groupId:t.id,data:{userIds:[w.id],userType:v==="tenant"?"tenant":"org"}}),g(),f()}catch{}}},ke=async w=>{if(o)try{await I.mutateAsync({groupId:t.id,data:{userIds:[w]}}),g(),f()}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:d,"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"})}),S?e.jsx("input",{autoFocus:!0,value:de,onChange:w=>B(w.target.value),onBlur:X,onKeyDown:w=>{w.key==="Enter"&&X(),w.key==="Escape"&&(B(t.name),H(!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:()=>{r&&(B(t.name),H(!0))},title:r?"Click to rename":t.name,disabled:!r,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"}),l.length," member",l.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:Ne?e.jsxs("div",{children:[e.jsx("textarea",{autoFocus:!0,rows:2,value:Q,onChange:w=>$(w.target.value),maxLength:200,onKeyDown:w=>{w.key==="Escape"&&($(t.description||""),q(!1)),w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&le()},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:[Q.length,"/200 · Esc to cancel · ⌘↩ to save"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{$(t.description||""),q(!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:le,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:()=>{r&&($(t.description||""),q(!0))},disabled:!r,title:r?"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:r?"Add a description…":"No description"}),e.jsxs("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[R?`Created ${R}`:"Recently created",r?" · You can edit this group":""]})]})}),o&&e.jsx(Zs,{query:W,setQuery:J,open:ce,setOpen:K,candidates:Ce,showKindChip:!a,onAdd:ue,busy:N.isPending}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:u?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))}):b?e.jsx(Ot,{title:"Can't load members",message:b,onRetry:()=>g()}):l.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."})]}):l.map(w=>{var A,Y,G,Z,z,me;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:((A=w.user)==null?void 0:A.name)||((Y=w.user)==null?void 0:Y.email)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((G=w.user)==null?void 0:G.name)||((Z=w.user)==null?void 0:Z.email)||"Unknown"}),((z=w.user)==null?void 0:z.email)&&w.user.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:w.user.email})]}),!a&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:w.userType}),e.jsx("button",{type:"button",onClick:()=>ke(w.userId),disabled:!o||I.isPending,"aria-label":`Remove ${((me=w.user)==null?void 0:me.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(O.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:h,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 Ys({isTenantUser:t,tenantId:a,onCancel:r,onCreated:n}){const[o,d]=y.useState(""),[f,x]=y.useState(""),[h,j]=y.useState(null),u=qs(),c=o.trim().length>=3&&o.trim().length<=50,g=async()=>{if(!c)return;j(null);const l={name:o.trim(),description:f.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...t&&a?{tenantId:a}:{}};try{const b=await u.mutateAsync(l),v=b==null?void 0:b.id;v?n(v):r()}catch(b){j(b instanceof Error?b.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(gt,{children:"Name"}),e.jsx("input",{autoFocus:!0,value:o,onChange:l=>d(l.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(gt,{children:"Description (optional)"}),e.jsx("textarea",{rows:2,value:f,onChange:l=>x(l.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:[f.length,"/200"]})]}),h&&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:h})]}),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:r,disabled:u.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:!c||u.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:u.isPending?e.jsxs(e.Fragment,{children:[e.jsx(m.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 Zs({query:t,setQuery:a,open:r,setOpen:n,candidates:o,showKindChip:d,onAdd:f,busy:x}){const h=y.useRef(null),j=y.useRef(null),[u,c]=y.useState(null);y.useLayoutEffect(()=>{if(!r){c(null);return}const l=()=>{const b=h.current;if(!b)return;const v=b.getBoundingClientRect(),p=240,N=window.innerHeight-v.bottom<p+16&&v.top>p;c({left:v.left,top:N?v.top-6:v.bottom+6,width:v.width,above:N})};return l(),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0)}},[r,o.length]),y.useEffect(()=>{if(!r)return;const l=b=>{var p,D;const v=b.target;(p=h.current)!=null&&p.contains(v)||(D=j.current)!=null&&D.contains(v)||n(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r,n]);const g=r&&o.length>0&&u;return e.jsxs("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{ref:h,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(fs,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:t,onChange:l=>{a(l.target.value),n(!0)},onFocus:()=>n(!0),placeholder:"Add a member by name or email…",disabled:x,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"&&as.createPortal(e.jsx("div",{ref:j,style:{position:"fixed",left:u.left,top:u.top,width:u.width,transform:u.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(l=>e.jsxs("button",{type:"button",onClick:()=>f(l),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:l.name||l.email||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:l.name||l.email||"Unknown"}),l.email&&l.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:l.email})]}),d&&l.type&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:l.type==="tenant"?"tenant":"org"})]},l.id))}),document.body)]})}function Pt(t,a){if(!t)return a;if(t instanceof Error){const r=t.message||"",n=r.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return n?n[1]:r||a}return typeof t=="string"?t:a}function Ot({title:t,message:a,onRetry:r}){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:a}),r&&e.jsx("button",{type:"button",onClick:r,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 gt({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 a=t.split(" ").map(r=>r[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:a||"?"})})}function oe(t,a,r){var d,f;const n=(t.controls||[]).find(x=>x.id===r);if(n)return n.label;const o=(f=(d=m.findCardById(t,a))==null?void 0:d.controls)==null?void 0:f.find(x=>x.id===r);return(o==null?void 0:o.label)||r}function ie(t,a){var r;return((r=m.findCardById(t,a))==null?void 0:r.title)||a}function er(t){const{errors:a,dashboard:r}=t;if(!r)return a;const n=new Map;for(const o of a){const d=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(d){const[,u,c]=d,g=`${u}:${c}:missing-metric`;n.has(g)||n.set(g,`"${ie(r,u)}" has an outdated "${oe(r,u,c)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const f=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(f){const[,u,c]=f,g=`${u}:${c}:missing-group-by`;n.has(g)||n.set(g,`"${ie(r,u)}" has an outdated "${oe(r,u,c)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const x=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(x){const[,u,c]=x,g=`${u}:${c}:invalid-metric`;n.has(g)||n.set(g,`"${ie(r,u)}" has an invalid "${oe(r,u,c)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const h=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(h){const[,u,c]=h,g=`${u}:${c}:invalid-group-by`;n.has(g)||n.set(g,`"${ie(r,u)}" has an invalid "${oe(r,u,c)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const j=o.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(j){const[,u,c]=j,g=`${u}:${c}:missing-temporal-group-by`;n.has(g)||n.set(g,`"${ie(r,u)}" can no longer use "${oe(r,u,c)}" 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 tr({visible:t,onSelect:a}){return t?e.jsxs(s.DropdownMenuItem,{onSelect:a,children:[e.jsx(s.CalendarClock,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null}function sr({scheduleReportVisible:t,analyticalBriefingVisible:a,onScheduleReport:r,onCreateAnalyticalBriefing:n}){return e.jsxs(e.Fragment,{children:[e.jsx(tr,{visible:t,onSelect:r}),a?e.jsxs(s.DropdownMenuItem,{onSelect:n,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]})}function bt(t,a){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(a)}}function rr(){var at,ot,it,dt,ct,lt,ut;F.useExportRecovery(),F.useExportPolling();const{authToken:t,tokenProps:a,id:r,showBriefings:n}=s.useSemaphorContext(),o=s.useBriefingUiCapabilities(),{isLocalDev:d}=s.useDashboardPreferences(),{openBrandStudioPreview:f}=s.useBrandStudioPreview(),{permissions:x}=Cs(),h=s.useHasDashboardId(),{isLoading:j}=s.useDashboardQuery(),u=m.useDashboardStore(i=>i.theme),c=m.useDashboardStore(i=>i.isDownloadingPdf),g=m.useDashboardStore(i=>i.dashboardAssistantDraftScopeKey),l=m.useDashboardStore(i=>i.lenses),b=m.useDashboardStore(i=>i.selectedLensId),v=l==null?void 0:l.find(i=>i.id===b),p=m.useDashboardStore(i=>i.dashboard),D=m.useDashboardStore(i=>i.selectedSheetId),N=(at=p==null?void 0:p.sheets)==null?void 0:at.find(i=>i.id===D),I=m.isDocumentSheet(N),C=I?(ot=N==null?void 0:N.document)==null?void 0:ot.page:void 0,S=m.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:H}=m.useDashboardStore(i=>i.actions),[de,B]=y.useState(!1),[Ne,q]=y.useState(!1),[Q,$]=y.useState(!1),[W,J]=y.useState(!1),[ce,K]=y.useState(null),[Ce,X]=y.useState(!1),[le,ue]=y.useState(!1),[ke,R]=y.useState(!1),[w,A]=y.useState(null),[Y,G]=y.useState([]),[Z,z]=y.useState(!1),[me,Ve]=y.useState(!1),_t=m.useDashboardStore(i=>i.filterValues),L=m.useDashboardStore(i=>i.isVisualEditing);m.useEditorStore(i=>i.card);const ee=s.useManagementStore(i=>i.selectedDashboard),pe=s.useManagementStore(i=>i.initialDashboard);s.useManagementStore(i=>i.selectedVisual),m.useDashboardStore(i=>i.selectedFrameId),m.useEditorStore(i=>i.frame);const he=ee?(dt=ee==null?void 0:ee.permissions)==null?void 0:dt.canEdit:(it=pe==null?void 0:pe.permissions)==null?void 0:it.canEdit,He=m.useDashboardStore(i=>i.showDashboardJSON),Ee=m.useDashboardStore(i=>i.onSaveFunction),{setIsDashboardEditing:Ke,setShowDashboardJSON:Qe}=m.useDashboardStore(i=>i.actions),{setInitialDashboard:We,clearSelectedDashboard:Le}=s.useManagementStore(i=>i.actions),te=!!a.orgUserId||!!(a.tenantId&&a.endUserId&&a.endUserEmail),{resources:xe}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Me}=s.useUserPreferences(),Ut=((ct=Me==null?void 0:Me.preference)==null?void 0:ct.defaultDashboardId)||null,{mutate:Tt,isPending:Ft}=s.useDefaultDashboardMutation(),{currentUser:Bt}=s.useCurrentUserInfo(),qt=s.canUserManageGroups(Bt),_=ee||pe,Je=_?{id:_.id,title:(p==null?void 0:p.title)||_.title||"Dashboard"}:null,{handleAddNewFrame:$t}=s.useAddNewFrame(),[Ie,Ae]=y.useState(!1),[Gt,se]=y.useState(!1),[Pe,fe]=y.useState("close"),re=s.useUpdateResource(s.ResourceType.DASHBOARD),[P,ge]=y.useState(null),zt=async(i,E)=>{if(!(p!=null&&p.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:p.id,newTitle:i,previousTitle:E}),re.mutate({resourceId:p.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:T=>{console.error("Failed to update dashboard title:",T),s.ue.error("Failed to update dashboard title"),H(E)}})};y.useEffect(()=>{if(xe&&xe.length>0){const i=p==null?void 0:p.id;if(i){const E=xe.find(T=>T.id===i);E&&We(E)}}},[xe,p==null?void 0:p.id,We]);const ne=a.orgUserId||a.tenantId,Oe=y.useMemo(()=>nr({accessToken:t==null?void 0:t.accessToken,dashboardId:(p==null?void 0:p.id)||r||a.dashboard_id,selectedSheetId:I?D:void 0,pageSize:C==null?void 0:C.size,orientation:C==null?void 0:C.orientation,theme:u}),[t==null?void 0:t.accessToken,r,p==null?void 0:p.id,I,C==null?void 0:C.orientation,C==null?void 0:C.size,D,u,a.dashboard_id]),Xe=S&&!L&&ne&&he,{setDashboard:Ye}=m.useDashboardStore(i=>i.actions),Ze=m.useDashboardStore(i=>i.semanticExecutionPayload),Vt=()=>{Ke(!0)},Re=()=>{Ke(!1),Qe(!1),ge(null)};y.useEffect(()=>{if(!S){P&&ge(null);return}P||!p||j||ge(bt(p,Ze))},[p,P,S,j,Ze]);const be=(P==null?void 0:P.dashboard)??null,{isDirty:et,isDirtyPending:Ht,resetDirty:ve}=is.useDebouncedDirtyCheck(p,be,300,1e3,Te.serializeDashboardForDirtyCheck),tt=y.useCallback(()=>be?Te.serializeDashboardForDirtyCheck(p)!==Te.serializeDashboardForDirtyCheck(be):!1,[p,be]),st=et||Ht,ye=Ie||re.isPending,Kt=()=>{tt()?(fe("close"),se(!0)):(Re(),ve())},Qt=async()=>{await _e({closeAfterSave:!0,navigateHomeAfterSave:Pe==="home"})},Wt=()=>{const i=Pe==="home"&&!!te;P&&Ye(P.dashboard,{semanticExecutionPayload:P.semanticExecutionPayload}),Re(),i&&Le(),fe("close"),se(!1),ve()},Jt=()=>{P&&(Ye(P.dashboard,{semanticExecutionPayload:P.semanticExecutionPayload}),ve())},Xt=()=>{if(te){if(S&&tt()){fe("home"),se(!0);return}Le()}};async function _e(i){const E=m.useDashboardStore.getState().dashboard;if(!E)return;const T=(i==null?void 0:i.closeAfterSave)??Z,ss=(i==null?void 0:i.navigateHomeAfterSave)??!1;z(T),T&&se(!1);const rs=s.cloneDeep(E);R(!0),A(null),G([]),Ae(!0);const ns={template:E};re.mutate({resourceId:E.id,data:ns},{onSuccess:M=>{var je,we,mt;const V=(M==null?void 0:M.id)||((je=M==null?void 0:M.dashboard)==null?void 0:je.id)||((we=M==null?void 0:M.resource)==null?void 0:we.id)||((mt=M==null?void 0:M.template)==null?void 0:mt.id)||null;if(!E.id&&V){const Ue=m.useAIInteractionStore.getState(),Se=Ue.pendingDashboardDraftMigration;(Se==null?void 0:Se.scopeKey)===g?Ue.actions.setPendingDashboardDraftMigrationExpectedDashboardId(V):Se&&Ue.actions.clearPendingDashboardDraftMigration()}Ae(!1),s.ue.success("Dashboard saved!"),ge(bt(rs,m.useDashboardStore.getState().semanticExecutionPayload)),R(!1),z(!1),T&&(Re(),ve(),ss&&te&&Le()),fe("close")},onError:M=>{Ae(!1),A("Failed to save dashboard. Please try again.");const V=M.details,je=Array.isArray(V==null?void 0:V.errors)?(V.errors||[]).filter(we=>typeof we=="string"):[];G(er({errors:je,dashboard:E||void 0})),s.ue.error("Failed to save dashboard")}})}async function Yt(){if(B(!0),!b||!v)return;const i=m.useDashboardStore.getState().dashboard;if(!i){B(!1);return}const E=JSON.stringify(i),T={...v,template:E,filterValues:_t};await $e(a.apiServiceUrl,T,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Ee==null||Ee(i),B(!1)}const rt=(v==null?void 0:v.name)||p.title;re.isPending&&console.log("Title during update:",{title:rt,dashboardStateTitle:p.title,dashboardId:p==null?void 0:p.id,currentLensName:v==null?void 0:v.name});const Zt=te&&!!(t!=null&&t.accessToken)&&!!(a!=null&&a.apiServiceUrl),es=h&&te,U=(p==null?void 0:p.id)||null,nt=s.resolveDashboardBriefingsVisibility((lt=a.config)==null?void 0:lt.showBriefings,n),ae=!!U&&Ut===U,ts=()=>{U&&Tt({dashboardId:ae?null:U})};return!h&&!L?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:[es&&!L&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Xt,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})}),!L&&h&&(j?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:rt||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:he,dashboardId:p==null?void 0:p.id});const E=(p==null?void 0:p.title)||"";H(i),zt(i,E)},isEditable:he&&!v,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:re.isPending}),ae&&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"}),Zt&&U&&e.jsx(m.TooltipProvider,{children:e.jsxs(m.Tooltip,{children:[e.jsx(m.TooltipTrigger,{asChild:!0,children:e.jsx(m.Button,{variant:"ghost",size:"xs",onClick:ts,disabled:Ft||!(t!=null&&t.accessToken)||!(a!=null&&a.apiServiceUrl),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":ae?"Clear default dashboard":"Set as default dashboard",children:ae?e.jsx(s.PinOff,{className:"h-3.5 w-3.5"}):e.jsx(s.Pin,{className:"h-3.5 w-3.5"})})}),e.jsx(m.TooltipContent,{children:e.jsx("p",{children:ae?"Clear default":"Set as default"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[L&&e.jsxs(e.Fragment,{children:[e.jsx(F.AdvancedModeToggle,{}),e.jsx(F.VisualEditingControls,{})]}),!L&&h&&((ut=_==null?void 0:_.permissions)==null?void 0:ut.canShare)&&e.jsxs(m.Button,{variant:"outline",size:"xs",onClick:()=>q(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!L&&S&&x.canUseFilters&&h&&e.jsx(F.DashboardFilterControlsLauncher,{}),S&&!L&&ne&&v&&d&&h&&e.jsxs(m.Button,{variant:"secondary",size:"xs",disabled:de,onClick:Yt,children:[e.jsx(pt.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),S&&!L&&h&&!I&&e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[e.jsxs(m.Button,{variant:"ghost",size:"xs",disabled:!S,onClick:()=>void $t(),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(m.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:!S,children:e.jsx(O.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:()=>Ve(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),e.jsx(F.VisualsLibraryDialog,{open:me,onOpenChange:Ve})]}),!L&&!S&&he&&h&&e.jsxs(m.Button,{size:"xs",onClick:Vt,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Xe&&h&&et&&e.jsxs(m.Button,{variant:"outline",size:"xs",onClick:Jt,disabled:ye,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),Xe&&h&&e.jsxs(m.Button,{size:"xs",className:m.cn(!st&&"opacity-60"),disabled:ye||!st,onClick:()=>_e(),children:[ye?e.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(pt.Save,{className:"h-3.5 w-3.5"}),ye?"Saving...":"Save"]}),S&&!L&&h&&e.jsxs(m.Button,{variant:"outline",size:"xs",onClick:Kt,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!L&&h&&e.jsx("div",{className:"ml-2",children:e.jsx(F.NotificationBell,{})}),!L&&d&&e.jsx(ys,{}),!L&&h&&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 & briefings"}),e.jsxs(s.DropdownMenuItem,{disabled:c,onSelect:()=>ue(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsx(sr,{scheduleReportVisible:!!(nt&&o.surfaceVisible&&U&&!S),analyticalBriefingVisible:!!(nt&&o.surfaceVisible&&U&&!S),onScheduleReport:()=>K("scheduled_report"),onCreateAnalyticalBriefing:()=>K("analytical_briefing")}),e.jsx(s.DropdownMenuSeparator,{}),qt&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$(!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:()=>J(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),d&&h&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var i;t!=null&&t.accessToken&&((i=navigator==null?void 0:navigator.clipboard)!=null&&i.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"]}),I&&e.jsxs(s.DropdownMenuItem,{disabled:!Oe,onSelect:()=>{var i;if(!Oe){s.ue.error("Open a document sheet with a token to copy the local PDF URL");return}(i=navigator==null?void 0:navigator.clipboard)!=null&&i.writeText?navigator.clipboard.writeText(Oe).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:()=>m.invalidateToken(a.apiServiceUrl),children:[e.jsx(hs,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:f,children:[e.jsx(ds.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),S&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Qe(!He),children:[e.jsx(cs.Braces,{className:"h-3.5 w-3.5"}),He?"Hide dashboard JSON":"Show dashboard JSON"]}),ne&&S&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>X(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),ne&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(Ns,{})})]})]})]})]}),Ne&&Je&&e.jsx(s.ShareDialog,{resource:Je,resourceType:s.ResourceType.DASHBOARD,onClose:()=>q(!1)}),e.jsx(Ks,{open:Q,onOpenChange:$}),e.jsx(os.CalendarPreferencesDialog,{open:W,onOpenChange:J}),U&&ce?e.jsx(F.DashboardBriefingLauncher,{dashboardId:U,dashboardTitle:(p==null?void 0:p.title)||(_==null?void 0:_.title),open:!0,onOpenChange:i=>{i||K(null)},hideTrigger:!0,workflowIntent:ce}):null,d&&ne&&h&&e.jsx(Ds,{open:Ce,onOpenChange:X}),h&&e.jsx(s.DownloadPdf,{open:le,onOpenChange:ue}),e.jsx(s.AlertDialog,{open:ke,onOpenChange:i=>{!i&&Ie&&!w||(R(i),i||(A(null),G([]),z(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:w?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:w?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),Y.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:Y.slice(0,5).map(i=>e.jsx("li",{children:i},i))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:w?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{R(!1),A(null),G([]),z(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>_e({closeAfterSave:Z,navigateHomeAfterSave:Pe==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(m.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(F.UnsavedChangesAlert,{open:Gt,onOpenChange:i=>{se(i)},onSave:Qt,onDiscard:Wt,isSaving:Ie,saveLabel:"Save",discardLabel:"Discard"})]})]})}function nr({accessToken:t,dashboardId:a,selectedSheetId:r,pageSize:n,orientation:o,theme:d}){if(!t||!r)return null;const f=new URL("http://localhost:5173/print-document");f.searchParams.set("token",t),a&&f.searchParams.set("dashboardId",a),f.searchParams.set("selectedSheetId",r),d&&f.searchParams.set("theme",d);const x=new URL("http://127.0.0.1:3002/");return x.searchParams.set("pdfMode","document"),x.searchParams.set("pageSize",n||"letter"),x.searchParams.set("orientation",o||"portrait"),x.searchParams.set("url",f.toString()),x.toString()}exports.default=rr;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),o=require("react"),b=require("./x-B6ghREd2.js"),s=require("./switch-DMT7qf_R.js");require("./analyze-result-contract-DpDcImgk.js");require("./index-BPM3gDRw.js");require("./index-DRlMUglg.js");require("react-dom");require("../briefings/index.cjs");function S(){const t=s.useDashboardStore(e=>e.dashboard),c=s.useDashboardStore(e=>e.actions.setDashboard),u=s.useDashboardStore(e=>e.showDashboardJSON),h=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),r=o.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,i]=o.useState(r),n=o.useRef(r);return o.useEffect(()=>{r!==n.current&&(i(r),n.current=r)},[r]),a.jsxs("div",{className:s.cn("relative p-2",{hidden:!u}),children:[a.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>h(!1),children:[a.jsx(b.X,{className:"mr-2 h-4 w-4"}),"Close"]}),a.jsx("div",{className:"h-[550px] overflow-hidden",children:a.jsx(s.CodeEditor,{value:l,onValueChange:e=>{i(e);try{const d=JSON.parse(e);n.current=JSON.stringify(d,null,2),c(d)}catch{}},language:"json"})})]})}exports.default=S;
@@ -1,22 +1,23 @@
1
1
  import { jsxs as d, jsx as t } from "react/jsx-runtime";
2
2
  import { useMemo as m, useState as f, useRef as b, useEffect as p } from "react";
3
3
  import { X as S } from "./x-CXDkqdur.js";
4
- import { u as o, c as N, B as D, C as J } from "./switch-TbCsyhv9.js";
5
- import "./analyze-result-contract-sWcmvBOA.js";
6
- import "./index-CH2ZzQo4.js";
4
+ import { u as o, c as N, B as D, C as J } from "./switch-2bh3Hka1.js";
5
+ import "./analyze-result-contract-D7pjjYPy.js";
6
+ import "./index-yHe0SeLO.js";
7
7
  import "./index-CJdxSyQq.js";
8
8
  import "react-dom";
9
- function j() {
10
- const e = o((s) => s.dashboard), c = o((s) => s.actions.setDashboard), h = o(
9
+ import "../briefings/index.js";
10
+ function z() {
11
+ const r = o((s) => s.dashboard), c = o((s) => s.actions.setDashboard), h = o(
11
12
  (s) => s.showDashboardJSON
12
13
  ), l = o(
13
14
  (s) => s.actions.setShowDashboardJSON
14
15
  ), a = m(
15
- () => e ? JSON.stringify(e, null, 2) : "",
16
- [e]
17
- ), [u, n] = f(a), r = b(a);
16
+ () => r ? JSON.stringify(r, null, 2) : "",
17
+ [r]
18
+ ), [u, n] = f(a), e = b(a);
18
19
  return p(() => {
19
- a !== r.current && (n(a), r.current = a);
20
+ a !== e.current && (n(a), e.current = a);
20
21
  }, [a]), /* @__PURE__ */ d(
21
22
  "div",
22
23
  {
@@ -45,7 +46,7 @@ function j() {
45
46
  n(s);
46
47
  try {
47
48
  const i = JSON.parse(s);
48
- r.current = JSON.stringify(
49
+ e.current = JSON.stringify(
49
50
  i,
50
51
  null,
51
52
  2
@@ -61,5 +62,5 @@ function j() {
61
62
  );
62
63
  }
63
64
  export {
64
- j as default
65
+ z as default
65
66
  };