@epam/statgpt-sdmx-toolkit 0.5.0-rc.2 → 0.5.0-rc.21

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/index.mjs CHANGED
@@ -3,7 +3,7 @@ const z = (t) => {
3
3
  const e = t.split("=");
4
4
  return e.length === 1 ? t : e[1];
5
5
  }
6
- }, C = (t) => {
6
+ }, S = (t) => {
7
7
  if (t == null)
8
8
  return {};
9
9
  const e = z(t), n = {
@@ -12,110 +12,121 @@ const z = (t) => {
12
12
  version: ""
13
13
  };
14
14
  return e && (e.includes(":") && (n.agency = e.split(":")[0], n.id = e.split(":")[1].split("(")[0]), e.includes("(") && e.includes(")") && (n.version = e.split("(")[1]?.split(")")[0])), n;
15
- }, nt = (t) => {
16
- const [e, n] = t.split(")."), { agency: r, id: s, version: a } = C(e + ")");
15
+ }, rt = (t) => {
16
+ const [e, n] = t.split(")."), { agency: r, id: s, version: a } = S(e + ")");
17
17
  return { childId: n, agency: r, id: s, version: a };
18
18
  }, ue = (t, e, n) => {
19
19
  const r = e === "" ? "" : `(${e})`;
20
20
  return `${n}:${t}${r}`;
21
21
  };
22
- var de = /* @__PURE__ */ ((t) => (t.DESCENDANTS = "descendants", t.NONE = "none", t.ALL = "all", t))(de || {}), rt = /* @__PURE__ */ ((t) => (t.EXACT = "exact", t.AVAILABLE = "available", t))(rt || {});
23
- function Nt(t) {
22
+ var de = /* @__PURE__ */ ((t) => (t.DESCENDANTS = "descendants", t.NONE = "none", t.ALL = "all", t))(de || {}), st = /* @__PURE__ */ ((t) => (t.EXACT = "exact", t.AVAILABLE = "available", t))(st || {});
23
+ function _t(t) {
24
24
  return {
25
25
  data: {
26
26
  codelists: t.data.codelists,
27
27
  conceptSchemes: t.data.conceptSchemes,
28
- dataConstraints: t.data.dataConstraints?.map(Rt),
28
+ dataConstraints: t.data.dataConstraints?.map(kt),
29
29
  dataflows: t.data.dataflows,
30
30
  dataStructures: t.data.dataStructures,
31
31
  metadataStructures: t.data.metadataStructures
32
32
  }
33
33
  };
34
34
  }
35
- function Rt(t) {
35
+ function kt(t) {
36
36
  return {
37
37
  ...t,
38
- cubeRegions: t.cubeRegions?.map(kt)
38
+ cubeRegions: t.cubeRegions?.map(It)
39
39
  };
40
40
  }
41
- function kt(t) {
41
+ function It(t) {
42
42
  return {
43
43
  isIncluded: t.include,
44
- memberSelection: t.keyValues.map(_t)
44
+ memberSelection: t.keyValues.map(Yt)
45
45
  };
46
46
  }
47
- function _t(t) {
47
+ function Yt(t) {
48
48
  return {
49
49
  included: t.include,
50
50
  componentId: t.id,
51
- selectionValues: t.values.map(It)
51
+ selectionValues: t.values.map(Ct)
52
52
  };
53
53
  }
54
- function It(t) {
54
+ function Ct(t) {
55
55
  return {
56
56
  memberValue: t.value
57
57
  };
58
58
  }
59
- const Yt = (t = "", e = "", n = "") => `sdmx/3.0/availability/dataflow/${t}/${e}/${n}`;
60
- class Ua {
59
+ const St = (t = "", e = "", n = "") => `sdmx/3.0/availability/dataflow/${t}/${e}/${n}`;
60
+ class Va {
61
61
  constructor(e) {
62
62
  this.client = e;
63
63
  }
64
64
  async getConstraints(e, n, r) {
65
- const { agency: s, id: a, version: o } = C(e), c = {
65
+ const { agency: s, id: a, version: o } = S(e), i = {
66
66
  filters: n || [],
67
- mode: rt.AVAILABLE,
67
+ mode: st.AVAILABLE,
68
68
  references: de.NONE
69
- }, i = Yt(s, a, o), u = !!this.client.config.sdmxProxyUrl, d = u || this.client.config.isDialProxyMode, l = u ? this.client.config.sdmxProxyUrl : this.client.config.constrainsApiUrl || this.client.config.apiUrl;
69
+ }, c = St(s, a, o), u = !!this.client.config.sdmxProxyUrl, d = u || this.client.config.isDialProxyMode, l = u ? this.client.config.sdmxProxyUrl : this.client.config.constrainsApiUrl || this.client.config.apiUrl;
70
70
  if (d) {
71
71
  const m = await this.client.postRequest(
72
- i,
73
- { body: c },
72
+ c,
73
+ { body: i },
74
74
  l,
75
75
  r
76
76
  );
77
- return Nt(m);
77
+ return _t(m);
78
78
  }
79
79
  return await this.client.postRequest(
80
- i,
81
- { body: c },
80
+ c,
81
+ { body: i },
82
82
  l,
83
83
  r
84
84
  );
85
85
  }
86
86
  }
87
- var G = /* @__PURE__ */ ((t) => (t.CSV = "csv", t.JSON = "json", t.XML = "xml", t))(G || {}), Ct = /* @__PURE__ */ ((t) => (t.ID = "id", t.NAME = "name", t.ID_NAME = "both", t))(Ct || {}), St = /* @__PURE__ */ ((t) => (t.FULL_DATASET = "full", t.DATA_IN_TABLE = "query", t))(St || {});
88
- const Lt = (t, e) => {
87
+ var C = /* @__PURE__ */ ((t) => (t.CSV = "csv", t.JSON = "json", t.XML = "xml", t))(C || {}), Lt = /* @__PURE__ */ ((t) => (t.ID = "id", t.NAME = "name", t.ID_NAME = "both", t))(Lt || {}), $t = /* @__PURE__ */ ((t) => (t.FULL_DATASET = "full", t.DATA_IN_TABLE = "query", t))($t || {});
88
+ const Wt = (t, e) => {
89
89
  switch (t) {
90
- case G.CSV:
91
- return _e(
90
+ case C.CSV:
91
+ return ke(
92
92
  "application/vnd.sdmx.data+csv;version=2.0.0",
93
93
  e
94
94
  );
95
- case G.XML:
95
+ case C.XML:
96
96
  return "application/vnd.sdmx.data+xml;version=3.0.0";
97
- case G.JSON:
97
+ case C.JSON:
98
98
  return "application/vnd.sdmx.data+json;version=2.1";
99
99
  default:
100
- return _e(
100
+ return ke(
101
101
  "application/vnd.sdmx.data+csv;version=2.0.0",
102
102
  e
103
103
  );
104
104
  }
105
- }, _e = (t, e) => `${t}; labels=${e}`;
106
- var st = /* @__PURE__ */ ((t) => (t.REFERENCE_PARTIAL = "referencepartial", t.FULL = "full", t))(st || {});
107
- const $t = "all", Wt = "sdmx/3.0/data/dataflow", at = "&", Ie = ":", qt = "=", Ut = "+", Ha = ",", Ht = "*", Ye = (t, e, n) => {
108
- const { filterKey: r, timeFilter: s } = n, { agency: a, id: o, version: c } = C(t), i = [s || "", e].filter((d) => !!d).join(at);
109
- return `${`${Wt}/${a}/${o}/${c}`}/${r || Ht}?${i}`;
110
- }, Ft = (t = "", e = "", n = "", r = de.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${t}/${e}/${n}?references=${r}&detail=${st.REFERENCE_PARTIAL}`;
111
- class Fa {
105
+ }, qt = (t) => {
106
+ switch (t) {
107
+ case C.CSV:
108
+ return "text/csv; charset=utf-8";
109
+ case C.XML:
110
+ return "application/xml; charset=utf-8";
111
+ case C.JSON:
112
+ return "application/json; charset=utf-8";
113
+ default:
114
+ return "text/csv; charset=utf-8";
115
+ }
116
+ }, ke = (t, e) => `${t}; labels=${e}`;
117
+ var at = /* @__PURE__ */ ((t) => (t.REFERENCE_PARTIAL = "referencepartial", t.FULL = "full", t))(at || {});
118
+ const Ut = "all", Ft = "sdmx/3.0/data/dataflow", Ht = "&", Ie = ":", Qt = "=", ot = "+", Ga = ",", Bt = "*", Ye = (t, e, n) => {
119
+ const { filterKey: r, timeFilter: s } = n, { agency: a, id: o, version: i } = S(t), c = [s || "", e].filter((d) => !!d).join(Ht);
120
+ return `${`${Ft}/${a}/${o}/${i}`}/${r || Bt}?${c}`;
121
+ }, Vt = (t = "", e = "", n = "", r = de.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${t}/${e}/${n}?references=${r}&detail=${at.REFERENCE_PARTIAL}`;
122
+ class Xa {
112
123
  constructor(e) {
113
124
  this.client = e;
114
125
  }
115
126
  async getDataSet(e, n, r) {
116
- const { agency: s, id: a, version: o } = C(e);
127
+ const { agency: s, id: a, version: o } = S(e);
117
128
  return await this.client.getRequest(
118
- Ft(s, a, o, n),
129
+ Vt(s, a, o, n),
119
130
  void 0,
120
131
  r
121
132
  );
@@ -124,7 +135,7 @@ class Fa {
124
135
  const s = new URLSearchParams({
125
136
  includeHistory: "false",
126
137
  limit: "1000",
127
- attributes: $t,
138
+ attributes: Ut,
128
139
  dimensionAtObservation: "TIME_PERIOD"
129
140
  // TODO: use time dimensions
130
141
  }).toString(), a = Ye(e, s, n);
@@ -134,10 +145,10 @@ class Fa {
134
145
  r
135
146
  );
136
147
  }
137
- async downloadDataSet(e, n, r, s, a, o, c = !1, i) {
148
+ async downloadDataSet(e, n, r, s, a, o, i = !1, c) {
138
149
  const u = new URLSearchParams({
139
150
  compress: "false",
140
- attributes: c ? "all" : "none",
151
+ attributes: i ? "all" : "none",
141
152
  limit: "1000"
142
153
  }).toString(), d = Ye(e, u, a);
143
154
  return this.client.streamRequest(
@@ -145,53 +156,54 @@ class Fa {
145
156
  {
146
157
  method: "GET",
147
158
  headers: {
148
- Accept: Lt(n, s),
159
+ Accept: Wt(n, s),
149
160
  "Accept-language": r
150
161
  }
151
162
  },
152
163
  o,
153
- i
164
+ c,
165
+ qt(n)
154
166
  );
155
167
  }
156
168
  }
157
- const Qt = (t, e) => t.error || t.message || `${e.status} ${e.statusText}`, Bt = "application/json", Vt = "Content-Type", X = "Api-Key", Gt = "X-CONVERSATION-ID", j = "Ocp-Apim-Subscription-Key", Ce = "X-Source-Artefact-Urn";
169
+ const Gt = (t, e) => t.error || t.message || `${e.status} ${e.statusText}`, Xt = "application/json", jt = "Content-Type", X = "Api-Key", zt = "X-CONVERSATION-ID", j = "Ocp-Apim-Subscription-Key", Ce = "X-Source-Artefact-Urn";
158
170
  class Se extends Error {
159
171
  constructor(e) {
160
172
  super(e.message), this.isHttpError = !0, this.name = "HttpError", this.code = e.code, this.status = e.status, this.details = e.details, this.displayMessage = e.displayMessage;
161
173
  }
162
174
  }
163
- const ot = 6048e5, Xt = 864e5, le = 6e4, fe = 36e5, jt = 1e3, Le = /* @__PURE__ */ Symbol.for("constructDateFrom");
164
- function E(t, e) {
175
+ const it = 6048e5, Kt = 864e5, le = 6e4, fe = 36e5, Jt = 1e3, Le = /* @__PURE__ */ Symbol.for("constructDateFrom");
176
+ function T(t, e) {
165
177
  return typeof t == "function" ? t(e) : t && typeof t == "object" && Le in t ? t[Le](e) : t instanceof Date ? new t.constructor(e) : new Date(e);
166
178
  }
167
- function p(t, e) {
168
- return E(e || t, t);
179
+ function y(t, e) {
180
+ return T(e || t, t);
169
181
  }
170
- function it(t, e, n) {
171
- const r = p(t, n?.in);
172
- return isNaN(e) ? E(n?.in || t, NaN) : (e && r.setDate(r.getDate() + e), r);
182
+ function ct(t, e, n) {
183
+ const r = y(t, n?.in);
184
+ return isNaN(e) ? T(n?.in || t, NaN) : (e && r.setDate(r.getDate() + e), r);
173
185
  }
174
- let zt = {};
175
- function $() {
176
- return zt;
186
+ let Zt = {};
187
+ function W() {
188
+ return Zt;
177
189
  }
178
190
  function I(t, e) {
179
- const n = $(), r = e?.weekStartsOn ?? e?.locale?.options?.weekStartsOn ?? n.weekStartsOn ?? n.locale?.options?.weekStartsOn ?? 0, s = p(t, e?.in), a = s.getDay(), o = (a < r ? 7 : 0) + a - r;
191
+ const n = W(), r = e?.weekStartsOn ?? e?.locale?.options?.weekStartsOn ?? n.weekStartsOn ?? n.locale?.options?.weekStartsOn ?? 0, s = y(t, e?.in), a = s.getDay(), o = (a < r ? 7 : 0) + a - r;
180
192
  return s.setDate(s.getDate() - o), s.setHours(0, 0, 0, 0), s;
181
193
  }
182
- function L(t, e) {
194
+ function $(t, e) {
183
195
  return I(t, { ...e, weekStartsOn: 1 });
184
196
  }
185
- function ct(t, e) {
186
- const n = p(t, e?.in), r = n.getFullYear(), s = E(n, 0);
197
+ function ut(t, e) {
198
+ const n = y(t, e?.in), r = n.getFullYear(), s = T(n, 0);
187
199
  s.setFullYear(r + 1, 0, 4), s.setHours(0, 0, 0, 0);
188
- const a = L(s), o = E(n, 0);
200
+ const a = $(s), o = T(n, 0);
189
201
  o.setFullYear(r, 0, 4), o.setHours(0, 0, 0, 0);
190
- const c = L(o);
191
- return n.getTime() >= a.getTime() ? r + 1 : n.getTime() >= c.getTime() ? r : r - 1;
202
+ const i = $(o);
203
+ return n.getTime() >= a.getTime() ? r + 1 : n.getTime() >= i.getTime() ? r : r - 1;
192
204
  }
193
205
  function K(t) {
194
- const e = p(t), n = new Date(
206
+ const e = y(t), n = new Date(
195
207
  Date.UTC(
196
208
  e.getFullYear(),
197
209
  e.getMonth(),
@@ -204,40 +216,40 @@ function K(t) {
204
216
  );
205
217
  return n.setUTCFullYear(e.getFullYear()), +t - +n;
206
218
  }
207
- function Kt(t, ...e) {
208
- const n = E.bind(
219
+ function en(t, ...e) {
220
+ const n = T.bind(
209
221
  null,
210
222
  e.find((r) => typeof r == "object")
211
223
  );
212
224
  return e.map(n);
213
225
  }
214
226
  function $e(t, e) {
215
- const n = p(t, e?.in);
227
+ const n = y(t, e?.in);
216
228
  return n.setHours(0, 0, 0, 0), n;
217
229
  }
218
- function Jt(t, e, n) {
219
- const [r, s] = Kt(
230
+ function tn(t, e, n) {
231
+ const [r, s] = en(
220
232
  n?.in,
221
233
  t,
222
234
  e
223
- ), a = $e(r), o = $e(s), c = +a - K(a), i = +o - K(o);
224
- return Math.round((c - i) / Xt);
235
+ ), a = $e(r), o = $e(s), i = +a - K(a), c = +o - K(o);
236
+ return Math.round((i - c) / Kt);
225
237
  }
226
- function Zt(t, e) {
227
- const n = ct(t, e), r = E(t, 0);
228
- return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), L(r);
238
+ function nn(t, e) {
239
+ const n = ut(t, e), r = T(t, 0);
240
+ return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), $(r);
229
241
  }
230
- function en(t) {
242
+ function rn(t) {
231
243
  return t instanceof Date || typeof t == "object" && Object.prototype.toString.call(t) === "[object Date]";
232
244
  }
233
245
  function ne(t) {
234
- return !(!en(t) && typeof t != "number" || isNaN(+p(t)));
246
+ return !(!rn(t) && typeof t != "number" || isNaN(+y(t)));
235
247
  }
236
- function tn(t, e) {
237
- const n = p(t, e?.in);
248
+ function sn(t, e) {
249
+ const n = y(t, e?.in);
238
250
  return n.setFullYear(n.getFullYear(), 0, 1), n.setHours(0, 0, 0, 0), n;
239
251
  }
240
- const nn = {
252
+ const an = {
241
253
  lessThanXSeconds: {
242
254
  one: "less than a second",
243
255
  other: "less than {{count}} seconds"
@@ -299,9 +311,9 @@ const nn = {
299
311
  one: "almost 1 year",
300
312
  other: "almost {{count}} years"
301
313
  }
302
- }, rn = (t, e, n) => {
314
+ }, on = (t, e, n) => {
303
315
  let r;
304
- const s = nn[t];
316
+ const s = an[t];
305
317
  return typeof s == "string" ? r = s : e === 1 ? r = s.one : r = s.other.replace("{{count}}", e.toString()), n?.addSuffix ? n.comparison && n.comparison > 0 ? "in " + r : r + " ago" : r;
306
318
  };
307
319
  function ee(t) {
@@ -310,66 +322,66 @@ function ee(t) {
310
322
  return t.formats[n] || t.formats[t.defaultWidth];
311
323
  };
312
324
  }
313
- const sn = {
325
+ const cn = {
314
326
  full: "EEEE, MMMM do, y",
315
327
  long: "MMMM do, y",
316
328
  medium: "MMM d, y",
317
329
  short: "MM/dd/yyyy"
318
- }, an = {
330
+ }, un = {
319
331
  full: "h:mm:ss a zzzz",
320
332
  long: "h:mm:ss a z",
321
333
  medium: "h:mm:ss a",
322
334
  short: "h:mm a"
323
- }, on = {
335
+ }, dn = {
324
336
  full: "{{date}} 'at' {{time}}",
325
337
  long: "{{date}} 'at' {{time}}",
326
338
  medium: "{{date}}, {{time}}",
327
339
  short: "{{date}}, {{time}}"
328
- }, cn = {
340
+ }, ln = {
329
341
  date: ee({
330
- formats: sn,
342
+ formats: cn,
331
343
  defaultWidth: "full"
332
344
  }),
333
345
  time: ee({
334
- formats: an,
346
+ formats: un,
335
347
  defaultWidth: "full"
336
348
  }),
337
349
  dateTime: ee({
338
- formats: on,
350
+ formats: dn,
339
351
  defaultWidth: "full"
340
352
  })
341
- }, un = {
353
+ }, fn = {
342
354
  lastWeek: "'last' eeee 'at' p",
343
355
  yesterday: "'yesterday at' p",
344
356
  today: "'today at' p",
345
357
  tomorrow: "'tomorrow at' p",
346
358
  nextWeek: "eeee 'at' p",
347
359
  other: "P"
348
- }, dn = (t, e, n, r) => un[t];
349
- function U(t) {
360
+ }, mn = (t, e, n, r) => fn[t];
361
+ function F(t) {
350
362
  return (e, n) => {
351
363
  const r = n?.context ? String(n.context) : "standalone";
352
364
  let s;
353
365
  if (r === "formatting" && t.formattingValues) {
354
- const o = t.defaultFormattingWidth || t.defaultWidth, c = n?.width ? String(n.width) : o;
355
- s = t.formattingValues[c] || t.formattingValues[o];
366
+ const o = t.defaultFormattingWidth || t.defaultWidth, i = n?.width ? String(n.width) : o;
367
+ s = t.formattingValues[i] || t.formattingValues[o];
356
368
  } else {
357
- const o = t.defaultWidth, c = n?.width ? String(n.width) : t.defaultWidth;
358
- s = t.values[c] || t.values[o];
369
+ const o = t.defaultWidth, i = n?.width ? String(n.width) : t.defaultWidth;
370
+ s = t.values[i] || t.values[o];
359
371
  }
360
372
  const a = t.argumentCallback ? t.argumentCallback(e) : e;
361
373
  return s[a];
362
374
  };
363
375
  }
364
- const ln = {
376
+ const hn = {
365
377
  narrow: ["B", "A"],
366
378
  abbreviated: ["BC", "AD"],
367
379
  wide: ["Before Christ", "Anno Domini"]
368
- }, fn = {
380
+ }, wn = {
369
381
  narrow: ["1", "2", "3", "4"],
370
382
  abbreviated: ["Q1", "Q2", "Q3", "Q4"],
371
383
  wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
372
- }, mn = {
384
+ }, gn = {
373
385
  narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
374
386
  abbreviated: [
375
387
  "Jan",
@@ -399,7 +411,7 @@ const ln = {
399
411
  "November",
400
412
  "December"
401
413
  ]
402
- }, hn = {
414
+ }, pn = {
403
415
  narrow: ["S", "M", "T", "W", "T", "F", "S"],
404
416
  short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
405
417
  abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
@@ -412,7 +424,7 @@ const ln = {
412
424
  "Friday",
413
425
  "Saturday"
414
426
  ]
415
- }, gn = {
427
+ }, yn = {
416
428
  narrow: {
417
429
  am: "a",
418
430
  pm: "p",
@@ -443,7 +455,7 @@ const ln = {
443
455
  evening: "evening",
444
456
  night: "night"
445
457
  }
446
- }, wn = {
458
+ }, bn = {
447
459
  narrow: {
448
460
  am: "a",
449
461
  pm: "p",
@@ -474,7 +486,7 @@ const ln = {
474
486
  evening: "in the evening",
475
487
  night: "at night"
476
488
  }
477
- }, yn = (t, e) => {
489
+ }, Dn = (t, e) => {
478
490
  const n = Number(t), r = n % 100;
479
491
  if (r > 20 || r < 10)
480
492
  switch (r % 10) {
@@ -486,29 +498,29 @@ const ln = {
486
498
  return n + "rd";
487
499
  }
488
500
  return n + "th";
489
- }, pn = {
490
- ordinalNumber: yn,
491
- era: U({
492
- values: ln,
501
+ }, En = {
502
+ ordinalNumber: Dn,
503
+ era: F({
504
+ values: hn,
493
505
  defaultWidth: "wide"
494
506
  }),
495
- quarter: U({
496
- values: fn,
507
+ quarter: F({
508
+ values: wn,
497
509
  defaultWidth: "wide",
498
510
  argumentCallback: (t) => t - 1
499
511
  }),
500
- month: U({
501
- values: mn,
512
+ month: F({
513
+ values: gn,
502
514
  defaultWidth: "wide"
503
515
  }),
504
- day: U({
505
- values: hn,
516
+ day: F({
517
+ values: pn,
506
518
  defaultWidth: "wide"
507
519
  }),
508
- dayPeriod: U({
509
- values: gn,
520
+ dayPeriod: F({
521
+ values: yn,
510
522
  defaultWidth: "wide",
511
- formattingValues: wn,
523
+ formattingValues: bn,
512
524
  defaultFormattingWidth: "wide"
513
525
  })
514
526
  };
@@ -517,12 +529,12 @@ function H(t) {
517
529
  const r = n.width, s = r && t.matchPatterns[r] || t.matchPatterns[t.defaultMatchWidth], a = e.match(s);
518
530
  if (!a)
519
531
  return null;
520
- const o = a[0], c = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], i = Array.isArray(c) ? Dn(c, (l) => l.test(o)) : (
532
+ const o = a[0], i = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], c = Array.isArray(i) ? xn(i, (l) => l.test(o)) : (
521
533
  // [TODO] -- I challenge you to fix the type
522
- bn(c, (l) => l.test(o))
534
+ Tn(i, (l) => l.test(o))
523
535
  );
524
536
  let u;
525
- u = t.valueCallback ? t.valueCallback(i) : i, u = n.valueCallback ? (
537
+ u = t.valueCallback ? t.valueCallback(c) : c, u = n.valueCallback ? (
526
538
  // [TODO] -- I challenge you to fix the type
527
539
  n.valueCallback(u)
528
540
  ) : u;
@@ -530,17 +542,17 @@ function H(t) {
530
542
  return { value: u, rest: d };
531
543
  };
532
544
  }
533
- function bn(t, e) {
545
+ function Tn(t, e) {
534
546
  for (const n in t)
535
547
  if (Object.prototype.hasOwnProperty.call(t, n) && e(t[n]))
536
548
  return n;
537
549
  }
538
- function Dn(t, e) {
550
+ function xn(t, e) {
539
551
  for (let n = 0; n < t.length; n++)
540
552
  if (e(t[n]))
541
553
  return n;
542
554
  }
543
- function Tn(t) {
555
+ function Pn(t) {
544
556
  return (e, n = {}) => {
545
557
  const r = e.match(t.matchPattern);
546
558
  if (!r) return null;
@@ -548,27 +560,27 @@ function Tn(t) {
548
560
  if (!a) return null;
549
561
  let o = t.valueCallback ? t.valueCallback(a[0]) : a[0];
550
562
  o = n.valueCallback ? n.valueCallback(o) : o;
551
- const c = e.slice(s.length);
552
- return { value: o, rest: c };
563
+ const i = e.slice(s.length);
564
+ return { value: o, rest: i };
553
565
  };
554
566
  }
555
- const En = /^(\d+)(th|st|nd|rd)?/i, xn = /\d+/i, Pn = {
567
+ const vn = /^(\d+)(th|st|nd|rd)?/i, Mn = /\d+/i, On = {
556
568
  narrow: /^(b|a)/i,
557
569
  abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
558
570
  wide: /^(before christ|before common era|anno domini|common era)/i
559
- }, vn = {
571
+ }, An = {
560
572
  any: [/^b/i, /^(a|c)/i]
561
- }, Mn = {
573
+ }, Nn = {
562
574
  narrow: /^[1234]/i,
563
575
  abbreviated: /^q[1234]/i,
564
576
  wide: /^[1234](th|st|nd|rd)? quarter/i
565
- }, On = {
577
+ }, Rn = {
566
578
  any: [/1/i, /2/i, /3/i, /4/i]
567
- }, An = {
579
+ }, _n = {
568
580
  narrow: /^[jfmasond]/i,
569
581
  abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
570
582
  wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
571
- }, Nn = {
583
+ }, kn = {
572
584
  narrow: [
573
585
  /^j/i,
574
586
  /^f/i,
@@ -597,18 +609,18 @@ const En = /^(\d+)(th|st|nd|rd)?/i, xn = /\d+/i, Pn = {
597
609
  /^n/i,
598
610
  /^d/i
599
611
  ]
600
- }, Rn = {
612
+ }, In = {
601
613
  narrow: /^[smtwf]/i,
602
614
  short: /^(su|mo|tu|we|th|fr|sa)/i,
603
615
  abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
604
616
  wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
605
- }, kn = {
617
+ }, Yn = {
606
618
  narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
607
619
  any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
608
- }, _n = {
620
+ }, Cn = {
609
621
  narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
610
622
  any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
611
- }, In = {
623
+ }, Sn = {
612
624
  any: {
613
625
  am: /^a/i,
614
626
  pm: /^p/i,
@@ -619,80 +631,80 @@ const En = /^(\d+)(th|st|nd|rd)?/i, xn = /\d+/i, Pn = {
619
631
  evening: /evening/i,
620
632
  night: /night/i
621
633
  }
622
- }, Yn = {
623
- ordinalNumber: Tn({
624
- matchPattern: En,
625
- parsePattern: xn,
634
+ }, Ln = {
635
+ ordinalNumber: Pn({
636
+ matchPattern: vn,
637
+ parsePattern: Mn,
626
638
  valueCallback: (t) => parseInt(t, 10)
627
639
  }),
628
640
  era: H({
629
- matchPatterns: Pn,
641
+ matchPatterns: On,
630
642
  defaultMatchWidth: "wide",
631
- parsePatterns: vn,
643
+ parsePatterns: An,
632
644
  defaultParseWidth: "any"
633
645
  }),
634
646
  quarter: H({
635
- matchPatterns: Mn,
647
+ matchPatterns: Nn,
636
648
  defaultMatchWidth: "wide",
637
- parsePatterns: On,
649
+ parsePatterns: Rn,
638
650
  defaultParseWidth: "any",
639
651
  valueCallback: (t) => t + 1
640
652
  }),
641
653
  month: H({
642
- matchPatterns: An,
654
+ matchPatterns: _n,
643
655
  defaultMatchWidth: "wide",
644
- parsePatterns: Nn,
656
+ parsePatterns: kn,
645
657
  defaultParseWidth: "any"
646
658
  }),
647
659
  day: H({
648
- matchPatterns: Rn,
660
+ matchPatterns: In,
649
661
  defaultMatchWidth: "wide",
650
- parsePatterns: kn,
662
+ parsePatterns: Yn,
651
663
  defaultParseWidth: "any"
652
664
  }),
653
665
  dayPeriod: H({
654
- matchPatterns: _n,
666
+ matchPatterns: Cn,
655
667
  defaultMatchWidth: "any",
656
- parsePatterns: In,
668
+ parsePatterns: Sn,
657
669
  defaultParseWidth: "any"
658
670
  })
659
- }, ut = {
671
+ }, dt = {
660
672
  code: "en-US",
661
- formatDistance: rn,
662
- formatLong: cn,
663
- formatRelative: dn,
664
- localize: pn,
665
- match: Yn,
673
+ formatDistance: on,
674
+ formatLong: ln,
675
+ formatRelative: mn,
676
+ localize: En,
677
+ match: Ln,
666
678
  options: {
667
679
  weekStartsOn: 0,
668
680
  firstWeekContainsDate: 1
669
681
  }
670
682
  };
671
- function Cn(t, e) {
672
- const n = p(t, e?.in);
673
- return Jt(n, tn(n)) + 1;
683
+ function $n(t, e) {
684
+ const n = y(t, e?.in);
685
+ return tn(n, sn(n)) + 1;
674
686
  }
675
- function dt(t, e) {
676
- const n = p(t, e?.in), r = +L(n) - +Zt(n);
677
- return Math.round(r / ot) + 1;
687
+ function lt(t, e) {
688
+ const n = y(t, e?.in), r = +$(n) - +nn(n);
689
+ return Math.round(r / it) + 1;
678
690
  }
679
691
  function me(t, e) {
680
- const n = p(t, e?.in), r = n.getFullYear(), s = $(), a = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? s.firstWeekContainsDate ?? s.locale?.options?.firstWeekContainsDate ?? 1, o = E(e?.in || t, 0);
692
+ const n = y(t, e?.in), r = n.getFullYear(), s = W(), a = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? s.firstWeekContainsDate ?? s.locale?.options?.firstWeekContainsDate ?? 1, o = T(e?.in || t, 0);
681
693
  o.setFullYear(r + 1, 0, a), o.setHours(0, 0, 0, 0);
682
- const c = I(o, e), i = E(e?.in || t, 0);
683
- i.setFullYear(r, 0, a), i.setHours(0, 0, 0, 0);
684
- const u = I(i, e);
685
- return +n >= +c ? r + 1 : +n >= +u ? r : r - 1;
694
+ const i = I(o, e), c = T(e?.in || t, 0);
695
+ c.setFullYear(r, 0, a), c.setHours(0, 0, 0, 0);
696
+ const u = I(c, e);
697
+ return +n >= +i ? r + 1 : +n >= +u ? r : r - 1;
686
698
  }
687
- function Sn(t, e) {
688
- const n = $(), r = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? n.firstWeekContainsDate ?? n.locale?.options?.firstWeekContainsDate ?? 1, s = me(t, e), a = E(e?.in || t, 0);
699
+ function Wn(t, e) {
700
+ const n = W(), r = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? n.firstWeekContainsDate ?? n.locale?.options?.firstWeekContainsDate ?? 1, s = me(t, e), a = T(e?.in || t, 0);
689
701
  return a.setFullYear(s, 0, r), a.setHours(0, 0, 0, 0), I(a, e);
690
702
  }
691
- function lt(t, e) {
692
- const n = p(t, e?.in), r = +I(n, e) - +Sn(n, e);
693
- return Math.round(r / ot) + 1;
703
+ function ft(t, e) {
704
+ const n = y(t, e?.in), r = +I(n, e) - +Wn(n, e);
705
+ return Math.round(r / it) + 1;
694
706
  }
695
- function g(t, e) {
707
+ function w(t, e) {
696
708
  const n = t < 0 ? "-" : "", r = Math.abs(t).toString().padStart(e, "0");
697
709
  return n + r;
698
710
  }
@@ -700,16 +712,16 @@ const R = {
700
712
  // Year
701
713
  y(t, e) {
702
714
  const n = t.getFullYear(), r = n > 0 ? n : 1 - n;
703
- return g(e === "yy" ? r % 100 : r, e.length);
715
+ return w(e === "yy" ? r % 100 : r, e.length);
704
716
  },
705
717
  // Month
706
718
  M(t, e) {
707
719
  const n = t.getMonth();
708
- return e === "M" ? String(n + 1) : g(n + 1, 2);
720
+ return e === "M" ? String(n + 1) : w(n + 1, 2);
709
721
  },
710
722
  // Day of the month
711
723
  d(t, e) {
712
- return g(t.getDate(), e.length);
724
+ return w(t.getDate(), e.length);
713
725
  },
714
726
  // AM or PM
715
727
  a(t, e) {
@@ -728,28 +740,28 @@ const R = {
728
740
  },
729
741
  // Hour [1-12]
730
742
  h(t, e) {
731
- return g(t.getHours() % 12 || 12, e.length);
743
+ return w(t.getHours() % 12 || 12, e.length);
732
744
  },
733
745
  // Hour [0-23]
734
746
  H(t, e) {
735
- return g(t.getHours(), e.length);
747
+ return w(t.getHours(), e.length);
736
748
  },
737
749
  // Minute
738
750
  m(t, e) {
739
- return g(t.getMinutes(), e.length);
751
+ return w(t.getMinutes(), e.length);
740
752
  },
741
753
  // Second
742
754
  s(t, e) {
743
- return g(t.getSeconds(), e.length);
755
+ return w(t.getSeconds(), e.length);
744
756
  },
745
757
  // Fraction of second
746
758
  S(t, e) {
747
759
  const n = e.length, r = t.getMilliseconds(), s = Math.trunc(
748
760
  r * Math.pow(10, n - 3)
749
761
  );
750
- return g(s, e.length);
762
+ return w(s, e.length);
751
763
  }
752
- }, S = {
764
+ }, L = {
753
765
  midnight: "midnight",
754
766
  noon: "noon",
755
767
  morning: "morning",
@@ -786,14 +798,14 @@ const R = {
786
798
  const s = me(t, r), a = s > 0 ? s : 1 - s;
787
799
  if (e === "YY") {
788
800
  const o = a % 100;
789
- return g(o, 2);
801
+ return w(o, 2);
790
802
  }
791
- return e === "Yo" ? n.ordinalNumber(a, { unit: "year" }) : g(a, e.length);
803
+ return e === "Yo" ? n.ordinalNumber(a, { unit: "year" }) : w(a, e.length);
792
804
  },
793
805
  // ISO week-numbering year
794
806
  R: function(t, e) {
795
- const n = ct(t);
796
- return g(n, e.length);
807
+ const n = ut(t);
808
+ return w(n, e.length);
797
809
  },
798
810
  // Extended year. This is a single number designating the year of this calendar system.
799
811
  // The main difference between `y` and `u` localizers are B.C. years:
@@ -806,7 +818,7 @@ const R = {
806
818
  // while `uu` pads single digit years to 2 characters and returns other years unchanged.
807
819
  u: function(t, e) {
808
820
  const n = t.getFullYear();
809
- return g(n, e.length);
821
+ return w(n, e.length);
810
822
  },
811
823
  // Quarter
812
824
  Q: function(t, e, n) {
@@ -817,7 +829,7 @@ const R = {
817
829
  return String(r);
818
830
  // 01, 02, 03, 04
819
831
  case "QQ":
820
- return g(r, 2);
832
+ return w(r, 2);
821
833
  // 1st, 2nd, 3rd, 4th
822
834
  case "Qo":
823
835
  return n.ordinalNumber(r, { unit: "quarter" });
@@ -849,7 +861,7 @@ const R = {
849
861
  return String(r);
850
862
  // 01, 02, 03, 04
851
863
  case "qq":
852
- return g(r, 2);
864
+ return w(r, 2);
853
865
  // 1st, 2nd, 3rd, 4th
854
866
  case "qo":
855
867
  return n.ordinalNumber(r, { unit: "quarter" });
@@ -907,7 +919,7 @@ const R = {
907
919
  return String(r + 1);
908
920
  // 01, 02, ..., 12
909
921
  case "LL":
910
- return g(r + 1, 2);
922
+ return w(r + 1, 2);
911
923
  // 1st, 2nd, ..., 12th
912
924
  case "Lo":
913
925
  return n.ordinalNumber(r + 1, { unit: "month" });
@@ -929,13 +941,13 @@ const R = {
929
941
  },
930
942
  // Local week of year
931
943
  w: function(t, e, n, r) {
932
- const s = lt(t, r);
933
- return e === "wo" ? n.ordinalNumber(s, { unit: "week" }) : g(s, e.length);
944
+ const s = ft(t, r);
945
+ return e === "wo" ? n.ordinalNumber(s, { unit: "week" }) : w(s, e.length);
934
946
  },
935
947
  // ISO week of year
936
948
  I: function(t, e, n) {
937
- const r = dt(t);
938
- return e === "Io" ? n.ordinalNumber(r, { unit: "week" }) : g(r, e.length);
949
+ const r = lt(t);
950
+ return e === "Io" ? n.ordinalNumber(r, { unit: "week" }) : w(r, e.length);
939
951
  },
940
952
  // Day of the month
941
953
  d: function(t, e, n) {
@@ -943,8 +955,8 @@ const R = {
943
955
  },
944
956
  // Day of year
945
957
  D: function(t, e, n) {
946
- const r = Cn(t);
947
- return e === "Do" ? n.ordinalNumber(r, { unit: "dayOfYear" }) : g(r, e.length);
958
+ const r = $n(t);
959
+ return e === "Do" ? n.ordinalNumber(r, { unit: "dayOfYear" }) : w(r, e.length);
948
960
  },
949
961
  // Day of week
950
962
  E: function(t, e, n) {
@@ -986,7 +998,7 @@ const R = {
986
998
  return String(a);
987
999
  // Padded numerical value
988
1000
  case "ee":
989
- return g(a, 2);
1001
+ return w(a, 2);
990
1002
  // 1st, 2nd, ..., 7th
991
1003
  case "eo":
992
1004
  return n.ordinalNumber(a, { unit: "day" });
@@ -1023,7 +1035,7 @@ const R = {
1023
1035
  return String(a);
1024
1036
  // Padded numerical value
1025
1037
  case "cc":
1026
- return g(a, e.length);
1038
+ return w(a, e.length);
1027
1039
  // 1st, 2nd, ..., 7th
1028
1040
  case "co":
1029
1041
  return n.ordinalNumber(a, { unit: "day" });
@@ -1060,7 +1072,7 @@ const R = {
1060
1072
  return String(s);
1061
1073
  // 02
1062
1074
  case "ii":
1063
- return g(s, e.length);
1075
+ return w(s, e.length);
1064
1076
  // 2nd
1065
1077
  case "io":
1066
1078
  return n.ordinalNumber(s, { unit: "day" });
@@ -1120,7 +1132,7 @@ const R = {
1120
1132
  b: function(t, e, n) {
1121
1133
  const r = t.getHours();
1122
1134
  let s;
1123
- switch (r === 12 ? s = S.noon : r === 0 ? s = S.midnight : s = r / 12 >= 1 ? "pm" : "am", e) {
1135
+ switch (r === 12 ? s = L.noon : r === 0 ? s = L.midnight : s = r / 12 >= 1 ? "pm" : "am", e) {
1124
1136
  case "b":
1125
1137
  case "bb":
1126
1138
  return n.dayPeriod(s, {
@@ -1148,7 +1160,7 @@ const R = {
1148
1160
  B: function(t, e, n) {
1149
1161
  const r = t.getHours();
1150
1162
  let s;
1151
- switch (r >= 17 ? s = S.evening : r >= 12 ? s = S.afternoon : r >= 4 ? s = S.morning : s = S.night, e) {
1163
+ switch (r >= 17 ? s = L.evening : r >= 12 ? s = L.afternoon : r >= 4 ? s = L.morning : s = L.night, e) {
1152
1164
  case "B":
1153
1165
  case "BB":
1154
1166
  case "BBB":
@@ -1183,12 +1195,12 @@ const R = {
1183
1195
  // Hour [0-11]
1184
1196
  K: function(t, e, n) {
1185
1197
  const r = t.getHours() % 12;
1186
- return e === "Ko" ? n.ordinalNumber(r, { unit: "hour" }) : g(r, e.length);
1198
+ return e === "Ko" ? n.ordinalNumber(r, { unit: "hour" }) : w(r, e.length);
1187
1199
  },
1188
1200
  // Hour [1-24]
1189
1201
  k: function(t, e, n) {
1190
1202
  let r = t.getHours();
1191
- return r === 0 && (r = 24), e === "ko" ? n.ordinalNumber(r, { unit: "hour" }) : g(r, e.length);
1203
+ return r === 0 && (r = 24), e === "ko" ? n.ordinalNumber(r, { unit: "hour" }) : w(r, e.length);
1192
1204
  },
1193
1205
  // Minute
1194
1206
  m: function(t, e, n) {
@@ -1269,25 +1281,25 @@ const R = {
1269
1281
  // Seconds timestamp
1270
1282
  t: function(t, e, n) {
1271
1283
  const r = Math.trunc(+t / 1e3);
1272
- return g(r, e.length);
1284
+ return w(r, e.length);
1273
1285
  },
1274
1286
  // Milliseconds timestamp
1275
1287
  T: function(t, e, n) {
1276
- return g(+t, e.length);
1288
+ return w(+t, e.length);
1277
1289
  }
1278
1290
  };
1279
1291
  function qe(t, e = "") {
1280
1292
  const n = t > 0 ? "-" : "+", r = Math.abs(t), s = Math.trunc(r / 60), a = r % 60;
1281
- return a === 0 ? n + String(s) : n + String(s) + e + g(a, 2);
1293
+ return a === 0 ? n + String(s) : n + String(s) + e + w(a, 2);
1282
1294
  }
1283
1295
  function Ue(t, e) {
1284
- return t % 60 === 0 ? (t > 0 ? "-" : "+") + g(Math.abs(t) / 60, 2) : Y(t, e);
1296
+ return t % 60 === 0 ? (t > 0 ? "-" : "+") + w(Math.abs(t) / 60, 2) : Y(t, e);
1285
1297
  }
1286
1298
  function Y(t, e = "") {
1287
- const n = t > 0 ? "-" : "+", r = Math.abs(t), s = g(Math.trunc(r / 60), 2), a = g(r % 60, 2);
1299
+ const n = t > 0 ? "-" : "+", r = Math.abs(t), s = w(Math.trunc(r / 60), 2), a = w(r % 60, 2);
1288
1300
  return n + s + e + a;
1289
1301
  }
1290
- const He = (t, e) => {
1302
+ const Fe = (t, e) => {
1291
1303
  switch (t) {
1292
1304
  case "P":
1293
1305
  return e.date({ width: "short" });
@@ -1298,7 +1310,7 @@ const He = (t, e) => {
1298
1310
  default:
1299
1311
  return e.date({ width: "full" });
1300
1312
  }
1301
- }, ft = (t, e) => {
1313
+ }, mt = (t, e) => {
1302
1314
  switch (t) {
1303
1315
  case "p":
1304
1316
  return e.time({ width: "short" });
@@ -1309,10 +1321,10 @@ const He = (t, e) => {
1309
1321
  default:
1310
1322
  return e.time({ width: "full" });
1311
1323
  }
1312
- }, Ln = (t, e) => {
1324
+ }, qn = (t, e) => {
1313
1325
  const n = t.match(/(P+)(p+)?/) || [], r = n[1], s = n[2];
1314
1326
  if (!s)
1315
- return He(t, e);
1327
+ return Fe(t, e);
1316
1328
  let a;
1317
1329
  switch (r) {
1318
1330
  case "P":
@@ -1328,78 +1340,78 @@ const He = (t, e) => {
1328
1340
  a = e.dateTime({ width: "full" });
1329
1341
  break;
1330
1342
  }
1331
- return a.replace("{{date}}", He(r, e)).replace("{{time}}", ft(s, e));
1343
+ return a.replace("{{date}}", Fe(r, e)).replace("{{time}}", mt(s, e));
1332
1344
  }, re = {
1333
- p: ft,
1334
- P: Ln
1335
- }, $n = /^D+$/, Wn = /^Y+$/, qn = ["D", "DD", "YY", "YYYY"];
1336
- function mt(t) {
1337
- return $n.test(t);
1338
- }
1345
+ p: mt,
1346
+ P: qn
1347
+ }, Un = /^D+$/, Fn = /^Y+$/, Hn = ["D", "DD", "YY", "YYYY"];
1339
1348
  function ht(t) {
1340
- return Wn.test(t);
1349
+ return Un.test(t);
1350
+ }
1351
+ function wt(t) {
1352
+ return Fn.test(t);
1341
1353
  }
1342
1354
  function se(t, e, n) {
1343
- const r = Un(t, e, n);
1344
- if (console.warn(r), qn.includes(t)) throw new RangeError(r);
1355
+ const r = Qn(t, e, n);
1356
+ if (console.warn(r), Hn.includes(t)) throw new RangeError(r);
1345
1357
  }
1346
- function Un(t, e, n) {
1358
+ function Qn(t, e, n) {
1347
1359
  const r = t[0] === "Y" ? "years" : "days of the month";
1348
1360
  return `Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
1349
1361
  }
1350
- const Hn = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Fn = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Qn = /^'([^]*?)'?$/, Bn = /''/g, Vn = /[a-zA-Z]/;
1351
- function Gn(t, e, n) {
1352
- const r = $(), s = r.locale ?? ut, a = r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, o = r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, c = p(t, n?.in);
1353
- if (!ne(c))
1362
+ const Bn = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Vn = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Gn = /^'([^]*?)'?$/, Xn = /''/g, jn = /[a-zA-Z]/;
1363
+ function zn(t, e, n) {
1364
+ const r = W(), s = r.locale ?? dt, a = r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, o = r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, i = y(t, n?.in);
1365
+ if (!ne(i))
1354
1366
  throw new RangeError("Invalid time value");
1355
- let i = e.match(Fn).map((d) => {
1367
+ let c = e.match(Vn).map((d) => {
1356
1368
  const l = d[0];
1357
1369
  if (l === "p" || l === "P") {
1358
1370
  const m = re[l];
1359
1371
  return m(d, s.formatLong);
1360
1372
  }
1361
1373
  return d;
1362
- }).join("").match(Hn).map((d) => {
1374
+ }).join("").match(Bn).map((d) => {
1363
1375
  if (d === "''")
1364
1376
  return { isToken: !1, value: "'" };
1365
1377
  const l = d[0];
1366
1378
  if (l === "'")
1367
- return { isToken: !1, value: Xn(d) };
1379
+ return { isToken: !1, value: Kn(d) };
1368
1380
  if (We[l])
1369
1381
  return { isToken: !0, value: d };
1370
- if (l.match(Vn))
1382
+ if (l.match(jn))
1371
1383
  throw new RangeError(
1372
1384
  "Format string contains an unescaped latin alphabet character `" + l + "`"
1373
1385
  );
1374
1386
  return { isToken: !1, value: d };
1375
1387
  });
1376
- s.localize.preprocessor && (i = s.localize.preprocessor(c, i));
1388
+ s.localize.preprocessor && (c = s.localize.preprocessor(i, c));
1377
1389
  const u = {
1378
1390
  firstWeekContainsDate: a,
1379
1391
  weekStartsOn: o,
1380
1392
  locale: s
1381
1393
  };
1382
- return i.map((d) => {
1394
+ return c.map((d) => {
1383
1395
  if (!d.isToken) return d.value;
1384
1396
  const l = d.value;
1385
- (ht(l) || mt(l)) && se(l, e, String(t));
1397
+ (wt(l) || ht(l)) && se(l, e, String(t));
1386
1398
  const m = We[l[0]];
1387
- return m(c, l, s.localize, u);
1399
+ return m(i, l, s.localize, u);
1388
1400
  }).join("");
1389
1401
  }
1390
- function Xn(t) {
1391
- const e = t.match(Qn);
1392
- return e ? e[1].replace(Bn, "'") : t;
1402
+ function Kn(t) {
1403
+ const e = t.match(Gn);
1404
+ return e ? e[1].replace(Xn, "'") : t;
1393
1405
  }
1394
- function jn() {
1395
- return Object.assign({}, $());
1406
+ function Jn() {
1407
+ return Object.assign({}, W());
1396
1408
  }
1397
- function zn(t, e) {
1398
- const n = p(t, e?.in).getDay();
1409
+ function Zn(t, e) {
1410
+ const n = y(t, e?.in).getDay();
1399
1411
  return n === 0 ? 7 : n;
1400
1412
  }
1401
- function Kn(t, e) {
1402
- const n = Jn(e) ? new e(0) : E(e, 0);
1413
+ function er(t, e) {
1414
+ const n = tr(e) ? new e(0) : T(e, 0);
1403
1415
  return n.setFullYear(t.getFullYear(), t.getMonth(), t.getDate()), n.setHours(
1404
1416
  t.getHours(),
1405
1417
  t.getMinutes(),
@@ -1407,17 +1419,17 @@ function Kn(t, e) {
1407
1419
  t.getMilliseconds()
1408
1420
  ), n;
1409
1421
  }
1410
- function Jn(t) {
1422
+ function tr(t) {
1411
1423
  return typeof t == "function" && t.prototype?.constructor === t;
1412
1424
  }
1413
- const Zn = 10;
1425
+ const nr = 10;
1414
1426
  class gt {
1415
1427
  subPriority = 0;
1416
1428
  validate(e, n) {
1417
1429
  return !0;
1418
1430
  }
1419
1431
  }
1420
- class er extends gt {
1432
+ class rr extends gt {
1421
1433
  constructor(e, n, r, s, a) {
1422
1434
  super(), this.value = e, this.validateValue = n, this.setValue = r, this.priority = s, a && (this.subPriority = a);
1423
1435
  }
@@ -1428,21 +1440,21 @@ class er extends gt {
1428
1440
  return this.setValue(e, n, this.value, r);
1429
1441
  }
1430
1442
  }
1431
- class tr extends gt {
1432
- priority = Zn;
1443
+ class sr extends gt {
1444
+ priority = nr;
1433
1445
  subPriority = -1;
1434
1446
  constructor(e, n) {
1435
- super(), this.context = e || ((r) => E(n, r));
1447
+ super(), this.context = e || ((r) => T(n, r));
1436
1448
  }
1437
1449
  set(e, n) {
1438
- return n.timestampIsSet ? e : E(e, Kn(e, this.context));
1450
+ return n.timestampIsSet ? e : T(e, er(e, this.context));
1439
1451
  }
1440
1452
  }
1441
1453
  class h {
1442
1454
  run(e, n, r, s) {
1443
1455
  const a = this.parse(e, n, r, s);
1444
1456
  return a ? {
1445
- setter: new er(
1457
+ setter: new rr(
1446
1458
  a.value,
1447
1459
  this.validate,
1448
1460
  this.set,
@@ -1456,7 +1468,7 @@ class h {
1456
1468
  return !0;
1457
1469
  }
1458
1470
  }
1459
- class nr extends h {
1471
+ class ar extends h {
1460
1472
  priority = 140;
1461
1473
  parse(e, n, r) {
1462
1474
  switch (n) {
@@ -1515,27 +1527,27 @@ const D = {
1515
1527
  // 0 to 999, -0 to -999
1516
1528
  fourDigitsSigned: /^-?\d{1,4}/
1517
1529
  // 0 to 9999, -0 to -9999
1518
- }, O = {
1530
+ }, A = {
1519
1531
  basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/,
1520
1532
  basic: /^([+-])(\d{2})(\d{2})|Z/,
1521
1533
  basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,
1522
1534
  extended: /^([+-])(\d{2}):(\d{2})|Z/,
1523
1535
  extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/
1524
1536
  };
1525
- function T(t, e) {
1537
+ function E(t, e) {
1526
1538
  return t && {
1527
1539
  value: e(t.value),
1528
1540
  rest: t.rest
1529
1541
  };
1530
1542
  }
1531
- function y(t, e) {
1543
+ function p(t, e) {
1532
1544
  const n = e.match(t);
1533
1545
  return n ? {
1534
1546
  value: parseInt(n[0], 10),
1535
1547
  rest: e.slice(n[0].length)
1536
1548
  } : null;
1537
1549
  }
1538
- function A(t, e) {
1550
+ function N(t, e) {
1539
1551
  const n = e.match(t);
1540
1552
  if (!n)
1541
1553
  return null;
@@ -1546,39 +1558,39 @@ function A(t, e) {
1546
1558
  };
1547
1559
  const r = n[1] === "+" ? 1 : -1, s = n[2] ? parseInt(n[2], 10) : 0, a = n[3] ? parseInt(n[3], 10) : 0, o = n[5] ? parseInt(n[5], 10) : 0;
1548
1560
  return {
1549
- value: r * (s * fe + a * le + o * jt),
1561
+ value: r * (s * fe + a * le + o * Jt),
1550
1562
  rest: e.slice(n[0].length)
1551
1563
  };
1552
1564
  }
1553
- function wt(t) {
1554
- return y(D.anyDigitsSigned, t);
1565
+ function pt(t) {
1566
+ return p(D.anyDigitsSigned, t);
1555
1567
  }
1556
1568
  function b(t, e) {
1557
1569
  switch (t) {
1558
1570
  case 1:
1559
- return y(D.singleDigit, e);
1571
+ return p(D.singleDigit, e);
1560
1572
  case 2:
1561
- return y(D.twoDigits, e);
1573
+ return p(D.twoDigits, e);
1562
1574
  case 3:
1563
- return y(D.threeDigits, e);
1575
+ return p(D.threeDigits, e);
1564
1576
  case 4:
1565
- return y(D.fourDigits, e);
1577
+ return p(D.fourDigits, e);
1566
1578
  default:
1567
- return y(new RegExp("^\\d{1," + t + "}"), e);
1579
+ return p(new RegExp("^\\d{1," + t + "}"), e);
1568
1580
  }
1569
1581
  }
1570
1582
  function J(t, e) {
1571
1583
  switch (t) {
1572
1584
  case 1:
1573
- return y(D.singleDigitSigned, e);
1585
+ return p(D.singleDigitSigned, e);
1574
1586
  case 2:
1575
- return y(D.twoDigitsSigned, e);
1587
+ return p(D.twoDigitsSigned, e);
1576
1588
  case 3:
1577
- return y(D.threeDigitsSigned, e);
1589
+ return p(D.threeDigitsSigned, e);
1578
1590
  case 4:
1579
- return y(D.fourDigitsSigned, e);
1591
+ return p(D.fourDigitsSigned, e);
1580
1592
  default:
1581
- return y(new RegExp("^-?\\d{1," + t + "}"), e);
1593
+ return p(new RegExp("^-?\\d{1," + t + "}"), e);
1582
1594
  }
1583
1595
  }
1584
1596
  function he(t) {
@@ -1601,15 +1613,15 @@ function yt(t, e) {
1601
1613
  if (r <= 50)
1602
1614
  s = t || 100;
1603
1615
  else {
1604
- const a = r + 50, o = Math.trunc(a / 100) * 100, c = t >= a % 100;
1605
- s = t + o - (c ? 100 : 0);
1616
+ const a = r + 50, o = Math.trunc(a / 100) * 100, i = t >= a % 100;
1617
+ s = t + o - (i ? 100 : 0);
1606
1618
  }
1607
1619
  return n ? s : 1 - s;
1608
1620
  }
1609
- function pt(t) {
1621
+ function bt(t) {
1610
1622
  return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
1611
1623
  }
1612
- class rr extends h {
1624
+ class or extends h {
1613
1625
  priority = 130;
1614
1626
  incompatibleTokens = ["Y", "R", "u", "w", "I", "i", "e", "c", "t", "T"];
1615
1627
  parse(e, n, r) {
@@ -1619,16 +1631,16 @@ class rr extends h {
1619
1631
  });
1620
1632
  switch (n) {
1621
1633
  case "y":
1622
- return T(b(4, e), s);
1634
+ return E(b(4, e), s);
1623
1635
  case "yo":
1624
- return T(
1636
+ return E(
1625
1637
  r.ordinalNumber(e, {
1626
1638
  unit: "year"
1627
1639
  }),
1628
1640
  s
1629
1641
  );
1630
1642
  default:
1631
- return T(b(n.length, e), s);
1643
+ return E(b(n.length, e), s);
1632
1644
  }
1633
1645
  }
1634
1646
  validate(e, n) {
@@ -1647,7 +1659,7 @@ class rr extends h {
1647
1659
  return e.setFullYear(a, 0, 1), e.setHours(0, 0, 0, 0), e;
1648
1660
  }
1649
1661
  }
1650
- class sr extends h {
1662
+ class ir extends h {
1651
1663
  priority = 130;
1652
1664
  parse(e, n, r) {
1653
1665
  const s = (a) => ({
@@ -1656,16 +1668,16 @@ class sr extends h {
1656
1668
  });
1657
1669
  switch (n) {
1658
1670
  case "Y":
1659
- return T(b(4, e), s);
1671
+ return E(b(4, e), s);
1660
1672
  case "Yo":
1661
- return T(
1673
+ return E(
1662
1674
  r.ordinalNumber(e, {
1663
1675
  unit: "year"
1664
1676
  }),
1665
1677
  s
1666
1678
  );
1667
1679
  default:
1668
- return T(b(n.length, e), s);
1680
+ return E(b(n.length, e), s);
1669
1681
  }
1670
1682
  }
1671
1683
  validate(e, n) {
@@ -1674,12 +1686,12 @@ class sr extends h {
1674
1686
  set(e, n, r, s) {
1675
1687
  const a = me(e, s);
1676
1688
  if (r.isTwoDigitYear) {
1677
- const c = yt(
1689
+ const i = yt(
1678
1690
  r.year,
1679
1691
  a
1680
1692
  );
1681
1693
  return e.setFullYear(
1682
- c,
1694
+ i,
1683
1695
  0,
1684
1696
  s.firstWeekContainsDate
1685
1697
  ), e.setHours(0, 0, 0, 0), I(e, s);
@@ -1703,14 +1715,14 @@ class sr extends h {
1703
1715
  "T"
1704
1716
  ];
1705
1717
  }
1706
- class ar extends h {
1718
+ class cr extends h {
1707
1719
  priority = 130;
1708
1720
  parse(e, n) {
1709
1721
  return J(n === "R" ? 4 : n.length, e);
1710
1722
  }
1711
1723
  set(e, n, r) {
1712
- const s = E(e, 0);
1713
- return s.setFullYear(r, 0, 4), s.setHours(0, 0, 0, 0), L(s);
1724
+ const s = T(e, 0);
1725
+ return s.setFullYear(r, 0, 4), s.setHours(0, 0, 0, 0), $(s);
1714
1726
  }
1715
1727
  incompatibleTokens = [
1716
1728
  "G",
@@ -1730,7 +1742,7 @@ class ar extends h {
1730
1742
  "T"
1731
1743
  ];
1732
1744
  }
1733
- class or extends h {
1745
+ class ur extends h {
1734
1746
  priority = 130;
1735
1747
  parse(e, n) {
1736
1748
  return J(n === "u" ? 4 : n.length, e);
@@ -1740,7 +1752,7 @@ class or extends h {
1740
1752
  }
1741
1753
  incompatibleTokens = ["G", "y", "Y", "R", "w", "I", "i", "e", "c", "t", "T"];
1742
1754
  }
1743
- class ir extends h {
1755
+ class dr extends h {
1744
1756
  priority = 120;
1745
1757
  parse(e, n, r) {
1746
1758
  switch (n) {
@@ -1802,7 +1814,7 @@ class ir extends h {
1802
1814
  "T"
1803
1815
  ];
1804
1816
  }
1805
- class cr extends h {
1817
+ class lr extends h {
1806
1818
  priority = 120;
1807
1819
  parse(e, n, r) {
1808
1820
  switch (n) {
@@ -1864,7 +1876,7 @@ class cr extends h {
1864
1876
  "T"
1865
1877
  ];
1866
1878
  }
1867
- class ur extends h {
1879
+ class fr extends h {
1868
1880
  incompatibleTokens = [
1869
1881
  "Y",
1870
1882
  "R",
@@ -1886,16 +1898,16 @@ class ur extends h {
1886
1898
  switch (n) {
1887
1899
  // 1, 2, ..., 12
1888
1900
  case "M":
1889
- return T(
1890
- y(D.month, e),
1901
+ return E(
1902
+ p(D.month, e),
1891
1903
  s
1892
1904
  );
1893
1905
  // 01, 02, ..., 12
1894
1906
  case "MM":
1895
- return T(b(2, e), s);
1907
+ return E(b(2, e), s);
1896
1908
  // 1st, 2nd, ..., 12th
1897
1909
  case "Mo":
1898
- return T(
1910
+ return E(
1899
1911
  r.ordinalNumber(e, {
1900
1912
  unit: "month"
1901
1913
  }),
@@ -1927,23 +1939,23 @@ class ur extends h {
1927
1939
  return e.setMonth(r, 1), e.setHours(0, 0, 0, 0), e;
1928
1940
  }
1929
1941
  }
1930
- class dr extends h {
1942
+ class mr extends h {
1931
1943
  priority = 110;
1932
1944
  parse(e, n, r) {
1933
1945
  const s = (a) => a - 1;
1934
1946
  switch (n) {
1935
1947
  // 1, 2, ..., 12
1936
1948
  case "L":
1937
- return T(
1938
- y(D.month, e),
1949
+ return E(
1950
+ p(D.month, e),
1939
1951
  s
1940
1952
  );
1941
1953
  // 01, 02, ..., 12
1942
1954
  case "LL":
1943
- return T(b(2, e), s);
1955
+ return E(b(2, e), s);
1944
1956
  // 1st, 2nd, ..., 12th
1945
1957
  case "Lo":
1946
- return T(
1958
+ return E(
1947
1959
  r.ordinalNumber(e, {
1948
1960
  unit: "month"
1949
1961
  }),
@@ -1990,16 +2002,16 @@ class dr extends h {
1990
2002
  "T"
1991
2003
  ];
1992
2004
  }
1993
- function lr(t, e, n) {
1994
- const r = p(t, n?.in), s = lt(r, n) - e;
1995
- return r.setDate(r.getDate() - s * 7), p(r, n?.in);
2005
+ function hr(t, e, n) {
2006
+ const r = y(t, n?.in), s = ft(r, n) - e;
2007
+ return r.setDate(r.getDate() - s * 7), y(r, n?.in);
1996
2008
  }
1997
- class fr extends h {
2009
+ class wr extends h {
1998
2010
  priority = 100;
1999
2011
  parse(e, n, r) {
2000
2012
  switch (n) {
2001
2013
  case "w":
2002
- return y(D.week, e);
2014
+ return p(D.week, e);
2003
2015
  case "wo":
2004
2016
  return r.ordinalNumber(e, { unit: "week" });
2005
2017
  default:
@@ -2010,7 +2022,7 @@ class fr extends h {
2010
2022
  return n >= 1 && n <= 53;
2011
2023
  }
2012
2024
  set(e, n, r, s) {
2013
- return I(lr(e, r, s), s);
2025
+ return I(hr(e, r, s), s);
2014
2026
  }
2015
2027
  incompatibleTokens = [
2016
2028
  "y",
@@ -2028,16 +2040,16 @@ class fr extends h {
2028
2040
  "T"
2029
2041
  ];
2030
2042
  }
2031
- function mr(t, e, n) {
2032
- const r = p(t, n?.in), s = dt(r, n) - e;
2043
+ function gr(t, e, n) {
2044
+ const r = y(t, n?.in), s = lt(r, n) - e;
2033
2045
  return r.setDate(r.getDate() - s * 7), r;
2034
2046
  }
2035
- class hr extends h {
2047
+ class pr extends h {
2036
2048
  priority = 100;
2037
2049
  parse(e, n, r) {
2038
2050
  switch (n) {
2039
2051
  case "I":
2040
- return y(D.week, e);
2052
+ return p(D.week, e);
2041
2053
  case "Io":
2042
2054
  return r.ordinalNumber(e, { unit: "week" });
2043
2055
  default:
@@ -2048,7 +2060,7 @@ class hr extends h {
2048
2060
  return n >= 1 && n <= 53;
2049
2061
  }
2050
2062
  set(e, n, r) {
2051
- return L(mr(e, r));
2063
+ return $(gr(e, r));
2052
2064
  }
2053
2065
  incompatibleTokens = [
2054
2066
  "y",
@@ -2067,7 +2079,7 @@ class hr extends h {
2067
2079
  "T"
2068
2080
  ];
2069
2081
  }
2070
- const gr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], wr = [
2082
+ const yr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], br = [
2071
2083
  31,
2072
2084
  29,
2073
2085
  31,
@@ -2081,13 +2093,13 @@ const gr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], wr = [
2081
2093
  30,
2082
2094
  31
2083
2095
  ];
2084
- class yr extends h {
2096
+ class Dr extends h {
2085
2097
  priority = 90;
2086
2098
  subPriority = 1;
2087
2099
  parse(e, n, r) {
2088
2100
  switch (n) {
2089
2101
  case "d":
2090
- return y(D.date, e);
2102
+ return p(D.date, e);
2091
2103
  case "do":
2092
2104
  return r.ordinalNumber(e, { unit: "date" });
2093
2105
  default:
@@ -2095,8 +2107,8 @@ class yr extends h {
2095
2107
  }
2096
2108
  }
2097
2109
  validate(e, n) {
2098
- const r = e.getFullYear(), s = pt(r), a = e.getMonth();
2099
- return s ? n >= 1 && n <= wr[a] : n >= 1 && n <= gr[a];
2110
+ const r = e.getFullYear(), s = bt(r), a = e.getMonth();
2111
+ return s ? n >= 1 && n <= br[a] : n >= 1 && n <= yr[a];
2100
2112
  }
2101
2113
  set(e, n, r) {
2102
2114
  return e.setDate(r), e.setHours(0, 0, 0, 0), e;
@@ -2116,14 +2128,14 @@ class yr extends h {
2116
2128
  "T"
2117
2129
  ];
2118
2130
  }
2119
- class pr extends h {
2131
+ class Er extends h {
2120
2132
  priority = 90;
2121
2133
  subpriority = 1;
2122
2134
  parse(e, n, r) {
2123
2135
  switch (n) {
2124
2136
  case "D":
2125
2137
  case "DD":
2126
- return y(D.dayOfYear, e);
2138
+ return p(D.dayOfYear, e);
2127
2139
  case "Do":
2128
2140
  return r.ordinalNumber(e, { unit: "date" });
2129
2141
  default:
@@ -2132,7 +2144,7 @@ class pr extends h {
2132
2144
  }
2133
2145
  validate(e, n) {
2134
2146
  const r = e.getFullYear();
2135
- return pt(r) ? n >= 1 && n <= 366 : n >= 1 && n <= 365;
2147
+ return bt(r) ? n >= 1 && n <= 366 : n >= 1 && n <= 365;
2136
2148
  }
2137
2149
  set(e, n, r) {
2138
2150
  return e.setMonth(0, r), e.setHours(0, 0, 0, 0), e;
@@ -2155,11 +2167,11 @@ class pr extends h {
2155
2167
  "T"
2156
2168
  ];
2157
2169
  }
2158
- function ge(t, e, n) {
2159
- const r = $(), s = n?.weekStartsOn ?? n?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, a = p(t, n?.in), o = a.getDay(), i = (e % 7 + 7) % 7, u = 7 - s, d = e < 0 || e > 6 ? e - (o + u) % 7 : (i + u) % 7 - (o + u) % 7;
2160
- return it(a, d, n);
2170
+ function we(t, e, n) {
2171
+ const r = W(), s = n?.weekStartsOn ?? n?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, a = y(t, n?.in), o = a.getDay(), c = (e % 7 + 7) % 7, u = 7 - s, d = e < 0 || e > 6 ? e - (o + u) % 7 : (c + u) % 7 - (o + u) % 7;
2172
+ return ct(a, d, n);
2161
2173
  }
2162
- class br extends h {
2174
+ class Tr extends h {
2163
2175
  priority = 90;
2164
2176
  parse(e, n, r) {
2165
2177
  switch (n) {
@@ -2191,25 +2203,25 @@ class br extends h {
2191
2203
  return n >= 0 && n <= 6;
2192
2204
  }
2193
2205
  set(e, n, r, s) {
2194
- return e = ge(e, r, s), e.setHours(0, 0, 0, 0), e;
2206
+ return e = we(e, r, s), e.setHours(0, 0, 0, 0), e;
2195
2207
  }
2196
2208
  incompatibleTokens = ["D", "i", "e", "c", "t", "T"];
2197
2209
  }
2198
- class Dr extends h {
2210
+ class xr extends h {
2199
2211
  priority = 90;
2200
2212
  parse(e, n, r, s) {
2201
2213
  const a = (o) => {
2202
- const c = Math.floor((o - 1) / 7) * 7;
2203
- return (o + s.weekStartsOn + 6) % 7 + c;
2214
+ const i = Math.floor((o - 1) / 7) * 7;
2215
+ return (o + s.weekStartsOn + 6) % 7 + i;
2204
2216
  };
2205
2217
  switch (n) {
2206
2218
  // 3
2207
2219
  case "e":
2208
2220
  case "ee":
2209
- return T(b(n.length, e), a);
2221
+ return E(b(n.length, e), a);
2210
2222
  // 3rd
2211
2223
  case "eo":
2212
- return T(
2224
+ return E(
2213
2225
  r.ordinalNumber(e, {
2214
2226
  unit: "day"
2215
2227
  }),
@@ -2241,7 +2253,7 @@ class Dr extends h {
2241
2253
  return n >= 0 && n <= 6;
2242
2254
  }
2243
2255
  set(e, n, r, s) {
2244
- return e = ge(e, r, s), e.setHours(0, 0, 0, 0), e;
2256
+ return e = we(e, r, s), e.setHours(0, 0, 0, 0), e;
2245
2257
  }
2246
2258
  incompatibleTokens = [
2247
2259
  "y",
@@ -2261,21 +2273,21 @@ class Dr extends h {
2261
2273
  "T"
2262
2274
  ];
2263
2275
  }
2264
- class Tr extends h {
2276
+ class Pr extends h {
2265
2277
  priority = 90;
2266
2278
  parse(e, n, r, s) {
2267
2279
  const a = (o) => {
2268
- const c = Math.floor((o - 1) / 7) * 7;
2269
- return (o + s.weekStartsOn + 6) % 7 + c;
2280
+ const i = Math.floor((o - 1) / 7) * 7;
2281
+ return (o + s.weekStartsOn + 6) % 7 + i;
2270
2282
  };
2271
2283
  switch (n) {
2272
2284
  // 3
2273
2285
  case "c":
2274
2286
  case "cc":
2275
- return T(b(n.length, e), a);
2287
+ return E(b(n.length, e), a);
2276
2288
  // 3rd
2277
2289
  case "co":
2278
- return T(
2290
+ return E(
2279
2291
  r.ordinalNumber(e, {
2280
2292
  unit: "day"
2281
2293
  }),
@@ -2307,7 +2319,7 @@ class Tr extends h {
2307
2319
  return n >= 0 && n <= 6;
2308
2320
  }
2309
2321
  set(e, n, r, s) {
2310
- return e = ge(e, r, s), e.setHours(0, 0, 0, 0), e;
2322
+ return e = we(e, r, s), e.setHours(0, 0, 0, 0), e;
2311
2323
  }
2312
2324
  incompatibleTokens = [
2313
2325
  "y",
@@ -2327,11 +2339,11 @@ class Tr extends h {
2327
2339
  "T"
2328
2340
  ];
2329
2341
  }
2330
- function Er(t, e, n) {
2331
- const r = p(t, n?.in), s = zn(r, n), a = e - s;
2332
- return it(r, a, n);
2342
+ function vr(t, e, n) {
2343
+ const r = y(t, n?.in), s = Zn(r, n), a = e - s;
2344
+ return ct(r, a, n);
2333
2345
  }
2334
- class xr extends h {
2346
+ class Mr extends h {
2335
2347
  priority = 90;
2336
2348
  parse(e, n, r) {
2337
2349
  const s = (a) => a === 0 ? 7 : a;
@@ -2345,7 +2357,7 @@ class xr extends h {
2345
2357
  return r.ordinalNumber(e, { unit: "day" });
2346
2358
  // Tue
2347
2359
  case "iii":
2348
- return T(
2360
+ return E(
2349
2361
  r.day(e, {
2350
2362
  width: "abbreviated",
2351
2363
  context: "formatting"
@@ -2360,7 +2372,7 @@ class xr extends h {
2360
2372
  );
2361
2373
  // T
2362
2374
  case "iiiii":
2363
- return T(
2375
+ return E(
2364
2376
  r.day(e, {
2365
2377
  width: "narrow",
2366
2378
  context: "formatting"
@@ -2369,7 +2381,7 @@ class xr extends h {
2369
2381
  );
2370
2382
  // Tu
2371
2383
  case "iiiiii":
2372
- return T(
2384
+ return E(
2373
2385
  r.day(e, {
2374
2386
  width: "short",
2375
2387
  context: "formatting"
@@ -2380,7 +2392,7 @@ class xr extends h {
2380
2392
  s
2381
2393
  );
2382
2394
  default:
2383
- return T(
2395
+ return E(
2384
2396
  r.day(e, {
2385
2397
  width: "wide",
2386
2398
  context: "formatting"
@@ -2402,7 +2414,7 @@ class xr extends h {
2402
2414
  return n >= 1 && n <= 7;
2403
2415
  }
2404
2416
  set(e, n, r) {
2405
- return e = Er(e, r), e.setHours(0, 0, 0, 0), e;
2417
+ return e = vr(e, r), e.setHours(0, 0, 0, 0), e;
2406
2418
  }
2407
2419
  incompatibleTokens = [
2408
2420
  "y",
@@ -2422,7 +2434,7 @@ class xr extends h {
2422
2434
  "T"
2423
2435
  ];
2424
2436
  }
2425
- class Pr extends h {
2437
+ class Or extends h {
2426
2438
  priority = 80;
2427
2439
  parse(e, n, r) {
2428
2440
  switch (n) {
@@ -2459,7 +2471,7 @@ class Pr extends h {
2459
2471
  }
2460
2472
  incompatibleTokens = ["b", "B", "H", "k", "t", "T"];
2461
2473
  }
2462
- class vr extends h {
2474
+ class Ar extends h {
2463
2475
  priority = 80;
2464
2476
  parse(e, n, r) {
2465
2477
  switch (n) {
@@ -2496,7 +2508,7 @@ class vr extends h {
2496
2508
  }
2497
2509
  incompatibleTokens = ["a", "B", "H", "k", "t", "T"];
2498
2510
  }
2499
- class Mr extends h {
2511
+ class Nr extends h {
2500
2512
  priority = 80;
2501
2513
  parse(e, n, r) {
2502
2514
  switch (n) {
@@ -2533,12 +2545,12 @@ class Mr extends h {
2533
2545
  }
2534
2546
  incompatibleTokens = ["a", "b", "t", "T"];
2535
2547
  }
2536
- class Or extends h {
2548
+ class Rr extends h {
2537
2549
  priority = 70;
2538
2550
  parse(e, n, r) {
2539
2551
  switch (n) {
2540
2552
  case "h":
2541
- return y(D.hour12h, e);
2553
+ return p(D.hour12h, e);
2542
2554
  case "ho":
2543
2555
  return r.ordinalNumber(e, { unit: "hour" });
2544
2556
  default:
@@ -2554,12 +2566,12 @@ class Or extends h {
2554
2566
  }
2555
2567
  incompatibleTokens = ["H", "K", "k", "t", "T"];
2556
2568
  }
2557
- class Ar extends h {
2569
+ class _r extends h {
2558
2570
  priority = 70;
2559
2571
  parse(e, n, r) {
2560
2572
  switch (n) {
2561
2573
  case "H":
2562
- return y(D.hour23h, e);
2574
+ return p(D.hour23h, e);
2563
2575
  case "Ho":
2564
2576
  return r.ordinalNumber(e, { unit: "hour" });
2565
2577
  default:
@@ -2574,12 +2586,12 @@ class Ar extends h {
2574
2586
  }
2575
2587
  incompatibleTokens = ["a", "b", "h", "K", "k", "t", "T"];
2576
2588
  }
2577
- class Nr extends h {
2589
+ class kr extends h {
2578
2590
  priority = 70;
2579
2591
  parse(e, n, r) {
2580
2592
  switch (n) {
2581
2593
  case "K":
2582
- return y(D.hour11h, e);
2594
+ return p(D.hour11h, e);
2583
2595
  case "Ko":
2584
2596
  return r.ordinalNumber(e, { unit: "hour" });
2585
2597
  default:
@@ -2594,12 +2606,12 @@ class Nr extends h {
2594
2606
  }
2595
2607
  incompatibleTokens = ["h", "H", "k", "t", "T"];
2596
2608
  }
2597
- class Rr extends h {
2609
+ class Ir extends h {
2598
2610
  priority = 70;
2599
2611
  parse(e, n, r) {
2600
2612
  switch (n) {
2601
2613
  case "k":
2602
- return y(D.hour24h, e);
2614
+ return p(D.hour24h, e);
2603
2615
  case "ko":
2604
2616
  return r.ordinalNumber(e, { unit: "hour" });
2605
2617
  default:
@@ -2615,12 +2627,12 @@ class Rr extends h {
2615
2627
  }
2616
2628
  incompatibleTokens = ["a", "b", "h", "H", "K", "t", "T"];
2617
2629
  }
2618
- class kr extends h {
2630
+ class Yr extends h {
2619
2631
  priority = 60;
2620
2632
  parse(e, n, r) {
2621
2633
  switch (n) {
2622
2634
  case "m":
2623
- return y(D.minute, e);
2635
+ return p(D.minute, e);
2624
2636
  case "mo":
2625
2637
  return r.ordinalNumber(e, { unit: "minute" });
2626
2638
  default:
@@ -2635,12 +2647,12 @@ class kr extends h {
2635
2647
  }
2636
2648
  incompatibleTokens = ["t", "T"];
2637
2649
  }
2638
- class _r extends h {
2650
+ class Cr extends h {
2639
2651
  priority = 50;
2640
2652
  parse(e, n, r) {
2641
2653
  switch (n) {
2642
2654
  case "s":
2643
- return y(D.second, e);
2655
+ return p(D.second, e);
2644
2656
  case "so":
2645
2657
  return r.ordinalNumber(e, { unit: "second" });
2646
2658
  default:
@@ -2655,225 +2667,225 @@ class _r extends h {
2655
2667
  }
2656
2668
  incompatibleTokens = ["t", "T"];
2657
2669
  }
2658
- class Ir extends h {
2670
+ class Sr extends h {
2659
2671
  priority = 30;
2660
2672
  parse(e, n) {
2661
2673
  const r = (s) => Math.trunc(s * Math.pow(10, -n.length + 3));
2662
- return T(b(n.length, e), r);
2674
+ return E(b(n.length, e), r);
2663
2675
  }
2664
2676
  set(e, n, r) {
2665
2677
  return e.setMilliseconds(r), e;
2666
2678
  }
2667
2679
  incompatibleTokens = ["t", "T"];
2668
2680
  }
2669
- class Yr extends h {
2681
+ class Lr extends h {
2670
2682
  priority = 10;
2671
2683
  parse(e, n) {
2672
2684
  switch (n) {
2673
2685
  case "X":
2674
- return A(
2675
- O.basicOptionalMinutes,
2686
+ return N(
2687
+ A.basicOptionalMinutes,
2676
2688
  e
2677
2689
  );
2678
2690
  case "XX":
2679
- return A(O.basic, e);
2691
+ return N(A.basic, e);
2680
2692
  case "XXXX":
2681
- return A(
2682
- O.basicOptionalSeconds,
2693
+ return N(
2694
+ A.basicOptionalSeconds,
2683
2695
  e
2684
2696
  );
2685
2697
  case "XXXXX":
2686
- return A(
2687
- O.extendedOptionalSeconds,
2698
+ return N(
2699
+ A.extendedOptionalSeconds,
2688
2700
  e
2689
2701
  );
2690
2702
  default:
2691
- return A(O.extended, e);
2703
+ return N(A.extended, e);
2692
2704
  }
2693
2705
  }
2694
2706
  set(e, n, r) {
2695
- return n.timestampIsSet ? e : E(
2707
+ return n.timestampIsSet ? e : T(
2696
2708
  e,
2697
2709
  e.getTime() - K(e) - r
2698
2710
  );
2699
2711
  }
2700
2712
  incompatibleTokens = ["t", "T", "x"];
2701
2713
  }
2702
- class Cr extends h {
2714
+ class $r extends h {
2703
2715
  priority = 10;
2704
2716
  parse(e, n) {
2705
2717
  switch (n) {
2706
2718
  case "x":
2707
- return A(
2708
- O.basicOptionalMinutes,
2719
+ return N(
2720
+ A.basicOptionalMinutes,
2709
2721
  e
2710
2722
  );
2711
2723
  case "xx":
2712
- return A(O.basic, e);
2724
+ return N(A.basic, e);
2713
2725
  case "xxxx":
2714
- return A(
2715
- O.basicOptionalSeconds,
2726
+ return N(
2727
+ A.basicOptionalSeconds,
2716
2728
  e
2717
2729
  );
2718
2730
  case "xxxxx":
2719
- return A(
2720
- O.extendedOptionalSeconds,
2731
+ return N(
2732
+ A.extendedOptionalSeconds,
2721
2733
  e
2722
2734
  );
2723
2735
  default:
2724
- return A(O.extended, e);
2736
+ return N(A.extended, e);
2725
2737
  }
2726
2738
  }
2727
2739
  set(e, n, r) {
2728
- return n.timestampIsSet ? e : E(
2740
+ return n.timestampIsSet ? e : T(
2729
2741
  e,
2730
2742
  e.getTime() - K(e) - r
2731
2743
  );
2732
2744
  }
2733
2745
  incompatibleTokens = ["t", "T", "X"];
2734
2746
  }
2735
- class Sr extends h {
2747
+ class Wr extends h {
2736
2748
  priority = 40;
2737
2749
  parse(e) {
2738
- return wt(e);
2750
+ return pt(e);
2739
2751
  }
2740
2752
  set(e, n, r) {
2741
- return [E(e, r * 1e3), { timestampIsSet: !0 }];
2753
+ return [T(e, r * 1e3), { timestampIsSet: !0 }];
2742
2754
  }
2743
2755
  incompatibleTokens = "*";
2744
2756
  }
2745
- class Lr extends h {
2757
+ class qr extends h {
2746
2758
  priority = 20;
2747
2759
  parse(e) {
2748
- return wt(e);
2760
+ return pt(e);
2749
2761
  }
2750
2762
  set(e, n, r) {
2751
- return [E(e, r), { timestampIsSet: !0 }];
2763
+ return [T(e, r), { timestampIsSet: !0 }];
2752
2764
  }
2753
2765
  incompatibleTokens = "*";
2754
2766
  }
2755
- const $r = {
2756
- G: new nr(),
2757
- y: new rr(),
2758
- Y: new sr(),
2759
- R: new ar(),
2760
- u: new or(),
2761
- Q: new ir(),
2762
- q: new cr(),
2763
- M: new ur(),
2764
- L: new dr(),
2765
- w: new fr(),
2766
- I: new hr(),
2767
- d: new yr(),
2768
- D: new pr(),
2769
- E: new br(),
2770
- e: new Dr(),
2771
- c: new Tr(),
2772
- i: new xr(),
2773
- a: new Pr(),
2774
- b: new vr(),
2775
- B: new Mr(),
2776
- h: new Or(),
2777
- H: new Ar(),
2778
- K: new Nr(),
2779
- k: new Rr(),
2780
- m: new kr(),
2781
- s: new _r(),
2782
- S: new Ir(),
2783
- X: new Yr(),
2784
- x: new Cr(),
2785
- t: new Sr(),
2786
- T: new Lr()
2787
- }, Wr = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, qr = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Ur = /^'([^]*?)'?$/, Hr = /''/g, Fr = /\S/, Qr = /[a-zA-Z]/;
2788
- function Br(t, e, n, r) {
2789
- const s = () => E(n, NaN), a = jn(), o = a.locale ?? ut, c = a.firstWeekContainsDate ?? a.locale?.options?.firstWeekContainsDate ?? 1, i = a.weekStartsOn ?? a.locale?.options?.weekStartsOn ?? 0;
2767
+ const Ur = {
2768
+ G: new ar(),
2769
+ y: new or(),
2770
+ Y: new ir(),
2771
+ R: new cr(),
2772
+ u: new ur(),
2773
+ Q: new dr(),
2774
+ q: new lr(),
2775
+ M: new fr(),
2776
+ L: new mr(),
2777
+ w: new wr(),
2778
+ I: new pr(),
2779
+ d: new Dr(),
2780
+ D: new Er(),
2781
+ E: new Tr(),
2782
+ e: new xr(),
2783
+ c: new Pr(),
2784
+ i: new Mr(),
2785
+ a: new Or(),
2786
+ b: new Ar(),
2787
+ B: new Nr(),
2788
+ h: new Rr(),
2789
+ H: new _r(),
2790
+ K: new kr(),
2791
+ k: new Ir(),
2792
+ m: new Yr(),
2793
+ s: new Cr(),
2794
+ S: new Sr(),
2795
+ X: new Lr(),
2796
+ x: new $r(),
2797
+ t: new Wr(),
2798
+ T: new qr()
2799
+ }, Fr = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Hr = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Qr = /^'([^]*?)'?$/, Br = /''/g, Vr = /\S/, Gr = /[a-zA-Z]/;
2800
+ function Xr(t, e, n, r) {
2801
+ const s = () => T(n, NaN), a = Jn(), o = a.locale ?? dt, i = a.firstWeekContainsDate ?? a.locale?.options?.firstWeekContainsDate ?? 1, c = a.weekStartsOn ?? a.locale?.options?.weekStartsOn ?? 0;
2790
2802
  if (!e)
2791
- return t ? s() : p(n, r?.in);
2803
+ return t ? s() : y(n, r?.in);
2792
2804
  const u = {
2793
- firstWeekContainsDate: c,
2794
- weekStartsOn: i,
2805
+ firstWeekContainsDate: i,
2806
+ weekStartsOn: c,
2795
2807
  locale: o
2796
- }, d = [new tr(r?.in, n)], l = e.match(qr).map((f) => {
2797
- const w = f[0];
2798
- if (w in re) {
2799
- const v = re[w];
2800
- return v(f, o.formatLong);
2808
+ }, d = [new sr(r?.in, n)], l = e.match(Hr).map((f) => {
2809
+ const g = f[0];
2810
+ if (g in re) {
2811
+ const P = re[g];
2812
+ return P(f, o.formatLong);
2801
2813
  }
2802
2814
  return f;
2803
- }).join("").match(Wr), m = [];
2815
+ }).join("").match(Fr), m = [];
2804
2816
  for (let f of l) {
2805
- ht(f) && se(f, e, t), mt(f) && se(f, e, t);
2806
- const w = f[0], v = $r[w];
2807
- if (v) {
2808
- const { incompatibleTokens: M } = v;
2809
- if (Array.isArray(M)) {
2810
- const q = m.find(
2811
- (Q) => M.includes(Q.token) || Q.token === w
2817
+ wt(f) && se(f, e, t), ht(f) && se(f, e, t);
2818
+ const g = f[0], P = Ur[g];
2819
+ if (P) {
2820
+ const { incompatibleTokens: O } = P;
2821
+ if (Array.isArray(O)) {
2822
+ const U = m.find(
2823
+ (B) => O.includes(B.token) || B.token === g
2812
2824
  );
2813
- if (q)
2825
+ if (U)
2814
2826
  throw new RangeError(
2815
- `The format string mustn't contain \`${q.fullToken}\` and \`${f}\` at the same time`
2827
+ `The format string mustn't contain \`${U.fullToken}\` and \`${f}\` at the same time`
2816
2828
  );
2817
- } else if (v.incompatibleTokens === "*" && m.length > 0)
2829
+ } else if (P.incompatibleTokens === "*" && m.length > 0)
2818
2830
  throw new RangeError(
2819
2831
  `The format string mustn't contain \`${f}\` and any other token at the same time`
2820
2832
  );
2821
- m.push({ token: w, fullToken: f });
2822
- const W = v.run(
2833
+ m.push({ token: g, fullToken: f });
2834
+ const q = P.run(
2823
2835
  t,
2824
2836
  f,
2825
2837
  o.match,
2826
2838
  u
2827
2839
  );
2828
- if (!W)
2840
+ if (!q)
2829
2841
  return s();
2830
- d.push(W.setter), t = W.rest;
2842
+ d.push(q.setter), t = q.rest;
2831
2843
  } else {
2832
- if (w.match(Qr))
2844
+ if (g.match(Gr))
2833
2845
  throw new RangeError(
2834
- "Format string contains an unescaped latin alphabet character `" + w + "`"
2846
+ "Format string contains an unescaped latin alphabet character `" + g + "`"
2835
2847
  );
2836
- if (f === "''" ? f = "'" : w === "'" && (f = Vr(f)), t.indexOf(f) === 0)
2848
+ if (f === "''" ? f = "'" : g === "'" && (f = jr(f)), t.indexOf(f) === 0)
2837
2849
  t = t.slice(f.length);
2838
2850
  else
2839
2851
  return s();
2840
2852
  }
2841
2853
  }
2842
- if (t.length > 0 && Fr.test(t))
2854
+ if (t.length > 0 && Vr.test(t))
2843
2855
  return s();
2844
- const x = d.map((f) => f.priority).sort((f, w) => w - f).filter((f, w, v) => v.indexOf(f) === w).map(
2845
- (f) => d.filter((w) => w.priority === f).sort((w, v) => v.subPriority - w.subPriority)
2856
+ const v = d.map((f) => f.priority).sort((f, g) => g - f).filter((f, g, P) => P.indexOf(f) === g).map(
2857
+ (f) => d.filter((g) => g.priority === f).sort((g, P) => P.subPriority - g.subPriority)
2846
2858
  ).map((f) => f[0]);
2847
- let P = p(n, r?.in);
2848
- if (isNaN(+P)) return s();
2849
- const N = {};
2850
- for (const f of x) {
2851
- if (!f.validate(P, u))
2859
+ let x = y(n, r?.in);
2860
+ if (isNaN(+x)) return s();
2861
+ const M = {};
2862
+ for (const f of v) {
2863
+ if (!f.validate(x, u))
2852
2864
  return s();
2853
- const w = f.set(P, N, u);
2854
- Array.isArray(w) ? (P = w[0], Object.assign(N, w[1])) : P = w;
2865
+ const g = f.set(x, M, u);
2866
+ Array.isArray(g) ? (x = g[0], Object.assign(M, g[1])) : x = g;
2855
2867
  }
2856
- return P;
2868
+ return x;
2857
2869
  }
2858
- function Vr(t) {
2859
- return t.match(Ur)[1].replace(Hr, "'");
2870
+ function jr(t) {
2871
+ return t.match(Qr)[1].replace(Br, "'");
2860
2872
  }
2861
- function Gr(t, e) {
2862
- const n = () => E(e?.in, NaN), s = Kr(t);
2873
+ function zr(t, e) {
2874
+ const n = () => T(e?.in, NaN), s = es(t);
2863
2875
  let a;
2864
2876
  if (s.date) {
2865
- const u = Jr(s.date, 2);
2866
- a = Zr(u.restDateString, u.year);
2877
+ const u = ts(s.date, 2);
2878
+ a = ns(u.restDateString, u.year);
2867
2879
  }
2868
2880
  if (!a || isNaN(+a)) return n();
2869
2881
  const o = +a;
2870
- let c = 0, i;
2871
- if (s.time && (c = es(s.time), isNaN(c)))
2882
+ let i = 0, c;
2883
+ if (s.time && (i = rs(s.time), isNaN(i)))
2872
2884
  return n();
2873
2885
  if (s.timezone) {
2874
- if (i = ts(s.timezone), isNaN(i)) return n();
2886
+ if (c = ss(s.timezone), isNaN(c)) return n();
2875
2887
  } else {
2876
- const u = new Date(o + c), d = p(0, e?.in);
2888
+ const u = new Date(o + i), d = y(0, e?.in);
2877
2889
  return d.setFullYear(
2878
2890
  u.getUTCFullYear(),
2879
2891
  u.getUTCMonth(),
@@ -2885,28 +2897,28 @@ function Gr(t, e) {
2885
2897
  u.getUTCMilliseconds()
2886
2898
  ), d;
2887
2899
  }
2888
- return p(o + c + i, e?.in);
2900
+ return y(o + i + c, e?.in);
2889
2901
  }
2890
- const B = {
2902
+ const V = {
2891
2903
  dateTimeDelimiter: /[T ]/,
2892
2904
  timeZoneDelimiter: /[Z ]/i,
2893
2905
  timezone: /([Z+-].*)$/
2894
- }, Xr = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, jr = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, zr = /^([+-])(\d{2})(?::?(\d{2}))?$/;
2895
- function Kr(t) {
2896
- const e = {}, n = t.split(B.dateTimeDelimiter);
2906
+ }, Kr = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, Jr = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, Zr = /^([+-])(\d{2})(?::?(\d{2}))?$/;
2907
+ function es(t) {
2908
+ const e = {}, n = t.split(V.dateTimeDelimiter);
2897
2909
  let r;
2898
2910
  if (n.length > 2)
2899
2911
  return e;
2900
- if (/:/.test(n[0]) ? r = n[0] : (e.date = n[0], r = n[1], B.timeZoneDelimiter.test(e.date) && (e.date = t.split(B.timeZoneDelimiter)[0], r = t.substr(
2912
+ if (/:/.test(n[0]) ? r = n[0] : (e.date = n[0], r = n[1], V.timeZoneDelimiter.test(e.date) && (e.date = t.split(V.timeZoneDelimiter)[0], r = t.substr(
2901
2913
  e.date.length,
2902
2914
  t.length
2903
2915
  ))), r) {
2904
- const s = B.timezone.exec(r);
2916
+ const s = V.timezone.exec(r);
2905
2917
  s ? (e.time = r.replace(s[1], ""), e.timezone = s[1]) : e.time = r;
2906
2918
  }
2907
2919
  return e;
2908
2920
  }
2909
- function Jr(t, e) {
2921
+ function ts(t, e) {
2910
2922
  const n = new RegExp(
2911
2923
  "^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
2912
2924
  ), r = t.match(n);
@@ -2917,84 +2929,84 @@ function Jr(t, e) {
2917
2929
  restDateString: t.slice((r[1] || r[2]).length)
2918
2930
  };
2919
2931
  }
2920
- function Zr(t, e) {
2932
+ function ns(t, e) {
2921
2933
  if (e === null) return /* @__PURE__ */ new Date(NaN);
2922
- const n = t.match(Xr);
2934
+ const n = t.match(Kr);
2923
2935
  if (!n) return /* @__PURE__ */ new Date(NaN);
2924
- const r = !!n[4], s = F(n[1]), a = F(n[2]) - 1, o = F(n[3]), c = F(n[4]), i = F(n[5]) - 1;
2936
+ const r = !!n[4], s = Q(n[1]), a = Q(n[2]) - 1, o = Q(n[3]), i = Q(n[4]), c = Q(n[5]) - 1;
2925
2937
  if (r)
2926
- return os(e, c, i) ? ns(e, c, i) : /* @__PURE__ */ new Date(NaN);
2938
+ return us(e, i, c) ? as(e, i, c) : /* @__PURE__ */ new Date(NaN);
2927
2939
  {
2928
2940
  const u = /* @__PURE__ */ new Date(0);
2929
- return !ss(e, a, o) || !as(e, s) ? /* @__PURE__ */ new Date(NaN) : (u.setUTCFullYear(e, a, Math.max(s, o)), u);
2941
+ return !is(e, a, o) || !cs(e, s) ? /* @__PURE__ */ new Date(NaN) : (u.setUTCFullYear(e, a, Math.max(s, o)), u);
2930
2942
  }
2931
2943
  }
2932
- function F(t) {
2944
+ function Q(t) {
2933
2945
  return t ? parseInt(t) : 1;
2934
2946
  }
2935
- function es(t) {
2936
- const e = t.match(jr);
2947
+ function rs(t) {
2948
+ const e = t.match(Jr);
2937
2949
  if (!e) return NaN;
2938
2950
  const n = te(e[1]), r = te(e[2]), s = te(e[3]);
2939
- return is(n, r, s) ? n * fe + r * le + s * 1e3 : NaN;
2951
+ return ds(n, r, s) ? n * fe + r * le + s * 1e3 : NaN;
2940
2952
  }
2941
2953
  function te(t) {
2942
2954
  return t && parseFloat(t.replace(",", ".")) || 0;
2943
2955
  }
2944
- function ts(t) {
2956
+ function ss(t) {
2945
2957
  if (t === "Z") return 0;
2946
- const e = t.match(zr);
2958
+ const e = t.match(Zr);
2947
2959
  if (!e) return 0;
2948
2960
  const n = e[1] === "+" ? -1 : 1, r = parseInt(e[2]), s = e[3] && parseInt(e[3]) || 0;
2949
- return cs(r, s) ? n * (r * fe + s * le) : NaN;
2961
+ return ls(r, s) ? n * (r * fe + s * le) : NaN;
2950
2962
  }
2951
- function ns(t, e, n) {
2963
+ function as(t, e, n) {
2952
2964
  const r = /* @__PURE__ */ new Date(0);
2953
2965
  r.setUTCFullYear(t, 0, 4);
2954
2966
  const s = r.getUTCDay() || 7, a = (e - 1) * 7 + n + 1 - s;
2955
2967
  return r.setUTCDate(r.getUTCDate() + a), r;
2956
2968
  }
2957
- const rs = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2958
- function bt(t) {
2969
+ const os = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2970
+ function Dt(t) {
2959
2971
  return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
2960
2972
  }
2961
- function ss(t, e, n) {
2962
- return e >= 0 && e <= 11 && n >= 1 && n <= (rs[e] || (bt(t) ? 29 : 28));
2973
+ function is(t, e, n) {
2974
+ return e >= 0 && e <= 11 && n >= 1 && n <= (os[e] || (Dt(t) ? 29 : 28));
2963
2975
  }
2964
- function as(t, e) {
2965
- return e >= 1 && e <= (bt(t) ? 366 : 365);
2976
+ function cs(t, e) {
2977
+ return e >= 1 && e <= (Dt(t) ? 366 : 365);
2966
2978
  }
2967
- function os(t, e, n) {
2979
+ function us(t, e, n) {
2968
2980
  return e >= 1 && e <= 53 && n >= 0 && n <= 6;
2969
2981
  }
2970
- function is(t, e, n) {
2982
+ function ds(t, e, n) {
2971
2983
  return t === 24 ? e === 0 && n === 0 : n >= 0 && n < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
2972
2984
  }
2973
- function cs(t, e) {
2985
+ function ls(t, e) {
2974
2986
  return e >= 0 && e <= 59;
2975
2987
  }
2976
- const V = (t) => {
2988
+ const G = (t) => {
2977
2989
  if (!t.includes("T")) {
2978
- for (const n of us) {
2979
- const r = Br(t, n, /* @__PURE__ */ new Date());
2990
+ for (const n of fs) {
2991
+ const r = Xr(t, n, /* @__PURE__ */ new Date());
2980
2992
  if (ne(r))
2981
2993
  return r;
2982
2994
  }
2983
2995
  return null;
2984
2996
  }
2985
- const e = Gr(t);
2997
+ const e = zr(t);
2986
2998
  return ne(e) ? e : null;
2987
- }, us = ["yyyy-MM-dd", "MM-dd-yyyy"], ae = (t, e, n) => {
2999
+ }, fs = ["yyyy-MM-dd", "MM-dd-yyyy"], ae = (t, e, n) => {
2988
3000
  const r = {};
2989
- return e?.contentType !== null && (r[Vt] = e?.contentType || Bt), e?.jwt ? r.Authorization = `Bearer ${e.jwt}` : t && (r[X] = t), e?.chatReference && (r[Gt] = e.chatReference), { ...r, ...n };
2990
- }, ds = (t) => {
3001
+ return e?.contentType !== null && (r[jt] = e?.contentType || Xt), e?.jwt ? r.Authorization = `Bearer ${e.jwt}` : t && (r[X] = t), e?.chatReference && (r[zt] = e.chatReference), { ...r, ...n };
3002
+ }, ms = (t) => {
2991
3003
  const e = { ...t };
2992
3004
  return e[X] && (e[X] = e[X].substring(0, 8) + "...[REDACTED]"), e.Authorization && (e.Authorization = "Bearer [REDACTED]"), e[j] && (e[j] = e[j].substring(0, 8) + "...[REDACTED]"), e;
2993
- }, Fe = async (t, e, n) => await fetch(t, {
3005
+ }, He = async (t, e, n) => await fetch(t, {
2994
3006
  method: n.method || "GET",
2995
3007
  headers: e,
2996
3008
  body: n.body ? JSON.stringify(n.body) : void 0
2997
- }), ls = async (t, e, n) => {
3009
+ }), hs = async (t, e, n) => {
2998
3010
  const r = n?.body === void 0 ? void 0 : n?.isFormData ? n.body : JSON.stringify(n.body);
2999
3011
  return await fetch(t, {
3000
3012
  method: n.method,
@@ -3003,20 +3015,20 @@ const V = (t) => {
3003
3015
  signal: n?.signal
3004
3016
  });
3005
3017
  };
3006
- class fs {
3018
+ class ws {
3007
3019
  constructor() {
3008
3020
  this.decoder = new TextDecoder();
3009
3021
  }
3010
3022
  async streamChat(e, n, r = {}, s) {
3011
- const { onMessage: a, onError: o, onComplete: c, signal: i } = r;
3023
+ const { onMessage: a, onError: o, onComplete: i, signal: c } = r;
3012
3024
  try {
3013
3025
  const u = await this.initializeStreamRequest(
3014
3026
  e,
3015
3027
  n,
3016
- i,
3028
+ c,
3017
3029
  s
3018
3030
  );
3019
- await this.processStreamData(u, a), c?.();
3031
+ await this.processStreamData(u, a), i?.();
3020
3032
  } catch (u) {
3021
3033
  this.handleStreamError(u, o);
3022
3034
  }
@@ -3024,7 +3036,7 @@ class fs {
3024
3036
  async initializeStreamRequest(e, n, r, s) {
3025
3037
  const a = ae(void 0, {
3026
3038
  jwt: s
3027
- }), o = await ls(
3039
+ }), o = await hs(
3028
3040
  e,
3029
3041
  {
3030
3042
  Accept: "text/event-stream",
@@ -3037,16 +3049,16 @@ class fs {
3037
3049
  }
3038
3050
  );
3039
3051
  if (!o.ok) {
3040
- const c = await o.text();
3041
- let i = {};
3052
+ const i = await o.text();
3053
+ let c = {};
3042
3054
  try {
3043
- i = JSON.parse(c);
3055
+ c = JSON.parse(i);
3044
3056
  } catch {
3045
- i.error = "Failed to parse error body";
3057
+ c.error = "Failed to parse error body";
3046
3058
  }
3047
3059
  throw new Se({
3048
3060
  status: o.status,
3049
- message: i.error ?? "No response body"
3061
+ message: c.error ?? "No response body"
3050
3062
  });
3051
3063
  }
3052
3064
  if (!o.body)
@@ -3067,11 +3079,11 @@ class fs {
3067
3079
  }
3068
3080
  const o = this.decoder.decode(a, { stream: !0 });
3069
3081
  r += o;
3070
- const c = r.split(`
3082
+ const i = r.split(`
3071
3083
  `);
3072
- r = c.pop() || "";
3073
- for (const i of c)
3074
- this.parseSSEDataLine(i, n);
3084
+ r = i.pop() || "";
3085
+ for (const c of i)
3086
+ this.parseSSEDataLine(c, n);
3075
3087
  }
3076
3088
  } finally {
3077
3089
  e.releaseLock();
@@ -3099,8 +3111,8 @@ class fs {
3099
3111
  }
3100
3112
  }
3101
3113
  }
3102
- new fs();
3103
- class Qa {
3114
+ new ws();
3115
+ class ja {
3104
3116
  constructor(e) {
3105
3117
  this.config = e, console.info("SdmxApiClient initialized", {
3106
3118
  apiUrl: e.apiUrl || "NOT SET"
@@ -3122,71 +3134,72 @@ class Qa {
3122
3134
  s
3123
3135
  );
3124
3136
  }
3125
- async streamRequest(e, n, r, s) {
3126
- const a = `${this.config.apiUrl}/${e}`, o = this.buildHeaders(s, n.headers), c = new ReadableStream({
3127
- async start(u) {
3137
+ async streamRequest(e, n, r, s, a) {
3138
+ const o = `${this.config.apiUrl}/${e}`, i = this.buildHeaders(s, n.headers), c = new ReadableStream({
3139
+ async start(d) {
3128
3140
  try {
3129
- const d = await Fe(a, o, n);
3130
- if (!d.ok) {
3131
- const P = await d.text();
3141
+ const l = await He(o, i, n);
3142
+ if (!l.ok) {
3143
+ const M = await l.text();
3132
3144
  throw console.error(
3133
- `Fetch failed! Status: ${d.status}, Body: ${P}`
3134
- ), new Error(`Fetch failed with status ${d.status}`);
3145
+ `Fetch failed! Status: ${l.status}, Body: ${M}`
3146
+ ), new Error(`Fetch failed with status ${l.status}`);
3135
3147
  }
3136
- const l = d.body?.getReader();
3137
- if (!l) throw new Error("Failed to create stream reader");
3138
- const m = new Uint8Array([239, 187, 191]);
3139
- u.enqueue(m);
3148
+ const m = l.body?.getReader();
3149
+ if (!m) throw new Error("Failed to create stream reader");
3150
+ const v = new Uint8Array([239, 187, 191]);
3151
+ d.enqueue(v);
3140
3152
  const x = async () => {
3141
- const { done: P, value: N } = await l.read();
3142
- P ? u.close() : (u.enqueue(N), await x());
3153
+ const { done: M, value: f } = await m.read();
3154
+ M ? d.close() : (d.enqueue(f), await x());
3143
3155
  };
3144
3156
  x();
3145
- } catch (d) {
3146
- u.error(d);
3157
+ } catch (l) {
3158
+ d.error(l);
3147
3159
  }
3148
3160
  }
3149
- }), i = new Headers({
3150
- "Content-Disposition": `attachment; filename=${encodeURIComponent(r)}`
3161
+ }), u = new Headers({
3162
+ "Content-Disposition": `attachment; filename=${encodeURIComponent(r)}`,
3163
+ ...a ? { "Content-Type": a } : {}
3151
3164
  });
3152
- return new Response(c, { headers: i });
3165
+ return new Response(c, { headers: u });
3153
3166
  }
3154
3167
  async request(e, n, r, s) {
3155
- const a = Date.now(), o = `${r || this.config.apiUrl}/${e}`, c = this.buildHeaders(s, n.headers);
3156
- this.addInfoRequestLog("API Request", o, n, c);
3168
+ const a = Date.now(), o = `${r || this.config.apiUrl}/${e}`, i = this.buildHeaders(s, n.headers);
3169
+ this.addInfoRequestLog("API Request", o, n, i);
3157
3170
  try {
3158
- const i = await Fe(o, c, n), u = Date.now() - a;
3171
+ const c = await He(o, i, n), u = Date.now() - a;
3159
3172
  let d;
3160
- const l = await i.text();
3173
+ const l = await c.text();
3161
3174
  try {
3162
3175
  d = l ? JSON.parse(l) : {};
3163
3176
  } catch {
3164
3177
  if (this.addErrorRequestParsing(
3165
3178
  o,
3166
3179
  n,
3167
- i,
3180
+ c,
3168
3181
  u,
3169
3182
  l
3170
- ), !i.ok)
3183
+ ), !c.ok)
3171
3184
  throw new Error(
3172
- `API request failed: ${i.status} ${i.statusText} - ${l.substring(0, 100)}`
3185
+ `API request failed: ${c.status} ${c.statusText} - ${l.substring(0, 100)}`
3173
3186
  );
3174
3187
  d = { data: l };
3175
3188
  }
3176
- if (!i.ok) {
3177
- this.addErrorRequestLog(o, n, i, u, d);
3178
- const m = Qt(d, i);
3189
+ if (!c.ok) {
3190
+ this.addErrorRequestLog(o, n, c, u, d);
3191
+ const m = Gt(d, c);
3179
3192
  throw new Error(`API request failed: ${m}`);
3180
3193
  }
3181
3194
  return d;
3182
- } catch (i) {
3195
+ } catch (c) {
3183
3196
  const u = Date.now() - a;
3184
3197
  throw console.error("API Request Exception", {
3185
3198
  method: n.method,
3186
3199
  url: o,
3187
3200
  duration: `${u}ms`,
3188
- error: i instanceof Error ? i.message : String(i)
3189
- }), i;
3201
+ error: c instanceof Error ? c.message : String(c)
3202
+ }), c;
3190
3203
  }
3191
3204
  }
3192
3205
  buildHeaders(e, n) {
@@ -3205,7 +3218,7 @@ class Qa {
3205
3218
  const a = {
3206
3219
  method: r.method || "GET",
3207
3220
  url: n,
3208
- headers: ds(s)
3221
+ headers: ms(s)
3209
3222
  };
3210
3223
  r.body && (a.body = r.body), console.info(e, a);
3211
3224
  }
@@ -3231,112 +3244,112 @@ class Qa {
3231
3244
  });
3232
3245
  }
3233
3246
  }
3234
- var we = /* @__PURE__ */ ((t) => (t.LAST_UPDATE_AT = "lastUpdatedAt", t.SERIES_COUNT = "series_count", t))(we || {});
3235
- function Ba(t) {
3247
+ var ge = /* @__PURE__ */ ((t) => (t.LAST_UPDATE_AT = "lastUpdatedAt", t.SERIES_COUNT = "series_count", t))(ge || {});
3248
+ function za(t) {
3236
3249
  return t?.annotations?.find((e) => {
3237
- if (e.id === we.LAST_UPDATE_AT)
3250
+ if (e.id === ge.LAST_UPDATE_AT)
3238
3251
  return e;
3239
3252
  })?.value;
3240
3253
  }
3241
- const ye = (t, e) => t?.names && t?.names[e] || t?.name, Dt = (t, e, n) => {
3254
+ const pe = (t, e) => t?.names && t?.names[e] || t?.name, Et = (t, e, n) => {
3242
3255
  if (!(!t || e?.has(t?.id)) && (e?.set(t?.id, t), t?.parent)) {
3243
3256
  const r = n?.get(t?.parent);
3244
- Dt(r, e, n);
3257
+ Et(r, e, n);
3245
3258
  }
3246
- }, ms = (t, e) => {
3259
+ }, gs = (t, e) => {
3247
3260
  const n = /* @__PURE__ */ new Map(), r = new Map(t?.map((s) => [s.id, s]));
3248
3261
  return e?.forEach((s) => {
3249
- Dt(s, n, r);
3262
+ Et(s, n, r);
3250
3263
  }), Array.from(n?.values());
3251
3264
  };
3252
- var hs = /* @__PURE__ */ ((t) => (t.C = "c", t))(hs || {}), k = /* @__PURE__ */ ((t) => (t.EQUALS = "eq", t.NOT_EQUALS = "ne", t.LESS = "lt", t.LESS_OR_EQUAL = "le", t.GREATER = "gt", t.GREATER_OR_EQUAL = "ge", t.CONTAINS = "co", t.NOT_CONTAINS = "nc", t.STARTS = "sw", t.ENDS = "ew", t))(k || {}), gs = /* @__PURE__ */ ((t) => (t.BOOLEAN = "Boolean", t.DATE_TIME = "DateTime", t.DECIMAL = "Decimal", t.INTEGER = "Integer", t.OBSERVATION_TIME_PERIOD = "ObservationalTimePeriod", t.STRING = "String", t.TIME = "Time", t.TIME_RANGE = "TimeRange", t.URI = "URI", t))(gs || {}), ws = /* @__PURE__ */ ((t) => (t.ANNUAL = "A", t.QUARTERLY = "Q", t.MONTHLY = "M", t))(ws || {});
3253
- const Va = ["FREQ", "FREQUENCY"], ys = "TIME_PERIOD", ps = "time_period_start", bs = "time_period_end", Ga = (t) => {
3265
+ var ps = /* @__PURE__ */ ((t) => (t.C = "c", t))(ps || {}), _ = /* @__PURE__ */ ((t) => (t.EQUALS = "eq", t.NOT_EQUALS = "ne", t.LESS = "lt", t.LESS_OR_EQUAL = "le", t.GREATER = "gt", t.GREATER_OR_EQUAL = "ge", t.CONTAINS = "co", t.NOT_CONTAINS = "nc", t.STARTS = "sw", t.ENDS = "ew", t))(_ || {}), ys = /* @__PURE__ */ ((t) => (t.BOOLEAN = "Boolean", t.DATE_TIME = "DateTime", t.DECIMAL = "Decimal", t.INTEGER = "Integer", t.OBSERVATION_TIME_PERIOD = "ObservationalTimePeriod", t.STRING = "String", t.TIME = "Time", t.TIME_RANGE = "TimeRange", t.URI = "URI", t))(ys || {}), bs = /* @__PURE__ */ ((t) => (t.ANNUAL = "A", t.QUARTERLY = "Q", t.MONTHLY = "M", t))(bs || {});
3266
+ const Ka = ["FREQ", "FREQUENCY"], Ds = "TIME_PERIOD", Es = "time_period_start", Ts = "time_period_end", Ja = (t) => {
3254
3267
  const e = t?.find(
3255
- (a) => a.id === ps
3268
+ (a) => a.id === Es
3256
3269
  ), n = t?.find(
3257
- (a) => a.id === bs
3270
+ (a) => a.id === Ts
3258
3271
  ), r = n?.title ? new Date(n?.title) : null;
3259
3272
  return {
3260
3273
  startPeriod: e?.title ? new Date(e?.title) : null,
3261
3274
  endPeriod: r
3262
3275
  };
3263
- }, Ds = (t, e) => t.id.localeCompare(e.id), Ts = (t, e) => t.memberValue.localeCompare(e.memberValue), Es = (t, e) => {
3264
- const n = new Array(t.length), r = t.map((o, c) => [o, c]);
3276
+ }, xs = (t, e) => t.id.localeCompare(e.id), Ps = (t, e) => t.memberValue.localeCompare(e.memberValue), vs = (t, e) => {
3277
+ const n = new Array(t.length), r = t.map((o, i) => [o, i]);
3265
3278
  r.sort(
3266
- (o, c) => Ds(o[0], c[0])
3279
+ (o, i) => xs(o[0], i[0])
3267
3280
  );
3268
3281
  const s = [...e];
3269
- s.sort(Ts);
3282
+ s.sort(Ps);
3270
3283
  let a = 0;
3271
3284
  for (const o of r) {
3272
- const c = o[0];
3273
- for (; a < s.length && s[a].memberValue.localeCompare(c.id) < 0; )
3285
+ const i = o[0];
3286
+ for (; a < s.length && s[a].memberValue.localeCompare(i.id) < 0; )
3274
3287
  a += 1;
3275
- a < s.length && s[a].memberValue === c.id && (n[o[1]] = o[0]);
3288
+ a < s.length && s[a].memberValue === i.id && (n[o[1]] = o[0]);
3276
3289
  }
3277
3290
  return n.filter((o) => o != null);
3278
- }, xs = (t) => !!t?.some((e) => e.parent), Xa = (t, e, n, r, s = []) => {
3291
+ }, Ms = (t) => !!t?.some((e) => e.parent), Za = (t, e, n, r, s = []) => {
3279
3292
  let a = t || [];
3280
- if (Ps(n || [], e || "")) {
3293
+ if (Os(n || [], e || "")) {
3281
3294
  const o = (n || [])[0].cubeRegions?.find(
3282
- ({ isIncluded: c }) => c
3295
+ ({ isIncluded: i }) => i
3283
3296
  );
3284
3297
  if (o) {
3285
- const c = o.memberSelection?.find(
3286
- ({ componentId: i }) => i === e
3298
+ const i = o.memberSelection?.find(
3299
+ ({ componentId: c }) => c === e
3287
3300
  );
3288
- c ? a = a.length === 0 ? (c.selectionValues || []).map(({ memberValue: i }) => ({
3289
- id: i,
3290
- name: i
3291
- })) : Es(a, c.selectionValues) : a = [];
3301
+ i ? a = a.length === 0 ? (i.selectionValues || []).map(({ memberValue: c }) => ({
3302
+ id: c,
3303
+ name: c
3304
+ })) : vs(a, i.selectionValues) : a = [];
3292
3305
  }
3293
3306
  } else s.length !== 0 && (a = a.filter(({ id: o }) => s.includes(o)));
3294
- return xs(t) && (a = ms(t, a)), a?.map((o) => ({
3307
+ return Ms(t) && (a = gs(t, a)), a?.map((o) => ({
3295
3308
  ...o,
3296
- name: r ? ye(o, r) : o?.name
3309
+ name: r ? pe(o, r) : o?.name
3297
3310
  }));
3298
- }, Ps = (t, e) => t != null && t.length > 0 && e != null, vs = (t) => {
3311
+ }, Os = (t, e) => t != null && t.length > 0 && e != null, As = (t) => {
3299
3312
  const e = [];
3300
3313
  return t?.filters?.forEach((n) => {
3301
- n.componentCode !== ys && e.push({
3314
+ n.componentCode !== Ds && e.push({
3302
3315
  componentCode: n.componentCode,
3303
- operator: k.EQUALS,
3316
+ operator: _.EQUALS,
3304
3317
  value: n.values.join(",")
3305
3318
  });
3306
3319
  }), e;
3307
- }, ja = (t) => {
3320
+ }, eo = (t) => {
3308
3321
  const e = /* @__PURE__ */ new Map();
3309
3322
  return t?.forEach((n) => {
3310
- e.set(n.urn, vs(n));
3323
+ e.set(n.urn, As(n));
3311
3324
  }), e;
3312
- }, Ms = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, Qe = (t) => {
3325
+ }, Ns = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, Qe = (t) => {
3313
3326
  if (typeof t != "string")
3314
3327
  throw new TypeError("Invalid argument expected string");
3315
- const e = t.match(Ms);
3328
+ const e = t.match(Ns);
3316
3329
  if (!e)
3317
3330
  throw new Error(`Invalid argument not valid semver ('${t}' received)`);
3318
3331
  return e.shift(), e;
3319
3332
  }, Be = (t) => t === "*" || t === "x" || t === "X", Ve = (t) => {
3320
3333
  const e = parseInt(t, 10);
3321
3334
  return isNaN(e) ? t : e;
3322
- }, Os = (t, e) => typeof t != typeof e ? [String(t), String(e)] : [t, e], As = (t, e) => {
3335
+ }, Rs = (t, e) => typeof t != typeof e ? [String(t), String(e)] : [t, e], _s = (t, e) => {
3323
3336
  if (Be(t) || Be(e))
3324
3337
  return 0;
3325
- const [n, r] = Os(Ve(t), Ve(e));
3338
+ const [n, r] = Rs(Ve(t), Ve(e));
3326
3339
  return n > r ? 1 : n < r ? -1 : 0;
3327
3340
  }, Ge = (t, e) => {
3328
3341
  for (let n = 0; n < Math.max(t.length, e.length); n++) {
3329
- const r = As(t[n] || "0", e[n] || "0");
3342
+ const r = _s(t[n] || "0", e[n] || "0");
3330
3343
  if (r !== 0)
3331
3344
  return r;
3332
3345
  }
3333
3346
  return 0;
3334
- }, Ns = (t, e) => {
3347
+ }, ks = (t, e) => {
3335
3348
  const n = Qe(t), r = Qe(e), s = n.pop(), a = r.pop(), o = Ge(n, r);
3336
3349
  return o !== 0 ? o : s && a ? Ge(s.split("."), a.split(".")) : s || a ? s ? -1 : 1 : 0;
3337
- }, Rs = (t, e, n) => {
3338
- ks(n);
3339
- const r = Ns(t, e);
3350
+ }, Is = (t, e, n) => {
3351
+ Ys(n);
3352
+ const r = ks(t, e);
3340
3353
  return Tt[n].includes(r);
3341
3354
  }, Tt = {
3342
3355
  ">": [1],
@@ -3345,53 +3358,53 @@ const Va = ["FREQ", "FREQUENCY"], ys = "TIME_PERIOD", ps = "time_period_start",
3345
3358
  "<=": [-1, 0],
3346
3359
  "<": [-1],
3347
3360
  "!=": [-1, 1]
3348
- }, Xe = Object.keys(Tt), ks = (t) => {
3361
+ }, Xe = Object.keys(Tt), Ys = (t) => {
3349
3362
  if (Xe.indexOf(t) === -1)
3350
3363
  throw new Error(`Invalid operator, expected one of ${Xe.join("|")}`);
3351
- }, oe = "+", pe = (t, e) => {
3352
- const { agency: n, id: r, version: s } = C(t), a = e.filter(
3353
- (i) => i.agencyID === n && i.id === r && !i?.version?.includes(oe)
3364
+ }, oe = "+", ye = (t, e) => {
3365
+ const { agency: n, id: r, version: s } = S(t), a = e.filter(
3366
+ (c) => c.agencyID === n && c.id === r && !c?.version?.includes(oe)
3354
3367
  );
3355
3368
  if (a.length === 1)
3356
3369
  return a[0];
3357
3370
  if (!s?.includes(oe))
3358
- return a.find((i) => i.version === s);
3371
+ return a.find((c) => c.version === s);
3359
3372
  const o = a.map(
3360
- (i) => i.version
3361
- ), c = _s(s, o);
3373
+ (c) => c.version
3374
+ ), i = Cs(s, o);
3362
3375
  return a.find(
3363
- (i) => i.version === c[0]
3376
+ (c) => c.version === i[0]
3364
3377
  );
3365
- }, _s = (t, e) => {
3366
- const n = Is(t, e);
3378
+ }, Cs = (t, e) => {
3379
+ const n = Ss(t, e);
3367
3380
  return n.length > 0 ? [n[0]] : [];
3368
- }, Is = (t, e) => {
3381
+ }, Ss = (t, e) => {
3369
3382
  const n = [];
3370
3383
  return e.forEach((r) => {
3371
- Cs(t, r) && n.push(r);
3384
+ $s(t, r) && n.push(r);
3372
3385
  }), n;
3373
- }, Ys = (t) => {
3386
+ }, Ls = (t) => {
3374
3387
  const e = t.trim(), n = e.indexOf("+");
3375
3388
  if (n <= 0) return "";
3376
3389
  let r = n;
3377
3390
  for (; r > 0 && e[r - 1] >= "0" && e[r - 1] <= "9"; )
3378
3391
  r--;
3379
3392
  return r > 0 ? e.slice(0, r) : "";
3380
- }, Cs = (t, e) => {
3381
- const n = t.trim().replace(/\+/, ""), r = Ys(t);
3382
- return e.startsWith(r) && Rs(e, n, ">=");
3393
+ }, $s = (t, e) => {
3394
+ const n = t.trim().replace(/\+/, ""), r = Ls(t);
3395
+ return e.startsWith(r) && Is(e, n, ">=");
3383
3396
  }, be = (t, e) => {
3384
- const { concept: n } = Ss(t, e);
3397
+ const { concept: n } = Ws(t, e);
3385
3398
  return n;
3386
- }, Ss = (t, e) => {
3399
+ }, Ws = (t, e) => {
3387
3400
  if (t == null)
3388
3401
  return {
3389
3402
  concept: void 0,
3390
3403
  scheme: void 0
3391
3404
  };
3392
- const { childId: n, agency: r, id: s, version: a } = nt(t);
3405
+ const { childId: n, agency: r, id: s, version: a } = rt(t);
3393
3406
  if (a?.includes(oe)) {
3394
- const o = pe(
3407
+ const o = ye(
3395
3408
  t,
3396
3409
  e
3397
3410
  );
@@ -3401,7 +3414,7 @@ const Va = ["FREQ", "FREQUENCY"], ys = "TIME_PERIOD", ps = "time_period_start",
3401
3414
  };
3402
3415
  }
3403
3416
  for (const o of e)
3404
- if (Ls(o, s, r, a))
3417
+ if (qs(o, s, r, a))
3405
3418
  return {
3406
3419
  concept: je(o?.concepts || [], n),
3407
3420
  scheme: o
@@ -3410,79 +3423,79 @@ const Va = ["FREQ", "FREQUENCY"], ys = "TIME_PERIOD", ps = "time_period_start",
3410
3423
  concept: void 0,
3411
3424
  scheme: void 0
3412
3425
  };
3413
- }, je = (t, e) => t?.find((n) => n.id === e), Ls = (t, e, n, r) => t.id === e && t.agencyID === n && t.version === r, za = (t = [], e = [], n) => {
3426
+ }, je = (t, e) => t?.find((n) => n.id === e), qs = (t, e, n, r) => t.id === e && t.agencyID === n && t.version === r, to = (t = [], e = [], n) => {
3414
3427
  const r = n?.conceptIdentity || "", s = be(r, e), a = z(
3415
3428
  n?.localRepresentation?.enumeration
3416
3429
  ), o = z(
3417
3430
  s?.coreRepresentation?.enumeration
3418
- ), c = a || o;
3419
- if (c != null)
3420
- return pe(c, t);
3421
- }, $s = (t, e) => {
3431
+ ), i = a || o;
3432
+ if (i != null)
3433
+ return ye(i, t);
3434
+ }, Us = (t, e) => {
3422
3435
  const n = t?.data?.dataSets?.[0], s = t?.data?.structures?.[0]?.attributes?.dimensionGroup || [], a = n?.dimensionGroupAttributes, o = {};
3423
- for (const c of s) {
3424
- const i = c.relationship.dimensions, { codedSeriesKey: u, decodedSeriesKey: d } = Et(
3436
+ for (const i of s) {
3437
+ const c = i.relationship.dimensions, { codedSeriesKey: u, decodedSeriesKey: d } = xt(
3425
3438
  t,
3426
3439
  e,
3427
- i
3440
+ c
3428
3441
  );
3429
- o[c.id] = {
3442
+ o[i.id] = {
3430
3443
  values: a?.[u] || [],
3431
3444
  decodedSeriesKey: d,
3432
3445
  codedSeriesKey: u
3433
3446
  };
3434
3447
  }
3435
3448
  return o;
3436
- }, Et = (t, e, n) => {
3449
+ }, xt = (t, e, n) => {
3437
3450
  const r = t?.data?.structures?.[0], s = [
3438
3451
  ...r?.dimensions.series || [],
3439
3452
  ...r?.dimensions.observation || []
3440
3453
  ], a = new Array(s?.length), o = new Array(s?.length);
3441
- return n?.forEach((c) => {
3442
- const i = s?.findIndex((l) => l.id === c) || 0, u = e[i], d = s[i].values.findIndex(
3454
+ return n?.forEach((i) => {
3455
+ const c = s?.findIndex((l) => l.id === i) || 0, u = e[c], d = s[c].values.findIndex(
3443
3456
  (l) => l.id === u || l.value === u
3444
3457
  ) || 0;
3445
- a[i] = d >= 0 ? d : u, o[i] = u;
3458
+ a[c] = d >= 0 ? d : u, o[c] = u;
3446
3459
  }), {
3447
3460
  codedSeriesKey: a.join(":"),
3448
3461
  decodedSeriesKey: o.join(":")
3449
3462
  };
3450
- }, Ka = (t, e, n) => {
3463
+ }, no = (t, e, n) => {
3451
3464
  const r = t?.data?.dataSets?.[0], s = t?.data?.structures?.[0], a = (s?.attributes?.dimensionGroup || []).filter(
3452
3465
  (l) => l.relationship.dimensions?.length === 1 && l.relationship.dimensions.includes(e || "")
3453
- ), o = r?.dimensionGroupAttributes, c = [
3466
+ ), o = r?.dimensionGroupAttributes, i = [
3454
3467
  ...s?.dimensions.series || [],
3455
3468
  ...s?.dimensions.observation || []
3456
- ], i = c?.findIndex((l) => l.id === e), u = new Array(c?.length);
3457
- u[i] = n || "";
3469
+ ], c = i?.findIndex((l) => l.id === e), u = new Array(i?.length);
3470
+ u[c] = n || "";
3458
3471
  const d = {};
3459
3472
  for (const l of a) {
3460
- const m = l.relationship.dimensions, { codedSeriesKey: x, decodedSeriesKey: P } = Et(
3473
+ const m = l.relationship.dimensions, { codedSeriesKey: v, decodedSeriesKey: x } = xt(
3461
3474
  t,
3462
3475
  u,
3463
3476
  m
3464
3477
  );
3465
3478
  d[l.id] = {
3466
- values: o?.[x] || [],
3467
- decodedSeriesKey: P,
3468
- codedSeriesKey: x
3479
+ values: o?.[v] || [],
3480
+ decodedSeriesKey: x,
3481
+ codedSeriesKey: v
3469
3482
  };
3470
3483
  }
3471
3484
  return d;
3472
- }, Ws = (t, e) => {
3485
+ }, Fs = (t, e) => {
3473
3486
  if (e == null)
3474
3487
  return;
3475
3488
  const n = t.values?.[e];
3476
3489
  return n ?? (e instanceof Array ? { values: e } : { value: e.toString() });
3477
- }, Ja = (t, e, n, r) => {
3490
+ }, ro = (t, e, n, r) => {
3478
3491
  const s = e?.find(
3479
3492
  (a) => a?.id === t?.id
3480
3493
  )?.values;
3481
3494
  return n?.filter((a) => s?.some((o) => o.id === a.id))?.map((a) => ({
3482
3495
  ...a,
3483
- name: r ? ye(a, r) : a?.name
3496
+ name: r ? pe(a, r) : a?.name
3484
3497
  })) || [];
3485
- }, qs = (t, e) => {
3498
+ }, Hs = (t, e) => {
3486
3499
  const n = e?.dataStructureComponents?.attributeList, r = t?.metadataStructureComponents?.metadataAttributeList;
3487
3500
  return n?.metadataAttributeUsages?.map((s) => {
3488
3501
  const a = r?.metadataAttributes?.find(
@@ -3494,55 +3507,55 @@ const Va = ["FREQ", "FREQUENCY"], ys = "TIME_PERIOD", ps = "time_period_start",
3494
3507
  isMandatory: Number(a?.minOccurs) > 0
3495
3508
  };
3496
3509
  });
3497
- }, Za = (t = [], e, n) => {
3510
+ }, so = (t = [], e, n) => {
3498
3511
  const r = z(e?.conceptIdentity) || "", s = be(r, t);
3499
- return n ? ye(s, n) : s?.name ?? s?.id ?? e?.id;
3512
+ return n ? pe(s, n) : s?.name ?? s?.id ?? e?.id;
3500
3513
  };
3501
- var Us = /* @__PURE__ */ ((t) => (t.CONDITIONAL = "Conditional", t.MANDATORY = "Mandatory", t))(Us || {}), De = /* @__PURE__ */ ((t) => (t.DIMENSION = "Dimension", t.MEASURE_DIMENSION = "MeasureDimension", t.TIME_DIMENSION = "TimeDimension", t))(De || {}), Hs = /* @__PURE__ */ ((t) => (t.UNBOUNDED = "unbounded", t))(Hs || {});
3514
+ var Qs = /* @__PURE__ */ ((t) => (t.CONDITIONAL = "Conditional", t.MANDATORY = "Mandatory", t))(Qs || {}), De = /* @__PURE__ */ ((t) => (t.DIMENSION = "Dimension", t.MEASURE_DIMENSION = "MeasureDimension", t.TIME_DIMENSION = "TimeDimension", t))(De || {}), Bs = /* @__PURE__ */ ((t) => (t.UNBOUNDED = "unbounded", t))(Bs || {});
3502
3515
  function ze(t) {
3503
3516
  return t?.dataStructures?.[0]?.dataStructureComponents?.dimensionList;
3504
3517
  }
3505
- function eo(t) {
3518
+ function ao(t) {
3506
3519
  return t?.data?.structures?.[0]?.dimensions?.series || [];
3507
3520
  }
3508
- function to(t) {
3521
+ function oo(t) {
3509
3522
  return t?.data?.structures?.[0]?.dimensions?.observation?.[0].values.map((e) => e.value ? e.value : e.id).filter((e) => e != null) || [];
3510
3523
  }
3511
- function no(t) {
3524
+ function io(t) {
3512
3525
  return t.find(
3513
3526
  (e) => e.type === De.TIME_DIMENSION
3514
3527
  );
3515
3528
  }
3516
- const ro = (t) => {
3529
+ const co = (t) => {
3517
3530
  const e = /* @__PURE__ */ new Map(), n = t?.dataStructures?.[0], r = t?.metadataStructures?.[0], s = t?.conceptSchemes || [], a = t?.codelists || [];
3518
3531
  return t && [
3519
3532
  ...ze(t)?.dimensions || [],
3520
3533
  ...ze(t)?.timeDimensions || [],
3521
- ...qs(r, n),
3534
+ ...Hs(r, n),
3522
3535
  ...n?.dataStructureComponents?.attributeList?.attributes || []
3523
3536
  ].forEach(
3524
- (c) => {
3525
- const i = be(
3526
- c?.conceptIdentity,
3537
+ (i) => {
3538
+ const c = be(
3539
+ i?.conceptIdentity,
3527
3540
  s
3528
- ), u = c?.localRepresentation?.enumeration || i?.coreRepresentation?.enumeration, d = pe(
3541
+ ), u = i?.localRepresentation?.enumeration || c?.coreRepresentation?.enumeration, d = ye(
3529
3542
  u,
3530
3543
  a
3531
3544
  );
3532
- c?.id && (u ? e.set(c?.id, {
3545
+ i?.id && (u ? e.set(i?.id, {
3533
3546
  ...d,
3534
- name: i?.name,
3535
- names: i?.names
3536
- }) : e.set(c?.id, {
3537
- id: c?.id,
3538
- name: i?.name,
3539
- names: i?.names
3547
+ name: c?.name,
3548
+ names: c?.names
3549
+ }) : e.set(i?.id, {
3550
+ id: i?.id,
3551
+ name: c?.name,
3552
+ names: c?.names
3540
3553
  }));
3541
3554
  }
3542
3555
  ), e;
3543
- }, so = (t) => t?.find(
3544
- (e) => e.id === we.SERIES_COUNT
3545
- )?.title || "", Te = 1440 * 60 * 1e3, Ee = 7 * Te;
3556
+ }, uo = (t) => t?.find(
3557
+ (e) => e.id === ge.SERIES_COUNT
3558
+ )?.title || "", Ee = 1440 * 60 * 1e3, Te = 7 * Ee;
3546
3559
  function xe(t) {
3547
3560
  const e = `${t}-01-01`, n = new Date(e);
3548
3561
  if (n.getDay() !== 4) {
@@ -3551,7 +3564,7 @@ function xe(t) {
3551
3564
  }
3552
3565
  return n;
3553
3566
  }
3554
- function Fs(t) {
3567
+ function Vs(t) {
3555
3568
  const e = new Date(t), r = -((e.getDay() + 6) % 7) + 3;
3556
3569
  return e.setDate(e.getDate() + r), new Date(e.valueOf());
3557
3570
  }
@@ -3562,29 +3575,30 @@ function Ke(t, e = "W") {
3562
3575
  const s = `${t}-12-24`;
3563
3576
  return Z(new Date(s), e).weekNumber;
3564
3577
  }
3565
- function xt(t, e, n = "W") {
3578
+ function Pt(t, e, n = "W") {
3566
3579
  return `${t}-${n}${e < 10 ? "0" + e : e}`;
3567
3580
  }
3568
3581
  function Z(t, e = "W") {
3569
- const n = Fs(t), r = n.getFullYear(), s = xe(r), a = 1 + Math.ceil(
3570
- (n.getTime() - s.getTime()) / Ee
3582
+ const n = Vs(t), r = n.getFullYear(), s = xe(r), a = 1 + Math.ceil(
3583
+ (n.getTime() - s.getTime()) / Te
3571
3584
  );
3572
3585
  return {
3573
- code: xt(r, a, e),
3586
+ code: Pt(r, a, e),
3574
3587
  weekNumber: a,
3575
3588
  weekYear: r
3576
3589
  };
3577
3590
  }
3578
- function Qs(t) {
3579
- const [e, n] = t.split("-W"), s = xe(+e).getTime() + (+n - 1) * Ee - 3 * Te;
3591
+ function Gs(t) {
3592
+ const [e, n] = t.split("-W"), s = xe(+e).getTime() + (+n - 1) * Te - 3 * Ee;
3580
3593
  return new Date(s);
3581
3594
  }
3582
- function Bs(t) {
3583
- const [e, n] = t.split("-W"), s = xe(+e).getTime() + (+n - 1) * Ee + 3 * Te;
3595
+ function Xs(t) {
3596
+ const [e, n] = t.split("-W"), s = xe(+e).getTime() + (+n - 1) * Te + 3 * Ee;
3584
3597
  return new Date(s);
3585
3598
  }
3586
- const Vs = "/api/download", Gs = 6e4, ao = async (t, e, n, r, s, a, o) => {
3587
- const c = new URLSearchParams({
3599
+ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t) => t.normalize("NFKC").replace(zs, "_").replace(/_+/g, "_").replace(/\s+/g, " ").replace(/^[._ ]+/, "").trim() || "download", Ks = (t, e, n, r, s, a, o) => {
3600
+ const i = new URL(Je, window.location.origin);
3601
+ if (i.search = new URLSearchParams({
3588
3602
  urn: t,
3589
3603
  format: e,
3590
3604
  compress: "false",
@@ -3593,75 +3607,89 @@ const Vs = "/api/download", Gs = 6e4, ao = async (t, e, n, r, s, a, o) => {
3593
3607
  attribute: r,
3594
3608
  language: n,
3595
3609
  isMetadata: o ? "true" : "none"
3596
- }).toString(), i = `${Vs}?${c}`, u = await fetch(i, {
3610
+ }).toString(), i.origin !== window.location.origin || i.pathname !== Je)
3611
+ throw new Error("Invalid download URL");
3612
+ return i.toString();
3613
+ }, Js = (t, e) => {
3614
+ const n = URL.createObjectURL(t), r = document.createElement("a");
3615
+ r.href = n, r.download = vt(e), r.rel = "noopener noreferrer", r.click(), window.setTimeout(
3616
+ () => URL.revokeObjectURL(n),
3617
+ js
3618
+ );
3619
+ }, lo = async (t, e, n, r, s, a, o, i) => {
3620
+ const c = vt(a), u = Ks(
3621
+ t,
3622
+ e,
3623
+ n,
3624
+ r,
3625
+ s,
3626
+ c,
3627
+ o
3628
+ ), d = await fetch(u, {
3597
3629
  method: "GET",
3598
- credentials: "same-origin"
3630
+ credentials: "same-origin",
3631
+ signal: i
3599
3632
  });
3600
- if (!u.ok) {
3601
- const x = await u.text();
3633
+ if (!d.ok) {
3634
+ const m = await d.text();
3602
3635
  throw new Error(
3603
- `Download request failed: ${u.status} ${u.statusText}${x ? ` - ${x}` : ""}`
3636
+ `Download request failed: ${d.status} ${d.statusText}${m ? ` - ${m}` : ""}`
3604
3637
  );
3605
3638
  }
3606
- const d = await u.blob(), l = URL.createObjectURL(d), m = document.createElement("a");
3607
- m.href = l, m.download = a, m.style.display = "none", document.body.appendChild(m), m.click(), document.body.removeChild(m), window.setTimeout(
3608
- () => URL.revokeObjectURL(l),
3609
- Gs
3610
- );
3611
- }, oo = (t, e) => {
3639
+ const l = await d.blob();
3640
+ i?.aborted || Js(l, c);
3641
+ }, fo = (t, e) => {
3612
3642
  const n = [];
3613
3643
  for (const r of t) {
3614
3644
  if (r.type !== De.DIMENSION)
3615
3645
  continue;
3616
3646
  const s = e.find((a) => a.componentCode === r.id);
3617
- s != null && s.values?.length > 0 ? n.push(s.values?.join(Ut)) : n.push("*");
3647
+ s != null && s.values?.length > 0 ? n.push(s.values?.join(ot)) : n.push("*");
3618
3648
  }
3619
3649
  return n.join(".");
3620
- }, Xs = (t, e) => {
3650
+ }, Zs = (t, e) => {
3621
3651
  if (!t || !t.startPeriod && !t.endPeriod)
3622
3652
  return null;
3623
3653
  const n = [], { startPeriod: r, endPeriod: s } = t;
3624
3654
  if (r && n.push(
3625
- `${k.GREATER_OR_EQUAL}${Ie}${Je(r)}`
3655
+ `${_.GREATER_OR_EQUAL}${Ie}${Ze(r)}`
3626
3656
  ), s && n.push(
3627
- `${k.LESS_OR_EQUAL}${Ie}${Je(s)}`
3657
+ `${_.LESS_OR_EQUAL}${Ie}${Ze(s)}`
3628
3658
  ), n.length === 0)
3629
3659
  return null;
3630
- const a = e;
3631
- return n.map(
3632
- (o) => `${encodeURIComponent(`c[${a}]`)}${qt}${encodeURIComponent(o)}`
3633
- ).join(at);
3634
- }, Je = (t) => Gn(t, "yyyy-MM-dd"), io = (t, e) => {
3635
- const n = js(t, e) || null;
3636
- return n ? Xs(n, e?.id) : null;
3637
- }, js = (t, e) => {
3660
+ const a = e, o = n.join(ot);
3661
+ return `${encodeURIComponent(`c[${a}]`)}${Qt}${encodeURIComponent(o)}`;
3662
+ }, Ze = (t) => zn(t, "yyyy-MM-dd"), mo = (t, e) => {
3663
+ const n = ea(t, e) || null;
3664
+ return n ? Zs(n, e?.id) : null;
3665
+ }, ea = (t, e) => {
3638
3666
  const n = e.id, r = t?.filters?.find(
3639
- (i) => i.componentCode === n
3667
+ (c) => c.componentCode === n
3640
3668
  );
3641
3669
  if (!r || !r.values)
3642
3670
  return null;
3643
- const s = r.values?.filter((i) => !!i);
3671
+ const s = r.values?.filter((c) => !!c);
3644
3672
  if (!s.length)
3645
3673
  return null;
3646
3674
  const a = r.operator;
3647
- if (a === k.LESS_OR_EQUAL || a === k.LESS)
3648
- return { startPeriod: null, endPeriod: V(s[0]) };
3649
- if (a === k.GREATER_OR_EQUAL || a === k.GREATER)
3650
- return { startPeriod: V(s[0]), endPeriod: null };
3651
- const o = V(s[0]), c = V(s[1]);
3652
- return { startPeriod: o, endPeriod: c };
3653
- }, zs = "Observation", co = (t) => {
3675
+ if (a === _.LESS_OR_EQUAL || a === _.LESS)
3676
+ return { startPeriod: null, endPeriod: G(s[0]) };
3677
+ if (a === _.GREATER_OR_EQUAL || a === _.GREATER)
3678
+ return { startPeriod: G(s[0]), endPeriod: null };
3679
+ const o = G(s[0]), i = G(s[1]);
3680
+ return { startPeriod: o, endPeriod: i };
3681
+ }, ta = "Observation", ho = (t) => {
3654
3682
  const e = t?.data?.dataSets, n = t?.data?.structures?.[0];
3655
3683
  if (!e || !n)
3656
3684
  return [];
3657
- const r = n.attributes, s = n.dimensions, a = r?.dimensionGroup || [], o = e[0].series || e[0].observations, c = s.series?.length ? s.series : s.observation, i = [];
3685
+ const r = n.attributes, s = n.dimensions, a = r?.dimensionGroup || [], o = e[0].series || e[0].observations, i = s.series?.length ? s.series : s.observation, c = [];
3658
3686
  for (const u in o) {
3659
- const d = [], { name: l, parsedTimeSeriesValue: m } = Ks(
3687
+ const d = [], { name: l, parsedTimeSeriesValue: m } = na(
3660
3688
  u,
3661
- c
3662
- ), x = o[u], P = x.attributes || [];
3663
- if (Object.keys(x).length === 0) {
3664
- i.push({
3689
+ i
3690
+ ), v = o[u], x = v.attributes || [];
3691
+ if (Object.keys(v).length === 0) {
3692
+ c.push({
3665
3693
  name: l,
3666
3694
  parsedTimeSeriesValue: m,
3667
3695
  values: d,
@@ -3671,127 +3699,127 @@ const Vs = "/api/download", Gs = 6e4, ao = async (t, e, n, r, s, a, o) => {
3671
3699
  continue;
3672
3700
  }
3673
3701
  d.push(
3674
- ...ta(x, n)
3702
+ ...oa(v, n)
3675
3703
  );
3676
- const N = ie(
3704
+ const M = ie(
3677
3705
  r?.series || [],
3678
- (M) => P[M]
3679
- ), f = na(
3706
+ (O) => x[O]
3707
+ ), f = ia(
3680
3708
  n.attributes?.dataSet || [],
3681
- e[0].attributes?.filter((M) => M != null) || []
3682
- ), w = $s(
3709
+ e[0].attributes?.filter((O) => O != null) || []
3710
+ ), g = Us(
3683
3711
  t,
3684
3712
  m
3685
- ), v = a.map((M, W) => {
3686
- const q = w[M.id], Q = Ws(
3687
- M,
3688
- q.values[W]
3713
+ ), P = a.map((O, q) => {
3714
+ const U = g[O.id], B = Fs(
3715
+ O,
3716
+ U.values[q]
3689
3717
  );
3690
3718
  return {
3691
- attribute: M,
3692
- dimensionGroupValue: Q,
3693
- dimensionGroupData: q
3719
+ attribute: O,
3720
+ dimensionGroupValue: B,
3721
+ dimensionGroupData: U
3694
3722
  };
3695
3723
  });
3696
- i.push({
3724
+ c.push({
3697
3725
  name: l,
3698
3726
  parsedTimeSeriesValue: m,
3699
3727
  values: d,
3700
- attributes: N,
3728
+ attributes: M,
3701
3729
  dataSetAttrs: f,
3702
- dimensionGroupAttributes: v
3730
+ dimensionGroupAttributes: P
3703
3731
  });
3704
3732
  }
3705
- return i;
3706
- }, Ks = (t, e) => {
3733
+ return c;
3734
+ }, na = (t, e) => {
3707
3735
  const n = t.split(new RegExp("(?<!\\|):(?!\\||$)")), r = [];
3708
3736
  for (let s = 0; s < n.length; s++) {
3709
3737
  const a = e?.[s], o = Number(n[s]);
3710
3738
  if (o < 0 || a == null)
3711
3739
  continue;
3712
- const c = a.values[o];
3713
- if (c == null) {
3740
+ const i = a.values[o];
3741
+ if (i == null) {
3714
3742
  r.push(n[s].replace("|:", ":"));
3715
3743
  continue;
3716
3744
  }
3717
- r.push(c?.id || c?.value || "");
3745
+ r.push(i?.id || i?.value || "");
3718
3746
  }
3719
3747
  return {
3720
- name: Zs(r),
3748
+ name: sa(r),
3721
3749
  parsedTimeSeriesValue: r
3722
3750
  };
3723
3751
  }, ie = (t, e) => {
3724
3752
  const n = [];
3725
3753
  for (let r = 0; r < t.length; r++) {
3726
- const s = t[r], a = e(r), o = a != null && s.values != null ? Js(a, s) : void 0;
3754
+ const s = t[r], a = e(r), o = a != null && s.values != null ? ra(a, s) : void 0;
3727
3755
  n.push({
3728
3756
  name: s.id,
3729
3757
  value: o
3730
3758
  });
3731
3759
  }
3732
3760
  return n;
3733
- }, Js = (t, e) => {
3761
+ }, ra = (t, e) => {
3734
3762
  const n = e.values[t];
3735
3763
  return n == null ? typeof t == "object" ? t : t.toString() : n?.id || n?.value || n?.ids || n?.values;
3736
- }, Zs = (t) => t.map((e) => e ? ea(e) : "").join("."), ea = (t) => t.replace(/\./g, "|.").replace(/:/g, "|:"), ta = (t, e) => {
3764
+ }, sa = (t) => t.map((e) => e ? aa(e) : "").join("."), aa = (t) => t.replace(/\./g, "|.").replace(/:/g, "|:"), oa = (t, e) => {
3737
3765
  const n = e.measures?.observation?.length;
3738
3766
  if (t.observations == null)
3739
3767
  return [
3740
3768
  {
3741
- values: Ze(t, e.measures),
3769
+ values: et(t, e.measures),
3742
3770
  obsAttributes: ie(
3743
3771
  e.attributes?.observation || [],
3744
3772
  (o) => t[o + n]
3745
3773
  ),
3746
- dimensionAtObservation: zs
3774
+ dimensionAtObservation: ta
3747
3775
  }
3748
3776
  ];
3749
3777
  const r = t.observations, s = e.dimensions.observation?.[0], a = [];
3750
3778
  for (const o in r) {
3751
- const c = s?.values[o];
3779
+ const i = s?.values[o];
3752
3780
  a.push({
3753
- dimensionAtObservation: c?.value || c?.id,
3754
- values: Ze(
3781
+ dimensionAtObservation: i?.value || i?.id,
3782
+ values: et(
3755
3783
  r[o],
3756
3784
  e.measures
3757
3785
  ),
3758
3786
  obsAttributes: ie(
3759
3787
  e.attributes?.observation || [],
3760
- (i) => r[o][i + n]
3788
+ (c) => r[o][c + n]
3761
3789
  )
3762
3790
  });
3763
3791
  }
3764
3792
  return a;
3765
- }, Ze = (t, e) => e?.observation?.map((n, r) => ({ name: n.id, value: t[r] })) || [], na = (t, e) => t.reduce(
3793
+ }, et = (t, e) => e?.observation?.map((n, r) => ({ name: n.id, value: t[r] })) || [], ia = (t, e) => t.reduce(
3766
3794
  (n, r, s) => {
3767
3795
  const a = e[s];
3768
- return ra(n, r, a, ""), n;
3796
+ return ca(n, r, a, ""), n;
3769
3797
  },
3770
3798
  []
3771
- ), ra = (t, e, n, r) => {
3799
+ ), ca = (t, e, n, r) => {
3772
3800
  const s = n != null ? e?.values?.length > 0 ? e.values[n]?.id || e.values[n]?.value : String(n) : r;
3773
3801
  t.push({
3774
3802
  name: e.id,
3775
3803
  value: s || ""
3776
3804
  });
3777
- }, sa = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, aa = /^[0-9][0-9][0-9][0-9]-W(0[1-9]|[1-4][0-9]|5[0-3])$/, oa = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, ia = /^[0-9][0-9][0-9][0-9]$/, ca = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, ua = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, Pe = (t) => ia.exec(t), ve = (t) => !!Pe(t), da = (t) => oa.exec(t), Me = (t) => !!da(t), Oe = (t) => ua.exec(t), Ae = (t) => !!Oe(t), Ne = (t) => sa.exec(t), Re = (t) => !!Ne(t), la = (t) => ca.exec(t), fa = (t) => !!la(t), ma = (t) => aa.exec(t), ke = (t) => !!ma(t);
3778
- function Pt(t) {
3779
- return ve(t) ? ha(t) : Me(t) ? wa(t) : Re(t) ? pa(t) : Ae(t) ? Da(t) : ke(t) ? Qs(t) : Ea(t);
3805
+ }, ua = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, da = /^[0-9][0-9][0-9][0-9]-W(0[1-9]|[1-4][0-9]|5[0-3])$/, la = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, fa = /^[0-9][0-9][0-9][0-9]$/, ma = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, ha = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, Pe = (t) => fa.exec(t), ve = (t) => !!Pe(t), wa = (t) => la.exec(t), Me = (t) => !!wa(t), Oe = (t) => ha.exec(t), Ae = (t) => !!Oe(t), Ne = (t) => ua.exec(t), Re = (t) => !!Ne(t), ga = (t) => ma.exec(t), pa = (t) => !!ga(t), ya = (t) => da.exec(t), _e = (t) => !!ya(t);
3806
+ function Mt(t) {
3807
+ return ve(t) ? ba(t) : Me(t) ? Ea(t) : Re(t) ? xa(t) : Ae(t) ? va(t) : _e(t) ? Gs(t) : Oa(t);
3780
3808
  }
3781
- function vt(t) {
3782
- return ve(t) ? ga(t) : Me(t) ? ya(t) : Re(t) ? ba(t) : Ae(t) ? Ta(t) : ke(t) ? Bs(t) : xa(t);
3809
+ function Ot(t) {
3810
+ return ve(t) ? Da(t) : Me(t) ? Ta(t) : Re(t) ? Pa(t) : Ae(t) ? Ma(t) : _e(t) ? Xs(t) : Aa(t);
3783
3811
  }
3784
- function ha(t) {
3812
+ function ba(t) {
3785
3813
  const e = Pe(t);
3786
3814
  if (e)
3787
3815
  return new Date(Number(e[0]), 0, 1);
3788
3816
  }
3789
- function ga(t) {
3817
+ function Da(t) {
3790
3818
  const e = Pe(t);
3791
3819
  if (e)
3792
3820
  return new Date(Number(e[0]) + 1, 0, 1);
3793
3821
  }
3794
- function wa(t) {
3822
+ function Ea(t) {
3795
3823
  const [e, n] = t.split("-S");
3796
3824
  switch (+n) {
3797
3825
  case 1:
@@ -3800,7 +3828,7 @@ function wa(t) {
3800
3828
  return new Date(+e, 6, 1);
3801
3829
  }
3802
3830
  }
3803
- function ya(t) {
3831
+ function Ta(t) {
3804
3832
  const [e, n] = t.split("-S");
3805
3833
  switch (+n) {
3806
3834
  case 1:
@@ -3809,7 +3837,7 @@ function ya(t) {
3809
3837
  return new Date(+e + 1, 0, 1);
3810
3838
  }
3811
3839
  }
3812
- function pa(t) {
3840
+ function xa(t) {
3813
3841
  const e = Ne(t);
3814
3842
  if (!e)
3815
3843
  return;
@@ -3825,7 +3853,7 @@ function pa(t) {
3825
3853
  return new Date(+n, 9, 1);
3826
3854
  }
3827
3855
  }
3828
- function ba(t) {
3856
+ function Pa(t) {
3829
3857
  const e = Ne(t);
3830
3858
  if (!e)
3831
3859
  return;
@@ -3841,45 +3869,45 @@ function ba(t) {
3841
3869
  return new Date(+n + 1, 0, 1);
3842
3870
  }
3843
3871
  }
3844
- function Da(t) {
3872
+ function va(t) {
3845
3873
  const e = Oe(t);
3846
3874
  if (!e)
3847
3875
  return;
3848
3876
  const [n, r] = e[0].split("-M");
3849
3877
  return new Date(+n, +r - 1, 1);
3850
3878
  }
3851
- function Ta(t) {
3879
+ function Ma(t) {
3852
3880
  const e = Oe(t);
3853
3881
  if (!e)
3854
3882
  return;
3855
3883
  const [n, r] = e[0].split("-M");
3856
3884
  return new Date(+n, +r, 1);
3857
3885
  }
3858
- const Ea = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), xa = (t) => {
3886
+ const Oa = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), Aa = (t) => {
3859
3887
  const e = /* @__PURE__ */ new Date(`${t}T23:59:00`);
3860
3888
  return e.setMinutes(e.getMinutes() + 1), e;
3861
- }, Pa = 1, va = (t, e, n, r = !0, s = "Q") => {
3862
- const a = [], o = e && e > 3 ? _a(e, r) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
3863
- for (let i = o; i <= c; i++)
3864
- a.push(`${t}-${s}${i}`);
3889
+ }, Na = 1, Ra = (t, e, n, r = !0, s = "Q") => {
3890
+ const a = [], o = e && e > 3 ? La(e, r) : 1, i = n ? Math.floor((n - 1) / 3) : 4;
3891
+ for (let c = o; c <= i; c++)
3892
+ a.push(`${t}-${s}${c}`);
3865
3893
  return a;
3866
- }, Ma = (t, e, n, r = "S") => {
3894
+ }, _a = (t, e, n, r = "S") => {
3867
3895
  const s = [];
3868
3896
  return (e || 1) < 7 && (n || 12) > 6 && s.push(`${t}-${r}1`), n == null && s.push(`${t}-${r}2`), s;
3869
- }, uo = (t) => Math.ceil(t / 3), Mt = (t, e, n = "M") => `${t}-${n}${e.toString().padStart(2, "0")}`, Oa = (t, e, n = "M") => {
3897
+ }, wo = (t) => Math.ceil(t / 3), At = (t, e, n = "M") => `${t}-${n}${e.toString().padStart(2, "0")}`, ka = (t, e, n = "M") => {
3870
3898
  const r = [];
3871
3899
  for (let s = e; s <= 12; s++)
3872
- r.push(Mt(t, s, n));
3900
+ r.push(At(t, s, n));
3873
3901
  return r;
3874
- }, Aa = (t, e, n, r = "M") => {
3902
+ }, Ia = (t, e, n, r = "M") => {
3875
3903
  const s = [];
3876
3904
  for (let a = e; a < n; a++)
3877
- s.push(Mt(t, a, r));
3905
+ s.push(At(t, a, r));
3878
3906
  return s;
3879
- }, Na = (t, e, n, r = "M") => {
3907
+ }, Ya = (t, e, n, r = "M") => {
3880
3908
  const s = e || 1, a = n == null, o = n || 12;
3881
- return a ? Oa(t, s, r) : Aa(t, s, o, r);
3882
- }, lo = (t, e, n = "M") => {
3909
+ return a ? ka(t, s, r) : Ia(t, s, o, r);
3910
+ }, go = (t, e, n = "M") => {
3883
3911
  switch (e) {
3884
3912
  case 0:
3885
3913
  return [
@@ -3908,55 +3936,55 @@ const Ea = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), xa = (t) => {
3908
3936
  default:
3909
3937
  return [];
3910
3938
  }
3911
- }, Ra = (t, e) => {
3912
- const n = _(e, !0), r = _(t), s = n.getFullYear(), a = r.getFullYear(), o = n.getTime() <= r.getTime() ? a + Pa - s : 0;
3913
- return Array.from({ length: o }, (i, u) => s + u);
3914
- }, _ = (t, e = !1) => {
3915
- const n = ka(t, e);
3939
+ }, Ca = (t, e) => {
3940
+ const n = k(e, !0), r = k(t), s = n.getFullYear(), a = r.getFullYear(), o = n.getTime() <= r.getTime() ? a + Na - s : 0;
3941
+ return Array.from({ length: o }, (c, u) => s + u);
3942
+ }, k = (t, e = !1) => {
3943
+ const n = Sa(t, e);
3916
3944
  return n ? (n.getTimezoneOffset() > 0 && n.setMinutes(n.getMinutes() + n.getTimezoneOffset()), n) : /* @__PURE__ */ new Date();
3917
- }, ka = (t, e = !1) => {
3945
+ }, Sa = (t, e = !1) => {
3918
3946
  const n = Number(t);
3919
- return t.toString().length !== 13 ? e ? Pt(t) : vt(t) : isNaN(n) ? /* @__PURE__ */ new Date(`${t}T00:00:00.000Z`) : new Date(n);
3920
- }, _a = (t, e) => e ? Math.floor((t + 1) / 3) : Math.ceil((t + 1) / 3), fo = (t, e) => {
3921
- const n = tt(t) - tt(e);
3947
+ return t.toString().length !== 13 ? e ? Mt(t) : Ot(t) : isNaN(n) ? /* @__PURE__ */ new Date(`${t}T00:00:00.000Z`) : new Date(n);
3948
+ }, La = (t, e) => e ? Math.floor((t + 1) / 3) : Math.ceil((t + 1) / 3), po = (t, e) => {
3949
+ const n = nt(t) - nt(e);
3922
3950
  if (n === 0 && t !== e) {
3923
- const r = et(t), s = et(e);
3951
+ const r = tt(t), s = tt(e);
3924
3952
  return r - s;
3925
3953
  }
3926
3954
  return n;
3927
- }, et = (t) => ve(t) ? 6 : Me(t) ? 5 : Re(t) ? 4 : Ae(t) ? 3 : ke(t) ? 2 : fa(t) ? 1 : 0, tt = (t, e = !1) => (e ? Pt(t) : vt(t))?.getTime() || 0, Ot = (t, e, n) => {
3928
- const r = _(e, !0), s = _(n), a = _(t, !0), o = _(t), c = r.getTime() > a.getTime() ? r : a, i = s.getTime() < o.getTime() ? s : o;
3955
+ }, tt = (t) => ve(t) ? 6 : Me(t) ? 5 : Re(t) ? 4 : Ae(t) ? 3 : _e(t) ? 2 : pa(t) ? 1 : 0, nt = (t, e = !1) => (e ? Mt(t) : Ot(t))?.getTime() || 0, Nt = (t, e, n) => {
3956
+ const r = k(e, !0), s = k(n), a = k(t, !0), o = k(t), i = r.getTime() > a.getTime() ? r : a, c = s.getTime() < o.getTime() ? s : o;
3929
3957
  return {
3930
- start: c,
3931
- end: i
3958
+ start: i,
3959
+ end: c
3932
3960
  };
3933
- }, Ia = (t, e, n, r = "W") => {
3934
- const s = +t, { start: a, end: o } = Ot(t, e, n);
3961
+ }, $a = (t, e, n, r = "W") => {
3962
+ const s = +t, { start: a, end: o } = Nt(t, e, n);
3935
3963
  if (a.getTime() > o.getTime())
3936
3964
  return [];
3937
- const c = Z(a, r), i = c.weekYear === s ? c.weekNumber : c.weekYear < s ? 1 : Ke(s, r), u = Z(o, r), d = u.weekYear === s ? u.weekNumber : u.weekYear > s ? Ke(s, r) : 1, l = [];
3938
- if (i < d)
3939
- for (let m = i; m <= d; m++)
3940
- l.push(xt(s, m, r));
3965
+ const i = Z(a, r), c = i.weekYear === s ? i.weekNumber : i.weekYear < s ? 1 : Ke(s, r), u = Z(o, r), d = u.weekYear === s ? u.weekNumber : u.weekYear > s ? Ke(s, r) : 1, l = [];
3966
+ if (c < d)
3967
+ for (let m = c; m <= d; m++)
3968
+ l.push(Pt(s, m, r));
3941
3969
  return l;
3942
- }, Ya = (t) => {
3970
+ }, Wa = (t) => {
3943
3971
  const e = new Date(t);
3944
3972
  return e.setMinutes(e.getMinutes() - e.getTimezoneOffset()), e.toISOString().slice(0, 10);
3945
- }, Ca = (t, e, n) => {
3946
- const { start: r, end: s } = Ot(t, e, n);
3973
+ }, qa = (t, e, n) => {
3974
+ const { start: r, end: s } = Nt(t, e, n);
3947
3975
  if (r.getTime() > s.getTime())
3948
3976
  return [];
3949
3977
  const a = [], o = new Date(
3950
3978
  r.getFullYear(),
3951
3979
  r.getMonth(),
3952
3980
  r.getDate()
3953
- ), c = new Date(s.getFullYear(), s.getMonth(), s.getDate());
3954
- for (; o.getTime() < c.getTime(); ) {
3955
- const i = Ya(o);
3956
- a.push(i), o.setDate(o.getDate() + 1);
3981
+ ), i = new Date(s.getFullYear(), s.getMonth(), s.getDate());
3982
+ for (; o.getTime() < i.getTime(); ) {
3983
+ const c = Wa(o);
3984
+ a.push(c), o.setDate(o.getDate() + 1);
3957
3985
  }
3958
3986
  return a;
3959
- }, Sa = (t) => ({
3987
+ }, Ua = (t) => ({
3960
3988
  isDailyExist: !!t?.some(({ memberValue: e }) => e === "D"),
3961
3989
  isWeeklyExist: !!t?.some(({ memberValue: e }) => e === "W"),
3962
3990
  isMonthlyExist: !!t?.some(({ memberValue: e }) => e === "M"),
@@ -3965,49 +3993,49 @@ const Ea = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), xa = (t) => {
3965
3993
  isYearlyExist: !!t?.some(
3966
3994
  ({ memberValue: e }) => e === "A" || e === "Y"
3967
3995
  )
3968
- }), La = (t, e, n, r) => {
3969
- const s = r === 0 ? _(e.toString(), !0)?.getMonth() + 1 : void 0, a = r === t.length - 1 ? _(n.toString())?.getMonth() + 1 || 1 : void 0;
3996
+ }), Fa = (t, e, n, r) => {
3997
+ const s = r === 0 ? k(e.toString(), !0)?.getMonth() + 1 : void 0, a = r === t.length - 1 ? k(n.toString())?.getMonth() + 1 || 1 : void 0;
3970
3998
  return { startMonth: s, endMonth: a };
3971
- }, $a = ["FREQUENCY", "FREQ"], mo = (t, e) => {
3999
+ }, Ha = ["FREQUENCY", "FREQ"], yo = (t, e) => {
3972
4000
  const n = t?.[0]?.cubeRegions?.[0]?.memberSelection?.find(
3973
- (i) => $a.includes(i.componentId)
3974
- )?.selectionValues, r = Sa(n || []), s = e?.startPeriod?.getTime() || 1, a = e?.endPeriod?.getTime() || 1, o = Ra(a, s), c = [];
3975
- return o.forEach((i, u) => {
3976
- const d = [], { startMonth: l, endMonth: m } = La(
4001
+ (c) => Ha.includes(c.componentId)
4002
+ )?.selectionValues, r = Ua(n || []), s = e?.startPeriod?.getTime() || 1, a = e?.endPeriod?.getTime() || 1, o = Ca(a, s), i = [];
4003
+ return o.forEach((c, u) => {
4004
+ const d = [], { startMonth: l, endMonth: m } = Fa(
3977
4005
  o,
3978
4006
  new Date(s),
3979
4007
  new Date(a),
3980
4008
  u
3981
4009
  ), {
3982
- isDailyExist: x,
3983
- isWeeklyExist: P,
3984
- isMonthlyExist: N,
4010
+ isDailyExist: v,
4011
+ isWeeklyExist: x,
4012
+ isMonthlyExist: M,
3985
4013
  isQuarterlyExist: f,
3986
- isSemiAnnualExist: w,
3987
- isYearlyExist: v
4014
+ isSemiAnnualExist: g,
4015
+ isYearlyExist: P
3988
4016
  } = r;
3989
- v && d.push(i.toString()), w && d.push(...Ma(i, l, m)), f && d.push(
3990
- ...va(i, l, m, !1)
3991
- ), N && d.push(...Na(i, l, m)), P && d.push(
3992
- ...Ia(i, s.toString(), a.toString())
3993
- ), x && d.push(
3994
- ...Ca(i, s.toString(), a.toString())
3995
- ), c.push(...d);
3996
- }), c;
4017
+ P && d.push(c.toString()), g && d.push(..._a(c, l, m)), f && d.push(
4018
+ ...Ra(c, l, m, !1)
4019
+ ), M && d.push(...Ya(c, l, m)), x && d.push(
4020
+ ...$a(c, s.toString(), a.toString())
4021
+ ), v && d.push(
4022
+ ...qa(c, s.toString(), a.toString())
4023
+ ), i.push(...d);
4024
+ }), i;
3997
4025
  };
3998
- function Wa(t) {
4026
+ function Qa(t) {
3999
4027
  const { urn: e } = t.details;
4000
4028
  return ue(e.resourceId, e.version, e.agencyId);
4001
4029
  }
4002
- function ho(t) {
4030
+ function bo(t) {
4003
4031
  const e = {};
4004
4032
  for (const n of t.datasets) {
4005
- const r = n.dataset, s = Wa(r);
4033
+ const r = n.dataset, s = Qa(r);
4006
4034
  e[s] = r.details.dimensions;
4007
4035
  }
4008
4036
  return e;
4009
4037
  }
4010
- function go(t) {
4038
+ function Do(t) {
4011
4039
  return t?.codelists?.length ? t.codelists.map((e) => ({
4012
4040
  id: e.id,
4013
4041
  agencyID: e.agencyID ?? "",
@@ -4030,7 +4058,7 @@ function go(t) {
4030
4058
  }))
4031
4059
  }));
4032
4060
  }
4033
- function qa(t, e) {
4061
+ function Ba(t, e) {
4034
4062
  const n = (r) => {
4035
4063
  const s = r.indexOf("(");
4036
4064
  if (s === -1) return r;
@@ -4046,32 +4074,32 @@ function ce(t) {
4046
4074
  t.agencyID ?? ""
4047
4075
  );
4048
4076
  }
4049
- function At(t, e, n) {
4077
+ function Rt(t, e, n) {
4050
4078
  e?.forEach((r) => {
4051
- const { childId: s, agency: a, id: o, version: c } = nt(r.code), i = ue(o, c, a), u = n?.find(
4052
- (l) => qa(i, ce(l))
4079
+ const { childId: s, agency: a, id: o, version: i } = rt(r.code), c = ue(o, i, a), u = n?.find(
4080
+ (l) => Ba(c, ce(l))
4053
4081
  ), d = u?.codes?.find((l) => l.id === s);
4054
4082
  if (d != null) {
4055
4083
  const l = r.code.replace(
4056
- i,
4084
+ c,
4057
4085
  ce(u)
4058
4086
  );
4059
4087
  t.push({ ...d, code: l });
4060
4088
  }
4061
- At(t, r.hierarchicalCodes, n);
4089
+ Rt(t, r.hierarchicalCodes, n);
4062
4090
  });
4063
4091
  }
4064
- function wo(t, e) {
4092
+ function Eo(t, e) {
4065
4093
  const n = [];
4066
- return At(n, t?.hierarchicalCodes, e), n;
4094
+ return Rt(n, t?.hierarchicalCodes, e), n;
4067
4095
  }
4068
- function yo(t) {
4096
+ function To(t) {
4069
4097
  const e = {};
4070
4098
  return t?.forEach((n) => {
4071
4099
  e[ce(n)] = n.codes;
4072
4100
  }), e;
4073
4101
  }
4074
- function po(t, e, n) {
4102
+ function xo(t, e, n) {
4075
4103
  if (!n || n.length === 0 || !e)
4076
4104
  return t;
4077
4105
  const r = n[0].cubeRegions?.find(
@@ -4085,145 +4113,147 @@ function po(t, e, n) {
4085
4113
  const a = new Set(s.selectionValues.map((o) => o.memberValue));
4086
4114
  return t.filter((o) => a.has(o.id));
4087
4115
  }
4088
- class bo {
4116
+ class Po {
4089
4117
  constructor(e) {
4090
4118
  this.client = e;
4091
4119
  }
4092
4120
  async getAvailableHierarchies(e, n, r) {
4093
- const { agency: s, id: a, version: o } = C(e), i = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/codelist`, u = r ? { [Ce]: r } : void 0;
4121
+ const { agency: s, id: a, version: o } = S(e), c = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/codelist`, u = r ? { [Ce]: r } : void 0;
4094
4122
  return this.client.request(
4095
4123
  `${s}/${a}/${o}?references=hierarchy&detail=allcompletestubs`,
4096
4124
  { method: "GET", headers: u },
4097
- i,
4125
+ c,
4098
4126
  n
4099
4127
  );
4100
4128
  }
4101
4129
  async getHierarchy(e, n, r) {
4102
- const { agency: s, id: a, version: o } = C(e), i = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/hierarchy`, u = r ? { [Ce]: r } : void 0;
4130
+ const { agency: s, id: a, version: o } = S(e), c = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/hierarchy`, u = r ? { [Ce]: r } : void 0;
4103
4131
  return this.client.request(
4104
4132
  `${s}/${a}/${o}?references=descendants&detail=full`,
4105
4133
  { method: "GET", headers: u },
4106
- i,
4134
+ c,
4107
4135
  n
4108
4136
  );
4109
4137
  }
4110
4138
  }
4111
4139
  export {
4112
- we as Annotations,
4113
- Us as AssignmentStatus,
4114
- Ua as AvailabilityApi,
4115
- Wt as DATASET_DATA_URL,
4116
- Fa as DatasetApi,
4140
+ ge as Annotations,
4141
+ Qs as AssignmentStatus,
4142
+ Va as AvailabilityApi,
4143
+ Ft as DATASET_DATA_URL,
4144
+ Xa as DatasetApi,
4117
4145
  De as DimensionType,
4118
- St as DownloadType,
4119
- Va as FREQUENCY_DIMENSION_ID,
4120
- $a as FREQUENCY_DIM_ID,
4121
- Ct as FileColumnsAttribute,
4122
- Ht as GET_v3_FILTER_ALL,
4123
- Ha as GET_v3_FILTER_AND,
4124
- Ut as GET_v3_FILTER_OR,
4125
- bo as HierarchyApi,
4126
- zs as OBSERVATION_KEY,
4127
- Hs as OccurrenceType,
4128
- ws as Periods,
4129
- gs as RepresentationTextType,
4130
- hs as SDMX_DATA_QUERY_PARAMS,
4146
+ $t as DownloadType,
4147
+ Ka as FREQUENCY_DIMENSION_ID,
4148
+ Ha as FREQUENCY_DIM_ID,
4149
+ Lt as FileColumnsAttribute,
4150
+ Bt as GET_v3_FILTER_ALL,
4151
+ Ga as GET_v3_FILTER_AND,
4152
+ ot as GET_v3_FILTER_OR,
4153
+ Po as HierarchyApi,
4154
+ ta as OBSERVATION_KEY,
4155
+ Bs as OccurrenceType,
4156
+ bs as Periods,
4157
+ ys as RepresentationTextType,
4158
+ ps as SDMX_DATA_QUERY_PARAMS,
4131
4159
  oe as SINGLE_WILDCARD_SYMBOL,
4132
- Qa as SdmxApiClient,
4133
- rt as SdmxAvailabilityMode,
4134
- G as SdmxDataFormat,
4135
- st as SdmxDetails,
4160
+ ja as SdmxApiClient,
4161
+ st as SdmxAvailabilityMode,
4162
+ C as SdmxDataFormat,
4163
+ at as SdmxDetails,
4136
4164
  de as SdmxReferences,
4137
- k as SeriesFilterOperator,
4138
- ys as TIME_PERIOD,
4139
- bs as TIME_PERIOD_END_ANNOTATION_KEY,
4140
- ps as TIME_PERIOD_START_ANNOTATION_KEY,
4141
- ho as buildDatasetDimensionsMetadataMap,
4142
- ca as dailyPattern,
4143
- ea as decodeDimensionId,
4144
- za as findCodelistByDimension,
4165
+ _ as SeriesFilterOperator,
4166
+ Ds as TIME_PERIOD,
4167
+ Ts as TIME_PERIOD_END_ANNOTATION_KEY,
4168
+ Es as TIME_PERIOD_START_ANNOTATION_KEY,
4169
+ bo as buildDatasetDimensionsMetadataMap,
4170
+ ma as dailyPattern,
4171
+ aa as decodeDimensionId,
4172
+ to as findCodelistByDimension,
4145
4173
  Ye as generateDatasetDataRequest,
4146
4174
  ue as generateShortUrn,
4147
- mo as getAdditionalColumns,
4148
- Ga as getAnnotationPeriod,
4149
- pe as getArtifactByUrnWithWildCard,
4150
- Ka as getAttachedDimensionsSeriesByDimension,
4151
- $s as getAttachedDimensionsSeriesByTsId,
4152
- Et as getAttachedDimensionsSeriesKey,
4153
- Ws as getAttributeValueFromDataQueryResponse,
4154
- Ja as getAvailableCodes,
4155
- Xa as getAvailableCodesFromConstrains,
4156
- nt as getChildParsedUrn,
4157
- yo as getCodeListsData,
4175
+ yo as getAdditionalColumns,
4176
+ Ja as getAnnotationPeriod,
4177
+ ye as getArtifactByUrnWithWildCard,
4178
+ no as getAttachedDimensionsSeriesByDimension,
4179
+ Us as getAttachedDimensionsSeriesByTsId,
4180
+ xt as getAttachedDimensionsSeriesKey,
4181
+ Fs as getAttributeValueFromDataQueryResponse,
4182
+ ro as getAvailableCodes,
4183
+ Za as getAvailableCodesFromConstrains,
4184
+ rt as getChildParsedUrn,
4185
+ To as getCodeListsData,
4158
4186
  be as getConcept,
4159
4187
  je as getConceptByUrn,
4160
- Ss as getConceptWithScheme,
4161
- qs as getConvertedMetaAttributes,
4162
- la as getDailyRegExp,
4163
- Ca as getDaysColumns,
4164
- Za as getDimensionTitle,
4188
+ Ws as getConceptWithScheme,
4189
+ Hs as getConvertedMetaAttributes,
4190
+ ga as getDailyRegExp,
4191
+ qa as getDaysColumns,
4192
+ so as getDimensionTitle,
4165
4193
  ze as getDimensions,
4166
- ms as getFilteredItemsWithParents,
4167
- vs as getFiltersDtoFromDataQuery,
4168
- ja as getFiltersDtoMapFromDataQuery,
4169
- po as getHierarchyAvailableCodes,
4170
- wo as getHierarchyCodes,
4194
+ gs as getFilteredItemsWithParents,
4195
+ As as getFiltersDtoFromDataQuery,
4196
+ eo as getFiltersDtoMapFromDataQuery,
4197
+ xo as getHierarchyAvailableCodes,
4198
+ Eo as getHierarchyCodes,
4171
4199
  Z as getISOWeek,
4172
4200
  z as getKeyFromUrn,
4173
- Ba as getLastUpdatedTime,
4201
+ za as getLastUpdatedTime,
4174
4202
  Ke as getLastWeekNumberOfYear,
4175
- ye as getLocalizedName,
4176
- Na as getMonthlyData,
4177
- lo as getMonthlyDataByQuarter,
4203
+ pe as getLocalizedName,
4204
+ Ya as getMonthlyData,
4205
+ go as getMonthlyDataByQuarter,
4178
4206
  Oe as getMonthlyRegExp,
4179
- vt as getParsedEndPeriodDate,
4180
- co as getParsedResponse,
4181
- Pt as getParsedStartPeriodDate,
4182
- _ as getPeriodDate,
4183
- Sa as getPeriods,
4184
- uo as getQuarterByMonth,
4207
+ Ot as getParsedEndPeriodDate,
4208
+ ho as getParsedResponse,
4209
+ Mt as getParsedStartPeriodDate,
4210
+ k as getPeriodDate,
4211
+ Ua as getPeriods,
4212
+ wo as getQuarterByMonth,
4185
4213
  Ne as getQuarterlyRegExp,
4186
- va as getQuartersData,
4187
- Xs as getQueryTimePeriodFilters,
4188
- Lt as getRequestAcceptHeader,
4189
- _s as getResolvedVersionBySingleWildcard,
4190
- Ma as getSemiAnnualData,
4191
- da as getSemiAnnuallyRegExp,
4214
+ Ra as getQuartersData,
4215
+ Zs as getQueryTimePeriodFilters,
4216
+ Wt as getRequestAcceptHeader,
4217
+ Cs as getResolvedVersionBySingleWildcard,
4218
+ qt as getResponseContentType,
4219
+ _a as getSemiAnnualData,
4220
+ wa as getSemiAnnuallyRegExp,
4192
4221
  ie as getSeriesAttributes,
4193
- Ks as getSeriesName,
4194
- ro as getStructureComponentsMap,
4195
- eo as getStructureDimensions,
4196
- no as getTimeDimension,
4197
- to as getTimePeriods,
4198
- io as getTimeQueryFilter,
4199
- js as getTimeRangeFromAttachment,
4200
- so as getTimeSeriesCount,
4201
- oo as getTimeSeriesFilterKey,
4202
- Zs as getTimeSeriesId,
4203
- xt as getWeekCode,
4204
- Bs as getWeeklyPeriodEndDate,
4205
- Qs as getWeeklyPeriodStartDate,
4206
- ma as getWeeklyRegExp,
4207
- Ia as getWeeksColumns,
4208
- Ys as getWildCardPrefix,
4209
- Ot as getYearPeriod,
4222
+ na as getSeriesName,
4223
+ co as getStructureComponentsMap,
4224
+ ao as getStructureDimensions,
4225
+ io as getTimeDimension,
4226
+ oo as getTimePeriods,
4227
+ mo as getTimeQueryFilter,
4228
+ ea as getTimeRangeFromAttachment,
4229
+ uo as getTimeSeriesCount,
4230
+ fo as getTimeSeriesFilterKey,
4231
+ sa as getTimeSeriesId,
4232
+ Pt as getWeekCode,
4233
+ Xs as getWeeklyPeriodEndDate,
4234
+ Gs as getWeeklyPeriodStartDate,
4235
+ ya as getWeeklyRegExp,
4236
+ $a as getWeeksColumns,
4237
+ Ls as getWildCardPrefix,
4238
+ Nt as getYearPeriod,
4210
4239
  Pe as getYearlyRegExp,
4211
- Ra as getYears,
4212
- fa as isDaily,
4240
+ Ca as getYears,
4241
+ pa as isDaily,
4213
4242
  Ae as isMonthly,
4214
4243
  Re as isQuarterly,
4215
4244
  Me as isSemiAnnually,
4216
- ke as isWeekly,
4217
- Cs as isWildCardVersionCorrect,
4245
+ _e as isWeekly,
4246
+ $s as isWildCardVersionCorrect,
4218
4247
  ve as isYearly,
4219
- ua as monthlyPattern,
4220
- ao as openDownloadWindow,
4221
- sa as quarterPattern,
4222
- go as resolveCodelistsFromResponse,
4223
- oa as semiAnnuallyPattern,
4224
- fo as sortPeriods,
4225
- C as splitUrn,
4226
- qa as urnMatchesIgnoreVersion,
4227
- aa as weeklyPattern,
4228
- ia as yearlyPattern
4248
+ ha as monthlyPattern,
4249
+ lo as openDownloadWindow,
4250
+ ua as quarterPattern,
4251
+ Do as resolveCodelistsFromResponse,
4252
+ vt as sanitizeDownloadFilename,
4253
+ la as semiAnnuallyPattern,
4254
+ po as sortPeriods,
4255
+ S as splitUrn,
4256
+ Ba as urnMatchesIgnoreVersion,
4257
+ da as weeklyPattern,
4258
+ fa as yearlyPattern
4229
4259
  };