@epam/statgpt-sdmx-toolkit 0.4.0-rc.9 → 0.4.1

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