react-semaphor 0.1.293 → 0.1.295

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 (40) hide show
  1. package/dist/chunks/{braces-BwW2HFlB.js → braces-BdoTYzuj.js} +1 -1
  2. package/dist/chunks/{braces-C7GP95Fp.js → braces-DWldEFn5.js} +1 -1
  3. package/dist/chunks/{dashboard-controls-DgUc38Tn.js → dashboard-controls-B3lrnI_r.js} +9 -9
  4. package/dist/chunks/{dashboard-controls-jrkoCSY_.js → dashboard-controls-D7U6E1sB.js} +504 -472
  5. package/dist/chunks/dashboard-filter-controls-button-D0AsV28-.js +11 -0
  6. package/dist/chunks/dashboard-filter-controls-button-XwenlcXw.js +1152 -0
  7. package/dist/chunks/{dashboard-json-COjT-zjQ.js → dashboard-json-CU55qPXj.js} +1 -1
  8. package/dist/chunks/{dashboard-json-C0NiRL-A.js → dashboard-json-V6m6lJ_c.js} +1 -1
  9. package/dist/chunks/{dashboard-summary-settings-dialog-CGuFl7Xe.js → dashboard-summary-settings-dialog-0CIiWsKc.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-CXqaN_zj.js → dashboard-summary-settings-dialog-DRLPzp1P.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-ppdXk86H.js → edit-dashboard-visual-8ha6EM_g.js} +2205 -2147
  12. package/dist/chunks/edit-dashboard-visual-sSLAkmgf.js +183 -0
  13. package/dist/chunks/{index-9z-jMqN8.js → index-14M0TnH6.js} +35272 -33064
  14. package/dist/chunks/index-Ze8VskG1.js +1435 -0
  15. package/dist/chunks/{resource-management-panel-CP8cegZP.js → resource-management-panel-BL5-5ouC.js} +64 -64
  16. package/dist/chunks/{resource-management-panel-os6AuEKT.js → resource-management-panel-CcDAn86l.js} +1 -1
  17. package/dist/chunks/use-create-flow-overlay-state-BbQVNDCj.js +21 -0
  18. package/dist/chunks/{use-create-flow-overlay-state-wpuqRZX5.js → use-create-flow-overlay-state-D3PxfjYv.js} +430 -425
  19. package/dist/chunks/use-visual-utils-CdIOq4nt.js +337 -0
  20. package/dist/chunks/use-visual-utils-kh8p2QFm.js +1 -0
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +258 -253
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/dashboard.d.ts +65 -0
  29. package/dist/types/main.d.ts +79 -4
  30. package/dist/types/shared.d.ts +40 -0
  31. package/dist/types/surfboard.d.ts +65 -0
  32. package/dist/types/types.d.ts +65 -0
  33. package/package.json +1 -1
  34. package/dist/chunks/dashboard-filter-controls-button-B19UWmsK.js +0 -11
  35. package/dist/chunks/dashboard-filter-controls-button-DGH4DxJ8.js +0 -1109
  36. package/dist/chunks/edit-dashboard-visual-CDOz4LWO.js +0 -183
  37. package/dist/chunks/index-K25f5Rqr.js +0 -1435
  38. package/dist/chunks/use-create-flow-overlay-state-CecnMS_v.js +0 -21
  39. package/dist/chunks/use-visual-utils-BTfG-ppd.js +0 -1
  40. package/dist/chunks/use-visual-utils-BhRKGJql.js +0 -334
@@ -510,6 +510,12 @@ declare interface ColumnSettings {
510
510
  maxWidth?: number;
511
511
  textOverflow?: 'ellipsis' | 'wrap' | 'clip';
512
512
  textWrap: 'wrap' | 'nowrap';
513
+ /**
514
+ * Totals-row behavior for this column. Undefined = 'none'. The footer
515
+ * renders only when at least one visible column has a non-'none' behavior.
516
+ */
517
+ totalsBehavior?: TotalsBehavior;
518
+ totalsLabel?: string;
513
519
  numberFormat: {
514
520
  style: 'decimal' | 'currency' | 'percent' | 'scientific';
515
521
  currency: string;
@@ -522,6 +528,14 @@ declare interface ColumnSettings {
522
528
  dataBarColor: string;
523
529
  dataBarMinValue?: number;
524
530
  dataBarMaxValue?: number;
531
+ /**
532
+ * When true, render the cell bg with a heatmap intensity tint scaled
533
+ * across the column's value range. Composes with the existing text
534
+ * color/color-range logic (tint is bg only). `showDataBar` takes
535
+ * precedence when both are set — per the canonical design, a cell is
536
+ * either a data-bar or a heatmap, never both.
537
+ */
538
+ showHeatmap?: boolean;
525
539
  };
526
540
  dateFormat: {
527
541
  format: string;
@@ -1164,6 +1178,8 @@ declare interface FilterGroup {
1164
1178
  groups: FilterGroup[];
1165
1179
  }
1166
1180
 
1181
+ declare type FilterKind = 'field' | 'global-date';
1182
+
1167
1183
  /**
1168
1184
  * Filter layout settings for controlling how dashboard filters are displayed
1169
1185
  */
@@ -1255,6 +1271,7 @@ export declare type GetDashboardResponse = {
1255
1271
  filterValues?: TFilterValue[];
1256
1272
  defaultLensId?: string;
1257
1273
  assistantProfileId?: string;
1274
+ semanticExecutionPayload: SemanticExecutionPayload;
1258
1275
  };
1259
1276
 
1260
1277
  export declare type GetPluginsResponse = {
@@ -1592,6 +1609,22 @@ declare type RelativeDateFilter = {
1592
1609
  to: number;
1593
1610
  };
1594
1611
 
1612
+ declare type ResolvedPrimaryDateField = {
1613
+ sourceDataset: string;
1614
+ sourceField: string;
1615
+ name: string;
1616
+ qualifiedFieldName: string;
1617
+ qualifiedEntityName?: string;
1618
+ entityId: string;
1619
+ entityName: string;
1620
+ entityType: string;
1621
+ dataType: string;
1622
+ dateFormat?: string;
1623
+ customFormat?: string;
1624
+ defaultGranularity?: TimeGranularity;
1625
+ supportedGranularities?: TimeGranularity[];
1626
+ } | null;
1627
+
1595
1628
  /**
1596
1629
  * Parameters in JWT payload (after backend resolution).
1597
1630
  * The backend ALWAYS includes calendarContext, even if customer didn't provide it.
@@ -1632,6 +1665,14 @@ export declare type SemanticDomainAccessRequest = {
1632
1665
  domains?: string[];
1633
1666
  };
1634
1667
 
1668
+ declare type SemanticExecutionPayload = {
1669
+ domainsById: Record<string, {
1670
+ datasetsByName: Record<string, {
1671
+ primaryDateField: ResolvedPrimaryDateField;
1672
+ }>;
1673
+ }>;
1674
+ };
1675
+
1635
1676
  export declare type SensitivityPreset = 'low_noise' | 'standard' | 'early_warning';
1636
1677
 
1637
1678
  declare interface SortByField extends Field {
@@ -1710,6 +1751,14 @@ export declare type StyleProps = {
1710
1751
  };
1711
1752
  };
1712
1753
 
1754
+ /**
1755
+ * Row rhythm for the whole table. Authors pick one per card; undefined
1756
+ * falls back to 'compact' (the canonical default — dense scanning, matches
1757
+ * the Linear-style spec). Drives row padding, cell font size, and header
1758
+ * font size via a shared density spec in DataTable.
1759
+ */
1760
+ declare type TableDensity = 'compact' | 'comfortable' | 'spacious';
1761
+
1713
1762
  declare type TablePreferences = {
1714
1763
  columnSettingsMap?: ColumnSettingsMap;
1715
1764
  selectColumnVisible?: boolean;
@@ -1718,6 +1767,7 @@ declare type TablePreferences = {
1718
1767
  pageSize?: number;
1719
1768
  enableDevModePagination?: boolean;
1720
1769
  forceClientPagination?: boolean;
1770
+ density?: TableDensity;
1721
1771
  };
1722
1772
 
1723
1773
  /**
@@ -2246,6 +2296,7 @@ export declare type TEvent = {
2246
2296
  };
2247
2297
 
2248
2298
  declare type TFilter = {
2299
+ kind?: FilterKind;
2249
2300
  type?: 'single' | 'multiple';
2250
2301
  uiType?: 'radio' | 'dropdown' | 'tabs';
2251
2302
  dateSelectionMode?: DateSelectionMode;
@@ -2670,6 +2721,20 @@ export declare type TokenSecurityPolicy = {
2670
2721
  };
2671
2722
  };
2672
2723
 
2724
+ /**
2725
+ * Per-column contribution to the table-level totals row (`<tfoot>`).
2726
+ * Additive and optional — omitting it keeps the cell empty in the footer,
2727
+ * matching existing behavior when a totals row is not needed.
2728
+ *
2729
+ * - 'sum' → aggregate the column across the full dataset
2730
+ * - 'avg' → arithmetic mean across the full dataset
2731
+ * - 'count' → non-null count across the full dataset
2732
+ * - 'label' → render `totalsLabel` (or 'Total') as static text — typically
2733
+ * on the first column so the footer reads as a labeled row
2734
+ * - 'none' → blank cell in the footer
2735
+ */
2736
+ declare type TotalsBehavior = 'sum' | 'avg' | 'count' | 'label' | 'none';
2737
+
2673
2738
  /** Point style options supported by Chart.js */
2674
2739
  export declare type TPointStyle = 'circle' | 'cross' | 'crossRot' | 'dash' | 'line' | 'rect' | 'rectRounded' | 'rectRot' | 'star' | 'triangle';
2675
2740
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.293",
8
+ "version": "0.1.295",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,11 +0,0 @@
1
- "use strict";const g=require("react"),e=require("./index-K25f5Rqr.js"),t=require("react/jsx-runtime"),I=require("./use-create-flow-overlay-state-CecnMS_v.js"),M=require("./use-visual-utils-BTfG-ppd.js"),L=require("./date-formatter-CqXdM6JO.js");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const T=e.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const P=e.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]),V=1e4,z=15e3,O=3e4,R=3e4,H=12e4,k=2*60*60*1e3;function $(s){const r=Date.now()-s.getTime();return r<R?V:r<H?z:O}function _(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),m=e.useExportStore(p=>p.activeExports),[d,l]=g.useState(typeof document<"u"?!document.hidden:!0),h=g.useRef(null),o=g.useRef(!1),c=g.useRef(void 0),u=r==null?void 0:r.apiServiceUrl,n=s==null?void 0:s.accessToken,f=g.useCallback(()=>{const p=e.useExportStore.getState().activeExports;return Array.from(p.values()).filter(C=>e.isExportInProgress(C.status))},[]);g.useEffect(()=>{if(typeof document>"u")return;const p=()=>{l(!document.hidden)};return document.addEventListener("visibilitychange",p),()=>{document.removeEventListener("visibilitychange",p)}},[]);const b=g.useCallback(async()=>{if(!u||!n){o.current=!1;return}const p=f();if(p.length===0){o.current=!1;return}const C=Date.now(),D=p.filter(a=>C-a.startedAt.getTime()>k);if(D.length>0){const{updateExport:a}=e.useExportStore.getState().actions;for(const i of D)a(i.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const x=p.filter(a=>C-a.startedAt.getTime()<=k);if(x.length===0){o.current=!1;return}const j=await Promise.allSettled(x.map(async a=>{try{const i=await e.getExportStatus(u,n,a.id);let v;if(i.status==="completed")try{v=await e.getDownloadUrl(u,n,a.id)}catch(A){console.error(`[useExportPolling] Failed to get download URL for ${a.id}:`,A)}return{id:a.id,status:i.status,progress:i.progress,completedChunks:i.completedChunks,completedAt:i.completedAt?new Date(i.completedAt):void 0,lastUpdatedAt:new Date,fileSize:i.fileSize,error:i.error,downloadUrl:v}}catch(i){return console.error(`[useExportPolling] Failed to poll export ${a.id}:`,i),null}})),{updateExport:E}=e.useExportStore.getState().actions;for(const a of j)a.status==="fulfilled"&&a.value&&E(a.value.id,a.value);const w=f();if(w.length>0&&!document.hidden){const a=w.reduce((v,A)=>A.startedAt<v?A.startedAt:v,w[0].startedAt),i=$(a);h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{var v;(v=c.current)==null||v.call(c)},i)}else o.current=!1},[u,n,f]);return g.useEffect(()=>{c.current=b},[b]),g.useEffect(()=>{var C;f().length>0&&d&&!o.current&&(o.current=!0,(C=c.current)==null||C.call(c))},[m,d,f]),g.useEffect(()=>{var C;const p=f();d&&p.length>0&&!o.current&&(o.current=!0,(C=c.current)==null||C.call(c))},[d,f]),g.useEffect(()=>{!d&&h.current&&(clearTimeout(h.current),h.current=null,o.current=!1)},[d]),g.useEffect(()=>()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),{isPolling:o.current,isTabVisible:d,inProgressCount:f().length}}function q(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),m=e.useExportStore(c=>c.activeExports),{addExport:d}=e.useExportActions(),l=g.useRef(!1),h=r==null?void 0:r.apiServiceUrl,o=s==null?void 0:s.accessToken;g.useEffect(()=>{if(l.current||!h||!o)return;(async()=>{try{const{exports:u}=await e.getExports(h,o,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const n of u){if(m.has(n.id))continue;const f=n.totalChunks?Math.round(n.completedChunks/n.totalChunks*100):0;let b;if(n.status==="completed")try{b=await e.getDownloadUrl(h,o,n.id)}catch(C){console.error(`[useExportRecovery] Failed to get download URL for ${n.id}:`,C)}const p={id:n.id,status:n.status,progress:f,title:X(n),totalRows:n.totalRows,totalChunks:n.totalChunks,completedChunks:n.completedChunks,startedAt:new Date(n.createdAt),lastUpdatedAt:new Date,completedAt:n.completedAt?new Date(n.completedAt):void 0,fileSize:n.fileSize,error:n.error,expiresAt:new Date(n.expiresAt),downloadUrl:b};d(p)}l.current=!0}catch(u){console.error("[useExportRecovery] Failed to recover exports:",u),l.current=!0}})()},[h,o,d,m])}function X(s){return s.title?s.title:e.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function G({open:s,onOpenChange:r,isLibraryVisual:m,currentVisualName:d,isSaving:l=!1,destinationMode:h="both",onConfirm:o}){const[c,u]=g.useState(m&&d?`Copy of ${d}`:d||""),[n,f]=g.useState("");g.useEffect(()=>{s&&(u(m&&d?`Copy of ${d}`:d||""),f(""))},[s,m,d]);const b=!!c.trim(),p=h==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:h==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},C=()=>{!b||l||o({name:c.trim(),description:n.trim()||void 0,saveToLibrary:p.saveToLibrary,saveToCurrentDashboard:p.saveToCurrentDashboard})};return t.jsx(e.Dialog,{open:s,onOpenChange:r,children:t.jsxs(e.DialogContent,{className:"sm:max-w-[500px]",children:[t.jsxs(e.DialogHeader,{children:[t.jsxs(e.DialogTitle,{className:"flex items-center gap-2",children:[t.jsx("span",{children:"Save Visual As"}),p.badgeType!=="local"&&t.jsx(I.VisualBadge,{type:p.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),t.jsx(e.DialogDescription,{children:p.description})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"name",children:"Name"}),t.jsx(e.Input,{id:"name",value:c,onChange:D=>u(D.target.value),placeholder:"Enter visual name",disabled:l})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),t.jsx(e.Textarea,{id:"description",value:n,onChange:D=>f(D.target.value),placeholder:"Enter visual description",rows:3,disabled:l})]})]}),t.jsxs(e.DialogFooter,{children:[t.jsx(e.Button,{variant:"outline",onClick:()=>r(!1),disabled:l,children:"Cancel"}),t.jsxs(e.Button,{onClick:C,disabled:!b||l,children:[l&&t.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),p.actionLabel]})]})]})})}function K(){const[s,r]=g.useState(!1),[m,d]=g.useState(!1),[l,h]=g.useState(null),o=e.useEditorStore(i=>i.frame),c=e.useEditorStore(i=>i.card),u=e.useSelectedVisual(),n=e.useDashboardStore(i=>i.selectedSheetId),f=e.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),{getUpdatedFrame:b}=M.useVisualUtils(),{selectVisual:p}=e.useManagementActions(),{addFrame:C,setSelectedFrameId:D,setIsVisualEditing:x}=e.useDashboardActions(),j=!!(o!=null&&o.visualId),E=(()=>{var i,v;return((i=o==null?void 0:o.cards)==null?void 0:i.length)===1&&((v=o.cards[0])!=null&&v.title)?o.cards[0].title:u!=null&&u.title?u.title:(c==null?void 0:c.title)||"Untitled Visual"})(),w=e.useCreateVisualWithFrame(i=>{if(i!=null&&i.id){if(p(i),m&&l&&n){const v={...l,id:e.v4(),visualId:i.id};C(n,v,"end"),D(v.id),d(!1),h(null),x(!1)}f(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async i=>{if(!n){e.ue.error("No sheet selected");return}const v=b(),A=e.getDynamicFrameSaveIssue(v);if(A){e.ue.error(A);return}const N=v.cards.length===1?{...v,cards:v.cards.map(y=>({...y,title:i.name}))}:v;if(i.saveToLibrary){d(i.saveToCurrentDashboard),h(N);const y={title:i.name,description:i.description,frameObject:N,isPrivate:!1};w.mutate(y)}else if(i.saveToCurrentDashboard){const y={...N,id:e.v4(),visualId:void 0};C(n,y,"end"),D(y.id),e.ue.success("Visual saved to dashboard"),r(!1),x(!1)}},isLibraryVisual:j,currentVisualName:E,isSaving:w.isPending}}function Q(s={}){const r=e.useEditorStore(S=>S.frame),m=e.useManagementStore(S=>S.selectedVisual),d=e.useDashboardStore(S=>S.selectedFrameId),l=e.useDashboardStore(S=>S.selectedSheetId),{setIsVisualEditing:h,updateFrame:o}=e.useDashboardActions(),[c,u]=g.useState(!1),[n,f]=g.useState("both"),b=!!(r!=null&&r.visualId||m!=null&&m.id),p=!!(r!=null&&r.visualId&&d),C=b&&!p,{saveAsDialogOpen:D,setSaveAsDialogOpen:x,handleSaveAs:j,isLibraryVisual:E,currentVisualName:w,isSaving:a}=K(),{getUpdatedFrame:i}=M.useVisualUtils(),v=()=>{if(!l){e.ue.error("No sheet selected");return}if(c)return;u(!0);const S=i(),N=e.getDynamicFrameSaveIssue(S);if(N){u(!1),e.ue.error(N);return}const y={...S,visualId:void 0};o(l,y),setTimeout(()=>{u(!1),e.ue.success("Changes applied. Visual is now local to this dashboard"),h(!1)},300)},A=S=>{f(S),x(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-[5px]",children:[!b&&t.jsx(I.EditorAcceptButton,{className:"rounded-none",variant:"default"}),b&&C&&t.jsx(I.VisualSaveButton,{className:"rounded-none",variant:"default"}),b&&p&&t.jsx(I.VisualSaveAndApplyButton,{className:"rounded-none"}),t.jsxs(e.DropdownMenu,{modal:!1,children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"default",size:"xs",className:"w-7 rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:a||c,children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-[6px] border border-border/60 p-1 shadow-sm",children:[p&&t.jsxs(t.Fragment,{children:[t.jsxs(e.DropdownMenuItem,{onClick:v,disabled:c,children:[t.jsx(e.Check,{className:"h-3.5 w-3.5"}),c?"Applying...":"Apply Locally"]}),t.jsx(e.DropdownMenuSeparator,{})]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("local"),disabled:a,children:[t.jsx(e.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("library"),disabled:a,children:[t.jsx(I.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("both"),disabled:a,children:[t.jsx(I.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),t.jsx(I.EditorCancelButton,{}),t.jsx(G,{open:D,onOpenChange:S=>{a||x(S)},isLibraryVisual:E,currentVisualName:w,isSaving:a,destinationMode:n,onConfirm:j})]})}function W({className:s}){const r=e.useEditorStore(u=>u.isDevMode),m=e.useDashboardStore(u=>u.isVisualEditing),{setIsDevMode:d}=e.useEditorActions(),{config:l}=g.useContext(e.SemaphorContext).tokenProps,h=(l==null?void 0:l.showAdvancedMode)!==!1;if(!m||!h)return null;const o="h-full rounded-none border-0 bg-transparent px-2.5 shadow-none text-muted-foreground hover:bg-accent/50 hover:text-foreground",c="bg-muted text-foreground hover:bg-muted";return t.jsxs("div",{role:"radiogroup","aria-label":"Editor mode",className:e.cn("inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-input bg-background",s),children:[t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":!r,className:e.cn(o,!r&&c),onClick:()=>d(!1),children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Drag & drop"]}),t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":r,className:e.cn(o,"border-l border-border/60",r&&c),onClick:()=>d(!0),children:[t.jsx(e.CodeXml,{className:"h-3.5 w-3.5"}),"SQL"]})]})}function Y({open:s,onOpenChange:r,onSave:m,onDiscard:d,isSaving:l,title:h="Unsaved changes",description:o="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:c="Cancel",discardLabel:u="Discard",saveLabel:n="Save"}){const f=b=>{!b&&l||r(b)};return t.jsx(e.AlertDialog,{open:s,onOpenChange:f,children:t.jsxs(e.AlertDialogContent,{children:[t.jsxs(e.AlertDialogHeader,{children:[t.jsx(e.AlertDialogTitle,{children:h}),t.jsx(e.AlertDialogDescription,{children:o})]}),t.jsxs(e.AlertDialogFooter,{children:[t.jsx(e.Button,{type:"button",size:"xs",onClick:d,disabled:l,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:u}),t.jsx(e.AlertDialogCancel,{disabled:l,children:c}),t.jsx(e.Button,{type:"button",size:"xs",onClick:m,disabled:l,children:l?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):n})]})]})})}function Z(s,r,m,d){g.useEffect(()=>{s&&!m&&r&&d(e.cloneDeep(r))},[s,m,r,d])}function B({export:s,onRemove:r}){const m=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},d=c=>{c.stopPropagation(),r==null||r(s.id)},l=()=>{switch(s.status){case"completed":return t.jsx(e.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return t.jsx(I.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return t.jsx(e.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},h=e.isExportInProgress(s.status),o=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return t.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[t.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[l(),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"•"}),t.jsx("span",{children:e.formatFileSize(s.fileSize)})]})]}),h&&t.jsx("div",{className:"text-xs text-muted-foreground",children:o}),s.status==="failed"&&t.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),t.jsx(e.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:d,"aria-label":"Remove notification",children:t.jsx(e.X,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:L.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&t.jsxs(e.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:m,children:[t.jsx(e.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),h&&t.jsxs("div",{children:[t.jsx(e.Progress,{value:s.progress,className:"h-1.5"}),t.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&t.jsx("span",{className:"text-xs text-muted-foreground",children:L.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function U(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),m=e.useExportStore(x=>x.activeExports),{clearCompleted:d,removeExport:l,updateExport:h}=e.useExportActions(),[o,c]=g.useState(!1),[u,n]=g.useState(!1),f=Array.from(m.values()).sort((x,j)=>j.startedAt.getTime()-x.startedAt.getTime()),b=f.some(x=>x.status==="completed"||x.status==="failed"),p=g.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!x||!j)){c(!0);try{const E=Array.from(m.values());await Promise.all(E.map(async w=>{try{const a=await e.getExportStatus(x,j,w.id);let i;if(a.status==="completed")try{i=await e.getDownloadUrl(x,j,w.id)}catch(v){console.error(`Failed to get download URL for ${w.id}:`,v)}h(w.id,{status:a.status,progress:a.progress,completedChunks:a.completedChunks,completedAt:a.completedAt?new Date(a.completedAt):void 0,lastUpdatedAt:new Date,fileSize:a.fileSize,error:a.error,downloadUrl:i})}catch(a){console.error(`Failed to refresh export ${w.id}:`,a)}}))}finally{c(!1)}}},[m,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,h]),C=g.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!x||!j){d();return}n(!0);try{const E=f.filter(a=>a.status==="completed"||a.status==="failed"),w=await Promise.allSettled(E.map(async a=>(await e.cancelExport(x,j,a.id),a.id)));for(const a of w)a.status==="fulfilled"?l(a.value):console.error("Failed to delete export:",a.reason)}finally{n(!1)}},[f,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,d,l]),D=g.useCallback(async x=>{const j=r==null?void 0:r.apiServiceUrl,E=s==null?void 0:s.accessToken;if(j&&E)try{await e.cancelExport(j,E,x),l(x);return}catch(w){console.error(`Failed to cancel export ${x}:`,w)}l(x)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,l]);return f.length===0?t.jsxs("div",{className:"p-6 text-center",children:[t.jsx(T,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("h4",{className:"font-semibold",children:"Exports"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:p,disabled:o,title:"Refresh status",children:t.jsx(e.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),b&&t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:C,disabled:u,children:u?"Clearing...":"Clear all"})]})]}),t.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:t.jsx("div",{className:"divide-y",children:f.map(x=>t.jsx(B,{export:x,onRemove:D},x.id))})})]})}function J({variant:s}){const r=e.useExportStore(u=>u.activeExports),m=e.useInProgressExportsCount(),d=r.size>0,l=Array.from(r.values()).some(u=>u.status==="completed"||u.status==="failed"),o=m>0?m>9?"9+":String(m):null,c=d;return t.jsxs(e.Popover,{children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{variant:s??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[t.jsx(e.Bell,{className:"h-3.5 w-3.5"}),c&&t.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${o?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:o})]})}),t.jsx(e.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:t.jsx(U,{})})]})}function ee(s){if(s)return{renamed:s.type==="rename"?{oldId:s.oldId,newId:s.newId}:void 0,removedControlId:s.type==="remove"?s.controlId:void 0,cardBindingsById:s.type==="add"||s.type==="update"?s.cardBindingsById:void 0,affectedBindingControlIds:s.type==="add"||s.type==="update"?s.affectedBindingControlIds:void 0}}function te({open:s,onOpenChange:r,trigger:m,showTrigger:d=!0,initialMode:l="manage"}){const h=l==="create",{forceClose:o,handleOpenChange:c,isCreateFlowActive:u,preventPassiveDismissDuringCreate:n,resolvedOpen:f,setIsCreateFlowActive:b}=I.useCreateFlowOverlayState({open:s,onOpenChange:r,initialCreateFlowActive:l==="create",dismissMode:d?"passive":"explicit-only"}),p=e.useDashboardStore(N=>N.dashboard),{setDashboardControlsModel:C}=e.useDashboardActions(),{participants:D}=e.useDashboardStructuralParticipants(e.getDashboardCards(p)),x=Array.from(new Map(D.flatMap(N=>N.fieldChoices.map(y=>{var F;return[y.value,{option:y,target:(F=N.fieldTargetMap)==null?void 0:F[y.value]}]}))).values()),j=Array.from(new Map(D.flatMap(N=>N.metricChoices.map(y=>{var F;return[y.value,{option:y,target:(F=N.metricTargetMap)==null?void 0:F[y.value]}]}))).values()),E=e.collectDashboardControlIds({...p||{},controls:[]}),w=e.buildDashboardStructuralParticipantIdsByControlId(p),a=(N,y,F)=>{C(N,y,ee(F))},i=g.useCallback(()=>{if(h){o();return}b(!1)},[h,o,b]),v=t.jsx(I.ControlDefinitionListEditor,{scope:"dashboard",controls:p.controls||[],reservedControlIds:E,defaultValues:p.defaultControlValues||{},usageByControlId:e.buildDashboardControlUsageById(p),availableFieldChoices:x,availableMetricChoices:j,structuralParticipants:D,structuralParticipantIdsByControlId:w,initialCreateFlow:l==="create",onCreateFlowActiveChange:b,onCreateFlowComplete:i,onChange:a,emptyMessage:"No dashboard controls yet."}),A=u?"Add dashboard control":"Dashboard Controls",S=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),v]});return d?t.jsxs(e.Popover,{open:f,onOpenChange:c,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:m||t.jsxs(e.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[t.jsx(e.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),t.jsx(e.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:n,onPointerDownOutside:n,children:S})]}):t.jsx(e.Dialog,{open:f,onOpenChange:c,children:t.jsxs(e.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:n,onPointerDownOutside:n,children:[t.jsxs(e.DialogHeader,{className:u?"space-y-0":void 0,children:[t.jsx(e.DialogTitle,{className:"text-[15px]",children:A}),t.jsx(e.DialogDescription,{className:u?"sr-only":"text-[13px]",children:u?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:v})]})})}function se({showFilters:s,onToggleFilters:r,onAddFilter:m,onAddControl:d,onManageControls:l,size:h="default",className:o,primaryButtonClassName:c,secondaryButtonClassName:u,dropdownContentClassName:n}){const f=h==="toolbar";return t.jsxs("div",{className:e.cn("relative inline-flex items-stretch overflow-hidden rounded-[5px] border border-input bg-background",f?"h-8":"h-7",o),children:[t.jsxs(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",c),onClick:r,children:[s?t.jsx(P,{className:"h-3.5 w-3.5"}):t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Filter"]}),t.jsxs(e.DropdownMenu,{children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",u),"aria-label":"Filter and control actions",children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"start",className:e.cn("min-w-[180px] rounded-[6px] border border-border/60 p-1 shadow-sm",n),children:[t.jsxs(e.DropdownMenuItem,{onSelect:m,children:[t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Add filter"]}),t.jsxs(e.DropdownMenuItem,{onSelect:d,children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Add control"]}),t.jsxs(e.DropdownMenuItem,{onSelect:l,children:[t.jsx(e.Pencil,{className:"h-3.5 w-3.5"}),"Manage controls"]})]})]})]})}exports.AdvancedModeToggle=W;exports.DashboardControlsSettings=te;exports.DashboardFilterControlsButton=se;exports.ExportNotificationItem=B;exports.ExportNotificationList=U;exports.NotificationBell=J;exports.UnsavedChangesAlert=Y;exports.VisualEditingControls=Q;exports.useExportPolling=_;exports.useExportRecovery=q;exports.usePristineSnapshotInitializer=Z;