@sinequa/atomic 0.0.101 → 0.0.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/atomic.js CHANGED
@@ -1,15 +1,48 @@
1
- var T = Object.defineProperty;
2
- var ee = (e, t, r) => t in e ? T(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var G = (e, t, r) => ee(e, typeof t != "symbol" ? t + "" : t, r);
4
- const u = { apiPath: "api/v1", loginPath: "/login", backendUrl: window.location.origin };
5
- function m(e) {
1
+ var oe = Object.defineProperty;
2
+ var se = (e, t, r) => t in e ? oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var H = (e, t, r) => se(e, typeof t != "symbol" ? t + "" : t, r);
4
+ const u = { apiPath: "api/v1", loginPath: "/login", backendUrl: typeof window < "u" ? window.location.origin : "http://localhost", createRoutes: !1 };
5
+ function S(e) {
6
6
  Object.assign(u, e);
7
7
  }
8
- function je(e, t) {
9
- var n;
10
- return !(e != null && e.items) || ((n = e == null ? void 0 : e.items) == null ? void 0 : n.length) === 0 ? [] : e.items.reduce((o, s) => {
8
+ const y = {
9
+ store: {},
10
+ getItem(e) {
11
+ return this.store[e] ?? null;
12
+ },
13
+ setItem(e, t) {
14
+ this.store[e] = t.toString();
15
+ },
16
+ removeItem(e) {
17
+ delete this.store[e];
18
+ },
19
+ clear() {
20
+ this.store = {};
21
+ }
22
+ }, Q = y;
23
+ function F(e) {
24
+ return typeof window > "u" || !window.localStorage ? y.getItem(e) : window.localStorage.getItem(e);
25
+ }
26
+ function E(e, t) {
27
+ typeof window > "u" || !window.localStorage ? y.setItem(e, t) : window.localStorage.setItem(e, t);
28
+ }
29
+ function x(e) {
30
+ typeof window > "u" || !window.localStorage ? y.removeItem(e) : window.localStorage.removeItem(e);
31
+ }
32
+ function ce(e) {
33
+ return typeof window > "u" || !window.sessionStorage ? Q.getItem(e) : window.sessionStorage.getItem(e);
34
+ }
35
+ function ie(e, t) {
36
+ typeof window > "u" || !window.sessionStorage ? Q.setItem(e, t) : window.sessionStorage.setItem(e, t);
37
+ }
38
+ function le(e) {
39
+ typeof window > "u" || !window.sessionStorage ? Q.removeItem(e) : window.sessionStorage.removeItem(e);
40
+ }
41
+ function Ze(e, t) {
42
+ var a;
43
+ return !(e != null && e.items) || ((a = e == null ? void 0 : e.items) == null ? void 0 : a.length) === 0 ? [] : e.items.reduce((o, s) => {
11
44
  if (!s.value || s.value === "") return o;
12
- const c = te(s, e.column);
45
+ const c = ue(s, e.column);
13
46
  return o.push({
14
47
  operator: c.operator,
15
48
  value: c.value,
@@ -20,10 +53,10 @@ function je(e, t) {
20
53
  }), o;
21
54
  }, []);
22
55
  }
23
- function te(e, t) {
24
- const r = t, a = e.value.match(/.*\:\(?([><=\d\-\.AND ]+)\)?/);
25
- if (a != null && a[1]) {
26
- const o = (a == null ? void 0 : a[1].split(" AND ")).map((s) => {
56
+ function ue(e, t) {
57
+ const r = t, n = e.value.match(/.*\:\(?([><=\d\-\.AND ]+)\)?/);
58
+ if (n != null && n[1]) {
59
+ const o = (n == null ? void 0 : n[1].split(" AND ")).map((s) => {
27
60
  const c = s.indexOf(">=") !== -1 ? "gte" : "lt";
28
61
  let i = s.substring(s.indexOf(" ") + 1);
29
62
  return { field: r, operator: c, value: i, display: e.display || e.value };
@@ -36,51 +69,51 @@ function te(e, t) {
36
69
  }
37
70
  return { field: r, operator: "eq", value: e.value, display: e.display };
38
71
  }
39
- function Ve(e, t, r) {
72
+ function Me(e, t, r) {
40
73
  return e.valuesAreExpressions ? t.display === r.display : t.value === r.value;
41
74
  }
42
- function ze(e, t) {
75
+ function Ee(e, t) {
43
76
  const r = [];
44
77
  if (e.length > 0) {
45
- const a = /* @__PURE__ */ new Map(), n = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = new RegExp("\\b" + n, "i");
78
+ const n = /* @__PURE__ */ new Map(), a = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = new RegExp("\\b" + a, "i");
46
79
  e.forEach((s) => {
47
80
  if (s.display.length > 1) {
48
81
  const c = o.exec(s.display);
49
- X(r, a, "/", s.display, +(s.frequency || 0), 1, ((c == null ? void 0 : c.index) || 0) + t.length);
82
+ T(r, n, "/", s.display, +(s.frequency || 0), 1, ((c == null ? void 0 : c.index) || 0) + t.length);
50
83
  }
51
84
  });
52
85
  }
53
86
  return r;
54
87
  }
55
- function X(e, t, r, a, n, o, s) {
56
- const c = a.indexOf("/", r.length), i = a.substring(0, c + 1);
88
+ function T(e, t, r, n, a, o, s) {
89
+ const c = n.indexOf("/", r.length), i = n.substring(0, c + 1);
57
90
  let l = t.get(i);
58
91
  if (!l) {
59
- const f = i.replace(/^\/|\/$/g, "");
92
+ const h = i.replace(/^\/|\/$/g, "");
60
93
  l = {
61
- value: a.substring(r.length, c),
62
- count: n,
94
+ value: n.substring(r.length, c),
95
+ count: a,
63
96
  items: [],
64
97
  hasChildren: !1,
65
98
  $level: o,
66
99
  $opened: s >= i.length,
67
- $path: f
100
+ $path: h
68
101
  }, t.set(i, l), e.push(l);
69
102
  }
70
- i.length < a.length && (l.hasChildren = !0, X(l.items, t, i, a, n, o + 1, s));
103
+ i.length < n.length && (l.hasChildren = !0, T(l.items, t, i, n, a, o + 1, s));
71
104
  }
72
- function Je(e, t) {
73
- return e.reduce((r, a) => (t(a) ? r.true.push(a) : r.false.push(a), r), { true: [], false: [] });
105
+ function Te(e, t) {
106
+ return e.reduce((r, n) => (t(n) ? r.true.push(n) : r.false.push(n), r), { true: [], false: [] });
74
107
  }
75
- const re = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, ae = 2, j = 3, ne = 5, V = 6, oe = 8, z = 9, se = 11, J = 12, ce = 14, H = 15;
76
- function U(e) {
108
+ const de = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, fe = 2, W = 3, he = 5, X = 6, _e = 8, Y = 9, we = 11, K = 12, Se = 14, Z = 15;
109
+ function I(e) {
77
110
  if (!e) return [];
78
- const t = [], r = e.matchAll(re);
79
- for (let a of r)
80
- a[j] ? t.push({ type: "group", value: a[j], op: a[ae] }) : a[V] ? t.push({ type: "adjacent", value: a[V], op: a[ne] }) : a[z] ? t.push({ type: "exact", value: a[z], op: a[oe] }) : a[J] ? t.push({ type: "regex", value: a[J], op: a[se] }) : a[H] && t.push({ type: "token", value: a[H], op: a[ce] });
111
+ const t = [], r = e.matchAll(de);
112
+ for (let n of r)
113
+ n[W] ? t.push({ type: "group", value: n[W], op: n[fe] }) : n[X] ? t.push({ type: "adjacent", value: n[X], op: n[he] }) : n[Y] ? t.push({ type: "exact", value: n[Y], op: n[_e] }) : n[K] ? t.push({ type: "regex", value: n[K], op: n[we] }) : n[Z] && t.push({ type: "token", value: n[Z], op: n[Se] });
81
114
  return t;
82
115
  }
83
- function N(e) {
116
+ function G(e) {
84
117
  return e.map((t) => {
85
118
  const r = t.op || "";
86
119
  switch (t.type) {
@@ -97,59 +130,66 @@ function N(e) {
97
130
  }
98
131
  }).join(" ");
99
132
  }
100
- function He(e, t, r) {
101
- let a = U(e);
102
- for (let n of t)
103
- a.push({ type: "adjacent", value: n, op: r });
104
- return N(a);
133
+ function et(e, t, r) {
134
+ let n = I(e);
135
+ for (let a of t)
136
+ n.push({ type: "adjacent", value: a, op: r });
137
+ return G(n);
105
138
  }
106
- function We(e, t) {
107
- const r = U(t), a = r.findIndex((n) => n.value === e);
108
- return a !== -1 ? (r.splice(a, 1), t = N(r)) : t;
139
+ function tt(e, t) {
140
+ const r = I(t), n = r.findIndex((a) => a.value === e);
141
+ return n !== -1 ? (r.splice(n, 1), t = G(r)) : t;
109
142
  }
110
- function Xe(e) {
111
- const t = U(e).filter((r) => r.type !== "adjacent");
112
- return N(t);
143
+ function rt(e) {
144
+ const t = I(e).filter((r) => r.type !== "adjacent");
145
+ return G(t);
113
146
  }
114
- function Ye(e) {
115
- return U(e).filter((t) => t.type === "adjacent").map((t) => t.value);
147
+ function nt(e) {
148
+ return I(e).filter((t) => t.type === "adjacent").map((t) => t.value);
116
149
  }
117
- function Ke(e, t, r) {
118
- const a = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: n, unit: o, isFuture: s } = ie(t, r);
119
- return a.format(n * (s ? 1 : -1), o);
150
+ function at(e, t, r) {
151
+ const n = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: a, unit: o, isFuture: s } = me(t, r);
152
+ return n.format(a * (s ? 1 : -1), o);
120
153
  }
121
- function ie(e, t) {
122
- const r = new Date(e), a = t ? new Date(t) : /* @__PURE__ */ new Date(), n = Math.abs(a.getTime() - r.getTime());
154
+ function me(e, t) {
155
+ const r = new Date(e), n = t ? new Date(t) : /* @__PURE__ */ new Date(), a = Math.abs(n.getTime() - r.getTime());
123
156
  return {
124
- offset: Math.floor(n / (1e3 * 60 * 60 * 24)),
157
+ offset: Math.floor(a / (1e3 * 60 * 60 * 24)),
125
158
  unit: "day",
126
- isFuture: r > a
159
+ isFuture: r > n
127
160
  };
128
161
  }
129
- function Ze(e) {
162
+ function ot(e) {
130
163
  const t = e.target;
131
164
  return t && t.nodeName !== "INPUT" && t.nodeName !== "TEXTAREA";
132
165
  }
133
- function Me(e) {
166
+ function st(e) {
134
167
  if (e === void 0) return;
135
- const { q: t, f: r, p: a, s: n, t: o, n: s, b: c } = R(e), [i] = e.split("?");
168
+ const { q: t, f: r, p: n, s: a, t: o, n: s, b: c } = R(e), [i] = e.split("?");
136
169
  return {
137
170
  path: i,
138
171
  text: t,
139
- filters: r ? Y(r) : void 0,
140
- page: a ? parseInt(a, 10) : void 0,
141
- sort: n,
172
+ filters: r ? ee(r) : void 0,
173
+ page: n ? parseInt(n, 10) : void 0,
174
+ sort: a,
142
175
  tab: o,
143
176
  name: s,
144
177
  basket: c
145
178
  };
146
179
  }
147
- function Ee(e) {
180
+ function ct(e) {
181
+ if (!e) return "";
182
+ const { text: t, filters: r, page: n, sort: a, tab: o, name: s, basket: c } = e, i = {};
183
+ t && (i.q = t), r && (i.f = JSON.stringify(r)), n && (i.p = n.toString()), a && (i.s = a), o && (i.t = o), s && (i.n = s), c && (i.b = c);
184
+ const l = new URLSearchParams(i).toString();
185
+ return l || "";
186
+ }
187
+ function it(e) {
148
188
  if (e === void 0) return [];
149
189
  const { f: t } = R(e);
150
- return Y(t);
190
+ return ee(t);
151
191
  }
152
- function Y(e) {
192
+ function ee(e) {
153
193
  const t = decodeURIComponent(e);
154
194
  try {
155
195
  return JSON.parse(t ?? "[]");
@@ -163,55 +203,55 @@ function R(e) {
163
203
  const r = new URLSearchParams(t);
164
204
  return Object.fromEntries(r);
165
205
  }
166
- function Te(e) {
206
+ function lt(e) {
167
207
  const { q: t = "" } = R(e);
168
208
  return t;
169
209
  }
170
- function et(e) {
210
+ function ut(e) {
171
211
  const { id: t } = R(e);
172
212
  return decodeURIComponent(t);
173
213
  }
174
- function tt(e) {
214
+ function dt(e) {
175
215
  const { p: t = "0" } = R(e);
176
216
  return parseInt(t, 10);
177
217
  }
178
- function rt(e) {
218
+ function ft(e) {
179
219
  const { t } = R(e);
180
220
  return t;
181
221
  }
182
- function at(e, t) {
222
+ function ht(e, t) {
183
223
  if (!e)
184
224
  return e;
185
225
  let r = 0;
186
- const a = e.length;
187
- let n = 0;
188
- if (e[n] === "[") {
189
- for (; n < a && /[0-9]/.test(e[n]); )
190
- n++;
191
- e[n] === "]" && (r = n + 1);
226
+ const n = e.length;
227
+ let a = 0;
228
+ if (e[a] === "[") {
229
+ for (; a < n && /[0-9]/.test(e[a]); )
230
+ a++;
231
+ e[a] === "]" && (r = a + 1);
192
232
  }
193
- const o = y(e, r, !1);
233
+ const o = B(e, r, !1);
194
234
  if (!o)
195
235
  return e;
196
236
  const s = t.charCodeAt(0), c = t.charCodeAt(1);
197
237
  let i = o;
198
238
  for (; i; )
199
239
  if (s === i.lang1 && c === i.lang2) {
200
- const f = y(e, i.end + 4, !0);
201
- return e.substring(f.start, f.end);
240
+ const h = B(e, i.end + 4, !0);
241
+ return e.substring(h.start, h.end);
202
242
  } else
203
- i = y(e, i.end + 4, !1);
243
+ i = B(e, i.end + 4, !1);
204
244
  const l = e.substring(o.start, o.end);
205
245
  return l || e;
206
246
  }
207
- function y(e, t, r) {
208
- for (let a = t, n = e.length - 3; a < n; a++)
209
- if (e[a] === "[" && e[a + 3] === "]")
247
+ function B(e, t, r) {
248
+ for (let n = t, a = e.length - 3; n < a; n++)
249
+ if (e[n] === "[" && e[n + 3] === "]")
210
250
  return {
211
251
  start: t,
212
- end: a,
213
- lang1: e.charCodeAt(a + 1),
214
- lang2: e.charCodeAt(a + 2)
252
+ end: n,
253
+ lang1: e.charCodeAt(n + 1),
254
+ lang2: e.charCodeAt(n + 2)
215
255
  };
216
256
  if (r)
217
257
  return {
@@ -221,22 +261,60 @@ function y(e, t, r) {
221
261
  lang2: -1
222
262
  };
223
263
  }
224
- function nt(e, t) {
225
- const { useLocale: r, useLocaleAsPrefix: a, indexFile: n, path: o, folder: s } = t, c = r ? `${e}/` : null, i = a ? `${e}.${n}` : n ?? "";
264
+ function _t(e, t) {
265
+ const { useLocale: r, useLocaleAsPrefix: n, indexFile: a, path: o, folder: s } = t, c = r ? `${e}/` : null, i = n ? `${e}.${a}` : a ?? "";
226
266
  return [o, s, `${c || ""}${i}`].filter((l) => l !== void 0).join("/");
227
267
  }
228
- var K = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(K || {});
229
- let L = {
268
+ function O(e) {
269
+ const t = new CustomEvent("notification", {
270
+ bubbles: !0,
271
+ cancelable: !1,
272
+ detail: e
273
+ });
274
+ dispatchEvent(t);
275
+ }
276
+ const wt = {
277
+ success: (e, t) => {
278
+ O({
279
+ type: "success",
280
+ message: e,
281
+ options: t
282
+ });
283
+ },
284
+ info: (e, t) => {
285
+ O({
286
+ type: "info",
287
+ message: e,
288
+ options: t
289
+ });
290
+ },
291
+ warning: (e, t) => {
292
+ O({
293
+ type: "warning",
294
+ message: e,
295
+ options: t
296
+ });
297
+ },
298
+ error: (e, t) => {
299
+ O({
300
+ type: "error",
301
+ message: e,
302
+ options: t
303
+ });
304
+ }
305
+ };
306
+ var te = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(te || {});
307
+ let U = {
230
308
  level: 1,
231
309
  enableConsoleOutput: !0
232
310
  };
233
- function ot(e) {
234
- L = { ...L, ...e };
311
+ function St(e) {
312
+ U = { ...U, ...e };
235
313
  }
236
- function $(e, t, r) {
237
- if (e < L.level) return;
238
- const a = (/* @__PURE__ */ new Date()).toISOString(), o = `${`[${K[e]}][${a}]`} ${t}`;
239
- if (L.enableConsoleOutput)
314
+ function D(e, t, r) {
315
+ if (e < U.level) return;
316
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = `${`[${te[e]}][${n}]`} ${t}`;
317
+ if (U.enableConsoleOutput)
240
318
  switch (e) {
241
319
  case 0:
242
320
  console.debug(o, r || "");
@@ -252,135 +330,135 @@ function $(e, t, r) {
252
330
  break;
253
331
  }
254
332
  }
255
- function x(e, t) {
256
- $(0, e, t);
333
+ function p(e, t) {
334
+ D(0, e, t);
257
335
  }
258
- function S(e, t) {
259
- $(1, e, t);
336
+ function w(e, t) {
337
+ D(1, e, t);
260
338
  }
261
339
  function C(e, t) {
262
- $(2, e, t);
340
+ D(2, e, t);
263
341
  }
264
- function h(e, t) {
265
- $(3, e, t);
342
+ function f(e, t) {
343
+ D(3, e, t);
266
344
  }
267
- function st(e, t, r) {
345
+ function mt(e, t, r) {
268
346
  var o, s, c, i;
269
347
  if (!e || !t) return;
270
348
  if (r) {
271
- const l = Object.keys(t.queries).find((I) => I === (r == null ? void 0 : r.toLowerCase()));
272
- let f;
273
- l && (f = t.queries[l]);
274
- const v = (s = ((o = f == null ? void 0 : f.columnsInfo) == null ? void 0 : o.columns) || []) == null ? void 0 : s.find((I) => {
275
- var q, Q;
276
- return (Q = (q = I.aliases) == null ? void 0 : q.split(",")) == null ? void 0 : Q.includes(e);
349
+ const l = Object.keys(t.queries).find((N) => N === (r == null ? void 0 : r.toLowerCase()));
350
+ let h;
351
+ l && (h = t.queries[l]);
352
+ const v = (s = ((o = h == null ? void 0 : h.columnsInfo) == null ? void 0 : o.columns) || []) == null ? void 0 : s.find((N) => {
353
+ var J, z;
354
+ return (z = (J = N.aliases) == null ? void 0 : J.split(",")) == null ? void 0 : z.includes(e);
277
355
  });
278
356
  if (v) return v.name;
279
357
  }
280
- const a = (i = (c = t.indexes) == null ? void 0 : c._) == null ? void 0 : i.columns, n = Object.entries(a).find((l) => {
281
- var f;
282
- return (f = l[1].aliases) == null ? void 0 : f.includes(e);
358
+ const n = (i = (c = t.indexes) == null ? void 0 : c._) == null ? void 0 : i.columns, a = Object.entries(n).find((l) => {
359
+ var h;
360
+ return (h = l[1].aliases) == null ? void 0 : h.includes(e);
283
361
  });
284
- if (n) return n[0];
362
+ if (a) return a[0];
285
363
  }
286
- function ct(e, t) {
364
+ function kt(e, t) {
287
365
  const r = e[t];
288
- return r === void 0 ? [] : Array.isArray(r) ? r.map((a) => {
289
- if (typeof a == "string")
290
- return a;
291
- if (typeof a == "object" && a !== null && "display" in a)
292
- return a.display;
293
- }).filter((a) => a !== void 0) : [String(r)];
294
- }
295
- function D(e) {
366
+ return r === void 0 ? [] : Array.isArray(r) ? r.map((n) => {
367
+ if (typeof n == "string")
368
+ return n;
369
+ if (typeof n == "object" && n !== null && "display" in n)
370
+ return n.display;
371
+ }).filter((n) => n !== void 0) : [String(r)];
372
+ }
373
+ function A(e) {
296
374
  return e !== null && typeof e == "object";
297
375
  }
298
- function le(e) {
299
- return D(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
376
+ function ke(e) {
377
+ return A(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
300
378
  }
301
- function ue(e) {
302
- return D(e) && Object.prototype.toString.call(e) === "[object Blob]";
379
+ function ge(e) {
380
+ return A(e) && Object.prototype.toString.call(e) === "[object Blob]";
303
381
  }
304
- function de(e) {
382
+ function be(e) {
305
383
  return typeof e == "string";
306
384
  }
307
- function it(e) {
308
- return (D(e) || Array.isArray(e)) && !le(e) && !ue(e) && !de(e);
385
+ function gt(e) {
386
+ return (A(e) || Array.isArray(e)) && !ke(e) && !ge(e) && !be(e);
309
387
  }
310
- function fe(e = !0) {
388
+ function Ce(e = !0) {
311
389
  let t = Date.now();
312
- return (e ? "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" : "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g, (a) => {
313
- const n = (t + Math.random() * 16) % 16 | 0;
314
- return t = Math.floor(t / 16), (a === "x" ? n : n & 3 | 8).toString(16);
390
+ return (e ? "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" : "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g, (n) => {
391
+ const a = (t + Math.random() * 16) % 16 | 0;
392
+ return t = Math.floor(t / 16), (n === "x" ? a : a & 3 | 8).toString(16);
315
393
  });
316
394
  }
317
- function lt(e) {
395
+ function bt(e) {
318
396
  if (!e)
319
397
  return "``";
320
398
  if (e = String(e), e.search(/[\\`]/) === -1)
321
399
  return "`" + e + "`";
322
400
  const t = ["`"];
323
- for (let r = 0, a = e.length; r < a; r++) {
324
- const n = e[r];
325
- (n === "\\" || n === "`") && t.push("\\"), t.push(n);
401
+ for (let r = 0, n = e.length; r < n; r++) {
402
+ const a = e[r];
403
+ (a === "\\" || a === "`") && t.push("\\"), t.push(a);
326
404
  }
327
405
  return t.push("`"), t.join("");
328
406
  }
329
- function ut(e) {
407
+ function Ct(e) {
330
408
  return crypto.subtle.digest("SHA-512", new TextEncoder().encode(e)).then((t) => Array.prototype.map.call(new Uint8Array(t), (r) => ("00" + r.toString(16)).slice(-2)).join(""));
331
409
  }
332
- var k = /* @__PURE__ */ ((e) => (e.None = "None", e.Search_FirstPage = "Search_FirstPage", e.Search_Text = "Search_Text", e.Search_Refine = "Search_Refine", e.Search_Select_Item = "Search_Select_Item", e.Search_Select_Custom = "Search_Select_Custom", e.Search_Select_Concept = "Search_Select_Concept", e.Search_Select_Correction = "Search_Select_Correction", e.Search_GotoPage = "Search_GotoPage", e.Search_GotoTab = "Search_GotoTab", e.Search_DisplayResult = "Search_DisplayResult", e.Search_RemoveResult = "Search_RemoveResult", e.Search_RemoveAdvanced = "Search_RemoveAdvanced", e.Search_SavedQuery = "Search_SavedQuery", e.Search_WebService = "Search_WebService", e.Search_DidYouMean_Original = "Search_DidYouMean_Original", e.Search_DidYouMean_Correction = "Search_DidYouMean_Correction", e.Search_ExportCSV = "Search_ExportCSV", e.Search_SavedQuery_ExportCSV = "Search_SavedQuery_ExportCSV", e.Search_Selection_ExportCSV = "Search_Selection_ExportCSV", e.Search_AlertQuery = "Search_AlertQuery", e.Search_Select_AnalyticsItem = "Search_Select_AnalyticsItem", e.Search_Sort = "Search_Sort", e.Search_Exit_Logout = "Search_Exit_Logout", e.Search_Timeline_Usage = "Search_Timeline_Usage", e.Search_AutoComplete = "Search_Autocomplete", e.Search_Login_Success = "Login_Success_Form", e.Search_QueryIntent_Detected = "Search_QueryIntent_Detected", e.SavedQuery_Add = "SavedQuery_Add", e.SavedQuery_Delete = "SavedQuery_Delete", e.SavedQuery_DeleteAll = "SavedQuery_DeleteAll", e.SavedQuery_Rename = "SavedQuery_Rename", e.Alert_Edit = "Alert_Edit", e.Alert_Delete = "Alert_Delete", e.Alert_DeleteAll = "Alert_DeleteAll", e.Link_Display = "Link_Display", e.Link_Click = "Link_Click", e.Basket_Add = "Basket_Add", e.Basket_Delete = "Basket_Delete", e.Basket_DeleteAll = "Basket_DeleteAll", e.Basket_Rename = "Basket_Rename", e.Basket_AddDoc = "Basket_AddDoc", e.Basket_RemoveDoc = "Basket_RemoveDoc", e.Basket_Open = "Basket_Open", e.Basket_ExportCSV = "Basket_ExportCSV", e.Label_Add = "Label_Add", e.Label_Delete = "Label_Delete", e.Label_Rename = "Label_Rename", e.Label_Open = "Label_Open", e.Label_AddDoc = "Label_AddDoc", e.Label_RemoveDoc = "Label_RemoveDoc", e.Label_ExportCSV = "Label_ExportCSV", e.Label_Menu_ExportCSV = "Label_Menu_ExportCSV", e.Rating_Set = "Rating_Set", e.Rating_Delete = "Rating_Delete", e.Doc_Preview = "Doc_Preview", e.Doc_CacheHtml = "Doc_CacheHtml", e.Doc_CachePdf = "Doc_CachePdf", e.Doc_CacheOriginal = "Doc_CacheOriginal", e.Doc_Url1 = "Doc_Url1", e.Doc_Url2 = "Doc_Url2", e.Preview_Close = "Preview_Close", e.Click_ResultLink = "Click_ResultLink", e.Click_ResultLink1 = "Click_ResultLink1", e.Click_ResultLink2 = "Click_ResultLink2", e.Click_ResultLink3 = "Click_ResultLink3", e.Click_ResultLink4 = "Click_ResultLink4", e.Click_ResultLink5 = "Click_ResultLink5", e.Click_ResultLink6 = "Click_ResultLink6", e.Click_ResultLink7 = "Click_ResultLink7", e.Click_ResultLink8 = "Click_ResultLink8", e.Click_ResultLink9 = "Click_ResultLink9", e.Click_ResultLink10 = "Click_ResultLink10", e.Click_PreviewLink1 = "Click_PreviewLink1", e.Click_PreviewLink2 = "Click_PreviewLink2", e.Click_PreviewLink3 = "Click_PreviewLink3", e.Click_PreviewLink4 = "Click_PreviewLink4", e.Click_PreviewLink5 = "Click_PreviewLink5", e.Click_PreviewLink6 = "Click_PreviewLink6", e.Click_PreviewLink7 = "Click_PreviewLink7", e.Click_PreviewLink8 = "Click_PreviewLink8", e.Click_PreviewLink9 = "Click_PreviewLink9", e.Click_PreviewLink10 = "Click_PreviewLink10", e.RFM_ClickSet = "RFM_ClickSet", e.RFM_ClickReset = "RFM_ClickReset", e.RFM_Like = "RFM_Like", e.RFM_LikeReset = "RFM_LikeReset", e.RFM_Dislike = "RFM_Dislike", e.RFM_Important = "RFM_Important", e.RFM_ImportantReset = "RFM_ImportantReset", e.RFM_Ban = "RFM_Ban", e.Navigation_Exit = "Navigation_Exit", e.Navigation_Return = "Navigation_Return", e.Navigation_Route = "Navigation_Route", e.Answer_Display = "Answer_Display", e.Answer_Click = "Answer_Click", e.Answer_Result = "Answer_Result", e.Answer_Liked = "Answer_Liked", e.Answer_Disliked = "Answer_Disliked", e.Answer_Liked_Cancelled = "Answer_Liked_Cancelled", e.Answer_Disliked_Cancelled = "Answer_Disliked_Cancelled", e.TopPassages_Display = "TopPassages_Display", e.TopPassages_Click = "TopPassages_Click", e.UserSettings_Reset = "UserSettings_Reset", e))(k || {}), he = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.bool = 1] = "bool", e[e.date = 2] = "date", e[e.dateTime = 3] = "dateTime", e[e.time = 4] = "time", e[e.unsigned = 5] = "unsigned", e[e.integer = 6] = "integer", e[e.float = 7] = "float", e[e.double = 8] = "double", e[e.dates = 9] = "dates", e[e.dateTimes = 10] = "dateTimes", e[e.times = 11] = "times", e[e.varchar = 12] = "varchar", e[e.binary = 13] = "binary", e[e.string = 14] = "string", e[e.csv = 15] = "csv", e))(he || {}), _e = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.a = 2053] = "a", e[e.c = 4] = "c", e[e.d = 8] = "d", e[e.e = 2068] = "e", e[e.i = 256] = "i", e[e.l = 2052] = "l", e[e.n = 8192] = "n", e[e.t = 524292] = "t", e[e.x = 8388608] = "x", e[e.z = 33554432] = "z", e[e.f_ordinal = 8192] = "f_ordinal", e[e.f_multidates = 8192] = "f_multidates", e[e.f_varchar = 33554432] = "f_varchar", e[e.f_binary = 33562624] = "f_binary", e[e.f_string = 33562888] = "f_string", e[e.f_csv = 42477853] = "f_csv", e[e.f_overridable = 33554696] = "f_overridable", e))(_e || {});
333
- const dt = "1.0";
334
- var Se = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(Se || {}), me = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.positiveRate = 1] = "positiveRate", e[e.mainlyPosRate = 2] = "mainlyPosRate", e[e.unrate = 4] = "unrate", e[e.mainlyNegRate = 8] = "mainlyNegRate", e[e.negativeRate = 16] = "negativeRate", e[e.all = 31] = "all", e[e.positiveOnly = 7] = "positiveOnly", e[e.negativeOnly = 28] = "negativeOnly", e[e.personalAll = 21] = "personalAll", e[e.personalPosOnly = 5] = "personalPosOnly", e[e.personalNegOnly = 20] = "personalNegOnly", e))(me || {});
335
- class w extends Error {
336
- constructor(r, a) {
410
+ var k = /* @__PURE__ */ ((e) => (e.None = "None", e.Search_FirstPage = "Search_FirstPage", e.Search_Text = "Search_Text", e.Search_Refine = "Search_Refine", e.Search_Select_Item = "Search_Select_Item", e.Search_Select_Custom = "Search_Select_Custom", e.Search_Select_Concept = "Search_Select_Concept", e.Search_Select_Correction = "Search_Select_Correction", e.Search_GotoPage = "Search_GotoPage", e.Search_GotoTab = "Search_GotoTab", e.Search_DisplayResult = "Search_DisplayResult", e.Search_RemoveResult = "Search_RemoveResult", e.Search_RemoveAdvanced = "Search_RemoveAdvanced", e.Search_SavedQuery = "Search_SavedQuery", e.Search_WebService = "Search_WebService", e.Search_DidYouMean_Original = "Search_DidYouMean_Original", e.Search_DidYouMean_Correction = "Search_DidYouMean_Correction", e.Search_ExportCSV = "Search_ExportCSV", e.Search_SavedQuery_ExportCSV = "Search_SavedQuery_ExportCSV", e.Search_Selection_ExportCSV = "Search_Selection_ExportCSV", e.Search_AlertQuery = "Search_AlertQuery", e.Search_Select_AnalyticsItem = "Search_Select_AnalyticsItem", e.Search_Sort = "Search_Sort", e.Search_Exit_Logout = "Search_Exit_Logout", e.Search_Timeline_Usage = "Search_Timeline_Usage", e.Search_AutoComplete = "Search_Autocomplete", e.Search_Login_Success = "Login_Success_Form", e.Search_QueryIntent_Detected = "Search_QueryIntent_Detected", e.SavedQuery_Add = "SavedQuery_Add", e.SavedQuery_Delete = "SavedQuery_Delete", e.SavedQuery_DeleteAll = "SavedQuery_DeleteAll", e.SavedQuery_Rename = "SavedQuery_Rename", e.Alert_Edit = "Alert_Edit", e.Alert_Delete = "Alert_Delete", e.Alert_DeleteAll = "Alert_DeleteAll", e.Link_Display = "Link_Display", e.Link_Click = "Link_Click", e.Basket_Add = "Basket_Add", e.Basket_Delete = "Basket_Delete", e.Basket_DeleteAll = "Basket_DeleteAll", e.Basket_Rename = "Basket_Rename", e.Basket_AddDoc = "Basket_AddDoc", e.Basket_RemoveDoc = "Basket_RemoveDoc", e.Basket_Open = "Basket_Open", e.Basket_ExportCSV = "Basket_ExportCSV", e.Label_Add = "Label_Add", e.Label_Delete = "Label_Delete", e.Label_Rename = "Label_Rename", e.Label_Open = "Label_Open", e.Label_AddDoc = "Label_AddDoc", e.Label_RemoveDoc = "Label_RemoveDoc", e.Label_ExportCSV = "Label_ExportCSV", e.Label_Menu_ExportCSV = "Label_Menu_ExportCSV", e.Rating_Set = "Rating_Set", e.Rating_Delete = "Rating_Delete", e.Doc_Preview = "Doc_Preview", e.Doc_CacheHtml = "Doc_CacheHtml", e.Doc_CachePdf = "Doc_CachePdf", e.Doc_CacheOriginal = "Doc_CacheOriginal", e.Doc_Url1 = "Doc_Url1", e.Doc_Url2 = "Doc_Url2", e.Preview_Close = "Preview_Close", e.Click_ResultLink = "Click_ResultLink", e.Click_ResultLink1 = "Click_ResultLink1", e.Click_ResultLink2 = "Click_ResultLink2", e.Click_ResultLink3 = "Click_ResultLink3", e.Click_ResultLink4 = "Click_ResultLink4", e.Click_ResultLink5 = "Click_ResultLink5", e.Click_ResultLink6 = "Click_ResultLink6", e.Click_ResultLink7 = "Click_ResultLink7", e.Click_ResultLink8 = "Click_ResultLink8", e.Click_ResultLink9 = "Click_ResultLink9", e.Click_ResultLink10 = "Click_ResultLink10", e.Click_PreviewLink1 = "Click_PreviewLink1", e.Click_PreviewLink2 = "Click_PreviewLink2", e.Click_PreviewLink3 = "Click_PreviewLink3", e.Click_PreviewLink4 = "Click_PreviewLink4", e.Click_PreviewLink5 = "Click_PreviewLink5", e.Click_PreviewLink6 = "Click_PreviewLink6", e.Click_PreviewLink7 = "Click_PreviewLink7", e.Click_PreviewLink8 = "Click_PreviewLink8", e.Click_PreviewLink9 = "Click_PreviewLink9", e.Click_PreviewLink10 = "Click_PreviewLink10", e.RFM_ClickSet = "RFM_ClickSet", e.RFM_ClickReset = "RFM_ClickReset", e.RFM_Like = "RFM_Like", e.RFM_LikeReset = "RFM_LikeReset", e.RFM_Dislike = "RFM_Dislike", e.RFM_Important = "RFM_Important", e.RFM_ImportantReset = "RFM_ImportantReset", e.RFM_Ban = "RFM_Ban", e.Navigation_Exit = "Navigation_Exit", e.Navigation_Return = "Navigation_Return", e.Navigation_Route = "Navigation_Route", e.Answer_Display = "Answer_Display", e.Answer_Click = "Answer_Click", e.Answer_Result = "Answer_Result", e.Answer_Liked = "Answer_Liked", e.Answer_Disliked = "Answer_Disliked", e.Answer_Liked_Cancelled = "Answer_Liked_Cancelled", e.Answer_Disliked_Cancelled = "Answer_Disliked_Cancelled", e.TopPassages_Display = "TopPassages_Display", e.TopPassages_Click = "TopPassages_Click", e.UserSettings_Reset = "UserSettings_Reset", e))(k || {}), Re = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.bool = 1] = "bool", e[e.date = 2] = "date", e[e.dateTime = 3] = "dateTime", e[e.time = 4] = "time", e[e.unsigned = 5] = "unsigned", e[e.integer = 6] = "integer", e[e.float = 7] = "float", e[e.double = 8] = "double", e[e.dates = 9] = "dates", e[e.dateTimes = 10] = "dateTimes", e[e.times = 11] = "times", e[e.varchar = 12] = "varchar", e[e.binary = 13] = "binary", e[e.string = 14] = "string", e[e.csv = 15] = "csv", e))(Re || {}), pe = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.a = 2053] = "a", e[e.c = 4] = "c", e[e.d = 8] = "d", e[e.e = 2068] = "e", e[e.i = 256] = "i", e[e.l = 2052] = "l", e[e.n = 8192] = "n", e[e.t = 524292] = "t", e[e.x = 8388608] = "x", e[e.z = 33554432] = "z", e[e.f_ordinal = 8192] = "f_ordinal", e[e.f_multidates = 8192] = "f_multidates", e[e.f_varchar = 33554432] = "f_varchar", e[e.f_binary = 33562624] = "f_binary", e[e.f_string = 33562888] = "f_string", e[e.f_csv = 42477853] = "f_csv", e[e.f_overridable = 33554696] = "f_overridable", e))(pe || {});
411
+ const Rt = "1.0";
412
+ var ve = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(ve || {}), xe = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.positiveRate = 1] = "positiveRate", e[e.mainlyPosRate = 2] = "mainlyPosRate", e[e.unrate = 4] = "unrate", e[e.mainlyNegRate = 8] = "mainlyNegRate", e[e.negativeRate = 16] = "negativeRate", e[e.all = 31] = "all", e[e.positiveOnly = 7] = "positiveOnly", e[e.negativeOnly = 28] = "negativeOnly", e[e.personalAll = 21] = "personalAll", e[e.personalPosOnly = 5] = "personalPosOnly", e[e.personalNegOnly = 20] = "personalNegOnly", e))(xe || {});
413
+ class m extends Error {
414
+ constructor(r, n) {
337
415
  super(r);
338
- G(this, "status");
339
- this.name = "ApiError", this.status = a;
416
+ H(this, "status");
417
+ this.name = "ApiError", this.status = n;
340
418
  }
341
419
  }
342
- class Z extends w {
420
+ class re extends m {
343
421
  constructor(t = "Unauthorized access") {
344
422
  super(t, 401), this.name = "UnauthorizedError";
345
423
  }
346
424
  }
347
- class we extends w {
425
+ class Pe extends m {
348
426
  constructor(t = "Server error") {
349
427
  super(t, 500), this.name = "ServerError";
350
428
  }
351
429
  }
352
- class ke extends w {
430
+ class Le extends m {
353
431
  constructor(t = "Request timed out") {
354
432
  super(t, 408), this.name = "TimeoutError";
355
433
  }
356
434
  }
357
- function ft(e) {
435
+ function pt(e) {
358
436
  const t = new AbortController(), { signal: r } = t;
359
437
  return e && setTimeout(() => {
360
- r.aborted || t.abort(new ke(`Request timed out after ${e}ms`));
438
+ r.aborted || t.abort(new Le(`Request timed out after ${e}ms`));
361
439
  }, e), { controller: t, signal: r };
362
440
  }
363
- async function ht(e, t = 0, r = 1e3) {
364
- let a;
365
- for (let n = 0; n <= t; n++)
441
+ async function vt(e, t = 0, r = 1e3) {
442
+ let n;
443
+ for (let a = 0; a <= t; a++)
366
444
  try {
367
445
  return await e();
368
446
  } catch (o) {
369
- if (a = o, o instanceof w && o.status >= 400 && o.status < 500 && o.status !== 429 || o instanceof DOMException && o.name === "AbortError")
447
+ if (n = o, o instanceof m && o.status >= 400 && o.status < 500 && o.status !== 429 || o instanceof DOMException && o.name === "AbortError")
370
448
  throw o;
371
- n < t && (C(`Retrying request (${n + 1}/${t})`, { error: o }), await new Promise((s) => setTimeout(s, r)));
449
+ a < t && (C(`Retrying request (${a + 1}/${t})`, { error: o }), await new Promise((s) => setTimeout(s, r)));
372
450
  }
373
- throw a;
451
+ throw n;
374
452
  }
375
- function p(e) {
376
- const t = O(), r = new Headers(e);
453
+ function P(e) {
454
+ const t = $(), r = new Headers(e);
377
455
  r.append("Sinequa-Force-Camel-Case", "true"), r.append("accept", "application/json"), t && r.append("Sinequa-csrf-token", t);
378
- const { userOverride: a, userOverrideActive: n, bearerToken: o } = u;
379
- return o && r.append("Authorization", `Bearer ${o}`), a && n && (r.append("sinequa-override-user", a.username), r.append("sinequa-override-domain", a.domain)), r;
456
+ const { userOverride: n, userOverrideActive: a, bearerToken: o } = u;
457
+ return o && r.append("Authorization", `Bearer ${o}`), n && a && (r.append("sinequa-override-user", n.username), r.append("sinequa-override-domain", n.domain)), r;
380
458
  }
381
459
  async function g(e, t = "json") {
382
460
  const r = e.headers.get("sinequa-jwt-refresh");
383
- if (r !== null && F(r), e.status === 200)
461
+ if (r !== null && V(r), e.status === 200)
384
462
  switch (t) {
385
463
  case "arraybuffer":
386
464
  return await e.arrayBuffer();
@@ -394,141 +472,141 @@ async function g(e, t = "json") {
394
472
  }
395
473
  if (e.status === 401) {
396
474
  if (u.userOverrideActive)
397
- throw u.userOverrideActive = !1, C("Unauthorized access attempt with user override", { endpoint: e.url }), new Z("Unauthorized... User override failed.");
398
- await W(e, 401);
475
+ throw u.userOverrideActive = !1, C("Unauthorized access attempt with user override", { endpoint: e.url }), new re("Unauthorized... User override failed.");
476
+ await M(e, 401);
399
477
  }
400
- throw e.status === 500 && (h("Server error occurred", { endpoint: e.url }), await W(e, 500)), C(`Unexpected response status: ${e.status}`, { endpoint: e.url }), new w(`Request failed with status ${e.status}`, e.status);
478
+ throw e.status === 500 && (f("Server error occurred", { endpoint: e.url }), await M(e, 500)), C(`Unexpected response status: ${e.status}`, { endpoint: e.url }), new m(`Request failed with status ${e.status}`, e.status);
401
479
  }
402
- async function W(e, t) {
480
+ async function M(e, t) {
403
481
  var r;
404
482
  try {
405
- const { done: a, value: n } = await ((r = e.body) == null ? void 0 : r.getReader().read()) || { done: !0, value: void 0 };
406
- if (a || !n)
407
- throw new w(`Request failed with status ${t}`, t);
408
- const o = JSON.parse(new TextDecoder().decode(n));
483
+ const { done: n, value: a } = await ((r = e.body) == null ? void 0 : r.getReader().read()) || { done: !0, value: void 0 };
484
+ if (n || !a)
485
+ throw new m(`Request failed with status ${t}`, t);
486
+ const o = JSON.parse(new TextDecoder().decode(a));
409
487
  throw o.status = t, o;
410
- } catch (a) {
411
- throw a instanceof w ? a : t === 401 ? new Z("Failed to parse error response") : t === 500 ? new we("Failed to parse error response") : new w(`Request failed with status ${t}`, t);
488
+ } catch (n) {
489
+ throw n instanceof m ? n : t === 401 ? new re() : t === 500 ? new Pe() : new m(`Request failed with status ${t}`, t);
412
490
  }
413
491
  }
414
492
  async function d(e, t, r) {
415
- const a = p(r == null ? void 0 : r.headers), { app: n, backendUrl: o, apiPath: s } = u, c = {
416
- app: n,
493
+ const n = P(r == null ? void 0 : r.headers), { app: a, backendUrl: o, apiPath: s } = u, c = {
494
+ app: a,
417
495
  ...t,
418
496
  locale: t.locale || navigator.language,
419
497
  noUserOverride: !0,
420
498
  noAutoAuthentication: !0
421
499
  }, i = `${o}/${s}/${e}`;
422
- x(`Making POST request to: ${i}`);
500
+ p(`Making POST request to: ${i}`);
423
501
  try {
424
502
  const l = await fetch(
425
503
  i,
426
504
  {
427
505
  method: "POST",
428
- headers: a,
506
+ headers: n,
429
507
  credentials: "include",
430
508
  body: JSON.stringify(c)
431
509
  }
432
510
  );
433
511
  return g(l, r == null ? void 0 : r.responseType);
434
512
  } catch (l) {
435
- throw h("Error making POST request:", l), l;
513
+ throw f("Error making POST request:", l), l;
436
514
  }
437
515
  }
438
516
  async function b(e, t, r) {
439
- const a = p(r == null ? void 0 : r.headers), { backendUrl: n, apiPath: o } = u, s = t ? `?${new URLSearchParams(t)}` : "", c = `${n}/${o}/${e}${s}`;
440
- x(`Making GET request to: ${c}`);
517
+ const n = P(r == null ? void 0 : r.headers), { backendUrl: a, apiPath: o } = u, s = t ? `?${new URLSearchParams(t)}` : "", c = `${a}/${o}/${e}${s}`;
518
+ p(`Making GET request to: ${c}`);
441
519
  try {
442
520
  const i = await fetch(
443
521
  c,
444
522
  {
445
523
  method: "GET",
446
524
  credentials: "include",
447
- headers: a
525
+ headers: n
448
526
  }
449
527
  );
450
528
  return g(i, r == null ? void 0 : r.responseType);
451
529
  } catch (i) {
452
- throw h("Error making GET request:", i), i;
530
+ throw f("Error making GET request:", i), i;
453
531
  }
454
532
  }
455
- async function _t(e, t, r) {
456
- const a = p(r == null ? void 0 : r.headers), { app: n, backendUrl: o, apiPath: s } = u, c = {
457
- app: n,
533
+ async function xt(e, t, r) {
534
+ const n = P(r == null ? void 0 : r.headers), { app: a, backendUrl: o, apiPath: s } = u, c = {
535
+ app: a,
458
536
  ...t,
459
537
  locale: t.locale || navigator.language,
460
538
  noUserOverride: !0,
461
539
  noAutoAuthentication: !0
462
540
  }, i = `${o}/${s}/${e}`;
463
- x(`Making PUT request to: ${i}`);
541
+ p(`Making PUT request to: ${i}`);
464
542
  try {
465
543
  const l = await fetch(
466
544
  i,
467
545
  {
468
546
  method: "PUT",
469
- headers: a,
547
+ headers: n,
470
548
  credentials: "include",
471
549
  body: JSON.stringify(c)
472
550
  }
473
551
  );
474
552
  return g(l, r == null ? void 0 : r.responseType);
475
553
  } catch (l) {
476
- throw h("Error making PUT request:", l), l;
554
+ throw f("Error making PUT request:", l), l;
477
555
  }
478
556
  }
479
- async function St(e, t, r) {
480
- const a = p(r == null ? void 0 : r.headers), { backendUrl: n, apiPath: o } = u, s = t ? `?${new URLSearchParams(t)}` : "", c = `${n}/${o}/${e}${s}`;
481
- x(`Making DELETE request to: ${c}`);
557
+ async function Pt(e, t, r) {
558
+ const n = P(r == null ? void 0 : r.headers), { backendUrl: a, apiPath: o } = u, s = t ? `?${new URLSearchParams(t)}` : "", c = `${a}/${o}/${e}${s}`;
559
+ p(`Making DELETE request to: ${c}`);
482
560
  try {
483
561
  const i = await fetch(
484
562
  c,
485
563
  {
486
564
  method: "DELETE",
487
565
  credentials: "include",
488
- headers: a
566
+ headers: n
489
567
  }
490
568
  );
491
569
  return g(i, r == null ? void 0 : r.responseType);
492
570
  } catch (i) {
493
- throw h("Error making DELETE request:", i), i;
571
+ throw f("Error making DELETE request:", i), i;
494
572
  }
495
573
  }
496
- async function mt(e, t, r) {
497
- const a = p(r == null ? void 0 : r.headers), { app: n, backendUrl: o, apiPath: s } = u, c = {
498
- app: n,
574
+ async function Lt(e, t, r) {
575
+ const n = P(r == null ? void 0 : r.headers), { app: a, backendUrl: o, apiPath: s } = u, c = {
576
+ app: a,
499
577
  ...t,
500
578
  locale: t.locale || navigator.language,
501
579
  noUserOverride: !0,
502
580
  noAutoAuthentication: !0
503
581
  }, i = `${o}/${s}/${e}`;
504
- x(`Making PATCH request to: ${i}`);
582
+ p(`Making PATCH request to: ${i}`);
505
583
  try {
506
584
  const l = await fetch(
507
585
  i,
508
586
  {
509
587
  method: "PATCH",
510
- headers: a,
588
+ headers: n,
511
589
  credentials: "include",
512
590
  body: JSON.stringify(c)
513
591
  }
514
592
  );
515
593
  return g(l, r == null ? void 0 : r.responseType);
516
594
  } catch (l) {
517
- throw h("Error making PATCH request:", l), l;
595
+ throw f("Error making PATCH request:", l), l;
518
596
  }
519
597
  }
520
- let A, M;
521
- function P(e, t = !0) {
522
- let r = ge(e.$auditRecord);
523
- r && (be(r), t && Ce(r)), e.$auditRecord = r;
598
+ let q, ne;
599
+ function L(e, t = !0) {
600
+ let r = Oe(e.$auditRecord);
601
+ r && (Ue(r), t && $e(r)), e.$auditRecord = r;
524
602
  }
525
- function ge(e) {
603
+ function Oe(e) {
526
604
  if (!e)
527
605
  return;
528
606
  let t;
529
607
  if (Array.isArray(e))
530
608
  t = e;
531
- else if (D(e)) {
609
+ else if (A(e)) {
532
610
  const r = e;
533
611
  if (r.auditEvents || r.mlAuditEvents)
534
612
  return r;
@@ -536,91 +614,97 @@ function ge(e) {
536
614
  }
537
615
  return { auditEvents: t };
538
616
  }
539
- function be(e) {
617
+ function Ue(e) {
540
618
  var r;
541
- const t = Re();
542
- return (r = e.auditEvents) == null || r.forEach((a) => {
543
- a.detail || (a.detail = {}), a.detail.sessionid = t;
619
+ const t = ye();
620
+ return (r = e.auditEvents) == null || r.forEach((n) => {
621
+ n.detail || (n.detail = {}), n.detail.sessionid = t;
544
622
  }), e;
545
623
  }
546
- function Ce(e) {
624
+ function $e(e) {
547
625
  var r;
548
- const t = decodeURIComponent(window.location.href);
549
- return (r = e == null ? void 0 : e.auditEvents) == null || r.forEach((a) => {
550
- a.detail || (a.detail = {}), a.detail.url = t;
626
+ const t = typeof window < "u" ? decodeURIComponent(window.location.href) : "http://localhost";
627
+ return (r = e == null ? void 0 : e.auditEvents) == null || r.forEach((n) => {
628
+ n.detail || (n.detail = {}), n.detail.url = t;
551
629
  }), e;
552
630
  }
553
- function Re() {
554
- return (!A || xe()) && (A = fe()), M = /* @__PURE__ */ new Date(), A;
631
+ function ye() {
632
+ return (!q || Ie()) && (q = Ce()), ne = /* @__PURE__ */ new Date(), q;
555
633
  }
556
- function xe() {
557
- return (/* @__PURE__ */ new Date()).getTime() - M.getTime() > 10 * 60 * 1e3;
634
+ function Ie() {
635
+ return (/* @__PURE__ */ new Date()).getTime() - ne.getTime() > 10 * 60 * 1e3;
558
636
  }
559
- async function ve(e, t = !0) {
637
+ async function De(e, t = !0) {
560
638
  const r = {
561
639
  event: k.None,
562
640
  $auditRecord: e
563
641
  };
564
- return P(r, t), d("audit.notify", r);
642
+ return L(r, t), d("audit.notify", r);
565
643
  }
566
- const wt = { notify: ve };
567
- async function kt(e, t, r) {
568
- var f;
569
- const a = ((f = e.items) == null ? void 0 : f.length) || 0, n = 10, o = {
570
- query: { ...t, action: "aggregate", aggregations: { [e.name]: { skip: a, count: n } } },
644
+ const Ot = { notify: De };
645
+ async function Ut(e, t, r) {
646
+ var h;
647
+ const n = ((h = e.items) == null ? void 0 : h.length) || 0, a = 10, o = {
648
+ query: { ...t, action: "aggregate", aggregations: { [e.name]: { skip: n, count: a } } },
571
649
  $auditRecord: { auditEvents: [r] }
572
650
  };
573
- P(o);
651
+ L(o);
574
652
  const s = await d("query", o), c = await g(s), { aggregations: i } = c, l = i[0];
575
- return l.$hasMore = l.items.length > n, l.items = [...e.items, ...l.items], Promise.resolve(l);
653
+ return l.$hasMore = l.items.length > a, l.items = [...e.items, ...l.items], Promise.resolve(l);
576
654
  }
577
- async function gt() {
655
+ async function $t() {
578
656
  const { app: e } = u, t = new URLSearchParams({ app: e || "" });
579
657
  return b("app", t);
580
658
  }
581
- async function pe() {
659
+ async function Ae() {
582
660
  const { app: e } = u, t = new URLSearchParams({
583
661
  app: e || "",
584
662
  preLogin: "true"
585
663
  });
586
664
  return b("app", t);
587
665
  }
588
- function bt() {
666
+ function yt() {
589
667
  let { backendUrl: e, app: t } = u;
590
- if (e || (e = window.location.origin), !t) {
591
- const r = window.location.pathname.match(/\/app(?:-debug)?\/([^\/#]+)/);
592
- r && (t = r[1]);
668
+ if (typeof window < "u") {
669
+ if (e || (e = window.location.origin), !t) {
670
+ const r = window.location.pathname.match(
671
+ /\/app(?:-debug)?\/([^\/#]+)/
672
+ );
673
+ r && (t = r[1]);
674
+ }
675
+ S({
676
+ ...u,
677
+ backendUrl: e,
678
+ app: t
679
+ });
593
680
  }
594
- return m({
595
- ...u,
596
- backendUrl: e,
597
- app: t
598
- }), pe().then((r) => {
599
- const { autoOAuthProvider: a, autoSAMLProvider: n } = u, o = !a && !r.autoOAuthProvider && !n && !r.autoSAMLProvider;
600
- return m({
681
+ return Ae().then((r) => {
682
+ const { autoOAuthProvider: n, autoSAMLProvider: a } = u, o = !n && !r.autoOAuthProvider && !a && !r.autoSAMLProvider;
683
+ return S({
601
684
  ...u,
602
- autoOAuthProvider: a || r.autoOAuthProvider,
603
- autoSAMLProvider: n || r.autoSAMLProvider,
604
- useCredentialsOrSSO: o
685
+ autoOAuthProvider: n || r.autoOAuthProvider,
686
+ autoSAMLProvider: a || r.autoSAMLProvider,
687
+ useCredentials: o,
688
+ useSSO: o
605
689
  }), r;
606
690
  }).catch((r) => {
607
691
  throw console.error("atomic:fetchAppPreLogin error", r), r;
608
692
  });
609
693
  }
610
- async function Ct(e, t, r = {}) {
611
- const a = `search.dataset/${e}/${t}`, n = await d(a, { parameters: r }), o = t[0].toLowerCase() + t.slice(1), s = n.datasets[o];
694
+ async function It(e, t, r = {}) {
695
+ const n = `search.dataset/${e}/${t}`, a = await d(n, { parameters: r }), o = t[0].toLowerCase() + t.slice(1), s = a.datasets[o];
612
696
  if ("errorCode" in s && "errorMessage" in s)
613
697
  throw new Error(s.errorMessage);
614
698
  return s;
615
699
  }
616
- async function Rt(e, t) {
617
- const r = `search.dataset/${e}`, { parameters: a = {}, datasets: n = [] } = t;
618
- return (await d(r, { parameters: a, datasets: n })).datasets;
700
+ async function Dt(e, t) {
701
+ const r = `search.dataset/${e}`, { parameters: n = {}, datasets: a = [] } = t;
702
+ return (await d(r, { parameters: n, datasets: a })).datasets;
619
703
  }
620
- async function xt(e) {
704
+ async function At(e) {
621
705
  return await b(`search.dataset/${e}`);
622
706
  }
623
- async function vt(e, t = !0, r) {
707
+ async function Nt(e, t = !0, r) {
624
708
  try {
625
709
  return (await d("labels", {
626
710
  action: "list",
@@ -629,11 +713,11 @@ async function vt(e, t = !0, r) {
629
713
  locale: r,
630
714
  localize: !1
631
715
  })).labels;
632
- } catch (a) {
633
- throw h("Error in fetchLabels", a), a;
716
+ } catch (n) {
717
+ throw f("Error in fetchLabels", n), n;
634
718
  }
635
719
  }
636
- async function Pe() {
720
+ async function Ne() {
637
721
  try {
638
722
  const { app: e = "" } = u, t = new URLSearchParams({
639
723
  app: e,
@@ -641,12 +725,12 @@ async function Pe() {
641
725
  });
642
726
  return b("labels", t);
643
727
  } catch (e) {
644
- throw h("Error in getUserRights", e), e;
728
+ throw f("Error in getUserRights", e), e;
645
729
  }
646
730
  }
647
- async function Le(e, t, r = !0) {
731
+ async function Be(e, t, r = !0) {
648
732
  try {
649
- const a = {
733
+ const n = {
650
734
  action: "add",
651
735
  labels: e,
652
736
  ids: t,
@@ -670,14 +754,14 @@ async function Le(e, t, r = !0) {
670
754
  ]
671
755
  }
672
756
  };
673
- return d("labels", a);
674
- } catch (a) {
675
- throw h("Error in add", a), a;
757
+ return d("labels", n);
758
+ } catch (n) {
759
+ throw f("Error in add", n), n;
676
760
  }
677
761
  }
678
- async function Oe(e, t, r = !0) {
762
+ async function qe(e, t, r = !0) {
679
763
  try {
680
- const a = {
764
+ const n = {
681
765
  action: "remove",
682
766
  labels: e,
683
767
  ids: t,
@@ -701,14 +785,14 @@ async function Oe(e, t, r = !0) {
701
785
  ]
702
786
  }
703
787
  };
704
- return d("labels", a);
705
- } catch (a) {
706
- throw h("Error in remove", a), a;
788
+ return d("labels", n);
789
+ } catch (n) {
790
+ throw f("Error in remove", n), n;
707
791
  }
708
792
  }
709
- async function Ue(e, t, r = !0) {
793
+ async function Fe(e, t, r = !0) {
710
794
  try {
711
- const a = {
795
+ const n = {
712
796
  action: "rename",
713
797
  labels: e,
714
798
  newLabel: t,
@@ -722,12 +806,12 @@ async function Ue(e, t, r = !0) {
722
806
  }
723
807
  }
724
808
  };
725
- return d("labels", a);
726
- } catch (a) {
727
- throw h("Error in rename", a), a;
809
+ return d("labels", n);
810
+ } catch (n) {
811
+ throw f("Error in rename", n), n;
728
812
  }
729
813
  }
730
- async function $e(e, t = !0) {
814
+ async function Qe(e, t = !0) {
731
815
  try {
732
816
  const r = {
733
817
  action: "delete",
@@ -743,12 +827,12 @@ async function $e(e, t = !0) {
743
827
  };
744
828
  return d("labels", r);
745
829
  } catch (r) {
746
- throw h("Error in deleteLabels", r), r;
830
+ throw f("Error in deleteLabels", r), r;
747
831
  }
748
832
  }
749
- async function De(e, t, r = !0) {
833
+ async function Ge(e, t, r = !0) {
750
834
  try {
751
- const a = {
835
+ const n = {
752
836
  action: "bulkAdd",
753
837
  labels: e,
754
838
  query: t,
@@ -762,14 +846,14 @@ async function De(e, t, r = !0) {
762
846
  }
763
847
  }
764
848
  };
765
- return d("labels", a);
766
- } catch (a) {
767
- throw h("Error in bulkAdd", a), a;
849
+ return d("labels", n);
850
+ } catch (n) {
851
+ throw f("Error in bulkAdd", n), n;
768
852
  }
769
853
  }
770
- async function Ie(e, t, r = !0) {
854
+ async function je(e, t, r = !0) {
771
855
  try {
772
- const a = {
856
+ const n = {
773
857
  action: "bulkRemove",
774
858
  labels: e,
775
859
  query: t,
@@ -783,30 +867,36 @@ async function Ie(e, t, r = !0) {
783
867
  }
784
868
  }
785
869
  };
786
- return d("labels", a);
787
- } catch (a) {
788
- throw h("Error in bulkRemove", a), a;
870
+ return d("labels", n);
871
+ } catch (n) {
872
+ throw f("Error in bulkRemove", n), n;
789
873
  }
790
874
  }
791
- const pt = {
792
- getUserRights: Pe,
793
- add: Le,
794
- remove: Oe,
795
- rename: Ue,
796
- delete: $e,
797
- bulkAdd: De,
798
- bulkRemove: Ie
875
+ const Bt = {
876
+ getUserRights: Ne,
877
+ add: Be,
878
+ remove: qe,
879
+ rename: Fe,
880
+ delete: Qe,
881
+ bulkAdd: Ge,
882
+ bulkRemove: je
799
883
  };
800
- async function Pt(e, t) {
801
- const r = `${window.location.origin}${window.location.pathname}`, a = { name: t == null ? void 0 : t.name, text: t == null ? void 0 : t.text };
884
+ async function qt(e, t) {
885
+ if (typeof window > "u")
886
+ return d("preview", {
887
+ action: "get",
888
+ id: e,
889
+ query: t
890
+ });
891
+ const r = `${window.location.origin}${window.location.pathname}`, n = { name: t == null ? void 0 : t.name, text: t == null ? void 0 : t.text };
802
892
  return d("preview", {
803
893
  action: "get",
804
894
  id: e,
805
- query: a,
895
+ query: n,
806
896
  browserUrl: r
807
897
  });
808
898
  }
809
- async function Lt(e) {
899
+ async function Ft(e) {
810
900
  const t = new Headers();
811
901
  t.append("content-type", "text");
812
902
  const r = await fetch(
@@ -818,44 +908,44 @@ async function Lt(e) {
818
908
  );
819
909
  g(r);
820
910
  }
821
- async function ye() {
911
+ async function Ve() {
822
912
  const e = new URLSearchParams({
823
913
  action: "get",
824
914
  noAutoAuthentication: "true"
825
915
  });
826
916
  return b("principal", e);
827
917
  }
828
- const E = 11;
829
- async function Ot(e, t, r) {
918
+ const ae = 11;
919
+ async function Qt(e, t, r) {
830
920
  var s;
831
- const n = await d("query", {
921
+ const a = await d("query", {
832
922
  query: e,
833
923
  $auditRecord: t,
834
924
  queryIntentData: r
835
925
  });
836
- n.aggregations.forEach((c) => {
837
- c.$hasMore = !1, !c.isDistribution && !c.isTree && c.items && (c.$hasMore = c.items.length === E), c.isTree && c.items && B(c);
838
- }), (s = n.records) == null || s.map((c) => Object.assign(c, { value: c.title, type: "default" }));
839
- const o = { ...n, nextPage: n.page < Math.ceil(n.rowCount / n.pageSize) ? n.page + 1 : void 0, previousPage: n.page > 1 ? n.page - 1 : void 0 };
926
+ a.aggregations.forEach((c) => {
927
+ c.$hasMore = !1, !c.isDistribution && !c.isTree && c.items && (c.$hasMore = c.items.length === ae), c.isTree && c.items && j(c);
928
+ }), (s = a.records) == null || s.map((c) => Object.assign(c, { value: c.title, type: "default" }));
929
+ const o = { ...a, nextPage: a.page < Math.ceil(a.rowCount / a.pageSize) ? a.page + 1 : void 0, previousPage: a.page > 1 ? a.page - 1 : void 0 };
840
930
  return Promise.resolve(o);
841
931
  }
842
- async function Ut(e, t, r) {
843
- const { app: a = "" } = u, n = {
932
+ async function Gt(e, t, r) {
933
+ const { app: n = "" } = u, a = {
844
934
  methods: [],
845
935
  mode: t,
846
936
  propagateErrors: !0,
847
937
  $auditRecord: { auditEvents: [r] }
848
938
  };
849
939
  for (const c of e)
850
- n.methods.push({
940
+ a.methods.push({
851
941
  method: "query",
852
- app: a,
942
+ app: n,
853
943
  query: c
854
944
  });
855
- const o = await d("multi", n);
945
+ const o = await d("multi", a);
856
946
  o.results.forEach((c) => {
857
947
  c.aggregations.forEach((i) => {
858
- i.$hasMore = !1, !i.isDistribution && !i.isTree && i.items && (i.$hasMore = i.items.length === E), i.isTree && B(i);
948
+ i.$hasMore = !1, !i.isDistribution && !i.isTree && i.items && (i.$hasMore = i.items.length === ae), i.isTree && j(i);
859
949
  });
860
950
  }), o.results.forEach((c) => {
861
951
  var i;
@@ -864,23 +954,23 @@ async function Ut(e, t, r) {
864
954
  const s = o.results.map((c) => ({ ...c, nextPage: c.page < Math.ceil(c.rowCount / c.pageSize) ? c.page + 1 : void 0, previousPage: c.page > 1 ? c.page - 1 : void 0 }));
865
955
  return Promise.resolve(s);
866
956
  }
867
- function B(e, t = "", r = 0) {
868
- let a = [];
869
- return e.items && e.items.forEach((n) => {
870
- let o = t ? `${t}/${n.value}` : n.value, s = r + 1;
871
- a.push({ path: o, level: s }), n.$path = o, n.$level = s, n.hasChildren ? a = a.concat(B(n, o, s)) : n.hasChildren = !1;
872
- }), a;
957
+ function j(e, t = "", r = 0) {
958
+ let n = [];
959
+ return e.items && e.items.forEach((a) => {
960
+ let o = t ? `${t}/${a.value}` : a.value, s = r + 1;
961
+ n.push({ path: o, level: s }), a.$path = o, a.$level = s, a.hasChildren ? n = n.concat(j(a, o, s)) : a.hasChildren = !1;
962
+ }), n;
873
963
  }
874
- async function $t(e) {
964
+ async function jt(e) {
875
965
  const r = await d("queryintent", {
876
966
  query: e
877
967
  });
878
968
  return r == null ? void 0 : r.intents;
879
969
  }
880
- async function Dt({ model: e, appName: t, query: r, article: a }) {
881
- const { webservice: n, format: o, maxcount: s, exportedColumns: c, export: i } = e, l = {
970
+ async function Vt({ model: e, appName: t, query: r, article: n }) {
971
+ const { webservice: a, format: o, maxcount: s, exportedColumns: c, export: i } = e, l = {
882
972
  app: t,
883
- webservice: n,
973
+ webservice: a,
884
974
  query: r,
885
975
  type: i,
886
976
  format: o,
@@ -890,14 +980,14 @@ async function Dt({ model: e, appName: t, query: r, article: a }) {
890
980
  auditEvents: [{
891
981
  type: "Search_ExportCSV",
892
982
  detail: {
893
- resultid: a ? a.id : void 0
983
+ resultid: n ? n.id : void 0
894
984
  }
895
985
  }]
896
986
  }
897
987
  };
898
- return P(l), await d("search.queryexport", l, { responseType: "blob" });
988
+ return L(l), await d("search.queryexport", l, { responseType: "blob" });
899
989
  }
900
- async function It(e, t) {
990
+ async function Jt(e, t) {
901
991
  return await d(
902
992
  "similardocuments",
903
993
  {
@@ -908,22 +998,22 @@ async function It(e, t) {
908
998
  }
909
999
  );
910
1000
  }
911
- async function yt(e, t) {
912
- var n;
913
- const a = await d("query.links", {
1001
+ async function zt(e, t) {
1002
+ var a;
1003
+ const n = await d("query.links", {
914
1004
  webservice: e,
915
1005
  query: t
916
1006
  });
917
- return (n = a == null ? void 0 : a.links) == null ? void 0 : n.map((o) => ({ ...o, query: t }));
1007
+ return (a = n == null ? void 0 : n.links) == null ? void 0 : a.map((o) => ({ ...o, query: t }));
918
1008
  }
919
- async function At(e, t, r, a, n) {
1009
+ async function Ht(e, t, r, n, a) {
920
1010
  const { app: o } = u, s = {
921
1011
  app: o || "",
922
1012
  suggestQuery: e,
923
1013
  text: t,
924
1014
  filter: r,
925
- kinds: a,
926
- showSource: n
1015
+ kinds: n,
1016
+ showSource: a
927
1017
  };
928
1018
  try {
929
1019
  return (await d("search.suggest", s)).suggests;
@@ -931,17 +1021,17 @@ async function At(e, t, r, a, n) {
931
1021
  throw console.error("Error fetching suggestions:", c), c;
932
1022
  }
933
1023
  }
934
- async function Nt(e, t, r, a) {
935
- const { app: n } = u;
1024
+ async function Wt(e, t, r, n) {
1025
+ const { app: a } = u;
936
1026
  return (await d("suggestquery", {
937
- app: n || "",
1027
+ app: a || "",
938
1028
  suggestQuery: e,
939
1029
  text: t,
940
1030
  query: r,
941
- kinds: a
1031
+ kinds: n
942
1032
  })).suggests;
943
1033
  }
944
- async function Bt(e, t) {
1034
+ async function Xt(e, t) {
945
1035
  if (!t) return Promise.resolve([]);
946
1036
  const { app: r } = u;
947
1037
  return (await d("suggestfield", {
@@ -951,41 +1041,41 @@ async function Bt(e, t) {
951
1041
  fields: t
952
1042
  })).suggests;
953
1043
  }
954
- async function Ft(e, t, r, a, n, o) {
1044
+ async function Yt(e, t, r, n, a, o) {
955
1045
  return d("doc.textchunks", {
956
1046
  id: e,
957
1047
  textChunks: t,
958
1048
  highlights: r,
959
- query: a,
960
- leftSentencesCount: n,
1049
+ query: n,
1050
+ leftSentencesCount: a,
961
1051
  rightSentencesCount: o
962
1052
  });
963
1053
  }
964
- async function qt() {
1054
+ async function Kt() {
965
1055
  const { app: e } = u, t = new URLSearchParams({
966
1056
  app: e || "",
967
1057
  action: "load"
968
1058
  });
969
1059
  return b("usersettings", t);
970
1060
  }
971
- async function Ae(e, t) {
1061
+ async function Je(e, t) {
972
1062
  const r = {
973
1063
  action: "save",
974
1064
  userSettings: e,
975
1065
  $auditRecord: { auditEvents: [t] }
976
1066
  };
977
- return P(r), d("usersettings", r);
1067
+ return L(r), d("usersettings", r);
978
1068
  }
979
- async function Qt(e, t) {
980
- const a = {
1069
+ async function Zt(e, t) {
1070
+ const n = {
981
1071
  action: "patch",
982
1072
  userSettings: e,
983
1073
  $auditRecord: t ? { auditEvents: [t] } : void 0
984
1074
  };
985
- return P(a), d("usersettings", a);
1075
+ return L(n), d("usersettings", n);
986
1076
  }
987
- async function Gt() {
988
- return Ae({}, { type: "UserSettings_Reset" });
1077
+ async function Mt() {
1078
+ return Je({}, { type: "UserSettings_Reset" });
989
1079
  }
990
1080
  function _(e) {
991
1081
  const t = new CustomEvent(
@@ -998,8 +1088,16 @@ function _(e) {
998
1088
  );
999
1089
  dispatchEvent(t);
1000
1090
  }
1001
- const Ne = async () => {
1002
- const { autoOAuthProvider: e } = u, t = {
1091
+ const ze = async () => {
1092
+ const { autoOAuthProvider: e } = u;
1093
+ if (typeof window > "u")
1094
+ return d("security.oauth", {
1095
+ action: "getcode",
1096
+ provider: e,
1097
+ tokenInCookie: !0,
1098
+ originalUrl: "http://localhost"
1099
+ });
1100
+ const t = {
1003
1101
  action: "getcode",
1004
1102
  provider: e,
1005
1103
  tokenInCookie: !0,
@@ -1007,12 +1105,20 @@ const Ne = async () => {
1007
1105
  };
1008
1106
  try {
1009
1107
  const r = await d("security.oauth", t);
1010
- return r.redirectUrl && (localStorage.setItem("oauthRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1108
+ return r.redirectUrl && (E("oauthRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1011
1109
  } catch (r) {
1012
1110
  throw console.error("Failed to authenticate with OAuth", r), r;
1013
1111
  }
1014
- }, Be = async () => {
1015
- const { autoSAMLProvider: e } = u, t = {
1112
+ }, He = async () => {
1113
+ const { autoSAMLProvider: e } = u;
1114
+ if (typeof window > "u")
1115
+ return d("security.saml", {
1116
+ action: "getresponse",
1117
+ provider: e,
1118
+ tokenInCookie: !0,
1119
+ originalUrl: "http://localhost"
1120
+ });
1121
+ const t = {
1016
1122
  action: "getresponse",
1017
1123
  provider: e,
1018
1124
  tokenInCookie: !0,
@@ -1020,12 +1126,12 @@ const Ne = async () => {
1020
1126
  };
1021
1127
  try {
1022
1128
  const r = await d("security.saml", t);
1023
- return r.redirectUrl && (localStorage.setItem("samlRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1129
+ return r.redirectUrl && (E("samlRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1024
1130
  } catch (r) {
1025
1131
  throw console.error("Failed to authenticate with SAML", r), r;
1026
1132
  }
1027
- }, Fe = async (e) => {
1028
- const { username: t, password: r } = e || {}, a = {
1133
+ }, We = async (e) => {
1134
+ const { username: t, password: r } = e || {}, n = {
1029
1135
  action: "get",
1030
1136
  tokenInCookie: !0,
1031
1137
  user: t,
@@ -1034,179 +1140,180 @@ const Ne = async () => {
1034
1140
  noAutoAuthentication: !0
1035
1141
  };
1036
1142
  try {
1037
- const n = await d("security.webtoken", a);
1038
- return n.csrfToken ? (F(n.csrfToken), n.csrfToken) : null;
1039
- } catch (n) {
1040
- throw console.error("Failed to get JWT", n), n;
1143
+ const a = await d("security.webtoken", n);
1144
+ return a.csrfToken ? (V(a.csrfToken), a.csrfToken) : null;
1145
+ } catch (a) {
1146
+ throw console.error("Failed to get JWT", a), a;
1041
1147
  }
1042
- }, qe = async () => {
1148
+ }, Xe = async () => {
1043
1149
  const e = new URLSearchParams({
1044
1150
  action: "deleteWebTokenCookie",
1045
1151
  noUserOverride: "true",
1046
1152
  noAutoAuthentication: "true"
1047
1153
  });
1048
1154
  return b("challenge", e);
1049
- }, O = () => {
1050
- const e = localStorage.getItem("csrfToken"), t = sessionStorage.getItem("sinequa-credentials");
1155
+ }, $ = () => {
1156
+ const e = F("csrfToken"), t = ce("sinequa-credentials");
1051
1157
  return t ? JSON.parse(t).data.csrfToken : e || null;
1052
- }, F = (e) => sessionStorage.setItem("sinequa-credentials", JSON.stringify({ data: { csrfToken: e } })), jt = async (e) => {
1158
+ }, V = (e) => ie("sinequa-credentials", JSON.stringify({ data: { csrfToken: e } })), Et = async (e) => {
1053
1159
  if (e)
1054
- S("Attempting authentication using credentials"), m({ useCredentials: !0, useCredentialsOrSSO: !1, useSSO: !1 });
1160
+ w("Attempting authentication using credentials"), S({ useCredentials: !0, useSSO: !1 });
1055
1161
  else
1056
1162
  try {
1057
- const s = localStorage.getItem("oauthRedirectUrl"), c = localStorage.getItem("samlRedirectUrl");
1058
- S("Attempting to retrieve CSRF token");
1059
- const i = await Qe();
1060
- if (x("CSRF token retrieval result", i ? "success" : "failed"), i === null) {
1163
+ const s = F("oauthRedirectUrl"), c = F("samlRedirectUrl");
1164
+ w("Attempting to retrieve CSRF token");
1165
+ const i = await Ye();
1166
+ if (p("CSRF token retrieval result", i ? "success" : "failed"), i === null) {
1061
1167
  if (s || c)
1062
- return C("Redirection from provider failed after previous attempt"), localStorage.removeItem("oauthRedirectUrl"), localStorage.removeItem("samlRedirectUrl"), _(!1), !1;
1063
- const { autoOAuthProvider: l, autoSAMLProvider: f, useSAML: v } = u;
1168
+ return C("Redirection from provider failed after previous attempt"), x("oauthRedirectUrl"), x("samlRedirectUrl"), _(!1), !1;
1169
+ const { autoOAuthProvider: l, autoSAMLProvider: h, useSAML: v } = u;
1064
1170
  if (l && !v)
1065
- return S("Initiating OAuth authentication flow"), await Ne(), C("OAuth authentication flow did not redirect as expected"), _(!1), !1;
1066
- if (f)
1067
- return S("Initiating SAML authentication flow"), await Be(), C("SAML authentication flow did not redirect as expected"), _(!1), !1;
1068
- S("No direct authentication method available, will try SSO then credentials"), m({ useCredentials: !0, useSSO: !0, useCredentialsOrSSO: !0 });
1171
+ return w("Initiating OAuth authentication flow"), await ze(), C("OAuth authentication flow did not redirect as expected"), _(!1), !1;
1172
+ if (h)
1173
+ return w("Initiating SAML authentication flow"), await He(), C("SAML authentication flow did not redirect as expected"), _(!1), !1;
1174
+ w("No direct authentication method available, will try SSO then credentials"), S({ useCredentials: !0, useSSO: !0 });
1069
1175
  } else
1070
- return localStorage.removeItem("oauthRedirectUrl"), localStorage.removeItem("samlRedirectUrl"), S("User authenticated via existing token"), _(!0), !0;
1176
+ return x("oauthRedirectUrl"), x("samlRedirectUrl"), w("User authenticated via existing token"), _(!0), !0;
1071
1177
  } catch (s) {
1072
- throw h("Unexpected error during authentication", s), _(!1), s;
1178
+ throw f("Unexpected error during authentication", s), _(!1), s;
1073
1179
  }
1074
- const { useSSO: t, useCredentialsOrSSO: r, useCredentials: a } = u;
1075
- if (r)
1180
+ if (u.useCredentials && u.useSSO)
1076
1181
  try {
1077
- if (S("Checking if user is authenticated via SSO"), await ye())
1078
- return S("User authenticated using SSO"), m({ useCredentials: !1, useCredentialsOrSSO: !1, useSSO: !0 }), _(!0), !0;
1182
+ if (w("Checking if user is authenticated via SSO"), await Ve())
1183
+ return w("User authenticated using SSO"), S({ useCredentials: !1, useSSO: !0 }), _(!0), !0;
1079
1184
  } catch (s) {
1080
1185
  if ((s == null ? void 0 : s.status) === 401)
1081
- S("SSO authentication failed with 401, falling back to credentials"), m({ useCredentials: !0, useSSO: !1, useCredentialsOrSSO: !1 });
1082
- else
1083
- throw h("SSO authentication failed with unexpected error", s), _(!1), h;
1186
+ return w("SSO authentication failed with 401, falling back to credentials"), S({ useCredentials: !0, useSSO: !1 }), !1;
1187
+ throw f("SSO authentication failed with unexpected error", s), _(!1), f;
1084
1188
  }
1085
- if (O() || t)
1086
- return console.log("user already authenticated", O()), m({ isRedirectUrl: !1 }), _(!0), !0;
1087
- const { username: n, password: o } = e || {};
1088
- if (a && !n && !o)
1089
- return console.error("Credentials are required for authentication"), _(!1), !1;
1090
- if (n && o)
1189
+ const { useSSO: r } = u;
1190
+ if ($() !== null || r)
1191
+ return w("user already authenticated", $()), S({ isRedirectUrl: !1 }), _(!0), !0;
1192
+ const { useCredentials: n } = u, { username: a, password: o } = e || {};
1193
+ if (n && !a && !o)
1194
+ return f("Credentials are required for authentication"), _(!1), !1;
1195
+ if (a && o)
1091
1196
  try {
1092
- return console.log("authentication using credentials..."), m({ useCredentials: !0 }), await Fe(e), _(!0), !0;
1197
+ return w("authentication using credentials..."), S({ useCredentials: !0, useSSO: !1 }), await We(e), _(!0), !0;
1093
1198
  } catch (s) {
1094
1199
  throw _(!1), s;
1095
1200
  }
1096
- return _(!1), console.error("No authentication method available. Please provide credentials or configure OAuth/SAML."), !1;
1097
- }, Vt = async () => {
1201
+ return _(!1), f("No authentication method available. Please provide credentials or configure OAuth/SAML."), !1;
1202
+ }, Tt = async () => {
1098
1203
  const { useCredentials: e, userOverrideActive: t } = u;
1099
- localStorage.removeItem("csrfToken"), sessionStorage.removeItem("sinequa-credentials"), e && !t ? (await qe()).methodresult === "ok" ? _(!1) : console.error("logout failed") : _(!1);
1100
- }, zt = () => !!O(), Qe = async () => {
1204
+ x("csrfToken"), le("sinequa-credentials"), e && !t ? (await Xe()).methodresult === "ok" ? _(!1) : console.error("logout failed") : _(!1);
1205
+ }, er = () => !!$(), Ye = async () => {
1101
1206
  const { backendUrl: e, apiPath: t } = u;
1102
1207
  try {
1103
- const a = await (await fetch(`${e}/${t}/challenge?action=getCsrfToken&suppressErrors=true`)).json();
1104
- return a != null && a.csrfToken ? (F(a.csrfToken), a.csrfToken) : null;
1208
+ const n = await (await fetch(`${e}/${t}/challenge?action=getCsrfToken&suppressErrors=true`)).json();
1209
+ return n != null && n.csrfToken ? (V(n.csrfToken), n.csrfToken) : null;
1105
1210
  } catch (r) {
1106
1211
  throw console.error("Failed to get CSRF token", r), r;
1107
1212
  }
1108
1213
  };
1109
1214
  export {
1110
- w as ApiError,
1111
- wt as Audit,
1215
+ m as ApiError,
1216
+ Ot as Audit,
1112
1217
  k as AuditEventType,
1113
- Se as DidYouMeanKind,
1114
- he as EngineType,
1115
- _e as EngineTypeModifier,
1116
- K as LogLevel,
1117
- dt as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1118
- me as RFMDisplay,
1119
- we as ServerError,
1120
- ke as TimeoutError,
1121
- Z as UnauthorizedError,
1122
- P as addAuditAdditionalInfo,
1123
- He as addConcepts,
1124
- be as addSessionId,
1125
- Ce as addUrl,
1126
- Ve as aggregationItemStrictCompare,
1127
- bt as appInitializerFn,
1128
- Je as bisect,
1129
- B as buildPathsAndLevels,
1130
- ot as configureLogger,
1131
- p as createHeaders,
1132
- ft as createTimeoutController,
1133
- x as debug,
1134
- St as del,
1135
- Gt as deleteUserSettings,
1136
- qe as deleteWebTokenCookie,
1137
- h as error,
1138
- lt as escapeExpr,
1139
- kt as fetchAggregation,
1140
- gt as fetchApp,
1141
- pe as fetchAppPreLogin,
1142
- Ut as fetchBulkQuery,
1143
- Ct as fetchDataset,
1144
- xt as fetchDatasetList,
1145
- Rt as fetchDatasets,
1146
- vt as fetchLabels,
1147
- Pt as fetchPreview,
1148
- Lt as fetchPreviewUrl,
1149
- ye as fetchPrincipal,
1150
- Ot as fetchQuery,
1151
- Dt as fetchQueryExport,
1152
- $t as fetchQueryIntent,
1153
- It as fetchSimilarDocuments,
1154
- yt as fetchSponsoredLinks,
1155
- At as fetchSuggest,
1156
- Bt as fetchSuggestField,
1157
- Nt as fetchSuggestQuery,
1158
- Ft as fetchTextChunks,
1159
- qt as fetchUserSettings,
1218
+ ve as DidYouMeanKind,
1219
+ Re as EngineType,
1220
+ pe as EngineTypeModifier,
1221
+ te as LogLevel,
1222
+ Rt as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1223
+ xe as RFMDisplay,
1224
+ Pe as ServerError,
1225
+ Le as TimeoutError,
1226
+ re as UnauthorizedError,
1227
+ L as addAuditAdditionalInfo,
1228
+ et as addConcepts,
1229
+ Ue as addSessionId,
1230
+ $e as addUrl,
1231
+ Me as aggregationItemStrictCompare,
1232
+ yt as appInitializerFn,
1233
+ Te as bisect,
1234
+ j as buildPathsAndLevels,
1235
+ St as configureLogger,
1236
+ P as createHeaders,
1237
+ pt as createTimeoutController,
1238
+ p as debug,
1239
+ Pt as del,
1240
+ Mt as deleteUserSettings,
1241
+ Xe as deleteWebTokenCookie,
1242
+ f as error,
1243
+ bt as escapeExpr,
1244
+ Ut as fetchAggregation,
1245
+ $t as fetchApp,
1246
+ Ae as fetchAppPreLogin,
1247
+ Gt as fetchBulkQuery,
1248
+ It as fetchDataset,
1249
+ At as fetchDatasetList,
1250
+ Dt as fetchDatasets,
1251
+ Nt as fetchLabels,
1252
+ qt as fetchPreview,
1253
+ Ft as fetchPreviewUrl,
1254
+ Ve as fetchPrincipal,
1255
+ Qt as fetchQuery,
1256
+ Vt as fetchQueryExport,
1257
+ jt as fetchQueryIntent,
1258
+ Jt as fetchSimilarDocuments,
1259
+ zt as fetchSponsoredLinks,
1260
+ Ht as fetchSuggest,
1261
+ Xt as fetchSuggestField,
1262
+ Wt as fetchSuggestQuery,
1263
+ Yt as fetchTextChunks,
1264
+ Kt as fetchUserSettings,
1160
1265
  b as get,
1161
- Ye as getConcepts,
1162
- Qe as getCsrfToken,
1163
- Y as getFiltersFromURI,
1164
- Ee as getFiltersFromUrl,
1165
- nt as getHelpIndexUrl,
1166
- et as getIdFromUrl,
1167
- Fe as getJWToken,
1168
- ct as getMetadata,
1169
- ie as getOffsetFromDates,
1170
- tt as getQueryPageFromUrl,
1171
- Me as getQueryParamsFromUrl,
1172
- rt as getQueryTabFromUrl,
1173
- Te as getQueryTextFromUrl,
1174
- Ke as getRelativeDate,
1175
- O as getToken,
1266
+ nt as getConcepts,
1267
+ Ye as getCsrfToken,
1268
+ ee as getFiltersFromURI,
1269
+ it as getFiltersFromUrl,
1270
+ _t as getHelpIndexUrl,
1271
+ ut as getIdFromUrl,
1272
+ We as getJWToken,
1273
+ kt as getMetadata,
1274
+ me as getOffsetFromDates,
1275
+ dt as getQueryPageFromUrl,
1276
+ st as getQueryParamsFromUrl,
1277
+ ft as getQueryTabFromUrl,
1278
+ lt as getQueryTextFromUrl,
1279
+ at as getRelativeDate,
1280
+ $ as getToken,
1281
+ ct as getUrlParamsFromQueryParams,
1176
1282
  u as globalConfig,
1177
- fe as guid,
1283
+ Ce as guid,
1178
1284
  g as handleResponse,
1179
- S as info,
1180
- le as isArrayBuffer,
1181
- zt as isAuthenticated,
1182
- ue as isBlob,
1183
- it as isJsonable,
1184
- Ze as isNotInputEvent,
1185
- D as isObject,
1186
- de as isString,
1187
- pt as labels,
1188
- jt as login,
1189
- Vt as logout,
1190
- U as parseText,
1191
- te as parseValueAndOperatorFromItem,
1192
- mt as patch,
1193
- Qt as patchUserSettings,
1285
+ w as info,
1286
+ ke as isArrayBuffer,
1287
+ er as isAuthenticated,
1288
+ ge as isBlob,
1289
+ gt as isJsonable,
1290
+ ot as isNotInputEvent,
1291
+ A as isObject,
1292
+ be as isString,
1293
+ Bt as labels,
1294
+ Et as login,
1295
+ Tt as logout,
1296
+ wt as notify,
1297
+ I as parseText,
1298
+ ue as parseValueAndOperatorFromItem,
1299
+ Lt as patch,
1300
+ Zt as patchUserSettings,
1194
1301
  d as post,
1195
- _t as put,
1302
+ xt as put,
1196
1303
  R as queryParamsFromUrl,
1197
- We as removeConcept,
1198
- Xe as removeConcepts,
1199
- st as resolveToColumnName,
1200
- N as rewriteText,
1201
- Ae as saveUserSettings,
1202
- m as setGlobalConfig,
1203
- F as setToken,
1204
- ut as sha512,
1205
- ze as suggestionsToTreeAggregationNodes,
1206
- at as sysLang,
1207
- je as translateAggregationToDateOptions,
1208
- Ne as tryOAuthAuthentication,
1209
- Be as trySAMLAuthentication,
1304
+ tt as removeConcept,
1305
+ rt as removeConcepts,
1306
+ mt as resolveToColumnName,
1307
+ G as rewriteText,
1308
+ Je as saveUserSettings,
1309
+ S as setGlobalConfig,
1310
+ V as setToken,
1311
+ Ct as sha512,
1312
+ Ee as suggestionsToTreeAggregationNodes,
1313
+ ht as sysLang,
1314
+ Ze as translateAggregationToDateOptions,
1315
+ ze as tryOAuthAuthentication,
1316
+ He as trySAMLAuthentication,
1210
1317
  C as warn,
1211
- ht as withRetry
1318
+ vt as withRetry
1212
1319
  };