@epam/statgpt-sdmx-toolkit 0.7.0-dev.20 → 0.7.0-dev.21

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