react-semaphor 0.1.278 → 0.1.279

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 (29) hide show
  1. package/dist/chunks/{dashboard-controls-D9mU5Z1G.js → dashboard-controls-Cm_n6Dce.js} +1 -1
  2. package/dist/chunks/{dashboard-controls-DHf9WSeg.js → dashboard-controls-I3SWzXID.js} +4 -4
  3. package/dist/chunks/dashboard-filter-controls-button-DXXJnFns.js +11 -0
  4. package/dist/chunks/{dashboard-filter-controls-button-Col3P9nH.js → dashboard-filter-controls-button-DuifafhB.js} +3 -3
  5. package/dist/chunks/{dashboard-json-BZrsDc0Z.js → dashboard-json--iZU90D2.js} +1 -1
  6. package/dist/chunks/{dashboard-json-DiHAynxA.js → dashboard-json-C0_fJrmP.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-BJxnE9wH.js → dashboard-summary-settings-dialog-BzWnRhFU.js} +2 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-t6Y8a94z.js → dashboard-summary-settings-dialog-DOofgrKU.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-CdJVVU7F.js → edit-dashboard-visual-CEb2cSMS.js} +2889 -2862
  10. package/dist/chunks/edit-dashboard-visual-DEuJScSB.js +193 -0
  11. package/dist/chunks/{index-BI7I65hX.js → index-BzQ2UBDI.js} +25392 -25254
  12. package/dist/chunks/{index-DVnK3_oU.js → index-ZpmXTndp.js} +236 -236
  13. package/dist/chunks/{resource-management-panel-BuDLgHdE.js → resource-management-panel-DMHJbuqI.js} +2 -2
  14. package/dist/chunks/{resource-management-panel-BpGYomkJ.js → resource-management-panel-DNez0W3b.js} +2 -2
  15. package/dist/chunks/{use-create-flow-overlay-state-BfpuoFBE.js → use-create-flow-overlay-state-BdoJfJmU.js} +1 -1
  16. package/dist/chunks/{use-create-flow-overlay-state-DgQupBfa.js → use-create-flow-overlay-state-BvBTFIgX.js} +2 -2
  17. package/dist/chunks/{use-visual-utils-BA3-XR15.js → use-visual-utils-C2syL_qa.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-DWrGnklK.js → use-visual-utils-D4Lp-wat.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/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/dist/types/main.d.ts +1 -1
  27. package/package.json +1 -1
  28. package/dist/chunks/dashboard-filter-controls-button-C3eC--zB.js +0 -11
  29. package/dist/chunks/edit-dashboard-visual-Cg9xHe7E.js +0 -193
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DVnK3_oU.js"),h=require("react"),re=require("./use-visual-utils-DWrGnklK.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-ZpmXTndp.js"),h=require("react"),re=require("./use-visual-utils-D4Lp-wat.js");/**
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 ie=t.createLucideIcon("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);function ae(s,g={}){const{enabled:x=!0,eventType:d="mousedown"}=g,i=h.useRef(null);return h.useEffect(()=>{const m=j=>{const o=j.target;i.current&&i.current.contains(o)||o instanceof Element&&(o.closest("[data-radix-popper-content-wrapper]")||o.closest("[data-radix-select-content]")||o.closest("[data-radix-popover-content]")||o.closest("[data-radix-dropdown-menu-content]")||o.closest("[data-radix-tooltip-content]")||o.closest('[role="listbox"]')||o.closest('[role="option"]')||o.closest('[role="combobox"]'))||o instanceof Element&&o.hasAttribute("data-radix-")||s()};return x&&document.addEventListener(d,m),()=>{document.removeEventListener(d,m)}},[s,x,d]),i}function ne(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((s,g)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},g))})}const de=s=>{const g=t.useDashboardStore(i=>i.isVisualEditing),x=t.useDashboardStore(i=>i.selectedFrameId),d=t.useEditorStore(i=>i.frame);return!!(g&&x&&(d==null?void 0:d.visualId)===s)};function le({visual:s,isDeleting:g,isDuplicating:x,onAddVisual:d,onOpenVisual:i,onEditDetails:m,onDeleteClick:j,onDuplicateVisual:o,onShareVisual:D,formatDate:N}){var O,T,U,P;const{selectVisual:p}=t.useManagementActions(),c=t.useIsVisualSelected(s.id),u=de(s.id),A=t.useDashboardStore(a=>a.isVisualEditing),{isConsoleMode:R}=t.useDashboardPreferences(),b=h.useRef(null),[C,S]=h.useState(!1),[E,L]=h.useState(!1);h.useEffect(()=>{x?(S(!0),L(!0)):E&&(S(!1),L(!1))},[x,E]),h.useEffect(()=>{u&&b.current&&b.current.scrollIntoView({behavior:"smooth",block:"center"})},[u]);const y=()=>{p(s),i==null||i(s)},v=a=>{a.currentTarget===a.target&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),y())};return e.jsxs("div",{ref:b,className:t.cn("group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",u?"border-primary/30 bg-primary/10":c&&"border-border/60 bg-muted/50"),onClick:y,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:v,children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:s.title||"Untitled Visual",children:s.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(O=s.description)!=null&&O.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex flex-shrink-0 items-center gap-1 transition-opacity",c||u||C?"pointer-events-auto opacity-100":"pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100"),onClick:a=>a.stopPropagation(),children:e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-lg border border-border/60 bg-background/95 shadow-sm",children:[e.jsxs(t.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-none border-0 px-2 text-xs font-medium shadow-none hover:bg-muted/50",disabled:A,onClick:a=>{a.stopPropagation(),d(s)},"aria-label":`Add ${s.title||"visual"}`,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenu,{modal:!1,open:C,onOpenChange:S,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 rounded-none border-0 border-l border-border/60 p-0 shadow-none hover:bg-muted/50","aria-label":"Open visual actions",children:e.jsx(t.EllipsisVertical,{className:"h-3 w-3"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-44 rounded-xl border border-border/60 p-1 shadow-sm",children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),d(s)},disabled:A,children:[e.jsx(t.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),i==null||i(s)},children:[e.jsx(ie,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.preventDefault(),a.stopPropagation(),o(s.id)},disabled:x,children:[x?e.jsx(t.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(t.Copy,{className:"mr-2 h-3 w-3"}),x?"Duplicating...":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),m==null||m(s)},children:[e.jsx(t.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),D(s)},children:[e.jsx(t.Users,{className:"mr-2 h-3 w-3"}),"Share"]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),j(s)},className:"text-destructive",disabled:g,children:[e.jsx(t.Trash2,{className:"mr-2 h-3 w-3"}),g?"Deleting...":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs text-muted-foreground",children:[(((T=s.ownership.createdBy)==null?void 0:T.type)==="tenant"||((U=s.ownership.createdBy)==null?void 0:U.type)==="organization"&&R)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.User,{className:"h-3 w-3"}),e.jsx("span",{children:((P=s.ownership.createdBy)==null?void 0:P.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:N(s.lastModified)})]})]})]})]})]})})]})}function ce({searchQuery:s}){const[g,x]=h.useState(!1),[d,i]=h.useState(null),[m,j]=h.useState(!1),[o,D]=h.useState(null),[N,p]=h.useState(null),[c,u]=h.useState(null),{handleEditLibraryVisual:A,handleAddLibraryVisual:R}=re.useVisualUtils(),{resources:b,isLoading:C,isError:S,updateResource:E,deleteResource:L,duplicateResource:y,isDeleting:v}=t.useVisualManagement(()=>{j(!1),D(null)}),O=b.filter(n=>{var M,l;return((M=n==null?void 0:n.title)==null?void 0:M.toLowerCase().includes(s.toLowerCase()))||((l=n==null?void 0:n.description)==null?void 0:l.toLowerCase().includes(s.toLowerCase()))}),T=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=n=>{D(n),j(!0)},P=()=>{o&&L(o.id)},{startUpdating:a,stopUpdating:_,isUpdating:F}=t.useResourceUpdateState(),V=(n,M,l)=>{var X;const B=Object.fromEntries(Object.entries(M).filter(([,I])=>I!==void 0));if(Object.keys(B).length===0){(X=l==null?void 0:l.onSuccess)==null||X.call(l);return}const w=Object.keys(B),H=w.length===1?w[0]:void 0;a(n,H),E({resourceId:n,data:B},{onSuccess:()=>{var I;_(n,H),(I=l==null?void 0:l.onSuccess)==null||I.call(l)},onError:()=>{var I;_(n,H),(I=l==null?void 0:l.onError)==null||I.call(l)}})},$=n=>{p(n),y(n,{onSettled:()=>p(null)})},z=n=>{A(n)},G=n=>{R(n)},W=n=>{i(n),x(!0)},Y=n=>{u(n)},J=()=>{u(null)},Q=({title:n,description:M})=>{if(!c)return;const l={};n!==c.title&&(l.title=n),(c.description||"")!==M&&(l.description=M),V(c.id,l,{onSuccess:()=>{u(null)}})};return C?e.jsx(ne,{}):S?e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load visuals"}),e.jsx(t.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]})}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-1.5 overflow-y-auto px-0.5",children:O.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(t.Grid3x3,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:s?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?"Try adjusting your search":'Click "New" above to add your first visual'})]}):O.map(n=>e.jsx(le,{visual:n,onAddVisual:G,onOpenVisual:z,onEditDetails:Y,onDeleteClick:U,onDuplicateVisual:$,onShareVisual:W,isDeleting:v,isDuplicating:N===n.id,formatDate:T},n.id))}),g&&d&&e.jsx(t.ShareDialog,{resource:d,resourceType:t.ResourceType.VISUAL,onClose:()=>{x(!1),i(null)}}),c&&e.jsx(t.ResourceEditDialog,{open:!!c,resourceLabel:"Visual",initialTitle:c.title||"",initialDescription:c.description||"",onClose:J,onSave:Q,isSaving:F(c.id)}),e.jsx(t.AlertDialog,{open:m,onOpenChange:n=>{!n&&v||(j(n),n||D(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Visual"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',o==null?void 0:o.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:v,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),P()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:v,children:[v?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),v?"Deleting...":"Delete"]})]})]})})]})}function ue({dashboard:s,isDeleting:g,isDuplicating:x,onLoadDashboard:d,onEditDetails:i,onDeleteClick:m,onDuplicateDashboard:j,onShareDashboard:o,formatDate:D,onDashboardItemClick:N}){var E,L;const{selectDashboard:p}=t.useManagementActions(),c=t.useIsDashboardSelected(s.id),{userContext:u,isLoading:A}=t.useCurrentUserInfo(),R=((E=u==null?void 0:u.permissions)==null?void 0:E.canEdit)??!1,b=A||!R,C=()=>{p(s),d(s.id),N==null||N(s.id)},S=y=>{y.currentTarget===y.target&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),C())};return e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",c&&"border-border/60 bg-muted/50"),onClick:C,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:S,children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:s.title||"Untitled Dashboard",children:s.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(L=s.description)!=null&&L.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex-shrink-0 transition-opacity",c?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"),children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:g,isDuplicating:x,shouldHideActions:b,onEditDetails:i,onDeleteClick:m,onDuplicateDashboard:j,onShareDashboard:o,formatDate:D})})]})}function he({onRetry:s}){return e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load dashboards"}),e.jsx(t.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:s,children:"Retry"})]})})}function me(s){var ee;const{searchQuery:g,onLoadDashboard:x,onEditDashboard:d,onDashboardItemClick:i}=s,[m,j]=h.useState(!1),[o,D]=h.useState(null),[N,p]=h.useState(!1),[c,u]=h.useState(null),[A,R]=h.useState(null),[b,C]=h.useState(null),S=t.useManagementStore(r=>r.lastSelectedDashboard),E=t.useManagementStore(r=>r.selectedDashboard),L=t.useManagementStore(r=>r.actions.selectDashboard),y=t.useManagementStore(r=>r.actions.clearSelectedDashboard),{tokenProps:v,id:O}=t.useSemaphorContext(),{resources:T,isLoading:U,isError:P,updateResource:a,deleteResource:_,duplicateResource:F,isDeleting:V}=t.useDashboardManagement(()=>{p(!1);const r=c==null?void 0:c.id;u(null),(E==null?void 0:E.id)===r&&(!(v!=null&&v.dashboard_id)&&!O?y():S&&S.id!==r&&L(S))}),{userContext:$}=t.useCurrentUserInfo(),z=((ee=$==null?void 0:$.permissions)==null?void 0:ee.canCreateDashboard)??!1,G=T.filter(r=>{var K,f;return((K=r==null?void 0:r.title)==null?void 0:K.toLowerCase().includes(g.toLowerCase()))||((f=r==null?void 0:r.description)==null?void 0:f.toLowerCase().includes(g.toLowerCase()))}),W=r=>new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Y=r=>{x==null||x(r)},J=r=>{u(r),p(!0)},Q=()=>{c&&_(c.id)},n=r=>{R(r),F(r,{onSettled:()=>R(null)})},{startUpdating:M,stopUpdating:l,isUpdating:B}=t.useResourceUpdateState(),w=(r,K,f)=>{var se;const Z=Object.fromEntries(Object.entries(K).filter(([,q])=>q!==void 0));if(Object.keys(Z).length===0){(se=f==null?void 0:f.onSuccess)==null||se.call(f);return}const te=Object.keys(Z),k=te.length===1?te[0]:void 0;M(r,k),a({resourceId:r,data:Z},{onSuccess:()=>{var q;l(r,k),(q=f==null?void 0:f.onSuccess)==null||q.call(f)},onError:()=>{var q;l(r,k),(q=f==null?void 0:f.onError)==null||q.call(f)}})},H=r=>{D(r),j(!0)},X=r=>{d==null||d(r.id),C(r)},I=()=>{C(null)},oe=({title:r,description:K})=>{if(!b)return;const f={};r!==b.title&&(f.title=r),(b.description||"")!==K&&(f.description=K),w(b.id,f,{onSuccess:()=>{C(null)}})};return U?e.jsx(ne,{}):P?e.jsx(he,{onRetry:()=>window.location.reload()}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-1.5 overflow-y-auto px-0.5",children:G.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(t.ChartColumn,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:g?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:g?"Try adjusting your search":z?'Click "New" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):G.map(r=>e.jsx(ue,{dashboard:r,isDeleting:V,isDuplicating:A===r.id,onLoadDashboard:Y,onEditDetails:X,onDeleteClick:J,onDuplicateDashboard:n,onShareDashboard:H,formatDate:W,onDashboardItemClick:i},r.id))}),m&&o&&e.jsx(t.ShareDialog,{resource:o,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(t.AlertDialog,{open:N,onOpenChange:r=>{!r&&V||(p(r),r||u(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Dashboard"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',c==null?void 0:c.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:V,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:r=>{r.preventDefault(),r.stopPropagation(),Q()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:V,children:[V?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),V?"Deleting...":"Delete"]})]})]})}),b&&e.jsx(t.ResourceEditDialog,{open:!!b,resourceLabel:"Dashboard",initialTitle:b.title||"",initialDescription:b.description||"",onClose:I,onSave:oe,isSaving:B(b.id)})]})}function pe({open:s,onOpenChange:g,onSubmit:x,isCreating:d}){const[i,m]=h.useState(""),[j,o]=h.useState("");h.useEffect(()=>{s||(m(""),o(""))},[s]);const D=()=>{i.trim()&&x({title:i,description:j})},N=p=>{g(p)};return e.jsx(t.Dialog,{open:s,onOpenChange:N,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Create New Visual"}),e.jsx(t.DialogDescription,{children:"Add a new visual to your library. You can configure it after creation."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"title",children:"Visual Title"}),e.jsx(t.Input$1,{id:"title",placeholder:"Enter visual title...",value:i,onChange:p=>m(p.target.value),disabled:d,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),D())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Input$1,{id:"description",placeholder:"Enter visual description...",value:j,onChange:p=>o(p.target.value),disabled:d})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>N(!1),disabled:d,children:"Cancel"}),e.jsx(t.Button,{onClick:D,disabled:!i.trim()||d,children:d?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function xe({isOpen:s,onClose:g,className:x,onDashboardItemClick:d,variant:i="inline"}){var l,B;const m=t.useDashboardStore(w=>w.isDashboardEditing),[j,o]=h.useState(!1),[D,N]=h.useState(""),[p,c]=h.useState(!1),{currentUser:u,userContext:A}=t.useCurrentUserInfo(),R=((l=A==null?void 0:A.permissions)==null?void 0:l.canCreateDashboard)??!1,{onCreateSuccess:b}=t.useDashboardCreation({onDashboardSelect:d}),{selectVisual:C}=t.useManagementActions(),{handleEditLibraryVisual:S}=re.useVisualUtils(),{createResource:E,isCreating:L,refetch:y}=t.useDashboardManagement(),{createResource:v,isCreating:O}=t.useVisualManagement(void 0,w=>{o(!1),w&&(C(w),S(w))}),T=i==="overlay",U=m?"New Visual":"New",P=m?"New Visual":"New Dashboard",a=m?"Search visuals...":"Search dashboards...",_=m?"Collapse visuals panel":"Collapse dashboard panel",F=((u==null?void 0:u.name)??"").trim(),V=((u==null?void 0:u.email)??"").trim(),z=F&&F.toLowerCase()!=="undefined"?F:V||"Current user",G=((B=z.charAt(0))==null?void 0:B.toUpperCase())||"?",W=V&&V.toLowerCase()!=="undefined"?V:"",Y=ae(g,{enabled:s&&T}),J=t.cn("flex h-full flex-col border-r border-border/60 bg-background",T?t.cn("absolute inset-y-0 left-0 z-[51] w-60 overflow-hidden shadow-lg transition-transform duration-300 ease-in-out",s?"translate-x-0":"pointer-events-none -translate-x-full"):"w-full max-w-[17rem] min-w-[11rem] overflow-hidden",x),Q=w=>{},n=w=>{console.log("Editing dashboard:",w)},M=w=>{E(w,{onSuccess:H=>{o(!1),b(H,y)}})};return e.jsx(e.Fragment,{children:(!T||s)&&e.jsxs("div",{ref:Y,className:J,children:[e.jsxs("div",{className:"border-b border-border/60 bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"whitespace-nowrap text-sm font-semibold",children:m?"Visuals":"Dashboards"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{size:"sm",variant:"ghost",onClick:()=>c(!p),className:"h-8 w-8 rounded-md p-0 text-muted-foreground hover:bg-muted/50 hover:text-foreground","aria-label":p?"Hide search":"Show search",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(m||R)&&e.jsxs(t.Button,{size:"sm",variant:"secondary",className:"h-8 gap-1.5 whitespace-nowrap rounded-md border border-border/60 bg-muted/30 px-2 text-xs font-medium hover:bg-muted/55",onClick:()=>o(!0),"aria-label":P,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),U]}),e.jsx(t.Button,{size:"sm",variant:"outline",className:"h-8 w-8 rounded-md border-border/60 bg-background p-0.5 text-muted-foreground hover:bg-muted/35 hover:text-foreground",onClick:g,"aria-label":_,children:e.jsx(t.PanelLeft,{className:"h-3.5 w-3.5"})})]})]}),p&&e.jsx("div",{className:"border-t border-border/50 bg-muted/20 px-3 pb-3 pt-2",children:e.jsx(t.Input$1,{placeholder:a,value:D,onChange:w=>N(w.target.value),className:"h-9 border-border/60 bg-background text-sm focus-visible:border-ring/40 focus-visible:ring-0 focus-visible:ring-offset-0",autoFocus:!0})})]}),e.jsx("div",{className:"flex flex-1 flex-col overflow-auto px-2.5 py-2.5",children:m?e.jsx(ce,{searchQuery:D}):e.jsx(me,{searchQuery:D,onLoadDashboard:Q,onEditDashboard:n,onDashboardItemClick:d})}),u&&e.jsx(t.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border/60 bg-muted/20 px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"flex h-7 w-7 cursor-default items-center justify-center rounded-full bg-primary/10",children:e.jsx("span",{className:"text-xs font-medium text-primary",children:G})})}),e.jsx(t.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:z}),W&&e.jsx("div",{className:"text-xs text-muted-foreground",children:W}),u.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role: ",t.toTitleCase(u.role.replace(/_/g," "))]})]})})]}),e.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:z})]})})}),m?e.jsx(pe,{open:j,onOpenChange:o,onSubmit:v,isCreating:O}):e.jsx(t.CreateDashboardDialog,{open:j,onOpenChange:o,onSubmit:M,isCreating:L})]})})}exports.ResourceManagementPanel=xe;
6
+ */const ie=t.createLucideIcon("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);function ae(s,g={}){const{enabled:x=!0,eventType:d="mousedown"}=g,i=h.useRef(null);return h.useEffect(()=>{const m=j=>{const o=j.target;i.current&&i.current.contains(o)||o instanceof Element&&(o.closest("[data-radix-popper-content-wrapper]")||o.closest("[data-radix-select-content]")||o.closest("[data-radix-popover-content]")||o.closest("[data-radix-dropdown-menu-content]")||o.closest("[data-radix-tooltip-content]")||o.closest('[role="listbox"]')||o.closest('[role="option"]')||o.closest('[role="combobox"]'))||o instanceof Element&&o.hasAttribute("data-radix-")||s()};return x&&document.addEventListener(d,m),()=>{document.removeEventListener(d,m)}},[s,x,d]),i}function ne(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((s,g)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},g))})}const de=s=>{const g=t.useDashboardStore(i=>i.isVisualEditing),x=t.useDashboardStore(i=>i.selectedFrameId),d=t.useEditorStore(i=>i.frame);return!!(g&&x&&(d==null?void 0:d.visualId)===s)};function le({visual:s,isDeleting:g,isDuplicating:x,onAddVisual:d,onOpenVisual:i,onEditDetails:m,onDeleteClick:j,onDuplicateVisual:o,onShareVisual:D,formatDate:N}){var O,T,U,P;const{selectVisual:p}=t.useManagementActions(),c=t.useIsVisualSelected(s.id),u=de(s.id),A=t.useDashboardStore(a=>a.isVisualEditing),{isConsoleMode:R}=t.useDashboardPreferences(),b=h.useRef(null),[C,S]=h.useState(!1),[E,L]=h.useState(!1);h.useEffect(()=>{x?(S(!0),L(!0)):E&&(S(!1),L(!1))},[x,E]),h.useEffect(()=>{u&&b.current&&b.current.scrollIntoView({behavior:"smooth",block:"center"})},[u]);const y=()=>{p(s),i==null||i(s)},v=a=>{a.currentTarget===a.target&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),y())};return e.jsxs("div",{ref:b,className:t.cn("group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",u?"border-primary/30 bg-primary/10":c&&"border-border/60 bg-muted/50"),onClick:y,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:v,children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:s.title||"Untitled Visual",children:s.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(O=s.description)!=null&&O.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex flex-shrink-0 items-center gap-1 transition-opacity",c||u||C?"pointer-events-auto opacity-100":"pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100"),onClick:a=>a.stopPropagation(),children:e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-lg border border-border/60 bg-background/95 shadow-sm",children:[e.jsxs(t.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-none border-0 px-2 text-xs font-medium shadow-none hover:bg-muted/50",disabled:A,onClick:a=>{a.stopPropagation(),d(s)},"aria-label":`Add ${s.title||"visual"}`,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenu,{modal:!1,open:C,onOpenChange:S,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 rounded-none border-0 border-l border-border/60 p-0 shadow-none hover:bg-muted/50","aria-label":"Open visual actions",children:e.jsx(t.EllipsisVertical,{className:"h-3 w-3"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-44 rounded-xl border border-border/60 p-1 shadow-sm",children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),d(s)},disabled:A,children:[e.jsx(t.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),i==null||i(s)},children:[e.jsx(ie,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.preventDefault(),a.stopPropagation(),o(s.id)},disabled:x,children:[x?e.jsx(t.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(t.Copy,{className:"mr-2 h-3 w-3"}),x?"Duplicating...":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),m==null||m(s)},children:[e.jsx(t.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),D(s)},children:[e.jsx(t.Users,{className:"mr-2 h-3 w-3"}),"Share"]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),j(s)},className:"text-destructive",disabled:g,children:[e.jsx(t.Trash2,{className:"mr-2 h-3 w-3"}),g?"Deleting...":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs text-muted-foreground",children:[(((T=s.ownership.createdBy)==null?void 0:T.type)==="tenant"||((U=s.ownership.createdBy)==null?void 0:U.type)==="organization"&&R)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.User,{className:"h-3 w-3"}),e.jsx("span",{children:((P=s.ownership.createdBy)==null?void 0:P.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:N(s.lastModified)})]})]})]})]})]})})]})}function ce({searchQuery:s}){const[g,x]=h.useState(!1),[d,i]=h.useState(null),[m,j]=h.useState(!1),[o,D]=h.useState(null),[N,p]=h.useState(null),[c,u]=h.useState(null),{handleEditLibraryVisual:A,handleAddLibraryVisual:R}=re.useVisualUtils(),{resources:b,isLoading:C,isError:S,updateResource:E,deleteResource:L,duplicateResource:y,isDeleting:v}=t.useVisualManagement(()=>{j(!1),D(null)}),O=b.filter(n=>{var M,l;return((M=n==null?void 0:n.title)==null?void 0:M.toLowerCase().includes(s.toLowerCase()))||((l=n==null?void 0:n.description)==null?void 0:l.toLowerCase().includes(s.toLowerCase()))}),T=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=n=>{D(n),j(!0)},P=()=>{o&&L(o.id)},{startUpdating:a,stopUpdating:_,isUpdating:F}=t.useResourceUpdateState(),V=(n,M,l)=>{var X;const B=Object.fromEntries(Object.entries(M).filter(([,I])=>I!==void 0));if(Object.keys(B).length===0){(X=l==null?void 0:l.onSuccess)==null||X.call(l);return}const w=Object.keys(B),H=w.length===1?w[0]:void 0;a(n,H),E({resourceId:n,data:B},{onSuccess:()=>{var I;_(n,H),(I=l==null?void 0:l.onSuccess)==null||I.call(l)},onError:()=>{var I;_(n,H),(I=l==null?void 0:l.onError)==null||I.call(l)}})},G=n=>{p(n),y(n,{onSettled:()=>p(null)})},z=n=>{A(n)},W=n=>{R(n)},Y=n=>{i(n),x(!0)},$=n=>{u(n)},J=()=>{u(null)},Q=({title:n,description:M})=>{if(!c)return;const l={};n!==c.title&&(l.title=n),(c.description||"")!==M&&(l.description=M),V(c.id,l,{onSuccess:()=>{u(null)}})};return C?e.jsx(ne,{}):S?e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load visuals"}),e.jsx(t.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]})}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-1.5 overflow-y-auto px-0.5",children:O.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(t.Grid3x3,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:s?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?"Try adjusting your search":'Click "New" above to add your first visual'})]}):O.map(n=>e.jsx(le,{visual:n,onAddVisual:W,onOpenVisual:z,onEditDetails:$,onDeleteClick:U,onDuplicateVisual:G,onShareVisual:Y,isDeleting:v,isDuplicating:N===n.id,formatDate:T},n.id))}),g&&d&&e.jsx(t.ShareDialog,{resource:d,resourceType:t.ResourceType.VISUAL,onClose:()=>{x(!1),i(null)}}),c&&e.jsx(t.ResourceEditDialog,{open:!!c,resourceLabel:"Visual",initialTitle:c.title||"",initialDescription:c.description||"",onClose:J,onSave:Q,isSaving:F(c.id)}),e.jsx(t.AlertDialog,{open:m,onOpenChange:n=>{!n&&v||(j(n),n||D(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Visual"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',o==null?void 0:o.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:v,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),P()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:v,children:[v?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),v?"Deleting...":"Delete"]})]})]})})]})}function ue({dashboard:s,isDeleting:g,isDuplicating:x,onLoadDashboard:d,onEditDetails:i,onDeleteClick:m,onDuplicateDashboard:j,onShareDashboard:o,formatDate:D,onDashboardItemClick:N}){var E,L;const{selectDashboard:p}=t.useManagementActions(),c=t.useIsDashboardSelected(s.id),{userContext:u,isLoading:A}=t.useCurrentUserInfo(),R=((E=u==null?void 0:u.permissions)==null?void 0:E.canEdit)??!1,b=A||!R,C=()=>{p(s),d(s.id),N==null||N(s.id)},S=y=>{y.currentTarget===y.target&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),C())};return e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",c&&"border-border/60 bg-muted/50"),onClick:C,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:S,children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:s.title||"Untitled Dashboard",children:s.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(L=s.description)!=null&&L.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex-shrink-0 transition-opacity",c?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"),children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:g,isDuplicating:x,shouldHideActions:b,onEditDetails:i,onDeleteClick:m,onDuplicateDashboard:j,onShareDashboard:o,formatDate:D})})]})}function he({onRetry:s}){return e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load dashboards"}),e.jsx(t.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:s,children:"Retry"})]})})}function me(s){var ee;const{searchQuery:g,onLoadDashboard:x,onEditDashboard:d,onDashboardItemClick:i}=s,[m,j]=h.useState(!1),[o,D]=h.useState(null),[N,p]=h.useState(!1),[c,u]=h.useState(null),[A,R]=h.useState(null),[b,C]=h.useState(null),S=t.useManagementStore(r=>r.lastSelectedDashboard),E=t.useManagementStore(r=>r.selectedDashboard),L=t.useManagementStore(r=>r.actions.selectDashboard),y=t.useManagementStore(r=>r.actions.clearSelectedDashboard),{tokenProps:v,id:O}=t.useSemaphorContext(),{resources:T,isLoading:U,isError:P,updateResource:a,deleteResource:_,duplicateResource:F,isDeleting:V}=t.useDashboardManagement(()=>{p(!1);const r=c==null?void 0:c.id;u(null),(E==null?void 0:E.id)===r&&(!(v!=null&&v.dashboard_id)&&!O?y():S&&S.id!==r&&L(S))}),{userContext:G}=t.useCurrentUserInfo(),z=((ee=G==null?void 0:G.permissions)==null?void 0:ee.canCreateDashboard)??!1,W=T.filter(r=>{var K,f;return((K=r==null?void 0:r.title)==null?void 0:K.toLowerCase().includes(g.toLowerCase()))||((f=r==null?void 0:r.description)==null?void 0:f.toLowerCase().includes(g.toLowerCase()))}),Y=r=>new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),$=r=>{x==null||x(r)},J=r=>{u(r),p(!0)},Q=()=>{c&&_(c.id)},n=r=>{R(r),F(r,{onSettled:()=>R(null)})},{startUpdating:M,stopUpdating:l,isUpdating:B}=t.useResourceUpdateState(),w=(r,K,f)=>{var se;const Z=Object.fromEntries(Object.entries(K).filter(([,q])=>q!==void 0));if(Object.keys(Z).length===0){(se=f==null?void 0:f.onSuccess)==null||se.call(f);return}const te=Object.keys(Z),k=te.length===1?te[0]:void 0;M(r,k),a({resourceId:r,data:Z},{onSuccess:()=>{var q;l(r,k),(q=f==null?void 0:f.onSuccess)==null||q.call(f)},onError:()=>{var q;l(r,k),(q=f==null?void 0:f.onError)==null||q.call(f)}})},H=r=>{D(r),j(!0)},X=r=>{d==null||d(r.id),C(r)},I=()=>{C(null)},oe=({title:r,description:K})=>{if(!b)return;const f={};r!==b.title&&(f.title=r),(b.description||"")!==K&&(f.description=K),w(b.id,f,{onSuccess:()=>{C(null)}})};return U?e.jsx(ne,{}):P?e.jsx(he,{onRetry:()=>window.location.reload()}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-1.5 overflow-y-auto px-0.5",children:W.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(t.ChartColumn,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:g?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:g?"Try adjusting your search":z?'Click "New" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):W.map(r=>e.jsx(ue,{dashboard:r,isDeleting:V,isDuplicating:A===r.id,onLoadDashboard:$,onEditDetails:X,onDeleteClick:J,onDuplicateDashboard:n,onShareDashboard:H,formatDate:Y,onDashboardItemClick:i},r.id))}),m&&o&&e.jsx(t.ShareDialog,{resource:o,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(t.AlertDialog,{open:N,onOpenChange:r=>{!r&&V||(p(r),r||u(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Dashboard"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',c==null?void 0:c.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:V,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:r=>{r.preventDefault(),r.stopPropagation(),Q()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:V,children:[V?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),V?"Deleting...":"Delete"]})]})]})}),b&&e.jsx(t.ResourceEditDialog,{open:!!b,resourceLabel:"Dashboard",initialTitle:b.title||"",initialDescription:b.description||"",onClose:I,onSave:oe,isSaving:B(b.id)})]})}function pe({open:s,onOpenChange:g,onSubmit:x,isCreating:d}){const[i,m]=h.useState(""),[j,o]=h.useState("");h.useEffect(()=>{s||(m(""),o(""))},[s]);const D=()=>{i.trim()&&x({title:i,description:j})},N=p=>{g(p)};return e.jsx(t.Dialog,{open:s,onOpenChange:N,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Create New Visual"}),e.jsx(t.DialogDescription,{children:"Add a new visual to your library. You can configure it after creation."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"title",children:"Visual Title"}),e.jsx(t.Input,{id:"title",placeholder:"Enter visual title...",value:i,onChange:p=>m(p.target.value),disabled:d,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),D())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Input,{id:"description",placeholder:"Enter visual description...",value:j,onChange:p=>o(p.target.value),disabled:d})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>N(!1),disabled:d,children:"Cancel"}),e.jsx(t.Button,{onClick:D,disabled:!i.trim()||d,children:d?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function xe({isOpen:s,onClose:g,className:x,onDashboardItemClick:d,variant:i="inline"}){var l,B;const m=t.useDashboardStore(w=>w.isDashboardEditing),[j,o]=h.useState(!1),[D,N]=h.useState(""),[p,c]=h.useState(!1),{currentUser:u,userContext:A}=t.useCurrentUserInfo(),R=((l=A==null?void 0:A.permissions)==null?void 0:l.canCreateDashboard)??!1,{onCreateSuccess:b}=t.useDashboardCreation({onDashboardSelect:d}),{selectVisual:C}=t.useManagementActions(),{handleEditLibraryVisual:S}=re.useVisualUtils(),{createResource:E,isCreating:L,refetch:y}=t.useDashboardManagement(),{createResource:v,isCreating:O}=t.useVisualManagement(void 0,w=>{o(!1),w&&(C(w),S(w))}),T=i==="overlay",U=m?"New Visual":"New",P=m?"New Visual":"New Dashboard",a=m?"Search visuals...":"Search dashboards...",_=m?"Collapse visuals panel":"Collapse dashboard panel",F=((u==null?void 0:u.name)??"").trim(),V=((u==null?void 0:u.email)??"").trim(),z=F&&F.toLowerCase()!=="undefined"?F:V||"Current user",W=((B=z.charAt(0))==null?void 0:B.toUpperCase())||"?",Y=V&&V.toLowerCase()!=="undefined"?V:"",$=ae(g,{enabled:s&&T}),J=t.cn("flex h-full flex-col border-r border-border/60 bg-background",T?t.cn("absolute inset-y-0 left-0 z-[51] w-60 overflow-hidden shadow-lg transition-transform duration-300 ease-in-out",s?"translate-x-0":"pointer-events-none -translate-x-full"):"w-full max-w-[17rem] min-w-[11rem] overflow-hidden",x),Q=w=>{},n=w=>{console.log("Editing dashboard:",w)},M=w=>{E(w,{onSuccess:H=>{o(!1),b(H,y)}})};return e.jsx(e.Fragment,{children:(!T||s)&&e.jsxs("div",{ref:$,className:J,children:[e.jsxs("div",{className:"border-b border-border/60 bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"whitespace-nowrap text-sm font-semibold",children:m?"Visuals":"Dashboards"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{size:"sm",variant:"ghost",onClick:()=>c(!p),className:"h-8 w-8 rounded-md p-0 text-muted-foreground hover:bg-muted/50 hover:text-foreground","aria-label":p?"Hide search":"Show search",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(m||R)&&e.jsxs(t.Button,{size:"sm",variant:"secondary",className:"h-8 gap-1.5 whitespace-nowrap rounded-md border border-border/60 bg-muted/30 px-2 text-xs font-medium hover:bg-muted/55",onClick:()=>o(!0),"aria-label":P,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),U]}),e.jsx(t.Button,{size:"sm",variant:"outline",className:"h-8 w-8 rounded-md border-border/60 bg-background p-0.5 text-muted-foreground hover:bg-muted/35 hover:text-foreground",onClick:g,"aria-label":_,children:e.jsx(t.PanelLeft,{className:"h-3.5 w-3.5"})})]})]}),p&&e.jsx("div",{className:"border-t border-border/50 bg-muted/20 px-3 pb-3 pt-2",children:e.jsx(t.Input,{placeholder:a,value:D,onChange:w=>N(w.target.value),className:"h-9 border-border/60 bg-background text-sm focus-visible:border-ring/40 focus-visible:ring-0 focus-visible:ring-offset-0",autoFocus:!0})})]}),e.jsx("div",{className:"flex flex-1 flex-col overflow-auto px-2.5 py-2.5",children:m?e.jsx(ce,{searchQuery:D}):e.jsx(me,{searchQuery:D,onLoadDashboard:Q,onEditDashboard:n,onDashboardItemClick:d})}),u&&e.jsx(t.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border/60 bg-muted/20 px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"flex h-7 w-7 cursor-default items-center justify-center rounded-full bg-primary/10",children:e.jsx("span",{className:"text-xs font-medium text-primary",children:W})})}),e.jsx(t.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:z}),Y&&e.jsx("div",{className:"text-xs text-muted-foreground",children:Y}),u.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role: ",t.toTitleCase(u.role.replace(/_/g," "))]})]})})]}),e.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:z})]})})}),m?e.jsx(pe,{open:j,onOpenChange:o,onSubmit:v,isCreating:O}):e.jsx(t.CreateDashboardDialog,{open:j,onOpenChange:o,onSubmit:M,isCreating:L})]})})}exports.ResourceManagementPanel=xe;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as r, Fragment as le } from "react/jsx-runtime";
2
- import { bM as Pe, u as re, U as je, K as ce, cy as Fe, cz as Be, c as X, B as P, cr as ie, cA as ze, cB as He, cC as Ke, cD as _e, cE as Q, w as oe, cF as We, cG as Ge, cH as Ye, cI as ge, ce as ue, cJ as $e, cK as Je, cL as xe, cM as De, cN as we, cO as Qe, al as Ne, ah as ve, cP as ye, cQ as Ce, cR as Se, cS as Ee, cT as Ve, cU as Le, cV as Ae, cW as Oe, cX as Te, cY as Xe, cZ as he, c_ as Ze, af as te, b as qe, c$ as Re, d0 as ke, e as et, f as tt, g as rt, h as nt, i as ot, L as be, d1 as de, v as st, d2 as at, d3 as it, d4 as dt, bT as lt, bU as ct, bV as ut, bW as ht, d5 as mt, d6 as pt } from "./index-BI7I65hX.js";
2
+ import { bM as Pe, u as re, U as je, K as ce, cy as Fe, cz as Be, c as X, B as P, cr as ie, cA as ze, cB as He, cC as Ke, cD as _e, cE as Q, w as oe, cF as We, cG as Ge, cH as Ye, cI as ge, ce as ue, cJ as $e, cK as Je, cL as xe, cM as De, cN as we, cO as Qe, al as Ne, ah as ve, cP as ye, cQ as Ce, cR as Se, cS as Ee, cT as Ve, cU as Le, cV as Ae, cW as Oe, cX as Te, cY as Xe, cZ as he, c_ as Ze, af as te, b as qe, c$ as Re, d0 as ke, e as et, f as tt, g as rt, h as nt, i as ot, L as be, I as de, v as st, d1 as at, d2 as it, d3 as dt, bT as lt, bU as ct, bV as ut, bW as ht, d4 as mt, d5 as pt } from "./index-BzQ2UBDI.js";
3
3
  import ft, { useRef as gt, useEffect as ne, useState as x } from "react";
4
- import { u as Ue } from "./use-visual-utils-BA3-XR15.js";
4
+ import { u as Ue } from "./use-visual-utils-C2syL_qa.js";
5
5
  /**
6
6
  * @license lucide-react v0.453.0 - ISC
7
7
  *
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./index-DVnK3_oU.js"),t=require("react/jsx-runtime"),v=require("react"),G=require("./use-visual-utils-DWrGnklK.js");/**
1
+ "use strict";const e=require("./index-ZpmXTndp.js"),t=require("react/jsx-runtime"),v=require("react"),G=require("./use-visual-utils-D4Lp-wat.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,7 +1,7 @@
1
- import { bM as te, U as E, bN as Oe, bO as tt, bP as at, bQ as st, bR as lt, bS as rt, u as ve, af as nt, bT as dt, bU as it, bV as ot, ac as Z, c as q, bW as ct, bX as ut, B as I, s as mt, H as ae, N as Me, J as _e, bY as ze, w as Be, M as fe, bZ as Qe, X as je, x as _, b_ as pt, b$ as ht, c0 as J, c1 as we, c2 as Te, c3 as ie, c4 as Fe, c5 as ft, c6 as bt, c7 as P, c8 as yt, c9 as vt, a6 as Ve, ca as Ee, cb as ge, cc as Ue, cd as Re, ce as gt, L as R, I as $e, y as oe, z as ce, A as ue, E as me, F as pe, cf as Ke, cg as xt, ch as Ct, ci as He, cj as Ye, ck as Nt, cl as kt, cm as St, cn as Dt, co as It, cp as wt, cq as Tt, cr as Ft, cs as he, ct as Vt, cu as Le, cv as Et, cw as Lt, cx as At } from "./index-BI7I65hX.js";
1
+ import { bM as te, U as E, bN as Oe, bO as tt, bP as at, bQ as st, bR as lt, bS as rt, u as ve, af as nt, bT as dt, bU as it, bV as ot, ac as Z, c as q, bW as ct, bX as ut, B as I, s as mt, H as ae, N as Me, J as _e, bY as ze, w as Be, M as fe, bZ as Qe, X as je, x as _, b_ as pt, b$ as ht, c0 as J, c1 as we, c2 as Te, c3 as ie, c4 as Fe, c5 as ft, c6 as bt, c7 as P, c8 as yt, c9 as vt, a6 as Ve, ca as Ee, cb as ge, cc as Ue, cd as Re, ce as gt, L as R, I as $e, y as oe, z as ce, A as ue, E as me, F as pe, cf as Ke, cg as xt, ch as Ct, ci as He, cj as Ye, ck as Nt, cl as kt, cm as St, cn as Dt, co as It, cp as wt, cq as Tt, cr as Ft, cs as he, ct as Vt, cu as Le, cv as Et, cw as Lt, cx as At } from "./index-BzQ2UBDI.js";
2
2
  import { jsx as t, jsxs as d, Fragment as X } from "react/jsx-runtime";
3
3
  import { useMemo as L, useState as j, useRef as qt, useCallback as M, useEffect as be, Fragment as Ot } from "react";
4
- import { u as xe } from "./use-visual-utils-BA3-XR15.js";
4
+ import { u as xe } from "./use-visual-utils-C2syL_qa.js";
5
5
  /**
6
6
  * @license lucide-react v0.453.0 - ISC
7
7
  *
@@ -1,4 +1,4 @@
1
- import { G as K, b as Y, H as X, J as Z, K as q, M as _, N as ee, u as F, O as te, Q as re, x as M, T as se, U as f, V as oe } from "./index-BI7I65hX.js";
1
+ import { G as K, b as Y, H as X, J as Z, K as q, M as _, N as ee, u as F, O as te, Q as re, x as M, T as se, U as f, V as oe } from "./index-BzQ2UBDI.js";
2
2
  import { useState as H, useEffect as ae, useCallback as N } from "react";
3
3
  function ne(e) {
4
4
  const a = e.toUpperCase().indexOf("WHERE"), t = e.toUpperCase().indexOf("GROUP BY"), r = e.toUpperCase().indexOf("LIMIT"), s = e.toUpperCase().indexOf("ORDER BY");
@@ -1 +1 @@
1
- "use strict";const o=require("./index-DVnK3_oU.js"),S=require("react");function Q(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let i=e.length;if(s!==-1&&(i=s),r!==-1&&r<i&&(i=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,i),a=e.substring(i);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function z(e){const[n,t]=S.useState(null),[r,s]=S.useState(null),i=o.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!i)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,i]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,i;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((i=r.customCardPreferences)!=null&&i.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function P(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],i=r.getQueryData(s);if(i)return console.log("Using cached visual data for:",t),{data:i,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function j(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var i,d;const t=(e==null?void 0:e.frameObject)??((i=e==null?void 0:e.visual)==null?void 0:i.frameObject);if(!t)return!1;const r=j(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(c=>c.frame),t=o.useEditorStore(c=>c.card),r=o.useEditorStore(c=>c.isDevMode),s=z(((g=t.customCardPreferences)==null?void 0:g.url)||""),i=o.useEditorStore(c=>c.selectedSchemaName),d=o.useEditorStore(c=>c.selectedDatamodelId),a=o.useEditorStore(c=>c.selectedDatabaseName),l=o.useEditorStore(c=>c.selectedTableName),h=o.useEditorStore(c=>c.selectedConnectionId),m=o.useEditorStore(c=>c.isShowingVisual),p=t.sql;return{getUpdatedFrame:S.useCallback(()=>{var E;let c=p;p&&!p.includes("{{")&&(c=Q(p),e(c));const U=(E=s==null?void 0:s.getState())==null?void 0:E.settings,v=o.buildSavedEditorCard(t,{isDevMode:r,cardSql:c,isShowingVisual:m,selectedSchemaName:i,selectedDatamodelId:d,selectedDatabaseName:a,selectedTableName:l,selectedConnectionId:h,remoteChartSettings:U,stripConfig:Y}),C=n.cards.map(w=>w.id===t.id?v:w);return{...n,cards:C,activeCardId:G(C,n.activeCardId)}},[t,n,r,m,i,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:D,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:O}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),R=o.useDashboardStore(u=>u.selectedFrameId),x=o.useDashboardStore(u=>u.dashboard),B=o.useDashboardStore(u=>u.filterValues),T=o.useDashboardStore(u=>u.inlineFilterValuesMap),y=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),_=S.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(b,{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w,setIsDashboardEditing:V,setIsVisualEditing:D,dashboard:x,selectedSheetId:I,selectedFrameId:R,filterValues:B,inlineFilterValuesMap:T}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,i,d,V,D,a,l,h,m,p,$,g,c,U,v,C,E,w,A,x,I,R,B,T]),H=S.useCallback(async u=>{var b;try{if(s(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:W}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),k=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!k)return{success:!1,error:"Visual has no frame data"};const F=j(k);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const L={...o.cloneLinkedFrameWithSourceMapping(F),visualId:u.id};return N(I,L,"end"),V(!0),M(L.id),O(!1),{success:!0,fromCache:W}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,I,N,V,M,O]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:_,handleAddLibraryVisual:H,getUpdatedFrame:K().getUpdatedFrame,refetch:y.refetch}}exports.useVisualUtils=X;
1
+ "use strict";const o=require("./index-ZpmXTndp.js"),S=require("react");function Q(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let i=e.length;if(s!==-1&&(i=s),r!==-1&&r<i&&(i=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,i),a=e.substring(i);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function z(e){const[n,t]=S.useState(null),[r,s]=S.useState(null),i=o.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!i)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,i]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,i;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((i=r.customCardPreferences)!=null&&i.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function P(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],i=r.getQueryData(s);if(i)return console.log("Using cached visual data for:",t),{data:i,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function j(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var i,d;const t=(e==null?void 0:e.frameObject)??((i=e==null?void 0:e.visual)==null?void 0:i.frameObject);if(!t)return!1;const r=j(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(c=>c.frame),t=o.useEditorStore(c=>c.card),r=o.useEditorStore(c=>c.isDevMode),s=z(((g=t.customCardPreferences)==null?void 0:g.url)||""),i=o.useEditorStore(c=>c.selectedSchemaName),d=o.useEditorStore(c=>c.selectedDatamodelId),a=o.useEditorStore(c=>c.selectedDatabaseName),l=o.useEditorStore(c=>c.selectedTableName),h=o.useEditorStore(c=>c.selectedConnectionId),m=o.useEditorStore(c=>c.isShowingVisual),p=t.sql;return{getUpdatedFrame:S.useCallback(()=>{var E;let c=p;p&&!p.includes("{{")&&(c=Q(p),e(c));const U=(E=s==null?void 0:s.getState())==null?void 0:E.settings,v=o.buildSavedEditorCard(t,{isDevMode:r,cardSql:c,isShowingVisual:m,selectedSchemaName:i,selectedDatamodelId:d,selectedDatabaseName:a,selectedTableName:l,selectedConnectionId:h,remoteChartSettings:U,stripConfig:Y}),C=n.cards.map(w=>w.id===t.id?v:w);return{...n,cards:C,activeCardId:G(C,n.activeCardId)}},[t,n,r,m,i,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:D,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:O}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),R=o.useDashboardStore(u=>u.selectedFrameId),x=o.useDashboardStore(u=>u.dashboard),B=o.useDashboardStore(u=>u.filterValues),T=o.useDashboardStore(u=>u.inlineFilterValuesMap),y=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),_=S.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(b,{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w,setIsDashboardEditing:V,setIsVisualEditing:D,dashboard:x,selectedSheetId:I,selectedFrameId:R,filterValues:B,inlineFilterValuesMap:T}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,i,d,V,D,a,l,h,m,p,$,g,c,U,v,C,E,w,A,x,I,R,B,T]),H=S.useCallback(async u=>{var b;try{if(s(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:W}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),k=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!k)return{success:!1,error:"Visual has no frame data"};const F=j(k);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const L={...o.cloneLinkedFrameWithSourceMapping(F),visualId:u.id};return N(I,L,"end"),V(!0),M(L.id),O(!1),{success:!0,fromCache:W}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,I,N,V,M,O]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:_,handleAddLibraryVisual:H,getUpdatedFrame:K().getUpdatedFrame,refetch:y.refetch}}exports.useVisualUtils=X;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-DVnK3_oU.js"),e=require("../types/index.cjs");exports.Dashboard=r.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-ZpmXTndp.js"),e=require("../types/index.cjs");exports.Dashboard=r.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as E } from "../chunks/index-BI7I65hX.js";
1
+ import { D as E } from "../chunks/index-BzQ2UBDI.js";
2
2
  import { CONTROL_CARD_DEFAULT_VALUE as L, EMPTY_SELECTION as T } from "../types/index.js";
3
3
  export {
4
4
  L as CONTROL_CARD_DEFAULT_VALUE,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-DVnK3_oU.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-t6Y8a94z.js"),t=require("react/jsx-runtime"),x=require("react"),O=require("./chunks/resource-management-panel-BuDLgHdE.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const A=require("./chunks/dashboard-filter-controls-button-C3eC--zB.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(x);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=x.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),u=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var m;return(m=i==null?void 0:i.cards)==null?void 0:m.find(f=>(f==null?void 0:f.id)===s)});return{card:u,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:u,className:a,icon:i,showNone:m=!1}){const f=R.useRef(null),[D,C]=R.useState(!1),[b,j]=R.useState("100%"),y=m?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var h;return l?"Loading...":c?"Error":n?(h=r==null?void 0:r.find(S=>S.id===n))==null?void 0:h.name:`Select ${s}`}function T(h,S){o(S),C(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:C,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:I()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:u,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(h=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:h.name,onSelect:S=>T(S,h.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===h.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:h.name,children:h.name})]})},h.id))})]})]})})]})}function H({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=x.useState(!1),l=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function $(s,r){x.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function G(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function K({alertId:s,onBack:r}){var h,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:u}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,m]=x.useState([]),[f,D]=x.useState([]),[C,b]=x.useState(null),j=x.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=C&&N.some(B=>B.id===C)?C:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,C,o]),y=x.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??C;if(!p||!g||!s||!v){m([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();m(Array.isArray(N.attempts)?N.attempts:[])}else m([])}catch{m([])}},[s,n,C,o]),I=x.useCallback(async()=>{await u();const d=await j();await y(d)},[y,j,u]);x.useEffect(()=>{j().catch(()=>{})},[j]),x.useEffect(()=>{y().catch(()=>{})},[y]);const T=x.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:G(a)}),((h=a.alertState)==null?void 0:h.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void I(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===C?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Y(){var c,u;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((u=r.data)==null?void 0:u.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",m=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(m==null?void 0:m.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=A.AdvancedModeToggle;exports.DashboardControlsSettings=A.DashboardControlsSettings;exports.DashboardFilterControlsButton=A.DashboardFilterControlsButton;exports.ExportNotificationItem=A.ExportNotificationItem;exports.ExportNotificationList=A.ExportNotificationList;exports.NotificationBell=A.NotificationBell;exports.UnsavedChangesAlert=A.UnsavedChangesAlert;exports.VisualEditingControls=A.VisualEditingControls;exports.useExportPolling=A.useExportPolling;exports.useExportRecovery=A.useExportRecovery;exports.usePristineSnapshotInitializer=A.usePristineSnapshotInitializer;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=K;exports.Combobox=W;exports.ScheduleDashboard=H;exports.TenantQuotaPage=Y;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-ZpmXTndp.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-DOofgrKU.js"),t=require("react/jsx-runtime"),x=require("react"),O=require("./chunks/resource-management-panel-DMHJbuqI.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const A=require("./chunks/dashboard-filter-controls-button-DXXJnFns.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(x);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=x.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),u=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var m;return(m=i==null?void 0:i.cards)==null?void 0:m.find(f=>(f==null?void 0:f.id)===s)});return{card:u,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:u,className:a,icon:i,showNone:m=!1}){const f=R.useRef(null),[D,C]=R.useState(!1),[b,j]=R.useState("100%"),y=m?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var h;return l?"Loading...":c?"Error":n?(h=r==null?void 0:r.find(S=>S.id===n))==null?void 0:h.name:`Select ${s}`}function T(h,S){o(S),C(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:C,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:I()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:u,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(h=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:h.name,onSelect:S=>T(S,h.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===h.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:h.name,children:h.name})]})},h.id))})]})]})})]})}function H({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=x.useState(!1),l=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function $(s,r){x.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function G(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function K({alertId:s,onBack:r}){var h,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:u}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,m]=x.useState([]),[f,D]=x.useState([]),[C,b]=x.useState(null),j=x.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=C&&N.some(B=>B.id===C)?C:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,C,o]),y=x.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??C;if(!p||!g||!s||!v){m([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();m(Array.isArray(N.attempts)?N.attempts:[])}else m([])}catch{m([])}},[s,n,C,o]),I=x.useCallback(async()=>{await u();const d=await j();await y(d)},[y,j,u]);x.useEffect(()=>{j().catch(()=>{})},[j]),x.useEffect(()=>{y().catch(()=>{})},[y]);const T=x.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:G(a)}),((h=a.alertState)==null?void 0:h.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void I(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===C?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Y(){var c,u;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((u=r.data)==null?void 0:u.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",m=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(m==null?void 0:m.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=A.AdvancedModeToggle;exports.DashboardControlsSettings=A.DashboardControlsSettings;exports.DashboardFilterControlsButton=A.DashboardFilterControlsButton;exports.ExportNotificationItem=A.ExportNotificationItem;exports.ExportNotificationList=A.ExportNotificationList;exports.NotificationBell=A.NotificationBell;exports.UnsavedChangesAlert=A.UnsavedChangesAlert;exports.VisualEditingControls=A.VisualEditingControls;exports.useExportPolling=A.useExportPolling;exports.useExportRecovery=A.useExportRecovery;exports.usePristineSnapshotInitializer=A.usePristineSnapshotInitializer;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=K;exports.Combobox=W;exports.ScheduleDashboard=H;exports.TenantQuotaPage=Y;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=$;
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { b as j, W as q, Y as H, Z as W, _ as G, $ as K, a0 as Y, a1 as X, a2 as J, a3 as Z, u as F, a4 as O, a5 as ee, P as ae, k as te, B as T, c as _, a6 as se, l as re, m as ne, n as ie, a7 as Q, a8 as oe, o as le, p as de, q as ce, r as ue, s as me, a9 as he, aa as pe, ab as fe, ac as E, ad as be, ae as ge } from "./chunks/index-BI7I65hX.js";
2
- import { aU as Me, aW as Fe, bC as Le, aY as Ue, aV as ze, ax as Be, aZ as Oe, D as je, av as We, ap as Qe, bI as Ve, b1 as $e, ah as qe, ak as He, ak as Ge, al as Ke, aw as Ye, a as Xe, bH as Je, as as Ze, bn as ea, bk as aa, bD as ta, b8 as sa, bp as ra, au as na, aq as ia, ar as oa, b2 as la, bL as da, bm as ca, bw as ua, bt as ma, bA as ha, bu as pa, bv as fa, bs as ba, br as ga, ba as xa, bG as Na, bF as va, bE as ya, b9 as Aa, bd as Ca, be as Sa, b7 as Da, at as Ea, b6 as Ta, a$ as wa, b0 as Ra, a_ as Ia, bb as _a, b5 as Pa, bK as ka, bJ as Ma, b4 as Fa, b3 as La, bz as Ua, bl as za, by as Ba, bf as Oa, bc as ja, bq as Wa, bo as Qa, bx as Va, bB as $a, aE as qa, aB as Ha, aN as Ga, aL as Ka, aT as Ya, aS as Xa, aK as Ja, aJ as Za, aI as et, aM as at, aX as tt, aG as st, aH as rt, aO as nt, aQ as it, ao as ot, aP as lt, az as dt, bh as ct, bj as ut, bi as mt, N as ht, an as pt, ag as ft, ay as bt, aA as gt, ai as xt, M as Nt, bg as vt, U as yt, aD as At, aC as Ct, aF as St, af as Dt, am as Et, aR as Tt, aj as wt } from "./chunks/index-BI7I65hX.js";
1
+ import { b as j, W as q, Y as H, Z as W, _ as G, $ as K, a0 as Y, a1 as X, a2 as J, a3 as Z, u as F, a4 as O, a5 as ee, P as ae, k as te, B as T, c as _, a6 as se, l as re, m as ne, n as ie, a7 as Q, a8 as oe, o as le, p as de, q as ce, r as ue, s as me, a9 as he, aa as pe, ab as fe, ac as E, ad as be, ae as ge } from "./chunks/index-BzQ2UBDI.js";
2
+ import { aU as Me, aW as Fe, bC as Le, aY as Ue, aV as ze, ax as Be, aZ as Oe, D as je, av as We, ap as Qe, bI as Ve, b1 as $e, ah as qe, ak as He, ak as Ge, al as Ke, aw as Ye, a as Xe, bH as Je, as as Ze, bn as ea, bk as aa, bD as ta, b8 as sa, bp as ra, au as na, aq as ia, ar as oa, b2 as la, bL as da, bm as ca, bw as ua, bt as ma, bA as ha, bu as pa, bv as fa, bs as ba, br as ga, ba as xa, bG as Na, bF as va, bE as ya, b9 as Aa, bd as Ca, be as Sa, b7 as Da, at as Ea, b6 as Ta, a$ as wa, b0 as Ra, a_ as Ia, bb as _a, b5 as Pa, bK as ka, bJ as Ma, b4 as Fa, b3 as La, bz as Ua, bl as za, by as Ba, bf as Oa, bc as ja, bq as Wa, bo as Qa, bx as Va, bB as $a, aE as qa, aB as Ha, aN as Ga, aL as Ka, aT as Ya, aS as Xa, aK as Ja, aJ as Za, aI as et, aM as at, aX as tt, aG as st, aH as rt, aO as nt, aQ as it, ao as ot, aP as lt, az as dt, bh as ct, bj as ut, bi as mt, N as ht, an as pt, ag as ft, ay as bt, aA as gt, ai as xt, M as Nt, bg as vt, U as yt, aD as At, aC as Ct, aF as St, af as Dt, am as Et, aR as Tt, aj as wt } from "./chunks/index-BzQ2UBDI.js";
3
3
  import { CONTROL_CARD_DEFAULT_VALUE as It, DEFAULT_CALENDAR_CONTEXT as _t, DEFAULT_SEMANTIC_DOMAIN_ACCESS as Pt, EMPTY_SELECTION as kt } from "./types/index.js";
4
- import { C as Ft, D as Lt } from "./chunks/dashboard-summary-settings-dialog-BJxnE9wH.js";
4
+ import { C as Ft, D as Lt } from "./chunks/dashboard-summary-settings-dialog-BzWnRhFU.js";
5
5
  import { jsx as e, jsxs as r, Fragment as xe } from "react/jsx-runtime";
6
6
  import * as R from "react";
7
7
  import { useMemo as V, useState as P, useEffect as L, useCallback as M } from "react";
8
- import { ResourceManagementPanel as zt } from "./chunks/resource-management-panel-BpGYomkJ.js";
8
+ import { ResourceManagementPanel as zt } from "./chunks/resource-management-panel-DNez0W3b.js";
9
9
  import { u as Ot } from "./chunks/use-debounced-dirty-check-BwAbnX_5.js";
10
10
  import "react-dom";
11
- import { A as Wt, D as Qt, c as Vt, a as $t, E as qt, N as Ht, U as Gt, V as Kt, u as Yt, b as Xt, d as Jt } from "./chunks/dashboard-filter-controls-button-Col3P9nH.js";
11
+ import { A as Wt, D as Qt, c as Vt, a as $t, E as qt, N as Ht, U as Gt, V as Kt, u as Yt, b as Xt, d as Jt } from "./chunks/dashboard-filter-controls-button-DuifafhB.js";
12
12
  import { n as es, s as as } from "./chunks/normalize-dashboard-for-dirty-check-5KpZN8xr.js";
13
13
  function De(a) {
14
14
  const { authToken: s, tokenProps: i } = j();