react-semaphor 0.1.540 → 0.1.542

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 (118) hide show
  1. package/dist/analytics-protocol/index.js +75 -75
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +3 -3
  4. package/dist/briefings/index.js +50 -45
  5. package/dist/chunks/apply-dashboard-operations-Btbp2-6v.js +2260 -0
  6. package/dist/chunks/{assistant-chat-ya7xopaC.js → assistant-chat-oHF5lTjA.js} +12 -12
  7. package/dist/chunks/bookmark-state-CXw7lZ50.js +118 -0
  8. package/dist/chunks/{calendar-day-equality-Bpl15IBo.js → calendar-day-equality-BmJAWduY.js} +180 -207
  9. package/dist/chunks/comparison-window-caption-ChIyd_-L.js +1618 -0
  10. package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +323 -0
  11. package/dist/chunks/{dashboard-briefing-launcher-DJI-zfEq.js → dashboard-briefing-launcher-B-cm719R.js} +18 -18
  12. package/dist/chunks/{dashboard-controls-Dh7HqoKy.js → dashboard-controls-CIn22Qgp.js} +69 -70
  13. package/dist/chunks/{dashboard-filter-value-compatibility-D95O4nd7.js → dashboard-filter-value-compatibility-CwQ_iSNb.js} +2 -2
  14. package/dist/chunks/{dashboard-json-BnmlB71h.js → dashboard-json-ZUYsIExq.js} +4 -4
  15. package/dist/chunks/{dashboard-B6Bithfl.js → dashboard-s5WJBcK8.js} +1 -1
  16. package/dist/chunks/{document-dashboard-inputs-BrYYlRVo.js → document-dashboard-inputs-C6MJVyoI.js} +2357 -4948
  17. package/dist/chunks/document-sheet-utils-BsZUnHRl.js +3619 -0
  18. package/dist/chunks/{edit-dashboard-visual-CydOkSko.js → edit-dashboard-visual-DLdereA7.js} +728 -728
  19. package/dist/chunks/{filter-value-text-BhWugPWE.js → filter-value-text-CYsVYPuD.js} +18 -19
  20. package/dist/chunks/index-CV5rHq5D.js +2673 -0
  21. package/dist/chunks/{matrix-analytical-definition-bcprSe4u.js → matrix-analytical-definition-C7Gb0e12.js} +1 -1
  22. package/dist/chunks/{matrix-card-CJn1hB5V.js → matrix-card-DjwWcCo8.js} +2 -2
  23. package/dist/chunks/{matrix-formatter-DQ8avoIQ.js → matrix-formatter-BnsTX90d.js} +430 -417
  24. package/dist/chunks/{matrix-member-presentation-BNPSDKBG.js → matrix-member-presentation-CQGdVks6.js} +1 -1
  25. package/dist/chunks/{matrix-operation-contract-B8PBF1Gd.js → matrix-operation-contract-8OIO4gob.js} +65 -65
  26. package/dist/chunks/metric-comparison-DEwi9uc2.js +498 -0
  27. package/dist/chunks/numeric-presentation-BSAqPpHt.js +5227 -0
  28. package/dist/chunks/{pivot-header-presentation-MkcKnjn3.js → pivot-header-presentation-DHcx1XGQ.js} +1 -1
  29. package/dist/chunks/{pivot-result-identity-D6hhcRXi.js → pivot-result-identity-DJhXXcns.js} +1 -1
  30. package/dist/chunks/pivot-result-lifecycle-BBlAfBA0.js +1155 -0
  31. package/dist/chunks/raw-temporal-presentation-CZ2r0Vb_.js +585 -0
  32. package/dist/chunks/{report-preferences-dialog-neMDolLg.js → report-preferences-dialog-MRUWpMcJ.js} +75 -75
  33. package/dist/chunks/{report-runtime-context-B984Nq1E.js → report-runtime-context-Dq8XyODK.js} +1 -1
  34. package/dist/chunks/{saved-dashboard-context-CCrLpfSQ.js → saved-dashboard-context-DjPqgFly.js} +233 -206
  35. package/dist/chunks/{selection-reducer-vKIb_jS6.js → selection-reducer-Dj_8xD69.js} +1 -1
  36. package/dist/chunks/{semaphor-ready-indicator--4DWtVBu.js → semaphor-ready-indicator-BWSpRsPj.js} +38555 -40449
  37. package/dist/chunks/{shelf-drop-preview-context-CpdB5ois.js → shelf-drop-preview-context-CQbFLm3q.js} +6 -6
  38. package/dist/chunks/sort-target-MT1WK1vX.js +29 -0
  39. package/dist/chunks/{source-entity-resolution-CVA1a85c.js → source-entity-resolution-BYn9giz3.js} +1 -1
  40. package/dist/chunks/{switch-DWEWiv1J.js → switch-C3jLxlG0.js} +2 -2
  41. package/dist/chunks/table-export-sheet-BHSnuZHd.js +949 -0
  42. package/dist/chunks/table-settings-CLZocegs.js +501 -0
  43. package/dist/chunks/temporal-bucket-D7NBrrtL.js +2071 -0
  44. package/dist/chunks/{token-types-bxUxXDX2.js → token-types-DBbZVQsm.js} +1 -1
  45. package/dist/chunks/{use-create-flow-overlay-state-8g6Zhphh.js → use-create-flow-overlay-state-BJDNqdOh.js} +151 -151
  46. package/dist/chunks/{validators-Ej1DdCXa.js → validators-DMHTpf7a.js} +73 -73
  47. package/dist/dashboard/index.js +2 -2
  48. package/dist/dashboard-authoring/index.js +399 -380
  49. package/dist/data-app-sdk/index.js +5 -5
  50. package/dist/data-app-sdk-adapters/index.js +2 -2
  51. package/dist/data-app-sdk-validation/index.js +9 -9
  52. package/dist/format-utils/index.js +346 -238
  53. package/dist/index.js +174 -175
  54. package/dist/pdf-export-policy/index.js +20 -10
  55. package/dist/report-runtime-context/index.js +1 -1
  56. package/dist/surfboard/index.js +2 -2
  57. package/dist/types/briefings/attachment-outcomes.d.ts +23 -0
  58. package/dist/types/briefings/attachments.d.ts +17 -1
  59. package/dist/types/briefings/index.d.ts +6 -3
  60. package/dist/types/index.js +48 -48
  61. package/dist/types/lib/api/exports-api.d.ts +11 -65
  62. package/dist/types/lib/dashboard-inputs/control-contract-overrides.d.ts +17 -0
  63. package/dist/types/lib/dashboard-viewer/export-table-view.d.ts +2 -0
  64. package/dist/types/lib/hooks/use-dashboard-card.d.ts +2 -0
  65. package/dist/types/lib/hooks/use-dashboard.d.ts +3 -6
  66. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +8 -2
  67. package/dist/types/lib/matrix-table/matrix-delivery.d.ts +8 -6
  68. package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +50 -0
  69. package/dist/types/lib/query-context/card-server-request.d.ts +5 -1
  70. package/dist/types/lib/types/common-types.d.ts +7 -0
  71. package/dist/types/lib/types/explorer-types.d.ts +8 -2
  72. package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +3 -3
  73. package/dist/types/shared/assistant-context/index.d.ts +1 -1
  74. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +23 -6
  75. package/dist/types/shared/dashboard-authoring/card-export-request.d.ts +173 -0
  76. package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +20 -0
  77. package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
  78. package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +4 -3
  79. package/dist/types/shared/format-utils/attachment-filter-line.d.ts +14 -0
  80. package/dist/types/shared/format-utils/exporters/export-cells.d.ts +90 -0
  81. package/dist/types/shared/format-utils/exporters/export-file-format.d.ts +44 -0
  82. package/dist/types/shared/format-utils/exporters/index.d.ts +6 -0
  83. package/dist/types/shared/format-utils/exporters/xlsx-file.d.ts +90 -0
  84. package/dist/types/shared/format-utils/filter-line.d.ts +7 -0
  85. package/dist/types/shared/format-utils/formatters/date-formatter.d.ts +8 -12
  86. package/dist/types/shared/format-utils/formatters/index.d.ts +1 -1
  87. package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +2 -0
  88. package/dist/types/shared/format-utils/index.d.ts +3 -0
  89. package/dist/types/shared/format-utils/matrix-continuation.d.ts +55 -9
  90. package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +21 -1
  91. package/dist/types/shared/format-utils/matrix-export-xlsx.d.ts +27 -0
  92. package/dist/types/shared/format-utils/pdf-export-policy.d.ts +9 -0
  93. package/dist/types/shared/format-utils/presentation-execution.d.ts +27 -2
  94. package/dist/types/shared/format-utils/raw-temporal.d.ts +8 -0
  95. package/dist/types/shared/format-utils/table-export/index.d.ts +8 -0
  96. package/dist/types/shared/format-utils/table-export/prepare-table-export.d.ts +50 -0
  97. package/dist/types/shared/format-utils/table-export/table-export-formatting.d.ts +47 -0
  98. package/dist/types/shared/format-utils/table-export/table-export-raw-temporal.d.ts +40 -0
  99. package/dist/types/shared/format-utils/table-export/table-export-result.d.ts +31 -0
  100. package/dist/types/shared/format-utils/table-export/table-export-sheet.d.ts +38 -0
  101. package/dist/types/shared/format-utils/temporal-bucket.d.ts +9 -0
  102. package/package.json +2 -1
  103. package/dist/chunks/aggregate-table-row-presentation-BjK9YfMI.js +0 -979
  104. package/dist/chunks/apply-dashboard-operations-C-iahGka.js +0 -402
  105. package/dist/chunks/bookmark-state-k7y5SNGf.js +0 -331
  106. package/dist/chunks/calculated-field-identity-DcBS2NPP.js +0 -2161
  107. package/dist/chunks/canonical-result-keys-CEQefvdO.js +0 -33
  108. package/dist/chunks/common-types-CUf03Htv.js +0 -288
  109. package/dist/chunks/csv-utils-GUfKyT1J.js +0 -56
  110. package/dist/chunks/custom-visual-inputs-BrUOIwln.js +0 -3288
  111. package/dist/chunks/document-sheet-utils-C1eEldxs.js +0 -1076
  112. package/dist/chunks/index-CqMiAkay.js +0 -3164
  113. package/dist/chunks/matrix-definition-DQDI2okF.js +0 -206
  114. package/dist/chunks/metric-comparison-CojWeLqx.js +0 -392
  115. package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +0 -804
  116. package/dist/chunks/raw-temporal-D61lr48Y.js +0 -1464
  117. package/dist/chunks/temporal-bucket-D8JF7zKz.js +0 -575
  118. package/dist/chunks/temporal-bucket-contract-DaOajRC7.js +0 -108
@@ -1,979 +0,0 @@
1
- var ae = Object.defineProperty;
2
- var ne = (e, t, o) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var N = (e, t, o) => ne(e, typeof t != "symbol" ? t + "" : t, o);
4
- import { i as se, g as S, k as le, B as R, q as ie, A as ue, y as ce, s as me } from "./raw-temporal-D61lr48Y.js";
5
- import { h as G, m as _, i as j, j as de, k as X, l as b } from "./matrix-formatter-DQ8avoIQ.js";
6
- import { h as E } from "./csv-utils-GUfKyT1J.js";
7
- import { l as fe, aD as Z, w as M, A as ge, z as he } from "./validators-Ej1DdCXa.js";
8
- import "./matrix-operation-contract-B8PBF1Gd.js";
9
- import "./analytics-base-schemas-BFAoRlkU.js";
10
- import "zod";
11
- import { g as W, p as v } from "./matrix-definition-DQDI2okF.js";
12
- import { PDF_SAFETY_LIMIT_EXCEEDED as K, getUtf8ByteLength as ye, FAST_PDF_POLICY as pe } from "../pdf-export-policy/index.js";
13
- import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as we } from "../value-format-preferences/index.js";
14
- import { f as be, c as Te, g as ve } from "./temporal-bucket-D8JF7zKz.js";
15
- import { z as Se, g as Le } from "./zoned-wall-clock-MulfA26h.js";
16
- function Ce(e, t, o) {
17
- const a = {
18
- ...t,
19
- locale: t.locale ?? o
20
- };
21
- if (a.type === "number")
22
- return S(e, a);
23
- const { prefix: r, suffix: s, ...n } = a;
24
- return `${r ?? ""}${S(e, {
25
- ...n,
26
- negativeStyle: a.type === "currency" ? a.negativeStyle : "minus"
27
- })}${s ?? ""}`;
28
- }
29
- function P(e, t, o) {
30
- return e === null ? { value: e, text: null } : !t || !se(t) && t.type !== "duration" ? {
31
- value: e,
32
- text: S(e, { type: "number", locale: o })
33
- } : t.type === "duration" ? {
34
- value: e,
35
- text: le(e, {
36
- inputUnit: t.inputUnit,
37
- outputStyle: t.outputStyle,
38
- largestUnit: t.largestUnit,
39
- smallestUnit: t.smallestUnit,
40
- maxUnits: t.maxUnits,
41
- prefix: t.prefix,
42
- suffix: t.suffix,
43
- negativeInParentheses: t.negativeStyle === "parentheses"
44
- })
45
- } : { value: e, text: Ce(e, t, o) };
46
- }
47
- function U(e, t, o, a) {
48
- return e === null ? { value: e, text: null } : a === "percent" ? {
49
- value: e,
50
- text: S(e, {
51
- type: "percent",
52
- locale: o,
53
- minimumFractionDigits: t,
54
- maximumFractionDigits: t,
55
- percentValueMode: "fraction"
56
- })
57
- } : {
58
- value: e,
59
- text: S(e, {
60
- type: "number",
61
- locale: o,
62
- minimumFractionDigits: t,
63
- maximumFractionDigits: t,
64
- suffix: "×"
65
- })
66
- };
67
- }
68
- function V(e, t) {
69
- if (e === void 0) return t;
70
- if (!Number.isInteger(e) || e < 0 || e > 6)
71
- throw new RangeError("Comparison precision must be an integer from 0 to 6.");
72
- return e;
73
- }
74
- function Tt(e, t) {
75
- const o = {
76
- mode: t.displayMode,
77
- current: P(
78
- e.currentValue,
79
- t.metricFormat,
80
- t.locale
81
- ),
82
- comparison: P(
83
- e.comparisonValue,
84
- t.metricFormat,
85
- t.locale
86
- )
87
- };
88
- return (t.displayMode === "difference" || t.displayMode === "both") && (o.difference = P(
89
- e.delta,
90
- t.metricFormat,
91
- t.locale
92
- )), (t.displayMode === "percent_change" || t.displayMode === "both") && (o.percentChange = U(
93
- e.percentChange,
94
- V(t.precision, 1),
95
- t.locale,
96
- "percent"
97
- )), t.displayMode === "ratio" && (o.ratio = U(
98
- e.ratio,
99
- V(t.precision, 2),
100
- t.locale,
101
- "ratio"
102
- )), o;
103
- }
104
- const ke = 1e4, vt = 1e6, St = 5e6, Lt = 1024 ** 3, Ct = 1024 ** 3;
105
- function kt(e) {
106
- return e > ke;
107
- }
108
- const At = {
109
- rowLabels: "tabular",
110
- subtotals: "after"
111
- };
112
- function Mt(e, t) {
113
- const o = t.rowLabels === "outline" ? { kind: "compact" } : e.layout.kind === "tabular" ? e.layout : { kind: "tabular", repeatLabels: !1 }, a = e.totals.rows;
114
- return {
115
- ...e,
116
- layout: o,
117
- totals: {
118
- ...e.totals,
119
- rows: {
120
- ...a,
121
- levels: Object.fromEntries(
122
- Object.entries(a.levels).map(([r, s]) => [
123
- r,
124
- { ...s, position: t.subtotals }
125
- ])
126
- )
127
- }
128
- }
129
- };
130
- }
131
- const Ae = 2;
132
- function Me(e) {
133
- return typeof e == "number" ? Number.isInteger(e) : Z(e) ? !e.value.includes(".") : !0;
134
- }
135
- function $e(e, t, o) {
136
- const a = e.descriptors.measures.filter(
137
- (n) => o.measureFormats[n.id] === void 0 && n.semanticFormat === void 0 && fe(n.column.dataType) === "number"
138
- );
139
- if (a.length === 0) return o;
140
- const r = /* @__PURE__ */ new Set();
141
- e.columns.forEach((n, l) => {
142
- if (!(n.kind !== "measure" || r.has(n.measureId)))
143
- for (const c of t) {
144
- const i = c.values[l];
145
- if ((i == null ? void 0 : i.kind) === "value" && !Me(i.value)) {
146
- r.add(n.measureId);
147
- return;
148
- }
149
- }
150
- });
151
- const s = { ...o.measureFormats };
152
- for (const { id: n } of a) {
153
- const l = r.has(n) ? Ae : 0;
154
- s[n] = {
155
- type: "number",
156
- minimumFractionDigits: l,
157
- maximumFractionDigits: l,
158
- useGrouping: !0
159
- };
160
- }
161
- return { ...o, measureFormats: s };
162
- }
163
- function k(e) {
164
- return M(e.slice(0, -1));
165
- }
166
- function Ee(e, t) {
167
- return t.length > e.length && M(t.slice(0, e.length)) === M(e);
168
- }
169
- function Pe(e) {
170
- return e.map((t, o) => {
171
- if (o === 0 || t.kind !== "layout") return !1;
172
- const a = e[o - 1];
173
- if (a.kind !== "layout") return !1;
174
- if (t.role !== "member" || Ee(a.rowPath, t.rowPath)) return !0;
175
- const r = e[o - 2];
176
- return a.role === "member" && (!r || r.kind !== "layout" || r.role !== "member" || k(r.rowPath) !== k(a.rowPath)) && t.rowPath.length === a.rowPath.length && k(t.rowPath) === k(a.rowPath);
177
- });
178
- }
179
- const xe = "pdf-group-continuation";
180
- function _e(e) {
181
- if (!e.previousRow || e.row.isSubtotal === !0 || e.row.isGrandTotal === !0 || e.previousRow.isSubtotal === !0 || e.previousRow.isGrandTotal === !0)
182
- return !0;
183
- for (let t = 0; t <= e.levelIndex; t++)
184
- if (e.getValue(e.row, t) !== e.getValue(e.previousRow, t))
185
- return !0;
186
- return !1;
187
- }
188
- function Y(e, t, o) {
189
- return !(o != null && o.hasTextAffixes) && t.kind === "value" && (typeof t.value == "number" || Z(t.value)) ? e : E(e);
190
- }
191
- function Ie(e, t, o) {
192
- const a = G(e.descriptors, t.presentation, o), r = e.columns.map((u) => {
193
- var m;
194
- return u.kind === "measure" && ((m = a.measureSemantics.get(u.measureId)) == null ? void 0 : m.isNumeric) === !0;
195
- }), s = (u) => _([u], a.levels), n = (u, m, d) => j(u, m, t.presentation.totals[d], a.levels), l = e.columns.map((u) => {
196
- if (u.kind !== "measure") return u.label;
197
- const m = u.columnPath.map(s);
198
- return u.role !== "member" && m.push(n(u.columnPath, u.role, "columns")), [...m, u.label].join(" / ");
199
- }), c = Math.min(t.spec.columns.length, Math.max(
200
- 0,
201
- ...e.columns.map((u) => u.kind === "measure" ? u.columnPath.length + (u.role !== "member" ? 1 : 0) : 0)
202
- )), i = Array.from({ length: c + 1 }, (u, m) => e.columns.map((d) => m === c ? d.label : d.kind !== "measure" ? "" : m < d.columnPath.length ? s(d.columnPath[m]) : m === d.columnPath.length && d.role !== "member" ? n(d.columnPath, d.role, "columns") : "")), g = (u, m) => de({
203
- path: u.rowPath,
204
- role: u.kind === "layout" ? u.role : "member",
205
- levelCount: Math.max(1, t.spec.rows.length),
206
- repeatLabels: t.presentation.layout.kind !== "tabular" || t.presentation.layout.repeatLabels,
207
- previousPath: m == null ? void 0 : m.rowPath
208
- }), f = (u, m) => {
209
- if (u.kind !== "layout") throw new Error("Layout presentation requires layout rows.");
210
- if (u.values.length !== e.columns.length) throw new Error("Matrix row does not match its frozen layout.");
211
- const d = g(u, m);
212
- return e.columns.map((y, p) => {
213
- if (y.kind === "hierarchy")
214
- return `${" ".repeat(Math.max(0, u.rowPath.length - 1))}${n(u.rowPath, u.role, "rows")}`;
215
- if (y.kind === "level") {
216
- const C = t.spec.rows.findIndex((oe) => oe.id === y.levelId), w = d[C];
217
- return w != null && w.visible ? w.total ? n(u.rowPath, u.role, "rows") : _(w.path, a.levels) : "";
218
- }
219
- const L = u.values[p], T = a.measures.get(y.measureId);
220
- if (L.kind === "value" && !T)
221
- throw new Error("Matrix value is missing its measure descriptor.");
222
- return X(L, T, t.presentation.absence);
223
- });
224
- }, h = (u, m) => f(u, m).map((d, y) => {
225
- const p = e.columns[y];
226
- return p.kind === "measure" ? Y(d, u.values[y], a.measureSemantics.get(p.measureId)) : E(d);
227
- });
228
- return {
229
- headers: l,
230
- headerBands: i,
231
- numericColumns: r,
232
- /** A row's cells; after `previous`, a tabular layout prints each label once. */
233
- row: (u, m) => f(u, m),
234
- /**
235
- * Level columns whose group label the row above shows, so this row
236
- * continues the group (Plan 2, 2d, C8). Only a member row after a member
237
- * row continues one: a total prints as a band, and its rules stay whole
238
- * above and below it.
239
- */
240
- continuedColumns: (u, m) => {
241
- const d = (p) => (p == null ? void 0 : p.kind) === "layout" && p.role === "member";
242
- if (!d(u) || !d(m)) return [];
243
- const y = g(u, m);
244
- return e.columns.flatMap((p, L) => {
245
- var C;
246
- if (p.kind !== "level") return [];
247
- const T = t.spec.rows.findIndex((w) => w.id === p.levelId);
248
- return T < u.rowPath.length && ((C = y[T]) == null ? void 0 : C.visible) === !1 ? [L] : [];
249
- });
250
- },
251
- csvRow: (u) => h(u),
252
- /**
253
- * `previousRow` is the row before `data[0]`, carried by the export's
254
- * continuation, so a tabular layout prints each label once across the
255
- * whole file. Retries are pure: suppression never relies on mutable
256
- * formatter state or an earlier worker. Without it, the first row prints
257
- * its labels.
258
- */
259
- csvRows: (u, m) => u.map((d, y) => h(d, y ? u[y - 1] : m ?? void 0))
260
- };
261
- }
262
- function $t(e) {
263
- return e.columns.map((t) => E(t.label));
264
- }
265
- function Et(e, t, o) {
266
- if (e.kind !== "flat") throw new Error("Flat Matrix CSV requires flat rows.");
267
- if (e.values.length !== t.columns.length) throw new Error("Matrix row does not match its frozen layout.");
268
- const a = [...e.rowPath, ...e.columnPath];
269
- return t.columns.map((r, s) => {
270
- if (r.kind === "measure") {
271
- const l = e.values[s], c = o.measures.get(r.measureId);
272
- if (l.kind === "value" && !c) throw new Error("Matrix value is missing its measure descriptor.");
273
- return Y(
274
- X(l, c, o.absence),
275
- l,
276
- o.measureSemantics.get(r.measureId)
277
- );
278
- }
279
- const n = r.kind === "level" ? a.find((l) => l.levelId === r.levelId) : void 0;
280
- if (!n) throw new Error("Flat Matrix row does not match its frozen layout.");
281
- return E(_([n], o.levels));
282
- });
283
- }
284
- function De(e) {
285
- const t = Ie(e.layout, e.request, e.report), o = e.layout.columns.map((n, l) => ({
286
- index: l,
287
- columnId: `matrix:${l}`,
288
- label: t.headers[l],
289
- isNumeric: t.numericColumns[l]
290
- })), a = (n, l, c) => ({
291
- text: n,
292
- colspan: 1,
293
- rowspan: 1,
294
- columnId: o[l].columnId,
295
- isHeader: c,
296
- isNumeric: o[l].isNumeric,
297
- className: o[l].isNumeric ? "numeric" : e.layout.columns[l].kind === "hierarchy" ? "matrix-hierarchy" : ""
298
- }), r = [], s = e.layout.columns.findIndex((n) => n.kind === "measure");
299
- e.request.spec.columns.length && s >= 0 && r.push({
300
- repeatHeader: !0,
301
- headerType: "pivot-axis",
302
- headerRowIndex: 0,
303
- cells: [
304
- ...s ? [{ ...a("", 0, !0), colspan: s }] : [],
305
- {
306
- ...a(e.request.spec.columns.map((n) => W(n, e.request.presentation)).join(" / "), s, !0),
307
- colspan: e.layout.columns.length - s,
308
- isNumeric: !1,
309
- className: ""
310
- }
311
- ]
312
- });
313
- for (const [n, l] of t.headerBands.entries())
314
- r.push({
315
- repeatHeader: !0,
316
- headerType: n === t.headerBands.length - 1 ? "metrics" : "pivot-level",
317
- headerRowIndex: r.length,
318
- cells: l.map((c, i) => a(c, i, !0))
319
- });
320
- return {
321
- headers: r,
322
- rows: e.rows.map((n, l) => {
323
- const c = new Set(t.continuedColumns(n, e.rows[l - 1]));
324
- return {
325
- index: l,
326
- type: n.kind === "layout" && n.role !== "member" ? "subtotal" : "data",
327
- subtotalLevel: String(n.rowPath.length),
328
- // A tabular layout prints each label once unless it repeats them; the
329
- // blank cell continues its group, so a grid draws no rule above it.
330
- cells: t.row(n, e.rows[l - 1]).map((i, g) => c.has(g) ? { ...a(i, g, !1), className: xe } : a(i, g, !1))
331
- };
332
- }),
333
- grandTotal: null,
334
- // Totals are already in the ordered body at their authored position.
335
- metadata: {
336
- tableType: "pivot",
337
- totalRows: e.rows.length,
338
- totalColumns: o.length,
339
- rowLevels: e.layout.columns.filter((n) => n.kind !== "measure").length,
340
- pivotLevels: e.request.spec.columns.length,
341
- hasGrandTotal: !1,
342
- columnOrder: o.map((n) => n.columnId),
343
- columns: o
344
- }
345
- };
346
- }
347
- function Re(e, t, o) {
348
- const { levels: a } = G(e.descriptors, t.presentation, o), r = t.spec.columns.length > 0, s = [], n = [], l = e.columns.map((i, g) => {
349
- if (i.kind !== "measure") return null;
350
- const f = r ? `${i.role}:${M(i.columnPath)}` : `measure:${g}`;
351
- let h = s.indexOf(f);
352
- return h < 0 && (h = s.push(f) - 1, n.push(r ? j(i.columnPath, i.role, t.presentation.totals.columns, a) : i.label)), h;
353
- }), c = t.spec.columns[t.spec.columns.length - 1];
354
- return {
355
- columnGroups: l,
356
- groupLabels: n,
357
- /** What bands name their groups by: the innermost column level, or "Measures". */
358
- groupLevelLabel: c ? W(c, t.presentation) : "Measures"
359
- };
360
- }
361
- function Pt(e) {
362
- const { layout: t, rows: o, report: a } = e, r = {
363
- ...e.request,
364
- presentation: $e(t, o, e.request.presentation)
365
- }, s = De({ layout: t, rows: o, request: r, report: a }), n = Pe(o), l = Re(t, r, a), c = {
366
- ...s,
367
- rows: s.rows.map((i, g) => ({ ...i, keepWithPrevious: n[g] })),
368
- metadata: { ...s.metadata, ...l }
369
- };
370
- return { request: r, table: c, ...l };
371
- }
372
- class Fe extends Error {
373
- constructor() {
374
- super(...arguments);
375
- N(this, "code", K);
376
- }
377
- }
378
- function O(e) {
379
- if (!e || typeof e != "object")
380
- return;
381
- const { error: t, message: o, detail: a } = e;
382
- for (const r of [t, o, a])
383
- if (typeof r == "string" && r.trim())
384
- return r.trim();
385
- }
386
- async function Ne(e) {
387
- const t = `PDF request failed: ${e.status} ${e.statusText}`.trim(), o = e.headers.get("content-type") || "";
388
- try {
389
- if (o.includes("application/json")) {
390
- const r = await e.json(), s = typeof r.code == "string" ? r.code : typeof r.errorCode == "string" ? r.errorCode : void 0;
391
- return { message: O(r) || t, code: s };
392
- }
393
- const a = await e.text();
394
- if (!a.trim())
395
- return { message: t };
396
- try {
397
- const r = JSON.parse(a), s = typeof r.code == "string" ? r.code : typeof r.errorCode == "string" ? r.errorCode : void 0;
398
- return {
399
- message: O(r) || a.trim(),
400
- code: s
401
- };
402
- } catch {
403
- return { message: a.trim() };
404
- }
405
- } catch {
406
- return { message: t };
407
- }
408
- }
409
- async function xt(e) {
410
- if (!e.token) throw new Error("Missing auth token for PDF export");
411
- if (ye(e.serializedPayload) > pe.maxRequestBytes)
412
- throw new Error("Fast-path PDF request exceeds the structured body limit");
413
- const t = await (e.fetchImpl ?? fetch)(e.url, {
414
- method: "POST",
415
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${e.token}` },
416
- body: e.serializedPayload,
417
- signal: e.signal
418
- });
419
- if (!t.ok) {
420
- const a = await Ne(t);
421
- throw a.code === K ? new Fe(a.message) : new Error(a.message);
422
- }
423
- const o = await t.json();
424
- if (o != null && o.error) throw new Error(o.error);
425
- if (typeof (o == null ? void 0 : o.url) != "string" || !o.url.trim())
426
- throw new Error("Fast-path PDF response missing download URL");
427
- return o;
428
- }
429
- const Ue = /* @__PURE__ */ new Set(["short", "medium", "long"]), Ve = /^(\d{4})-(\d{2})-(\d{2})$/, Oe = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/, Be = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/, F = " – ";
430
- function _t(e) {
431
- if (!ve(e)) return;
432
- const t = Object.keys(e);
433
- if (e.mode === "period_label" && t.length === 1)
434
- return { mode: "period_label" };
435
- if (e.mode === "style" && t.length === 2 && typeof e.dateStyle == "string" && Ue.has(e.dateStyle))
436
- return { mode: "style", dateStyle: e.dateStyle };
437
- if (e.mode === "pattern" && t.length === 3 && e.dialect === "semaphor_tokens" && typeof e.pattern == "string" && ze(e.pattern) === null)
438
- return {
439
- mode: "pattern",
440
- dialect: "semaphor_tokens",
441
- pattern: e.pattern
442
- };
443
- }
444
- function ze(e) {
445
- try {
446
- return ce({ dialect: "semaphor_tokens", pattern: e }), null;
447
- } catch (t) {
448
- return t instanceof Error ? t.message : "The pattern is invalid.";
449
- }
450
- }
451
- function It(e) {
452
- const { value: t, part: o, presentation: a, preferences: r, calendar: s } = e;
453
- if ((a == null ? void 0 : a.mode) === "period_label" && t.periodLabel && o === "range")
454
- return { ok: !0, text: t.periodLabel };
455
- const [n, l] = t.bounds, i = l === void 0 || o === "start" ? [{ raw: n, role: "start" }] : o === "end" ? [{ raw: l, role: "end" }] : [
456
- { raw: n, role: "start" },
457
- { raw: l, role: "end" }
458
- ], g = i.map(({ raw: m }) => Ze(m, s.tz));
459
- if (g.some((m) => m === null))
460
- return {
461
- ok: !1,
462
- text: i.map(({ raw: m }) => m).join(F),
463
- diagnostic: {
464
- code: "invalid_temporal_input_value",
465
- message: "A date input bound is not a date or an instant."
466
- }
467
- };
468
- const f = t.precision === "day" ? g.map(
469
- (m, d) => Ke(m, i[d].role, s.tz)
470
- ) : [], h = f.length > 0 && f.every((m) => m !== null) ? f : null;
471
- return { ok: !0, text: h ? Ge(h, a, r, s) : je(
472
- g.map((m) => We(m, s.tz)),
473
- a,
474
- r,
475
- s
476
- ) };
477
- }
478
- function Ge(e, t, o, a) {
479
- const [r, s = r] = e;
480
- if ((t == null ? void 0 : t.mode) === "pattern")
481
- return J(
482
- e.map(
483
- (c) => H(I(c), "date", t.pattern, o, a)
484
- )
485
- );
486
- const n = (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : o.dateStyle;
487
- if (!t || t.mode === "period_label") {
488
- const c = Ye(r, s, a);
489
- if (c)
490
- return be({
491
- value: I(r),
492
- metadata: {
493
- kind: "temporal_bucket",
494
- granularity: c,
495
- calendar: { tz: a.tz, weekStart: a.weekStart ?? 1 }
496
- },
497
- format: Te({
498
- metadata: {
499
- kind: "temporal_bucket",
500
- granularity: c,
501
- calendar: { tz: a.tz, weekStart: a.weekStart ?? 1 }
502
- },
503
- locale: o.locale,
504
- styles: { dateStyle: n, dateTime: { ...o.dateTime } }
505
- }).format
506
- });
507
- }
508
- const l = new Intl.DateTimeFormat(o.locale, {
509
- calendar: "gregory",
510
- timeZone: "UTC",
511
- dateStyle: n
512
- });
513
- return He(r, s) ? l.format(A(r)) : q(l, A(r), A(s));
514
- }
515
- function je(e, t, o, a) {
516
- if ((t == null ? void 0 : t.mode) === "pattern")
517
- return J(
518
- e.map(
519
- (l) => H(
520
- l.toISOString(),
521
- "instant",
522
- t.pattern,
523
- o,
524
- a
525
- )
526
- )
527
- );
528
- const r = new Intl.DateTimeFormat(o.locale, {
529
- calendar: "gregory",
530
- timeZone: a.tz,
531
- dateStyle: (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : o.dateTime.dateStyle,
532
- timeStyle: o.dateTime.timeStyle
533
- }), [s, n] = e;
534
- return n && n.getTime() !== s.getTime() ? q(r, s, n) : r.format(s);
535
- }
536
- function q(e, t, o) {
537
- const a = e;
538
- return typeof a.formatRange == "function" ? a.formatRange(t, o) : `${e.format(t)}${F}${e.format(o)}`;
539
- }
540
- function H(e, t, o, a, r) {
541
- const s = ie({
542
- format: {
543
- type: "raw_temporal",
544
- presentation: { mode: "pattern", dialect: "semaphor_tokens", pattern: o }
545
- },
546
- // Temporal formatting reads no currency.
547
- preferences: {
548
- ...a,
549
- defaultCurrency: we.defaultCurrency
550
- },
551
- calendar: { tz: r.tz }
552
- }), n = t === "date" && Xe(o) ? "instant" : t;
553
- return ue({
554
- value: n === t ? e : R(`${e}T00:00:00`, r.tz).toISOString(),
555
- metadata: { kind: "raw_temporal", valueKind: n },
556
- format: s
557
- }).text;
558
- }
559
- function Xe(e) {
560
- return /HH|mm|ss/.test(e);
561
- }
562
- function J(e) {
563
- return e[1] === void 0 || e[0] === e[1] ? e[0] : e.join(F);
564
- }
565
- function Ze(e, t) {
566
- const o = Ve.exec(e);
567
- if (o) {
568
- const r = {
569
- year: Number(o[1]),
570
- month: Number(o[2]),
571
- day: Number(o[3])
572
- };
573
- return Je(r) ? { kind: "date", date: r } : null;
574
- }
575
- const a = Be.test(e) ? new Date(e.replace(" ", "T")) : Oe.test(e) ? R(e.replace(" ", "T"), t) : null;
576
- return a && !Number.isNaN(a.getTime()) ? { kind: "instant", instant: a } : null;
577
- }
578
- function We(e, t) {
579
- return e.kind === "instant" ? e.instant : R(`${I(e.date)}T00:00:00`, t);
580
- }
581
- function Ke(e, t, o) {
582
- if (e.kind === "date") return e.date;
583
- const a = Se(e.instant, o), r = { year: a.year, month: a.month, day: a.day };
584
- if (a.hour === 0 && a.minute === 0 && a.second === 0 && e.instant.getUTCMilliseconds() === 0) return t === "start" ? r : qe(r, -1);
585
- const n = a.hour === 23 && a.minute === 59 && a.second === 59;
586
- return t === "end" && n ? r : null;
587
- }
588
- function Ye(e, t, o) {
589
- return o.fiscalCalendar || e.day !== 1 || e.year !== t.year || t.day !== Q(t.year, t.month) ? null : e.month === t.month ? "month" : e.month % 3 === 1 && t.month === e.month + 2 ? "quarter" : e.month === 1 && t.month === 12 ? "year" : null;
590
- }
591
- function I(e) {
592
- return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
593
- }
594
- function A(e) {
595
- const t = /* @__PURE__ */ new Date(0);
596
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(0, 0, 0, 0), t;
597
- }
598
- function qe(e, t) {
599
- const o = A(e);
600
- return o.setUTCDate(o.getUTCDate() + t), {
601
- year: o.getUTCFullYear(),
602
- month: o.getUTCMonth() + 1,
603
- day: o.getUTCDate()
604
- };
605
- }
606
- function He(e, t) {
607
- return e.year === t.year && e.month === t.month && e.day === t.day;
608
- }
609
- function Q(e, t) {
610
- return new Date(Date.UTC(e, t, 0)).getUTCDate();
611
- }
612
- function Je(e) {
613
- return e.year >= 1 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= Q(e.year, e.month);
614
- }
615
- const Qe = /^\d{4}-\d{2}-\d{2}$/;
616
- function ee(e) {
617
- const t = e.split(".");
618
- return t[t.length - 1].replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").map((r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()).join(" ");
619
- }
620
- const B = 10;
621
- function x(e, t) {
622
- const o = e.slice(0, B).map(t).join(", "), a = e.length - B;
623
- return a > 0 ? `${o}, and ${a} more` : o;
624
- }
625
- function et(e) {
626
- if (e.valueType !== "date" || e.operation !== "between" && e.operation !== "not between")
627
- return;
628
- const t = ge(e.relativeMeta);
629
- if (t)
630
- return he(t) || t.unit === "quarter" || t.unit === "year" ? t : void 0;
631
- }
632
- function z(e, t = {}) {
633
- const { name: o, operation: a, values: r, valueType: s } = e, n = t.label ?? ee(o), l = et(e);
634
- if (l) {
635
- const i = Le(l);
636
- if (i)
637
- return a === "between" ? `${n}: ${i}` : `${n} not in ${i}`;
638
- }
639
- if (!r || r.length === 0)
640
- return a === "is null" ? `${n} is empty` : a === "is not null" ? `${n} is not empty` : "";
641
- const c = (i) => {
642
- if (s === "date" && i) {
643
- const g = e.temporalPrecision === "minute", f = {
644
- year: "numeric",
645
- month: "short",
646
- day: "numeric",
647
- ...g ? {
648
- hour: "numeric",
649
- minute: "2-digit"
650
- } : {}
651
- };
652
- if (typeof i == "string" && Qe.test(i)) {
653
- const [u, m, d] = i.split("-").map(Number);
654
- return new Intl.DateTimeFormat(void 0, {
655
- year: "numeric",
656
- month: "short",
657
- day: "numeric",
658
- timeZone: "UTC"
659
- }).format(new Date(Date.UTC(u, m - 1, d)));
660
- }
661
- if (typeof i == "string" && me(i) === "wall_datetime") {
662
- const [u, m, d, y, p] = i.split(/[-T :.]/).map(Number);
663
- return new Intl.DateTimeFormat(void 0, {
664
- ...f,
665
- timeZone: "UTC"
666
- }).format(new Date(Date.UTC(u, m - 1, d, y, p)));
667
- }
668
- const h = new Date(i);
669
- if (!isNaN(h.getTime()))
670
- try {
671
- return new Intl.DateTimeFormat(void 0, {
672
- ...f,
673
- ...t.timezone ? { timeZone: t.timezone } : {}
674
- }).format(h);
675
- } catch {
676
- return g ? h.toLocaleString(void 0, f) : h.toLocaleDateString(void 0, f);
677
- }
678
- }
679
- return String(i);
680
- };
681
- switch (a) {
682
- case "=":
683
- return `${n}: ${c(r[0])}`;
684
- case "!=":
685
- return `${n} ≠ ${c(r[0])}`;
686
- case ">":
687
- return `${n} > ${c(r[0])}`;
688
- case "<":
689
- return `${n} < ${c(r[0])}`;
690
- case ">=":
691
- return `${n} ≥ ${c(r[0])}`;
692
- case "<=":
693
- return `${n} ≤ ${c(r[0])}`;
694
- case "between":
695
- case "not between": {
696
- const i = `${c(r[0])} - ${c(r[1])}`;
697
- return a === "between" ? `${n}: ${i}` : `${n} not in ${i}`;
698
- }
699
- case "in":
700
- return r.length === 1 ? `${n}: ${c(r[0])}` : `${n}: ${x(r, c)}`;
701
- case "not in":
702
- return `${n} not in (${x(r, c)})`;
703
- case "like":
704
- return `${n} contains "${r[0]}"`;
705
- case "not like":
706
- return `${n} doesn't contain "${r[0]}"`;
707
- default:
708
- return `${n}: ${x(r, c)}`;
709
- }
710
- }
711
- function Dt(e, t = {}) {
712
- if (!e || e.length === 0)
713
- return "";
714
- const o = /* @__PURE__ */ new Map();
715
- e.forEach((r) => {
716
- const s = o.get(r.name) || [];
717
- s.push(r), o.set(r.name, s);
718
- });
719
- const a = [];
720
- return o.forEach((r, s) => {
721
- if (r.length === 1) {
722
- const n = z(r[0], t);
723
- n && a.push(n);
724
- } else {
725
- const n = ee(s), l = r.map((c) => z(c, t).replace(`${n}: `, "").replace(`${n} `, "")).filter(Boolean);
726
- l.length > 0 && a.push(`${n}: ${l.join(" and ")}`);
727
- }
728
- }), a.join(" | ");
729
- }
730
- const tt = /* @__PURE__ */ new Set([
731
- "day",
732
- "week",
733
- "month",
734
- "quarter",
735
- "year"
736
- ]);
737
- function rt(e, t) {
738
- try {
739
- const o = b(
740
- v(e),
741
- t,
742
- "yyyy-MM-dd"
743
- ), [a, r, s] = o.split("-").map(Number), n = new Date(Date.UTC(a, r - 1, s));
744
- return n.setUTCDate(n.getUTCDate() - 1), b(n, "UTC", "yyyy-MM-dd");
745
- } catch {
746
- return;
747
- }
748
- }
749
- function Rt(e, t, o, a = !1) {
750
- const r = ot(
751
- e,
752
- t,
753
- o,
754
- a
755
- );
756
- return `${r.start} - ${r.end}`;
757
- }
758
- function ot(e, t, o, a = !1) {
759
- try {
760
- if (o && tt.has(o)) {
761
- const r = rt(e.end, t);
762
- if (r) {
763
- const s = a ? "MMM d" : "MMM d, yyyy";
764
- return {
765
- start: b(
766
- v(e.start),
767
- t,
768
- s
769
- ),
770
- end: b(
771
- v(`${r}T00:00:00Z`),
772
- "UTC",
773
- "MMM d, yyyy"
774
- )
775
- };
776
- }
777
- }
778
- if (o === "second" || o === "minute" || o === "hour") {
779
- const r = a ? "MMM d, h:mm a" : "MMM d, yyyy, h:mm a";
780
- return {
781
- start: b(v(e.start), t, r),
782
- end: `before ${b(
783
- v(e.end),
784
- t,
785
- r
786
- )}`
787
- };
788
- }
789
- } catch {
790
- }
791
- return { start: e.start, end: `before ${e.end}` };
792
- }
793
- const at = "__TOTAL__";
794
- function $(e) {
795
- return typeof e == "object" && e !== null && !Array.isArray(e);
796
- }
797
- function D(e) {
798
- return e === at;
799
- }
800
- function Ft(e) {
801
- const t = /* @__PURE__ */ new Map(), o = (e.groupByColumns ?? []).map((r, s) => {
802
- var i, g, f;
803
- if (!$(r))
804
- throw new Error(`Aggregate groupByColumns[${s}] is invalid`);
805
- const n = typeof r.id == "string" && r.id.length > 0 ? r.id : void 0, l = n ? (f = (g = (i = e.columnKeyMap) == null ? void 0 : i.byRole) == null ? void 0 : g.groupby) == null ? void 0 : f[n] : void 0, c = (l == null ? void 0 : l.outputKey) || (l == null ? void 0 : l.rawKey) || (typeof r.alias == "string" && r.alias.length > 0 ? r.alias : typeof r.name == "string" && r.name.length > 0 ? r.name : void 0);
806
- if (!c)
807
- throw new Error(`Aggregate groupByColumns[${s}] has no output key`);
808
- return [n, r.alias, r.name, c].forEach((h) => {
809
- typeof h == "string" && h.length > 0 && t.set(h, c);
810
- }), c;
811
- }), a = (e.rowAggregates ?? []).flatMap((r) => !$(r) || typeof r.function != "string" || typeof r.groupLevel != "string" ? [] : [
812
- {
813
- function: r.function,
814
- groupLevel: r.groupLevel === "ALL" ? "ALL" : t.get(r.groupLevel) || r.groupLevel,
815
- ...typeof r.label == "string" ? { label: r.label } : {}
816
- }
817
- ]);
818
- return { groupColumnKeys: o, rowAggregates: a };
819
- }
820
- function te(e) {
821
- return e === "SUM" ? "Total" : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
822
- }
823
- function nt(e) {
824
- var o;
825
- if (e.customLabel) return e.customLabel;
826
- const t = te(e.aggregateFunction);
827
- if (e.levelValue !== void 0 && !D(e.levelValue)) {
828
- if (e.levelValue === null) {
829
- const r = (o = e.formatValue) == null ? void 0 : o.call(e, null);
830
- return r ? `Subtotal ${r}` : `Subtotal ${t}`;
831
- }
832
- const a = e.formatValue ? e.formatValue(e.levelValue) : String(e.levelValue);
833
- if (a) return `Subtotal (${a})`;
834
- }
835
- return `Subtotal ${t}`;
836
- }
837
- function st(e, t) {
838
- return t || `Grand ${te(e)}`;
839
- }
840
- function Nt(e) {
841
- const t = e.context.groupColumnKeys.indexOf(e.columnKey);
842
- if (t < 0)
843
- throw new Error(
844
- `Aggregate group column "${e.columnKey}" is unknown`
845
- );
846
- return _e({
847
- row: e.row,
848
- previousRow: e.previousRow,
849
- levelIndex: t,
850
- getValue: (o, a) => o[e.context.groupColumnKeys[a]]
851
- });
852
- }
853
- function re(e) {
854
- var a, r;
855
- const t = e.context.groupColumnKeys, o = typeof e.row.aggregate == "string" ? e.row.aggregate : "SUM";
856
- if (e.row.isGrandTotal === !0) {
857
- const s = (a = e.context.rowAggregates.find(
858
- (n) => n.groupLevel === "ALL"
859
- )) == null ? void 0 : a.label;
860
- return {
861
- kind: "grand-total",
862
- cells: t.map((n, l) => ({
863
- columnKey: n,
864
- text: l === 0 ? st(o, s) : "",
865
- placement: l === 0 ? "label" : "empty",
866
- colSpan: l === 0 ? t.length : 1
867
- }))
868
- };
869
- }
870
- if (e.row.isSubtotal === !0) {
871
- if (typeof e.row.subtotalLevel != "string")
872
- throw new Error("Aggregate subtotal row is missing subtotalLevel");
873
- const s = t.indexOf(e.row.subtotalLevel);
874
- if (s < 0)
875
- throw new Error(
876
- `Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`
877
- );
878
- const n = $(e.row.subtotalContext) ? e.row.subtotalContext : void 0, l = $(n == null ? void 0 : n.groupByValues) ? n.groupByValues : {}, c = (r = e.context.rowAggregates.find(
879
- (i) => i.groupLevel === e.row.subtotalLevel && i.function === o
880
- )) == null ? void 0 : r.label;
881
- return {
882
- kind: "subtotal",
883
- cells: t.map((i, g) => {
884
- if (g > s)
885
- return {
886
- columnKey: i,
887
- text: "",
888
- placement: "empty",
889
- colSpan: 1
890
- };
891
- if (g < s) {
892
- const f = e.row[i];
893
- return {
894
- columnKey: i,
895
- text: f === void 0 || D(f) ? "" : e.formatValue(f, i),
896
- placement: "value",
897
- colSpan: 1
898
- };
899
- }
900
- return {
901
- columnKey: i,
902
- text: nt({
903
- aggregateFunction: o,
904
- customLabel: c,
905
- levelValue: l[i],
906
- formatValue: (f) => e.formatLabelValue ? e.formatLabelValue(f, i) : String(e.formatValue(f, i) ?? "")
907
- }),
908
- placement: "label",
909
- colSpan: t.length - s
910
- };
911
- })
912
- };
913
- }
914
- return {
915
- kind: "data",
916
- cells: t.map((s) => {
917
- const n = e.row[s];
918
- return {
919
- columnKey: s,
920
- text: n === void 0 || D(n) ? "" : e.formatValue(n, s),
921
- placement: "value",
922
- colSpan: 1
923
- };
924
- })
925
- };
926
- }
927
- function Ut(e) {
928
- const t = re(e).cells.find(
929
- (o) => o.columnKey === e.columnKey
930
- );
931
- if (!t)
932
- throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);
933
- return t.text;
934
- }
935
- function Vt(e) {
936
- return re(e).cells.map((t) => t.text);
937
- }
938
- export {
939
- at as A,
940
- Ft as B,
941
- nt as C,
942
- ke as D,
943
- st as E,
944
- vt as F,
945
- Nt as G,
946
- re as H,
947
- Ut as I,
948
- Vt as J,
949
- _e as K,
950
- ot as L,
951
- St as M,
952
- xe as P,
953
- Tt as a,
954
- Lt as b,
955
- Ct as c,
956
- Et as d,
957
- De as e,
958
- Rt as f,
959
- Pt as g,
960
- At as h,
961
- Mt as i,
962
- Ae as j,
963
- $e as k,
964
- Pe as l,
965
- $t as m,
966
- Fe as n,
967
- Ne as o,
968
- Ie as p,
969
- xt as q,
970
- kt as r,
971
- _t as s,
972
- It as t,
973
- B as u,
974
- ze as v,
975
- et as w,
976
- z as x,
977
- Dt as y,
978
- D as z
979
- };