react-semaphor 0.1.544 → 0.1.546

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