react-semaphor 0.1.602 → 0.1.604

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/activity/index.js +1 -73
  2. package/dist/analytics-protocol/index.js +1 -1451
  3. package/dist/appearance/index.js +1 -12
  4. package/dist/appearance-runtime/index.js +1 -5
  5. package/dist/assistant-context/index.js +1 -11
  6. package/dist/assistant-protocol/index.js +1 -152
  7. package/dist/brand-studio/index.js +4 -1594
  8. package/dist/briefings/index.js +1 -70
  9. package/dist/chunks/add-to-dashboard-DeHEBEqG.js +12 -0
  10. package/dist/chunks/analytics-base-schemas-BREc5WGv.js +1 -0
  11. package/dist/chunks/appearance-context-BqBZrijL.js +1 -0
  12. package/dist/chunks/appearance-runtime-provider-DmbCrOOG.js +1 -0
  13. package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
  14. package/dist/chunks/assistant-chat-CjYrwVDa.js +56 -0
  15. package/dist/chunks/attribution-BEFSsbNn.js +1 -0
  16. package/dist/chunks/availability-3AIOf6Z-.js +1 -0
  17. package/dist/chunks/bookmark-impact-C89zBLq3.js +1 -0
  18. package/dist/chunks/bookmark-state-69YYnRql.js +1 -0
  19. package/dist/chunks/brand-DCaZyRt6.js +1 -0
  20. package/dist/chunks/card-filter-builder-CTp6RAz1.js +17 -0
  21. package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
  22. package/dist/chunks/comparison-window-caption-C312mn3s.js +1 -0
  23. package/dist/chunks/context-ALdccLHw.js +2 -0
  24. package/dist/chunks/conversation-JMK2kyTK.js +1 -0
  25. package/dist/chunks/dashboard-BX28ld6s.js +1 -0
  26. package/dist/chunks/dashboard-briefing-launcher-qo7GH4EO.js +37 -0
  27. package/dist/chunks/dashboard-controls-DhRjB7MA.js +42 -0
  28. package/dist/chunks/dashboard-json-9cHzhSjC.js +1 -0
  29. package/dist/chunks/dates-D-KP8G-z.js +1 -0
  30. package/dist/chunks/edit-DEAK0UZo.js +1 -0
  31. package/dist/chunks/edit-dashboard-visual-Duq_QkB_.js +93 -0
  32. package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
  33. package/dist/chunks/filter-line-CwQrqORc.js +1 -0
  34. package/dist/chunks/filter-reach-preview-gixPFlZj.js +1 -0
  35. package/dist/chunks/filter-value-text-B3tXakhd.js +1 -0
  36. package/dist/chunks/index-B-VF1ogs.js +1 -0
  37. package/dist/chunks/index-BE1DfxNs.js +1 -0
  38. package/dist/chunks/index-DViPGDFj.js +1 -0
  39. package/dist/chunks/layout-grid-BWtlgw0T.js +6 -0
  40. package/dist/chunks/matrix-analytical-definition-CtFqWyCK.js +1 -0
  41. package/dist/chunks/matrix-member-presentation-Q0MCJ-YK.js +1 -0
  42. package/dist/chunks/matrix-operation-contract-D1RC1bfi.js +1 -0
  43. package/dist/chunks/metric-comparison-DEZYXROZ.js +1 -0
  44. package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
  45. package/dist/chunks/paintbrush-BjS3SbrH.js +6 -0
  46. package/dist/chunks/palette-BzC-CGOc.js +6 -0
  47. package/dist/chunks/pickers-DuBrUht0.js +1 -0
  48. package/dist/chunks/pivot-result-contract-expectations-DTQAgr4n.js +1 -0
  49. package/dist/chunks/pivot-result-identity-DTNCB--h.js +1 -0
  50. package/dist/chunks/raw-temporal-value-DeyEhL0S.js +1 -0
  51. package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
  52. package/dist/chunks/report-preferences-dialog-B_gUmCzG.js +1 -0
  53. package/dist/chunks/report-runtime-context-BWzIHCKK.js +1 -0
  54. package/dist/chunks/resolve-dashboard-input-context-B-TtRqxu.js +8 -0
  55. package/dist/chunks/resolver-AN9ChBfZ.js +1 -0
  56. package/dist/chunks/save-DdFUZcbi.js +6 -0
  57. package/dist/chunks/saved-dashboard-context-BAJ5tWiq.js +1 -0
  58. package/dist/chunks/schema-MC0cQSAb.js +4 -0
  59. package/dist/chunks/selection-filter-compiler-CCoCD25M.js +1 -0
  60. package/dist/chunks/semaphor-ready-indicator-DzjorP3t.js +999 -0
  61. package/dist/chunks/set-DuJfGkbY.js +1 -0
  62. package/dist/chunks/shelf-drop-preview-context-BlLJ5RsT.js +6 -0
  63. package/dist/chunks/stored-dashboard-Ctcpkllg.js +1 -0
  64. package/dist/chunks/style-sheet-parts-BRGt9O05.js +178 -0
  65. package/dist/chunks/table-export-sheet-rC5pKmXg.js +2 -0
  66. package/dist/chunks/token-types-Bj9iMy0w.js +1 -0
  67. package/dist/chunks/validators-CqV3Yka1.js +1 -0
  68. package/dist/chunks/variable-draft-DJrfUyhv.js +1 -0
  69. package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
  70. package/dist/dashboard/index.js +1 -7
  71. package/dist/dashboard-authoring/index.js +1 -4491
  72. package/dist/format-utils/index.js +1 -424
  73. package/dist/index.js +1 -554
  74. package/dist/layouts/index.js +1 -7
  75. package/dist/live-channel/index.js +1 -124
  76. package/dist/pdf-export-policy/index.js +1 -92
  77. package/dist/pdf-table-layout/index.js +1 -993
  78. package/dist/report-runtime-context/index.js +1 -9
  79. package/dist/shared/index.js +1 -6
  80. package/dist/style.css +1 -1
  81. package/dist/surfboard/index.js +1 -9
  82. package/dist/types/components/ui-custom/date-range-presets.d.ts +8 -0
  83. package/dist/types/index.js +1 -88
  84. package/dist/types/lib/document/document-edits.d.ts +0 -4
  85. package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
  86. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
  87. package/dist/types/lib/stores/dashboard-store.d.ts +0 -1
  88. package/dist/types/lib/stores/explorer-actions.d.ts +7 -6
  89. package/dist/types/lib/types/common-types.d.ts +0 -2
  90. package/dist/types/lib/types/explorer-types.d.ts +1 -1
  91. package/dist/types/lib/types/semantic-types.d.ts +6 -10
  92. package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
  93. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +18 -0
  94. package/dist/types/shared/analytics-protocol/analyze-result-types.d.ts +3 -0
  95. package/dist/types/shared/analytics-protocol/comparison-choices.d.ts +92 -0
  96. package/dist/types/shared/analytics-protocol/comparison-placement.d.ts +30 -0
  97. package/dist/types/shared/analytics-protocol/contracts.d.ts +11 -5
  98. package/dist/types/shared/analytics-protocol/date-window.d.ts +105 -0
  99. package/dist/types/shared/analytics-protocol/filter-field-ownership.d.ts +27 -0
  100. package/dist/types/shared/analytics-protocol/fixtures.d.ts +4 -2
  101. package/dist/types/shared/analytics-protocol/index.d.ts +3 -0
  102. package/dist/types/shared/analytics-protocol/metric-comparison.d.ts +93 -11
  103. package/dist/types/shared/assistant-protocol/context.d.ts +16 -16
  104. package/dist/types/shared/dashboard-authoring/calculations/calculated-column.d.ts +1 -1
  105. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
  106. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
  107. package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
  108. package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
  109. package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
  110. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
  111. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +132 -0
  112. package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
  113. package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
  114. package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
  115. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +8 -0
  116. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  117. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +2 -1
  118. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +0 -3
  119. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +21 -358
  120. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +2 -0
  121. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  122. package/dist/types/shared/dashboard-authoring/dashboard-variable-card.d.ts +2 -4
  123. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +115 -0
  124. package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
  125. package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
  126. package/dist/types/shared/dashboard-authoring/index.d.ts +6 -1
  127. package/dist/types/shared/dashboard-authoring/kpi-date-context.d.ts +2 -0
  128. package/dist/types/shared/dashboard-authoring/kpi-figure.d.ts +18 -0
  129. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +8 -7
  130. package/dist/types/shared/dashboard-authoring/measure-calculations/dates.d.ts +11 -1
  131. package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +2 -2
  132. package/dist/types/shared/dashboard-authoring/measure-calculations/options.d.ts +4 -0
  133. package/dist/types/shared/dashboard-authoring/measure-calculations/read.d.ts +18 -1
  134. package/dist/types/shared/dashboard-authoring/measure-calculations/resolve.d.ts +2 -0
  135. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +46 -88
  136. package/dist/types/shared/dashboard-authoring/operations/calculated-field-operations.d.ts +33 -8
  137. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +0 -2
  138. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +5 -0
  139. package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
  140. package/dist/types/shared/format-utils/comparison-detail.d.ts +34 -0
  141. package/dist/types/shared/format-utils/index.d.ts +1 -0
  142. package/dist/types/shared/format-utils/partial-period.d.ts +4 -2
  143. package/dist/types/shared/temporal/calendar-periods.d.ts +11 -0
  144. package/dist/types/shared/temporal/index.d.ts +2 -0
  145. package/dist/types/shared/temporal/temporal-text.d.ts +33 -0
  146. package/dist/types/shared/temporal/temporal.d.ts +27 -0
  147. package/dist/types/shared/temporal/zoned-wall-clock.d.ts +4 -3
  148. package/dist/usage-events/index.js +1 -285
  149. package/dist/value-format-preferences/index.js +1 -635
  150. package/package.json +6 -2
  151. package/dist/chunks/add-to-dashboard-ClhEIFst.js +0 -291
  152. package/dist/chunks/analytics-base-schemas-DevrgqQb.js +0 -678
  153. package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
  154. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
  155. package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
  156. package/dist/chunks/assistant-chat-BWF3GYip.js +0 -6115
  157. package/dist/chunks/attribution-BvoKvhcj.js +0 -32
  158. package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
  159. package/dist/chunks/bookmark-impact-BF3iRx5a.js +0 -76
  160. package/dist/chunks/bookmark-state-CBSTdW6q.js +0 -1666
  161. package/dist/chunks/brand-BoUV0iHF.js +0 -54
  162. package/dist/chunks/card-filter-builder-B8XHwMY6.js +0 -4069
  163. package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
  164. package/dist/chunks/comparison-window-caption-W83qB4V5.js +0 -741
  165. package/dist/chunks/context-BJoEFgNl.js +0 -369
  166. package/dist/chunks/conversation-sQiWYUOb.js +0 -16
  167. package/dist/chunks/dashboard-DG5EIYYB.js +0 -14
  168. package/dist/chunks/dashboard-briefing-launcher-CBSrhyWZ.js +0 -4875
  169. package/dist/chunks/dashboard-controls-D6ECO4N1.js +0 -2290
  170. package/dist/chunks/dashboard-json-DrJftBSL.js +0 -66
  171. package/dist/chunks/dates-Bz-qM5px.js +0 -164
  172. package/dist/chunks/edit-9df1zOWe.js +0 -226
  173. package/dist/chunks/edit-dashboard-visual-BDYAJIbb.js +0 -18605
  174. package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
  175. package/dist/chunks/filter-line-BXT6y303.js +0 -703
  176. package/dist/chunks/filter-reach-copy-BukhZmzm.js +0 -5250
  177. package/dist/chunks/filter-value-text-D3-bf3_b.js +0 -153
  178. package/dist/chunks/index-BVKzKl5d.js +0 -90
  179. package/dist/chunks/index-BW0yozjs.js +0 -2795
  180. package/dist/chunks/index-CV_Kzou0.js +0 -595
  181. package/dist/chunks/layout-grid-Ds0diMeY.js +0 -16
  182. package/dist/chunks/matrix-analytical-definition-CgQgVeeI.js +0 -1162
  183. package/dist/chunks/matrix-member-presentation-DSBIIudt.js +0 -258
  184. package/dist/chunks/matrix-operation-contract--DkNCOzd.js +0 -1412
  185. package/dist/chunks/metric-comparison-zMylnIkc.js +0 -541
  186. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
  187. package/dist/chunks/paintbrush-CX8pao1j.js +0 -27
  188. package/dist/chunks/palette-CuA0HlzF.js +0 -23
  189. package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
  190. package/dist/chunks/pivot-result-contract-expectations-C8KL7hPx.js +0 -5046
  191. package/dist/chunks/pivot-result-identity-C1AOH1PS.js +0 -77
  192. package/dist/chunks/raw-temporal-value-E416F-0L.js +0 -454
  193. package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
  194. package/dist/chunks/report-preferences-dialog-CbuVNDGi.js +0 -1637
  195. package/dist/chunks/report-runtime-context-E7USjN7E.js +0 -388
  196. package/dist/chunks/resolve-dashboard-input-context-CULCE_hM.js +0 -25172
  197. package/dist/chunks/resolver-DG_tfEpt.js +0 -156
  198. package/dist/chunks/save-BKHlDONy.js +0 -21
  199. package/dist/chunks/saved-dashboard-context-C1WlOx5z.js +0 -632
  200. package/dist/chunks/schema-C9NPiIru.js +0 -2568
  201. package/dist/chunks/selection-filter-compiler-ifT8JCXS.js +0 -131
  202. package/dist/chunks/semaphor-ready-indicator-CBIRcDWs.js +0 -145326
  203. package/dist/chunks/shelf-drop-preview-context-xR69SMA8.js +0 -2466
  204. package/dist/chunks/stored-dashboard-BuM8vnWf.js +0 -4070
  205. package/dist/chunks/style-sheet-parts-Bt9ZNre8.js +0 -8674
  206. package/dist/chunks/table-export-sheet-DVljtHkG.js +0 -949
  207. package/dist/chunks/token-types-D_xKgyVS.js +0 -8
  208. package/dist/chunks/upload-Dll_M7XQ.js +0 -15
  209. package/dist/chunks/validators-ClWHpYql.js +0 -3686
  210. package/dist/chunks/variable-draft-CDGGl53R.js +0 -242
  211. package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
@@ -1,1666 +0,0 @@
1
- import { a6 as Y, f as Pe, k as Le, aE as qe } from "./validators-ClWHpYql.js";
2
- import { z as l } from "zod";
3
- import { Q as B, E as Be, q as je } from "./matrix-operation-contract--DkNCOzd.js";
4
- import { D as Ue, C as ze, r as j, a as We, e as Qe } from "./metric-comparison-zMylnIkc.js";
5
- import "./analytics-base-schemas-DevrgqQb.js";
6
- import { a as N } from "./applied-constraints-DU-wndZ7.js";
7
- import { r as Ge } from "./pivot-result-identity-C1AOH1PS.js";
8
- const re = 8, se = 6, V = Object.freeze([]);
9
- function Ye(e) {
10
- switch (e.type) {
11
- case "table":
12
- case "chart":
13
- return e.card ? [e.card] : V;
14
- case "kpi":
15
- return Array.isArray(e.cards) ? e.cards : V;
16
- default:
17
- return V;
18
- }
19
- }
20
- function Je(e, t) {
21
- switch (e.type) {
22
- case "table":
23
- case "chart": {
24
- if (!e.card) return e;
25
- const n = t(e.card);
26
- return n === e.card ? e : { ...e, card: n };
27
- }
28
- case "kpi": {
29
- if (!Array.isArray(e.cards)) return e;
30
- const n = e.cards.map(t);
31
- return n.every((r, s) => r === e.cards[s]) ? e : { ...e, cards: n };
32
- }
33
- default:
34
- return e;
35
- }
36
- }
37
- function _(e) {
38
- var n;
39
- const t = [];
40
- for (const r of e.sheets || []) {
41
- const s = r.id;
42
- for (const a of r.cards || [])
43
- t.push({ kind: "sheetCard", sheetId: s, cardId: a.id, card: a });
44
- for (const a of r.frames || [])
45
- for (const i of a.cards || [])
46
- t.push({
47
- kind: "frameCard",
48
- sheetId: s,
49
- frameId: a.id,
50
- cardId: i.id,
51
- card: i
52
- });
53
- for (const a of ((n = r.document) == null ? void 0 : n.sections) || [])
54
- for (const i of Ye(a))
55
- t.push({
56
- kind: "documentSectionCard",
57
- sheetId: s,
58
- sectionId: a.id,
59
- cardId: i.id,
60
- card: i
61
- });
62
- }
63
- return t;
64
- }
65
- function nn(e, t, n) {
66
- let r = !1;
67
- const s = He(e, (i) => i.id !== n.id ? i : (r = !0, i === n ? i : n));
68
- if (r || !t) return s;
69
- const a = (s.sheets || []).map(
70
- (i) => i.id === t && i.kind !== "document" ? { ...i, cards: [...i.cards ?? [], n] } : i
71
- );
72
- return { ...s, sheets: a };
73
- }
74
- function He(e, t) {
75
- const n = (s, a) => {
76
- const i = s.map((o) => t(o, a(o)));
77
- return i.every((o, c) => o === s[c]) ? s : i;
78
- }, r = (e.sheets || []).map((s) => {
79
- var f, y, h;
80
- const a = s.id, i = s.cards && n(s.cards, (p) => ({ kind: "sheetCard", sheetId: a, cardId: p.id, card: p })), o = (f = s.frames) == null ? void 0 : f.map((p) => {
81
- if (!p.cards) return p;
82
- const I = n(p.cards, (g) => ({ kind: "frameCard", sheetId: a, frameId: p.id, cardId: g.id, card: g }));
83
- return I === p.cards ? p : { ...p, cards: I };
84
- }), c = (h = (y = s.document) == null ? void 0 : y.sections) == null ? void 0 : h.map(
85
- (p) => Je(p, (I) => t(I, { kind: "documentSectionCard", sheetId: a, sectionId: p.id, cardId: I.id, card: I }))
86
- ), u = !!o && o.some((p, I) => p !== s.frames[I]), d = !!c && c.some((p, I) => p !== s.document.sections[I]);
87
- return i === s.cards && !u && !d ? s : {
88
- ...s,
89
- ...i === s.cards ? {} : { cards: i },
90
- ...u ? { frames: o } : {},
91
- ...d ? { document: { ...s.document, sections: c } } : {}
92
- };
93
- });
94
- return r.every((s, a) => s === e.sheets[a]) ? e : { ...e, sheets: r };
95
- }
96
- function $(e) {
97
- return !!e && typeof e == "object" && !Array.isArray(e);
98
- }
99
- function rn(e) {
100
- if (!$(e))
101
- return [{ path: "", message: "must be an object." }];
102
- const t = [];
103
- e.title !== void 0 && typeof e.title != "string" && t.push({ path: "title", message: "must be a string." });
104
- const n = e.cards;
105
- if (!Array.isArray(n))
106
- t.push({ path: "cards", message: "must be an array of KPI cards." });
107
- else {
108
- (n.length < 1 || n.length > re) && t.push({
109
- path: "cards",
110
- message: `must hold 1 to ${re} KPI cards.`
111
- });
112
- const s = /* @__PURE__ */ new Set();
113
- n.forEach((a, i) => {
114
- if (!$(a)) {
115
- t.push({ path: `cards[${i}]`, message: "must be a card." });
116
- return;
117
- }
118
- typeof a.id != "string" || !a.id ? t.push({
119
- path: `cards[${i}].id`,
120
- message: "must be a non-empty string."
121
- }) : s.has(a.id) ? t.push({
122
- path: `cards[${i}].id`,
123
- message: `duplicates card id '${a.id}'.`
124
- }) : s.add(a.id), a.type !== "kpi" && t.push({ path: `cards[${i}].type`, message: "must be 'kpi'." });
125
- });
126
- }
127
- const r = e.kpi;
128
- return $(r) ? (r.layout !== "tiles" && r.layout !== "lines" ? t.push({
129
- path: "kpi.layout",
130
- message: "must be 'tiles' or 'lines'."
131
- }) : r.layout === "tiles" && Array.isArray(n) && n.length > se && t.push({
132
- path: "kpi.layout",
133
- message: `must be 'lines' for more than ${se} KPI cards.`
134
- }), r.columns !== void 0 && r.columns !== 1 && r.columns !== 2 && t.push({ path: "kpi.columns", message: "must be 1 or 2." })) : t.push({ path: "kpi", message: "must be an object." }), t;
135
- }
136
- const Ie = "dashboardInput";
137
- function ae(e) {
138
- return e === "label" || e === "value" || e === "start" || e === "end" || e === "range";
139
- }
140
- function Xe(e) {
141
- return e === "generatedAt" || e === "pageNumber" || e === "pageCount";
142
- }
143
- function v(e) {
144
- if (!e || typeof e != "object" || Array.isArray(e)) return;
145
- const t = e;
146
- if (t.source === "input" || t.source === Ie)
147
- return typeof t.inputId == "string" && ae(t.export) ? { source: "input", inputId: t.inputId, export: t.export } : void 0;
148
- if (t.source === "dashboardInputAlias")
149
- return typeof t.variableName != "string" || t.export !== void 0 && !ae(t.export) ? void 0 : {
150
- source: "dashboardInputAlias",
151
- variableName: t.variableName,
152
- ...t.export ? { export: t.export } : {}
153
- };
154
- if (t.source === "documentMeta")
155
- return Xe(t.key) ? { source: "documentMeta", key: t.key } : void 0;
156
- if (t.source === "data")
157
- return typeof t.variableId == "string" && typeof t.export == "string" ? { source: "data", variableId: t.variableId, export: t.export } : void 0;
158
- }
159
- function sn(e, t) {
160
- const n = v(e), r = v(t);
161
- return !n || !r ? JSON.stringify(e) === JSON.stringify(t) : [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)])].every((a) => n[a] === r[a]);
162
- }
163
- function Ze(e) {
164
- return x(e) ? e.type === "variable" ? e.ref === void 0 ? [] : [e.ref] : e.type === "when" && x(e.test) && e.test.ref !== void 0 ? [e.test.ref] : [] : [];
165
- }
166
- function et(e, t) {
167
- if (!x(e)) return e;
168
- if (e.type === "variable" && e.ref !== void 0) {
169
- const n = t(e.ref);
170
- return n === e.ref ? e : { ...e, ref: n };
171
- }
172
- if (e.type === "when" && x(e.test) && e.test.ref !== void 0) {
173
- const n = t(e.test.ref);
174
- return n === e.test.ref ? e : { ...e, test: { ...e.test, ref: n } };
175
- }
176
- return e;
177
- }
178
- function x(e) {
179
- return !!e && typeof e == "object" && !Array.isArray(e);
180
- }
181
- function ie(e) {
182
- return !!e && typeof e == "object" && e.source === Ie;
183
- }
184
- function an(e) {
185
- return U(e);
186
- }
187
- function U(e) {
188
- if (!e || typeof e != "object") return e;
189
- if (Array.isArray(e)) {
190
- let a = !1;
191
- const i = e.map((o) => {
192
- const c = U(o);
193
- return c !== o && (a = !0), c;
194
- });
195
- return a ? i : e;
196
- }
197
- const t = e;
198
- let n;
199
- const r = (a, i) => {
200
- i !== t[a] && (n ?? (n = { ...t }), n[a] = i);
201
- }, s = et(
202
- t,
203
- (a) => ie(a) ? v(a) ?? a : a
204
- );
205
- if (s !== t && (s.ref !== t.ref && r("ref", s.ref), s.test !== t.test && r("test", s.test)), t.inputAliases && typeof t.inputAliases == "object") {
206
- const a = t.inputAliases;
207
- let i = !1;
208
- const o = Object.fromEntries(
209
- Object.entries(a).map(([c, u]) => ie(u) ? (i = !0, [c, v(u) ?? u]) : [c, u])
210
- );
211
- i && r("inputAliases", o);
212
- }
213
- for (const [a, i] of Object.entries(t))
214
- a === "ref" && t.type === "variable" || a === "test" && t.type === "when" || a === "inputAliases" || r(a, U(i));
215
- return n ?? e;
216
- }
217
- function on(e) {
218
- return b(e);
219
- }
220
- function b(e) {
221
- const t = [];
222
- for (const n of Array.isArray(e) ? e : [])
223
- if (!(!n || typeof n != "object")) {
224
- for (const r of Ze(n)) {
225
- const s = v(r);
226
- s && t.push(s);
227
- }
228
- n.type === "link" && t.push(...b(n.children), ...b(Array.isArray(n.url) ? n.url : [])), n.type === "when" && t.push(...b(n.then), ...b(n.else));
229
- }
230
- return t;
231
- }
232
- function tt(e) {
233
- var r;
234
- const t = (r = e.preferences) == null ? void 0 : r.textVisualOptions, n = t == null ? void 0 : t.richContent;
235
- return n && Array.isArray(n.blocks) ? n.blocks.flatMap(
236
- (s) => (s == null ? void 0 : s.type) === "list" ? (Array.isArray(s.items) ? s.items : []).flatMap((a) => b(a)) : b(s == null ? void 0 : s.children)
237
- ) : b(t == null ? void 0 : t.content);
238
- }
239
- function be(e, t) {
240
- var s;
241
- const n = [], r = { kind: "document", sheetId: e };
242
- for (const a of ["header", "footer"])
243
- for (const i of ((s = t[a]) == null ? void 0 : s.blocks) ?? [])
244
- if (i.type === "text")
245
- for (const o of b(i.content))
246
- n.push({ ref: o, place: r, where: { kind: a, blockId: i.id } });
247
- for (const a of t.sections ?? [])
248
- if (a.type === "text")
249
- for (const i of b(a.content))
250
- n.push({ ref: i, place: r, where: { kind: "section", sectionId: a.id } });
251
- return n;
252
- }
253
- const oe = /* @__PURE__ */ new WeakMap();
254
- function Se(e) {
255
- const t = oe.get(e);
256
- if (t) return t;
257
- const n = [];
258
- for (const r of e.sheets ?? []) {
259
- if (r.kind === "document") {
260
- r.document && n.push(...be(r.id, r.document));
261
- continue;
262
- }
263
- const s = { kind: "sheet", sheetId: r.id }, a = [...r.cards ?? [], ...(r.frames ?? []).flatMap((i) => i.cards ?? [])];
264
- for (const i of a)
265
- if (i.type === "text")
266
- for (const o of tt(i))
267
- n.push({ ref: o, place: s, where: { kind: "card", cardId: i.id } });
268
- }
269
- return oe.set(e, n), n;
270
- }
271
- function Ce(e, t) {
272
- return e.kind === t.kind && e.sheetId === t.sheetId;
273
- }
274
- function ge(e, t) {
275
- const n = Se(e);
276
- return t ? n.filter((r) => Ce(r.place, t)) : [...n];
277
- }
278
- function nt(e, t) {
279
- const n = [];
280
- for (const { ref: r, place: s } of Se(e))
281
- r.source !== "data" || r.variableId !== t || n.some((a) => Ce(a, s)) || n.push(s);
282
- return n;
283
- }
284
- function cn(e, t) {
285
- const n = /* @__PURE__ */ new Set();
286
- for (const { ref: r } of ge(e, t))
287
- r.source === "data" && n.add(r.variableId);
288
- return [...n];
289
- }
290
- function un(e, t) {
291
- const n = be("", e).filter(
292
- ({ ref: r }) => r.source === "input" && r.inputId === t
293
- );
294
- return {
295
- header: n.some(({ where: r }) => r.kind === "header"),
296
- footer: n.some(({ where: r }) => r.kind === "footer"),
297
- textSections: new Set(
298
- n.flatMap(({ where: r }) => r.kind === "section" ? [r.sectionId] : [])
299
- ).size
300
- };
301
- }
302
- function ke(e, t) {
303
- const n = nt(e, t);
304
- return n.length ? n.map((r) => ({
305
- sheetId: r.sheetId,
306
- cardId: t,
307
- sheetKind: r.kind === "document" ? "document" : "dashboard"
308
- })) : (e.sheets ?? []).filter((r) => r.kind !== "document").map((r) => ({ sheetId: r.id, cardId: t, sheetKind: "dashboard" }));
309
- }
310
- function C(e, t) {
311
- var r;
312
- if (!it(e, t))
313
- return !1;
314
- const n = e.scope;
315
- switch (n.kind) {
316
- case "allSheets":
317
- return ((r = n.sheetKinds) != null && r.length ? t.sheetKind ? n.sheetKinds.includes(t.sheetKind) : !1 : !!t.sheetId || !!t.cardId) && !at(n.exceptSheetIds, t) && !de(n.exceptCardIds, t);
318
- case "sheets":
319
- return !!t.sheetId && n.sheetIds.includes(t.sheetId) && !de(n.exceptCardIds, t);
320
- case "cards":
321
- return !!t.cardId && n.cardIds.includes(t.cardId);
322
- case "documentSections":
323
- return !!t.sheetId && !!t.sectionId && n.sheetId === t.sheetId && n.sectionIds.includes(t.sectionId);
324
- default:
325
- return !1;
326
- }
327
- }
328
- function dn(e, t) {
329
- if (C(e, {
330
- sheetId: t.sheetId,
331
- sheetKind: t.sheetKind
332
- }))
333
- return !0;
334
- switch (e.scope.kind) {
335
- case "cards":
336
- for (const n of [...t.cardIds, ...t.variableIds ?? []])
337
- if (C(e, {
338
- sheetId: t.sheetId,
339
- cardId: n,
340
- sheetKind: t.sheetKind
341
- }))
342
- return !0;
343
- return !1;
344
- case "documentSections":
345
- return t.sheetKind === "document" && e.scope.sheetId === t.sheetId;
346
- default:
347
- return !1;
348
- }
349
- }
350
- const ce = /* @__PURE__ */ new WeakMap();
351
- function rt(e) {
352
- const t = ce.get(e);
353
- if (t) return t;
354
- const n = /* @__PURE__ */ new Map();
355
- for (const a of _(e)) {
356
- const i = n.get(a.sheetId) ?? /* @__PURE__ */ new Set();
357
- i.add(a.cardId), n.set(a.sheetId, i);
358
- }
359
- const r = /* @__PURE__ */ new Map();
360
- for (const { ref: a, place: i } of ge(e)) {
361
- if (a.source !== "data") continue;
362
- const o = r.get(i.sheetId) ?? /* @__PURE__ */ new Set();
363
- o.add(a.variableId), r.set(i.sheetId, o);
364
- }
365
- const s = /* @__PURE__ */ new Map();
366
- for (const a of e.sheets ?? [])
367
- s.set(a.id, {
368
- sheetId: a.id,
369
- sheetKind: a.kind === "document" ? "document" : "dashboard",
370
- cardIds: n.get(a.id) ?? /* @__PURE__ */ new Set(),
371
- variableIds: r.get(a.id) ?? /* @__PURE__ */ new Set()
372
- });
373
- return ce.set(e, s), s;
374
- }
375
- function ln(e, t) {
376
- var s, a;
377
- const n = /* @__PURE__ */ new Set(), r = rt(e);
378
- for (const i of r.values())
379
- C(t, {
380
- sheetId: i.sheetId,
381
- sheetKind: i.sheetKind
382
- }) && n.add(`sheet:${i.sheetId}`);
383
- for (const i of _(e))
384
- C(t, {
385
- sheetId: i.sheetId,
386
- cardId: i.cardId,
387
- ...i.kind === "documentSectionCard" ? { sectionId: i.sectionId } : {},
388
- sheetKind: ((s = r.get(i.sheetId)) == null ? void 0 : s.sheetKind) ?? "dashboard"
389
- }) && n.add(`card:${i.cardId}`);
390
- for (const i of e.variables ?? [])
391
- ke(e, i.id).some(
392
- (o) => C(t, o)
393
- ) && n.add(`card:${i.id}`);
394
- for (const i of e.sheets ?? [])
395
- if (i.kind === "document")
396
- for (const o of ((a = i.document) == null ? void 0 : a.sections) ?? [])
397
- C(t, {
398
- sheetId: i.id,
399
- sectionId: o.id,
400
- sheetKind: "document"
401
- }) && n.add(`section:${o.id}`);
402
- return n;
403
- }
404
- function fn(e) {
405
- return e.kind === "filter" && e.scope.kind === "cards";
406
- }
407
- function mn(e, t) {
408
- var a, i, o;
409
- const n = (c) => {
410
- var u, d;
411
- return ue(c, t.removedSheetIds, t.renamedSheetIds, !1, (u = t.copiedTab) == null ? void 0 : u.sheetIds, (d = t.copiedTab) == null ? void 0 : d.mode);
412
- }, r = (c) => {
413
- var u, d;
414
- return ue(
415
- c,
416
- t.removedCardIds,
417
- t.renamedCardIds,
418
- t.keepOnlyRenamedCardIds === !0,
419
- (u = t.copiedTab) == null ? void 0 : u.cardIds,
420
- (d = t.copiedTab) == null ? void 0 : d.mode
421
- );
422
- };
423
- let s;
424
- switch (e.kind) {
425
- case "allSheets":
426
- s = {
427
- ...e,
428
- ...e.exceptSheetIds ? { exceptSheetIds: n(e.exceptSheetIds) } : {},
429
- ...e.exceptCardIds ? { exceptCardIds: r(e.exceptCardIds) } : {}
430
- };
431
- break;
432
- case "sheets":
433
- s = {
434
- ...e,
435
- sheetIds: n(e.sheetIds),
436
- ...e.exceptCardIds ? { exceptCardIds: r(e.exceptCardIds) } : {}
437
- };
438
- break;
439
- case "cards":
440
- s = { ...e, cardIds: r(e.cardIds) };
441
- break;
442
- case "documentSections": {
443
- if ((a = t.removedSheetIds) != null && a.has(e.sheetId)) {
444
- s = { ...e, sectionIds: [] };
445
- break;
446
- }
447
- const c = {
448
- ...e,
449
- sheetId: ((i = t.renamedSheetIds) == null ? void 0 : i.get(e.sheetId)) ?? e.sheetId,
450
- sectionIds: (o = t.renamedSectionIds) != null && o.size ? e.sectionIds.map((d) => t.renamedSectionIds.get(d) ?? d) : e.sectionIds
451
- }, u = t.copiedTab;
452
- s = (u == null ? void 0 : u.mode) === "replace" && u.sheetIds.has(c.sheetId) ? {
453
- ...c,
454
- sheetId: u.sheetIds.get(c.sheetId),
455
- sectionIds: c.sectionIds.map((d) => u.sectionIds.get(d) ?? d)
456
- } : c;
457
- break;
458
- }
459
- default:
460
- return e;
461
- }
462
- return st(e, s) ? e : s;
463
- }
464
- function ue(e, t, n, r, s, a) {
465
- let i = e;
466
- return t != null && t.size && (i = i.filter((o) => !t.has(o))), r && (i = i.filter((o) => n == null ? void 0 : n.has(o))), n != null && n.size && (i = i.map((o) => n.get(o) ?? o)), s != null && s.size && (i = a === "extend" ? [.../* @__PURE__ */ new Set([...i, ...i.flatMap((o) => s.has(o) ? [s.get(o)] : [])])] : i.map((o) => s.get(o) ?? o)), i;
467
- }
468
- function st(e, t) {
469
- return JSON.stringify(e) === JSON.stringify(t);
470
- }
471
- function at(e, t) {
472
- return !!t.sheetId && !!(e != null && e.includes(t.sheetId));
473
- }
474
- function de(e, t) {
475
- return !!t.cardId && !!(e != null && e.includes(t.cardId));
476
- }
477
- function it(e, t) {
478
- return t.sheetKind !== "document" || !e.compatibility || e.compatibility.source === "documentInput" ? !0 : e.compatibility.source === "cardInlineFilter" || e.compatibility.source === "cardControl" ? !!t.cardId && e.compatibility.cardId === t.cardId : !1;
479
- }
480
- function pn(e, t, n) {
481
- switch (e.kind) {
482
- case "sheets":
483
- return e.sheetIds.length > 0 && e.sheetIds.every((r) => r === t);
484
- case "cards":
485
- return e.cardIds.length > 0 && e.cardIds.every((r) => n.has(r));
486
- case "documentSections":
487
- return e.sheetId === t;
488
- case "allSheets":
489
- return !1;
490
- }
491
- }
492
- function hn(e) {
493
- return e.kind === "sheets" && e.sheetIds.length === 0 || e.kind === "cards" && e.cardIds.length === 0;
494
- }
495
- function ot(e) {
496
- return e.kind === "allSheets" || e.kind === "sheets" ? e.exceptCardIds ?? [] : [];
497
- }
498
- function yn(e) {
499
- return e.kind === "allSheets" ? e.exceptSheetIds ?? [] : [];
500
- }
501
- function In(e, t) {
502
- var a;
503
- if (e.kind !== "allSheets" && e.kind !== "sheets" || !((a = e.exceptCardIds) != null && a.includes(t))) return e;
504
- const n = e.exceptCardIds.filter((i) => i !== t), { exceptCardIds: r, ...s } = e;
505
- return n.length ? { ...s, exceptCardIds: n } : s;
506
- }
507
- function bn(e, t, n) {
508
- var o;
509
- if (t.kind !== "allSheets" && t.kind !== "sheets") return t;
510
- const r = ot(e), s = e.kind === "sheets" ? e.sheetIds.filter((c) => n.has(c)) : e.kind === "allSheets" && le(e) ? [...n].filter((c) => {
511
- var u;
512
- return !((u = e.exceptSheetIds) != null && u.includes(c));
513
- }) : [], a = [...n].filter((c) => !s.includes(c));
514
- if (t.kind === "sheets")
515
- return {
516
- ...t,
517
- sheetIds: [.../* @__PURE__ */ new Set([...t.sheetIds, ...s])],
518
- ...r.length ? { exceptCardIds: [...r] } : {}
519
- };
520
- const i = e.kind === "allSheets" ? ((o = e.exceptSheetIds) == null ? void 0 : o.filter((c) => n.has(c))) ?? [] : [];
521
- return {
522
- kind: "allSheets",
523
- ...e.kind === "allSheets" && le(e) ? {
524
- ...e.sheetKinds ? { sheetKinds: e.sheetKinds } : {},
525
- ...i.length ? { exceptSheetIds: i } : {}
526
- } : s.length ? {
527
- sheetKinds: ["dashboard", "document"],
528
- ...a.length ? { exceptSheetIds: a } : {}
529
- } : {},
530
- ...r.length ? { exceptCardIds: [...r] } : {}
531
- };
532
- }
533
- function le(e) {
534
- var t;
535
- return e.kind === "allSheets" && (!((t = e.sheetKinds) != null && t.length) || e.sheetKinds.includes("document"));
536
- }
537
- function Sn(e, t) {
538
- switch (e.kind) {
539
- case "allSheets":
540
- case "sheets": {
541
- const n = e.exceptCardIds ?? [];
542
- return n.includes(t) ? e : { ...e, exceptCardIds: [...n, t] };
543
- }
544
- case "cards":
545
- return { ...e, cardIds: e.cardIds.filter((n) => n !== t) };
546
- case "documentSections":
547
- return;
548
- }
549
- }
550
- const ct = 6;
551
- function Cn(e) {
552
- if (!(e === void 0 || !Number.isFinite(e)) && Number.isInteger(e))
553
- return Math.max(0, Math.min(ct, e));
554
- }
555
- function we(e) {
556
- var t;
557
- return ((t = e == null ? void 0 : e.comparison) == null ? void 0 : t.mode) === "explicit" ? e.comparison.spec : void 0;
558
- }
559
- function ut(e) {
560
- var t;
561
- return ((t = we(e)) == null ? void 0 : t.kind) || "none";
562
- }
563
- function gn(e) {
564
- const t = we(e);
565
- return (t == null ? void 0 : t.kind) === "target" ? t.targetValue : void 0;
566
- }
567
- function kn(e) {
568
- return (e == null ? void 0 : e.semanticComparisonPolarity) || (e == null ? void 0 : e.comparisonPolarity) || Ue;
569
- }
570
- function J(e, t) {
571
- const n = Object.entries(e || {}).filter(
572
- ([a, i]) => i.output.outputId === a
573
- );
574
- if (!t.name) return;
575
- const r = j({
576
- ...t,
577
- name: t.name
578
- }), s = n.filter(
579
- ([, a]) => a.output.metricAlias === r
580
- );
581
- return s.length === 1 ? s[0][1] : void 0;
582
- }
583
- function wn(e, t) {
584
- const n = J(e, t);
585
- return {
586
- comparisonKind: (n == null ? void 0 : n.type) ?? ut(t),
587
- metadata: n
588
- };
589
- }
590
- function An(e) {
591
- return (e == null ? void 0 : e.showComparison) ?? ze.showComparison;
592
- }
593
- function vn(e) {
594
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
595
- return Object.entries(e || {}).forEach(([c, u]) => {
596
- const d = u.output;
597
- d.outputId === c && (t.add(d.currentColumnKey), n.add(d.currentColumnKey), d.availability.status === "available" && (d.comparisonColumnKey && (r.add(d.comparisonColumnKey), o.set(
598
- d.comparisonColumnKey,
599
- {
600
- metricName: u.displayName || d.metricId,
601
- comparisonLabel: u.displayLabel || "Comparison"
602
- }
603
- )), d.deltaColumnKey && (t.add(d.deltaColumnKey), s.add(d.deltaColumnKey)), d.percentChangeColumnKey && (t.add(d.percentChangeColumnKey), a.add(d.percentChangeColumnKey)), d.ratioColumnKey && (t.add(d.ratioColumnKey), i.add(d.ratioColumnKey)), d.rowStatusColumnKey && (t.add(d.rowStatusColumnKey), n.add(d.rowStatusColumnKey)), d.currentBucketColumnKey && (t.add(d.currentBucketColumnKey), n.add(d.currentBucketColumnKey)), d.comparisonSourceBucketColumnKey && (t.add(d.comparisonSourceBucketColumnKey), n.add(d.comparisonSourceBucketColumnKey))));
604
- }), {
605
- internalKeys: t,
606
- bookkeepingKeys: n,
607
- comparisonColumnKeys: r,
608
- deltaColumnKeys: s,
609
- percentChangeColumnKeys: a,
610
- ratioColumnKeys: i,
611
- comparisonSeriesLabels: o
612
- };
613
- }
614
- const dt = "SEMAPHOR_CALCULATED_FIELD";
615
- function H(e, t, n) {
616
- if (n && (t === "groupby" || t === "pivotby"))
617
- return n;
618
- if (t === "metric" && e.name === "*" && !e.expression)
619
- return e.alias || "count";
620
- if (e.alias) return e.alias;
621
- const r = e.entityName && e.entityName !== dt ? e.entityName : void 0;
622
- if (e.role === "metric") {
623
- let s = e.aggregate || "metric";
624
- if (e.expression) {
625
- const a = e.expression.match(
626
- /^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
627
- );
628
- s = a ? a[1].toLowerCase() : "expr";
629
- } else
630
- s = s.toLowerCase();
631
- return r && r !== e.name ? `${r}_${e.name}_${s}` : `${e.name}_${s}`;
632
- }
633
- return r && r !== e.name ? `${r}_${e.name}` : e.name;
634
- }
635
- function Ae(e) {
636
- return H(e, "detail");
637
- }
638
- function lt(e) {
639
- const t = e.label;
640
- return t && e.labelCount === 1 && (t === e.rawKey || !e.rawKeys.has(t)) ? t : e.rawKey;
641
- }
642
- function Tn(e) {
643
- const t = [
644
- ...(e.groupByColumns ?? []).map((o) => ({ field: o, role: "groupby" })),
645
- ...(e.metricColumns ?? []).map((o) => ({ field: o, role: "metric" })),
646
- ...(e.pivotByColumns ?? []).map((o) => ({ field: o, role: "pivotby" })),
647
- ...(e.detailColumns ?? []).map((o) => ({ field: o, role: "detail" }))
648
- ], n = ve(e.detailColumns ?? []), r = new Map((e.detailColumns ?? []).map((o, c) => [o, c])), s = new Map(
649
- t.map(({ field: o, role: c }) => [
650
- o,
651
- c === "detail" ? n[r.get(o)] : H(o, c)
652
- ])
653
- ), a = new Set(s.values()), i = /* @__PURE__ */ new Map();
654
- for (const { field: o } of t)
655
- o.label && i.set(o.label, (i.get(o.label) ?? 0) + 1);
656
- return new Map(
657
- t.map(({ field: o }) => [
658
- o,
659
- lt({
660
- label: o.label,
661
- labelCount: o.label ? i.get(o.label) ?? 0 : 0,
662
- rawKey: s.get(o),
663
- rawKeys: a
664
- })
665
- ])
666
- );
667
- }
668
- function ve(e) {
669
- const t = e.map((s) => Ae(s)), n = new Set(t), r = /* @__PURE__ */ new Map();
670
- return t.forEach((s, a) => {
671
- r.has(s) || r.set(s, a);
672
- }), t.map((s, a) => {
673
- if (r.get(s) === a) return s;
674
- let i = 2;
675
- for (; n.has(`${s}_${i}`); ) i += 1;
676
- return n.add(`${s}_${i}`), `${s}_${i}`;
677
- });
678
- }
679
- function En(e) {
680
- const t = e.detailColumns;
681
- if (!t || t.length < 2) return e;
682
- const n = ve(t);
683
- let r = !1;
684
- const s = t.map((a, i) => Ae(a) === n[i] ? a : (r = !0, { ...a, alias: n[i] }));
685
- return r ? { ...e, detailColumns: s } : e;
686
- }
687
- const Te = "text", M = 100, ft = 10, S = "value", Ee = ["previous", "change", "percentChange"];
688
- function mt(e) {
689
- return Ee.includes(e);
690
- }
691
- const pt = ["up", "down", "flat"];
692
- function Kn(e, t, n) {
693
- const { signWords: r, absolute: s, percent: a, ...i } = t ?? {};
694
- return e !== "change" && e !== "percentChange" ? i : {
695
- ...i,
696
- ...(n == null ? void 0 : n.signWords) === void 0 ? { signWords: pt } : {},
697
- ...(n == null ? void 0 : n.absolute) === void 0 ? { absolute: !0 } : {},
698
- ...e === "percentChange" && (n == null ? void 0 : n.percent) === void 0 ? { percent: !0 } : {}
699
- };
700
- }
701
- function X(e) {
702
- var r, s, a, i;
703
- if (e.get.kind !== "aggregate" || (r = e.query.sql) != null && r.trim()) return;
704
- const t = (i = (a = (s = e.query.config) == null ? void 0 : s.metricColumns) == null ? void 0 : a[0]) == null ? void 0 : i.comparison;
705
- if ((t == null ? void 0 : t.mode) !== "explicit") return;
706
- const n = t.spec;
707
- return n.kind === "previous_period" || n.kind === "previous_year" ? n : void 0;
708
- }
709
- function fe(e, t) {
710
- if (t === "preview" && e.get.kind !== "aggregate")
711
- return M + 1;
712
- switch (e.get.kind) {
713
- case "only":
714
- return 2;
715
- case "list":
716
- return M + 1;
717
- default:
718
- return 1;
719
- }
720
- }
721
- const me = {
722
- answer: /* @__PURE__ */ new WeakMap(),
723
- preview: /* @__PURE__ */ new WeakMap()
724
- };
725
- function ht(e, t = "answer") {
726
- var a;
727
- const n = me[t].get(e);
728
- if (n) return n;
729
- const { query: r } = e, s = {
730
- id: e.id,
731
- title: e.name,
732
- type: Te,
733
- respondsToSelections: !1,
734
- dataVariableId: e.id,
735
- // The viewer's dashboard comparison never changes a variable: its own
736
- // measure says whether it compares (P3b-03).
737
- preferences: { inheritGlobalComparison: !1 },
738
- ...r.connectionId ? { connectionId: r.connectionId } : {},
739
- ...r.dataSource ? { dataSource: r.dataSource } : {},
740
- ...r.calculatedFields ? { calculatedFields: r.calculatedFields } : {},
741
- ...(a = r.sql) != null && a.trim() ? { sql: r.sql, config: { rowLimit: fe(e, t) } } : { config: { ...r.config, rowLimit: fe(e, t) } }
742
- };
743
- return me[t].set(e, s), s;
744
- }
745
- function Dn(e) {
746
- return e.type === Te && typeof e.dataVariableId == "string" && e.dataVariableId.length > 0;
747
- }
748
- function Nn(e, t, n) {
749
- var r;
750
- if (n === S && ((r = e.query.sql) != null && r.trim())) {
751
- const s = Object.keys(t)[0];
752
- return s === void 0 ? void 0 : t[s];
753
- }
754
- return n in t ? t[n] : void 0;
755
- }
756
- function z(e) {
757
- const t = Y(e);
758
- return t === "string" || t === "unknown" ? "text" : t;
759
- }
760
- function yt(e) {
761
- return typeof e == "number" ? "number" : typeof e == "boolean" ? "boolean" : "text";
762
- }
763
- function It(e, t, n, r) {
764
- var i, o;
765
- const s = Ge(r, e.id, t);
766
- return [
767
- s == null ? void 0 : s.outputKey,
768
- s == null ? void 0 : s.rawKey,
769
- t === "metric" ? ((o = (i = r == null ? void 0 : r.byMetricAlias) == null ? void 0 : i[j(e)]) == null ? void 0 : o.outputKey) ?? j(e) : void 0,
770
- H(e, t === "metric" ? "metric" : "groupby"),
771
- e.label,
772
- e.name
773
- ].find((c) => !!c && n.has(c));
774
- }
775
- function On(e, t) {
776
- var r;
777
- if (e.get.kind === "aggregate")
778
- return X(e) ? [S, ...Ee] : [S];
779
- if (e.get.kind === "list") return [S];
780
- if ((r = e.query.sql) != null && r.trim()) return [...t ?? []];
781
- const n = e.query.config;
782
- return bt([
783
- ...((n == null ? void 0 : n.groupByColumns) ?? []).map((s) => s.name),
784
- ...((n == null ? void 0 : n.metricColumns) ?? []).map((s) => s.name)
785
- ]);
786
- }
787
- function xn(e, t) {
788
- var a, i, o, c;
789
- if (e.get.kind === "list") return "list";
790
- if ((a = e.query.sql) != null && a.trim()) return;
791
- const n = e.query.config, r = (u, d) => {
792
- if (!u) return;
793
- const f = d === "metric" ? B(u) : u.dataType;
794
- return Y(f) === "unknown" ? void 0 : z(f);
795
- };
796
- if (e.get.kind === "aggregate")
797
- return mt(t) && X(e) ? "number" : t === S ? r((i = n == null ? void 0 : n.metricColumns) == null ? void 0 : i[0], "metric") : void 0;
798
- const s = (o = n == null ? void 0 : n.groupByColumns) == null ? void 0 : o.find((u) => u.name === t);
799
- return s ? r(s, "groupby") : r((c = n == null ? void 0 : n.metricColumns) == null ? void 0 : c.find((u) => u.name === t), "metric");
800
- }
801
- function bt(e) {
802
- return [...new Set(e)];
803
- }
804
- function St(e, t, n) {
805
- var p, I, g;
806
- const r = t[0] ?? {}, s = new Set(
807
- (p = n.columns) != null && p.length ? n.columns.map((m) => m.key) : Object.keys(r)
808
- ), a = new Map(
809
- (n.columns ?? []).map((m) => [m.key, m.dataType])
810
- ), i = (m, k) => a.has(m) ? z(a.get(m)) : k !== void 0 ? z(k) : yt(r[m]);
811
- if ((I = e.query.sql) != null && I.trim())
812
- return [...s].map((m) => ({ part: m, key: m, type: i(m, void 0) }));
813
- const o = e.query.config ?? {}, c = [], u = s.size === 1 ? [...s][0] : void 0, d = e.get.kind === "aggregate" || e.get.kind === "list", f = (m, k, ne) => {
814
- if (c.some(($e) => $e.part === ne)) return;
815
- const K = It(m, k, s, n.columnKeyMap) ?? (d ? u : void 0);
816
- if (!K) return;
817
- const Ve = k === "metric" ? i(K, B(m)) : i(K, m.dataType);
818
- c.push({ part: ne, key: K, type: Ve });
819
- }, y = o.metricColumns ?? [];
820
- if (e.get.kind === "aggregate") {
821
- const m = y[0] ? (g = J(n.comparisonMetadata, y[0])) == null ? void 0 : g.output.currentColumnKey : void 0;
822
- return m && s.has(m) ? c.push({ part: S, key: m, type: i(m, B(y[0])) }) : y[0] && f(y[0], "metric", S), c;
823
- }
824
- const h = o.groupByColumns ?? [];
825
- if (e.get.kind === "list")
826
- return h[0] && f(h[0], "groupby", S), c;
827
- for (const m of h) f(m, "groupby", m.name);
828
- for (const m of y) f(m, "metric", m.name);
829
- return c;
830
- }
831
- function W(e, t) {
832
- return e == null ? { value: null, type: t } : typeof e == "number" || typeof e == "boolean" || typeof e == "string" ? { value: e, type: t } : e instanceof Date ? { value: e.toISOString(), type: t } : { value: JSON.stringify(e), type: t };
833
- }
834
- function w(e) {
835
- return !!e && typeof e == "object" && !Array.isArray(e);
836
- }
837
- function Mn(e) {
838
- if (!w(e)) return {};
839
- const t = w(e.data) ? e.data : e, n = N(e).length ? N(e) : N(t), r = w(t.metadata) ? t.metadata : void 0;
840
- return {
841
- ...t.records !== void 0 ? { records: t.records } : {},
842
- ...Array.isArray(t.columns) ? { columns: t.columns } : {},
843
- ...w(t.columnKeyMap) ? { columnKeyMap: t.columnKeyMap } : {},
844
- ...n.length ? { filterReach: n } : {},
845
- ...r && w(r.comparisonMetadata) ? { comparisonMetadata: r.comparisonMetadata } : {},
846
- ...typeof t.error == "string" && t.error ? { error: t.error } : {}
847
- };
848
- }
849
- function Rn(e, t, n = "answer") {
850
- var d;
851
- const r = (Array.isArray(t.records) ? t.records : []).filter(
852
- (f) => !!f && typeof f == "object"
853
- ), s = N(t), a = n === "preview" ? { matched: r.length > M ? "beyondCap" : r.length } : {};
854
- if (!r.length) return { status: "none", why: "noRows", filterReach: s, ...a };
855
- const i = St(e, r, t);
856
- if (e.get.kind === "list") {
857
- const f = i[0], y = r.length > M, h = f ? r.map((I) => W(I[f.key], f.type)).filter((I) => I.value !== null) : [];
858
- if (!h.length && !y) return { status: "none", why: "noRows", filterReach: s, ...a };
859
- const p = Math.max(1, e.get.limit ?? ft);
860
- return {
861
- status: "listed",
862
- items: h.slice(0, p),
863
- more: y ? "beyondCap" : Math.max(0, h.length - p),
864
- filterReach: s,
865
- ...a
866
- };
867
- }
868
- if (e.get.kind === "only" && r.length > 1)
869
- return { status: "none", why: "moreThanOne", filterReach: s, ...a };
870
- const o = r[0], c = Object.fromEntries(
871
- i.map((f) => [f.part, W(o[f.key], f.type)])
872
- );
873
- if (e.get.kind === "aggregate" && ((d = c[S]) == null ? void 0 : d.value) == null)
874
- return { status: "none", why: "noRows", filterReach: s, ...a };
875
- const u = X(e) ? Ct(e, o, t) : void 0;
876
- return {
877
- status: "answered",
878
- parts: u && "parts" in u ? { ...c, ...u.parts } : c,
879
- filterReach: s,
880
- ...u && "unavailable" in u ? { comparisonUnavailable: u.unavailable } : {},
881
- ...a
882
- };
883
- }
884
- function Ct(e, t, n) {
885
- var o, c;
886
- const r = (c = (o = e.query.config) == null ? void 0 : o.metricColumns) == null ? void 0 : c[0], s = r ? J(n.comparisonMetadata, r) : void 0, a = s == null ? void 0 : s.output;
887
- if (!a || a.availability.status !== "available" || !a.comparisonColumnKey)
888
- return { unavailable: (a == null ? void 0 : a.availability.status) === "unavailable" ? a.availability.reason : "temporal_binding_missing" };
889
- const i = (u) => {
890
- const d = t[u], f = typeof d == "string" && d.trim() !== "" ? Number(d) : d;
891
- return W(typeof f == "number" && !Number.isFinite(f) ? null : f, "number");
892
- };
893
- return {
894
- parts: {
895
- previous: i(a.comparisonColumnKey),
896
- change: i(a.deltaColumnKey ?? ""),
897
- percentChange: i(a.percentChangeColumnKey ?? "")
898
- }
899
- };
900
- }
901
- const pe = /* @__PURE__ */ new WeakMap();
902
- function Z(e) {
903
- const t = pe.get(e);
904
- if (t) return t;
905
- const n = new Map(
906
- (e.sheets ?? []).map(
907
- (a) => [a.id, a.kind === "document" ? "document" : "dashboard"]
908
- )
909
- ), r = [
910
- ..._(e).map(
911
- (a) => ({
912
- kind: "card",
913
- id: a.cardId,
914
- card: a.card,
915
- sheetId: a.sheetId,
916
- sheetKind: n.get(a.sheetId) ?? "dashboard",
917
- ...a.kind === "documentSectionCard" ? { sectionId: a.sectionId } : {}
918
- })
919
- ),
920
- ...(e.variables ?? []).map(
921
- (a) => ({
922
- kind: "variable",
923
- id: a.id,
924
- variable: a,
925
- card: ht(a)
926
- })
927
- )
928
- ], s = { targets: r, byId: new Map(r.map((a) => [a.id, a])) };
929
- return pe.set(e, s), s;
930
- }
931
- function gt(e) {
932
- return Z(e).targets;
933
- }
934
- function _n(e, t) {
935
- return Z(e).byId.get(t);
936
- }
937
- function kt(e, t) {
938
- return Z(e).byId.has(t);
939
- }
940
- function wt(e, t) {
941
- return t.kind === "card" ? [
942
- {
943
- sheetId: t.sheetId,
944
- cardId: t.id,
945
- sheetKind: t.sheetKind,
946
- ...t.sectionId ? { sectionId: t.sectionId } : {}
947
- }
948
- ] : ke(e, t.id);
949
- }
950
- function At(e, t, n) {
951
- return wt(e, n).some(
952
- (r) => C(t, r)
953
- );
954
- }
955
- function Fn(e, t) {
956
- return gt(e).filter(
957
- (n) => n.kind === "variable" && At(e, t, n)
958
- );
959
- }
960
- const vt = ["new", "edit", "delete", "create", "update", "remove"];
961
- function Ke(e, t) {
962
- return (e.sheets || []).flatMap(
963
- (n) => _({ sheets: [n] }).filter(t).map((r) => ({
964
- card: r.card,
965
- sheet: n,
966
- ...r.kind === "frameCard" && { frameId: r.frameId },
967
- ...r.kind === "documentSectionCard" && {
968
- sectionId: r.sectionId
969
- }
970
- }))
971
- );
972
- }
973
- function T(e) {
974
- return Ke(e, (t) => t.kind !== "documentSectionCard");
975
- }
976
- function Vn(e) {
977
- return [
978
- ...T(e),
979
- ...Ke(e, (t) => t.kind === "documentSectionCard")
980
- ];
981
- }
982
- function $n(e) {
983
- return T(e).map((t) => t.card);
984
- }
985
- function Pn(e, t, n) {
986
- return n && t === n ? !0 : !kt(e, t);
987
- }
988
- function Ln(e) {
989
- return !e || e.trim().length === 0 ? { isValid: !1, error: "Card ID cannot be empty" } : e.length < 3 ? { isValid: !1, error: "Card ID must be at least 3 characters" } : e.length > 50 ? { isValid: !1, error: "Card ID must be less than 50 characters" } : /^[a-zA-Z0-9-_]+$/.test(e) ? /^[a-zA-Z0-9]/.test(e) ? vt.includes(e.toLowerCase()) ? {
990
- isValid: !1,
991
- error: `"${e}" is a reserved keyword and cannot be used`
992
- } : { isValid: !0 } : {
993
- isValid: !1,
994
- error: "Card ID must start with a letter or number"
995
- } : {
996
- isValid: !1,
997
- error: "Card ID can only contain letters, numbers, hyphens, and underscores"
998
- };
999
- }
1000
- function qn(e, t) {
1001
- var n;
1002
- return (n = Tt(e, t)) == null ? void 0 : n.card;
1003
- }
1004
- function Tt(e, t) {
1005
- for (const n of T(e))
1006
- if (n.card.id === t)
1007
- return n;
1008
- }
1009
- function Bn(e, t) {
1010
- for (const n of e.sheets || [])
1011
- for (const r of n.frames || [])
1012
- for (const s of r.cards || [])
1013
- if (s.id === t)
1014
- return { card: s, sheet: n };
1015
- }
1016
- const R = {
1017
- includeMetricFilterDatasets: !0,
1018
- preferQualifiedIdentity: !1
1019
- };
1020
- function De(e) {
1021
- if (!e) return;
1022
- if (e.kind === "semantic")
1023
- return { entityName: e.datasetName, entityId: e.datasetId, label: e.label };
1024
- const t = [e.databaseName, e.schemaName, e.tableName].filter((n) => !!(n && n.trim())).join(".");
1025
- return {
1026
- entityName: e.tableName,
1027
- qualifiedEntityName: t.includes(".") ? t : void 0,
1028
- label: e.label
1029
- };
1030
- }
1031
- function Et(e) {
1032
- var n;
1033
- const t = De(e.source);
1034
- return t ? `${(n = e.source) == null ? void 0 : n.kind}:${t.qualifiedEntityName || t.entityName}` : "";
1035
- }
1036
- function Kt(e) {
1037
- return [
1038
- e.id,
1039
- e.qualifiedEntityName,
1040
- e.entityId,
1041
- e.entityName,
1042
- e.qualifiedFieldName,
1043
- e.name,
1044
- // Source-only fields from different datasets can otherwise share a key
1045
- // and the second dataset would be silently dropped.
1046
- Et(e)
1047
- ].join("|");
1048
- }
1049
- function Dt(e) {
1050
- return [e.entityName, e.qualifiedEntityName || "", e.entityId || ""].join("|");
1051
- }
1052
- function jn(e) {
1053
- return e.entityName || e.qualifiedEntityName || "";
1054
- }
1055
- function Nt(e) {
1056
- var t, n;
1057
- return !!(e.expression || e.derivedField || (n = (t = e.calculatedFormula) == null ? void 0 : t.inputFields) != null && n.length);
1058
- }
1059
- function Ot(e) {
1060
- return Pe(e) ? !0 : e.entityName || e.qualifiedEntityName ? !1 : !e.source || Nt(e);
1061
- }
1062
- function P(e, t) {
1063
- const n = Dt(t);
1064
- e.found.has(n) || e.found.set(n, t);
1065
- }
1066
- function E(e, t) {
1067
- var u, d, f;
1068
- if (!e) return;
1069
- const n = Kt(e);
1070
- if (t.visitedFields.has(n)) return;
1071
- t.visitedFields.add(n);
1072
- const r = Ot(e);
1073
- if (!r) {
1074
- const y = !e.entityName && !e.qualifiedEntityName ? De(e.source) : void 0;
1075
- P(
1076
- t,
1077
- y || {
1078
- // May be empty for qualified-only metadata; identity then comes from
1079
- // `qualifiedEntityName` (see `identityFor` and the calculator).
1080
- entityName: e.entityName || "",
1081
- entityId: e.entityId,
1082
- qualifiedEntityName: e.qualifiedEntityName,
1083
- label: e.source && e.source.kind === "semantic" ? e.source.label : void 0
1084
- }
1085
- );
1086
- }
1087
- t.includeMetricFilterDatasets && "parameters" in e && ((u = e.parameters) != null && u.filters) && ee(e.parameters.filters, t);
1088
- const s = (d = e.calculatedFormula) == null ? void 0 : d.inputFields, a = !!(s && s.length > 0);
1089
- a && s.forEach((y) => E(y, t));
1090
- let i = !1, o = !1;
1091
- const c = a || (f = e.derivedField) == null ? void 0 : f.inputs;
1092
- if (c && Object.keys(c).length > 0)
1093
- for (const y of Object.values(c)) {
1094
- const h = y.field.source;
1095
- if (!h) {
1096
- a || (o = !0);
1097
- continue;
1098
- }
1099
- if (h.kind === "sql") {
1100
- o = !0;
1101
- continue;
1102
- }
1103
- if (h.kind === "semantic")
1104
- P(t, {
1105
- entityName: h.datasetName,
1106
- entityId: h.datasetId,
1107
- label: h.label
1108
- });
1109
- else {
1110
- const p = [h.databaseName, h.schemaName, h.tableName].filter((I) => !!(I && I.trim())).join(".");
1111
- P(t, {
1112
- entityName: h.tableName,
1113
- qualifiedEntityName: p.includes(".") ? p : void 0,
1114
- label: h.label
1115
- });
1116
- }
1117
- i = !0;
1118
- }
1119
- o && (t.complete = !1), r && !a && !i && (t.complete = !1);
1120
- }
1121
- function ee(e, t) {
1122
- if (e && !t.visitedGroups.has(e.id)) {
1123
- t.visitedGroups.add(e.id);
1124
- for (const n of e.conditions || [])
1125
- E(n.field, t);
1126
- for (const n of e.groups || [])
1127
- ee(n, t);
1128
- }
1129
- }
1130
- function F(e, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set()) {
1131
- return {
1132
- found: /* @__PURE__ */ new Map(),
1133
- complete: !0,
1134
- visitedFields: t,
1135
- visitedGroups: n,
1136
- includeMetricFilterDatasets: e
1137
- };
1138
- }
1139
- function te(e, t) {
1140
- var r;
1141
- const n = (r = e.qualifiedEntityName) != null && r.includes(".") ? e.qualifiedEntityName : void 0;
1142
- return t === "qualifiedOnly" ? n : t === "preferQualified" ? n || e.entityName || void 0 : e.entityName || void 0;
1143
- }
1144
- function Un(e) {
1145
- const t = F(!1);
1146
- return E(e, t), { datasets: Array.from(t.found.values()), complete: t.complete };
1147
- }
1148
- function Ne(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = R) {
1149
- const a = { ...R, ...s }, i = F(a.includeMetricFilterDatasets, n, r);
1150
- E(e, i), i.found.forEach((o) => {
1151
- const c = te(o, a.preferQualifiedIdentity ? "preferQualified" : "name");
1152
- c && t.add(c);
1153
- });
1154
- }
1155
- function zn(e, t) {
1156
- Ne(e, t, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), {
1157
- preferQualifiedIdentity: !0
1158
- });
1159
- }
1160
- function Wn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
1161
- const s = F(!0, n, r);
1162
- E(e, s), s.found.forEach((a) => {
1163
- const i = te(a, "qualifiedOnly");
1164
- i && t.add(i);
1165
- });
1166
- }
1167
- function Qn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
1168
- Ne(e, t, n, r, {
1169
- includeMetricFilterDatasets: !1
1170
- });
1171
- }
1172
- function Gn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = R) {
1173
- const a = { ...R, ...s }, i = F(a.includeMetricFilterDatasets, n, r);
1174
- ee(e, i), i.found.forEach((o) => {
1175
- const c = te(o, a.preferQualifiedIdentity ? "preferQualified" : "name");
1176
- c && t.add(c);
1177
- });
1178
- }
1179
- function Yn(e, t) {
1180
- return t != null && t[e] ? t[e] : (e.includes(".") ? e.slice(e.lastIndexOf(".") + 1) : e).replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/\b\w/g, (r) => r.toUpperCase());
1181
- }
1182
- const Jn = {
1183
- database: null,
1184
- schema: null,
1185
- table: null
1186
- }, Hn = "__card_default__", Q = {
1187
- bookmarksPerViewerPerDashboard: 20,
1188
- bookmarkNameMaxChars: 100,
1189
- columnLabelMaxChars: 120,
1190
- columnWidthMaxPx: 4e3,
1191
- tableSettingsMaxBytes: 65536,
1192
- rememberedTableSettingsMaxBytes: 262144,
1193
- bookmarkStateMaxBytes: 65536
1194
- }, Oe = 1;
1195
- function Xn(e) {
1196
- return new TextEncoder().encode(JSON.stringify(e ?? null)).length;
1197
- }
1198
- function xt(e) {
1199
- const t = encodeURIComponent;
1200
- switch (e.kind) {
1201
- case "dimension":
1202
- return `dim:${e.role}:${t(e.fieldId)}`;
1203
- case "metric":
1204
- return `metric:${t(e.metricId)}:${t(
1205
- e.metricAlias
1206
- )}`;
1207
- case "result":
1208
- return `result:${t(e.key)}`;
1209
- }
1210
- }
1211
- function D(e) {
1212
- if (e)
1213
- try {
1214
- return decodeURIComponent(e);
1215
- } catch {
1216
- return;
1217
- }
1218
- }
1219
- function Mt(e) {
1220
- if (typeof e != "string") return;
1221
- const t = e.split(":");
1222
- let n;
1223
- if (t[0] === "dim" && t.length === 3) {
1224
- const r = t[1], s = D(t[2]);
1225
- (r === "detail" || r === "groupby") && s && (n = { kind: "dimension", role: r, fieldId: s });
1226
- } else if (t[0] === "metric" && t.length === 3) {
1227
- const r = D(t[1]), s = D(t[2]);
1228
- r && s && (n = { kind: "metric", metricId: r, metricAlias: s });
1229
- } else if (t[0] === "result" && t.length === 2) {
1230
- const r = D(t[1]);
1231
- r && (n = { kind: "result", key: r });
1232
- }
1233
- return n && xt(n) === e ? n : void 0;
1234
- }
1235
- function O(e) {
1236
- return typeof e == "string" && Mt(e) !== void 0;
1237
- }
1238
- const he = l.array(l.string()).max(2e3), Rt = l.object({
1239
- order: he.optional(),
1240
- hidden: he.optional(),
1241
- labels: l.record(l.string(), l.string().max(Q.columnLabelMaxChars)).optional(),
1242
- sort: l.array(
1243
- l.object({
1244
- columnId: l.string(),
1245
- direction: l.enum(["asc", "desc"])
1246
- }).strict()
1247
- ).max(2e3).optional(),
1248
- widths: l.record(
1249
- l.string(),
1250
- l.number().int().min(1).max(Q.columnWidthMaxPx)
1251
- ).optional()
1252
- }).strict();
1253
- function G(e) {
1254
- const t = /* @__PURE__ */ new Set(), n = [];
1255
- for (const r of e)
1256
- !O(r) || t.has(r) || (t.add(r), n.push(r));
1257
- return n;
1258
- }
1259
- function Zn(e) {
1260
- if (!Array.isArray(e)) return;
1261
- const t = G(
1262
- e.filter((n) => typeof n == "string")
1263
- );
1264
- return t.length ? t : void 0;
1265
- }
1266
- function xe(e) {
1267
- if (!e) return;
1268
- const t = e.order ? G(e.order) : void 0, n = e.hidden ? G(e.hidden) : void 0, r = Object.entries(e.labels ?? {}).flatMap(
1269
- ([c, u]) => {
1270
- const d = typeof u == "string" ? u.trim() : "";
1271
- return O(c) && d ? [
1272
- [
1273
- c,
1274
- d.slice(0, Q.columnLabelMaxChars)
1275
- ]
1276
- ] : [];
1277
- }
1278
- ), s = /* @__PURE__ */ new Set(), a = e.sort ? e.sort.filter((c) => !O(c.columnId) || s.has(c.columnId) ? !1 : (s.add(c.columnId), !0)) : void 0, i = Object.entries(e.widths ?? {}).filter(
1279
- ([c]) => O(c)
1280
- ), o = {};
1281
- return t != null && t.length && (o.order = t), n != null && n.length && (o.hidden = n), r.length && (o.labels = Object.fromEntries(r)), a && (o.sort = a.map(({ columnId: c, direction: u }) => ({
1282
- columnId: c,
1283
- direction: u
1284
- }))), i.length && (o.widths = Object.fromEntries(i)), Object.keys(o).length ? o : void 0;
1285
- }
1286
- function er(e) {
1287
- var t, n;
1288
- return !!((t = e == null ? void 0 : e.order) != null && t.length) || !!((n = e == null ? void 0 : e.hidden) != null && n.length) || Object.keys((e == null ? void 0 : e.labels) ?? {}).length > 0 || Object.keys((e == null ? void 0 : e.widths) ?? {}).length > 0;
1289
- }
1290
- function Me(e) {
1291
- return xe(e) === void 0;
1292
- }
1293
- function Re(e, t) {
1294
- if (t !== Oe)
1295
- return {
1296
- ok: !1,
1297
- error: `Unsupported table settings version ${t}.`
1298
- };
1299
- const n = Rt.safeParse(e);
1300
- return n.success ? {
1301
- ok: !0,
1302
- value: xe(n.data) ?? {}
1303
- } : { ok: !1, error: "Table settings are invalid." };
1304
- }
1305
- function tr(e, t, n) {
1306
- if (!e || typeof e != "object" || Array.isArray(e)) return {};
1307
- const r = {};
1308
- for (const [s, a] of Object.entries(
1309
- e
1310
- )) {
1311
- if (!n.has(s)) continue;
1312
- const i = Re(a, t);
1313
- i.ok && !Me(i.value) && (r[s] = i.value);
1314
- }
1315
- return r;
1316
- }
1317
- const _t = /* @__PURE__ */ new Set([
1318
- "table",
1319
- "detailTable"
1320
- ]);
1321
- function _e(e) {
1322
- return _t.has(e.type);
1323
- }
1324
- function Ft(e) {
1325
- var t, n;
1326
- return _e(e) && ((n = (t = e.preferences) == null ? void 0 : t.tablePrefs) == null ? void 0 : n.allowViewerColumnCustomization) !== !1;
1327
- }
1328
- function nr(e) {
1329
- return new Set(
1330
- T(e).filter(({ card: t }) => _e(t)).map(({ card: t }) => t.id)
1331
- );
1332
- }
1333
- function rr(e) {
1334
- return new Set(
1335
- T(e).filter(({ card: t }) => Ft(t)).map(({ card: t }) => t.id)
1336
- );
1337
- }
1338
- const Vt = {
1339
- date: /* @__PURE__ */ new Set([
1340
- "between",
1341
- "not between",
1342
- "=",
1343
- "!=",
1344
- ">",
1345
- ">=",
1346
- "<",
1347
- "<=",
1348
- "is null",
1349
- "is not null"
1350
- ]),
1351
- number: /* @__PURE__ */ new Set([
1352
- "between",
1353
- "not between",
1354
- "=",
1355
- "!=",
1356
- ">",
1357
- ">=",
1358
- "<",
1359
- "<=",
1360
- "in",
1361
- "not in",
1362
- "is null",
1363
- "is not null"
1364
- ]),
1365
- string: /* @__PURE__ */ new Set([
1366
- "=",
1367
- "!=",
1368
- "in",
1369
- "not in",
1370
- "like",
1371
- "not like",
1372
- "is null",
1373
- "is not null"
1374
- ]),
1375
- boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
1376
- };
1377
- function $t(e) {
1378
- const t = Y(e);
1379
- return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
1380
- }
1381
- function sr(e, t) {
1382
- return typeof t != "string" ? !1 : Vt[$t(e)].has(t);
1383
- }
1384
- const Pt = /* @__PURE__ */ new Set([
1385
- "=",
1386
- ">",
1387
- "<",
1388
- ">=",
1389
- "<=",
1390
- "!=",
1391
- "in",
1392
- "not in",
1393
- "like",
1394
- "not like",
1395
- "between",
1396
- "not between",
1397
- "is null",
1398
- "is not null"
1399
- ]);
1400
- function Lt(e, t) {
1401
- return t === "number" ? typeof e == "number" && Number.isFinite(e) : t === "boolean" ? typeof e == "boolean" : t === "date" ? e instanceof Date || typeof e == "string" && e.trim().length > 0 : typeof e == "string" || typeof e == "number" || typeof e == "boolean";
1402
- }
1403
- function qt(e, t, n, r) {
1404
- const s = Le(e.relativeMeta);
1405
- if (s && We(s).dataAnchored) {
1406
- r.push(
1407
- `${n}.relativeMeta counts back from the latest data; a dashboard filter's dates run to now. Use a period counted back from today.`
1408
- );
1409
- return;
1410
- }
1411
- if (s && !qe(String(e.operation), s)) {
1412
- r.push(
1413
- `${n}.relativeMeta runs only under between, not between, before, after, on or before, or on or after.`
1414
- );
1415
- return;
1416
- }
1417
- Bt(e.operation, e.values, t, `${n}.values`, r);
1418
- }
1419
- function Bt(e, t, n, r, s) {
1420
- if (e === "is null" || e === "is not null") {
1421
- t.length !== 0 && s.push(`${r} must be empty for null filter operations.`);
1422
- return;
1423
- }
1424
- if (e === "between" || e === "not between") {
1425
- if (t.length !== 2) {
1426
- s.push(
1427
- `${r} must contain exactly two values for between operations.`
1428
- );
1429
- return;
1430
- }
1431
- } else if (e === "in" || e === "not in") {
1432
- if (t.length === 0) {
1433
- s.push(
1434
- `${r} must contain at least one value for set operations.`
1435
- );
1436
- return;
1437
- }
1438
- } else if (t.length !== 1) {
1439
- s.push(
1440
- `${r} must contain exactly one value for '${String(e)}' operations.`
1441
- );
1442
- return;
1443
- }
1444
- for (const a of t)
1445
- if (!Lt(a, n)) {
1446
- s.push(
1447
- `${r} contains a value that is incompatible with valueType '${n}'.`
1448
- );
1449
- return;
1450
- }
1451
- }
1452
- const L = 1, ar = ["PRIVATE", "TEAM", "DASHBOARD"], jt = l.object({
1453
- filterId: l.string().min(1),
1454
- name: l.string(),
1455
- operation: l.string(),
1456
- valueType: l.enum(["string", "number", "date", "boolean"]),
1457
- values: l.array(l.unknown())
1458
- }).passthrough().superRefine((e, t) => {
1459
- const n = [];
1460
- Pt.has(e.operation) ? qt(e, e.valueType, "filterValue", n) : n.push("filterValue.operation must be a valid filter operation.");
1461
- for (const r of n) t.addIssue({ code: "custom", message: r });
1462
- }), q = l.unknown().superRefine((e, t) => {
1463
- for (const n of Qe(e).errors)
1464
- t.addIssue({ code: "custom", message: n.message });
1465
- }), Ut = l.discriminatedUnion("kind", [
1466
- l.object({ kind: l.literal("filter"), filterValue: jt }).strict(),
1467
- l.object({ kind: l.literal("control"), value: l.unknown() }).strict(),
1468
- l.object({
1469
- kind: l.literal("selection"),
1470
- selection: Be
1471
- }).strict()
1472
- ]), zt = l.union([
1473
- l.object({
1474
- status: l.literal("set"),
1475
- value: Ut,
1476
- comparisonSelection: q.optional()
1477
- }).strict(),
1478
- l.object({
1479
- status: l.literal("cleared"),
1480
- comparisonSelection: q.optional()
1481
- }).strict(),
1482
- l.object({ comparisonSelection: q }).strict()
1483
- ]), Fe = ["bySheetId", "byCardId", "byDocumentSectionId"], Wt = /* @__PURE__ */ new Set(["version", "selectedSheetId", "inputs", "tableSettings"]), Qt = /* @__PURE__ */ new Set(["shared", ...Fe]), A = (e) => !!e && typeof e == "object" && !Array.isArray(e);
1484
- function ye(e, t, n) {
1485
- if (e === void 0) return;
1486
- if (!A(e)) {
1487
- t.push({ target: "input", id: n });
1488
- return;
1489
- }
1490
- const r = {};
1491
- for (const [s, a] of Object.entries(e)) {
1492
- const i = s ? zt.safeParse(a) : void 0;
1493
- i != null && i.success ? r[s] = i.data : t.push({
1494
- target: je(s) ? "selection" : "input",
1495
- id: s
1496
- });
1497
- }
1498
- return Object.keys(r).length ? r : void 0;
1499
- }
1500
- function Gt(e, t) {
1501
- if (t !== L)
1502
- return { ok: !1, error: `Unsupported bookmark version ${t}.` };
1503
- if (!A(e) || e.version !== L)
1504
- return { ok: !1, error: "The bookmark state is invalid." };
1505
- const n = [], r = Object.keys(e).filter((o) => !Wt.has(o));
1506
- let s;
1507
- typeof e.selectedSheetId == "string" && e.selectedSheetId ? s = e.selectedSheetId : e.selectedSheetId !== void 0 && n.push({ target: "sheet", id: String(e.selectedSheetId) });
1508
- const a = {};
1509
- if (A(e.inputs)) {
1510
- r.push(
1511
- ...Object.keys(e.inputs).filter((c) => !Qt.has(c)).map((c) => `inputs.${c}`)
1512
- );
1513
- const o = ye(e.inputs.shared, n, "shared");
1514
- o && (a.shared = o);
1515
- for (const c of Fe) {
1516
- const u = e.inputs[c];
1517
- if (u === void 0) continue;
1518
- if (!A(u)) {
1519
- n.push({ target: "input", id: c });
1520
- continue;
1521
- }
1522
- const d = {};
1523
- for (const [f, y] of Object.entries(u)) {
1524
- const h = ye(y, n, `${c}.${f}`);
1525
- h && (d[f] = h);
1526
- }
1527
- Object.keys(d).length && (a[c] = d);
1528
- }
1529
- } else e.inputs !== void 0 && r.push("inputs");
1530
- const i = {};
1531
- if (A(e.tableSettings))
1532
- for (const [o, c] of Object.entries(e.tableSettings)) {
1533
- const u = o ? Re(c, Oe) : void 0;
1534
- u != null && u.ok ? Me(u.value) || (i[o] = u.value) : n.push({ target: "card", id: o });
1535
- }
1536
- else e.tableSettings !== void 0 && r.push("tableSettings");
1537
- return {
1538
- ok: !0,
1539
- value: {
1540
- version: L,
1541
- ...s ? { selectedSheetId: s } : {},
1542
- ...Object.keys(a).length ? { inputs: a } : {},
1543
- ...Object.keys(i).length ? { tableSettings: i } : {}
1544
- },
1545
- issues: n,
1546
- unknownKeys: r
1547
- };
1548
- }
1549
- function ir(e, t) {
1550
- const n = Gt(e, t);
1551
- return n.ok ? n.issues.some((r) => r.target === "card") ? { ok: !1, error: "The bookmark table settings are invalid." } : n.issues.length || n.unknownKeys.length ? { ok: !1, error: "The bookmark state is invalid." } : { ok: !0, value: n.value } : n;
1552
- }
1553
- export {
1554
- re as $,
1555
- qn as A,
1556
- L as B,
1557
- Hn as C,
1558
- _ as D,
1559
- Jn as E,
1560
- C as F,
1561
- fn as G,
1562
- _n as H,
1563
- Tn as I,
1564
- Ye as J,
1565
- Tt as K,
1566
- ot as L,
1567
- gt as M,
1568
- yn as N,
1569
- le as O,
1570
- rt as P,
1571
- dn as Q,
1572
- ge as R,
1573
- bn as S,
1574
- On as T,
1575
- Cn as U,
1576
- Q as V,
1577
- H as W,
1578
- Ae as X,
1579
- lt as Y,
1580
- ve as Z,
1581
- En as _,
1582
- jn as a,
1583
- se as a0,
1584
- Je as a1,
1585
- nn as a2,
1586
- He as a3,
1587
- rn as a4,
1588
- ln as a5,
1589
- mn as a6,
1590
- pn as a7,
1591
- hn as a8,
1592
- In as a9,
1593
- sr as aA,
1594
- Pt as aB,
1595
- qt as aC,
1596
- $n as aD,
1597
- an as aE,
1598
- et as aF,
1599
- v as aG,
1600
- T as aH,
1601
- ut as aI,
1602
- kn as aJ,
1603
- J as aK,
1604
- ae as aL,
1605
- wn as aM,
1606
- gn as aN,
1607
- vn as aO,
1608
- An as aP,
1609
- Vn as aQ,
1610
- Xe as aR,
1611
- Pn as aS,
1612
- Ln as aT,
1613
- Bn as aU,
1614
- sn as aV,
1615
- Sn as aa,
1616
- Te as ab,
1617
- M as ac,
1618
- ft as ad,
1619
- S as ae,
1620
- Ee as af,
1621
- mt as ag,
1622
- pt as ah,
1623
- Kn as ai,
1624
- X as aj,
1625
- ht as ak,
1626
- Dn as al,
1627
- Nn as am,
1628
- xn as an,
1629
- Mn as ao,
1630
- Rn as ap,
1631
- on as aq,
1632
- nt as ar,
1633
- cn as as,
1634
- un as at,
1635
- ke as au,
1636
- kt as av,
1637
- wt as aw,
1638
- At as ax,
1639
- Fn as ay,
1640
- $t as az,
1641
- zn as b,
1642
- Ne as c,
1643
- De as d,
1644
- Wn as e,
1645
- Qn as f,
1646
- Gn as g,
1647
- Yn as h,
1648
- Gt as i,
1649
- Oe as j,
1650
- Mt as k,
1651
- xe as l,
1652
- Xn as m,
1653
- Zn as n,
1654
- er as o,
1655
- ir as p,
1656
- Me as q,
1657
- Un as r,
1658
- Re as s,
1659
- xt as t,
1660
- tr as u,
1661
- _e as v,
1662
- Ft as w,
1663
- nr as x,
1664
- rr as y,
1665
- ar as z
1666
- };