react-semaphor 0.1.555 → 0.1.556

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 (97) hide show
  1. package/dist/analytics-protocol/index.js +10 -10
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +5 -5
  4. package/dist/brand-studio/index.js +438 -455
  5. package/dist/briefings/index.js +6 -6
  6. package/dist/chunks/{analytics-base-schemas-BKs3flFS.js → analytics-base-schemas-BUFUoO6G.js} +2 -2
  7. package/dist/chunks/{assistant-chat-8NZP6m-u.js → assistant-chat-C7Acww1T.js} +15 -15
  8. package/dist/chunks/{bookmark-state-BAeGKd3s.js → bookmark-state-7iZErWnR.js} +3 -3
  9. package/dist/chunks/comparison-window-caption-BseG5aOZ.js +1221 -0
  10. package/dist/chunks/{context-BerEBuFR.js → context-DVy4HOU0.js} +1 -1
  11. package/dist/chunks/{custom-visual-inputs-Gw-Ggg3O.js → custom-visual-inputs-ChuKjx27.js} +31 -33
  12. package/dist/chunks/{dashboard-Ds68ckO3.js → dashboard-BU6rE5kV.js} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-DlTr-VGc.js → dashboard-briefing-launcher-qrYd2zkN.js} +15 -15
  14. package/dist/chunks/{dashboard-controls-oNXJZN6x.js → dashboard-controls-BsapXI2H.js} +14 -14
  15. package/dist/chunks/{dashboard-json-CW7Q_efH.js → dashboard-json-CJqPqYnI.js} +5 -5
  16. package/dist/chunks/{document-dashboard-inputs-C21mL3ib.js → document-dashboard-inputs-BNSprf5_.js} +12 -12
  17. package/dist/chunks/{edit-dashboard-visual-BnnT_oKR.js → edit-dashboard-visual-CjAdV-WG.js} +4603 -4687
  18. package/dist/chunks/{filter-reach-copy-DlNPHbE-.js → filter-reach-copy-BTrqtFkh.js} +917 -987
  19. package/dist/chunks/{filter-value-text-DMrpj4h9.js → filter-value-text-CJTJDCym.js} +4 -4
  20. package/dist/chunks/{global-date-filter-utils-7OboTgrM.js → global-date-filter-utils-CTVf3dG3.js} +2904 -3102
  21. package/dist/chunks/{index-B2k6KtUN.js → index-B_vIRa-q.js} +12 -19
  22. package/dist/chunks/{index-CtoK1Lgu.js → index-dIV-Gdsb.js} +159 -161
  23. package/dist/chunks/{matrix-analytical-definition-DPVGg1mU.js → matrix-analytical-definition-Cg0ioFGQ.js} +21 -21
  24. package/dist/chunks/{matrix-card-D9bsdAye.js → matrix-card-yYibXSw1.js} +3 -3
  25. package/dist/chunks/{matrix-formatter-K2OVPJQI.js → matrix-formatter-C2kjsCDf.js} +44 -44
  26. package/dist/chunks/{matrix-member-presentation-DRWcJ8Mi.js → matrix-member-presentation-DEEauKXC.js} +1 -1
  27. package/dist/chunks/{matrix-operation-contract--lMaLlpV.js → matrix-operation-contract-C1G6AJNh.js} +33 -33
  28. package/dist/chunks/{metric-comparison-CYIt2F5X.js → metric-comparison-BfcmwxM1.js} +4 -4
  29. package/dist/chunks/{model-change-B0rAK-5w.js → model-change-CJEj3ZD6.js} +1 -1
  30. package/dist/chunks/pivot-result-contract-expectations-fKBHFPfz.js +56 -0
  31. package/dist/chunks/pivot-result-identity-CWi5WrrY.js +77 -0
  32. package/dist/chunks/{raw-temporal-contract-WuXA8jBP.js → raw-temporal-contract-CjHaUIsE.js} +1 -1
  33. package/dist/chunks/{raw-temporal-presentation-CivONfcO.js → raw-temporal-presentation-DWzLIHc3.js} +8 -8
  34. package/dist/chunks/{report-preferences-dialog-D_KyuEFx.js → report-preferences-dialog-D_wrbIQt.js} +17 -17
  35. package/dist/chunks/{report-runtime-context-BaIKSaja.js → report-runtime-context-BgM-iNWB.js} +2 -2
  36. package/dist/chunks/{resolve-dashboard-input-context-CIm9A8_j.js → resolve-dashboard-input-context-Df8V5QHW.js} +1415 -1567
  37. package/dist/chunks/{saved-dashboard-context-akb9JfOL.js → saved-dashboard-context-VvXI6r03.js} +9 -9
  38. package/dist/chunks/{selection-reducer-yw_JgICP.js → selection-reducer-By4CSmEF.js} +1 -1
  39. package/dist/chunks/{semaphor-ready-indicator-Ba7dwP5_.js → semaphor-ready-indicator-fejZmdq9.js} +49593 -56071
  40. package/dist/chunks/{shelf-drop-preview-context-5rg3pJHW.js → shelf-drop-preview-context-BuTCXe-S.js} +7 -7
  41. package/dist/chunks/{source-entity-resolution-CGymm5td.js → source-entity-resolution-B46EZIzX.js} +1 -1
  42. package/dist/chunks/{switch-B-UTI6v-.js → switch-Bq92UGId.js} +3 -3
  43. package/dist/chunks/{table-export-sheet-CgO6gaSM.js → table-export-sheet-noKl8-en.js} +1 -1
  44. package/dist/chunks/{table-settings-DOT_Bv1m.js → table-settings-PpINOzw8.js} +3 -3
  45. package/dist/chunks/{temporal-bucket-C4rqmwaQ.js → temporal-bucket-DzyadxVY.js} +53 -53
  46. package/dist/chunks/temporal-input-presentation-CJWS4d0L.js +879 -0
  47. package/dist/chunks/{token-types-DYECHYGH.js → token-types--0bgRCaO.js} +1 -1
  48. package/dist/chunks/{use-create-flow-overlay-state-BHNs0wl7.js → use-create-flow-overlay-state-Cz-ve64t.js} +7 -7
  49. package/dist/chunks/{validators-ClKLGDGZ.js → validators-CZo_H4E6.js} +305 -307
  50. package/dist/dashboard/index.js +2 -2
  51. package/dist/dashboard-authoring/index.js +60 -60
  52. package/dist/data-app-sdk/index.js +6 -6
  53. package/dist/data-app-sdk-adapters/index.js +3 -3
  54. package/dist/data-app-sdk-validation/index.js +6 -6
  55. package/dist/format-utils/index.js +207 -223
  56. package/dist/index.js +96 -97
  57. package/dist/layouts/index.js +1 -1
  58. package/dist/pdf-export-policy/index.js +9 -11
  59. package/dist/report-runtime-context/index.js +2 -2
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +2 -2
  62. package/dist/types/brand-studio/brand-studio-draft.d.ts +0 -3
  63. package/dist/types/brand-studio/index.d.ts +1 -1
  64. package/dist/types/components/visual/data-table/types/data-table.d.ts +0 -1
  65. package/dist/types/components/visual/shared/utils/table-column-order.d.ts +0 -6
  66. package/dist/types/index.js +27 -28
  67. package/dist/types/lib/api/exports-api.d.ts +1 -1
  68. package/dist/types/lib/charts/table-chart-types.d.ts +1 -1
  69. package/dist/types/lib/charts/types.d.ts +2 -2
  70. package/dist/types/lib/dashboard-viewer/export-table-view.d.ts +0 -3
  71. package/dist/types/lib/document/document-edits.d.ts +1 -1
  72. package/dist/types/lib/document/document-section-kinds.d.ts +2 -4
  73. package/dist/types/lib/document/document-table-data-policy.d.ts +1 -2
  74. package/dist/types/lib/formatters/grouped-temporal-activation.d.ts +3 -3
  75. package/dist/types/lib/formatters/grouped-temporal-presentation.d.ts +0 -6
  76. package/dist/types/lib/query-context/card-server-request.d.ts +0 -1
  77. package/dist/types/lib/table-formatting/table-formatting-types.d.ts +1 -1
  78. package/dist/types/lib/types/common-types.d.ts +0 -7
  79. package/dist/types/lib/types/explorer-types.d.ts +1 -14
  80. package/dist/types/lib/utils/card-config-utils.d.ts +11 -1
  81. package/dist/types/shared/dashboard-authoring/card-export-request.d.ts +1 -2
  82. package/dist/types/shared/dashboard-authoring/legacy-table-routing.d.ts +9 -4
  83. package/dist/types/shared/format-utils/grouped-table-presentation.d.ts +0 -14
  84. package/dist/types/shared/format-utils/index.d.ts +0 -2
  85. package/dist/types/shared/format-utils/pdf-export-policy.d.ts +1 -1
  86. package/dist/types/shared/format-utils/pivot-result-contract-expectations.d.ts +2 -20
  87. package/dist/types/shared/format-utils/pivot-result-identity.d.ts +0 -20
  88. package/dist/types/shared/format-utils/table-export/prepare-table-export.d.ts +0 -1
  89. package/dist/types/shared/format-utils/table-export/table-export-result.d.ts +0 -4
  90. package/package.json +2 -2
  91. package/dist/chunks/comparison-window-caption-C2WNTlxK.js +0 -1433
  92. package/dist/chunks/pivot-header-presentation-CX4fkRuG.js +0 -42
  93. package/dist/chunks/pivot-result-identity-BHJGZwIc.js +0 -94
  94. package/dist/chunks/pivot-result-lifecycle-BygCpOhk.js +0 -1238
  95. package/dist/types/components/visual/pivot-table/types.d.ts +0 -80
  96. package/dist/types/shared/format-utils/aggregate-table-row-presentation.d.ts +0 -85
  97. package/dist/types/shared/format-utils/pivot-result-lifecycle.d.ts +0 -55
@@ -0,0 +1,1221 @@
1
+ var Ke = Object.defineProperty;
2
+ var Ve = (e, t, r) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var ae = (e, t, r) => Ve(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { i as Ue, h as N, l as je, c as Be, p as ze, J as He, f as V, E as Xe, F as Ge, G as qe, I as We } from "./temporal-bucket-DzyadxVY.js";
5
+ import { i as Ee, m as J, j as Fe, k as Ye, l as Se, a as se, d as Ze, n as L } from "./matrix-formatter-C2kjsCDf.js";
6
+ import { h as H, e as Je, p as Qe, k as et } from "./export-file-format-C-tJsxsf.js";
7
+ import { aI as O, ab as tt, t as B, aH as rt, v as Q, u as nt } from "./validators-CZo_H4E6.js";
8
+ import "./matrix-operation-contract-C1G6AJNh.js";
9
+ import "./analytics-base-schemas-BUFUoO6G.js";
10
+ import "zod";
11
+ import { y as ke, a as ot, t as ie, s as at, P as le, l as st, o as it, v as lt, E as R } from "./temporal-input-presentation-CJWS4d0L.js";
12
+ import { PDF_SAFETY_LIMIT_EXCEEDED as Me, getUtf8ByteLength as ct, FAST_PDF_POLICY as mt } from "../pdf-export-policy/index.js";
13
+ import { p as ut } from "./pivot-result-contract-expectations-fKBHFPfz.js";
14
+ import { c as dt, b as ce } from "./pivot-result-identity-CWi5WrrY.js";
15
+ import { v as ft } from "./raw-temporal-contract-CjHaUIsE.js";
16
+ import { g as pt } from "./zoned-wall-clock-MulfA26h.js";
17
+ function yt(e, t, r) {
18
+ const n = {
19
+ ...t,
20
+ locale: t.locale ?? r
21
+ };
22
+ if (n.type === "number")
23
+ return N(e, n);
24
+ const { prefix: o, suffix: l, ...s } = n;
25
+ return `${o ?? ""}${N(e, {
26
+ ...s,
27
+ negativeStyle: n.type === "currency" ? n.negativeStyle : "minus"
28
+ })}${l ?? ""}`;
29
+ }
30
+ function W(e, t, r) {
31
+ return e === null ? { value: e, text: null } : !t || !Ue(t) && t.type !== "duration" ? {
32
+ value: e,
33
+ text: N(e, { type: "number", locale: r })
34
+ } : t.type === "duration" ? {
35
+ value: e,
36
+ text: je(e, {
37
+ inputUnit: t.inputUnit,
38
+ outputStyle: t.outputStyle,
39
+ largestUnit: t.largestUnit,
40
+ smallestUnit: t.smallestUnit,
41
+ maxUnits: t.maxUnits,
42
+ prefix: t.prefix,
43
+ suffix: t.suffix,
44
+ negativeInParentheses: t.negativeStyle === "parentheses"
45
+ })
46
+ } : { value: e, text: yt(e, t, r) };
47
+ }
48
+ function me(e, t, r, n) {
49
+ return e === null ? { value: e, text: null } : n === "percent" ? {
50
+ value: e,
51
+ text: N(e, {
52
+ type: "percent",
53
+ locale: r,
54
+ minimumFractionDigits: t,
55
+ maximumFractionDigits: t,
56
+ percentValueMode: "fraction"
57
+ })
58
+ } : {
59
+ value: e,
60
+ text: N(e, {
61
+ type: "number",
62
+ locale: r,
63
+ minimumFractionDigits: t,
64
+ maximumFractionDigits: t,
65
+ suffix: "×"
66
+ })
67
+ };
68
+ }
69
+ function ue(e, t) {
70
+ if (e === void 0) return t;
71
+ if (!Number.isInteger(e) || e < 0 || e > 6)
72
+ throw new RangeError("Comparison precision must be an integer from 0 to 6.");
73
+ return e;
74
+ }
75
+ function xr(e, t) {
76
+ const r = {
77
+ mode: t.displayMode,
78
+ current: W(
79
+ e.currentValue,
80
+ t.metricFormat,
81
+ t.locale
82
+ ),
83
+ comparison: W(
84
+ e.comparisonValue,
85
+ t.metricFormat,
86
+ t.locale
87
+ )
88
+ };
89
+ return (t.displayMode === "difference" || t.displayMode === "both") && (r.difference = W(
90
+ e.delta,
91
+ t.metricFormat,
92
+ t.locale
93
+ )), (t.displayMode === "percent_change" || t.displayMode === "both") && (r.percentChange = me(
94
+ e.percentChange,
95
+ ue(t.precision, 1),
96
+ t.locale,
97
+ "percent"
98
+ )), t.displayMode === "ratio" && (r.ratio = me(
99
+ e.ratio,
100
+ ue(t.precision, 2),
101
+ t.locale,
102
+ "ratio"
103
+ )), r;
104
+ }
105
+ const ht = /* @__PURE__ */ new Set(["second", "minute", "hour", "day", "month"]);
106
+ function bt(e) {
107
+ const { presentation: t } = e;
108
+ return e.formattedValues ? (t == null ? void 0 : t.kind) === "text" || (t == null ? void 0 : t.kind) === "measure" && t.format.type === "duration" ? "text" : (t == null ? void 0 : t.kind) === "temporal_bucket" ? ht.has(t.grain) ? "date" : "text" : (t == null ? void 0 : t.kind) === "datetime" ? "date" : e.dataType === "number" ? "number" : e.dataType === "boolean" ? "boolean" : e.dataType === "unknown" ? "by_value" : "text" : "by_value";
109
+ }
110
+ function gt(e) {
111
+ const t = (o, l) => Number.isInteger(o) ? Math.min(20, Math.max(0, o)) : l, r = t(e.minimumFractionDigits, 0), n = Math.max(r, t(e.maximumFractionDigits, 2));
112
+ return n === 0 ? "" : `.${"0".repeat(n)}`;
113
+ }
114
+ function Y(e) {
115
+ return `"${e.replace(/"/g, "")}"`;
116
+ }
117
+ function wt(e) {
118
+ let t;
119
+ try {
120
+ t = new Intl.NumberFormat(e.locale ?? "en-US", {
121
+ style: "currency",
122
+ currency: e.currency || "USD"
123
+ }).formatToParts(1);
124
+ } catch {
125
+ return;
126
+ }
127
+ const r = t.findIndex((l) => l.type === "currency"), n = t.findIndex((l) => l.type === "integer");
128
+ if (r < 0 || n < 0) return;
129
+ const o = (l, s) => t.slice(l, s).filter((c) => c.type === "literal").map((c) => c.value.replace(/\s/g, " ")).join("");
130
+ return r < n ? { side: "before", text: t[r].value + o(r + 1, n) } : {
131
+ side: "after",
132
+ text: o(n + 1, r) + t[r].value
133
+ };
134
+ }
135
+ function vt(e) {
136
+ const t = gt(e);
137
+ let r;
138
+ if (e.type === "scientific")
139
+ r = `0${t}E+00`;
140
+ else {
141
+ const n = `${e.useGrouping === !1 ? "0" : "#,##0"}${t}`;
142
+ if (e.type === "currency") {
143
+ const o = wt(e);
144
+ r = o ? o.side === "before" ? `${Y(o.text)}${n}` : `${n}${Y(o.text)}` : n;
145
+ } else e.type === "percent" ? r = e.percentValueMode === "whole" ? `${n}${Y("%")}` : `${n}%` : r = n;
146
+ }
147
+ return e.negativeStyle === "parentheses" ? `${r};(${r})` : r;
148
+ }
149
+ function Ct(e, t) {
150
+ if (!e.formattedValues) return;
151
+ const { presentation: r } = e;
152
+ if (t === "number" || t === "by_value")
153
+ return (r == null ? void 0 : r.kind) !== "measure" || r.format.type === "duration" ? void 0 : vt(r.format);
154
+ if (t === "date") {
155
+ if ((r == null ? void 0 : r.kind) === "temporal_bucket")
156
+ return r.grain === "day" ? "yyyy-mm-dd" : r.grain === "month" ? "mmm yyyy" : "yyyy-mm-dd hh:mm";
157
+ if ((r == null ? void 0 : r.kind) === "datetime")
158
+ return r.dateOnly ? "yyyy-mm-dd" : "yyyy-mm-dd hh:mm:ss";
159
+ }
160
+ }
161
+ function de(e) {
162
+ const t = bt(e), r = Ct(e, t);
163
+ return Object.freeze({
164
+ key: e.key,
165
+ label: e.label,
166
+ cellType: t,
167
+ ...r === void 0 ? {} : { numberFormat: r }
168
+ });
169
+ }
170
+ const xt = 15, Tt = /^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
171
+ function Ie(e) {
172
+ return Tt.test(e) ? e : void 0;
173
+ }
174
+ function fe(e) {
175
+ const r = e.replace(/^-/, "").replace(/[eE].*$/, "").replace(".", "").replace(/^0+/, "").replace(/0+$/, "");
176
+ if (r.length > xt) return !1;
177
+ const n = Number(e);
178
+ return Number.isFinite(n) && (n !== 0 || r.length === 0);
179
+ }
180
+ const Et = Date.UTC(1900, 2, 1), Ft = Date.UTC(1e4, 0, 1), St = Date.UTC(1899, 11, 30), kt = 864e5;
181
+ function Mt(e) {
182
+ const t = Date.UTC(
183
+ e.year,
184
+ e.month - 1,
185
+ e.day,
186
+ e.hour,
187
+ e.minute,
188
+ e.second
189
+ );
190
+ if (!(e.year < 1900 || !Number.isFinite(t)) && !(t < Et || t >= Ft))
191
+ return (t - St) / kt;
192
+ }
193
+ function pe(e, t, r) {
194
+ if (typeof e == "number")
195
+ return Number.isFinite(e) ? { kind: "number", text: t, value: e } : void 0;
196
+ if (O(e))
197
+ return fe(e.value) ? { kind: "number", text: t, value: e } : void 0;
198
+ if (r && typeof e == "string") {
199
+ const n = Ie(e);
200
+ return n !== void 0 && fe(n) ? { kind: "number", text: t, value: n } : void 0;
201
+ }
202
+ }
203
+ function U(e) {
204
+ const { value: t, text: r, column: n } = e;
205
+ if (r === "") return { kind: "empty" };
206
+ const o = { kind: "text", text: r };
207
+ switch (n.cellType) {
208
+ case "text":
209
+ return o;
210
+ case "date": {
211
+ const l = e.wallClock ? Mt(e.wallClock) : void 0;
212
+ return l === void 0 ? o : { kind: "date", text: r, serial: l };
213
+ }
214
+ case "number":
215
+ return pe(t, r, !0) ?? o;
216
+ case "boolean":
217
+ return typeof t == "boolean" ? { kind: "boolean", text: r, value: t } : o;
218
+ case "by_value":
219
+ return typeof t == "boolean" ? { kind: "boolean", text: r, value: t } : pe(t, r, !1) ?? o;
220
+ }
221
+ }
222
+ function Tr(e) {
223
+ return e.kind === "empty" ? "" : e.text;
224
+ }
225
+ const $e = 1e4, It = 1e6, Er = 5e6, Fr = 1024 ** 3, Sr = 1024 ** 3;
226
+ function kr(e) {
227
+ return e > $e;
228
+ }
229
+ function Mr(e) {
230
+ return e.cardType === "matrixTable" ? "try-direct" : e.loadedRowCount === null || e.loadedRowCount <= $e ? "direct" : e.loadedRowCount <= It ? "background" : "blocked";
231
+ }
232
+ const Ir = {
233
+ rowLabels: "tabular",
234
+ subtotals: "after"
235
+ };
236
+ function $r(e, t) {
237
+ const r = t.rowLabels === "outline" ? { kind: "compact" } : e.layout.kind === "tabular" ? e.layout : { kind: "tabular", repeatLabels: !1 }, n = e.totals.rows;
238
+ return {
239
+ ...e,
240
+ layout: r,
241
+ totals: {
242
+ ...e.totals,
243
+ rows: {
244
+ ...n,
245
+ levels: Object.fromEntries(
246
+ Object.entries(n.levels).map(([o, l]) => [
247
+ o,
248
+ { ...l, position: t.subtotals }
249
+ ])
250
+ )
251
+ }
252
+ }
253
+ };
254
+ }
255
+ const $t = 2;
256
+ function Lt(e) {
257
+ return typeof e == "number" ? Number.isInteger(e) : O(e) ? !e.value.includes(".") : !0;
258
+ }
259
+ function Pt(e, t, r) {
260
+ const n = e.descriptors.measures.filter(
261
+ (s) => r.measureFormats[s.id] === void 0 && s.semanticFormat === void 0 && tt(s.column.dataType) === "number"
262
+ );
263
+ if (n.length === 0) return r;
264
+ const o = /* @__PURE__ */ new Set();
265
+ e.columns.forEach((s, c) => {
266
+ if (!(s.kind !== "measure" || o.has(s.measureId)))
267
+ for (const f of t) {
268
+ const d = f.values[c];
269
+ if ((d == null ? void 0 : d.kind) === "value" && !Lt(d.value)) {
270
+ o.add(s.measureId);
271
+ return;
272
+ }
273
+ }
274
+ });
275
+ const l = { ...r.measureFormats };
276
+ for (const { id: s } of n) {
277
+ const c = o.has(s) ? $t : 0;
278
+ l[s] = {
279
+ type: "number",
280
+ minimumFractionDigits: c,
281
+ maximumFractionDigits: c,
282
+ useGrouping: !0
283
+ };
284
+ }
285
+ return { ...r, measureFormats: l };
286
+ }
287
+ function j(e) {
288
+ return B(e.slice(0, -1));
289
+ }
290
+ function Dt(e, t) {
291
+ return t.length > e.length && B(t.slice(0, e.length)) === B(e);
292
+ }
293
+ function _t(e) {
294
+ return e.map((t, r) => {
295
+ if (r === 0 || t.kind !== "layout") return !1;
296
+ const n = e[r - 1];
297
+ if (n.kind !== "layout") return !1;
298
+ if (t.role !== "member" || Dt(n.rowPath, t.rowPath)) return !0;
299
+ const o = e[r - 2];
300
+ return n.role === "member" && (!o || o.kind !== "layout" || o.role !== "member" || j(o.rowPath) !== j(n.rowPath)) && t.rowPath.length === n.rowPath.length && j(t.rowPath) === j(n.rowPath);
301
+ });
302
+ }
303
+ const At = "pdf-group-continuation";
304
+ function Le(e, t, r) {
305
+ return !(r != null && r.hasTextAffixes) && t.kind === "value" && (typeof t.value == "number" || O(t.value)) ? e : H(e);
306
+ }
307
+ function Rt(e, t, r) {
308
+ const n = Ee(e.descriptors, t.presentation, r), o = e.columns.map((m) => {
309
+ var a;
310
+ return m.kind === "measure" && ((a = n.measureSemantics.get(m.measureId)) == null ? void 0 : a.isNumeric) === !0;
311
+ }), l = (m) => J([m], n.levels), s = (m, a, u) => Fe(m, a, t.presentation.totals[u], n.levels), c = e.columns.map((m) => {
312
+ if (m.kind !== "measure") return m.label;
313
+ const a = m.columnPath.map(l);
314
+ return m.role !== "member" && a.push(s(m.columnPath, m.role, "columns")), [...a, m.label].join(" / ");
315
+ }), f = Math.min(t.spec.columns.length, Math.max(
316
+ 0,
317
+ ...e.columns.map((m) => m.kind === "measure" ? m.columnPath.length + (m.role !== "member" ? 1 : 0) : 0)
318
+ )), d = Array.from({ length: f + 1 }, (m, a) => e.columns.map((u) => a === f ? u.label : u.kind !== "measure" ? "" : a < u.columnPath.length ? l(u.columnPath[a]) : a === u.columnPath.length && u.role !== "member" ? s(u.columnPath, u.role, "columns") : "")), b = (m, a) => Ye({
319
+ path: m.rowPath,
320
+ role: m.kind === "layout" ? m.role : "member",
321
+ levelCount: Math.max(1, t.spec.rows.length),
322
+ repeatLabels: t.presentation.layout.kind !== "tabular" || t.presentation.layout.repeatLabels,
323
+ previousPath: a == null ? void 0 : a.rowPath
324
+ }), w = (m, a) => {
325
+ if (m.kind !== "layout") throw new Error("Layout presentation requires layout rows.");
326
+ if (m.values.length !== e.columns.length) throw new Error("Matrix row does not match its frozen layout.");
327
+ const u = b(m, a);
328
+ return e.columns.map((h, p) => {
329
+ if (h.kind === "hierarchy")
330
+ return `${" ".repeat(Math.max(0, m.rowPath.length - 1))}${s(m.rowPath, m.role, "rows")}`;
331
+ if (h.kind === "level") {
332
+ const v = t.spec.rows.findIndex((S) => S.id === h.levelId), C = u[v];
333
+ return C != null && C.visible ? C.total ? s(m.rowPath, m.role, "rows") : J(C.path, n.levels) : "";
334
+ }
335
+ const T = m.values[p], g = n.measures.get(h.measureId);
336
+ if (T.kind === "value" && !g)
337
+ throw new Error("Matrix value is missing its measure descriptor.");
338
+ return Se(T, g, t.presentation.absence);
339
+ });
340
+ }, x = (m, a) => w(m, a).map((u, h) => {
341
+ const p = e.columns[h];
342
+ return p.kind === "measure" ? Le(u, m.values[h], n.measureSemantics.get(p.measureId)) : H(u);
343
+ });
344
+ return {
345
+ headers: c,
346
+ headerBands: d,
347
+ numericColumns: o,
348
+ /** The card's prepared formats this presentation formats with (the Excel form reads its measure formats). */
349
+ formatting: n,
350
+ /** A row's cells; after `previous`, a tabular layout prints each label once. */
351
+ row: (m, a) => w(m, a),
352
+ /**
353
+ * Level columns whose group label the row above shows, so this row
354
+ * continues the group (Plan 2, 2d, C8). Only a member row after a member
355
+ * row continues one: a total prints as a band, and its rules stay whole
356
+ * above and below it.
357
+ */
358
+ continuedColumns: (m, a) => {
359
+ const u = (p) => (p == null ? void 0 : p.kind) === "layout" && p.role === "member";
360
+ if (!u(m) || !u(a)) return [];
361
+ const h = b(m, a);
362
+ return e.columns.flatMap((p, T) => {
363
+ var v;
364
+ if (p.kind !== "level") return [];
365
+ const g = t.spec.rows.findIndex((C) => C.id === p.levelId);
366
+ return g < m.rowPath.length && ((v = h[g]) == null ? void 0 : v.visible) === !1 ? [T] : [];
367
+ });
368
+ },
369
+ csvRow: (m) => x(m),
370
+ /**
371
+ * `previousRow` is the row before `data[0]`, carried by the export's
372
+ * continuation, so a tabular layout prints each label once across the
373
+ * whole file. Retries are pure: suppression never relies on mutable
374
+ * formatter state or an earlier worker. Without it, the first row prints
375
+ * its labels.
376
+ */
377
+ csvRows: (m, a) => m.map((u, h) => x(u, h ? m[h - 1] : a ?? void 0))
378
+ };
379
+ }
380
+ function Lr(e) {
381
+ return e.columns.map((t) => H(t.label));
382
+ }
383
+ function Pr(e, t, r) {
384
+ return Nt(e, t, r).map((n, o) => {
385
+ const l = t.columns[o];
386
+ return l.kind === "measure" ? Le(n, e.values[o], r.measureSemantics.get(l.measureId)) : H(n);
387
+ });
388
+ }
389
+ function Nt(e, t, r) {
390
+ if (e.kind !== "flat") throw new Error("Flat Matrix CSV requires flat rows.");
391
+ if (e.values.length !== t.columns.length) throw new Error("Matrix row does not match its frozen layout.");
392
+ const n = [...e.rowPath, ...e.columnPath];
393
+ return t.columns.map((o, l) => {
394
+ if (o.kind === "measure") {
395
+ const c = e.values[l], f = r.measures.get(o.measureId);
396
+ if (c.kind === "value" && !f) throw new Error("Matrix value is missing its measure descriptor.");
397
+ return Se(c, f, r.absence);
398
+ }
399
+ const s = o.kind === "level" ? n.find((c) => c.levelId === o.levelId) : void 0;
400
+ if (!s) throw new Error("Flat Matrix row does not match its frozen layout.");
401
+ return J([s], r.levels);
402
+ });
403
+ }
404
+ function Ot(e) {
405
+ const t = Rt(e.layout, e.request, e.report), r = e.layout.columns.map((s, c) => ({
406
+ index: c,
407
+ columnId: `matrix:${c}`,
408
+ label: t.headers[c],
409
+ isNumeric: t.numericColumns[c]
410
+ })), n = (s, c, f) => ({
411
+ text: s,
412
+ colspan: 1,
413
+ rowspan: 1,
414
+ columnId: r[c].columnId,
415
+ isHeader: f,
416
+ isNumeric: r[c].isNumeric,
417
+ className: r[c].isNumeric ? "numeric" : e.layout.columns[c].kind === "hierarchy" ? "matrix-hierarchy" : ""
418
+ }), o = [], l = e.layout.columns.findIndex((s) => s.kind === "measure");
419
+ e.request.spec.columns.length && l >= 0 && o.push({
420
+ repeatHeader: !0,
421
+ headerType: "pivot-axis",
422
+ headerRowIndex: 0,
423
+ cells: [
424
+ ...l ? [{ ...n("", 0, !0), colspan: l }] : [],
425
+ {
426
+ ...n(e.request.spec.columns.map((s) => ke(s, e.request.presentation)).join(" / "), l, !0),
427
+ colspan: e.layout.columns.length - l,
428
+ isNumeric: !1,
429
+ className: ""
430
+ }
431
+ ]
432
+ });
433
+ for (const [s, c] of t.headerBands.entries())
434
+ o.push({
435
+ repeatHeader: !0,
436
+ headerType: s === t.headerBands.length - 1 ? "metrics" : "pivot-level",
437
+ headerRowIndex: o.length,
438
+ cells: c.map((f, d) => n(f, d, !0))
439
+ });
440
+ return {
441
+ headers: o,
442
+ rows: e.rows.map((s, c) => {
443
+ const f = new Set(t.continuedColumns(s, e.rows[c - 1]));
444
+ return {
445
+ index: c,
446
+ type: s.kind === "layout" && s.role !== "member" ? "subtotal" : "data",
447
+ subtotalLevel: String(s.rowPath.length),
448
+ // A tabular layout prints each label once unless it repeats them; the
449
+ // blank cell continues its group, so a grid draws no rule above it.
450
+ cells: t.row(s, e.rows[c - 1]).map((d, b) => f.has(b) ? { ...n(d, b, !1), className: At } : n(d, b, !1))
451
+ };
452
+ }),
453
+ grandTotal: null,
454
+ // Totals are already in the ordered body at their authored position.
455
+ metadata: {
456
+ tableType: "pivot",
457
+ totalRows: e.rows.length,
458
+ totalColumns: r.length,
459
+ rowLevels: e.layout.columns.filter((s) => s.kind !== "measure").length,
460
+ pivotLevels: e.request.spec.columns.length,
461
+ hasGrandTotal: !1,
462
+ columnOrder: r.map((s) => s.columnId),
463
+ columns: r
464
+ }
465
+ };
466
+ }
467
+ function Kt(e, t, r) {
468
+ const { levels: n } = Ee(e.descriptors, t.presentation, r), o = t.spec.columns.length > 0, l = [], s = [], c = e.columns.map((d, b) => {
469
+ if (d.kind !== "measure") return null;
470
+ const w = o ? `${d.role}:${B(d.columnPath)}` : `measure:${b}`;
471
+ let x = l.indexOf(w);
472
+ return x < 0 && (x = l.push(w) - 1, s.push(o ? Fe(d.columnPath, d.role, t.presentation.totals.columns, n) : d.label)), x;
473
+ }), f = t.spec.columns[t.spec.columns.length - 1];
474
+ return {
475
+ columnGroups: c,
476
+ groupLabels: s,
477
+ /** What bands name their groups by: the innermost column level, or "Measures". */
478
+ groupLevelLabel: f ? ke(f, t.presentation) : "Measures"
479
+ };
480
+ }
481
+ function Dr(e) {
482
+ const { layout: t, rows: r, report: n } = e, o = {
483
+ ...e.request,
484
+ presentation: Pt(t, r, e.request.presentation)
485
+ }, l = Ot({ layout: t, rows: r, request: o, report: n }), s = _t(r), c = Kt(t, o, n), f = {
486
+ ...l,
487
+ rows: l.rows.map((d, b) => ({ ...d, keepWithPrevious: s[b] })),
488
+ metadata: { ...l.metadata, ...c }
489
+ };
490
+ return { request: o, table: f, ...c };
491
+ }
492
+ class Vt extends Error {
493
+ constructor() {
494
+ super(...arguments);
495
+ ae(this, "code", Me);
496
+ }
497
+ }
498
+ function ye(e) {
499
+ if (!e || typeof e != "object")
500
+ return;
501
+ const { error: t, message: r, detail: n } = e;
502
+ for (const o of [t, r, n])
503
+ if (typeof o == "string" && o.trim())
504
+ return o.trim();
505
+ }
506
+ async function Ut(e) {
507
+ const t = `PDF request failed: ${e.status} ${e.statusText}`.trim(), r = e.headers.get("content-type") || "";
508
+ try {
509
+ if (r.includes("application/json")) {
510
+ const o = await e.json(), l = typeof o.code == "string" ? o.code : typeof o.errorCode == "string" ? o.errorCode : void 0;
511
+ return { message: ye(o) || t, code: l };
512
+ }
513
+ const n = await e.text();
514
+ if (!n.trim())
515
+ return { message: t };
516
+ try {
517
+ const o = JSON.parse(n), l = typeof o.code == "string" ? o.code : typeof o.errorCode == "string" ? o.errorCode : void 0;
518
+ return {
519
+ message: ye(o) || n.trim(),
520
+ code: l
521
+ };
522
+ } catch {
523
+ return { message: n.trim() };
524
+ }
525
+ } catch {
526
+ return { message: t };
527
+ }
528
+ }
529
+ async function _r(e) {
530
+ if (!e.token) throw new Error("Missing auth token for PDF export");
531
+ if (ct(e.serializedPayload) > mt.maxRequestBytes)
532
+ throw new Error("Fast-path PDF request exceeds the structured body limit");
533
+ const t = await (e.fetchImpl ?? fetch)(e.url, {
534
+ method: "POST",
535
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${e.token}` },
536
+ body: e.serializedPayload,
537
+ signal: e.signal
538
+ });
539
+ if (!t.ok) {
540
+ const n = await Ut(t);
541
+ throw n.code === Me ? new Vt(n.message) : new Error(n.message);
542
+ }
543
+ const r = await t.json();
544
+ if (r != null && r.error) throw new Error(r.error);
545
+ if (typeof (r == null ? void 0 : r.url) != "string" || !r.url.trim())
546
+ throw new Error("Fast-path PDF response missing download URL");
547
+ return r;
548
+ }
549
+ function jt(e, t) {
550
+ return e.dashboardId === t.dashboardId && e.cardId === t.cardId && e.attachmentIndex === void 0;
551
+ }
552
+ function Pe(e) {
553
+ return new Map(
554
+ e.presentationExecutionSnapshot.resolvedFormats.flatMap(
555
+ (t) => t.format.type === "raw_temporal" && t.target.kind === "column" && jt(t.scope, e.scope) ? [[t.target.columnKey, t.format]] : []
556
+ )
557
+ );
558
+ }
559
+ function De(e) {
560
+ const t = e == null ? void 0 : e.sql, r = e == null ? void 0 : e.python;
561
+ return (e == null ? void 0 : e.resultOwner) === "freeform" && typeof t == "string" && !!t.trim() && (typeof r != "string" || !r.trim());
562
+ }
563
+ function Ar(e) {
564
+ return e.formatting.useFormattedValues !== !1 && De(e.queryPayload) && Pe(e.formatting).size > 0;
565
+ }
566
+ function Bt(e, t) {
567
+ return e.map((r, n) => {
568
+ if (!Object.prototype.hasOwnProperty.call(r, t) || r[t] === void 0)
569
+ throw new Error(
570
+ `missing_raw_temporal_result_contract: Row ${n} is missing declared temporal column "${t}".`
571
+ );
572
+ const o = r[t];
573
+ return o === null || typeof o == "string" ? o : String(o);
574
+ });
575
+ }
576
+ function zt(e) {
577
+ if (e.formatting.useFormattedValues === !1)
578
+ return {
579
+ activatedColumnKeys: /* @__PURE__ */ new Set(),
580
+ byColumnKey: /* @__PURE__ */ new Map()
581
+ };
582
+ const t = Pe(e.formatting), r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
583
+ if (t.size === 0)
584
+ return { activatedColumnKeys: r, byColumnKey: n };
585
+ const o = new Map(
586
+ e.columns.flatMap((c) => {
587
+ const f = c.key || c.field;
588
+ return f ? [[f, c]] : [];
589
+ })
590
+ ), l = De(e.queryPayload), s = /* @__PURE__ */ new Map();
591
+ for (const [c, f] of t) {
592
+ const d = o.get(c);
593
+ let b;
594
+ if (d != null && d.rawTemporal)
595
+ b = ft(d, {
596
+ metadataRequired: !0
597
+ }), r.add(c);
598
+ else if (l) {
599
+ r.add(c);
600
+ const w = Be({
601
+ columnKey: c,
602
+ values: Bt(e.records, c)
603
+ });
604
+ s.set(c, w), w.status === "classified" && (b = w.metadata);
605
+ } else
606
+ continue;
607
+ b && n.set(c, {
608
+ metadata: b,
609
+ format: f,
610
+ formatValue: ze({ metadata: b, format: f })
611
+ });
612
+ }
613
+ return {
614
+ activatedColumnKeys: r,
615
+ byColumnKey: n,
616
+ ...l ? {
617
+ sqlChunkEvidence: He(s)
618
+ } : {}
619
+ };
620
+ }
621
+ function Ht(e) {
622
+ if (!e.resolution.activatedColumnKeys.has(e.columnKey))
623
+ return;
624
+ if (e.value === void 0)
625
+ throw new Error(
626
+ `missing_raw_temporal_result_contract: Row ${e.rowIndex} is missing temporal column "${e.columnKey}".`
627
+ );
628
+ const t = e.resolution.byColumnKey.get(e.columnKey);
629
+ if (!t)
630
+ return { text: e.value === null ? "" : String(e.value) };
631
+ if (e.value !== null && typeof e.value != "string")
632
+ return { text: String(e.value) };
633
+ const r = t.formatValue(e.value);
634
+ return r.ok && r.wallClock ? { text: r.text, wallClock: r.wallClock } : { text: r.text };
635
+ }
636
+ function he(e, t) {
637
+ const r = e.byColumnKey.get(t);
638
+ return r ? r.metadata.valueKind === "date" : void 0;
639
+ }
640
+ const Xt = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime"]), Gt = /^\d{4}-\d{2}-\d{2}|^\d{2}\/\d{2}\/\d{4}/, qt = /^\d{4}-\d{2}-\d{2}$/, _e = "MM/dd/yyyy";
641
+ function z(e) {
642
+ return typeof e == "object" && e !== null && !Array.isArray(e);
643
+ }
644
+ function A(e) {
645
+ return e.key || e.field || void 0;
646
+ }
647
+ function be(e) {
648
+ return e == null ? "" : typeof e == "string" ? e : O(e) ? e.value : e instanceof Date ? e.toISOString() : typeof e == "object" ? JSON.stringify(e) : String(e);
649
+ }
650
+ function ge(e, t) {
651
+ var n;
652
+ const r = (n = e.columnSettings) == null ? void 0 : n[t];
653
+ if (!(!z(r) || r.type !== "date"))
654
+ return z(r.dateFormat) ? r.dateFormat : {};
655
+ }
656
+ function we(e) {
657
+ return e.useCustomFormat && e.customFormat ? e.customFormat : e.format || _e;
658
+ }
659
+ function ve(e, t) {
660
+ return e && e !== "auto" ? e : t;
661
+ }
662
+ function Wt(e) {
663
+ return !/[HhKkmsSa]/.test(e.replace(/'[^']*'/g, ""));
664
+ }
665
+ function Yt(e) {
666
+ if (typeof e == "number") return Number.isFinite(e) ? e : null;
667
+ if (typeof e != "string" || !e.trim()) return null;
668
+ const t = Number(e);
669
+ return Number.isFinite(t) ? t : null;
670
+ }
671
+ function Zt(e) {
672
+ const t = Ie(e);
673
+ if (t !== void 0)
674
+ try {
675
+ return rt(t, /[.eE]/.test(t) ? "decimal" : "integer");
676
+ } catch {
677
+ return;
678
+ }
679
+ }
680
+ function Jt(e) {
681
+ return e.calendar.fiscalCalendar && (e.granularity === "quarter" || e.granularity === "year") ? "fiscal" : e.granularity;
682
+ }
683
+ function Rr(e) {
684
+ const { formatting: t, queryPayload: r } = e, n = t.useFormattedValues, o = t.scope, l = (a) => ot({ snapshot: t.presentationExecutionSnapshot, scope: o, target: { kind: "column", columnKey: a } }), s = (a) => at({ snapshot: t.presentationExecutionSnapshot, scope: o, target: { kind: "column", columnKey: a } });
685
+ function c(a) {
686
+ var h;
687
+ if ((h = t.visibleColumns) != null && h.length) return t.visibleColumns;
688
+ const u = a.columns.map(A).filter((p) => !!p);
689
+ return u.length > 0 ? u : a.records[0] ? Object.keys(a.records[0]) : [];
690
+ }
691
+ function f(a, u) {
692
+ return t.columnLabels && Object.prototype.hasOwnProperty.call(t.columnLabels, a) && t.columnLabels[a] || void 0 || d(u) || (u == null ? void 0 : u.label) || (u == null ? void 0 : u.headerName) || a;
693
+ }
694
+ function d(a, u) {
695
+ const h = a == null ? void 0 : a.pivotIdentity;
696
+ if (!h || !h.members || h.members.length === 0) return;
697
+ const p = ce({ identity: h, columnKey: (a == null ? void 0 : a.key) || (a == null ? void 0 : a.field) || "" });
698
+ return ut({
699
+ members: p,
700
+ metricLabel: (a == null ? void 0 : a.label) || (a == null ? void 0 : a.headerName),
701
+ mode: n ? "formatted" : "canonical",
702
+ resolveTemporalFormat: (T) => {
703
+ const g = p.find((C) => C.fieldId === T);
704
+ if (!(g != null && g.temporalBucket)) return;
705
+ const v = ie({
706
+ snapshot: t.presentationExecutionSnapshot,
707
+ scope: o,
708
+ target: { kind: "field", fieldId: T, role: "pivotby" }
709
+ });
710
+ return v ? b(g.temporalBucket, v) : void 0;
711
+ }
712
+ }).flattenedLabel;
713
+ }
714
+ function b(a, u) {
715
+ return Xe({
716
+ metadata: a,
717
+ cardFormat: u,
718
+ locale: u.locale,
719
+ ...u.presentation.mode === "auto" ? { styles: u.presentation.styles } : {}
720
+ }).format;
721
+ }
722
+ function w(a, u) {
723
+ const { records: h, columns: p } = a, T = z(r.cardConfig) ? r.cardConfig : void 0, g = T == null ? void 0 : T.pivotByColumns, v = Array.isArray(g) ? g.flatMap(
724
+ (i) => z(i) && typeof i.id == "string" && i.id ? [i.id] : []
725
+ ) : [];
726
+ dt(
727
+ p.map((i) => ({ key: A(i) || "<unknown>", pivotIdentity: i.pivotIdentity })),
728
+ { expectedPivotFieldIds: v }
729
+ );
730
+ const C = c(a), S = new Map(
731
+ p.flatMap((i) => {
732
+ const y = A(i);
733
+ return y ? [[y, i]] : [];
734
+ })
735
+ ), Re = new Map(a.resultColumns.map((i) => [i.key, i.dataType])), I = zt({
736
+ records: h,
737
+ columns: p,
738
+ formatting: t,
739
+ queryPayload: r
740
+ }), X = new Map(
741
+ p.flatMap((i) => {
742
+ const y = A(i);
743
+ return y && i.temporalBucket ? [[y, i.temporalBucket]] : [];
744
+ })
745
+ ), te = /* @__PURE__ */ new Map();
746
+ for (const i of C) {
747
+ const y = ie({
748
+ snapshot: t.presentationExecutionSnapshot,
749
+ scope: o,
750
+ target: { kind: "column", columnKey: i }
751
+ }), E = X.get(i);
752
+ if (n) {
753
+ if (y && !E) throw new Error(`Missing temporal bucket metadata for column "${i}"`);
754
+ if (E && !y) throw new Error(`Missing resolved temporal presentation for column "${i}"`);
755
+ }
756
+ y && E && te.set(i, b(E, y));
757
+ }
758
+ const G = C.map((i) => {
759
+ const y = Re.get(i), E = y && Xt.has(y) ? y : "unknown", F = n ? x(i, I, X) : void 0, M = f(i, S.get(i)), P = n && I.activatedColumnKeys.has(i) && he(I, i) === void 0;
760
+ return {
761
+ key: i,
762
+ label: M,
763
+ dataType: E,
764
+ ...F ? { presentation: F } : {},
765
+ xlsx: de({ key: i, label: M, formattedValues: n, dataType: E, presentation: F }),
766
+ ...P ? { xlsxPending: !0 } : {}
767
+ };
768
+ });
769
+ function Ne(i, y, E, F) {
770
+ if (!n) return { text: be(i), value: i };
771
+ const M = Ht({ value: i, columnKey: y, rowIndex: E, resolution: I });
772
+ if (M !== void 0) return { text: M.text, value: i, ...M.wallClock ? { wallClock: M.wallClock } : {} };
773
+ const P = X.get(y);
774
+ if (P) {
775
+ const k = te.get(y);
776
+ if (!k) throw new Error(`Missing resolved temporal presentation for column "${y}"`);
777
+ if (i != null && typeof i != "string")
778
+ throw new Error(`Canonical temporal column "${y}" must contain a string or null`);
779
+ const D = i ?? null, _ = Ge(D, P);
780
+ return {
781
+ text: qe({ value: D, metadata: P, format: k }),
782
+ value: i,
783
+ ..._ ? { wallClock: _ } : {}
784
+ };
785
+ }
786
+ if (i == null) return { text: "", value: i };
787
+ const q = s(y);
788
+ if (q && typeof i == "number" && Number.isFinite(i))
789
+ return {
790
+ text: se(
791
+ new Date(i).toISOString(),
792
+ q.pattern || _e,
793
+ ve(q.timezone, t.timezone),
794
+ "UTC"
795
+ ),
796
+ value: i
797
+ };
798
+ const $ = l(y);
799
+ if (typeof i == "number")
800
+ return { text: $ ? V(i, $) : String(i), value: i };
801
+ if (O(i))
802
+ return { text: $ ? V(i, $) : i.value, value: i };
803
+ const K = ge(t, y);
804
+ if (K && (i instanceof Date || typeof i == "string" && Gt.test(i))) {
805
+ const k = i instanceof Date ? i.toISOString() : i, D = typeof i == "string" && qt.test(i), _ = D ? "UTC" : ve(K.timezone, t.timezone), ne = D ? "UTC" : K.sourceTimezone || "auto", oe = Ze(k, _, ne);
806
+ return {
807
+ text: se(k, we(K), _, ne),
808
+ value: i,
809
+ ...oe ? { wallClock: oe } : {}
810
+ };
811
+ }
812
+ if (typeof i == "string" && $ && F.dataType === "number") {
813
+ const k = Zt(i);
814
+ if (k) return { text: V(k, $), value: i };
815
+ }
816
+ return { text: be(i), value: i };
817
+ }
818
+ const Oe = h.map(
819
+ (i, y) => G.map((E) => {
820
+ const F = Ne(i[E.key], E.key, y, E);
821
+ return U({ value: F.value, text: F.text, column: E.xlsx, wallClock: F.wallClock });
822
+ })
823
+ ), re = (u == null ? void 0 : u.withHeader) !== !1 && t.includeHeaders;
824
+ if (re)
825
+ for (const i of C) {
826
+ const y = S.get(i);
827
+ y != null && y.pivotIdentity && ce({ identity: y.pivotIdentity, columnKey: A(y) || i });
828
+ }
829
+ return {
830
+ ...re ? { header: G.map((i) => i.label) } : {},
831
+ columns: G,
832
+ rows: Oe,
833
+ ...I.sqlChunkEvidence ? { rawTemporalClassification: I.sqlChunkEvidence } : {}
834
+ };
835
+ }
836
+ function x(a, u, h) {
837
+ if (u.activatedColumnKeys.has(a)) {
838
+ const v = he(u, a);
839
+ return v === void 0 ? { kind: "text" } : { kind: "datetime", dateOnly: v };
840
+ }
841
+ const p = h.get(a);
842
+ if (p) return { kind: "temporal_bucket", grain: Jt(p) };
843
+ if (s(a)) return { kind: "text" };
844
+ const T = ge(t, a);
845
+ if (T) return { kind: "datetime", dateOnly: Wt(we(T)) };
846
+ const g = l(a);
847
+ return g ? { kind: "measure", format: g } : void 0;
848
+ }
849
+ function m(a, u) {
850
+ if (!Number.isInteger(u) || u < 0)
851
+ throw new Error("totalRows must be a non-negative integer");
852
+ return u === 0 ? void 0 : (t.visibleColumns ?? Object.keys(a)).map((p) => {
853
+ const g = Object.prototype.hasOwnProperty.call(a, p) ? a[p] : p === t.tableTotalsLabelColumnKey ? "Total" : null, v = n ? l(p) : void 0, C = de({
854
+ key: p,
855
+ label: p,
856
+ formattedValues: n,
857
+ dataType: "unknown",
858
+ ...v ? { presentation: { kind: "measure", format: v } } : {}
859
+ });
860
+ if (g == null) return { kind: "empty" };
861
+ if (!n) return U({ value: g, text: String(g), column: C });
862
+ const S = v ? Yt(g) : null;
863
+ return U(v && S !== null ? { value: S, text: V(S, v), column: C } : { value: g, text: String(g), column: C });
864
+ });
865
+ }
866
+ return { format: w, totals: m };
867
+ }
868
+ const Qt = /* @__PURE__ */ new Set([
869
+ "scope",
870
+ "useFormattedValues",
871
+ "timezone",
872
+ "presentationExecutionSnapshot",
873
+ "delimiter",
874
+ "csvEncoding",
875
+ "includeHeaders",
876
+ "columnSettings",
877
+ "visibleColumns",
878
+ "columnLabels",
879
+ "tableTotalsLabelColumnKey",
880
+ "fileFormat",
881
+ "title"
882
+ ]);
883
+ function ee(e) {
884
+ return e !== null && typeof e == "object" && !Array.isArray(e);
885
+ }
886
+ function Ce(e, t) {
887
+ if (e !== void 0) {
888
+ if (!ee(e))
889
+ throw new Error(`formatting.${t} must be an object`);
890
+ return e;
891
+ }
892
+ }
893
+ function Nr(e) {
894
+ if (!ee(e))
895
+ throw new Error("formatting must be an object");
896
+ const t = ["reportContext", "resolvedFormats"].find(
897
+ (a) => Object.prototype.hasOwnProperty.call(e, a)
898
+ );
899
+ if (t)
900
+ throw new le(
901
+ `formatting.${t} is retired; formatting.presentationExecutionSnapshot is authoritative.`
902
+ );
903
+ const r = Object.keys(e).find((a) => !Qt.has(a));
904
+ if (r)
905
+ throw new Error(`formatting contains unknown property "${r}"`);
906
+ const n = typeof e.timezone == "string" ? e.timezone.trim() : "";
907
+ if (!n)
908
+ throw new Error("formatting.timezone must be a non-empty string");
909
+ const o = Je(e.delimiter);
910
+ if (!o)
911
+ throw new Error("formatting.delimiter must be a comma, semicolon or tab");
912
+ const l = Qe(e.csvEncoding);
913
+ if (!l)
914
+ throw new Error("formatting.csvEncoding must be 'utf-8-bom' or 'utf-8'");
915
+ if (typeof e.includeHeaders != "boolean")
916
+ throw new Error("formatting.includeHeaders must be a boolean");
917
+ if (e.useFormattedValues !== void 0 && typeof e.useFormattedValues != "boolean")
918
+ throw new Error("formatting.useFormattedValues must be a boolean");
919
+ const s = e.fileFormat === void 0 ? void 0 : et(e.fileFormat);
920
+ if (e.fileFormat !== void 0 && !s)
921
+ throw new Error("formatting.fileFormat must be 'csv' or 'xlsx'");
922
+ if (e.title !== void 0 && typeof e.title != "string")
923
+ throw new Error("formatting.title must be a string");
924
+ const c = e.visibleColumns === void 0 ? void 0 : Array.isArray(e.visibleColumns) && e.visibleColumns.every((a) => typeof a == "string") ? e.visibleColumns : void 0;
925
+ if (e.visibleColumns !== void 0 && !c)
926
+ throw new Error("formatting.visibleColumns must be an array of strings");
927
+ const f = Ce(e.columnLabels, "columnLabels");
928
+ if (f && Object.values(f).some((a) => typeof a != "string"))
929
+ throw new Error("formatting.columnLabels values must be strings");
930
+ const d = Ce(e.columnSettings, "columnSettings"), b = e.tableTotalsLabelColumnKey === void 0 ? void 0 : typeof e.tableTotalsLabelColumnKey == "string" && e.tableTotalsLabelColumnKey.trim() ? e.tableTotalsLabelColumnKey : null;
931
+ if (b === null)
932
+ throw new Error("formatting.tableTotalsLabelColumnKey must be a non-empty string");
933
+ if (b && !(c != null && c.includes(b)))
934
+ throw new Error("formatting.tableTotalsLabelColumnKey must identify a visible column");
935
+ const w = st(e.scope, "formatting.scope");
936
+ if (!w.cardId || w.attachmentIndex !== void 0)
937
+ throw new Error("formatting.scope must identify exactly one dashboard card");
938
+ const x = e.useFormattedValues !== !1, m = it(e.presentationExecutionSnapshot);
939
+ if (n !== m.reportContext.calendar.tz)
940
+ throw new Error(
941
+ "formatting.timezone must equal presentationExecutionSnapshot.reportContext.calendar.tz"
942
+ );
943
+ try {
944
+ lt({
945
+ snapshot: m,
946
+ expectedScope: { dashboardId: w.dashboardId, cardId: w.cardId },
947
+ visibleColumns: c,
948
+ useFormattedValues: x
949
+ });
950
+ } catch (a) {
951
+ throw new le(
952
+ `formatting.presentationExecutionSnapshot.${a instanceof Error ? a.message : String(a)}`
953
+ );
954
+ }
955
+ return {
956
+ scope: { dashboardId: w.dashboardId, cardId: w.cardId },
957
+ useFormattedValues: x,
958
+ timezone: n,
959
+ presentationExecutionSnapshot: m,
960
+ delimiter: o,
961
+ csvEncoding: l,
962
+ includeHeaders: e.includeHeaders,
963
+ ...d ? { columnSettings: d } : {},
964
+ ...c ? { visibleColumns: c } : {},
965
+ ...f ? { columnLabels: f } : {},
966
+ ...b ? { tableTotalsLabelColumnKey: b } : {},
967
+ ...s ? { fileFormat: s } : {},
968
+ ...typeof e.title == "string" ? { title: e.title } : {}
969
+ };
970
+ }
971
+ function Or(e) {
972
+ const t = e.formatOptions, r = (n) => ee(n) ? n : void 0;
973
+ return {
974
+ scope: { dashboardId: e.dashboardId, cardId: e.cardId },
975
+ useFormattedValues: t.useFormattedValues !== !1,
976
+ timezone: t.presentationExecutionSnapshot.reportContext.calendar.tz,
977
+ presentationExecutionSnapshot: t.presentationExecutionSnapshot,
978
+ delimiter: typeof t.delimiter == "string" ? t.delimiter : ",",
979
+ csvEncoding: t.csvEncoding,
980
+ includeHeaders: t.includeHeaders !== !1,
981
+ columnSettings: r(t.columnSettings),
982
+ visibleColumns: Array.isArray(t.visibleColumns) ? t.visibleColumns : void 0,
983
+ columnLabels: r(t.columnLabels),
984
+ tableTotalsLabelColumnKey: typeof t.tableTotalsLabelColumnKey == "string" ? t.tableTotalsLabelColumnKey : void 0,
985
+ ...e.fileFormat ? { fileFormat: e.fileFormat } : {},
986
+ ...typeof e.title == "string" ? { title: e.title } : {}
987
+ };
988
+ }
989
+ const er = /^\d{4}-\d{2}-\d{2}$/;
990
+ function Ae(e) {
991
+ const t = e.split(".");
992
+ return t[t.length - 1].replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").map((o) => o.charAt(0).toUpperCase() + o.slice(1).toLowerCase()).join(" ");
993
+ }
994
+ const xe = 10;
995
+ function Z(e, t) {
996
+ const r = e.slice(0, xe).map(t).join(", "), n = e.length - xe;
997
+ return n > 0 ? `${r}, and ${n} more` : r;
998
+ }
999
+ function tr(e) {
1000
+ if (e.valueType !== "date" || e.operation !== "between" && e.operation !== "not between")
1001
+ return;
1002
+ const t = Q(e.relativeMeta);
1003
+ if (t)
1004
+ return nt(t) || t.unit === "quarter" || t.unit === "year" ? t : void 0;
1005
+ }
1006
+ function rr(e, t) {
1007
+ if (t !== "label") return tr(e);
1008
+ if (!(e.valueType !== "date" || e.operation !== "between" && e.operation !== "not between"))
1009
+ return Q(e.relativeMeta);
1010
+ }
1011
+ function Te(e, t = {}) {
1012
+ const { name: r, operation: n, values: o, valueType: l } = e, s = t.label ?? Ae(r), c = rr(e, t.relativeDates);
1013
+ if (c) {
1014
+ const d = pt(c);
1015
+ if (d)
1016
+ return n === "between" ? `${s}: ${d}` : `${s} not in ${d}`;
1017
+ }
1018
+ if (!o || o.length === 0)
1019
+ return n === "is null" ? `${s} is empty` : n === "is not null" ? `${s} is not empty` : "";
1020
+ const f = (d) => {
1021
+ if (l === "date" && d) {
1022
+ const b = e.temporalPrecision === "minute", w = {
1023
+ year: "numeric",
1024
+ month: "short",
1025
+ day: "numeric",
1026
+ ...b ? {
1027
+ hour: "numeric",
1028
+ minute: "2-digit"
1029
+ } : {}
1030
+ };
1031
+ if (typeof d == "string" && er.test(d)) {
1032
+ const [m, a, u] = d.split("-").map(Number);
1033
+ return new Intl.DateTimeFormat(void 0, {
1034
+ year: "numeric",
1035
+ month: "short",
1036
+ day: "numeric",
1037
+ timeZone: "UTC"
1038
+ }).format(new Date(Date.UTC(m, a - 1, u)));
1039
+ }
1040
+ if (typeof d == "string" && We(d) === "wall_datetime") {
1041
+ const [m, a, u, h, p] = d.split(/[-T :.]/).map(Number);
1042
+ return new Intl.DateTimeFormat(void 0, {
1043
+ ...w,
1044
+ timeZone: "UTC"
1045
+ }).format(new Date(Date.UTC(m, a - 1, u, h, p)));
1046
+ }
1047
+ const x = new Date(d);
1048
+ if (!isNaN(x.getTime()))
1049
+ try {
1050
+ return new Intl.DateTimeFormat(void 0, {
1051
+ ...w,
1052
+ ...t.timezone ? { timeZone: t.timezone } : {}
1053
+ }).format(x);
1054
+ } catch {
1055
+ return b ? x.toLocaleString(void 0, w) : x.toLocaleDateString(void 0, w);
1056
+ }
1057
+ }
1058
+ return String(d);
1059
+ };
1060
+ switch (n) {
1061
+ case "=":
1062
+ return `${s}: ${f(o[0])}`;
1063
+ case "!=":
1064
+ return `${s} ≠ ${f(o[0])}`;
1065
+ case ">":
1066
+ return `${s} > ${f(o[0])}`;
1067
+ case "<":
1068
+ return `${s} < ${f(o[0])}`;
1069
+ case ">=":
1070
+ return `${s} ≥ ${f(o[0])}`;
1071
+ case "<=":
1072
+ return `${s} ≤ ${f(o[0])}`;
1073
+ case "between":
1074
+ case "not between": {
1075
+ const d = `${f(o[0])} - ${f(o[1])}`;
1076
+ return n === "between" ? `${s}: ${d}` : `${s} not in ${d}`;
1077
+ }
1078
+ case "in":
1079
+ return o.length === 1 ? `${s}: ${f(o[0])}` : `${s}: ${Z(o, f)}`;
1080
+ case "not in":
1081
+ return `${s} not in (${Z(o, f)})`;
1082
+ case "like":
1083
+ return `${s} contains "${o[0]}"`;
1084
+ case "not like":
1085
+ return `${s} doesn't contain "${o[0]}"`;
1086
+ default:
1087
+ return `${s}: ${Z(o, f)}`;
1088
+ }
1089
+ }
1090
+ function Kr(e, t = {}) {
1091
+ if (!e || e.length === 0)
1092
+ return "";
1093
+ const r = /* @__PURE__ */ new Map();
1094
+ e.forEach((o) => {
1095
+ const l = r.get(o.name) || [];
1096
+ l.push(o), r.set(o.name, l);
1097
+ });
1098
+ const n = [];
1099
+ return r.forEach((o, l) => {
1100
+ if (o.length === 1) {
1101
+ const s = Te(o[0], t);
1102
+ s && n.push(s);
1103
+ } else {
1104
+ const s = Ae(l), c = o.map((f) => Te(f, t).replace(`${s}: `, "").replace(`${s} `, "")).filter(Boolean);
1105
+ c.length > 0 && n.push(`${s}: ${c.join(" and ")}`);
1106
+ }
1107
+ }), n.join(" | ");
1108
+ }
1109
+ function Vr(e) {
1110
+ return ((e == null ? void 0 : e.filterValues) ?? []).filter(nr).map(or);
1111
+ }
1112
+ function nr(e) {
1113
+ return !!e && typeof e == "object" && typeof e.name == "string" && Array.isArray(e.values);
1114
+ }
1115
+ function or(e) {
1116
+ if (!("relativeMeta" in e) || e.relativeMeta === void 0) return e;
1117
+ const { relativeMeta: t, ...r } = e, n = Q(t);
1118
+ return n ? { ...r, relativeMeta: n } : r;
1119
+ }
1120
+ const ar = /* @__PURE__ */ new Set([
1121
+ "day",
1122
+ "week",
1123
+ "month",
1124
+ "quarter",
1125
+ "year"
1126
+ ]);
1127
+ function sr(e, t) {
1128
+ try {
1129
+ const r = L(
1130
+ R(e),
1131
+ t,
1132
+ "yyyy-MM-dd"
1133
+ ), [n, o, l] = r.split("-").map(Number), s = new Date(Date.UTC(n, o - 1, l));
1134
+ return s.setUTCDate(s.getUTCDate() - 1), L(s, "UTC", "yyyy-MM-dd");
1135
+ } catch {
1136
+ return;
1137
+ }
1138
+ }
1139
+ function Ur(e, t, r, n = !1) {
1140
+ const o = ir(
1141
+ e,
1142
+ t,
1143
+ r,
1144
+ n
1145
+ );
1146
+ return `${o.start} - ${o.end}`;
1147
+ }
1148
+ function ir(e, t, r, n = !1) {
1149
+ try {
1150
+ if (r && ar.has(r)) {
1151
+ const o = sr(e.end, t);
1152
+ if (o) {
1153
+ const l = n ? "MMM d" : "MMM d, yyyy";
1154
+ return {
1155
+ start: L(
1156
+ R(e.start),
1157
+ t,
1158
+ l
1159
+ ),
1160
+ end: L(
1161
+ R(`${o}T00:00:00Z`),
1162
+ "UTC",
1163
+ "MMM d, yyyy"
1164
+ )
1165
+ };
1166
+ }
1167
+ }
1168
+ if (r === "second" || r === "minute" || r === "hour") {
1169
+ const o = n ? "MMM d, h:mm a" : "MMM d, yyyy, h:mm a";
1170
+ return {
1171
+ start: L(R(e.start), t, o),
1172
+ end: `before ${L(
1173
+ R(e.end),
1174
+ t,
1175
+ o
1176
+ )}`
1177
+ };
1178
+ }
1179
+ } catch {
1180
+ }
1181
+ return { start: e.start, end: `before ${e.end}` };
1182
+ }
1183
+ export {
1184
+ Ar as A,
1185
+ xe as B,
1186
+ tr as C,
1187
+ $e as D,
1188
+ Te as E,
1189
+ It as F,
1190
+ Kr as G,
1191
+ Vr as H,
1192
+ ir as I,
1193
+ Er as M,
1194
+ At as P,
1195
+ xr as a,
1196
+ Fr as b,
1197
+ Sr as c,
1198
+ kr as d,
1199
+ Tr as e,
1200
+ Ur as f,
1201
+ Mr as g,
1202
+ Lr as h,
1203
+ Pr as i,
1204
+ Ot as j,
1205
+ Dr as k,
1206
+ Ir as l,
1207
+ Nt as m,
1208
+ $r as n,
1209
+ $t as o,
1210
+ Rt as p,
1211
+ Pt as q,
1212
+ de as r,
1213
+ _t as s,
1214
+ U as t,
1215
+ Vt as u,
1216
+ Ut as v,
1217
+ _r as w,
1218
+ Rr as x,
1219
+ Nr as y,
1220
+ Or as z
1221
+ };