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
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
var D = Object.defineProperty;
|
|
2
|
-
var E = (e, t, r) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
-
var _ = (e, t, r) => E(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { canonicalizeSupportedLocale as w } from "../value-format-preferences/index.js";
|
|
5
|
-
const q = [
|
|
6
|
-
"YYYY",
|
|
7
|
-
"MMMM",
|
|
8
|
-
"MMM",
|
|
9
|
-
"YY",
|
|
10
|
-
"MM",
|
|
11
|
-
"DD",
|
|
12
|
-
"HH",
|
|
13
|
-
"mm",
|
|
14
|
-
"ss"
|
|
15
|
-
], P = /* @__PURE__ */ new Set([" ", "-", "/", ":", ".", ",", "T"]), v = {
|
|
16
|
-
week_of_short: "week",
|
|
17
|
-
week_of_long: "week",
|
|
18
|
-
quarter_short: "quarter",
|
|
19
|
-
quarter_long: "quarter",
|
|
20
|
-
fiscal_quarter_short: "quarter",
|
|
21
|
-
fiscal_year: "year"
|
|
22
|
-
};
|
|
23
|
-
function O(e) {
|
|
24
|
-
return typeof e == "string" && Object.prototype.hasOwnProperty.call(v, e);
|
|
25
|
-
}
|
|
26
|
-
function N(e, t) {
|
|
27
|
-
return q.find(
|
|
28
|
-
(r) => e.startsWith(r, t)
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
function k(e) {
|
|
32
|
-
var a;
|
|
33
|
-
if (!e || e.trim() !== e)
|
|
34
|
-
return {
|
|
35
|
-
ok: !1,
|
|
36
|
-
code: "invalid_temporal_bucket_pattern",
|
|
37
|
-
message: "Temporal bucket patterns must be non-empty and trimmed."
|
|
38
|
-
};
|
|
39
|
-
const t = [];
|
|
40
|
-
let r = 0, n = !1;
|
|
41
|
-
for (; r < e.length; ) {
|
|
42
|
-
const o = N(e, r);
|
|
43
|
-
if (o) {
|
|
44
|
-
if (n)
|
|
45
|
-
return {
|
|
46
|
-
ok: !1,
|
|
47
|
-
code: "invalid_temporal_bucket_pattern",
|
|
48
|
-
message: "Adjacent temporal bucket tokens require a separator."
|
|
49
|
-
};
|
|
50
|
-
t.push({ kind: "token", value: o }), r += o.length, n = !0;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const u = e[r];
|
|
54
|
-
if (!P.has(u))
|
|
55
|
-
return {
|
|
56
|
-
ok: !1,
|
|
57
|
-
code: "invalid_temporal_bucket_pattern",
|
|
58
|
-
message: `Unsupported temporal bucket pattern character "${u}".`
|
|
59
|
-
};
|
|
60
|
-
if (t.length === 0)
|
|
61
|
-
return {
|
|
62
|
-
ok: !1,
|
|
63
|
-
code: "invalid_temporal_bucket_pattern",
|
|
64
|
-
message: "Temporal bucket patterns cannot begin with a separator."
|
|
65
|
-
};
|
|
66
|
-
const s = t[t.length - 1];
|
|
67
|
-
s.kind === "literal" ? s.value += u : t.push({ kind: "literal", value: u }), r += 1, n = !1;
|
|
68
|
-
}
|
|
69
|
-
return ((a = t[t.length - 1]) == null ? void 0 : a.kind) !== "token" ? {
|
|
70
|
-
ok: !1,
|
|
71
|
-
code: "invalid_temporal_bucket_pattern",
|
|
72
|
-
message: "Temporal bucket patterns cannot end with a separator."
|
|
73
|
-
} : { ok: !0, segments: t };
|
|
74
|
-
}
|
|
75
|
-
function F(e) {
|
|
76
|
-
return e.flatMap(
|
|
77
|
-
(t) => t.kind === "token" ? [t.value] : []
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
function b(e, t) {
|
|
81
|
-
return e.filter((r) => t.includes(r)).length === 1;
|
|
82
|
-
}
|
|
83
|
-
function l(e, t) {
|
|
84
|
-
return e.some((r) => t.includes(r));
|
|
85
|
-
}
|
|
86
|
-
function H(e) {
|
|
87
|
-
return new Set(e).size !== e.length;
|
|
88
|
-
}
|
|
89
|
-
function B(e, t) {
|
|
90
|
-
if (H(e)) return !1;
|
|
91
|
-
const r = ["YYYY", "YY"], n = ["MMMM", "MMM", "MM"], a = ["HH", "mm", "ss"], o = b(e, r), u = b(e, n), s = e.includes("DD"), d = l(e, a);
|
|
92
|
-
switch (t) {
|
|
93
|
-
case "second":
|
|
94
|
-
return e.includes("HH") && e.includes("mm") && e.includes("ss") && (!l(e, [...r, ...n, "DD"]) || o && u && s);
|
|
95
|
-
case "minute":
|
|
96
|
-
return e.includes("HH") && e.includes("mm") && (!l(e, [...r, ...n, "DD"]) || o && u && s);
|
|
97
|
-
case "hour":
|
|
98
|
-
return e.includes("HH") && (!l(e, [...r, ...n, "DD"]) || o && u && s);
|
|
99
|
-
case "day":
|
|
100
|
-
case "week":
|
|
101
|
-
return o && u && s && !d;
|
|
102
|
-
case "month":
|
|
103
|
-
return o && u && !s && !d;
|
|
104
|
-
case "quarter":
|
|
105
|
-
return !1;
|
|
106
|
-
case "year":
|
|
107
|
-
return o && !u && !s && !d;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function Y(e, t) {
|
|
111
|
-
if (e.presentation.mode === "auto")
|
|
112
|
-
return { ok: !0 };
|
|
113
|
-
if (e.presentation.mode === "preset") {
|
|
114
|
-
const n = v[e.presentation.preset];
|
|
115
|
-
return n === t ? { ok: !0 } : {
|
|
116
|
-
ok: !1,
|
|
117
|
-
code: "incompatible_temporal_bucket_preset",
|
|
118
|
-
message: `Preset ${e.presentation.preset} requires ${n} granularity.`
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
const r = k(e.presentation.pattern);
|
|
122
|
-
return r.ok ? B(
|
|
123
|
-
F(r.segments),
|
|
124
|
-
t
|
|
125
|
-
) ? { ok: !0, segments: r.segments } : {
|
|
126
|
-
ok: !1,
|
|
127
|
-
code: "incompatible_temporal_bucket_pattern",
|
|
128
|
-
message: `Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`
|
|
129
|
-
} : r;
|
|
130
|
-
}
|
|
131
|
-
function ee(e, t) {
|
|
132
|
-
if (!(!e || !t))
|
|
133
|
-
return Y(e, t).ok ? e : void 0;
|
|
134
|
-
}
|
|
135
|
-
class m extends Error {
|
|
136
|
-
constructor(r, n) {
|
|
137
|
-
super(n);
|
|
138
|
-
_(this, "code");
|
|
139
|
-
this.name = "TemporalBucketContractError", this.code = r;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const x = {
|
|
143
|
-
type: "temporal_bucket",
|
|
144
|
-
presentation: { mode: "auto" }
|
|
145
|
-
}, A = [
|
|
146
|
-
"Jan",
|
|
147
|
-
"Feb",
|
|
148
|
-
"Mar",
|
|
149
|
-
"Apr",
|
|
150
|
-
"May",
|
|
151
|
-
"Jun",
|
|
152
|
-
"Jul",
|
|
153
|
-
"Aug",
|
|
154
|
-
"Sep",
|
|
155
|
-
"Oct",
|
|
156
|
-
"Nov",
|
|
157
|
-
"Dec"
|
|
158
|
-
], C = [
|
|
159
|
-
"January",
|
|
160
|
-
"February",
|
|
161
|
-
"March",
|
|
162
|
-
"April",
|
|
163
|
-
"May",
|
|
164
|
-
"June",
|
|
165
|
-
"July",
|
|
166
|
-
"August",
|
|
167
|
-
"September",
|
|
168
|
-
"October",
|
|
169
|
-
"November",
|
|
170
|
-
"December"
|
|
171
|
-
];
|
|
172
|
-
function p(e) {
|
|
173
|
-
return {
|
|
174
|
-
ok: !1,
|
|
175
|
-
error: { code: "invalid_temporal_bucket_value", message: e }
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function R(e) {
|
|
179
|
-
return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
|
|
180
|
-
}
|
|
181
|
-
function j(e, t) {
|
|
182
|
-
return t === 2 ? R(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
|
|
183
|
-
}
|
|
184
|
-
function U(e, t, r) {
|
|
185
|
-
const n = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], a = t < 3 ? e - 1 : e;
|
|
186
|
-
return (a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + n[t - 1] + r) % 7;
|
|
187
|
-
}
|
|
188
|
-
function y(e) {
|
|
189
|
-
var t;
|
|
190
|
-
return (t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth;
|
|
191
|
-
}
|
|
192
|
-
function z(e, t) {
|
|
193
|
-
return (e - t + 12) % 12 % 3 === 0;
|
|
194
|
-
}
|
|
195
|
-
function J(e, t) {
|
|
196
|
-
const { granularity: r } = t, n = y(t) ?? 1;
|
|
197
|
-
switch (r) {
|
|
198
|
-
case "second":
|
|
199
|
-
return !0;
|
|
200
|
-
case "minute":
|
|
201
|
-
return e.second === 0;
|
|
202
|
-
case "hour":
|
|
203
|
-
return e.minute === 0 && e.second === 0;
|
|
204
|
-
case "day":
|
|
205
|
-
return !0;
|
|
206
|
-
case "week":
|
|
207
|
-
return U(e.year, e.month, e.day) === t.calendar.weekStart;
|
|
208
|
-
case "month":
|
|
209
|
-
return e.day === 1;
|
|
210
|
-
case "quarter":
|
|
211
|
-
return e.day === 1 && z(e.month, n);
|
|
212
|
-
case "year":
|
|
213
|
-
return e.day === 1 && e.month === n;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function L(e, t) {
|
|
217
|
-
if (e === null) return { ok: !0, value: null };
|
|
218
|
-
const r = t.granularity === "second" || t.granularity === "minute" || t.granularity === "hour", n = r ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
219
|
-
if (!n)
|
|
220
|
-
return p(
|
|
221
|
-
`Expected ${r ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${t.granularity} granularity.`
|
|
222
|
-
);
|
|
223
|
-
const a = {
|
|
224
|
-
year: Number(n[1]),
|
|
225
|
-
month: Number(n[2]),
|
|
226
|
-
day: Number(n[3]),
|
|
227
|
-
hour: r ? Number(n[4]) : 0,
|
|
228
|
-
minute: r ? Number(n[5]) : 0,
|
|
229
|
-
second: r ? Number(n[6]) : 0
|
|
230
|
-
};
|
|
231
|
-
return a.year < 1 || a.month < 1 || a.month > 12 || a.day < 1 || a.day > j(a.year, a.month) || a.hour > 23 || a.minute > 59 || a.second > 59 ? p(`Invalid canonical ${t.granularity} bucket value ${e}.`) : J(a, t) ? { ok: !0, value: a } : p(
|
|
232
|
-
`Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
function g(e) {
|
|
236
|
-
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
237
|
-
return !1;
|
|
238
|
-
const t = Object.getPrototypeOf(e);
|
|
239
|
-
return t === null || t === Object.prototype;
|
|
240
|
-
}
|
|
241
|
-
function I(e) {
|
|
242
|
-
if (!g(e))
|
|
243
|
-
return {
|
|
244
|
-
ok: !1,
|
|
245
|
-
issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
|
|
246
|
-
};
|
|
247
|
-
const t = [], r = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
|
|
248
|
-
for (const o of Object.keys(e))
|
|
249
|
-
r.has(o) || t.push({ path: o, message: `Unknown property "${o}".` });
|
|
250
|
-
e.type !== "temporal_bucket" && t.push({ path: "type", message: "Expected temporal_bucket." });
|
|
251
|
-
const n = e.presentation;
|
|
252
|
-
if (!g(n))
|
|
253
|
-
t.push({ path: "presentation", message: "Expected a presentation object." });
|
|
254
|
-
else {
|
|
255
|
-
const o = n.mode, u = o === "preset" ? /* @__PURE__ */ new Set(["mode", "preset"]) : o === "pattern" ? /* @__PURE__ */ new Set(["mode", "pattern"]) : /* @__PURE__ */ new Set(["mode"]);
|
|
256
|
-
for (const s of Object.keys(n))
|
|
257
|
-
u.has(s) || t.push({
|
|
258
|
-
path: `presentation.${s}`,
|
|
259
|
-
message: `Unknown property "${s}".`
|
|
260
|
-
});
|
|
261
|
-
if (o === "preset")
|
|
262
|
-
O(n.preset) || t.push({ path: "presentation.preset", message: "Expected a supported preset." });
|
|
263
|
-
else if (o === "pattern")
|
|
264
|
-
if (typeof n.pattern != "string" || !n.pattern)
|
|
265
|
-
t.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
|
|
266
|
-
else {
|
|
267
|
-
const s = k(n.pattern);
|
|
268
|
-
s.ok || t.push({
|
|
269
|
-
path: "presentation.pattern",
|
|
270
|
-
message: s.message
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
else o !== "auto" && t.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
|
|
274
|
-
}
|
|
275
|
-
const a = w(e.locale);
|
|
276
|
-
return a || t.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), t.length > 0 || !a ? { ok: !1, issues: t } : {
|
|
277
|
-
ok: !0,
|
|
278
|
-
value: {
|
|
279
|
-
type: "temporal_bucket",
|
|
280
|
-
presentation: n,
|
|
281
|
-
locale: a
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
function G(e, t) {
|
|
286
|
-
const r = !!t.calendar.fiscalCalendar;
|
|
287
|
-
return e === "fiscal_quarter_short" || e === "fiscal_year" ? r : e === "quarter_short" || e === "quarter_long" ? !r : !0;
|
|
288
|
-
}
|
|
289
|
-
function S(e, t) {
|
|
290
|
-
return Y(e, t.granularity).ok ? e.presentation.mode === "preset" ? G(e.presentation.preset, t) : !(e.presentation.mode === "pattern" && t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year")) : !1;
|
|
291
|
-
}
|
|
292
|
-
function M(e, t) {
|
|
293
|
-
if (!(!e || e.presentation.mode === "auto"))
|
|
294
|
-
return S(e, t) ? e : void 0;
|
|
295
|
-
}
|
|
296
|
-
function te(e) {
|
|
297
|
-
var a;
|
|
298
|
-
const t = w(e.locale);
|
|
299
|
-
if (!t)
|
|
300
|
-
throw new m(
|
|
301
|
-
"invalid_temporal_bucket_format",
|
|
302
|
-
"Temporal bucket locale must be a supported base BCP 47 locale."
|
|
303
|
-
);
|
|
304
|
-
const r = M(e.cardFormat, e.metadata);
|
|
305
|
-
if (r)
|
|
306
|
-
return { format: { ...r, locale: t }, source: "card" };
|
|
307
|
-
const n = ((a = e.semanticFormat) == null ? void 0 : a.granularity) === e.metadata.granularity ? M(e.semanticFormat.format, e.metadata) : void 0;
|
|
308
|
-
return n ? { format: { ...n, locale: t }, source: "semantic" } : { format: { ...x, locale: t }, source: "automatic" };
|
|
309
|
-
}
|
|
310
|
-
function c(e, t = 2) {
|
|
311
|
-
return String(e).padStart(t, "0");
|
|
312
|
-
}
|
|
313
|
-
function i(e, t, r) {
|
|
314
|
-
if (t === "en-US")
|
|
315
|
-
return (r === "short" ? A : C)[e - 1];
|
|
316
|
-
const n = new Date(Date.UTC(2e3, e - 1, 15));
|
|
317
|
-
return new Intl.DateTimeFormat(t, { month: r, timeZone: "UTC" }).format(
|
|
318
|
-
n
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
function K(e, t, r) {
|
|
322
|
-
return t.map((n) => {
|
|
323
|
-
if (n.kind === "literal") return n.value;
|
|
324
|
-
switch (n.value) {
|
|
325
|
-
case "YYYY":
|
|
326
|
-
return c(e.year, 4);
|
|
327
|
-
case "YY":
|
|
328
|
-
return c(e.year % 100);
|
|
329
|
-
case "MMMM":
|
|
330
|
-
return i(e.month, r, "long");
|
|
331
|
-
case "MMM":
|
|
332
|
-
return i(e.month, r, "short");
|
|
333
|
-
case "MM":
|
|
334
|
-
return c(e.month);
|
|
335
|
-
case "DD":
|
|
336
|
-
return c(e.day);
|
|
337
|
-
case "HH":
|
|
338
|
-
return c(e.hour);
|
|
339
|
-
case "mm":
|
|
340
|
-
return c(e.minute);
|
|
341
|
-
case "ss":
|
|
342
|
-
return c(e.second);
|
|
343
|
-
}
|
|
344
|
-
}).join("");
|
|
345
|
-
}
|
|
346
|
-
function T(e, t) {
|
|
347
|
-
return `${e.hour % 12 || 12}:${c(e.minute)}${t ? `:${c(e.second)}` : ""} ${e.hour < 12 ? "AM" : "PM"}`;
|
|
348
|
-
}
|
|
349
|
-
function h(e) {
|
|
350
|
-
return `${A[e.month - 1]} ${e.day}, ${e.year}`;
|
|
351
|
-
}
|
|
352
|
-
function Q(e, t) {
|
|
353
|
-
return Math.floor((e.month - t + 12) % 12 / 3) + 1;
|
|
354
|
-
}
|
|
355
|
-
function $(e, t) {
|
|
356
|
-
return t === 1 || e.month < t ? e.year : e.year + 1;
|
|
357
|
-
}
|
|
358
|
-
function W(e) {
|
|
359
|
-
return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
|
|
360
|
-
}
|
|
361
|
-
function f(e, t, r, n) {
|
|
362
|
-
const a = y(n) ?? 1, o = Q(e, a);
|
|
363
|
-
switch (t) {
|
|
364
|
-
case "week_of_short":
|
|
365
|
-
return `Week of ${i(e.month, r, "short")} ${e.day}, ${e.year}`;
|
|
366
|
-
case "week_of_long":
|
|
367
|
-
return `Week of ${i(e.month, r, "long")} ${e.day}, ${e.year}`;
|
|
368
|
-
case "quarter_short":
|
|
369
|
-
return `Q${o} ${e.year}`;
|
|
370
|
-
case "quarter_long":
|
|
371
|
-
return `${W(o)} Quarter ${e.year}`;
|
|
372
|
-
case "fiscal_quarter_short":
|
|
373
|
-
return `Q${o} FY${$(e, a)}`;
|
|
374
|
-
case "fiscal_year":
|
|
375
|
-
return `FY${$(e, a)}`;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
function V(e, t, r) {
|
|
379
|
-
const n = y(t);
|
|
380
|
-
switch (t.granularity) {
|
|
381
|
-
case "second":
|
|
382
|
-
return `${h(e)}, ${T(e, !0)}`;
|
|
383
|
-
case "minute":
|
|
384
|
-
case "hour":
|
|
385
|
-
return `${h(e)}, ${T(e, !1)}`;
|
|
386
|
-
case "day":
|
|
387
|
-
return h(e);
|
|
388
|
-
case "week":
|
|
389
|
-
return f(e, "week_of_short", r, t);
|
|
390
|
-
case "month":
|
|
391
|
-
return `${i(e.month, r, "short")} ${e.year}`;
|
|
392
|
-
case "quarter":
|
|
393
|
-
return f(
|
|
394
|
-
e,
|
|
395
|
-
n ? "fiscal_quarter_short" : "quarter_short",
|
|
396
|
-
r,
|
|
397
|
-
t
|
|
398
|
-
);
|
|
399
|
-
case "year":
|
|
400
|
-
return n ? f(e, "fiscal_year", r, t) : String(e.year);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
function re(e) {
|
|
404
|
-
const t = I(e.format);
|
|
405
|
-
if (!t.ok || !S(t.value, e.metadata))
|
|
406
|
-
throw new m(
|
|
407
|
-
"invalid_temporal_bucket_format",
|
|
408
|
-
"Resolved temporal bucket format is invalid or inapplicable to its metadata."
|
|
409
|
-
);
|
|
410
|
-
const r = L(e.value, e.metadata);
|
|
411
|
-
if (!r.ok)
|
|
412
|
-
throw new m(
|
|
413
|
-
r.error.code,
|
|
414
|
-
r.error.message
|
|
415
|
-
);
|
|
416
|
-
if (r.value === null) return "(Blank)";
|
|
417
|
-
const { presentation: n, locale: a } = t.value;
|
|
418
|
-
if (n.mode === "auto")
|
|
419
|
-
return V(r.value, e.metadata, a);
|
|
420
|
-
if (n.mode === "preset")
|
|
421
|
-
return f(
|
|
422
|
-
r.value,
|
|
423
|
-
n.preset,
|
|
424
|
-
a,
|
|
425
|
-
e.metadata
|
|
426
|
-
);
|
|
427
|
-
const o = k(n.pattern);
|
|
428
|
-
if (!o.ok)
|
|
429
|
-
throw new m(
|
|
430
|
-
"invalid_temporal_bucket_format",
|
|
431
|
-
o.message
|
|
432
|
-
);
|
|
433
|
-
return K(r.value, o.segments, a);
|
|
434
|
-
}
|
|
435
|
-
export {
|
|
436
|
-
q as T,
|
|
437
|
-
m as a,
|
|
438
|
-
L as b,
|
|
439
|
-
te as c,
|
|
440
|
-
re as f,
|
|
441
|
-
O as i,
|
|
442
|
-
I as p,
|
|
443
|
-
ee as r,
|
|
444
|
-
k as t,
|
|
445
|
-
Y as v
|
|
446
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const p=require("./temporal-bucket-pMnV-4Nj.cjs"),c={type:"temporal_bucket",presentation:{mode:"auto"}},m={value:"auto",label:"Automatic",format:c};function o(t,e){return{value:`pattern:${t}`,label:e,format:{type:"temporal_bucket",presentation:{mode:"pattern",pattern:t}}}}function i(t,e){return{value:`preset:${t}`,label:e,format:{type:"temporal_bucket",presentation:{mode:"preset",preset:t}}}}function M(t){return{...o(t,"Custom format…"),value:"custom",custom:!0}}const l={second:[m,o("HH:mm:ss","14:30:45 (HH:mm:ss)"),o("YYYY-MM-DD HH:mm:ss","2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"),M("DD/MM/YYYY HH:mm:ss")],minute:[m,o("HH:mm","14:30 (HH:mm)"),o("YYYY-MM-DD HH:mm","2024-01-15 14:30 (YYYY-MM-DD HH:mm)"),M("DD/MM/YYYY HH:mm")],hour:[m,o("HH","14 (HH)"),o("YYYY-MM-DD HH","2024-01-15 14 (YYYY-MM-DD HH)"),M("DD/MM/YYYY HH")],day:[m,o("YYYY-MM-DD","2024-01-15 (YYYY-MM-DD)"),o("MM/DD/YYYY","01/15/2024 (MM/DD/YYYY)"),o("DD/MM/YYYY","15/01/2024 (DD/MM/YYYY)"),o("MMM DD, YYYY","Jan 15, 2024 (MMM DD, YYYY)"),o("MMMM DD, YYYY","January 15, 2024 (MMMM DD, YYYY)"),M("YYYY/MM/DD")],week:[m,i("week_of_short","Week of Jan 15, 2024"),i("week_of_long","Week of January 15, 2024"),o("YYYY-MM-DD","2024-01-15 (YYYY-MM-DD)"),M("YYYY/MM/DD")],month:[m,o("MMM YYYY","Jan 2024 (MMM YYYY)"),o("MMMM YYYY","January 2024 (MMMM YYYY)"),o("YYYY-MM","2024-01 (YYYY-MM)"),o("MM/YYYY","01/2024 (MM/YYYY)"),o("YYYY MMM","2024 Jan (YYYY MMM)"),M("YYYY/MM")],quarter:[m,i("quarter_short","Q1 2024"),i("quarter_long","1st Quarter 2024")],year:[m,o("YYYY","2024 (YYYY)"),o("YY","24 (YY)")]},k={second:"2026-07-31T14:05:09",minute:"2026-07-31T14:05:00",hour:"2026-07-31T14:00:00",day:"2026-07-31",week:"2026-07-27",month:"2026-07-01",quarter:"2026-07-01",year:"2026-01-01"};function D(t,e){return p.formatTemporalBucket({value:k[e],metadata:{kind:"temporal_bucket",granularity:e,calendar:{tz:"UTC",weekStart:1,...t.presentation.mode==="preset"&&(t.presentation.preset==="fiscal_quarter_short"||t.presentation.preset==="fiscal_year")?{fiscalCalendar:{kind:"month_aligned",yearStartMonth:7}}:{}}},format:{...t,locale:"en-US"}})}function f(t,e){const u=l[t],Y=(e==null?void 0:e.presentation.mode)==="preset"?e.presentation.preset:void 0,n=Y&&e&&p.validateTemporalBucketFormatApplicability(e,t).ok&&!u.some(r=>{var a;return((a=r.format)==null?void 0:a.presentation.mode)==="preset"&&r.format.presentation.preset===Y})?i(Y,Y):void 0;return(n?[...u,n]:u).map(r=>{if(!r.format||r.custom)return r;const a=D(r.format,t);return r.format.presentation.mode==="pattern"?{...r,label:`${a} (${r.format.presentation.pattern})`}:r.format.presentation.mode==="auto"?{...r,label:`Automatic (${a})`}:{...r,label:a}})}function d(t,e){const u=l[e];if(t.presentation.mode==="pattern"){const Y=t.presentation.pattern,n=u.find(s=>{var r;return((r=s.format)==null?void 0:r.presentation.mode)==="pattern"&&s.format.presentation.pattern===Y});return{value:(n==null?void 0:n.value)??"custom",customPattern:n!=null&&n.custom||!n?Y:"",format:t}}if(t.presentation.mode==="preset"){const Y=t.presentation.preset,n=u.find(r=>{var a;return((a=r.format)==null?void 0:a.presentation.mode)==="preset"&&r.format.presentation.preset===Y}),s=p.validateTemporalBucketFormatApplicability(t,e).ok;return n?{value:n.value,customPattern:"",format:t}:s?{value:`preset:${Y}`,customPattern:"",format:t}:{value:"auto",customPattern:"",format:c}}return{value:"auto",customPattern:"",format:t}}function T(t,e,u=""){var r;const Y=l[t].find(a=>a.value===e),n=e.startsWith("preset:")?e.slice(7):void 0,s=e==="custom"?{type:"temporal_bucket",presentation:{mode:"pattern",pattern:u.trim()||(((r=Y==null?void 0:Y.format)==null?void 0:r.presentation.mode)==="pattern"?Y.format.presentation.pattern:"")}}:(Y==null?void 0:Y.format)??(n&&p.isTemporalBucketPreset(n)?{type:"temporal_bucket",presentation:{mode:"preset",preset:n}}:void 0);return!s||!p.validateTemporalBucketFormatApplicability(s,t).ok?c:s}function H(t,e){return p.validateTemporalBucketFormatApplicability(t,e).ok?t:c}exports.AUTOMATIC_TEMPORAL_BUCKET_FORMAT=c;exports.getTemporalBucketAuthoringOptions=f;exports.getTemporalBucketAuthoringSelection=d;exports.previewTemporalBucketAuthoringFormat=D;exports.reconcileTemporalBucketAuthoringFormat=H;exports.resolveTemporalBucketAuthoringFormat=T;
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { v as i, f as l, i as f } from "./temporal-bucket-BnPxGrAi.js";
|
|
2
|
-
const c = {
|
|
3
|
-
type: "temporal_bucket",
|
|
4
|
-
presentation: { mode: "auto" }
|
|
5
|
-
}, m = {
|
|
6
|
-
value: "auto",
|
|
7
|
-
label: "Automatic",
|
|
8
|
-
format: c
|
|
9
|
-
};
|
|
10
|
-
function r(t, e) {
|
|
11
|
-
return {
|
|
12
|
-
value: `pattern:${t}`,
|
|
13
|
-
label: e,
|
|
14
|
-
format: {
|
|
15
|
-
type: "temporal_bucket",
|
|
16
|
-
presentation: { mode: "pattern", pattern: t }
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function p(t, e) {
|
|
21
|
-
return {
|
|
22
|
-
value: `preset:${t}`,
|
|
23
|
-
label: e,
|
|
24
|
-
format: {
|
|
25
|
-
type: "temporal_bucket",
|
|
26
|
-
presentation: { mode: "preset", preset: t }
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function u(t) {
|
|
31
|
-
return {
|
|
32
|
-
...r(t, "Custom format…"),
|
|
33
|
-
value: "custom",
|
|
34
|
-
custom: !0
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const D = {
|
|
38
|
-
second: [
|
|
39
|
-
m,
|
|
40
|
-
r("HH:mm:ss", "14:30:45 (HH:mm:ss)"),
|
|
41
|
-
r(
|
|
42
|
-
"YYYY-MM-DD HH:mm:ss",
|
|
43
|
-
"2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"
|
|
44
|
-
),
|
|
45
|
-
u("DD/MM/YYYY HH:mm:ss")
|
|
46
|
-
],
|
|
47
|
-
minute: [
|
|
48
|
-
m,
|
|
49
|
-
r("HH:mm", "14:30 (HH:mm)"),
|
|
50
|
-
r("YYYY-MM-DD HH:mm", "2024-01-15 14:30 (YYYY-MM-DD HH:mm)"),
|
|
51
|
-
u("DD/MM/YYYY HH:mm")
|
|
52
|
-
],
|
|
53
|
-
hour: [
|
|
54
|
-
m,
|
|
55
|
-
r("HH", "14 (HH)"),
|
|
56
|
-
r("YYYY-MM-DD HH", "2024-01-15 14 (YYYY-MM-DD HH)"),
|
|
57
|
-
u("DD/MM/YYYY HH")
|
|
58
|
-
],
|
|
59
|
-
day: [
|
|
60
|
-
m,
|
|
61
|
-
r("YYYY-MM-DD", "2024-01-15 (YYYY-MM-DD)"),
|
|
62
|
-
r("MM/DD/YYYY", "01/15/2024 (MM/DD/YYYY)"),
|
|
63
|
-
r("DD/MM/YYYY", "15/01/2024 (DD/MM/YYYY)"),
|
|
64
|
-
r("MMM DD, YYYY", "Jan 15, 2024 (MMM DD, YYYY)"),
|
|
65
|
-
r("MMMM DD, YYYY", "January 15, 2024 (MMMM DD, YYYY)"),
|
|
66
|
-
u("YYYY/MM/DD")
|
|
67
|
-
],
|
|
68
|
-
week: [
|
|
69
|
-
m,
|
|
70
|
-
p("week_of_short", "Week of Jan 15, 2024"),
|
|
71
|
-
p("week_of_long", "Week of January 15, 2024"),
|
|
72
|
-
r("YYYY-MM-DD", "2024-01-15 (YYYY-MM-DD)"),
|
|
73
|
-
u("YYYY/MM/DD")
|
|
74
|
-
],
|
|
75
|
-
month: [
|
|
76
|
-
m,
|
|
77
|
-
r("MMM YYYY", "Jan 2024 (MMM YYYY)"),
|
|
78
|
-
r("MMMM YYYY", "January 2024 (MMMM YYYY)"),
|
|
79
|
-
r("YYYY-MM", "2024-01 (YYYY-MM)"),
|
|
80
|
-
r("MM/YYYY", "01/2024 (MM/YYYY)"),
|
|
81
|
-
r("YYYY MMM", "2024 Jan (YYYY MMM)"),
|
|
82
|
-
u("YYYY/MM")
|
|
83
|
-
],
|
|
84
|
-
quarter: [
|
|
85
|
-
m,
|
|
86
|
-
p("quarter_short", "Q1 2024"),
|
|
87
|
-
p("quarter_long", "1st Quarter 2024")
|
|
88
|
-
],
|
|
89
|
-
year: [
|
|
90
|
-
m,
|
|
91
|
-
r("YYYY", "2024 (YYYY)"),
|
|
92
|
-
r("YY", "24 (YY)")
|
|
93
|
-
]
|
|
94
|
-
}, H = {
|
|
95
|
-
second: "2026-07-31T14:05:09",
|
|
96
|
-
minute: "2026-07-31T14:05:00",
|
|
97
|
-
hour: "2026-07-31T14:00:00",
|
|
98
|
-
day: "2026-07-31",
|
|
99
|
-
week: "2026-07-27",
|
|
100
|
-
month: "2026-07-01",
|
|
101
|
-
quarter: "2026-07-01",
|
|
102
|
-
year: "2026-01-01"
|
|
103
|
-
};
|
|
104
|
-
function d(t, e) {
|
|
105
|
-
return l({
|
|
106
|
-
value: H[e],
|
|
107
|
-
metadata: {
|
|
108
|
-
kind: "temporal_bucket",
|
|
109
|
-
granularity: e,
|
|
110
|
-
calendar: {
|
|
111
|
-
tz: "UTC",
|
|
112
|
-
weekStart: 1,
|
|
113
|
-
...t.presentation.mode === "preset" && (t.presentation.preset === "fiscal_quarter_short" || t.presentation.preset === "fiscal_year") ? {
|
|
114
|
-
fiscalCalendar: {
|
|
115
|
-
kind: "month_aligned",
|
|
116
|
-
yearStartMonth: 7
|
|
117
|
-
}
|
|
118
|
-
} : {}
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
format: { ...t, locale: "en-US" }
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function _(t, e) {
|
|
125
|
-
const M = D[t], n = (e == null ? void 0 : e.presentation.mode) === "preset" ? e.presentation.preset : void 0, a = n && e && i(e, t).ok && !M.some(
|
|
126
|
-
(Y) => {
|
|
127
|
-
var o;
|
|
128
|
-
return ((o = Y.format) == null ? void 0 : o.presentation.mode) === "preset" && Y.format.presentation.preset === n;
|
|
129
|
-
}
|
|
130
|
-
) ? p(n, n) : void 0;
|
|
131
|
-
return (a ? [...M, a] : M).map((Y) => {
|
|
132
|
-
if (!Y.format || Y.custom) return Y;
|
|
133
|
-
const o = d(
|
|
134
|
-
Y.format,
|
|
135
|
-
t
|
|
136
|
-
);
|
|
137
|
-
return Y.format.presentation.mode === "pattern" ? {
|
|
138
|
-
...Y,
|
|
139
|
-
label: `${o} (${Y.format.presentation.pattern})`
|
|
140
|
-
} : Y.format.presentation.mode === "auto" ? { ...Y, label: `Automatic (${o})` } : { ...Y, label: o };
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
function T(t, e) {
|
|
144
|
-
const M = D[e];
|
|
145
|
-
if (t.presentation.mode === "pattern") {
|
|
146
|
-
const n = t.presentation.pattern, a = M.find(
|
|
147
|
-
(s) => {
|
|
148
|
-
var Y;
|
|
149
|
-
return ((Y = s.format) == null ? void 0 : Y.presentation.mode) === "pattern" && s.format.presentation.pattern === n;
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
return {
|
|
153
|
-
value: (a == null ? void 0 : a.value) ?? "custom",
|
|
154
|
-
customPattern: a != null && a.custom || !a ? n : "",
|
|
155
|
-
format: t
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
if (t.presentation.mode === "preset") {
|
|
159
|
-
const n = t.presentation.preset, a = M.find(
|
|
160
|
-
(Y) => {
|
|
161
|
-
var o;
|
|
162
|
-
return ((o = Y.format) == null ? void 0 : o.presentation.mode) === "preset" && Y.format.presentation.preset === n;
|
|
163
|
-
}
|
|
164
|
-
), s = i(
|
|
165
|
-
t,
|
|
166
|
-
e
|
|
167
|
-
).ok;
|
|
168
|
-
return a ? { value: a.value, customPattern: "", format: t } : s ? {
|
|
169
|
-
value: `preset:${n}`,
|
|
170
|
-
customPattern: "",
|
|
171
|
-
format: t
|
|
172
|
-
} : { value: "auto", customPattern: "", format: c };
|
|
173
|
-
}
|
|
174
|
-
return { value: "auto", customPattern: "", format: t };
|
|
175
|
-
}
|
|
176
|
-
function h(t, e, M = "") {
|
|
177
|
-
var Y;
|
|
178
|
-
const n = D[t].find(
|
|
179
|
-
(o) => o.value === e
|
|
180
|
-
), a = e.startsWith("preset:") ? e.slice(7) : void 0, s = e === "custom" ? {
|
|
181
|
-
type: "temporal_bucket",
|
|
182
|
-
presentation: {
|
|
183
|
-
mode: "pattern",
|
|
184
|
-
pattern: M.trim() || (((Y = n == null ? void 0 : n.format) == null ? void 0 : Y.presentation.mode) === "pattern" ? n.format.presentation.pattern : "")
|
|
185
|
-
}
|
|
186
|
-
} : (n == null ? void 0 : n.format) ?? (a && f(a) ? {
|
|
187
|
-
type: "temporal_bucket",
|
|
188
|
-
presentation: {
|
|
189
|
-
mode: "preset",
|
|
190
|
-
preset: a
|
|
191
|
-
}
|
|
192
|
-
} : void 0);
|
|
193
|
-
return !s || !i(s, t).ok ? c : s;
|
|
194
|
-
}
|
|
195
|
-
function A(t, e) {
|
|
196
|
-
return i(t, e).ok ? t : c;
|
|
197
|
-
}
|
|
198
|
-
export {
|
|
199
|
-
c as A,
|
|
200
|
-
T as a,
|
|
201
|
-
A as b,
|
|
202
|
-
_ as g,
|
|
203
|
-
d as p,
|
|
204
|
-
h as r
|
|
205
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var q=Object.defineProperty;var F=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var b=(e,t,r)=>F(e,typeof t!="symbol"?t+"":t,r);const w=require("../value-format-preferences/index.cjs"),Y=["YYYY","MMMM","MMM","YY","MM","DD","HH","mm","ss"],O=new Set([" ","-","/",":",".",",","T"]),A={week_of_short:"week",week_of_long:"week",quarter_short:"quarter",quarter_long:"quarter",fiscal_quarter_short:"quarter",fiscal_year:"year"};function E(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(A,e)}function N(e,t){return Y.find(r=>e.startsWith(r,t))}function p(e){var a;if(!e||e.trim()!==e)return{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Temporal bucket patterns must be non-empty and trimmed."};const t=[];let r=0,n=!1;for(;r<e.length;){const o=N(e,r);if(o){if(n)return{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Adjacent temporal bucket tokens require a separator."};t.push({kind:"token",value:o}),r+=o.length,n=!0;continue}const u=e[r];if(!O.has(u))return{ok:!1,code:"invalid_temporal_bucket_pattern",message:`Unsupported temporal bucket pattern character "${u}".`};if(t.length===0)return{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Temporal bucket patterns cannot begin with a separator."};const s=t[t.length-1];s.kind==="literal"?s.value+=u:t.push({kind:"literal",value:u}),r+=1,n=!1}return((a=t[t.length-1])==null?void 0:a.kind)!=="token"?{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Temporal bucket patterns cannot end with a separator."}:{ok:!0,segments:t}}function H(e){return e.flatMap(t=>t.kind==="token"?[t.value]:[])}function g(e,t){return e.filter(r=>t.includes(r)).length===1}function m(e,t){return e.some(r=>t.includes(r))}function R(e){return new Set(e).size!==e.length}function C(e,t){if(R(e))return!1;const r=["YYYY","YY"],n=["MMMM","MMM","MM"],a=["HH","mm","ss"],o=g(e,r),u=g(e,n),s=e.includes("DD"),d=m(e,a);switch(t){case"second":return e.includes("HH")&&e.includes("mm")&&e.includes("ss")&&(!m(e,[...r,...n,"DD"])||o&&u&&s);case"minute":return e.includes("HH")&&e.includes("mm")&&(!m(e,[...r,...n,"DD"])||o&&u&&s);case"hour":return e.includes("HH")&&(!m(e,[...r,...n,"DD"])||o&&u&&s);case"day":case"week":return o&&u&&s&&!d;case"month":return o&&u&&!s&&!d;case"quarter":return!1;case"year":return o&&!u&&!s&&!d}}function y(e,t){if(e.presentation.mode==="auto")return{ok:!0};if(e.presentation.mode==="preset"){const n=A[e.presentation.preset];return n===t?{ok:!0}:{ok:!1,code:"incompatible_temporal_bucket_preset",message:`Preset ${e.presentation.preset} requires ${n} granularity.`}}const r=p(e.presentation.pattern);return r.ok?C(H(r.segments),t)?{ok:!0,segments:r.segments}:{ok:!1,code:"incompatible_temporal_bucket_pattern",message:`Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`}:r}function x(e,t){if(!(!e||!t))return y(e,t).ok?e:void 0}class i extends Error{constructor(r,n){super(n);b(this,"code");this.name="TemporalBucketContractError",this.code=r}}const j={type:"temporal_bucket",presentation:{mode:"auto"}},P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],U=["January","February","March","April","May","June","July","August","September","October","November","December"];function h(e){return{ok:!1,error:{code:"invalid_temporal_bucket_value",message:e}}}function z(e){return e%4===0&&(e%100!==0||e%400===0)}function L(e,t){return t===2?z(e)?29:28:[4,6,9,11].includes(t)?30:31}function J(e,t,r){const n=[0,3,2,5,0,3,5,1,4,6,2,4],a=t<3?e-1:e;return(a+Math.floor(a/4)-Math.floor(a/100)+Math.floor(a/400)+n[t-1]+r)%7}function _(e){var t;return(t=e.calendar.fiscalCalendar)==null?void 0:t.yearStartMonth}function K(e,t){return(e-t+12)%12%3===0}function I(e,t){const{granularity:r}=t,n=_(t)??1;switch(r){case"second":return!0;case"minute":return e.second===0;case"hour":return e.minute===0&&e.second===0;case"day":return!0;case"week":return J(e.year,e.month,e.day)===t.calendar.weekStart;case"month":return e.day===1;case"quarter":return e.day===1&&K(e.month,n);case"year":return e.day===1&&e.month===n}}function S(e,t){if(e===null)return{ok:!0,value:null};const r=t.granularity==="second"||t.granularity==="minute"||t.granularity==="hour",n=r?/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e):/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return h(`Expected ${r?"YYYY-MM-DDTHH:mm:ss":"YYYY-MM-DD"} for ${t.granularity} granularity.`);const a={year:Number(n[1]),month:Number(n[2]),day:Number(n[3]),hour:r?Number(n[4]):0,minute:r?Number(n[5]):0,second:r?Number(n[6]):0};return a.year<1||a.month<1||a.month>12||a.day<1||a.day>L(a.year,a.month)||a.hour>23||a.minute>59||a.second>59?h(`Invalid canonical ${t.granularity} bucket value ${e}.`):I(a,t)?{ok:!0,value:a}:h(`Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`)}function T(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function B(e){if(!T(e))return{ok:!1,issues:[{path:"$",message:"Resolved temporal bucket format must be an object."}]};const t=[],r=new Set(["type","presentation","locale"]);for(const o of Object.keys(e))r.has(o)||t.push({path:o,message:`Unknown property "${o}".`});e.type!=="temporal_bucket"&&t.push({path:"type",message:"Expected temporal_bucket."});const n=e.presentation;if(!T(n))t.push({path:"presentation",message:"Expected a presentation object."});else{const o=n.mode,u=o==="preset"?new Set(["mode","preset"]):o==="pattern"?new Set(["mode","pattern"]):new Set(["mode"]);for(const s of Object.keys(n))u.has(s)||t.push({path:`presentation.${s}`,message:`Unknown property "${s}".`});if(o==="preset")E(n.preset)||t.push({path:"presentation.preset",message:"Expected a supported preset."});else if(o==="pattern")if(typeof n.pattern!="string"||!n.pattern)t.push({path:"presentation.pattern",message:"Expected a non-empty pattern."});else{const s=p(n.pattern);s.ok||t.push({path:"presentation.pattern",message:s.message})}else o!=="auto"&&t.push({path:"presentation.mode",message:"Expected auto, preset, or pattern."})}const a=w.canonicalizeSupportedLocale(e.locale);return a||t.push({path:"locale",message:"Expected a supported base BCP 47 locale."}),t.length>0||!a?{ok:!1,issues:t}:{ok:!0,value:{type:"temporal_bucket",presentation:n,locale:a}}}function G(e,t){const r=!!t.calendar.fiscalCalendar;return e==="fiscal_quarter_short"||e==="fiscal_year"?r:e==="quarter_short"||e==="quarter_long"?!r:!0}function D(e,t){return y(e,t.granularity).ok?e.presentation.mode==="preset"?G(e.presentation.preset,t):!(e.presentation.mode==="pattern"&&t.calendar.fiscalCalendar&&(t.granularity==="quarter"||t.granularity==="year")):!1}function M(e,t){if(!(!e||e.presentation.mode==="auto"))return D(e,t)?e:void 0}function Q(e){var a;const t=w.canonicalizeSupportedLocale(e.locale);if(!t)throw new i("invalid_temporal_bucket_format","Temporal bucket locale must be a supported base BCP 47 locale.");const r=M(e.cardFormat,e.metadata);if(r)return{format:{...r,locale:t},source:"card"};const n=((a=e.semanticFormat)==null?void 0:a.granularity)===e.metadata.granularity?M(e.semanticFormat.format,e.metadata):void 0;return n?{format:{...n,locale:t},source:"semantic"}:{format:{...j,locale:t},source:"automatic"}}function c(e,t=2){return String(e).padStart(t,"0")}function l(e,t,r){if(t==="en-US")return(r==="short"?P:U)[e-1];const n=new Date(Date.UTC(2e3,e-1,15));return new Intl.DateTimeFormat(t,{month:r,timeZone:"UTC"}).format(n)}function V(e,t,r){return t.map(n=>{if(n.kind==="literal")return n.value;switch(n.value){case"YYYY":return c(e.year,4);case"YY":return c(e.year%100);case"MMMM":return l(e.month,r,"long");case"MMM":return l(e.month,r,"short");case"MM":return c(e.month);case"DD":return c(e.day);case"HH":return c(e.hour);case"mm":return c(e.minute);case"ss":return c(e.second)}}).join("")}function $(e,t){return`${e.hour%12||12}:${c(e.minute)}${t?`:${c(e.second)}`:""} ${e.hour<12?"AM":"PM"}`}function k(e){return`${P[e.month-1]} ${e.day}, ${e.year}`}function W(e,t){return Math.floor((e.month-t+12)%12/3)+1}function v(e,t){return t===1||e.month<t?e.year:e.year+1}function Z(e){return e===1?"1st":e===2?"2nd":e===3?"3rd":`${e}th`}function f(e,t,r,n){const a=_(n)??1,o=W(e,a);switch(t){case"week_of_short":return`Week of ${l(e.month,r,"short")} ${e.day}, ${e.year}`;case"week_of_long":return`Week of ${l(e.month,r,"long")} ${e.day}, ${e.year}`;case"quarter_short":return`Q${o} ${e.year}`;case"quarter_long":return`${Z(o)} Quarter ${e.year}`;case"fiscal_quarter_short":return`Q${o} FY${v(e,a)}`;case"fiscal_year":return`FY${v(e,a)}`}}function X(e,t,r){const n=_(t);switch(t.granularity){case"second":return`${k(e)}, ${$(e,!0)}`;case"minute":case"hour":return`${k(e)}, ${$(e,!1)}`;case"day":return k(e);case"week":return f(e,"week_of_short",r,t);case"month":return`${l(e.month,r,"short")} ${e.year}`;case"quarter":return f(e,n?"fiscal_quarter_short":"quarter_short",r,t);case"year":return n?f(e,"fiscal_year",r,t):String(e.year)}}function ee(e){const t=B(e.format);if(!t.ok||!D(t.value,e.metadata))throw new i("invalid_temporal_bucket_format","Resolved temporal bucket format is invalid or inapplicable to its metadata.");const r=S(e.value,e.metadata);if(!r.ok)throw new i(r.error.code,r.error.message);if(r.value===null)return"(Blank)";const{presentation:n,locale:a}=t.value;if(n.mode==="auto")return X(r.value,e.metadata,a);if(n.mode==="preset")return f(r.value,n.preset,a,e.metadata);const o=p(n.pattern);if(!o.ok)throw new i("invalid_temporal_bucket_format",o.message);return V(r.value,o.segments,a)}exports.TEMPORAL_BUCKET_PATTERN_TOKENS=Y;exports.TemporalBucketContractError=i;exports.formatTemporalBucket=ee;exports.isTemporalBucketPreset=E;exports.parseResolvedTemporalBucketFormat=B;exports.parseTemporalBucketValue=S;exports.resolveApplicableTemporalBucketFormat=x;exports.resolveTemporalBucketPresentation=Q;exports.tokenizeTemporalBucketPattern=p;exports.validateTemporalBucketFormatApplicability=y;
|