react-semaphor 0.1.445 → 0.1.447
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.js +8 -8
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +9 -9
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{analyze-result-contract-DUv3QnMl.js → analyze-result-contract-T-0Ntzys.js} +1 -1
- package/dist/chunks/{braces-BdbUk_r9.js → braces-8TRlDwDw.js} +1 -1
- package/dist/chunks/{braces-BKimshER.cjs → braces-v55uLCAK.cjs} +1 -1
- package/dist/chunks/{catalog-field-grounding-AOGwWu0K.js → catalog-field-grounding-S2jKwKGD.js} +9 -9
- package/dist/chunks/{common-types-DFsDdpH7.js → common-types-B7Jk3Rtj.js} +5 -5
- package/dist/chunks/{dashboard-briefing-launcher-2SLNOaTg.js → dashboard-briefing-launcher-CDjcivK2.js} +192 -191
- package/dist/chunks/dashboard-briefing-launcher-D44Au-Qp.cjs +26 -0
- package/dist/chunks/dashboard-controls-DH3J4L1D.cjs +52 -0
- package/dist/chunks/dashboard-controls-tHwb3g3W.js +2409 -0
- package/dist/chunks/{dashboard-date-comparison-definition-BaYxjLi5.js → dashboard-date-comparison-definition-Ba-clViK.js} +1 -1
- package/dist/chunks/{dashboard-input-contract-BFpERluO.js → dashboard-input-contract-DSt8dGzP.js} +4 -4
- package/dist/chunks/{dashboard-json-BZwq3EcS.js → dashboard-json-Bihrrl5_.js} +11 -11
- package/dist/chunks/dashboard-json-VOXcUBqx.cjs +1 -0
- package/dist/chunks/edit-dashboard-visual-8XtuSSKG.cjs +177 -0
- package/dist/chunks/{edit-dashboard-visual-njLPYip3.js → edit-dashboard-visual-Dsc9mZnc.js} +7113 -7097
- package/dist/chunks/{editor-action-buttons-CBVMFipA.cjs → editor-action-buttons-BFqvBlLw.cjs} +1 -1
- package/dist/chunks/{editor-action-buttons-BhLX5Q6m.js → editor-action-buttons-BbVgPOda.js} +41 -41
- package/dist/chunks/{format-types-CZH5w1lo.js → format-types-DZGgYj39.js} +5 -5
- package/dist/chunks/index-BSTyv45D.cjs +1395 -0
- package/dist/chunks/{index-If0wlXGi.js → index-CJdxSyQq.js} +308 -308
- package/dist/chunks/{index-Dpm_VET4.cjs → index-DRlMUglg.cjs} +2 -2
- package/dist/chunks/{dashboard-u61yfU6u.js → index-srGACKDr.js} +148223 -151540
- package/dist/chunks/{layout-grid-D5tYJg1-.js → layout-grid-CiubineE.js} +1 -1
- package/dist/chunks/{layout-grid-3-HWzEwU.cjs → layout-grid-xm8pqtx0.cjs} +1 -1
- package/dist/chunks/{metric-comparison-BJ_Qu1ZF.js → metric-comparison-97zHGEx5.js} +7 -7
- package/dist/chunks/mouse-pointer-2-BZvGk45-.js +19 -0
- package/dist/chunks/mouse-pointer-2-DX4A_XZw.cjs +6 -0
- package/dist/chunks/{palette-DW_l7Jr0.cjs → palette-BN-jYtaK.cjs} +1 -1
- package/dist/chunks/{palette-jqaAcwiQ.js → palette-Cp1hqZtm.js} +1 -1
- package/dist/chunks/{pivot-result-identity-B6QCWOSi.js → pivot-result-identity-CwJWpKI7.js} +3 -3
- package/dist/chunks/{pivot-result-lifecycle-BM3Pl-D1.js → pivot-result-lifecycle-BBabQ_da.js} +27 -27
- package/dist/chunks/{presentation-execution-CGlb7YZ6.js → presentation-execution-BLfPTGX_.js} +10 -10
- package/dist/chunks/{report-preferences-dialog-D_NJu2wU.js → report-preferences-dialog-DZez53xw.js} +6 -6
- package/dist/chunks/report-preferences-dialog-TYTIHpHi.cjs +1 -0
- package/dist/chunks/{report-runtime-context-Qzn11HQe.js → report-runtime-context-bCy3CVzK.js} +1 -1
- package/dist/chunks/{save-4_uMnE6s.cjs → save-3dYRmehL.cjs} +1 -1
- package/dist/chunks/{save-HCJjjzdX.js → save-DgMfP0j8.js} +1 -1
- package/dist/chunks/{search-DHZCro8B.js → search-BHsQIWBV.js} +1 -1
- package/dist/chunks/{search-6ZmeMq55.cjs → search-BqqhaMx9.cjs} +1 -1
- package/dist/chunks/{code-editor-B4gTfvc5.js → switch-Bz2uj3q0.js} +9405 -9330
- package/dist/chunks/switch-rbwGjmad.cjs +138 -0
- package/dist/chunks/{temporal-bucket-authoring-BUZMuVca.js → temporal-bucket-authoring-CgOuakGW.js} +2 -2
- package/dist/chunks/{temporal-bucket-contract-B2bJ1oe4.js → temporal-bucket-contract-_F6vNhhH.js} +3 -3
- package/dist/chunks/{temporal-result-owner-Cb27SSG9.js → temporal-result-owner-6peubmhU.js} +3 -3
- package/dist/chunks/{token-types-DLo91nOf.js → token-types-BHR58aTy.js} +1 -1
- package/dist/chunks/{update-policy-eg59mQqv.js → update-policy-g0rCQ9BM.js} +9 -9
- package/dist/chunks/{validators-wZ2WlNHc.js → validators-Cs74WVie.js} +46 -46
- package/dist/chunks/x-B6ghREd2.cjs +31 -0
- package/dist/chunks/{index-xHCrHprY.js → x-CXDkqdur.js} +59 -59
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +6 -6
- package/dist/data-app-builder/index.cjs +13 -18
- package/dist/data-app-builder/index.js +92 -106
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +6 -6
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.js +4 -4
- package/dist/format-utils/index.js +8 -8
- package/dist/index.cjs +1 -1
- package/dist/index.js +16 -16
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/brand-studio.d.ts +2 -2
- package/dist/types/dashboard.d.ts +3 -2
- package/dist/types/data-app-builder.d.ts +2 -2
- package/dist/types/data-app-sdk.d.ts +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +7 -7
- package/dist/types/main.d.ts +27 -25
- package/dist/types/surfboard.d.ts +3 -2
- package/package.json +1 -2
- package/dist/chunks/code-editor-BYVorgOf.cjs +0 -138
- package/dist/chunks/dashboard-CAiwJW3L.cjs +0 -1397
- package/dist/chunks/dashboard-briefing-launcher-CHwjpUYz.cjs +0 -26
- package/dist/chunks/dashboard-controls-BfL14aqO.js +0 -2238
- package/dist/chunks/dashboard-controls-BgGTg4yw.cjs +0 -36
- package/dist/chunks/dashboard-json-BOv8tCa9.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-BdVCH0DJ.cjs +0 -182
- package/dist/chunks/index-jSrCwPQz.cjs +0 -31
- package/dist/chunks/report-preferences-dialog-r8QzOSFb.cjs +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./code-editor-BYVorgOf.cjs"),t=require("./dashboard-CAiwJW3L.cjs"),T=require("./index-jSrCwPQz.cjs");require("./validators-9D4KBqKD.cjs");require("./analyze-result-contract-BHb7sUUW.cjs");require("../value-format-preferences/index.cjs");const g=require("react");require("./index-Dpm_VET4.cjs");require("./temporal-bucket-authoring-CPTwHzvs.cjs");require("./temporal-result-owner-f6-i65Fb.cjs");const st=require("react-dom");require("../briefings/index.cjs");const $=require("./dashboard-briefing-launcher-CHwjpUYz.cjs"),vs=require("./search-6ZmeMq55.cjs"),ys=require("./format-types-CSv0V7mm.cjs"),tt=require("./report-preferences-dialog-r8QzOSFb.cjs"),rt=require("./use-debounced-dirty-check-XHSwAefL.cjs"),Be=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.cjs"),xs=require("./save-4_uMnE6s.cjs"),at=require("./palette-DW_l7Jr0.cjs"),nt=require("./braces-BKimshER.cjs");function ot(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>s[a]})}}return n.default=s,Object.freeze(n)}const A=ot(g);/**
|
|
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 it=T.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 dt=T.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 lt=T.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 ct=T.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 ut=T.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 mt=T.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 js=T.createLucideIcon("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]),Me=["light","dark","system"];function ht(){const{theme:s,setTheme:n}=t.useTheme(),a=d.useDashboardStore(h=>h.actions.setDashboardTheme);function r(){const h=Me.includes(s)?s:"system",x=Me[(Me.indexOf(h)+1)%Me.length];n(x),a(x)}const o=s==="light"?ut:s==="dark"?lt:dt,u=s==="light"?"Theme: light (click for dark)":s==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(d.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":u,title:u,children:e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}function ws(s){const n=new Date().toISOString(),a=t.buildDashboardSheetsInputExecutionSnapshot({dashboard:s.dashboard,sheetIds:(s.dashboard.sheets||[]).filter(r=>r.kind!=="document").map(r=>r.id),sheetKind:"dashboard",mode:"dashboard",generatedAt:n,runtimeValues:{dashboardInputValues:s.dashboardInputValues,filterValues:s.filterValues,controlValues:s.controlValues,inlineFilterValuesMap:s.inlineFilterValuesMap,cardControlValuesMap:s.cardControlValuesMap}}).snapshot;return{generatedAt:n,dashboardInputValues:a.dashboardInputValues}}async function pt(s,n,a,r,o,u){if(!u)return null;const h=JSON.stringify(a),x=`${s}/v1/lens`;return await d.postRequest(x,u,{name:n,template:h,filterValues:r,inputValues:o,operation:"create"})}async function Ge(s,n,a){if(!a)return null;const{id:r,template:o,filterValues:u,inputValues:h,isDefault:x,shared:v}=n,f=`${s}/v1/lens`;return await d.postRequest(f,a,{lensId:r,template:o,filterValues:u,inputValues:h,isDefault:x,shared:v,operation:"update"})}async function xt(s,n,a){if(!a)return null;const r=`${s}/v1/lens`;return await d.postRequest(r,a,{operation:"delete",lensId:n})}const ft="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function gt({open:s,onOpenChange:n}={}){const[a,r]=g.useState(""),[o,u]=g.useState(!1),h=d.useDashboardStore(c=>c.lenses),{setLenses:x,setSelectedLensId:v}=d.useDashboardActions(),[f,l]=g.useState(!1),[p,y]=g.useState(!1),m=s!==void 0,j=m?s:p,w=c=>{m||y(c),n==null||n(c)},D=d.useDashboardStore(c=>c.dashboard),P=d.useDashboardStore(c=>c.filterValues),{authToken:C,tokenProps:F}=t.useSemaphorContext();async function S(){l(!0);const c=d.useDashboardStore.getState(),O=ws({dashboard:D,dashboardInputValues:c.dashboardInputValues,filterValues:P,controlValues:c.controlValues,inlineFilterValuesMap:c.inlineFilterValuesMap,cardControlValuesMap:c.cardControlValuesMap}),U=await pt(F.apiServiceUrl,a,D,P,O,C==null?void 0:C.accessToken);U&&(x([...h||[],U]),v(U.id),w(!1)),l(!1)}return e.jsxs(t.Dialog,{open:j,onOpenChange:w,children:[m?null:e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsxs(d.Button,{variant:"secondary",size:"xs",children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(t.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(t.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(d.Label,{htmlFor:"lens-name",className:ft,children:"Name"}),e.jsx(d.Input,{id:"lens-name",size:"xs",value:a,placeholder:"Monthly review, West region, …",onChange:c=>r(c.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(t.DialogFooter,{children:[e.jsx(d.Button,{variant:"outline",size:"xs",onClick:()=>w(!1),children:"Cancel"}),e.jsx(d.Button,{size:"xs",type:"submit",onClick:S,disabled:f||!a.trim(),children:f?"Creating…":"Create"})]})]})]})}function bt({includeLabel:s=!1}={}){const n=d.useDashboardStore(l=>l.lenses),a=d.useDashboardStore(l=>l.selectedLensId),{setLenses:r,setSelectedLensId:o}=d.useDashboardActions(),{authToken:u,tokenProps:h}=t.useSemaphorContext();async function x(l){o(l)}async function v(l){if(await xt(h.apiServiceUrl,l,u==null?void 0:u.accessToken)){const y=n==null?void 0:n.filter(m=>m.id!==l);r(y||[]),o("original")}}async function f(l){const p=n==null?void 0:n.map(j=>j.id===l.id?{...j,isDefault:!l.isDefault}:{...j,isDefault:!1});r(p||[]);const y={...l,isDefault:!l.isDefault};await Ge(h.apiServiceUrl,y,u==null?void 0:u.accessToken);const m=n==null?void 0:n.find(j=>j.isDefault);if(m&&m.id!==l.id){const j={...m,isDefault:!1};await Ge(h.apiServiceUrl,j,u==null?void 0:u.accessToken)}}return e.jsxs(e.Fragment,{children:[s?e.jsxs(e.Fragment,{children:[e.jsx(t.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(t.DropdownMenuSeparator,{})]}):null,e.jsxs(t.DropdownMenuRadioGroup,{value:a,onValueChange:x,children:[e.jsx(t.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(l=>e.jsxs(t.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(t.House,{onClick:p=>{p.preventDefault(),f(l)},className:d.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(t.Cross2Icon,{onClick:p=>{p.preventDefault(),v(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 vt(){const{displayPreferences:s,shouldShowElement:n}=t.useDisplayPreferences(),{currentUser:a,userContext:r}=t.useCurrentUserInfo(),o=g.useMemo(()=>t.getRoleBasedDisplayOverrides(a),[a]),u=g.useMemo(()=>x=>o&&o[x]!==void 0&&o[x]===!1?!1:n(x),[o,n,s]),h=g.useMemo(()=>{var x,v,f,l,p;return{canEdit:((x=r==null?void 0:r.permissions)==null?void 0:x.canEdit)??t.canUserEdit(a),canUseFilters:((v=r==null?void 0:r.permissions)==null?void 0:v.canEdit)??t.canUserUseFilters(a),canManageDashboards:((f=r==null?void 0:r.permissions)==null?void 0:f.canCreateDashboard)??t.canUserManageDashboards(a),canCreateDashboards:((l=r==null?void 0:r.permissions)==null?void 0:l.canCreateDashboard)??t.canUserCreateDashboards(a),canAccessVisuals:((p=r==null?void 0:r.permissions)==null?void 0:p.canEdit)??t.canUserAccessVisuals(a)}},[a,r]);return{displayPreferences:s,shouldShowElement:u,permissions:h,currentUser:a}}var $e="Avatar",[yt]=d.createContextScope($e),jt=[0,()=>{}],[wt,Ds]=yt($e),ze=A.forwardRef((s,n)=>{const{__scopeAvatar:a,...r}=s,[o,u]=A.useState("idle"),[h,x]=Nt();return e.jsx(wt,{scope:a,imageLoadingStatus:o,setImageLoadingStatus:u,imageCount:h,setImageCount:x,children:e.jsx(d.Primitive.span,{...r,ref:n})})});ze.displayName=$e;var Ns="AvatarImage",_e=A.forwardRef((s,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:o,...u}=s,h=Ds(Ns,a);St(h.setImageCount);const x=Dt(r,{referrerPolicy:u.referrerPolicy,crossOrigin:u.crossOrigin,loadingStatus:h.imageLoadingStatus,setLoadingStatus:h.setImageLoadingStatus}),v=d.useCallbackRef(l=>{o==null||o(l)}),f=A.useRef(x);return d.useLayoutEffect2(()=>{const l=f.current;f.current=x,x!==l&&v(x)},[x,v]),x==="loaded"?e.jsx(d.Primitive.img,{...u,ref:n,src:r}):null});_e.displayName=Ns;var Ss="AvatarFallback",He=A.forwardRef((s,n)=>{const{__scopeAvatar:a,delayMs:r,...o}=s,u=Ds(Ss,a),[h,x]=A.useState(r===void 0);return A.useEffect(()=>{if(r!==void 0){const v=window.setTimeout(()=>x(!0),r);return()=>window.clearTimeout(v)}},[r]),h&&u.imageLoadingStatus!=="loaded"?e.jsx(d.Primitive.span,{...o,ref:n}):null});He.displayName=Ss;function Dt(s,{loadingStatus:n,setLoadingStatus:a,referrerPolicy:r,crossOrigin:o}){return d.useLayoutEffect2(()=>{if(!s){a("error");return}const u=new window.Image,h=v=>{const f=v.currentTarget;a(fs(f))},x=()=>a("error");return u.addEventListener("load",h),u.addEventListener("error",x),r&&(u.referrerPolicy=r),u.crossOrigin=o??null,u.src=s,a(fs(u)),()=>{u.removeEventListener("load",h),u.removeEventListener("error",x),a("idle")}},[s,o,r,a]),n}function fs(s){return s.complete?s.naturalWidth>0?"loaded":"error":"loading"}function Nt(){let s=jt;{s=A.useState(0);const[n]=s,a=A.useRef(!1);A.useEffect(()=>{n>1&&!a.current&&(a.current=!0,console.warn("Avatar: Only one `Avatar.Image` component should be rendered per `Avatar.Root`, but multiple were detected. This will lead to unexpected behavior."))},[n])}return s}function St(s){A.useEffect(()=>(s(n=>n+1),()=>{s(n=>n-1)}),[s])}const Cs=A.forwardRef(({className:s,...n},a)=>e.jsx(ze,{ref:a,className:d.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));Cs.displayName=ze.displayName;const Ct=A.forwardRef(({className:s,...n},a)=>e.jsx(_e,{ref:a,className:d.cn("aspect-square h-full w-full",s),...n}));Ct.displayName=_e.displayName;const ks=A.forwardRef(({className:s,...n},a)=>e.jsx(He,{ref:a,className:d.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ks.displayName=He.displayName;const kt=async(s,n,a)=>{const r=`${s}/management/v1/groups`;return await d.postRequestRegular(r,n,a)},Mt=async(s,n,a,r)=>{const o=`${s}/management/v1/groups/${a}`;return d.requestJsonRegular(o,n,"PATCH",r)},It=async(s,n,a)=>{const r=`${s}/management/v1/groups/${a}`;await d.requestJsonRegular(r,n,"DELETE")},Lt=async(s,n,a,r)=>{const o=`${s}/management/v1/groups/${a}/members`;return await d.postRequestRegular(o,n,r)},Et=async(s,n,a,r)=>{const o=`${s}/management/v1/groups/${a}/members`;await d.requestJsonRegular(o,n,"DELETE",r)};function At(){const{authToken:s,tokenProps:n}=t.useSemaphorContext(),a=t.useQueryClient();return t.useMutation({mutationFn:r=>kt(n.apiServiceUrl,(s==null?void 0:s.accessToken)||"",r),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),t.ue.success("Group created successfully")},onError:r=>{console.error("Failed to create group:",r),t.ue.error("Failed to create group",{description:d.getRequestErrorMessage(r,"Failed to create group")})}})}function Pt(){const{authToken:s,tokenProps:n}=t.useSemaphorContext(),a=t.useQueryClient();return t.useMutation({mutationFn:({groupId:r,data:o})=>Mt(n.apiServiceUrl,(s==null?void 0:s.accessToken)||"",r,o),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["groups"]}),t.ue.success("Group updated successfully")},onError:r=>{console.error("Failed to update group:",r),t.ue.error("Failed to update group",{description:d.getRequestErrorMessage(r,"Failed to update group")})}})}function Rt(){const{authToken:s,tokenProps:n}=t.useSemaphorContext(),a=t.useQueryClient();return t.useMutation({mutationFn:r=>It(n.apiServiceUrl,(s==null?void 0:s.accessToken)||"",r),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",o]}),t.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),t.ue.error("Failed to delete group",{description:d.getRequestErrorMessage(r,"Failed to delete group")})}})}function Ut(){const{authToken:s,tokenProps:n}=t.useSemaphorContext(),a=t.useQueryClient();return t.useMutation({mutationFn:({groupId:r,data:o})=>Lt(n.apiServiceUrl,(s==null?void 0:s.accessToken)||"",r,o),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["group-members",o.groupId]}),a.invalidateQueries({queryKey:["groups"]}),t.ue.success("Members added successfully")},onError:r=>{console.error("Failed to add group members:",r),t.ue.error("Failed to add members",{description:d.getRequestErrorMessage(r,"Failed to add members")})}})}function Ft(){const{authToken:s,tokenProps:n}=t.useSemaphorContext(),a=t.useQueryClient();return t.useMutation({mutationFn:({groupId:r,data:o})=>Et(n.apiServiceUrl,(s==null?void 0:s.accessToken)||"",r,o),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["group-members",o.groupId]}),a.invalidateQueries({queryKey:["groups"]}),t.ue.success("Members removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),t.ue.error("Failed to remove members",{description:d.getRequestErrorMessage(r,"Failed to remove members")})}})}const Tt=[];function Ot({open:s,onOpenChange:n}){var C,F,S;const{tokenProps:a}=t.useSemaphorContext(),{currentUser:r}=t.useCurrentUserInfo(),o=(r==null?void 0:r.type)==="tenant",u=a==null?void 0:a.tenantId,{groups:h,isLoading:x,error:v,refetch:f}=t.useGroups({type:o?"TENANT_GROUP":"all",tenantId:o?u:void 0,includeMembers:!1}),l=v?Ms(v,"Unable to load groups."):null,[p,y]=g.useState({kind:"list"}),[m,j]=g.useState(null),w=Rt();g.useEffect(()=>{s||(y({kind:"list"}),j(null))},[s]);const D=p.kind==="members"&&h.find(c=>c.id===p.groupId)||null,P=async()=>{if(m)try{await w.mutateAsync(m.id),j(null),y({kind:"list"}),f()}catch{}};return e.jsx(t.Dialog,{open:s,onOpenChange:n,children:e.jsxs(t.DialogContent,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[p.kind==="list"?e.jsxs("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[e.jsx(t.DialogTitle,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),e.jsx(t.DialogDescription,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):p.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:()=>y({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(t.ArrowLeft,{className:"h-3.5 w-3.5"})}),e.jsx(t.DialogTitle,{className:"truncate text-[13px] font-medium",children:"New group"}),e.jsx(t.DialogDescription,{className:"sr-only",children:"Create a new group to organize members."})]}):null,p.kind==="list"&&e.jsx(Vt,{groups:h,isLoading:x,errorMessage:l,onRetry:()=>f(),currentUserId:r==null?void 0:r.id,onOpenGroup:c=>y({kind:"members",groupId:c}),onCreate:()=>y({kind:"create"}),onDeleteRequest:c=>j(c)}),p.kind==="members"&&D&&e.jsx(Gt,{group:D,isTenantViewer:o,canEdit:((C=D.permissions)==null?void 0:C.canEdit)??D.createdBy===(r==null?void 0:r.id),canDelete:((F=D.permissions)==null?void 0:F.canDelete)??D.createdBy===(r==null?void 0:r.id),canManageMembers:((S=D.permissions)==null?void 0:S.canManageMembers)??D.createdBy===(r==null?void 0:r.id),onBack:()=>y({kind:"list"}),onMembersChanged:f,onUpdated:f,onRequestDelete:()=>j(D)},D.id),p.kind==="create"&&e.jsx($t,{isTenantUser:o,tenantId:u,onCancel:()=>y({kind:"list"}),onCreated:c=>{f(),y({kind:"members",groupId:c})}}),m&&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:m.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:()=>j(null),disabled:w.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:P,disabled:w.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:[w.isPending?e.jsx(d.LoaderCircle,{className:"h-3 w-3 animate-spin"}):e.jsx(t.Trash2,{className:"h-3 w-3"}),"Delete group"]})]})]})]})})}function Vt({groups:s,isLoading:n,errorMessage:a,onRetry:r,currentUserId:o,onOpenGroup:u,onCreate:h,onDeleteRequest:x}){const[v,f]=g.useState(""),l=g.useMemo(()=>s.filter(p=>!v.trim()||p.name.toLowerCase().includes(v.toLowerCase())||(p.description||"").toLowerCase().includes(v.toLowerCase())),[s,v]);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(vs.Search,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:v,onChange:p=>f(p.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),v&&e.jsx("button",{type:"button",onClick:()=>f(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(T.X,{className:"h-2.5 w-2.5"})})]}),e.jsxs("button",{type:"button",onClick:h,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(t.Plus,{className:"h-3 w-3"}),"New group"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:n?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(p=>e.jsx("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},p))}):a?e.jsx(Is,{title:"Can't load groups",message:a,onRetry:r}):l.length===0&&s.length===0?e.jsx(Bt,{onCreate:h}):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 "',v,'"']}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):l.map(p=>{var y;return e.jsx(qt,{group:p,canDelete:((y=p.permissions)==null?void 0:y.canDelete)??p.createdBy===o,onClick:()=>u(p.id),onDelete:()=>x(p)},p.id)})})]})}function qt({group:s,canDelete:n,onClick:a,onDelete:r}){let o="";try{o=ys.format(new Date(s.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(t.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:s.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(js,{className:"h-2.5 w-2.5"}),s.memberCount," member",s.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(t.Calendar,{className:"h-2.5 w-2.5"}),o]})]}),s.description&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:s.description})]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n&&e.jsx("span",{role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),r()},onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),u.stopPropagation(),r())},"aria-label":`Delete ${s.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(t.Trash2,{className:"h-3 w-3"})}),e.jsx(vs.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]})}function Bt({onCreate:s}){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(t.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:s,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(t.Plus,{className:"h-3 w-3"}),"New group"]})]})}function Gt({group:s,isTenantViewer:n,canEdit:a,canDelete:r,canManageMembers:o,onBack:u,onMembersChanged:h,onUpdated:x,onRequestDelete:v}){const{data:f,isLoading:l,error:p,refetch:y}=t.useGroupMembers(s.id),m=(f==null?void 0:f.members)??Tt,j=p?Ms(p,"Unable to load members for this group."):null,w=s.type==="TENANT_GROUP"?"tenant":"organization",{users:D}=t.useUnifiedUsers({type:w,tenantId:s.tenantId||void 0,active:!0,limit:200}),P=g.useMemo(()=>new Set(m.map(b=>b.userId)),[m]),C=Ut(),F=Ft(),S=Pt(),[c,O]=g.useState(!1),[U,V]=g.useState(s.name),[I,N]=g.useState(!1),[W,J]=g.useState(s.description||""),[z,ce]=g.useState(""),[ue,me]=g.useState(!1),he=g.useMemo(()=>{const b=z.trim().toLowerCase();return D.filter(q=>!P.has(q.id)).filter(q=>!b||(q.name||"").toLowerCase().includes(b)||(q.email||"").toLowerCase().includes(b)).slice(0,50)},[D,P,z]),pe=async()=>{const b=U.trim();if(O(!1),b.length>=3&&b!==s.name)try{await S.mutateAsync({groupId:s.id,data:{name:b}}),x()}catch{}},Z=async()=>{const b=W.trim();if(N(!1),b!==(s.description||""))try{await S.mutateAsync({groupId:s.id,data:{description:b}}),x()}catch{}},xe=async b=>{if(o){ce(""),me(!1);try{await C.mutateAsync({groupId:s.id,data:{userIds:[b.id],userType:w==="tenant"?"tenant":"org"}}),y(),h()}catch{}}},ee=async b=>{if(o)try{await F.mutateAsync({groupId:s.id,data:{userIds:[b]}}),y(),h()}catch{}};let X="";try{X=ys.format(new Date(s.createdAt),"MMM d, yyyy")}catch{X=""}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(t.ArrowLeft,{className:"h-3.5 w-3.5"})}),c?e.jsx("input",{autoFocus:!0,value:U,onChange:b=>V(b.target.value),onBlur:pe,onKeyDown:b=>{b.key==="Enter"&&pe(),b.key==="Escape"&&(V(s.name),O(!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&&(V(s.name),O(!0))},title:a?"Click to rename":s.name,disabled:!a,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:s.name}),e.jsxs("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[e.jsx(js,{className:"h-2.5 w-2.5"}),m.length," member",m.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:I?e.jsxs("div",{children:[e.jsx("textarea",{autoFocus:!0,rows:2,value:W,onChange:b=>J(b.target.value),maxLength:200,onKeyDown:b=>{b.key==="Escape"&&(J(s.description||""),N(!1)),b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&Z()},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:[W.length,"/200 · Esc to cancel · ⌘↩ to save"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{J(s.description||""),N(!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:Z,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&&(J(s.description||""),N(!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:[s.description?e.jsx("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:s.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:[X?`Created ${X}`:"Recently created",a?" · You can edit this group":""]})]})}),o&&e.jsx(zt,{query:z,setQuery:ce,open:ue,setOpen:me,candidates:he,showKindChip:!n,onAdd:xe,busy:C.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(b=>e.jsx("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},b))}):j?e.jsx(Is,{title:"Can't load members",message:j,onRetry:()=>y()}):m.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."})]}):m.map(b=>{var q,se,fe,_,H,K;return e.jsxs("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[e.jsx(Ls,{name:((q=b.user)==null?void 0:q.name)||((se=b.user)==null?void 0:se.email)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((fe=b.user)==null?void 0:fe.name)||((_=b.user)==null?void 0:_.email)||"Unknown"}),((H=b.user)==null?void 0:H.email)&&b.user.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:b.user.email})]}),!n&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:b.userType}),e.jsx("button",{type:"button",onClick:()=>ee(b.userId),disabled:!o||F.isPending,"aria-label":`Remove ${((K=b.user)==null?void 0:K.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(T.X,{className:"h-3 w-3"})})]},b.id)})}),r&&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:v,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(t.Trash2,{className:"h-3 w-3"}),"Delete group"]})})]})}function $t({isTenantUser:s,tenantId:n,onCancel:a,onCreated:r}){const[o,u]=g.useState(""),[h,x]=g.useState(""),[v,f]=g.useState(null),l=At(),p=o.trim().length>=3&&o.trim().length<=50,y=async()=>{if(!p)return;f(null);const m={name:o.trim(),description:h.trim()||void 0,type:s?"TENANT_GROUP":"ORG_GROUP",...s&&n?{tenantId:n}:{}};try{const j=await l.mutateAsync(m),w=j==null?void 0:j.id;w?r(w):a()}catch(j){f(j instanceof Error?j.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(gs,{children:"Name"}),e.jsx("input",{autoFocus:!0,value:o,onChange:m=>u(m.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(gs,{children:"Description (optional)"}),e.jsx("textarea",{rows:2,value:h,onChange:m=>x(m.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:[h.length,"/200"]})]}),v&&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:v})]}),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:y,disabled:!p||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(d.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Plus,{className:"h-3 w-3"}),"Create group"]})})]})]})}function zt({query:s,setQuery:n,open:a,setOpen:r,candidates:o,showKindChip:u,onAdd:h,busy:x}){const v=g.useRef(null),f=g.useRef(null),[l,p]=g.useState(null);g.useLayoutEffect(()=>{if(!a){p(null);return}const m=()=>{const j=v.current;if(!j)return;const w=j.getBoundingClientRect(),D=240,C=window.innerHeight-w.bottom<D+16&&w.top>D;p({left:w.left,top:C?w.top-6:w.bottom+6,width:w.width,above:C})};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[a,o.length]),g.useEffect(()=>{if(!a)return;const m=j=>{var D,P;const w=j.target;(D=v.current)!=null&&D.contains(w)||(P=f.current)!=null&&P.contains(w)||r(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[a,r]);const y=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:v,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(mt,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:s,onChange:m=>{n(m.target.value),r(!0)},onFocus:()=>r(!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"})]}),y&&typeof document<"u"&&st.createPortal(e.jsx("div",{ref:f,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(m=>e.jsxs("button",{type:"button",onClick:()=>h(m),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(Ls,{name:m.name||m.email||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:m.name||m.email||"Unknown"}),m.email&&m.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:m.email})]}),u&&m.type&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:m.type==="tenant"?"tenant":"org"})]},m.id))}),document.body)]})}function Ms(s,n){if(!s)return n;if(s instanceof Error){const a=s.message||"",r=a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return r?r[1]:a||n}return typeof s=="string"?s:n}function Is({title:s,message:n,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:s}),e.jsx("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:n}),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 gs({children:s}){return e.jsx("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:s})}function Ls({name:s}){const n=s.split(" ").map(a=>a[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return e.jsx(Cs,{className:"h-6 w-6 shrink-0",children:e.jsx(ks,{className:"text-[9px] font-semibold",children:n||"?"})})}function de(s,n,a){var u,h;const r=(s.controls||[]).find(x=>x.id===a);if(r)return r.label;const o=(h=(u=d.findCardById(s,n))==null?void 0:u.controls)==null?void 0:h.find(x=>x.id===a);return(o==null?void 0:o.label)||a}function le(s,n){var a;return((a=d.findCardById(s,n))==null?void 0:a.title)||n}function _t(s){const{errors:n,dashboard:a}=s;if(!a)return n;const r=new Map;for(const o of n){const u=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(u){const[,l,p]=u,y=`${l}:${p}:missing-metric`;r.has(y)||r.set(y,`"${le(a,l)}" has an outdated "${de(a,l,p)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const h=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(h){const[,l,p]=h,y=`${l}:${p}:missing-group-by`;r.has(y)||r.set(y,`"${le(a,l)}" has an outdated "${de(a,l,p)}" 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[,l,p]=x,y=`${l}:${p}:invalid-metric`;r.has(y)||r.set(y,`"${le(a,l)}" has an invalid "${de(a,l,p)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const v=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(v){const[,l,p]=v,y=`${l}:${p}:invalid-group-by`;r.has(y)||r.set(y,`"${le(a,l)}" has an invalid "${de(a,l,p)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const f=o.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(f){const[,l,p]=f,y=`${l}:${p}:missing-temporal-group-by`;r.has(y)||r.set(y,`"${le(a,l)}" can no longer use "${de(a,l,p)}" for time grain because the card does not currently group by a date field.`);continue}r.set(o,o)}return Array.from(r.values())}function Ht({visible:s,onSelect:n}){return s?e.jsxs(t.DropdownMenuItem,{onSelect:n,children:[e.jsx(t.CalendarClock,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null}function Kt({scheduleReportVisible:s,analyticalBriefingVisible:n,onScheduleReport:a,onCreateAnalyticalBriefing:r}){return e.jsxs(e.Fragment,{children:[e.jsx(Ht,{visible:s,onSelect:a}),n?e.jsxs(t.DropdownMenuItem,{onSelect:r,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]})}function bs(s,n){return{dashboard:t.cloneDeep(s),semanticExecutionPayload:t.cloneDeep(n)}}function Qt(){var ls,cs,us,ms,hs;$.useExportRecovery(),$.useExportPolling();const{authToken:s,tokenProps:n,id:a,showBriefings:r}=t.useSemaphorContext(),o=t.useBriefingUiCapabilities(),{isLocalDev:u}=t.useDashboardPreferences(),{canEditDashboard:h,hasInspectionUser:x,inspectionMessage:v,isInspectionMode:f,isInspectionSurface:l}=t.useDashboardInteractionMode(),{openBrandStudioPreview:p}=t.useBrandStudioPreview(),{permissions:y}=vt(),m=t.useHasDashboardId(),{isLoading:j}=t.useDashboardQuery(),w=d.useDashboardStore(i=>i.theme),D=d.useDashboardStore(i=>i.isDownloadingPdf),P=d.useDashboardStore(i=>i.dashboardAssistantDraftScopeKey),C=d.useDashboardStore(i=>i.lenses),F=d.useDashboardStore(i=>i.selectedLensId),S=C==null?void 0:C.find(i=>i.id===F),c=d.useDashboardStore(i=>i.dashboard),O=d.useDashboardStore(i=>i.selectedSheetId),U=(ls=c==null?void 0:c.sheets)==null?void 0:ls.find(i=>i.id===O),V=d.isDocumentSheet(U),I=V?(cs=U==null?void 0:U.document)==null?void 0:cs.page:void 0,N=d.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:W}=d.useDashboardStore(i=>i.actions),[J,z]=g.useState(!1),[ce,ue]=g.useState(!1),[me,he]=g.useState(!1),[pe,Z]=g.useState(!1),[xe,ee]=g.useState(null),[X,b]=g.useState(!1),[q,se]=g.useState(!1),[fe,_]=g.useState(!1),[H,K]=g.useState(null),[Ke,ge]=g.useState([]),[Qe,be]=g.useState(!1),[Es,We]=g.useState(!1),Je=d.useDashboardStore(i=>i.filterValues),L=d.useDashboardStore(i=>i.isVisualEditing);d.useEditorStore(i=>i.card);const As=t.useManagementStore(i=>i.selectedDashboard),Ps=t.useManagementStore(i=>i.initialDashboard);t.useManagementStore(i=>i.selectedVisual),d.useDashboardStore(i=>i.selectedFrameId),d.useEditorStore(i=>i.frame);const Xe=d.useDashboardStore(i=>i.showDashboardJSON),Ie=d.useDashboardStore(i=>i.onSaveFunction),{setIsDashboardEditing:Ye,setShowDashboardJSON:Ze}=d.useDashboardStore(i=>i.actions),{setInitialDashboard:es,clearSelectedDashboard:Le}=t.useManagementStore(i=>i.actions),te=!!n.orgUserId||!!(n.tenantId&&n.endUserId&&n.endUserEmail),{resources:ve}=t.useResourceManagement(t.ResourceType.DASHBOARD),{data:Ee}=t.useUserPreferences(),Rs=((us=Ee==null?void 0:Ee.preference)==null?void 0:us.defaultDashboardId)||null,{mutate:Us,isPending:Fs}=t.useDefaultDashboardMutation(),{currentUser:Ts}=t.useCurrentUserInfo(),Os=t.canUserManageGroups(Ts),B=As||Ps,Y=t.resolveDashboardControlsVisibility({config:n.config,canNavigateDashboardHub:te,canShareDashboard:((ms=B==null?void 0:B.permissions)==null?void 0:ms.canShare)===!0,canManageGroups:Os}),ss=B?{id:B.id,title:(c==null?void 0:c.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:Vs}=t.useAddNewFrame(),[Ae,Pe]=g.useState(!1),[qs,re]=g.useState(!1),[Re,ye]=g.useState("close"),ae=t.useUpdateResource(t.ResourceType.DASHBOARD),[M,je]=g.useState(null),Bs=async(i,k)=>{if(!f){if(!(c!=null&&c.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:c.id,newTitle:i,previousTitle:k}),ae.mutate({resourceId:c.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),t.ue.success("Dashboard title updated")},onError:R=>{console.error("Failed to update dashboard title:",R),t.ue.error("Failed to update dashboard title"),W(k)}})}};g.useEffect(()=>{if(ve&&ve.length>0){const i=c==null?void 0:c.id;if(i){const k=ve.find(R=>R.id===i);k&&es(k)}}},[ve,c==null?void 0:c.id,es]);const ne=n.orgUserId||n.tenantId,Ue=g.useMemo(()=>Wt({accessToken:s==null?void 0:s.accessToken,dashboardId:(c==null?void 0:c.id)||a||n.dashboard_id,selectedSheetId:V?O:void 0,pageSize:I==null?void 0:I.size,orientation:I==null?void 0:I.orientation,theme:w}),[s==null?void 0:s.accessToken,a,c==null?void 0:c.id,V,I==null?void 0:I.orientation,I==null?void 0:I.size,O,w,n.dashboard_id]),ts=N&&!L&&!f&&ne&&h,{setDashboard:Fe}=d.useDashboardStore(i=>i.actions),rs=d.useDashboardStore(i=>i.semanticExecutionPayload),Gs=()=>{Ye(!0)},we=()=>{Ye(!1),Ze(!1),je(null)};g.useEffect(()=>{if(!N){M&&je(null);return}M||!c||j||je(bs(c,rs))},[c,M,N,j,rs]);const De=(M==null?void 0:M.dashboard)??null,{isDirty:as,isDirtyPending:$s,resetDirty:oe}=rt.useDebouncedDirtyCheck(c,De,300,1e3,Be.serializeDashboardForDirtyCheck),ns=g.useCallback(()=>De?Be.serializeDashboardForDirtyCheck(c)!==Be.serializeDashboardForDirtyCheck(De):!1,[c,De]),os=as||$s,Ne=Ae||ae.isPending,zs=()=>{if(f){M&&Fe(M.dashboard,{semanticExecutionPayload:M.semanticExecutionPayload}),we(),oe();return}ns()?(ye("close"),re(!0)):(we(),oe())},_s=async()=>{await Te({closeAfterSave:!0,navigateHomeAfterSave:Re==="home"})},Hs=()=>{const i=Re==="home"&&!!te;M&&Fe(M.dashboard,{semanticExecutionPayload:M.semanticExecutionPayload}),we(),i&&Le(),ye("close"),re(!1),oe()},Ks=()=>{M&&(Fe(M.dashboard,{semanticExecutionPayload:M.semanticExecutionPayload}),oe())},Qs=()=>{if(te){if(N&&ns()){ye("home"),re(!0);return}Le()}};async function Te(i){if(f)return;const k=d.useDashboardStore.getState().dashboard;if(!k)return;const R=(i==null?void 0:i.closeAfterSave)??Qe,Oe=(i==null?void 0:i.navigateHomeAfterSave)??!1;be(R),R&&re(!1);const Ve=t.cloneDeep(k);_(!0),K(null),ge([]),Pe(!0);const et={template:k};ae.mutate({resourceId:k.id,data:et},{onSuccess:E=>{var Se,Ce,ps;const Q=(E==null?void 0:E.id)||((Se=E==null?void 0:E.dashboard)==null?void 0:Se.id)||((Ce=E==null?void 0:E.resource)==null?void 0:Ce.id)||((ps=E==null?void 0:E.template)==null?void 0:ps.id)||null;if(!k.id&&Q){const qe=d.useAIInteractionStore.getState(),ke=qe.pendingDashboardDraftMigration;(ke==null?void 0:ke.scopeKey)===P?qe.actions.setPendingDashboardDraftMigrationExpectedDashboardId(Q):ke&&qe.actions.clearPendingDashboardDraftMigration()}Pe(!1),t.ue.success("Dashboard saved!"),je(bs(Ve,d.useDashboardStore.getState().semanticExecutionPayload)),_(!1),be(!1),R&&(we(),oe(),Oe&&te&&Le()),ye("close")},onError:E=>{Pe(!1),K("Failed to save dashboard. Please try again.");const Q=E.details,Se=Array.isArray(Q==null?void 0:Q.errors)?(Q.errors||[]).filter(Ce=>typeof Ce=="string"):[];ge(_t({errors:Se,dashboard:k||void 0})),t.ue.error("Failed to save dashboard")}})}async function Ws(){if(f||(z(!0),!F||!S))return;const i=d.useDashboardStore.getState().dashboard;if(!i){z(!1);return}const k=JSON.stringify(i),R=d.useDashboardStore.getState(),Oe=ws({dashboard:i,dashboardInputValues:R.dashboardInputValues,filterValues:Je,controlValues:R.controlValues,inlineFilterValuesMap:R.inlineFilterValuesMap,cardControlValuesMap:R.cardControlValuesMap}),Ve={...S,template:k,filterValues:Je,inputValues:Oe};await Ge(n.apiServiceUrl,Ve,s==null?void 0:s.accessToken),t.ue.success("Lens saved"),Ie==null||Ie(i),z(!1)}const is=(S==null?void 0:S.name)||c.title;ae.isPending&&console.log("Title during update:",{title:is,dashboardStateTitle:c.title,dashboardId:c==null?void 0:c.id,currentLensName:S==null?void 0:S.name});const Js=te&&!!(s!=null&&s.accessToken)&&!!(n!=null&&n.apiServiceUrl),Xs=!f&&Y.showDashboardHub&&Js,Ys=!f&&m&&Y.showDashboardHub,G=(c==null?void 0:c.id)||null,ds=t.resolveDashboardBriefingsVisibility((hs=n.config)==null?void 0:hs.showBriefings,r),ie=!!G&&Rs===G,Zs=()=>{!G||f||Us({dashboardId:ie?null:G})};return!m&&!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:[Ys&&!L&&e.jsx(t.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Qs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(t.House,{className:"h-3.5 w-3.5"})}),!L&&m&&(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(t.EditableText,{value:is||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:h,dashboardId:c==null?void 0:c.id});const k=(c==null?void 0:c.title)||"";W(i),Bs(i,k)},isEditable:t.resolveDashboardTitleEditability({isDashboardEditing:N,canEditDashboard:h===!0&&!f,hasCurrentLens:!!S}),displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:ae.isPending}),Y.showDashboardHub&&ie&&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"}),Xs&&G&&e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(d.Button,{variant:"ghost",size:"xs",onClick:Zs,disabled:Fs||!(s!=null&&s.accessToken)||!(n!=null&&n.apiServiceUrl),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":ie?"Clear default dashboard":"Set as default dashboard",children:ie?e.jsx(t.PinOff,{className:"h-3.5 w-3.5"}):e.jsx(t.Pin,{className:"h-3.5 w-3.5"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:ie?"Clear default":"Set as default"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[L&&e.jsxs(e.Fragment,{children:[e.jsx($.AdvancedModeToggle,{}),e.jsx($.VisualEditingControls,{})]}),!L&&m&&!f&&Y.showDashboardSharing&&e.jsxs(d.Button,{variant:"outline",size:"xs",onClick:()=>ue(!0),children:[e.jsx(t.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!L&&N&&!f&&y.canUseFilters&&m&&e.jsx($.DashboardFilterControlsLauncher,{}),N&&!L&&!f&&ne&&S&&u&&m&&e.jsxs(d.Button,{variant:"secondary",size:"xs",disabled:J,onClick:Ws,children:[e.jsx(xs.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),N&&!L&&!f&&m&&!V&&e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[e.jsxs(d.Button,{variant:"ghost",size:"xs",disabled:!N,onClick:()=>void Vs(),className:"h-full rounded-none border-0 shadow-none hover:bg-accent",children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(d.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:!N,children:e.jsx(T.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(t.DropdownMenuContent,{align:"end",className:"z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",children:e.jsxs(t.DropdownMenuItem,{onClick:()=>We(!0),children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),e.jsx($.VisualsLibraryDialog,{open:Es,onOpenChange:We})]}),!L&&!N&&(h||f)&&(!l||!x||h!==void 0)&&m&&e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs(d.Button,{size:"xs",onClick:Gs,children:[e.jsx(t.Pencil,{className:"h-3.5 w-3.5"}),f?"Inspect":"Edit"]}),v?e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":v,className:"inline-flex size-6 items-center justify-center rounded-control text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.jsx(d.Info,{"aria-hidden":"true",className:"size-3.5"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:v})})]})}):null]}),ts&&m&&as&&e.jsxs(d.Button,{variant:"outline",size:"xs",onClick:Ks,disabled:Ne,children:[e.jsx(t.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),ts&&m&&e.jsxs(d.Button,{size:"xs",className:d.cn(!os&&"opacity-60"),disabled:Ne||!os,onClick:()=>Te(),children:[Ne?e.jsx(d.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xs.Save,{className:"h-3.5 w-3.5"}),Ne?"Saving...":"Save"]}),N&&!L&&m&&e.jsxs(d.Button,{variant:"outline",size:"xs",onClick:zs,children:[e.jsx(t.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!L&&m&&e.jsx("div",{className:"ml-2",children:e.jsx($.NotificationBell,{})}),!L&&u&&e.jsx(ht,{}),!L&&m&&!f&&e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.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(t.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[e.jsx(t.DropdownMenuLabel,{children:"Reports & briefings"}),e.jsxs(t.DropdownMenuItem,{disabled:D,onSelect:()=>se(!0),children:[e.jsx(t.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsx(Kt,{scheduleReportVisible:!!(ds&&o.surfaceVisible&&G&&!N),analyticalBriefingVisible:!!(ds&&o.surfaceVisible&&G&&!N),onScheduleReport:()=>ee("scheduled_report"),onCreateAnalyticalBriefing:()=>ee("analytical_briefing")}),e.jsx(t.DropdownMenuSeparator,{}),Y.showGroupManagement&&e.jsxs(e.Fragment,{children:[e.jsx(t.DropdownMenuLabel,{children:"Access"}),e.jsxs(t.DropdownMenuItem,{onClick:()=>he(!0),children:[e.jsx(t.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(t.DropdownMenuSeparator,{})]}),e.jsx(t.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(t.DropdownMenuItem,{onClick:()=>Z(!0),children:[e.jsx(t.Calendar,{className:"h-3.5 w-3.5"}),"Report preferences"]}),u&&m&&e.jsxs(e.Fragment,{children:[e.jsx(t.DropdownMenuSeparator,{}),e.jsx(t.DropdownMenuLabel,{children:"Developer"}),e.jsxs(t.DropdownMenuItem,{onSelect:()=>{var i;s!=null&&s.accessToken&&((i=navigator==null?void 0:navigator.clipboard)!=null&&i.writeText?navigator.clipboard.writeText(s.accessToken).then(()=>t.ue.success("Token copied to clipboard")).catch(()=>t.ue.error("Unable to copy token")):t.ue.error("Clipboard not available"))},children:[e.jsx(t.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),V&&e.jsxs(t.DropdownMenuItem,{disabled:!Ue,onSelect:()=>{var i;if(!Ue){t.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(Ue).then(()=>t.ue.success("Local document PDF URL copied to clipboard")).catch(()=>t.ue.error("Unable to copy local document PDF URL")):t.ue.error("Clipboard not available")},children:[e.jsx(t.Copy,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),e.jsxs(t.DropdownMenuItem,{onSelect:()=>d.invalidateToken(n.apiServiceUrl),children:[e.jsx(ct,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(t.DropdownMenuItem,{onSelect:p,children:[e.jsx(at.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),N&&e.jsxs(t.DropdownMenuItem,{onSelect:()=>Ze(!Xe),children:[e.jsx(nt.Braces,{className:"h-3.5 w-3.5"}),Xe?"Hide dashboard JSON":"Show dashboard JSON"]}),ne&&N&&e.jsxs(t.DropdownMenuItem,{onSelect:()=>b(!0),children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),ne&&e.jsxs(t.DropdownMenuSub,{children:[e.jsxs(t.DropdownMenuSubTrigger,{children:[e.jsx(it,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(t.DropdownMenuSubContent,{className:"w-60",children:e.jsx(bt,{})})]})]})]})]}),ce&&ss&&e.jsx(t.ShareDialog,{resource:ss,resourceType:t.ResourceType.DASHBOARD,onClose:()=>ue(!1)}),Y.showGroupManagement&&e.jsx(Ot,{open:me,onOpenChange:he}),e.jsx(tt.ReportPreferencesDialog,{open:pe,onOpenChange:Z}),G&&xe?e.jsx($.DashboardBriefingLauncher,{dashboardId:G,dashboardTitle:(c==null?void 0:c.title)||(B==null?void 0:B.title),open:!0,onOpenChange:i=>{i||ee(null)},hideTrigger:!0,workflowIntent:xe}):null,u&&ne&&m&&e.jsx(gt,{open:X,onOpenChange:b}),m&&e.jsx(t.DownloadPdf,{open:q,onOpenChange:se}),e.jsx(t.AlertDialog,{open:fe,onOpenChange:i=>{!i&&Ae&&!H||(_(i),i||(K(null),ge([]),be(!1)))},children:e.jsxs(t.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:H?"Save failed":"Saving dashboard"}),e.jsx(t.AlertDialogDescription,{className:"pt-2",children:H?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),Ke.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:Ke.slice(0,5).map(i=>e.jsx("li",{children:i},i))})]})]}),e.jsx(t.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:H?e.jsxs(e.Fragment,{children:[e.jsx(t.AlertDialogCancel,{onClick:()=>{_(!1),K(null),ge([]),be(!1)},className:"m-0",children:"Close"}),e.jsx(t.AlertDialogAction,{onClick:()=>Te({closeAfterSave:Qe,navigateHomeAfterSave:Re==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(t.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(d.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx($.UnsavedChangesAlert,{open:qs,onOpenChange:i=>{re(i)},onSave:_s,onDiscard:Hs,isSaving:Ae,saveLabel:"Save",discardLabel:"Discard"})]})]})}function Wt({accessToken:s,dashboardId:n,selectedSheetId:a,pageSize:r,orientation:o,theme:u}){if(!s||!a)return null;const h=new URL("http://localhost:5173/print-document");h.searchParams.set("token",s),n&&h.searchParams.set("dashboardId",n),h.searchParams.set("selectedSheetId",a),u&&h.searchParams.set("theme",u);const x=new URL("http://127.0.0.1:3002/");return x.searchParams.set("pdfMode","document"),x.searchParams.set("pageSize",r||"letter"),x.searchParams.set("orientation",o||"portrait"),x.searchParams.set("url",h.toString()),x.toString()}exports.default=Qt;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),o=require("react"),b=require("./index-jSrCwPQz.cjs"),r=require("./code-editor-BYVorgOf.cjs");require("./validators-9D4KBqKD.cjs");require("./analyze-result-contract-BHb7sUUW.cjs");require("../value-format-preferences/index.cjs");require("./dashboard-CAiwJW3L.cjs");require("./index-Dpm_VET4.cjs");require("./temporal-bucket-authoring-CPTwHzvs.cjs");require("./temporal-result-owner-f6-i65Fb.cjs");require("react-dom");require("../briefings/index.cjs");function S(){const t=r.useDashboardStore(e=>e.dashboard),u=r.useDashboardStore(e=>e.actions.setDashboard),c=r.useDashboardStore(e=>e.showDashboardJSON),h=r.useDashboardStore(e=>e.actions.setShowDashboardJSON),s=o.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,n]=o.useState(s),i=o.useRef(s);return o.useEffect(()=>{s!==i.current&&(n(s),i.current=s)},[s]),a.jsxs("div",{className:r.cn("relative p-2",{hidden:!c}),children:[a.jsxs(r.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(r.CodeEditor,{value:l,onValueChange:e=>{n(e);try{const d=JSON.parse(e);i.current=JSON.stringify(d,null,2),u(d)}catch{}},language:"json"})})]})}exports.default=S;
|