@sinequa/atomic 0.0.110 → 0.0.121

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