react-semaphor 0.1.516 → 0.1.518

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +2 -2
  3. package/dist/briefings/index.cjs +1 -1
  4. package/dist/briefings/index.js +3 -3
  5. package/dist/chunks/{calculated-field-identity-DzJBs2J8.js → calculated-field-identity-Dy_WpDdo.js} +1 -1
  6. package/dist/chunks/{card-config-utils-Cxnq2R6z.js → card-config-utils-CAyjC5Tp.js} +2 -2
  7. package/dist/chunks/{dashboard-briefing-launcher-BCEHJ_eD.js → dashboard-briefing-launcher-D5HGRwtb.js} +7 -7
  8. package/dist/chunks/{dashboard-briefing-launcher-CjZ4aE34.cjs → dashboard-briefing-launcher-RpT4b0d5.cjs} +1 -1
  9. package/dist/chunks/{dashboard-controls-DFfit5KH.js → dashboard-controls-C0Aw74JP.js} +9 -9
  10. package/dist/chunks/{dashboard-controls-f9aJ70Zu.cjs → dashboard-controls-DidqEx0U.cjs} +1 -1
  11. package/dist/chunks/{dashboard-json-DVtcA02f.js → dashboard-json-B5LLO49G.js} +5 -5
  12. package/dist/chunks/{dashboard-json-deqQC-UR.cjs → dashboard-json-rY4lTftA.cjs} +1 -1
  13. package/dist/chunks/{edit-dashboard-visual-lJ6rDH3w.js → edit-dashboard-visual-D3TrgFMg.js} +364 -361
  14. package/dist/chunks/{edit-dashboard-visual-DK6lSC_p.cjs → edit-dashboard-visual-NABO8NBr.cjs} +3 -3
  15. package/dist/chunks/{editor-action-buttons-Bnxxa439.js → editor-action-buttons-BfWg6DdZ.js} +4 -4
  16. package/dist/chunks/{editor-action-buttons-CmDaQbPN.cjs → editor-action-buttons-xQ5aj-0q.cjs} +1 -1
  17. package/dist/chunks/{field-aggregations-Dl2A3rbV.js → field-aggregations-BQjogiI1.js} +1 -1
  18. package/dist/chunks/{index-ylOpKRDu.js → index-B0KwXM6P.js} +117 -116
  19. package/dist/chunks/index-CapO5Uw9.cjs +4 -0
  20. package/dist/chunks/{index-UNKSfi7s.cjs → index-Dgv9vzT0.cjs} +230 -230
  21. package/dist/chunks/{index-BVVl2JDK.js → index-DqTelnri.js} +27499 -27198
  22. package/dist/chunks/{matrix-control-sources-KbZe1gj_.js → matrix-control-sources-B1K7x0SL.js} +2 -2
  23. package/dist/chunks/matrix-formatter-Qk8xsR05.cjs +1 -0
  24. package/dist/chunks/{matrix-formatter-CCXNRt3s.js → matrix-formatter-WBgtebUT.js} +8 -8
  25. package/dist/chunks/numeric-presentation-VhMUHfrJ.js +537 -0
  26. package/dist/chunks/numeric-presentation-mY6wJMdB.cjs +1 -0
  27. package/dist/chunks/{pivot-header-presentation-BSZhB1g-.js → pivot-header-presentation-CGtudHo7.js} +4 -4
  28. package/dist/chunks/{pivot-header-presentation-EoUS5ze5.cjs → pivot-header-presentation-DV2aBB6p.cjs} +2 -2
  29. package/dist/chunks/{pivot-result-lifecycle-kRhiJkzg.js → pivot-result-lifecycle-BFO354lk.js} +7 -7
  30. package/dist/chunks/pivot-result-lifecycle-OXAgoIYm.cjs +1 -0
  31. package/dist/chunks/raw-temporal-7bFbXd2a.js +930 -0
  32. package/dist/chunks/raw-temporal-CYdOOyR5.cjs +1 -0
  33. package/dist/chunks/{report-preferences-dialog-CHXPEl7v.js → report-preferences-dialog-BzxqfcF8.js} +3 -3
  34. package/dist/chunks/{report-preferences-dialog-Cto0vDwI.cjs → report-preferences-dialog-DLnhOXXg.cjs} +1 -1
  35. package/dist/chunks/{semantic-format-DwqGYx4V.js → semantic-format-Baqp8kD_.js} +1 -1
  36. package/dist/chunks/semantic-format-Bd7HmLG_.cjs +1 -0
  37. package/dist/chunks/{switch-DNbWXEOP.cjs → switch-C0520nRt.cjs} +24 -24
  38. package/dist/chunks/{switch-DNv-hVmt.js → switch-evlnTA4t.js} +3180 -3092
  39. package/dist/chunks/{temporal-bucket-DlFuhCnT.js → temporal-bucket-PcLFSYWX.js} +6 -6
  40. package/dist/chunks/temporal-input-presentation-2RJrvmYL.js +222 -0
  41. package/dist/chunks/temporal-input-presentation-BIOSVWCL.cjs +1 -0
  42. package/dist/dashboard/index.cjs +1 -1
  43. package/dist/dashboard/index.js +1 -1
  44. package/dist/dashboard-authoring/index.js +6 -6
  45. package/dist/data-app-builder/index.cjs +1 -1
  46. package/dist/data-app-builder/index.js +2 -2
  47. package/dist/data-app-sdk/index.cjs +1 -1
  48. package/dist/data-app-sdk/index.js +1 -1
  49. package/dist/format-utils/index.cjs +3 -3
  50. package/dist/format-utils/index.js +77 -73
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.js +10 -10
  53. package/dist/style.css +1 -1
  54. package/dist/surfboard/index.cjs +1 -1
  55. package/dist/surfboard/index.js +2 -2
  56. package/dist/types/components/editor/editor-main/dashboard-variable-node.d.ts +7 -3
  57. package/dist/types/components/editor/editor-main/text-card-rich-editor.d.ts +4 -1
  58. package/dist/types/lib/charts/chart-availability.d.ts +6 -0
  59. package/dist/types/lib/dashboard-inputs/dashboard-input-display.d.ts +11 -0
  60. package/dist/types/lib/dashboard-inputs/dashboard-input-text.d.ts +2 -1
  61. package/dist/types/lib/dashboard-inputs/text-card-rich-content.d.ts +3 -2
  62. package/dist/types/lib/dashboard-inputs/text-variable-options.d.ts +5 -4
  63. package/dist/types/lib/document/document-variables.d.ts +8 -4
  64. package/dist/types/lib/text-variables/temporal-input-text.d.ts +28 -0
  65. package/dist/types/lib/text-variables/text-variable-types.d.ts +17 -1
  66. package/dist/types/lib/types/common-types.d.ts +11 -1
  67. package/dist/types/shared/format-utils/index.d.ts +1 -0
  68. package/dist/types/shared/format-utils/temporal-input-presentation.d.ts +46 -0
  69. package/package.json +1 -1
  70. package/dist/chunks/index-C8w91oj4.js +0 -328
  71. package/dist/chunks/index-Cw2ypaFl.cjs +0 -1
  72. package/dist/chunks/index-DfqMtR9S.cjs +0 -4
  73. package/dist/chunks/matrix-formatter-BJTO8ky9.cjs +0 -1
  74. package/dist/chunks/pivot-result-lifecycle-gl9cBfB-.cjs +0 -1
  75. package/dist/chunks/raw-temporal-BqOfk-xN.js +0 -1137
  76. package/dist/chunks/raw-temporal-eJXecCyJ.cjs +0 -1
  77. package/dist/chunks/semantic-format-mVI32OJH.cjs +0 -1
@@ -1,1137 +0,0 @@
1
- var ne = Object.defineProperty;
2
- var ae = (e, t, r) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var b = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { b9 as p, ba as ie, i as D } from "./validators-CsdOtZI6.js";
5
- import { canonicalizeSupportedLocale as I, canonicalizeSupportedCurrencyCode as F } from "../value-format-preferences/index.js";
6
- import { d as g, t as K } from "./temporal-bucket-DlFuhCnT.js";
7
- import { p as ce } from "./raw-temporal-contract-BQZIJ1fn.js";
8
- import { f as se } from "./index-C8w91oj4.js";
9
- const O = [
10
- "day",
11
- "hour",
12
- "minute",
13
- "second",
14
- "millisecond"
15
- ], k = {
16
- day: 864e5,
17
- hour: 36e5,
18
- minute: 6e4,
19
- second: 1e3,
20
- millisecond: 1
21
- }, ue = {
22
- day: "d",
23
- hour: "hr",
24
- minute: "min",
25
- second: "s",
26
- millisecond: "ms"
27
- }, me = {
28
- day: ["day", "days"],
29
- hour: ["hour", "hours"],
30
- minute: ["minute", "minutes"],
31
- second: ["second", "seconds"],
32
- millisecond: ["millisecond", "milliseconds"]
33
- };
34
- function oe(e) {
35
- return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
36
- }
37
- function V(e, t) {
38
- return oe(e) ? e : t;
39
- }
40
- function P(e, t) {
41
- return O.indexOf(V(e, t));
42
- }
43
- function le(e, t) {
44
- const r = P(e, "day"), n = P(t, "second"), i = Math.min(r, n), a = Math.max(r, n);
45
- return O.slice(i, a + 1);
46
- }
47
- function fe(e, t) {
48
- return e * k[V(t, "second")];
49
- }
50
- function de(e, t) {
51
- const r = le(t.largestUnit, t.smallestUnit), n = r[r.length - 1], i = k[n];
52
- let a = Math.round(e / i) * i;
53
- return r.map((c) => {
54
- const s = k[c], u = Math.floor(a / s);
55
- return a -= u * s, { unit: c, value: u };
56
- });
57
- }
58
- function ge(e, t) {
59
- const r = e.filter((a) => a.value !== 0), n = r.length > 0 ? r : [e[e.length - 1]], i = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : n.length;
60
- return n.slice(0, i).map((a) => `${a.value}${ue[a.unit]}`).join(" ");
61
- }
62
- function ye(e, t) {
63
- const r = e.filter((a) => a.value !== 0), n = r.length > 0 ? r : [e[e.length - 1]], i = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : n.length;
64
- return n.slice(0, i).map((a) => {
65
- const [c, s] = me[a.unit];
66
- return `${a.value} ${a.value === 1 ? c : s}`;
67
- }).join(" ");
68
- }
69
- function he(e) {
70
- const t = e.some(
71
- (u) => u.unit === "day" && u.value !== 0
72
- ), r = e.some((u) => u.unit === "millisecond"), n = e.findIndex((u) => u.value !== 0), i = Math.max(0, e.length - 2), a = t ? 0 : n === -1 ? i : Math.min(n, i), c = n === -1 ? e.slice(i) : e.slice(a);
73
- if (c.length === 0)
74
- return "0";
75
- const s = c.map((u, l) => u.unit === "millisecond" ? String(u.value).padStart(3, "0") : l === 0 ? String(u.value) : String(u.value).padStart(2, "0")).join(":");
76
- return r ? s.replace(/:(\d{3})$/, ".$1") : s;
77
- }
78
- function Se(e, t, r) {
79
- const n = `${r.prefix || ""}${e}${r.suffix || ""}`;
80
- return t ? r.negativeInParentheses ? `(${n})` : `-${n}` : n;
81
- }
82
- function xe(e, t = {}) {
83
- if (e == null)
84
- return "";
85
- const r = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
86
- if (!Number.isFinite(r))
87
- return "";
88
- const n = t.inputUnit || "second", i = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", a = r < 0, c = Math.abs(fe(r, n)), s = de(c, t), u = i === "digital" ? he(s) : i === "long" ? ye(s, t.maxUnits) : ge(s, t.maxUnits);
89
- return Se(u, a, t);
90
- }
91
- function G(e, t) {
92
- return xe(
93
- e !== null && typeof e == "object" ? e.value : e,
94
- {
95
- inputUnit: t.inputUnit,
96
- outputStyle: t.outputStyle,
97
- largestUnit: t.largestUnit,
98
- smallestUnit: t.smallestUnit,
99
- maxUnits: t.maxUnits,
100
- prefix: t.prefix,
101
- suffix: t.suffix,
102
- negativeInParentheses: t.negativeStyle === "parentheses"
103
- }
104
- );
105
- }
106
- let C;
107
- function R(e, t) {
108
- const r = e.format;
109
- return r(t);
110
- }
111
- function we(e, t) {
112
- if (C ?? (C = R(
113
- new Intl.NumberFormat("en-US", { useGrouping: !1, maximumFractionDigits: 6 }),
114
- "9007199254740993.000009"
115
- ) === "9007199254740993.000009"), !C)
116
- throw new RangeError("This runtime cannot format exact decimal strings.");
117
- const r = Number(e);
118
- if (!Number.isFinite(r) || r === 0 && e !== "0")
119
- throw new RangeError("Exact value is outside the Intl formatting range; use raw text.");
120
- return R(t, e);
121
- }
122
- function _(e) {
123
- return typeof e == "number" ? e < 0 : e.value.startsWith("-");
124
- }
125
- function T(e) {
126
- return typeof e == "number" ? Math.abs(e) : _(e) ? { ...e, value: e.value.slice(1) } : e;
127
- }
128
- function Z(e, t) {
129
- return typeof e == "number" ? e * t : {
130
- kind: "exact_number",
131
- type: "decimal",
132
- value: p(e.value, t)
133
- };
134
- }
135
- function N(e, t) {
136
- return t === 0 ? e : typeof e == "number" ? e / 10 ** t : {
137
- kind: "exact_number",
138
- type: "decimal",
139
- value: p(e.value, `1e-${t}`)
140
- };
141
- }
142
- function h(e, t) {
143
- return typeof e == "number" ? t.format(e) : we(e.value, t);
144
- }
145
- function A(e) {
146
- if (!e) return !1;
147
- const t = e.toLowerCase().replace("_", "-");
148
- return t === "en-in" || t.startsWith("en-in-");
149
- }
150
- function L(e, t) {
151
- const r = T(e), n = (i) => typeof r == "number" ? r >= i : ie(r.value, String(i)) >= 0;
152
- return n(1e12) ? { power: 12, suffix: "T" } : n(1e9) ? { power: 9, suffix: "B" } : A(t) && n(1e7) ? { power: 7, suffix: "Cr" } : n(1e6) ? { power: 6, suffix: "M" } : A(t) && n(1e5) ? { power: 5, suffix: "L" } : n(1e3) ? { power: 3, suffix: "K" } : { power: 0, suffix: "" };
153
- }
154
- function z(e, t) {
155
- try {
156
- const r = x(t);
157
- return L(e, r);
158
- } catch {
159
- return L(e, "en-US");
160
- }
161
- }
162
- function ve(e) {
163
- try {
164
- return new Intl.NumberFormat(e), !0;
165
- } catch {
166
- return !1;
167
- }
168
- }
169
- function x(e) {
170
- return e && ve(e) ? e : "en-US";
171
- }
172
- function E(e, t) {
173
- if (e == null || Number.isNaN(e))
174
- return "";
175
- const r = x(t == null ? void 0 : t.locale);
176
- let n = e;
177
- if (t != null && t.multiplyBy && (n = Z(n, t.multiplyBy)), t != null && t.useSuffix) {
178
- const { power: a, suffix: c } = z(n, r);
179
- n = N(n, a);
180
- const s = h(n, new Intl.NumberFormat(r, {
181
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
182
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
183
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
184
- }));
185
- return `${(t == null ? void 0 : t.prefix) ?? ""}${s}${c}${(t == null ? void 0 : t.suffix) ?? ""}`;
186
- }
187
- const i = h(n, new Intl.NumberFormat(r, {
188
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
189
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
190
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
191
- }));
192
- if (t != null && t.negativeInParentheses && _(n)) {
193
- const a = i.replace("-", "");
194
- return `(${(t == null ? void 0 : t.prefix) ?? ""}${a}${(t == null ? void 0 : t.suffix) ?? ""})`;
195
- }
196
- return `${(t == null ? void 0 : t.prefix) ?? ""}${i}${(t == null ? void 0 : t.suffix) ?? ""}`;
197
- }
198
- function j(e, t) {
199
- if (e == null || Number.isNaN(e))
200
- return "";
201
- const r = x(t == null ? void 0 : t.locale), n = (t == null ? void 0 : t.currency) || "USD", i = _(e), a = !!(t != null && t.negativeInParentheses && i), c = a ? T(e) : e;
202
- try {
203
- if (t != null && t.useSuffix) {
204
- const { power: u, suffix: l } = z(c, r), m = N(c, u), d = `${h(m, new Intl.NumberFormat(r, {
205
- style: "currency",
206
- currency: n,
207
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
208
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
209
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
210
- }))}${l}`;
211
- return a ? `(${d})` : d;
212
- }
213
- const s = h(c, new Intl.NumberFormat(r, {
214
- style: "currency",
215
- currency: n,
216
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
217
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
218
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
219
- }));
220
- return a ? `(${s})` : s;
221
- } catch {
222
- const s = T(e), u = t != null && t.useSuffix ? z(s, r) : { power: 0, suffix: "" }, l = E(
223
- N(s, u.power),
224
- {
225
- locale: r,
226
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
227
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
228
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
229
- }
230
- ), m = `${n} ${l}${u.suffix}`;
231
- return i ? t != null && t.negativeInParentheses ? `(${m})` : `-${m}` : m;
232
- }
233
- }
234
- function q(e, t) {
235
- if (e == null || Number.isNaN(e))
236
- return "";
237
- const r = x(t == null ? void 0 : t.locale), i = (t == null ? void 0 : t.alreadyPercent) ?? (t == null ? void 0 : t.percentValueMode) === "whole" ? N(e, 2) : e;
238
- return h(i, new Intl.NumberFormat(r, {
239
- style: "percent",
240
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
241
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
242
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
243
- }));
244
- }
245
- function B(e, t) {
246
- if (e == null || Number.isNaN(e))
247
- return "";
248
- const r = x(t == null ? void 0 : t.locale);
249
- return h(e, new Intl.NumberFormat(r, {
250
- notation: "scientific",
251
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
252
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2
253
- }));
254
- }
255
- function H(e, t) {
256
- if (e == null || Number.isNaN(e))
257
- return "";
258
- const r = t.scale === void 0 ? e : Z(e, t.scale), n = t.negativeStyle === "parentheses" && _(r), i = n ? T(r) : r, a = {
259
- style: t.type === "number" ? "decimal" : t.type,
260
- locale: t.locale,
261
- currency: t.currency,
262
- minimumFractionDigits: t.minimumFractionDigits,
263
- maximumFractionDigits: t.maximumFractionDigits,
264
- useGrouping: t.useGrouping,
265
- percentValueMode: t.percentValueMode,
266
- useSuffix: t.compact
267
- };
268
- let c;
269
- switch (t.type) {
270
- case "currency":
271
- c = j(i, a);
272
- break;
273
- case "percent":
274
- c = q(i, a);
275
- break;
276
- case "scientific":
277
- c = B(i, a);
278
- break;
279
- default:
280
- c = E(i, a);
281
- break;
282
- }
283
- const s = `${t.prefix ?? ""}${c}${t.suffix ?? ""}`;
284
- return n ? `(${s})` : s;
285
- }
286
- function Ye(e, t) {
287
- return t.type === "duration" ? e == null ? "" : G(e, t) : H(e, t);
288
- }
289
- function Xe(e, t, r = "en-US") {
290
- if (e == null || typeof e == "number" && isNaN(e))
291
- return "";
292
- if ((t == null ? void 0 : t.style) === "duration")
293
- return G(e, {
294
- ...t.duration,
295
- prefix: t.prefix,
296
- suffix: t.suffix,
297
- negativeStyle: t.negativeStyle
298
- });
299
- const n = x((t == null ? void 0 : t.locale) || r), i = (t == null ? void 0 : t.style) || "decimal", a = i === "decimal" ? "number" : i;
300
- return a === "currency" && new Intl.NumberFormat(n, {
301
- style: "currency",
302
- currency: (t == null ? void 0 : t.currency) || "USD"
303
- }), H(e, {
304
- type: a,
305
- locale: n,
306
- currency: a === "currency" ? (t == null ? void 0 : t.currency) || "USD" : void 0,
307
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
308
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
309
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0,
310
- percentValueMode: a === "percent" ? (t == null ? void 0 : t.percentValueMode) ?? "whole" : void 0,
311
- scale: t == null ? void 0 : t.scale,
312
- compact: t == null ? void 0 : t.compact,
313
- negativeStyle: t == null ? void 0 : t.negativeStyle,
314
- prefix: t == null ? void 0 : t.prefix,
315
- suffix: t == null ? void 0 : t.suffix
316
- });
317
- }
318
- function We(e, t, r) {
319
- const n = {
320
- style: t === "currency" ? "currency" : t === "percent" ? "percent" : "decimal",
321
- locale: r == null ? void 0 : r.locale,
322
- currency: r == null ? void 0 : r.currency,
323
- minimumFractionDigits: r == null ? void 0 : r.decimalPlaces,
324
- maximumFractionDigits: r == null ? void 0 : r.decimalPlaces,
325
- useSuffix: r == null ? void 0 : r.useSuffix,
326
- prefix: r == null ? void 0 : r.prefix,
327
- suffix: r == null ? void 0 : r.suffix,
328
- negativeInParentheses: r == null ? void 0 : r.negativeInParentheses,
329
- multiplyBy: r == null ? void 0 : r.multiplyBy
330
- };
331
- switch (t) {
332
- case "currency":
333
- return j(e, n);
334
- case "percent":
335
- return q(e, n);
336
- case "scientific":
337
- return B(e, n);
338
- default:
339
- return E(e, n);
340
- }
341
- }
342
- const De = [
343
- "type",
344
- "locale",
345
- "minimumFractionDigits",
346
- "maximumFractionDigits",
347
- "useGrouping",
348
- "prefix",
349
- "suffix",
350
- "negativeStyle",
351
- "compact",
352
- "scale",
353
- "currency",
354
- "percentValueMode"
355
- ];
356
- function Te(e) {
357
- if (!g(e))
358
- return {
359
- ok: !1,
360
- issues: [{ path: "$", message: "Numeric format must be an object." }]
361
- };
362
- const t = [], r = new Set(De);
363
- Object.keys(e).filter((a) => !r.has(a)).forEach(
364
- (a) => t.push({ path: a, message: `Unknown property "${a}".` })
365
- ), e.type !== "number" && e.type !== "currency" && e.type !== "percent" && e.type !== "scientific" && t.push({
366
- path: "type",
367
- message: "Expected number, currency, percent, or scientific."
368
- });
369
- const n = e.locale === void 0 ? void 0 : I(e.locale);
370
- e.locale !== void 0 && !n && t.push({ path: "locale", message: "Expected a supported BCP 47 locale." });
371
- const i = e.currency === void 0 ? void 0 : F(e.currency);
372
- e.currency !== void 0 && !i && t.push({
373
- path: "currency",
374
- message: "Expected a supported ISO 4217 currency code."
375
- });
376
- for (const a of ["minimumFractionDigits", "maximumFractionDigits"]) {
377
- const c = e[a];
378
- c !== void 0 && (!Number.isInteger(c) || typeof c != "number" || c < 0 || c > 20) && t.push({
379
- path: a,
380
- message: "Expected an integer from 0 to 20."
381
- });
382
- }
383
- typeof e.minimumFractionDigits == "number" && typeof e.maximumFractionDigits == "number" && e.minimumFractionDigits > e.maximumFractionDigits && t.push({
384
- path: "maximumFractionDigits",
385
- message: "Must be greater than or equal to minimumFractionDigits."
386
- });
387
- for (const a of ["useGrouping", "compact"])
388
- e[a] !== void 0 && typeof e[a] != "boolean" && t.push({ path: a, message: "Expected a boolean." });
389
- for (const a of ["prefix", "suffix"])
390
- e[a] !== void 0 && typeof e[a] != "string" && t.push({ path: a, message: "Expected a string." });
391
- return e.negativeStyle !== void 0 && e.negativeStyle !== "minus" && e.negativeStyle !== "parentheses" && t.push({
392
- path: "negativeStyle",
393
- message: "Expected minus or parentheses."
394
- }), e.percentValueMode !== void 0 && e.percentValueMode !== "fraction" && e.percentValueMode !== "whole" && t.push({
395
- path: "percentValueMode",
396
- message: "Expected fraction or whole."
397
- }), 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 } : {
398
- ok: !0,
399
- value: {
400
- type: e.type,
401
- ...n ? { locale: n } : {},
402
- ...e.minimumFractionDigits !== void 0 ? { minimumFractionDigits: e.minimumFractionDigits } : {},
403
- ...e.maximumFractionDigits !== void 0 ? { maximumFractionDigits: e.maximumFractionDigits } : {},
404
- ...e.useGrouping !== void 0 ? { useGrouping: e.useGrouping } : {},
405
- ...e.prefix !== void 0 ? { prefix: e.prefix } : {},
406
- ...e.suffix !== void 0 ? { suffix: e.suffix } : {},
407
- ...e.negativeStyle !== void 0 ? {
408
- negativeStyle: e.negativeStyle
409
- } : {},
410
- ...e.compact !== void 0 ? { compact: e.compact } : {},
411
- ...e.scale !== void 0 ? { scale: e.scale } : {},
412
- ...i ? { currency: i } : {},
413
- ...e.percentValueMode !== void 0 ? {
414
- percentValueMode: e.percentValueMode
415
- } : {}
416
- }
417
- };
418
- }
419
- function Qe(e) {
420
- const t = Te(e);
421
- if (!t.ok)
422
- return t;
423
- const r = [];
424
- return t.value.locale || r.push({
425
- path: "locale",
426
- message: "Resolved numeric formats require an explicit locale."
427
- }), t.value.minimumFractionDigits === void 0 && r.push({
428
- path: "minimumFractionDigits",
429
- message: "Resolved numeric formats require minimumFractionDigits."
430
- }), t.value.maximumFractionDigits === void 0 && r.push({
431
- path: "maximumFractionDigits",
432
- message: "Resolved numeric formats require maximumFractionDigits."
433
- }), t.value.type === "currency" && !t.value.currency && r.push({
434
- path: "currency",
435
- message: "Resolved currency formats require an explicit currency."
436
- }), r.length > 0 ? { ok: !1, issues: r } : t;
437
- }
438
- function Je(e) {
439
- var n;
440
- const t = /* @__PURE__ */ new Set();
441
- if (e.snapshot.resolvedFormats.forEach((i, a) => {
442
- if (i.format.type !== "temporal_bucket") {
443
- if (i.scope.attachmentIndex !== void 0)
444
- throw new Error(
445
- `resolvedFormats.${a}.scope.attachmentIndex is not valid for a card export`
446
- );
447
- if (i.scope.dashboardId !== e.expectedScope.dashboardId || i.scope.cardId !== e.expectedScope.cardId)
448
- throw new Error(
449
- `resolvedFormats.${a}.scope must match the executing dashboard/card`
450
- );
451
- if (i.target.kind !== "column")
452
- throw new Error(
453
- `resolvedFormats.${a}.target must identify an export column`
454
- );
455
- if (t.has(i.target.columnKey))
456
- throw new Error(
457
- `resolvedFormats.${a} duplicates export column "${i.target.columnKey}"`
458
- );
459
- t.add(i.target.columnKey);
460
- }
461
- }), !e.useFormattedValues)
462
- return;
463
- if (!((n = e.visibleColumns) != null && n.length))
464
- throw new Error(
465
- "visibleColumns must identify every formatted export column"
466
- );
467
- const r = e.visibleColumns.find(
468
- (i) => !t.has(i)
469
- );
470
- if (r)
471
- throw new Error(
472
- `resolvedFormats is missing visible export column "${r}"`
473
- );
474
- }
475
- function Ne(e, t) {
476
- const r = new Intl.NumberFormat(e, {
477
- style: "currency",
478
- currency: t
479
- }).resolvedOptions();
480
- return {
481
- minimumFractionDigits: r.minimumFractionDigits,
482
- maximumFractionDigits: r.maximumFractionDigits
483
- };
484
- }
485
- function _e(e) {
486
- if (e.minimumFractionDigits !== void 0 || e.maximumFractionDigits !== void 0) {
487
- const r = e.minimumFractionDigits ?? 0;
488
- return {
489
- minimumFractionDigits: r,
490
- maximumFractionDigits: e.maximumFractionDigits ?? Math.max(r, 2)
491
- };
492
- }
493
- const t = e.type === "percent" ? 1 : e.type === "scientific" ? 2 : 0;
494
- return {
495
- minimumFractionDigits: t,
496
- maximumFractionDigits: t
497
- };
498
- }
499
- function et(e, t, r) {
500
- const n = I(e.locale) ?? t.locale, i = e.type === "number" || e.type === "currency" ? F(r) : void 0;
501
- if (!(e.type === "currency" || i !== void 0))
502
- return {
503
- ...e,
504
- locale: n,
505
- ..._e(e)
506
- };
507
- const c = i ?? F(e.currency) ?? t.defaultCurrency, s = Ne(
508
- n,
509
- c
510
- ), u = s.minimumFractionDigits ?? 0, l = s.maximumFractionDigits ?? u, m = e.minimumFractionDigits ?? Math.min(
511
- u,
512
- e.maximumFractionDigits ?? u
513
- ), f = e.maximumFractionDigits ?? Math.max(
514
- m,
515
- l
516
- );
517
- return {
518
- ...e,
519
- type: "currency",
520
- locale: n,
521
- currency: c,
522
- minimumFractionDigits: m,
523
- maximumFractionDigits: f
524
- };
525
- }
526
- class S extends Error {
527
- constructor(r, n) {
528
- super(n);
529
- b(this, "code");
530
- this.name = "RawTemporalFormatContractError", this.code = r;
531
- }
532
- }
533
- const Me = [
534
- "SSSSSSSSS",
535
- "SSSSSSSS",
536
- "SSSSSSS",
537
- "SSSSSS",
538
- "SSSSS",
539
- "SSSS",
540
- "SSS",
541
- "SS",
542
- "S"
543
- ], Y = /^(\d{4})-(\d{2})-(\d{2})$/, X = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/, W = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})$/, Fe = [
544
- "yyyy",
545
- "MMMM",
546
- "LLLL",
547
- "zzz",
548
- "XXX",
549
- "MMM",
550
- "LLL",
551
- "yy",
552
- "MM",
553
- "dd",
554
- "HH",
555
- "hh",
556
- "mm",
557
- "ss",
558
- "M",
559
- "d",
560
- "H",
561
- "h",
562
- "m",
563
- "s",
564
- "a"
565
- ], ke = /* @__PURE__ */ new Set([
566
- "HH",
567
- "H",
568
- "hh",
569
- "h",
570
- "mm",
571
- "m",
572
- "ss",
573
- "s",
574
- "a",
575
- ...Me
576
- ]), ze = /* @__PURE__ */ new Set(["zzz", "XXX"]), M = /* @__PURE__ */ new Set(["short", "medium", "long"]);
577
- function y(e, t) {
578
- return Object.keys(e).length === t.length && t.every((n) => n in e);
579
- }
580
- function o(e) {
581
- throw new S(
582
- "invalid_raw_temporal_format",
583
- e
584
- );
585
- }
586
- function Q(e) {
587
- if (!e || e.trim() !== e || e.length > 256)
588
- return o(
589
- "date_fns patterns must be non-empty, trimmed, and at most 256 characters."
590
- );
591
- const t = [], r = (i) => {
592
- const a = t[t.length - 1];
593
- (a == null ? void 0 : a.kind) === "literal" ? a.value += i : t.push({ kind: "literal", value: i });
594
- };
595
- let n = 0;
596
- for (; n < e.length; ) {
597
- if (e[n] === "'") {
598
- if (e[n + 1] === "'") {
599
- r("'"), n += 2;
600
- continue;
601
- }
602
- let c = "", s = !1;
603
- for (n += 1; n < e.length; ) {
604
- if (e[n] === "'") {
605
- if (e[n + 1] === "'") {
606
- c += "'", n += 2;
607
- continue;
608
- }
609
- s = !0, n += 1;
610
- break;
611
- }
612
- c += e[n], n += 1;
613
- }
614
- if (!s)
615
- return o("date_fns pattern has an unclosed quote.");
616
- r(c);
617
- continue;
618
- }
619
- if (e[n] === "S") {
620
- let c = n + 1;
621
- for (; e[c] === "S"; ) c += 1;
622
- const s = e.slice(n, c);
623
- if (s.length > 9)
624
- return o(
625
- "date_fns fractional-second tokens support at most nine digits."
626
- );
627
- t.push({
628
- kind: "token",
629
- value: s
630
- }), n = c;
631
- continue;
632
- }
633
- const i = Fe.find(
634
- (c) => e.startsWith(c, n)
635
- );
636
- if (i) {
637
- t.push({ kind: "token", value: i }), n += i.length;
638
- continue;
639
- }
640
- const a = e[n];
641
- if (/[A-Za-z]/.test(a))
642
- return o(
643
- `Unsupported date_fns pattern token beginning at "${e.slice(n)}".`
644
- );
645
- r(a), n += 1;
646
- }
647
- return t.some((i) => i.kind === "token") ? t : o("date_fns patterns must contain at least one token.");
648
- }
649
- function J(e, t) {
650
- if (e === "semaphor_tokens") {
651
- const r = K(t);
652
- r.ok || o(r.message);
653
- return;
654
- }
655
- Q(t);
656
- }
657
- function $e(e) {
658
- return !g(e) || !y(e, ["dateStyle", "dateTime"]) ? o("Automatic raw temporal styles are incomplete.") : M.has(e.dateStyle) ? !g(e.dateTime) || !y(e.dateTime, ["dateStyle", "timeStyle"]) || !M.has(e.dateTime.dateStyle) || !M.has(e.dateTime.timeStyle) ? o(
659
- "Automatic dateTime styles are incomplete or invalid."
660
- ) : {
661
- dateStyle: e.dateStyle,
662
- dateTime: {
663
- dateStyle: e.dateTime.dateStyle,
664
- timeStyle: e.dateTime.timeStyle
665
- }
666
- } : o("Automatic dateStyle is invalid.");
667
- }
668
- function ee(e) {
669
- const t = ["type", "locale", "calendarTimezone", "presentation"], r = [...t, "sourceTimezone"];
670
- if (!g(e) || !y(e, t) && !y(e, r) || e.type !== "raw_temporal")
671
- return o("Resolved raw temporal format has an invalid shape.");
672
- const n = I(e.locale);
673
- return n ? typeof e.calendarTimezone != "string" || !D(e.calendarTimezone) ? o(
674
- "Raw temporal calendarTimezone must be a valid IANA timezone."
675
- ) : e.sourceTimezone !== void 0 && (typeof e.sourceTimezone != "string" || !D(e.sourceTimezone)) ? o(
676
- "Raw temporal sourceTimezone must be a valid IANA timezone."
677
- ) : g(e.presentation) ? e.presentation.mode === "auto" ? y(e.presentation, ["mode", "styles"]) ? {
678
- type: "raw_temporal",
679
- locale: n,
680
- calendarTimezone: e.calendarTimezone,
681
- ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
682
- presentation: {
683
- mode: "auto",
684
- styles: $e(e.presentation.styles)
685
- }
686
- } : o(
687
- "Automatic raw temporal presentation has unknown fields."
688
- ) : e.presentation.mode !== "pattern" || !y(e.presentation, ["mode", "dialect", "pattern"]) || e.presentation.dialect !== "semaphor_tokens" && e.presentation.dialect !== "date_fns" || typeof e.presentation.pattern != "string" ? o(
689
- "Pattern raw temporal presentation has an invalid shape."
690
- ) : (J(e.presentation.dialect, e.presentation.pattern), {
691
- type: "raw_temporal",
692
- locale: n,
693
- calendarTimezone: e.calendarTimezone,
694
- ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
695
- presentation: {
696
- mode: "pattern",
697
- dialect: e.presentation.dialect,
698
- pattern: e.presentation.pattern
699
- }
700
- }) : o("Raw temporal presentation must be an object.") : o("Raw temporal locale is invalid or unsupported.");
701
- }
702
- function tt(e) {
703
- var s, u, l;
704
- if (e.format) {
705
- if (!g(e.format))
706
- return o(
707
- "Authored raw temporal format has an invalid shape."
708
- );
709
- const m = Object.keys(e.format);
710
- if (!m.includes("type") || !m.includes("presentation") || m.some(
711
- (d) => d !== "type" && d !== "presentation" && d !== "timezone" && d !== "sourceTimezone"
712
- ) || e.format.type !== "raw_temporal" || !g(e.format.presentation))
713
- return o(
714
- "Authored raw temporal format has an invalid shape."
715
- );
716
- const f = e.format.presentation;
717
- if (f.mode === "auto") {
718
- if (!y(f, ["mode"]))
719
- return o(
720
- "Automatic authored raw temporal format has unknown fields."
721
- );
722
- } else {
723
- if (f.mode !== "pattern" || !y(f, ["mode", "dialect", "pattern"]) || f.dialect !== "semaphor_tokens" && f.dialect !== "date_fns" || typeof f.pattern != "string")
724
- return o(
725
- "Authored raw temporal pattern has an invalid shape."
726
- );
727
- J(f.dialect, f.pattern);
728
- }
729
- }
730
- const t = (s = e.format) == null ? void 0 : s.timezone, r = (u = e.format) == null ? void 0 : u.sourceTimezone, n = t && t !== "auto" ? t : e.calendar.tz, i = r && r !== "auto" ? r === "local" ? Intl.DateTimeFormat().resolvedOptions().timeZone : r : void 0;
731
- if (t !== void 0 && t !== "auto" && !D(n) || i !== void 0 && !D(i))
732
- return o("Authored raw temporal timezone is invalid.");
733
- const a = ((l = e.format) == null ? void 0 : l.presentation) ?? { mode: "auto" }, c = {
734
- type: "raw_temporal",
735
- locale: e.preferences.locale,
736
- calendarTimezone: n,
737
- ...i ? { sourceTimezone: i } : {},
738
- presentation: a.mode === "pattern" ? { ...a } : {
739
- mode: "auto",
740
- styles: {
741
- dateStyle: e.preferences.dateStyle,
742
- dateTime: { ...e.preferences.dateTime }
743
- }
744
- }
745
- };
746
- return ee(c);
747
- }
748
- function Ie(e) {
749
- if (Y.test(e)) return "date";
750
- if (W.test(e)) return "instant";
751
- if (X.test(e)) return "wall_datetime";
752
- }
753
- function rt(e) {
754
- const t = /* @__PURE__ */ new Set();
755
- let r = !1;
756
- for (const n of e.values) {
757
- if (n === null) continue;
758
- r = !0;
759
- const i = Ie(n);
760
- i && t.add(i);
761
- }
762
- if (!r) return { status: "empty" };
763
- if (t.size === 0) return { status: "invalid_only" };
764
- if (t.size > 1)
765
- throw new S(
766
- "mixed_sql_temporal_semantics",
767
- `Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`
768
- );
769
- return {
770
- status: "classified",
771
- metadata: {
772
- kind: "raw_temporal",
773
- valueKind: [...t][0]
774
- }
775
- };
776
- }
777
- function nt(e) {
778
- return {
779
- version: 1,
780
- columns: Object.fromEntries(
781
- [...e].map(([t, r]) => [
782
- t,
783
- r.status === "classified" ? r.metadata.valueKind : r.status
784
- ])
785
- )
786
- };
787
- }
788
- function Ee(e) {
789
- if (!g(e) || e.version !== 1 || !g(e.columns) || Object.keys(e).some((n) => n !== "version" && n !== "columns"))
790
- throw new S(
791
- "invalid_raw_temporal_format",
792
- "Raw temporal chunk classification evidence is malformed."
793
- );
794
- const t = {}, r = /* @__PURE__ */ new Set([
795
- "empty",
796
- "invalid_only",
797
- "date",
798
- "wall_datetime",
799
- "instant"
800
- ]);
801
- for (const [n, i] of Object.entries(e.columns)) {
802
- if (!n.trim() || !r.has(i))
803
- throw new S(
804
- "invalid_raw_temporal_format",
805
- "Raw temporal chunk classification evidence contains an invalid column or status."
806
- );
807
- t[n] = i;
808
- }
809
- return { version: 1, columns: t };
810
- }
811
- function at(e) {
812
- if (e.length === 0) return;
813
- const t = e.map(Ee), r = Object.keys(t[0].columns).sort();
814
- for (let n = 1; n < t.length; n += 1) {
815
- const i = Object.keys(t[n].columns).sort();
816
- if (i.length !== r.length || i.some((a, c) => a !== r[c]))
817
- throw new S(
818
- "invalid_raw_temporal_format",
819
- "Raw temporal chunk classification evidence has inconsistent columns."
820
- );
821
- }
822
- for (const n of r)
823
- if (new Set(
824
- t.map((a) => a.columns[n]).filter(
825
- (a) => a !== "empty" && a !== "invalid_only"
826
- )
827
- ).size > 1)
828
- throw new S(
829
- "mixed_sql_temporal_semantics",
830
- `Declared SQL temporal column "${n}" has inconsistent semantics across export chunks. Normalize it to one kind.`
831
- );
832
- }
833
- function be(e) {
834
- return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
835
- }
836
- function Pe(e, t) {
837
- return t === 2 ? be(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
838
- }
839
- function Ce(e) {
840
- return e.year >= 1 && e.year <= 9999 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= Pe(e.year, e.month) && e.hour >= 0 && e.hour <= 23 && e.minute >= 0 && e.minute <= 59 && e.second >= 0 && e.second <= 59;
841
- }
842
- function Re(e) {
843
- return {
844
- year: Number(e[1]),
845
- month: Number(e[2]),
846
- day: Number(e[3]),
847
- hour: Number(e[4] ?? 0),
848
- minute: Number(e[5] ?? 0),
849
- second: Number(e[6] ?? 0),
850
- fraction: e[7] ?? ""
851
- };
852
- }
853
- function Ae(e, t) {
854
- const r = t === "date" ? e.match(Y) : t === "wall_datetime" ? e.match(X) : e.match(W);
855
- if (!r) return { status: "invalid_shape" };
856
- const n = Re(r);
857
- if (!Ce(n)) return { status: "out_of_range" };
858
- if (t === "instant") {
859
- const i = r[8];
860
- if (i && i !== "Z") {
861
- const [c, s] = i.slice(1).split(":").map(Number);
862
- if (c > 23 || s > 59) return { status: "out_of_range" };
863
- }
864
- const a = new Date(e.replace(" ", "T"));
865
- return Number.isNaN(a.getTime()) ? { status: "out_of_range" } : { status: "valid", fields: n, instant: a };
866
- }
867
- return { status: "valid", fields: n };
868
- }
869
- function $(e) {
870
- const t = /* @__PURE__ */ new Date(0);
871
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
872
- }
873
- function te(e, t) {
874
- const r = e.fraction ? `.${e.fraction.padEnd(3, "0").slice(0, 3)}` : "";
875
- return se(
876
- `${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}`,
877
- t
878
- );
879
- }
880
- function Le(e, t) {
881
- const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
882
- let i, a, c, s;
883
- return {
884
- number(u, l = 1) {
885
- let m = r.get(l);
886
- return m || (m = new Intl.NumberFormat(e, {
887
- useGrouping: !1,
888
- minimumIntegerDigits: l,
889
- maximumFractionDigits: 0
890
- }), r.set(l, m)), m.format(u);
891
- },
892
- month(u, l, m) {
893
- var w;
894
- const f = `${l}:${m ? "standalone" : "contextual"}`;
895
- let d = n.get(f);
896
- if (!d) {
897
- const v = {
898
- calendar: "gregory",
899
- timeZone: "UTC",
900
- month: l
901
- };
902
- m || (v.day = "numeric"), d = new Intl.DateTimeFormat(e, v), n.set(f, d);
903
- }
904
- return ((w = d.formatToParts(u).find((v) => v.type === "month")) == null ? void 0 : w.value) ?? "";
905
- },
906
- dayPeriod(u) {
907
- var l;
908
- return i ?? (i = new Intl.DateTimeFormat(e, {
909
- calendar: "gregory",
910
- timeZone: "UTC",
911
- hour: "numeric",
912
- hour12: !0
913
- })), ((l = i.formatToParts(u).find((m) => m.type === "dayPeriod")) == null ? void 0 : l.value) ?? "";
914
- },
915
- instantFields(u) {
916
- a ?? (a = new Intl.DateTimeFormat("en-CA", {
917
- calendar: "gregory",
918
- numberingSystem: "latn",
919
- timeZone: t,
920
- year: "numeric",
921
- month: "2-digit",
922
- day: "2-digit",
923
- hour: "2-digit",
924
- minute: "2-digit",
925
- second: "2-digit",
926
- hourCycle: "h23"
927
- }));
928
- const l = a.formatToParts(u), m = (f) => {
929
- var d;
930
- return Number((d = l.find((w) => w.type === f)) == null ? void 0 : d.value);
931
- };
932
- return {
933
- year: m("year"),
934
- month: m("month"),
935
- day: m("day"),
936
- hour: m("hour"),
937
- minute: m("minute"),
938
- second: m("second"),
939
- fraction: ""
940
- };
941
- },
942
- timezoneName(u) {
943
- var l;
944
- return c ?? (c = new Intl.DateTimeFormat(e, {
945
- calendar: "gregory",
946
- timeZone: t,
947
- timeZoneName: "short"
948
- })), ((l = c.formatToParts(u).find((m) => m.type === "timeZoneName")) == null ? void 0 : l.value) ?? "";
949
- },
950
- timezoneOffset(u) {
951
- var f;
952
- s ?? (s = new Intl.DateTimeFormat("en-US", {
953
- calendar: "gregory",
954
- timeZone: t,
955
- timeZoneName: "longOffset"
956
- }));
957
- const l = (f = s.formatToParts(u).find((d) => d.type === "timeZoneName")) == null ? void 0 : f.value;
958
- if (!l)
959
- return o("Unable to resolve the instant timezone offset.");
960
- const m = l.replace(/^GMT/, "");
961
- return m === "" || /^[+-]00:00$/.test(m) ? "Z" : m;
962
- }
963
- };
964
- }
965
- function Ue(e, t, r, n, i) {
966
- if (/^S{1,9}$/.test(e)) {
967
- const a = t.fraction.padEnd(e.length, "0").slice(0, e.length);
968
- return n.number(Number(a), e.length);
969
- }
970
- switch (e) {
971
- case "YYYY":
972
- case "yyyy":
973
- return n.number(t.year, 4);
974
- case "YY":
975
- case "yy":
976
- return n.number(t.year % 100, 2);
977
- case "MMMM":
978
- return n.month(r, "long", !1);
979
- case "LLLL":
980
- return n.month(r, "long", !0);
981
- case "MMM":
982
- return n.month(r, "short", !1);
983
- case "LLL":
984
- return n.month(r, "short", !0);
985
- case "MM":
986
- return n.number(t.month, 2);
987
- case "M":
988
- return n.number(t.month);
989
- case "DD":
990
- case "dd":
991
- return n.number(t.day, 2);
992
- case "d":
993
- return n.number(t.day);
994
- case "HH":
995
- return n.number(t.hour, 2);
996
- case "H":
997
- return n.number(t.hour);
998
- case "hh":
999
- return n.number(t.hour % 12 || 12, 2);
1000
- case "h":
1001
- return n.number(t.hour % 12 || 12);
1002
- case "mm":
1003
- return n.number(t.minute, 2);
1004
- case "m":
1005
- return n.number(t.minute);
1006
- case "ss":
1007
- return n.number(t.second, 2);
1008
- case "s":
1009
- return n.number(t.second);
1010
- case "a":
1011
- return n.dayPeriod(r);
1012
- case "zzz":
1013
- return i ? n.timezoneName(i) : o(
1014
- "Timezone pattern tokens require an instant value."
1015
- );
1016
- case "XXX":
1017
- return i ? n.timezoneOffset(i) : o(
1018
- "Timezone pattern tokens require an instant value."
1019
- );
1020
- default:
1021
- return o(
1022
- `Unsupported raw temporal pattern token "${e}".`
1023
- );
1024
- }
1025
- }
1026
- function pe(e, t, r, n) {
1027
- const i = $(t);
1028
- return e.map(
1029
- (a) => a.kind === "literal" ? a.value : Ue(a.value, t, i, r, n)
1030
- ).join("");
1031
- }
1032
- function re(e, t, r) {
1033
- const n = t === "date_fns" ? Q(r) : (() => {
1034
- const a = K(r);
1035
- return a.ok ? a.segments : o(a.message);
1036
- })(), i = n.filter((a) => a.kind === "token").map((a) => a.value);
1037
- return e === "date" && i.some((a) => ke.has(a)) ? o("Date patterns cannot contain time tokens.") : e !== "instant" && i.some((a) => ze.has(a)) ? o("Timezone pattern tokens require an instant value.") : n;
1038
- }
1039
- function it(e) {
1040
- re(
1041
- e.valueKind ?? "instant",
1042
- e.dialect,
1043
- e.pattern
1044
- );
1045
- }
1046
- function Ke(e, t, r, n) {
1047
- const i = re(
1048
- e.valueKind,
1049
- r,
1050
- n
1051
- ), a = Le(t.locale, t.calendarTimezone);
1052
- return (c) => {
1053
- const s = e.valueKind === "wall_datetime" && t.sourceTimezone ? te(c.fields, t.sourceTimezone) : void 0, u = e.valueKind === "instant" ? {
1054
- ...a.instantFields(c.instant),
1055
- fraction: c.fields.fraction
1056
- } : s ? {
1057
- ...a.instantFields(s),
1058
- fraction: c.fields.fraction
1059
- } : c.fields;
1060
- return pe(i, u, a, c.instant ?? s);
1061
- };
1062
- }
1063
- function Oe(e, t) {
1064
- const r = t.presentation.mode === "auto" ? t.presentation.styles : o("Automatic raw temporal formatting requires styles.");
1065
- if (e.valueKind === "date") {
1066
- const c = new Intl.DateTimeFormat(t.locale, {
1067
- calendar: "gregory",
1068
- timeZone: "UTC",
1069
- dateStyle: r.dateStyle
1070
- });
1071
- return (s) => c.format($(s.fields));
1072
- }
1073
- const n = e.valueKind === "instant", i = !n && r.dateTime.timeStyle === "long" ? "medium" : r.dateTime.timeStyle, a = new Intl.DateTimeFormat(t.locale, {
1074
- calendar: "gregory",
1075
- timeZone: n || e.valueKind === "wall_datetime" && t.sourceTimezone ? t.calendarTimezone : "UTC",
1076
- dateStyle: r.dateTime.dateStyle,
1077
- timeStyle: i
1078
- });
1079
- return (c) => n ? a.format(c.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? a.format(te(c.fields, t.sourceTimezone)) : a.format($(c.fields));
1080
- }
1081
- function U(e, t, r) {
1082
- return {
1083
- ok: !1,
1084
- text: e,
1085
- diagnostic: {
1086
- code: r,
1087
- message: `Raw temporal ${t.valueKind} value is ${r === "invalid_raw_temporal_value" ? "malformed" : "out of range"}.`
1088
- }
1089
- };
1090
- }
1091
- function Ve(e) {
1092
- const t = ce(e.metadata), r = ee(e.format), n = r.presentation.mode === "auto" ? Oe(t, r) : Ke(
1093
- t,
1094
- r,
1095
- r.presentation.dialect,
1096
- r.presentation.pattern
1097
- );
1098
- return (i) => {
1099
- if (i === null)
1100
- return { ok: !0, text: "", status: "empty" };
1101
- const a = Ae(i, t.valueKind);
1102
- return a.status === "invalid_shape" ? U(i, t, "invalid_raw_temporal_value") : a.status === "out_of_range" ? U(i, t, "out_of_range_raw_temporal_value") : { ok: !0, text: n(a), status: "formatted" };
1103
- };
1104
- }
1105
- function ct(e) {
1106
- return Ve({
1107
- metadata: e.metadata,
1108
- format: e.format
1109
- })(e.value);
1110
- }
1111
- export {
1112
- S as R,
1113
- Ye as a,
1114
- E as b,
1115
- j as c,
1116
- q as d,
1117
- B as e,
1118
- Xe as f,
1119
- H as g,
1120
- We as h,
1121
- xe as i,
1122
- G as j,
1123
- Qe as k,
1124
- et as l,
1125
- ee as m,
1126
- tt as n,
1127
- rt as o,
1128
- Te as p,
1129
- nt as q,
1130
- Ne as r,
1131
- Ee as s,
1132
- at as t,
1133
- it as u,
1134
- Je as v,
1135
- Ve as w,
1136
- ct as x
1137
- };