react-semaphor 0.1.262 → 0.1.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/chunks/{dashboard-controls-Cq2fQ7bv.js → dashboard-controls-DVMSiuTb.js} +527 -545
  2. package/dist/chunks/dashboard-controls-JZ-mgUSY.js +42 -0
  3. package/dist/chunks/{dashboard-filter-controls-button-udrHABi3.js → dashboard-filter-controls-button-ClYx7NdN.js} +3 -3
  4. package/dist/chunks/{dashboard-filter-controls-button-Cedz-YZx.js → dashboard-filter-controls-button-CnijsTUC.js} +1 -1
  5. package/dist/chunks/{dashboard-json-BU6cvmRP.js → dashboard-json-BILMCUhG.js} +1 -1
  6. package/dist/chunks/{dashboard-json-RKwWONKm.js → dashboard-json-CKWfqC0m.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-Bl-XplTR.js → dashboard-summary-settings-dialog-5JMWm5zV.js} +1 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-DDxHxKjp.js → dashboard-summary-settings-dialog-6SEdlbOP.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-B1r0Ho9B.js → edit-dashboard-visual-BjU_0_QA.js} +890 -884
  10. package/dist/chunks/{edit-dashboard-visual-BwDFI3hI.js → edit-dashboard-visual-DPqnhyq1.js} +5 -5
  11. package/dist/chunks/{index-DZ93VE76.js → index-BUNYVJ8g.js} +227 -227
  12. package/dist/chunks/{index-BtbNfaQD.js → index-D2dG8YFx.js} +20197 -20194
  13. package/dist/chunks/{resource-management-panel-Cz7MYBC7.js → resource-management-panel-BAytqOVf.js} +1 -1
  14. package/dist/chunks/{resource-management-panel-DxG6-naG.js → resource-management-panel-I5Q6TQbc.js} +2 -2
  15. package/dist/chunks/{use-create-flow-overlay-state-BcMrPzMc.js → use-create-flow-overlay-state-CPUI4zrE.js} +2 -2
  16. package/dist/chunks/{use-create-flow-overlay-state-D13D1vB_.js → use-create-flow-overlay-state-DakZJeCH.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-DmxEKpor.js → use-visual-utils-B_9CT1PY.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-DScc5-p_.js → use-visual-utils-Cd9d6nnp.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/surfboard/index.cjs +1 -1
  24. package/dist/surfboard/index.js +2 -2
  25. package/package.json +1 -1
  26. package/dist/chunks/dashboard-controls-AFlpiHtC.js +0 -42
@@ -0,0 +1,42 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-BUNYVJ8g.js"),x=require("react");require("react-dom");const P=require("./dashboard-filter-controls-button-CnijsTUC.js"),_s=require("./date-formatter-CqXdM6JO.js"),Xe=require("./dashboard-summary-settings-dialog-5JMWm5zV.js"),Us=require("./use-debounced-dirty-check-XHSwAefL.js"),we=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),Ye=require("./use-create-flow-overlay-state-DakZJeCH.js");function Rs(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(o,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return o.default=t,Object.freeze(o)}const C=Rs(x);/**
2
+ * @license lucide-react v0.453.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Gs=s.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
7
+ * @license lucide-react v0.453.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const $s=s.createLucideIcon("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
12
+ * @license lucide-react v0.453.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const qs=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
17
+ * @license lucide-react v0.453.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Bs=s.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
22
+ * @license lucide-react v0.453.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Hs=s.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 Le={exports:{}},Ce={};/**
27
+ * @license React
28
+ * use-sync-external-store-shim.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var Ze;function Vs(){if(Ze)return Ce;Ze=1;var t=x;function o(n,d){return n===d&&(n!==0||1/n===1/d)||n!==n&&d!==d}var a=typeof Object.is=="function"?Object.is:o,r=t.useState,l=t.useEffect,c=t.useLayoutEffect,m=t.useDebugValue;function u(n,d){var g=d(),b=r({inst:{value:g,getSnapshot:d}}),v=b[0].inst,S=b[1];return c(function(){v.value=g,v.getSnapshot=d,p(v)&&S({inst:v})},[n,g,d]),l(function(){return p(v)&&S({inst:v}),n(function(){p(v)&&S({inst:v})})},[n]),m(g),g}function p(n){var d=n.getSnapshot;n=n.value;try{var g=d();return!a(n,g)}catch{return!0}}function j(n,d){return d()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?j:u;return Ce.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Ce}var Me={};/**
35
+ * @license React
36
+ * use-sync-external-store-shim.development.js
37
+ *
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var es;function zs(){return es||(es=1,process.env.NODE_ENV!=="production"&&function(){function t(g,b){return g===b&&(g!==0||1/g===1/b)||g!==g&&b!==b}function o(g,b){h||l.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 v=b();if(!n){var S=b();c(v,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),n=!0)}S=m({inst:{value:v,getSnapshot:b}});var N=S[0].inst,I=S[1];return p(function(){N.value=v,N.getSnapshot=b,a(N)&&I({inst:N})},[g,v,b]),u(function(){return a(N)&&I({inst:N}),g(function(){a(N)&&I({inst:N})})},[g]),j(v),v}function a(g){var b=g.getSnapshot;g=g.value;try{var v=b();return!c(g,v)}catch{return!0}}function r(g,b){return b()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var l=x,c=typeof Object.is=="function"?Object.is:t,m=l.useState,u=l.useEffect,p=l.useLayoutEffect,j=l.useDebugValue,h=!1,n=!1,d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:o;Me.useSyncExternalStore=l.useSyncExternalStore!==void 0?l.useSyncExternalStore:d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Me}process.env.NODE_ENV==="production"?Le.exports=Vs():Le.exports=zs();var Ks=Le.exports;function Qs(){const{setTheme:t}=s.useTheme(),o=s.useDashboardStore(a=>a.actions.setDashboardTheme);return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(s.Button,{className:"h-7 p-2",variant:"ghost",size:"sm",children:[e.jsx(Hs,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(qs,{strokeWidth:1.5,className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:()=>{t("light"),o("light")},children:"Light"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("dark"),o("dark")},children:"Dark"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("system"),o("system")},children:"System"})]})]})}async function Ws(t,o,a,r,l){if(!l)return null;const c=JSON.stringify(a),m=`${t}/v1/lens`;return await s.postRequest(m,l,{name:o,template:c,filterValues:r,operation:"create"})}async function Ae(t,o,a){if(!a)return null;const{id:r,template:l,filterValues:c,isDefault:m,shared:u}=o,p=`${t}/v1/lens`;return await s.postRequest(p,a,{lensId:r,template:l,filterValues:c,isDefault:m,shared:u,operation:"update"})}async function Js(t,o,a){if(!a)return null;const r=`${t}/v1/lens`;return await s.postRequest(r,a,{operation:"delete",lensId:o})}function Xs(){const[t,o]=x.useState(""),[a,r]=x.useState(!1),l=s.useDashboardStore(S=>S.lenses),{setLenses:c,setSelectedLensId:m}=s.useDashboardActions(),[u,p]=x.useState(!1),[j,h]=x.useState(!1),n=s.useDashboardStore(S=>S.dashboard),d=s.useDashboardStore(S=>S.filterValues),{authToken:g,tokenProps:b}=s.useSemaphorContext();async function v(){p(!0);const S=await Ws(b.apiServiceUrl,t,n,d,g==null?void 0:g.accessToken);S&&(c([...l||[],S]),m(S.id),h(!1)),p(!1)}return e.jsxs(s.Dialog,{open:j,onOpenChange:h,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:S=>{o(S.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:v,disabled:u,children:u?"Creating...":"Add"})})]})]})}function Ys(){const[t,o]=x.useState(!1),a=s.useDashboardStore(n=>n.lenses),r=s.useDashboardStore(n=>n.selectedLensId),{setLenses:l,setSelectedLensId:c}=s.useDashboardActions(),{authToken:m,tokenProps:u}=s.useSemaphorContext();async function p(n){c(n)}async function j(n){if(await Js(u.apiServiceUrl,n,m==null?void 0:m.accessToken)){const g=a==null?void 0:a.filter(b=>b.id!==n);l(g||[]),c("original")}}async function h(n){const d=a==null?void 0:a.map(v=>v.id===n.id?{...v,isDefault:!n.isDefault}:{...v,isDefault:!1});l(d||[]);const g={...n,isDefault:!n.isDefault};await Ae(u.apiServiceUrl,g,m==null?void 0:m.accessToken);const b=a==null?void 0:a.find(v=>v.isDefault);if(b&&b.id!==n.id){const v={...b,isDefault:!1};await Ae(u.apiServiceUrl,v,m==null?void 0:m.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:o,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(Gs,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:p,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(n=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:n.id,children:[e.jsx("p",{children:n.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:d=>{d.preventDefault(),h(n)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!n.isDefault,"text-green-500":n.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:d=>{d.preventDefault(),j(n.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},n.id))]})]})]})}function Zs(){const{displayPreferences:t,shouldShowElement:o}=s.useDisplayPreferences(),{currentUser:a,userContext:r}=s.useCurrentUserInfo(),l=x.useMemo(()=>s.getRoleBasedDisplayOverrides(a),[a]),c=x.useMemo(()=>u=>l&&l[u]!==void 0&&l[u]===!1?!1:o(u),[l,o,t]),m=x.useMemo(()=>{var u,p,j,h,n;return{canEdit:((u=r==null?void 0:r.permissions)==null?void 0:u.canEdit)??s.canUserEdit(a),canUseFilters:((p=r==null?void 0:r.permissions)==null?void 0:p.canEdit)??s.canUserUseFilters(a),canManageDashboards:((j=r==null?void 0:r.permissions)==null?void 0:j.canCreateDashboard)??s.canUserManageDashboards(a),canCreateDashboards:((h=r==null?void 0:r.permissions)==null?void 0:h.canCreateDashboard)??s.canUserCreateDashboards(a),canAccessVisuals:((n=r==null?void 0:r.permissions)==null?void 0:n.canEdit)??s.canUserAccessVisuals(a)}},[a,r]);return{displayPreferences:t,shouldShowElement:c,permissions:m,currentUser:a}}const et=async(t,o,a)=>{const r=`${t}/management/v1/groups`;return await s.postRequestRegular(r,o,a)},st=async(t,o,a)=>{const r=`${t}/management/v1/groups/${a}`;await s.requestJsonRegular(r,o,"DELETE")},tt=async(t,o,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`;return await s.postRequestRegular(l,o,r)},at=async(t,o,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`;await s.requestJsonRegular(l,o,"DELETE",r)};function rt(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>et(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{a.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:s.getRequestErrorMessage(r,"Failed to create group")})}})}function nt(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>st(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",l]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:s.getRequestErrorMessage(r,"Failed to delete group")})}})}function ot(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>tt(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.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:s.getRequestErrorMessage(r,"Failed to add members")})}})}function it(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>at(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.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:s.getRequestErrorMessage(r,"Failed to remove members")})}})}function lt({onSuccess:t,tenantId:o,isTenantUser:a}){const[r,l]=x.useState(""),[c,m]=x.useState(""),[u,p]=x.useState({}),j=rt(),h=()=>{const d={};return r.trim()?r.length<3?d.name="Group name must be at least 3 characters":r.length>50&&(d.name="Group name must be less than 50 characters"):d.name="Group name is required",c&&c.length>200&&(d.description="Description must be less than 200 characters"),p(d),Object.keys(d).length===0},n=async d=>{if(d.preventDefault(),!h())return;const g={name:r.trim(),description:c.trim()||void 0,type:a?"TENANT_GROUP":"ORG_GROUP",...a&&o?{tenantId:o}:{}};try{await j.mutateAsync(g),l(""),m(""),p({}),t()}catch(b){console.error("Failed to create group:",b)}};return e.jsxs("form",{onSubmit:n,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-name",children:["Group Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(s.Input,{id:"group-name",placeholder:"e.g., Marketing Team, Engineering Squad",value:r,onChange:d=>{l(d.target.value),u.name&&p(g=>({...g,name:""}))},className:u.name?"border-destructive":"",disabled:j.isPending}),u.name&&e.jsx("p",{className:"text-sm text-destructive",children:u.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-description",children:["Description",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group...",value:c,onChange:d=>{m(d.target.value),u.description&&p(g=>({...g,description:""}))},className:u.description?"border-destructive":"",disabled:j.isPending,rows:3}),u.description&&e.jsx("p",{className:"text-sm text-destructive",children:u.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.length,"/200 characters"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(s.CircleAlert,{className:"h-4 w-4 mt-0.5 text-muted-foreground"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This group will be accessible to users in your workspace. You can add members after creating the group."})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(s.Button,{type:"button",variant:"outline",onClick:()=>{l(""),m(""),p({})},disabled:j.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",disabled:j.isPending||!r.trim(),children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Create Group"]})})]})]})}function ct(t,o=[]){let a=[];function r(c,m){const u=C.createContext(m);u.displayName=c+"Context";const p=a.length;a=[...a,m];const j=n=>{var N;const{scope:d,children:g,...b}=n,v=((N=d==null?void 0:d[t])==null?void 0:N[p])||u,S=C.useMemo(()=>b,Object.values(b));return e.jsx(v.Provider,{value:S,children:g})};j.displayName=c+"Provider";function h(n,d){var v;const g=((v=d==null?void 0:d[t])==null?void 0:v[p])||u,b=C.useContext(g);if(b)return b;if(m!==void 0)return m;throw new Error(`\`${n}\` must be used within \`${c}\``)}return[j,h]}const l=()=>{const c=a.map(m=>C.createContext(m));return function(u){const p=(u==null?void 0:u[t])||c;return C.useMemo(()=>({[`__scope${t}`]:{...u,[t]:p}}),[u,p])}};return l.scopeName=t,[r,dt(l,...o)]}function dt(...t){const o=t[0];if(t.length===1)return o;const a=()=>{const r=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(c){const m=r.reduce((u,{useScope:p,scopeName:j})=>{const n=p(c)[`__scope${j}`];return{...u,...n}},{});return C.useMemo(()=>({[`__scope${o.scopeName}`]:m}),[m])}};return a.scopeName=o.scopeName,a}var ut=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ee=ut.reduce((t,o)=>{const a=s.createSlot(`Primitive.${o}`),r=C.forwardRef((l,c)=>{const{asChild:m,...u}=l,p=m?a:o;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(p,{...u,ref:c})});return r.displayName=`Primitive.${o}`,{...t,[o]:r}},{});function mt(){return Ks.useSyncExternalStore(ht,()=>!0,()=>!1)}function ht(){return()=>{}}var Ie="Avatar",[pt]=ct(Ie),[gt,ts]=pt(Ie),as=C.forwardRef((t,o)=>{const{__scopeAvatar:a,...r}=t,[l,c]=C.useState("idle");return e.jsx(gt,{scope:a,imageLoadingStatus:l,onImageLoadingStatusChange:c,children:e.jsx(Ee.span,{...r,ref:o})})});as.displayName=Ie;var rs="AvatarImage",ns=C.forwardRef((t,o)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:l=()=>{},...c}=t,m=ts(rs,a),u=ft(r,c),p=s.useCallbackRef(j=>{l(j),m.onImageLoadingStatusChange(j)});return s.useLayoutEffect2(()=>{u!=="idle"&&p(u)},[u,p]),u==="loaded"?e.jsx(Ee.img,{...c,ref:o,src:r}):null});ns.displayName=rs;var os="AvatarFallback",is=C.forwardRef((t,o)=>{const{__scopeAvatar:a,delayMs:r,...l}=t,c=ts(os,a),[m,u]=C.useState(r===void 0);return C.useEffect(()=>{if(r!==void 0){const p=window.setTimeout(()=>u(!0),r);return()=>window.clearTimeout(p)}},[r]),m&&c.imageLoadingStatus!=="loaded"?e.jsx(Ee.span,{...l,ref:o}):null});is.displayName=os;function ss(t,o){return t?o?(t.src!==o&&(t.src=o),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function ft(t,{referrerPolicy:o,crossOrigin:a}){const r=mt(),l=C.useRef(null),c=r?(l.current||(l.current=new window.Image),l.current):null,[m,u]=C.useState(()=>ss(c,t));return s.useLayoutEffect2(()=>{u(ss(c,t))},[c,t]),s.useLayoutEffect2(()=>{const p=n=>()=>{u(n)};if(!c)return;const j=p("loaded"),h=p("error");return c.addEventListener("load",j),c.addEventListener("error",h),o&&(c.referrerPolicy=o),typeof a=="string"&&(c.crossOrigin=a),()=>{c.removeEventListener("load",j),c.removeEventListener("error",h)}},[c,a,o]),m}var ls=as,cs=ns,ds=is;const ke=C.forwardRef(({className:t,...o},a)=>e.jsx(ls,{ref:a,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...o}));ke.displayName=ls.displayName;const xt=C.forwardRef(({className:t,...o},a)=>e.jsx(cs,{ref:a,className:s.cn("aspect-square h-full w-full",t),...o}));xt.displayName=cs.displayName;const Te=C.forwardRef(({className:t,...o},a)=>e.jsx(ds,{ref:a,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...o}));Te.displayName=ds.displayName;function bt({open:t,onOpenChange:o,group:a,onUpdate:r}){const[l,c]=x.useState("members"),[m,u]=x.useState(""),[p,j]=x.useState([]),[h,n]=x.useState([]),{data:d,isLoading:g,refetch:b}=s.useGroupMembers(a.id),v=a.type==="TENANT_GROUP"?"tenant":"organization",{users:S,isLoading:N}=s.useUnifiedUsers({type:v,tenantId:a.tenantId||void 0,active:!0,limit:100}),I=ot(),k=it(),E=(d==null?void 0:d.members)||[],_=x.useMemo(()=>new Set(E.map(f=>f.userId)),[E]),U=x.useMemo(()=>S.filter(f=>!_.has(f.id)),[S,_]),R=x.useMemo(()=>{if(!m)return U;const f=m.toLowerCase();return U.filter(w=>{var L,F;return((L=w.name)==null?void 0:L.toLowerCase().includes(f))||((F=w.email)==null?void 0:F.toLowerCase().includes(f))})},[U,m]),y=x.useMemo(()=>{if(!m)return E;const f=m.toLowerCase();return E.filter(w=>{var L,F,$,V;return((F=(L=w.user)==null?void 0:L.name)==null?void 0:F.toLowerCase().includes(f))||((V=($=w.user)==null?void 0:$.email)==null?void 0:V.toLowerCase().includes(f))})},[E,m]),G=async()=>{if(p.length!==0)try{await I.mutateAsync({groupId:a.id,data:{userIds:p,userType:v==="tenant"?"tenant":"org"}}),j([]),c("members"),b(),r==null||r()}catch(f){console.error("Failed to add members:",f)}},Z=async()=>{if(h.length!==0)try{await k.mutateAsync({groupId:a.id,data:{userIds:h}}),n([]),b(),r==null||r()}catch(f){console.error("Failed to remove members:",f)}},H=f=>{j(w=>w.includes(f)?w.filter(L=>L!==f):[...w,f])},ue=f=>{n(w=>w.includes(f)?w.filter(L=>L!==f):[...w,f])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:o,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:a.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 ",a.name," group"]})]}),e.jsxs(s.Tabs,{value:l,onValueChange:f=>{c(f),u(""),n([])},className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(s.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(s.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(s.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(s.Input,{placeholder:"Search members...",value:m,onChange:f=>u(f.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:h.length>0?"h-[300px]":"h-[350px]",children:g?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(f=>e.jsx(s.Skeleton,{className:"h-16 w-full"},f))}):y.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:m?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:m?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:y.map(f=>e.jsx(vt,{member:f,selected:h.includes(f.userId),onToggle:()=>ue(f.userId)},f.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(s.Button,{variant:"destructive",size:"sm",onClick:Z,disabled:k.isPending,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.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(s.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(s.Input,{placeholder:"Search users to add...",value:m,onChange:f=>u(f.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:N?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(f=>e.jsx(s.Skeleton,{className:"h-16 w-full"},f))}):R.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:m?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:R.map(f=>e.jsx(jt,{user:f,selected:p.includes(f.id),onToggle:()=>H(f.id)},f.id))})}),p.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:[p.length," user",p.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:G,disabled:I.isPending,children:I.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.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:o,onToggle:a}){var l,c,m,u;const r=((c=(l=t.user)==null?void 0:l.name)==null?void 0:c.split(" ").map(p=>p[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:a,children:[e.jsx(s.Checkbox,{checked:o}),e.jsx(ke,{className:"h-8 w-8",children:e.jsx(Te,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((m=t.user)==null?void 0:m.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u=t.user)==null?void 0:u.email})]})]})}function jt({user:t,selected:o,onToggle:a}){var l;const r=((l=t.name)==null?void 0:l.split(" ").map(c=>c[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:a,children:[e.jsx(s.Checkbox,{checked:o}),e.jsx(ke,{className:"h-8 w-8",children:e.jsx(Te,{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 St({open:t,onOpenChange:o}){const[a,r]=x.useState("groups"),[l,c]=x.useState(""),[m,u]=x.useState(null),[p,j]=x.useState(!1),[h,n]=x.useState(null),{tokenProps:d}=s.useSemaphorContext(),{currentUser:g}=s.useCurrentUserInfo(),b=nt(),v=(g==null?void 0:g.type)==="tenant",S=d==null?void 0:d.tenantId,{groups:N,isLoading:I,refetch:k}=s.useGroups({type:v?"TENANT_GROUP":"all",tenantId:v?S:void 0,includeMembers:!1}),E=N.filter(y=>{var G;return y.name.toLowerCase().includes(l.toLowerCase())||((G=y.description)==null?void 0:G.toLowerCase().includes(l.toLowerCase()))}),_=async()=>{if(h)try{await b.mutateAsync(h.id),n(null),k()}catch(y){console.error("Failed to delete group:",y)}},U=y=>{u(y),j(!0)},R=()=>{r("groups"),k()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:o,children:e.jsxs(s.DialogContent,{className:"max-w-4xl max-h-[80vh]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-5 w-5"}),"Group Management"]}),e.jsx(s.DialogDescription,{children:"Manage your groups, create new groups, and control group membership"})]}),e.jsxs(s.Tabs,{value:a,onValueChange:r,className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsxs(s.TabsTrigger,{value:"groups",className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-4 w-4"}),"Groups"]}),e.jsxs(s.TabsTrigger,{value:"create",className:"flex items-center gap-2",children:[e.jsx(s.Plus,{className:"h-4 w-4"}),"Create Group"]})]}),e.jsx(s.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"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(s.Input,{placeholder:"Search groups...",value:l,onChange:y=>c(y.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:I?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(y=>e.jsx(s.Skeleton,{className:"h-24 w-full"},y))}):E.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:"No groups found"}),e.jsx("p",{className:"text-xs mt-1",children:l?"Try a different search":"Create your first group to get started"})]}):e.jsx("div",{className:"space-y-3",children:E.map(y=>e.jsx(yt,{group:y,onManageMembers:()=>U(y),onDelete:()=>n(y),currentUserId:g==null?void 0:g.id},y.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(lt,{onSuccess:R,tenantId:S,isTenantUser:v})})]})]})}),m&&e.jsx(bt,{open:p,onOpenChange:j,group:m,onUpdate:()=>k()}),e.jsx(s.AlertDialog,{open:!!h,onOpenChange:()=>n(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Group"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',h==null?void 0:h.name,'"? This action cannot be undone and will remove all members from the group.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:_,disabled:b.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Group"})]})]})})]})}function yt({group:t,onManageMembers:o,onDelete:a,currentUserId:r}){const l=t.createdBy===r;return e.jsx("div",{className:"rounded-lg border bg-card p-4 transition-colors hover:bg-muted/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"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 ",_s.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:o,title:"Manage members",children:e.jsx(s.UserPlus,{className:"h-4 w-4"})}),l&&e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:a,title:"Delete group",className:"text-destructive hover:text-destructive",children:e.jsx(s.Trash2,{className:"h-4 w-4"})})]})]})})}function X(t,o,a){var c,m;const r=(t.controls||[]).find(u=>u.id===a);if(r)return r.label;const l=(m=(c=s.findCardById(t,o))==null?void 0:c.controls)==null?void 0:m.find(u=>u.id===a);return(l==null?void 0:l.label)||a}function Y(t,o){var a;return((a=s.findCardById(t,o))==null?void 0:a.title)||o}function Dt(t){const{errors:o,dashboard:a}=t;if(!a)return o;const r=new Map;for(const l of o){const c=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,h,n]=c,d=`${h}:${n}:missing-metric`;r.has(d)||r.set(d,`"${Y(a,h)}" has an outdated "${X(a,h,n)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const m=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(m){const[,h,n]=m,d=`${h}:${n}:missing-group-by`;r.has(d)||r.set(d,`"${Y(a,h)}" has an outdated "${X(a,h,n)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const u=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(u){const[,h,n]=u,d=`${h}:${n}:invalid-metric`;r.has(d)||r.set(d,`"${Y(a,h)}" has an invalid "${X(a,h,n)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const p=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(p){const[,h,n]=p,d=`${h}:${n}:invalid-group-by`;r.has(d)||r.set(d,`"${Y(a,h)}" has an invalid "${X(a,h,n)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const j=l.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(j){const[,h,n]=j,d=`${h}:${n}:missing-temporal-group-by`;r.has(d)||r.set(d,`"${Y(a,h)}" can no longer use "${X(a,h,n)}" for time grain because the card does not currently group by a date field.`);continue}r.set(l,l)}return Array.from(r.values())}function Nt(){var ze,Ke,Qe,We;P.useExportRecovery(),P.useExportPolling();const{authToken:t,tokenProps:o,id:a}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{permissions:l}=Zs(),c=s.useHasDashboardId(),{isLoading:m}=s.useDashboardQuery();s.useDashboardStore(i=>i.theme);const u=s.useDashboardStore(i=>i.dashboardAssistantDraftScopeKey),p=s.useDashboardStore(i=>i.lenses),j=s.useDashboardStore(i=>i.selectedLensId),h=p==null?void 0:p.find(i=>i.id===j),n=s.useDashboardStore(i=>i.dashboard);s.useDashboardStore(i=>i.selectedSheetId);const d=s.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:g}=s.useDashboardStore(i=>i.actions),[b,v]=x.useState(!1),[S,N]=x.useState(!1),[I,k]=x.useState(!1),[E,_]=x.useState(!1),[U,R]=x.useState(!1),[y,G]=x.useState(!1),[Z,H]=x.useState(null),[ue,f]=x.useState(!1),[w,L]=x.useState(null),[F,$]=x.useState([]),[V,ee]=x.useState(!1),us=s.useDashboardStore(i=>i.isDashboardPanelOpen),ms=s.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),hs=s.useDashboardStore(i=>i.filterValues),D=s.useDashboardStore(i=>i.isVisualEditing);s.useEditorStore(i=>i.card);const z=s.useManagementStore(i=>i.selectedDashboard),se=s.useManagementStore(i=>i.initialDashboard);s.useManagementStore(i=>i.selectedVisual),s.useDashboardStore(i=>i.selectedFrameId),s.useEditorStore(i=>i.frame);const te=z?(Ke=z==null?void 0:z.permissions)==null?void 0:Ke.canEdit:(ze=se==null?void 0:se.permissions)==null?void 0:ze.canEdit,ae=s.useDashboardStore(i=>i.showFilters),Oe=s.useAssistantLayoutStore(i=>i.setPanelOpen),ps=s.useDashboardStore(i=>i.showDashboardJSON),me=s.useDashboardStore(i=>i.onSaveFunction),Pe=s.useDashboardStore(i=>i.actions.setShowFilters),{setIsDashboardEditing:Fe,setShowDashboardJSON:_e}=s.useDashboardStore(i=>i.actions),{setInitialDashboard:Ue,clearSelectedDashboard:he}=s.useManagementStore(i=>i.actions),{resources:re}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:pe}=s.useUserPreferences(),gs=((Qe=pe==null?void 0:pe.preference)==null?void 0:Qe.defaultDashboardId)||null,{mutate:fs,isPending:xs}=s.useDefaultDashboardMutation(),{currentUser:bs}=s.useCurrentUserInfo(),vs=s.canUserManageGroups(bs),B=z||se,Re=B?{id:B.id,title:(n==null?void 0:n.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:js}=s.useAddNewFrame(),[ge,fe]=x.useState(!1),[Ss,K]=x.useState(!1),[xe,ne]=x.useState("close"),Q=s.useUpdateResource(s.ResourceType.DASHBOARD),[T,be]=x.useState(null),Ge=x.useCallback(i=>{window.setTimeout(()=>{H(i)},0)},[]),ys=async(i,M)=>{if(!(n!=null&&n.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:n.id,newTitle:i,previousTitle:M}),Q.mutate({resourceId:n.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:O=>{console.error("Failed to update dashboard title:",O),s.ue.error("Failed to update dashboard title"),g(M)}})};x.useEffect(()=>{if(re&&re.length>0){const i=n==null?void 0:n.id;if(i){const M=re.find(O=>O.id===i);M&&Ue(M)}}},[re,n==null?void 0:n.id,Ue]);const oe=o.orgUserId||o.tenantId,$e=d&&!D&&oe&&te,{setDashboard:ve}=s.useDashboardStore(i=>i.actions),Ds=()=>{Fe(!0)},je=()=>{Fe(!1),_e(!1),be(null),H(null)};P.usePristineSnapshotInitializer(d,n,T,i=>be(i));const{isDirty:qe,isDirtyPending:Ns,resetDirty:ie}=Us.useDebouncedDirtyCheck(n,T,300,1e3,we.serializeDashboardForDirtyCheck),Be=x.useCallback(()=>T?we.serializeDashboardForDirtyCheck(n)!==we.serializeDashboardForDirtyCheck(T):!1,[n,T]),Se=qe||Ns,W=ge||Q.isPending,ws=()=>{Be()?(ne("close"),K(!0)):(je(),ie())},Cs=async()=>{await ye({closeAfterSave:!0,navigateHomeAfterSave:xe==="home"})},Ms=()=>{T&&ve(T),je(),xe==="home"&&he(),ne("close"),K(!1),ie()},Ls=()=>{T&&(ve(T),ie())},As=()=>{if(d&&Be()){ne("home"),K(!0);return}he()};async function ye(i){const M=s.useDashboardStore.getState().dashboard;if(!M)return;const O=(i==null?void 0:i.closeAfterSave)??V,Os=(i==null?void 0:i.navigateHomeAfterSave)??!1;ee(O),O&&K(!1);const Ps=s.cloneDeep(M);f(!0),L(null),$([]),fe(!0);const Fs={template:M};Q.mutate({resourceId:M.id,data:Fs},{onSuccess:A=>{var le,ce,Je;const q=(A==null?void 0:A.id)||((le=A==null?void 0:A.dashboard)==null?void 0:le.id)||((ce=A==null?void 0:A.resource)==null?void 0:ce.id)||((Je=A==null?void 0:A.template)==null?void 0:Je.id)||null;if(!M.id&&q){const Ne=s.useAIInteractionStore.getState(),de=Ne.pendingDashboardDraftMigration;(de==null?void 0:de.scopeKey)===u?Ne.actions.setPendingDashboardDraftMigrationExpectedDashboardId(q):de&&Ne.actions.clearPendingDashboardDraftMigration()}fe(!1),s.ue.success("Dashboard saved!"),be(Ps),f(!1),ee(!1),O&&(je(),ie(),Os&&he()),ne("close")},onError:A=>{fe(!1),L("Failed to save dashboard. Please try again.");const q=A.details,le=Array.isArray(q==null?void 0:q.errors)?(q.errors||[]).filter(ce=>typeof ce=="string"):[];$(Dt({errors:le,dashboard:M||void 0})),s.ue.error("Failed to save dashboard")}})}async function Es(){if(v(!0),!j||!h)return;const i=s.useDashboardStore.getState().dashboard;if(!i){v(!1);return}const M=JSON.stringify(i),O={...h,template:M,filterValues:hs};await Ae(o.apiServiceUrl,O,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),me==null||me(i),v(!1)}const He=(h==null?void 0:h.name)||n.title;Q.isPending&&console.log("Title during update:",{title:He,dashboardStateTitle:n.title,dashboardId:n==null?void 0:n.id,currentLensName:h==null?void 0:h.name});const Ve=o.orgUserId||o.tenantId&&o.endUserId&&o.endUserEmail,Is=!!Ve&&!!(t!=null&&t.accessToken)&&!!(o!=null&&o.apiServiceUrl),ks=c,J=(n==null?void 0:n.id)||null,De=!!J&&gs===J,Ts=()=>{J&&fs({dashboardId:De?null:J})};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:[Ve&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{ms(!us)},className:"h-7 p-2",children:e.jsx($s,{className:"h-4 w-4"})}),ks&&!D&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:As,className:"h-7 p-2",children:e.jsx(s.House,{className:"h-4 w-4"})})]}),!D&&c&&(m?e.jsx("div",{className:"h-4 w-28 rounded-md bg-muted/70 animate-pulse","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:He||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:te,dashboardId:n==null?void 0:n.id});const M=(n==null?void 0:n.title)||"";g(i),ys(i,M)},isEditable:te&&!h,displayClassName:"text-sm font-medium",inputClassName:"text-sm font-medium",placeholder:"Dashboard Title",isPending:Q.isPending}),Is&&J&&e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"icon",onClick:Ts,disabled:xs||!(t!=null&&t.accessToken)||!(o!=null&&o.apiServiceUrl),className:"h-7 w-7",children:e.jsx(s.Star,{className:s.cn("h-4 w-4 transition-colors",De?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400")})})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:De?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[D&&e.jsxs(e.Fragment,{children:[e.jsx(P.AdvancedModeToggle,{className:"mr-2"}),e.jsx(P.VisualEditingControls,{className:"h-7"})]}),r&&!D&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{tooltip:"Copy Token",onClick:()=>{var i;t!=null&&t.accessToken&&((i=navigator==null?void 0:navigator.clipboard)!=null&&i.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},className:"h-7 p-2",children:e.jsx(s.Copy,{className:"h-4 w-4"})}),e.jsx(s.IconButton,{tooltip:"Invalidate Token",onClick:()=>s.invalidateToken(o.apiServiceUrl),className:"h-7 p-2",children:e.jsx(Bs,{className:"h-4 w-4"})})]}),!D&&c&&e.jsx(s.DownloadPdf,{}),!D&&c&&e.jsx(P.NotificationBell,{}),!D&&c&&((We=B==null?void 0:B.permissions)==null?void 0:We.canShare)&&e.jsx(s.IconButton,{tooltip:"Share Dashboard",onClick:()=>N(!0),className:"h-7 p-2",children:e.jsx(s.Share2,{className:"h-4 w-4"})}),!D&&d&&l.canUseFilters&&c&&e.jsx(P.DashboardFilterControlsButton,{showFilters:ae,onToggleFilters:()=>{ae||Oe("dashboard",!1),Pe(!ae)},onAddFilter:()=>{ae||(Oe("dashboard",!1),Pe(!0))},onAddControl:()=>{Ge("create")},onManageControls:()=>Ge("manage")}),d&&!D&&c&&Z?e.jsx(P.DashboardControlsSettings,{open:!0,onOpenChange:i=>{i||H(null)},showTrigger:!1,initialMode:Z}):null,d&&!D&&oe&&r&&c&&e.jsx(Xs,{}),!D&&oe&&r&&c&&e.jsx(Ys,{}),d&&!D&&oe&&h&&r&&c&&e.jsxs(s.Button,{className:"h-7 p-2",variant:"secondary",disabled:b,onClick:Es,size:"sm",children:[e.jsx(Ye.Save,{className:"mr-2 h-4 w-4"}),"Save Lens"]}),d&&!D&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!d,onClick:()=>js(),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Visual"]}),!D&&!d&&te&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:Ds,size:"sm",children:[e.jsx(s.Pencil,{className:"mr-2 h-4 w-4"}),"Edit"]}),$e&&c&&qe&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:Ls,size:"sm",disabled:W,children:[e.jsx(s.Undo2,{className:"mr-2 h-4 w-4"}),"Undo"]}),$e&&c&&e.jsxs("div",{className:"relative inline-flex",children:[e.jsxs(s.Button,{className:s.cn("h-7 p-2",!Se&&"opacity-60"),disabled:W||!Se,onClick:()=>ye(),size:"sm",children:[W?e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Ye.Save,{className:"mr-2 h-4 w-4"}),W?"Saving...":"Save"]}),Se&&!W&&e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-orange-500 ring-2 ring-background"})]}),!D&&d&&r&&c&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(s.Button,{className:"h-7 p-2",onClick:()=>_e(!ps),size:"sm",variant:"ghost",children:e.jsx(s.Code,{className:"h-4 w-4"})})}),!D&&r&&e.jsx(Qs,{}),d&&!D&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:ws,children:[e.jsx(s.Cross2Icon,{className:"mr-2 h-4 w-4"}),"Close"]}),!D&&c&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"h-8 w-8 rounded-md border border-transparent p-0 text-muted-foreground hover:bg-muted/50 hover:text-foreground",buttonProps:{"aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-xl border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{className:"px-2.5 text-xs font-medium text-muted-foreground",children:"Automation"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>_(!0),className:"flex items-center gap-2",children:[e.jsx(s.Clock,{className:"mr-2 h-4 w-4"}),"Schedule Dashboard"]}),e.jsx(s.DropdownMenuSeparator,{}),vs&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-2.5 text-xs font-medium text-muted-foreground",children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>k(!0),className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{className:"px-2.5 text-xs font-medium text-muted-foreground",children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>R(!0),className:"flex items-center gap-2",children:[e.jsx(s.Calendar,{className:"mr-2 h-4 w-4"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>G(!0),className:"flex items-center gap-2",children:[e.jsx(s.FileText,{className:"mr-2 h-4 w-4"}),"Summary Settings"]})]})]}),S&&Re&&e.jsx(s.ShareDialog,{resource:Re,resourceType:s.ResourceType.DASHBOARD,onClose:()=>N(!1)}),e.jsx(St,{open:I,onOpenChange:k}),(n==null?void 0:n.id)&&e.jsx(s.EmailScheduleDialog,{open:E,onOpenChange:_,dashboardId:n.id,dashboardName:n==null?void 0:n.title}),e.jsx(Xe.CalendarPreferencesDialog,{open:U,onOpenChange:R}),e.jsx(Xe.DashboardSummarySettingsDialog,{open:y,onOpenChange:G,dashboard:n,disabled:!d,onApply:i=>ve({...n,summary:i})}),e.jsx(s.AlertDialog,{open:ue,onOpenChange:i=>{!i&&ge&&!w||(f(i),i||(L(null),$([]),ee(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:w?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:w?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),F.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:F.slice(0,5).map(i=>e.jsx("li",{children:i},i))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:w?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{f(!1),L(null),$([]),ee(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>ye({closeAfterSave:V,navigateHomeAfterSave:xe==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(P.UnsavedChangesAlert,{open:Ss,onOpenChange:i=>{K(i)},onSave:Cs,onDiscard:Ms,isSaving:ge,saveLabel:"Save",discardLabel:"Discard"})]})]})}exports.default=Nt;
@@ -1,8 +1,8 @@
1
1
  import ve, { useState as L, useRef as O, useCallback as V, useEffect as F, useContext as ge } from "react";
2
- import { bL as Z, b as $, aB as U, bI as j, bE as ee, bF as _, aC as te, bD as be, e as ae, f as se, g as re, h as oe, i as ne, L as G, c$ as we, d5 as Ce, v as xe, B as S, w as H, U as z, J as ye, u as P, K as Ne, N as X, d6 as De, d7 as K, x as R, ae as Ae, c as I, cy as ie, cz as le, a5 as de, cB as ce, cC as M, s as Ee, cG as Se, cp as Ie, M as Le, d8 as Te, d9 as Fe, da as ke, cO as Ue, cP as Me, cQ as Ve, db as Pe, cR as Be, cS as Oe, cT as ze, cU as Re, cV as $e, ar as je, bK as _e, X as He, dc as Xe, dd as Ge, cu as Ke, bG as q, a7 as qe, aE as Qe, P as ue, k as me, de as We, l as he, df as Je, dg as Ye, dh as Ze, di as et, dj as tt, dk as pe, dl as Q, dm as at } from "./index-BtbNfaQD.js";
2
+ import { bL as Z, b as $, aB as U, bI as j, bE as ee, bF as _, aC as te, bD as be, e as ae, f as se, g as re, h as oe, i as ne, L as G, c$ as we, d5 as Ce, v as xe, B as S, w as H, U as z, J as ye, u as P, K as Ne, N as X, d6 as De, d7 as K, x as R, ae as Ae, c as I, cy as ie, cz as le, a5 as de, cB as ce, cC as M, s as Ee, cG as Se, cp as Ie, M as Le, d8 as Te, d9 as Fe, da as ke, cO as Ue, cP as Me, cQ as Ve, db as Pe, cR as Be, cS as Oe, cT as ze, cU as Re, cV as $e, ar as je, bK as _e, X as He, dc as Xe, dd as Ge, cu as Ke, bG as q, a7 as qe, aE as Qe, P as ue, k as me, de as We, l as he, df as Je, dg as Ye, dh as Ze, di as et, dj as tt, dk as pe, dl as Q, dm as at } from "./index-D2dG8YFx.js";
3
3
  import { jsx as t, jsxs as s, Fragment as B } from "react/jsx-runtime";
4
- import { V as st, E as rt, a as ot, b as nt, L as it, c as lt, d as dt, C as ct, u as ut, e as mt } from "./use-create-flow-overlay-state-BcMrPzMc.js";
5
- import { a as fe } from "./use-visual-utils-DmxEKpor.js";
4
+ import { V as st, E as rt, a as ot, b as nt, L as it, c as lt, d as dt, C as ct, u as ut, e as mt } from "./use-create-flow-overlay-state-CPUI4zrE.js";
5
+ import { a as fe } from "./use-visual-utils-B_9CT1PY.js";
6
6
  import { k as W } from "./date-formatter-vkCj9Ct-.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
@@ -1,4 +1,4 @@
1
- "use strict";const g=require("react"),t=require("./index-DZ93VE76.js"),e=require("react/jsx-runtime"),A=require("./use-create-flow-overlay-state-D13D1vB_.js"),M=require("./use-visual-utils-DScc5-p_.js"),T=require("./date-formatter-CqXdM6JO.js");/**
1
+ "use strict";const g=require("react"),t=require("./index-BUNYVJ8g.js"),e=require("react/jsx-runtime"),A=require("./use-create-flow-overlay-state-DakZJeCH.js"),M=require("./use-visual-utils-Cd9d6nnp.js"),T=require("./date-formatter-CqXdM6JO.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,5 +1,5 @@
1
1
  import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
- import { u as s, c as l, B as h, X as d, d as c } from "./index-BtbNfaQD.js";
2
+ import { u as s, c as l, B as h, X as d, d as c } from "./index-D2dG8YFx.js";
3
3
  import "react";
4
4
  import "react-dom";
5
5
  function N() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("./index-DZ93VE76.js");require("react");require("react-dom");function i(){const o=a.useDashboardStore(e=>e.dashboard),r=a.useDashboardStore(e=>e.actions.setDashboard),t=a.useDashboardStore(e=>e.showDashboardJSON),n=a.useDashboardStore(e=>e.actions.setShowDashboardJSON);return s.jsxs("div",{className:a.cn("relative p-2",{hidden:!t}),children:[s.jsxs(a.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>n(!1),children:[s.jsx(a.X,{className:"mr-2 h-4 w-4"}),"Close"]}),s.jsx(a.de,{onChange:e=>{if(e)try{JSON.parse(e),r(JSON.parse(e))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto",value:JSON.stringify(o,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}exports.default=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("./index-BUNYVJ8g.js");require("react");require("react-dom");function i(){const o=a.useDashboardStore(e=>e.dashboard),r=a.useDashboardStore(e=>e.actions.setDashboard),t=a.useDashboardStore(e=>e.showDashboardJSON),n=a.useDashboardStore(e=>e.actions.setShowDashboardJSON);return s.jsxs("div",{className:a.cn("relative p-2",{hidden:!t}),children:[s.jsxs(a.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>n(!1),children:[s.jsx(a.X,{className:"mr-2 h-4 w-4"}),"Close"]}),s.jsx(a.de,{onChange:e=>{if(e)try{JSON.parse(e),r(JSON.parse(e))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto",value:JSON.stringify(o,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}exports.default=i;
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-DZ93VE76.js");function W(r={}){var C,I,P,D;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),S=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,f=(s==null?void 0:s.apiServiceUrl)??null,[y,g]=l.useState(!1),[v,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[x,w]=l.useState(null),k=x||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((D=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:D.weekStart)??null},b=l.useCallback(async()=>{if(!(!S||!d||!f)){g(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{g(!1)}}},[d,f,S]);l.useEffect(()=>{S&&b()},[S,b]);const T=l.useCallback(async u=>{if(!d||!f)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,f,b]),N=l.useCallback(async()=>{if(!d||!f)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return w({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,f,b]);return{preferences:k,isLoading:y,isSaving:v,isClearing:m,error:j,updatePreferences:T,clearPreferences:N,refetch:b}}const A=[{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"}],H=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return A.map(r=>r.value)}function V(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function U(r){const o=A.find(s=>s.value===r);return o?o.label:r}function X(r){const o=H.find(s=>s.value===r);return o?o.label:String(r)}function q({open:r,onOpenChange:o}){var M,z,F;const{preferences:s,isLoading:S,isSaving:d,isClearing:f,updatePreferences:y,clearPreferences:g}=W({enabled:r}),v=s.tz||((M=s.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((z=s.inherited)==null?void 0:z.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[x,w]=l.useState(v),[k,b]=l.useState(p),[T,N]=l.useState(!1),C=l.useMemo(()=>G(),[]),I=l.useMemo(()=>C.filter(t=>!A.some(R=>R.value===t)),[C]),P=l.useMemo(()=>U(x),[x]),D=s.inherited?U(s.inherited.tz):"UTC",u=s.inherited?X(s.inherited.weekStart):"Monday",i=V((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),w(v),b(p))},[r,j,s.userHasPrefs,v,p]);const h=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}m?await g()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:x,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{o(!1)},L=d||f,O=L||S;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[D,", Week starts ",u]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:N,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[P,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.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:A.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),w(t.value),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),w(t),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:H.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:L,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:O,children:L?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const E=6,B=1,_=20;function Z(r){return Number.isNaN(r)?E:Math.min(_,Math.max(B,r))}function J({open:r,onOpenChange:o,dashboard:s,onApply:S,disabled:d=!1}){const[f,y]=l.useState(!1),[g,v]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),v((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>Z(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{S({enabled:f,position:g,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.SmallSwitch,{id:"dashboard-summary-enabled",checked:f,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:g,disabled:d,onValueChange:x=>v(x),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:B,max:_,disabled:d,value:p,onChange:x=>m(x.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-BUNYVJ8g.js");function W(r={}){var C,I,P,D;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),S=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,f=(s==null?void 0:s.apiServiceUrl)??null,[y,g]=l.useState(!1),[v,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[x,w]=l.useState(null),k=x||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((D=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:D.weekStart)??null},b=l.useCallback(async()=>{if(!(!S||!d||!f)){g(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{g(!1)}}},[d,f,S]);l.useEffect(()=>{S&&b()},[S,b]);const T=l.useCallback(async u=>{if(!d||!f)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,f,b]),N=l.useCallback(async()=>{if(!d||!f)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return w({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,f,b]);return{preferences:k,isLoading:y,isSaving:v,isClearing:m,error:j,updatePreferences:T,clearPreferences:N,refetch:b}}const A=[{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"}],H=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return A.map(r=>r.value)}function V(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function U(r){const o=A.find(s=>s.value===r);return o?o.label:r}function X(r){const o=H.find(s=>s.value===r);return o?o.label:String(r)}function q({open:r,onOpenChange:o}){var M,z,F;const{preferences:s,isLoading:S,isSaving:d,isClearing:f,updatePreferences:y,clearPreferences:g}=W({enabled:r}),v=s.tz||((M=s.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((z=s.inherited)==null?void 0:z.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[x,w]=l.useState(v),[k,b]=l.useState(p),[T,N]=l.useState(!1),C=l.useMemo(()=>G(),[]),I=l.useMemo(()=>C.filter(t=>!A.some(R=>R.value===t)),[C]),P=l.useMemo(()=>U(x),[x]),D=s.inherited?U(s.inherited.tz):"UTC",u=s.inherited?X(s.inherited.weekStart):"Monday",i=V((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),w(v),b(p))},[r,j,s.userHasPrefs,v,p]);const h=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}m?await g()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:x,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{o(!1)},L=d||f,O=L||S;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[D,", Week starts ",u]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:N,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[P,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.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:A.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),w(t.value),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),w(t),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:H.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:L,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:O,children:L?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const E=6,B=1,_=20;function Z(r){return Number.isNaN(r)?E:Math.min(_,Math.max(B,r))}function J({open:r,onOpenChange:o,dashboard:s,onApply:S,disabled:d=!1}){const[f,y]=l.useState(!1),[g,v]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),v((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>Z(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{S({enabled:f,position:g,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.SmallSwitch,{id:"dashboard-summary-enabled",checked:f,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:g,disabled:d,onValueChange:x=>v(x),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:B,max:_,disabled:d,value:p,onChange:x=>m(x.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as a, Fragment as ce } from "react/jsx-runtime";
2
2
  import de, { useState as f, useCallback as j, useEffect as K, useMemo as F } from "react";
3
- import { b as ue, e as q, f as Y, g as Q, h as ee, i as ae, R, c as k, j as $, L as y, P as me, k as he, B as E, C as fe, l as pe, m as ve, n as be, o as Se, p as ge, q as V, r as G, s as X, t as ye, v as re, w as we, x as P, S as xe, y as Ne, z as Ce, A as ke, E as Te, F as Z, I as Ie } from "./index-BtbNfaQD.js";
3
+ import { b as ue, e as q, f as Y, g as Q, h as ee, i as ae, R, c as k, j as $, L as y, P as me, k as he, B as E, C as fe, l as pe, m as ve, n as be, o as Se, p as ge, q as V, r as G, s as X, t as ye, v as re, w as we, x as P, S as xe, y as Ne, z as Ce, A as ke, E as Te, F as Z, I as Ie } from "./index-D2dG8YFx.js";
4
4
  function Pe(s = {}) {
5
5
  var I, D, M, L;
6
6
  const { authToken: i, tokenProps: r } = ue(), S = s.enabled ?? !0, o = (i == null ? void 0 : i.accessToken) ?? null, h = (r == null ? void 0 : r.apiServiceUrl) ?? null, [N, w] = f(!1), [g, v] = f(!1), [u, n] = f(!1), [x, c] = f(null), [p, C] = f(null), A = p || {