react-semaphor 0.1.295 → 0.1.296

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-BdoTYzuj.js → braces-BNXseceK.js} +1 -1
  2. package/dist/chunks/{braces-DWldEFn5.js → braces-DVrX_3Q_.js} +1 -1
  3. package/dist/chunks/dashboard-controls-CKKZcVA5.js +2219 -0
  4. package/dist/chunks/dashboard-controls-DS2xJxHU.js +47 -0
  5. package/dist/chunks/dashboard-filter-controls-button-nqfmscB7.js +11 -0
  6. package/dist/chunks/{dashboard-filter-controls-button-XwenlcXw.js → dashboard-filter-controls-button-xPaIlNHP.js} +501 -495
  7. package/dist/chunks/{dashboard-json-CU55qPXj.js → dashboard-json-cuj9vYY9.js} +1 -1
  8. package/dist/chunks/{dashboard-json-V6m6lJ_c.js → dashboard-json-ovQyHWw6.js} +1 -1
  9. package/dist/chunks/{dashboard-summary-settings-dialog-DRLPzp1P.js → dashboard-summary-settings-dialog-BUg3Qyhh.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-0CIiWsKc.js → dashboard-summary-settings-dialog-DF076HeJ.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-8ha6EM_g.js → edit-dashboard-visual-32TAM00c.js} +5331 -5303
  12. package/dist/chunks/edit-dashboard-visual-BtiMcO-L.js +183 -0
  13. package/dist/chunks/{index-14M0TnH6.js → index-BDeJH9hO.js} +103265 -88338
  14. package/dist/chunks/index-Dbrs96G8.js +1533 -0
  15. package/dist/chunks/{resource-management-panel-CcDAn86l.js → resource-management-panel-2qcXsKwg.js} +2 -2
  16. package/dist/chunks/{resource-management-panel-BL5-5ouC.js → resource-management-panel-C4qoxy_g.js} +31 -30
  17. package/dist/chunks/use-create-flow-overlay-state-BMD3YRzU.js +21 -0
  18. package/dist/chunks/{use-create-flow-overlay-state-D3PxfjYv.js → use-create-flow-overlay-state-CHeppRNE.js} +572 -568
  19. package/dist/chunks/{use-visual-utils-CdIOq4nt.js → use-visual-utils-BIHLaVwh.js} +70 -68
  20. package/dist/chunks/use-visual-utils-dOYWf6nM.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 +113 -112
  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 +235 -1
  29. package/dist/types/main.d.ts +288 -1
  30. package/dist/types/shared.d.ts +204 -1
  31. package/dist/types/surfboard.d.ts +235 -1
  32. package/dist/types/types.d.ts +235 -1
  33. package/package.json +7 -1
  34. package/dist/chunks/dashboard-controls-B3lrnI_r.js +0 -47
  35. package/dist/chunks/dashboard-controls-D7U6E1sB.js +0 -2014
  36. package/dist/chunks/dashboard-filter-controls-button-D0AsV28-.js +0 -11
  37. package/dist/chunks/edit-dashboard-visual-sSLAkmgf.js +0 -183
  38. package/dist/chunks/index-Ze8VskG1.js +0 -1435
  39. package/dist/chunks/use-create-flow-overlay-state-BbQVNDCj.js +0 -21
  40. package/dist/chunks/use-visual-utils-kh8p2QFm.js +0 -1
@@ -722,6 +722,18 @@ export declare type DashboardProps = {
722
722
  cardControlDefinitions?: ControlDefinition[];
723
723
  controlBindings?: ControlBinding[];
724
724
  };
725
+ /**
726
+ * Document-local runtime values for print/render entry points. Values are
727
+ * keyed by document input id and are intentionally separate from dashboard
728
+ * filters/controls.
729
+ */
730
+ documentInputValues?: DocumentInputRuntimeValues;
731
+ /**
732
+ * Render target for print entry points. Generic dashboard PDF exports also
733
+ * use cardDisplay.mode="print"; document-specific print handling must only
734
+ * run when this is explicitly "document".
735
+ */
736
+ renderMode?: 'dashboard' | 'document';
725
737
  customStyle?: TStyle;
726
738
  currentTheme?: Theme;
727
739
  version?: string;
@@ -877,6 +889,215 @@ declare type Dialect = 'mysql' | 'postgres' | 'bigquery' | 'redshift' | 'snowfla
877
889
 
878
890
  export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
879
891
 
892
+ export declare type DocumentChartSection = {
893
+ id: string;
894
+ type: 'chart';
895
+ title?: string;
896
+ card: TCard;
897
+ heightPx: number;
898
+ };
899
+
900
+ export declare type DocumentControlInputDefinition = DocumentInputBase & {
901
+ kind: 'control';
902
+ control: ControlDefinition;
903
+ exports?: DocumentInputExportKey[];
904
+ };
905
+
906
+ export declare type DocumentDefinition = {
907
+ version: 1;
908
+ page: DocumentPageSetup;
909
+ runtime?: DocumentRuntimeSettings;
910
+ inputs?: DocumentInputDefinition[];
911
+ defaultInputValues?: Record<string, unknown>;
912
+ header?: DocumentHeaderRegion;
913
+ footer?: DocumentFooterRegion;
914
+ sections: DocumentSection[];
915
+ theme?: DocumentTheme;
916
+ };
917
+
918
+ export declare type DocumentFilterInputDefinition = DocumentInputBase & {
919
+ kind: 'filter';
920
+ filter: TFilter;
921
+ exports?: DocumentInputExportKey[];
922
+ };
923
+
924
+ export declare type DocumentFooterRegion = DocumentRegionBase & {
925
+ region: 'footer';
926
+ layout: {
927
+ type: 'preset';
928
+ preset: 'mvp_footer';
929
+ };
930
+ };
931
+
932
+ export declare type DocumentHeaderRegion = DocumentRegionBase & {
933
+ region: 'header';
934
+ layout: {
935
+ type: 'preset';
936
+ preset: 'mvp_header';
937
+ };
938
+ };
939
+
940
+ export declare type DocumentImageRegionBlock = DocumentRegionBlockBase & {
941
+ type: 'image';
942
+ role?: 'logo';
943
+ src: string;
944
+ alt?: string;
945
+ widthPx?: number;
946
+ };
947
+
948
+ export declare type DocumentInputBase = {
949
+ id: string;
950
+ label: string;
951
+ variableName: string;
952
+ requiredAtExecution: boolean;
953
+ documentPlacement?: 'input_bar';
954
+ description?: string;
955
+ };
956
+
957
+ export declare type DocumentInputDefinition = DocumentFilterInputDefinition | DocumentControlInputDefinition;
958
+
959
+ export declare type DocumentInputExportKey = 'label' | 'value' | 'start' | 'end' | 'range';
960
+
961
+ export declare type DocumentInputRuntimeValues = {
962
+ sheetId?: string;
963
+ filterValuesByInputId?: Record<string, TFilterValue | undefined>;
964
+ controlValuesByInputId?: Record<string, unknown>;
965
+ generatedAt?: string;
966
+ };
967
+
968
+ export declare type DocumentPageBreakSection = {
969
+ id: string;
970
+ type: 'page_break';
971
+ };
972
+
973
+ export declare type DocumentPageSetup = {
974
+ size: 'letter' | 'a4';
975
+ orientation: 'portrait' | 'landscape';
976
+ margins: {
977
+ top: number;
978
+ right: number;
979
+ bottom: number;
980
+ left: number;
981
+ unit: 'in' | 'mm';
982
+ };
983
+ };
984
+
985
+ export declare type DocumentRegion = DocumentHeaderRegion | DocumentFooterRegion;
986
+
987
+ export declare type DocumentRegionBase = {
988
+ enabled: boolean;
989
+ heightPx?: number;
990
+ layout: DocumentRegionLayout;
991
+ blocks: DocumentRegionBlock[];
992
+ };
993
+
994
+ export declare type DocumentRegionBlock = DocumentTextRegionBlock | DocumentImageRegionBlock;
995
+
996
+ export declare type DocumentRegionBlockBase = {
997
+ id: string;
998
+ area?: 'left' | 'center' | 'right' | 'title' | 'metadata' | 'note' | 'pageInfo';
999
+ };
1000
+
1001
+ export declare type DocumentRegionLayout = {
1002
+ type: 'preset';
1003
+ preset: 'mvp_header' | 'mvp_footer';
1004
+ };
1005
+
1006
+ export declare type DocumentRuntimeSettings = {
1007
+ generatedAtFormat?: string;
1008
+ };
1009
+
1010
+ export declare type DocumentSection = DocumentTextSection | DocumentTableSection | DocumentChartSection | DocumentSpacerSection | DocumentPageBreakSection;
1011
+
1012
+ export declare type DocumentSpacerSection = {
1013
+ id: string;
1014
+ type: 'spacer';
1015
+ heightPx: number;
1016
+ };
1017
+
1018
+ export declare type DocumentTableDensity = 'comfortable' | 'standard' | 'compact' | 'dense';
1019
+
1020
+ export declare type DocumentTableGridLines = 'none' | 'outer' | 'inner' | 'horizontal' | 'vertical' | 'top' | 'right' | 'bottom' | 'left' | 'full';
1021
+
1022
+ export declare type DocumentTableHeaderStyle = 'plain' | 'filled' | 'accent';
1023
+
1024
+ export declare type DocumentTableSection = {
1025
+ id: string;
1026
+ type: 'table';
1027
+ title?: string;
1028
+ card: TCard;
1029
+ table: {
1030
+ totalsRow?: boolean;
1031
+ columnFormatting?: Record<string, unknown>;
1032
+ repeatHeaderOnPageBreak?: boolean;
1033
+ rowHeightPx?: number;
1034
+ style?: DocumentTableStyle;
1035
+ };
1036
+ };
1037
+
1038
+ export declare type DocumentTableStyle = {
1039
+ density?: DocumentTableDensity;
1040
+ headerStyle?: DocumentTableHeaderStyle;
1041
+ headerBackgroundColor?: string;
1042
+ headerTextColor?: string;
1043
+ stripedRows?: boolean;
1044
+ gridLines?: DocumentTableGridLines;
1045
+ wrapText?: boolean;
1046
+ };
1047
+
1048
+ export declare type DocumentTextContent = DocumentTextNode[];
1049
+
1050
+ export declare type DocumentTextInlineFormat = {
1051
+ bold?: boolean;
1052
+ italic?: boolean;
1053
+ underline?: boolean;
1054
+ };
1055
+
1056
+ export declare type DocumentTextNode = {
1057
+ type: 'text';
1058
+ value: string;
1059
+ format?: DocumentTextInlineFormat;
1060
+ } | {
1061
+ type: 'variable';
1062
+ ref: DocumentVariableRef;
1063
+ format?: DocumentTextInlineFormat;
1064
+ };
1065
+
1066
+ export declare type DocumentTextRegionBlock = DocumentRegionBlockBase & {
1067
+ type: 'text';
1068
+ role?: 'title' | 'metadata' | 'note' | 'pageInfo';
1069
+ content: DocumentTextContent;
1070
+ style?: DocumentTextStyle;
1071
+ };
1072
+
1073
+ export declare type DocumentTextSection = {
1074
+ id: string;
1075
+ type: 'text';
1076
+ content: DocumentTextContent;
1077
+ style?: DocumentTextStyle;
1078
+ };
1079
+
1080
+ export declare type DocumentTextStyle = {
1081
+ fontSize?: number;
1082
+ fontWeight?: 'normal' | 'medium' | 'semibold' | 'bold';
1083
+ color?: string;
1084
+ align?: 'left' | 'center' | 'right';
1085
+ };
1086
+
1087
+ export declare type DocumentTheme = {
1088
+ fontFamily?: string;
1089
+ primaryColor?: string;
1090
+ };
1091
+
1092
+ export declare type DocumentVariableRef = {
1093
+ source: 'input';
1094
+ inputId: string;
1095
+ export: DocumentInputExportKey;
1096
+ } | {
1097
+ source: 'documentMeta';
1098
+ key: 'generatedAt' | 'pageNumber' | 'pageCount';
1099
+ };
1100
+
880
1101
  declare interface DrillDownInteraction {
881
1102
  mode: 'drillDown';
882
1103
  /**
@@ -1609,6 +1830,16 @@ declare type RelativeDateFilter = {
1609
1830
  to: number;
1610
1831
  };
1611
1832
 
1833
+ export declare type ResolvedDocumentInput = {
1834
+ inputId: string;
1835
+ variableName: string;
1836
+ rawValue: unknown;
1837
+ displayValue: string;
1838
+ filterValues?: TFilterValue[];
1839
+ controlValue?: unknown;
1840
+ exports: Record<string, string | number | boolean | null>;
1841
+ };
1842
+
1612
1843
  declare type ResolvedPrimaryDateField = {
1613
1844
  sourceDataset: string;
1614
1845
  sourceField: string;
@@ -1757,7 +1988,7 @@ export declare type StyleProps = {
1757
1988
  * the Linear-style spec). Drives row padding, cell font size, and header
1758
1989
  * font size via a shared density spec in DataTable.
1759
1990
  */
1760
- declare type TableDensity = 'compact' | 'comfortable' | 'spacious';
1991
+ declare type TableDensity = 'dense' | 'compact' | 'standard' | 'comfortable' | 'spacious';
1761
1992
 
1762
1993
  declare type TablePreferences = {
1763
1994
  columnSettingsMap?: ColumnSettingsMap;
@@ -1768,6 +1999,7 @@ declare type TablePreferences = {
1768
1999
  enableDevModePagination?: boolean;
1769
2000
  forceClientPagination?: boolean;
1770
2001
  density?: TableDensity;
2002
+ documentWrapText?: boolean;
1771
2003
  };
1772
2004
 
1773
2005
  /**
@@ -2740,6 +2972,7 @@ export declare type TPointStyle = 'circle' | 'cross' | 'crossRot' | 'dash' | 'li
2740
2972
 
2741
2973
  export declare type TSheet = {
2742
2974
  id: string;
2975
+ kind?: 'dashboard' | 'document';
2743
2976
  title?: string;
2744
2977
  description?: string;
2745
2978
  layout?: ReactGridLayout.Layout[];
@@ -2747,6 +2980,7 @@ export declare type TSheet = {
2747
2980
  cards?: TCard[];
2748
2981
  frames?: TFrame[];
2749
2982
  calculatedFields?: Field[];
2983
+ document?: DocumentDefinition;
2750
2984
  };
2751
2985
 
2752
2986
  /**
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.295",
8
+ "version": "0.1.296",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -84,6 +84,11 @@
84
84
  "@dnd-kit/sortable": "^10.0.0",
85
85
  "@dnd-kit/utilities": "^3.2.2",
86
86
  "@headlessui/react": "^2.2.0",
87
+ "@lexical/history": "^0.43.0",
88
+ "@lexical/react": "^0.43.0",
89
+ "@lexical/rich-text": "^0.43.0",
90
+ "@lexical/selection": "^0.43.0",
91
+ "@lexical/utils": "^0.43.0",
87
92
  "@r2wc/react-to-web-component": "^2.0.4",
88
93
  "@radix-ui/react-accordion": "^1.2.2",
89
94
  "@radix-ui/react-alert-dialog": "^1.1.4",
@@ -128,6 +133,7 @@
128
133
  "fast-deep-equal": "^3.1.3",
129
134
  "immer": "^10.0.3",
130
135
  "jwt-decode": "^4.0.0",
136
+ "lexical": "^0.43.0",
131
137
  "lodash.merge": "^4.6.2",
132
138
  "lucide-react": "^0.453.0",
133
139
  "ms": "^2.1.3",
@@ -1,47 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Ze8VskG1.js"),f=require("react");require("react-dom");const R=require("./dashboard-filter-controls-button-D0AsV28-.js"),Qs=require("./date-formatter-CqXdM6JO.js"),is=require("./dashboard-summary-settings-dialog-DRLPzp1P.js"),Ws=require("./use-debounced-dirty-check-XHSwAefL.js"),Ie=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),ls=require("./use-create-flow-overlay-state-BbQVNDCj.js"),Js=require("./braces-DWldEFn5.js");function Ys(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const w=Ys(f);/**
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 Xs=s.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Zs=s.createLucideIcon("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const et=s.createLucideIcon("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const st=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const tt=s.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
27
- * @license lucide-react v0.453.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const at=s.createLucideIcon("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var Te={exports:{}},ke={};/**
32
- * @license React
33
- * use-sync-external-store-shim.production.js
34
- *
35
- * Copyright (c) Meta Platforms, Inc. and affiliates.
36
- *
37
- * This source code is licensed under the MIT license found in the
38
- * LICENSE file in the root directory of this source tree.
39
- */var cs;function rt(){if(cs)return ke;cs=1;var t=f;function n(u,o){return u===o&&(u!==0||1/u===1/o)||u!==u&&o!==o}var r=typeof Object.is=="function"?Object.is:n,a=t.useState,l=t.useEffect,c=t.useLayoutEffect,h=t.useDebugValue;function m(u,o){var p=o(),g=a({inst:{value:p,getSnapshot:o}}),S=g[0].inst,y=g[1];return c(function(){S.value=p,S.getSnapshot=o,x(S)&&y({inst:S})},[u,p,o]),l(function(){return x(S)&&y({inst:S}),u(function(){x(S)&&y({inst:S})})},[u]),h(p),p}function x(u){var o=u.getSnapshot;u=u.value;try{var p=o();return!r(u,p)}catch{return!0}}function b(u,o){return o()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?b:m;return ke.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,ke}var Oe={};/**
40
- * @license React
41
- * use-sync-external-store-shim.development.js
42
- *
43
- * Copyright (c) Meta Platforms, Inc. and affiliates.
44
- *
45
- * This source code is licensed under the MIT license found in the
46
- * LICENSE file in the root directory of this source tree.
47
- */var ds;function nt(){return ds||(ds=1,process.env.NODE_ENV!=="production"&&function(){function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}function n(p,g){d||l.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var S=g();if(!u){var y=g();c(S,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}y=h({inst:{value:S,getSnapshot:g}});var N=y[0].inst,C=y[1];return x(function(){N.value=S,N.getSnapshot=g,r(N)&&C({inst:N})},[p,S,g]),m(function(){return r(N)&&C({inst:N}),p(function(){r(N)&&C({inst:N})})},[p]),b(S),S}function r(p){var g=p.getSnapshot;p=p.value;try{var S=g();return!c(p,S)}catch{return!0}}function a(p,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var l=f,c=typeof Object.is=="function"?Object.is:t,h=l.useState,m=l.useEffect,x=l.useLayoutEffect,b=l.useDebugValue,d=!1,u=!1,o=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:n;Oe.useSyncExternalStore=l.useSyncExternalStore!==void 0?l.useSyncExternalStore:o,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Oe}process.env.NODE_ENV==="production"?Te.exports=rt():Te.exports=nt();var ot=Te.exports;const be=["light","dark","system"];function it(){const{theme:t,setTheme:n}=s.useTheme(),r=s.useDashboardStore(h=>h.actions.setDashboardTheme);function a(){const h=be.includes(t)?t:"system",m=be[(be.indexOf(h)+1)%be.length];n(m),r(m)}const l=t==="light"?at:t==="dark"?st:et,c=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(s.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":c,title:c,children:e.jsx(l,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function lt(t,n,r,a,l){if(!l)return null;const c=JSON.stringify(r),h=`${t}/v1/lens`;return await s.postRequest(h,l,{name:n,template:c,filterValues:a,operation:"create"})}async function Pe(t,n,r){if(!r)return null;const{id:a,template:l,filterValues:c,isDefault:h,shared:m}=n,x=`${t}/v1/lens`;return await s.postRequest(x,r,{lensId:a,template:l,filterValues:c,isDefault:h,shared:m,operation:"update"})}async function ct(t,n,r){if(!r)return null;const a=`${t}/v1/lens`;return await s.postRequest(a,r,{operation:"delete",lensId:n})}const dt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function ut({open:t,onOpenChange:n}={}){const[r,a]=f.useState(""),[l,c]=f.useState(!1),h=s.useDashboardStore(j=>j.lenses),{setLenses:m,setSelectedLensId:x}=s.useDashboardActions(),[b,d]=f.useState(!1),[u,o]=f.useState(!1),p=t!==void 0,g=p?t:u,S=j=>{p||o(j),n==null||n(j)},y=s.useDashboardStore(j=>j.dashboard),N=s.useDashboardStore(j=>j.filterValues),{authToken:C,tokenProps:T}=s.useSemaphorContext();async function L(){d(!0);const j=await lt(T.apiServiceUrl,r,y,N,C==null?void 0:C.accessToken);j&&(m([...h||[],j]),x(j.id),S(!1)),d(!1)}return e.jsxs(s.Dialog,{open:g,onOpenChange:S,children:[p?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-[6px] border-border/60 sm:max-w-[420px] sm:rounded-[6px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Lenses are private by default and are only visible to you."})]}),e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(s.Label,{htmlFor:"lens-name",className:dt,children:"Name"}),e.jsx(s.Input,{id:"lens-name",size:"xs",value:r,placeholder:"Monthly review, West region, …",onChange:j=>a(j.target.value)}),l&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:()=>S(!1),children:"Cancel"}),e.jsx(s.Button,{size:"xs",type:"submit",onClick:L,disabled:b||!r.trim(),children:b?"Creating…":"Create"})]})]})]})}function mt({includeLabel:t=!1}={}){const n=s.useDashboardStore(d=>d.lenses),r=s.useDashboardStore(d=>d.selectedLensId),{setLenses:a,setSelectedLensId:l}=s.useDashboardActions(),{authToken:c,tokenProps:h}=s.useSemaphorContext();async function m(d){l(d)}async function x(d){if(await ct(h.apiServiceUrl,d,c==null?void 0:c.accessToken)){const o=n==null?void 0:n.filter(p=>p.id!==d);a(o||[]),l("original")}}async function b(d){const u=n==null?void 0:n.map(g=>g.id===d.id?{...g,isDefault:!d.isDefault}:{...g,isDefault:!1});a(u||[]);const o={...d,isDefault:!d.isDefault};await Pe(h.apiServiceUrl,o,c==null?void 0:c.accessToken);const p=n==null?void 0:n.find(g=>g.isDefault);if(p&&p.id!==d.id){const g={...p,isDefault:!1};await Pe(h.apiServiceUrl,g,c==null?void 0:c.accessToken)}}return e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{})]}):null,e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:m,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(d=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:d.id,children:[e.jsx("p",{children:d.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:u=>{u.preventDefault(),b(d)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!d.isDefault,"text-green-500":d.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:u=>{u.preventDefault(),x(d.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},d.id))]})]})}function ht(){const{displayPreferences:t,shouldShowElement:n}=s.useDisplayPreferences(),{currentUser:r,userContext:a}=s.useCurrentUserInfo(),l=f.useMemo(()=>s.getRoleBasedDisplayOverrides(r),[r]),c=f.useMemo(()=>m=>l&&l[m]!==void 0&&l[m]===!1?!1:n(m),[l,n,t]),h=f.useMemo(()=>{var m,x,b,d,u;return{canEdit:((m=a==null?void 0:a.permissions)==null?void 0:m.canEdit)??s.canUserEdit(r),canUseFilters:((x=a==null?void 0:a.permissions)==null?void 0:x.canEdit)??s.canUserUseFilters(r),canManageDashboards:((b=a==null?void 0:a.permissions)==null?void 0:b.canCreateDashboard)??s.canUserManageDashboards(r),canCreateDashboards:((d=a==null?void 0:a.permissions)==null?void 0:d.canCreateDashboard)??s.canUserCreateDashboards(r),canAccessVisuals:((u=a==null?void 0:a.permissions)==null?void 0:u.canEdit)??s.canUserAccessVisuals(r)}},[r,a]);return{displayPreferences:t,shouldShowElement:c,permissions:h,currentUser:r}}const pt=async(t,n,r)=>{const a=`${t}/management/v1/groups`;return await s.postRequestRegular(a,n,r)},xt=async(t,n,r)=>{const a=`${t}/management/v1/groups/${r}`;await s.requestJsonRegular(a,n,"DELETE")},ft=async(t,n,r,a)=>{const l=`${t}/management/v1/groups/${r}/members`;return await s.postRequestRegular(l,n,a)},gt=async(t,n,r,a)=>{const l=`${t}/management/v1/groups/${r}/members`;await s.requestJsonRegular(l,n,"DELETE",a)};function bt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>pt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:()=>{r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:a=>{console.error("Failed to create group:",a),s.ue.error("Failed to create group",{description:s.getRequestErrorMessage(a,"Failed to create group")})}})}function vt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>xt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["groups"]}),r.removeQueries({queryKey:["group",l]}),s.ue.success("Group deleted successfully")},onError:a=>{console.error("Failed to delete group:",a),s.ue.error("Failed to delete group",{description:s.getRequestErrorMessage(a,"Failed to delete group")})}})}function St(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:l})=>ft(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,l),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["group",l.groupId]}),r.invalidateQueries({queryKey:["group-members",l.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:a=>{console.error("Failed to add group members:",a),s.ue.error("Failed to add members",{description:s.getRequestErrorMessage(a,"Failed to add members")})}})}function yt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:l})=>gt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,l),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["group",l.groupId]}),r.invalidateQueries({queryKey:["group-members",l.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:a=>{console.error("Failed to remove group members:",a),s.ue.error("Failed to remove members",{description:s.getRequestErrorMessage(a,"Failed to remove members")})}})}const us="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function jt({onSuccess:t,tenantId:n,isTenantUser:r}){const[a,l]=f.useState(""),[c,h]=f.useState(""),[m,x]=f.useState({}),b=bt(),d=()=>{const o={};return a.trim()?a.length<3?o.name="Group name must be at least 3 characters":a.length>50&&(o.name="Group name must be less than 50 characters"):o.name="Group name is required",c&&c.length>200&&(o.description="Description must be less than 200 characters"),x(o),Object.keys(o).length===0},u=async o=>{if(o.preventDefault(),!d())return;const p={name:a.trim(),description:c.trim()||void 0,type:r?"TENANT_GROUP":"ORG_GROUP",...r&&n?{tenantId:n}:{}};try{await b.mutateAsync(p),l(""),h(""),x({}),t()}catch(g){console.error("Failed to create group:",g)}};return e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(s.Label,{htmlFor:"group-name",className:us,children:["Group name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(s.Input,{id:"group-name",size:"xs",placeholder:"e.g., Marketing Team, Engineering Squad",value:a,onChange:o=>{l(o.target.value),m.name&&x(p=>({...p,name:""}))},className:m.name?"border-destructive":"",disabled:b.isPending}),m.name&&e.jsx("p",{className:"text-[12px] text-destructive",children:m.name})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"group-description",className:us,children:"Description (optional)"}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group…",value:c,onChange:o=>{h(o.target.value),m.description&&x(p=>({...p,description:""}))},className:`text-[13px] ${m.description?"border-destructive":""}`,disabled:b.isPending,rows:3}),m.description?e.jsx("p",{className:"text-[12px] text-destructive",children:m.description}):e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[c.length,"/200"]})]}),e.jsxs("div",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[e.jsx(s.Info,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),e.jsx("p",{children:"This group will be accessible to users in your workspace. You can add members after creating it."})]}),e.jsxs("div",{className:"flex justify-end gap-1.5 pt-1",children:[e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>{l(""),h(""),x({})},disabled:b.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",size:"xs",disabled:b.isPending||!a.trim(),children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating…"]}):"Create group"})]})]})}function Dt(t,n=[]){let r=[];function a(c,h){const m=w.createContext(h);m.displayName=c+"Context";const x=r.length;r=[...r,h];const b=u=>{var N;const{scope:o,children:p,...g}=u,S=((N=o==null?void 0:o[t])==null?void 0:N[x])||m,y=w.useMemo(()=>g,Object.values(g));return e.jsx(S.Provider,{value:y,children:p})};b.displayName=c+"Provider";function d(u,o){var S;const p=((S=o==null?void 0:o[t])==null?void 0:S[x])||m,g=w.useContext(p);if(g)return g;if(h!==void 0)return h;throw new Error(`\`${u}\` must be used within \`${c}\``)}return[b,d]}const l=()=>{const c=r.map(h=>w.createContext(h));return function(m){const x=(m==null?void 0:m[t])||c;return w.useMemo(()=>({[`__scope${t}`]:{...m,[t]:x}}),[m,x])}};return l.scopeName=t,[a,Nt(l,...n)]}function Nt(...t){const n=t[0];if(t.length===1)return n;const r=()=>{const a=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(c){const h=a.reduce((m,{useScope:x,scopeName:b})=>{const u=x(c)[`__scope${b}`];return{...m,...u}},{});return w.useMemo(()=>({[`__scope${n.scopeName}`]:h}),[h])}};return r.scopeName=n.scopeName,r}var wt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fe=wt.reduce((t,n)=>{const r=s.createSlot(`Primitive.${n}`),a=w.forwardRef((l,c)=>{const{asChild:h,...m}=l,x=h?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(x,{...m,ref:c})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{});function Ct(){return ot.useSyncExternalStore(Mt,()=>!0,()=>!1)}function Mt(){return()=>{}}var _e="Avatar",[Et]=Dt(_e),[Lt,ps]=Et(_e),xs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,...a}=t,[l,c]=w.useState("idle");return e.jsx(Lt,{scope:r,imageLoadingStatus:l,onImageLoadingStatusChange:c,children:e.jsx(Fe.span,{...a,ref:n})})});xs.displayName=_e;var fs="AvatarImage",gs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,src:a,onLoadingStatusChange:l=()=>{},...c}=t,h=ps(fs,r),m=At(a,c),x=s.useCallbackRef(b=>{l(b),h.onImageLoadingStatusChange(b)});return s.useLayoutEffect2(()=>{m!=="idle"&&x(m)},[m,x]),m==="loaded"?e.jsx(Fe.img,{...c,ref:n,src:a}):null});gs.displayName=fs;var bs="AvatarFallback",vs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,delayMs:a,...l}=t,c=ps(bs,r),[h,m]=w.useState(a===void 0);return w.useEffect(()=>{if(a!==void 0){const x=window.setTimeout(()=>m(!0),a);return()=>window.clearTimeout(x)}},[a]),h&&c.imageLoadingStatus!=="loaded"?e.jsx(Fe.span,{...l,ref:n}):null});vs.displayName=bs;function ms(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function At(t,{referrerPolicy:n,crossOrigin:r}){const a=Ct(),l=w.useRef(null),c=a?(l.current||(l.current=new window.Image),l.current):null,[h,m]=w.useState(()=>ms(c,t));return s.useLayoutEffect2(()=>{m(ms(c,t))},[c,t]),s.useLayoutEffect2(()=>{const x=u=>()=>{m(u)};if(!c)return;const b=x("loaded"),d=x("error");return c.addEventListener("load",b),c.addEventListener("error",d),n&&(c.referrerPolicy=n),typeof r=="string"&&(c.crossOrigin=r),()=>{c.removeEventListener("load",b),c.removeEventListener("error",d)}},[c,r,n]),h}var Ss=xs,ys=gs,js=vs;const Re=w.forwardRef(({className:t,...n},r)=>e.jsx(Ss,{ref:r,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));Re.displayName=Ss.displayName;const It=w.forwardRef(({className:t,...n},r)=>e.jsx(ys,{ref:r,className:s.cn("aspect-square h-full w-full",t),...n}));It.displayName=ys.displayName;const Ue=w.forwardRef(({className:t,...n},r)=>e.jsx(js,{ref:r,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));Ue.displayName=js.displayName;function kt({open:t,onOpenChange:n,group:r,onUpdate:a}){const[l,c]=f.useState("members"),[h,m]=f.useState(""),[x,b]=f.useState([]),[d,u]=f.useState([]),{data:o,isLoading:p,refetch:g}=s.useGroupMembers(r.id),S=r.type==="TENANT_GROUP"?"tenant":"organization",{users:y,isLoading:N}=s.useUnifiedUsers({type:S,tenantId:r.tenantId||void 0,active:!0,limit:100}),C=St(),T=yt(),L=(o==null?void 0:o.members)||[],j=f.useMemo(()=>new Set(L.map(v=>v.userId)),[L]),P=f.useMemo(()=>y.filter(v=>!j.has(v.id)),[y,j]),$=f.useMemo(()=>{if(!h)return P;const v=h.toLowerCase();return P.filter(M=>{var k,F;return((k=M.name)==null?void 0:k.toLowerCase().includes(v))||((F=M.email)==null?void 0:F.toLowerCase().includes(v))})},[P,h]),D=f.useMemo(()=>{if(!h)return L;const v=h.toLowerCase();return L.filter(M=>{var k,F,ee,U;return((F=(k=M.user)==null?void 0:k.name)==null?void 0:F.toLowerCase().includes(v))||((U=(ee=M.user)==null?void 0:ee.email)==null?void 0:U.toLowerCase().includes(v))})},[L,h]),q=async()=>{if(x.length!==0)try{await C.mutateAsync({groupId:r.id,data:{userIds:x,userType:S==="tenant"?"tenant":"org"}}),b([]),c("members"),g(),a==null||a()}catch(v){console.error("Failed to add members:",v)}},X=async()=>{if(d.length!==0)try{await T.mutateAsync({groupId:r.id,data:{userIds:d}}),u([]),g(),a==null||a()}catch(v){console.error("Failed to remove members:",v)}},ve=v=>{b(M=>M.includes(v)?M.filter(k=>k!==v):[...M,v])},Z=v=>{u(M=>M.includes(v)?M.filter(k=>k!==v):[...M,v])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-3xl max-h-[80vh]","aria-describedby":"group-members-description",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:r.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[L.length," ",L.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",r.name," group"]})]}),e.jsxs(s.Tabs,{value:l,onValueChange:v=>{c(v),m(""),u([])},className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(s.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(s.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(s.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search members...",value:h,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:d.length>0?"h-[300px]":"h-[350px]",children:p?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):D.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:h?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:h?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:D.map(v=>e.jsx(Ot,{member:v,selected:d.includes(v.userId),onToggle:()=>Z(v.userId)},v.id))})}),d.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[d.length," member",d.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:X,disabled:T.isPending,children:T.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(s.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search users to add...",value:h,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:N?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):$.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.UserPlus,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:h?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:$.map(v=>e.jsx(Tt,{user:v,selected:x.includes(v.id),onToggle:()=>ve(v.id)},v.id))})}),x.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.length," user",x.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:q,disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.UserPlus,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function Ot({member:t,selected:n,onToggle:r}){var l,c,h,m;const a=((c=(l=t.user)==null?void 0:l.name)==null?void 0:c.split(" ").map(x=>x[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(Re,{className:"h-8 w-8",children:e.jsx(Ue,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((h=t.user)==null?void 0:h.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(m=t.user)==null?void 0:m.email})]})]})}function Tt({user:t,selected:n,onToggle:r}){var l;const a=((l=t.name)==null?void 0:l.split(" ").map(c=>c[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(Re,{className:"h-8 w-8",children:e.jsx(Ue,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.email})]})]})}function Pt({open:t,onOpenChange:n}){const[r,a]=f.useState("groups"),[l,c]=f.useState(""),[h,m]=f.useState(null),[x,b]=f.useState(!1),[d,u]=f.useState(null),{tokenProps:o}=s.useSemaphorContext(),{currentUser:p}=s.useCurrentUserInfo(),g=vt(),S=(p==null?void 0:p.type)==="tenant",y=o==null?void 0:o.tenantId,{groups:N,isLoading:C,refetch:T}=s.useGroups({type:S?"TENANT_GROUP":"all",tenantId:S?y:void 0,includeMembers:!1}),L=N.filter(D=>{var q;return D.name.toLowerCase().includes(l.toLowerCase())||((q=D.description)==null?void 0:q.toLowerCase().includes(l.toLowerCase()))}),j=async()=>{if(d)try{await g.mutateAsync(d.id),u(null),T()}catch(D){console.error("Failed to delete group:",D)}},P=D=>{m(D),b(!0)},$=()=>{a("groups"),T()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-h-[80vh] max-w-3xl rounded-[6px] border-border/60 sm:rounded-[6px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Group management"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Manage groups, create new ones, and control membership."})]}),e.jsxs(s.Tabs,{value:r,onValueChange:a,className:"mt-2",children:[e.jsxs(s.TabsList,{className:"h-8 w-full justify-start gap-1 bg-transparent p-0 border-b border-border/60 rounded-none",children:[e.jsx(s.TabsTrigger,{value:"groups",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Groups"}),e.jsx(s.TabsTrigger,{value:"create",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Create group"})]}),e.jsx(s.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{size:"xs",placeholder:"Search groups…",value:l,onChange:D=>c(D.target.value),className:"pl-7"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:C?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(D=>e.jsx(s.Skeleton,{className:"h-16 w-full rounded-[6px]"},D))}):L.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx("p",{className:"text-[13px]",children:"No groups found."}),e.jsx("p",{className:"mt-1 text-[12px]",children:l?"Try a different search.":"Create your first group to get started."})]}):e.jsx("div",{className:"space-y-2 pr-2",children:L.map(D=>e.jsx(Ft,{group:D,onManageMembers:()=>P(D),onDelete:()=>u(D),currentUserId:p==null?void 0:p.id},D.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(jt,{onSuccess:$,tenantId:y,isTenantUser:S})})]})]})}),h&&e.jsx(kt,{open:x,onOpenChange:b,group:h,onUpdate:()=>T()}),e.jsx(s.AlertDialog,{open:!!d,onOpenChange:()=>u(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete group"}),e.jsxs(s.AlertDialogDescription,{children:['Delete "',d==null?void 0:d.name,`"? This removes all members and can't be undone.`]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:j,disabled:g.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete group"})]})]})})]})}function Ft({group:t,onManageMembers:n,onDelete:r,currentUserId:a}){const l=t.createdBy===a;return e.jsx("div",{className:"rounded-[6px] border border-border/60 bg-card px-3 py-2.5 transition-colors hover:bg-muted/30",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:t.name}),t.description&&e.jsx("p",{className:"text-[12px] text-muted-foreground",children:t.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(s.Users,{className:"h-3 w-3"}),t.memberCount," ",t.memberCount===1?"member":"members"]}),e.jsxs("span",{children:["Created ",Qs.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(s.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:n,title:"Manage members","aria-label":"Manage members",children:e.jsx(s.UserPlus,{className:"h-3.5 w-3.5"})}),l&&e.jsx(s.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:r,title:"Delete group","aria-label":"Delete group",children:e.jsx(s.Trash2,{className:"h-3.5 w-3.5"})})]})]})})}function J(t,n,r){var c,h;const a=(t.controls||[]).find(m=>m.id===r);if(a)return a.label;const l=(h=(c=s.findCardById(t,n))==null?void 0:c.controls)==null?void 0:h.find(m=>m.id===r);return(l==null?void 0:l.label)||r}function Y(t,n){var r;return((r=s.findCardById(t,n))==null?void 0:r.title)||n}function _t(t){const{errors:n,dashboard:r}=t;if(!r)return n;const a=new Map;for(const l of n){const c=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,d,u]=c,o=`${d}:${u}:missing-metric`;a.has(o)||a.set(o,`"${Y(r,d)}" has an outdated "${J(r,d,u)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const h=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(h){const[,d,u]=h,o=`${d}:${u}:missing-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" has an outdated "${J(r,d,u)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const m=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(m){const[,d,u]=m,o=`${d}:${u}:invalid-metric`;a.has(o)||a.set(o,`"${Y(r,d)}" has an invalid "${J(r,d,u)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const x=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(x){const[,d,u]=x,o=`${d}:${u}:invalid-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" has an invalid "${J(r,d,u)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const b=l.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(b){const[,d,u]=b,o=`${d}:${u}:missing-temporal-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" can no longer use "${J(r,d,u)}" for time grain because the card does not currently group by a date field.`);continue}a.set(l,l)}return Array.from(a.values())}function hs(t,n){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(n)}}function Rt(){var ts,as,rs,ns;R.useExportRecovery(),R.useExportPolling();const{authToken:t,tokenProps:n,id:r}=s.useSemaphorContext(),{isLocalDev:a}=s.useDashboardPreferences(),{permissions:l}=ht(),c=s.useHasDashboardId(),{isLoading:h}=s.useDashboardQuery();s.useDashboardStore(i=>i.theme);const m=s.useDashboardStore(i=>i.isDownloadingPdf),x=s.useDashboardStore(i=>i.dashboardAssistantDraftScopeKey),b=s.useDashboardStore(i=>i.lenses),d=s.useDashboardStore(i=>i.selectedLensId),u=b==null?void 0:b.find(i=>i.id===d),o=s.useDashboardStore(i=>i.dashboard);s.useDashboardStore(i=>i.selectedSheetId);const p=s.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:g}=s.useDashboardStore(i=>i.actions),[S,y]=f.useState(!1),[N,C]=f.useState(!1),[T,L]=f.useState(!1),[j,P]=f.useState(!1),[$,D]=f.useState(!1),[q,X]=f.useState(!1),[ve,Z]=f.useState(!1),[v,M]=f.useState(!1),[k,F]=f.useState(null),[ee,U]=f.useState(!1),[se,te]=f.useState(null),[Ge,ae]=f.useState([]),[$e,re]=f.useState(!1),Ds=s.useDashboardStore(i=>i.isDashboardPanelOpen),Ns=s.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),ws=s.useDashboardStore(i=>i.filterValues),A=s.useDashboardStore(i=>i.isVisualEditing);s.useEditorStore(i=>i.card);const z=s.useManagementStore(i=>i.selectedDashboard),ne=s.useManagementStore(i=>i.initialDashboard);s.useManagementStore(i=>i.selectedVisual),s.useDashboardStore(i=>i.selectedFrameId),s.useEditorStore(i=>i.frame);const oe=z?(as=z==null?void 0:z.permissions)==null?void 0:as.canEdit:(ts=ne==null?void 0:ne.permissions)==null?void 0:ts.canEdit,ie=s.useDashboardStore(i=>i.showFilters),qe=s.useAssistantLayoutStore(i=>i.setPanelOpen),Be=s.useDashboardStore(i=>i.showDashboardJSON),Se=s.useDashboardStore(i=>i.onSaveFunction),ze=s.useDashboardStore(i=>i.actions.setShowFilters),{setIsDashboardEditing:He,setShowDashboardJSON:Ve}=s.useDashboardStore(i=>i.actions),{setInitialDashboard:Ke,clearSelectedDashboard:ye}=s.useManagementStore(i=>i.actions),{resources:le}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:je}=s.useUserPreferences(),Cs=((rs=je==null?void 0:je.preference)==null?void 0:rs.defaultDashboardId)||null,{mutate:Ms,isPending:Es}=s.useDefaultDashboardMutation(),{currentUser:Ls}=s.useCurrentUserInfo(),As=s.canUserManageGroups(Ls),B=z||ne,Qe=B?{id:B.id,title:(o==null?void 0:o.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:Is}=s.useAddNewFrame(),[De,Ne]=f.useState(!1),[ks,H]=f.useState(!1),[we,ce]=f.useState("close"),V=s.useUpdateResource(s.ResourceType.DASHBOARD),[O,de]=f.useState(null),We=f.useCallback(i=>{window.setTimeout(()=>{F(i)},0)},[]),Os=async(i,E)=>{if(!(o!=null&&o.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:o.id,newTitle:i,previousTitle:E}),V.mutate({resourceId:o.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:_=>{console.error("Failed to update dashboard title:",_),s.ue.error("Failed to update dashboard title"),g(E)}})};f.useEffect(()=>{if(le&&le.length>0){const i=o==null?void 0:o.id;if(i){const E=le.find(_=>_.id===i);E&&Ke(E)}}},[le,o==null?void 0:o.id,Ke]);const K=n.orgUserId||n.tenantId,Je=p&&!A&&K&&oe,{setDashboard:Ce}=s.useDashboardStore(i=>i.actions),Me=s.useDashboardStore(i=>i.semanticExecutionPayload),Ts=()=>{He(!0)},Ee=()=>{He(!1),Ve(!1),de(null),F(null)};f.useEffect(()=>{if(!p){O&&de(null);return}O||!o||h||de(hs(o,Me))},[o,O,p,h,Me]);const ue=(O==null?void 0:O.dashboard)??null,{isDirty:Ye,isDirtyPending:Ps,resetDirty:me}=Ws.useDebouncedDirtyCheck(o,ue,300,1e3,Ie.serializeDashboardForDirtyCheck),Xe=f.useCallback(()=>ue?Ie.serializeDashboardForDirtyCheck(o)!==Ie.serializeDashboardForDirtyCheck(ue):!1,[o,ue]),Ze=Ye||Ps,he=De||V.isPending,Fs=()=>{Xe()?(ce("close"),H(!0)):(Ee(),me())},_s=async()=>{await Le({closeAfterSave:!0,navigateHomeAfterSave:we==="home"})},Rs=()=>{O&&Ce(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),Ee(),we==="home"&&ye(),ce("close"),H(!1),me()},Us=()=>{O&&(Ce(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),me())},Gs=()=>{if(p&&Xe()){ce("home"),H(!0);return}ye()};async function Le(i){const E=s.useDashboardStore.getState().dashboard;if(!E)return;const _=(i==null?void 0:i.closeAfterSave)??$e,Hs=(i==null?void 0:i.navigateHomeAfterSave)??!1;re(_),_&&H(!1);const Vs=s.cloneDeep(E);U(!0),te(null),ae([]),Ne(!0);const Ks={template:E};V.mutate({resourceId:E.id,data:Ks},{onSuccess:I=>{var xe,fe,os;const G=(I==null?void 0:I.id)||((xe=I==null?void 0:I.dashboard)==null?void 0:xe.id)||((fe=I==null?void 0:I.resource)==null?void 0:fe.id)||((os=I==null?void 0:I.template)==null?void 0:os.id)||null;if(!E.id&&G){const Ae=s.useAIInteractionStore.getState(),ge=Ae.pendingDashboardDraftMigration;(ge==null?void 0:ge.scopeKey)===x?Ae.actions.setPendingDashboardDraftMigrationExpectedDashboardId(G):ge&&Ae.actions.clearPendingDashboardDraftMigration()}Ne(!1),s.ue.success("Dashboard saved!"),de(hs(Vs,s.useDashboardStore.getState().semanticExecutionPayload)),U(!1),re(!1),_&&(Ee(),me(),Hs&&ye()),ce("close")},onError:I=>{Ne(!1),te("Failed to save dashboard. Please try again.");const G=I.details,xe=Array.isArray(G==null?void 0:G.errors)?(G.errors||[]).filter(fe=>typeof fe=="string"):[];ae(_t({errors:xe,dashboard:E||void 0})),s.ue.error("Failed to save dashboard")}})}async function $s(){if(y(!0),!d||!u)return;const i=s.useDashboardStore.getState().dashboard;if(!i){y(!1);return}const E=JSON.stringify(i),_={...u,template:E,filterValues:ws};await Pe(n.apiServiceUrl,_,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Se==null||Se(i),y(!1)}const es=(u==null?void 0:u.name)||o.title,Q=!!(o!=null&&o.id);V.isPending&&console.log("Title during update:",{title:es,dashboardStateTitle:o.title,dashboardId:o==null?void 0:o.id,currentLensName:u==null?void 0:u.name});const ss=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,qs=!!ss&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl);f.useEffect(()=>{!Q&&j&&P(!1)},[Q,j]);const Bs=c,W=(o==null?void 0:o.id)||null,pe=!!W&&Cs===W,zs=()=>{W&&Ms({dashboardId:pe?null:W})};return e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[ss&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{Ns(!Ds)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(Zs,{className:"h-3.5 w-3.5"})}),Bs&&!A&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Gs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!A&&c&&(h?e.jsx("div",{className:"h-4 w-28 rounded-md bg-muted/70 animate-pulse","aria-label":"Loading dashboard title",role:"status",children:e.jsx("span",{className:"sr-only",children:"Loading dashboard title"})}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:es||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:oe,dashboardId:o==null?void 0:o.id});const E=(o==null?void 0:o.title)||"";g(i),Os(i,E)},isEditable:oe&&!u,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:V.isPending}),qs&&W&&e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"xs",onClick:zs,disabled:Es||!(t!=null&&t.accessToken)||!(n!=null&&n.apiServiceUrl),className:"w-7 px-0","aria-label":pe?"Remove as default dashboard":"Make this a default dashboard",children:e.jsx(s.Star,{className:s.cn("h-3.5 w-3.5 transition-colors",pe?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:pe?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&e.jsxs(e.Fragment,{children:[e.jsx(R.AdvancedModeToggle,{}),e.jsx(R.VisualEditingControls,{})]}),!A&&c&&((ns=B==null?void 0:B.permissions)==null?void 0:ns.canShare)&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:()=>C(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!A&&p&&l.canUseFilters&&c&&e.jsx(R.DashboardFilterControlsButton,{showFilters:ie,onToggleFilters:()=>{ie||qe("dashboard",!1),ze(!ie)},onAddFilter:()=>{ie||(qe("dashboard",!1),ze(!0))},onAddControl:()=>{We("create")},onManageControls:()=>We("manage")}),p&&!A&&c&&k?e.jsx(R.DashboardControlsSettings,{open:!0,onOpenChange:i=>{i||F(null)},showTrigger:!1,initialMode:k}):null,p&&!A&&K&&u&&a&&c&&e.jsxs(s.Button,{variant:"secondary",size:"xs",disabled:S,onClick:$s,children:[e.jsx(ls.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),p&&!A&&c&&e.jsxs(s.Button,{variant:"outline",size:"xs",disabled:!p,onClick:()=>Is(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!A&&!p&&oe&&c&&e.jsxs(s.Button,{size:"xs",onClick:Ts,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Je&&c&&Ye&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:Us,disabled:he,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),Je&&c&&e.jsxs(s.Button,{size:"xs",className:s.cn(!Ze&&"opacity-60"),disabled:he||!Ze,onClick:()=>Le(),children:[he?e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ls.Save,{className:"h-3.5 w-3.5"}),he?"Saving...":"Save"]}),p&&!A&&c&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:Fs,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!A&&c&&e.jsx("div",{className:"ml-2",children:e.jsx(R.NotificationBell,{})}),!A&&a&&e.jsx(it,{}),!A&&c&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-[6px] border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:m,onSelect:()=>M(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsxs(s.DropdownMenuItem,{disabled:!Q,onSelect:()=>{Q&&P(!0)},children:[e.jsx(s.Clock,{className:"h-3.5 w-3.5"}),"Schedule"]}),e.jsx(s.DropdownMenuSeparator,{}),As&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>L(!0),children:[e.jsx(s.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>D(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>X(!0),children:[e.jsx(s.FileText,{className:"h-3.5 w-3.5"}),"Summary Settings"]}),a&&c&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var i;t!=null&&t.accessToken&&((i=navigator==null?void 0:navigator.clipboard)!=null&&i.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>s.invalidateToken(n.apiServiceUrl),children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),p&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Ve(!Be),children:[e.jsx(Js.Braces,{className:"h-3.5 w-3.5"}),Be?"Hide dashboard JSON":"Show dashboard JSON"]}),K&&p&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Z(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),K&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(Xs,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(mt,{})})]})]})]})]}),N&&Qe&&e.jsx(s.ShareDialog,{resource:Qe,resourceType:s.ResourceType.DASHBOARD,onClose:()=>C(!1)}),e.jsx(Pt,{open:T,onOpenChange:L}),Q&&(o==null?void 0:o.id)&&e.jsx(s.EmailScheduleDialog,{open:j,onOpenChange:P,dashboardId:o.id,dashboardName:o==null?void 0:o.title}),e.jsx(is.CalendarPreferencesDialog,{open:$,onOpenChange:D}),e.jsx(is.DashboardSummarySettingsDialog,{open:q,onOpenChange:X,dashboard:o,disabled:!p,onApply:i=>Ce({...o,summary:i},{semanticExecutionPayload:Me})}),a&&K&&c&&e.jsx(ut,{open:ve,onOpenChange:Z}),c&&e.jsx(s.DownloadPdf,{open:v,onOpenChange:M}),e.jsx(s.AlertDialog,{open:ee,onOpenChange:i=>{!i&&De&&!se||(U(i),i||(te(null),ae([]),re(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:se?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:se?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),Ge.length>0&&e.jsxs("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:Ge.slice(0,5).map(i=>e.jsx("li",{children:i},i))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:se?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{U(!1),te(null),ae([]),re(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Le({closeAfterSave:$e,navigateHomeAfterSave:we==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(R.UnsavedChangesAlert,{open:ks,onOpenChange:i=>{H(i)},onSave:_s,onDiscard:Rs,isSaving:De,saveLabel:"Save",discardLabel:"Discard"})]})]})}exports.default=Rt;