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,810 @@
|
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var Y = (e, r, t) => r in e ? x(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var T = (e, r, t) => Y(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { j as L, al as O, e as R, d as U } from "./validators-DEmd8Sin.js";
|
|
5
|
+
import { canonicalizeSupportedLocale as I } from "../value-format-preferences/index.js";
|
|
6
|
+
const q = "higher_is_better", fe = {
|
|
7
|
+
displayMode: "difference",
|
|
8
|
+
showComparison: !0,
|
|
9
|
+
indicatorStyle: "arrow_badge",
|
|
10
|
+
showColor: !0,
|
|
11
|
+
conditionalLabel: !1
|
|
12
|
+
};
|
|
13
|
+
function G(e) {
|
|
14
|
+
return L(e) !== null;
|
|
15
|
+
}
|
|
16
|
+
function pe(e) {
|
|
17
|
+
var r, t, o, n;
|
|
18
|
+
if (((r = e.metricComparison) == null ? void 0 : r.mode) !== "off") {
|
|
19
|
+
if (((t = e.metricComparison) == null ? void 0 : t.mode) === "explicit")
|
|
20
|
+
return { source: "explicit", spec: e.metricComparison.spec };
|
|
21
|
+
if (!((e.inheritGlobalComparison ?? ((o = e.globalDateComparison) == null ? void 0 : o.inheritGlobalComparison)) === !1 || ((n = e.globalDateComparison) == null ? void 0 : n.selection.mode) !== "period"))
|
|
22
|
+
return {
|
|
23
|
+
source: "inherited",
|
|
24
|
+
spec: e.globalDateComparison.selection.spec,
|
|
25
|
+
...e.globalDateComparison.owner ? { owner: e.globalDateComparison.owner } : {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function be(e) {
|
|
30
|
+
if (e.alias) return e.alias;
|
|
31
|
+
const r = e.entityName && e.entityName !== "SEMAPHOR_CALCULATED_FIELD" ? e.entityName : void 0, t = r && r !== e.name ? `${r}_` : "";
|
|
32
|
+
if (e.role !== "metric") return `${t}${e.name}`;
|
|
33
|
+
let o = e.aggregate || "metric";
|
|
34
|
+
if (e.expression) {
|
|
35
|
+
const n = e.expression.match(
|
|
36
|
+
/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
|
|
37
|
+
);
|
|
38
|
+
o = n ? n[1].toLowerCase() : "expr";
|
|
39
|
+
} else
|
|
40
|
+
o = o.toLowerCase();
|
|
41
|
+
return `${t}${e.name}_${o}`;
|
|
42
|
+
}
|
|
43
|
+
function i(e, r, t) {
|
|
44
|
+
return t ? { code: e, message: r, path: t } : { code: e, message: r };
|
|
45
|
+
}
|
|
46
|
+
function d(e) {
|
|
47
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
48
|
+
}
|
|
49
|
+
function u(e, r, t, o) {
|
|
50
|
+
Object.keys(e).forEach((n) => {
|
|
51
|
+
r.includes(n) || o.push(
|
|
52
|
+
i(
|
|
53
|
+
"invalid_comparison_spec",
|
|
54
|
+
`Comparison kind does not accept field "${n}".`,
|
|
55
|
+
`${t}.${n}`
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function M(e, r, t) {
|
|
61
|
+
e.alignment !== void 0 && e.alignment !== "calendar" && e.alignment !== "weekday" && t.push(
|
|
62
|
+
i(
|
|
63
|
+
"invalid_comparison_spec",
|
|
64
|
+
'Comparison alignment must be "calendar" or "weekday".',
|
|
65
|
+
`${r}.alignment`
|
|
66
|
+
)
|
|
67
|
+
), e.toDate !== void 0 && typeof e.toDate != "boolean" && t.push(
|
|
68
|
+
i(
|
|
69
|
+
"invalid_comparison_spec",
|
|
70
|
+
"Comparison toDate must be a boolean.",
|
|
71
|
+
`${r}.toDate`
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
function D(e, r, t) {
|
|
76
|
+
e !== void 0 && (typeof e != "number" || !Number.isSafeInteger(e) || e <= 0) && t.push(
|
|
77
|
+
i(
|
|
78
|
+
"invalid_comparison_spec",
|
|
79
|
+
"Comparison offset must be a positive safe integer.",
|
|
80
|
+
r
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function P(e, r = "comparison") {
|
|
85
|
+
const t = [];
|
|
86
|
+
return d(e) ? (e.kind === "previous_period" ? (u(
|
|
87
|
+
e,
|
|
88
|
+
["kind", "offsetPeriods", "alignment", "toDate"],
|
|
89
|
+
r,
|
|
90
|
+
t
|
|
91
|
+
), D(e.offsetPeriods, `${r}.offsetPeriods`, t), M(e, r, t)) : e.kind === "previous_year" ? (u(
|
|
92
|
+
e,
|
|
93
|
+
["kind", "offsetYears", "alignment", "toDate"],
|
|
94
|
+
r,
|
|
95
|
+
t
|
|
96
|
+
), D(e.offsetYears, `${r}.offsetYears`, t), M(e, r, t)) : e.kind === "target" ? (u(e, ["kind", "targetValue"], r, t), (typeof e.targetValue != "number" || !Number.isFinite(e.targetValue)) && t.push(
|
|
97
|
+
i(
|
|
98
|
+
"invalid_comparison_spec",
|
|
99
|
+
"Target comparison requires a finite targetValue.",
|
|
100
|
+
`${r}.targetValue`
|
|
101
|
+
)
|
|
102
|
+
)) : t.push(
|
|
103
|
+
i(
|
|
104
|
+
"invalid_comparison_spec",
|
|
105
|
+
"Comparison kind must be previous_period, previous_year, or target.",
|
|
106
|
+
`${r}.kind`
|
|
107
|
+
)
|
|
108
|
+
), { ok: t.length === 0, errors: t, warnings: [] }) : {
|
|
109
|
+
ok: !1,
|
|
110
|
+
errors: [
|
|
111
|
+
i(
|
|
112
|
+
"invalid_comparison_spec",
|
|
113
|
+
"Comparison spec must be an object.",
|
|
114
|
+
r
|
|
115
|
+
)
|
|
116
|
+
],
|
|
117
|
+
warnings: []
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function ge(e, r = "comparison") {
|
|
121
|
+
if (!d(e))
|
|
122
|
+
return {
|
|
123
|
+
ok: !1,
|
|
124
|
+
errors: [
|
|
125
|
+
i(
|
|
126
|
+
"invalid_comparison_config",
|
|
127
|
+
"Comparison config must be an object.",
|
|
128
|
+
r
|
|
129
|
+
)
|
|
130
|
+
],
|
|
131
|
+
warnings: []
|
|
132
|
+
};
|
|
133
|
+
const t = [];
|
|
134
|
+
return e.mode === "off" ? u(e, ["mode"], r, t) : e.mode === "explicit" ? (u(e, ["mode", "spec"], r, t), t.push(...P(e.spec, `${r}.spec`).errors)) : t.push(
|
|
135
|
+
i(
|
|
136
|
+
"invalid_comparison_config",
|
|
137
|
+
"Comparison mode must be off or explicit.",
|
|
138
|
+
`${r}.mode`
|
|
139
|
+
)
|
|
140
|
+
), { ok: t.length === 0, errors: t, warnings: [] };
|
|
141
|
+
}
|
|
142
|
+
function V(e, r = "comparisonSelection") {
|
|
143
|
+
if (!d(e))
|
|
144
|
+
return {
|
|
145
|
+
ok: !1,
|
|
146
|
+
errors: [
|
|
147
|
+
i(
|
|
148
|
+
"invalid_global_date_comparison",
|
|
149
|
+
"Global Date comparison selection must be an object.",
|
|
150
|
+
r
|
|
151
|
+
)
|
|
152
|
+
],
|
|
153
|
+
warnings: []
|
|
154
|
+
};
|
|
155
|
+
const t = [];
|
|
156
|
+
if (e.mode === "off")
|
|
157
|
+
u(e, ["mode"], r, t);
|
|
158
|
+
else if (e.mode === "period") {
|
|
159
|
+
u(e, ["mode", "spec"], r, t);
|
|
160
|
+
const o = P(e.spec, `${r}.spec`);
|
|
161
|
+
t.push(...o.errors), d(e.spec) && e.spec.kind === "target" && t.push(
|
|
162
|
+
i(
|
|
163
|
+
"invalid_global_date_comparison",
|
|
164
|
+
"Global Date comparison supports previous_period or previous_year, not target.",
|
|
165
|
+
`${r}.spec.kind`
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
} else
|
|
169
|
+
t.push(
|
|
170
|
+
i(
|
|
171
|
+
"invalid_global_date_comparison",
|
|
172
|
+
"Global Date comparison mode must be off or period.",
|
|
173
|
+
`${r}.mode`
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
return { ok: t.length === 0, errors: t, warnings: [] };
|
|
177
|
+
}
|
|
178
|
+
function ye(e, r = "globalDateComparison") {
|
|
179
|
+
if (!d(e))
|
|
180
|
+
return {
|
|
181
|
+
ok: !1,
|
|
182
|
+
errors: [
|
|
183
|
+
i(
|
|
184
|
+
"invalid_global_date_comparison",
|
|
185
|
+
"Global Date comparison context must be an object.",
|
|
186
|
+
r
|
|
187
|
+
)
|
|
188
|
+
],
|
|
189
|
+
warnings: []
|
|
190
|
+
};
|
|
191
|
+
const t = [];
|
|
192
|
+
return u(
|
|
193
|
+
e,
|
|
194
|
+
["selection", "inheritGlobalComparison", "owner", "referenceTime"],
|
|
195
|
+
r,
|
|
196
|
+
t
|
|
197
|
+
), t.push(
|
|
198
|
+
...V(
|
|
199
|
+
e.selection,
|
|
200
|
+
`${r}.selection`
|
|
201
|
+
).errors
|
|
202
|
+
), e.inheritGlobalComparison !== void 0 && e.inheritGlobalComparison !== !1 && t.push(
|
|
203
|
+
i(
|
|
204
|
+
"invalid_global_date_comparison",
|
|
205
|
+
"inheritGlobalComparison may only be false when present.",
|
|
206
|
+
`${r}.inheritGlobalComparison`
|
|
207
|
+
)
|
|
208
|
+
), e.owner !== void 0 && (d(e.owner) ? e.owner.kind === "global_date" ? u(e.owner, ["kind"], `${r}.owner`, t) : e.owner.kind === "field_date" ? (u(
|
|
209
|
+
e.owner,
|
|
210
|
+
["kind", "filterId", "label"],
|
|
211
|
+
`${r}.owner`,
|
|
212
|
+
t
|
|
213
|
+
), (typeof e.owner.filterId != "string" || !e.owner.filterId.trim()) && t.push(
|
|
214
|
+
i(
|
|
215
|
+
"invalid_global_date_comparison",
|
|
216
|
+
"Field Date comparison owner requires a non-empty filterId.",
|
|
217
|
+
`${r}.owner.filterId`
|
|
218
|
+
)
|
|
219
|
+
), (typeof e.owner.label != "string" || !e.owner.label.trim()) && t.push(
|
|
220
|
+
i(
|
|
221
|
+
"invalid_global_date_comparison",
|
|
222
|
+
"Field Date comparison owner requires a non-empty label.",
|
|
223
|
+
`${r}.owner.label`
|
|
224
|
+
)
|
|
225
|
+
)) : t.push(
|
|
226
|
+
i(
|
|
227
|
+
"invalid_global_date_comparison",
|
|
228
|
+
"Comparison owner kind must be global_date or field_date.",
|
|
229
|
+
`${r}.owner.kind`
|
|
230
|
+
)
|
|
231
|
+
) : t.push(
|
|
232
|
+
i(
|
|
233
|
+
"invalid_global_date_comparison",
|
|
234
|
+
"Comparison owner must be an object.",
|
|
235
|
+
`${r}.owner`
|
|
236
|
+
)
|
|
237
|
+
)), e.referenceTime !== void 0 && (typeof e.referenceTime != "string" || !G(e.referenceTime)) && t.push(
|
|
238
|
+
i(
|
|
239
|
+
"invalid_global_date_comparison",
|
|
240
|
+
"referenceTime must be a valid ISO date-time string when present.",
|
|
241
|
+
`${r}.referenceTime`
|
|
242
|
+
)
|
|
243
|
+
), { ok: t.length === 0, errors: t, warnings: [] };
|
|
244
|
+
}
|
|
245
|
+
function _e(e, r = "comparisonPolarity") {
|
|
246
|
+
return e === "higher_is_better" || e === "lower_is_better" || e === "neutral" ? { ok: !0, errors: [], warnings: [] } : {
|
|
247
|
+
ok: !1,
|
|
248
|
+
errors: [
|
|
249
|
+
i(
|
|
250
|
+
"invalid_comparison_polarity",
|
|
251
|
+
"Comparison polarity must be higher_is_better, lower_is_better, or neutral.",
|
|
252
|
+
r
|
|
253
|
+
)
|
|
254
|
+
],
|
|
255
|
+
warnings: []
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function he(e, r = "comparisonPresentation") {
|
|
259
|
+
if (!d(e))
|
|
260
|
+
return {
|
|
261
|
+
ok: !1,
|
|
262
|
+
errors: [
|
|
263
|
+
i(
|
|
264
|
+
"invalid_comparison_presentation",
|
|
265
|
+
"Comparison presentation must be an object.",
|
|
266
|
+
r
|
|
267
|
+
)
|
|
268
|
+
],
|
|
269
|
+
warnings: []
|
|
270
|
+
};
|
|
271
|
+
const t = [], o = [
|
|
272
|
+
"displayMode",
|
|
273
|
+
"showComparison",
|
|
274
|
+
"precision",
|
|
275
|
+
"indicatorStyle",
|
|
276
|
+
"showColor",
|
|
277
|
+
"position",
|
|
278
|
+
"conditionalLabel",
|
|
279
|
+
"labelName",
|
|
280
|
+
"conditionalLabels",
|
|
281
|
+
"colors"
|
|
282
|
+
];
|
|
283
|
+
return Object.keys(e).forEach((a) => {
|
|
284
|
+
o.includes(a) || t.push(
|
|
285
|
+
i(
|
|
286
|
+
"invalid_comparison_presentation",
|
|
287
|
+
`Comparison presentation does not accept field "${a}".`,
|
|
288
|
+
`${r}.${a}`
|
|
289
|
+
)
|
|
290
|
+
);
|
|
291
|
+
}), [
|
|
292
|
+
["displayMode", ["difference", "percent_change", "both", "ratio"]],
|
|
293
|
+
["indicatorStyle", ["arrow_badge", "arrow", "badge", "none"]],
|
|
294
|
+
["position", ["left", "right", "top"]]
|
|
295
|
+
].forEach(([a, s]) => {
|
|
296
|
+
e[a] !== void 0 && !s.includes(e[a]) && t.push(
|
|
297
|
+
i(
|
|
298
|
+
"invalid_comparison_presentation",
|
|
299
|
+
`Comparison presentation ${a} is invalid.`,
|
|
300
|
+
`${r}.${a}`
|
|
301
|
+
)
|
|
302
|
+
);
|
|
303
|
+
}), ["showComparison", "showColor", "conditionalLabel"].forEach((a) => {
|
|
304
|
+
e[a] !== void 0 && typeof e[a] != "boolean" && t.push(
|
|
305
|
+
i(
|
|
306
|
+
"invalid_comparison_presentation",
|
|
307
|
+
`Comparison presentation ${a} must be a boolean.`,
|
|
308
|
+
`${r}.${a}`
|
|
309
|
+
)
|
|
310
|
+
);
|
|
311
|
+
}), e.precision !== void 0 && (typeof e.precision != "number" || !Number.isInteger(e.precision) || e.precision < 0 || e.precision > 6) && t.push(
|
|
312
|
+
i(
|
|
313
|
+
"invalid_comparison_presentation",
|
|
314
|
+
"Comparison presentation precision must be an integer from 0 through 6.",
|
|
315
|
+
`${r}.precision`
|
|
316
|
+
)
|
|
317
|
+
), e.labelName !== void 0 && typeof e.labelName != "string" && t.push(
|
|
318
|
+
i(
|
|
319
|
+
"invalid_comparison_presentation",
|
|
320
|
+
"Comparison presentation labelName must be a string.",
|
|
321
|
+
`${r}.labelName`
|
|
322
|
+
)
|
|
323
|
+
), ["conditionalLabels", "colors"].forEach((a) => {
|
|
324
|
+
const s = e[a];
|
|
325
|
+
if (s !== void 0) {
|
|
326
|
+
if (!d(s)) {
|
|
327
|
+
t.push(
|
|
328
|
+
i(
|
|
329
|
+
"invalid_comparison_presentation",
|
|
330
|
+
`Comparison presentation ${a} must be an object.`,
|
|
331
|
+
`${r}.${a}`
|
|
332
|
+
)
|
|
333
|
+
);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
Object.keys(s).forEach((l) => {
|
|
337
|
+
["increase", "decrease", "neutral"].includes(l) || t.push(
|
|
338
|
+
i(
|
|
339
|
+
"invalid_comparison_presentation",
|
|
340
|
+
`Comparison presentation ${a} does not accept field "${l}".`,
|
|
341
|
+
`${r}.${a}.${l}`
|
|
342
|
+
)
|
|
343
|
+
);
|
|
344
|
+
}), Object.entries(s).forEach(([l, c]) => {
|
|
345
|
+
c !== void 0 && typeof c != "string" && t.push(
|
|
346
|
+
i(
|
|
347
|
+
"invalid_comparison_presentation",
|
|
348
|
+
`Comparison presentation ${a}.${l} must be a string.`,
|
|
349
|
+
`${r}.${a}.${l}`
|
|
350
|
+
)
|
|
351
|
+
);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}), { ok: t.length === 0, errors: t, warnings: [] };
|
|
355
|
+
}
|
|
356
|
+
function B(e) {
|
|
357
|
+
return e === null ? "unknown" : e > 0 ? "increase" : e < 0 ? "decrease" : "no_change";
|
|
358
|
+
}
|
|
359
|
+
function H(e, r) {
|
|
360
|
+
return e === "unknown" || e === "no_change" || r === "neutral" ? "neutral" : r === "higher_is_better" && e === "increase" || r === "lower_is_better" && e === "decrease" ? "favorable" : "unfavorable";
|
|
361
|
+
}
|
|
362
|
+
function we(e) {
|
|
363
|
+
const {
|
|
364
|
+
currentValue: r,
|
|
365
|
+
comparisonValue: t,
|
|
366
|
+
polarity: o = q
|
|
367
|
+
} = e, a = r !== null && t !== null ? r - t : null, s = a !== null && t !== null && t !== 0 ? a / Math.abs(t) : null, l = r !== null && t !== null && t !== 0 ? r / t : null, c = B(a);
|
|
368
|
+
return {
|
|
369
|
+
status: t === null ? "insufficient_history" : "available",
|
|
370
|
+
currentValue: r,
|
|
371
|
+
comparisonValue: t,
|
|
372
|
+
delta: a,
|
|
373
|
+
percentChange: s,
|
|
374
|
+
ratio: l,
|
|
375
|
+
direction: c,
|
|
376
|
+
sentiment: H(c, o)
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function g(e) {
|
|
380
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
381
|
+
return !1;
|
|
382
|
+
const r = Object.getPrototypeOf(e);
|
|
383
|
+
if (r === null || r === Object.prototype) return !0;
|
|
384
|
+
const t = Object.prototype.hasOwnProperty.call(
|
|
385
|
+
r,
|
|
386
|
+
"constructor"
|
|
387
|
+
) ? r.constructor : void 0;
|
|
388
|
+
return typeof t == "function" && Function.prototype.toString.call(t) === Function.prototype.toString.call(Object);
|
|
389
|
+
}
|
|
390
|
+
const J = {
|
|
391
|
+
dateStyle: "short",
|
|
392
|
+
dateTime: { dateStyle: "short", timeStyle: "short" }
|
|
393
|
+
};
|
|
394
|
+
class _ extends Error {
|
|
395
|
+
constructor(t, o) {
|
|
396
|
+
super(o);
|
|
397
|
+
T(this, "code");
|
|
398
|
+
this.name = "TemporalBucketContractError", this.code = t;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
const Z = [
|
|
402
|
+
"Jan",
|
|
403
|
+
"Feb",
|
|
404
|
+
"Mar",
|
|
405
|
+
"Apr",
|
|
406
|
+
"May",
|
|
407
|
+
"Jun",
|
|
408
|
+
"Jul",
|
|
409
|
+
"Aug",
|
|
410
|
+
"Sep",
|
|
411
|
+
"Oct",
|
|
412
|
+
"Nov",
|
|
413
|
+
"Dec"
|
|
414
|
+
], z = [
|
|
415
|
+
"January",
|
|
416
|
+
"February",
|
|
417
|
+
"March",
|
|
418
|
+
"April",
|
|
419
|
+
"May",
|
|
420
|
+
"June",
|
|
421
|
+
"July",
|
|
422
|
+
"August",
|
|
423
|
+
"September",
|
|
424
|
+
"October",
|
|
425
|
+
"November",
|
|
426
|
+
"December"
|
|
427
|
+
];
|
|
428
|
+
function $(e) {
|
|
429
|
+
return {
|
|
430
|
+
ok: !1,
|
|
431
|
+
error: { code: "invalid_temporal_bucket_value", message: e }
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
function Q(e) {
|
|
435
|
+
return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
|
|
436
|
+
}
|
|
437
|
+
function W(e, r) {
|
|
438
|
+
return r === 2 ? Q(e) ? 29 : 28 : [4, 6, 9, 11].includes(r) ? 30 : 31;
|
|
439
|
+
}
|
|
440
|
+
function K(e, r, t) {
|
|
441
|
+
const o = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], n = r < 3 ? e - 1 : e;
|
|
442
|
+
return (n + Math.floor(n / 4) - Math.floor(n / 100) + Math.floor(n / 400) + o[r - 1] + t) % 7;
|
|
443
|
+
}
|
|
444
|
+
function S(e) {
|
|
445
|
+
var r;
|
|
446
|
+
return (r = e.calendar.fiscalCalendar) == null ? void 0 : r.yearStartMonth;
|
|
447
|
+
}
|
|
448
|
+
function X(e, r) {
|
|
449
|
+
return (e - r + 12) % 12 % 3 === 0;
|
|
450
|
+
}
|
|
451
|
+
function ee(e, r) {
|
|
452
|
+
const { granularity: t } = r, o = S(r) ?? 1;
|
|
453
|
+
switch (t) {
|
|
454
|
+
case "second":
|
|
455
|
+
return !0;
|
|
456
|
+
case "minute":
|
|
457
|
+
return e.second === 0;
|
|
458
|
+
case "hour":
|
|
459
|
+
return e.minute === 0 && e.second === 0;
|
|
460
|
+
case "day":
|
|
461
|
+
return !0;
|
|
462
|
+
case "week":
|
|
463
|
+
return K(e.year, e.month, e.day) === r.calendar.weekStart;
|
|
464
|
+
case "month":
|
|
465
|
+
return e.day === 1;
|
|
466
|
+
case "quarter":
|
|
467
|
+
return e.day === 1 && X(e.month, o);
|
|
468
|
+
case "year":
|
|
469
|
+
return e.day === 1 && e.month === o;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function re(e, r) {
|
|
473
|
+
if (e === null) return { ok: !0, value: null };
|
|
474
|
+
const t = r.granularity === "second" || r.granularity === "minute" || r.granularity === "hour", o = t ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
475
|
+
if (!o)
|
|
476
|
+
return $(
|
|
477
|
+
`Expected ${t ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${r.granularity} granularity.`
|
|
478
|
+
);
|
|
479
|
+
const n = {
|
|
480
|
+
year: Number(o[1]),
|
|
481
|
+
month: Number(o[2]),
|
|
482
|
+
day: Number(o[3]),
|
|
483
|
+
hour: t ? Number(o[4]) : 0,
|
|
484
|
+
minute: t ? Number(o[5]) : 0,
|
|
485
|
+
second: t ? Number(o[6]) : 0
|
|
486
|
+
};
|
|
487
|
+
return n.year < 1 || n.month < 1 || n.month > 12 || n.day < 1 || n.day > W(n.year, n.month) || n.hour > 23 || n.minute > 59 || n.second > 59 ? $(`Invalid canonical ${r.granularity} bucket value ${e}.`) : ee(n, r) ? { ok: !0, value: n } : $(
|
|
488
|
+
`Canonical value ${e} is not aligned to ${r.granularity} granularity and its governed Calendar.`
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
function te(e) {
|
|
492
|
+
if (!g(e))
|
|
493
|
+
return {
|
|
494
|
+
ok: !1,
|
|
495
|
+
issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
|
|
496
|
+
};
|
|
497
|
+
const r = [], t = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
|
|
498
|
+
for (const s of Object.keys(e))
|
|
499
|
+
t.has(s) || r.push({ path: s, message: `Unknown property "${s}".` });
|
|
500
|
+
e.type !== "temporal_bucket" && r.push({ path: "type", message: "Expected temporal_bucket." });
|
|
501
|
+
const o = e.presentation;
|
|
502
|
+
if (!g(o))
|
|
503
|
+
r.push({ path: "presentation", message: "Expected a presentation object." });
|
|
504
|
+
else {
|
|
505
|
+
const s = o.mode, l = s === "preset" ? /* @__PURE__ */ new Set(["mode", "preset"]) : s === "pattern" ? /* @__PURE__ */ new Set(["mode", "pattern"]) : s === "auto" ? /* @__PURE__ */ new Set(["mode", "styles"]) : /* @__PURE__ */ new Set(["mode"]);
|
|
506
|
+
for (const c of Object.keys(o))
|
|
507
|
+
l.has(c) || r.push({
|
|
508
|
+
path: `presentation.${c}`,
|
|
509
|
+
message: `Unknown property "${c}".`
|
|
510
|
+
});
|
|
511
|
+
if (s === "preset")
|
|
512
|
+
R(o.preset) || r.push({ path: "presentation.preset", message: "Expected a supported preset." });
|
|
513
|
+
else if (s === "pattern")
|
|
514
|
+
if (typeof o.pattern != "string" || !o.pattern)
|
|
515
|
+
r.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
|
|
516
|
+
else {
|
|
517
|
+
const c = O(o.pattern);
|
|
518
|
+
c.ok || r.push({
|
|
519
|
+
path: "presentation.pattern",
|
|
520
|
+
message: c.message
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
else if (s === "auto") {
|
|
524
|
+
const c = o.styles;
|
|
525
|
+
(!g(c) || !["short", "medium", "long"].includes(String(c.dateStyle)) || !g(c.dateTime) || !["short", "medium", "long"].includes(
|
|
526
|
+
String(c.dateTime.dateStyle)
|
|
527
|
+
) || !["short", "medium", "long"].includes(
|
|
528
|
+
String(c.dateTime.timeStyle)
|
|
529
|
+
) || Object.keys(c).some(
|
|
530
|
+
(m) => m !== "dateStyle" && m !== "dateTime"
|
|
531
|
+
) || Object.keys(c.dateTime).some(
|
|
532
|
+
(m) => m !== "dateStyle" && m !== "timeStyle"
|
|
533
|
+
)) && r.push({
|
|
534
|
+
path: "presentation.styles",
|
|
535
|
+
message: "Expected complete resolved date and datetime styles."
|
|
536
|
+
});
|
|
537
|
+
} else
|
|
538
|
+
r.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
|
|
539
|
+
}
|
|
540
|
+
const n = I(e.locale);
|
|
541
|
+
if (n || r.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), r.length > 0 || !n || !g(o))
|
|
542
|
+
return { ok: !1, issues: r };
|
|
543
|
+
if (o.mode === "auto") {
|
|
544
|
+
const s = o.styles;
|
|
545
|
+
return {
|
|
546
|
+
ok: !0,
|
|
547
|
+
value: {
|
|
548
|
+
type: "temporal_bucket",
|
|
549
|
+
locale: n,
|
|
550
|
+
presentation: {
|
|
551
|
+
mode: "auto",
|
|
552
|
+
styles: {
|
|
553
|
+
dateStyle: s.dateStyle,
|
|
554
|
+
dateTime: {
|
|
555
|
+
dateStyle: s.dateTime.dateStyle,
|
|
556
|
+
timeStyle: s.dateTime.timeStyle
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
ok: !0,
|
|
565
|
+
value: {
|
|
566
|
+
type: "temporal_bucket",
|
|
567
|
+
presentation: o.mode === "preset" ? {
|
|
568
|
+
mode: "preset",
|
|
569
|
+
preset: o.preset
|
|
570
|
+
} : {
|
|
571
|
+
mode: "pattern",
|
|
572
|
+
pattern: o.pattern
|
|
573
|
+
},
|
|
574
|
+
locale: n
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
function oe(e, r) {
|
|
579
|
+
const t = !!r.calendar.fiscalCalendar;
|
|
580
|
+
return e === "fiscal_quarter_short" || e === "fiscal_year" ? t : e === "quarter_short" || e === "quarter_long" ? !t : !0;
|
|
581
|
+
}
|
|
582
|
+
function F(e, r) {
|
|
583
|
+
return U(e, r.granularity).ok ? e.presentation.mode === "preset" ? oe(e.presentation.preset, r) : !(e.presentation.mode === "pattern" && r.calendar.fiscalCalendar && (r.granularity === "quarter" || r.granularity === "year")) : !1;
|
|
584
|
+
}
|
|
585
|
+
function v(e, r) {
|
|
586
|
+
if (!(!e || e.presentation.mode === "auto"))
|
|
587
|
+
return F(e, r) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
|
|
588
|
+
}
|
|
589
|
+
function Ce(e) {
|
|
590
|
+
var n;
|
|
591
|
+
const r = I(e.locale);
|
|
592
|
+
if (!r)
|
|
593
|
+
throw new _(
|
|
594
|
+
"invalid_temporal_bucket_format",
|
|
595
|
+
"Temporal bucket locale must be a supported base BCP 47 locale."
|
|
596
|
+
);
|
|
597
|
+
const t = v(e.cardFormat, e.metadata);
|
|
598
|
+
if (t)
|
|
599
|
+
return { format: { ...t, locale: r }, source: "card" };
|
|
600
|
+
const o = ((n = e.semanticFormat) == null ? void 0 : n.granularity) === e.metadata.granularity ? v(e.semanticFormat.format, e.metadata) : void 0;
|
|
601
|
+
return o ? { format: { ...o, locale: r }, source: "semantic" } : {
|
|
602
|
+
format: {
|
|
603
|
+
type: "temporal_bucket",
|
|
604
|
+
locale: r,
|
|
605
|
+
presentation: {
|
|
606
|
+
mode: "auto",
|
|
607
|
+
styles: e.styles ?? J
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
source: "automatic"
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function p(e, r = 2) {
|
|
614
|
+
return String(e).padStart(r, "0");
|
|
615
|
+
}
|
|
616
|
+
function h(e, r, t) {
|
|
617
|
+
if (r === "en-US")
|
|
618
|
+
return (t === "short" ? Z : z)[e - 1];
|
|
619
|
+
const o = new Date(Date.UTC(2e3, e - 1, 15));
|
|
620
|
+
return new Intl.DateTimeFormat(r, {
|
|
621
|
+
calendar: "gregory",
|
|
622
|
+
month: t,
|
|
623
|
+
timeZone: "UTC"
|
|
624
|
+
}).format(o);
|
|
625
|
+
}
|
|
626
|
+
function ne(e, r, t) {
|
|
627
|
+
return r.map((o) => {
|
|
628
|
+
if (o.kind === "literal") return o.value;
|
|
629
|
+
switch (o.value) {
|
|
630
|
+
case "YYYY":
|
|
631
|
+
return p(e.year, 4);
|
|
632
|
+
case "YY":
|
|
633
|
+
return p(e.year % 100);
|
|
634
|
+
case "MMMM":
|
|
635
|
+
return h(e.month, t, "long");
|
|
636
|
+
case "MMM":
|
|
637
|
+
return h(e.month, t, "short");
|
|
638
|
+
case "MM":
|
|
639
|
+
return p(e.month);
|
|
640
|
+
case "DD":
|
|
641
|
+
return p(e.day);
|
|
642
|
+
case "HH":
|
|
643
|
+
return p(e.hour);
|
|
644
|
+
case "mm":
|
|
645
|
+
return p(e.minute);
|
|
646
|
+
case "ss":
|
|
647
|
+
return p(e.second);
|
|
648
|
+
}
|
|
649
|
+
}).join("");
|
|
650
|
+
}
|
|
651
|
+
const N = /* @__PURE__ */ new Map();
|
|
652
|
+
function y(e, r) {
|
|
653
|
+
const t = `${e}:${JSON.stringify(r)}`, o = N.get(t);
|
|
654
|
+
if (o) return o;
|
|
655
|
+
const n = new Intl.DateTimeFormat(e, r);
|
|
656
|
+
return N.set(t, n), n;
|
|
657
|
+
}
|
|
658
|
+
function w(e) {
|
|
659
|
+
const r = /* @__PURE__ */ new Date(0);
|
|
660
|
+
return r.setUTCFullYear(e.year, e.month - 1, e.day), r.setUTCHours(e.hour, e.minute, e.second, 0), r;
|
|
661
|
+
}
|
|
662
|
+
function A(e, r, t) {
|
|
663
|
+
return y(r, {
|
|
664
|
+
calendar: "gregory",
|
|
665
|
+
dateStyle: t,
|
|
666
|
+
timeZone: "UTC"
|
|
667
|
+
}).format(w(e));
|
|
668
|
+
}
|
|
669
|
+
function ae(e, r, t) {
|
|
670
|
+
return y(r, {
|
|
671
|
+
calendar: "gregory",
|
|
672
|
+
dateStyle: t.dateStyle,
|
|
673
|
+
// Grouped buckets are civil values, not instants. Long time styles would
|
|
674
|
+
// append a zone label that the canonical value does not semantically own.
|
|
675
|
+
timeStyle: t.timeStyle === "long" ? "medium" : t.timeStyle,
|
|
676
|
+
timeZone: "UTC"
|
|
677
|
+
}).format(w(e));
|
|
678
|
+
}
|
|
679
|
+
function ie(e, r, t) {
|
|
680
|
+
var n;
|
|
681
|
+
if (t === "short") {
|
|
682
|
+
const a = w(e), s = y(r, {
|
|
683
|
+
calendar: "gregory",
|
|
684
|
+
dateStyle: "short",
|
|
685
|
+
timeZone: "UTC"
|
|
686
|
+
}).formatToParts(a), l = s.findIndex((f) => f.type === "month"), c = s.findIndex((f) => f.type === "year"), m = (n = y(r, {
|
|
687
|
+
calendar: "gregory",
|
|
688
|
+
timeZone: "UTC",
|
|
689
|
+
year: "numeric"
|
|
690
|
+
}).formatToParts(a).find((f) => f.type === "year")) == null ? void 0 : n.value;
|
|
691
|
+
if (l >= 0 && c >= 0 && m) {
|
|
692
|
+
const f = Math.min(l, c), j = Math.max(l, c);
|
|
693
|
+
let C = !1;
|
|
694
|
+
return s.slice(f, j + 1).filter((b) => b.type === "day" ? (C = !0, !1) : C && b.type === "literal" ? (C = !1, !1) : !0).map((b) => b.type === "year" ? m : b.value).join("");
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return y(r, {
|
|
698
|
+
calendar: "gregory",
|
|
699
|
+
month: t === "short" ? "numeric" : t === "medium" ? "short" : "long",
|
|
700
|
+
timeZone: "UTC",
|
|
701
|
+
year: "numeric"
|
|
702
|
+
}).format(w(e));
|
|
703
|
+
}
|
|
704
|
+
function se(e, r) {
|
|
705
|
+
return Math.floor((e.month - r + 12) % 12 / 3) + 1;
|
|
706
|
+
}
|
|
707
|
+
function E(e, r) {
|
|
708
|
+
return r === 1 || e.month < r ? e.year : e.year + 1;
|
|
709
|
+
}
|
|
710
|
+
function ce(e) {
|
|
711
|
+
return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
|
|
712
|
+
}
|
|
713
|
+
function k(e, r, t, o) {
|
|
714
|
+
const n = S(o) ?? 1, a = se(e, n);
|
|
715
|
+
switch (r) {
|
|
716
|
+
case "week_of_short":
|
|
717
|
+
return `Week of ${h(e.month, t, "short")} ${e.day}, ${e.year}`;
|
|
718
|
+
case "week_of_long":
|
|
719
|
+
return `Week of ${h(e.month, t, "long")} ${e.day}, ${e.year}`;
|
|
720
|
+
case "quarter_short":
|
|
721
|
+
return `Q${a} ${e.year}`;
|
|
722
|
+
case "quarter_long":
|
|
723
|
+
return `${ce(a)} Quarter ${e.year}`;
|
|
724
|
+
case "fiscal_quarter_short":
|
|
725
|
+
return `Q${a} FY${E(e, n)}`;
|
|
726
|
+
case "fiscal_year":
|
|
727
|
+
return `FY${E(e, n)}`;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function le(e, r, t, o) {
|
|
731
|
+
const n = S(r);
|
|
732
|
+
switch (r.granularity) {
|
|
733
|
+
case "second":
|
|
734
|
+
case "minute":
|
|
735
|
+
case "hour":
|
|
736
|
+
return ae(e, t, o.dateTime);
|
|
737
|
+
case "day":
|
|
738
|
+
return A(e, t, o.dateStyle);
|
|
739
|
+
case "week":
|
|
740
|
+
return `Week of ${A(e, t, o.dateStyle)}`;
|
|
741
|
+
case "month":
|
|
742
|
+
return ie(e, t, o.dateStyle);
|
|
743
|
+
case "quarter":
|
|
744
|
+
return k(
|
|
745
|
+
e,
|
|
746
|
+
n ? "fiscal_quarter_short" : "quarter_short",
|
|
747
|
+
t,
|
|
748
|
+
r
|
|
749
|
+
);
|
|
750
|
+
case "year":
|
|
751
|
+
return n ? k(e, "fiscal_year", t, r) : String(e.year);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
function $e(e) {
|
|
755
|
+
const r = te(e.format);
|
|
756
|
+
if (!r.ok || !F(r.value, e.metadata))
|
|
757
|
+
throw new _(
|
|
758
|
+
"invalid_temporal_bucket_format",
|
|
759
|
+
"Resolved temporal bucket format is invalid or inapplicable to its metadata."
|
|
760
|
+
);
|
|
761
|
+
const t = re(e.value, e.metadata);
|
|
762
|
+
if (!t.ok)
|
|
763
|
+
throw new _(
|
|
764
|
+
t.error.code,
|
|
765
|
+
t.error.message
|
|
766
|
+
);
|
|
767
|
+
if (t.value === null) return "(Blank)";
|
|
768
|
+
const { presentation: o, locale: n } = r.value;
|
|
769
|
+
if (o.mode === "auto")
|
|
770
|
+
return le(
|
|
771
|
+
t.value,
|
|
772
|
+
e.metadata,
|
|
773
|
+
n,
|
|
774
|
+
o.styles
|
|
775
|
+
);
|
|
776
|
+
if (o.mode === "preset")
|
|
777
|
+
return k(
|
|
778
|
+
t.value,
|
|
779
|
+
o.preset,
|
|
780
|
+
n,
|
|
781
|
+
e.metadata
|
|
782
|
+
);
|
|
783
|
+
const a = O(o.pattern);
|
|
784
|
+
if (!a.ok)
|
|
785
|
+
throw new _(
|
|
786
|
+
"invalid_temporal_bucket_format",
|
|
787
|
+
a.message
|
|
788
|
+
);
|
|
789
|
+
return ne(t.value, a.segments, n);
|
|
790
|
+
}
|
|
791
|
+
export {
|
|
792
|
+
fe as C,
|
|
793
|
+
q as D,
|
|
794
|
+
_ as T,
|
|
795
|
+
be as a,
|
|
796
|
+
ge as b,
|
|
797
|
+
V as c,
|
|
798
|
+
ye as d,
|
|
799
|
+
_e as e,
|
|
800
|
+
$e as f,
|
|
801
|
+
he as g,
|
|
802
|
+
we as h,
|
|
803
|
+
J as i,
|
|
804
|
+
te as j,
|
|
805
|
+
Ce as k,
|
|
806
|
+
g as l,
|
|
807
|
+
re as p,
|
|
808
|
+
pe as r,
|
|
809
|
+
P as v
|
|
810
|
+
};
|