@epam/statgpt-sdmx-toolkit 0.2.0-rc.36 → 0.2.0-rc.38

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