react-semaphor 0.1.560 → 0.1.562

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