react-semaphor 0.1.599 → 0.1.601

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 (62) hide show
  1. package/dist/analytics-protocol/index.js +106 -105
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +7 -7
  4. package/dist/briefings/index.js +48 -45
  5. package/dist/chunks/{assistant-chat-f3XuzrAm.js → assistant-chat-BE0XXzZP.js} +12 -12
  6. package/dist/chunks/{bookmark-impact-B5hyttm2.js → bookmark-impact-DXDAN5AY.js} +3 -3
  7. package/dist/chunks/{bookmark-state-h1OLXVjE.js → bookmark-state-BMyB3Tb6.js} +4 -4
  8. package/dist/chunks/{card-filter-builder-DfLqD2RV.js → card-filter-builder-CE0-YVN5.js} +9 -9
  9. package/dist/chunks/comparison-window-caption-Dxj2CHOa.js +741 -0
  10. package/dist/chunks/{dashboard-briefing-launcher-RxYGtk-F.js → dashboard-briefing-launcher-CntwKyiZ.js} +13 -13
  11. package/dist/chunks/{dashboard-controls-DeaXrtLK.js → dashboard-controls-XO089DMg.js} +15 -15
  12. package/dist/chunks/{dashboard-json-DvxKpKd_.js → dashboard-json-CQRiydUv.js} +4 -4
  13. package/dist/chunks/{dashboard-CoI4aOUc.js → dashboard-mJKPFRbb.js} +1 -1
  14. package/dist/chunks/{dates-BhtO28Sn.js → dates-B-Urp5OD.js} +8 -8
  15. package/dist/chunks/{edit-dashboard-visual-C4f5hONA.js → edit-dashboard-visual-f-Dm-BLR.js} +176 -176
  16. package/dist/chunks/filter-line-CKNMyNTQ.js +703 -0
  17. package/dist/chunks/{filter-reach-copy-Cl5Od38Q.js → filter-reach-copy-B8GGyVuR.js} +1441 -1270
  18. package/dist/chunks/{filter-value-text-CXyuLW9Q.js → filter-value-text-CRtKecI5.js} +6 -6
  19. package/dist/chunks/{index-EKpTtkYF.js → index-DoPApnxg.js} +386 -360
  20. package/dist/chunks/{layout-grid-DSrBSfPM.js → layout-grid-CiSCZdIr.js} +1 -1
  21. package/dist/chunks/{matrix-analytical-definition-BuUSBDm7.js → matrix-analytical-definition-myf3D3Qx.js} +383 -362
  22. package/dist/chunks/{matrix-member-presentation-B_2beBc0.js → matrix-member-presentation-g0c_NpDW.js} +1 -1
  23. package/dist/chunks/{matrix-operation-contract-DdK0J_KU.js → matrix-operation-contract-C1SuOHLZ.js} +35 -35
  24. package/dist/chunks/{metric-comparison-Bhz0V841.js → metric-comparison-Cm0G893W.js} +3 -3
  25. package/dist/chunks/{paintbrush-1UiU-uTz.js → paintbrush-DQIwqlck.js} +1 -1
  26. package/dist/chunks/{palette-DFIFf_-m.js → palette-Cun747Rg.js} +1 -1
  27. package/dist/chunks/{pivot-result-contract-expectations-Dk7WFR_u.js → pivot-result-contract-expectations-C1Dyx8du.js} +17 -17
  28. package/dist/chunks/{pivot-result-identity-CzzrJpEm.js → pivot-result-identity-CBS-ssEp.js} +1 -1
  29. package/dist/chunks/{raw-temporal-value-BLvdaMng.js → raw-temporal-value-DN_l-Tss.js} +16 -16
  30. package/dist/chunks/{report-preferences-dialog-CZaYsQLK.js → report-preferences-dialog-SDZEcG2x.js} +13 -13
  31. package/dist/chunks/{report-runtime-context-CEGluufW.js → report-runtime-context-BbedQdtc.js} +1 -1
  32. package/dist/chunks/{resolve-dashboard-input-context-vPtbuDDz.js → resolve-dashboard-input-context-DRBS0eRa.js} +553 -553
  33. package/dist/chunks/{save-CWQ02kHo.js → save-Dj5bjm7P.js} +1 -1
  34. package/dist/chunks/{saved-dashboard-context-C6X5nP4C.js → saved-dashboard-context-DWVlJcsa.js} +15 -15
  35. package/dist/chunks/{selection-filter-compiler-Ce4BpjRX.js → selection-filter-compiler-DmAr7yqC.js} +1 -1
  36. package/dist/chunks/{semaphor-ready-indicator-BUiaKY6O.js → semaphor-ready-indicator-OFOoAY-A.js} +16370 -16518
  37. package/dist/chunks/{shelf-drop-preview-context-CwxWJjBv.js → shelf-drop-preview-context-2swWypXu.js} +5 -5
  38. package/dist/chunks/{stored-dashboard-Bmct-STp.js → stored-dashboard-NtOuEX6a.js} +111 -111
  39. package/dist/chunks/{style-sheet-parts-BX7d7-2-.js → style-sheet-parts-Qv4UcLAo.js} +2 -2
  40. package/dist/chunks/{table-export-sheet-BWSVTclx.js → table-export-sheet-Do7ZB0_F.js} +1 -1
  41. package/dist/chunks/{token-types-CnlEiAdS.js → token-types-Dy_aXO-U.js} +1 -1
  42. package/dist/chunks/{upload-DsqUSS8l.js → upload-Bq-puSVy.js} +1 -1
  43. package/dist/chunks/{validators-D2Hm57lJ.js → validators-C7DFk3QK.js} +78 -78
  44. package/dist/chunks/{variable-draft-Bi-zUa_a.js → variable-draft-Cy03qnEi.js} +4 -4
  45. package/dist/dashboard/index.js +2 -2
  46. package/dist/dashboard-authoring/index.js +80 -75
  47. package/dist/format-utils/index.js +238 -237
  48. package/dist/index.js +18 -18
  49. package/dist/report-runtime-context/index.js +1 -1
  50. package/dist/surfboard/index.js +2 -2
  51. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  52. package/dist/types/briefings/attachments.d.ts +45 -4
  53. package/dist/types/briefings/index.d.ts +1 -1
  54. package/dist/types/index.js +5 -5
  55. package/dist/types/lib/export-utils.d.ts +72 -0
  56. package/dist/types/lib/formatters/dashboard-temporal-presentation.d.ts +10 -0
  57. package/dist/types/shared/analytics-protocol/catalog-source-address.d.ts +16 -0
  58. package/dist/types/shared/dashboard-authoring/card-data-file.d.ts +31 -0
  59. package/dist/types/shared/dashboard-authoring/index.d.ts +3 -0
  60. package/package.json +1 -1
  61. package/dist/chunks/comparison-window-caption-DJDwP9XO.js +0 -1309
  62. package/dist/chunks/filter-line-Dkg3yuOX.js +0 -134
@@ -0,0 +1,703 @@
1
+ import { aX as H, aW as xt, j as Tt, k as G, aE as ft, r as Et } from "./validators-C7DFk3QK.js";
2
+ import { at as St, ay as $t, au as Ft, f as kt, a as K, a6 as J, am as It, a4 as Dt, an as Lt, ao as _t, o as Q, s as Nt, aF as At, Y as tt, _ as Mt, a0 as Kt, a7 as Ot } from "./pivot-result-contract-expectations-C1Dyx8du.js";
3
+ import { c as Rt, b as et } from "./pivot-result-identity-CBS-ssEp.js";
4
+ import { v as Vt, d as zt, c as Pt } from "./raw-temporal-value-DN_l-Tss.js";
5
+ import { e as jt, p as Bt, k as Ut } from "./export-file-format-C-tJsxsf.js";
6
+ import "./matrix-operation-contract-C1SuOHLZ.js";
7
+ import "./analytics-base-schemas-DevrgqQb.js";
8
+ import { a as U } from "./metric-comparison-Cm0G893W.js";
9
+ import "../value-format-preferences/index.js";
10
+ const Ht = /* @__PURE__ */ new Set(["second", "minute", "hour", "day", "month"]);
11
+ function Gt(t) {
12
+ const { presentation: e } = t;
13
+ return t.formattedValues ? (e == null ? void 0 : e.kind) === "text" || (e == null ? void 0 : e.kind) === "measure" && e.format.type === "duration" ? "text" : (e == null ? void 0 : e.kind) === "temporal_bucket" ? Ht.has(e.grain) ? "date" : "text" : (e == null ? void 0 : e.kind) === "datetime" ? "date" : t.dataType === "number" ? "number" : t.dataType === "boolean" ? "boolean" : t.dataType === "unknown" ? "by_value" : "text" : "by_value";
14
+ }
15
+ function Wt(t) {
16
+ const e = (i, d) => Number.isInteger(i) ? Math.min(20, Math.max(0, i)) : d, r = e(t.minimumFractionDigits, 0), o = Math.max(r, e(t.maximumFractionDigits, 2));
17
+ return o === 0 ? "" : `.${"0".repeat(o)}`;
18
+ }
19
+ function j(t) {
20
+ return `"${t.replace(/"/g, "")}"`;
21
+ }
22
+ function qt(t) {
23
+ let e;
24
+ try {
25
+ e = new Intl.NumberFormat(t.locale ?? "en-US", {
26
+ style: "currency",
27
+ currency: t.currency || "USD"
28
+ }).formatToParts(1);
29
+ } catch {
30
+ return;
31
+ }
32
+ const r = e.findIndex((d) => d.type === "currency"), o = e.findIndex((d) => d.type === "integer");
33
+ if (r < 0 || o < 0) return;
34
+ const i = (d, s) => e.slice(d, s).filter((c) => c.type === "literal").map((c) => c.value.replace(/\s/g, " ")).join("");
35
+ return r < o ? { side: "before", text: e[r].value + i(r + 1, o) } : {
36
+ side: "after",
37
+ text: i(o + 1, r) + e[r].value
38
+ };
39
+ }
40
+ function Yt(t) {
41
+ const e = Wt(t);
42
+ let r;
43
+ if (t.type === "scientific")
44
+ r = `0${e}E+00`;
45
+ else {
46
+ const o = `${t.useGrouping === !1 ? "0" : "#,##0"}${e}`;
47
+ if (t.type === "currency") {
48
+ const i = qt(t);
49
+ r = i ? i.side === "before" ? `${j(i.text)}${o}` : `${o}${j(i.text)}` : o;
50
+ } else t.type === "percent" ? r = t.percentValueMode === "whole" ? `${o}${j("%")}` : `${o}%` : r = o;
51
+ }
52
+ return t.negativeStyle === "parentheses" ? `${r};(${r})` : r;
53
+ }
54
+ function Xt(t, e) {
55
+ if (!t.formattedValues) return;
56
+ const { presentation: r } = t;
57
+ if (e === "number" || e === "by_value")
58
+ return (r == null ? void 0 : r.kind) !== "measure" || r.format.type === "duration" ? void 0 : Yt(r.format);
59
+ if (e === "date") {
60
+ if ((r == null ? void 0 : r.kind) === "temporal_bucket")
61
+ return r.grain === "day" ? "yyyy-mm-dd" : r.grain === "month" ? "mmm yyyy" : "yyyy-mm-dd hh:mm";
62
+ if ((r == null ? void 0 : r.kind) === "datetime")
63
+ return r.dateOnly ? "yyyy-mm-dd" : "yyyy-mm-dd hh:mm:ss";
64
+ }
65
+ }
66
+ function rt(t) {
67
+ const e = Gt(t), r = Xt(t, e);
68
+ return Object.freeze({
69
+ key: t.key,
70
+ label: t.label,
71
+ cellType: e,
72
+ ...r === void 0 ? {} : { numberFormat: r }
73
+ });
74
+ }
75
+ const Zt = 15, Jt = /^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
76
+ function pt(t) {
77
+ return Jt.test(t) ? t : void 0;
78
+ }
79
+ function nt(t) {
80
+ const r = t.replace(/^-/, "").replace(/[eE].*$/, "").replace(".", "").replace(/^0+/, "").replace(/0+$/, "");
81
+ if (r.length > Zt) return !1;
82
+ const o = Number(t);
83
+ return Number.isFinite(o) && (o !== 0 || r.length === 0);
84
+ }
85
+ const Qt = Date.UTC(1900, 2, 1), te = Date.UTC(1e4, 0, 1), ee = Date.UTC(1899, 11, 30), re = 864e5;
86
+ function ne(t) {
87
+ const e = Date.UTC(
88
+ t.year,
89
+ t.month - 1,
90
+ t.day,
91
+ t.hour,
92
+ t.minute,
93
+ t.second
94
+ );
95
+ if (!(t.year < 1900 || !Number.isFinite(e)) && !(e < Qt || e >= te))
96
+ return (e - ee) / re;
97
+ }
98
+ function ot(t, e, r) {
99
+ if (typeof t == "number")
100
+ return Number.isFinite(t) ? { kind: "number", text: e, value: t } : void 0;
101
+ if (H(t))
102
+ return nt(t.value) ? { kind: "number", text: e, value: t } : void 0;
103
+ if (r && typeof t == "string") {
104
+ const o = pt(t);
105
+ return o !== void 0 && nt(o) ? { kind: "number", text: e, value: o } : void 0;
106
+ }
107
+ }
108
+ function O(t) {
109
+ const { value: e, text: r, column: o } = t;
110
+ if (r === "") return { kind: "empty" };
111
+ const i = { kind: "text", text: r };
112
+ switch (o.cellType) {
113
+ case "text":
114
+ return i;
115
+ case "date": {
116
+ const d = t.wallClock ? ne(t.wallClock) : void 0;
117
+ return d === void 0 ? i : { kind: "date", text: r, serial: d };
118
+ }
119
+ case "number":
120
+ return ot(e, r, !0) ?? i;
121
+ case "boolean":
122
+ return typeof e == "boolean" ? { kind: "boolean", text: r, value: e } : i;
123
+ case "by_value":
124
+ return typeof e == "boolean" ? { kind: "boolean", text: r, value: e } : ot(e, r, !1) ?? i;
125
+ }
126
+ }
127
+ function ke(t) {
128
+ return t.kind === "empty" ? "" : t.text;
129
+ }
130
+ function oe(t, e) {
131
+ return t.dashboardId === e.dashboardId && t.cardId === e.cardId && t.attachmentIndex === void 0;
132
+ }
133
+ function bt(t) {
134
+ return new Map(
135
+ t.presentationExecutionSnapshot.resolvedFormats.flatMap(
136
+ (e) => e.format.type === "raw_temporal" && e.target.kind === "column" && oe(e.scope, t.scope) ? [[e.target.columnKey, e.format]] : []
137
+ )
138
+ );
139
+ }
140
+ function yt(t) {
141
+ const e = t == null ? void 0 : t.sql, r = t == null ? void 0 : t.python;
142
+ return (t == null ? void 0 : t.resultOwner) === "freeform" && typeof e == "string" && !!e.trim() && (typeof r != "string" || !r.trim());
143
+ }
144
+ function Ie(t) {
145
+ return t.formatting.useFormattedValues !== !1 && yt(t.queryPayload) && bt(t.formatting).size > 0;
146
+ }
147
+ function ae(t, e) {
148
+ return t.map((r, o) => {
149
+ if (!Object.prototype.hasOwnProperty.call(r, e) || r[e] === void 0)
150
+ throw new Error(
151
+ `missing_raw_temporal_result_contract: Row ${o} is missing declared temporal column "${e}".`
152
+ );
153
+ const i = r[e];
154
+ return i === null || typeof i == "string" ? i : String(i);
155
+ });
156
+ }
157
+ function ie(t) {
158
+ if (t.formatting.useFormattedValues === !1)
159
+ return {
160
+ activatedColumnKeys: /* @__PURE__ */ new Set(),
161
+ byColumnKey: /* @__PURE__ */ new Map()
162
+ };
163
+ const e = bt(t.formatting), r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
164
+ if (e.size === 0)
165
+ return { activatedColumnKeys: r, byColumnKey: o };
166
+ const i = new Map(
167
+ t.columns.flatMap((c) => {
168
+ const y = c.key || c.field;
169
+ return y ? [[y, c]] : [];
170
+ })
171
+ ), d = yt(t.queryPayload), s = /* @__PURE__ */ new Map();
172
+ for (const [c, y] of e) {
173
+ const C = i.get(c);
174
+ let w;
175
+ if (C != null && C.rawTemporal)
176
+ w = Vt(C, {
177
+ metadataRequired: !0
178
+ }), r.add(c);
179
+ else if (d) {
180
+ r.add(c);
181
+ const u = St({
182
+ columnKey: c,
183
+ values: ae(t.records, c)
184
+ });
185
+ s.set(c, u), u.status === "classified" && (w = u.metadata);
186
+ } else
187
+ continue;
188
+ w && o.set(c, {
189
+ metadata: w,
190
+ format: y,
191
+ formatValue: $t({ metadata: w, format: y })
192
+ });
193
+ }
194
+ return {
195
+ activatedColumnKeys: r,
196
+ byColumnKey: o,
197
+ ...d ? {
198
+ sqlChunkEvidence: Ft(s)
199
+ } : {}
200
+ };
201
+ }
202
+ function se(t) {
203
+ if (!t.resolution.activatedColumnKeys.has(t.columnKey))
204
+ return;
205
+ if (t.value === void 0)
206
+ throw new Error(
207
+ `missing_raw_temporal_result_contract: Row ${t.rowIndex} is missing temporal column "${t.columnKey}".`
208
+ );
209
+ const e = t.resolution.byColumnKey.get(t.columnKey);
210
+ if (!e)
211
+ return { text: t.value === null ? "" : String(t.value) };
212
+ if (t.value !== null && typeof t.value != "string")
213
+ return { text: String(t.value) };
214
+ const r = e.formatValue(t.value);
215
+ return r.ok && r.wallClock ? { text: r.text, wallClock: r.wallClock } : { text: r.text };
216
+ }
217
+ function at(t, e) {
218
+ const r = t.byColumnKey.get(e);
219
+ return r ? r.metadata.valueKind === "date" : void 0;
220
+ }
221
+ const ce = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime"]), le = /^\d{4}-\d{2}-\d{2}|^\d{2}\/\d{2}\/\d{4}/, me = /^\d{4}-\d{2}-\d{2}$/, gt = "MM/dd/yyyy";
222
+ function R(t) {
223
+ return typeof t == "object" && t !== null && !Array.isArray(t);
224
+ }
225
+ function A(t) {
226
+ return t.key || t.field || void 0;
227
+ }
228
+ function it(t) {
229
+ return t == null ? "" : typeof t == "string" ? t : H(t) ? t.value : t instanceof Date ? t.toISOString() : typeof t == "object" ? JSON.stringify(t) : String(t);
230
+ }
231
+ function st(t, e) {
232
+ var o;
233
+ const r = (o = t.columnSettings) == null ? void 0 : o[e];
234
+ if (!(!R(r) || r.type !== "date"))
235
+ return R(r.dateFormat) ? r.dateFormat : {};
236
+ }
237
+ function ct(t) {
238
+ return t.useCustomFormat && t.customFormat ? t.customFormat : t.format || gt;
239
+ }
240
+ function lt(t, e) {
241
+ return t && t !== "auto" ? t : e;
242
+ }
243
+ function de(t) {
244
+ return !/[HhKkmsSa]/.test(t.replace(/'[^']*'/g, ""));
245
+ }
246
+ function ue(t) {
247
+ if (typeof t == "number") return Number.isFinite(t) ? t : null;
248
+ if (typeof t != "string" || !t.trim()) return null;
249
+ const e = Number(t);
250
+ return Number.isFinite(e) ? e : null;
251
+ }
252
+ function fe(t) {
253
+ const e = pt(t);
254
+ if (e !== void 0)
255
+ try {
256
+ return xt(e, /[.eE]/.test(e) ? "decimal" : "integer");
257
+ } catch {
258
+ return;
259
+ }
260
+ }
261
+ function pe(t) {
262
+ return t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year") ? "fiscal" : t.granularity;
263
+ }
264
+ function De(t) {
265
+ const { formatting: e, queryPayload: r } = t, o = e.useFormattedValues, i = e.scope, d = (a) => kt({ snapshot: e.presentationExecutionSnapshot, scope: i, target: { kind: "column", columnKey: a } }), s = (a) => Dt({ snapshot: e.presentationExecutionSnapshot, scope: i, target: { kind: "column", columnKey: a } });
266
+ function c(a) {
267
+ var g;
268
+ if ((g = e.visibleColumns) != null && g.length) return e.visibleColumns;
269
+ const l = a.columns.map(A).filter((f) => !!f);
270
+ return l.length > 0 ? l : a.records[0] ? Object.keys(a.records[0]) : [];
271
+ }
272
+ function y(a, l) {
273
+ return e.columnLabels && Object.prototype.hasOwnProperty.call(e.columnLabels, a) && e.columnLabels[a] || void 0 || C(l) || (l == null ? void 0 : l.label) || (l == null ? void 0 : l.headerName) || a;
274
+ }
275
+ function C(a, l) {
276
+ const g = a == null ? void 0 : a.pivotIdentity;
277
+ if (!g || !g.members || g.members.length === 0) return;
278
+ const f = et({ identity: g, columnKey: (a == null ? void 0 : a.key) || (a == null ? void 0 : a.field) || "" });
279
+ return At({
280
+ members: f,
281
+ metricLabel: (a == null ? void 0 : a.label) || (a == null ? void 0 : a.headerName),
282
+ mode: o ? "formatted" : "canonical",
283
+ resolveTemporalFormat: (T) => {
284
+ const b = f.find((E) => E.fieldId === T);
285
+ if (!(b != null && b.temporalBucket)) return;
286
+ const x = J({
287
+ snapshot: e.presentationExecutionSnapshot,
288
+ scope: i,
289
+ target: { kind: "field", fieldId: T, role: "pivotby" }
290
+ });
291
+ return x ? w(b.temporalBucket, x) : void 0;
292
+ }
293
+ }).flattenedLabel;
294
+ }
295
+ function w(a, l) {
296
+ return It({
297
+ metadata: a,
298
+ cardFormat: l,
299
+ locale: l.locale,
300
+ ...l.presentation.mode === "auto" ? { styles: l.presentation.styles } : {}
301
+ }).format;
302
+ }
303
+ function u(a, l) {
304
+ const { records: g, columns: f } = a, T = R(r.cardConfig) ? r.cardConfig : void 0, b = T == null ? void 0 : T.pivotByColumns, x = Array.isArray(b) ? b.flatMap(
305
+ (n) => R(n) && typeof n.id == "string" && n.id ? [n.id] : []
306
+ ) : [];
307
+ Rt(
308
+ f.map((n) => ({ key: A(n) || "<unknown>", pivotIdentity: n.pivotIdentity })),
309
+ { expectedPivotFieldIds: x }
310
+ );
311
+ const E = c(a), k = new Map(
312
+ f.flatMap((n) => {
313
+ const m = A(n);
314
+ return m ? [[m, n]] : [];
315
+ })
316
+ ), ht = new Map(a.resultColumns.map((n) => [n.key, n.dataType])), I = ie({
317
+ records: g,
318
+ columns: f,
319
+ formatting: e,
320
+ queryPayload: r
321
+ }), V = new Map(
322
+ f.flatMap((n) => {
323
+ const m = A(n);
324
+ return m && n.temporalBucket ? [[m, n.temporalBucket]] : [];
325
+ })
326
+ ), q = /* @__PURE__ */ new Map();
327
+ for (const n of E) {
328
+ const m = J({
329
+ snapshot: e.presentationExecutionSnapshot,
330
+ scope: i,
331
+ target: { kind: "column", columnKey: n }
332
+ }), v = V.get(n);
333
+ if (o) {
334
+ if (m && !v) throw new Error(`Missing temporal bucket metadata for column "${n}"`);
335
+ if (v && !m) throw new Error(`Missing resolved temporal presentation for column "${n}"`);
336
+ }
337
+ m && v && q.set(n, w(v, m));
338
+ }
339
+ const z = E.map((n) => {
340
+ const m = ht.get(n), v = m && ce.has(m) ? m : "unknown", S = o ? p(n, I, V) : void 0, F = y(n, k.get(n)), L = o && I.activatedColumnKeys.has(n) && at(I, n) === void 0;
341
+ return {
342
+ key: n,
343
+ label: F,
344
+ dataType: v,
345
+ ...S ? { presentation: S } : {},
346
+ xlsx: rt({ key: n, label: F, formattedValues: o, dataType: v, presentation: S }),
347
+ ...L ? { xlsxPending: !0 } : {}
348
+ };
349
+ });
350
+ function vt(n, m, v, S) {
351
+ if (!o) return { text: it(n), value: n };
352
+ const F = se({ value: n, columnKey: m, rowIndex: v, resolution: I });
353
+ if (F !== void 0) return { text: F.text, value: n, ...F.wallClock ? { wallClock: F.wallClock } : {} };
354
+ const L = V.get(m);
355
+ if (L) {
356
+ const $ = q.get(m);
357
+ if (!$) throw new Error(`Missing resolved temporal presentation for column "${m}"`);
358
+ if (n != null && typeof n != "string")
359
+ throw new Error(`Canonical temporal column "${m}" must contain a string or null`);
360
+ const _ = n ?? null, N = Lt(_, L);
361
+ return {
362
+ text: _t({ value: _, metadata: L, format: $ }),
363
+ value: n,
364
+ ...N ? { wallClock: N } : {}
365
+ };
366
+ }
367
+ if (n == null) return { text: "", value: n };
368
+ const P = s(m);
369
+ if (P && typeof n == "number" && Number.isFinite(n))
370
+ return {
371
+ text: Q(
372
+ new Date(n).toISOString(),
373
+ P.pattern || gt,
374
+ lt(P.timezone, e.timezone),
375
+ "UTC"
376
+ ),
377
+ value: n
378
+ };
379
+ const D = d(m);
380
+ if (typeof n == "number")
381
+ return { text: D ? K(n, D) : String(n), value: n };
382
+ if (H(n))
383
+ return { text: D ? K(n, D) : n.value, value: n };
384
+ const M = st(e, m);
385
+ if (M && (n instanceof Date || typeof n == "string" && le.test(n))) {
386
+ const $ = n instanceof Date ? n.toISOString() : n, _ = typeof n == "string" && me.test(n), N = _ ? "UTC" : lt(M.timezone, e.timezone), X = _ ? "UTC" : M.sourceTimezone || "auto", Z = Nt($, N, X);
387
+ return {
388
+ text: Q($, ct(M), N, X),
389
+ value: n,
390
+ ...Z ? { wallClock: Z } : {}
391
+ };
392
+ }
393
+ if (typeof n == "string" && D && S.dataType === "number") {
394
+ const $ = fe(n);
395
+ if ($) return { text: K($, D), value: n };
396
+ }
397
+ return { text: it(n), value: n };
398
+ }
399
+ const Ct = g.map(
400
+ (n, m) => z.map((v) => {
401
+ const S = vt(n[v.key], v.key, m, v);
402
+ return O({ value: S.value, text: S.text, column: v.xlsx, wallClock: S.wallClock });
403
+ })
404
+ ), Y = (l == null ? void 0 : l.withHeader) !== !1 && e.includeHeaders;
405
+ if (Y)
406
+ for (const n of E) {
407
+ const m = k.get(n);
408
+ m != null && m.pivotIdentity && et({ identity: m.pivotIdentity, columnKey: A(m) || n });
409
+ }
410
+ return {
411
+ ...Y ? { header: z.map((n) => n.label) } : {},
412
+ columns: z,
413
+ rows: Ct,
414
+ ...I.sqlChunkEvidence ? { rawTemporalClassification: I.sqlChunkEvidence } : {}
415
+ };
416
+ }
417
+ function p(a, l, g) {
418
+ if (l.activatedColumnKeys.has(a)) {
419
+ const x = at(l, a);
420
+ return x === void 0 ? { kind: "text" } : { kind: "datetime", dateOnly: x };
421
+ }
422
+ const f = g.get(a);
423
+ if (f) return { kind: "temporal_bucket", grain: pe(f) };
424
+ if (s(a)) return { kind: "text" };
425
+ const T = st(e, a);
426
+ if (T) return { kind: "datetime", dateOnly: de(ct(T)) };
427
+ const b = d(a);
428
+ return b ? { kind: "measure", format: b } : void 0;
429
+ }
430
+ function h(a, l) {
431
+ if (!Number.isInteger(l) || l < 0)
432
+ throw new Error("totalRows must be a non-negative integer");
433
+ return l === 0 ? void 0 : (e.visibleColumns ?? Object.keys(a)).map((f) => {
434
+ const b = Object.prototype.hasOwnProperty.call(a, f) ? a[f] : f === e.tableTotalsLabelColumnKey ? "Total" : null, x = o ? d(f) : void 0, E = rt({
435
+ key: f,
436
+ label: f,
437
+ formattedValues: o,
438
+ dataType: "unknown",
439
+ ...x ? { presentation: { kind: "measure", format: x } } : {}
440
+ });
441
+ if (b == null) return { kind: "empty" };
442
+ if (!o) return O({ value: b, text: String(b), column: E });
443
+ const k = x ? ue(b) : null;
444
+ return O(x && k !== null ? { value: k, text: K(k, x), column: E } : { value: b, text: String(b), column: E });
445
+ });
446
+ }
447
+ return { format: u, totals: h };
448
+ }
449
+ const be = /* @__PURE__ */ new Set([
450
+ "scope",
451
+ "useFormattedValues",
452
+ "timezone",
453
+ "presentationExecutionSnapshot",
454
+ "delimiter",
455
+ "csvEncoding",
456
+ "includeHeaders",
457
+ "columnSettings",
458
+ "visibleColumns",
459
+ "columnLabels",
460
+ "tableTotalsLabelColumnKey",
461
+ "fileFormat",
462
+ "title"
463
+ ]);
464
+ function W(t) {
465
+ return t !== null && typeof t == "object" && !Array.isArray(t);
466
+ }
467
+ function mt(t, e) {
468
+ if (t !== void 0) {
469
+ if (!W(t))
470
+ throw new Error(`formatting.${e} must be an object`);
471
+ return t;
472
+ }
473
+ }
474
+ function Le(t) {
475
+ if (!W(t))
476
+ throw new Error("formatting must be an object");
477
+ const e = ["reportContext", "resolvedFormats"].find(
478
+ (a) => Object.prototype.hasOwnProperty.call(t, a)
479
+ );
480
+ if (e)
481
+ throw new tt(
482
+ `formatting.${e} is retired; formatting.presentationExecutionSnapshot is authoritative.`
483
+ );
484
+ const r = Object.keys(t).find((a) => !be.has(a));
485
+ if (r)
486
+ throw new Error(`formatting contains unknown property "${r}"`);
487
+ const o = typeof t.timezone == "string" ? t.timezone.trim() : "";
488
+ if (!o)
489
+ throw new Error("formatting.timezone must be a non-empty string");
490
+ const i = jt(t.delimiter);
491
+ if (!i)
492
+ throw new Error("formatting.delimiter must be a comma, semicolon or tab");
493
+ const d = Bt(t.csvEncoding);
494
+ if (!d)
495
+ throw new Error("formatting.csvEncoding must be 'utf-8-bom' or 'utf-8'");
496
+ if (typeof t.includeHeaders != "boolean")
497
+ throw new Error("formatting.includeHeaders must be a boolean");
498
+ if (t.useFormattedValues !== void 0 && typeof t.useFormattedValues != "boolean")
499
+ throw new Error("formatting.useFormattedValues must be a boolean");
500
+ const s = t.fileFormat === void 0 ? void 0 : Ut(t.fileFormat);
501
+ if (t.fileFormat !== void 0 && !s)
502
+ throw new Error("formatting.fileFormat must be 'csv' or 'xlsx'");
503
+ if (t.title !== void 0 && typeof t.title != "string")
504
+ throw new Error("formatting.title must be a string");
505
+ const c = t.visibleColumns === void 0 ? void 0 : Array.isArray(t.visibleColumns) && t.visibleColumns.every((a) => typeof a == "string") ? t.visibleColumns : void 0;
506
+ if (t.visibleColumns !== void 0 && !c)
507
+ throw new Error("formatting.visibleColumns must be an array of strings");
508
+ const y = mt(t.columnLabels, "columnLabels");
509
+ if (y && Object.values(y).some((a) => typeof a != "string"))
510
+ throw new Error("formatting.columnLabels values must be strings");
511
+ const C = mt(t.columnSettings, "columnSettings"), w = t.tableTotalsLabelColumnKey === void 0 ? void 0 : typeof t.tableTotalsLabelColumnKey == "string" && t.tableTotalsLabelColumnKey.trim() ? t.tableTotalsLabelColumnKey : null;
512
+ if (w === null)
513
+ throw new Error("formatting.tableTotalsLabelColumnKey must be a non-empty string");
514
+ if (w && !(c != null && c.includes(w)))
515
+ throw new Error("formatting.tableTotalsLabelColumnKey must identify a visible column");
516
+ const u = Mt(t.scope, "formatting.scope");
517
+ if (!u.cardId || u.attachmentIndex !== void 0)
518
+ throw new Error("formatting.scope must identify exactly one dashboard card");
519
+ const p = t.useFormattedValues !== !1, h = Kt(t.presentationExecutionSnapshot);
520
+ if (o !== h.reportContext.calendar.tz)
521
+ throw new Error(
522
+ "formatting.timezone must equal presentationExecutionSnapshot.reportContext.calendar.tz"
523
+ );
524
+ try {
525
+ Ot({
526
+ snapshot: h,
527
+ expectedScope: { dashboardId: u.dashboardId, cardId: u.cardId },
528
+ visibleColumns: c,
529
+ useFormattedValues: p
530
+ });
531
+ } catch (a) {
532
+ throw new tt(
533
+ `formatting.presentationExecutionSnapshot.${a instanceof Error ? a.message : String(a)}`
534
+ );
535
+ }
536
+ return {
537
+ scope: { dashboardId: u.dashboardId, cardId: u.cardId },
538
+ useFormattedValues: p,
539
+ timezone: o,
540
+ presentationExecutionSnapshot: h,
541
+ delimiter: i,
542
+ csvEncoding: d,
543
+ includeHeaders: t.includeHeaders,
544
+ ...C ? { columnSettings: C } : {},
545
+ ...c ? { visibleColumns: c } : {},
546
+ ...y ? { columnLabels: y } : {},
547
+ ...w ? { tableTotalsLabelColumnKey: w } : {},
548
+ ...s ? { fileFormat: s } : {},
549
+ ...typeof t.title == "string" ? { title: t.title } : {}
550
+ };
551
+ }
552
+ function _e(t) {
553
+ const e = t.formatOptions, r = (o) => W(o) ? o : void 0;
554
+ return {
555
+ scope: { dashboardId: t.dashboardId, cardId: t.cardId },
556
+ useFormattedValues: e.useFormattedValues !== !1,
557
+ timezone: e.presentationExecutionSnapshot.reportContext.calendar.tz,
558
+ presentationExecutionSnapshot: e.presentationExecutionSnapshot,
559
+ delimiter: typeof e.delimiter == "string" ? e.delimiter : ",",
560
+ csvEncoding: e.csvEncoding,
561
+ includeHeaders: e.includeHeaders !== !1,
562
+ columnSettings: r(e.columnSettings),
563
+ visibleColumns: Array.isArray(e.visibleColumns) ? e.visibleColumns : void 0,
564
+ columnLabels: r(e.columnLabels),
565
+ tableTotalsLabelColumnKey: typeof e.tableTotalsLabelColumnKey == "string" ? e.tableTotalsLabelColumnKey : void 0,
566
+ ...t.fileFormat ? { fileFormat: t.fileFormat } : {},
567
+ ...typeof t.title == "string" ? { title: t.title } : {}
568
+ };
569
+ }
570
+ const ye = /^\d{4}-\d{2}-\d{2}$/;
571
+ function wt(t) {
572
+ const e = t.split(".");
573
+ return e[e.length - 1].replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").map((i) => i.charAt(0).toUpperCase() + i.slice(1).toLowerCase()).join(" ");
574
+ }
575
+ const dt = 10;
576
+ function B(t, e) {
577
+ const r = t.slice(0, dt).map(e).join(", "), o = t.length - dt;
578
+ return o > 0 ? `${r}, and ${o} more` : r;
579
+ }
580
+ function ge(t) {
581
+ if (t.valueType !== "date") return;
582
+ const e = G(t.relativeMeta);
583
+ return e && ft(t.operation, e) && U(e).printsByName ? e : void 0;
584
+ }
585
+ function we(t, e) {
586
+ if (e !== "label") return ge(t);
587
+ if (t.valueType !== "date") return;
588
+ const r = G(t.relativeMeta);
589
+ return r && ft(t.operation, r) ? r : void 0;
590
+ }
591
+ function ut(t, e = {}) {
592
+ const { name: r, operation: o, values: i, valueType: d } = t, s = e.label ?? wt(r), c = we(t, e.relativeDates);
593
+ if (c) {
594
+ const p = zt(o, c);
595
+ if (p) return `${s}: ${p}`;
596
+ const h = Tt(c).label;
597
+ if (h)
598
+ return o === "between" ? `${s}: ${h}` : `${s} not in ${h}`;
599
+ }
600
+ if (!i || i.length === 0)
601
+ return o === "is null" ? `${s} is empty` : o === "is not null" ? `${s} is not empty` : "";
602
+ const y = G(t.relativeMeta ?? t.materializedRelativeDate), C = y ? Et(o) : void 0, w = t.temporalPrecision === "minute" || !!(y && (C ? U(y).bounds[C] === "instant" : U(y).subDay)), u = (p) => {
603
+ if (d === "date" && p) {
604
+ const h = {
605
+ year: "numeric",
606
+ month: "short",
607
+ day: "numeric",
608
+ ...w ? {
609
+ hour: "numeric",
610
+ minute: "2-digit"
611
+ } : {}
612
+ };
613
+ if (typeof p == "string" && ye.test(p)) {
614
+ const [l, g, f] = p.split("-").map(Number);
615
+ return new Intl.DateTimeFormat(void 0, {
616
+ year: "numeric",
617
+ month: "short",
618
+ day: "numeric",
619
+ timeZone: "UTC"
620
+ }).format(new Date(Date.UTC(l, g - 1, f)));
621
+ }
622
+ if (typeof p == "string" && Pt(p) === "wall_datetime") {
623
+ const [l, g, f, T, b] = p.split(/[-T :.]/).map(Number);
624
+ return new Intl.DateTimeFormat(void 0, {
625
+ ...h,
626
+ timeZone: "UTC"
627
+ }).format(new Date(Date.UTC(l, g - 1, f, T, b)));
628
+ }
629
+ const a = new Date(p);
630
+ if (!isNaN(a.getTime()))
631
+ try {
632
+ return new Intl.DateTimeFormat(void 0, {
633
+ ...h,
634
+ ...e.timezone ? { timeZone: e.timezone } : {}
635
+ }).format(a);
636
+ } catch {
637
+ return w ? a.toLocaleString(void 0, h) : a.toLocaleDateString(void 0, h);
638
+ }
639
+ }
640
+ return String(p);
641
+ };
642
+ switch (o) {
643
+ case "=":
644
+ return `${s}: ${u(i[0])}`;
645
+ case "!=":
646
+ return `${s} ≠ ${u(i[0])}`;
647
+ case ">":
648
+ return `${s} > ${u(i[0])}`;
649
+ case "<":
650
+ return `${s} < ${u(i[0])}`;
651
+ case ">=":
652
+ return `${s} ≥ ${u(i[0])}`;
653
+ case "<=":
654
+ return `${s} ≤ ${u(i[0])}`;
655
+ case "between":
656
+ case "not between": {
657
+ const p = `${u(i[0])} - ${u(i[1])}`;
658
+ return o === "between" ? `${s}: ${p}` : `${s} not in ${p}`;
659
+ }
660
+ case "in":
661
+ return i.length === 1 ? `${s}: ${u(i[0])}` : `${s}: ${B(i, u)}`;
662
+ case "not in":
663
+ return `${s} not in (${B(i, u)})`;
664
+ case "like":
665
+ return `${s} contains "${i[0]}"`;
666
+ case "not like":
667
+ return `${s} doesn't contain "${i[0]}"`;
668
+ default:
669
+ return `${s}: ${B(i, u)}`;
670
+ }
671
+ }
672
+ function Ne(t, e = {}) {
673
+ if (!t || t.length === 0)
674
+ return "";
675
+ const r = /* @__PURE__ */ new Map();
676
+ t.forEach((i) => {
677
+ const d = r.get(i.name) || [];
678
+ d.push(i), r.set(i.name, d);
679
+ });
680
+ const o = [];
681
+ return r.forEach((i, d) => {
682
+ if (i.length === 1) {
683
+ const s = ut(i[0], e);
684
+ s && o.push(s);
685
+ } else {
686
+ const s = wt(d), c = i.map((y) => ut(y, e).replace(`${s}: `, "").replace(`${s} `, "")).filter(Boolean);
687
+ c.length > 0 && o.push(`${s}: ${c.join(" and ")}`);
688
+ }
689
+ }), o.join(" | ");
690
+ }
691
+ export {
692
+ dt as F,
693
+ Le as a,
694
+ _e as b,
695
+ Ie as c,
696
+ ge as d,
697
+ ke as e,
698
+ ut as f,
699
+ Ne as g,
700
+ De as p,
701
+ rt as r,
702
+ O as t
703
+ };