@epam/statgpt-sdmx-toolkit 0.2.0-rc.2 → 0.2.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +2 -2
  2. package/index.mjs +534 -544
  3. package/package.json +3 -3
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const N = (e) => {
1
+ const I = (e) => {
2
2
  if (e != null) {
3
3
  const t = e.split("=");
4
4
  return t.length === 1 ? e : t[1];
@@ -7,46 +7,36 @@ const N = (e) => {
7
7
  var r;
8
8
  if (e == null)
9
9
  return {};
10
- const t = N(e), n = {
10
+ const t = I(e), n = {
11
11
  agency: "",
12
12
  id: "",
13
13
  version: ""
14
- }, s = (o) => typeof o == "string" && /^[a-zA-Z0-9_.-]+$/.test(o);
15
- if (t) {
16
- if (t.includes(":")) {
17
- const o = t.split(":")[0], i = t.split(":")[1].split("(")[0];
18
- n.agency = s(o) ? o : "", n.id = s(i) ? i : "";
19
- }
20
- if (t.includes("(") && t.includes(")")) {
21
- const o = (r = t.split("(")[1]) == null ? void 0 : r.split(")")[0];
22
- n.version = s(o) ? o : "";
23
- }
24
- }
25
- return n;
26
- }, _e = (e) => {
27
- const [t, n] = e.split(")."), { agency: s, id: r, version: o } = p(t + ")");
28
- return { childId: n, agency: s, id: r, version: o };
29
- }, yn = (e, t, n) => {
30
- const s = t === "" ? "" : `(${t})`;
31
- return `${n}:${e}${s}`;
14
+ };
15
+ return t && (t.includes(":") && (n.agency = t.split(":")[0], n.id = t.split(":")[1].split("(")[0]), t.includes("(") && t.includes(")") && (n.version = (r = t.split("(")[1]) == null ? void 0 : r.split(")")[0])), n;
16
+ }, Pe = (e) => {
17
+ const [t, n] = e.split(")."), { agency: r, id: s, version: o } = p(t + ")");
18
+ return { childId: n, agency: r, id: s, version: o };
19
+ }, Sn = (e, t, n) => {
20
+ const r = t === "" ? "" : `(${t})`;
21
+ return `${n}:${e}${r}`;
32
22
  };
33
- var C = /* @__PURE__ */ ((e) => (e.DESCENDANTS = "descendants", e.NONE = "none", e.ALL = "all", e))(C || {}), Ae = /* @__PURE__ */ ((e) => (e.EXACT = "exact", e.AVAILABLE = "available", e))(Ae || {});
23
+ var k = /* @__PURE__ */ ((e) => (e.DESCENDANTS = "descendants", e.NONE = "none", e.ALL = "all", e))(k || {}), De = /* @__PURE__ */ ((e) => (e.EXACT = "exact", e.AVAILABLE = "available", e))(De || {});
34
24
  const Oe = (e = "", t = "", n = "") => `sdmx/3.0/availability/dataflow/${e}/${t}/${n}`;
35
- class Sn {
25
+ class Tn {
36
26
  constructor(t) {
37
27
  this.client = t;
38
28
  }
39
29
  async getConstraints(t, n) {
40
- const { agency: s, id: r, version: o } = p(t), i = {
30
+ const { agency: r, id: s, version: o } = p(t), i = {
41
31
  filters: n || [],
42
- mode: Ae.AVAILABLE,
43
- references: C.NONE
44
- }, c = Oe(s, r, o);
32
+ mode: De.AVAILABLE,
33
+ references: k.NONE
34
+ }, c = Oe(r, s, o);
45
35
  return await this.client.postRequest(c, { body: i });
46
36
  }
47
37
  }
48
- var $ = /* @__PURE__ */ ((e) => (e.CSV = "csv", e.JSON = "json", e.XML = "xml", e))($ || {}), Pe = /* @__PURE__ */ ((e) => (e.ID = "id", e.NAME = "name", e.ID_NAME = "both", e))(Pe || {}), Le = /* @__PURE__ */ ((e) => (e.FULL_DATASET = "full", e.DATA_IN_TABLE = "query", e))(Le || {});
49
- const be = (e, t) => {
38
+ var $ = /* @__PURE__ */ ((e) => (e.CSV = "csv", e.JSON = "json", e.XML = "xml", e))($ || {}), Le = /* @__PURE__ */ ((e) => (e.ID = "id", e.NAME = "name", e.ID_NAME = "both", e))(Le || {}), be = /* @__PURE__ */ ((e) => (e.FULL_DATASET = "full", e.DATA_IN_TABLE = "query", e))(be || {});
39
+ const Ue = (e, t) => {
50
40
  switch (e) {
51
41
  case $.CSV:
52
42
  return m(
@@ -67,32 +57,32 @@ const be = (e, t) => {
67
57
  );
68
58
  }
69
59
  }, m = (e, t) => `${e}; labels=${t}`;
70
- var De = /* @__PURE__ */ ((e) => (e.REFERENCE_PARTIAL = "referencepartial", e.FULL = "full", e))(De || {});
71
- const Ue = "all", xe = "sdmx/3.0/data/dataflow", ye = "&", ne = ":", Ye = "=", We = "+", Tn = ",", Ce = "*", se = (e, t, n) => {
72
- const { filterKey: s, timeFilter: r } = n, { agency: o, id: i, version: c } = p(e), a = [r || "", t].filter((l) => !!l).join(ye);
73
- return `${`${xe}/${o}/${i}/${c}`}/${s || Ce}?${a}`;
74
- }, ke = (e = "", t = "", n = "", s = C.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${e}/${t}/${n}?references=${s}&detail=${De.REFERENCE_PARTIAL}`;
60
+ var ye = /* @__PURE__ */ ((e) => (e.REFERENCE_PARTIAL = "referencepartial", e.FULL = "full", e))(ye || {});
61
+ const xe = "all", Ye = "sdmx/3.0/data/dataflow", Se = "&", re = ":", Ce = "=", We = "+", Rn = ",", ke = "*", se = (e, t, n) => {
62
+ const { filterKey: r, timeFilter: s } = n, { agency: o, id: i, version: c } = p(e), a = [s || "", t].filter((l) => !!l).join(Se);
63
+ return `${`${Ye}/${o}/${i}/${c}`}/${r || ke}?${a}`;
64
+ }, qe = (e = "", t = "", n = "", r = k.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${e}/${t}/${n}?references=${r}&detail=${ye.REFERENCE_PARTIAL}`;
75
65
  class wn {
76
66
  constructor(t) {
77
67
  this.client = t;
78
68
  }
79
69
  async getDataSet(t, n) {
80
- const { agency: s, id: r, version: o } = p(t);
70
+ const { agency: r, id: s, version: o } = p(t);
81
71
  return await this.client.getRequest(
82
- ke(s, r, o, n)
72
+ qe(r, s, o, n)
83
73
  );
84
74
  }
85
75
  async getDatasetData(t, n) {
86
- const s = new URLSearchParams({
76
+ const r = new URLSearchParams({
87
77
  includeHistory: "false",
88
78
  limit: "1000",
89
- attributes: Ue,
79
+ attributes: xe,
90
80
  dimensionAtObservation: "TIME_PERIOD"
91
81
  // TODO: use time dimensions
92
- }).toString(), r = se(t, s, n);
93
- return await this.client.getRequest(r);
82
+ }).toString(), s = se(t, r, n);
83
+ return await this.client.getRequest(s);
94
84
  }
95
- async downloadDataSet(t, n, s, r, o, i, c = !1) {
85
+ async downloadDataSet(t, n, r, s, o, i, c = !1) {
96
86
  const a = new URLSearchParams({
97
87
  format: n,
98
88
  compress: "false",
@@ -104,54 +94,54 @@ class wn {
104
94
  {
105
95
  method: "GET",
106
96
  headers: {
107
- Accept: be(n, r),
108
- "Accept-language": s
97
+ Accept: Ue(n, s),
98
+ "Accept-language": r
109
99
  }
110
100
  },
111
101
  i
112
102
  );
113
103
  }
114
104
  }
115
- const qe = (e, t) => e.error || e.message || `${t.status} ${t.statusText}`, Me = "application/json", Qe = "Content-Type", U = "Api-Key", Be = "X-CONVERSATION-ID", v = (e) => isNaN(Date.parse(e)) ? null : new Date(e), x = (e, t, n) => {
116
- const s = {
117
- [Qe]: (t == null ? void 0 : t.contentType) || Me
105
+ const Me = (e, t) => e.error || e.message || `${t.status} ${t.statusText}`, Qe = "application/json", Be = "Content-Type", x = "Api-Key", Ve = "X-CONVERSATION-ID", N = "Ocp-Apim-Subscription-Key", v = (e) => isNaN(Date.parse(e)) ? null : new Date(e), Y = (e, t, n) => {
106
+ const r = {
107
+ [Be]: (t == null ? void 0 : t.contentType) || Qe
118
108
  };
119
- return t != null && t.jwt && (s.Authorization = `Bearer ${t.jwt}`), t != null && t.chatReference && (s[Be] = t.chatReference), { ...s, ...n };
120
- }, Ve = (e) => {
109
+ return t != null && t.jwt && (r.Authorization = `Bearer ${t.jwt}`), t != null && t.chatReference && (r[Ve] = t.chatReference), { ...r, ...n };
110
+ }, Fe = (e) => {
121
111
  const t = { ...e };
122
- return t[U] && (t[U] = t[U].substring(0, 8) + "...[REDACTED]"), t.Authorization && (t.Authorization = "Bearer [REDACTED]"), t;
123
- }, re = async (e, t, n) => await fetch(e, {
112
+ return t[x] && (t[x] = t[x].substring(0, 8) + "...[REDACTED]"), t.Authorization && (t.Authorization = "Bearer [REDACTED]"), t[N] && (t[N] = t[N].substring(0, 8) + "...[REDACTED]"), t;
113
+ }, oe = async (e, t, n) => await fetch(e, {
124
114
  method: n.method || "GET",
125
115
  headers: t,
126
116
  body: n.body ? JSON.stringify(n.body) : void 0
127
- }), Fe = async (e, t, n) => await fetch(e, {
117
+ }), Ge = async (e, t, n) => await fetch(e, {
128
118
  method: n.method,
129
119
  headers: t,
130
120
  body: n != null && n.isFormData && typeof (n == null ? void 0 : n.body) == "string" ? n.body : JSON.stringify(n.body),
131
121
  signal: n == null ? void 0 : n.signal
132
122
  });
133
- class Ge {
123
+ class Ke {
134
124
  constructor() {
135
125
  this.decoder = new TextDecoder();
136
126
  }
137
- async streamChat(t, n, s = {}, r) {
138
- const { onMessage: o, onError: i, onComplete: c, signal: a } = s;
127
+ async streamChat(t, n, r = {}, s) {
128
+ const { onMessage: o, onError: i, onComplete: c, signal: a } = r;
139
129
  try {
140
130
  const u = await this.initializeStreamRequest(
141
131
  t,
142
132
  n,
143
133
  a,
144
- r
134
+ s
145
135
  );
146
136
  await this.processStreamData(u, o), c == null || c();
147
137
  } catch (u) {
148
138
  this.handleStreamError(u, i);
149
139
  }
150
140
  }
151
- async initializeStreamRequest(t, n, s, r) {
152
- const o = x(void 0, {
153
- jwt: r
154
- }), i = await Fe(
141
+ async initializeStreamRequest(t, n, r, s) {
142
+ const o = Y(void 0, {
143
+ jwt: s
144
+ }), i = await Ge(
155
145
  t,
156
146
  {
157
147
  Accept: "text/event-stream",
@@ -160,7 +150,7 @@ class Ge {
160
150
  {
161
151
  method: "POST",
162
152
  body: n,
163
- signal: s
153
+ signal: r
164
154
  }
165
155
  );
166
156
  if (!i.ok) {
@@ -174,19 +164,19 @@ class Ge {
174
164
  return i.body.getReader();
175
165
  }
176
166
  async processStreamData(t, n) {
177
- let s = "";
167
+ let r = "";
178
168
  try {
179
169
  for (; ; ) {
180
- const { done: r, value: o } = await t.read();
181
- if (r) {
182
- s.trim() && this.parseSSEDataLine(s, n);
170
+ const { done: s, value: o } = await t.read();
171
+ if (s) {
172
+ r.trim() && this.parseSSEDataLine(r, n);
183
173
  break;
184
174
  }
185
175
  const i = this.decoder.decode(o, { stream: !0 });
186
- s += i;
187
- const c = s.split(`
176
+ r += i;
177
+ const c = r.split(`
188
178
  `);
189
- s = c.pop() || "";
179
+ r = c.pop() || "";
190
180
  for (const a of c)
191
181
  this.parseSSEDataLine(a, n);
192
182
  }
@@ -195,28 +185,28 @@ class Ge {
195
185
  }
196
186
  }
197
187
  handleStreamError(t, n) {
198
- const s = t instanceof Error ? t : new Error(String(t));
199
- throw n == null || n(s), s;
188
+ const r = t instanceof Error ? t : new Error(String(t));
189
+ throw n == null || n(r), r;
200
190
  }
201
191
  parseSSEDataLine(t, n) {
202
- const s = t.trim();
203
- if (!(!s || s.startsWith(":")) && s.startsWith("data: ")) {
204
- const r = s.slice(6);
205
- if (r === "[DONE]") {
192
+ const r = t.trim();
193
+ if (!(!r || r.startsWith(":")) && r.startsWith("data: ")) {
194
+ const s = r.slice(6);
195
+ if (s === "[DONE]") {
206
196
  console.info("SSE: Stream completed");
207
197
  return;
208
198
  }
209
199
  try {
210
- const o = JSON.parse(r);
200
+ const o = JSON.parse(s);
211
201
  n == null || n(o);
212
202
  } catch (o) {
213
- console.error(`Failed to parse SSE data: ${r} ${o}`);
203
+ console.error(`Failed to parse SSE data: ${s} ${o}`);
214
204
  }
215
205
  }
216
206
  }
217
207
  }
218
- new Ge();
219
- class Rn {
208
+ new Ke();
209
+ class pn {
220
210
  constructor(t) {
221
211
  this.config = t, console.info("SdmxApiClient initialized", {
222
212
  apiUrl: t.apiUrl || "NOT SET"
@@ -228,19 +218,19 @@ class Rn {
228
218
  async postRequest(t, n) {
229
219
  return this.request(t, { ...n, method: "POST" });
230
220
  }
231
- async streamRequest(t, n, s) {
232
- const r = `${this.config.apiUrl}/${t}`, o = {
233
- ...x(void 0, {
221
+ async streamRequest(t, n, r) {
222
+ const s = `${this.config.apiUrl}/${t}`, o = {
223
+ ...Y(void 0, {
234
224
  jwt: this.config.jwt
235
225
  }),
236
226
  ...n.headers
237
227
  };
238
- this.config.apiKey != null && (o["Ocp-Apim-Subscription-Key"] = this.config.apiKey);
228
+ this.config.apiKey != null && (o[N] = this.config.apiKey);
239
229
  const i = new ReadableStream({
240
230
  async start(a) {
241
231
  var u;
242
232
  try {
243
- const l = await re(r, o, n);
233
+ const l = await oe(s, o, n);
244
234
  if (!l.ok) {
245
235
  const g = await l.text();
246
236
  throw console.error(
@@ -249,11 +239,11 @@ class Rn {
249
239
  }
250
240
  const f = (u = l.body) == null ? void 0 : u.getReader();
251
241
  if (!f) throw new Error("Failed to create stream reader");
252
- const h = new Uint8Array([239, 187, 191]);
253
- a.enqueue(h);
242
+ const E = new Uint8Array([239, 187, 191]);
243
+ a.enqueue(E);
254
244
  const d = async () => {
255
- const { done: g, value: E } = await f.read();
256
- g ? a.close() : (a.enqueue(E), await d());
245
+ const { done: g, value: h } = await f.read();
246
+ g ? a.close() : (a.enqueue(h), await d());
257
247
  };
258
248
  d();
259
249
  } catch (l) {
@@ -261,27 +251,27 @@ class Rn {
261
251
  }
262
252
  }
263
253
  }), c = new Headers({
264
- "Content-Disposition": `attachment; filename=${encodeURIComponent(s)}`
254
+ "Content-Disposition": `attachment; filename=${encodeURIComponent(r)}`
265
255
  });
266
256
  return new Response(i, { headers: c });
267
257
  }
268
258
  async request(t, n) {
269
- const s = Date.now(), r = t.includes("availability") && this.config.constrainsApiUrl ? `${this.config.constrainsApiUrl}/${t}` : `${this.config.apiUrl}/${t}`, o = {
270
- ...x(void 0, {
259
+ const r = Date.now(), s = t.includes("availability") && this.config.constrainsApiUrl ? `${this.config.constrainsApiUrl}/${t}` : `${this.config.apiUrl}/${t}`, o = {
260
+ ...Y(void 0, {
271
261
  jwt: this.config.jwt
272
262
  }),
273
263
  ...n.headers
274
264
  };
275
- this.config.apiKey != null && (o["Ocp-Apim-Subscription-Key"] = this.config.apiKey), this.addInfoRequestLog("API Request", r, n, o);
265
+ this.config.apiKey != null && (o["Ocp-Apim-Subscription-Key"] = this.config.apiKey), this.addInfoRequestLog("API Request", s, n, o);
276
266
  try {
277
- const i = await re(r, o, n), c = Date.now() - s;
267
+ const i = await oe(s, o, n), c = Date.now() - r;
278
268
  let a;
279
269
  const u = await i.text();
280
270
  try {
281
271
  a = u ? JSON.parse(u) : {};
282
272
  } catch {
283
273
  if (this.addErrorRequestParsing(
284
- r,
274
+ s,
285
275
  n,
286
276
  i,
287
277
  c,
@@ -293,99 +283,99 @@ class Rn {
293
283
  a = { data: u };
294
284
  }
295
285
  if (!i.ok) {
296
- this.addErrorRequestLog(r, n, i, c, a);
297
- const l = qe(a, i);
286
+ this.addErrorRequestLog(s, n, i, c, a);
287
+ const l = Me(a, i);
298
288
  throw new Error(`API request failed: ${l}`);
299
289
  }
300
290
  return a;
301
291
  } catch (i) {
302
- const c = Date.now() - s;
292
+ const c = Date.now() - r;
303
293
  throw console.error("API Request Exception", {
304
294
  method: n.method,
305
- url: r,
295
+ url: s,
306
296
  duration: `${c}ms`,
307
297
  error: i instanceof Error ? i.message : String(i)
308
298
  }), i;
309
299
  }
310
300
  }
311
- addInfoRequestLog(t, n, s, r) {
301
+ addInfoRequestLog(t, n, r, s) {
312
302
  const o = {
313
- method: s.method || "GET",
303
+ method: r.method || "GET",
314
304
  url: n,
315
- headers: Ve(r)
305
+ headers: Fe(s)
316
306
  };
317
- s.body && (o.body = s.body), console.info(t, o);
307
+ r.body && (o.body = r.body), console.info(t, o);
318
308
  }
319
- addErrorRequestLog(t, n, s, r, o) {
309
+ addErrorRequestLog(t, n, r, s, o) {
320
310
  console.error("API Request Failed", {
321
311
  method: n.method,
322
312
  url: t,
323
- status: s.status,
324
- statusText: s.statusText,
325
- duration: `${r}ms`,
313
+ status: r.status,
314
+ statusText: r.statusText,
315
+ duration: `${s}ms`,
326
316
  response: o
327
317
  });
328
318
  }
329
- addErrorRequestParsing(t, n, s, r, o) {
319
+ addErrorRequestParsing(t, n, r, s, o) {
330
320
  console.error("API Response Parse Error", {
331
321
  method: n.method,
332
322
  url: t,
333
- status: s.status,
334
- statusText: s.statusText,
335
- duration: `${r}ms`,
323
+ status: r.status,
324
+ statusText: r.statusText,
325
+ duration: `${s}ms`,
336
326
  responseText: o.substring(0, 200),
337
327
  error: "Response is not valid JSON"
338
328
  });
339
329
  }
340
330
  }
341
- const pn = ["FREQ", "FREQUENCY"];
342
- var Ke = /* @__PURE__ */ ((e) => (e.CONDITIONAL = "Conditional", e.MANDATORY = "Mandatory", e))(Ke || {}), k = /* @__PURE__ */ ((e) => (e.DIMENSION = "Dimension", e.MEASURE_DIMENSION = "MeasureDimension", e.TIME_DIMENSION = "TimeDimension", e))(k || {}), je = /* @__PURE__ */ ((e) => (e.UNBOUNDED = "unbounded", e))(je || {});
343
- const ze = (e, t) => {
331
+ const mn = ["FREQ", "FREQUENCY"];
332
+ var je = /* @__PURE__ */ ((e) => (e.CONDITIONAL = "Conditional", e.MANDATORY = "Mandatory", e))(je || {}), q = /* @__PURE__ */ ((e) => (e.DIMENSION = "Dimension", e.MEASURE_DIMENSION = "MeasureDimension", e.TIME_DIMENSION = "TimeDimension", e))(q || {}), ze = /* @__PURE__ */ ((e) => (e.UNBOUNDED = "unbounded", e))(ze || {});
333
+ const He = (e, t) => {
344
334
  var c, a, u, l, f;
345
- const n = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.dataSets) == null ? void 0 : a[0], s = (l = (u = e == null ? void 0 : e.data) == null ? void 0 : u.structures) == null ? void 0 : l[0], r = ((f = s == null ? void 0 : s.attributes) == null ? void 0 : f.dimensionGroup) || [], o = n == null ? void 0 : n.dimensionGroupAttributes, i = {};
346
- for (const h of r) {
347
- const d = h.relationship.dimensions, { codedSeriesKey: g, decodedSeriesKey: E } = Se(
335
+ const n = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.dataSets) == null ? void 0 : a[0], r = (l = (u = e == null ? void 0 : e.data) == null ? void 0 : u.structures) == null ? void 0 : l[0], s = ((f = r == null ? void 0 : r.attributes) == null ? void 0 : f.dimensionGroup) || [], o = n == null ? void 0 : n.dimensionGroupAttributes, i = {};
336
+ for (const E of s) {
337
+ const d = E.relationship.dimensions, { codedSeriesKey: g, decodedSeriesKey: h } = Te(
348
338
  e,
349
339
  t,
350
340
  d
351
341
  );
352
- i[h.id] = {
342
+ i[E.id] = {
353
343
  values: (o == null ? void 0 : o[g]) || [],
354
- decodedSeriesKey: E,
344
+ decodedSeriesKey: h,
355
345
  codedSeriesKey: g
356
346
  };
357
347
  }
358
348
  return i;
359
- }, Se = (e, t, n) => {
349
+ }, Te = (e, t, n) => {
360
350
  var c, a;
361
- const s = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.structures) == null ? void 0 : a[0], r = [
362
- ...(s == null ? void 0 : s.dimensions.series) || [],
363
- ...(s == null ? void 0 : s.dimensions.observation) || []
364
- ], o = new Array(r == null ? void 0 : r.length), i = new Array(r == null ? void 0 : r.length);
351
+ const r = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.structures) == null ? void 0 : a[0], s = [
352
+ ...(r == null ? void 0 : r.dimensions.series) || [],
353
+ ...(r == null ? void 0 : r.dimensions.observation) || []
354
+ ], o = new Array(s == null ? void 0 : s.length), i = new Array(s == null ? void 0 : s.length);
365
355
  return n == null || n.forEach((u) => {
366
- const l = (r == null ? void 0 : r.findIndex((d) => d.id === u)) || 0, f = t[l], h = r[l].values.findIndex(
356
+ const l = (s == null ? void 0 : s.findIndex((d) => d.id === u)) || 0, f = t[l], E = s[l].values.findIndex(
367
357
  (d) => d.id === f || d.value === f
368
358
  ) || 0;
369
- o[l] = h >= 0 ? h : f, i[l] = f;
359
+ o[l] = E >= 0 ? E : f, i[l] = f;
370
360
  }), {
371
361
  codedSeriesKey: o.join(":"),
372
362
  decodedSeriesKey: i.join(":")
373
363
  };
374
- }, mn = (e, t, n) => {
375
- var f, h, d, g, E;
376
- const s = (h = (f = e == null ? void 0 : e.data) == null ? void 0 : f.dataSets) == null ? void 0 : h[0], r = (g = (d = e == null ? void 0 : e.data) == null ? void 0 : d.structures) == null ? void 0 : g[0], o = (((E = r == null ? void 0 : r.attributes) == null ? void 0 : E.dimensionGroup) || []).filter(
364
+ }, vn = (e, t, n) => {
365
+ var f, E, d, g, h;
366
+ const r = (E = (f = e == null ? void 0 : e.data) == null ? void 0 : f.dataSets) == null ? void 0 : E[0], s = (g = (d = e == null ? void 0 : e.data) == null ? void 0 : d.structures) == null ? void 0 : g[0], o = (((h = s == null ? void 0 : s.attributes) == null ? void 0 : h.dimensionGroup) || []).filter(
377
367
  (D) => {
378
368
  var A;
379
369
  return ((A = D.relationship.dimensions) == null ? void 0 : A.length) === 1 && D.relationship.dimensions.includes(t || "");
380
370
  }
381
- ), i = s == null ? void 0 : s.dimensionGroupAttributes, c = [
382
- ...(r == null ? void 0 : r.dimensions.series) || [],
383
- ...(r == null ? void 0 : r.dimensions.observation) || []
371
+ ), i = r == null ? void 0 : r.dimensionGroupAttributes, c = [
372
+ ...(s == null ? void 0 : s.dimensions.series) || [],
373
+ ...(s == null ? void 0 : s.dimensions.observation) || []
384
374
  ], a = c == null ? void 0 : c.findIndex((D) => D.id === t), u = new Array(c == null ? void 0 : c.length);
385
375
  u[a] = n || "";
386
376
  const l = {};
387
377
  for (const D of o) {
388
- const A = D.relationship.dimensions, { codedSeriesKey: y, decodedSeriesKey: S } = Se(
378
+ const A = D.relationship.dimensions, { codedSeriesKey: y, decodedSeriesKey: S } = Te(
389
379
  e,
390
380
  u,
391
381
  A
@@ -397,23 +387,23 @@ const ze = (e, t) => {
397
387
  };
398
388
  }
399
389
  return l;
400
- }, He = (e, t) => {
401
- var s;
390
+ }, Je = (e, t) => {
391
+ var r;
402
392
  if (t == null)
403
393
  return;
404
- const n = (s = e.values) == null ? void 0 : s[t];
394
+ const n = (r = e.values) == null ? void 0 : r[t];
405
395
  return n ?? (t instanceof Array ? { values: t } : { value: t.toString() });
406
- }, Je = "Observation", vn = (e) => {
407
- var u, l, f, h, d, g;
396
+ }, Xe = "Observation", $n = (e) => {
397
+ var u, l, f, E, d, g;
408
398
  const t = (u = e == null ? void 0 : e.data) == null ? void 0 : u.dataSets, n = (f = (l = e == null ? void 0 : e.data) == null ? void 0 : l.structures) == null ? void 0 : f[0];
409
399
  if (!t || !n)
410
400
  return [];
411
- const s = n.attributes, r = n.dimensions, o = (s == null ? void 0 : s.dimensionGroup) || [], i = t[0].series || t[0].observations, c = (h = r.series) != null && h.length ? r.series : r.observation, a = [];
412
- for (const E in i) {
413
- const D = [], { name: A, parsedTimeSeriesValue: y } = Xe(
414
- E,
401
+ const r = n.attributes, s = n.dimensions, o = (r == null ? void 0 : r.dimensionGroup) || [], i = t[0].series || t[0].observations, c = (E = s.series) != null && E.length ? s.series : s.observation, a = [];
402
+ for (const h in i) {
403
+ const D = [], { name: A, parsedTimeSeriesValue: y } = Ze(
404
+ h,
415
405
  c
416
- ), S = i[E], _ = S.attributes || [];
406
+ ), S = i[h], P = S.attributes || [];
417
407
  if (Object.keys(S).length === 0) {
418
408
  a.push({
419
409
  name: A,
@@ -425,26 +415,26 @@ const ze = (e, t) => {
425
415
  continue;
426
416
  }
427
417
  D.push(
428
- ...nt(S, n)
418
+ ...rt(S, n)
429
419
  );
430
- const O = Y(
431
- (s == null ? void 0 : s.series) || [],
432
- (T) => _[T]
433
- ), P = st(
420
+ const O = C(
421
+ (r == null ? void 0 : r.series) || [],
422
+ (T) => P[T]
423
+ ), L = st(
434
424
  ((d = n.attributes) == null ? void 0 : d.dataSet) || [],
435
425
  ((g = t[0].attributes) == null ? void 0 : g.filter((T) => T != null)) || []
436
- ), L = ze(
426
+ ), b = He(
437
427
  e,
438
428
  y
439
- ), b = o.map((T, Ne) => {
440
- const te = L[T.id], Ie = He(
429
+ ), U = o.map((T, Ie) => {
430
+ const ne = b[T.id], _e = Je(
441
431
  T,
442
- te.values[Ne]
432
+ ne.values[Ie]
443
433
  );
444
434
  return {
445
435
  attribute: T,
446
- dimensionGroupValue: Ie,
447
- dimensionGroupData: te
436
+ dimensionGroupValue: _e,
437
+ dimensionGroupData: ne
448
438
  };
449
439
  });
450
440
  a.push({
@@ -452,145 +442,145 @@ const ze = (e, t) => {
452
442
  parsedTimeSeriesValue: y,
453
443
  values: D,
454
444
  attributes: O,
455
- dataSetAttrs: P,
456
- dimensionGroupAttributes: b
445
+ dataSetAttrs: L,
446
+ dimensionGroupAttributes: U
457
447
  });
458
448
  }
459
449
  return a;
460
- }, Xe = (e, t) => {
461
- const n = e.split(new RegExp("(?<!\\|):(?!\\||$)")), s = [];
462
- for (let r = 0; r < n.length; r++) {
463
- const o = t == null ? void 0 : t[r], i = Number(n[r]);
450
+ }, Ze = (e, t) => {
451
+ const n = e.split(new RegExp("(?<!\\|):(?!\\||$)")), r = [];
452
+ for (let s = 0; s < n.length; s++) {
453
+ const o = t == null ? void 0 : t[s], i = Number(n[s]);
464
454
  if (i < 0 || o == null)
465
455
  continue;
466
456
  const c = o.values[i];
467
457
  if (c == null) {
468
- s.push(n[r].replace("|:", ":"));
458
+ r.push(n[s].replace("|:", ":"));
469
459
  continue;
470
460
  }
471
- s.push((c == null ? void 0 : c.id) || (c == null ? void 0 : c.value) || "");
461
+ r.push((c == null ? void 0 : c.id) || (c == null ? void 0 : c.value) || "");
472
462
  }
473
463
  return {
474
- name: et(s),
475
- parsedTimeSeriesValue: s
464
+ name: tt(r),
465
+ parsedTimeSeriesValue: r
476
466
  };
477
- }, Y = (e, t) => {
467
+ }, C = (e, t) => {
478
468
  const n = [];
479
- for (let s = 0; s < e.length; s++) {
480
- const r = e[s], o = t(s), i = o != null && r.values != null ? Ze(o, r) : void 0;
469
+ for (let r = 0; r < e.length; r++) {
470
+ const s = e[r], o = t(r), i = o != null && s.values != null ? et(o, s) : void 0;
481
471
  n.push({
482
- name: r.id,
472
+ name: s.id,
483
473
  value: i
484
474
  });
485
475
  }
486
476
  return n;
487
- }, Ze = (e, t) => {
477
+ }, et = (e, t) => {
488
478
  const n = t.values[e];
489
479
  return n == null ? typeof e == "object" ? e : e.toString() : (n == null ? void 0 : n.id) || (n == null ? void 0 : n.value) || (n == null ? void 0 : n.ids) || (n == null ? void 0 : n.values);
490
- }, et = (e) => e.map((t) => t ? tt(t) : "").join("."), tt = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), nt = (e, t) => {
480
+ }, tt = (e) => e.map((t) => t ? nt(t) : "").join("."), nt = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), rt = (e, t) => {
491
481
  var i, c, a, u, l;
492
482
  const n = (c = (i = t.measures) == null ? void 0 : i.observation) == null ? void 0 : c.length;
493
483
  if (e.observations == null)
494
484
  return [
495
485
  {
496
- values: oe(e, t.measures),
497
- obsAttributes: Y(
486
+ values: ie(e, t.measures),
487
+ obsAttributes: C(
498
488
  ((a = t.attributes) == null ? void 0 : a.observation) || [],
499
489
  (f) => e[f + n]
500
490
  ),
501
- dimensionAtObservation: Je
491
+ dimensionAtObservation: Xe
502
492
  }
503
493
  ];
504
- const s = e.observations, r = (u = t.dimensions.observation) == null ? void 0 : u[0], o = [];
505
- for (const f in s) {
506
- const h = r == null ? void 0 : r.values[f];
494
+ const r = e.observations, s = (u = t.dimensions.observation) == null ? void 0 : u[0], o = [];
495
+ for (const f in r) {
496
+ const E = s == null ? void 0 : s.values[f];
507
497
  o.push({
508
- dimensionAtObservation: (h == null ? void 0 : h.value) || (h == null ? void 0 : h.id),
509
- values: oe(
510
- s[f],
498
+ dimensionAtObservation: (E == null ? void 0 : E.value) || (E == null ? void 0 : E.id),
499
+ values: ie(
500
+ r[f],
511
501
  t.measures
512
502
  ),
513
- obsAttributes: Y(
503
+ obsAttributes: C(
514
504
  ((l = t.attributes) == null ? void 0 : l.observation) || [],
515
- (d) => s[f][d + n]
505
+ (d) => r[f][d + n]
516
506
  )
517
507
  });
518
508
  }
519
509
  return o;
520
- }, oe = (e, t) => {
510
+ }, ie = (e, t) => {
521
511
  var n;
522
- return ((n = t == null ? void 0 : t.observation) == null ? void 0 : n.map((s, r) => ({ name: s.id, value: e[r] }))) || [];
512
+ return ((n = t == null ? void 0 : t.observation) == null ? void 0 : n.map((r, s) => ({ name: r.id, value: e[s] }))) || [];
523
513
  }, st = (e, t) => e.reduce(
524
- (n, s, r) => {
525
- const o = t[r];
526
- return rt(n, s, o, ""), n;
514
+ (n, r, s) => {
515
+ const o = t[s];
516
+ return ot(n, r, o, ""), n;
527
517
  },
528
518
  []
529
- ), rt = (e, t, n, s) => {
519
+ ), ot = (e, t, n, r) => {
530
520
  var o, i, c;
531
- const r = n != null ? ((o = t == null ? void 0 : t.values) == null ? void 0 : o.length) > 0 ? ((i = t.values[n]) == null ? void 0 : i.id) || ((c = t.values[n]) == null ? void 0 : c.value) : String(n) : s;
521
+ const s = n != null ? ((o = t == null ? void 0 : t.values) == null ? void 0 : o.length) > 0 ? ((i = t.values[n]) == null ? void 0 : i.id) || ((c = t.values[n]) == null ? void 0 : c.value) : String(n) : r;
532
522
  e.push({
533
523
  name: t.id,
534
- value: r || ""
524
+ value: s || ""
535
525
  });
536
- }, ot = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, it = /^[0-9][0-9][0-9][0-9]-W[0-9][0-9]?$/, ct = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, at = /^[0-9][0-9][0-9][0-9]$/, ut = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, lt = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, q = (e) => at.exec(e), M = (e) => !!q(e), dt = (e) => ct.exec(e), Q = (e) => !!dt(e), B = (e) => lt.exec(e), V = (e) => !!B(e), F = (e) => ot.exec(e), G = (e) => !!F(e), ft = (e) => ut.exec(e), gt = (e) => !!ft(e), ht = (e) => it.exec(e), K = (e) => !!ht(e), j = 1440 * 60 * 1e3, z = 7 * j;
537
- function H(e) {
526
+ }, it = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, ct = /^[0-9][0-9][0-9][0-9]-W[0-9][0-9]?$/, at = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, ut = /^[0-9][0-9][0-9][0-9]$/, lt = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, dt = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, M = (e) => ut.exec(e), Q = (e) => !!M(e), ft = (e) => at.exec(e), B = (e) => !!ft(e), V = (e) => dt.exec(e), F = (e) => !!V(e), G = (e) => it.exec(e), K = (e) => !!G(e), gt = (e) => lt.exec(e), Et = (e) => !!gt(e), ht = (e) => ct.exec(e), j = (e) => !!ht(e), z = 1440 * 60 * 1e3, H = 7 * z;
527
+ function J(e) {
538
528
  const t = `${e}-01-01`, n = new Date(t);
539
529
  if (n.getDay() !== 4) {
540
- const r = 1 + (4 - n.getDay() + 7) % 7;
541
- n.setMonth(0, r);
530
+ const s = 1 + (4 - n.getDay() + 7) % 7;
531
+ n.setMonth(0, s);
542
532
  }
543
533
  return n;
544
534
  }
545
- function Et(e) {
546
- const t = new Date(e), s = -((t.getDay() + 6) % 7) + 3;
547
- return t.setDate(t.getDate() + s), new Date(t.valueOf());
535
+ function At(e) {
536
+ const t = new Date(e), r = -((t.getDay() + 6) % 7) + 3;
537
+ return t.setDate(t.getDate() + r), new Date(t.valueOf());
548
538
  }
549
- function ie(e, t = "W") {
550
- const n = `${e}-12-31`, s = I(new Date(n), t);
551
- if (s.weekYear === e)
552
- return s.weekNumber;
553
- const r = `${e}-12-24`;
554
- return I(new Date(r), t).weekNumber;
539
+ function ce(e, t = "W") {
540
+ const n = `${e}-12-31`, r = _(new Date(n), t);
541
+ if (r.weekYear === e)
542
+ return r.weekNumber;
543
+ const s = `${e}-12-24`;
544
+ return _(new Date(s), t).weekNumber;
555
545
  }
556
- function Te(e, t, n = "W") {
546
+ function Re(e, t, n = "W") {
557
547
  return `${e}-${n}${t < 10 ? "0" + t : t}`;
558
548
  }
559
- function I(e, t = "W") {
560
- const n = Et(e), s = n.getFullYear(), r = H(s), o = 1 + Math.ceil(
561
- (n.getTime() - r.getTime()) / z
549
+ function _(e, t = "W") {
550
+ const n = At(e), r = n.getFullYear(), s = J(r), o = 1 + Math.ceil(
551
+ (n.getTime() - s.getTime()) / H
562
552
  );
563
553
  return {
564
- code: Te(s, o, t),
554
+ code: Re(r, o, t),
565
555
  weekNumber: o,
566
- weekYear: s
556
+ weekYear: r
567
557
  };
568
558
  }
569
- function At(e) {
570
- const [t, n] = e.split("-W"), r = H(+t).getTime() + (+n - 1) * z - 3 * j;
571
- return new Date(r);
572
- }
573
559
  function Dt(e) {
574
- const [t, n] = e.split("-W"), r = H(+t).getTime() + (+n - 1) * z + 3 * j;
575
- return new Date(r);
560
+ const [t, n] = e.split("-W"), s = J(+t).getTime() + (+n - 1) * H - 3 * z;
561
+ return new Date(s);
562
+ }
563
+ function yt(e) {
564
+ const [t, n] = e.split("-W"), s = J(+t).getTime() + (+n - 1) * H + 3 * z;
565
+ return new Date(s);
576
566
  }
577
567
  function we(e) {
578
- return M(e) ? yt(e) : Q(e) ? Tt(e) : G(e) ? Rt(e) : V(e) ? mt(e) : K(e) ? At(e) : $t(e);
568
+ return Q(e) ? St(e) : B(e) ? Rt(e) : K(e) ? pt(e) : F(e) ? vt(e) : j(e) ? Dt(e) : Nt(e);
579
569
  }
580
- function Re(e) {
581
- return M(e) ? St(e) : Q(e) ? wt(e) : G(e) ? pt(e) : V(e) ? vt(e) : K(e) ? Dt(e) : Nt(e);
570
+ function pe(e) {
571
+ return Q(e) ? Tt(e) : B(e) ? wt(e) : K(e) ? mt(e) : F(e) ? $t(e) : j(e) ? yt(e) : It(e);
582
572
  }
583
- function yt(e) {
584
- const t = q(e);
573
+ function St(e) {
574
+ const t = M(e);
585
575
  if (t)
586
576
  return new Date(Number(t[0]), 0, 1);
587
577
  }
588
- function St(e) {
589
- const t = q(e);
578
+ function Tt(e) {
579
+ const t = M(e);
590
580
  if (t)
591
581
  return new Date(Number(t[0]) + 1, 0, 1);
592
582
  }
593
- function Tt(e) {
583
+ function Rt(e) {
594
584
  const [t, n] = e.split("-S");
595
585
  switch (+n) {
596
586
  case 1:
@@ -608,12 +598,12 @@ function wt(e) {
608
598
  return new Date(+t + 1, 0, 1);
609
599
  }
610
600
  }
611
- function Rt(e) {
612
- const t = F(e);
601
+ function pt(e) {
602
+ const t = G(e);
613
603
  if (!t)
614
604
  return;
615
- const [n, s] = t[0].split("-Q");
616
- switch (+s) {
605
+ const [n, r] = t[0].split("-Q");
606
+ switch (+r) {
617
607
  case 1:
618
608
  return new Date(+n, 0, 1);
619
609
  case 2:
@@ -624,12 +614,12 @@ function Rt(e) {
624
614
  return new Date(+n, 9, 1);
625
615
  }
626
616
  }
627
- function pt(e) {
628
- const t = F(e);
617
+ function mt(e) {
618
+ const t = G(e);
629
619
  if (!t)
630
620
  return;
631
- const [n, s] = t[0].split("-Q");
632
- switch (+s) {
621
+ const [n, r] = t[0].split("-Q");
622
+ switch (+r) {
633
623
  case 1:
634
624
  return new Date(+n, 3, 1);
635
625
  case 2:
@@ -640,45 +630,45 @@ function pt(e) {
640
630
  return new Date(+n + 1, 0, 1);
641
631
  }
642
632
  }
643
- function mt(e) {
644
- const t = B(e);
633
+ function vt(e) {
634
+ const t = V(e);
645
635
  if (!t)
646
636
  return;
647
- const [n, s] = t[0].split("-M");
648
- return new Date(+n, +s - 1, 1);
637
+ const [n, r] = t[0].split("-M");
638
+ return new Date(+n, +r - 1, 1);
649
639
  }
650
- function vt(e) {
651
- const t = B(e);
640
+ function $t(e) {
641
+ const t = V(e);
652
642
  if (!t)
653
643
  return;
654
- const [n, s] = t[0].split("-M");
655
- return new Date(+n, +s, 1);
644
+ const [n, r] = t[0].split("-M");
645
+ return new Date(+n, +r, 1);
656
646
  }
657
- const $t = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), Nt = (e) => {
647
+ const Nt = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), It = (e) => {
658
648
  const t = /* @__PURE__ */ new Date(`${e}T23:59:00`);
659
649
  return t.setMinutes(t.getMinutes() + 1), t;
660
- }, It = 1, _t = (e, t, n, s = !0, r = "Q") => {
661
- const o = [], i = t && t > 3 ? Yt(t, s) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
650
+ }, _t = 1, Pt = (e, t, n, r = !0, s = "Q") => {
651
+ const o = [], i = t && t > 3 ? Ct(t, r) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
662
652
  for (let a = i; a <= c; a++)
663
- o.push(`${e}-${r}${a}`);
653
+ o.push(`${e}-${s}${a}`);
664
654
  return o;
665
- }, Ot = (e, t, n, s = "S") => {
666
- const r = [];
667
- return (t || 1) < 7 && (n || 12) > 6 && r.push(`${e}-${s}1`), n == null && r.push(`${e}-${s}2`), r;
668
- }, $n = (e) => Math.ceil(e / 3), pe = (e, t, n = "M") => `${e}-${n}${t.toString().padStart(2, "0")}`, Pt = (e, t, n = "M") => {
655
+ }, Ot = (e, t, n, r = "S") => {
669
656
  const s = [];
670
- for (let r = t; r <= 12; r++)
671
- s.push(pe(e, r, n));
672
- return s;
673
- }, Lt = (e, t, n, s = "M") => {
657
+ return (t || 1) < 7 && (n || 12) > 6 && s.push(`${e}-${r}1`), n == null && s.push(`${e}-${r}2`), s;
658
+ }, Nn = (e) => Math.ceil(e / 3), me = (e, t, n = "M") => `${e}-${n}${t.toString().padStart(2, "0")}`, Lt = (e, t, n = "M") => {
674
659
  const r = [];
675
- for (let o = t; o < n; o++)
676
- r.push(pe(e, o, s));
660
+ for (let s = t; s <= 12; s++)
661
+ r.push(me(e, s, n));
677
662
  return r;
678
- }, bt = (e, t, n, s = "M") => {
679
- const r = t || 1, o = n == null, i = n || 12;
680
- return o ? Pt(e, r, s) : Lt(e, r, i, s);
681
- }, Nn = (e, t, n = "M") => {
663
+ }, bt = (e, t, n, r = "M") => {
664
+ const s = [];
665
+ for (let o = t; o < n; o++)
666
+ s.push(me(e, o, r));
667
+ return s;
668
+ }, Ut = (e, t, n, r = "M") => {
669
+ const s = t || 1, o = n == null, i = n || 12;
670
+ return o ? Lt(e, s, r) : bt(e, s, i, r);
671
+ }, In = (e, t, n = "M") => {
682
672
  switch (t) {
683
673
  case 0:
684
674
  return [
@@ -707,73 +697,73 @@ const $t = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), Nt = (e) => {
707
697
  default:
708
698
  return [];
709
699
  }
710
- }, Ut = (e, t) => {
711
- const n = w(t, !0), s = w(e), r = n.getFullYear(), o = s.getFullYear(), i = n.getTime() <= s.getTime() ? o + It - r : 0;
712
- return Array.from({ length: i }, (a, u) => r + u);
713
- }, w = (e, t = !1) => {
714
- const n = xt(e, t);
700
+ }, xt = (e, t) => {
701
+ const n = R(t, !0), r = R(e), s = n.getFullYear(), o = r.getFullYear(), i = n.getTime() <= r.getTime() ? o + _t - s : 0;
702
+ return Array.from({ length: i }, (a, u) => s + u);
703
+ }, R = (e, t = !1) => {
704
+ const n = Yt(e, t);
715
705
  return n ? (n.getTimezoneOffset() > 0 && n.setMinutes(n.getMinutes() + n.getTimezoneOffset()), n) : /* @__PURE__ */ new Date();
716
- }, xt = (e, t = !1) => {
706
+ }, Yt = (e, t = !1) => {
717
707
  const n = Number(e);
718
- return e.toString().length !== 13 ? t ? we(e) : Re(e) : isNaN(n) ? /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`) : new Date(n);
719
- }, Yt = (e, t) => t ? Math.floor((e + 1) / 3) : Math.ceil((e + 1) / 3), In = (e, t) => {
720
- const n = ae(e) - ae(t);
708
+ return e.toString().length !== 13 ? t ? we(e) : pe(e) : isNaN(n) ? /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`) : new Date(n);
709
+ }, Ct = (e, t) => t ? Math.floor((e + 1) / 3) : Math.ceil((e + 1) / 3), _n = (e, t) => {
710
+ const n = ue(e) - ue(t);
721
711
  if (n === 0 && e !== t) {
722
- const s = ce(e), r = ce(t);
723
- return s - r;
712
+ const r = ae(e), s = ae(t);
713
+ return r - s;
724
714
  }
725
715
  return n;
726
- }, ce = (e) => M(e) ? 6 : Q(e) ? 5 : G(e) ? 4 : V(e) ? 3 : K(e) ? 2 : gt(e) ? 1 : 0, ae = (e, t = !1) => {
727
- const n = t ? we(e) : Re(e);
716
+ }, ae = (e) => Q(e) ? 6 : B(e) ? 5 : K(e) ? 4 : F(e) ? 3 : j(e) ? 2 : Et(e) ? 1 : 0, ue = (e, t = !1) => {
717
+ const n = t ? we(e) : pe(e);
728
718
  return (n == null ? void 0 : n.getTime()) || 0;
729
719
  };
730
- var J = /* @__PURE__ */ ((e) => (e.LAST_UPDATE_AT = "lastUpdatedAt", e.SERIES_COUNT = "series_count", e))(J || {}), Wt = /* @__PURE__ */ ((e) => (e.C = "c", e))(Wt || {}), R = /* @__PURE__ */ ((e) => (e.EQUALS = "eq", e.NOT_EQUALS = "ne", e.LESS = "lt", e.LESS_OR_EQUAL = "le", e.GREATER = "gt", e.GREATER_OR_EQUAL = "ge", e.CONTAINS = "co", e.NOT_CONTAINS = "nc", e.STARTS = "sw", e.ENDS = "ew", e))(R || {}), Ct = /* @__PURE__ */ ((e) => (e.BOOLEAN = "Boolean", e.DATE_TIME = "DateTime", e.DECIMAL = "Decimal", e.INTEGER = "Integer", e.OBSERVATION_TIME_PERIOD = "ObservationalTimePeriod", e.STRING = "String", e.TIME = "Time", e.TIME_RANGE = "TimeRange", e.URI = "URI", e))(Ct || {}), kt = /* @__PURE__ */ ((e) => (e.ANNUAL = "A", e.QUARTERLY = "Q", e.MONTHLY = "M", e))(kt || {});
731
- function _n(e) {
720
+ var X = /* @__PURE__ */ ((e) => (e.LAST_UPDATE_AT = "lastUpdatedAt", e.SERIES_COUNT = "series_count", e))(X || {}), Wt = /* @__PURE__ */ ((e) => (e.C = "c", e))(Wt || {}), w = /* @__PURE__ */ ((e) => (e.EQUALS = "eq", e.NOT_EQUALS = "ne", e.LESS = "lt", e.LESS_OR_EQUAL = "le", e.GREATER = "gt", e.GREATER_OR_EQUAL = "ge", e.CONTAINS = "co", e.NOT_CONTAINS = "nc", e.STARTS = "sw", e.ENDS = "ew", e))(w || {}), kt = /* @__PURE__ */ ((e) => (e.BOOLEAN = "Boolean", e.DATE_TIME = "DateTime", e.DECIMAL = "Decimal", e.INTEGER = "Integer", e.OBSERVATION_TIME_PERIOD = "ObservationalTimePeriod", e.STRING = "String", e.TIME = "Time", e.TIME_RANGE = "TimeRange", e.URI = "URI", e))(kt || {}), qt = /* @__PURE__ */ ((e) => (e.ANNUAL = "A", e.QUARTERLY = "Q", e.MONTHLY = "M", e))(qt || {});
721
+ function Pn(e) {
732
722
  var t, n;
733
- return (n = (t = e == null ? void 0 : e.annotations) == null ? void 0 : t.find((s) => {
734
- if (s.id === J.LAST_UPDATE_AT)
735
- return s;
723
+ return (n = (t = e == null ? void 0 : e.annotations) == null ? void 0 : t.find((r) => {
724
+ if (r.id === X.LAST_UPDATE_AT)
725
+ return r;
736
726
  })) == null ? void 0 : n.value;
737
727
  }
738
- const X = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.names[t]) || (e == null ? void 0 : e.name), me = (e, t, n) => {
728
+ const Z = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.names[t]) || (e == null ? void 0 : e.name), ve = (e, t, n) => {
739
729
  if (!(!e || t != null && t.has(e == null ? void 0 : e.id)) && (t == null || t.set(e == null ? void 0 : e.id, e), e != null && e.parent)) {
740
- const s = n == null ? void 0 : n.get(e == null ? void 0 : e.parent);
741
- me(s, t, n);
730
+ const r = n == null ? void 0 : n.get(e == null ? void 0 : e.parent);
731
+ ve(r, t, n);
742
732
  }
743
- }, qt = (e, t) => {
744
- const n = /* @__PURE__ */ new Map(), s = new Map(e == null ? void 0 : e.map((r) => [r.id, r]));
745
- return t == null || t.forEach((r) => {
746
- me(r, n, s);
733
+ }, Mt = (e, t) => {
734
+ const n = /* @__PURE__ */ new Map(), r = new Map(e == null ? void 0 : e.map((s) => [s.id, s]));
735
+ return t == null || t.forEach((s) => {
736
+ ve(s, n, r);
747
737
  }), Array.from(n == null ? void 0 : n.values());
748
- }, Mt = "time_period_end", Qt = "time_period_start", Bt = "TIME_PERIOD", On = (e) => {
738
+ }, Qt = "time_period_end", Bt = "time_period_start", Vt = "TIME_PERIOD", On = (e) => {
749
739
  const t = e == null ? void 0 : e.find(
750
- (o) => o.id === Qt
740
+ (o) => o.id === Bt
751
741
  ), n = e == null ? void 0 : e.find(
752
- (o) => o.id === Mt
753
- ), s = n != null && n.title ? new Date(n == null ? void 0 : n.title) : null;
742
+ (o) => o.id === Qt
743
+ ), r = n != null && n.title ? new Date(n == null ? void 0 : n.title) : null;
754
744
  return {
755
745
  startPeriod: t != null && t.title ? new Date(t == null ? void 0 : t.title) : null,
756
- endPeriod: s
746
+ endPeriod: r
757
747
  };
758
- }, Vt = (e, t) => e.id.localeCompare(t.id), Ft = (e, t) => e.memberValue.localeCompare(t.memberValue), Gt = (e, t) => {
759
- const n = new Array(e.length), s = e.map((i, c) => [i, c]);
760
- s.sort(
761
- (i, c) => Vt(i[0], c[0])
748
+ }, Ft = (e, t) => e.id.localeCompare(t.id), Gt = (e, t) => e.memberValue.localeCompare(t.memberValue), Kt = (e, t) => {
749
+ const n = new Array(e.length), r = e.map((i, c) => [i, c]);
750
+ r.sort(
751
+ (i, c) => Ft(i[0], c[0])
762
752
  );
763
- const r = [...t];
764
- r.sort(Ft);
753
+ const s = [...t];
754
+ s.sort(Gt);
765
755
  let o = 0;
766
- for (const i of s) {
756
+ for (const i of r) {
767
757
  const c = i[0];
768
- for (; o < r.length && r[o].memberValue.localeCompare(c.id) < 0; )
758
+ for (; o < s.length && s[o].memberValue.localeCompare(c.id) < 0; )
769
759
  o += 1;
770
- o < r.length && r[o].memberValue === c.id && (n[i[1]] = i[0]);
760
+ o < s.length && s[o].memberValue === c.id && (n[i[1]] = i[0]);
771
761
  }
772
762
  return n.filter((i) => i != null);
773
- }, Kt = (e) => !!(e != null && e.some((t) => t.parent)), Pn = (e, t, n, s, r = []) => {
763
+ }, jt = (e) => !!(e != null && e.some((t) => t.parent)), Ln = (e, t, n, r, s = []) => {
774
764
  var i, c;
775
765
  let o = e || [];
776
- if (jt(n || [], t || "")) {
766
+ if (zt(n || [], t || "")) {
777
767
  const a = (i = (n || [])[0].cubeRegions) == null ? void 0 : i.find(
778
768
  ({ isIncluded: u }) => u
779
769
  );
@@ -784,105 +774,105 @@ const X = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
784
774
  u ? o = o.length === 0 ? (u.selectionValues || []).map(({ memberValue: l }) => ({
785
775
  id: l,
786
776
  name: l
787
- })) : Gt(o, u.selectionValues) : o = [];
777
+ })) : Kt(o, u.selectionValues) : o = [];
788
778
  }
789
- } else r.length !== 0 && (o = o.filter(({ id: a }) => r.includes(a)));
790
- return Kt(e) && (o = qt(e, o)), o == null ? void 0 : o.map((a) => ({
779
+ } else s.length !== 0 && (o = o.filter(({ id: a }) => s.includes(a)));
780
+ return jt(e) && (o = Mt(e, o)), o == null ? void 0 : o.map((a) => ({
791
781
  ...a,
792
- name: s ? X(a, s) : a == null ? void 0 : a.name
782
+ name: r ? Z(a, r) : a == null ? void 0 : a.name
793
783
  }));
794
- }, jt = (e, t) => e != null && e.length > 0 && t != null, Ln = (e) => {
784
+ }, zt = (e, t) => e != null && e.length > 0 && t != null, bn = (e) => {
795
785
  var n;
796
786
  const t = [];
797
- return (n = e == null ? void 0 : e.filters) == null || n.forEach((s) => {
798
- s.componentCode !== Bt && t.push({
799
- componentCode: s.componentCode,
800
- operator: R.EQUALS,
801
- value: s.values.join(",")
787
+ return (n = e == null ? void 0 : e.filters) == null || n.forEach((r) => {
788
+ r.componentCode !== Vt && t.push({
789
+ componentCode: r.componentCode,
790
+ operator: w.EQUALS,
791
+ value: r.values.join(",")
802
792
  });
803
793
  }), t;
804
- }, zt = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, ue = (e) => {
794
+ }, Ht = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, le = (e) => {
805
795
  if (typeof e != "string")
806
796
  throw new TypeError("Invalid argument expected string");
807
- const t = e.match(zt);
797
+ const t = e.match(Ht);
808
798
  if (!t)
809
799
  throw new Error(`Invalid argument not valid semver ('${e}' received)`);
810
800
  return t.shift(), t;
811
- }, le = (e) => e === "*" || e === "x" || e === "X", de = (e) => {
801
+ }, de = (e) => e === "*" || e === "x" || e === "X", fe = (e) => {
812
802
  const t = parseInt(e, 10);
813
803
  return isNaN(t) ? e : t;
814
- }, Ht = (e, t) => typeof e != typeof t ? [String(e), String(t)] : [e, t], Jt = (e, t) => {
815
- if (le(e) || le(t))
804
+ }, Jt = (e, t) => typeof e != typeof t ? [String(e), String(t)] : [e, t], Xt = (e, t) => {
805
+ if (de(e) || de(t))
816
806
  return 0;
817
- const [n, s] = Ht(de(e), de(t));
818
- return n > s ? 1 : n < s ? -1 : 0;
819
- }, fe = (e, t) => {
807
+ const [n, r] = Jt(fe(e), fe(t));
808
+ return n > r ? 1 : n < r ? -1 : 0;
809
+ }, ge = (e, t) => {
820
810
  for (let n = 0; n < Math.max(e.length, t.length); n++) {
821
- const s = Jt(e[n] || "0", t[n] || "0");
822
- if (s !== 0)
823
- return s;
811
+ const r = Xt(e[n] || "0", t[n] || "0");
812
+ if (r !== 0)
813
+ return r;
824
814
  }
825
815
  return 0;
826
- }, Xt = (e, t) => {
827
- const n = ue(e), s = ue(t), r = n.pop(), o = s.pop(), i = fe(n, s);
828
- return i !== 0 ? i : r && o ? fe(r.split("."), o.split(".")) : r || o ? r ? -1 : 1 : 0;
829
- }, Zt = (e, t, n) => {
830
- en(n);
831
- const s = Xt(e, t);
832
- return ve[n].includes(s);
833
- }, ve = {
816
+ }, Zt = (e, t) => {
817
+ const n = le(e), r = le(t), s = n.pop(), o = r.pop(), i = ge(n, r);
818
+ return i !== 0 ? i : s && o ? ge(s.split("."), o.split(".")) : s || o ? s ? -1 : 1 : 0;
819
+ }, en = (e, t, n) => {
820
+ tn(n);
821
+ const r = Zt(e, t);
822
+ return $e[n].includes(r);
823
+ }, $e = {
834
824
  ">": [1],
835
825
  ">=": [0, 1],
836
826
  "=": [0],
837
827
  "<=": [-1, 0],
838
828
  "<": [-1],
839
829
  "!=": [-1, 1]
840
- }, ge = Object.keys(ve), en = (e) => {
841
- if (ge.indexOf(e) === -1)
842
- throw new Error(`Invalid operator, expected one of ${ge.join("|")}`);
843
- }, W = "+", Z = (e, t) => {
844
- const { agency: n, id: s, version: r } = p(e), o = t.filter(
830
+ }, Ee = Object.keys($e), tn = (e) => {
831
+ if (Ee.indexOf(e) === -1)
832
+ throw new Error(`Invalid operator, expected one of ${Ee.join("|")}`);
833
+ }, W = "+", ee = (e, t) => {
834
+ const { agency: n, id: r, version: s } = p(e), o = t.filter(
845
835
  (a) => {
846
836
  var u;
847
- return a.agencyID === n && a.id === s && !((u = a == null ? void 0 : a.version) != null && u.includes(W));
837
+ return a.agencyID === n && a.id === r && !((u = a == null ? void 0 : a.version) != null && u.includes(W));
848
838
  }
849
839
  );
850
840
  if (o.length === 1)
851
841
  return o[0];
852
- if (!(r != null && r.includes(W)))
853
- return o.find((a) => a.version === r);
842
+ if (!(s != null && s.includes(W)))
843
+ return o.find((a) => a.version === s);
854
844
  const i = o.map(
855
845
  (a) => a.version
856
- ), c = tn(r, i);
846
+ ), c = nn(s, i);
857
847
  return o.find(
858
848
  (a) => a.version === c[0]
859
849
  );
860
- }, tn = (e, t) => {
861
- const n = nn(e, t);
862
- return n.length > 0 ? [n[0]] : [];
863
850
  }, nn = (e, t) => {
851
+ const n = rn(e, t);
852
+ return n.length > 0 ? [n[0]] : [];
853
+ }, rn = (e, t) => {
864
854
  const n = [];
865
- return t.forEach((s) => {
866
- rn(e, s) && n.push(s);
855
+ return t.forEach((r) => {
856
+ on(e, r) && n.push(r);
867
857
  }), n;
868
858
  }, sn = (e) => {
869
859
  const t = e.trim().replace(/\d+\+/, "*"), [n] = t.split("*");
870
860
  return new RegExp(`^${n}`);
871
- }, rn = (e, t) => {
861
+ }, on = (e, t) => {
872
862
  const n = e.trim().replace(/\+/, "");
873
- return sn(e).test(t) && Zt(t, n, ">=");
874
- }, ee = (e, t) => {
875
- const { concept: n } = on(e, t);
863
+ return sn(e).test(t) && en(t, n, ">=");
864
+ }, te = (e, t) => {
865
+ const { concept: n } = cn(e, t);
876
866
  return n;
877
- }, on = (e, t) => {
867
+ }, cn = (e, t) => {
878
868
  if (e == null)
879
869
  return {
880
870
  concept: void 0,
881
871
  scheme: void 0
882
872
  };
883
- const { childId: n, agency: s, id: r, version: o } = _e(e);
873
+ const { childId: n, agency: r, id: s, version: o } = Pe(e);
884
874
  if (o != null && o.includes(W)) {
885
- const i = Z(
875
+ const i = ee(
886
876
  e,
887
877
  t
888
878
  );
@@ -892,7 +882,7 @@ const X = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
892
882
  };
893
883
  }
894
884
  for (const i of t)
895
- if (cn(i, r, s, o))
885
+ if (an(i, s, r, o))
896
886
  return {
897
887
  concept: he((i == null ? void 0 : i.concepts) || [], n),
898
888
  scheme: i
@@ -901,30 +891,30 @@ const X = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
901
891
  concept: void 0,
902
892
  scheme: void 0
903
893
  };
904
- }, he = (e, t) => e == null ? void 0 : e.find((n) => n.id === t), cn = (e, t, n, s) => e.id === t && e.agencyID === n && e.version === s, bn = (e = [], t = [], n) => {
894
+ }, he = (e, t) => e == null ? void 0 : e.find((n) => n.id === t), an = (e, t, n, r) => e.id === t && e.agencyID === n && e.version === r, Un = (e = [], t = [], n) => {
905
895
  var a, u;
906
- const s = (n == null ? void 0 : n.conceptIdentity) || "", r = ee(s, t), o = N(
896
+ const r = (n == null ? void 0 : n.conceptIdentity) || "", s = te(r, t), o = I(
907
897
  (a = n == null ? void 0 : n.localRepresentation) == null ? void 0 : a.enumeration
908
- ), i = N(
909
- (u = r == null ? void 0 : r.coreRepresentation) == null ? void 0 : u.enumeration
898
+ ), i = I(
899
+ (u = s == null ? void 0 : s.coreRepresentation) == null ? void 0 : u.enumeration
910
900
  ), c = o || i;
911
901
  if (c != null)
912
- return Z(c, e);
913
- }, Un = (e, t, n, s) => {
902
+ return ee(c, e);
903
+ }, xn = (e, t, n, r) => {
914
904
  var o, i;
915
- const r = (o = t == null ? void 0 : t.find(
905
+ const s = (o = t == null ? void 0 : t.find(
916
906
  (c) => (c == null ? void 0 : c.id) === (e == null ? void 0 : e.id)
917
907
  )) == null ? void 0 : o.values;
918
- return ((i = n == null ? void 0 : n.filter((c) => r == null ? void 0 : r.some((a) => a.id === c.id))) == null ? void 0 : i.map((c) => ({
908
+ return ((i = n == null ? void 0 : n.filter((c) => s == null ? void 0 : s.some((a) => a.id === c.id))) == null ? void 0 : i.map((c) => ({
919
909
  ...c,
920
- name: s ? X(c, s) : c == null ? void 0 : c.name
910
+ name: r ? Z(c, r) : c == null ? void 0 : c.name
921
911
  }))) || [];
922
- }, an = (e, t) => {
923
- var r, o, i;
924
- const n = (r = t == null ? void 0 : t.dataStructureComponents) == null ? void 0 : r.attributeList, s = (o = e == null ? void 0 : e.metadataStructureComponents) == null ? void 0 : o.metadataAttributeList;
912
+ }, un = (e, t) => {
913
+ var s, o, i;
914
+ const n = (s = t == null ? void 0 : t.dataStructureComponents) == null ? void 0 : s.attributeList, r = (o = e == null ? void 0 : e.metadataStructureComponents) == null ? void 0 : o.metadataAttributeList;
925
915
  return (i = n == null ? void 0 : n.metadataAttributeUsages) == null ? void 0 : i.map((c) => {
926
916
  var u;
927
- const a = (u = s == null ? void 0 : s.metadataAttributes) == null ? void 0 : u.find(
917
+ const a = (u = r == null ? void 0 : r.metadataAttributes) == null ? void 0 : u.find(
928
918
  (l) => (l == null ? void 0 : l.id) === (c == null ? void 0 : c.metadataAttributeReference)
929
919
  );
930
920
  return {
@@ -933,46 +923,46 @@ const X = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
933
923
  isMandatory: Number(a == null ? void 0 : a.minOccurs) > 0
934
924
  };
935
925
  });
936
- }, xn = (e = [], t, n) => {
937
- const s = N(t == null ? void 0 : t.conceptIdentity) || "", r = ee(s, e);
938
- return n ? X(r, n) : (r == null ? void 0 : r.name) ?? (r == null ? void 0 : r.id) ?? (t == null ? void 0 : t.id);
926
+ }, Yn = (e = [], t, n) => {
927
+ const r = I(t == null ? void 0 : t.conceptIdentity) || "", s = te(r, e);
928
+ return n ? Z(s, n) : (s == null ? void 0 : s.name) ?? (s == null ? void 0 : s.id) ?? (t == null ? void 0 : t.id);
939
929
  };
940
- function Ee(e) {
941
- var t, n, s;
942
- return (s = (n = (t = e == null ? void 0 : e.dataStructures) == null ? void 0 : t[0]) == null ? void 0 : n.dataStructureComponents) == null ? void 0 : s.dimensionList;
930
+ function Ae(e) {
931
+ var t, n, r;
932
+ return (r = (n = (t = e == null ? void 0 : e.dataStructures) == null ? void 0 : t[0]) == null ? void 0 : n.dataStructureComponents) == null ? void 0 : r.dimensionList;
943
933
  }
944
- function Yn(e) {
945
- var t, n, s, r;
946
- return ((r = (s = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : s.dimensions) == null ? void 0 : r.series) || [];
934
+ function Cn(e) {
935
+ var t, n, r, s;
936
+ return ((s = (r = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : r.dimensions) == null ? void 0 : s.series) || [];
947
937
  }
948
938
  function Wn(e) {
949
- var t, n, s, r, o;
950
- return ((o = (r = (s = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : s.dimensions) == null ? void 0 : r.observation) == null ? void 0 : o[0].values.map((i) => i.value).filter((i) => i != null)) || [];
939
+ var t, n, r, s, o;
940
+ return ((o = (s = (r = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : r.dimensions) == null ? void 0 : s.observation) == null ? void 0 : o[0].values.map((i) => i.value).filter((i) => i != null)) || [];
951
941
  }
952
- function Cn(e) {
942
+ function kn(e) {
953
943
  return e.find(
954
- (t) => t.type === k.TIME_DIMENSION
944
+ (t) => t.type === q.TIME_DIMENSION
955
945
  );
956
946
  }
957
- const kn = (e) => {
947
+ const qn = (e) => {
958
948
  var i, c, a, u, l, f;
959
- const t = /* @__PURE__ */ new Map(), n = (i = e == null ? void 0 : e.dataStructures) == null ? void 0 : i[0], s = (c = e == null ? void 0 : e.metadataStructures) == null ? void 0 : c[0], r = (e == null ? void 0 : e.conceptSchemes) || [], o = (e == null ? void 0 : e.codelists) || [];
949
+ const t = /* @__PURE__ */ new Map(), n = (i = e == null ? void 0 : e.dataStructures) == null ? void 0 : i[0], r = (c = e == null ? void 0 : e.metadataStructures) == null ? void 0 : c[0], s = (e == null ? void 0 : e.conceptSchemes) || [], o = (e == null ? void 0 : e.codelists) || [];
960
950
  return e && [
961
- ...((a = Ee(e)) == null ? void 0 : a.dimensions) || [],
962
- ...((u = Ee(e)) == null ? void 0 : u.timeDimensions) || [],
963
- ...an(s, n),
951
+ ...((a = Ae(e)) == null ? void 0 : a.dimensions) || [],
952
+ ...((u = Ae(e)) == null ? void 0 : u.timeDimensions) || [],
953
+ ...un(r, n),
964
954
  ...((f = (l = n == null ? void 0 : n.dataStructureComponents) == null ? void 0 : l.attributeList) == null ? void 0 : f.attributes) || []
965
955
  ].forEach(
966
956
  (d) => {
967
957
  var A, y;
968
- const g = ee(
958
+ const g = te(
969
959
  d == null ? void 0 : d.conceptIdentity,
970
- r
971
- ), E = ((A = d == null ? void 0 : d.localRepresentation) == null ? void 0 : A.enumeration) || ((y = g == null ? void 0 : g.coreRepresentation) == null ? void 0 : y.enumeration), D = Z(
972
- E,
960
+ s
961
+ ), h = ((A = d == null ? void 0 : d.localRepresentation) == null ? void 0 : A.enumeration) || ((y = g == null ? void 0 : g.coreRepresentation) == null ? void 0 : y.enumeration), D = ee(
962
+ h,
973
963
  o
974
964
  );
975
- d != null && d.id && (E ? t.set(d == null ? void 0 : d.id, {
965
+ d != null && d.id && (h ? t.set(d == null ? void 0 : d.id, {
976
966
  ...D,
977
967
  name: g == null ? void 0 : g.name,
978
968
  names: g == null ? void 0 : g.names
@@ -983,100 +973,100 @@ const kn = (e) => {
983
973
  }));
984
974
  }
985
975
  ), t;
986
- }, qn = (e) => {
976
+ }, Mn = (e) => {
987
977
  var t;
988
978
  return ((t = e == null ? void 0 : e.find(
989
- (n) => n.id === J.SERIES_COUNT
979
+ (n) => n.id === X.SERIES_COUNT
990
980
  )) == null ? void 0 : t.title) || "";
991
- }, un = "/api/download", Mn = (e, t, n, s, r, o, i) => {
981
+ }, ln = "/api/download", Qn = (e, t, n, r, s, o, i) => {
992
982
  const c = new URLSearchParams({
993
983
  urn: e,
994
984
  format: t,
995
985
  compress: "false",
996
986
  filename: o,
997
- filters: JSON.stringify(r),
998
- attribute: s,
987
+ filters: JSON.stringify(s),
988
+ attribute: r,
999
989
  language: n,
1000
990
  isMetadata: i ? "true" : "none"
1001
- }).toString(), a = `${un}?${c}`;
991
+ }).toString(), a = `${ln}?${c}`;
1002
992
  window.open(a, "_blank");
1003
- }, Qn = (e, t) => {
1004
- var s, r;
993
+ }, Bn = (e, t) => {
994
+ var r, s;
1005
995
  const n = [];
1006
996
  for (const o of e) {
1007
- if (o.type !== k.DIMENSION)
997
+ if (o.type !== q.DIMENSION)
1008
998
  continue;
1009
999
  const i = t.find((c) => c.componentCode === o.id);
1010
- i != null && ((s = i.values) == null ? void 0 : s.length) > 0 ? n.push((r = i.values) == null ? void 0 : r.join(We)) : n.push("*");
1000
+ i != null && ((r = i.values) == null ? void 0 : r.length) > 0 ? n.push((s = i.values) == null ? void 0 : s.join(We)) : n.push("*");
1011
1001
  }
1012
1002
  return n.join(".");
1013
- }, ln = (e, t) => {
1003
+ }, dn = (e, t) => {
1014
1004
  if (!e || !e.startPeriod && !e.endPeriod)
1015
1005
  return null;
1016
- const n = [], { startPeriod: s, endPeriod: r } = e;
1017
- if (s && n.push(
1018
- `${R.GREATER_OR_EQUAL}${ne}${s.toISOString().split("T")[0]}`
1019
- ), r && n.push(
1020
- `${R.LESS_OR_EQUAL}${ne}${r.toISOString().split("T")[0]}`
1006
+ const n = [], { startPeriod: r, endPeriod: s } = e;
1007
+ if (r && n.push(
1008
+ `${w.GREATER_OR_EQUAL}${re}${r.toISOString().split("T")[0]}`
1009
+ ), s && n.push(
1010
+ `${w.LESS_OR_EQUAL}${re}${s.toISOString().split("T")[0]}`
1021
1011
  ), n.length === 0)
1022
1012
  return null;
1023
1013
  const o = t;
1024
1014
  return n.map(
1025
- (i) => `${encodeURIComponent(`c[${o}]`)}${Ye}${encodeURIComponent(i)}`
1026
- ).join(ye);
1027
- }, Bn = (e, t) => {
1028
- const n = dn(e, t) || null;
1029
- return n ? ln(n, t == null ? void 0 : t.id) : null;
1030
- }, dn = (e, t) => {
1015
+ (i) => `${encodeURIComponent(`c[${o}]`)}${Ce}${encodeURIComponent(i)}`
1016
+ ).join(Se);
1017
+ }, Vn = (e, t) => {
1018
+ const n = fn(e, t) || null;
1019
+ return n ? dn(n, t == null ? void 0 : t.id) : null;
1020
+ }, fn = (e, t) => {
1031
1021
  var a, u;
1032
- const n = t.id, s = (a = e == null ? void 0 : e.filters) == null ? void 0 : a.find(
1022
+ const n = t.id, r = (a = e == null ? void 0 : e.filters) == null ? void 0 : a.find(
1033
1023
  (l) => l.componentCode === n
1034
1024
  );
1035
- if (!s || !s.values)
1025
+ if (!r || !r.values)
1036
1026
  return null;
1037
- const r = (u = s.values) == null ? void 0 : u.filter((l) => !!l);
1038
- if (!r.length)
1027
+ const s = (u = r.values) == null ? void 0 : u.filter((l) => !!l);
1028
+ if (!s.length)
1039
1029
  return null;
1040
- const o = s.operator;
1041
- if (o === R.LESS_OR_EQUAL || o === R.LESS)
1042
- return { startPeriod: null, endPeriod: v(r[0]) };
1043
- if (o === R.GREATER_OR_EQUAL || o === R.GREATER)
1044
- return { startPeriod: v(r[0]), endPeriod: null };
1045
- const i = v(r[0]), c = v(r[1]);
1030
+ const o = r.operator;
1031
+ if (o === w.LESS_OR_EQUAL || o === w.LESS)
1032
+ return { startPeriod: null, endPeriod: v(s[0]) };
1033
+ if (o === w.GREATER_OR_EQUAL || o === w.GREATER)
1034
+ return { startPeriod: v(s[0]), endPeriod: null };
1035
+ const i = v(s[0]), c = v(s[1]);
1046
1036
  return { startPeriod: i, endPeriod: c };
1047
- }, $e = (e, t, n) => {
1048
- const s = w(t, !0), r = w(n), o = w(e, !0), i = w(e), c = s.getTime() > o.getTime() ? s : o, a = r.getTime() < i.getTime() ? r : i;
1037
+ }, Ne = (e, t, n) => {
1038
+ const r = R(t, !0), s = R(n), o = R(e, !0), i = R(e), c = r.getTime() > o.getTime() ? r : o, a = s.getTime() < i.getTime() ? s : i;
1049
1039
  return {
1050
1040
  start: c,
1051
1041
  end: a
1052
1042
  };
1053
- }, fn = (e, t, n, s = "W") => {
1054
- const r = +e, { start: o, end: i } = $e(e, t, n);
1043
+ }, gn = (e, t, n, r = "W") => {
1044
+ const s = +e, { start: o, end: i } = Ne(e, t, n);
1055
1045
  if (o.getTime() > i.getTime())
1056
1046
  return [];
1057
- const c = I(o, s), a = c.weekYear === r ? c.weekNumber : c.weekYear < r ? 1 : ie(r, s), u = I(i, s), l = u.weekYear === r ? u.weekNumber : u.weekYear > r ? ie(r, s) : 1, f = [];
1047
+ const c = _(o, r), a = c.weekYear === s ? c.weekNumber : c.weekYear < s ? 1 : ce(s, r), u = _(i, r), l = u.weekYear === s ? u.weekNumber : u.weekYear > s ? ce(s, r) : 1, f = [];
1058
1048
  if (a < l)
1059
- for (let h = a; h <= l; h++)
1060
- f.push(Te(r, h, s));
1049
+ for (let E = a; E <= l; E++)
1050
+ f.push(Re(s, E, r));
1061
1051
  return f;
1062
- }, gn = (e) => {
1052
+ }, En = (e) => {
1063
1053
  const t = new Date(e);
1064
1054
  return t.setMinutes(t.getMinutes() - t.getTimezoneOffset()), t.toISOString().slice(0, 10);
1065
1055
  }, hn = (e, t, n) => {
1066
- const { start: s, end: r } = $e(e, t, n);
1067
- if (s.getTime() > r.getTime())
1056
+ const { start: r, end: s } = Ne(e, t, n);
1057
+ if (r.getTime() > s.getTime())
1068
1058
  return [];
1069
1059
  const o = [], i = new Date(
1070
- s.getFullYear(),
1071
- s.getMonth(),
1072
- s.getDate()
1073
- ), c = new Date(r.getFullYear(), r.getMonth(), r.getDate());
1060
+ r.getFullYear(),
1061
+ r.getMonth(),
1062
+ r.getDate()
1063
+ ), c = new Date(s.getFullYear(), s.getMonth(), s.getDate());
1074
1064
  for (; i.getTime() < c.getTime(); ) {
1075
- const a = gn(i);
1065
+ const a = En(i);
1076
1066
  o.push(a), i.setDate(i.getDate() + 1);
1077
1067
  }
1078
1068
  return o;
1079
- }, En = (e) => ({
1069
+ }, An = (e) => ({
1080
1070
  isDailyExist: !!(e != null && e.some(({ memberValue: t }) => t === "D")),
1081
1071
  isWeeklyExist: !!(e != null && e.some(({ memberValue: t }) => t === "W")),
1082
1072
  isMonthlyExist: !!(e != null && e.some(({ memberValue: t }) => t === "M")),
@@ -1085,146 +1075,146 @@ const kn = (e) => {
1085
1075
  isYearlyExist: !!(e != null && e.some(
1086
1076
  ({ memberValue: t }) => t === "A" || t === "Y"
1087
1077
  ))
1088
- }), An = (e, t, n, s) => {
1078
+ }), Dn = (e, t, n, r) => {
1089
1079
  var i, c;
1090
- const r = s === 0 ? ((i = w(t.toString(), !0)) == null ? void 0 : i.getMonth()) + 1 : void 0, o = s === e.length - 1 ? ((c = w(n.toString())) == null ? void 0 : c.getMonth()) + 1 || 1 : void 0;
1091
- return { startMonth: r, endMonth: o };
1092
- }, Dn = ["FREQUENCY", "FREQ"], Vn = (e, t) => {
1093
- var a, u, l, f, h, d, g;
1094
- const n = (h = (f = (l = (u = (a = e == null ? void 0 : e[0]) == null ? void 0 : a.cubeRegions) == null ? void 0 : u[0]) == null ? void 0 : l.memberSelection) == null ? void 0 : f.find(
1095
- (E) => Dn.includes(E.componentId)
1096
- )) == null ? void 0 : h.selectionValues, s = En(n || []), r = ((d = t == null ? void 0 : t.startPeriod) == null ? void 0 : d.getTime()) || 1, o = ((g = t == null ? void 0 : t.endPeriod) == null ? void 0 : g.getTime()) || 1, i = Ut(o, r), c = [];
1097
- return i.forEach((E, D) => {
1098
- const A = [], { startMonth: y, endMonth: S } = An(
1080
+ const s = r === 0 ? ((i = R(t.toString(), !0)) == null ? void 0 : i.getMonth()) + 1 : void 0, o = r === e.length - 1 ? ((c = R(n.toString())) == null ? void 0 : c.getMonth()) + 1 || 1 : void 0;
1081
+ return { startMonth: s, endMonth: o };
1082
+ }, yn = ["FREQUENCY", "FREQ"], Fn = (e, t) => {
1083
+ var a, u, l, f, E, d, g;
1084
+ const n = (E = (f = (l = (u = (a = e == null ? void 0 : e[0]) == null ? void 0 : a.cubeRegions) == null ? void 0 : u[0]) == null ? void 0 : l.memberSelection) == null ? void 0 : f.find(
1085
+ (h) => yn.includes(h.componentId)
1086
+ )) == null ? void 0 : E.selectionValues, r = An(n || []), s = ((d = t == null ? void 0 : t.startPeriod) == null ? void 0 : d.getTime()) || 1, o = ((g = t == null ? void 0 : t.endPeriod) == null ? void 0 : g.getTime()) || 1, i = xt(o, s), c = [];
1087
+ return i.forEach((h, D) => {
1088
+ const A = [], { startMonth: y, endMonth: S } = Dn(
1099
1089
  i,
1100
- new Date(r),
1090
+ new Date(s),
1101
1091
  new Date(o),
1102
1092
  D
1103
1093
  ), {
1104
- isDailyExist: _,
1094
+ isDailyExist: P,
1105
1095
  isWeeklyExist: O,
1106
- isMonthlyExist: P,
1107
- isQuarterlyExist: L,
1108
- isSemiAnnualExist: b,
1096
+ isMonthlyExist: L,
1097
+ isQuarterlyExist: b,
1098
+ isSemiAnnualExist: U,
1109
1099
  isYearlyExist: T
1110
- } = s;
1111
- T && A.push(E.toString()), b && A.push(...Ot(E, y, S)), L && A.push(
1112
- ..._t(E, y, S, !1)
1113
- ), P && A.push(...bt(E, y, S)), O && A.push(
1114
- ...fn(E, r.toString(), o.toString())
1115
- ), _ && A.push(
1116
- ...hn(E, r.toString(), o.toString())
1100
+ } = r;
1101
+ T && A.push(h.toString()), U && A.push(...Ot(h, y, S)), b && A.push(
1102
+ ...Pt(h, y, S, !1)
1103
+ ), L && A.push(...Ut(h, y, S)), O && A.push(
1104
+ ...gn(h, s.toString(), o.toString())
1105
+ ), P && A.push(
1106
+ ...hn(h, s.toString(), o.toString())
1117
1107
  ), c.push(...A);
1118
1108
  }), c;
1119
1109
  };
1120
1110
  export {
1121
- J as Annotations,
1122
- Ke as AssignmentStatus,
1123
- Sn as AvailabilityApi,
1124
- xe as DATASET_DATA_URL,
1111
+ X as Annotations,
1112
+ je as AssignmentStatus,
1113
+ Tn as AvailabilityApi,
1114
+ Ye as DATASET_DATA_URL,
1125
1115
  wn as DatasetApi,
1126
- k as DimensionType,
1127
- Le as DownloadType,
1128
- pn as FREQUENCY_DIMENSION_ID,
1129
- Dn as FREQUENCY_DIM_ID,
1130
- Pe as FileColumnsAttribute,
1131
- Ce as GET_v3_FILTER_ALL,
1132
- Tn as GET_v3_FILTER_AND,
1116
+ q as DimensionType,
1117
+ be as DownloadType,
1118
+ mn as FREQUENCY_DIMENSION_ID,
1119
+ yn as FREQUENCY_DIM_ID,
1120
+ Le as FileColumnsAttribute,
1121
+ ke as GET_v3_FILTER_ALL,
1122
+ Rn as GET_v3_FILTER_AND,
1133
1123
  We as GET_v3_FILTER_OR,
1134
- Je as OBSERVATION_KEY,
1135
- je as OccurrenceType,
1136
- kt as Periods,
1137
- Ct as RepresentationTextType,
1124
+ Xe as OBSERVATION_KEY,
1125
+ ze as OccurrenceType,
1126
+ qt as Periods,
1127
+ kt as RepresentationTextType,
1138
1128
  Wt as SDMX_DATA_QUERY_PARAMS,
1139
1129
  W as SINGLE_WILDCARD_SYMBOL,
1140
- Rn as SdmxApiClient,
1141
- Ae as SdmxAvailabilityMode,
1130
+ pn as SdmxApiClient,
1131
+ De as SdmxAvailabilityMode,
1142
1132
  $ as SdmxDataFormat,
1143
- De as SdmxDetails,
1144
- C as SdmxReferences,
1145
- R as SeriesFilterOperator,
1146
- Bt as TIME_PERIOD,
1147
- Mt as TIME_PERIOD_END,
1148
- Qt as TIME_PERIOD_START,
1149
- ut as dailyPattern,
1150
- tt as decodeDimensionId,
1151
- bn as findCodelistByDimension,
1133
+ ye as SdmxDetails,
1134
+ k as SdmxReferences,
1135
+ w as SeriesFilterOperator,
1136
+ Vt as TIME_PERIOD,
1137
+ Qt as TIME_PERIOD_END,
1138
+ Bt as TIME_PERIOD_START,
1139
+ lt as dailyPattern,
1140
+ nt as decodeDimensionId,
1141
+ Un as findCodelistByDimension,
1152
1142
  se as generateDatasetDataRequest,
1153
- yn as generateShortUrn,
1154
- Vn as getAdditionalColumns,
1143
+ Sn as generateShortUrn,
1144
+ Fn as getAdditionalColumns,
1155
1145
  On as getAnnotationPeriod,
1156
- Z as getArtifactByUrnWithWildCard,
1157
- mn as getAttachedDimensionsSeriesByDimension,
1158
- ze as getAttachedDimensionsSeriesByTsId,
1159
- Se as getAttachedDimensionsSeriesKey,
1160
- He as getAttributeValueFromDataQueryResponse,
1161
- Un as getAvailableCodes,
1162
- Pn as getAvailableCodesFromConstrains,
1163
- _e as getChildParsedUrn,
1164
- ee as getConcept,
1146
+ ee as getArtifactByUrnWithWildCard,
1147
+ vn as getAttachedDimensionsSeriesByDimension,
1148
+ He as getAttachedDimensionsSeriesByTsId,
1149
+ Te as getAttachedDimensionsSeriesKey,
1150
+ Je as getAttributeValueFromDataQueryResponse,
1151
+ xn as getAvailableCodes,
1152
+ Ln as getAvailableCodesFromConstrains,
1153
+ Pe as getChildParsedUrn,
1154
+ te as getConcept,
1165
1155
  he as getConceptByUrn,
1166
- on as getConceptWithScheme,
1167
- an as getConvertedMetaAttributes,
1168
- ft as getDailyRegExp,
1156
+ cn as getConceptWithScheme,
1157
+ un as getConvertedMetaAttributes,
1158
+ gt as getDailyRegExp,
1169
1159
  hn as getDaysColumns,
1170
- xn as getDimensionTitle,
1171
- Ee as getDimensions,
1172
- qt as getFilteredItemsWithParents,
1173
- Ln as getFiltersDtoFromDataQuery,
1174
- I as getISOWeek,
1175
- N as getKeyFromUrn,
1176
- _n as getLastUpdatedTime,
1177
- ie as getLastWeekNumberOfYear,
1178
- X as getLocalizedName,
1179
- bt as getMonthlyData,
1180
- Nn as getMonthlyDataByQuarter,
1181
- B as getMonthlyRegExp,
1182
- Re as getParsedEndPeriodDate,
1183
- vn as getParsedResponse,
1160
+ Yn as getDimensionTitle,
1161
+ Ae as getDimensions,
1162
+ Mt as getFilteredItemsWithParents,
1163
+ bn as getFiltersDtoFromDataQuery,
1164
+ _ as getISOWeek,
1165
+ I as getKeyFromUrn,
1166
+ Pn as getLastUpdatedTime,
1167
+ ce as getLastWeekNumberOfYear,
1168
+ Z as getLocalizedName,
1169
+ Ut as getMonthlyData,
1170
+ In as getMonthlyDataByQuarter,
1171
+ V as getMonthlyRegExp,
1172
+ pe as getParsedEndPeriodDate,
1173
+ $n as getParsedResponse,
1184
1174
  we as getParsedStartPeriodDate,
1185
- w as getPeriodDate,
1186
- En as getPeriods,
1187
- $n as getQuarterByMonth,
1188
- F as getQuarterlyRegExp,
1189
- _t as getQuartersData,
1190
- ln as getQueryTimePeriodFilters,
1191
- be as getRequestAcceptHeader,
1192
- tn as getResolvedVersionBySingleWildcard,
1175
+ R as getPeriodDate,
1176
+ An as getPeriods,
1177
+ Nn as getQuarterByMonth,
1178
+ G as getQuarterlyRegExp,
1179
+ Pt as getQuartersData,
1180
+ dn as getQueryTimePeriodFilters,
1181
+ Ue as getRequestAcceptHeader,
1182
+ nn as getResolvedVersionBySingleWildcard,
1193
1183
  Ot as getSemiAnnualData,
1194
- dt as getSemiAnnuallyRegExp,
1195
- Y as getSeriesAttributes,
1196
- Xe as getSeriesName,
1197
- kn as getStructureComponentsMap,
1198
- Yn as getStructureDimensions,
1199
- Cn as getTimeDimension,
1184
+ ft as getSemiAnnuallyRegExp,
1185
+ C as getSeriesAttributes,
1186
+ Ze as getSeriesName,
1187
+ qn as getStructureComponentsMap,
1188
+ Cn as getStructureDimensions,
1189
+ kn as getTimeDimension,
1200
1190
  Wn as getTimePeriods,
1201
- Bn as getTimeQueryFilter,
1202
- dn as getTimeRangeFromAttachment,
1203
- qn as getTimeSeriesCount,
1204
- Qn as getTimeSeriesFilterKey,
1205
- et as getTimeSeriesId,
1206
- Te as getWeekCode,
1207
- Dt as getWeeklyPeriodEndDate,
1208
- At as getWeeklyPeriodStartDate,
1191
+ Vn as getTimeQueryFilter,
1192
+ fn as getTimeRangeFromAttachment,
1193
+ Mn as getTimeSeriesCount,
1194
+ Bn as getTimeSeriesFilterKey,
1195
+ tt as getTimeSeriesId,
1196
+ Re as getWeekCode,
1197
+ yt as getWeeklyPeriodEndDate,
1198
+ Dt as getWeeklyPeriodStartDate,
1209
1199
  ht as getWeeklyRegExp,
1210
- fn as getWeeksColumns,
1200
+ gn as getWeeksColumns,
1211
1201
  sn as getWildCardRegexp,
1212
- $e as getYearPeriod,
1213
- q as getYearlyRegExp,
1214
- Ut as getYears,
1215
- gt as isDaily,
1216
- V as isMonthly,
1217
- G as isQuarterly,
1218
- Q as isSemiAnnually,
1219
- K as isWeekly,
1220
- rn as isWildCardVersionCorrect,
1221
- M as isYearly,
1222
- lt as monthlyPattern,
1223
- Mn as openDownloadWindow,
1224
- ot as quarterPattern,
1225
- ct as semiAnnuallyPattern,
1226
- In as sortPeriods,
1202
+ Ne as getYearPeriod,
1203
+ M as getYearlyRegExp,
1204
+ xt as getYears,
1205
+ Et as isDaily,
1206
+ F as isMonthly,
1207
+ K as isQuarterly,
1208
+ B as isSemiAnnually,
1209
+ j as isWeekly,
1210
+ on as isWildCardVersionCorrect,
1211
+ Q as isYearly,
1212
+ dt as monthlyPattern,
1213
+ Qn as openDownloadWindow,
1214
+ it as quarterPattern,
1215
+ at as semiAnnuallyPattern,
1216
+ _n as sortPeriods,
1227
1217
  p as splitUrn,
1228
- it as weeklyPattern,
1229
- at as yearlyPattern
1218
+ ct as weeklyPattern,
1219
+ ut as yearlyPattern
1230
1220
  };