@sinequa/atomic 0.0.134 → 0.0.139

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,7 +1,4 @@
1
- var le = Object.defineProperty;
2
- var ue = (e, t, r) => t in e ? le(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Y = (e, t, r) => ue(e, typeof t != "symbol" ? t + "" : t, r);
4
- function _(e) {
1
+ function p(e) {
5
2
  const t = new CustomEvent("authenticated", {
6
3
  bubbles: !0,
7
4
  cancelable: !1,
@@ -9,121 +6,119 @@ function _(e) {
9
6
  });
10
7
  dispatchEvent(t);
11
8
  }
12
- const d = {
9
+ const u = {
13
10
  loginPath: "/login",
14
11
  createRoutes: !1
15
12
  };
16
13
  function k(e) {
17
- Object.assign(d, e);
14
+ Object.assign(u, e);
18
15
  }
19
- function L(e) {
20
- const t = W(), r = new Headers(e);
16
+ function x(e) {
17
+ const t = H(), r = new Headers(e);
21
18
  r.append("Sinequa-Force-Camel-Case", "true"), r.append("accept", "application/json"), t && r.append("Sinequa-csrf-token", t);
22
- const { userOverride: n, userOverrideActive: a, bearerToken: s } = d;
23
- return s && r.append("Authorization", `Bearer ${s}`), n && a && (r.append("sinequa-override-user", n.username), r.append("sinequa-override-domain", n.domain)), r;
24
- }
25
- class b extends Error {
26
- constructor(r, n) {
27
- super(r);
28
- Y(this, "status");
29
- this.name = "ApiError", this.status = n;
19
+ const { userOverride: n, userOverrideActive: a, bearerToken: o } = u;
20
+ return o && r.append("Authorization", `Bearer ${o}`), n && a && (r.append("sinequa-override-user", n.username), r.append("sinequa-override-domain", n.domain)), r;
21
+ }
22
+ class v extends Error {
23
+ status;
24
+ constructor(t, r) {
25
+ super(t), this.name = "ApiError", this.status = r;
30
26
  }
31
27
  }
32
- class K extends b {
28
+ class J extends v {
33
29
  constructor(t = "Server error") {
34
30
  super(t, 500), this.name = "ServerError";
35
31
  }
36
32
  }
37
- class de extends b {
33
+ class ae extends v {
38
34
  constructor(t = "Request timed out") {
39
35
  super(t, 408), this.name = "TimeoutError";
40
36
  }
41
37
  }
42
- class V extends b {
38
+ class j extends v {
43
39
  constructor(t = "Unauthorized access") {
44
40
  super(t, 401), this.name = "UnauthorizedError";
45
41
  }
46
42
  }
47
- const fe = /.*\:\(?([><=\d\-\.AND ]+)\)?/;
48
- function ct(e, t) {
49
- var a;
50
- return !(e != null && e.items) || ((a = e == null ? void 0 : e.items) == null ? void 0 : a.length) === 0 ? [] : e.items.reduce((s, i) => {
51
- if (!i.value || i.value === "") return s;
52
- const o = he(i, e.column);
53
- return s.push({
54
- operator: o.operator,
55
- value: o.value,
56
- display: i.display || o.display,
57
- filters: o.filters,
58
- disabled: i.count === 0,
59
- hidden: i.count === 0 && e.isDistribution ? !t : !1
60
- }), s;
43
+ const oe = /.*\:\(?([><=\d\-\.AND ]+)\)?/;
44
+ function ot(e, t) {
45
+ return !e?.items || e?.items?.length === 0 ? [] : e.items.reduce((a, o) => {
46
+ if (!o.value || o.value === "") return a;
47
+ const s = se(o, e.column);
48
+ return a.push({
49
+ operator: s.operator,
50
+ value: s.value,
51
+ display: o.display || s.display,
52
+ filters: s.filters,
53
+ disabled: o.count === 0,
54
+ hidden: o.count === 0 && e.isDistribution ? !t : !1
55
+ }), a;
61
56
  }, []);
62
57
  }
63
- function he(e, t) {
64
- const r = t, n = e.value.match(fe);
65
- if (n != null && n[1]) {
66
- const s = (n == null ? void 0 : n[1].split(" AND ")).map((i) => {
67
- const o = i.indexOf(">=") !== -1 ? "gte" : "lt";
68
- let c = i.substring(i.indexOf(" ") + 1);
69
- return { field: r, operator: o, value: c, display: e.display || e.value };
58
+ function se(e, t) {
59
+ const r = t, n = e.value.match(oe);
60
+ if (n?.[1]) {
61
+ const o = (n?.[1].split(" AND ")).map((s) => {
62
+ const c = s.indexOf(">=") !== -1 ? "gte" : "lt";
63
+ let i = s.substring(s.indexOf(" ") + 1);
64
+ return { field: r, operator: c, value: i, display: e.display || e.value };
70
65
  });
71
- if (s.length === 2)
72
- return { field: r, operator: "and", filters: s, value: e.value, display: s[0].display || s[0].value };
73
- if (s.length === 1)
74
- return { ...s[0], field: r };
66
+ if (o.length === 2)
67
+ return { field: r, operator: "and", filters: o, value: e.value, display: o[0].display || o[0].value };
68
+ if (o.length === 1)
69
+ return { ...o[0], field: r };
75
70
  throw new Error("Failed to parse distribution expression");
76
71
  }
77
72
  return { field: r, operator: "eq", value: e.value, display: e.display };
78
73
  }
79
- function it(e, t, r) {
74
+ function st(e, t, r) {
80
75
  return e.valuesAreExpressions ? t.display === r.display : t.value === r.value;
81
76
  }
82
- function me(e) {
83
- return e.items && (e.items = e.items.map((t) => me(t))), e.items && e.items.some((t) => t.$selected || t.$opened) && (e.$opened = !0), e;
77
+ function ie(e) {
78
+ return e.items && (e.items = e.items.map((t) => ie(t))), e.items && e.items.some((t) => t.$selected || t.$opened) && (e.$opened = !0), e;
84
79
  }
85
- function lt(e, t) {
80
+ function it(e, t) {
86
81
  const r = [];
87
82
  if (e.length > 0) {
88
- const n = /* @__PURE__ */ new Map(), s = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g, ""), i = new RegExp("\\b" + s, "i");
89
- e.forEach((o) => {
90
- if (o.display.length > 1) {
91
- const c = o.display.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), l = i.exec(c);
92
- re(r, n, "/", o.display, +(o.frequency || 0), 1, ((l == null ? void 0 : l.index) || 0) + t.length);
83
+ const n = /* @__PURE__ */ new Map(), o = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g, ""), s = new RegExp("\\b" + o, "i");
84
+ e.forEach((c) => {
85
+ if (c.display.length > 1) {
86
+ const i = c.display.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), d = s.exec(i);
87
+ Z(r, n, "/", c.display, +(c.frequency || 0), 1, (d?.index || 0) + t.length);
93
88
  }
94
89
  });
95
90
  }
96
91
  return r;
97
92
  }
98
- function re(e, t, r, n, a, s, i) {
99
- const o = n.indexOf("/", r.length), c = n.substring(0, o + 1);
100
- let l = t.get(c);
101
- if (!l) {
102
- const f = c.replace(/^\/|\/$/g, "");
103
- l = {
104
- value: n.substring(r.length, o),
93
+ function Z(e, t, r, n, a, o, s) {
94
+ const c = n.indexOf("/", r.length), i = n.substring(0, c + 1);
95
+ let d = t.get(i);
96
+ if (!d) {
97
+ const _ = i.replace(/^\/|\/$/g, "");
98
+ d = {
99
+ value: n.substring(r.length, c),
105
100
  count: a,
106
101
  items: [],
107
102
  hasChildren: !1,
108
- $level: s,
109
- $opened: i >= c.length,
110
- $path: f
111
- }, t.set(c, l), e.push(l);
103
+ $level: o,
104
+ $opened: s >= i.length,
105
+ $path: _
106
+ }, t.set(i, d), e.push(d);
112
107
  }
113
- c.length < n.length && (l.hasChildren = !0, re(l.items, t, c, n, a, s + 1, i));
108
+ i.length < n.length && (d.hasChildren = !0, Z(d.items, t, i, n, a, o + 1, s));
114
109
  }
115
- function ut(e, t) {
110
+ function ct(e, t) {
116
111
  return e.reduce((r, n) => (t(n) ? r.true.push(n) : r.false.push(n), r), { true: [], false: [] });
117
112
  }
118
- const we = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, _e = 2, Z = 3, ge = 5, E = 6, Se = 8, T = 9, pe = 11, ee = 12, ke = 14, te = 15;
119
- function I(e) {
113
+ const ce = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, le = 2, W = 3, ue = 5, M = 6, de = 8, X = 9, fe = 11, Y = 12, he = 14, K = 15;
114
+ function D(e) {
120
115
  if (!e) return [];
121
- const t = [], r = e.matchAll(we);
116
+ const t = [], r = e.matchAll(ce);
122
117
  for (let n of r)
123
- n[Z] ? t.push({ type: "group", value: n[Z], op: n[_e] }) : n[E] ? t.push({ type: "adjacent", value: n[E], op: n[ge] }) : n[T] ? t.push({ type: "exact", value: n[T], op: n[Se] }) : n[ee] ? t.push({ type: "regex", value: n[ee], op: n[pe] }) : n[te] && t.push({ type: "token", value: n[te], op: n[ke] });
118
+ n[W] ? t.push({ type: "group", value: n[W], op: n[le] }) : n[M] ? t.push({ type: "adjacent", value: n[M], op: n[ue] }) : n[X] ? t.push({ type: "exact", value: n[X], op: n[de] }) : n[Y] ? t.push({ type: "regex", value: n[Y], op: n[fe] }) : n[K] && t.push({ type: "token", value: n[K], op: n[he] });
124
119
  return t;
125
120
  }
126
- function G(e) {
121
+ function Q(e) {
127
122
  return e.map((t) => {
128
123
  const r = t.op || "";
129
124
  switch (t.type) {
@@ -140,28 +135,28 @@ function G(e) {
140
135
  }
141
136
  }).join(" ");
142
137
  }
143
- function dt(e, t, r) {
144
- let n = I(e);
138
+ function lt(e, t, r) {
139
+ let n = D(e);
145
140
  for (let a of t)
146
141
  n.push({ type: "adjacent", value: a, op: r });
147
- return G(n);
142
+ return Q(n);
148
143
  }
149
- function ft(e, t) {
150
- const r = I(t), n = r.findIndex((a) => a.value === e);
151
- return n !== -1 ? (r.splice(n, 1), t = G(r)) : t;
144
+ function ut(e, t) {
145
+ const r = D(t), n = r.findIndex((a) => a.value === e);
146
+ return n !== -1 ? (r.splice(n, 1), t = Q(r)) : t;
152
147
  }
153
- function ht(e) {
154
- const t = I(e).filter((r) => r.type !== "adjacent");
155
- return G(t);
148
+ function dt(e) {
149
+ const t = D(e).filter((r) => r.type !== "adjacent");
150
+ return Q(t);
156
151
  }
157
- function mt(e) {
158
- return I(e).filter((t) => t.type === "adjacent").map((t) => t.value);
152
+ function ft(e) {
153
+ return D(e).filter((t) => t.type === "adjacent").map((t) => t.value);
159
154
  }
160
- function wt(e, t, r) {
161
- const n = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: a, unit: s, isFuture: i } = ve(t, r);
162
- return n.format(a * (i ? 1 : -1), s);
155
+ function ht(e, t, r) {
156
+ const n = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: a, unit: o, isFuture: s } = me(t, r);
157
+ return n.format(a * (s ? 1 : -1), o);
163
158
  }
164
- function ve(e, t) {
159
+ function me(e, t) {
165
160
  const r = new Date(e), n = t ? new Date(t) : /* @__PURE__ */ new Date(), a = Math.abs(n.getTime() - r.getTime());
166
161
  return {
167
162
  offset: Math.floor(a / (1e3 * 60 * 60 * 24)),
@@ -169,37 +164,37 @@ function ve(e, t) {
169
164
  isFuture: r > n
170
165
  };
171
166
  }
172
- function _t(e) {
167
+ function mt(e) {
173
168
  const t = e.target;
174
169
  return t && t.nodeName !== "INPUT" && t.nodeName !== "TEXTAREA";
175
170
  }
176
- function gt(e) {
171
+ function pt(e) {
177
172
  if (e === void 0) return;
178
- const { q: t, f: r, p: n, s: a, t: s, n: i, b: o } = R(e), [c] = e.split("?");
173
+ const { q: t, f: r, p: n, s: a, t: o, n: s, b: c } = R(e), [i] = e.split("?");
179
174
  return {
180
- path: c,
175
+ path: i,
181
176
  text: t,
182
- filters: r ? ne(r) : void 0,
177
+ filters: r ? E(r) : void 0,
183
178
  page: n ? parseInt(n, 10) : void 0,
184
179
  sort: a,
185
- tab: s,
186
- name: i,
187
- basket: o
180
+ tab: o,
181
+ name: s,
182
+ basket: c
188
183
  };
189
184
  }
190
- function St(e) {
185
+ function gt(e) {
191
186
  if (!e) return "";
192
- const { text: t, filters: r, page: n, sort: a, tab: s, name: i, basket: o } = e, c = {};
193
- t && (c.q = t), r && (c.f = JSON.stringify(r)), n && (c.p = n.toString()), a && (c.s = a), s && (c.t = s), i && (c.n = i), o && (c.b = o);
194
- const l = new URLSearchParams(c).toString();
195
- return l || "";
187
+ const { text: t, filters: r, page: n, sort: a, tab: o, name: s, basket: c } = e, i = {};
188
+ 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);
189
+ const d = new URLSearchParams(i).toString();
190
+ return d || "";
196
191
  }
197
- function pt(e) {
192
+ function wt(e) {
198
193
  if (e === void 0) return [];
199
194
  const { f: t } = R(e);
200
- return ne(t);
195
+ return E(t);
201
196
  }
202
- function ne(e) {
197
+ function E(e) {
203
198
  const t = decodeURIComponent(e);
204
199
  try {
205
200
  return JSON.parse(t ?? "[]");
@@ -213,23 +208,23 @@ function R(e) {
213
208
  const r = new URLSearchParams(t);
214
209
  return Object.fromEntries(r);
215
210
  }
216
- function kt(e) {
211
+ function _t(e) {
217
212
  const { q: t = "" } = R(e);
218
213
  return t;
219
214
  }
220
- function vt(e) {
215
+ function St(e) {
221
216
  const { id: t } = R(e);
222
217
  return decodeURIComponent(t);
223
218
  }
224
- function bt(e) {
219
+ function kt(e) {
225
220
  const { p: t = "0" } = R(e);
226
221
  return parseInt(t, 10);
227
222
  }
228
- function Ct(e) {
223
+ function bt(e) {
229
224
  const { t } = R(e);
230
225
  return t;
231
226
  }
232
- function Rt(e, t) {
227
+ function vt(e, t) {
233
228
  if (!e)
234
229
  return e;
235
230
  let r = 0;
@@ -240,21 +235,21 @@ function Rt(e, t) {
240
235
  a++;
241
236
  e[a] === "]" && (r = a + 1);
242
237
  }
243
- const s = B(e, r, !1);
244
- if (!s)
238
+ const o = N(e, r, !1);
239
+ if (!o)
245
240
  return e;
246
- const i = t.charCodeAt(0), o = t.charCodeAt(1);
247
- let c = s;
248
- for (; c; )
249
- if (i === c.lang1 && o === c.lang2) {
250
- const f = B(e, c.end + 4, !0);
251
- return e.substring(f.start, f.end);
241
+ const s = t.charCodeAt(0), c = t.charCodeAt(1);
242
+ let i = o;
243
+ for (; i; )
244
+ if (s === i.lang1 && c === i.lang2) {
245
+ const _ = N(e, i.end + 4, !0);
246
+ return e.substring(_.start, _.end);
252
247
  } else
253
- c = B(e, c.end + 4, !1);
254
- const l = e.substring(s.start, s.end);
255
- return l || e;
248
+ i = N(e, i.end + 4, !1);
249
+ const d = e.substring(o.start, o.end);
250
+ return d || e;
256
251
  }
257
- function B(e, t, r) {
252
+ function N(e, t, r) {
258
253
  for (let n = t, a = e.length - 3; n < a; n++)
259
254
  if (e[n] === "[" && e[n + 3] === "]")
260
255
  return {
@@ -271,9 +266,9 @@ function B(e, t, r) {
271
266
  lang2: -1
272
267
  };
273
268
  }
274
- function xt(e, t) {
275
- const { useLocale: r, useLocaleAsPrefix: n, indexFile: a, path: s, folder: i } = t, o = r ? `${e}/` : null, c = n ? `${e}.${a}` : a ?? "";
276
- return [s, i, `${o || ""}${c}`].filter((l) => l !== void 0).join("/");
269
+ function Ct(e, t) {
270
+ const { useLocale: r, useLocaleAsPrefix: n, indexFile: a, path: o, folder: s } = t, c = r ? `${e}/` : null, i = n ? `${e}.${a}` : a ?? "";
271
+ return [o, s, `${c || ""}${i}`].filter((d) => d !== void 0).join("/");
277
272
  }
278
273
  function O(e) {
279
274
  const t = new CustomEvent("notification", {
@@ -283,7 +278,7 @@ function O(e) {
283
278
  });
284
279
  dispatchEvent(t);
285
280
  }
286
- const Pt = {
281
+ const Rt = {
287
282
  success: (e, t) => {
288
283
  O({
289
284
  type: "success",
@@ -313,18 +308,18 @@ const Pt = {
313
308
  });
314
309
  }
315
310
  };
316
- var ae = /* @__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))(ae || {});
317
- let U = {
311
+ var T = /* @__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))(T || {});
312
+ let $ = {
318
313
  level: 1,
319
314
  enableConsoleOutput: !0
320
315
  };
321
- function Lt(e) {
322
- U = { ...U, ...e };
316
+ function yt(e) {
317
+ $ = { ...$, ...e };
323
318
  }
324
- function D(e, t, r) {
325
- if (e < U.level) return;
326
- const a = `${`[${ae[e]}]`} ${t}`;
327
- if (U.enableConsoleOutput)
319
+ function I(e, t, r) {
320
+ if (e < $.level) return;
321
+ const a = `${`[${T[e]}]`} ${t}`;
322
+ if ($.enableConsoleOutput)
328
323
  switch (e) {
329
324
  case 0:
330
325
  console.debug(a, r || "");
@@ -340,21 +335,21 @@ function D(e, t, r) {
340
335
  break;
341
336
  }
342
337
  }
343
- function x(e, t) {
344
- D(0, e, t);
338
+ function y(e, t) {
339
+ I(0, e, t);
345
340
  }
346
- function p(e, t) {
347
- D(1, e, t);
341
+ function S(e, t) {
342
+ I(1, e, t);
348
343
  }
349
344
  function P(e, t) {
350
- D(2, e, t);
345
+ I(2, e, t);
351
346
  }
352
- function h(e, t) {
353
- D(3, e, t);
347
+ function f(e, t) {
348
+ I(3, e, t);
354
349
  }
355
350
  async function C(e, t = "json") {
356
351
  const r = e.headers.get("sinequa-jwt-refresh");
357
- if (r !== null && $(r), e.status === 200)
352
+ if (r !== null && U(r), e.status === 200)
358
353
  switch (t) {
359
354
  case "arraybuffer":
360
355
  return await e.arrayBuffer();
@@ -366,100 +361,99 @@ async function C(e, t = "json") {
366
361
  return await e.json();
367
362
  }
368
363
  if (e.status === 401) {
369
- if (d.userOverrideActive)
364
+ if (u.userOverrideActive)
370
365
  throw P("Unauthorized access attempt with user override", {
371
366
  endpoint: e.url
372
- }), new V("Unauthorized... User override failed.");
367
+ }), new j("Unauthorized... User override failed.");
373
368
  return await q(e, 401);
374
369
  }
375
- return e.status === 500 ? (h("Server error occurred", { endpoint: e.url }), await q(e, 500)) : (P(`Unexpected response status: ${e.status}`, {
370
+ return e.status === 500 ? (f("Server error occurred", { endpoint: e.url }), await q(e, 500)) : (P(`Unexpected response status: ${e.status}`, {
376
371
  endpoint: e.url
377
372
  }), await q(e, e.status));
378
373
  }
379
374
  async function q(e, t) {
380
- var r;
381
375
  try {
382
- const { done: n, value: a } = await ((r = e.body) == null ? void 0 : r.getReader().read()) || {
376
+ const { done: r, value: n } = await e.body?.getReader().read() || {
383
377
  done: !0,
384
378
  value: void 0
385
379
  };
386
- if (n || !a)
387
- throw t === 401 ? new V() : t === 500 ? new K() : new b(`Request failed with status ${t}`, t);
388
- const s = JSON.parse(new TextDecoder().decode(a));
380
+ if (r || !n)
381
+ throw t === 401 ? new j() : t === 500 ? new J() : new v(`Request failed with status ${t}`, t);
382
+ const a = JSON.parse(new TextDecoder().decode(n));
389
383
  throw new Error(
390
- s.errorMessage || s.message || `Request failed with status ${t}`,
384
+ a.errorMessage || a.message || `Request failed with status ${t}`,
391
385
  {
392
386
  cause: {
393
- errorCode: s.errorCode,
394
- errorCodeTest: s.errorCodeTest
387
+ errorCode: a.errorCode,
388
+ errorCodeTest: a.errorCodeTest
395
389
  }
396
390
  }
397
391
  );
398
- } catch (n) {
399
- throw n instanceof b ? n : t === 401 ? new V(n.message) : t === 500 ? new K(n.message) : new b(
400
- n.message ?? `Request failed with status ${t}`,
392
+ } catch (r) {
393
+ throw r instanceof v ? r : t === 401 ? new j(r.message) : t === 500 ? new J(r.message) : new v(
394
+ r.message ?? `Request failed with status ${t}`,
401
395
  t
402
396
  );
403
397
  }
404
398
  }
405
- async function yt(e, t, r) {
406
- const n = L(r == null ? void 0 : r.headers), { backendUrl: a } = d, s = t ? `?${new URLSearchParams(t)}` : "", i = a ? `${a}/${e}${s}` : `${e}${s}`;
407
- x(`Making DELETE request to: ${i}`);
399
+ async function pe(e, t, r) {
400
+ const n = x(r?.headers), { backendUrl: a } = u, o = t ? `?${new URLSearchParams(t)}` : "", s = a ? `${a}/${e}${o}` : `${e}${o}`;
401
+ y(`Making DELETE request to: ${s}`);
408
402
  try {
409
- const o = await fetch(i, {
403
+ const c = await fetch(s, {
410
404
  method: "DELETE",
411
405
  credentials: "include",
412
406
  headers: n
413
407
  });
414
- return C(o, r == null ? void 0 : r.responseType);
415
- } catch (o) {
416
- throw h("Error making DELETE request:", o), o;
408
+ return C(c, r?.responseType);
409
+ } catch (c) {
410
+ throw f("Error making DELETE request:", c), c;
417
411
  }
418
412
  }
419
- async function S(e, t, r) {
420
- const n = L(r == null ? void 0 : r.headers), { backendUrl: a } = d, s = t ? `?${new URLSearchParams(t)}` : "";
413
+ async function w(e, t, r) {
414
+ const n = x(r?.headers), { backendUrl: a } = u, o = t ? `?${new URLSearchParams(t)}` : "";
421
415
  e.startsWith("plugin") && (e = `api/v1/${e}`);
422
- const i = a ? `${a}/${e}${s}` : `${e}${s}`;
423
- x(`Making GET request to: ${i}`);
416
+ const s = a ? `${a}/${e}${o}` : `${e}${o}`;
417
+ y(`Making GET request to: ${s}`);
424
418
  try {
425
- const o = await fetch(i, {
419
+ const c = await fetch(s, {
426
420
  method: "GET",
427
421
  credentials: "include",
428
422
  headers: n,
429
- signal: r == null ? void 0 : r.signal
423
+ signal: r?.signal
430
424
  });
431
- return C(o, r == null ? void 0 : r.responseType);
432
- } catch (o) {
433
- throw h("Error making GET request:", o), o;
425
+ return C(c, r?.responseType);
426
+ } catch (c) {
427
+ throw f("Error making GET request:", c), c;
434
428
  }
435
429
  }
436
- async function be(e, t, r) {
437
- const n = L(r == null ? void 0 : r.headers);
430
+ async function ge(e, t, r) {
431
+ const n = x(r?.headers);
438
432
  n.append("content-type", "application/json");
439
- const { app: a, backendUrl: s } = d, i = {
433
+ const { app: a, backendUrl: o } = u, s = {
440
434
  app: a,
441
435
  ...t,
442
436
  locale: t.locale || navigator.language,
443
437
  noUserOverride: !0,
444
438
  noAutoAuthentication: !0
445
- }, o = s ? `${s}/${e}` : `${e}`;
446
- x(`Making PATCH request to: ${o}`);
439
+ }, c = o ? `${o}/${e}` : `${e}`;
440
+ y(`Making PATCH request to: ${c}`);
447
441
  try {
448
- const c = await fetch(o, {
442
+ const i = await fetch(c, {
449
443
  method: "PATCH",
450
444
  headers: n,
451
445
  credentials: "include",
452
- body: JSON.stringify(i)
446
+ body: JSON.stringify(s)
453
447
  });
454
- return C(c, r == null ? void 0 : r.responseType);
455
- } catch (c) {
456
- throw h("Error making PATCH request:", c), c;
448
+ return C(i, r?.responseType);
449
+ } catch (i) {
450
+ throw f("Error making PATCH request:", i), i;
457
451
  }
458
452
  }
459
- async function u(e, t, r) {
460
- const n = L(r == null ? void 0 : r.headers), { app: a, backendUrl: s } = d;
453
+ async function l(e, t, r) {
454
+ const n = x(r?.headers), { app: a, backendUrl: o } = u;
461
455
  n.has("Content-Type") || n.set("Content-Type", "application/json");
462
- const i = {
456
+ const s = {
463
457
  app: a,
464
458
  ...t,
465
459
  locale: t.locale || navigator.language,
@@ -467,137 +461,130 @@ async function u(e, t, r) {
467
461
  noAutoAuthentication: !0
468
462
  };
469
463
  e.startsWith("plugin") && (e = `api/v1/${e}`);
470
- const o = s ? `${s}/${e}` : `${e}`;
471
- x(`Making POST request to: ${o}`);
464
+ const c = o ? `${o}/${e}` : `${e}`;
465
+ y(`Making POST request to: ${c}`);
472
466
  try {
473
- const c = await fetch(o, {
467
+ const i = await fetch(c, {
474
468
  method: "POST",
475
469
  headers: n,
476
470
  credentials: "include",
477
- body: JSON.stringify(i),
478
- signal: r == null ? void 0 : r.signal
471
+ body: JSON.stringify(s),
472
+ signal: r?.signal
479
473
  });
480
- return C(c, r == null ? void 0 : r.responseType);
481
- } catch (c) {
482
- throw h("Error making POST request:", c), c;
474
+ return C(i, r?.responseType);
475
+ } catch (i) {
476
+ throw f("Error making POST request:", i), i;
483
477
  }
484
478
  }
485
- async function Ot(e, t, r) {
486
- const n = L(r == null ? void 0 : r.headers), { app: a, backendUrl: s } = d, i = {
479
+ async function Pt(e, t, r) {
480
+ const n = x(r?.headers), { app: a, backendUrl: o } = u, s = {
487
481
  app: a,
488
482
  ...t,
489
483
  locale: t.locale || navigator.language,
490
484
  noUserOverride: !0,
491
485
  noAutoAuthentication: !0
492
- }, o = `${s}/${e}`;
493
- x(`Making PUT request to: ${o}`);
486
+ }, c = `${o}/${e}`;
487
+ y(`Making PUT request to: ${c}`);
494
488
  try {
495
- const c = await fetch(o, {
489
+ const i = await fetch(c, {
496
490
  method: "PUT",
497
491
  headers: n,
498
492
  credentials: "include",
499
- body: JSON.stringify(i)
493
+ body: JSON.stringify(s)
500
494
  });
501
- return C(c, r == null ? void 0 : r.responseType);
502
- } catch (c) {
503
- throw h("Error making PUT request:", c), c;
495
+ return C(i, r?.responseType);
496
+ } catch (i) {
497
+ throw f("Error making PUT request:", i), i;
504
498
  }
505
499
  }
506
- function Ut(e) {
500
+ function xt(e) {
507
501
  const t = new AbortController(), { signal: r } = t;
508
502
  return e && setTimeout(() => {
509
- r.aborted || t.abort(new de(`Request timed out after ${e}ms`));
503
+ r.aborted || t.abort(new ae(`Request timed out after ${e}ms`));
510
504
  }, e), { controller: t, signal: r };
511
505
  }
512
- function se(e) {
506
+ function ee(e) {
513
507
  if (!e) return;
514
508
  const t = new Date(e);
515
509
  return Number.isNaN(t.getTime()) ? void 0 : t;
516
510
  }
517
- function $t(e) {
518
- const t = se(e);
511
+ function Lt(e) {
512
+ const t = ee(e);
519
513
  return !!t && t.getTime() <= Date.now();
520
514
  }
521
- function It(e, t = 7) {
522
- const r = se(e);
515
+ function Ot(e, t = 7) {
516
+ const r = ee(e);
523
517
  if (!r) return !1;
524
- const n = Date.now(), a = n + t * 24 * 60 * 60 * 1e3, s = r.getTime();
525
- return s > n && s <= a;
518
+ const n = Date.now(), a = n + t * 24 * 60 * 60 * 1e3, o = r.getTime();
519
+ return o > n && o <= a;
526
520
  }
527
- async function Dt(e, t = 0, r = 1e3) {
521
+ async function $t(e, t = 0, r = 1e3) {
528
522
  let n;
529
523
  for (let a = 0; a <= t; a++)
530
524
  try {
531
525
  return await e();
532
- } catch (s) {
533
- if (n = s, s instanceof b && s.status >= 400 && s.status < 500 && s.status !== 429 || s instanceof DOMException && s.name === "AbortError")
534
- throw s;
535
- a < t && (P(`Retrying request (${a + 1}/${t})`, { error: s }), await new Promise((i) => setTimeout(i, r)));
526
+ } catch (o) {
527
+ if (n = o, o instanceof v && o.status >= 400 && o.status < 500 && o.status !== 429 || o instanceof DOMException && o.name === "AbortError")
528
+ throw o;
529
+ a < t && (P(`Retrying request (${a + 1}/${t})`, { error: o }), await new Promise((s) => setTimeout(s, r)));
536
530
  }
537
531
  throw n;
538
532
  }
539
- function At(e, t, r) {
540
- var s, i, o, c;
533
+ function Ut(e, t, r) {
541
534
  if (!e || !t) return;
542
535
  if (r) {
543
- const l = Object.keys(t.queries).find((F) => F === (r == null ? void 0 : r.toLowerCase()));
544
- let f;
545
- l && (f = t.queries[l]);
546
- const N = (i = ((s = f == null ? void 0 : f.columnsInfo) == null ? void 0 : s.columns) || []) == null ? void 0 : i.find((F) => {
547
- var X, M;
548
- return (M = (X = F.aliases) == null ? void 0 : X.split(",")) == null ? void 0 : M.includes(e);
549
- });
550
- if (N) return N.name;
536
+ const o = Object.keys(t.queries).find((i) => i === r?.toLowerCase());
537
+ let s;
538
+ o && (s = t.queries[o]);
539
+ const c = (s?.columnsInfo?.columns || [])?.find((i) => i.aliases?.split(",")?.includes(e));
540
+ if (c) return c.name;
551
541
  }
552
- const n = (c = (o = t.indexes) == null ? void 0 : o._) == null ? void 0 : c.columns, a = Object.entries(n).find((l) => {
553
- var f;
554
- return (f = l[1].aliases) == null ? void 0 : f.includes(e);
555
- });
542
+ const n = t.indexes?._?.columns, a = Object.entries(n).find((o) => o[1].aliases?.includes(e));
556
543
  if (a) return a[0];
557
544
  }
558
- var v = /* @__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))(v || {}), m = /* @__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))(m || {}), g = /* @__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))(g || {});
559
- const Nt = "1.0";
560
- var Ce = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(Ce || {}), Re = /* @__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))(Re || {});
561
- function xe(e) {
545
+ var b = /* @__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))(b || {}), h = /* @__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))(h || {}), g = /* @__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))(g || {});
546
+ const Dt = "1.0";
547
+ var we = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(we || {}), _e = /* @__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))(_e || {});
548
+ function Se(e) {
562
549
  if (!e)
563
- return m.none;
550
+ return h.none;
564
551
  switch (e.toLocaleLowerCase()) {
565
552
  case "bool":
566
553
  case "boolean":
567
- return m.bool;
554
+ return h.bool;
568
555
  case "date":
569
- return m.date;
556
+ return h.date;
570
557
  case "datetime":
571
- return m.dateTime;
558
+ return h.dateTime;
572
559
  case "time":
573
- return m.time;
560
+ return h.time;
574
561
  case "unsigned":
575
- return m.unsigned;
562
+ return h.unsigned;
576
563
  case "integer":
577
- return m.integer;
564
+ return h.integer;
578
565
  case "float":
579
- return m.float;
566
+ return h.float;
580
567
  case "double":
581
- return m.double;
568
+ return h.double;
582
569
  case "dates":
583
- return m.dates;
570
+ return h.dates;
584
571
  case "datetimes":
585
- return m.dateTimes;
572
+ return h.dateTimes;
586
573
  case "times":
587
- return m.times;
574
+ return h.times;
588
575
  case "varchar":
589
- return m.varchar;
576
+ return h.varchar;
590
577
  case "binary":
591
- return m.binary;
578
+ return h.binary;
592
579
  case "string":
593
- return m.string;
580
+ return h.string;
594
581
  case "csv":
595
- return m.csv;
582
+ return h.csv;
596
583
  default:
597
- return m.none;
584
+ return h.none;
598
585
  }
599
586
  }
600
- function Pe(e) {
587
+ function ke(e) {
601
588
  switch (e) {
602
589
  case "a":
603
590
  return g.a;
@@ -623,44 +610,44 @@ function Pe(e) {
623
610
  return g.none;
624
611
  }
625
612
  }
626
- function Le(e) {
613
+ function be(e) {
627
614
  let t = g.none;
628
615
  if (e)
629
616
  for (const r of e)
630
- t |= Pe(r);
617
+ t |= ke(r);
631
618
  return t;
632
619
  }
633
- function w(e, t, r, n) {
634
- const a = xe(t), s = Le(r || "");
620
+ function m(e, t, r, n) {
621
+ const a = Se(t), o = be(r || "");
635
622
  return {
636
623
  name: e,
637
624
  type: t,
638
625
  typeModifier: r,
639
626
  eType: a,
640
- eTypeModifier: s,
627
+ eTypeModifier: o,
641
628
  aliases: n
642
629
  };
643
630
  }
644
- const Ft = {
645
- id: w("id", "string"),
646
- text: w("text", "varchar"),
647
- documentlanguages: w("documentlanguages", "csv", "ci", ["language"]),
648
- databasealias: w("databasealias", "varchar"),
649
- globalrelevance: w("globalrelevance", "double"),
650
- matchingpartnames: w("matchingpartnames", "csv"),
651
- matchlocations: w("matchlocations", "csv"),
652
- matchlocationsperpartname: w("matchlocationsperpartname", "varchar"),
631
+ const It = {
632
+ id: m("id", "string"),
633
+ text: m("text", "varchar"),
634
+ documentlanguages: m("documentlanguages", "csv", "ci", ["language"]),
635
+ databasealias: m("databasealias", "varchar"),
636
+ globalrelevance: m("globalrelevance", "double"),
637
+ matchingpartnames: m("matchingpartnames", "csv"),
638
+ matchlocations: m("matchlocations", "csv"),
639
+ matchlocationsperpartname: m("matchlocationsperpartname", "varchar"),
653
640
  // json
654
- extracts: w("extracts", "csv"),
655
- extractsperpartname: w("extractsperpartname", "varchar"),
641
+ extracts: m("extracts", "csv"),
642
+ extractsperpartname: m("extractsperpartname", "varchar"),
656
643
  // json
657
- extractslocations: w("extractslocations", "csv"),
658
- documentweight: w("documentweight", "varchar"),
659
- groupcount: w("groupcount", "integer"),
660
- accesslists: w("accesslists", "varchar", void 0, ["accessLists"])
644
+ extractslocations: m("extractslocations", "csv"),
645
+ documentweight: m("documentweight", "varchar"),
646
+ groupcount: m("groupcount", "integer"),
647
+ accesslists: m("accesslists", "varchar", void 0, ["accessLists"])
661
648
  // json
662
649
  };
663
- function Bt(e, t) {
650
+ function At(e, t) {
664
651
  let r = e[t];
665
652
  return r === void 0 ? [] : (typeof r == "string" && (r = String(r).split(",")), Array.isArray(r) ? r.map((n) => {
666
653
  if (typeof n == "string") return n.trim();
@@ -668,7 +655,7 @@ function Bt(e, t) {
668
655
  return n.display.trim();
669
656
  }).filter((n) => n !== void 0) : [String(r).trim()]);
670
657
  }
671
- function qt(e, t) {
658
+ function Nt(e, t) {
672
659
  let r = e[t];
673
660
  if (r === void 0) return [];
674
661
  if (typeof r == "string" && (r = String(r).split(",")), Array.isArray(r))
@@ -676,8 +663,8 @@ function qt(e, t) {
676
663
  if (typeof a == "string")
677
664
  return { display: a.trim(), value: a.trim() };
678
665
  if (typeof a == "object" && a !== null && "display" in a) {
679
- const s = a.display.trim(), i = "value" in a ? String(a.value).trim() : s;
680
- return { display: s, value: i };
666
+ const o = a.display.trim(), s = "value" in a ? String(a.value).trim() : o;
667
+ return { display: o, value: s };
681
668
  }
682
669
  }).filter(
683
670
  (a) => a !== void 0
@@ -688,30 +675,36 @@ function qt(e, t) {
688
675
  function A(e) {
689
676
  return e !== null && typeof e == "object";
690
677
  }
691
- function ye(e) {
678
+ function ve(e) {
692
679
  return A(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
693
680
  }
694
- function Oe(e) {
681
+ function Ce(e) {
695
682
  return A(e) && Object.prototype.toString.call(e) === "[object Blob]";
696
683
  }
697
- function Ue(e) {
684
+ function Re(e) {
685
+ return Object.prototype.toString.call(e) === "[object Date]";
686
+ }
687
+ function ye(e) {
698
688
  return typeof e == "string";
699
689
  }
700
- function Qt(e) {
701
- return (A(e) || Array.isArray(e)) && !ye(e) && !Oe(e) && !Ue(e);
690
+ function qt(e) {
691
+ return (A(e) || Array.isArray(e)) && !ve(e) && !Ce(e) && !ye(e);
692
+ }
693
+ function Pe(e) {
694
+ return e ? (e.getHours() * 60 * 60 + e.getMinutes() * 60 + e.getSeconds()) * 1e3 + e.getMilliseconds() : 0;
702
695
  }
703
- function $e(e = !0) {
696
+ function xe(e = !0) {
704
697
  let t = Date.now();
705
698
  return (e ? "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" : "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g, (n) => {
706
699
  const a = (t + Math.random() * 16) % 16 | 0;
707
700
  return t = Math.floor(t / 16), (n === "x" ? a : a & 3 | 8).toString(16);
708
701
  });
709
702
  }
710
- function jt(e) {
703
+ function Ft(e) {
711
704
  if (!e)
712
705
  return "``";
713
706
  if (e = String(e), e.search(/[\\`]/) === -1)
714
- return "`" + e + "`";
707
+ return `\`${e}\``;
715
708
  const t = ["`"];
716
709
  for (let r = 0, n = e.length; r < n; r++) {
717
710
  const a = e[r];
@@ -719,28 +712,30 @@ function jt(e) {
719
712
  }
720
713
  return t.push("`"), t.join("");
721
714
  }
722
- function Vt(e) {
715
+ function Bt(e) {
723
716
  if (typeof crypto < "u" && crypto.subtle && typeof crypto.subtle.digest == "function")
724
717
  try {
725
- 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("")).catch(() => Promise.resolve(Q(e)));
718
+ return crypto.subtle.digest("SHA-512", new TextEncoder().encode(e)).then(
719
+ (t) => Array.prototype.map.call(new Uint8Array(t), (r) => `00${r.toString(16)}`.slice(-2)).join("")
720
+ ).catch(() => Promise.resolve(F(e)));
726
721
  } catch {
727
- return Promise.resolve(Q(e));
722
+ return Promise.resolve(F(e));
728
723
  }
729
- return Promise.resolve(Q(e));
724
+ return Promise.resolve(F(e));
730
725
  }
731
- function Q(e) {
726
+ function F(e) {
732
727
  let n = 2166136261;
733
- for (let f = 0; f < e.length; f++)
734
- n ^= e.charCodeAt(f), n = n * 16777619 >>> 0;
735
- const a = n.toString(16).padStart(8, "0"), s = ((n ^ 2863311530) >>> 0).toString(16).padStart(8, "0"), i = ((n ^ 1431655765) >>> 0).toString(16).padStart(8, "0"), o = ((n ^ 3435973836) >>> 0).toString(16).padStart(8, "0"), c = a + s + i + o;
736
- return (c + c + c + c).substring(0, 128);
728
+ for (let _ = 0; _ < e.length; _++)
729
+ n ^= e.charCodeAt(_), n = n * 16777619 >>> 0;
730
+ const a = n.toString(16).padStart(8, "0"), o = ((n ^ 2863311530) >>> 0).toString(16).padStart(8, "0"), s = ((n ^ 1431655765) >>> 0).toString(16).padStart(8, "0"), c = ((n ^ 3435973836) >>> 0).toString(16).padStart(8, "0"), i = a + o + s + c;
731
+ return (i + i + i + i).substring(0, 128);
737
732
  }
738
- let j, oe;
739
- function y(e, t = !0) {
740
- let r = Ie(e.$auditRecord);
741
- r && (De(r), t && Ae(r)), e.$auditRecord = r;
733
+ let B, te;
734
+ function L(e, t = !0) {
735
+ let r = Le(e.$auditRecord);
736
+ r && (Oe(r), t && $e(r)), e.$auditRecord = r;
742
737
  }
743
- function Ie(e) {
738
+ function Le(e) {
744
739
  if (!e)
745
740
  return;
746
741
  let t;
@@ -754,57 +749,54 @@ function Ie(e) {
754
749
  }
755
750
  return { auditEvents: t };
756
751
  }
757
- function De(e) {
758
- var r;
759
- const t = Ne();
760
- return (r = e.auditEvents) == null || r.forEach((n) => {
761
- n.detail || (n.detail = {}), n.detail.sessionid = t;
752
+ function Oe(e) {
753
+ const t = Ue();
754
+ return e.auditEvents?.forEach((r) => {
755
+ r.detail || (r.detail = {}), r.detail.sessionid = t;
762
756
  }), e;
763
757
  }
764
- function Ae(e) {
765
- var r;
758
+ function $e(e) {
766
759
  const t = typeof window < "u" ? decodeURIComponent(window.location.href) : "http://localhost";
767
- return (r = e == null ? void 0 : e.auditEvents) == null || r.forEach((n) => {
768
- n.detail || (n.detail = {}), n.detail.url = t;
760
+ return e?.auditEvents?.forEach((r) => {
761
+ r.detail || (r.detail = {}), r.detail.url = t;
769
762
  }), e;
770
763
  }
771
- function Ne() {
772
- return (!j || Fe()) && (j = $e()), oe = /* @__PURE__ */ new Date(), j;
764
+ function Ue() {
765
+ return (!B || De()) && (B = xe()), te = /* @__PURE__ */ new Date(), B;
773
766
  }
774
- function Fe() {
775
- return (/* @__PURE__ */ new Date()).getTime() - oe.getTime() > 10 * 60 * 1e3;
767
+ function De() {
768
+ return (/* @__PURE__ */ new Date()).getTime() - te.getTime() > 600 * 1e3;
776
769
  }
777
- async function Be(e, t = !0) {
770
+ async function Ie(e, t = !0) {
778
771
  const r = {
779
- event: v.None,
772
+ event: b.None,
780
773
  $auditRecord: e
781
774
  };
782
- return y(r, t), u("api/v1/audit.notify", r);
775
+ return L(r, t), l("api/v1/audit.notify", r);
783
776
  }
784
- const Gt = { notify: Be };
785
- async function zt(e, t, r) {
786
- var f;
787
- const n = ((f = e.items) == null ? void 0 : f.length) || 0, a = 10, s = {
777
+ const jt = { notify: Ie };
778
+ async function Qt(e, t, r) {
779
+ const n = e.items?.length || 0, a = 10, o = {
788
780
  query: { ...t, action: "aggregate", aggregations: { [e.name]: { skip: n, count: a } } },
789
781
  $auditRecord: { auditEvents: [r] }
790
782
  };
791
- y(s);
792
- const i = await u("api/v1/query", s), o = await C(i), { aggregations: c } = o, l = c[0];
793
- return l.$hasMore = l.items.length > a, l.items = [...e.items, ...l.items], Promise.resolve(l);
783
+ L(o);
784
+ const s = await l("api/v1/query", o), c = await C(s), { aggregations: i } = c, d = i[0];
785
+ return d.$hasMore = d.items.length > a, d.items = [...e.items, ...d.items], Promise.resolve(d);
794
786
  }
795
- async function Ht() {
796
- const { app: e } = d, t = new URLSearchParams({ app: e || "" });
797
- return S("api/v1/app", t);
787
+ async function Vt() {
788
+ const { app: e } = u, t = new URLSearchParams({ app: e || "" });
789
+ return w("api/v1/app", t);
798
790
  }
799
- async function qe() {
800
- const { app: e } = d, t = new URLSearchParams({
791
+ async function Ae() {
792
+ const { app: e } = u, t = new URLSearchParams({
801
793
  app: e || "",
802
794
  preLogin: "true"
803
795
  });
804
- return S("api/v1/app", t);
796
+ return w("api/v1/app", t);
805
797
  }
806
- function Jt() {
807
- let { backendUrl: e, app: t, useCredentials: r } = d;
798
+ function Gt() {
799
+ let { backendUrl: e, app: t, useCredentials: r } = u;
808
800
  if (typeof window < "u") {
809
801
  if (e || (e = window.location.origin), !t) {
810
802
  const n = window.location.pathname.match(
@@ -813,48 +805,48 @@ function Jt() {
813
805
  n && (t = n[1]);
814
806
  }
815
807
  k({
816
- ...d,
808
+ ...u,
817
809
  backendUrl: e,
818
810
  app: t
819
811
  });
820
812
  }
821
813
  return r ? (k({
822
- ...d,
814
+ ...u,
823
815
  useCredentials: !0,
824
816
  useSSO: !1,
825
817
  autoOAuthProvider: void 0,
826
818
  autoSAMLProvider: void 0,
827
819
  bearerToken: void 0,
828
820
  useSAML: void 0
829
- }), Promise.resolve({})) : qe().then((n) => {
830
- const { autoOAuthProvider: a, autoSAMLProvider: s } = d, i = !a && !n.autoOAuthProvider && !s && !n.autoSAMLProvider;
821
+ }), Promise.resolve({})) : Ae().then((n) => {
822
+ const { autoOAuthProvider: a, autoSAMLProvider: o } = u, s = !a && !n.autoOAuthProvider && !o && !n.autoSAMLProvider;
831
823
  return k({
832
- ...d,
824
+ ...u,
833
825
  autoOAuthProvider: a || n.autoOAuthProvider,
834
- autoSAMLProvider: s || n.autoSAMLProvider,
835
- useCredentials: i,
836
- useSSO: i
826
+ autoSAMLProvider: o || n.autoSAMLProvider,
827
+ useCredentials: s,
828
+ useSSO: s
837
829
  }), n;
838
830
  }).catch((n) => {
839
- throw h("atomic:fetchAppPreLogin error", n), n;
831
+ throw f("atomic:fetchAppPreLogin error", n), n;
840
832
  });
841
833
  }
842
- async function Wt(e, t, r = {}) {
843
- const n = `api/v1/search.dataset/${e}/${t}`, a = await u(n, { parameters: r }), s = t[0].toLowerCase() + t.slice(1), i = a.datasets[s];
844
- if ("errorCode" in i && "errorMessage" in i)
845
- throw new Error(i.errorMessage);
846
- return i;
834
+ async function zt(e, t, r = {}) {
835
+ const n = `api/v1/search.dataset/${e}/${t}`, a = await l(n, { parameters: r }), o = t[0].toLowerCase() + t.slice(1), s = a.datasets[o];
836
+ if ("errorCode" in s && "errorMessage" in s)
837
+ throw new Error(s.errorMessage);
838
+ return s;
847
839
  }
848
- async function Xt(e, t) {
840
+ async function Ht(e, t) {
849
841
  const r = `api/v1/search.dataset/${e}`, { parameters: n = {}, datasets: a = [] } = t;
850
- return (await u(r, { parameters: n, datasets: a })).datasets;
842
+ return (await l(r, { parameters: n, datasets: a })).datasets;
851
843
  }
852
- async function Mt(e) {
853
- return await S(`api/v1/search.dataset/${e}`);
844
+ async function Jt(e) {
845
+ return await w(`api/v1/search.dataset/${e}`);
854
846
  }
855
- async function Yt(e, t = !0, r) {
847
+ async function Wt(e, t = !0, r) {
856
848
  try {
857
- return (await u("api/v1/labels", {
849
+ return (await l("api/v1/labels", {
858
850
  action: "list",
859
851
  q: e,
860
852
  public: t,
@@ -862,21 +854,21 @@ async function Yt(e, t = !0, r) {
862
854
  localize: !1
863
855
  })).labels;
864
856
  } catch (n) {
865
- throw h("Error in fetchLabels", n), n;
857
+ throw f("Error in fetchLabels", n), n;
866
858
  }
867
859
  }
868
- async function Qe() {
860
+ async function Ne() {
869
861
  try {
870
- const { app: e = "" } = d, t = new URLSearchParams({
862
+ const { app: e = "" } = u, t = new URLSearchParams({
871
863
  app: e,
872
864
  action: "getUserRights"
873
865
  });
874
- return S("api/v1/labels", t);
866
+ return w("api/v1/labels", t);
875
867
  } catch (e) {
876
- throw h("Error in getUserRights", e), e;
868
+ throw f("Error in getUserRights", e), e;
877
869
  }
878
870
  }
879
- async function je(e, t, r = !0) {
871
+ async function qe(e, t, r = !0) {
880
872
  try {
881
873
  const n = {
882
874
  action: "add",
@@ -886,7 +878,7 @@ async function je(e, t, r = !0) {
886
878
  $auditRecord: {
887
879
  auditEvents: [
888
880
  {
889
- type: v.Label_AddDoc,
881
+ type: b.Label_AddDoc,
890
882
  detail: {
891
883
  public: r,
892
884
  label: e ? e.toString() : null,
@@ -902,12 +894,12 @@ async function je(e, t, r = !0) {
902
894
  ]
903
895
  }
904
896
  };
905
- return u("api/v1/labels", n);
897
+ return l("api/v1/labels", n);
906
898
  } catch (n) {
907
- throw h("Error in add", n), n;
899
+ throw f("Error in add", n), n;
908
900
  }
909
901
  }
910
- async function Ve(e, t, r = !0) {
902
+ async function Fe(e, t, r = !0) {
911
903
  try {
912
904
  const n = {
913
905
  action: "remove",
@@ -917,7 +909,7 @@ async function Ve(e, t, r = !0) {
917
909
  $auditRecord: {
918
910
  auditEvents: [
919
911
  {
920
- type: v.Label_RemoveDoc,
912
+ type: b.Label_RemoveDoc,
921
913
  detail: {
922
914
  public: r,
923
915
  label: e ? e.toString() : null,
@@ -933,12 +925,12 @@ async function Ve(e, t, r = !0) {
933
925
  ]
934
926
  }
935
927
  };
936
- return u("api/v1/labels", n);
928
+ return l("api/v1/labels", n);
937
929
  } catch (n) {
938
- throw h("Error in remove", n), n;
930
+ throw f("Error in remove", n), n;
939
931
  }
940
932
  }
941
- async function Ge(e, t, r = !0) {
933
+ async function Be(e, t, r = !0) {
942
934
  try {
943
935
  const n = {
944
936
  action: "rename",
@@ -946,7 +938,7 @@ async function Ge(e, t, r = !0) {
946
938
  newLabel: t,
947
939
  public: r,
948
940
  auditEvents: {
949
- type: v.Label_Rename,
941
+ type: b.Label_Rename,
950
942
  detail: {
951
943
  public: r,
952
944
  oldlabel: e ? e.toString() : null,
@@ -954,31 +946,31 @@ async function Ge(e, t, r = !0) {
954
946
  }
955
947
  }
956
948
  };
957
- return u("api/v1/labels", n);
949
+ return l("api/v1/labels", n);
958
950
  } catch (n) {
959
- throw h("Error in rename", n), n;
951
+ throw f("Error in rename", n), n;
960
952
  }
961
953
  }
962
- async function ze(e, t = !0) {
954
+ async function je(e, t = !0) {
963
955
  try {
964
956
  const r = {
965
957
  action: "delete",
966
958
  labels: e,
967
959
  public: t,
968
960
  auditEvents: {
969
- type: v.Label_Delete,
961
+ type: b.Label_Delete,
970
962
  detail: {
971
963
  public: t,
972
964
  label: e ? e.toString() : null
973
965
  }
974
966
  }
975
967
  };
976
- return u("api/v1/labels", r);
968
+ return l("api/v1/labels", r);
977
969
  } catch (r) {
978
- throw h("Error in deleteLabels", r), r;
970
+ throw f("Error in deleteLabels", r), r;
979
971
  }
980
972
  }
981
- async function He(e, t, r = !0) {
973
+ async function Qe(e, t, r = !0) {
982
974
  try {
983
975
  const n = {
984
976
  action: "bulkAdd",
@@ -986,7 +978,7 @@ async function He(e, t, r = !0) {
986
978
  query: t,
987
979
  public: r,
988
980
  auditEvents: {
989
- type: v.Label_Add,
981
+ type: b.Label_Add,
990
982
  detail: {
991
983
  public: r,
992
984
  label: e ? e.toString() : null,
@@ -994,12 +986,12 @@ async function He(e, t, r = !0) {
994
986
  }
995
987
  }
996
988
  };
997
- return u("api/v1/labels", n);
989
+ return l("api/v1/labels", n);
998
990
  } catch (n) {
999
- throw h("Error in bulkAdd", n), n;
991
+ throw f("Error in bulkAdd", n), n;
1000
992
  }
1001
993
  }
1002
- async function Je(e, t, r = !0) {
994
+ async function Ve(e, t, r = !0) {
1003
995
  try {
1004
996
  const n = {
1005
997
  action: "bulkRemove",
@@ -1007,7 +999,7 @@ async function Je(e, t, r = !0) {
1007
999
  query: t,
1008
1000
  public: r,
1009
1001
  auditEvents: {
1010
- type: v.Label_Delete,
1002
+ type: b.Label_Delete,
1011
1003
  detail: {
1012
1004
  public: r,
1013
1005
  label: e ? e.toString() : null,
@@ -1015,36 +1007,36 @@ async function Je(e, t, r = !0) {
1015
1007
  }
1016
1008
  }
1017
1009
  };
1018
- return u("api/v1/labels", n);
1010
+ return l("api/v1/labels", n);
1019
1011
  } catch (n) {
1020
- throw h("Error in bulkRemove", n), n;
1012
+ throw f("Error in bulkRemove", n), n;
1021
1013
  }
1022
1014
  }
1023
- const Kt = {
1024
- getUserRights: Qe,
1025
- add: je,
1026
- remove: Ve,
1027
- rename: Ge,
1028
- delete: ze,
1029
- bulkAdd: He,
1030
- bulkRemove: Je
1015
+ const Mt = {
1016
+ getUserRights: Ne,
1017
+ add: qe,
1018
+ remove: Fe,
1019
+ rename: Be,
1020
+ delete: je,
1021
+ bulkAdd: Qe,
1022
+ bulkRemove: Ve
1031
1023
  };
1032
- async function Zt(e, t) {
1024
+ async function Xt(e, t) {
1033
1025
  if (typeof window > "u")
1034
- return u("api/v1/preview", {
1026
+ return l("api/v1/preview", {
1035
1027
  action: "get",
1036
1028
  id: e,
1037
1029
  query: t
1038
1030
  });
1039
- const r = `${window.location.origin}${window.location.pathname}`, n = { name: t == null ? void 0 : t.name, text: t == null ? void 0 : t.text };
1040
- return u("api/v1/preview", {
1031
+ const r = `${window.location.origin}${window.location.pathname}`, n = { name: t?.name, text: t?.text };
1032
+ return l("api/v1/preview", {
1041
1033
  action: "get",
1042
1034
  id: e,
1043
1035
  query: n,
1044
1036
  browserUrl: r
1045
1037
  });
1046
1038
  }
1047
- async function Et(e) {
1039
+ async function Yt(e) {
1048
1040
  const t = new Headers();
1049
1041
  t.append("content-type", "text");
1050
1042
  const r = await fetch(
@@ -1056,23 +1048,23 @@ async function Et(e) {
1056
1048
  );
1057
1049
  C(r);
1058
1050
  }
1059
- async function ce() {
1051
+ async function re() {
1060
1052
  const e = new URLSearchParams({
1061
1053
  action: "get",
1062
1054
  noAutoAuthentication: "true"
1063
1055
  });
1064
- return S("api/v1/principal", e);
1056
+ return w("api/v1/principal", e);
1065
1057
  }
1066
- async function We(e) {
1058
+ async function Ge(e) {
1067
1059
  const t = {
1068
1060
  noAutoAuthentication: "true",
1069
1061
  ...e
1070
1062
  }, r = new URLSearchParams();
1071
1063
  return Object.entries(t).forEach(([n, a]) => {
1072
1064
  a !== void 0 && r.append(n, String(a));
1073
- }), S("api/v1/principal/list", r);
1065
+ }), w("api/v1/principal/list", r);
1074
1066
  }
1075
- async function Xe(e) {
1067
+ async function ze(e) {
1076
1068
  if (!e)
1077
1069
  return Promise.reject(new Error("userid is required"));
1078
1070
  const t = new URLSearchParams({
@@ -1080,79 +1072,75 @@ async function Xe(e) {
1080
1072
  noAutoAuthentication: "true",
1081
1073
  userid: e
1082
1074
  });
1083
- return S("api/v1/principal", t);
1075
+ return w("api/v1/principal", t);
1084
1076
  }
1085
- async function Me(e) {
1077
+ async function He(e) {
1086
1078
  if (e.length === 0)
1087
1079
  return Promise.reject(new Error("userids is required"));
1088
1080
  const t = new URLSearchParams({
1089
1081
  noAutoAuthentication: "true",
1090
1082
  userids: [...e].join(",")
1091
1083
  });
1092
- return S("api/v1/principal/userids", t);
1084
+ return w("api/v1/principal/userids", t);
1093
1085
  }
1094
- const Tt = {
1086
+ const Kt = {
1095
1087
  principal: {
1096
- get: ce,
1097
- list: We,
1098
- userid: Xe,
1099
- userids: Me
1088
+ get: re,
1089
+ list: Ge,
1090
+ userid: ze,
1091
+ userids: He
1100
1092
  }
1101
- }, ie = 11;
1102
- async function er(e, t, r) {
1103
- var i;
1104
- const a = await u("api/v1/query", {
1093
+ }, ne = 11;
1094
+ async function Zt(e, t, r) {
1095
+ const a = await l("api/v1/query", {
1105
1096
  query: e,
1106
1097
  $auditRecord: t,
1107
1098
  queryIntentData: r
1108
1099
  });
1109
- a.aggregations.forEach((o) => {
1110
- o.$hasMore = !1, !o.isDistribution && !o.isTree && o.items && (o.$hasMore = o.items.length === ie), o.isTree && o.items && z(o);
1111
- }), (i = a.records) == null || i.map((o) => Object.assign(o, { value: o.title, type: "default" }));
1112
- const s = { ...a, nextPage: a.page < Math.ceil(a.rowCount / a.pageSize) ? a.page + 1 : void 0, previousPage: a.page > 1 ? a.page - 1 : void 0 };
1113
- return Promise.resolve(s);
1114
- }
1115
- async function tr(e, t, r) {
1116
- const { app: n = "" } = d, a = {
1100
+ a.aggregations.forEach((s) => {
1101
+ s.$hasMore = !1, !s.isDistribution && !s.isTree && s.items && (s.$hasMore = s.items.length === ne), s.isTree && s.items && V(s);
1102
+ }), a.records?.map((s) => Object.assign(s, { value: s.title, type: "default" }));
1103
+ 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 };
1104
+ return Promise.resolve(o);
1105
+ }
1106
+ async function Et(e, t, r) {
1107
+ const { app: n = "" } = u, a = {
1117
1108
  methods: [],
1118
1109
  mode: t,
1119
1110
  propagateErrors: !0,
1120
1111
  $auditRecord: { auditEvents: [r] }
1121
1112
  };
1122
- for (const o of e)
1113
+ for (const c of e)
1123
1114
  a.methods.push({
1124
1115
  method: "query",
1125
1116
  app: n,
1126
- query: o
1117
+ query: c
1127
1118
  });
1128
- const s = await u("api/v1/multi", a);
1129
- s.results.forEach((o) => {
1130
- o.aggregations.forEach((c) => {
1131
- c.$hasMore = !1, !c.isDistribution && !c.isTree && c.items && (c.$hasMore = c.items.length === ie), c.isTree && z(c);
1119
+ const o = await l("api/v1/multi", a);
1120
+ o.results.forEach((c) => {
1121
+ c.aggregations.forEach((i) => {
1122
+ i.$hasMore = !1, !i.isDistribution && !i.isTree && i.items && (i.$hasMore = i.items.length === ne), i.isTree && V(i);
1132
1123
  });
1133
- }), s.results.forEach((o) => {
1134
- var c;
1135
- return (c = o.records) == null ? void 0 : c.map((l) => Object.assign(l, { value: l.title, type: "default" }));
1136
- });
1137
- const i = s.results.map((o) => ({ ...o, nextPage: o.page < Math.ceil(o.rowCount / o.pageSize) ? o.page + 1 : void 0, previousPage: o.page > 1 ? o.page - 1 : void 0 }));
1138
- return Promise.resolve(i);
1124
+ }), o.results.forEach((c) => c.records?.map((i) => Object.assign(i, { value: i.title, type: "default" })));
1125
+ 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 }));
1126
+ return Promise.resolve(s);
1139
1127
  }
1140
- function z(e, t = "", r = 0) {
1128
+ function V(e, t = "", r = 0) {
1141
1129
  let n = [];
1142
1130
  return e.items && e.items.forEach((a) => {
1143
- let s = t ? `${t}/${a.value}` : a.value, i = r + 1;
1144
- n.push({ path: s, level: i }), a.$path = s, a.$level = i, a.hasChildren ? n = n.concat(z(a, s, i)) : a.hasChildren = !1;
1131
+ let o = t ? `${t}/${a.value}` : a.value, s = r + 1;
1132
+ n.push({ path: o, level: s }), a.$path = o, a.$level = s, a.hasChildren ? n = n.concat(V(a, o, s)) : a.hasChildren = !1;
1145
1133
  }), n;
1146
1134
  }
1147
- async function rr({ model: e, appName: t, query: r, article: n }) {
1148
- const { webservice: a, format: s, maxcount: i, exportedColumns: o, export: c } = e, l = {
1135
+ async function Tt({ model: e, appName: t, query: r, article: n }) {
1136
+ const { webservice: a, format: o, maxcount: s, exportedColumns: c, export: i } = e, d = {
1149
1137
  app: t,
1150
1138
  webservice: a,
1151
1139
  query: r,
1152
- type: c,
1153
- format: s,
1154
- maxcount: i,
1155
- exportedColumns: o,
1140
+ type: i,
1141
+ format: o,
1142
+ maxcount: s,
1143
+ exportedColumns: c,
1156
1144
  $auditRecord: {
1157
1145
  auditEvents: [{
1158
1146
  type: "Search_ExportCSV",
@@ -1162,16 +1150,15 @@ async function rr({ model: e, appName: t, query: r, article: n }) {
1162
1150
  }]
1163
1151
  }
1164
1152
  };
1165
- return y(l), await u("api/v1/search.queryexport", l, { responseType: "blob" });
1153
+ return L(d), await l("api/v1/search.queryexport", d, { responseType: "blob" });
1166
1154
  }
1167
- async function nr(e) {
1168
- const r = await u("api/v1/queryintent", {
1155
+ async function er(e) {
1156
+ return (await l("api/v1/queryintent", {
1169
1157
  query: e
1170
- });
1171
- return r == null ? void 0 : r.intents;
1158
+ }))?.intents;
1172
1159
  }
1173
- async function ar(e, t, r) {
1174
- return (await u(
1160
+ async function tr(e, t, r) {
1161
+ return (await l(
1175
1162
  "api/v1/similardocuments",
1176
1163
  {
1177
1164
  sourceDocumentId: e,
@@ -1182,17 +1169,55 @@ async function ar(e, t, r) {
1182
1169
  { signal: r }
1183
1170
  )).data;
1184
1171
  }
1185
- async function sr(e, t) {
1186
- var a;
1187
- const n = await u("api/v1/query.links", {
1172
+ async function rr(e, t) {
1173
+ return (await l("api/v1/query.links", {
1188
1174
  webservice: e,
1189
1175
  query: t
1190
- });
1191
- return (a = n == null ? void 0 : n.links) == null ? void 0 : a.map((s) => ({ ...s, query: t }));
1176
+ }))?.links?.map((a) => ({ ...a, query: t }));
1177
+ }
1178
+ function Je(e, t) {
1179
+ if (typeof e == "number")
1180
+ return `${e}`;
1181
+ if (Re(e))
1182
+ return We(e);
1183
+ if (typeof e == "boolean")
1184
+ return e ? "true" : "false";
1185
+ if (e === null)
1186
+ return "null";
1187
+ if (Array.isArray(e)) {
1188
+ const r = [];
1189
+ return e.forEach((n) => {
1190
+ r.length > 0 && r.push(","), n ? typeof n == "string" ? r.push(n) : r.push(n.display || n.value || "") : r.push("null");
1191
+ }), r.splice(0, 0, "["), r.push("]"), r.join("");
1192
+ }
1193
+ return e;
1192
1194
  }
1193
- async function or(e, t, r, n, a) {
1194
- const { app: s } = d, i = {
1195
- app: s || "",
1195
+ function We(e) {
1196
+ if (!e)
1197
+ return "";
1198
+ try {
1199
+ if (Pe(e) === 0)
1200
+ return new Intl.DateTimeFormat("en-CA", {
1201
+ year: "numeric",
1202
+ month: "2-digit",
1203
+ day: "2-digit"
1204
+ }).format(e);
1205
+ {
1206
+ const t = new Intl.DateTimeFormat("en-CA").format(e), r = new Intl.DateTimeFormat("en-CA", {
1207
+ hour: "2-digit",
1208
+ minute: "2-digit",
1209
+ second: "2-digit",
1210
+ hour12: !1
1211
+ }).format(e);
1212
+ return `${t} ${r}`;
1213
+ }
1214
+ } catch {
1215
+ return "Invalid date";
1216
+ }
1217
+ }
1218
+ async function nr(e, t, r, n, a) {
1219
+ const { app: o } = u, s = {
1220
+ app: o || "",
1196
1221
  suggestQuery: e,
1197
1222
  text: t,
1198
1223
  filter: r,
@@ -1200,97 +1225,116 @@ async function or(e, t, r, n, a) {
1200
1225
  showSource: a
1201
1226
  };
1202
1227
  try {
1203
- return (await u("api/v1/search.suggest", i)).suggests;
1204
- } catch (o) {
1205
- throw console.error("Error fetching suggestions:", o), o;
1228
+ return (await l(
1229
+ "api/v1/search.suggest",
1230
+ s
1231
+ )).suggests;
1232
+ } catch (c) {
1233
+ throw console.error("Error fetching suggestions:", c), c;
1206
1234
  }
1207
1235
  }
1208
- async function cr(e, t, r, n) {
1209
- const { app: a } = d;
1210
- return (await u("api/v1/suggestquery", {
1211
- app: a || "",
1212
- suggestQuery: e,
1213
- text: t,
1214
- query: r,
1215
- kinds: n
1216
- })).suggests;
1236
+ async function ar(e, t, r, n) {
1237
+ const { app: a } = u;
1238
+ return (await l(
1239
+ "api/v1/suggestquery",
1240
+ {
1241
+ app: a || "",
1242
+ suggestQuery: e,
1243
+ text: t,
1244
+ query: r,
1245
+ kinds: n
1246
+ }
1247
+ )).suggests;
1217
1248
  }
1218
- async function ir(e, t) {
1249
+ async function or(e, t, r) {
1219
1250
  if (!t) return Promise.resolve([]);
1220
- const { app: r } = d;
1221
- return (await u("api/v1/suggestfield", {
1222
- app: r || "",
1223
- text: e,
1224
- action: "suggests",
1225
- fields: t
1226
- })).suggests;
1227
- }
1228
- async function lr(e, t, r, n, a, s) {
1229
- return u("api/v1/doc.textchunks", {
1251
+ const { app: n } = u, o = await l(
1252
+ "api/v1/suggestfield",
1253
+ {
1254
+ app: n || "",
1255
+ text: e,
1256
+ fields: t,
1257
+ query: r
1258
+ }
1259
+ );
1260
+ return o.suggests.forEach((s) => {
1261
+ s.display = Je(s.display);
1262
+ }), o.suggests;
1263
+ }
1264
+ async function sr(e, t, r, n, a, o) {
1265
+ return l("api/v1/doc.textchunks", {
1230
1266
  id: e,
1231
1267
  textChunks: t,
1232
1268
  highlights: r,
1233
1269
  query: n,
1234
1270
  leftSentencesCount: a,
1235
- rightSentencesCount: s
1271
+ rightSentencesCount: o
1236
1272
  });
1237
1273
  }
1238
- async function ur() {
1239
- const { app: e } = d, t = new URLSearchParams({
1274
+ async function ir() {
1275
+ const { app: e } = u, t = new URLSearchParams({
1240
1276
  app: e || "",
1241
1277
  action: "load"
1242
1278
  });
1243
- return S("api/v1/usersettings", t);
1279
+ return w("api/v1/usersettings", t);
1244
1280
  }
1245
- async function Ye(e, t) {
1281
+ async function Me(e, t) {
1246
1282
  const r = {
1247
1283
  action: "save",
1248
1284
  userSettings: e,
1249
1285
  $auditRecord: { auditEvents: [t] }
1250
1286
  };
1251
- return y(r), u("api/v1/usersettings", r);
1287
+ return L(r), l("api/v1/usersettings", r);
1252
1288
  }
1253
- async function dr(e, t) {
1289
+ async function cr(e, t) {
1254
1290
  const n = {
1255
1291
  action: "patch",
1256
1292
  userSettings: e,
1257
1293
  $auditRecord: t ? { auditEvents: [t] } : void 0
1258
1294
  };
1259
- return y(n), u("api/v1/usersettings", n);
1295
+ return L(n), l("api/v1/usersettings", n);
1260
1296
  }
1261
- async function fr() {
1262
- return Ye({}, { type: "UserSettings_Reset" });
1297
+ async function lr() {
1298
+ return Me({}, { type: "UserSettings_Reset" });
1263
1299
  }
1264
- async function hr(e, t) {
1265
- return u("api/v2/security/password/change", { newPassword: e, currentPassword: t });
1300
+ async function ur(e, t) {
1301
+ return l("api/v2/security/password/change", { newPassword: e, currentPassword: t });
1266
1302
  }
1267
- async function mr(e) {
1303
+ async function dr(e) {
1268
1304
  const t = "api/v2/security/password/ask-reset-email", n = {
1269
1305
  changePasswordRedirectUrl: `${window.location.origin}/login?mode=changepassword`,
1270
1306
  userName: e
1271
1307
  };
1272
- return u(t, n);
1308
+ return l(t, n);
1273
1309
  }
1274
- async function wr(e) {
1275
- return await S(`api/v2/user-profile/${e}`);
1310
+ async function fr(e) {
1311
+ return await w(`api/v2/user-profile/${e}`);
1276
1312
  }
1277
- async function _r(e) {
1278
- return await u("api/v2/user-profile", e);
1313
+ async function hr(e) {
1314
+ return await l("api/v2/user-profile", e);
1279
1315
  }
1280
- async function gr(e, t, r) {
1281
- var a;
1282
- return await be(
1283
- `api/v2/user-profile/${(a = e.data) == null ? void 0 : a.id}/${t}/${r}`,
1316
+ async function mr(e, t, r) {
1317
+ return await ge(
1318
+ `api/v2/user-profile/${e.data?.id}/${t}/${r}`,
1284
1319
  e
1285
1320
  );
1286
1321
  }
1287
- async function Sr() {
1288
- return await S("api/v2/version");
1322
+ async function pr(e, t, r) {
1323
+ try {
1324
+ return (await pe(
1325
+ `api/v2/user-profile/${e.data?.id}/${t}/${r}`
1326
+ )).success === !0;
1327
+ } catch {
1328
+ return !1;
1329
+ }
1330
+ }
1331
+ async function gr() {
1332
+ return await w("api/v2/version");
1289
1333
  }
1290
- const Ke = async () => {
1291
- const { autoOAuthProvider: e } = d;
1334
+ const Xe = async () => {
1335
+ const { autoOAuthProvider: e } = u;
1292
1336
  if (typeof window > "u")
1293
- return u("security.oauth", {
1337
+ return l("security.oauth", {
1294
1338
  action: "getcode",
1295
1339
  provider: e,
1296
1340
  tokenInCookie: !0,
@@ -1303,7 +1347,7 @@ const Ke = async () => {
1303
1347
  originalUrl: window.location.href
1304
1348
  };
1305
1349
  try {
1306
- const r = await u(
1350
+ const r = await l(
1307
1351
  "api/v1/security.oauth",
1308
1352
  t
1309
1353
  );
@@ -1311,10 +1355,10 @@ const Ke = async () => {
1311
1355
  } catch (r) {
1312
1356
  throw console.error("Failed to authenticate with OAuth", r), r;
1313
1357
  }
1314
- }, Ze = async () => {
1315
- const { autoSAMLProvider: e } = d;
1358
+ }, Ye = async () => {
1359
+ const { autoSAMLProvider: e } = u;
1316
1360
  if (typeof window > "u")
1317
- return u("security.saml", {
1361
+ return l("security.saml", {
1318
1362
  action: "getresponse",
1319
1363
  provider: e,
1320
1364
  tokenInCookie: !0,
@@ -1327,7 +1371,7 @@ const Ke = async () => {
1327
1371
  originalUrl: window.location.href
1328
1372
  };
1329
1373
  try {
1330
- const r = await u(
1374
+ const r = await l(
1331
1375
  "api/v1/security.saml",
1332
1376
  t
1333
1377
  );
@@ -1335,7 +1379,7 @@ const Ke = async () => {
1335
1379
  } catch (r) {
1336
1380
  throw console.error("Failed to authenticate with SAML", r), r;
1337
1381
  }
1338
- }, H = {
1382
+ }, G = {
1339
1383
  store: {},
1340
1384
  getItem(e) {
1341
1385
  return this.store[e] ?? null;
@@ -1349,36 +1393,36 @@ const Ke = async () => {
1349
1393
  clear() {
1350
1394
  this.store = {};
1351
1395
  }
1352
- }, J = H;
1353
- function Ee(e) {
1354
- return typeof window > "u" || !window.localStorage ? H.getItem(e) : window.localStorage.getItem(e);
1396
+ }, z = G;
1397
+ function Ke(e) {
1398
+ return typeof window > "u" || !window.localStorage ? G.getItem(e) : window.localStorage.getItem(e);
1355
1399
  }
1356
- function Te(e) {
1357
- typeof window > "u" || !window.localStorage ? H.removeItem(e) : window.localStorage.removeItem(e);
1400
+ function Ze(e) {
1401
+ typeof window > "u" || !window.localStorage ? G.removeItem(e) : window.localStorage.removeItem(e);
1358
1402
  }
1359
- function et(e) {
1360
- return typeof window > "u" || !window.sessionStorage ? J.getItem(e) : window.sessionStorage.getItem(e);
1403
+ function Ee(e) {
1404
+ return typeof window > "u" || !window.sessionStorage ? z.getItem(e) : window.sessionStorage.getItem(e);
1361
1405
  }
1362
- function tt(e, t) {
1363
- typeof window > "u" || !window.sessionStorage ? J.setItem(e, t) : window.sessionStorage.setItem(e, t);
1406
+ function Te(e, t) {
1407
+ typeof window > "u" || !window.sessionStorage ? z.setItem(e, t) : window.sessionStorage.setItem(e, t);
1364
1408
  }
1365
- function rt(e) {
1366
- typeof window > "u" || !window.sessionStorage ? J.removeItem(e) : window.sessionStorage.removeItem(e);
1409
+ function et(e) {
1410
+ typeof window > "u" || !window.sessionStorage ? z.removeItem(e) : window.sessionStorage.removeItem(e);
1367
1411
  }
1368
- const $ = (e) => tt(
1412
+ const U = (e) => Te(
1369
1413
  "sinequa-credentials",
1370
1414
  JSON.stringify({ data: { csrfToken: e } })
1371
- ), nt = async () => {
1415
+ ), tt = async () => {
1372
1416
  try {
1373
- const e = await S(
1417
+ const e = await w(
1374
1418
  "api/v1/challenge?action=getCsrfToken&suppressErrors=true"
1375
1419
  );
1376
- return e != null && e.csrfToken ? ($(e.csrfToken), e.csrfToken) : null;
1420
+ return e?.csrfToken ? (U(e.csrfToken), e.csrfToken) : null;
1377
1421
  } catch (e) {
1378
- throw h("Failed to get CSRF token", e), e;
1422
+ throw f("Failed to get CSRF token", e), e;
1379
1423
  }
1380
1424
  };
1381
- async function at(e) {
1425
+ async function rt(e) {
1382
1426
  if (e) {
1383
1427
  const { username: t, password: r } = e, n = {
1384
1428
  action: "get",
@@ -1389,11 +1433,11 @@ async function at(e) {
1389
1433
  noAutoAuthentication: !0
1390
1434
  };
1391
1435
  try {
1392
- const a = await u(
1436
+ const a = await l(
1393
1437
  "api/v1/security.webtoken",
1394
1438
  n
1395
1439
  );
1396
- return a != null && a.csrfToken ? ($(a.csrfToken), a.csrfToken) : null;
1440
+ return a?.csrfToken ? (U(a.csrfToken), a.csrfToken) : null;
1397
1441
  } catch (a) {
1398
1442
  throw console.error("Failed to get JWT", a), a;
1399
1443
  }
@@ -1404,7 +1448,7 @@ async function at(e) {
1404
1448
  noUserOverride: !0,
1405
1449
  noAutoAuthentication: !1
1406
1450
  // Allow auto authentication for credentialless requests
1407
- }, { bearerToken: r } = d;
1451
+ }, { bearerToken: r } = u;
1408
1452
  if (!r)
1409
1453
  throw new Error(
1410
1454
  "Bearer token is required in globalConfig for credentialless JWT retrieval."
@@ -1412,213 +1456,215 @@ async function at(e) {
1412
1456
  const n = new Headers();
1413
1457
  n.append("Sinequa-Force-Camel-Case", "true"), n.append("accept", "application/json"), n.append("Content-Type", "application/json"), n.append("Authorization", `Bearer ${r}`);
1414
1458
  try {
1415
- const a = await u(
1459
+ const a = await l(
1416
1460
  "api/v1/security.webtoken",
1417
1461
  t,
1418
1462
  { headers: n }
1419
1463
  );
1420
- return a.csrfToken ? ($(a.csrfToken), a.csrfToken) : null;
1464
+ return a.csrfToken ? (U(a.csrfToken), a.csrfToken) : null;
1421
1465
  } catch (a) {
1422
1466
  throw console.error("Failed to get JWT without credentials", a), a;
1423
1467
  }
1424
1468
  }
1425
1469
  }
1426
- const W = () => {
1427
- var r;
1428
- const e = et("sinequa-credentials");
1470
+ const H = () => {
1471
+ const e = Ee("sinequa-credentials");
1429
1472
  if (e)
1430
1473
  try {
1431
- const a = (r = JSON.parse(e).data) == null ? void 0 : r.csrfToken;
1432
- if (a !== void 0) return a;
1474
+ const n = JSON.parse(e).data?.csrfToken;
1475
+ if (n !== void 0) return n;
1433
1476
  } catch {
1434
1477
  }
1435
- const t = Ee("csrfToken");
1478
+ const t = Ke("csrfToken");
1436
1479
  return t !== null ? t : null;
1437
- }, pr = async (e) => {
1480
+ }, wr = async (e) => {
1438
1481
  if (e)
1439
- p("Attempting authentication using credentials"), k({ useCredentials: !0, useSSO: !1 });
1482
+ S("Attempting authentication using credentials"), k({ useCredentials: !0, useSSO: !1 });
1440
1483
  else {
1441
- let o = null;
1484
+ let c = null;
1442
1485
  try {
1443
- p("Attempting to retrieve CSRF token from the backend"), o = await nt(), x("CSRF token retrieval result", o ? "success" : "failed");
1444
- } catch (c) {
1445
- h("Failed to retrieve CSRF token", c);
1486
+ S("Attempting to retrieve CSRF token from the backend"), c = await tt(), y("CSRF token retrieval result", c ? "success" : "failed");
1487
+ } catch (i) {
1488
+ f("Failed to retrieve CSRF token", i);
1446
1489
  }
1447
1490
  try {
1448
- if (o === null) {
1449
- const { autoOAuthProvider: c, autoSAMLProvider: l, useSAML: f } = d;
1450
- if (c && !f)
1451
- return p("Initiating OAuth authentication flow"), await Ke(), P("OAuth authentication flow did not redirect as expected"), _(!1), !1;
1452
- if (l)
1453
- return p("Initiating SAML authentication flow"), await Ze(), P("SAML authentication flow did not redirect as expected"), _(!1), !1;
1454
- p(
1491
+ if (c === null) {
1492
+ const { autoOAuthProvider: i, autoSAMLProvider: d, useSAML: _ } = u;
1493
+ if (i && !_)
1494
+ return S("Initiating OAuth authentication flow"), await Xe(), P("OAuth authentication flow did not redirect as expected"), p(!1), !1;
1495
+ if (d)
1496
+ return S("Initiating SAML authentication flow"), await Ye(), P("SAML authentication flow did not redirect as expected"), p(!1), !1;
1497
+ S(
1455
1498
  "No direct authentication method available, will try SSO then credentials"
1456
1499
  ), k({ useCredentials: !0, useSSO: !0 });
1457
1500
  } else
1458
- return p("User authenticated via existing token"), _(!0), !0;
1459
- } catch (c) {
1460
- throw h("Unexpected error during authentication", c), _(!1), c;
1501
+ return S("User authenticated via existing token"), p(!0), !0;
1502
+ } catch (i) {
1503
+ throw f("Unexpected error during authentication", i), p(!1), i;
1461
1504
  }
1462
1505
  }
1463
- if (d.useCredentials && d.useSSO)
1506
+ if (u.useCredentials && u.useSSO)
1464
1507
  try {
1465
- if (p("Checking if user is authenticated via SSO"), await ce())
1466
- return p("User authenticated using SSO"), k({ useCredentials: !1, useSSO: !0 }), _(!0), !0;
1467
- } catch (o) {
1468
- if ((o == null ? void 0 : o.status) === 401)
1469
- return p("SSO authentication failed with 401, falling back to credentials"), k({ useCredentials: !0, useSSO: !1 }), !1;
1470
- throw h("SSO authentication failed with unexpected error", o), _(!1), h;
1508
+ if (S("Checking if user is authenticated via SSO"), await re())
1509
+ return S("User authenticated using SSO"), k({ useCredentials: !1, useSSO: !0 }), p(!0), !0;
1510
+ } catch (c) {
1511
+ if (c?.status === 401)
1512
+ return S("SSO authentication failed with 401, falling back to credentials"), k({ useCredentials: !0, useSSO: !1 }), !1;
1513
+ throw f("SSO authentication failed with unexpected error", c), p(!1), f;
1471
1514
  }
1472
- const { useSSO: r } = d, n = W();
1515
+ const { useSSO: r } = u, n = H();
1473
1516
  if (n && n !== null || r)
1474
- return p("user already authenticated", n), k({ isRedirectUrl: !1 }), _(!0), !0;
1475
- const { useCredentials: a } = d, { username: s, password: i } = e || {};
1476
- if (a && !s && !i)
1477
- return h("Credentials are required for authentication"), _(!1), !1;
1478
- if (s && i)
1517
+ return S("user already authenticated", n), k({ isRedirectUrl: !1 }), p(!0), !0;
1518
+ const { useCredentials: a } = u, { username: o, password: s } = e || {};
1519
+ if (a && !o && !s)
1520
+ return f("Credentials are required for authentication"), p(!1), !1;
1521
+ if (o && s)
1479
1522
  try {
1480
- p("authentication using credentials..."), k({ useCredentials: !0, useSSO: !1 });
1481
- const { userOverrideActive: o, useroverride: c } = d;
1482
- return k({ userOverrideActive: !1, useroverride: void 0 }), await at({ username: s, password: i }), k({ userOverrideActive: o, useroverride: c }), _(!0), !0;
1483
- } catch (o) {
1484
- throw _(!1), o;
1523
+ S("authentication using credentials..."), k({ useCredentials: !0, useSSO: !1 });
1524
+ const { userOverrideActive: c, useroverride: i } = u;
1525
+ return k({ userOverrideActive: !1, useroverride: void 0 }), await rt({ username: o, password: s }), k({ userOverrideActive: c, useroverride: i }), p(!0), !0;
1526
+ } catch (c) {
1527
+ throw p(!1), c;
1485
1528
  }
1486
- return _(!1), h(
1529
+ return p(!1), f(
1487
1530
  "No authentication method available. Please provide credentials or configure OAuth/SAML."
1488
1531
  ), !1;
1489
- }, st = async () => {
1532
+ }, nt = async () => {
1490
1533
  const e = new URLSearchParams({
1491
1534
  action: "deleteWebTokenCookie",
1492
1535
  noUserOverride: "true",
1493
1536
  noAutoAuthentication: "true"
1494
1537
  });
1495
- return S("api/v1/challenge", e);
1496
- }, kr = async () => {
1497
- const { useCredentials: e, userOverrideActive: t } = d;
1498
- Te("csrfToken"), rt("sinequa-credentials"), e && !t ? (await st()).methodresult === "ok" ? _(!1) : console.error("logout failed") : _(!1);
1499
- }, vr = () => !!W();
1538
+ return w("api/v1/challenge", e);
1539
+ }, _r = async () => {
1540
+ const { useCredentials: e, userOverrideActive: t } = u;
1541
+ Ze("csrfToken"), et("sinequa-credentials"), e && !t ? (await nt()).methodresult === "ok" ? p(!1) : console.error("logout failed") : p(!1);
1542
+ }, Sr = () => !!H();
1500
1543
  export {
1501
- Tt as API,
1502
- b as ApiError,
1503
- Gt as Audit,
1504
- v as AuditEventType,
1505
- Ce as DidYouMeanKind,
1506
- m as EngineType,
1544
+ Kt as API,
1545
+ v as ApiError,
1546
+ jt as Audit,
1547
+ b as AuditEventType,
1548
+ we as DidYouMeanKind,
1549
+ h as EngineType,
1507
1550
  g as EngineTypeModifier,
1508
- ae as LogLevel,
1509
- Nt as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1510
- Re as RFMDisplay,
1511
- K as ServerError,
1512
- de as TimeoutError,
1513
- V as UnauthorizedError,
1514
- y as addAuditAdditionalInfo,
1515
- dt as addConcepts,
1516
- De as addSessionId,
1517
- Ae as addUrl,
1518
- fe as aggItemRegex,
1519
- it as aggregationItemStrictCompare,
1520
- Jt as appInitializerFn,
1521
- ut as bisect,
1522
- z as buildPathsAndLevels,
1523
- Lt as configureLogger,
1524
- L as createHeaders,
1525
- Ut as createTimeoutController,
1526
- _r as createUserProfile,
1527
- x as debug,
1528
- yt as del,
1529
- fr as deleteUserSettings,
1530
- st as deleteWebTokenCookie,
1531
- _ as emitAuthenticatedEvent,
1532
- h as error,
1533
- jt as escapeExpr,
1534
- It as expiresSoon,
1535
- Ft as extraColumns,
1536
- zt as fetchAggregation,
1537
- Ht as fetchApp,
1538
- qe as fetchAppPreLogin,
1539
- tr as fetchBulkQuery,
1540
- hr as fetchChangePassword,
1541
- Wt as fetchDataset,
1542
- Mt as fetchDatasetList,
1543
- Xt as fetchDatasets,
1544
- Yt as fetchLabels,
1545
- Zt as fetchPreview,
1546
- Et as fetchPreviewUrl,
1547
- ce as fetchPrincipal,
1548
- We as fetchPrincipalList,
1549
- Xe as fetchPrincipalUserid,
1550
- Me as fetchPrincipalUserids,
1551
- er as fetchQuery,
1552
- rr as fetchQueryExport,
1553
- nr as fetchQueryIntent,
1554
- mr as fetchSendPasswordResetEmail,
1555
- ar as fetchSimilarDocuments,
1556
- sr as fetchSponsoredLinks,
1557
- or as fetchSuggest,
1558
- ir as fetchSuggestField,
1559
- cr as fetchSuggestQuery,
1560
- lr as fetchTextChunks,
1561
- wr as fetchUserProfile,
1562
- ur as fetchUserSettings,
1563
- Sr as fetchVersion,
1564
- S as get,
1565
- mt as getConcepts,
1566
- nt as getCsrfToken,
1567
- ne as getFiltersFromURI,
1568
- pt as getFiltersFromUrl,
1569
- xt as getHelpIndexUrl,
1570
- vt as getIdFromUrl,
1571
- at as getJWToken,
1572
- Bt as getMetadata,
1573
- qt as getMetadataWithValues,
1574
- ve as getOffsetFromDates,
1575
- bt as getQueryPageFromUrl,
1576
- gt as getQueryParamsFromUrl,
1577
- Ct as getQueryTabFromUrl,
1578
- kt as getQueryTextFromUrl,
1579
- wt as getRelativeDate,
1580
- W as getToken,
1581
- St as getUrlParamsFromQueryParams,
1582
- d as globalConfig,
1583
- $e as guid,
1551
+ T as LogLevel,
1552
+ Dt as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1553
+ _e as RFMDisplay,
1554
+ J as ServerError,
1555
+ ae as TimeoutError,
1556
+ j as UnauthorizedError,
1557
+ L as addAuditAdditionalInfo,
1558
+ lt as addConcepts,
1559
+ Oe as addSessionId,
1560
+ $e as addUrl,
1561
+ oe as aggItemRegex,
1562
+ st as aggregationItemStrictCompare,
1563
+ Gt as appInitializerFn,
1564
+ ct as bisect,
1565
+ V as buildPathsAndLevels,
1566
+ yt as configureLogger,
1567
+ x as createHeaders,
1568
+ xt as createTimeoutController,
1569
+ hr as createUserProfile,
1570
+ y as debug,
1571
+ pe as del,
1572
+ pr as deleteUserProfileProperty,
1573
+ lr as deleteUserSettings,
1574
+ nt as deleteWebTokenCookie,
1575
+ p as emitAuthenticatedEvent,
1576
+ f as error,
1577
+ Ft as escapeExpr,
1578
+ Ot as expiresSoon,
1579
+ It as extraColumns,
1580
+ Qt as fetchAggregation,
1581
+ Vt as fetchApp,
1582
+ Ae as fetchAppPreLogin,
1583
+ Et as fetchBulkQuery,
1584
+ ur as fetchChangePassword,
1585
+ zt as fetchDataset,
1586
+ Jt as fetchDatasetList,
1587
+ Ht as fetchDatasets,
1588
+ Wt as fetchLabels,
1589
+ Xt as fetchPreview,
1590
+ Yt as fetchPreviewUrl,
1591
+ re as fetchPrincipal,
1592
+ Ge as fetchPrincipalList,
1593
+ ze as fetchPrincipalUserid,
1594
+ He as fetchPrincipalUserids,
1595
+ Zt as fetchQuery,
1596
+ Tt as fetchQueryExport,
1597
+ er as fetchQueryIntent,
1598
+ dr as fetchSendPasswordResetEmail,
1599
+ tr as fetchSimilarDocuments,
1600
+ rr as fetchSponsoredLinks,
1601
+ nr as fetchSuggest,
1602
+ or as fetchSuggestField,
1603
+ ar as fetchSuggestQuery,
1604
+ sr as fetchTextChunks,
1605
+ fr as fetchUserProfile,
1606
+ ir as fetchUserSettings,
1607
+ gr as fetchVersion,
1608
+ w as get,
1609
+ ft as getConcepts,
1610
+ tt as getCsrfToken,
1611
+ E as getFiltersFromURI,
1612
+ wt as getFiltersFromUrl,
1613
+ Ct as getHelpIndexUrl,
1614
+ St as getIdFromUrl,
1615
+ rt as getJWToken,
1616
+ At as getMetadata,
1617
+ Nt as getMetadataWithValues,
1618
+ me as getOffsetFromDates,
1619
+ kt as getQueryPageFromUrl,
1620
+ pt as getQueryParamsFromUrl,
1621
+ bt as getQueryTabFromUrl,
1622
+ _t as getQueryTextFromUrl,
1623
+ ht as getRelativeDate,
1624
+ Pe as getTime,
1625
+ H as getToken,
1626
+ gt as getUrlParamsFromQueryParams,
1627
+ u as globalConfig,
1628
+ xe as guid,
1584
1629
  C as handleResponse,
1585
- p as info,
1586
- ye as isArrayBuffer,
1587
- vr as isAuthenticated,
1588
- Oe as isBlob,
1589
- $t as isExpired,
1590
- Qt as isJsonable,
1591
- _t as isNotInputEvent,
1630
+ S as info,
1631
+ ve as isArrayBuffer,
1632
+ Sr as isAuthenticated,
1633
+ Ce as isBlob,
1634
+ Re as isDate,
1635
+ Lt as isExpired,
1636
+ qt as isJsonable,
1637
+ mt as isNotInputEvent,
1592
1638
  A as isObject,
1593
- Ue as isString,
1594
- Kt as labels,
1595
- pr as login,
1596
- kr as logout,
1597
- w as makeColumn,
1598
- Pt as notify,
1599
- me as openParentNodes,
1600
- I as parseText,
1601
- he as parseValueAndOperatorFromItem,
1602
- be as patch,
1603
- gr as patchUserProfile,
1604
- dr as patchUserSettings,
1605
- u as post,
1606
- Ot as put,
1639
+ ye as isString,
1640
+ Mt as labels,
1641
+ wr as login,
1642
+ _r as logout,
1643
+ m as makeColumn,
1644
+ Rt as notify,
1645
+ ie as openParentNodes,
1646
+ D as parseText,
1647
+ se as parseValueAndOperatorFromItem,
1648
+ ge as patch,
1649
+ mr as patchUserProfile,
1650
+ cr as patchUserSettings,
1651
+ l as post,
1652
+ Pt as put,
1607
1653
  R as queryParamsFromUrl,
1608
- ft as removeConcept,
1609
- ht as removeConcepts,
1610
- At as resolveToColumnName,
1611
- G as rewriteText,
1612
- Ye as saveUserSettings,
1654
+ ut as removeConcept,
1655
+ dt as removeConcepts,
1656
+ Ut as resolveToColumnName,
1657
+ Q as rewriteText,
1658
+ Me as saveUserSettings,
1613
1659
  k as setGlobalConfig,
1614
- $ as setToken,
1615
- Vt as sha512,
1616
- lt as suggestionsToTreeAggregationNodes,
1617
- Rt as sysLang,
1618
- se as toDate,
1619
- ct as translateAggregationToDateOptions,
1620
- Ke as tryOAuthAuthentication,
1621
- Ze as trySAMLAuthentication,
1660
+ U as setToken,
1661
+ Bt as sha512,
1662
+ it as suggestionsToTreeAggregationNodes,
1663
+ vt as sysLang,
1664
+ ee as toDate,
1665
+ ot as translateAggregationToDateOptions,
1666
+ Xe as tryOAuthAuthentication,
1667
+ Ye as trySAMLAuthentication,
1622
1668
  P as warn,
1623
- Dt as withRetry
1669
+ $t as withRetry
1624
1670
  };