react-semaphor 0.1.304 → 0.1.306
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.cjs +2 -2
- package/dist/brand-studio/index.js +14 -14
- package/dist/chunks/braces-CuiOenEA.js +6 -0
- package/dist/chunks/braces-DZxcgUvn.js +23 -0
- package/dist/chunks/{dashboard-controls-DCZnUFI0.js → dashboard-controls-BpgZjEDy.js} +9 -9
- package/dist/chunks/{dashboard-controls-CyFZfGaN.js → dashboard-controls-CuQH4inS.js} +10 -9
- package/dist/chunks/{dashboard-filter-controls-button-YQZ-oeN5.js → dashboard-filter-controls-button-Bu90ytxy.js} +1 -1
- package/dist/chunks/{dashboard-filter-controls-button-DI7XUgZK.js → dashboard-filter-controls-button-NiAIAD1P.js} +4 -4
- package/dist/chunks/{dashboard-json-Z8jz16Yj.js → dashboard-json-Bk13vadr.js} +1 -1
- package/dist/chunks/{dashboard-json-C6R2qixD.js → dashboard-json-DzVn9KAU.js} +2 -2
- package/dist/chunks/{dashboard-summary-settings-dialog-DJyY-PB9.js → dashboard-summary-settings-dialog-8vZtKUjh.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-BlD77h63.js → dashboard-summary-settings-dialog-dt20G_7d.js} +2 -2
- package/dist/chunks/{edit-dashboard-visual-CfRJXwDR.js → edit-dashboard-visual-BIuWXuCC.js} +8796 -8713
- package/dist/chunks/edit-dashboard-visual-DGhTFzSF.js +183 -0
- package/dist/chunks/index-CwzM5Lxh.js +1360 -0
- package/dist/chunks/{index-GHhvGdF9.js → index-DQApwxKL.js} +50813 -48256
- package/dist/chunks/{palette-BqJlrRto.js → palette-BwGE32UR.js} +2 -7
- package/dist/chunks/{palette-DD-i7bNS.js → palette-DFjOzeAG.js} +3 -23
- package/dist/chunks/{resource-management-panel-Bdus73Iu.js → resource-management-panel-BqJAVm7E.js} +1 -1
- package/dist/chunks/{resource-management-panel-7Y4ITzGH.js → resource-management-panel-CD_TQoTn.js} +3 -3
- package/dist/chunks/{save-CFBIhbHD.js → save-B3tqymYm.js} +1 -1
- package/dist/chunks/{save-j-clxFtx.js → save-QktcpXPy.js} +1 -1
- package/dist/chunks/{switch-BH17qlxH.js → switch-B72T1Hf_.js} +27 -22
- package/dist/chunks/{switch-BFhVVwh9.js → switch-BuZXNXQV.js} +431 -390
- package/dist/chunks/{use-create-flow-overlay-state-CllZvyvE.js → use-create-flow-overlay-state-Bg-LkLP7.js} +4 -4
- package/dist/chunks/{use-create-flow-overlay-state-CSytlf2H.js → use-create-flow-overlay-state-iUCs5ZgT.js} +1 -1
- package/dist/chunks/{use-visual-utils-CyjLzcDG.js → use-visual-utils-D_2r0Fmm.js} +2 -2
- package/dist/chunks/{use-visual-utils-CDO4kVX5.js → use-visual-utils-DqVxN0_F.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 +7 -7
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +142 -44
- package/dist/types/main.d.ts +144 -44
- package/dist/types/shared.d.ts +142 -44
- package/dist/types/surfboard.d.ts +142 -44
- package/dist/types/types.d.ts +142 -44
- package/package.json +4 -4
- package/dist/chunks/edit-dashboard-visual-CNGc1zcN.js +0 -183
- package/dist/chunks/index-D2vz3gvd.js +0 -1360
- package/dist/chunks/rotate-ccw-CdGW8Rxm.js +0 -6
- package/dist/chunks/rotate-ccw-X8MbX_hF.js +0 -14
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-B72T1Hf_.js"),s=require("./index-CwzM5Lxh.js"),b=require("react");require("./index-DRlMUglg.js");require("react-dom");const G=require("./dashboard-filter-controls-button-Bu90ytxy.js"),ot=require("./index-D7KJindZ.js"),xs=require("./dashboard-summary-settings-dialog-8vZtKUjh.js"),it=require("./use-debounced-dirty-check-XHSwAefL.js"),Fe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),gs=require("./use-create-flow-overlay-state-iUCs5ZgT.js"),bs=require("./save-B3tqymYm.js"),lt=require("./palette-BwGE32UR.js"),ct=require("./braces-CuiOenEA.js");function dt(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 I=dt(b);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const ut=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
7
|
* @license lucide-react v0.453.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const mt=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
12
|
* @license lucide-react v0.453.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const ht=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
17
|
* @license lucide-react v0.453.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const pt=o.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
22
22
|
* @license lucide-react v0.453.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const ft=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
27
|
* @license lucide-react v0.453.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const xt=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"}]]);var Re={exports:{}},_e={};/**
|
|
32
32
|
* @license React
|
|
33
33
|
* use-sync-external-store-shim.production.js
|
|
34
34
|
*
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
*
|
|
37
37
|
* This source code is licensed under the MIT license found in the
|
|
38
38
|
* LICENSE file in the root directory of this source tree.
|
|
39
|
-
*/var
|
|
39
|
+
*/var vs;function gt(){if(vs)return _e;vs=1;var t=b;function a(x,p){return x===p&&(x!==0||1/x===1/p)||x!==x&&p!==p}var n=typeof Object.is=="function"?Object.is:a,r=t.useState,c=t.useEffect,m=t.useLayoutEffect,d=t.useDebugValue;function f(x,p){var u=p(),i=r({inst:{value:u,getSnapshot:p}}),y=i[0].inst,w=i[1];return m(function(){y.value=u,y.getSnapshot=p,g(y)&&w({inst:y})},[x,u,p]),c(function(){return g(y)&&w({inst:y}),x(function(){g(y)&&w({inst:y})})},[x]),d(u),u}function g(x){var p=x.getSnapshot;x=x.value;try{var u=p();return!n(x,u)}catch{return!0}}function v(x,p){return p()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:f;return _e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,_e}var Ue={};/**
|
|
40
40
|
* @license React
|
|
41
41
|
* use-sync-external-store-shim.development.js
|
|
42
42
|
*
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
*
|
|
45
45
|
* This source code is licensed under the MIT license found in the
|
|
46
46
|
* LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/var Ss;function gt(){return Ss||(Ss=1,process.env.NODE_ENV!=="production"&&function(){function t(u,i){return u===i&&(u!==0||1/u===1/i)||u!==u&&i!==i}function a(u,i){h||c.startTransition===void 0||(h=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var y=i();if(!x){var w=i();m(y,w)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),x=!0)}w=d({inst:{value:y,getSnapshot:i}});var D=w[0].inst,C=w[1];return g(function(){D.value=y,D.getSnapshot=i,n(D)&&C({inst:D})},[u,y,i]),f(function(){return n(D)&&C({inst:D}),u(function(){n(D)&&C({inst:D})})},[u]),v(y),y}function n(u){var i=u.getSnapshot;u=u.value;try{var y=i();return!m(u,y)}catch{return!0}}function r(u,i){return i()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var c=b,m=typeof Object.is=="function"?Object.is:t,d=c.useState,f=c.useEffect,g=c.useLayoutEffect,v=c.useDebugValue,h=!1,x=!1,p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:a;Ue.useSyncExternalStore=c.useSyncExternalStore!==void 0?c.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ue}process.env.NODE_ENV==="production"?Re.exports=xt():Re.exports=gt();var bt=Re.exports;const je=["light","dark","system"];function vt(){const{theme:t,setTheme:a}=s.useTheme(),n=o.useDashboardStore(d=>d.actions.setDashboardTheme);function r(){const d=je.includes(t)?t:"system",f=je[(je.indexOf(d)+1)%je.length];a(f),n(f)}const c=t==="light"?ft:t==="dark"?ht:mt,m=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":m,title:m,children:e.jsx(c,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function yt(t,a,n,r,c){if(!c)return null;const m=JSON.stringify(n),d=`${t}/v1/lens`;return await o.postRequest(d,c,{name:a,template:m,filterValues:r,operation:"create"})}async function qe(t,a,n){if(!n)return null;const{id:r,template:c,filterValues:m,isDefault:d,shared:f}=a,g=`${t}/v1/lens`;return await o.postRequest(g,n,{lensId:r,template:c,filterValues:m,isDefault:d,shared:f,operation:"update"})}async function St(t,a,n){if(!n)return null;const r=`${t}/v1/lens`;return await o.postRequest(r,n,{operation:"delete",lensId:a})}const jt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Dt({open:t,onOpenChange:a}={}){const[n,r]=b.useState(""),[c,m]=b.useState(!1),d=o.useDashboardStore(M=>M.lenses),{setLenses:f,setSelectedLensId:g}=o.useDashboardActions(),[v,h]=b.useState(!1),[x,p]=b.useState(!1),u=t!==void 0,i=u?t:x,y=M=>{u||p(M),a==null||a(M)},w=o.useDashboardStore(M=>M.dashboard),D=o.useDashboardStore(M=>M.filterValues),{authToken:C,tokenProps:N}=s.useSemaphorContext();async function E(){h(!0);const M=await yt(N.apiServiceUrl,n,w,D,C==null?void 0:C.accessToken);M&&(f([...d||[],M]),g(M.id),y(!1)),h(!1)}return e.jsxs(s.Dialog,{open:i,onOpenChange:y,children:[u?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:jt,children:"Name"}),e.jsx(o.Input,{id:"lens-name",size:"xs",value:n,placeholder:"Monthly review, West region, …",onChange:M=>r(M.target.value)}),c&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(o.Button,{variant:"outline",size:"xs",onClick:()=>y(!1),children:"Cancel"}),e.jsx(o.Button,{size:"xs",type:"submit",onClick:E,disabled:v||!n.trim(),children:v?"Creating…":"Create"})]})]})]})}function wt({includeLabel:t=!1}={}){const a=o.useDashboardStore(h=>h.lenses),n=o.useDashboardStore(h=>h.selectedLensId),{setLenses:r,setSelectedLensId:c}=o.useDashboardActions(),{authToken:m,tokenProps:d}=s.useSemaphorContext();async function f(h){c(h)}async function g(h){if(await St(d.apiServiceUrl,h,m==null?void 0:m.accessToken)){const p=a==null?void 0:a.filter(u=>u.id!==h);r(p||[]),c("original")}}async function v(h){const x=a==null?void 0:a.map(i=>i.id===h.id?{...i,isDefault:!h.isDefault}:{...i,isDefault:!1});r(x||[]);const p={...h,isDefault:!h.isDefault};await qe(d.apiServiceUrl,p,m==null?void 0:m.accessToken);const u=a==null?void 0:a.find(i=>i.isDefault);if(u&&u.id!==h.id){const i={...u,isDefault:!1};await qe(d.apiServiceUrl,i,m==null?void 0:m.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:f,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(h=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:h.id,children:[e.jsx("p",{children:h.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:x=>{x.preventDefault(),v(h)},className:o.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!h.isDefault,"text-green-500":h.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:x=>{x.preventDefault(),g(h.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},h.id))]})]})}function Ct(){const{displayPreferences:t,shouldShowElement:a}=s.useDisplayPreferences(),{currentUser:n,userContext:r}=s.useCurrentUserInfo(),c=b.useMemo(()=>s.getRoleBasedDisplayOverrides(n),[n]),m=b.useMemo(()=>f=>c&&c[f]!==void 0&&c[f]===!1?!1:a(f),[c,a,t]),d=b.useMemo(()=>{var f,g,v,h,x;return{canEdit:((f=r==null?void 0:r.permissions)==null?void 0:f.canEdit)??s.canUserEdit(n),canUseFilters:((g=r==null?void 0:r.permissions)==null?void 0:g.canEdit)??s.canUserUseFilters(n),canManageDashboards:((v=r==null?void 0:r.permissions)==null?void 0:v.canCreateDashboard)??s.canUserManageDashboards(n),canCreateDashboards:((h=r==null?void 0:r.permissions)==null?void 0:h.canCreateDashboard)??s.canUserCreateDashboards(n),canAccessVisuals:((x=r==null?void 0:r.permissions)==null?void 0:x.canEdit)??s.canUserAccessVisuals(n)}},[n,r]);return{displayPreferences:t,shouldShowElement:m,permissions:d,currentUser:n}}const Nt=async(t,a,n)=>{const r=`${t}/management/v1/groups`;return await o.postRequestRegular(r,a,n)},Mt=async(t,a,n)=>{const r=`${t}/management/v1/groups/${n}`;await o.requestJsonRegular(r,a,"DELETE")},It=async(t,a,n,r)=>{const c=`${t}/management/v1/groups/${n}/members`;return await o.postRequestRegular(c,a,r)},Et=async(t,a,n,r)=>{const c=`${t}/management/v1/groups/${n}/members`;await o.requestJsonRegular(c,a,"DELETE",r)};function Lt(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>Nt(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 At(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>Mt(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["groups"]}),n.removeQueries({queryKey:["group",c]}),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 Ot(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:c})=>It(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,c),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["group",c.groupId]}),n.invalidateQueries({queryKey:["group-members",c.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 kt(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:c})=>Et(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,c),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["group",c.groupId]}),n.invalidateQueries({queryKey:["group-members",c.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 js="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Tt({onSuccess:t,tenantId:a,isTenantUser:n}){const[r,c]=b.useState(""),[m,d]=b.useState(""),[f,g]=b.useState({}),v=Lt(),h=()=>{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",m&&m.length>200&&(p.description="Description must be less than 200 characters"),g(p),Object.keys(p).length===0},x=async p=>{if(p.preventDefault(),!h())return;const u={name:r.trim(),description:m.trim()||void 0,type:n?"TENANT_GROUP":"ORG_GROUP",...n&&a?{tenantId:a}:{}};try{await v.mutateAsync(u),c(""),d(""),g({}),t()}catch(i){console.error("Failed to create group:",i)}};return e.jsxs("form",{onSubmit:x,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(o.Label,{htmlFor:"group-name",className:js,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=>{c(p.target.value),f.name&&g(u=>({...u,name:""}))},className:f.name?"border-destructive":"",disabled:v.isPending}),f.name&&e.jsx("p",{className:"text-[12px] text-destructive",children:f.name})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{htmlFor:"group-description",className:js,children:"Description (optional)"}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group…",value:m,onChange:p=>{d(p.target.value),f.description&&g(u=>({...u,description:""}))},className:`text-[13px] ${f.description?"border-destructive":""}`,disabled:v.isPending,rows:3}),f.description?e.jsx("p",{className:"text-[12px] text-destructive",children:f.description}):e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[m.length,"/200"]})]}),e.jsxs("div",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[e.jsx(o.Info,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),e.jsx("p",{children:"This group will be accessible to users in your workspace. You can add members after creating it."})]}),e.jsxs("div",{className:"flex justify-end gap-1.5 pt-1",children:[e.jsx(o.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>{c(""),d(""),g({})},disabled:v.isPending,children:"Clear"}),e.jsx(o.Button,{type:"submit",size:"xs",disabled:v.isPending||!r.trim(),children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating…"]}):"Create group"})]})]})}function Pt(t,a=[]){let n=[];function r(m,d){const f=I.createContext(d);f.displayName=m+"Context";const g=n.length;n=[...n,d];const v=x=>{var D;const{scope:p,children:u,...i}=x,y=((D=p==null?void 0:p[t])==null?void 0:D[g])||f,w=I.useMemo(()=>i,Object.values(i));return e.jsx(y.Provider,{value:w,children:u})};v.displayName=m+"Provider";function h(x,p){var y;const u=((y=p==null?void 0:p[t])==null?void 0:y[g])||f,i=I.useContext(u);if(i)return i;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${m}\``)}return[v,h]}const c=()=>{const m=n.map(d=>I.createContext(d));return function(f){const g=(f==null?void 0:f[t])||m;return I.useMemo(()=>({[`__scope${t}`]:{...f,[t]:g}}),[f,g])}};return c.scopeName=t,[r,Ft(c,...a)]}function Ft(...t){const a=t[0];if(t.length===1)return a;const n=()=>{const r=t.map(c=>({useScope:c(),scopeName:c.scopeName}));return function(m){const d=r.reduce((f,{useScope:g,scopeName:v})=>{const x=g(m)[`__scope${v}`];return{...f,...x}},{});return I.useMemo(()=>({[`__scope${a.scopeName}`]:d}),[d])}};return n.scopeName=a.scopeName,n}var _t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ge=_t.reduce((t,a)=>{const n=o.createSlot(`Primitive.${a}`),r=I.forwardRef((c,m)=>{const{asChild:d,...f}=c,g=d?n:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(g,{...f,ref:m})});return r.displayName=`Primitive.${a}`,{...t,[a]:r}},{});function Ut(){return bt.useSyncExternalStore(Rt,()=>!0,()=>!1)}function Rt(){return()=>{}}var $e="Avatar",[qt]=Pt($e),[Gt,Cs]=qt($e),Ns=I.forwardRef((t,a)=>{const{__scopeAvatar:n,...r}=t,[c,m]=I.useState("idle");return e.jsx(Gt,{scope:n,imageLoadingStatus:c,onImageLoadingStatusChange:m,children:e.jsx(Ge.span,{...r,ref:a})})});Ns.displayName=$e;var Ms="AvatarImage",Is=I.forwardRef((t,a)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:c=()=>{},...m}=t,d=Cs(Ms,n),f=$t(r,m),g=o.useCallbackRef(v=>{c(v),d.onImageLoadingStatusChange(v)});return o.useLayoutEffect2(()=>{f!=="idle"&&g(f)},[f,g]),f==="loaded"?e.jsx(Ge.img,{...m,ref:a,src:r}):null});Is.displayName=Ms;var Es="AvatarFallback",Ls=I.forwardRef((t,a)=>{const{__scopeAvatar:n,delayMs:r,...c}=t,m=Cs(Es,n),[d,f]=I.useState(r===void 0);return I.useEffect(()=>{if(r!==void 0){const g=window.setTimeout(()=>f(!0),r);return()=>window.clearTimeout(g)}},[r]),d&&m.imageLoadingStatus!=="loaded"?e.jsx(Ge.span,{...c,ref:a}):null});Ls.displayName=Es;function Ds(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function $t(t,{referrerPolicy:a,crossOrigin:n}){const r=Ut(),c=I.useRef(null),m=r?(c.current||(c.current=new window.Image),c.current):null,[d,f]=I.useState(()=>Ds(m,t));return o.useLayoutEffect2(()=>{f(Ds(m,t))},[m,t]),o.useLayoutEffect2(()=>{const g=x=>()=>{f(x)};if(!m)return;const v=g("loaded"),h=g("error");return m.addEventListener("load",v),m.addEventListener("error",h),a&&(m.referrerPolicy=a),typeof n=="string"&&(m.crossOrigin=n),()=>{m.removeEventListener("load",v),m.removeEventListener("error",h)}},[m,n,a]),d}var As=Ns,Os=Is,ks=Ls;const Be=I.forwardRef(({className:t,...a},n)=>e.jsx(As,{ref:n,className:o.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));Be.displayName=As.displayName;const Bt=I.forwardRef(({className:t,...a},n)=>e.jsx(Os,{ref:n,className:o.cn("aspect-square h-full w-full",t),...a}));Bt.displayName=Os.displayName;const ze=I.forwardRef(({className:t,...a},n)=>e.jsx(ks,{ref:n,className:o.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));ze.displayName=ks.displayName;function zt({open:t,onOpenChange:a,group:n,onUpdate:r}){const[c,m]=b.useState("members"),[d,f]=b.useState(""),[g,v]=b.useState([]),[h,x]=b.useState([]),{data:p,isLoading:u,refetch:i}=s.useGroupMembers(n.id),y=n.type==="TENANT_GROUP"?"tenant":"organization",{users:w,isLoading:D}=s.useUnifiedUsers({type:y,tenantId:n.tenantId||void 0,active:!0,limit:100}),C=Ot(),N=kt(),E=(p==null?void 0:p.members)||[],M=b.useMemo(()=>new Set(E.map(S=>S.userId)),[E]),P=b.useMemo(()=>w.filter(S=>!M.has(S.id)),[w,M]),_=b.useMemo(()=>{if(!d)return P;const S=d.toLowerCase();return P.filter(L=>{var F,q;return((F=L.name)==null?void 0:F.toLowerCase().includes(S))||((q=L.email)==null?void 0:q.toLowerCase().includes(S))})},[P,d]),j=b.useMemo(()=>{if(!d)return E;const S=d.toLowerCase();return E.filter(L=>{var F,q,te,K;return((q=(F=L.user)==null?void 0:F.name)==null?void 0:q.toLowerCase().includes(S))||((K=(te=L.user)==null?void 0:te.email)==null?void 0:K.toLowerCase().includes(S))})},[E,d]),R=async()=>{if(g.length!==0)try{await C.mutateAsync({groupId:n.id,data:{userIds:g,userType:y==="tenant"?"tenant":"org"}}),v([]),m("members"),i(),r==null||r()}catch(S){console.error("Failed to add members:",S)}},B=async()=>{if(h.length!==0)try{await N.mutateAsync({groupId:n.id,data:{userIds:h}}),x([]),i(),r==null||r()}catch(S){console.error("Failed to remove members:",S)}},V=S=>{v(L=>L.includes(S)?L.filter(F=>F!==S):[...L,S])},H=S=>{x(L=>L.includes(S)?L.filter(F=>F!==S):[...L,S])};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:[E.length," ",E.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:c,onValueChange:S=>{m(S),f(""),x([])},className:"mt-4",children:[e.jsxs(o.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(o.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(o.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(o.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{placeholder:"Search members...",value:d,onChange:S=>f(S.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:h.length>0?"h-[300px]":"h-[350px]",children:u?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(S=>e.jsx(s.Skeleton,{className:"h-16 w-full"},S))}):j.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:d?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:d?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:j.map(S=>e.jsx(Vt,{member:S,selected:h.includes(S.userId),onToggle:()=>H(S.userId)},S.id))})}),h.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h.length," member",h.length!==1?"s":""," selected"]}),e.jsx(o.Button,{variant:"destructive",size:"sm",onClick:B,disabled:N.isPending,children:N.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(o.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{placeholder:"Search users to add...",value:d,onChange:S=>f(S.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:"h-[300px]",children:D?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(S=>e.jsx(s.Skeleton,{className:"h-16 w-full"},S))}):_.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.UserPlus,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:d?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:_.map(S=>e.jsx(Ht,{user:S,selected:g.includes(S.id),onToggle:()=>V(S.id)},S.id))})}),g.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[g.length," user",g.length!==1?"s":""," selected"]}),e.jsx(o.Button,{onClick:R,disabled:C.isPending,children:C.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(s.UserPlus,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function Vt({member:t,selected:a,onToggle:n}){var c,m,d,f;const r=((m=(c=t.user)==null?void 0:c.name)==null?void 0:m.split(" ").map(g=>g[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:n,children:[e.jsx(s.Checkbox,{checked:a}),e.jsx(Be,{className:"h-8 w-8",children:e.jsx(ze,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((d=t.user)==null?void 0:d.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(f=t.user)==null?void 0:f.email})]})]})}function Ht({user:t,selected:a,onToggle:n}){var c;const r=((c=t.name)==null?void 0:c.split(" ").map(m=>m[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(Be,{className:"h-8 w-8",children:e.jsx(ze,{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 Kt({open:t,onOpenChange:a}){const[n,r]=b.useState("groups"),[c,m]=b.useState(""),[d,f]=b.useState(null),[g,v]=b.useState(!1),[h,x]=b.useState(null),{tokenProps:p}=s.useSemaphorContext(),{currentUser:u}=s.useCurrentUserInfo(),i=At(),y=(u==null?void 0:u.type)==="tenant",w=p==null?void 0:p.tenantId,{groups:D,isLoading:C,refetch:N}=s.useGroups({type:y?"TENANT_GROUP":"all",tenantId:y?w:void 0,includeMembers:!1}),E=D.filter(j=>{var R;return j.name.toLowerCase().includes(c.toLowerCase())||((R=j.description)==null?void 0:R.toLowerCase().includes(c.toLowerCase()))}),M=async()=>{if(h)try{await i.mutateAsync(h.id),x(null),N()}catch(j){console.error("Failed to delete group:",j)}},P=j=>{f(j),v(!0)},_=()=>{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:c,onChange:j=>m(j.target.value),className:"pl-7"})]}),e.jsx(o.ScrollArea,{className:"h-[400px]",children:C?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(j=>e.jsx(s.Skeleton,{className:"h-16 w-full rounded-[6px]"},j))}):E.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx("p",{className:"text-[13px]",children:"No groups found."}),e.jsx("p",{className:"mt-1 text-[12px]",children:c?"Try a different search.":"Create your first group to get started."})]}):e.jsx("div",{className:"space-y-2 pr-2",children:E.map(j=>e.jsx(Qt,{group:j,onManageMembers:()=>P(j),onDelete:()=>x(j),currentUserId:u==null?void 0:u.id},j.id))})})]})}),e.jsx(o.TabsContent,{value:"create",className:"mt-4",children:e.jsx(Tt,{onSuccess:_,tenantId:w,isTenantUser:y})})]})]})}),d&&e.jsx(zt,{open:g,onOpenChange:v,group:d,onUpdate:()=>N()}),e.jsx(s.AlertDialog,{open:!!h,onOpenChange:()=>x(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete group"}),e.jsxs(s.AlertDialogDescription,{children:['Delete "',h==null?void 0:h.name,`"? This removes all members and can't be undone.`]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:M,disabled:i.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete group"})]})]})})]})}function Qt({group:t,onManageMembers:a,onDelete:n,currentUserId:r}){const c=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 ",it.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(s.UserPlus,{className:"h-3.5 w-3.5"})}),c&&e.jsx(o.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:n,title:"Delete group","aria-label":"Delete group",children:e.jsx(s.Trash2,{className:"h-3.5 w-3.5"})})]})]})})}function ee(t,a,n){var m,d;const r=(t.controls||[]).find(f=>f.id===n);if(r)return r.label;const c=(d=(m=o.findCardById(t,a))==null?void 0:m.controls)==null?void 0:d.find(f=>f.id===n);return(c==null?void 0:c.label)||n}function se(t,a){var n;return((n=o.findCardById(t,a))==null?void 0:n.title)||a}function Wt(t){const{errors:a,dashboard:n}=t;if(!n)return a;const r=new Map;for(const c of a){const m=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(m){const[,h,x]=m,p=`${h}:${x}:missing-metric`;r.has(p)||r.set(p,`"${se(n,h)}" has an outdated "${ee(n,h,x)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const d=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(d){const[,h,x]=d,p=`${h}:${x}:missing-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" has an outdated "${ee(n,h,x)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const f=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(f){const[,h,x]=f,p=`${h}:${x}:invalid-metric`;r.has(p)||r.set(p,`"${se(n,h)}" has an invalid "${ee(n,h,x)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const g=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(g){const[,h,x]=g,p=`${h}:${x}:invalid-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" has an invalid "${ee(n,h,x)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const v=c.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(v){const[,h,x]=v,p=`${h}:${x}:missing-temporal-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" can no longer use "${ee(n,h,x)}" for time grain because the card does not currently group by a date field.`);continue}r.set(c,c)}return Array.from(r.values())}const Jt=["enum","multi_enum","text","number","boolean","date"];function Yt({open:t,onOpenChange:a,initialMode:n="manage"}){var _;const r=n==="create",{forceClose:c,handleOpenChange:m,isCreateFlowActive:d,preventPassiveDismissDuringCreate:f,resolvedOpen:g,setIsCreateFlowActive:v}=gs.useCreateFlowOverlayState({open:t,onOpenChange:a,initialCreateFlowActive:n==="create",dismissMode:"explicit-only"}),h=o.useDashboardStore(j=>j.dashboard),x=o.useDashboardStore(j=>j.selectedSheetId),{setDashboardInputs:p}=o.useDashboardActions(),u=(_=h.sheets)==null?void 0:_.find(j=>j.id===x),i=(u==null?void 0:u.kind)==="document"&&!!u.document,y=b.useMemo(()=>i&&(u!=null&&u.document)?s.getDocumentSheetDashboardInputs(h,u.id):[],[h,i,u==null?void 0:u.document,u==null?void 0:u.id]),w=b.useMemo(()=>y.filter(j=>j.kind==="control"),[y]),D=b.useMemo(()=>w.map(j=>j.control),[w]),C=b.useMemo(()=>Zt(D),[D]),N=b.useMemo(()=>Xt(h),[h]),E=b.useCallback(()=>{if(r){c();return}v(!1)},[r,c,v]),M=b.useCallback((j,R,B)=>{!i||!(u!=null&&u.document)||p(sa({allInputs:h.inputs||[],documentSheetId:u.id,currentDocumentInputs:y,nextControls:j,nextDefaultValues:R,change:B}))},[h.inputs,y,i,u,p]);if(!i||!(u!=null&&u.document))return null;const P=d?"Add document control":"Document Controls";return e.jsx(s.Dialog,{open:g,onOpenChange:m,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:f,onPointerDownOutside:f,children:[e.jsxs(s.DialogHeader,{className:d?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:P}),e.jsx(s.DialogDescription,{className:d?"sr-only":"text-[13px]",children:d?"Configure and add a document-local control input.":"Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:e.jsx(gs.ControlDefinitionListEditor,{scope:"dashboard",controls:D,reservedControlIds:N,defaultValues:C,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:Jt,initialCreateFlow:n==="create",onCreateFlowActiveChange:v,onCreateFlowComplete:E,onChange:M,emptyMessage:"No document controls yet."})})]})})}function Xt(t){return(t.controls||[]).map(a=>a.id)}function Zt(t){const a={};for(const n of t)n.defaultValue!==void 0&&(a[n.id]=n.defaultValue);return a}function ea(t,a){return a?Object.prototype.hasOwnProperty.call(a,t.id)?{...t,defaultValue:a[t.id]}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}}function sa({allInputs:t,documentSheetId:a,currentDocumentInputs:n,nextControls:r,nextDefaultValues:c,change:m}){const d=new Map(r.map(p=>[p.id,ea(p,c)])),f=(m==null?void 0:m.type)==="rename"?{oldId:m.oldId,newId:m.newId}:null,g=new Set,v=[];for(const p of n){if(p.kind!=="control"){v.push(p);continue}const u=d.get(p.control.id)||((f==null?void 0:f.oldId)===p.control.id?d.get(f.newId):void 0);if(!u)continue;g.add(u.id);const i=s.createUniqueDashboardInputVariableNameFromName(u.id,[...t,...v].filter(w=>w.id!==p.id)),y=u.id===i?u:{...u,id:i};v.push({...p,label:y.label,variableName:i,requiredAtExecution:y.requiredAtExecution,control:y})}for(const p of d.values())g.has(p.id)||v.push(s.createDashboardControlInputFromControl({control:p,existingInputs:[...t,...v],sheetId:a}));const h=new Set(n.map(p=>p.id));return[...t.filter(p=>!h.has(p.id)),...v]}function ws(t,a){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(a)}}function ta(){var cs,ds,us,ms,hs,ps;G.useExportRecovery(),G.useExportPolling();const{authToken:t,tokenProps:a,id:n}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{openBrandStudioPreview:c}=s.useBrandStudioPreview(),{permissions:m}=Ct(),d=s.useHasDashboardId(),{isLoading:f}=s.useDashboardQuery(),g=o.useDashboardStore(l=>l.theme),v=o.useDashboardStore(l=>l.isDownloadingPdf),h=o.useDashboardStore(l=>l.dashboardAssistantDraftScopeKey),x=o.useDashboardStore(l=>l.lenses),p=o.useDashboardStore(l=>l.selectedLensId),u=x==null?void 0:x.find(l=>l.id===p),i=o.useDashboardStore(l=>l.dashboard),y=o.useDashboardStore(l=>l.selectedSheetId),w=(cs=i==null?void 0:i.sheets)==null?void 0:cs.find(l=>l.id===y),D=o.isDocumentSheet(w),C=D?(ds=w==null?void 0:w.document)==null?void 0:ds.page:void 0,N=o.useDashboardStore(l=>l.isDashboardEditing),{setDashboardTitle:E}=o.useDashboardStore(l=>l.actions),[M,P]=b.useState(!1),[_,j]=b.useState(!1),[R,B]=b.useState(!1),[V,H]=b.useState(!1),[S,L]=b.useState(!1),[F,q]=b.useState(!1),[te,K]=b.useState(!1),[Ts,Ve]=b.useState(!1),[De,ae]=b.useState(null),[Ps,ne]=b.useState(!1),[re,oe]=b.useState(null),[He,ie]=b.useState([]),[Ke,le]=b.useState(!1),Fs=o.useDashboardStore(l=>l.isDashboardPanelOpen),_s=o.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),Us=o.useDashboardStore(l=>l.filterValues),O=o.useDashboardStore(l=>l.isVisualEditing);o.useEditorStore(l=>l.card);const Q=s.useManagementStore(l=>l.selectedDashboard),ce=s.useManagementStore(l=>l.initialDashboard);s.useManagementStore(l=>l.selectedVisual),o.useDashboardStore(l=>l.selectedFrameId),o.useEditorStore(l=>l.frame);const de=Q?(ms=Q==null?void 0:Q.permissions)==null?void 0:ms.canEdit:(us=ce==null?void 0:ce.permissions)==null?void 0:us.canEdit,ue=o.useDashboardStore(l=>l.showFilters),Qe=s.useAssistantLayoutStore(l=>l.setPanelOpen),We=o.useDashboardStore(l=>l.showDashboardJSON),we=o.useDashboardStore(l=>l.onSaveFunction),Je=o.useDashboardStore(l=>l.actions.setShowFilters),{setDocumentInspectorTab:Ye,setIsDashboardEditing:Xe,setShowDashboardJSON:Ze}=o.useDashboardStore(l=>l.actions),{setInitialDashboard:es,clearSelectedDashboard:Ce}=s.useManagementStore(l=>l.actions),{resources:me}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Ne}=s.useUserPreferences(),Rs=((hs=Ne==null?void 0:Ne.preference)==null?void 0:hs.defaultDashboardId)||null,{mutate:qs,isPending:Gs}=s.useDefaultDashboardMutation(),{currentUser:$s}=s.useCurrentUserInfo(),Bs=s.canUserManageGroups($s),z=Q||ce,ss=z?{id:z.id,title:(i==null?void 0:i.title)||z.title||"Dashboard"}:null,{handleAddNewFrame:zs}=s.useAddNewFrame(),[Me,Ie]=b.useState(!1),[Vs,W]=b.useState(!1),[Ee,he]=b.useState("close"),J=s.useUpdateResource(s.ResourceType.DASHBOARD),[T,pe]=b.useState(null),ts=b.useCallback(l=>{window.setTimeout(()=>{ae(l)},0)},[]),Hs=async(l,A)=>{if(!(i!=null&&i.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:i.id,newTitle:l,previousTitle:A}),J.mutate({resourceId:i.id,data:{title:l}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:U=>{console.error("Failed to update dashboard title:",U),s.ue.error("Failed to update dashboard title"),E(A)}})};b.useEffect(()=>{if(me&&me.length>0){const l=i==null?void 0:i.id;if(l){const A=me.find(U=>U.id===l);A&&es(A)}}},[me,i==null?void 0:i.id,es]);const Y=a.orgUserId||a.tenantId,Le=b.useMemo(()=>aa({accessToken:t==null?void 0:t.accessToken,dashboardId:(i==null?void 0:i.id)||n||a.dashboard_id,selectedSheetId:D?y:void 0,pageSize:C==null?void 0:C.size,orientation:C==null?void 0:C.orientation,theme:g}),[t==null?void 0:t.accessToken,n,i==null?void 0:i.id,D,C==null?void 0:C.orientation,C==null?void 0:C.size,y,g,a.dashboard_id]),as=N&&!O&&Y&&de,{setDashboard:Ae}=o.useDashboardStore(l=>l.actions),Oe=o.useDashboardStore(l=>l.semanticExecutionPayload),Ks=()=>{Xe(!0)},ke=()=>{Xe(!1),Ze(!1),pe(null),ae(null)};b.useEffect(()=>{if(!N){T&&pe(null);return}T||!i||f||pe(ws(i,Oe))},[i,T,N,f,Oe]);const fe=(T==null?void 0:T.dashboard)??null,{isDirty:ns,isDirtyPending:Qs,resetDirty:xe}=lt.useDebouncedDirtyCheck(i,fe,300,1e3,Fe.serializeDashboardForDirtyCheck),rs=b.useCallback(()=>fe?Fe.serializeDashboardForDirtyCheck(i)!==Fe.serializeDashboardForDirtyCheck(fe):!1,[i,fe]),os=ns||Qs,ge=Me||J.isPending,Ws=()=>{rs()?(he("close"),W(!0)):(ke(),xe())},Js=async()=>{await Te({closeAfterSave:!0,navigateHomeAfterSave:Ee==="home"})},Ys=()=>{T&&Ae(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),ke(),Ee==="home"&&Ce(),he("close"),W(!1),xe()},Xs=()=>{T&&(Ae(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),xe())},Zs=()=>{if(N&&rs()){he("home"),W(!0);return}Ce()};async function Te(l){const A=o.useDashboardStore.getState().dashboard;if(!A)return;const U=(l==null?void 0:l.closeAfterSave)??Ke,nt=(l==null?void 0:l.navigateHomeAfterSave)??!1;le(U),U&&W(!1);const rt=s.cloneDeep(A);ne(!0),oe(null),ie([]),Ie(!0);const ot={template:A};J.mutate({resourceId:A.id,data:ot},{onSuccess:k=>{var ve,ye,fs;const $=(k==null?void 0:k.id)||((ve=k==null?void 0:k.dashboard)==null?void 0:ve.id)||((ye=k==null?void 0:k.resource)==null?void 0:ye.id)||((fs=k==null?void 0:k.template)==null?void 0:fs.id)||null;if(!A.id&&$){const Pe=o.useAIInteractionStore.getState(),Se=Pe.pendingDashboardDraftMigration;(Se==null?void 0:Se.scopeKey)===h?Pe.actions.setPendingDashboardDraftMigrationExpectedDashboardId($):Se&&Pe.actions.clearPendingDashboardDraftMigration()}Ie(!1),s.ue.success("Dashboard saved!"),pe(ws(rt,o.useDashboardStore.getState().semanticExecutionPayload)),ne(!1),le(!1),U&&(ke(),xe(),nt&&Ce()),he("close")},onError:k=>{Ie(!1),oe("Failed to save dashboard. Please try again.");const $=k.details,ve=Array.isArray($==null?void 0:$.errors)?($.errors||[]).filter(ye=>typeof ye=="string"):[];ie(Wt({errors:ve,dashboard:A||void 0})),s.ue.error("Failed to save dashboard")}})}async function et(){if(P(!0),!p||!u)return;const l=o.useDashboardStore.getState().dashboard;if(!l){P(!1);return}const A=JSON.stringify(l),U={...u,template:A,filterValues:Us};await qe(a.apiServiceUrl,U,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),we==null||we(l),P(!1)}const is=(u==null?void 0:u.name)||i.title,X=!!(i!=null&&i.id);J.isPending&&console.log("Title during update:",{title:is,dashboardStateTitle:i.title,dashboardId:i==null?void 0:i.id,currentLensName:u==null?void 0:u.name});const ls=a.orgUserId||a.tenantId&&a.endUserId&&a.endUserEmail,st=!!ls&&!!(t!=null&&t.accessToken)&&!!(a!=null&&a.apiServiceUrl);b.useEffect(()=>{!X&&V&&H(!1)},[X,V]);const tt=d,Z=(i==null?void 0:i.id)||null,be=!!Z&&Rs===Z,at=()=>{Z&&qs({dashboardId:be?null:Z})};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:[ls&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{_s(!Fs)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(ut,{className:"h-3.5 w-3.5"})}),tt&&!O&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Zs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!O&&d&&(f?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:is||"Untitled Dashboard",onSave:l=>{console.log("EditableText onSave called:",{newTitle:l,canEditDashboard:de,dashboardId:i==null?void 0:i.id});const A=(i==null?void 0:i.title)||"";E(l),Hs(l,A)},isEditable:de&&!u,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:J.isPending}),st&&Z&&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:at,disabled:Gs||!(t!=null&&t.accessToken)||!(a!=null&&a.apiServiceUrl),className:"w-7 px-0","aria-label":be?"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",be?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(o.TooltipContent,{children:e.jsx("p",{children:be?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[O&&e.jsxs(e.Fragment,{children:[e.jsx(G.AdvancedModeToggle,{}),e.jsx(G.VisualEditingControls,{})]}),!O&&d&&((ps=z==null?void 0:z.permissions)==null?void 0:ps.canShare)&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:()=>j(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!O&&N&&m.canUseFilters&&d&&e.jsx(G.DashboardFilterControlsButton,{showFilters:D?!1:ue,onToggleFilters:()=>{if(D&&y){Ye(y,"inputs");return}ue||Qe("dashboard",!1),Je(!ue)},onAddFilter:()=>{if(D&&y){Ye(y,"inputs");return}ue||(Qe("dashboard",!1),Je(!0))},onAddControl:()=>{ts("create")},onManageControls:()=>ts("manage")}),N&&!O&&d&&De?D?e.jsx(Yt,{open:!0,onOpenChange:l=>{l||ae(null)},initialMode:De}):e.jsx(G.DashboardControlsSettings,{open:!0,onOpenChange:l=>{l||ae(null)},showTrigger:!1,initialMode:De}):null,N&&!O&&Y&&u&&r&&d&&e.jsxs(o.Button,{variant:"secondary",size:"xs",disabled:M,onClick:et,children:[e.jsx(bs.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),N&&!O&&d&&!D&&e.jsxs(o.Button,{variant:"outline",size:"xs",disabled:!N,onClick:()=>zs(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!O&&!N&&de&&d&&e.jsxs(o.Button,{size:"xs",onClick:Ks,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),as&&d&&ns&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:Xs,disabled:ge,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),as&&d&&e.jsxs(o.Button,{size:"xs",className:o.cn(!os&&"opacity-60"),disabled:ge||!os,onClick:()=>Te(),children:[ge?e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(bs.Save,{className:"h-3.5 w-3.5"}),ge?"Saving...":"Save"]}),N&&!O&&d&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:Ws,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!O&&d&&e.jsx("div",{className:"ml-2",children:e.jsx(G.NotificationBell,{})}),!O&&r&&e.jsx(vt,{}),!O&&d&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:v,onSelect:()=>Ve(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsxs(s.DropdownMenuItem,{disabled:!X,onSelect:()=>{X&&H(!0)},children:[e.jsx(s.Clock,{className:"h-3.5 w-3.5"}),"Schedule"]}),e.jsx(s.DropdownMenuSeparator,{}),Bs&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>B(!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:()=>L(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>q(!0),children:[e.jsx(s.FileText,{className:"h-3.5 w-3.5"}),"Summary Settings"]}),r&&d&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var l;t!=null&&t.accessToken&&((l=navigator==null?void 0:navigator.clipboard)!=null&&l.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),D&&e.jsxs(s.DropdownMenuItem,{disabled:!Le,onSelect:()=>{var l;if(!Le){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(Le).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(pt,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:c,children:[e.jsx(vs.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Ze(!We),children:[e.jsx(vs.Braces,{className:"h-3.5 w-3.5"}),We?"Hide dashboard JSON":"Show dashboard JSON"]}),Y&&N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>K(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),Y&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(dt,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(wt,{})})]})]})]})]}),_&&ss&&e.jsx(s.ShareDialog,{resource:ss,resourceType:s.ResourceType.DASHBOARD,onClose:()=>j(!1)}),e.jsx(Kt,{open:R,onOpenChange:B}),X&&(i==null?void 0:i.id)&&e.jsx(s.EmailScheduleDialog,{open:V,onOpenChange:H,dashboardId:i.id,dashboardName:i==null?void 0:i.title}),e.jsx(xs.CalendarPreferencesDialog,{open:S,onOpenChange:L}),e.jsx(xs.DashboardSummarySettingsDialog,{open:F,onOpenChange:q,dashboard:i,disabled:!N,onApply:l=>Ae({...i,summary:l},{semanticExecutionPayload:Oe})}),r&&Y&&d&&e.jsx(Dt,{open:te,onOpenChange:K}),d&&e.jsx(s.DownloadPdf,{open:Ts,onOpenChange:Ve}),e.jsx(s.AlertDialog,{open:Ps,onOpenChange:l=>{!l&&Me&&!re||(ne(l),l||(oe(null),ie([]),le(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:re?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:re?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),He.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:He.slice(0,5).map(l=>e.jsx("li",{children:l},l))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:re?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{ne(!1),oe(null),ie([]),le(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Te({closeAfterSave:Ke,navigateHomeAfterSave:Ee==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(G.UnsavedChangesAlert,{open:Vs,onOpenChange:l=>{W(l)},onSave:Js,onDiscard:Ys,isSaving:Me,saveLabel:"Save",discardLabel:"Discard"})]})]})}function aa({accessToken:t,dashboardId:a,selectedSheetId:n,pageSize:r,orientation:c,theme:m}){if(!t||!n)return null;const d=new URL("http://localhost:5173/print-document");d.searchParams.set("token",t),a&&d.searchParams.set("dashboardId",a),d.searchParams.set("selectedSheetId",n),m&&d.searchParams.set("theme",m);const f=new URL("http://127.0.0.1:3002/");return f.searchParams.set("pdfMode","document"),f.searchParams.set("pageSize",r||"letter"),f.searchParams.set("orientation",c||"portrait"),f.searchParams.set("url",d.toString()),f.toString()}exports.default=ta;
|
|
47
|
+
*/var ys;function bt(){return ys||(ys=1,process.env.NODE_ENV!=="production"&&function(){function t(u,i){return u===i&&(u!==0||1/u===1/i)||u!==u&&i!==i}function a(u,i){h||c.startTransition===void 0||(h=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var y=i();if(!x){var w=i();m(y,w)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),x=!0)}w=d({inst:{value:y,getSnapshot:i}});var D=w[0].inst,C=w[1];return g(function(){D.value=y,D.getSnapshot=i,n(D)&&C({inst:D})},[u,y,i]),f(function(){return n(D)&&C({inst:D}),u(function(){n(D)&&C({inst:D})})},[u]),v(y),y}function n(u){var i=u.getSnapshot;u=u.value;try{var y=i();return!m(u,y)}catch{return!0}}function r(u,i){return i()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var c=b,m=typeof Object.is=="function"?Object.is:t,d=c.useState,f=c.useEffect,g=c.useLayoutEffect,v=c.useDebugValue,h=!1,x=!1,p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:a;Ue.useSyncExternalStore=c.useSyncExternalStore!==void 0?c.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ue}process.env.NODE_ENV==="production"?Re.exports=gt():Re.exports=bt();var vt=Re.exports;const je=["light","dark","system"];function yt(){const{theme:t,setTheme:a}=s.useTheme(),n=o.useDashboardStore(d=>d.actions.setDashboardTheme);function r(){const d=je.includes(t)?t:"system",f=je[(je.indexOf(d)+1)%je.length];a(f),n(f)}const c=t==="light"?xt:t==="dark"?pt:ht,m=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":m,title:m,children:e.jsx(c,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function St(t,a,n,r,c){if(!c)return null;const m=JSON.stringify(n),d=`${t}/v1/lens`;return await o.postRequest(d,c,{name:a,template:m,filterValues:r,operation:"create"})}async function qe(t,a,n){if(!n)return null;const{id:r,template:c,filterValues:m,isDefault:d,shared:f}=a,g=`${t}/v1/lens`;return await o.postRequest(g,n,{lensId:r,template:c,filterValues:m,isDefault:d,shared:f,operation:"update"})}async function jt(t,a,n){if(!n)return null;const r=`${t}/v1/lens`;return await o.postRequest(r,n,{operation:"delete",lensId:a})}const Dt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function wt({open:t,onOpenChange:a}={}){const[n,r]=b.useState(""),[c,m]=b.useState(!1),d=o.useDashboardStore(M=>M.lenses),{setLenses:f,setSelectedLensId:g}=o.useDashboardActions(),[v,h]=b.useState(!1),[x,p]=b.useState(!1),u=t!==void 0,i=u?t:x,y=M=>{u||p(M),a==null||a(M)},w=o.useDashboardStore(M=>M.dashboard),D=o.useDashboardStore(M=>M.filterValues),{authToken:C,tokenProps:N}=s.useSemaphorContext();async function E(){h(!0);const M=await St(N.apiServiceUrl,n,w,D,C==null?void 0:C.accessToken);M&&(f([...d||[],M]),g(M.id),y(!1)),h(!1)}return e.jsxs(s.Dialog,{open:i,onOpenChange:y,children:[u?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:Dt,children:"Name"}),e.jsx(o.Input,{id:"lens-name",size:"xs",value:n,placeholder:"Monthly review, West region, …",onChange:M=>r(M.target.value)}),c&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(o.Button,{variant:"outline",size:"xs",onClick:()=>y(!1),children:"Cancel"}),e.jsx(o.Button,{size:"xs",type:"submit",onClick:E,disabled:v||!n.trim(),children:v?"Creating…":"Create"})]})]})]})}function Ct({includeLabel:t=!1}={}){const a=o.useDashboardStore(h=>h.lenses),n=o.useDashboardStore(h=>h.selectedLensId),{setLenses:r,setSelectedLensId:c}=o.useDashboardActions(),{authToken:m,tokenProps:d}=s.useSemaphorContext();async function f(h){c(h)}async function g(h){if(await jt(d.apiServiceUrl,h,m==null?void 0:m.accessToken)){const p=a==null?void 0:a.filter(u=>u.id!==h);r(p||[]),c("original")}}async function v(h){const x=a==null?void 0:a.map(i=>i.id===h.id?{...i,isDefault:!h.isDefault}:{...i,isDefault:!1});r(x||[]);const p={...h,isDefault:!h.isDefault};await qe(d.apiServiceUrl,p,m==null?void 0:m.accessToken);const u=a==null?void 0:a.find(i=>i.isDefault);if(u&&u.id!==h.id){const i={...u,isDefault:!1};await qe(d.apiServiceUrl,i,m==null?void 0:m.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:f,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(h=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:h.id,children:[e.jsx("p",{children:h.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:x=>{x.preventDefault(),v(h)},className:o.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!h.isDefault,"text-green-500":h.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:x=>{x.preventDefault(),g(h.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},h.id))]})]})}function Nt(){const{displayPreferences:t,shouldShowElement:a}=s.useDisplayPreferences(),{currentUser:n,userContext:r}=s.useCurrentUserInfo(),c=b.useMemo(()=>s.getRoleBasedDisplayOverrides(n),[n]),m=b.useMemo(()=>f=>c&&c[f]!==void 0&&c[f]===!1?!1:a(f),[c,a,t]),d=b.useMemo(()=>{var f,g,v,h,x;return{canEdit:((f=r==null?void 0:r.permissions)==null?void 0:f.canEdit)??s.canUserEdit(n),canUseFilters:((g=r==null?void 0:r.permissions)==null?void 0:g.canEdit)??s.canUserUseFilters(n),canManageDashboards:((v=r==null?void 0:r.permissions)==null?void 0:v.canCreateDashboard)??s.canUserManageDashboards(n),canCreateDashboards:((h=r==null?void 0:r.permissions)==null?void 0:h.canCreateDashboard)??s.canUserCreateDashboards(n),canAccessVisuals:((x=r==null?void 0:r.permissions)==null?void 0:x.canEdit)??s.canUserAccessVisuals(n)}},[n,r]);return{displayPreferences:t,shouldShowElement:m,permissions:d,currentUser:n}}const Mt=async(t,a,n)=>{const r=`${t}/management/v1/groups`;return await o.postRequestRegular(r,a,n)},It=async(t,a,n)=>{const r=`${t}/management/v1/groups/${n}`;await o.requestJsonRegular(r,a,"DELETE")},Et=async(t,a,n,r)=>{const c=`${t}/management/v1/groups/${n}/members`;return await o.postRequestRegular(c,a,r)},Lt=async(t,a,n,r)=>{const c=`${t}/management/v1/groups/${n}/members`;await o.requestJsonRegular(c,a,"DELETE",r)};function At(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>Mt(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 Ot(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>It(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["groups"]}),n.removeQueries({queryKey:["group",c]}),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 kt(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:c})=>Et(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,c),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["group",c.groupId]}),n.invalidateQueries({queryKey:["group-members",c.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 Tt(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:c})=>Lt(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,c),onSuccess:(r,c)=>{n.invalidateQueries({queryKey:["group",c.groupId]}),n.invalidateQueries({queryKey:["group-members",c.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 Ss="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Pt({onSuccess:t,tenantId:a,isTenantUser:n}){const[r,c]=b.useState(""),[m,d]=b.useState(""),[f,g]=b.useState({}),v=At(),h=()=>{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",m&&m.length>200&&(p.description="Description must be less than 200 characters"),g(p),Object.keys(p).length===0},x=async p=>{if(p.preventDefault(),!h())return;const u={name:r.trim(),description:m.trim()||void 0,type:n?"TENANT_GROUP":"ORG_GROUP",...n&&a?{tenantId:a}:{}};try{await v.mutateAsync(u),c(""),d(""),g({}),t()}catch(i){console.error("Failed to create group:",i)}};return e.jsxs("form",{onSubmit:x,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(o.Label,{htmlFor:"group-name",className:Ss,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=>{c(p.target.value),f.name&&g(u=>({...u,name:""}))},className:f.name?"border-destructive":"",disabled:v.isPending}),f.name&&e.jsx("p",{className:"text-[12px] text-destructive",children:f.name})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{htmlFor:"group-description",className:Ss,children:"Description (optional)"}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group…",value:m,onChange:p=>{d(p.target.value),f.description&&g(u=>({...u,description:""}))},className:`text-[13px] ${f.description?"border-destructive":""}`,disabled:v.isPending,rows:3}),f.description?e.jsx("p",{className:"text-[12px] text-destructive",children:f.description}):e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[m.length,"/200"]})]}),e.jsxs("div",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[e.jsx(o.Info,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),e.jsx("p",{children:"This group will be accessible to users in your workspace. You can add members after creating it."})]}),e.jsxs("div",{className:"flex justify-end gap-1.5 pt-1",children:[e.jsx(o.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>{c(""),d(""),g({})},disabled:v.isPending,children:"Clear"}),e.jsx(o.Button,{type:"submit",size:"xs",disabled:v.isPending||!r.trim(),children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating…"]}):"Create group"})]})]})}function Ft(t,a=[]){let n=[];function r(m,d){const f=I.createContext(d);f.displayName=m+"Context";const g=n.length;n=[...n,d];const v=x=>{var D;const{scope:p,children:u,...i}=x,y=((D=p==null?void 0:p[t])==null?void 0:D[g])||f,w=I.useMemo(()=>i,Object.values(i));return e.jsx(y.Provider,{value:w,children:u})};v.displayName=m+"Provider";function h(x,p){var y;const u=((y=p==null?void 0:p[t])==null?void 0:y[g])||f,i=I.useContext(u);if(i)return i;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${m}\``)}return[v,h]}const c=()=>{const m=n.map(d=>I.createContext(d));return function(f){const g=(f==null?void 0:f[t])||m;return I.useMemo(()=>({[`__scope${t}`]:{...f,[t]:g}}),[f,g])}};return c.scopeName=t,[r,_t(c,...a)]}function _t(...t){const a=t[0];if(t.length===1)return a;const n=()=>{const r=t.map(c=>({useScope:c(),scopeName:c.scopeName}));return function(m){const d=r.reduce((f,{useScope:g,scopeName:v})=>{const x=g(m)[`__scope${v}`];return{...f,...x}},{});return I.useMemo(()=>({[`__scope${a.scopeName}`]:d}),[d])}};return n.scopeName=a.scopeName,n}var Ut=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ge=Ut.reduce((t,a)=>{const n=o.createSlot(`Primitive.${a}`),r=I.forwardRef((c,m)=>{const{asChild:d,...f}=c,g=d?n:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(g,{...f,ref:m})});return r.displayName=`Primitive.${a}`,{...t,[a]:r}},{});function Rt(){return vt.useSyncExternalStore(qt,()=>!0,()=>!1)}function qt(){return()=>{}}var $e="Avatar",[Gt]=Ft($e),[$t,ws]=Gt($e),Cs=I.forwardRef((t,a)=>{const{__scopeAvatar:n,...r}=t,[c,m]=I.useState("idle");return e.jsx($t,{scope:n,imageLoadingStatus:c,onImageLoadingStatusChange:m,children:e.jsx(Ge.span,{...r,ref:a})})});Cs.displayName=$e;var Ns="AvatarImage",Ms=I.forwardRef((t,a)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:c=()=>{},...m}=t,d=ws(Ns,n),f=Bt(r,m),g=o.useCallbackRef(v=>{c(v),d.onImageLoadingStatusChange(v)});return o.useLayoutEffect2(()=>{f!=="idle"&&g(f)},[f,g]),f==="loaded"?e.jsx(Ge.img,{...m,ref:a,src:r}):null});Ms.displayName=Ns;var Is="AvatarFallback",Es=I.forwardRef((t,a)=>{const{__scopeAvatar:n,delayMs:r,...c}=t,m=ws(Is,n),[d,f]=I.useState(r===void 0);return I.useEffect(()=>{if(r!==void 0){const g=window.setTimeout(()=>f(!0),r);return()=>window.clearTimeout(g)}},[r]),d&&m.imageLoadingStatus!=="loaded"?e.jsx(Ge.span,{...c,ref:a}):null});Es.displayName=Is;function js(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Bt(t,{referrerPolicy:a,crossOrigin:n}){const r=Rt(),c=I.useRef(null),m=r?(c.current||(c.current=new window.Image),c.current):null,[d,f]=I.useState(()=>js(m,t));return o.useLayoutEffect2(()=>{f(js(m,t))},[m,t]),o.useLayoutEffect2(()=>{const g=x=>()=>{f(x)};if(!m)return;const v=g("loaded"),h=g("error");return m.addEventListener("load",v),m.addEventListener("error",h),a&&(m.referrerPolicy=a),typeof n=="string"&&(m.crossOrigin=n),()=>{m.removeEventListener("load",v),m.removeEventListener("error",h)}},[m,n,a]),d}var Ls=Cs,As=Ms,Os=Es;const Be=I.forwardRef(({className:t,...a},n)=>e.jsx(Ls,{ref:n,className:o.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));Be.displayName=Ls.displayName;const zt=I.forwardRef(({className:t,...a},n)=>e.jsx(As,{ref:n,className:o.cn("aspect-square h-full w-full",t),...a}));zt.displayName=As.displayName;const ze=I.forwardRef(({className:t,...a},n)=>e.jsx(Os,{ref:n,className:o.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));ze.displayName=Os.displayName;function Vt({open:t,onOpenChange:a,group:n,onUpdate:r}){const[c,m]=b.useState("members"),[d,f]=b.useState(""),[g,v]=b.useState([]),[h,x]=b.useState([]),{data:p,isLoading:u,refetch:i}=s.useGroupMembers(n.id),y=n.type==="TENANT_GROUP"?"tenant":"organization",{users:w,isLoading:D}=s.useUnifiedUsers({type:y,tenantId:n.tenantId||void 0,active:!0,limit:100}),C=kt(),N=Tt(),E=(p==null?void 0:p.members)||[],M=b.useMemo(()=>new Set(E.map(S=>S.userId)),[E]),P=b.useMemo(()=>w.filter(S=>!M.has(S.id)),[w,M]),_=b.useMemo(()=>{if(!d)return P;const S=d.toLowerCase();return P.filter(L=>{var F,q;return((F=L.name)==null?void 0:F.toLowerCase().includes(S))||((q=L.email)==null?void 0:q.toLowerCase().includes(S))})},[P,d]),j=b.useMemo(()=>{if(!d)return E;const S=d.toLowerCase();return E.filter(L=>{var F,q,te,K;return((q=(F=L.user)==null?void 0:F.name)==null?void 0:q.toLowerCase().includes(S))||((K=(te=L.user)==null?void 0:te.email)==null?void 0:K.toLowerCase().includes(S))})},[E,d]),R=async()=>{if(g.length!==0)try{await C.mutateAsync({groupId:n.id,data:{userIds:g,userType:y==="tenant"?"tenant":"org"}}),v([]),m("members"),i(),r==null||r()}catch(S){console.error("Failed to add members:",S)}},B=async()=>{if(h.length!==0)try{await N.mutateAsync({groupId:n.id,data:{userIds:h}}),x([]),i(),r==null||r()}catch(S){console.error("Failed to remove members:",S)}},V=S=>{v(L=>L.includes(S)?L.filter(F=>F!==S):[...L,S])},H=S=>{x(L=>L.includes(S)?L.filter(F=>F!==S):[...L,S])};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:[E.length," ",E.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:c,onValueChange:S=>{m(S),f(""),x([])},className:"mt-4",children:[e.jsxs(o.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(o.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(o.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(o.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{placeholder:"Search members...",value:d,onChange:S=>f(S.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:h.length>0?"h-[300px]":"h-[350px]",children:u?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(S=>e.jsx(s.Skeleton,{className:"h-16 w-full"},S))}):j.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:d?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:d?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:j.map(S=>e.jsx(Ht,{member:S,selected:h.includes(S.userId),onToggle:()=>H(S.userId)},S.id))})}),h.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h.length," member",h.length!==1?"s":""," selected"]}),e.jsx(o.Button,{variant:"destructive",size:"sm",onClick:B,disabled:N.isPending,children:N.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(o.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(o.Input,{placeholder:"Search users to add...",value:d,onChange:S=>f(S.target.value),className:"pl-10"})]}),e.jsx(o.ScrollArea,{className:"h-[300px]",children:D?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(S=>e.jsx(s.Skeleton,{className:"h-16 w-full"},S))}):_.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.UserPlus,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:d?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:_.map(S=>e.jsx(Kt,{user:S,selected:g.includes(S.id),onToggle:()=>V(S.id)},S.id))})}),g.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[g.length," user",g.length!==1?"s":""," selected"]}),e.jsx(o.Button,{onClick:R,disabled:C.isPending,children:C.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(s.UserPlus,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function Ht({member:t,selected:a,onToggle:n}){var c,m,d,f;const r=((m=(c=t.user)==null?void 0:c.name)==null?void 0:m.split(" ").map(g=>g[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:n,children:[e.jsx(s.Checkbox,{checked:a}),e.jsx(Be,{className:"h-8 w-8",children:e.jsx(ze,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((d=t.user)==null?void 0:d.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(f=t.user)==null?void 0:f.email})]})]})}function Kt({user:t,selected:a,onToggle:n}){var c;const r=((c=t.name)==null?void 0:c.split(" ").map(m=>m[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(Be,{className:"h-8 w-8",children:e.jsx(ze,{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 Qt({open:t,onOpenChange:a}){const[n,r]=b.useState("groups"),[c,m]=b.useState(""),[d,f]=b.useState(null),[g,v]=b.useState(!1),[h,x]=b.useState(null),{tokenProps:p}=s.useSemaphorContext(),{currentUser:u}=s.useCurrentUserInfo(),i=Ot(),y=(u==null?void 0:u.type)==="tenant",w=p==null?void 0:p.tenantId,{groups:D,isLoading:C,refetch:N}=s.useGroups({type:y?"TENANT_GROUP":"all",tenantId:y?w:void 0,includeMembers:!1}),E=D.filter(j=>{var R;return j.name.toLowerCase().includes(c.toLowerCase())||((R=j.description)==null?void 0:R.toLowerCase().includes(c.toLowerCase()))}),M=async()=>{if(h)try{await i.mutateAsync(h.id),x(null),N()}catch(j){console.error("Failed to delete group:",j)}},P=j=>{f(j),v(!0)},_=()=>{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:c,onChange:j=>m(j.target.value),className:"pl-7"})]}),e.jsx(o.ScrollArea,{className:"h-[400px]",children:C?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(j=>e.jsx(s.Skeleton,{className:"h-16 w-full rounded-[6px]"},j))}):E.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx("p",{className:"text-[13px]",children:"No groups found."}),e.jsx("p",{className:"mt-1 text-[12px]",children:c?"Try a different search.":"Create your first group to get started."})]}):e.jsx("div",{className:"space-y-2 pr-2",children:E.map(j=>e.jsx(Wt,{group:j,onManageMembers:()=>P(j),onDelete:()=>x(j),currentUserId:u==null?void 0:u.id},j.id))})})]})}),e.jsx(o.TabsContent,{value:"create",className:"mt-4",children:e.jsx(Pt,{onSuccess:_,tenantId:w,isTenantUser:y})})]})]})}),d&&e.jsx(Vt,{open:g,onOpenChange:v,group:d,onUpdate:()=>N()}),e.jsx(s.AlertDialog,{open:!!h,onOpenChange:()=>x(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete group"}),e.jsxs(s.AlertDialogDescription,{children:['Delete "',h==null?void 0:h.name,`"? This removes all members and can't be undone.`]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:M,disabled:i.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete group"})]})]})})]})}function Wt({group:t,onManageMembers:a,onDelete:n,currentUserId:r}){const c=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 ",ot.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(s.UserPlus,{className:"h-3.5 w-3.5"})}),c&&e.jsx(o.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:n,title:"Delete group","aria-label":"Delete group",children:e.jsx(s.Trash2,{className:"h-3.5 w-3.5"})})]})]})})}function ee(t,a,n){var m,d;const r=(t.controls||[]).find(f=>f.id===n);if(r)return r.label;const c=(d=(m=o.findCardById(t,a))==null?void 0:m.controls)==null?void 0:d.find(f=>f.id===n);return(c==null?void 0:c.label)||n}function se(t,a){var n;return((n=o.findCardById(t,a))==null?void 0:n.title)||a}function Jt(t){const{errors:a,dashboard:n}=t;if(!n)return a;const r=new Map;for(const c of a){const m=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(m){const[,h,x]=m,p=`${h}:${x}:missing-metric`;r.has(p)||r.set(p,`"${se(n,h)}" has an outdated "${ee(n,h,x)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const d=c.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(d){const[,h,x]=d,p=`${h}:${x}:missing-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" has an outdated "${ee(n,h,x)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const f=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(f){const[,h,x]=f,p=`${h}:${x}:invalid-metric`;r.has(p)||r.set(p,`"${se(n,h)}" has an invalid "${ee(n,h,x)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const g=c.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(g){const[,h,x]=g,p=`${h}:${x}:invalid-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" has an invalid "${ee(n,h,x)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const v=c.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(v){const[,h,x]=v,p=`${h}:${x}:missing-temporal-group-by`;r.has(p)||r.set(p,`"${se(n,h)}" can no longer use "${ee(n,h,x)}" for time grain because the card does not currently group by a date field.`);continue}r.set(c,c)}return Array.from(r.values())}const Yt=["enum","multi_enum","text","number","boolean","date"];function Xt({open:t,onOpenChange:a,initialMode:n="manage"}){var _;const r=n==="create",{forceClose:c,handleOpenChange:m,isCreateFlowActive:d,preventPassiveDismissDuringCreate:f,resolvedOpen:g,setIsCreateFlowActive:v}=gs.useCreateFlowOverlayState({open:t,onOpenChange:a,initialCreateFlowActive:n==="create",dismissMode:"explicit-only"}),h=o.useDashboardStore(j=>j.dashboard),x=o.useDashboardStore(j=>j.selectedSheetId),{setDashboardInputs:p}=o.useDashboardActions(),u=(_=h.sheets)==null?void 0:_.find(j=>j.id===x),i=(u==null?void 0:u.kind)==="document"&&!!u.document,y=b.useMemo(()=>i&&(u!=null&&u.document)?s.getDocumentSheetDashboardInputs(h,u.id):[],[h,i,u==null?void 0:u.document,u==null?void 0:u.id]),w=b.useMemo(()=>y.filter(j=>j.kind==="control"),[y]),D=b.useMemo(()=>w.map(j=>j.control),[w]),C=b.useMemo(()=>ea(D),[D]),N=b.useMemo(()=>Zt(h),[h]),E=b.useCallback(()=>{if(r){c();return}v(!1)},[r,c,v]),M=b.useCallback((j,R,B)=>{!i||!(u!=null&&u.document)||p(ta({allInputs:h.inputs||[],documentSheetId:u.id,currentDocumentInputs:y,nextControls:j,nextDefaultValues:R,change:B}))},[h.inputs,y,i,u,p]);if(!i||!(u!=null&&u.document))return null;const P=d?"Add document control":"Document Controls";return e.jsx(s.Dialog,{open:g,onOpenChange:m,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:f,onPointerDownOutside:f,children:[e.jsxs(s.DialogHeader,{className:d?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:P}),e.jsx(s.DialogDescription,{className:d?"sr-only":"text-[13px]",children:d?"Configure and add a document-local control input.":"Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:e.jsx(gs.ControlDefinitionListEditor,{scope:"dashboard",controls:D,reservedControlIds:N,defaultValues:C,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:Yt,initialCreateFlow:n==="create",onCreateFlowActiveChange:v,onCreateFlowComplete:E,onChange:M,emptyMessage:"No document controls yet."})})]})})}function Zt(t){return(t.controls||[]).map(a=>a.id)}function ea(t){const a={};for(const n of t)n.defaultValue!==void 0&&(a[n.id]=n.defaultValue);return a}function sa(t,a){return a?Object.prototype.hasOwnProperty.call(a,t.id)?{...t,defaultValue:a[t.id]}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}}function ta({allInputs:t,documentSheetId:a,currentDocumentInputs:n,nextControls:r,nextDefaultValues:c,change:m}){const d=new Map(r.map(p=>[p.id,sa(p,c)])),f=(m==null?void 0:m.type)==="rename"?{oldId:m.oldId,newId:m.newId}:null,g=new Set,v=[];for(const p of n){if(p.kind!=="control"){v.push(p);continue}const u=d.get(p.control.id)||((f==null?void 0:f.oldId)===p.control.id?d.get(f.newId):void 0);if(!u)continue;g.add(u.id);const i=s.createUniqueDashboardInputVariableNameFromName(u.id,[...t,...v].filter(w=>w.id!==p.id)),y=u.id===i?u:{...u,id:i};v.push({...p,label:y.label,variableName:i,requiredAtExecution:y.requiredAtExecution,control:y})}for(const p of d.values())g.has(p.id)||v.push(s.createDashboardControlInputFromControl({control:p,existingInputs:[...t,...v],sheetId:a}));const h=new Set(n.map(p=>p.id));return[...t.filter(p=>!h.has(p.id)),...v]}function Ds(t,a){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(a)}}function aa(){var cs,ds,us,ms,hs,ps;G.useExportRecovery(),G.useExportPolling();const{authToken:t,tokenProps:a,id:n}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{openBrandStudioPreview:c}=s.useBrandStudioPreview(),{permissions:m}=Nt(),d=s.useHasDashboardId(),{isLoading:f}=s.useDashboardQuery(),g=o.useDashboardStore(l=>l.theme),v=o.useDashboardStore(l=>l.isDownloadingPdf),h=o.useDashboardStore(l=>l.dashboardAssistantDraftScopeKey),x=o.useDashboardStore(l=>l.lenses),p=o.useDashboardStore(l=>l.selectedLensId),u=x==null?void 0:x.find(l=>l.id===p),i=o.useDashboardStore(l=>l.dashboard),y=o.useDashboardStore(l=>l.selectedSheetId),w=(cs=i==null?void 0:i.sheets)==null?void 0:cs.find(l=>l.id===y),D=o.isDocumentSheet(w),C=D?(ds=w==null?void 0:w.document)==null?void 0:ds.page:void 0,N=o.useDashboardStore(l=>l.isDashboardEditing),{setDashboardTitle:E}=o.useDashboardStore(l=>l.actions),[M,P]=b.useState(!1),[_,j]=b.useState(!1),[R,B]=b.useState(!1),[V,H]=b.useState(!1),[S,L]=b.useState(!1),[F,q]=b.useState(!1),[te,K]=b.useState(!1),[ks,Ve]=b.useState(!1),[De,ae]=b.useState(null),[Ts,ne]=b.useState(!1),[re,oe]=b.useState(null),[He,ie]=b.useState([]),[Ke,le]=b.useState(!1),Ps=o.useDashboardStore(l=>l.isDashboardPanelOpen),Fs=o.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),_s=o.useDashboardStore(l=>l.filterValues),O=o.useDashboardStore(l=>l.isVisualEditing);o.useEditorStore(l=>l.card);const Q=s.useManagementStore(l=>l.selectedDashboard),ce=s.useManagementStore(l=>l.initialDashboard);s.useManagementStore(l=>l.selectedVisual),o.useDashboardStore(l=>l.selectedFrameId),o.useEditorStore(l=>l.frame);const de=Q?(ms=Q==null?void 0:Q.permissions)==null?void 0:ms.canEdit:(us=ce==null?void 0:ce.permissions)==null?void 0:us.canEdit,ue=o.useDashboardStore(l=>l.showFilters),Qe=s.useAssistantLayoutStore(l=>l.setPanelOpen),We=o.useDashboardStore(l=>l.showDashboardJSON),we=o.useDashboardStore(l=>l.onSaveFunction),Je=o.useDashboardStore(l=>l.actions.setShowFilters),{setDocumentInspectorTab:Ye,setIsDashboardEditing:Xe,setShowDashboardJSON:Ze}=o.useDashboardStore(l=>l.actions),{setInitialDashboard:es,clearSelectedDashboard:Ce}=s.useManagementStore(l=>l.actions),{resources:me}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Ne}=s.useUserPreferences(),Us=((hs=Ne==null?void 0:Ne.preference)==null?void 0:hs.defaultDashboardId)||null,{mutate:Rs,isPending:qs}=s.useDefaultDashboardMutation(),{currentUser:Gs}=s.useCurrentUserInfo(),$s=s.canUserManageGroups(Gs),z=Q||ce,ss=z?{id:z.id,title:(i==null?void 0:i.title)||z.title||"Dashboard"}:null,{handleAddNewFrame:Bs}=s.useAddNewFrame(),[Me,Ie]=b.useState(!1),[zs,W]=b.useState(!1),[Ee,he]=b.useState("close"),J=s.useUpdateResource(s.ResourceType.DASHBOARD),[T,pe]=b.useState(null),ts=b.useCallback(l=>{window.setTimeout(()=>{ae(l)},0)},[]),Vs=async(l,A)=>{if(!(i!=null&&i.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:i.id,newTitle:l,previousTitle:A}),J.mutate({resourceId:i.id,data:{title:l}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:U=>{console.error("Failed to update dashboard title:",U),s.ue.error("Failed to update dashboard title"),E(A)}})};b.useEffect(()=>{if(me&&me.length>0){const l=i==null?void 0:i.id;if(l){const A=me.find(U=>U.id===l);A&&es(A)}}},[me,i==null?void 0:i.id,es]);const Y=a.orgUserId||a.tenantId,Le=b.useMemo(()=>na({accessToken:t==null?void 0:t.accessToken,dashboardId:(i==null?void 0:i.id)||n||a.dashboard_id,selectedSheetId:D?y:void 0,pageSize:C==null?void 0:C.size,orientation:C==null?void 0:C.orientation,theme:g}),[t==null?void 0:t.accessToken,n,i==null?void 0:i.id,D,C==null?void 0:C.orientation,C==null?void 0:C.size,y,g,a.dashboard_id]),as=N&&!O&&Y&&de,{setDashboard:Ae}=o.useDashboardStore(l=>l.actions),Oe=o.useDashboardStore(l=>l.semanticExecutionPayload),Hs=()=>{Xe(!0)},ke=()=>{Xe(!1),Ze(!1),pe(null),ae(null)};b.useEffect(()=>{if(!N){T&&pe(null);return}T||!i||f||pe(Ds(i,Oe))},[i,T,N,f,Oe]);const fe=(T==null?void 0:T.dashboard)??null,{isDirty:ns,isDirtyPending:Ks,resetDirty:xe}=it.useDebouncedDirtyCheck(i,fe,300,1e3,Fe.serializeDashboardForDirtyCheck),rs=b.useCallback(()=>fe?Fe.serializeDashboardForDirtyCheck(i)!==Fe.serializeDashboardForDirtyCheck(fe):!1,[i,fe]),os=ns||Ks,ge=Me||J.isPending,Qs=()=>{rs()?(he("close"),W(!0)):(ke(),xe())},Ws=async()=>{await Te({closeAfterSave:!0,navigateHomeAfterSave:Ee==="home"})},Js=()=>{T&&Ae(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),ke(),Ee==="home"&&Ce(),he("close"),W(!1),xe()},Ys=()=>{T&&(Ae(T.dashboard,{semanticExecutionPayload:T.semanticExecutionPayload}),xe())},Xs=()=>{if(N&&rs()){he("home"),W(!0);return}Ce()};async function Te(l){const A=o.useDashboardStore.getState().dashboard;if(!A)return;const U=(l==null?void 0:l.closeAfterSave)??Ke,at=(l==null?void 0:l.navigateHomeAfterSave)??!1;le(U),U&&W(!1);const nt=s.cloneDeep(A);ne(!0),oe(null),ie([]),Ie(!0);const rt={template:A};J.mutate({resourceId:A.id,data:rt},{onSuccess:k=>{var ve,ye,fs;const $=(k==null?void 0:k.id)||((ve=k==null?void 0:k.dashboard)==null?void 0:ve.id)||((ye=k==null?void 0:k.resource)==null?void 0:ye.id)||((fs=k==null?void 0:k.template)==null?void 0:fs.id)||null;if(!A.id&&$){const Pe=o.useAIInteractionStore.getState(),Se=Pe.pendingDashboardDraftMigration;(Se==null?void 0:Se.scopeKey)===h?Pe.actions.setPendingDashboardDraftMigrationExpectedDashboardId($):Se&&Pe.actions.clearPendingDashboardDraftMigration()}Ie(!1),s.ue.success("Dashboard saved!"),pe(Ds(nt,o.useDashboardStore.getState().semanticExecutionPayload)),ne(!1),le(!1),U&&(ke(),xe(),at&&Ce()),he("close")},onError:k=>{Ie(!1),oe("Failed to save dashboard. Please try again.");const $=k.details,ve=Array.isArray($==null?void 0:$.errors)?($.errors||[]).filter(ye=>typeof ye=="string"):[];ie(Jt({errors:ve,dashboard:A||void 0})),s.ue.error("Failed to save dashboard")}})}async function Zs(){if(P(!0),!p||!u)return;const l=o.useDashboardStore.getState().dashboard;if(!l){P(!1);return}const A=JSON.stringify(l),U={...u,template:A,filterValues:_s};await qe(a.apiServiceUrl,U,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),we==null||we(l),P(!1)}const is=(u==null?void 0:u.name)||i.title,X=!!(i!=null&&i.id);J.isPending&&console.log("Title during update:",{title:is,dashboardStateTitle:i.title,dashboardId:i==null?void 0:i.id,currentLensName:u==null?void 0:u.name});const ls=a.orgUserId||a.tenantId&&a.endUserId&&a.endUserEmail,et=!!ls&&!!(t!=null&&t.accessToken)&&!!(a!=null&&a.apiServiceUrl);b.useEffect(()=>{!X&&V&&H(!1)},[X,V]);const st=d,Z=(i==null?void 0:i.id)||null,be=!!Z&&Us===Z,tt=()=>{Z&&Rs({dashboardId:be?null:Z})};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:[ls&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{Fs(!Ps)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(mt,{className:"h-3.5 w-3.5"})}),st&&!O&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Xs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!O&&d&&(f?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:is||"Untitled Dashboard",onSave:l=>{console.log("EditableText onSave called:",{newTitle:l,canEditDashboard:de,dashboardId:i==null?void 0:i.id});const A=(i==null?void 0:i.title)||"";E(l),Vs(l,A)},isEditable:de&&!u,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:J.isPending}),et&&Z&&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:tt,disabled:qs||!(t!=null&&t.accessToken)||!(a!=null&&a.apiServiceUrl),className:"w-7 px-0","aria-label":be?"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",be?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(o.TooltipContent,{children:e.jsx("p",{children:be?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[O&&e.jsxs(e.Fragment,{children:[e.jsx(G.AdvancedModeToggle,{}),e.jsx(G.VisualEditingControls,{})]}),!O&&d&&((ps=z==null?void 0:z.permissions)==null?void 0:ps.canShare)&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:()=>j(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!O&&N&&m.canUseFilters&&d&&e.jsx(G.DashboardFilterControlsButton,{showFilters:D?!1:ue,onToggleFilters:()=>{if(D&&y){Ye(y,"inputs");return}ue||Qe("dashboard",!1),Je(!ue)},onAddFilter:()=>{if(D&&y){Ye(y,"inputs");return}ue||(Qe("dashboard",!1),Je(!0))},onAddControl:()=>{ts("create")},onManageControls:()=>ts("manage")}),N&&!O&&d&&De?D?e.jsx(Xt,{open:!0,onOpenChange:l=>{l||ae(null)},initialMode:De}):e.jsx(G.DashboardControlsSettings,{open:!0,onOpenChange:l=>{l||ae(null)},showTrigger:!1,initialMode:De}):null,N&&!O&&Y&&u&&r&&d&&e.jsxs(o.Button,{variant:"secondary",size:"xs",disabled:M,onClick:Zs,children:[e.jsx(bs.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),N&&!O&&d&&!D&&e.jsxs(o.Button,{variant:"outline",size:"xs",disabled:!N,onClick:()=>Bs(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!O&&!N&&de&&d&&e.jsxs(o.Button,{size:"xs",onClick:Hs,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),as&&d&&ns&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:Ys,disabled:ge,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),as&&d&&e.jsxs(o.Button,{size:"xs",className:o.cn(!os&&"opacity-60"),disabled:ge||!os,onClick:()=>Te(),children:[ge?e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(bs.Save,{className:"h-3.5 w-3.5"}),ge?"Saving...":"Save"]}),N&&!O&&d&&e.jsxs(o.Button,{variant:"outline",size:"xs",onClick:Qs,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!O&&d&&e.jsx("div",{className:"ml-2",children:e.jsx(G.NotificationBell,{})}),!O&&r&&e.jsx(yt,{}),!O&&d&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:v,onSelect:()=>Ve(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsxs(s.DropdownMenuItem,{disabled:!X,onSelect:()=>{X&&H(!0)},children:[e.jsx(s.Clock,{className:"h-3.5 w-3.5"}),"Schedule"]}),e.jsx(s.DropdownMenuSeparator,{}),$s&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>B(!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:()=>L(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>q(!0),children:[e.jsx(s.FileText,{className:"h-3.5 w-3.5"}),"Summary Settings"]}),r&&d&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var l;t!=null&&t.accessToken&&((l=navigator==null?void 0:navigator.clipboard)!=null&&l.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),D&&e.jsxs(s.DropdownMenuItem,{disabled:!Le,onSelect:()=>{var l;if(!Le){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(Le).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(ft,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:c,children:[e.jsx(lt.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Ze(!We),children:[e.jsx(ct.Braces,{className:"h-3.5 w-3.5"}),We?"Hide dashboard JSON":"Show dashboard JSON"]}),Y&&N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>K(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),Y&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(ut,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(Ct,{})})]})]})]})]}),_&&ss&&e.jsx(s.ShareDialog,{resource:ss,resourceType:s.ResourceType.DASHBOARD,onClose:()=>j(!1)}),e.jsx(Qt,{open:R,onOpenChange:B}),X&&(i==null?void 0:i.id)&&e.jsx(s.EmailScheduleDialog,{open:V,onOpenChange:H,dashboardId:i.id,dashboardName:i==null?void 0:i.title}),e.jsx(xs.CalendarPreferencesDialog,{open:S,onOpenChange:L}),e.jsx(xs.DashboardSummarySettingsDialog,{open:F,onOpenChange:q,dashboard:i,disabled:!N,onApply:l=>Ae({...i,summary:l},{semanticExecutionPayload:Oe})}),r&&Y&&d&&e.jsx(wt,{open:te,onOpenChange:K}),d&&e.jsx(s.DownloadPdf,{open:ks,onOpenChange:Ve}),e.jsx(s.AlertDialog,{open:Ts,onOpenChange:l=>{!l&&Me&&!re||(ne(l),l||(oe(null),ie([]),le(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:re?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:re?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),He.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:He.slice(0,5).map(l=>e.jsx("li",{children:l},l))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:re?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{ne(!1),oe(null),ie([]),le(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Te({closeAfterSave:Ke,navigateHomeAfterSave:Ee==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(G.UnsavedChangesAlert,{open:zs,onOpenChange:l=>{W(l)},onSave:Ws,onDiscard:Js,isSaving:Me,saveLabel:"Save",discardLabel:"Discard"})]})]})}function na({accessToken:t,dashboardId:a,selectedSheetId:n,pageSize:r,orientation:c,theme:m}){if(!t||!n)return null;const d=new URL("http://localhost:5173/print-document");d.searchParams.set("token",t),a&&d.searchParams.set("dashboardId",a),d.searchParams.set("selectedSheetId",n),m&&d.searchParams.set("theme",m);const f=new URL("http://127.0.0.1:3002/");return f.searchParams.set("pdfMode","document"),f.searchParams.set("pageSize",r||"letter"),f.searchParams.set("orientation",c||"portrait"),f.searchParams.set("url",d.toString()),f.toString()}exports.default=aa;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c, Fragment as T } from "react/jsx-runtime";
|
|
2
|
-
import { c as X, u as S, B as L,
|
|
3
|
-
import { c5 as ys, u as j, b as Ge, c6 as xs, bl as ht, c as $e, d as Ve, e as ze, f as wt, o as Ns, c7 as de, by as Te, c8 as Ss, c9 as aa, ca as fa, cb as ga, cc as ws, bO as Dt, cd as Ds, ce as Cs, cf as Es, cg as Is, ch as As, ci as Ls, r as qe, z as Be, p as A, bV as Ms, cj as Os, ck as ks, bS as pt, cl as ft, bx as Ct, bc as va, cm as gt, ba, cn as Ps, bF as ya, bG as xa, bH as Na, bI as Sa, bJ as wa, bK as Da, bL as Ca, bM as vt, co as Ts, cp as _s, cq as Us, bp as Fs, cr as Rs, cs as Gs, X as $s, W as ke, ct as Vs, a1 as zs, Y as nt, cu as qs, cv as Bs, cw as Hs, ad as js, cx as Ks, L as rt, cy as Qs, cz as Ws, cA as Js, c4 as Ys, cB as Xs, bq as Zs, br as en, bs as tn, bt as an, bu as $, bZ as sn, N as nn, bA as rn, cC as on, bv as sa, cD as cn, cE as ln, cF as dn, a0 as un, O as mn, cG as hn, K as bt } from "./index-
|
|
2
|
+
import { c as X, u as S, B as L, aI as Nt, m as St, L as dt, I as ue, a as J, aJ as Re, aK as da, aL as ua, E as ls, f as Y, aM as ds, aN as us, aO as ut, T as ma, q as ha, r as _e, t as Ue, s as mt, aP as pa, aQ as ms, n as ta, z as hs, A as ps, D as fs, F as gs, K as vs, aR as bs } from "./switch-BuZXNXQV.js";
|
|
3
|
+
import { c5 as ys, u as j, b as Ge, c6 as xs, bl as ht, c as $e, d as Ve, e as ze, f as wt, o as Ns, c7 as de, by as Te, c8 as Ss, c9 as aa, ca as fa, cb as ga, cc as ws, bO as Dt, cd as Ds, ce as Cs, cf as Es, cg as Is, ch as As, ci as Ls, r as qe, z as Be, p as A, bV as Ms, cj as Os, ck as ks, bS as pt, cl as ft, bx as Ct, bc as va, cm as gt, ba, cn as Ps, bF as ya, bG as xa, bH as Na, bI as Sa, bJ as wa, bK as Da, bL as Ca, bM as vt, co as Ts, cp as _s, cq as Us, bp as Fs, cr as Rs, cs as Gs, X as $s, W as ke, ct as Vs, a1 as zs, Y as nt, cu as qs, cv as Bs, cw as Hs, ad as js, cx as Ks, L as rt, cy as Qs, cz as Ws, cA as Js, c4 as Ys, cB as Xs, bq as Zs, br as en, bs as tn, bt as an, bu as $, bZ as sn, N as nn, bA as rn, cC as on, bv as sa, cD as cn, cE as ln, cF as dn, a0 as un, O as mn, cG as hn, K as bt } from "./index-DQApwxKL.js";
|
|
4
4
|
import * as M from "react";
|
|
5
5
|
import Ea, { useState as N, useMemo as F, useCallback as Fe, useEffect as ot } from "react";
|
|
6
6
|
import "./index-CJdxSyQq.js";
|
|
7
7
|
import "react-dom";
|
|
8
|
-
import { b as pn, u as fn, A as gn, V as vn, c as bn, D as yn, N as xn, U as Nn } from "./dashboard-filter-controls-button-
|
|
8
|
+
import { b as pn, u as fn, A as gn, V as vn, c as bn, D as yn, N as xn, U as Nn } from "./dashboard-filter-controls-button-NiAIAD1P.js";
|
|
9
9
|
import { d as Sn } from "./index-DFOb_6HB.js";
|
|
10
|
-
import { C as wn, D as Dn } from "./dashboard-summary-settings-dialog-
|
|
10
|
+
import { C as wn, D as Dn } from "./dashboard-summary-settings-dialog-dt20G_7d.js";
|
|
11
11
|
import { u as Cn } from "./use-debounced-dirty-check-BwAbnX_5.js";
|
|
12
12
|
import { s as it } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
|
|
13
|
-
import { u as En, e as In } from "./use-create-flow-overlay-state-
|
|
14
|
-
import { S as na } from "./save-
|
|
15
|
-
import { P as An
|
|
13
|
+
import { u as En, e as In } from "./use-create-flow-overlay-state-Bg-LkLP7.js";
|
|
14
|
+
import { S as na } from "./save-QktcpXPy.js";
|
|
15
|
+
import { P as An } from "./palette-DFjOzeAG.js";
|
|
16
|
+
import { B as Ln } from "./braces-DZxcgUvn.js";
|
|
16
17
|
/**
|
|
17
18
|
* @license lucide-react v0.453.0 - ISC
|
|
18
19
|
*
|
|
@@ -1513,7 +1514,7 @@ function la(t, a) {
|
|
|
1513
1514
|
semanticExecutionPayload: bt(a)
|
|
1514
1515
|
};
|
|
1515
1516
|
}
|
|
1516
|
-
function
|
|
1517
|
+
function Rr() {
|
|
1517
1518
|
var Qt, Wt, Jt, Yt, Xt, Zt;
|
|
1518
1519
|
pn(), fn();
|
|
1519
1520
|
const {
|
|
@@ -2247,5 +2248,5 @@ function Sr({
|
|
|
2247
2248
|
return p.searchParams.set("pdfMode", "document"), p.searchParams.set("pageSize", s || "letter"), p.searchParams.set("orientation", i || "portrait"), p.searchParams.set("url", l.toString()), p.toString();
|
|
2248
2249
|
}
|
|
2249
2250
|
export {
|
|
2250
|
-
|
|
2251
|
+
Rr as default
|
|
2251
2252
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const g=require("react"),t=require("./index-
|
|
1
|
+
"use strict";const g=require("react"),t=require("./index-CwzM5Lxh.js"),e=require("react/jsx-runtime"),r=require("./switch-B72T1Hf_.js"),F=require("./use-create-flow-overlay-state-iUCs5ZgT.js"),R=require("./use-visual-utils-DqVxN0_F.js"),U=require("./date-formatter-D9Bvw5Qk.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Se, { useState as T, useRef as X, useCallback as $, useEffect as O, useContext as Ae } from "react";
|
|
2
|
-
import { u as W, ae as z, aZ as q, aV as le, aW as K, af as de, aU as Ie, b as ce, c as ue, d as me, e as he, f as pe, bV as Fe, o as Le, t as Te, v as Pe, b8 as fe, bW as ke, p as k, b9 as G, W as Ue, bq as ve, br as ge, bt as be, bu as R, by as Ve, bl as Me, bX as Be, bY as Oe, bF as ze, bG as Re, bH as $e, bI as _e, bJ as He, bK as je, bL as Xe, a$ as Ge, bZ as We, b_ as qe, bn as Ke, aX as J, M as Qe, ah as Ze, b$ as Ye, c0 as Je, c1 as et, c2 as tt, c3 as ee, c4 as at } from "./index-
|
|
2
|
+
import { u as W, ae as z, aZ as q, aV as le, aW as K, af as de, aU as Ie, b as ce, c as ue, d as me, e as he, f as pe, bV as Fe, o as Le, t as Te, v as Pe, b8 as fe, bW as ke, p as k, b9 as G, W as Ue, bq as ve, br as ge, bt as be, bu as R, by as Ve, bl as Me, bX as Be, bY as Oe, bF as ze, bG as Re, bH as $e, bI as _e, bJ as He, bK as je, bL as Xe, a$ as Ge, bZ as We, b_ as qe, bn as Ke, aX as J, M as Qe, ah as Ze, b$ as Ye, c0 as Je, c1 as et, c2 as tt, c3 as ee, c4 as at } from "./index-DQApwxKL.js";
|
|
3
3
|
import { jsx as t, jsxs as s, Fragment as _ } from "react/jsx-runtime";
|
|
4
|
-
import { c as xe, L as te, I as st, B as I, f as Q, n as j, u as B, m as Z,
|
|
5
|
-
import { V as dt, E as se, a as re, b as ct, c as ut, L as mt, d as ht, C as pt, u as ft, e as vt } from "./use-create-flow-overlay-state-
|
|
6
|
-
import { u as Ee } from "./use-visual-utils-
|
|
4
|
+
import { c as xe, L as te, I as st, B as I, f as Q, n as j, u as B, m as Z, aF as ae, af as ye, G as we, e as rt, l as ot, a as H, p as Y, X as nt, P as Ce, b as De, d as Ne, aG as it, aH as lt } from "./switch-BuZXNXQV.js";
|
|
5
|
+
import { V as dt, E as se, a as re, b as ct, c as ut, L as mt, d as ht, C as pt, u as ft, e as vt } from "./use-create-flow-overlay-state-Bg-LkLP7.js";
|
|
6
|
+
import { u as Ee } from "./use-visual-utils-D_2r0Fmm.js";
|
|
7
7
|
import { k as oe } from "./date-formatter-DyIOb6uC.js";
|
|
8
8
|
/**
|
|
9
9
|
* @license lucide-react v0.453.0 - ISC
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),s=require("./switch-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),s=require("./switch-B72T1Hf_.js");require("./index-CwzM5Lxh.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-BuZXNXQV.js";
|
|
4
|
+
import "./index-DQApwxKL.js";
|
|
5
5
|
import "./index-CJdxSyQq.js";
|
|
6
6
|
import "react-dom";
|
|
7
7
|
function C() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),o=require("react"),a=require("./index-D2vz3gvd.js"),s=require("./switch-BH17qlxH.js");function q(n={}){var k,P,A,E;const{authToken:c,tokenProps:t}=a.useSemaphorContext(),S=n.enabled??!0,u=(c==null?void 0:c.accessToken)??null,f=(t==null?void 0:t.apiServiceUrl)??null,[N,j]=o.useState(!1),[v,b]=o.useState(!1),[h,l]=o.useState(!1),[y,d]=o.useState(null),[p,w]=o.useState(null),T=p||{tz:((P=(k=t==null?void 0:t.params)==null?void 0:k.calendarContext)==null?void 0:P.tz)||null,weekStart:((E=(A=t==null?void 0:t.params)==null?void 0:A.calendarContext)==null?void 0:E.weekStart)??null},g=o.useCallback(async()=>{if(!(!S||!u||!f)){j(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to fetch preferences")}const i=await m.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(m){const i=m instanceof Error?m.message:"Unknown error";d(i)}finally{j(!1)}}},[u,f,S]);o.useEffect(()=>{S&&g()},[S,g]);const I=o.useCallback(async m=>{if(!u||!f)return d("Not authenticated"),!1;b(!0),d(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(m)});if(!i.ok){const x=await i.json().catch(()=>({}));throw new Error(x.error||"Failed to update preferences")}return await g(),!0}catch(i){const x=i instanceof Error?i.message:"Unknown error";return d(x),!1}finally{b(!1)}},[u,f,g]),C=o.useCallback(async()=>{if(!u||!f)return d("Not authenticated"),!1;l(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to clear preferences")}const i=await m.text();if(i)try{const x=JSON.parse(i);return w({tz:x.tz,weekStart:x.weekStart,source:x.source,isInherited:x.isInherited??!0,userHasPrefs:!1,inherited:x.inherited}),!0}catch{}return await g(),!0}catch(m){const i=m instanceof Error?m.message:"Unknown error";return d(i),!1}finally{l(!1)}},[u,f,g]);return{preferences:T,isLoading:N,isSaving:v,isClearing:h,error:y,updatePreferences:I,clearPreferences:C,refetch:g}}const D=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],$=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],B="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function X(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return D.map(n=>n.value)}function Z(n){switch(n){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function _(n){const c=D.find(t=>t.value===n);return c?c.label:n}function J(n){const c=$.find(t=>t.value===n);return c?c.label:String(n)}function K({open:n,onOpenChange:c}){var M,F,U;const{preferences:t,isLoading:S,isSaving:u,isClearing:f,updatePreferences:N,clearPreferences:j}=q({enabled:n}),v=t.tz||((M=t.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,b=t.weekStart??((F=t.inherited)==null?void 0:F.weekStart)??1,[h,l]=o.useState(!t.userHasPrefs),[y,d]=o.useState(!1),[p,w]=o.useState(v),[T,g]=o.useState(b),[I,C]=o.useState(!1),k=o.useMemo(()=>X(),[]),P=o.useMemo(()=>k.filter(r=>!D.some(V=>V.value===r)),[k]),A=o.useMemo(()=>_(p),[p]),E=t.inherited?_(t.inherited.tz):"UTC",m=t.inherited?J(t.inherited.weekStart):"Monday",i=Z((U=t.inherited)==null?void 0:U.source);o.useEffect(()=>{if(!n){d(!1);return}y||(t.userHasPrefs!==void 0&&l(!t.userHasPrefs),w(v),g(b))},[n,y,t.userHasPrefs,v,b]);const x=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}h?await j()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again."):await N({tz:p,weekStart:T})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again.")},G=()=>{c(!1)},L=u||f,W=L||S;return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(a.RadioGroup,{value:h?"defaults":"custom",onValueChange:r=>{d(!0),l(r==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",h&&"bg-muted/50"),onClick:()=>{d(!0),l(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[E,", week starts ",m]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!h&&"bg-muted/50"),onClick:()=>{d(!0),l(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:s.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",h&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Timezone"}),e.jsxs(s.Popover,{open:I,onOpenChange:C,modal:!0,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":I,className:"w-full justify-between text-[12px] font-normal",disabled:h,children:[e.jsx("span",{className:"truncate",children:A}),e.jsx(a.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:D.map(r=>e.jsxs(a.CommandItem,{value:`${r.value} ${r.label}`,onSelect:()=>{d(!0),w(r.value),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:r.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:r.value})]},r.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All timezones",children:P.map(r=>e.jsxs(a.CommandItem,{value:r,onSelect:()=>{d(!0),w(r),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r?"opacity-100":"opacity-0")}),r]},r))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Week starts on"}),e.jsx(a.RadioGroup,{value:String(T),onValueChange:r=>{d(!0),g(Number(r))},className:"flex gap-4",disabled:h,children:$.map(r=>e.jsxs("label",{htmlFor:`week-start-${r.value}`,className:s.cn("flex cursor-pointer items-center gap-2 text-[13px]",h&&"cursor-not-allowed"),children:[e.jsx(a.RadioGroupItem,{value:String(r.value),id:`week-start-${r.value}`,disabled:h}),r.label]},r.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:G,disabled:L,children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:x,disabled:W,children:L?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}const z=6,O=1,R=20,H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Y(n){return Number.isNaN(n)?z:Math.min(R,Math.max(O,n))}function Q({open:n,onOpenChange:c,dashboard:t,onApply:S,disabled:u=!1}){const[f,N]=o.useState(!1),[j,v]=o.useState("top"),[b,h]=o.useState(String(z)),l=t.summary;o.useEffect(()=>{n&&(N((l==null?void 0:l.enabled)===!0),v((l==null?void 0:l.position)==="bottom"?"bottom":"top"),h(String((l==null?void 0:l.maxItems)??z)))},[n,l==null?void 0:l.enabled,l==null?void 0:l.position,l==null?void 0:l.maxItems]);const y=o.useMemo(()=>Y(Number.parseInt(b||`${z}`,10)),[b]),d=()=>{S({enabled:f,position:j,maxItems:y}),c(!1)};return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Summary Settings"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-enabled",className:"text-[13px]",children:"Enable dashboard summary"}),e.jsx(s.Switch,{size:"xs",id:"dashboard-summary-enabled",checked:f,disabled:u,onCheckedChange:N})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-position",className:H,children:"Position"}),e.jsxs(s.Select,{value:j,disabled:u,onValueChange:p=>v(p),children:[e.jsx(s.SelectTrigger,{id:"dashboard-summary-position",size:"xs",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{value:"top",children:"Top"}),e.jsx(s.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-max-items",className:H,children:"Max items"}),e.jsx(s.Input,{size:"xs",id:"dashboard-summary-max-items",type:"number",min:O,max:R,disabled:u,value:b,onChange:p=>h(p.target.value),onBlur:()=>h(String(y))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),u&&e.jsx("p",{className:"text-[12px] text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:()=>c(!1),children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:d,disabled:u,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=K;exports.DashboardSummarySettingsDialog=Q;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),a=require("./index-CwzM5Lxh.js"),s=require("./switch-B72T1Hf_.js");function q(n={}){var k,P,A,E;const{authToken:c,tokenProps:t}=a.useSemaphorContext(),S=n.enabled??!0,u=(c==null?void 0:c.accessToken)??null,f=(t==null?void 0:t.apiServiceUrl)??null,[N,j]=o.useState(!1),[v,b]=o.useState(!1),[h,l]=o.useState(!1),[y,d]=o.useState(null),[p,w]=o.useState(null),T=p||{tz:((P=(k=t==null?void 0:t.params)==null?void 0:k.calendarContext)==null?void 0:P.tz)||null,weekStart:((E=(A=t==null?void 0:t.params)==null?void 0:A.calendarContext)==null?void 0:E.weekStart)??null},g=o.useCallback(async()=>{if(!(!S||!u||!f)){j(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to fetch preferences")}const i=await m.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(m){const i=m instanceof Error?m.message:"Unknown error";d(i)}finally{j(!1)}}},[u,f,S]);o.useEffect(()=>{S&&g()},[S,g]);const I=o.useCallback(async m=>{if(!u||!f)return d("Not authenticated"),!1;b(!0),d(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(m)});if(!i.ok){const x=await i.json().catch(()=>({}));throw new Error(x.error||"Failed to update preferences")}return await g(),!0}catch(i){const x=i instanceof Error?i.message:"Unknown error";return d(x),!1}finally{b(!1)}},[u,f,g]),C=o.useCallback(async()=>{if(!u||!f)return d("Not authenticated"),!1;l(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to clear preferences")}const i=await m.text();if(i)try{const x=JSON.parse(i);return w({tz:x.tz,weekStart:x.weekStart,source:x.source,isInherited:x.isInherited??!0,userHasPrefs:!1,inherited:x.inherited}),!0}catch{}return await g(),!0}catch(m){const i=m instanceof Error?m.message:"Unknown error";return d(i),!1}finally{l(!1)}},[u,f,g]);return{preferences:T,isLoading:N,isSaving:v,isClearing:h,error:y,updatePreferences:I,clearPreferences:C,refetch:g}}const D=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],$=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],B="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function X(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return D.map(n=>n.value)}function Z(n){switch(n){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function _(n){const c=D.find(t=>t.value===n);return c?c.label:n}function J(n){const c=$.find(t=>t.value===n);return c?c.label:String(n)}function K({open:n,onOpenChange:c}){var M,F,U;const{preferences:t,isLoading:S,isSaving:u,isClearing:f,updatePreferences:N,clearPreferences:j}=q({enabled:n}),v=t.tz||((M=t.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,b=t.weekStart??((F=t.inherited)==null?void 0:F.weekStart)??1,[h,l]=o.useState(!t.userHasPrefs),[y,d]=o.useState(!1),[p,w]=o.useState(v),[T,g]=o.useState(b),[I,C]=o.useState(!1),k=o.useMemo(()=>X(),[]),P=o.useMemo(()=>k.filter(r=>!D.some(V=>V.value===r)),[k]),A=o.useMemo(()=>_(p),[p]),E=t.inherited?_(t.inherited.tz):"UTC",m=t.inherited?J(t.inherited.weekStart):"Monday",i=Z((U=t.inherited)==null?void 0:U.source);o.useEffect(()=>{if(!n){d(!1);return}y||(t.userHasPrefs!==void 0&&l(!t.userHasPrefs),w(v),g(b))},[n,y,t.userHasPrefs,v,b]);const x=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}h?await j()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again."):await N({tz:p,weekStart:T})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again.")},G=()=>{c(!1)},L=u||f,W=L||S;return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(a.RadioGroup,{value:h?"defaults":"custom",onValueChange:r=>{d(!0),l(r==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",h&&"bg-muted/50"),onClick:()=>{d(!0),l(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[E,", week starts ",m]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!h&&"bg-muted/50"),onClick:()=>{d(!0),l(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:s.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",h&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Timezone"}),e.jsxs(s.Popover,{open:I,onOpenChange:C,modal:!0,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":I,className:"w-full justify-between text-[12px] font-normal",disabled:h,children:[e.jsx("span",{className:"truncate",children:A}),e.jsx(a.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:D.map(r=>e.jsxs(a.CommandItem,{value:`${r.value} ${r.label}`,onSelect:()=>{d(!0),w(r.value),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:r.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:r.value})]},r.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All timezones",children:P.map(r=>e.jsxs(a.CommandItem,{value:r,onSelect:()=>{d(!0),w(r),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r?"opacity-100":"opacity-0")}),r]},r))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Week starts on"}),e.jsx(a.RadioGroup,{value:String(T),onValueChange:r=>{d(!0),g(Number(r))},className:"flex gap-4",disabled:h,children:$.map(r=>e.jsxs("label",{htmlFor:`week-start-${r.value}`,className:s.cn("flex cursor-pointer items-center gap-2 text-[13px]",h&&"cursor-not-allowed"),children:[e.jsx(a.RadioGroupItem,{value:String(r.value),id:`week-start-${r.value}`,disabled:h}),r.label]},r.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:G,disabled:L,children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:x,disabled:W,children:L?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}const z=6,O=1,R=20,H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Y(n){return Number.isNaN(n)?z:Math.min(R,Math.max(O,n))}function Q({open:n,onOpenChange:c,dashboard:t,onApply:S,disabled:u=!1}){const[f,N]=o.useState(!1),[j,v]=o.useState("top"),[b,h]=o.useState(String(z)),l=t.summary;o.useEffect(()=>{n&&(N((l==null?void 0:l.enabled)===!0),v((l==null?void 0:l.position)==="bottom"?"bottom":"top"),h(String((l==null?void 0:l.maxItems)??z)))},[n,l==null?void 0:l.enabled,l==null?void 0:l.position,l==null?void 0:l.maxItems]);const y=o.useMemo(()=>Y(Number.parseInt(b||`${z}`,10)),[b]),d=()=>{S({enabled:f,position:j,maxItems:y}),c(!1)};return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Summary Settings"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-enabled",className:"text-[13px]",children:"Enable dashboard summary"}),e.jsx(s.Switch,{size:"xs",id:"dashboard-summary-enabled",checked:f,disabled:u,onCheckedChange:N})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-position",className:H,children:"Position"}),e.jsxs(s.Select,{value:j,disabled:u,onValueChange:p=>v(p),children:[e.jsx(s.SelectTrigger,{id:"dashboard-summary-position",size:"xs",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{value:"top",children:"Top"}),e.jsx(s.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-max-items",className:H,children:"Max items"}),e.jsx(s.Input,{size:"xs",id:"dashboard-summary-max-items",type:"number",min:O,max:R,disabled:u,value:b,onChange:p=>h(p.target.value),onBlur:()=>h(String(y))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),u&&e.jsx("p",{className:"text-[12px] text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:()=>c(!1),children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:d,disabled:u,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=K;exports.DashboardSummarySettingsDialog=Q;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as ue } from "react/jsx-runtime";
|
|
2
2
|
import me, { useState as f, useCallback as H, useEffect as q, useMemo as U } from "react";
|
|
3
|
-
import { u as he, b as Q, c as ee, d as ae, e as te, f as se, R, g as $, C as fe, h as pe, i as be, j as ve, k as ge, l as V, m as G, n as xe, o as re, p as I } from "./index-
|
|
4
|
-
import { a as k, L as P, P as Se, b as ye, B as A, d as Ne, e as X, f as we, S as ke, g as Ce, h as Te, i as Ie, j as Pe, k as Z, I as Ae } from "./switch-
|
|
3
|
+
import { u as he, b as Q, c as ee, d as ae, e as te, f as se, R, g as $, C as fe, h as pe, i as be, j as ve, k as ge, l as V, m as G, n as xe, o as re, p as I } from "./index-DQApwxKL.js";
|
|
4
|
+
import { a as k, L as P, P as Se, b as ye, B as A, d as Ne, e as X, f as we, S as ke, g as Ce, h as Te, i as Ie, j as Pe, k as Z, I as Ae } from "./switch-BuZXNXQV.js";
|
|
5
5
|
function ze(r = {}) {
|
|
6
6
|
var T, L, D, M;
|
|
7
7
|
const { authToken: i, tokenProps: t } = he(), g = r.enabled ?? !0, o = (i == null ? void 0 : i.accessToken) ?? null, h = (t == null ? void 0 : t.apiServiceUrl) ?? null, [N, S] = f(!1), [x, b] = f(!1), [u, n] = f(!1), [y, c] = f(null), [p, w] = f(null), z = p || {
|