@sinequa/atomic 0.0.113 → 0.0.122

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