@danxbot/ui 15.27.1 → 15.29.0

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/pure.js CHANGED
@@ -1,89 +1,89 @@
1
- function P(t) {
1
+ function W(t) {
2
2
  if (!Number.isFinite(t) || t < 0) return "";
3
3
  if (t < 1024) return `${t} B`;
4
- const n = ["KB", "MB", "GB", "TB"];
5
- let e = t / 1024, r = 0;
6
- for (; e >= 1024 && r < n.length - 1; )
7
- e /= 1024, r += 1;
8
- return `${e < 10 ? e.toFixed(1) : Math.round(e)} ${n[r]}`;
4
+ const e = ["KB", "MB", "GB", "TB"];
5
+ let n = t / 1024, r = 0;
6
+ for (; n >= 1024 && r < e.length - 1; )
7
+ n /= 1024, r += 1;
8
+ return `${n < 10 ? n.toFixed(1) : Math.round(n)} ${e[r]}`;
9
9
  }
10
- function H(t) {
11
- return x(t);
10
+ function K(t) {
11
+ return O(t);
12
12
  }
13
- function x(t) {
13
+ function O(t) {
14
14
  if (t == null || !Number.isFinite(t)) return "—";
15
- const n = t < 0 ? "-" : "", e = Math.abs(t), r = [
15
+ const e = t < 0 ? "-" : "", n = Math.abs(t), r = [
16
16
  [1e12, "T"],
17
17
  [1e9, "B"],
18
18
  [1e6, "M"],
19
19
  [1e3, "k"]
20
20
  ];
21
21
  for (const [o, i] of r)
22
- if (e >= o) return `${n}${Number((e / o).toFixed(1))}${i}`;
23
- return `${n}${Math.round(e)}`;
22
+ if (n >= o) return `${e}${Number((n / o).toFixed(1))}${i}`;
23
+ return `${e}${Math.round(n)}`;
24
24
  }
25
- function c(t, n = 2) {
26
- return String(t).padStart(n, "0");
25
+ function c(t, e = 2) {
26
+ return String(t).padStart(e, "0");
27
27
  }
28
28
  class y extends Error {
29
- constructor(n, e, r) {
29
+ constructor(e, n, r) {
30
30
  super(
31
- r === "gap" ? `${g(n)} does not exist in ${e} — the clock skipped it.` : `${g(n)} happens twice in ${e}.`
32
- ), this.wall = n, this.zone = e, this.kind = r, this.name = "AmbiguousTimeError";
31
+ r === "gap" ? `${T(e)} does not exist in ${n} — the clock skipped it.` : `${T(e)} happens twice in ${n}.`
32
+ ), this.wall = e, this.zone = n, this.kind = r, this.name = "AmbiguousTimeError";
33
33
  }
34
34
  wall;
35
35
  zone;
36
36
  kind;
37
37
  }
38
- function g(t) {
38
+ function T(t) {
39
39
  return `${c(t.year, 4)}-${c(t.month)}-${c(t.day)}T${c(t.hour)}:${c(t.minute)}:${c(t.second)}.${c(t.millisecond, 3)}`;
40
40
  }
41
- function E(t) {
41
+ function A(t) {
42
42
  return `${c(t.year, 4)}-${c(t.month)}-${c(t.day)}`;
43
43
  }
44
- function l(t, n) {
45
- const e = /* @__PURE__ */ new Date(0);
46
- return e.setUTCFullYear(t, n, 0), e.getUTCDate();
44
+ function l(t, e) {
45
+ const n = /* @__PURE__ */ new Date(0);
46
+ return n.setUTCFullYear(t, e, 0), n.getUTCDate();
47
47
  }
48
- function U(t) {
49
- const n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t);
50
- if (!n) throw new Error(`not an ISO date: ${JSON.stringify(t)} — expected YYYY-MM-DD`);
51
- const e = Number(n[1]), r = Number(n[2]), o = Number(n[3]);
48
+ function C(t) {
49
+ const e = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t);
50
+ if (!e) throw new Error(`not an ISO date: ${JSON.stringify(t)} — expected YYYY-MM-DD`);
51
+ const n = Number(e[1]), r = Number(e[2]), o = Number(e[3]);
52
52
  if (r < 1 || r > 12) throw new Error(`month out of range in ${t}`);
53
- if (o < 1 || o > l(e, r))
54
- throw new Error(`${t} is not a real date — ${e}-${r} has ${l(e, r)} days`);
55
- return { year: e, month: r, day: o };
53
+ if (o < 1 || o > l(n, r))
54
+ throw new Error(`${t} is not a real date — ${n}-${r} has ${l(n, r)} days`);
55
+ return { year: n, month: r, day: o };
56
56
  }
57
57
  const $ = "—";
58
- function Z(t) {
58
+ function j(t) {
59
59
  if (t == null || t === "") return $;
60
- let n;
60
+ let e;
61
61
  try {
62
- n = U(t);
62
+ e = C(t);
63
63
  } catch {
64
64
  return t;
65
65
  }
66
- return `${c(n.month)}/${c(n.day)}/${n.year}`;
66
+ return `${c(e.month)}/${c(e.day)}/${e.year}`;
67
67
  }
68
- const w = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/, O = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
69
- function W(t) {
70
- const n = t.trim();
71
- if (n === "") return null;
72
- let e, r, o;
73
- const i = O.exec(n);
68
+ const I = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/, U = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
69
+ function J(t) {
70
+ const e = t.trim();
71
+ if (e === "") return null;
72
+ let n, r, o;
73
+ const i = U.exec(e);
74
74
  if (i)
75
- e = Number(i[1]), r = Number(i[2]), o = Number(i[3]);
75
+ n = Number(i[1]), r = Number(i[2]), o = Number(i[3]);
76
76
  else {
77
- const u = w.exec(n);
77
+ const u = I.exec(e);
78
78
  if (!u) return null;
79
- r = Number(u[1]), o = Number(u[2]), e = Number(u[3]);
79
+ r = Number(u[1]), o = Number(u[2]), n = Number(u[3]);
80
80
  }
81
- return r < 1 || r > 12 || o < 1 || o > l(e, r) ? null : E({ year: e, month: r, day: o });
81
+ return r < 1 || r > 12 || o < 1 || o > l(n, r) ? null : A({ year: n, month: r, day: o });
82
82
  }
83
- const h = 36e5, D = /* @__PURE__ */ new Map();
84
- function A(t) {
85
- let n = D.get(t);
86
- return n || (n = new Intl.DateTimeFormat("en-US", {
83
+ const h = 36e5, S = /* @__PURE__ */ new Map();
84
+ function w(t) {
85
+ let e = S.get(t);
86
+ return e || (e = new Intl.DateTimeFormat("en-US", {
87
87
  timeZone: t,
88
88
  year: "numeric",
89
89
  month: "2-digit",
@@ -95,12 +95,12 @@ function A(t) {
95
95
  midnight as hour "24" under `hour12: false`, which parses as a valid
96
96
  number and silently lands the reading on the wrong day. */
97
97
  hourCycle: "h23"
98
- }), D.set(t, n)), n;
98
+ }), S.set(t, e)), e;
99
99
  }
100
- function b(t, n) {
101
- const e = A(t).formatToParts(new Date(n));
102
- let r = 0, o = 1, i = 1, u = 0, s = 0, m = 0;
103
- for (const f of e)
100
+ function b(t, e) {
101
+ const n = w(t).formatToParts(new Date(e));
102
+ let r = 0, o = 1, i = 1, u = 0, s = 0, a = 0;
103
+ for (const f of n)
104
104
  switch (f.type) {
105
105
  case "year":
106
106
  r = Number(f.value);
@@ -118,145 +118,168 @@ function b(t, n) {
118
118
  s = Number(f.value);
119
119
  break;
120
120
  case "second":
121
- m = Number(f.value);
121
+ a = Number(f.value);
122
122
  break;
123
123
  }
124
- const a = (n % 1e3 + 1e3) % 1e3;
125
- return { year: r, month: o, day: i, hour: u, minute: s, second: m, millisecond: a };
124
+ const m = (e % 1e3 + 1e3) % 1e3;
125
+ return { year: r, month: o, day: i, hour: u, minute: s, second: a, millisecond: m };
126
126
  }
127
127
  function p(t) {
128
- const n = /* @__PURE__ */ new Date(0);
129
- return n.setUTCFullYear(t.year, t.month - 1, t.day), n.setUTCHours(t.hour, t.minute, t.second, t.millisecond), n.getTime();
128
+ const e = /* @__PURE__ */ new Date(0);
129
+ return e.setUTCFullYear(t.year, t.month - 1, t.day), e.setUTCHours(t.hour, t.minute, t.second, t.millisecond), e.getTime();
130
130
  }
131
- function N(t, n) {
132
- return p(b(t, n)) - n;
131
+ function N(t, e) {
132
+ return p(b(t, e)) - e;
133
133
  }
134
- function I(t, n) {
135
- return t.year === n.year && t.month === n.month && t.day === n.day && t.hour === n.hour && t.minute === n.minute && t.second === n.second && t.millisecond === n.millisecond;
134
+ function _(t, e) {
135
+ return t.year === e.year && t.month === e.month && t.day === e.day && t.hour === e.hour && t.minute === e.minute && t.second === e.second && t.millisecond === e.millisecond;
136
136
  }
137
- function k(t, n) {
138
- const e = p(n), r = N(t, e - 24 * h), o = N(t, e + 24 * h), i = [];
137
+ function x(t, e) {
138
+ const n = p(e), r = N(t, n - 24 * h), o = N(t, n + 24 * h), i = [];
139
139
  for (const u of r === o ? [r] : [r, o]) {
140
- const s = e - u;
141
- I(b(t, s), n) && i.push(s);
140
+ const s = n - u;
141
+ _(b(t, s), e) && i.push(s);
142
142
  }
143
143
  return i.sort((u, s) => u - s), i.filter((u, s) => s === 0 || u !== i[s - 1]);
144
144
  }
145
- function B(t, n, e = "compatible") {
146
- const r = k(t, n);
145
+ function R(t, e, n = "compatible") {
146
+ const r = x(t, e);
147
147
  if (r.length === 1) return r[0];
148
148
  if (r.length > 1) {
149
- if (e === "reject") throw new y(n, t, "overlap");
150
- return e === "later" ? r[r.length - 1] : r[0];
149
+ if (n === "reject") throw new y(e, t, "overlap");
150
+ return n === "later" ? r[r.length - 1] : r[0];
151
151
  }
152
- if (e === "reject") throw new y(n, t, "gap");
153
- const o = p(n), i = N(t, o - 24 * h), u = N(t, o + 24 * h), s = u - i, m = o - i, a = o - u;
154
- return e === "earlier" ? Math.min(m, a) : s > 0 ? Math.max(m, a) : Math.min(m, a);
152
+ if (n === "reject") throw new y(e, t, "gap");
153
+ const o = p(e), i = N(t, o - 24 * h), u = N(t, o + 24 * h), s = u - i, a = o - i, m = o - u;
154
+ return n === "earlier" ? Math.min(a, m) : s > 0 ? Math.max(a, m) : Math.min(a, m);
155
155
  }
156
- function F() {
156
+ function D() {
157
157
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
158
158
  }
159
- function T(t) {
159
+ function F(t) {
160
160
  if (typeof t == "number") return Number.isFinite(t) ? t : null;
161
- const n = t.replace(/(\.\d{3})\d+/, "$1"), e = Date.parse(n);
162
- return Number.isNaN(e) ? null : e;
161
+ const e = t.replace(/(\.\d{3})\d+/, "$1"), n = Date.parse(e);
162
+ return Number.isNaN(n) ? null : n;
163
163
  }
164
- function j(t, n = {}) {
164
+ function Q(t, e = {}) {
165
165
  if (t == null || t === "") return $;
166
- const e = T(t);
167
- if (e === null) return String(t);
168
- const r = n.zone ?? F(), o = b(r, e), i = (o.hour + 11) % 12 + 1, u = o.hour < 12 ? "AM" : "PM";
166
+ const n = F(t);
167
+ if (n === null) return String(t);
168
+ const r = e.zone ?? D(), o = b(r, n), i = (o.hour + 11) % 12 + 1, u = o.hour < 12 ? "AM" : "PM";
169
169
  return `${c(o.month)}/${c(o.day)}/${o.year}, ${i}:${c(o.minute)} ${u}`;
170
170
  }
171
- const C = /^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:,?\s+(\d{1,2}):(\d{2})(?::(\d{2}))?\s*([AaPp][Mm]))?$/, L = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?\s*(Z|[+-]\d{2}:?\d{2})$/;
172
- function J(t, n = {}) {
173
- const e = t.trim();
174
- if (e === "") return null;
175
- if (L.test(e)) {
176
- const d = T(e);
171
+ const k = /^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:,?\s+(\d{1,2}):(\d{2})(?::(\d{2}))?\s*([AaPp][Mm]))?$/, B = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?\s*(Z|[+-]\d{2}:?\d{2})$/;
172
+ function q(t, e = {}) {
173
+ const n = t.trim();
174
+ if (n === "") return null;
175
+ if (B.test(n)) {
176
+ const d = F(n);
177
177
  return d === null ? null : new Date(d).toISOString();
178
178
  }
179
- const r = C.exec(e);
179
+ const r = k.exec(n);
180
180
  if (!r) return null;
181
181
  const o = Number(r[1]), i = Number(r[2]), u = Number(r[3]);
182
182
  if (o < 1 || o > 12 || i < 1 || i > l(u, o)) return null;
183
- let s = 0, m = 0, a = 0;
183
+ let s = 0, a = 0, m = 0;
184
184
  if (r[4] !== void 0) {
185
185
  const d = Number(r[4]);
186
- m = Number(r[5]), a = r[6] !== void 0 ? Number(r[6]) : 0;
186
+ a = Number(r[5]), m = r[6] !== void 0 ? Number(r[6]) : 0;
187
187
  const M = r[7].toUpperCase();
188
- if (d < 1 || d > 12 || m > 59 || a > 59) return null;
188
+ if (d < 1 || d > 12 || a > 59 || m > 59) return null;
189
189
  s = M === "AM" ? d === 12 ? 0 : d : d === 12 ? 12 : d + 12;
190
190
  }
191
- const f = { year: u, month: o, day: i, hour: s, minute: m, second: a, millisecond: 0 }, S = n.zone ?? F();
192
- return new Date(B(S, f)).toISOString();
191
+ const f = { year: u, month: o, day: i, hour: s, minute: a, second: m, millisecond: 0 }, E = e.zone ?? D();
192
+ return new Date(R(E, f)).toISOString();
193
193
  }
194
- const _ = new Intl.NumberFormat("en-US", {
194
+ const L = new Intl.NumberFormat("en-US", {
195
195
  style: "currency",
196
196
  currency: "USD",
197
197
  minimumFractionDigits: 2,
198
198
  maximumFractionDigits: 2
199
199
  });
200
- function G(t) {
201
- return t == null || !Number.isFinite(t) ? $ : _.format(t);
200
+ function v(t) {
201
+ return t == null || !Number.isFinite(t) ? $ : L.format(t);
202
202
  }
203
- function K(t) {
204
- const n = t.trim();
205
- if (n === "") return null;
206
- const e = /^\((.*)\)$/.exec(n), r = e !== null, i = (e ? e[1] : n).replace(/[$,\s]/g, "");
203
+ function G(t) {
204
+ const e = t.trim();
205
+ if (e === "") return null;
206
+ const n = /^\((.*)\)$/.exec(e), r = n !== null, i = (n ? n[1] : e).replace(/[$,\s]/g, "");
207
207
  if (!/^-?\d+(\.\d+)?$/.test(i)) return null;
208
208
  const u = Number(i);
209
209
  return Number.isFinite(u) ? r ? -Math.abs(u) : u : null;
210
210
  }
211
- function V(t, n = {}) {
211
+ function V(t, e = {}) {
212
212
  if (t == null || !Number.isFinite(t)) return $;
213
- const { decimals: e } = n, r = e === void 0 ? { maximumFractionDigits: 6 } : { minimumFractionDigits: e, maximumFractionDigits: e };
213
+ const { decimals: n } = e, r = n === void 0 ? { maximumFractionDigits: 6 } : { minimumFractionDigits: n, maximumFractionDigits: n };
214
214
  return new Intl.NumberFormat("en-US", r).format(t);
215
215
  }
216
- function q(t) {
217
- const n = t.trim();
218
- if (n === "") return null;
219
- const e = n.replace(/,/g, "");
220
- if (!/^-?\d+(\.\d+)?$/.test(e)) return null;
221
- const r = Number(e);
216
+ function X(t) {
217
+ const e = t.trim();
218
+ if (e === "") return null;
219
+ const n = e.replace(/,/g, "");
220
+ if (!/^-?\d+(\.\d+)?$/.test(n)) return null;
221
+ const r = Number(n);
222
222
  return Number.isFinite(r) ? r : null;
223
223
  }
224
- function Q(t, n = {}) {
225
- const { trueLabel: e = "Yes", falseLabel: r = "No", unknownLabel: o = "Unknown" } = n;
226
- return t === !0 ? e : t === !1 ? r : o;
224
+ function z(t, e = {}) {
225
+ const { trueLabel: n = "Yes", falseLabel: r = "No", unknownLabel: o = "Unknown" } = e;
226
+ return t === !0 ? n : t === !1 ? r : o;
227
227
  }
228
- const R = /* @__PURE__ */ new Set(["yes", "y", "true", "t", "1"]), Y = /* @__PURE__ */ new Set(["no", "n", "false", "f", "0"]);
229
- function X(t) {
230
- const n = t.trim().toLowerCase();
231
- return R.has(n) ? !0 : Y.has(n) ? !1 : null;
228
+ const H = /* @__PURE__ */ new Set(["yes", "y", "true", "t", "1"]), Y = /* @__PURE__ */ new Set(["no", "n", "false", "f", "0"]);
229
+ function tt(t) {
230
+ const e = t.trim().toLowerCase();
231
+ return H.has(e) ? !0 : Y.has(e) ? !1 : null;
232
232
  }
233
- function v(t, n) {
234
- if (!Number.isFinite(t) || !Number.isFinite(n) || n <= 0 || t <= 0) return null;
235
- const e = Math.round(Math.min(t, n) / n * 5);
236
- return Math.max(1, Math.min(5, e));
233
+ function et(t, e) {
234
+ if (!Number.isFinite(t) || !Number.isFinite(e) || e <= 0 || t <= 0) return null;
235
+ const n = Math.round(Math.min(t, e) / e * 5);
236
+ return Math.max(1, Math.min(5, n));
237
237
  }
238
- const z = {
238
+ const nt = {
239
239
  1: "Just a guess",
240
240
  2: "Somewhat unsure",
241
241
  3: "Fairly confident",
242
242
  4: "Confident",
243
243
  5: "Highly confident"
244
- };
244
+ }, g = 8, P = [
245
+ "--chart-1",
246
+ "--chart-2",
247
+ "--chart-3",
248
+ "--chart-4",
249
+ "--chart-5",
250
+ "--chart-6",
251
+ "--chart-7",
252
+ "--chart-8"
253
+ ], Z = "--chart-seq";
254
+ function rt(t) {
255
+ const e = P[t];
256
+ if (!Number.isInteger(t) || e === void 0)
257
+ throw new Error(
258
+ `chartSeriesColor: there are ${g} categorical hues (index 0-${g - 1}); got ${t}. Fold the rest into "Other".`
259
+ );
260
+ return `var(${e})`;
261
+ }
262
+ const ot = `var(${Z})`;
245
263
  export {
246
- z as CONFIDENCE_LEVEL_LABELS,
247
- v as confidenceLevel,
248
- Q as formatBoolean,
249
- P as formatBytes,
250
- x as formatCompactNumber,
251
- G as formatCurrency,
252
- Z as formatDate,
253
- j as formatDateTime,
264
+ ot as CHART_SEQUENTIAL_COLOR,
265
+ Z as CHART_SEQUENTIAL_TOKEN,
266
+ g as CHART_SERIES_COUNT,
267
+ P as CHART_SERIES_TOKENS,
268
+ nt as CONFIDENCE_LEVEL_LABELS,
269
+ rt as chartSeriesColor,
270
+ et as confidenceLevel,
271
+ z as formatBoolean,
272
+ W as formatBytes,
273
+ O as formatCompactNumber,
274
+ v as formatCurrency,
275
+ j as formatDate,
276
+ Q as formatDateTime,
254
277
  V as formatNumber,
255
- H as formatTokens,
256
- X as parseBoolean,
257
- K as parseCurrency,
258
- W as parseDate,
259
- J as parseDateTime,
260
- q as parseNumber
278
+ K as formatTokens,
279
+ tt as parseBoolean,
280
+ G as parseCurrency,
281
+ J as parseDate,
282
+ q as parseDateTime,
283
+ X as parseNumber
261
284
  };
262
285
  //# sourceMappingURL=pure.js.map