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