react-semaphor 0.1.449 → 0.1.454
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.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +119 -112
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/brand-studio/index.cjs +4 -4
- package/dist/brand-studio/index.js +15 -13
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +39 -2131
- package/dist/chunks/{analyze-result-contract-T-0Ntzys.js → analyze-result-contract-BbRJ-C06.js} +1 -1
- package/dist/chunks/{analyze-result-contract-BHb7sUUW.cjs → analyze-result-contract-LPDNldic.cjs} +1 -1
- package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +1 -0
- package/dist/chunks/canonical-result-keys-D6avdjpA.js +467 -0
- package/dist/chunks/color-CJvdlFM_.js +2162 -0
- package/dist/chunks/color-CyB5o13F.cjs +4 -0
- package/dist/chunks/{common-types-CQ6SHfLk.cjs → common-types-C57kJ59w.cjs} +1 -1
- package/dist/chunks/{common-types-B7Jk3Rtj.js → common-types-H51FLKB7.js} +1 -1
- package/dist/chunks/contracts-CoCOpd_i.js +11 -0
- package/dist/chunks/contracts-CtB2VONT.cjs +1 -0
- package/dist/chunks/dashboard-briefing-launcher-Dwj1i7lr.cjs +26 -0
- package/dist/chunks/{dashboard-briefing-launcher-DCHiEkLE.js → dashboard-briefing-launcher-SYroFdae.js} +86 -84
- package/dist/chunks/{dashboard-controls-DwRFCcHV.js → dashboard-controls-1LpeU2sz.js} +15 -13
- package/dist/chunks/{dashboard-controls-CaFioayc.cjs → dashboard-controls-CpFoh7-A.cjs} +1 -1
- package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +1 -0
- package/dist/chunks/{dashboard-date-comparison-definition-Ba-clViK.js → dashboard-date-comparison-definition-DC3ekV2S.js} +1 -1
- package/dist/chunks/{dashboard-json-WoILbfTe.js → dashboard-json-D-T-sQxU.js} +25 -23
- package/dist/chunks/dashboard-json-DwSQopc_.cjs +1 -0
- package/dist/chunks/edit-dashboard-visual-BEmoQAET.cjs +172 -0
- package/dist/chunks/{edit-dashboard-visual-ciFhxqaI.js → edit-dashboard-visual-DqxUq4Bs.js} +6925 -6947
- package/dist/chunks/editor-action-buttons-18r2xwei.cjs +16 -0
- package/dist/chunks/{editor-action-buttons-BPo_45pM.js → editor-action-buttons-B2l3WIRC.js} +41 -39
- package/dist/chunks/format-types-CFHQoIuk.js +1350 -0
- package/dist/chunks/format-types-PSZZ7hG8.cjs +1 -0
- package/dist/chunks/index-Bn5wlkHt.cjs +4 -0
- package/dist/chunks/index-ByFbacH7.cjs +1 -0
- package/dist/chunks/index-CACdoqu3.js +318 -0
- package/dist/chunks/index-CLB_NGZ8.cjs +1392 -0
- package/dist/chunks/index-Ca784dpx.js +3714 -0
- package/dist/chunks/{index-CPuawpXJ.js → index-DAoS4BNU.js} +48514 -48484
- package/dist/chunks/index-DSKR3nKn.js +421 -0
- package/dist/chunks/index-F25jnH0p.cjs +1 -0
- package/dist/chunks/matrix-result-contract-CofATICL.js +437 -0
- package/dist/chunks/matrix-result-contract-zamd9euI.cjs +1 -0
- package/dist/chunks/pivot-header-presentation-DhyQXxKq.cjs +4 -0
- package/dist/chunks/pivot-header-presentation-ckYOQ4aZ.js +557 -0
- package/dist/chunks/{pivot-result-identity-CDLRT-YG.cjs → pivot-result-identity-Bb4EixVN.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-CwJWpKI7.js → pivot-result-identity-DU1v-5Xk.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-DmcF1ris.cjs +1 -0
- package/dist/chunks/pivot-result-lifecycle-sjzIOpvp.js +1641 -0
- package/dist/chunks/raw-temporal-contract-BtjH_G-d.cjs +1 -0
- package/dist/chunks/raw-temporal-contract-CxncLze5.js +64 -0
- package/dist/chunks/report-preferences-dialog-BgSvlDXa.cjs +1 -0
- package/dist/chunks/report-preferences-dialog-DDc2WUa0.js +723 -0
- package/dist/chunks/{report-runtime-context-C8LZFsqV.cjs → report-runtime-context-DqxS4wbi.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-bCy3CVzK.js → report-runtime-context-SM6YO61_.js} +5 -5
- package/dist/chunks/saved-temporal-bucket-format-CFfWXRl9.cjs +1 -0
- package/dist/chunks/saved-temporal-bucket-format-SGAV0ivR.js +922 -0
- package/dist/chunks/{switch-BXet-Sno.js → switch-BeZW-HnS.js} +4350 -5249
- package/dist/chunks/switch-D-CCcfhc.cjs +138 -0
- package/dist/chunks/temporal-bucket-5UYEotyQ.js +810 -0
- package/dist/chunks/temporal-bucket-DHY1y9lq.cjs +1 -0
- package/dist/chunks/temporal-bucket-authoring-K1kE6R_z.js +222 -0
- package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +1 -0
- package/dist/chunks/{temporal-bucket-contract-ChDBWX8I.cjs → temporal-bucket-contract-D2-93DGr.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-_F6vNhhH.js → temporal-bucket-contract-D5d-xEl3.js} +1 -1
- package/dist/chunks/{token-types-BdQ8kHBm.cjs → token-types-D7CaaI80.cjs} +1 -1
- package/dist/chunks/{token-types-BHR58aTy.js → token-types-GbxRUozo.js} +1 -1
- package/dist/chunks/{update-policy-BxvYMYz0.cjs → update-policy-BmiOd0PB.cjs} +1 -1
- package/dist/chunks/{update-policy-g0rCQ9BM.js → update-policy-hednMF-0.js} +1 -1
- package/dist/chunks/validators-BDYprKI9.cjs +1 -0
- package/dist/chunks/{validators-Cs74WVie.js → validators-DEmd8Sin.js} +1561 -1197
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +35 -32
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +78 -77
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +29 -30
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +21 -21
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +156 -140
- package/dist/index.cjs +1 -1
- package/dist/index.js +157 -155
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +81 -11
- package/dist/types/briefings.d.ts +727 -19
- package/dist/types/dashboard-assistant.d.ts +37 -17
- package/dist/types/dashboard-authoring.d.ts +61 -14
- package/dist/types/dashboard.d.ts +137 -12
- package/dist/types/data-app-builder.d.ts +28 -2
- package/dist/types/data-app-codegen-node.d.ts +29 -3
- package/dist/types/data-app-codegen.d.ts +29 -3
- package/dist/types/data-app-sdk-adapters.d.ts +28 -2
- package/dist/types/data-app-sdk-validation.d.ts +51 -7
- package/dist/types/data-app-sdk.d.ts +55 -10
- package/dist/types/format-utils.d.ts +190 -3
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +128 -33
- package/dist/types/shared.d.ts +14 -12
- package/dist/types/surfboard.d.ts +138 -13
- package/dist/types/types.d.ts +117 -23
- package/dist/types/value-format-preferences.d.ts +3 -0
- package/package.json +2 -1
- package/dist/chunks/card-config-utils-15sRtebL.cjs +0 -1
- package/dist/chunks/card-config-utils-BYZ5MJOh.js +0 -16
- package/dist/chunks/catalog-field-grounding-Bnx-3tE0.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-S2jKwKGD.js +0 -100
- package/dist/chunks/dashboard-briefing-launcher-DDgDr2s3.cjs +0 -26
- package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +0 -1
- package/dist/chunks/dashboard-input-contract-DSt8dGzP.js +0 -18
- package/dist/chunks/dashboard-input-contract-DV3cshjz.cjs +0 -1
- package/dist/chunks/dashboard-json-CYtvwtvj.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-DwKcvlsF.cjs +0 -177
- package/dist/chunks/editor-action-buttons-BVmsk0Aj.cjs +0 -16
- package/dist/chunks/format-types-CSv0V7mm.cjs +0 -1
- package/dist/chunks/format-types-DZGgYj39.js +0 -1663
- package/dist/chunks/index-CJdxSyQq.js +0 -2578
- package/dist/chunks/index-DPv8_Ild.cjs +0 -1395
- package/dist/chunks/index-DRlMUglg.cjs +0 -4
- package/dist/chunks/metric-comparison-97zHGEx5.js +0 -387
- package/dist/chunks/metric-comparison-CUAJ8n4y.cjs +0 -1
- package/dist/chunks/pivot-result-lifecycle-BBabQ_da.js +0 -914
- package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +0 -4
- package/dist/chunks/presentation-execution-BLfPTGX_.js +0 -637
- package/dist/chunks/presentation-execution-BTV-Q43g.cjs +0 -1
- package/dist/chunks/report-preferences-dialog-D9ZCGh9l.js +0 -691
- package/dist/chunks/report-preferences-dialog-DaqTEcac.cjs +0 -1
- package/dist/chunks/switch-Cjk6G06r.cjs +0 -138
- package/dist/chunks/temporal-bucket-BnPxGrAi.js +0 -446
- package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +0 -1
- package/dist/chunks/temporal-bucket-authoring-CgOuakGW.js +0 -205
- package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +0 -1
- package/dist/chunks/temporal-result-owner-6peubmhU.js +0 -443
- package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +0 -1
- package/dist/chunks/validators-9D4KBqKD.cjs +0 -1
|
@@ -0,0 +1,1641 @@
|
|
|
1
|
+
var ee = Object.defineProperty;
|
|
2
|
+
var te = (e, t, r) => t in e ? ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var g = (e, t, r) => te(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { b as k, al as G, x as re } from "./validators-DEmd8Sin.js";
|
|
5
|
+
import { p as ae } from "./raw-temporal-contract-CxncLze5.js";
|
|
6
|
+
import { canonicalizeSupportedLocale as E, canonicalizeSupportedCurrencyCode as $ } from "../value-format-preferences/index.js";
|
|
7
|
+
import { l as h, j as ne, a as ie } from "./temporal-bucket-5UYEotyQ.js";
|
|
8
|
+
import { f as oe } from "./index-CACdoqu3.js";
|
|
9
|
+
import { b as se } from "./report-runtime-context-SM6YO61_.js";
|
|
10
|
+
import "./analyze-result-contract-BbRJ-C06.js";
|
|
11
|
+
import { a as ce } from "./temporal-bucket-contract-D5d-xEl3.js";
|
|
12
|
+
import { d as me, P as le } from "./pivot-result-identity-DU1v-5Xk.js";
|
|
13
|
+
function N(e) {
|
|
14
|
+
if (!e) return !1;
|
|
15
|
+
const t = e.toLowerCase().replace("_", "-");
|
|
16
|
+
return t === "en-in" || t.startsWith("en-in-");
|
|
17
|
+
}
|
|
18
|
+
function z(e, t) {
|
|
19
|
+
const r = Math.abs(e);
|
|
20
|
+
return r >= 1e12 ? { divisor: 1e12, suffix: "T" } : r >= 1e9 ? { divisor: 1e9, suffix: "B" } : N(t) && r >= 1e7 ? { divisor: 1e7, suffix: "Cr" } : r >= 1e6 ? { divisor: 1e6, suffix: "M" } : N(t) && r >= 1e5 ? { divisor: 1e5, suffix: "L" } : r >= 1e3 ? { divisor: 1e3, suffix: "K" } : { divisor: 1, suffix: "" };
|
|
21
|
+
}
|
|
22
|
+
function D(e, t) {
|
|
23
|
+
try {
|
|
24
|
+
const r = x(t);
|
|
25
|
+
return z(e, r);
|
|
26
|
+
} catch {
|
|
27
|
+
return z(e, "en-US");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function ue(e) {
|
|
31
|
+
try {
|
|
32
|
+
return new Intl.NumberFormat(e), !0;
|
|
33
|
+
} catch {
|
|
34
|
+
return !1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function x(e) {
|
|
38
|
+
return e && ue(e) ? e : "en-US";
|
|
39
|
+
}
|
|
40
|
+
function A(e, t) {
|
|
41
|
+
if (e == null || isNaN(e))
|
|
42
|
+
return "";
|
|
43
|
+
const r = x(t == null ? void 0 : t.locale);
|
|
44
|
+
let a = e;
|
|
45
|
+
if (t != null && t.multiplyBy && (a *= t.multiplyBy), t != null && t.useSuffix) {
|
|
46
|
+
const { divisor: i, suffix: o } = D(a, r);
|
|
47
|
+
a = a / i;
|
|
48
|
+
const s = new Intl.NumberFormat(r, {
|
|
49
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
50
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
|
|
51
|
+
useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
|
|
52
|
+
}).format(a);
|
|
53
|
+
return `${(t == null ? void 0 : t.prefix) ?? ""}${s}${o}${(t == null ? void 0 : t.suffix) ?? ""}`;
|
|
54
|
+
}
|
|
55
|
+
const n = new Intl.NumberFormat(r, {
|
|
56
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
57
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
|
|
58
|
+
useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
|
|
59
|
+
}).format(a);
|
|
60
|
+
if (t != null && t.negativeInParentheses && a < 0) {
|
|
61
|
+
const i = n.replace("-", "");
|
|
62
|
+
return `(${(t == null ? void 0 : t.prefix) ?? ""}${i}${(t == null ? void 0 : t.suffix) ?? ""})`;
|
|
63
|
+
}
|
|
64
|
+
return `${(t == null ? void 0 : t.prefix) ?? ""}${n}${(t == null ? void 0 : t.suffix) ?? ""}`;
|
|
65
|
+
}
|
|
66
|
+
function B(e, t) {
|
|
67
|
+
if (e == null || isNaN(e))
|
|
68
|
+
return "";
|
|
69
|
+
const r = x(t == null ? void 0 : t.locale), a = (t == null ? void 0 : t.currency) || "USD", n = e < 0, i = !!(t != null && t.negativeInParentheses && n), o = i ? Math.abs(e) : e;
|
|
70
|
+
try {
|
|
71
|
+
if (t != null && t.useSuffix) {
|
|
72
|
+
const { divisor: m, suffix: l } = D(o, r), c = o / m, f = `${new Intl.NumberFormat(r, {
|
|
73
|
+
style: "currency",
|
|
74
|
+
currency: a,
|
|
75
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
76
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
|
|
77
|
+
useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
|
|
78
|
+
}).format(c)}${l}`;
|
|
79
|
+
return i ? `(${f})` : f;
|
|
80
|
+
}
|
|
81
|
+
const s = new Intl.NumberFormat(r, {
|
|
82
|
+
style: "currency",
|
|
83
|
+
currency: a,
|
|
84
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
85
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
|
|
86
|
+
useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
|
|
87
|
+
}).format(o);
|
|
88
|
+
return i ? `(${s})` : s;
|
|
89
|
+
} catch {
|
|
90
|
+
const s = Math.abs(e), m = t != null && t.useSuffix ? D(s, r) : { divisor: 1, suffix: "" }, l = A(
|
|
91
|
+
s / m.divisor,
|
|
92
|
+
{
|
|
93
|
+
locale: r,
|
|
94
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
95
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
|
|
96
|
+
useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
|
|
97
|
+
}
|
|
98
|
+
), c = `${a} ${l}${m.suffix}`;
|
|
99
|
+
return n ? t != null && t.negativeInParentheses ? `(${c})` : `-${c}` : c;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function U(e, t) {
|
|
103
|
+
if (e == null || isNaN(e))
|
|
104
|
+
return "";
|
|
105
|
+
const r = x(t == null ? void 0 : t.locale), n = (t == null ? void 0 : t.alreadyPercent) ?? (t == null ? void 0 : t.percentValueMode) === "whole" ? e / 100 : e;
|
|
106
|
+
return new Intl.NumberFormat(r, {
|
|
107
|
+
style: "percent",
|
|
108
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
109
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
|
|
110
|
+
useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
|
|
111
|
+
}).format(n);
|
|
112
|
+
}
|
|
113
|
+
function Z(e, t) {
|
|
114
|
+
if (e == null || isNaN(e))
|
|
115
|
+
return "";
|
|
116
|
+
const r = x(t == null ? void 0 : t.locale);
|
|
117
|
+
return new Intl.NumberFormat(r, {
|
|
118
|
+
notation: "scientific",
|
|
119
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
120
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2
|
|
121
|
+
}).format(e);
|
|
122
|
+
}
|
|
123
|
+
function de(e, t) {
|
|
124
|
+
if (e == null || Number.isNaN(e))
|
|
125
|
+
return "";
|
|
126
|
+
const r = t.scale === void 0 ? e : e * t.scale, a = t.negativeStyle === "parentheses" && r < 0, n = a ? Math.abs(r) : r, i = {
|
|
127
|
+
style: t.type === "number" ? "decimal" : t.type,
|
|
128
|
+
locale: t.locale,
|
|
129
|
+
currency: t.currency,
|
|
130
|
+
minimumFractionDigits: t.minimumFractionDigits,
|
|
131
|
+
maximumFractionDigits: t.maximumFractionDigits,
|
|
132
|
+
useGrouping: t.useGrouping,
|
|
133
|
+
percentValueMode: t.percentValueMode,
|
|
134
|
+
useSuffix: t.compact
|
|
135
|
+
};
|
|
136
|
+
let o;
|
|
137
|
+
switch (t.type) {
|
|
138
|
+
case "currency":
|
|
139
|
+
o = B(n, i);
|
|
140
|
+
break;
|
|
141
|
+
case "percent":
|
|
142
|
+
o = U(n, i);
|
|
143
|
+
break;
|
|
144
|
+
case "scientific":
|
|
145
|
+
o = Z(n, i);
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
o = A(n, i);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
const s = `${t.prefix ?? ""}${o}${t.suffix ?? ""}`;
|
|
152
|
+
return a ? `(${s})` : s;
|
|
153
|
+
}
|
|
154
|
+
function ot(e, t, r = "en-US") {
|
|
155
|
+
if (e == null || isNaN(e))
|
|
156
|
+
return "";
|
|
157
|
+
const a = x((t == null ? void 0 : t.locale) || r), n = (t == null ? void 0 : t.style) || "decimal", i = n === "decimal" ? "number" : n;
|
|
158
|
+
return i === "currency" && new Intl.NumberFormat(a, {
|
|
159
|
+
style: "currency",
|
|
160
|
+
currency: (t == null ? void 0 : t.currency) || "USD"
|
|
161
|
+
}), de(e, {
|
|
162
|
+
type: i,
|
|
163
|
+
locale: a,
|
|
164
|
+
currency: i === "currency" ? (t == null ? void 0 : t.currency) || "USD" : void 0,
|
|
165
|
+
minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
|
|
166
|
+
maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
|
|
167
|
+
useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0,
|
|
168
|
+
percentValueMode: i === "percent" ? (t == null ? void 0 : t.percentValueMode) ?? "whole" : void 0,
|
|
169
|
+
scale: t == null ? void 0 : t.scale,
|
|
170
|
+
compact: t == null ? void 0 : t.compact,
|
|
171
|
+
negativeStyle: t == null ? void 0 : t.negativeStyle,
|
|
172
|
+
prefix: t == null ? void 0 : t.prefix,
|
|
173
|
+
suffix: t == null ? void 0 : t.suffix
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function st(e, t, r) {
|
|
177
|
+
const a = {
|
|
178
|
+
style: t === "currency" ? "currency" : t === "percent" ? "percent" : "decimal",
|
|
179
|
+
locale: r == null ? void 0 : r.locale,
|
|
180
|
+
currency: r == null ? void 0 : r.currency,
|
|
181
|
+
minimumFractionDigits: r == null ? void 0 : r.decimalPlaces,
|
|
182
|
+
maximumFractionDigits: r == null ? void 0 : r.decimalPlaces,
|
|
183
|
+
useSuffix: r == null ? void 0 : r.useSuffix,
|
|
184
|
+
prefix: r == null ? void 0 : r.prefix,
|
|
185
|
+
suffix: r == null ? void 0 : r.suffix,
|
|
186
|
+
negativeInParentheses: r == null ? void 0 : r.negativeInParentheses,
|
|
187
|
+
multiplyBy: r == null ? void 0 : r.multiplyBy
|
|
188
|
+
};
|
|
189
|
+
switch (t) {
|
|
190
|
+
case "currency":
|
|
191
|
+
return B(e, a);
|
|
192
|
+
case "percent":
|
|
193
|
+
return U(e, a);
|
|
194
|
+
case "scientific":
|
|
195
|
+
return Z(e, a);
|
|
196
|
+
default:
|
|
197
|
+
return A(e, a);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const fe = [
|
|
201
|
+
"type",
|
|
202
|
+
"locale",
|
|
203
|
+
"minimumFractionDigits",
|
|
204
|
+
"maximumFractionDigits",
|
|
205
|
+
"useGrouping",
|
|
206
|
+
"prefix",
|
|
207
|
+
"suffix",
|
|
208
|
+
"negativeStyle",
|
|
209
|
+
"compact",
|
|
210
|
+
"scale",
|
|
211
|
+
"currency",
|
|
212
|
+
"percentValueMode"
|
|
213
|
+
];
|
|
214
|
+
function ye(e) {
|
|
215
|
+
if (!h(e))
|
|
216
|
+
return {
|
|
217
|
+
ok: !1,
|
|
218
|
+
issues: [{ path: "$", message: "Numeric format must be an object." }]
|
|
219
|
+
};
|
|
220
|
+
const t = [], r = new Set(fe);
|
|
221
|
+
Object.keys(e).filter((i) => !r.has(i)).forEach(
|
|
222
|
+
(i) => t.push({ path: i, message: `Unknown property "${i}".` })
|
|
223
|
+
), e.type !== "number" && e.type !== "currency" && e.type !== "percent" && e.type !== "scientific" && t.push({
|
|
224
|
+
path: "type",
|
|
225
|
+
message: "Expected number, currency, percent, or scientific."
|
|
226
|
+
});
|
|
227
|
+
const a = e.locale === void 0 ? void 0 : E(e.locale);
|
|
228
|
+
e.locale !== void 0 && !a && t.push({ path: "locale", message: "Expected a supported BCP 47 locale." });
|
|
229
|
+
const n = e.currency === void 0 ? void 0 : $(e.currency);
|
|
230
|
+
e.currency !== void 0 && !n && t.push({
|
|
231
|
+
path: "currency",
|
|
232
|
+
message: "Expected a supported ISO 4217 currency code."
|
|
233
|
+
});
|
|
234
|
+
for (const i of ["minimumFractionDigits", "maximumFractionDigits"]) {
|
|
235
|
+
const o = e[i];
|
|
236
|
+
o !== void 0 && (!Number.isInteger(o) || typeof o != "number" || o < 0 || o > 20) && t.push({
|
|
237
|
+
path: i,
|
|
238
|
+
message: "Expected an integer from 0 to 20."
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
typeof e.minimumFractionDigits == "number" && typeof e.maximumFractionDigits == "number" && e.minimumFractionDigits > e.maximumFractionDigits && t.push({
|
|
242
|
+
path: "maximumFractionDigits",
|
|
243
|
+
message: "Must be greater than or equal to minimumFractionDigits."
|
|
244
|
+
});
|
|
245
|
+
for (const i of ["useGrouping", "compact"])
|
|
246
|
+
e[i] !== void 0 && typeof e[i] != "boolean" && t.push({ path: i, message: "Expected a boolean." });
|
|
247
|
+
for (const i of ["prefix", "suffix"])
|
|
248
|
+
e[i] !== void 0 && typeof e[i] != "string" && t.push({ path: i, message: "Expected a string." });
|
|
249
|
+
return e.negativeStyle !== void 0 && e.negativeStyle !== "minus" && e.negativeStyle !== "parentheses" && t.push({
|
|
250
|
+
path: "negativeStyle",
|
|
251
|
+
message: "Expected minus or parentheses."
|
|
252
|
+
}), e.percentValueMode !== void 0 && e.percentValueMode !== "fraction" && e.percentValueMode !== "whole" && t.push({
|
|
253
|
+
path: "percentValueMode",
|
|
254
|
+
message: "Expected fraction or whole."
|
|
255
|
+
}), e.scale !== void 0 && (typeof e.scale != "number" || !Number.isFinite(e.scale)) && t.push({ path: "scale", message: "Expected a finite number." }), t.length > 0 ? { ok: !1, issues: t } : {
|
|
256
|
+
ok: !0,
|
|
257
|
+
value: {
|
|
258
|
+
type: e.type,
|
|
259
|
+
...a ? { locale: a } : {},
|
|
260
|
+
...e.minimumFractionDigits !== void 0 ? { minimumFractionDigits: e.minimumFractionDigits } : {},
|
|
261
|
+
...e.maximumFractionDigits !== void 0 ? { maximumFractionDigits: e.maximumFractionDigits } : {},
|
|
262
|
+
...e.useGrouping !== void 0 ? { useGrouping: e.useGrouping } : {},
|
|
263
|
+
...e.prefix !== void 0 ? { prefix: e.prefix } : {},
|
|
264
|
+
...e.suffix !== void 0 ? { suffix: e.suffix } : {},
|
|
265
|
+
...e.negativeStyle !== void 0 ? {
|
|
266
|
+
negativeStyle: e.negativeStyle
|
|
267
|
+
} : {},
|
|
268
|
+
...e.compact !== void 0 ? { compact: e.compact } : {},
|
|
269
|
+
...e.scale !== void 0 ? { scale: e.scale } : {},
|
|
270
|
+
...n ? { currency: n } : {},
|
|
271
|
+
...e.percentValueMode !== void 0 ? {
|
|
272
|
+
percentValueMode: e.percentValueMode
|
|
273
|
+
} : {}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function he(e) {
|
|
278
|
+
const t = ye(e);
|
|
279
|
+
if (!t.ok)
|
|
280
|
+
return t;
|
|
281
|
+
const r = [];
|
|
282
|
+
return t.value.locale || r.push({
|
|
283
|
+
path: "locale",
|
|
284
|
+
message: "Resolved numeric formats require an explicit locale."
|
|
285
|
+
}), t.value.minimumFractionDigits === void 0 && r.push({
|
|
286
|
+
path: "minimumFractionDigits",
|
|
287
|
+
message: "Resolved numeric formats require minimumFractionDigits."
|
|
288
|
+
}), t.value.maximumFractionDigits === void 0 && r.push({
|
|
289
|
+
path: "maximumFractionDigits",
|
|
290
|
+
message: "Resolved numeric formats require maximumFractionDigits."
|
|
291
|
+
}), t.value.type === "currency" && !t.value.currency && r.push({
|
|
292
|
+
path: "currency",
|
|
293
|
+
message: "Resolved currency formats require an explicit currency."
|
|
294
|
+
}), r.length > 0 ? { ok: !1, issues: r } : t;
|
|
295
|
+
}
|
|
296
|
+
function ct(e) {
|
|
297
|
+
var a;
|
|
298
|
+
const t = /* @__PURE__ */ new Set();
|
|
299
|
+
if (e.snapshot.resolvedFormats.forEach((n, i) => {
|
|
300
|
+
if (n.format.type !== "temporal_bucket") {
|
|
301
|
+
if (n.scope.attachmentIndex !== void 0)
|
|
302
|
+
throw new Error(
|
|
303
|
+
`resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`
|
|
304
|
+
);
|
|
305
|
+
if (n.scope.dashboardId !== e.expectedScope.dashboardId || n.scope.cardId !== e.expectedScope.cardId)
|
|
306
|
+
throw new Error(
|
|
307
|
+
`resolvedFormats.${i}.scope must match the executing dashboard/card`
|
|
308
|
+
);
|
|
309
|
+
if (n.target.kind !== "column")
|
|
310
|
+
throw new Error(
|
|
311
|
+
`resolvedFormats.${i}.target must identify an export column`
|
|
312
|
+
);
|
|
313
|
+
if (t.has(n.target.columnKey))
|
|
314
|
+
throw new Error(
|
|
315
|
+
`resolvedFormats.${i} duplicates export column "${n.target.columnKey}"`
|
|
316
|
+
);
|
|
317
|
+
t.add(n.target.columnKey);
|
|
318
|
+
}
|
|
319
|
+
}), !e.useFormattedValues)
|
|
320
|
+
return;
|
|
321
|
+
if (!((a = e.visibleColumns) != null && a.length))
|
|
322
|
+
throw new Error(
|
|
323
|
+
"visibleColumns must identify every formatted export column"
|
|
324
|
+
);
|
|
325
|
+
const r = e.visibleColumns.find(
|
|
326
|
+
(n) => !t.has(n)
|
|
327
|
+
);
|
|
328
|
+
if (r)
|
|
329
|
+
throw new Error(
|
|
330
|
+
`resolvedFormats is missing visible export column "${r}"`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
function ge(e, t) {
|
|
334
|
+
const r = new Intl.NumberFormat(e, {
|
|
335
|
+
style: "currency",
|
|
336
|
+
currency: t
|
|
337
|
+
}).resolvedOptions();
|
|
338
|
+
return {
|
|
339
|
+
minimumFractionDigits: r.minimumFractionDigits,
|
|
340
|
+
maximumFractionDigits: r.maximumFractionDigits
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function ve(e) {
|
|
344
|
+
if (e.minimumFractionDigits !== void 0 || e.maximumFractionDigits !== void 0) {
|
|
345
|
+
const r = e.minimumFractionDigits ?? 0;
|
|
346
|
+
return {
|
|
347
|
+
minimumFractionDigits: r,
|
|
348
|
+
maximumFractionDigits: e.maximumFractionDigits ?? Math.max(r, 2)
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const t = e.type === "percent" ? 1 : e.type === "scientific" ? 2 : 0;
|
|
352
|
+
return {
|
|
353
|
+
minimumFractionDigits: t,
|
|
354
|
+
maximumFractionDigits: t
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function mt(e, t, r) {
|
|
358
|
+
const a = E(e.locale) ?? t.locale, n = e.type === "number" || e.type === "currency" ? $(r) : void 0;
|
|
359
|
+
if (!(e.type === "currency" || n !== void 0))
|
|
360
|
+
return {
|
|
361
|
+
...e,
|
|
362
|
+
locale: a,
|
|
363
|
+
...ve(e)
|
|
364
|
+
};
|
|
365
|
+
const o = n ?? $(e.currency) ?? t.defaultCurrency, s = ge(
|
|
366
|
+
a,
|
|
367
|
+
o
|
|
368
|
+
), m = s.minimumFractionDigits ?? 0, l = s.maximumFractionDigits ?? m, c = e.minimumFractionDigits ?? Math.min(
|
|
369
|
+
m,
|
|
370
|
+
e.maximumFractionDigits ?? m
|
|
371
|
+
), y = e.maximumFractionDigits ?? Math.max(
|
|
372
|
+
c,
|
|
373
|
+
l
|
|
374
|
+
);
|
|
375
|
+
return {
|
|
376
|
+
...e,
|
|
377
|
+
type: "currency",
|
|
378
|
+
locale: a,
|
|
379
|
+
currency: o,
|
|
380
|
+
minimumFractionDigits: c,
|
|
381
|
+
maximumFractionDigits: y
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
class p extends Error {
|
|
385
|
+
constructor(r, a) {
|
|
386
|
+
super(a);
|
|
387
|
+
g(this, "code");
|
|
388
|
+
this.name = "RawTemporalFormatContractError", this.code = r;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const we = [
|
|
392
|
+
"SSSSSSSSS",
|
|
393
|
+
"SSSSSSSS",
|
|
394
|
+
"SSSSSSS",
|
|
395
|
+
"SSSSSS",
|
|
396
|
+
"SSSSS",
|
|
397
|
+
"SSSS",
|
|
398
|
+
"SSS",
|
|
399
|
+
"SS",
|
|
400
|
+
"S"
|
|
401
|
+
], H = /^(\d{4})-(\d{2})-(\d{2})$/, Y = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/, X = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})$/, pe = [
|
|
402
|
+
"yyyy",
|
|
403
|
+
"MMMM",
|
|
404
|
+
"LLLL",
|
|
405
|
+
"zzz",
|
|
406
|
+
"XXX",
|
|
407
|
+
"MMM",
|
|
408
|
+
"LLL",
|
|
409
|
+
"yy",
|
|
410
|
+
"MM",
|
|
411
|
+
"dd",
|
|
412
|
+
"HH",
|
|
413
|
+
"hh",
|
|
414
|
+
"mm",
|
|
415
|
+
"ss",
|
|
416
|
+
"M",
|
|
417
|
+
"d",
|
|
418
|
+
"H",
|
|
419
|
+
"h",
|
|
420
|
+
"m",
|
|
421
|
+
"s",
|
|
422
|
+
"a"
|
|
423
|
+
], xe = /* @__PURE__ */ new Set([
|
|
424
|
+
"HH",
|
|
425
|
+
"H",
|
|
426
|
+
"hh",
|
|
427
|
+
"h",
|
|
428
|
+
"mm",
|
|
429
|
+
"m",
|
|
430
|
+
"ss",
|
|
431
|
+
"s",
|
|
432
|
+
"a",
|
|
433
|
+
...we
|
|
434
|
+
]), Se = /* @__PURE__ */ new Set(["zzz", "XXX"]), F = /* @__PURE__ */ new Set(["short", "medium", "long"]);
|
|
435
|
+
function v(e, t) {
|
|
436
|
+
return Object.keys(e).length === t.length && t.every((a) => a in e);
|
|
437
|
+
}
|
|
438
|
+
function d(e) {
|
|
439
|
+
throw new p(
|
|
440
|
+
"invalid_raw_temporal_format",
|
|
441
|
+
e
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
function W(e) {
|
|
445
|
+
if (!e || e.trim() !== e || e.length > 256)
|
|
446
|
+
return d(
|
|
447
|
+
"date_fns patterns must be non-empty, trimmed, and at most 256 characters."
|
|
448
|
+
);
|
|
449
|
+
const t = [], r = (n) => {
|
|
450
|
+
const i = t[t.length - 1];
|
|
451
|
+
(i == null ? void 0 : i.kind) === "literal" ? i.value += n : t.push({ kind: "literal", value: n });
|
|
452
|
+
};
|
|
453
|
+
let a = 0;
|
|
454
|
+
for (; a < e.length; ) {
|
|
455
|
+
if (e[a] === "'") {
|
|
456
|
+
if (e[a + 1] === "'") {
|
|
457
|
+
r("'"), a += 2;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
let o = "", s = !1;
|
|
461
|
+
for (a += 1; a < e.length; ) {
|
|
462
|
+
if (e[a] === "'") {
|
|
463
|
+
if (e[a + 1] === "'") {
|
|
464
|
+
o += "'", a += 2;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
s = !0, a += 1;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
o += e[a], a += 1;
|
|
471
|
+
}
|
|
472
|
+
if (!s)
|
|
473
|
+
return d("date_fns pattern has an unclosed quote.");
|
|
474
|
+
r(o);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (e[a] === "S") {
|
|
478
|
+
let o = a + 1;
|
|
479
|
+
for (; e[o] === "S"; ) o += 1;
|
|
480
|
+
const s = e.slice(a, o);
|
|
481
|
+
if (s.length > 9)
|
|
482
|
+
return d(
|
|
483
|
+
"date_fns fractional-second tokens support at most nine digits."
|
|
484
|
+
);
|
|
485
|
+
t.push({
|
|
486
|
+
kind: "token",
|
|
487
|
+
value: s
|
|
488
|
+
}), a = o;
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
const n = pe.find(
|
|
492
|
+
(o) => e.startsWith(o, a)
|
|
493
|
+
);
|
|
494
|
+
if (n) {
|
|
495
|
+
t.push({ kind: "token", value: n }), a += n.length;
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
const i = e[a];
|
|
499
|
+
if (/[A-Za-z]/.test(i))
|
|
500
|
+
return d(
|
|
501
|
+
`Unsupported date_fns pattern token beginning at "${e.slice(a)}".`
|
|
502
|
+
);
|
|
503
|
+
r(i), a += 1;
|
|
504
|
+
}
|
|
505
|
+
return t.some((n) => n.kind === "token") ? t : d("date_fns patterns must contain at least one token.");
|
|
506
|
+
}
|
|
507
|
+
function J(e, t) {
|
|
508
|
+
if (e === "semaphor_tokens") {
|
|
509
|
+
const r = G(t);
|
|
510
|
+
r.ok || d(r.message);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
W(t);
|
|
514
|
+
}
|
|
515
|
+
function be(e) {
|
|
516
|
+
return !h(e) || !v(e, ["dateStyle", "dateTime"]) ? d("Automatic raw temporal styles are incomplete.") : F.has(e.dateStyle) ? !h(e.dateTime) || !v(e.dateTime, ["dateStyle", "timeStyle"]) || !F.has(e.dateTime.dateStyle) || !F.has(e.dateTime.timeStyle) ? d(
|
|
517
|
+
"Automatic dateTime styles are incomplete or invalid."
|
|
518
|
+
) : {
|
|
519
|
+
dateStyle: e.dateStyle,
|
|
520
|
+
dateTime: {
|
|
521
|
+
dateStyle: e.dateTime.dateStyle,
|
|
522
|
+
timeStyle: e.dateTime.timeStyle
|
|
523
|
+
}
|
|
524
|
+
} : d("Automatic dateStyle is invalid.");
|
|
525
|
+
}
|
|
526
|
+
function R(e) {
|
|
527
|
+
const t = ["type", "locale", "calendarTimezone", "presentation"], r = [...t, "sourceTimezone"];
|
|
528
|
+
if (!h(e) || !v(e, t) && !v(e, r) || e.type !== "raw_temporal")
|
|
529
|
+
return d("Resolved raw temporal format has an invalid shape.");
|
|
530
|
+
const a = E(e.locale);
|
|
531
|
+
return a ? typeof e.calendarTimezone != "string" || !k(e.calendarTimezone) ? d(
|
|
532
|
+
"Raw temporal calendarTimezone must be a valid IANA timezone."
|
|
533
|
+
) : e.sourceTimezone !== void 0 && (typeof e.sourceTimezone != "string" || !k(e.sourceTimezone)) ? d(
|
|
534
|
+
"Raw temporal sourceTimezone must be a valid IANA timezone."
|
|
535
|
+
) : h(e.presentation) ? e.presentation.mode === "auto" ? v(e.presentation, ["mode", "styles"]) ? {
|
|
536
|
+
type: "raw_temporal",
|
|
537
|
+
locale: a,
|
|
538
|
+
calendarTimezone: e.calendarTimezone,
|
|
539
|
+
...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
|
|
540
|
+
presentation: {
|
|
541
|
+
mode: "auto",
|
|
542
|
+
styles: be(e.presentation.styles)
|
|
543
|
+
}
|
|
544
|
+
} : d(
|
|
545
|
+
"Automatic raw temporal presentation has unknown fields."
|
|
546
|
+
) : e.presentation.mode !== "pattern" || !v(e.presentation, ["mode", "dialect", "pattern"]) || e.presentation.dialect !== "semaphor_tokens" && e.presentation.dialect !== "date_fns" || typeof e.presentation.pattern != "string" ? d(
|
|
547
|
+
"Pattern raw temporal presentation has an invalid shape."
|
|
548
|
+
) : (J(e.presentation.dialect, e.presentation.pattern), {
|
|
549
|
+
type: "raw_temporal",
|
|
550
|
+
locale: a,
|
|
551
|
+
calendarTimezone: e.calendarTimezone,
|
|
552
|
+
...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
|
|
553
|
+
presentation: {
|
|
554
|
+
mode: "pattern",
|
|
555
|
+
dialect: e.presentation.dialect,
|
|
556
|
+
pattern: e.presentation.pattern
|
|
557
|
+
}
|
|
558
|
+
}) : d("Raw temporal presentation must be an object.") : d("Raw temporal locale is invalid or unsupported.");
|
|
559
|
+
}
|
|
560
|
+
function lt(e) {
|
|
561
|
+
var s, m, l;
|
|
562
|
+
if (e.format) {
|
|
563
|
+
if (!h(e.format))
|
|
564
|
+
return d(
|
|
565
|
+
"Authored raw temporal format has an invalid shape."
|
|
566
|
+
);
|
|
567
|
+
const c = Object.keys(e.format);
|
|
568
|
+
if (!c.includes("type") || !c.includes("presentation") || c.some(
|
|
569
|
+
(f) => f !== "type" && f !== "presentation" && f !== "timezone" && f !== "sourceTimezone"
|
|
570
|
+
) || e.format.type !== "raw_temporal" || !h(e.format.presentation))
|
|
571
|
+
return d(
|
|
572
|
+
"Authored raw temporal format has an invalid shape."
|
|
573
|
+
);
|
|
574
|
+
const y = e.format.presentation;
|
|
575
|
+
if (y.mode === "auto") {
|
|
576
|
+
if (!v(y, ["mode"]))
|
|
577
|
+
return d(
|
|
578
|
+
"Automatic authored raw temporal format has unknown fields."
|
|
579
|
+
);
|
|
580
|
+
} else {
|
|
581
|
+
if (y.mode !== "pattern" || !v(y, ["mode", "dialect", "pattern"]) || y.dialect !== "semaphor_tokens" && y.dialect !== "date_fns" || typeof y.pattern != "string")
|
|
582
|
+
return d(
|
|
583
|
+
"Authored raw temporal pattern has an invalid shape."
|
|
584
|
+
);
|
|
585
|
+
J(y.dialect, y.pattern);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const t = (s = e.format) == null ? void 0 : s.timezone, r = (m = e.format) == null ? void 0 : m.sourceTimezone, a = t && t !== "auto" ? t : e.calendar.tz, n = r && r !== "auto" ? r === "local" ? Intl.DateTimeFormat().resolvedOptions().timeZone : r : void 0;
|
|
589
|
+
if (t !== void 0 && t !== "auto" && !k(a) || n !== void 0 && !k(n))
|
|
590
|
+
return d("Authored raw temporal timezone is invalid.");
|
|
591
|
+
const i = ((l = e.format) == null ? void 0 : l.presentation) ?? { mode: "auto" }, o = {
|
|
592
|
+
type: "raw_temporal",
|
|
593
|
+
locale: e.preferences.locale,
|
|
594
|
+
calendarTimezone: a,
|
|
595
|
+
...n ? { sourceTimezone: n } : {},
|
|
596
|
+
presentation: i.mode === "pattern" ? { ...i } : {
|
|
597
|
+
mode: "auto",
|
|
598
|
+
styles: {
|
|
599
|
+
dateStyle: e.preferences.dateStyle,
|
|
600
|
+
dateTime: { ...e.preferences.dateTime }
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
return R(o);
|
|
605
|
+
}
|
|
606
|
+
function _e(e) {
|
|
607
|
+
if (H.test(e)) return "date";
|
|
608
|
+
if (X.test(e)) return "instant";
|
|
609
|
+
if (Y.test(e)) return "wall_datetime";
|
|
610
|
+
}
|
|
611
|
+
function ut(e) {
|
|
612
|
+
const t = /* @__PURE__ */ new Set();
|
|
613
|
+
let r = !1;
|
|
614
|
+
for (const a of e.values) {
|
|
615
|
+
if (a === null) continue;
|
|
616
|
+
r = !0;
|
|
617
|
+
const n = _e(a);
|
|
618
|
+
n && t.add(n);
|
|
619
|
+
}
|
|
620
|
+
if (!r) return { status: "empty" };
|
|
621
|
+
if (t.size === 0) return { status: "invalid_only" };
|
|
622
|
+
if (t.size > 1)
|
|
623
|
+
throw new p(
|
|
624
|
+
"mixed_sql_temporal_semantics",
|
|
625
|
+
`Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`
|
|
626
|
+
);
|
|
627
|
+
return {
|
|
628
|
+
status: "classified",
|
|
629
|
+
metadata: {
|
|
630
|
+
kind: "raw_temporal",
|
|
631
|
+
valueKind: [...t][0]
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
function dt(e) {
|
|
636
|
+
return {
|
|
637
|
+
version: 1,
|
|
638
|
+
columns: Object.fromEntries(
|
|
639
|
+
[...e].map(([t, r]) => [
|
|
640
|
+
t,
|
|
641
|
+
r.status === "classified" ? r.metadata.valueKind : r.status
|
|
642
|
+
])
|
|
643
|
+
)
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function Te(e) {
|
|
647
|
+
if (!h(e) || e.version !== 1 || !h(e.columns) || Object.keys(e).some((a) => a !== "version" && a !== "columns"))
|
|
648
|
+
throw new p(
|
|
649
|
+
"invalid_raw_temporal_format",
|
|
650
|
+
"Raw temporal chunk classification evidence is malformed."
|
|
651
|
+
);
|
|
652
|
+
const t = {}, r = /* @__PURE__ */ new Set([
|
|
653
|
+
"empty",
|
|
654
|
+
"invalid_only",
|
|
655
|
+
"date",
|
|
656
|
+
"wall_datetime",
|
|
657
|
+
"instant"
|
|
658
|
+
]);
|
|
659
|
+
for (const [a, n] of Object.entries(e.columns)) {
|
|
660
|
+
if (!a.trim() || !r.has(n))
|
|
661
|
+
throw new p(
|
|
662
|
+
"invalid_raw_temporal_format",
|
|
663
|
+
"Raw temporal chunk classification evidence contains an invalid column or status."
|
|
664
|
+
);
|
|
665
|
+
t[a] = n;
|
|
666
|
+
}
|
|
667
|
+
return { version: 1, columns: t };
|
|
668
|
+
}
|
|
669
|
+
function ft(e) {
|
|
670
|
+
if (e.length === 0) return;
|
|
671
|
+
const t = e.map(Te), r = Object.keys(t[0].columns).sort();
|
|
672
|
+
for (let a = 1; a < t.length; a += 1) {
|
|
673
|
+
const n = Object.keys(t[a].columns).sort();
|
|
674
|
+
if (n.length !== r.length || n.some((i, o) => i !== r[o]))
|
|
675
|
+
throw new p(
|
|
676
|
+
"invalid_raw_temporal_format",
|
|
677
|
+
"Raw temporal chunk classification evidence has inconsistent columns."
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
for (const a of r)
|
|
681
|
+
if (new Set(
|
|
682
|
+
t.map((i) => i.columns[a]).filter(
|
|
683
|
+
(i) => i !== "empty" && i !== "invalid_only"
|
|
684
|
+
)
|
|
685
|
+
).size > 1)
|
|
686
|
+
throw new p(
|
|
687
|
+
"mixed_sql_temporal_semantics",
|
|
688
|
+
`Declared SQL temporal column "${a}" has inconsistent semantics across export chunks. Normalize it to one kind.`
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
function ke(e) {
|
|
692
|
+
return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
|
|
693
|
+
}
|
|
694
|
+
function Ie(e, t) {
|
|
695
|
+
return t === 2 ? ke(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
|
|
696
|
+
}
|
|
697
|
+
function Fe(e) {
|
|
698
|
+
return e.year >= 1 && e.year <= 9999 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= Ie(e.year, e.month) && e.hour >= 0 && e.hour <= 23 && e.minute >= 0 && e.minute <= 59 && e.second >= 0 && e.second <= 59;
|
|
699
|
+
}
|
|
700
|
+
function $e(e) {
|
|
701
|
+
return {
|
|
702
|
+
year: Number(e[1]),
|
|
703
|
+
month: Number(e[2]),
|
|
704
|
+
day: Number(e[3]),
|
|
705
|
+
hour: Number(e[4] ?? 0),
|
|
706
|
+
minute: Number(e[5] ?? 0),
|
|
707
|
+
second: Number(e[6] ?? 0),
|
|
708
|
+
fraction: e[7] ?? ""
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function De(e, t) {
|
|
712
|
+
const r = t === "date" ? e.match(H) : t === "wall_datetime" ? e.match(Y) : e.match(X);
|
|
713
|
+
if (!r) return { status: "invalid_shape" };
|
|
714
|
+
const a = $e(r);
|
|
715
|
+
if (!Fe(a)) return { status: "out_of_range" };
|
|
716
|
+
if (t === "instant") {
|
|
717
|
+
const n = r[8];
|
|
718
|
+
if (n && n !== "Z") {
|
|
719
|
+
const [o, s] = n.slice(1).split(":").map(Number);
|
|
720
|
+
if (o > 23 || s > 59) return { status: "out_of_range" };
|
|
721
|
+
}
|
|
722
|
+
const i = new Date(e.replace(" ", "T"));
|
|
723
|
+
return Number.isNaN(i.getTime()) ? { status: "out_of_range" } : { status: "valid", fields: a, instant: i };
|
|
724
|
+
}
|
|
725
|
+
return { status: "valid", fields: a };
|
|
726
|
+
}
|
|
727
|
+
function C(e) {
|
|
728
|
+
const t = /* @__PURE__ */ new Date(0);
|
|
729
|
+
return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
|
|
730
|
+
}
|
|
731
|
+
function Q(e, t) {
|
|
732
|
+
const r = e.fraction ? `.${e.fraction.padEnd(3, "0").slice(0, 3)}` : "";
|
|
733
|
+
return oe(
|
|
734
|
+
`${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}T${String(e.hour).padStart(2, "0")}:${String(e.minute).padStart(2, "0")}:${String(e.second).padStart(2, "0")}${r}`,
|
|
735
|
+
t
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
function Ce(e, t) {
|
|
739
|
+
const r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
740
|
+
let n, i, o, s;
|
|
741
|
+
return {
|
|
742
|
+
number(m, l = 1) {
|
|
743
|
+
let c = r.get(l);
|
|
744
|
+
return c || (c = new Intl.NumberFormat(e, {
|
|
745
|
+
useGrouping: !1,
|
|
746
|
+
minimumIntegerDigits: l,
|
|
747
|
+
maximumFractionDigits: 0
|
|
748
|
+
}), r.set(l, c)), c.format(m);
|
|
749
|
+
},
|
|
750
|
+
month(m, l, c) {
|
|
751
|
+
var b;
|
|
752
|
+
const y = `${l}:${c ? "standalone" : "contextual"}`;
|
|
753
|
+
let f = a.get(y);
|
|
754
|
+
if (!f) {
|
|
755
|
+
const _ = {
|
|
756
|
+
calendar: "gregory",
|
|
757
|
+
timeZone: "UTC",
|
|
758
|
+
month: l
|
|
759
|
+
};
|
|
760
|
+
c || (_.day = "numeric"), f = new Intl.DateTimeFormat(e, _), a.set(y, f);
|
|
761
|
+
}
|
|
762
|
+
return ((b = f.formatToParts(m).find((_) => _.type === "month")) == null ? void 0 : b.value) ?? "";
|
|
763
|
+
},
|
|
764
|
+
dayPeriod(m) {
|
|
765
|
+
var l;
|
|
766
|
+
return n ?? (n = new Intl.DateTimeFormat(e, {
|
|
767
|
+
calendar: "gregory",
|
|
768
|
+
timeZone: "UTC",
|
|
769
|
+
hour: "numeric",
|
|
770
|
+
hour12: !0
|
|
771
|
+
})), ((l = n.formatToParts(m).find((c) => c.type === "dayPeriod")) == null ? void 0 : l.value) ?? "";
|
|
772
|
+
},
|
|
773
|
+
instantFields(m) {
|
|
774
|
+
i ?? (i = new Intl.DateTimeFormat("en-CA", {
|
|
775
|
+
calendar: "gregory",
|
|
776
|
+
numberingSystem: "latn",
|
|
777
|
+
timeZone: t,
|
|
778
|
+
year: "numeric",
|
|
779
|
+
month: "2-digit",
|
|
780
|
+
day: "2-digit",
|
|
781
|
+
hour: "2-digit",
|
|
782
|
+
minute: "2-digit",
|
|
783
|
+
second: "2-digit",
|
|
784
|
+
hourCycle: "h23"
|
|
785
|
+
}));
|
|
786
|
+
const l = i.formatToParts(m), c = (y) => {
|
|
787
|
+
var f;
|
|
788
|
+
return Number((f = l.find((b) => b.type === y)) == null ? void 0 : f.value);
|
|
789
|
+
};
|
|
790
|
+
return {
|
|
791
|
+
year: c("year"),
|
|
792
|
+
month: c("month"),
|
|
793
|
+
day: c("day"),
|
|
794
|
+
hour: c("hour"),
|
|
795
|
+
minute: c("minute"),
|
|
796
|
+
second: c("second"),
|
|
797
|
+
fraction: ""
|
|
798
|
+
};
|
|
799
|
+
},
|
|
800
|
+
timezoneName(m) {
|
|
801
|
+
var l;
|
|
802
|
+
return o ?? (o = new Intl.DateTimeFormat(e, {
|
|
803
|
+
calendar: "gregory",
|
|
804
|
+
timeZone: t,
|
|
805
|
+
timeZoneName: "short"
|
|
806
|
+
})), ((l = o.formatToParts(m).find((c) => c.type === "timeZoneName")) == null ? void 0 : l.value) ?? "";
|
|
807
|
+
},
|
|
808
|
+
timezoneOffset(m) {
|
|
809
|
+
var y;
|
|
810
|
+
s ?? (s = new Intl.DateTimeFormat("en-US", {
|
|
811
|
+
calendar: "gregory",
|
|
812
|
+
timeZone: t,
|
|
813
|
+
timeZoneName: "longOffset"
|
|
814
|
+
}));
|
|
815
|
+
const l = (y = s.formatToParts(m).find((f) => f.type === "timeZoneName")) == null ? void 0 : y.value;
|
|
816
|
+
if (!l)
|
|
817
|
+
return d("Unable to resolve the instant timezone offset.");
|
|
818
|
+
const c = l.replace(/^GMT/, "");
|
|
819
|
+
return c === "" || /^[+-]00:00$/.test(c) ? "Z" : c;
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
function Ee(e, t, r, a, n) {
|
|
824
|
+
if (/^S{1,9}$/.test(e)) {
|
|
825
|
+
const i = t.fraction.padEnd(e.length, "0").slice(0, e.length);
|
|
826
|
+
return a.number(Number(i), e.length);
|
|
827
|
+
}
|
|
828
|
+
switch (e) {
|
|
829
|
+
case "YYYY":
|
|
830
|
+
case "yyyy":
|
|
831
|
+
return a.number(t.year, 4);
|
|
832
|
+
case "YY":
|
|
833
|
+
case "yy":
|
|
834
|
+
return a.number(t.year % 100, 2);
|
|
835
|
+
case "MMMM":
|
|
836
|
+
return a.month(r, "long", !1);
|
|
837
|
+
case "LLLL":
|
|
838
|
+
return a.month(r, "long", !0);
|
|
839
|
+
case "MMM":
|
|
840
|
+
return a.month(r, "short", !1);
|
|
841
|
+
case "LLL":
|
|
842
|
+
return a.month(r, "short", !0);
|
|
843
|
+
case "MM":
|
|
844
|
+
return a.number(t.month, 2);
|
|
845
|
+
case "M":
|
|
846
|
+
return a.number(t.month);
|
|
847
|
+
case "DD":
|
|
848
|
+
case "dd":
|
|
849
|
+
return a.number(t.day, 2);
|
|
850
|
+
case "d":
|
|
851
|
+
return a.number(t.day);
|
|
852
|
+
case "HH":
|
|
853
|
+
return a.number(t.hour, 2);
|
|
854
|
+
case "H":
|
|
855
|
+
return a.number(t.hour);
|
|
856
|
+
case "hh":
|
|
857
|
+
return a.number(t.hour % 12 || 12, 2);
|
|
858
|
+
case "h":
|
|
859
|
+
return a.number(t.hour % 12 || 12);
|
|
860
|
+
case "mm":
|
|
861
|
+
return a.number(t.minute, 2);
|
|
862
|
+
case "m":
|
|
863
|
+
return a.number(t.minute);
|
|
864
|
+
case "ss":
|
|
865
|
+
return a.number(t.second, 2);
|
|
866
|
+
case "s":
|
|
867
|
+
return a.number(t.second);
|
|
868
|
+
case "a":
|
|
869
|
+
return a.dayPeriod(r);
|
|
870
|
+
case "zzz":
|
|
871
|
+
return n ? a.timezoneName(n) : d(
|
|
872
|
+
"Timezone pattern tokens require an instant value."
|
|
873
|
+
);
|
|
874
|
+
case "XXX":
|
|
875
|
+
return n ? a.timezoneOffset(n) : d(
|
|
876
|
+
"Timezone pattern tokens require an instant value."
|
|
877
|
+
);
|
|
878
|
+
default:
|
|
879
|
+
return d(
|
|
880
|
+
`Unsupported raw temporal pattern token "${e}".`
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
function Ae(e, t, r, a) {
|
|
885
|
+
const n = C(t);
|
|
886
|
+
return e.map(
|
|
887
|
+
(i) => i.kind === "literal" ? i.value : Ee(i.value, t, n, r, a)
|
|
888
|
+
).join("");
|
|
889
|
+
}
|
|
890
|
+
function Re(e, t, r, a) {
|
|
891
|
+
const n = r === "date_fns" ? W(a) : (() => {
|
|
892
|
+
const s = G(a);
|
|
893
|
+
return s.ok ? s.segments : d(s.message);
|
|
894
|
+
})(), i = n.filter((s) => s.kind === "token").map((s) => s.value);
|
|
895
|
+
if (e.valueKind === "date" && i.some((s) => xe.has(s)))
|
|
896
|
+
return d("Date patterns cannot contain time tokens.");
|
|
897
|
+
if (e.valueKind !== "instant" && i.some((s) => Se.has(s)))
|
|
898
|
+
return d("Timezone pattern tokens require an instant value.");
|
|
899
|
+
const o = Ce(t.locale, t.calendarTimezone);
|
|
900
|
+
return (s) => {
|
|
901
|
+
const m = e.valueKind === "wall_datetime" && t.sourceTimezone ? Q(s.fields, t.sourceTimezone) : void 0, l = e.valueKind === "instant" ? {
|
|
902
|
+
...o.instantFields(s.instant),
|
|
903
|
+
fraction: s.fields.fraction
|
|
904
|
+
} : m ? {
|
|
905
|
+
...o.instantFields(m),
|
|
906
|
+
fraction: s.fields.fraction
|
|
907
|
+
} : s.fields;
|
|
908
|
+
return Ae(n, l, o, s.instant ?? m);
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function Me(e, t) {
|
|
912
|
+
const r = t.presentation.mode === "auto" ? t.presentation.styles : d("Automatic raw temporal formatting requires styles.");
|
|
913
|
+
if (e.valueKind === "date") {
|
|
914
|
+
const o = new Intl.DateTimeFormat(t.locale, {
|
|
915
|
+
calendar: "gregory",
|
|
916
|
+
timeZone: "UTC",
|
|
917
|
+
dateStyle: r.dateStyle
|
|
918
|
+
});
|
|
919
|
+
return (s) => o.format(C(s.fields));
|
|
920
|
+
}
|
|
921
|
+
const a = e.valueKind === "instant", n = !a && r.dateTime.timeStyle === "long" ? "medium" : r.dateTime.timeStyle, i = new Intl.DateTimeFormat(t.locale, {
|
|
922
|
+
calendar: "gregory",
|
|
923
|
+
timeZone: a || e.valueKind === "wall_datetime" && t.sourceTimezone ? t.calendarTimezone : "UTC",
|
|
924
|
+
dateStyle: r.dateTime.dateStyle,
|
|
925
|
+
timeStyle: n
|
|
926
|
+
});
|
|
927
|
+
return (o) => a ? i.format(o.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? i.format(Q(o.fields, t.sourceTimezone)) : i.format(C(o.fields));
|
|
928
|
+
}
|
|
929
|
+
function P(e, t, r) {
|
|
930
|
+
return {
|
|
931
|
+
ok: !1,
|
|
932
|
+
text: e,
|
|
933
|
+
diagnostic: {
|
|
934
|
+
code: r,
|
|
935
|
+
message: `Raw temporal ${t.valueKind} value is ${r === "invalid_raw_temporal_value" ? "malformed" : "out of range"}.`
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
function Ke(e) {
|
|
940
|
+
const t = ae(e.metadata), r = R(e.format), a = r.presentation.mode === "auto" ? Me(t, r) : Re(
|
|
941
|
+
t,
|
|
942
|
+
r,
|
|
943
|
+
r.presentation.dialect,
|
|
944
|
+
r.presentation.pattern
|
|
945
|
+
);
|
|
946
|
+
return (n) => {
|
|
947
|
+
if (n === null)
|
|
948
|
+
return { ok: !0, text: "", status: "empty" };
|
|
949
|
+
const i = De(n, t.valueKind);
|
|
950
|
+
return i.status === "invalid_shape" ? P(n, t, "invalid_raw_temporal_value") : i.status === "out_of_range" ? P(n, t, "out_of_range_raw_temporal_value") : { ok: !0, text: a(i), status: "formatted" };
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function yt(e) {
|
|
954
|
+
return Ke({
|
|
955
|
+
metadata: e.metadata,
|
|
956
|
+
format: e.format
|
|
957
|
+
})(e.value);
|
|
958
|
+
}
|
|
959
|
+
class j extends Error {
|
|
960
|
+
constructor(r) {
|
|
961
|
+
super(
|
|
962
|
+
`invalid_presentation_execution_snapshot: ${r} Resave this report before running it again.`
|
|
963
|
+
);
|
|
964
|
+
g(this, "code", "invalid_presentation_execution_snapshot");
|
|
965
|
+
g(this, "deliveryBlocking", !0);
|
|
966
|
+
this.name = "PresentationExecutionSnapshotError";
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
class ht extends Error {
|
|
970
|
+
constructor(r) {
|
|
971
|
+
super(
|
|
972
|
+
`missing_resolved_raw_temporal_format: Column "${r}" has no captured presentation. Resave this report before running it again.`
|
|
973
|
+
);
|
|
974
|
+
g(this, "code", "missing_resolved_raw_temporal_format");
|
|
975
|
+
g(this, "deliveryBlocking", !0);
|
|
976
|
+
this.name = "MissingResolvedRawTemporalFormatError";
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
function S(e, t, r) {
|
|
980
|
+
const a = new Set(t), n = Object.keys(e).find((i) => !a.has(i));
|
|
981
|
+
if (n)
|
|
982
|
+
throw new Error(`${r} contains unknown property "${n}"`);
|
|
983
|
+
}
|
|
984
|
+
function Ne(e, t = "scope") {
|
|
985
|
+
if (!h(e))
|
|
986
|
+
throw new Error(`${t} must be an object`);
|
|
987
|
+
S(
|
|
988
|
+
e,
|
|
989
|
+
["dashboardId", "cardId", "attachmentIndex"],
|
|
990
|
+
t
|
|
991
|
+
);
|
|
992
|
+
const r = typeof e.dashboardId == "string" ? e.dashboardId.trim() : "";
|
|
993
|
+
if (!r)
|
|
994
|
+
throw new Error(`${t}.dashboardId is required`);
|
|
995
|
+
const a = typeof e.cardId == "string" ? e.cardId.trim() : void 0;
|
|
996
|
+
if (e.cardId !== void 0 && !a)
|
|
997
|
+
throw new Error(`${t}.cardId must be a non-empty string`);
|
|
998
|
+
const n = e.attachmentIndex;
|
|
999
|
+
if (n !== void 0 && (typeof n != "number" || !Number.isInteger(n) || n < 0))
|
|
1000
|
+
throw new Error(
|
|
1001
|
+
`${t}.attachmentIndex must be a non-negative integer`
|
|
1002
|
+
);
|
|
1003
|
+
return {
|
|
1004
|
+
dashboardId: r,
|
|
1005
|
+
...a ? { cardId: a } : {},
|
|
1006
|
+
...typeof n == "number" ? { attachmentIndex: n } : {}
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
function w(e, t, r, a) {
|
|
1010
|
+
if (e.kind !== t) return;
|
|
1011
|
+
S(e, ["kind", r], a);
|
|
1012
|
+
const n = typeof e[r] == "string" ? e[r].trim() : "";
|
|
1013
|
+
if (!n)
|
|
1014
|
+
throw new Error(`${a}.${r} is required`);
|
|
1015
|
+
return n;
|
|
1016
|
+
}
|
|
1017
|
+
function ze(e, t) {
|
|
1018
|
+
if (!h(e))
|
|
1019
|
+
throw new Error(`${t} must be an object`);
|
|
1020
|
+
const r = w(e, "metric", "metricId", t);
|
|
1021
|
+
if (r) return { kind: "metric", metricId: r };
|
|
1022
|
+
const a = w(e, "column", "columnKey", t);
|
|
1023
|
+
if (a) return { kind: "column", columnKey: a };
|
|
1024
|
+
const n = w(
|
|
1025
|
+
e,
|
|
1026
|
+
"matrix_measure",
|
|
1027
|
+
"measureId",
|
|
1028
|
+
t
|
|
1029
|
+
);
|
|
1030
|
+
if (n) return { kind: "matrix_measure", measureId: n };
|
|
1031
|
+
throw new Error(`${t} is not a valid numeric presentation target`);
|
|
1032
|
+
}
|
|
1033
|
+
function Pe(e, t) {
|
|
1034
|
+
if (!h(e))
|
|
1035
|
+
throw new Error(`${t} must be an object`);
|
|
1036
|
+
if (e.kind === "field") {
|
|
1037
|
+
S(e, ["kind", "fieldId", "role"], t);
|
|
1038
|
+
const n = typeof e.fieldId == "string" ? e.fieldId.trim() : "";
|
|
1039
|
+
if (!n)
|
|
1040
|
+
throw new Error(`${t}.fieldId is required`);
|
|
1041
|
+
const i = e.role;
|
|
1042
|
+
if (i !== void 0 && i !== "groupby" && i !== "pivotby")
|
|
1043
|
+
throw new Error(`${t}.role must be groupby or pivotby`);
|
|
1044
|
+
return {
|
|
1045
|
+
kind: "field",
|
|
1046
|
+
fieldId: n,
|
|
1047
|
+
...i ? { role: i } : {}
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
const r = w(e, "column", "columnKey", t);
|
|
1051
|
+
if (r) return { kind: "column", columnKey: r };
|
|
1052
|
+
const a = w(
|
|
1053
|
+
e,
|
|
1054
|
+
"matrix_axis",
|
|
1055
|
+
"axisInstanceId",
|
|
1056
|
+
t
|
|
1057
|
+
);
|
|
1058
|
+
if (a) return { kind: "matrix_axis", axisInstanceId: a };
|
|
1059
|
+
throw new Error(`${t} is not a valid temporal bucket presentation target`);
|
|
1060
|
+
}
|
|
1061
|
+
function je(e, t) {
|
|
1062
|
+
if (!h(e))
|
|
1063
|
+
throw new Error(`${t} must be an object`);
|
|
1064
|
+
const r = w(e, "column", "columnKey", t);
|
|
1065
|
+
if (!r)
|
|
1066
|
+
throw new Error(`${t} must identify a column`);
|
|
1067
|
+
return { kind: "column", columnKey: r };
|
|
1068
|
+
}
|
|
1069
|
+
function Oe(e) {
|
|
1070
|
+
return [
|
|
1071
|
+
e.dashboardId,
|
|
1072
|
+
e.cardId ?? null,
|
|
1073
|
+
e.attachmentIndex ?? null
|
|
1074
|
+
];
|
|
1075
|
+
}
|
|
1076
|
+
function I(e) {
|
|
1077
|
+
switch (e.kind) {
|
|
1078
|
+
case "metric":
|
|
1079
|
+
return [e.kind, e.metricId];
|
|
1080
|
+
case "column":
|
|
1081
|
+
return [e.kind, e.columnKey];
|
|
1082
|
+
case "matrix_measure":
|
|
1083
|
+
return [e.kind, e.measureId];
|
|
1084
|
+
case "field":
|
|
1085
|
+
return [e.kind, e.fieldId, e.role ?? ""];
|
|
1086
|
+
case "matrix_axis":
|
|
1087
|
+
return [e.kind, e.axisInstanceId];
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
function M(e, t) {
|
|
1091
|
+
return e.dashboardId === t.dashboardId && e.cardId === t.cardId && e.attachmentIndex === t.attachmentIndex;
|
|
1092
|
+
}
|
|
1093
|
+
function K(e, t) {
|
|
1094
|
+
const r = I(e), a = I(t);
|
|
1095
|
+
return r.length === a.length && r.every((n, i) => n === a[i]);
|
|
1096
|
+
}
|
|
1097
|
+
function Le(e) {
|
|
1098
|
+
if (!Array.isArray(e))
|
|
1099
|
+
throw new Error("resolvedFormats must be an array");
|
|
1100
|
+
const t = /* @__PURE__ */ new Set();
|
|
1101
|
+
return e.map((r, a) => {
|
|
1102
|
+
var m, l;
|
|
1103
|
+
const n = `resolvedFormats.${a}`;
|
|
1104
|
+
if (!h(r))
|
|
1105
|
+
throw new Error(`${n} must be an object`);
|
|
1106
|
+
S(r, ["scope", "target", "format"], n);
|
|
1107
|
+
const i = Ne(r.scope, `${n}.scope`);
|
|
1108
|
+
if (!h(r.format))
|
|
1109
|
+
throw new Error(`${n}.format must be an object`);
|
|
1110
|
+
let o;
|
|
1111
|
+
switch (r.format.type) {
|
|
1112
|
+
case "temporal_bucket": {
|
|
1113
|
+
const c = ne(r.format);
|
|
1114
|
+
if (!c.ok)
|
|
1115
|
+
throw new Error(
|
|
1116
|
+
`${n}.format is invalid: ${((m = c.issues[0]) == null ? void 0 : m.message) ?? "invalid value"}`
|
|
1117
|
+
);
|
|
1118
|
+
o = {
|
|
1119
|
+
scope: i,
|
|
1120
|
+
target: Pe(r.target, `${n}.target`),
|
|
1121
|
+
format: c.value
|
|
1122
|
+
};
|
|
1123
|
+
break;
|
|
1124
|
+
}
|
|
1125
|
+
case "raw_temporal":
|
|
1126
|
+
o = {
|
|
1127
|
+
scope: i,
|
|
1128
|
+
target: je(r.target, `${n}.target`),
|
|
1129
|
+
format: R(r.format)
|
|
1130
|
+
};
|
|
1131
|
+
break;
|
|
1132
|
+
case "number":
|
|
1133
|
+
case "currency":
|
|
1134
|
+
case "percent":
|
|
1135
|
+
case "scientific": {
|
|
1136
|
+
const c = he(r.format);
|
|
1137
|
+
if (!c.ok)
|
|
1138
|
+
throw new Error(
|
|
1139
|
+
`${n}.format is invalid: ${((l = c.issues[0]) == null ? void 0 : l.message) ?? "invalid value"}`
|
|
1140
|
+
);
|
|
1141
|
+
o = {
|
|
1142
|
+
scope: i,
|
|
1143
|
+
target: ze(r.target, `${n}.target`),
|
|
1144
|
+
format: c.value
|
|
1145
|
+
};
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
default:
|
|
1149
|
+
throw new Error(`${n}.format.type is unsupported`);
|
|
1150
|
+
}
|
|
1151
|
+
const s = JSON.stringify([
|
|
1152
|
+
...Oe(o.scope),
|
|
1153
|
+
...I(o.target)
|
|
1154
|
+
]);
|
|
1155
|
+
if (t.has(s))
|
|
1156
|
+
throw new Error(
|
|
1157
|
+
`${n} duplicates a scoped presentation target`
|
|
1158
|
+
);
|
|
1159
|
+
return t.add(s), o;
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
function qe(e) {
|
|
1163
|
+
try {
|
|
1164
|
+
if (!h(e))
|
|
1165
|
+
throw new Error("presentation execution snapshot must be an object");
|
|
1166
|
+
if (S(
|
|
1167
|
+
e,
|
|
1168
|
+
["version", "reportContext", "resolvedFormats"],
|
|
1169
|
+
"presentation execution snapshot"
|
|
1170
|
+
), e.version !== 1)
|
|
1171
|
+
throw new Error("presentation execution snapshot version must be 1");
|
|
1172
|
+
const t = se(e.reportContext);
|
|
1173
|
+
if (!t.ok) {
|
|
1174
|
+
const r = t.issues[0];
|
|
1175
|
+
throw new Error(
|
|
1176
|
+
`presentation execution snapshot reportContext is invalid: ${r != null && r.path && r.path !== "$" ? `${r.path}: ` : ""}${(r == null ? void 0 : r.message) ?? "invalid value"}`
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
return {
|
|
1180
|
+
version: 1,
|
|
1181
|
+
reportContext: t.value,
|
|
1182
|
+
resolvedFormats: Le(e.resolvedFormats)
|
|
1183
|
+
};
|
|
1184
|
+
} catch (t) {
|
|
1185
|
+
throw t instanceof j ? t : new j(
|
|
1186
|
+
t instanceof Error ? t.message : "Snapshot is invalid."
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function gt(e) {
|
|
1191
|
+
return qe({
|
|
1192
|
+
version: 1,
|
|
1193
|
+
reportContext: e.reportContext,
|
|
1194
|
+
resolvedFormats: [...e.resolvedFormats]
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
function vt(e) {
|
|
1198
|
+
const t = e.snapshot.resolvedFormats.find(
|
|
1199
|
+
(r) => r.format.type !== "temporal_bucket" && r.format.type !== "raw_temporal" && M(r.scope, e.scope) && K(r.target, e.target)
|
|
1200
|
+
);
|
|
1201
|
+
return t == null ? void 0 : t.format;
|
|
1202
|
+
}
|
|
1203
|
+
function wt(e) {
|
|
1204
|
+
const t = e.snapshot.resolvedFormats.find(
|
|
1205
|
+
(r) => r.format.type === "raw_temporal" && M(r.scope, e.scope) && K(r.target, e.target)
|
|
1206
|
+
);
|
|
1207
|
+
return t == null ? void 0 : t.format;
|
|
1208
|
+
}
|
|
1209
|
+
function pt(e) {
|
|
1210
|
+
const t = e.snapshot.resolvedFormats.find(
|
|
1211
|
+
(r) => r.format.type === "temporal_bucket" && M(r.scope, e.scope) && K(r.target, e.target)
|
|
1212
|
+
);
|
|
1213
|
+
return t == null ? void 0 : t.format;
|
|
1214
|
+
}
|
|
1215
|
+
function xt(e) {
|
|
1216
|
+
var n;
|
|
1217
|
+
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1218
|
+
if (e.snapshot.resolvedFormats.forEach((i, o) => {
|
|
1219
|
+
if (i.scope.attachmentIndex !== void 0)
|
|
1220
|
+
throw new Error(
|
|
1221
|
+
`resolvedFormats.${o}.scope.attachmentIndex is not valid for a card export`
|
|
1222
|
+
);
|
|
1223
|
+
if (i.scope.dashboardId !== e.expectedScope.dashboardId || i.scope.cardId !== e.expectedScope.cardId)
|
|
1224
|
+
throw new Error(
|
|
1225
|
+
`resolvedFormats.${o}.scope must match the executing dashboard/card`
|
|
1226
|
+
);
|
|
1227
|
+
if (i.target.kind === "field" && i.format.type === "temporal_bucket") {
|
|
1228
|
+
const s = JSON.stringify(I(i.target));
|
|
1229
|
+
if (r.has(s))
|
|
1230
|
+
throw new Error(
|
|
1231
|
+
`resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`
|
|
1232
|
+
);
|
|
1233
|
+
r.add(s);
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
if (i.target.kind !== "column")
|
|
1237
|
+
throw new Error(
|
|
1238
|
+
`resolvedFormats.${o}.target must identify an export column or temporal pivot field`
|
|
1239
|
+
);
|
|
1240
|
+
if (t.has(i.target.columnKey))
|
|
1241
|
+
throw new Error(
|
|
1242
|
+
`resolvedFormats.${o} duplicates export column "${i.target.columnKey}"`
|
|
1243
|
+
);
|
|
1244
|
+
t.add(i.target.columnKey);
|
|
1245
|
+
}), !e.useFormattedValues) return;
|
|
1246
|
+
if (!((n = e.visibleColumns) != null && n.length))
|
|
1247
|
+
throw new Error("visibleColumns must identify every formatted export column");
|
|
1248
|
+
const a = e.visibleColumns.find(
|
|
1249
|
+
(i) => !t.has(i)
|
|
1250
|
+
);
|
|
1251
|
+
if (a)
|
|
1252
|
+
throw new Error(
|
|
1253
|
+
`resolvedFormats is missing visible export column "${a}"`
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
function T(e) {
|
|
1257
|
+
return Array.from(
|
|
1258
|
+
new Set(
|
|
1259
|
+
(e ?? []).flatMap(
|
|
1260
|
+
(t) => typeof t.id == "string" && t.id ? [t.id] : []
|
|
1261
|
+
)
|
|
1262
|
+
)
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
function St(e) {
|
|
1266
|
+
const t = e.metricFields ?? [], r = T(t), a = /* @__PURE__ */ new Map();
|
|
1267
|
+
return r.forEach((n) => {
|
|
1268
|
+
a.set(
|
|
1269
|
+
n,
|
|
1270
|
+
t.filter((i) => i.id === n).length
|
|
1271
|
+
);
|
|
1272
|
+
}), {
|
|
1273
|
+
expectedRoleFieldIds: {
|
|
1274
|
+
groupby: T(e.groupByFields),
|
|
1275
|
+
metric: r.length > 0 ? r : [re],
|
|
1276
|
+
pivotby: T(e.pivotByFields),
|
|
1277
|
+
detail: T(e.detailFields)
|
|
1278
|
+
},
|
|
1279
|
+
expectedMetricAliases: t.flatMap(
|
|
1280
|
+
(n) => n.id && (a.get(n.id) ?? 0) > 1 ? [ie(n)] : []
|
|
1281
|
+
)
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
class u extends Error {
|
|
1285
|
+
constructor(r, a) {
|
|
1286
|
+
super(`invalid_pivot_result_lifecycle: ${r}`);
|
|
1287
|
+
g(this, "code", "invalid_pivot_result_lifecycle");
|
|
1288
|
+
g(this, "deliveryBlocking", !0);
|
|
1289
|
+
this.cause = a, this.name = "PivotResultLifecycleError";
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
function Ve(e) {
|
|
1293
|
+
if (!Array.isArray(e) || e.some(
|
|
1294
|
+
(r) => !r || typeof r != "object" || Array.isArray(r) || typeof r.key != "string" || !r.key || typeof r.name != "string" || typeof r.label != "string"
|
|
1295
|
+
))
|
|
1296
|
+
throw new u(
|
|
1297
|
+
"Canonical pivot columns must be an array of keyed, named result descriptors."
|
|
1298
|
+
);
|
|
1299
|
+
const t = e;
|
|
1300
|
+
if (new Set(t.map((r) => r.key)).size !== t.length)
|
|
1301
|
+
throw new u(
|
|
1302
|
+
"Canonical pivot column keys must be unique."
|
|
1303
|
+
);
|
|
1304
|
+
for (const r of t) {
|
|
1305
|
+
const a = ce(r, {
|
|
1306
|
+
metadataRequired: !1
|
|
1307
|
+
});
|
|
1308
|
+
if (!a.ok)
|
|
1309
|
+
throw new u(
|
|
1310
|
+
`Canonical pivot column "${r.key}" has invalid temporal metadata: ${a.error.message}`
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
return t;
|
|
1314
|
+
}
|
|
1315
|
+
function O(e) {
|
|
1316
|
+
if (!e || typeof e != "object" || Array.isArray(e) || e.version !== 1 || e.source !== "explorer" || !e.byRole || typeof e.byRole != "object" || Array.isArray(e.byRole))
|
|
1317
|
+
throw new u(
|
|
1318
|
+
"A loaded canonical pivot result requires its role-scoped column key map."
|
|
1319
|
+
);
|
|
1320
|
+
const t = e, r = /* @__PURE__ */ new Set(["groupby", "metric", "pivotby", "detail"]);
|
|
1321
|
+
for (const [a, n] of Object.entries(t.byRole)) {
|
|
1322
|
+
if (!r.has(a) || !n || typeof n != "object" || Array.isArray(n))
|
|
1323
|
+
throw new u(
|
|
1324
|
+
`Canonical pivot role map contains invalid "${a}" bindings.`
|
|
1325
|
+
);
|
|
1326
|
+
for (const [i, o] of Object.entries(n))
|
|
1327
|
+
if (!i || !o || typeof o != "object" || Array.isArray(o) || o.role !== a || typeof o.rawKey != "string" || !o.rawKey || o.outputKey !== void 0 && (typeof o.outputKey != "string" || !o.outputKey))
|
|
1328
|
+
throw new u(
|
|
1329
|
+
`Canonical pivot role map contains an invalid "${a}:${i}" binding.`
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
if (t.byMetricAlias !== void 0) {
|
|
1333
|
+
if (!t.byMetricAlias || typeof t.byMetricAlias != "object" || Array.isArray(t.byMetricAlias))
|
|
1334
|
+
throw new u(
|
|
1335
|
+
"Canonical pivot metric-alias bindings must be an object."
|
|
1336
|
+
);
|
|
1337
|
+
for (const [a, n] of Object.entries(
|
|
1338
|
+
t.byMetricAlias
|
|
1339
|
+
))
|
|
1340
|
+
if (!a || !n || typeof n != "object" || Array.isArray(n) || n.role !== "metric" || typeof n.rawKey != "string" || !n.rawKey || n.outputKey !== void 0 && (typeof n.outputKey != "string" || !n.outputKey))
|
|
1341
|
+
throw new u(
|
|
1342
|
+
`Canonical pivot metric-alias map contains an invalid "${a}" binding.`
|
|
1343
|
+
);
|
|
1344
|
+
}
|
|
1345
|
+
return t;
|
|
1346
|
+
}
|
|
1347
|
+
function Ge(e) {
|
|
1348
|
+
if (e === void 0) return {};
|
|
1349
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1350
|
+
throw new u(
|
|
1351
|
+
"Canonical pivot column metadata must be an object."
|
|
1352
|
+
);
|
|
1353
|
+
for (const [t, r] of Object.entries(e)) {
|
|
1354
|
+
if (!t || !r || typeof r != "object" || Array.isArray(r))
|
|
1355
|
+
throw new u(
|
|
1356
|
+
`Canonical pivot column metadata contains an invalid "${t}" classification.`
|
|
1357
|
+
);
|
|
1358
|
+
const { isSubtotal: a, subtotalScope: n } = r;
|
|
1359
|
+
if (a !== void 0 && typeof a != "boolean" || n !== void 0 && n !== "base" && n !== "pivot-value" && n !== "grand-total" || a === !0 && n !== "pivot-value" && n !== "grand-total" || (n === "pivot-value" || n === "grand-total") && a !== !0 || n === "base" && a === !0)
|
|
1360
|
+
throw new u(
|
|
1361
|
+
`Canonical pivot column metadata contains an incoherent "${t}" subtotal classification.`
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
return e;
|
|
1365
|
+
}
|
|
1366
|
+
function L(e, t) {
|
|
1367
|
+
if (!Array.isArray(e) || e.some((r) => typeof r != "string" || !r) || new Set(e).size !== e.length)
|
|
1368
|
+
throw new u(
|
|
1369
|
+
`Canonical pivot contract ${t} must be an array of unique field identities.`
|
|
1370
|
+
);
|
|
1371
|
+
return e;
|
|
1372
|
+
}
|
|
1373
|
+
function Be(e, t) {
|
|
1374
|
+
if (!e || typeof e != "object" || Array.isArray(e) || e.version !== 1)
|
|
1375
|
+
throw new u(
|
|
1376
|
+
"A canonical pivot result requires its versioned result contract."
|
|
1377
|
+
);
|
|
1378
|
+
const r = e, a = r.expectedRoleFieldIds;
|
|
1379
|
+
if (!a || typeof a != "object" || Array.isArray(a))
|
|
1380
|
+
throw new u(
|
|
1381
|
+
"Canonical pivot contract role identities must be an object."
|
|
1382
|
+
);
|
|
1383
|
+
const i = Object.fromEntries(
|
|
1384
|
+
[
|
|
1385
|
+
"groupby",
|
|
1386
|
+
"metric",
|
|
1387
|
+
"pivotby",
|
|
1388
|
+
"detail"
|
|
1389
|
+
].map((f) => [
|
|
1390
|
+
f,
|
|
1391
|
+
L(
|
|
1392
|
+
a[f],
|
|
1393
|
+
`expectedRoleFieldIds.${f}`
|
|
1394
|
+
)
|
|
1395
|
+
])
|
|
1396
|
+
), o = L(
|
|
1397
|
+
r.expectedMetricAliases,
|
|
1398
|
+
"expectedMetricAliases"
|
|
1399
|
+
), s = r.columnKinds;
|
|
1400
|
+
if (!s || typeof s != "object" || Array.isArray(s))
|
|
1401
|
+
throw new u(
|
|
1402
|
+
"Canonical pivot contract column kinds must be an object."
|
|
1403
|
+
);
|
|
1404
|
+
const m = /* @__PURE__ */ new Set([
|
|
1405
|
+
"row",
|
|
1406
|
+
"pivot_metric",
|
|
1407
|
+
"value"
|
|
1408
|
+
]), l = t.map((f) => f.key), c = Object.keys(s);
|
|
1409
|
+
if (c.length !== l.length || c.some(
|
|
1410
|
+
(f) => !l.includes(f) || !m.has(
|
|
1411
|
+
s[f]
|
|
1412
|
+
)
|
|
1413
|
+
))
|
|
1414
|
+
throw new u(
|
|
1415
|
+
"Canonical pivot contract must classify every authoritative result column exactly once."
|
|
1416
|
+
);
|
|
1417
|
+
const y = Ge(
|
|
1418
|
+
r.columnClassifications
|
|
1419
|
+
);
|
|
1420
|
+
if (Object.keys(y).some(
|
|
1421
|
+
(f) => !l.includes(f)
|
|
1422
|
+
))
|
|
1423
|
+
throw new u(
|
|
1424
|
+
"Canonical pivot contract contains a classification for an unknown result column."
|
|
1425
|
+
);
|
|
1426
|
+
return {
|
|
1427
|
+
version: 1,
|
|
1428
|
+
expectedRoleFieldIds: i,
|
|
1429
|
+
expectedMetricAliases: o,
|
|
1430
|
+
columnKinds: s,
|
|
1431
|
+
columnClassifications: y
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
function q(e, t) {
|
|
1435
|
+
const r = [
|
|
1436
|
+
"groupby",
|
|
1437
|
+
"metric",
|
|
1438
|
+
"pivotby",
|
|
1439
|
+
"detail"
|
|
1440
|
+
];
|
|
1441
|
+
for (const i of r) {
|
|
1442
|
+
const o = new Set(t.expectedRoleFieldIds[i] ?? []), s = Object.keys(e.byRole[i] ?? {});
|
|
1443
|
+
if (s.length !== o.size || s.some((m) => !o.has(m)))
|
|
1444
|
+
throw new u(
|
|
1445
|
+
`The role-scoped ${i} bindings do not match the authored result fields.`
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
const a = new Set(t.expectedMetricAliases), n = Object.keys(e.byMetricAlias ?? {});
|
|
1449
|
+
if (n.length !== a.size || n.some((i) => !a.has(i)))
|
|
1450
|
+
throw new u(
|
|
1451
|
+
"The metric-alias bindings do not match the authored metric instances."
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
function Ue(e) {
|
|
1455
|
+
if (!Array.isArray(e) || e.some(
|
|
1456
|
+
(t) => !t || typeof t != "object" || Array.isArray(t)
|
|
1457
|
+
))
|
|
1458
|
+
throw new u(
|
|
1459
|
+
"Canonical pivot records must be an array of row objects."
|
|
1460
|
+
);
|
|
1461
|
+
return e;
|
|
1462
|
+
}
|
|
1463
|
+
function Ze(e, t) {
|
|
1464
|
+
e.forEach((r, a) => {
|
|
1465
|
+
t.forEach((n) => {
|
|
1466
|
+
if (!Object.prototype.hasOwnProperty.call(r, n.key) || r[n.key] === void 0)
|
|
1467
|
+
throw new u(
|
|
1468
|
+
`Canonical pivot column "${n.key}" is absent from row ${a}.`
|
|
1469
|
+
);
|
|
1470
|
+
});
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
function He(e, t, r) {
|
|
1474
|
+
const a = new Set(t.map((n) => n.key));
|
|
1475
|
+
["groupby", "detail"].forEach((n) => {
|
|
1476
|
+
Object.entries(e.byRole[n] ?? {}).forEach(
|
|
1477
|
+
([i, o]) => {
|
|
1478
|
+
const s = o.outputKey || o.rawKey;
|
|
1479
|
+
if (!a.has(s) || r.columnKinds[s] !== "row")
|
|
1480
|
+
throw new u(
|
|
1481
|
+
`The role-scoped ${n} binding for "${i}" does not name an authoritative result column.`
|
|
1482
|
+
);
|
|
1483
|
+
}
|
|
1484
|
+
);
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
function V(e, t) {
|
|
1488
|
+
t.forEach((r) => {
|
|
1489
|
+
const a = e.columnKinds[r.key];
|
|
1490
|
+
if (a === "pivot_metric" && r.pivotIdentity === void 0)
|
|
1491
|
+
throw new u(
|
|
1492
|
+
`Physical pivot result column "${r.key}" is missing its identity.`
|
|
1493
|
+
);
|
|
1494
|
+
if (a !== "pivot_metric" && r.pivotIdentity !== void 0)
|
|
1495
|
+
throw new u(
|
|
1496
|
+
`Canonical pivot result column "${r.key}" carries pivot identity outside the physical pivot projection.`
|
|
1497
|
+
);
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
function Ye(e) {
|
|
1501
|
+
const t = Ue(e.records), r = Ve(e.columns), a = Be(
|
|
1502
|
+
e.pivotResultContract,
|
|
1503
|
+
r
|
|
1504
|
+
), n = a.expectedRoleFieldIds.pivotby ?? [];
|
|
1505
|
+
if (e.pivotResultState === "loaded_empty") {
|
|
1506
|
+
if (t.length !== 0)
|
|
1507
|
+
throw new u(
|
|
1508
|
+
"A loaded_empty pivot result cannot carry records."
|
|
1509
|
+
);
|
|
1510
|
+
if (r.some(
|
|
1511
|
+
(m) => a.columnKinds[m.key] === "pivot_metric"
|
|
1512
|
+
))
|
|
1513
|
+
throw new u(
|
|
1514
|
+
"A loaded_empty pivot result cannot carry physical pivot columns."
|
|
1515
|
+
);
|
|
1516
|
+
V(a, r);
|
|
1517
|
+
const s = O(e.columnKeyMap);
|
|
1518
|
+
return q(s, a), {
|
|
1519
|
+
pivotResultState: "loaded_empty",
|
|
1520
|
+
records: [],
|
|
1521
|
+
columns: r,
|
|
1522
|
+
columnKeyMap: s,
|
|
1523
|
+
pivotResultContract: a
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
if (e.pivotResultState !== "loaded_valid")
|
|
1527
|
+
throw new u(
|
|
1528
|
+
"A canonical pivot result must declare loaded_empty or loaded_valid."
|
|
1529
|
+
);
|
|
1530
|
+
if (t.length === 0)
|
|
1531
|
+
throw new u(
|
|
1532
|
+
"A loaded_valid pivot result must carry at least one record."
|
|
1533
|
+
);
|
|
1534
|
+
const i = O(e.columnKeyMap);
|
|
1535
|
+
q(i, a), He(i, r, a), V(a, r);
|
|
1536
|
+
const o = r.filter(
|
|
1537
|
+
(s) => a.columnKinds[s.key] === "pivot_metric"
|
|
1538
|
+
);
|
|
1539
|
+
if (n.length > 0 && o.length === 0)
|
|
1540
|
+
throw new u(
|
|
1541
|
+
"A loaded_valid pivot result is missing its physical pivot columns."
|
|
1542
|
+
);
|
|
1543
|
+
try {
|
|
1544
|
+
me(o, {
|
|
1545
|
+
expectedPivotFieldIds: n,
|
|
1546
|
+
columnClassifications: a.columnClassifications
|
|
1547
|
+
});
|
|
1548
|
+
} catch (s) {
|
|
1549
|
+
throw s instanceof le ? new u(s.message, s) : s;
|
|
1550
|
+
}
|
|
1551
|
+
return Ze(t, r), {
|
|
1552
|
+
pivotResultState: "loaded_valid",
|
|
1553
|
+
records: t,
|
|
1554
|
+
columns: r,
|
|
1555
|
+
columnKeyMap: i,
|
|
1556
|
+
pivotResultContract: a
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
function bt(e) {
|
|
1560
|
+
const t = /* @__PURE__ */ new Set();
|
|
1561
|
+
["groupby", "detail"].forEach((i) => {
|
|
1562
|
+
Object.values(e.columnKeyMap.byRole[i] ?? {}).forEach((o) => {
|
|
1563
|
+
t.add(o.outputKey || o.rawKey);
|
|
1564
|
+
});
|
|
1565
|
+
});
|
|
1566
|
+
const r = new Set(e.physicalPivotColumnKeys), a = new Set(
|
|
1567
|
+
e.columns.map((i) => i.key)
|
|
1568
|
+
), n = {
|
|
1569
|
+
version: 1,
|
|
1570
|
+
expectedRoleFieldIds: {
|
|
1571
|
+
groupby: Array.from(
|
|
1572
|
+
new Set(e.expectedRoleFieldIds.groupby ?? [])
|
|
1573
|
+
),
|
|
1574
|
+
metric: Array.from(
|
|
1575
|
+
new Set(e.expectedRoleFieldIds.metric ?? [])
|
|
1576
|
+
),
|
|
1577
|
+
pivotby: Array.from(
|
|
1578
|
+
new Set(e.expectedRoleFieldIds.pivotby ?? [])
|
|
1579
|
+
),
|
|
1580
|
+
detail: Array.from(
|
|
1581
|
+
new Set(e.expectedRoleFieldIds.detail ?? [])
|
|
1582
|
+
)
|
|
1583
|
+
},
|
|
1584
|
+
expectedMetricAliases: [...e.expectedMetricAliases ?? []],
|
|
1585
|
+
columnKinds: Object.fromEntries(
|
|
1586
|
+
e.columns.map((i) => [
|
|
1587
|
+
i.key,
|
|
1588
|
+
t.has(i.key) ? "row" : r.has(i.key) ? "pivot_metric" : "value"
|
|
1589
|
+
])
|
|
1590
|
+
),
|
|
1591
|
+
columnClassifications: Object.fromEntries(
|
|
1592
|
+
Object.entries(e.columnMetadata ?? {}).filter(
|
|
1593
|
+
([i]) => a.has(i)
|
|
1594
|
+
)
|
|
1595
|
+
)
|
|
1596
|
+
};
|
|
1597
|
+
return Ye({
|
|
1598
|
+
pivotResultState: e.records.length === 0 ? "loaded_empty" : "loaded_valid",
|
|
1599
|
+
pivotResultContract: n,
|
|
1600
|
+
records: e.records,
|
|
1601
|
+
columns: e.columns,
|
|
1602
|
+
columnKeyMap: e.columnKeyMap
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
export {
|
|
1606
|
+
Ke as A,
|
|
1607
|
+
yt as B,
|
|
1608
|
+
St as C,
|
|
1609
|
+
u as D,
|
|
1610
|
+
Ye as E,
|
|
1611
|
+
bt as F,
|
|
1612
|
+
ht as M,
|
|
1613
|
+
j as P,
|
|
1614
|
+
p as R,
|
|
1615
|
+
vt as a,
|
|
1616
|
+
de as b,
|
|
1617
|
+
A as c,
|
|
1618
|
+
B as d,
|
|
1619
|
+
U as e,
|
|
1620
|
+
ot as f,
|
|
1621
|
+
Z as g,
|
|
1622
|
+
st as h,
|
|
1623
|
+
he as i,
|
|
1624
|
+
mt as j,
|
|
1625
|
+
Ne as k,
|
|
1626
|
+
Le as l,
|
|
1627
|
+
qe as m,
|
|
1628
|
+
gt as n,
|
|
1629
|
+
wt as o,
|
|
1630
|
+
ye as p,
|
|
1631
|
+
pt as q,
|
|
1632
|
+
ge as r,
|
|
1633
|
+
xt as s,
|
|
1634
|
+
R as t,
|
|
1635
|
+
lt as u,
|
|
1636
|
+
ct as v,
|
|
1637
|
+
ut as w,
|
|
1638
|
+
dt as x,
|
|
1639
|
+
Te as y,
|
|
1640
|
+
ft as z
|
|
1641
|
+
};
|