react-semaphor 0.1.603 → 0.1.604

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 (167) hide show
  1. package/dist/activity/index.js +1 -73
  2. package/dist/analytics-protocol/index.js +1 -1491
  3. package/dist/appearance/index.js +1 -12
  4. package/dist/appearance-runtime/index.js +1 -5
  5. package/dist/assistant-context/index.js +1 -11
  6. package/dist/assistant-protocol/index.js +1 -152
  7. package/dist/brand-studio/index.js +4 -1594
  8. package/dist/briefings/index.js +1 -70
  9. package/dist/chunks/add-to-dashboard-DeHEBEqG.js +12 -0
  10. package/dist/chunks/analytics-base-schemas-BREc5WGv.js +1 -0
  11. package/dist/chunks/appearance-context-BqBZrijL.js +1 -0
  12. package/dist/chunks/appearance-runtime-provider-DmbCrOOG.js +1 -0
  13. package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
  14. package/dist/chunks/assistant-chat-CjYrwVDa.js +56 -0
  15. package/dist/chunks/attribution-BEFSsbNn.js +1 -0
  16. package/dist/chunks/availability-3AIOf6Z-.js +1 -0
  17. package/dist/chunks/bookmark-impact-C89zBLq3.js +1 -0
  18. package/dist/chunks/bookmark-state-69YYnRql.js +1 -0
  19. package/dist/chunks/brand-DCaZyRt6.js +1 -0
  20. package/dist/chunks/card-filter-builder-CTp6RAz1.js +17 -0
  21. package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
  22. package/dist/chunks/comparison-window-caption-C312mn3s.js +1 -0
  23. package/dist/chunks/context-ALdccLHw.js +2 -0
  24. package/dist/chunks/conversation-JMK2kyTK.js +1 -0
  25. package/dist/chunks/dashboard-BX28ld6s.js +1 -0
  26. package/dist/chunks/dashboard-briefing-launcher-qo7GH4EO.js +37 -0
  27. package/dist/chunks/dashboard-controls-DhRjB7MA.js +42 -0
  28. package/dist/chunks/dashboard-json-9cHzhSjC.js +1 -0
  29. package/dist/chunks/dates-D-KP8G-z.js +1 -0
  30. package/dist/chunks/edit-DEAK0UZo.js +1 -0
  31. package/dist/chunks/edit-dashboard-visual-Duq_QkB_.js +93 -0
  32. package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
  33. package/dist/chunks/filter-line-CwQrqORc.js +1 -0
  34. package/dist/chunks/filter-reach-preview-gixPFlZj.js +1 -0
  35. package/dist/chunks/filter-value-text-B3tXakhd.js +1 -0
  36. package/dist/chunks/index-B-VF1ogs.js +1 -0
  37. package/dist/chunks/index-BE1DfxNs.js +1 -0
  38. package/dist/chunks/index-DViPGDFj.js +1 -0
  39. package/dist/chunks/layout-grid-BWtlgw0T.js +6 -0
  40. package/dist/chunks/matrix-analytical-definition-CtFqWyCK.js +1 -0
  41. package/dist/chunks/matrix-member-presentation-Q0MCJ-YK.js +1 -0
  42. package/dist/chunks/matrix-operation-contract-D1RC1bfi.js +1 -0
  43. package/dist/chunks/metric-comparison-DEZYXROZ.js +1 -0
  44. package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
  45. package/dist/chunks/paintbrush-BjS3SbrH.js +6 -0
  46. package/dist/chunks/palette-BzC-CGOc.js +6 -0
  47. package/dist/chunks/pickers-DuBrUht0.js +1 -0
  48. package/dist/chunks/pivot-result-contract-expectations-DTQAgr4n.js +1 -0
  49. package/dist/chunks/pivot-result-identity-DTNCB--h.js +1 -0
  50. package/dist/chunks/raw-temporal-value-DeyEhL0S.js +1 -0
  51. package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
  52. package/dist/chunks/report-preferences-dialog-B_gUmCzG.js +1 -0
  53. package/dist/chunks/report-runtime-context-BWzIHCKK.js +1 -0
  54. package/dist/chunks/resolve-dashboard-input-context-B-TtRqxu.js +8 -0
  55. package/dist/chunks/resolver-AN9ChBfZ.js +1 -0
  56. package/dist/chunks/save-DdFUZcbi.js +6 -0
  57. package/dist/chunks/saved-dashboard-context-BAJ5tWiq.js +1 -0
  58. package/dist/chunks/schema-MC0cQSAb.js +4 -0
  59. package/dist/chunks/selection-filter-compiler-CCoCD25M.js +1 -0
  60. package/dist/chunks/semaphor-ready-indicator-DzjorP3t.js +999 -0
  61. package/dist/chunks/set-DuJfGkbY.js +1 -0
  62. package/dist/chunks/shelf-drop-preview-context-BlLJ5RsT.js +6 -0
  63. package/dist/chunks/stored-dashboard-Ctcpkllg.js +1 -0
  64. package/dist/chunks/style-sheet-parts-BRGt9O05.js +178 -0
  65. package/dist/chunks/table-export-sheet-rC5pKmXg.js +2 -0
  66. package/dist/chunks/token-types-Bj9iMy0w.js +1 -0
  67. package/dist/chunks/validators-CqV3Yka1.js +1 -0
  68. package/dist/chunks/variable-draft-DJrfUyhv.js +1 -0
  69. package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
  70. package/dist/dashboard/index.js +1 -7
  71. package/dist/dashboard-authoring/index.js +1 -4614
  72. package/dist/format-utils/index.js +1 -425
  73. package/dist/index.js +1 -554
  74. package/dist/layouts/index.js +1 -7
  75. package/dist/live-channel/index.js +1 -124
  76. package/dist/pdf-export-policy/index.js +1 -92
  77. package/dist/pdf-table-layout/index.js +1 -993
  78. package/dist/report-runtime-context/index.js +1 -9
  79. package/dist/shared/index.js +1 -6
  80. package/dist/style.css +1 -1
  81. package/dist/surfboard/index.js +1 -9
  82. package/dist/types/index.js +1 -88
  83. package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
  84. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
  85. package/dist/types/lib/stores/explorer-actions.d.ts +7 -6
  86. package/dist/types/lib/types/semantic-types.d.ts +6 -10
  87. package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
  88. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
  89. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
  90. package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
  91. package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
  92. package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
  93. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
  94. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +132 -0
  95. package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
  96. package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
  97. package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
  98. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +115 -0
  99. package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
  100. package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
  101. package/dist/types/shared/dashboard-authoring/index.d.ts +6 -1
  102. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -0
  103. package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
  104. package/dist/usage-events/index.js +1 -285
  105. package/dist/value-format-preferences/index.js +1 -635
  106. package/package.json +4 -1
  107. package/dist/chunks/add-to-dashboard-CFF-wFU-.js +0 -291
  108. package/dist/chunks/analytics-base-schemas-DsUh5Q3C.js +0 -680
  109. package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
  110. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
  111. package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
  112. package/dist/chunks/assistant-chat-B6hNQI1t.js +0 -6115
  113. package/dist/chunks/attribution-BvoKvhcj.js +0 -32
  114. package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
  115. package/dist/chunks/bookmark-impact-Ba2PLcGp.js +0 -76
  116. package/dist/chunks/bookmark-state-n7AaNzR_.js +0 -1667
  117. package/dist/chunks/brand-BoUV0iHF.js +0 -54
  118. package/dist/chunks/card-filter-builder-Y22HizVx.js +0 -4069
  119. package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
  120. package/dist/chunks/comparison-window-caption-Ck2TIbnR.js +0 -741
  121. package/dist/chunks/context-UCQ7sere.js +0 -369
  122. package/dist/chunks/conversation-sQiWYUOb.js +0 -16
  123. package/dist/chunks/dashboard-BghI99oY.js +0 -14
  124. package/dist/chunks/dashboard-briefing-launcher-DtBAnGiH.js +0 -4875
  125. package/dist/chunks/dashboard-controls-CtFXlyjV.js +0 -2290
  126. package/dist/chunks/dashboard-json-DfGBUtCd.js +0 -66
  127. package/dist/chunks/dates-BnrXF4bb.js +0 -185
  128. package/dist/chunks/edit-9df1zOWe.js +0 -226
  129. package/dist/chunks/edit-dashboard-visual-oxt3x1wb.js +0 -18397
  130. package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
  131. package/dist/chunks/filter-line-Cy5YYqRL.js +0 -703
  132. package/dist/chunks/filter-reach-copy-CE_ZX147.js +0 -5111
  133. package/dist/chunks/filter-value-text-fWvSDwkl.js +0 -153
  134. package/dist/chunks/index-BVKzKl5d.js +0 -90
  135. package/dist/chunks/index-CV_Kzou0.js +0 -595
  136. package/dist/chunks/index-D5rxbtS4.js +0 -2795
  137. package/dist/chunks/layout-grid-9LndRoLa.js +0 -16
  138. package/dist/chunks/matrix-analytical-definition-CCp48UCw.js +0 -1233
  139. package/dist/chunks/matrix-member-presentation-zNehruXR.js +0 -391
  140. package/dist/chunks/matrix-operation-contract-DPBj69D8.js +0 -1413
  141. package/dist/chunks/metric-comparison-B0FR-Q8I.js +0 -600
  142. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
  143. package/dist/chunks/paintbrush-58FQYY-y.js +0 -27
  144. package/dist/chunks/palette-Be62Tkoa.js +0 -23
  145. package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
  146. package/dist/chunks/pivot-result-contract-expectations-BYqAmG9n.js +0 -5092
  147. package/dist/chunks/pivot-result-identity-CAP4--iq.js +0 -77
  148. package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +0 -3778
  149. package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
  150. package/dist/chunks/report-preferences-dialog-uJp9GBTM.js +0 -1651
  151. package/dist/chunks/report-runtime-context-c77_KF9v.js +0 -388
  152. package/dist/chunks/resolve-dashboard-input-context-Rtl1ffmE.js +0 -25324
  153. package/dist/chunks/resolver-DG_tfEpt.js +0 -156
  154. package/dist/chunks/save-C5A0JnEV.js +0 -21
  155. package/dist/chunks/saved-dashboard-context-tcyTU8jm.js +0 -618
  156. package/dist/chunks/schema-C9NPiIru.js +0 -2568
  157. package/dist/chunks/selection-filter-compiler-DNijjI5y.js +0 -150
  158. package/dist/chunks/semaphor-ready-indicator-FBvunj6S.js +0 -145603
  159. package/dist/chunks/shelf-drop-preview-context-QKStrcK9.js +0 -2466
  160. package/dist/chunks/stored-dashboard-CHozcAY9.js +0 -4075
  161. package/dist/chunks/style-sheet-parts-CDCG-8Ej.js +0 -8681
  162. package/dist/chunks/table-export-sheet-ZFIvs6Sj.js +0 -949
  163. package/dist/chunks/token-types-XbM6QByy.js +0 -8
  164. package/dist/chunks/upload-H15d7uHK.js +0 -15
  165. package/dist/chunks/validators-Baf3VIf5.js +0 -3686
  166. package/dist/chunks/variable-draft-C2y8Jp6Z.js +0 -242
  167. package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
@@ -1,2290 +0,0 @@
1
- import { jsx as e, jsxs as o, Fragment as R } from "react/jsx-runtime";
2
- import { cz as Fr, u as k, cA as $r, cB as Gr, cC as ot, cD as Vr, cE as Hr, cF as jr, cG as qr, cH as zr, cI as Kr, b8 as J, b5 as xe, cJ as ve, bG as C, cK as Qr, bH as $t, bI as Gt, bK as tt, bL as rt, cL as Vt, b_ as it, bV as Wr, bT as ne, cM as Jr, cN as Yr, cO as Ht, cP as Xr, cQ as jt, bP as Zr, bJ as ea, cR as ta, cS as A, cT as ra, bM as aa, cU as na, aS as sa, cV as oa, bv as ia, cW as da, bw as ca, p as la, aa as ua, am as Et, o as Be, x as ma, q as Xe, O as ha, cX as pa, cY as fa, a8 as ga, cZ as ba, s as xa, c_ as va, I as ya, c$ as wa, d0 as Na, d1 as Sa, d2 as At, d3 as It, d4 as Mt, d5 as Da, bx as ka, d6 as Ca, T as Ea, d7 as Aa, d8 as Ia, d9 as ae, da as he, db as Ma, dc as La, dd as Oa, de as Lt, w as Pa, df as _a, dg as Ta, dh as Ra, di as Ua, dj as Ba, dk as Fa, dl as $a, dm as Ga, dn as Ot, Q as Va } from "./semaphor-ready-indicator-FBvunj6S.js";
3
- import { c as ye, B as V, a5 as Ha, a6 as ja, a7 as at, L as $e, X as qt, s as qa, y as za, z as Ka, A as Qa, D as Wa, E as Ja, e as Ya, f as Xa, h as Za, F as en, t as tn, u as rn, v as an, I as nn, w as sn, j as zt, g as Pt } from "./style-sheet-parts-CDCG-8Ej.js";
4
- import * as E from "react";
5
- import Kt, { useMemo as H, useState as N, useEffect as ge, useRef as _t, useLayoutEffect as on } from "react";
6
- import { c as be } from "./pickers-DkqmtnTL.js";
7
- import "./validators-Baf3VIf5.js";
8
- import "./matrix-operation-contract-DPBj69D8.js";
9
- import "./analytics-base-schemas-DsUh5Q3C.js";
10
- import "../value-format-preferences/index.js";
11
- import { u as dn, c as cn, k as ln, D as un, A as mn, a as hn, h as pn, l as fn, V as gn, b as bn, d as xn, S as vn, j as yn, i as wn, m as Nn, U as Sn } from "./dashboard-briefing-launcher-DtBAnGiH.js";
12
- import { I as Dn } from "./card-filter-builder-Y22HizVx.js";
13
- import { c as kn, R as Cn } from "./report-preferences-dialog-uJp9GBTM.js";
14
- import { createPortal as En } from "react-dom";
15
- import { i7 as we, i8 as dt, i9 as Qt, q as An } from "./resolve-dashboard-input-context-Rtl1ffmE.js";
16
- import { aX as Wt } from "./pivot-result-contract-expectations-BYqAmG9n.js";
17
- import { g as nt } from "./stored-dashboard-CHozcAY9.js";
18
- import { r as In } from "./export-file-format-C-tJsxsf.js";
19
- import { u as Mn, s as Ln } from "./normalize-dashboard-for-dirty-check-XKgH3GFX.js";
20
- import { A as Jt } from "./bookmark-state-n7AaNzR_.js";
21
- import { d as On, a as Pn } from "./bookmark-impact-Ba2PLcGp.js";
22
- import { S as _n } from "./save-C5A0JnEV.js";
23
- import { P as Tn } from "./paintbrush-58FQYY-y.js";
24
- import { P as Rn } from "./palette-Be62Tkoa.js";
25
- /**
26
- * @license lucide-react v0.453.0 - ISC
27
- *
28
- * This source code is licensed under the ISC license.
29
- * See the LICENSE file in the root directory of this source tree.
30
- */
31
- const Un = ye("Moon", [
32
- ["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
33
- ]);
34
- /**
35
- * @license lucide-react v0.453.0 - ISC
36
- *
37
- * This source code is licensed under the ISC license.
38
- * See the LICENSE file in the root directory of this source tree.
39
- */
40
- const Bn = ye("ShieldX", [
41
- [
42
- "path",
43
- {
44
- 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",
45
- key: "oel41y"
46
- }
47
- ],
48
- ["path", { d: "m14.5 9.5-5 5", key: "17q4r4" }],
49
- ["path", { d: "m9.5 9.5 5 5", key: "18nt4w" }]
50
- ]);
51
- /**
52
- * @license lucide-react v0.453.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */
57
- const Fn = ye("Sun", [
58
- ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
59
- ["path", { d: "M12 2v2", key: "tus03m" }],
60
- ["path", { d: "M12 20v2", key: "1lh1kg" }],
61
- ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
62
- ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
63
- ["path", { d: "M2 12h2", key: "1t8f8n" }],
64
- ["path", { d: "M20 12h2", key: "1q8mjw" }],
65
- ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
66
- ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
67
- ]);
68
- /**
69
- * @license lucide-react v0.453.0 - ISC
70
- *
71
- * This source code is licensed under the ISC license.
72
- * See the LICENSE file in the root directory of this source tree.
73
- */
74
- const $n = ye("UserPlus", [
75
- ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
76
- ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
77
- ["line", { x1: "19", x2: "19", y1: "8", y2: "14", key: "1bvyxn" }],
78
- ["line", { x1: "22", x2: "16", y1: "11", y2: "11", key: "1shjgl" }]
79
- ]);
80
- /**
81
- * @license lucide-react v0.453.0 - ISC
82
- *
83
- * This source code is licensed under the ISC license.
84
- * See the LICENSE file in the root directory of this source tree.
85
- */
86
- const Yt = ye("UserRound", [
87
- ["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
88
- ["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
89
- ]);
90
- var st = { exports: {} }, Ze = {};
91
- /**
92
- * @license React
93
- * use-sync-external-store-shim.production.js
94
- *
95
- * Copyright (c) Meta Platforms, Inc. and affiliates.
96
- *
97
- * This source code is licensed under the MIT license found in the
98
- * LICENSE file in the root directory of this source tree.
99
- */
100
- var Tt;
101
- function Gn() {
102
- if (Tt) return Ze;
103
- Tt = 1;
104
- var t = Kt;
105
- function n(i, f) {
106
- return i === f && (i !== 0 || 1 / i === 1 / f) || i !== i && f !== f;
107
- }
108
- var a = typeof Object.is == "function" ? Object.is : n, r = t.useState, s = t.useEffect, c = t.useLayoutEffect, u = t.useDebugValue;
109
- function m(i, f) {
110
- var l = f(), x = r({ inst: { value: l, getSnapshot: f } }), h = x[0].inst, w = x[1];
111
- return c(
112
- function() {
113
- h.value = l, h.getSnapshot = f, p(h) && w({ inst: h });
114
- },
115
- [i, l, f]
116
- ), s(
117
- function() {
118
- return p(h) && w({ inst: h }), i(function() {
119
- p(h) && w({ inst: h });
120
- });
121
- },
122
- [i]
123
- ), u(l), l;
124
- }
125
- function p(i) {
126
- var f = i.getSnapshot;
127
- i = i.value;
128
- try {
129
- var l = f();
130
- return !a(i, l);
131
- } catch {
132
- return !0;
133
- }
134
- }
135
- function y(i, f) {
136
- return f();
137
- }
138
- var g = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? y : m;
139
- return Ze.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : g, Ze;
140
- }
141
- var et = {};
142
- /**
143
- * @license React
144
- * use-sync-external-store-shim.development.js
145
- *
146
- * Copyright (c) Meta Platforms, Inc. and affiliates.
147
- *
148
- * This source code is licensed under the MIT license found in the
149
- * LICENSE file in the root directory of this source tree.
150
- */
151
- var Rt;
152
- function Vn() {
153
- return Rt || (Rt = 1, process.env.NODE_ENV !== "production" && function() {
154
- function t(l, x) {
155
- return l === x && (l !== 0 || 1 / l === 1 / x) || l !== l && x !== x;
156
- }
157
- function n(l, x) {
158
- g || s.startTransition === void 0 || (g = !0, console.error(
159
- "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."
160
- ));
161
- var h = x();
162
- if (!i) {
163
- var w = x();
164
- c(h, w) || (console.error(
165
- "The result of getSnapshot should be cached to avoid an infinite loop"
166
- ), i = !0);
167
- }
168
- w = u({
169
- inst: { value: h, getSnapshot: x }
170
- });
171
- var S = w[0].inst, O = w[1];
172
- return p(
173
- function() {
174
- S.value = h, S.getSnapshot = x, a(S) && O({ inst: S });
175
- },
176
- [l, h, x]
177
- ), m(
178
- function() {
179
- return a(S) && O({ inst: S }), l(function() {
180
- a(S) && O({ inst: S });
181
- });
182
- },
183
- [l]
184
- ), y(h), h;
185
- }
186
- function a(l) {
187
- var x = l.getSnapshot;
188
- l = l.value;
189
- try {
190
- var h = x();
191
- return !c(l, h);
192
- } catch {
193
- return !0;
194
- }
195
- }
196
- function r(l, x) {
197
- return x();
198
- }
199
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
200
- var s = Kt, c = typeof Object.is == "function" ? Object.is : t, u = s.useState, m = s.useEffect, p = s.useLayoutEffect, y = s.useDebugValue, g = !1, i = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : n;
201
- et.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
202
- }()), et;
203
- }
204
- process.env.NODE_ENV === "production" ? st.exports = Gn() : st.exports = Vn();
205
- var Hn = st.exports;
206
- const Fe = ["light", "dark", "system"];
207
- function jn() {
208
- const { theme: t, setTheme: n } = Fr(), a = k(
209
- (u) => u.actions.setDashboardTheme
210
- );
211
- function r() {
212
- const u = Fe.includes(t) ? t : "system", m = Fe[(Fe.indexOf(u) + 1) % Fe.length];
213
- n(m), a(m);
214
- }
215
- const s = t === "light" ? Fn : t === "dark" ? Un : $r, c = t === "light" ? "Theme: light (click for dark)" : t === "dark" ? "Theme: dark (click for system)" : "Theme: system (click for light)";
216
- return /* @__PURE__ */ e(
217
- V,
218
- {
219
- type: "button",
220
- variant: "ghost",
221
- size: "xs",
222
- className: "h-7 w-7 p-0",
223
- onClick: r,
224
- "aria-label": c,
225
- title: c,
226
- children: /* @__PURE__ */ e(s, { className: "h-3.5 w-3.5", strokeWidth: 1.5 })
227
- }
228
- );
229
- }
230
- function qn() {
231
- const { displayPreferences: t, shouldShowElement: n } = Gr(), { currentUser: a, userContext: r } = ot(), s = H(
232
- () => Vr(a),
233
- [a]
234
- ), c = H(() => (m) => s && s[m] !== void 0 && s[m] === !1 ? !1 : n(m), [s, n, t]), u = H(
235
- () => {
236
- var m, p, y, g, i;
237
- return {
238
- canEdit: ((m = r == null ? void 0 : r.permissions) == null ? void 0 : m.canEdit) ?? Kr(a),
239
- canUseFilters: ((p = r == null ? void 0 : r.permissions) == null ? void 0 : p.canEdit) ?? zr(a),
240
- canManageDashboards: ((y = r == null ? void 0 : r.permissions) == null ? void 0 : y.canCreateDashboard) ?? qr(a),
241
- canCreateDashboards: ((g = r == null ? void 0 : r.permissions) == null ? void 0 : g.canCreateDashboard) ?? jr(a),
242
- canAccessVisuals: ((i = r == null ? void 0 : r.permissions) == null ? void 0 : i.canEdit) ?? Hr(a)
243
- };
244
- },
245
- [a, r]
246
- );
247
- return {
248
- displayPreferences: t,
249
- shouldShowElement: c,
250
- permissions: u,
251
- currentUser: a
252
- };
253
- }
254
- function zn(t, n = []) {
255
- let a = [];
256
- function r(c, u) {
257
- const m = E.createContext(u);
258
- m.displayName = c + "Context";
259
- const p = a.length;
260
- a = [...a, u];
261
- const y = (i) => {
262
- var S;
263
- const { scope: f, children: l, ...x } = i, h = ((S = f == null ? void 0 : f[t]) == null ? void 0 : S[p]) || m, w = E.useMemo(() => x, Object.values(x));
264
- return /* @__PURE__ */ e(h.Provider, { value: w, children: l });
265
- };
266
- y.displayName = c + "Provider";
267
- function g(i, f) {
268
- var h;
269
- const l = ((h = f == null ? void 0 : f[t]) == null ? void 0 : h[p]) || m, x = E.useContext(l);
270
- if (x) return x;
271
- if (u !== void 0) return u;
272
- throw new Error(`\`${i}\` must be used within \`${c}\``);
273
- }
274
- return [y, g];
275
- }
276
- const s = () => {
277
- const c = a.map((u) => E.createContext(u));
278
- return function(m) {
279
- const p = (m == null ? void 0 : m[t]) || c;
280
- return E.useMemo(
281
- () => ({ [`__scope${t}`]: { ...m, [t]: p } }),
282
- [m, p]
283
- );
284
- };
285
- };
286
- return s.scopeName = t, [r, Kn(s, ...n)];
287
- }
288
- function Kn(...t) {
289
- const n = t[0];
290
- if (t.length === 1) return n;
291
- const a = () => {
292
- const r = t.map((s) => ({
293
- useScope: s(),
294
- scopeName: s.scopeName
295
- }));
296
- return function(c) {
297
- const u = r.reduce((m, { useScope: p, scopeName: y }) => {
298
- const i = p(c)[`__scope${y}`];
299
- return { ...m, ...i };
300
- }, {});
301
- return E.useMemo(() => ({ [`__scope${n.scopeName}`]: u }), [u]);
302
- };
303
- };
304
- return a.scopeName = n.scopeName, a;
305
- }
306
- var Qn = [
307
- "a",
308
- "button",
309
- "div",
310
- "form",
311
- "h2",
312
- "h3",
313
- "img",
314
- "input",
315
- "label",
316
- "li",
317
- "nav",
318
- "ol",
319
- "p",
320
- "select",
321
- "span",
322
- "svg",
323
- "ul"
324
- ], ct = Qn.reduce((t, n) => {
325
- const a = Ha(`Primitive.${n}`), r = E.forwardRef((s, c) => {
326
- const { asChild: u, ...m } = s, p = u ? a : n;
327
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ e(p, { ...m, ref: c });
328
- });
329
- return r.displayName = `Primitive.${n}`, { ...t, [n]: r };
330
- }, {});
331
- function Wn() {
332
- return Hn.useSyncExternalStore(
333
- Jn,
334
- () => !0,
335
- () => !1
336
- );
337
- }
338
- function Jn() {
339
- return () => {
340
- };
341
- }
342
- var lt = "Avatar", [Yn] = zn(lt), [Xn, Xt] = Yn(lt), Zt = E.forwardRef(
343
- (t, n) => {
344
- const { __scopeAvatar: a, ...r } = t, [s, c] = E.useState("idle");
345
- return /* @__PURE__ */ e(
346
- Xn,
347
- {
348
- scope: a,
349
- imageLoadingStatus: s,
350
- onImageLoadingStatusChange: c,
351
- children: /* @__PURE__ */ e(ct.span, { ...r, ref: n })
352
- }
353
- );
354
- }
355
- );
356
- Zt.displayName = lt;
357
- var er = "AvatarImage", tr = E.forwardRef(
358
- (t, n) => {
359
- const { __scopeAvatar: a, src: r, onLoadingStatusChange: s = () => {
360
- }, ...c } = t, u = Xt(er, a), m = Zn(r, c), p = ja((y) => {
361
- s(y), u.onImageLoadingStatusChange(y);
362
- });
363
- return at(() => {
364
- m !== "idle" && p(m);
365
- }, [m, p]), m === "loaded" ? /* @__PURE__ */ e(ct.img, { ...c, ref: n, src: r }) : null;
366
- }
367
- );
368
- tr.displayName = er;
369
- var rr = "AvatarFallback", ar = E.forwardRef(
370
- (t, n) => {
371
- const { __scopeAvatar: a, delayMs: r, ...s } = t, c = Xt(rr, a), [u, m] = E.useState(r === void 0);
372
- return E.useEffect(() => {
373
- if (r !== void 0) {
374
- const p = window.setTimeout(() => m(!0), r);
375
- return () => window.clearTimeout(p);
376
- }
377
- }, [r]), u && c.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ e(ct.span, { ...s, ref: n }) : null;
378
- }
379
- );
380
- ar.displayName = rr;
381
- function Ut(t, n) {
382
- return t ? n ? (t.src !== n && (t.src = n), t.complete && t.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
383
- }
384
- function Zn(t, { referrerPolicy: n, crossOrigin: a }) {
385
- const r = Wn(), s = E.useRef(null), c = r ? (s.current || (s.current = new window.Image()), s.current) : null, [u, m] = E.useState(
386
- () => Ut(c, t)
387
- );
388
- return at(() => {
389
- m(Ut(c, t));
390
- }, [c, t]), at(() => {
391
- const p = (i) => () => {
392
- m(i);
393
- };
394
- if (!c) return;
395
- const y = p("loaded"), g = p("error");
396
- return c.addEventListener("load", y), c.addEventListener("error", g), n && (c.referrerPolicy = n), typeof a == "string" && (c.crossOrigin = a), () => {
397
- c.removeEventListener("load", y), c.removeEventListener("error", g);
398
- };
399
- }, [c, a, n]), u;
400
- }
401
- var nr = Zt, sr = tr, or = ar;
402
- const ir = E.forwardRef(({ className: t, ...n }, a) => /* @__PURE__ */ e(
403
- nr,
404
- {
405
- ref: a,
406
- className: be(
407
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
408
- t
409
- ),
410
- ...n
411
- }
412
- ));
413
- ir.displayName = nr.displayName;
414
- const es = E.forwardRef(({ className: t, ...n }, a) => /* @__PURE__ */ e(
415
- sr,
416
- {
417
- ref: a,
418
- className: be("aspect-square h-full w-full", t),
419
- ...n
420
- }
421
- ));
422
- es.displayName = sr.displayName;
423
- const dr = E.forwardRef(({ className: t, ...n }, a) => /* @__PURE__ */ e(
424
- or,
425
- {
426
- ref: a,
427
- className: be(
428
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
429
- t
430
- ),
431
- ...n
432
- }
433
- ));
434
- dr.displayName = or.displayName;
435
- const ts = async (t, n, a) => {
436
- const r = `${t}/management/v1/groups`;
437
- return await Qt(r, n, a);
438
- }, rs = async (t, n, a, r) => {
439
- const s = `${t}/management/v1/groups/${a}`;
440
- return dt(s, n, "PATCH", r);
441
- }, as = async (t, n, a) => {
442
- const r = `${t}/management/v1/groups/${a}`;
443
- await dt(r, n, "DELETE");
444
- }, ns = async (t, n, a, r) => {
445
- const s = `${t}/management/v1/groups/${a}/members`;
446
- return await Qt(s, n, r);
447
- }, ss = async (t, n, a, r) => {
448
- const s = `${t}/management/v1/groups/${a}/members`;
449
- await dt(s, n, "DELETE", r);
450
- };
451
- function os() {
452
- const { authToken: t, tokenProps: n } = J(), a = xe();
453
- return ve({
454
- mutationFn: (r) => ts(n.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", r),
455
- onSuccess: () => {
456
- a.invalidateQueries({ queryKey: ["groups"] }), C.success("Group created successfully");
457
- },
458
- onError: (r) => {
459
- console.error("Failed to create group:", r), C.error("Failed to create group", {
460
- description: we(r, "Failed to create group")
461
- });
462
- }
463
- });
464
- }
465
- function is() {
466
- const { authToken: t, tokenProps: n } = J(), a = xe();
467
- return ve({
468
- mutationFn: ({
469
- groupId: r,
470
- data: s
471
- }) => rs(n.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", r, s),
472
- onSuccess: (r, s) => {
473
- a.invalidateQueries({ queryKey: ["group", s.groupId] }), a.invalidateQueries({ queryKey: ["groups"] }), C.success("Group updated successfully");
474
- },
475
- onError: (r) => {
476
- console.error("Failed to update group:", r), C.error("Failed to update group", {
477
- description: we(r, "Failed to update group")
478
- });
479
- }
480
- });
481
- }
482
- function ds() {
483
- const { authToken: t, tokenProps: n } = J(), a = xe();
484
- return ve({
485
- mutationFn: (r) => as(n.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", r),
486
- onSuccess: (r, s) => {
487
- a.invalidateQueries({ queryKey: ["groups"] }), a.removeQueries({ queryKey: ["group", s] }), C.success("Group deleted successfully");
488
- },
489
- onError: (r) => {
490
- console.error("Failed to delete group:", r), C.error("Failed to delete group", {
491
- description: we(r, "Failed to delete group")
492
- });
493
- }
494
- });
495
- }
496
- function cs() {
497
- const { authToken: t, tokenProps: n } = J(), a = xe();
498
- return ve({
499
- mutationFn: ({
500
- groupId: r,
501
- data: s
502
- }) => ns(n.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", r, s),
503
- onSuccess: (r, s) => {
504
- a.invalidateQueries({ queryKey: ["group", s.groupId] }), a.invalidateQueries({
505
- queryKey: ["group-members", s.groupId]
506
- }), a.invalidateQueries({ queryKey: ["groups"] }), C.success("Members added successfully");
507
- },
508
- onError: (r) => {
509
- console.error("Failed to add group members:", r), C.error("Failed to add members", {
510
- description: we(r, "Failed to add members")
511
- });
512
- }
513
- });
514
- }
515
- function ls() {
516
- const { authToken: t, tokenProps: n } = J(), a = xe();
517
- return ve({
518
- mutationFn: ({
519
- groupId: r,
520
- data: s
521
- }) => ss(n.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", r, s),
522
- onSuccess: (r, s) => {
523
- a.invalidateQueries({ queryKey: ["group", s.groupId] }), a.invalidateQueries({
524
- queryKey: ["group-members", s.groupId]
525
- }), a.invalidateQueries({ queryKey: ["groups"] }), C.success("Members removed successfully");
526
- },
527
- onError: (r) => {
528
- console.error("Failed to remove group members:", r), C.error("Failed to remove members", {
529
- description: we(r, "Failed to remove members")
530
- });
531
- }
532
- });
533
- }
534
- const us = [];
535
- function ms({
536
- open: t,
537
- onOpenChange: n
538
- }) {
539
- var O, b, F;
540
- const { tokenProps: a } = J(), { currentUser: r } = ot(), s = (r == null ? void 0 : r.type) === "tenant", c = a == null ? void 0 : a.tenantId, {
541
- groups: u,
542
- isLoading: m,
543
- error: p,
544
- refetch: y
545
- } = Qr({
546
- type: s ? "TENANT_GROUP" : "all",
547
- tenantId: s ? c : void 0,
548
- includeMembers: !1
549
- }), g = p ? cr(p, "Unable to load groups.") : null, [i, f] = N({ kind: "list" }), [l, x] = N(null), h = ds();
550
- ge(() => {
551
- t || (f({ kind: "list" }), x(null));
552
- }, [t]);
553
- const w = i.kind === "members" && u.find((P) => P.id === i.groupId) || null, S = async () => {
554
- if (l)
555
- try {
556
- await h.mutateAsync(l.id), x(null), f({ kind: "list" }), y();
557
- } catch {
558
- }
559
- };
560
- return /* @__PURE__ */ e($t, { open: t, onOpenChange: n, children: /* @__PURE__ */ o(Gt, { className: "flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0", children: [
561
- i.kind === "list" ? /* @__PURE__ */ o("div", { className: "shrink-0 border-b border-border px-5 pt-4 pb-3.5", children: [
562
- /* @__PURE__ */ e(tt, { className: "text-[15px] font-semibold tracking-tight", children: "Group management" }),
563
- /* @__PURE__ */ e(rt, { className: "mt-1 text-[12px] leading-[1.5] text-muted-foreground", children: "Organize people into groups for shared access." })
564
- ] }) : i.kind === "create" ? /* @__PURE__ */ o("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
565
- /* @__PURE__ */ e(
566
- "button",
567
- {
568
- type: "button",
569
- onClick: () => f({ kind: "list" }),
570
- "aria-label": "Back",
571
- className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
572
- children: /* @__PURE__ */ e(Vt, { className: "h-3.5 w-3.5" })
573
- }
574
- ),
575
- /* @__PURE__ */ e(tt, { className: "truncate text-[13px] font-medium", children: "New group" }),
576
- /* @__PURE__ */ e(rt, { className: "sr-only", children: "Create a new group to organize members." })
577
- ] }) : null,
578
- i.kind === "list" && /* @__PURE__ */ e(
579
- hs,
580
- {
581
- groups: u,
582
- isLoading: m,
583
- errorMessage: g,
584
- onRetry: () => y(),
585
- currentUserId: r == null ? void 0 : r.id,
586
- onOpenGroup: (P) => f({ kind: "members", groupId: P }),
587
- onCreate: () => f({ kind: "create" }),
588
- onDeleteRequest: (P) => x(P)
589
- }
590
- ),
591
- i.kind === "members" && w && /* @__PURE__ */ e(
592
- gs,
593
- {
594
- group: w,
595
- isTenantViewer: s,
596
- canEdit: ((O = w.permissions) == null ? void 0 : O.canEdit) ?? w.createdBy === (r == null ? void 0 : r.id),
597
- canDelete: ((b = w.permissions) == null ? void 0 : b.canDelete) ?? w.createdBy === (r == null ? void 0 : r.id),
598
- canManageMembers: ((F = w.permissions) == null ? void 0 : F.canManageMembers) ?? w.createdBy === (r == null ? void 0 : r.id),
599
- onBack: () => f({ kind: "list" }),
600
- onMembersChanged: y,
601
- onUpdated: y,
602
- onRequestDelete: () => x(w)
603
- },
604
- w.id
605
- ),
606
- i.kind === "create" && /* @__PURE__ */ e(
607
- bs,
608
- {
609
- isTenantUser: s,
610
- tenantId: c,
611
- onCancel: () => f({ kind: "list" }),
612
- onCreated: (P) => {
613
- y(), f({ kind: "members", groupId: P });
614
- }
615
- }
616
- ),
617
- l && /* @__PURE__ */ o("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5", children: [
618
- /* @__PURE__ */ o("div", { className: "min-w-0 text-[12px] text-foreground", children: [
619
- "Delete ",
620
- /* @__PURE__ */ e("span", { className: "font-medium", children: l.name }),
621
- "?",
622
- /* @__PURE__ */ e("span", { className: "ml-2 text-muted-foreground", children: "Members lose any access granted via this group." })
623
- ] }),
624
- /* @__PURE__ */ o("div", { className: "flex shrink-0 items-center gap-1.5", children: [
625
- /* @__PURE__ */ e(
626
- "button",
627
- {
628
- type: "button",
629
- onClick: () => x(null),
630
- disabled: h.isPending,
631
- className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",
632
- children: "Cancel"
633
- }
634
- ),
635
- /* @__PURE__ */ o(
636
- "button",
637
- {
638
- type: "button",
639
- onClick: S,
640
- disabled: h.isPending,
641
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",
642
- children: [
643
- h.isPending ? /* @__PURE__ */ e($e, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(it, { className: "h-3 w-3" }),
644
- "Delete group"
645
- ]
646
- }
647
- )
648
- ] })
649
- ] })
650
- ] }) });
651
- }
652
- function hs({
653
- groups: t,
654
- isLoading: n,
655
- errorMessage: a,
656
- onRetry: r,
657
- currentUserId: s,
658
- onOpenGroup: c,
659
- onCreate: u,
660
- onDeleteRequest: m
661
- }) {
662
- const [p, y] = N(""), g = H(
663
- () => t.filter(
664
- (i) => !p.trim() || i.name.toLowerCase().includes(p.toLowerCase()) || (i.description || "").toLowerCase().includes(p.toLowerCase())
665
- ),
666
- [t, p]
667
- );
668
- return /* @__PURE__ */ o("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
669
- /* @__PURE__ */ o("div", { className: "flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5", children: [
670
- /* @__PURE__ */ o("div", { className: "flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40", children: [
671
- /* @__PURE__ */ e(Wr, { className: "h-3 w-3 text-muted-foreground" }),
672
- /* @__PURE__ */ e(
673
- "input",
674
- {
675
- value: p,
676
- onChange: (i) => y(i.target.value),
677
- placeholder: "Search groups…",
678
- className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"
679
- }
680
- ),
681
- p && /* @__PURE__ */ e(
682
- "button",
683
- {
684
- type: "button",
685
- onClick: () => y(""),
686
- className: "flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
687
- children: /* @__PURE__ */ e(qt, { className: "h-2.5 w-2.5" })
688
- }
689
- )
690
- ] }),
691
- /* @__PURE__ */ o(
692
- "button",
693
- {
694
- type: "button",
695
- onClick: u,
696
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
697
- children: [
698
- /* @__PURE__ */ e(ne, { className: "h-3 w-3" }),
699
- "New group"
700
- ]
701
- }
702
- )
703
- ] }),
704
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto", children: n ? /* @__PURE__ */ e("div", { className: "space-y-px p-3", children: [1, 2, 3].map((i) => /* @__PURE__ */ e(
705
- "div",
706
- {
707
- className: "h-12 animate-pulse rounded-[4px] bg-muted/60"
708
- },
709
- i
710
- )) }) : a ? /* @__PURE__ */ e(
711
- lr,
712
- {
713
- title: "Can't load groups",
714
- message: a,
715
- onRetry: r
716
- }
717
- ) : g.length === 0 && t.length === 0 ? /* @__PURE__ */ e(fs, { onCreate: u }) : g.length === 0 ? /* @__PURE__ */ o("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
718
- /* @__PURE__ */ o("div", { className: "text-[12px] text-foreground", children: [
719
- 'No groups match "',
720
- p,
721
- '"'
722
- ] }),
723
- /* @__PURE__ */ e("div", { className: "text-[11px] text-muted-foreground", children: "Try a different search." })
724
- ] }) : g.map((i) => {
725
- var f;
726
- return /* @__PURE__ */ e(
727
- ps,
728
- {
729
- group: i,
730
- canDelete: ((f = i.permissions) == null ? void 0 : f.canDelete) ?? i.createdBy === s,
731
- onClick: () => c(i.id),
732
- onDelete: () => m(i)
733
- },
734
- i.id
735
- );
736
- }) })
737
- ] });
738
- }
739
- function ps({
740
- group: t,
741
- canDelete: n,
742
- onClick: a,
743
- onDelete: r
744
- }) {
745
- let s = "";
746
- try {
747
- s = Wt(new Date(t.createdAt), "MMM d, yyyy");
748
- } catch {
749
- s = "";
750
- }
751
- return /* @__PURE__ */ o(
752
- "button",
753
- {
754
- type: "button",
755
- onClick: a,
756
- className: "group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",
757
- children: [
758
- /* @__PURE__ */ e("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground", children: /* @__PURE__ */ e(Xr, { className: "h-3.5 w-3.5" }) }),
759
- /* @__PURE__ */ o("div", { className: "min-w-0 flex-1", children: [
760
- /* @__PURE__ */ e("div", { className: "truncate text-[13px] font-medium text-foreground", children: t.name }),
761
- /* @__PURE__ */ o("div", { className: "mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground", children: [
762
- /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-1", children: [
763
- /* @__PURE__ */ e(Yt, { className: "h-2.5 w-2.5" }),
764
- t.memberCount,
765
- " member",
766
- t.memberCount === 1 ? "" : "s"
767
- ] }),
768
- s && /* @__PURE__ */ o(R, { children: [
769
- /* @__PURE__ */ e("span", { className: "text-border", children: "·" }),
770
- /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-1", children: [
771
- /* @__PURE__ */ e(jt, { className: "h-2.5 w-2.5" }),
772
- s
773
- ] })
774
- ] }),
775
- t.description && /* @__PURE__ */ o(R, { children: [
776
- /* @__PURE__ */ e("span", { className: "text-border", children: "·" }),
777
- /* @__PURE__ */ e("span", { className: "truncate text-muted-foreground", children: t.description })
778
- ] })
779
- ] })
780
- ] }),
781
- /* @__PURE__ */ o("div", { className: "flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100", children: [
782
- n && /* @__PURE__ */ e(
783
- "span",
784
- {
785
- role: "button",
786
- tabIndex: 0,
787
- onClick: (c) => {
788
- c.stopPropagation(), r();
789
- },
790
- onKeyDown: (c) => {
791
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), c.stopPropagation(), r());
792
- },
793
- "aria-label": `Delete ${t.name}`,
794
- className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
795
- children: /* @__PURE__ */ e(it, { className: "h-3 w-3" })
796
- }
797
- ),
798
- /* @__PURE__ */ e(Zr, { className: "h-3.5 w-3.5 text-muted-foreground" })
799
- ] })
800
- ]
801
- }
802
- );
803
- }
804
- function fs({ onCreate: t }) {
805
- return /* @__PURE__ */ o("div", { className: "flex h-full flex-col items-center justify-center gap-2 py-12 text-center", children: [
806
- /* @__PURE__ */ e("div", { className: "flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground", children: /* @__PURE__ */ e(Ht, { className: "h-4 w-4" }) }),
807
- /* @__PURE__ */ e("div", { className: "text-[13px] font-medium text-foreground", children: "No groups yet" }),
808
- /* @__PURE__ */ e("div", { className: "max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground", children: "Groups let you grant shared access to dashboards. Create one and add members." }),
809
- /* @__PURE__ */ o(
810
- "button",
811
- {
812
- type: "button",
813
- onClick: t,
814
- className: "mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
815
- children: [
816
- /* @__PURE__ */ e(ne, { className: "h-3 w-3" }),
817
- "New group"
818
- ]
819
- }
820
- )
821
- ] });
822
- }
823
- function gs({
824
- group: t,
825
- isTenantViewer: n,
826
- canEdit: a,
827
- canDelete: r,
828
- canManageMembers: s,
829
- onBack: c,
830
- onMembersChanged: u,
831
- onUpdated: m,
832
- onRequestDelete: p
833
- }) {
834
- const {
835
- data: y,
836
- isLoading: g,
837
- error: i,
838
- refetch: f
839
- } = Jr(t.id), l = (y == null ? void 0 : y.members) ?? us, x = i ? cr(i, "Unable to load members for this group.") : null, h = t.type === "TENANT_GROUP" ? "tenant" : "organization", { users: w } = Yr({
840
- type: h,
841
- tenantId: t.tenantId || void 0,
842
- active: !0,
843
- limit: 200
844
- }), S = H(
845
- () => new Set(l.map((v) => v.userId)),
846
- [l]
847
- ), O = cs(), b = ls(), F = is(), [P, $] = N(!1), [M, D] = N(t.name), [Ne, Y] = N(!1), [X, Z] = N(t.description || ""), [ee, Se] = N(""), [De, ke] = N(!1), Ce = H(() => {
848
- const v = ee.trim().toLowerCase();
849
- return w.filter((B) => !S.has(B.id)).filter(
850
- (B) => !v || (B.name || "").toLowerCase().includes(v) || (B.email || "").toLowerCase().includes(v)
851
- ).slice(0, 50);
852
- }, [w, S, ee]), se = async () => {
853
- const v = M.trim();
854
- if ($(!1), v.length >= 3 && v !== t.name)
855
- try {
856
- await F.mutateAsync({
857
- groupId: t.id,
858
- data: { name: v }
859
- }), m();
860
- } catch {
861
- }
862
- }, te = async () => {
863
- const v = X.trim();
864
- if (Y(!1), v !== (t.description || ""))
865
- try {
866
- await F.mutateAsync({
867
- groupId: t.id,
868
- data: { description: v }
869
- }), m();
870
- } catch {
871
- }
872
- }, Ee = async (v) => {
873
- if (s) {
874
- Se(""), ke(!1);
875
- try {
876
- await O.mutateAsync({
877
- groupId: t.id,
878
- data: {
879
- userIds: [v.id],
880
- userType: h === "tenant" ? "tenant" : "org"
881
- }
882
- }), f(), u();
883
- } catch {
884
- }
885
- }
886
- }, Ae = async (v) => {
887
- if (s)
888
- try {
889
- await b.mutateAsync({
890
- groupId: t.id,
891
- data: { userIds: [v] }
892
- }), f(), u();
893
- } catch {
894
- }
895
- };
896
- let j = "";
897
- try {
898
- j = Wt(new Date(t.createdAt), "MMM d, yyyy");
899
- } catch {
900
- j = "";
901
- }
902
- return /* @__PURE__ */ o("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
903
- /* @__PURE__ */ o("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
904
- /* @__PURE__ */ e(
905
- "button",
906
- {
907
- type: "button",
908
- onClick: c,
909
- "aria-label": "Back",
910
- className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
911
- children: /* @__PURE__ */ e(Vt, { className: "h-3.5 w-3.5" })
912
- }
913
- ),
914
- P ? /* @__PURE__ */ e(
915
- "input",
916
- {
917
- autoFocus: !0,
918
- value: M,
919
- onChange: (v) => D(v.target.value),
920
- onBlur: se,
921
- onKeyDown: (v) => {
922
- v.key === "Enter" && se(), v.key === "Escape" && (D(t.name), $(!1));
923
- },
924
- className: "h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"
925
- }
926
- ) : /* @__PURE__ */ e(
927
- "button",
928
- {
929
- type: "button",
930
- onClick: () => {
931
- a && (D(t.name), $(!0));
932
- },
933
- title: a ? "Click to rename" : t.name,
934
- disabled: !a,
935
- className: "truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",
936
- children: t.name
937
- }
938
- ),
939
- /* @__PURE__ */ o("span", { className: "ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground", children: [
940
- /* @__PURE__ */ e(Yt, { className: "h-2.5 w-2.5" }),
941
- l.length,
942
- " member",
943
- l.length === 1 ? "" : "s"
944
- ] })
945
- ] }),
946
- /* @__PURE__ */ e("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: Ne ? /* @__PURE__ */ o("div", { children: [
947
- /* @__PURE__ */ e(
948
- "textarea",
949
- {
950
- autoFocus: !0,
951
- rows: 2,
952
- value: X,
953
- onChange: (v) => Z(v.target.value),
954
- maxLength: 200,
955
- onKeyDown: (v) => {
956
- v.key === "Escape" && (Z(t.description || ""), Y(!1)), v.key === "Enter" && (v.metaKey || v.ctrlKey) && te();
957
- },
958
- placeholder: "What is this group for?",
959
- className: "block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
960
- }
961
- ),
962
- /* @__PURE__ */ o("div", { className: "mt-1.5 flex items-center justify-between", children: [
963
- /* @__PURE__ */ o("span", { className: "text-[10.5px] text-muted-foreground", children: [
964
- X.length,
965
- "/200 · Esc to cancel · ⌘↩ to save"
966
- ] }),
967
- /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5", children: [
968
- /* @__PURE__ */ e(
969
- "button",
970
- {
971
- type: "button",
972
- onClick: () => {
973
- Z(t.description || ""), Y(!1);
974
- },
975
- className: "h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",
976
- children: "Cancel"
977
- }
978
- ),
979
- /* @__PURE__ */ e(
980
- "button",
981
- {
982
- type: "button",
983
- onClick: te,
984
- className: "inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",
985
- children: "Save"
986
- }
987
- )
988
- ] })
989
- ] })
990
- ] }) : /* @__PURE__ */ o(
991
- "button",
992
- {
993
- type: "button",
994
- onClick: () => {
995
- a && (Z(t.description || ""), Y(!0));
996
- },
997
- disabled: !a,
998
- title: a ? "Click to edit description" : void 0,
999
- className: "block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",
1000
- children: [
1001
- t.description ? /* @__PURE__ */ e("p", { className: "text-[12px] leading-[1.55] text-foreground/90", children: t.description }) : /* @__PURE__ */ e("p", { className: "text-[12px] leading-[1.55] text-muted-foreground", children: a ? "Add a description…" : "No description" }),
1002
- /* @__PURE__ */ o("p", { className: "mt-1 text-[10.5px] text-muted-foreground", children: [
1003
- j ? `Created ${j}` : "Recently created",
1004
- a ? " · You can edit this group" : ""
1005
- ] })
1006
- ]
1007
- }
1008
- ) }),
1009
- s && /* @__PURE__ */ e(
1010
- xs,
1011
- {
1012
- query: ee,
1013
- setQuery: Se,
1014
- open: De,
1015
- setOpen: ke,
1016
- candidates: Ce,
1017
- showKindChip: !n,
1018
- onAdd: Ee,
1019
- busy: O.isPending
1020
- }
1021
- ),
1022
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto", children: g ? /* @__PURE__ */ e("div", { className: "space-y-px p-3", children: [1, 2, 3].map((v) => /* @__PURE__ */ e(
1023
- "div",
1024
- {
1025
- className: "h-10 animate-pulse rounded-[4px] bg-muted/60"
1026
- },
1027
- v
1028
- )) }) : x ? /* @__PURE__ */ e(
1029
- lr,
1030
- {
1031
- title: "Can't load members",
1032
- message: x,
1033
- onRetry: () => f()
1034
- }
1035
- ) : l.length === 0 ? /* @__PURE__ */ o("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
1036
- /* @__PURE__ */ e("div", { className: "text-[12px] text-foreground", children: "No members yet" }),
1037
- /* @__PURE__ */ e("div", { className: "text-[11px] text-muted-foreground", children: s ? "Search above to add people to this group." : "This group does not have any members." })
1038
- ] }) : l.map((v) => {
1039
- var B, Ie, q, z, K, oe;
1040
- return /* @__PURE__ */ o(
1041
- "div",
1042
- {
1043
- className: "group flex items-center gap-2 border-b border-border/60 px-5 py-2",
1044
- children: [
1045
- /* @__PURE__ */ e(ur, { name: ((B = v.user) == null ? void 0 : B.name) || ((Ie = v.user) == null ? void 0 : Ie.email) || "?" }),
1046
- /* @__PURE__ */ o("div", { className: "min-w-0 flex-1", children: [
1047
- /* @__PURE__ */ e("div", { className: "truncate text-[12.5px] font-medium text-foreground", children: ((q = v.user) == null ? void 0 : q.name) || ((z = v.user) == null ? void 0 : z.email) || "Unknown" }),
1048
- ((K = v.user) == null ? void 0 : K.email) && v.user.name && /* @__PURE__ */ e("div", { className: "truncate text-[10.5px] text-muted-foreground", children: v.user.email })
1049
- ] }),
1050
- !n && /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: v.userType }),
1051
- /* @__PURE__ */ e(
1052
- "button",
1053
- {
1054
- type: "button",
1055
- onClick: () => Ae(v.userId),
1056
- disabled: !s || b.isPending,
1057
- "aria-label": `Remove ${((oe = v.user) == null ? void 0 : oe.name) || "member"}`,
1058
- className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",
1059
- children: /* @__PURE__ */ e(qt, { className: "h-3 w-3" })
1060
- }
1061
- )
1062
- ]
1063
- },
1064
- v.id
1065
- );
1066
- }) }),
1067
- r && /* @__PURE__ */ e("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: /* @__PURE__ */ o(
1068
- "button",
1069
- {
1070
- type: "button",
1071
- onClick: p,
1072
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",
1073
- children: [
1074
- /* @__PURE__ */ e(it, { className: "h-3 w-3" }),
1075
- "Delete group"
1076
- ]
1077
- }
1078
- ) })
1079
- ] });
1080
- }
1081
- function bs({
1082
- isTenantUser: t,
1083
- tenantId: n,
1084
- onCancel: a,
1085
- onCreated: r
1086
- }) {
1087
- const [s, c] = N(""), [u, m] = N(""), [p, y] = N(null), g = os(), i = s.trim().length >= 3 && s.trim().length <= 50, f = async () => {
1088
- if (!i) return;
1089
- y(null);
1090
- const l = {
1091
- name: s.trim(),
1092
- description: u.trim() || void 0,
1093
- type: t ? "TENANT_GROUP" : "ORG_GROUP",
1094
- ...t && n ? { tenantId: n } : {}
1095
- };
1096
- try {
1097
- const x = await g.mutateAsync(l), h = x == null ? void 0 : x.id;
1098
- h ? r(h) : a();
1099
- } catch (x) {
1100
- y(x instanceof Error ? x.message : "Failed to create group");
1101
- }
1102
- };
1103
- return /* @__PURE__ */ o("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
1104
- /* @__PURE__ */ o("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [
1105
- /* @__PURE__ */ e(Bt, { children: "Name" }),
1106
- /* @__PURE__ */ e(
1107
- "input",
1108
- {
1109
- autoFocus: !0,
1110
- value: s,
1111
- onChange: (l) => c(l.target.value),
1112
- placeholder: "Marketing leads, North America sales, …",
1113
- maxLength: 50,
1114
- className: "mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1115
- }
1116
- ),
1117
- /* @__PURE__ */ e("div", { className: "mt-1 text-[10.5px] text-muted-foreground", children: "3–50 characters." }),
1118
- /* @__PURE__ */ o("div", { className: "mt-4", children: [
1119
- /* @__PURE__ */ e(Bt, { children: "Description (optional)" }),
1120
- /* @__PURE__ */ e(
1121
- "textarea",
1122
- {
1123
- rows: 2,
1124
- value: u,
1125
- onChange: (l) => m(l.target.value),
1126
- maxLength: 200,
1127
- placeholder: "What is this group for?",
1128
- className: "mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1129
- }
1130
- ),
1131
- /* @__PURE__ */ o("div", { className: "mt-1 flex justify-end text-[10.5px] text-muted-foreground", children: [
1132
- u.length,
1133
- "/200"
1134
- ] })
1135
- ] }),
1136
- p && /* @__PURE__ */ e("div", { className: "mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300", children: p })
1137
- ] }),
1138
- /* @__PURE__ */ o("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: [
1139
- /* @__PURE__ */ e(
1140
- "button",
1141
- {
1142
- type: "button",
1143
- onClick: a,
1144
- disabled: g.isPending,
1145
- className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",
1146
- children: "Cancel"
1147
- }
1148
- ),
1149
- /* @__PURE__ */ e(
1150
- "button",
1151
- {
1152
- type: "button",
1153
- onClick: f,
1154
- disabled: !i || g.isPending,
1155
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",
1156
- children: g.isPending ? /* @__PURE__ */ o(R, { children: [
1157
- /* @__PURE__ */ e($e, { className: "h-3 w-3 animate-spin" }),
1158
- "Creating…"
1159
- ] }) : /* @__PURE__ */ o(R, { children: [
1160
- /* @__PURE__ */ e(ne, { className: "h-3 w-3" }),
1161
- "Create group"
1162
- ] })
1163
- }
1164
- )
1165
- ] })
1166
- ] });
1167
- }
1168
- function xs({
1169
- query: t,
1170
- setQuery: n,
1171
- open: a,
1172
- setOpen: r,
1173
- candidates: s,
1174
- showKindChip: c,
1175
- onAdd: u,
1176
- busy: m
1177
- }) {
1178
- const p = _t(null), y = _t(null), [g, i] = N(null);
1179
- on(() => {
1180
- if (!a) {
1181
- i(null);
1182
- return;
1183
- }
1184
- const l = () => {
1185
- const x = p.current;
1186
- if (!x) return;
1187
- const h = x.getBoundingClientRect(), w = 240, O = window.innerHeight - h.bottom < w + 16 && h.top > w;
1188
- i({
1189
- left: h.left,
1190
- top: O ? h.top - 6 : h.bottom + 6,
1191
- width: h.width,
1192
- above: O
1193
- });
1194
- };
1195
- return l(), window.addEventListener("resize", l), window.addEventListener("scroll", l, !0), () => {
1196
- window.removeEventListener("resize", l), window.removeEventListener("scroll", l, !0);
1197
- };
1198
- }, [a, s.length]), ge(() => {
1199
- if (!a) return;
1200
- const l = (x) => {
1201
- var w, S;
1202
- const h = x.target;
1203
- (w = p.current) != null && w.contains(h) || (S = y.current) != null && S.contains(h) || r(!1);
1204
- };
1205
- return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
1206
- }, [a, r]);
1207
- const f = a && s.length > 0 && g;
1208
- return /* @__PURE__ */ o("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: [
1209
- /* @__PURE__ */ o(
1210
- "div",
1211
- {
1212
- ref: p,
1213
- className: "flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",
1214
- children: [
1215
- /* @__PURE__ */ e($n, { className: "h-3 w-3 text-muted-foreground" }),
1216
- /* @__PURE__ */ e(
1217
- "input",
1218
- {
1219
- value: t,
1220
- onChange: (l) => {
1221
- n(l.target.value), r(!0);
1222
- },
1223
- onFocus: () => r(!0),
1224
- placeholder: "Add a member by name or email…",
1225
- disabled: m,
1226
- className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"
1227
- }
1228
- )
1229
- ]
1230
- }
1231
- ),
1232
- f && typeof document < "u" && En(
1233
- /* @__PURE__ */ e(
1234
- "div",
1235
- {
1236
- ref: y,
1237
- style: {
1238
- position: "fixed",
1239
- left: g.left,
1240
- top: g.top,
1241
- width: g.width,
1242
- transform: g.above ? "translateY(-100%)" : void 0
1243
- },
1244
- className: "z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",
1245
- children: s.map((l) => /* @__PURE__ */ o(
1246
- "button",
1247
- {
1248
- type: "button",
1249
- onClick: () => u(l),
1250
- className: "flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",
1251
- children: [
1252
- /* @__PURE__ */ e(ur, { name: l.name || l.email || "?" }),
1253
- /* @__PURE__ */ o("div", { className: "min-w-0 flex-1", children: [
1254
- /* @__PURE__ */ e("div", { className: "truncate text-[12px] font-medium text-foreground", children: l.name || l.email || "Unknown" }),
1255
- l.email && l.name && /* @__PURE__ */ e("div", { className: "truncate text-[10.5px] text-muted-foreground", children: l.email })
1256
- ] }),
1257
- c && l.type && /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: l.type === "tenant" ? "tenant" : "org" })
1258
- ]
1259
- },
1260
- l.id
1261
- ))
1262
- }
1263
- ),
1264
- document.body
1265
- )
1266
- ] });
1267
- }
1268
- function cr(t, n) {
1269
- if (!t) return n;
1270
- if (t instanceof Error) {
1271
- const a = t.message || "", r = a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);
1272
- return r ? r[1] : a || n;
1273
- }
1274
- return typeof t == "string" ? t : n;
1275
- }
1276
- function lr({
1277
- title: t,
1278
- message: n,
1279
- onRetry: a
1280
- }) {
1281
- return /* @__PURE__ */ o("div", { className: "flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center", children: [
1282
- /* @__PURE__ */ e("div", { className: "text-[12.5px] font-medium text-foreground", children: t }),
1283
- /* @__PURE__ */ e("div", { className: "max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground", children: n }),
1284
- a && /* @__PURE__ */ e(
1285
- "button",
1286
- {
1287
- type: "button",
1288
- onClick: a,
1289
- className: "mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",
1290
- children: "Try again"
1291
- }
1292
- )
1293
- ] });
1294
- }
1295
- function Bt({ children: t }) {
1296
- return /* @__PURE__ */ e("label", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: t });
1297
- }
1298
- function ur({ name: t }) {
1299
- const n = t.split(" ").map((a) => a[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
1300
- return /* @__PURE__ */ e(ir, { className: "h-6 w-6 shrink-0", children: /* @__PURE__ */ e(dr, { className: "text-[9px] font-semibold", children: n || "?" }) });
1301
- }
1302
- const vs = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
1303
- function ys({
1304
- open: t,
1305
- onOpenChange: n
1306
- }) {
1307
- const a = k(
1308
- (s) => {
1309
- var c, u;
1310
- return In({
1311
- dashboardDefault: (u = (c = s.dashboard) == null ? void 0 : c.exportDefaults) == null ? void 0 : u.csvEncoding
1312
- });
1313
- }
1314
- ), { setDashboardExportDefaults: r } = k(
1315
- (s) => s.actions
1316
- );
1317
- return /* @__PURE__ */ e($t, { open: t, onOpenChange: n, children: /* @__PURE__ */ o(Gt, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
1318
- /* @__PURE__ */ o(ea, { children: [
1319
- /* @__PURE__ */ e(tt, { className: "text-[15px]", children: "Download settings" }),
1320
- /* @__PURE__ */ e(rt, { className: "text-[13px] leading-5", children: "Applies to every CSV downloaded or delivered from this dashboard. People can still change it for a single download." })
1321
- ] }),
1322
- /* @__PURE__ */ o("div", { className: "space-y-2", children: [
1323
- /* @__PURE__ */ e(qa, { htmlFor: "dashboard-csv-encoding", className: vs, children: "CSV encoding" }),
1324
- /* @__PURE__ */ o(
1325
- za,
1326
- {
1327
- value: a,
1328
- onValueChange: (s) => r({ csvEncoding: s }),
1329
- children: [
1330
- /* @__PURE__ */ e(Ka, { id: "dashboard-csv-encoding", size: "sm", children: /* @__PURE__ */ e(Qa, {}) }),
1331
- /* @__PURE__ */ e(Wa, { children: ta.map((s) => /* @__PURE__ */ e(Ja, { value: s.value, children: s.label }, s.value)) })
1332
- ]
1333
- }
1334
- )
1335
- ] })
1336
- ] }) });
1337
- }
1338
- function pe(t, n, a) {
1339
- var c, u;
1340
- const r = (t.controls || []).find(
1341
- (m) => m.id === a
1342
- );
1343
- if (r)
1344
- return r.label;
1345
- const s = (u = (c = Jt(t, n)) == null ? void 0 : c.controls) == null ? void 0 : u.find(
1346
- (m) => m.id === a
1347
- );
1348
- return (s == null ? void 0 : s.label) || a;
1349
- }
1350
- function fe(t, n) {
1351
- var a;
1352
- return ((a = Jt(t, n)) == null ? void 0 : a.title) || n;
1353
- }
1354
- function ws(t) {
1355
- const { errors: n, dashboard: a } = t;
1356
- if (!a)
1357
- return n;
1358
- const r = /* @__PURE__ */ new Map();
1359
- for (const s of n) {
1360
- const c = s.match(
1361
- /^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/
1362
- );
1363
- if (c) {
1364
- const [, g, i] = c, f = `${g}:${i}:missing-metric`;
1365
- r.has(f) || r.set(
1366
- f,
1367
- `"${fe(a, g)}" has an outdated "${pe(
1368
- a,
1369
- g,
1370
- i
1371
- )}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`
1372
- );
1373
- continue;
1374
- }
1375
- const u = s.match(
1376
- /^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/
1377
- );
1378
- if (u) {
1379
- const [, g, i] = u, f = `${g}:${i}:missing-group-by`;
1380
- r.has(f) || r.set(
1381
- f,
1382
- `"${fe(a, g)}" has an outdated "${pe(
1383
- a,
1384
- g,
1385
- i
1386
- )}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`
1387
- );
1388
- continue;
1389
- }
1390
- const m = s.match(
1391
- /^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/
1392
- );
1393
- if (m) {
1394
- const [, g, i] = m, f = `${g}:${i}:invalid-metric`;
1395
- r.has(f) || r.set(
1396
- f,
1397
- `"${fe(a, g)}" has an invalid "${pe(
1398
- a,
1399
- g,
1400
- i
1401
- )}" metric mapping. Open the card controls and choose a valid metric for each option.`
1402
- );
1403
- continue;
1404
- }
1405
- const p = s.match(
1406
- /^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/
1407
- );
1408
- if (p) {
1409
- const [, g, i] = p, f = `${g}:${i}:invalid-group-by`;
1410
- r.has(f) || r.set(
1411
- f,
1412
- `"${fe(a, g)}" has an invalid "${pe(
1413
- a,
1414
- g,
1415
- i
1416
- )}" field mapping. Open the card controls and choose a valid field for each option.`
1417
- );
1418
- continue;
1419
- }
1420
- const y = s.match(
1421
- /^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/
1422
- );
1423
- if (y) {
1424
- const [, g, i] = y, f = `${g}:${i}:missing-temporal-group-by`;
1425
- r.has(f) || r.set(
1426
- f,
1427
- `"${fe(a, g)}" can no longer use "${pe(
1428
- a,
1429
- g,
1430
- i
1431
- )}" for time grain because the card does not currently group by a date field.`
1432
- );
1433
- continue;
1434
- }
1435
- r.set(s, s);
1436
- }
1437
- return Array.from(r.values());
1438
- }
1439
- function Ns({
1440
- visible: t,
1441
- onSelect: n
1442
- }) {
1443
- return t ? /* @__PURE__ */ o(A, { onSelect: n, children: [
1444
- /* @__PURE__ */ e(ra, { className: "h-3.5 w-3.5" }),
1445
- "Schedule email report"
1446
- ] }) : null;
1447
- }
1448
- function Ss({
1449
- scheduleReportVisible: t,
1450
- analyticalBriefingVisible: n,
1451
- onScheduleReport: a,
1452
- onCreateAnalyticalBriefing: r
1453
- }) {
1454
- return /* @__PURE__ */ o(R, { children: [
1455
- /* @__PURE__ */ e(
1456
- Ns,
1457
- {
1458
- visible: t,
1459
- onSelect: a
1460
- }
1461
- ),
1462
- n ? /* @__PURE__ */ o(A, { onSelect: r, children: [
1463
- /* @__PURE__ */ e(ne, { className: "h-3.5 w-3.5" }),
1464
- "Create analytical briefing"
1465
- ] }) : null
1466
- ] });
1467
- }
1468
- const Ds = "dashboard-bookmark-usage";
1469
- function ks(t) {
1470
- var p;
1471
- const n = k((y) => y.viewerStateClient), a = (p = t.saved) == null ? void 0 : p.id, s = aa({
1472
- // Keyed by the viewer, never by the client object (TanStack drops functions when hashing).
1473
- queryKey: [Ds, (n == null ? void 0 : n.viewerKey) ?? null],
1474
- queryFn: () => n.bookmarks.usage(),
1475
- enabled: t.enabled && !!n && !!a,
1476
- staleTime: 5 * 6e4,
1477
- retry: !1
1478
- }).data, { saved: c, draft: u, enabled: m } = t;
1479
- return H(() => !m || !c || !s ? [] : !s.bookmarks && !Object.keys(s.tables).length ? [] : On({ saved: c, draft: u, usage: s }), [u, m, c, s]);
1480
- }
1481
- function Cs({
1482
- saved: t,
1483
- draft: n,
1484
- enabled: a
1485
- }) {
1486
- const r = ks({ saved: t, draft: n, enabled: a });
1487
- return r.length ? /* @__PURE__ */ o(Ya, { children: [
1488
- /* @__PURE__ */ e(Xa, { asChild: !0, children: /* @__PURE__ */ o(
1489
- V,
1490
- {
1491
- variant: "ghost",
1492
- size: "xs",
1493
- className: "gap-1 text-muted-foreground hover:text-foreground",
1494
- children: [
1495
- /* @__PURE__ */ e(na, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
1496
- "Affects saved views"
1497
- ]
1498
- }
1499
- ) }),
1500
- /* @__PURE__ */ o(Za, { align: "end", className: "w-[320px] p-3 text-[12px]", children: [
1501
- /* @__PURE__ */ e("p", { className: "text-foreground", children: "This edit removes parts of the dashboard that viewers saved. Their views still open, with a note about what no longer applies." }),
1502
- /* @__PURE__ */ e(
1503
- "ul",
1504
- {
1505
- "aria-label": "Affected saved views",
1506
- className: "mt-2 grid gap-1 border-t border-border/60 pt-2",
1507
- children: r.map((s) => {
1508
- const { name: c, uses: u } = Pn(s);
1509
- return /* @__PURE__ */ o(
1510
- "li",
1511
- {
1512
- className: "flex items-baseline justify-between gap-3",
1513
- children: [
1514
- /* @__PURE__ */ e("span", { className: "min-w-0 truncate text-foreground", children: c }),
1515
- /* @__PURE__ */ e("span", { className: "shrink-0 text-[11.5px] text-muted-foreground", children: u })
1516
- ]
1517
- },
1518
- `${s.target}:${s.cardId ?? ""}:${s.id}`
1519
- );
1520
- })
1521
- }
1522
- )
1523
- ] })
1524
- ] }) : null;
1525
- }
1526
- function Ft(t, n) {
1527
- return {
1528
- dashboard: nt(t),
1529
- semanticExecutionPayload: nt(n)
1530
- };
1531
- }
1532
- function Xs() {
1533
- var St, Dt, kt, Ct;
1534
- const {
1535
- authToken: t,
1536
- tokenProps: n,
1537
- id: a,
1538
- showBriefings: r,
1539
- toolbarStatus: s
1540
- } = J(), c = sa(), { isLocalDev: u, isConsoleMode: m } = oa(), {
1541
- canEditDashboard: p,
1542
- hasInspectionUser: y,
1543
- inspectionMessage: g,
1544
- isInspectionMode: i,
1545
- isInspectionSurface: f
1546
- } = ia(), { openBrandStudioPreview: l } = da(), { permissions: x } = qn(), h = ca(), { isLoading: w } = la(), S = k((d) => d.theme), O = k((d) => d.isDownloadingPdf), b = k((d) => d.dashboard), F = k((d) => d.selectedSheetId), P = (St = b == null ? void 0 : b.sheets) == null ? void 0 : St.find(
1547
- (d) => d.id === F
1548
- ), $ = An(P), M = $ ? (Dt = P == null ? void 0 : P.document) == null ? void 0 : Dt.page : void 0, D = k(
1549
- (d) => d.isDashboardEditing
1550
- ), { setDashboardTitle: Ne } = k((d) => d.actions), [Y, X] = N(!1), [Z, ee] = N(!1), [Se, De] = N(!1), [ke, Ce] = N(!1), [se, te] = N(null), [Ee, Ae] = N(null), { registerBriefingViewer: j } = ua();
1551
- ge(
1552
- () => j((d) => Ae(d)),
1553
- [j]
1554
- );
1555
- const [v, B] = N(!1), [Ie, q] = N(!1), [z, K] = N(null), [oe, Me] = N([]), [ut, Le] = N(!1), [mr, mt] = N(!1), U = k((d) => d.isVisualEditing);
1556
- Et((d) => d.card);
1557
- const hr = Be(
1558
- (d) => d.selectedDashboard
1559
- ), pr = Be(
1560
- (d) => d.initialDashboard
1561
- );
1562
- Be((d) => d.selectedVisual), k((d) => d.selectedFrameId), Et((d) => d.frame);
1563
- const ht = k(
1564
- (d) => d.showDashboardJSON
1565
- );
1566
- k((d) => d.onSaveFunction);
1567
- const { setIsDashboardEditing: pt, setShowDashboardJSON: ft, markDashboardSaved: fr, openStyleSheet: gr } = k(
1568
- (d) => d.actions
1569
- ), { setInitialDashboard: gt, clearSelectedDashboard: Ge } = Be(
1570
- (d) => d.actions
1571
- ), ie = !!n.orgUserId || !!(n.tenantId && n.endUserId && n.endUserEmail), { resources: Oe } = ma(Xe.DASHBOARD), I = ha(), { currentUser: br } = ot(), xr = pa(br), G = hr || pr, Q = fa({
1572
- config: n.config,
1573
- canNavigateDashboardHub: ie,
1574
- canShareDashboard: ((kt = G == null ? void 0 : G.permissions) == null ? void 0 : kt.canShare) === !0,
1575
- canManageGroups: xr
1576
- }), bt = G ? {
1577
- id: G.id,
1578
- title: (b == null ? void 0 : b.title) || G.title || "Dashboard"
1579
- } : null, { handleAddNewFrame: vr } = ga(), [Ve, He] = N(!1), [yr, de] = N(!1), [je, Pe] = N("close"), ce = ba(Xe.DASHBOARD), [L, le] = N(null), wr = async (d, T) => {
1580
- if (!i) {
1581
- if (!(b != null && b.id)) {
1582
- console.log("No dashboard ID found");
1583
- return;
1584
- }
1585
- console.log("Updating dashboard title:", {
1586
- dashboardId: b.id,
1587
- newTitle: d,
1588
- previousTitle: T
1589
- }), ce.mutate(
1590
- {
1591
- resourceId: b.id,
1592
- data: { title: d }
1593
- },
1594
- {
1595
- onSuccess: () => {
1596
- le(
1597
- (_) => (_ == null ? void 0 : _.dashboard.id) === b.id ? {
1598
- ..._,
1599
- dashboard: { ..._.dashboard, title: d }
1600
- } : _
1601
- ), C.success("Dashboard title updated");
1602
- },
1603
- onError: (_) => {
1604
- console.error("Failed to update dashboard title:", _), C.error("Failed to update dashboard title");
1605
- const re = k.getState().dashboard;
1606
- (re == null ? void 0 : re.id) === b.id && re.title === d && Ne(T);
1607
- }
1608
- }
1609
- );
1610
- }
1611
- };
1612
- ge(() => {
1613
- if (Oe && Oe.length > 0) {
1614
- const d = b == null ? void 0 : b.id;
1615
- if (d) {
1616
- const T = Oe.find(
1617
- (_) => _.id === d
1618
- );
1619
- T && gt(T);
1620
- }
1621
- }
1622
- }, [Oe, b == null ? void 0 : b.id, gt]);
1623
- const Nr = n.orgUserId || n.tenantId, qe = H(
1624
- () => As({
1625
- accessToken: t == null ? void 0 : t.accessToken,
1626
- dashboardId: (b == null ? void 0 : b.id) || a || n.dashboard_id,
1627
- selectedSheetId: $ ? F : void 0,
1628
- pageSize: M == null ? void 0 : M.size,
1629
- orientation: M == null ? void 0 : M.orientation,
1630
- theme: S
1631
- }),
1632
- [
1633
- t == null ? void 0 : t.accessToken,
1634
- a,
1635
- b == null ? void 0 : b.id,
1636
- $,
1637
- M == null ? void 0 : M.orientation,
1638
- M == null ? void 0 : M.size,
1639
- F,
1640
- S,
1641
- n.dashboard_id
1642
- ]
1643
- ), ze = D && !U && !i && Nr && p, { setDashboard: Ke } = k((d) => d.actions), Sr = k(
1644
- (d) => d.semanticExecutionPayload
1645
- ), Dr = () => {
1646
- pt(!0);
1647
- }, _e = () => {
1648
- pt(!1), ft(!1), le(null);
1649
- };
1650
- ge(() => {
1651
- if (!D) {
1652
- L && le(null);
1653
- return;
1654
- }
1655
- if (L || !b || w)
1656
- return;
1657
- const d = xa(k.getState());
1658
- le(
1659
- Ft(d.dashboard, d.semanticExecutionPayload)
1660
- );
1661
- }, [
1662
- b,
1663
- L,
1664
- D,
1665
- w,
1666
- Sr
1667
- ]);
1668
- const Qe = (L == null ? void 0 : L.dashboard) ?? null, { isDirty: We, isDirtyPending: kr, resetDirty: ue } = Mn(
1669
- b,
1670
- Qe,
1671
- 300,
1672
- 1e3,
1673
- Ln
1674
- ), xt = dn(
1675
- Qe,
1676
- i,
1677
- p
1678
- ), vt = We || kr, Te = Ve || ce.isPending, Cr = () => {
1679
- if (i) {
1680
- L && Ke(L.dashboard, {
1681
- semanticExecutionPayload: L.semanticExecutionPayload
1682
- }), _e(), ue();
1683
- return;
1684
- }
1685
- xt() ? (Pe("close"), de(!0)) : (_e(), ue());
1686
- }, Er = async () => {
1687
- await Je({
1688
- closeAfterSave: !0,
1689
- navigateHomeAfterSave: je === "home"
1690
- });
1691
- }, Ar = () => {
1692
- const d = je === "home" && !!ie;
1693
- L && Ke(L.dashboard, {
1694
- semanticExecutionPayload: L.semanticExecutionPayload
1695
- }), _e(), d && Ge(), Pe("close"), de(!1), ue();
1696
- }, Ir = () => {
1697
- L && (Ke(L.dashboard, {
1698
- semanticExecutionPayload: L.semanticExecutionPayload
1699
- }), ue());
1700
- }, Mr = () => {
1701
- if (ie) {
1702
- if (D && xt()) {
1703
- Pe("home"), de(!0);
1704
- return;
1705
- }
1706
- Ge();
1707
- }
1708
- };
1709
- async function Je(d) {
1710
- if (i)
1711
- return;
1712
- const T = k.getState().dashboard;
1713
- if (!T)
1714
- return;
1715
- const _ = (d == null ? void 0 : d.closeAfterSave) ?? ut, re = (d == null ? void 0 : d.navigateHomeAfterSave) ?? !1;
1716
- Le(_), _ && de(!1);
1717
- const _r = nt(T);
1718
- q(!0), K(null), Me([]), He(!0);
1719
- const Tr = {
1720
- template: T
1721
- };
1722
- ce.mutate(
1723
- {
1724
- resourceId: T.id,
1725
- data: Tr
1726
- },
1727
- {
1728
- onSuccess: () => {
1729
- He(!1), fr(), C.success("Dashboard saved!"), le(
1730
- Ft(
1731
- _r,
1732
- k.getState().semanticExecutionPayload
1733
- )
1734
- ), q(!1), Le(!1), _ && (_e(), ue(), re && ie && Ge()), Pe("close");
1735
- },
1736
- onError: (Rr) => {
1737
- He(!1), K("Failed to save dashboard. Please try again.");
1738
- const Ue = Rr.details, Ur = Array.isArray(
1739
- Ue == null ? void 0 : Ue.errors
1740
- ) ? (Ue.errors || []).filter(
1741
- (Br) => typeof Br == "string"
1742
- ) : [];
1743
- Me(
1744
- ws({
1745
- errors: Ur,
1746
- dashboard: T || void 0
1747
- })
1748
- ), C.error("Failed to save dashboard");
1749
- }
1750
- }
1751
- );
1752
- }
1753
- const yt = b.title;
1754
- ce.isPending && console.log("Title during update:", {
1755
- title: yt,
1756
- dashboardStateTitle: b.title,
1757
- dashboardId: b == null ? void 0 : b.id
1758
- });
1759
- const Lr = ie && !!(t != null && t.accessToken) && !!(n != null && n.apiServiceUrl), Or = !i && Q.showDashboardHub && Lr, Pr = !i && h && Q.showDashboardHub, W = (b == null ? void 0 : b.id) || null, wt = va(
1760
- (Ct = n.config) == null ? void 0 : Ct.showBriefings,
1761
- r
1762
- ), Re = cn(W), Ye = ln();
1763
- if (!h && !U)
1764
- return null;
1765
- const me = !U && h && !i, Nt = D && me;
1766
- return /* @__PURE__ */ e(ya, { width: I.width, hasOverflowMenu: me, children: /* @__PURE__ */ o(
1767
- "div",
1768
- {
1769
- ref: I.measure,
1770
- className: "flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-1.5",
1771
- role: "dashboard-controls",
1772
- children: [
1773
- /* @__PURE__ */ o("div", { className: "flex min-w-[80px] flex-1 items-center gap-2", children: [
1774
- Pr && !U && /* @__PURE__ */ e(
1775
- Dn,
1776
- {
1777
- "aria-label": "Dashboard Hub",
1778
- tooltip: "Dashboard Hub",
1779
- onClick: Mr,
1780
- className: "h-7 w-7 px-0",
1781
- buttonProps: { size: "xs" },
1782
- children: /* @__PURE__ */ e(wa, { className: "h-3.5 w-3.5" })
1783
- }
1784
- ),
1785
- !U && h && (w ? /* @__PURE__ */ e(
1786
- "div",
1787
- {
1788
- className: "h-4 w-28 animate-pulse rounded-md bg-muted/70",
1789
- "aria-label": "Loading dashboard title",
1790
- role: "status",
1791
- children: /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading dashboard title" })
1792
- }
1793
- ) : /* @__PURE__ */ o("div", { className: "flex min-w-0 items-center gap-1", children: [
1794
- /* @__PURE__ */ e(
1795
- Na,
1796
- {
1797
- value: yt || "Untitled Dashboard",
1798
- onSave: (d) => {
1799
- console.log("EditableText onSave called:", {
1800
- newTitle: d,
1801
- canEditDashboard: p,
1802
- dashboardId: b == null ? void 0 : b.id
1803
- });
1804
- const T = (b == null ? void 0 : b.title) || "";
1805
- Ne(d), wr(d, T);
1806
- },
1807
- isEditable: Sa({
1808
- isDashboardEditing: D,
1809
- canEditDashboard: p === !0 && !i
1810
- }),
1811
- displayClassName: "text-[13px] font-medium",
1812
- inputClassName: "text-[13px] font-medium",
1813
- placeholder: "Dashboard Title",
1814
- isPending: ce.isPending
1815
- }
1816
- ),
1817
- !i && W && /* @__PURE__ */ e(un, { dashboardId: W }),
1818
- s ? /* @__PURE__ */ e("div", { className: "flex min-w-[1.25rem] shrink-[2]", children: s }) : null
1819
- ] }))
1820
- ] }),
1821
- /* @__PURE__ */ o("div", { className: "flex min-w-0 items-center gap-1.5", children: [
1822
- /* @__PURE__ */ o("div", { className: "-m-1 flex min-w-0 items-center gap-1.5 overflow-x-auto p-1 [scrollbar-width:thin] [&>*]:shrink-0", children: [
1823
- U && /* @__PURE__ */ o(R, { children: [
1824
- /* @__PURE__ */ e(mn, {}),
1825
- /* @__PURE__ */ e(hn, {})
1826
- ] }),
1827
- h && !i && /* @__PURE__ */ e(kn, {}),
1828
- !U && D && !i && x.canUseFilters && h && /* @__PURE__ */ e(pn, {}),
1829
- D && !i && h && /* @__PURE__ */ e(fn, {}),
1830
- D && !U && !i && h && !$ && /* @__PURE__ */ o("div", { className: "inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background", children: [
1831
- /* @__PURE__ */ o(
1832
- V,
1833
- {
1834
- variant: "ghost",
1835
- size: "xs",
1836
- disabled: !D,
1837
- onClick: () => void vr(),
1838
- "aria-label": I.width === "sm" ? "Add visual" : void 0,
1839
- title: I.width === "sm" ? "Add visual" : void 0,
1840
- className: be(
1841
- "h-full rounded-none border-0 shadow-none hover:bg-accent",
1842
- I.width === "sm" && "w-7 px-0"
1843
- ),
1844
- children: [
1845
- /* @__PURE__ */ e(ne, { className: "h-3.5 w-3.5" }),
1846
- I.width !== "sm" && "Visual"
1847
- ]
1848
- }
1849
- ),
1850
- /* @__PURE__ */ o(At, { modal: !1, children: [
1851
- /* @__PURE__ */ e(It, { asChild: !0, children: /* @__PURE__ */ e(
1852
- V,
1853
- {
1854
- variant: "ghost",
1855
- size: "xs",
1856
- className: "h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent",
1857
- "aria-label": "Open visual options",
1858
- disabled: !D,
1859
- children: /* @__PURE__ */ e(en, { className: "h-3.5 w-3.5" })
1860
- }
1861
- ) }),
1862
- /* @__PURE__ */ e(
1863
- Mt,
1864
- {
1865
- align: "end",
1866
- className: "z-[60] w-48 rounded-control border-border/60 p-1 shadow-sm",
1867
- children: /* @__PURE__ */ o(A, { onClick: () => mt(!0), children: [
1868
- /* @__PURE__ */ e(ne, { className: "h-3.5 w-3.5" }),
1869
- "From library..."
1870
- ] })
1871
- }
1872
- )
1873
- ] }),
1874
- /* @__PURE__ */ e(
1875
- gn,
1876
- {
1877
- open: mr,
1878
- onOpenChange: mt
1879
- }
1880
- )
1881
- ] }),
1882
- !i && h && /* @__PURE__ */ e(bn, {}),
1883
- !U && !D && (p || i) && (!f || !y || p !== void 0) && h && /* @__PURE__ */ o("div", { className: "inline-flex items-center gap-1", children: [
1884
- /* @__PURE__ */ o(
1885
- V,
1886
- {
1887
- size: "xs",
1888
- onClick: Dr,
1889
- "aria-label": i ? "Inspect" : "Edit",
1890
- title: I.width === "sm" ? i ? "Inspect" : "Edit" : void 0,
1891
- className: I.width === "sm" ? "w-7 px-0" : void 0,
1892
- children: [
1893
- /* @__PURE__ */ e(Da, { className: "h-3.5 w-3.5" }),
1894
- I.width !== "sm" && (i ? "Inspect" : "Edit")
1895
- ]
1896
- }
1897
- ),
1898
- g ? /* @__PURE__ */ e(tn, { children: /* @__PURE__ */ o(rn, { children: [
1899
- /* @__PURE__ */ e(an, { asChild: !0, children: /* @__PURE__ */ e(
1900
- "button",
1901
- {
1902
- type: "button",
1903
- "aria-label": g,
1904
- className: "inline-flex size-6 items-center justify-center rounded-control text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
1905
- children: /* @__PURE__ */ e(nn, { "aria-hidden": "true", className: "size-3.5" })
1906
- }
1907
- ) }),
1908
- /* @__PURE__ */ e(sn, { children: /* @__PURE__ */ e("p", { children: g }) })
1909
- ] }) }) : null
1910
- ] }),
1911
- ze && h && We && /* @__PURE__ */ e(
1912
- Cs,
1913
- {
1914
- saved: Qe,
1915
- draft: b,
1916
- enabled: D && !i
1917
- }
1918
- ),
1919
- ze && h && We && /* @__PURE__ */ o(
1920
- V,
1921
- {
1922
- variant: "outline",
1923
- size: "xs",
1924
- onClick: Ir,
1925
- disabled: Te,
1926
- "aria-label": "Undo",
1927
- title: I.width === "sm" ? "Undo" : void 0,
1928
- className: I.width === "sm" ? "w-7 px-0" : void 0,
1929
- children: [
1930
- /* @__PURE__ */ e(ka, { className: "h-3.5 w-3.5" }),
1931
- I.width !== "sm" && "Undo"
1932
- ]
1933
- }
1934
- ),
1935
- ze && h && /* @__PURE__ */ o(
1936
- V,
1937
- {
1938
- size: "xs",
1939
- className: be(!vt && "opacity-60"),
1940
- disabled: Te || !vt,
1941
- onClick: () => Je(),
1942
- children: [
1943
- Te ? /* @__PURE__ */ e($e, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(_n, { className: "h-3.5 w-3.5" }),
1944
- Te ? "Saving..." : "Save"
1945
- ]
1946
- }
1947
- ),
1948
- D && !U && h && /* @__PURE__ */ o(
1949
- V,
1950
- {
1951
- variant: "outline",
1952
- size: "xs",
1953
- onClick: Cr,
1954
- "aria-label": "Close",
1955
- title: I.width === "sm" ? "Close" : void 0,
1956
- className: I.width === "sm" ? "w-7 px-0" : void 0,
1957
- children: [
1958
- /* @__PURE__ */ e(Ca, { className: "h-3.5 w-3.5" }),
1959
- I.width !== "sm" && "Close"
1960
- ]
1961
- }
1962
- )
1963
- ] }),
1964
- !U && h && /* @__PURE__ */ o(R, { children: [
1965
- /* @__PURE__ */ e(xn, {}),
1966
- m && p === !0 && !i && /* @__PURE__ */ e(vn, {})
1967
- ] }),
1968
- !U && u && I.width === "lg" && /* @__PURE__ */ e(jn, {}),
1969
- me && /* @__PURE__ */ e(Ea, {}),
1970
- me && Nt && /* @__PURE__ */ e(yn, {}),
1971
- me && /* @__PURE__ */ o(At, { children: [
1972
- /* @__PURE__ */ e(It, { asChild: !0, children: /* @__PURE__ */ e(
1973
- V,
1974
- {
1975
- variant: "ghost",
1976
- size: "xs",
1977
- className: "w-7 px-0",
1978
- "aria-label": "More dashboard options",
1979
- children: /* @__PURE__ */ e(Aa, { className: "h-3.5 w-3.5" })
1980
- }
1981
- ) }),
1982
- /* @__PURE__ */ o(
1983
- Mt,
1984
- {
1985
- align: "end",
1986
- className: "w-56 rounded-control border border-border/60 p-1 shadow-sm",
1987
- children: [
1988
- /* @__PURE__ */ e(Es, {}),
1989
- Re.available && Or && /* @__PURE__ */ o(R, { children: [
1990
- /* @__PURE__ */ o(
1991
- A,
1992
- {
1993
- disabled: Re.disabled,
1994
- onSelect: Re.toggle,
1995
- children: [
1996
- /* @__PURE__ */ e(Ia, { className: "h-3.5 w-3.5" }),
1997
- /* @__PURE__ */ e("span", { className: "flex-1", children: "Default dashboard" }),
1998
- Re.isDefault && /* @__PURE__ */ e(zt, { className: "h-3.5 w-3.5" })
1999
- ]
2000
- }
2001
- ),
2002
- /* @__PURE__ */ e(ae, {})
2003
- ] }),
2004
- /* @__PURE__ */ e(he, { children: "Reports & briefings" }),
2005
- /* @__PURE__ */ o(
2006
- A,
2007
- {
2008
- disabled: O,
2009
- onSelect: () => B(!0),
2010
- children: [
2011
- /* @__PURE__ */ e(Ma, { className: "h-3.5 w-3.5" }),
2012
- "Export"
2013
- ]
2014
- }
2015
- ),
2016
- /* @__PURE__ */ e(
2017
- Ss,
2018
- {
2019
- scheduleReportVisible: !!(wt && c.surfaceVisible && W && !D),
2020
- analyticalBriefingVisible: !!(wt && c.surfaceVisible && W && !D),
2021
- onScheduleReport: () => te("scheduled_report"),
2022
- onCreateAnalyticalBriefing: () => te("analytical_briefing")
2023
- }
2024
- ),
2025
- D && /* @__PURE__ */ o(
2026
- A,
2027
- {
2028
- onSelect: () => Ce(!0),
2029
- children: [
2030
- /* @__PURE__ */ e(La, { className: "h-3.5 w-3.5" }),
2031
- "Download settings"
2032
- ]
2033
- }
2034
- ),
2035
- /* @__PURE__ */ e(ae, {}),
2036
- (Q.showDashboardSharing || Q.showGroupManagement) && /* @__PURE__ */ o(R, { children: [
2037
- /* @__PURE__ */ e(he, { children: "Access" }),
2038
- Q.showDashboardSharing && /* @__PURE__ */ o(A, { onSelect: () => X(!0), children: [
2039
- /* @__PURE__ */ e(Oa, { className: "h-3.5 w-3.5" }),
2040
- "Share"
2041
- ] }),
2042
- Q.showGroupManagement && /* @__PURE__ */ o(
2043
- A,
2044
- {
2045
- onClick: () => ee(!0),
2046
- children: [
2047
- /* @__PURE__ */ e(Ht, { className: "h-3.5 w-3.5" }),
2048
- "Manage Groups"
2049
- ]
2050
- }
2051
- ),
2052
- /* @__PURE__ */ e(ae, {})
2053
- ] }),
2054
- Nt && /* @__PURE__ */ o(R, { children: [
2055
- /* @__PURE__ */ e(he, { children: "Dashboard" }),
2056
- /* @__PURE__ */ o(A, { onSelect: Ye.open, children: [
2057
- /* @__PURE__ */ e(Pt, { className: "h-3.5 w-3.5" }),
2058
- /* @__PURE__ */ e("span", { className: "flex-1", children: Ye.label }),
2059
- /* @__PURE__ */ e("span", { className: "pl-4 text-[11px] tabular-nums text-muted-foreground", children: Ye.count })
2060
- ] }),
2061
- /* @__PURE__ */ o(A, { onSelect: gr, children: [
2062
- /* @__PURE__ */ e(Tn, { className: "h-3.5 w-3.5" }),
2063
- "Style"
2064
- ] }),
2065
- /* @__PURE__ */ e(ae, {})
2066
- ] }),
2067
- /* @__PURE__ */ e(he, { children: "Preferences" }),
2068
- /* @__PURE__ */ o(A, { onClick: () => De(!0), children: [
2069
- /* @__PURE__ */ e(jt, { className: "h-3.5 w-3.5" }),
2070
- "Report preferences"
2071
- ] }),
2072
- u && h && /* @__PURE__ */ o(R, { children: [
2073
- /* @__PURE__ */ e(ae, {}),
2074
- /* @__PURE__ */ e(he, { children: "Developer" }),
2075
- /* @__PURE__ */ o(
2076
- A,
2077
- {
2078
- onSelect: () => {
2079
- var d;
2080
- t != null && t.accessToken && ((d = navigator == null ? void 0 : navigator.clipboard) != null && d.writeText ? navigator.clipboard.writeText(t.accessToken).then(
2081
- () => C.success("Token copied to clipboard")
2082
- ).catch(() => C.error("Unable to copy token")) : C.error("Clipboard not available"));
2083
- },
2084
- children: [
2085
- /* @__PURE__ */ e(Lt, { className: "h-3.5 w-3.5" }),
2086
- "Copy token"
2087
- ]
2088
- }
2089
- ),
2090
- $ && /* @__PURE__ */ o(
2091
- A,
2092
- {
2093
- disabled: !qe,
2094
- onSelect: () => {
2095
- var d;
2096
- if (!qe) {
2097
- C.error(
2098
- "Open a document sheet with a token to copy the local PDF URL"
2099
- );
2100
- return;
2101
- }
2102
- (d = navigator == null ? void 0 : navigator.clipboard) != null && d.writeText ? navigator.clipboard.writeText(qe).then(
2103
- () => C.success(
2104
- "Local document PDF URL copied to clipboard"
2105
- )
2106
- ).catch(
2107
- () => C.error(
2108
- "Unable to copy local document PDF URL"
2109
- )
2110
- ) : C.error("Clipboard not available");
2111
- },
2112
- children: [
2113
- /* @__PURE__ */ e(Lt, { className: "h-3.5 w-3.5" }),
2114
- "Copy local document PDF URL"
2115
- ]
2116
- }
2117
- ),
2118
- /* @__PURE__ */ o(
2119
- A,
2120
- {
2121
- onSelect: () => wn(n.apiServiceUrl),
2122
- children: [
2123
- /* @__PURE__ */ e(Bn, { className: "h-3.5 w-3.5" }),
2124
- "Invalidate token"
2125
- ]
2126
- }
2127
- ),
2128
- /* @__PURE__ */ o(A, { onSelect: l, children: [
2129
- /* @__PURE__ */ e(Rn, { className: "h-3.5 w-3.5" }),
2130
- "Brand Studio"
2131
- ] }),
2132
- D && /* @__PURE__ */ o(
2133
- A,
2134
- {
2135
- onSelect: () => ft(!ht),
2136
- children: [
2137
- /* @__PURE__ */ e(Pt, { className: "h-3.5 w-3.5" }),
2138
- ht ? "Hide dashboard JSON" : "Show dashboard JSON"
2139
- ]
2140
- }
2141
- )
2142
- ] })
2143
- ]
2144
- }
2145
- )
2146
- ] }),
2147
- Y && bt && /* @__PURE__ */ e(
2148
- Pa,
2149
- {
2150
- resource: bt,
2151
- resourceType: Xe.DASHBOARD,
2152
- onClose: () => X(!1)
2153
- }
2154
- ),
2155
- Q.showGroupManagement && /* @__PURE__ */ e(
2156
- ms,
2157
- {
2158
- open: Z,
2159
- onOpenChange: ee
2160
- }
2161
- ),
2162
- /* @__PURE__ */ e(
2163
- Cn,
2164
- {
2165
- open: Se,
2166
- onOpenChange: De
2167
- }
2168
- ),
2169
- /* @__PURE__ */ e(
2170
- ys,
2171
- {
2172
- open: ke,
2173
- onOpenChange: Ce
2174
- }
2175
- ),
2176
- W && (se || Ee) ? /* @__PURE__ */ e(
2177
- Nn,
2178
- {
2179
- dashboardId: W,
2180
- dashboardTitle: (b == null ? void 0 : b.title) || (G == null ? void 0 : G.title),
2181
- open: !0,
2182
- onOpenChange: (d) => {
2183
- d || (te(null), Ae(null));
2184
- },
2185
- hideTrigger: !0,
2186
- workflowIntent: se ?? void 0,
2187
- openRun: Ee ?? void 0
2188
- }
2189
- ) : null,
2190
- h && /* @__PURE__ */ e(
2191
- _a,
2192
- {
2193
- open: v,
2194
- onOpenChange: B
2195
- }
2196
- ),
2197
- /* @__PURE__ */ e(
2198
- Ta,
2199
- {
2200
- open: Ie,
2201
- onOpenChange: (d) => {
2202
- !d && Ve && !z || (q(d), d || (K(null), Me([]), Le(!1)));
2203
- },
2204
- children: /* @__PURE__ */ o(Ra, { className: "max-w-sm", children: [
2205
- /* @__PURE__ */ o(Ua, { children: [
2206
- /* @__PURE__ */ e(Ba, { children: z ? "Save failed" : "Saving dashboard" }),
2207
- /* @__PURE__ */ e(Fa, { className: "pt-2", children: z ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." }),
2208
- oe.length > 0 && /* @__PURE__ */ o("div", { className: "space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left", children: [
2209
- /* @__PURE__ */ e("div", { className: "text-sm font-medium text-destructive", children: "What needs attention" }),
2210
- /* @__PURE__ */ e("ul", { className: "list-disc space-y-1 pl-4 text-xs text-muted-foreground", children: oe.slice(0, 5).map((d) => /* @__PURE__ */ e("li", { children: d }, d)) })
2211
- ] })
2212
- ] }),
2213
- /* @__PURE__ */ e($a, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: z ? /* @__PURE__ */ o(R, { children: [
2214
- /* @__PURE__ */ e(
2215
- Ga,
2216
- {
2217
- onClick: () => {
2218
- q(!1), K(null), Me([]), Le(!1);
2219
- },
2220
- className: "m-0",
2221
- children: "Close"
2222
- }
2223
- ),
2224
- /* @__PURE__ */ e(
2225
- Ot,
2226
- {
2227
- onClick: () => Je({
2228
- closeAfterSave: ut,
2229
- navigateHomeAfterSave: je === "home"
2230
- }),
2231
- className: "m-0",
2232
- children: "Retry"
2233
- }
2234
- )
2235
- ] }) : /* @__PURE__ */ o(Ot, { disabled: !0, className: "m-0 cursor-default", children: [
2236
- /* @__PURE__ */ e($e, { className: "mr-2 h-4 w-4 animate-spin" }),
2237
- "Saving..."
2238
- ] }) })
2239
- ] })
2240
- }
2241
- ),
2242
- /* @__PURE__ */ e(
2243
- Sn,
2244
- {
2245
- open: yr,
2246
- onOpenChange: (d) => {
2247
- de(d);
2248
- },
2249
- onSave: Er,
2250
- onDiscard: Ar,
2251
- isSaving: Ve,
2252
- saveLabel: "Save",
2253
- discardLabel: "Discard changes"
2254
- }
2255
- )
2256
- ] })
2257
- ]
2258
- }
2259
- ) });
2260
- }
2261
- function Es() {
2262
- const t = Va();
2263
- return t.length === 0 ? null : /* @__PURE__ */ o(R, { children: [
2264
- t.map((n) => /* @__PURE__ */ o(A, { onSelect: n.onSelect, children: [
2265
- n.icon,
2266
- /* @__PURE__ */ e("span", { className: "flex-1", children: n.label }),
2267
- n.hint && /* @__PURE__ */ e("span", { className: "text-[11px] text-muted-foreground", children: n.hint }),
2268
- n.checked && /* @__PURE__ */ e(zt, { className: "h-3.5 w-3.5" })
2269
- ] }, n.id)),
2270
- /* @__PURE__ */ e(ae, {})
2271
- ] });
2272
- }
2273
- function As({
2274
- accessToken: t,
2275
- dashboardId: n,
2276
- selectedSheetId: a,
2277
- pageSize: r,
2278
- orientation: s,
2279
- theme: c
2280
- }) {
2281
- if (!t || !a)
2282
- return null;
2283
- const u = new URL("http://localhost:5173/print-document");
2284
- u.searchParams.set("token", t), n && u.searchParams.set("dashboardId", n), u.searchParams.set("selectedSheetId", a), c && u.searchParams.set("theme", c);
2285
- const m = new URL("http://127.0.0.1:3002/");
2286
- return m.searchParams.set("pdfMode", "document"), m.searchParams.set("pageSize", r || "letter"), m.searchParams.set("orientation", s || "portrait"), m.searchParams.set("url", u.toString()), m.toString();
2287
- }
2288
- export {
2289
- Xs as default
2290
- };