@sinequa/atomic 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/atomic.js
CHANGED
|
@@ -15,7 +15,7 @@ const u = {
|
|
|
15
15
|
function k(e) {
|
|
16
16
|
Object.assign(u, e);
|
|
17
17
|
}
|
|
18
|
-
const ce =
|
|
18
|
+
const ce = /.*:\(?([><=\d\-.AND ]+)\)?/;
|
|
19
19
|
function ut(e, t) {
|
|
20
20
|
return !e?.items || e?.items?.length === 0 ? [] : e.items.reduce((o, a) => {
|
|
21
21
|
if (!a.value || a.value === "") return o;
|
|
@@ -34,17 +34,27 @@ function le(e, t) {
|
|
|
34
34
|
const r = t, n = e.value.match(ce);
|
|
35
35
|
if (n?.[1]) {
|
|
36
36
|
const a = (n?.[1].split(" AND ")).map((s) => {
|
|
37
|
-
const i = s.indexOf(">=") !== -1 ? "gte" : "lt";
|
|
38
|
-
let c = s.substring(s.indexOf(" ") + 1);
|
|
37
|
+
const i = s.indexOf(">=") !== -1 ? "gte" : "lt", c = s.substring(s.indexOf(" ") + 1);
|
|
39
38
|
return { field: r, operator: i, value: c, display: e.display || e.value };
|
|
40
39
|
});
|
|
41
40
|
if (a.length === 2)
|
|
42
|
-
return {
|
|
41
|
+
return {
|
|
42
|
+
field: r,
|
|
43
|
+
operator: "and",
|
|
44
|
+
filters: a,
|
|
45
|
+
value: e.value,
|
|
46
|
+
display: a[0].display || a[0].value
|
|
47
|
+
};
|
|
43
48
|
if (a.length === 1)
|
|
44
49
|
return { ...a[0], field: r };
|
|
45
50
|
throw new Error("Failed to parse distribution expression");
|
|
46
51
|
}
|
|
47
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
field: r,
|
|
54
|
+
operator: "eq",
|
|
55
|
+
value: e.value,
|
|
56
|
+
display: e.display
|
|
57
|
+
};
|
|
48
58
|
}
|
|
49
59
|
function dt(e, t, r) {
|
|
50
60
|
return e.valuesAreExpressions ? t.display === r.display : t.value === r.value;
|
|
@@ -59,7 +69,15 @@ function ft(e, t) {
|
|
|
59
69
|
e.forEach((i) => {
|
|
60
70
|
if (i.display.length > 1) {
|
|
61
71
|
const c = i.display.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), d = s.exec(c);
|
|
62
|
-
ee(
|
|
72
|
+
ee(
|
|
73
|
+
r,
|
|
74
|
+
n,
|
|
75
|
+
"/",
|
|
76
|
+
i.display,
|
|
77
|
+
+(i.frequency || 0),
|
|
78
|
+
1,
|
|
79
|
+
(d?.index || 0) + t.length
|
|
80
|
+
);
|
|
63
81
|
}
|
|
64
82
|
});
|
|
65
83
|
}
|
|
@@ -80,7 +98,15 @@ function ee(e, t, r, n, o, a, s) {
|
|
|
80
98
|
$path: _
|
|
81
99
|
}, t.set(c, d), e.push(d);
|
|
82
100
|
}
|
|
83
|
-
c.length < n.length && (d.hasChildren = !0, ee(
|
|
101
|
+
c.length < n.length && (d.hasChildren = !0, ee(
|
|
102
|
+
d.items,
|
|
103
|
+
t,
|
|
104
|
+
c,
|
|
105
|
+
n,
|
|
106
|
+
o,
|
|
107
|
+
a + 1,
|
|
108
|
+
s
|
|
109
|
+
));
|
|
84
110
|
}
|
|
85
111
|
function ht(e, t) {
|
|
86
112
|
return e.reduce((r, n) => (t(n) ? r.true.push(n) : r.false.push(n), r), { true: [], false: [] });
|
package/dist/atomic.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(o=typeof globalThis<"u"?globalThis:o||self,m(o.atomic={}))})(this,(function(o){"use strict";function m(e){if(typeof CustomEvent>"u"||typeof dispatchEvent>"u")return;const t=new CustomEvent("authenticated",{bubbles:!0,cancelable:!1,detail:{authenticated:e}});dispatchEvent(t)}const d={loginPath:"/login",createRoutes:!1};function p(e){Object.assign(d,e)}const T=/.*\:\(?([><=\d\-\.AND ]+)\)?/;function Be(e,t){return!e?.items||e?.items?.length===0?[]:e.items.reduce((a,s)=>{if(!s.value||s.value==="")return a;const i=ee(s,e.column);return a.push({operator:i.operator,value:i.value,display:s.display||i.display,filters:i.filters,disabled:s.count===0,hidden:s.count===0&&e.isDistribution?!t:!1}),a},[])}function ee(e,t){const r=t,n=e.value.match(T);if(n?.[1]){const s=(n?.[1].split(" AND ")).map(i=>{const c=i.indexOf(">=")!==-1?"gte":"lt";let l=i.substring(i.indexOf(" ")+1);return{field:r,operator:c,value:l,display:e.display||e.value}});if(s.length===2)return{field:r,operator:"and",filters:s,value:e.value,display:s[0].display||s[0].value};if(s.length===1)return{...s[0],field:r};throw new Error("Failed to parse distribution expression")}return{field:r,operator:"eq",value:e.value,display:e.display}}function Qe(e,t,r){return e.valuesAreExpressions?t.display===r.display:t.value===r.value}function te(e){return e.items&&(e.items=e.items.map(t=>te(t))),e.items&&e.items.some(t=>t.$selected||t.$opened)&&(e.$opened=!0),e}function je(e,t){const r=[];if(e.length>0){const n=new Map,s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,""),i=new RegExp("\\b"+s,"i");e.forEach(c=>{if(c.display.length>1){const l=c.display.normalize("NFD").replace(/[\u0300-\u036f]/g,""),h=i.exec(l);re(r,n,"/",c.display,+(c.frequency||0),1,(h?.index||0)+t.length)}})}return r}function re(e,t,r,n,a,s,i){const c=n.indexOf("/",r.length),l=n.substring(0,c+1);let h=t.get(l);if(!h){const b=l.replace(/^\/|\/$/g,"");h={value:n.substring(r.length,c),count:a,items:[],hasChildren:!1,$level:s,$opened:i>=l.length,$path:b},t.set(l,h),e.push(h)}l.length<n.length&&(h.hasChildren=!0,re(h.items,t,l,n,a,s+1,i))}function Ve(e,t){return e.reduce((r,n)=>(t(n)?r.true.push(n):r.false.push(n),r),{true:[],false:[]})}const xe=/(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g,Ge=2,ne=3,Me=5,ae=6,ze=8,oe=9,He=11,se=12,Je=14,ie=15;function I(e){if(!e)return[];const t=[],r=e.matchAll(xe);for(let n of r)n[ne]?t.push({type:"group",value:n[ne],op:n[Ge]}):n[ae]?t.push({type:"adjacent",value:n[ae],op:n[Me]}):n[oe]?t.push({type:"exact",value:n[oe],op:n[ze]}):n[se]?t.push({type:"regex",value:n[se],op:n[He]}):n[ie]&&t.push({type:"token",value:n[ie],op:n[Je]});return t}function N(e){return e.map(t=>{const r=t.op||"";switch(t.type){case"group":return`${r}(${t.value})`;case"adjacent":return`${r}[${t.value}]`;case"exact":return`${r}"${t.value}"`;case"regex":return`${r}/${t.value}/`;case"token":return`${r}${t.value}`}}).join(" ")}function We(e,t,r){let n=I(e);for(let a of t)n.push({type:"adjacent",value:a,op:r});return N(n)}function Xe(e,t){const r=I(t),n=r.findIndex(a=>a.value===e);return n!==-1?(r.splice(n,1),t=N(r)):t}function Ye(e){const t=I(e).filter(r=>r.type!=="adjacent");return N(t)}function Ke(e){return I(e).filter(t=>t.type==="adjacent").map(t=>t.value)}function Ze(e,t,r){const n=new Intl.RelativeTimeFormat(e,{numeric:"auto"}),{offset:a,unit:s,isFuture:i}=ce(t,r);return n.format(a*(i?1:-1),s)}function ce(e,t){const r=new Date(e),n=t?new Date(t):new Date,a=Math.abs(n.getTime()-r.getTime());return{offset:Math.floor(a/(1e3*60*60*24)),unit:"day",isFuture:r>n}}function Ee(e){const t=e.target;return t&&t.nodeName!=="INPUT"&&t.nodeName!=="TEXTAREA"}function Te(e){if(e===void 0)return;const{q:t,f:r,p:n,s:a,t:s,n:i,b:c}=L(e),[l]=e.split("?");return{path:l,text:t,filters:r?G(r):void 0,page:n?parseInt(n,10):void 0,sort:a,tab:s,name:i,basket:c}}function et(e){if(!e)return"";const{text:t,filters:r,page:n,sort:a,tab:s,name:i,basket:c}=e,l={};t&&(l.q=t),r&&(l.f=JSON.stringify(r)),n&&(l.p=n.toString()),a&&(l.s=a),s&&(l.t=s),i&&(l.n=i),c&&(l.b=c);const h=new URLSearchParams(l).toString();return h||""}function tt(e){if(e===void 0)return[];const{f:t}=L(e);return G(t)}function G(e){const t=decodeURIComponent(e);try{return JSON.parse(t??"[]")}catch{return console.error(`Error parsing filters from URI: ${e}`),[]}}function L(e){const t=e.split("?")[1];if(t===void 0)return{};const r=new URLSearchParams(t);return Object.fromEntries(r)}function rt(e){const{q:t=""}=L(e);return t}function nt(e){const{id:t}=L(e);return decodeURIComponent(t)}function at(e){const{p:t="0"}=L(e);return parseInt(t,10)}function ot(e){const{t}=L(e);return t}function st(e,t){if(!e)return e;let r=0;const n=e.length;let a=0;if(e[a]==="["){for(;a<n&&/[0-9]/.test(e[a]);)a++;e[a]==="]"&&(r=a+1)}const s=M(e,r,!1);if(!s)return e;const i=t.charCodeAt(0),c=t.charCodeAt(1);let l=s;for(;l;)if(i===l.lang1&&c===l.lang2){const b=M(e,l.end+4,!0);return e.substring(b.start,b.end)}else l=M(e,l.end+4,!1);const h=e.substring(s.start,s.end);return h||e}function M(e,t,r){for(let n=t,a=e.length-3;n<a;n++)if(e[n]==="["&&e[n+3]==="]")return{start:t,end:n,lang1:e.charCodeAt(n+1),lang2:e.charCodeAt(n+2)};if(r)return{start:t,end:e.length,lang1:-1,lang2:-1}}function it(e,t){const{useLocale:r,useLocaleAsPrefix:n,indexFile:a,path:s,folder:i}=t,c=r?`${e}/`:null,l=n?`${e}.${a}`:a??"";return[s,i,`${c||""}${l}`].filter(h=>h!==void 0).join("/")}function q(e){const t=new CustomEvent("notification",{bubbles:!0,cancelable:!1,detail:e});dispatchEvent(t)}const ct={success:(e,t)=>{q({type:"success",message:e,options:t})},info:(e,t)=>{q({type:"info",message:e,options:t})},warning:(e,t)=>{q({type:"warning",message:e,options:t})},error:(e,t)=>{q({type:"error",message:e,options:t})}};var z=(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))(z||{});let B={level:1,enableConsoleOutput:!0};function lt(e){B={...B,...e}}function Q(e,t,r){if(e<B.level)return;const a=`${`[${z[e]}]`} ${t}`;if(B.enableConsoleOutput)switch(e){case 0:console.debug(a,r||"");break;case 1:console.info(a,r||"");break;case 2:console.warn(a,r||"");break;case 3:console.error(a,r||"");break}}function U(e,t){Q(0,e,t)}function k(e,t){Q(1,e,t)}function A(e,t){Q(2,e,t)}function f(e,t){Q(3,e,t)}function O(e){const t=x(),r=new Headers(e);r.append("Sinequa-Force-Camel-Case","true"),r.append("accept","application/json"),t&&r.append("Sinequa-csrf-token",t);const{userOverride:n,userOverrideActive:a,bearerToken:s}=d;return s&&r.append("Authorization",`Bearer ${s}`),n&&a&&(r.append("sinequa-override-user",n.username),r.append("sinequa-override-domain",n.domain)),r}class P extends Error{status;constructor(t,r){super(t),this.name="ApiError",this.status=r}}class H extends P{constructor(t="Server error"){super(t,500),this.name="ServerError"}}class le extends P{constructor(t="Request timed out"){super(t,408),this.name="TimeoutError"}}class j extends P{constructor(t="Unauthorized access"){super(t,401),this.name="UnauthorizedError"}}async function y(e,t="json"){const r=e.headers.get("sinequa-jwt-refresh");if(r!==null&&F(r),e.status===200)switch(t){case"arraybuffer":return await e.arrayBuffer();case"blob":return await e.blob();case"text":return await e.text();default:return await e.json()}if(e.status===401){if(d.userOverrideActive){let n={};try{n=await e.clone().json()}catch{}throw A("Unauthorized access attempt with user override",{endpoint:e.url,error:n}),new j(n.errorMessage??n.message??"Unauthorized... User override failed.")}return await J(e,401)}return e.status===500?(f("Server error occurred",{endpoint:e.url}),await J(e,500)):(A(`Unexpected response status: ${e.status}`,{endpoint:e.url}),await J(e,e.status))}async function J(e,t){try{const{done:r,value:n}=await e.body?.getReader().read()||{done:!0,value:void 0};if(r||!n)throw t===401?new j:t===500?new H:new P(`Request failed with status ${t}`,t);const a=JSON.parse(new TextDecoder().decode(n));throw new Error(a.errorMessage||a.message||`Request failed with status ${t}`,{cause:{errorCode:a.errorCode,errorCodeTest:a.errorCodeTest}})}catch(r){throw r instanceof P?r:t===401?new j(r.message):t===500?new H(r.message):new P(r.message??`Request failed with status ${t}`,t)}}async function ue(e,t,r){const n=O(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"",i=a?`${a}/${e}${s}`:`${e}${s}`;U(`Making DELETE request to: ${i}`);try{const c=await fetch(i,{method:"DELETE",credentials:"include",headers:n});return y(c,r?.responseType)}catch(c){throw f("Error making DELETE request:",c),c}}async function _(e,t,r){const n=O(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"";e.startsWith("plugin")&&(e=`api/v1/${e}`);const i=a?`${a}/${e}${s}`:`${e}${s}`;U(`Making GET request to: ${i}`);try{const c=await fetch(i,{method:"GET",credentials:"include",headers:n,signal:r?.signal});return y(c,r?.responseType)}catch(c){throw f("Error making GET request:",c),c}}async function de(e,t,r){const n=O(r?.headers);n.append("content-type","application/json");const{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},c=s?`${s}/${e}`:`${e}`;U(`Making PATCH request to: ${c}`);try{const l=await fetch(c,{method:"PATCH",headers:n,credentials:"include",body:JSON.stringify(i)});return y(l,r?.responseType)}catch(l){throw f("Error making PATCH request:",l),l}}async function u(e,t,r){const n=O(r?.headers),{app:a,backendUrl:s}=d;n.has("Content-Type")||n.set("Content-Type","application/json");const i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0};e.startsWith("plugin")&&(e=`api/v1/${e}`);const c=s?`${s}/${e}`:`${e}`;U(`Making POST request to: ${c}`);try{const l=await fetch(c,{method:"POST",headers:n,credentials:"include",body:JSON.stringify(i),signal:r?.signal});return y(l,r?.responseType)}catch(l){throw f("Error making POST request:",l),l}}async function ut(e,t,r){const n=O(r?.headers),{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},c=`${s}/${e}`;U(`Making PUT request to: ${c}`);try{const l=await fetch(c,{method:"PUT",headers:n,credentials:"include",body:JSON.stringify(i)});return y(l,r?.responseType)}catch(l){throw f("Error making PUT request:",l),l}}function v(e){const t=new AbortController,{signal:r}=t;return e&&setTimeout(()=>{r.aborted||t.abort(new le(`Request timed out after ${e}ms`))},e),{controller:t,signal:r}}function W(e){if(!e)return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function dt(e){const t=W(e);return!!t&&t.getTime()<=Date.now()}function ft(e,t=7){const r=W(e);if(!r)return!1;const n=Date.now(),a=n+t*24*60*60*1e3,s=r.getTime();return s>n&&s<=a}async function ht(e,t=0,r=1e3){let n;for(let a=0;a<=t;a++)try{return await e()}catch(s){if(n=s,s instanceof P&&s.status>=400&&s.status<500&&s.status!==429||s instanceof DOMException&&s.name==="AbortError")throw s;a<t&&(A(`Retrying request (${a+1}/${t})`,{error:s}),await new Promise(i=>setTimeout(i,r)))}throw n}function gt(e,t,r){if(!e||!t)return;if(r){const s=Object.keys(t.queries).find(l=>l===r?.toLowerCase());let i;s&&(i=t.queries[s]);const c=(i?.columnsInfo?.columns||[])?.find(l=>l.aliases?.split(",")?.includes(e));if(c)return c.name}const n=t.indexes?._?.columns,a=Object.entries(n).find(s=>s[1].aliases?.includes(e));if(a)return a[0]}var C=(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.Change_Password_Failed="change.password.failed",e.Change_Password_Success_Form="change.password.success.form",e.Forgot_Password_Request="forgot.password.request",e.Login_Denied="login.denied",e.Login_Success_Form="login.success.form",e.Send_Reset_Password_Link="send.reset.password.link",e.Xrest_ChangePassword="xrest.changepassword",e))(C||{}),g=(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))(g||{}),S=(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))(S||{});const mt="1.0";var fe=(e=>(e[e.Original=0]="Original",e[e.Corrected=1]="Corrected",e))(fe||{}),he=(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))(he||{});function wt(e){if(!e)return g.none;switch(e.toLocaleLowerCase()){case"bool":case"boolean":return g.bool;case"date":return g.date;case"datetime":return g.dateTime;case"time":return g.time;case"unsigned":return g.unsigned;case"integer":return g.integer;case"float":return g.float;case"double":return g.double;case"dates":return g.dates;case"datetimes":return g.dateTimes;case"times":return g.times;case"varchar":return g.varchar;case"binary":return g.binary;case"string":return g.string;case"csv":return g.csv;default:return g.none}}function _t(e){switch(e){case"a":return S.a;case"c":return S.c;case"d":return S.d;case"e":return S.e;case"i":return S.i;case"l":return S.l;case"n":return S.n;case"t":return S.t;case"x":return S.x;case"z":return S.z;default:return S.none}}function St(e){let t=S.none;if(e)for(const r of e)t|=_t(r);return t}function w(e,t,r,n){const a=wt(t),s=St(r||"");return{name:e,type:t,typeModifier:r,eType:a,eTypeModifier:s,aliases:n}}const pt={id:w("id","string"),text:w("text","varchar"),documentlanguages:w("documentlanguages","csv","ci",["language"]),databasealias:w("databasealias","varchar"),globalrelevance:w("globalrelevance","double"),matchingpartnames:w("matchingpartnames","csv"),matchlocations:w("matchlocations","csv"),matchlocationsperpartname:w("matchlocationsperpartname","varchar"),extracts:w("extracts","csv"),extractsperpartname:w("extractsperpartname","varchar"),extractslocations:w("extractslocations","csv"),documentweight:w("documentweight","varchar"),groupcount:w("groupcount","integer"),accesslists:w("accesslists","varchar",void 0,["accessLists"])};function ge(e){return e.filter(t=>!!t)}const kt={eq:(e,t)=>({field:e,operator:"eq",value:t}),neq:(e,t)=>({field:e,operator:"neq",value:t}),gt:(e,t)=>({field:e,operator:"gt",value:t}),gte:(e,t)=>({field:e,operator:"gte",value:t}),lt:(e,t)=>({field:e,operator:"lt",value:t}),lte:(e,t)=>({field:e,operator:"lte",value:t}),like:(e,t)=>({field:e,operator:"like",value:t}),contains:(e,t)=>({field:e,operator:"contains",value:t}),regex:(e,t)=>({field:e,operator:"regex",value:t}),isNull:e=>({field:e,operator:"null"}),isNotNull:e=>({field:e,operator:"notnull"}),in:(e,t)=>({field:e,operator:"in",values:t}),between:(e,t,r)=>({field:e,operator:"between",start:t,end:r}),and:(...e)=>me("and",e),or:(...e)=>me("or",e),not:(...e)=>{const t=ge(e);return t.length?{operator:"not",filters:t}:void 0}};function me(e,t){const r=ge(t);return r.length===0?void 0:r.length===1?r[0]:{operator:e,filters:r}}function bt(e,t){let r=e[t];return r===void 0?[]:(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r)?r.map(n=>{if(typeof n=="string")return n.trim();if(typeof n=="object"&&n!==null&&"display"in n)return n.display.trim()}).filter(n=>n!==void 0):[String(r).trim()])}function vt(e,t){let r=e[t];if(r===void 0)return[];if(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r))return r.map(a=>{if(typeof a=="string")return{display:a.trim(),value:a.trim()};if(typeof a=="object"&&a!==null&&"display"in a){const s=a.display.trim(),i="value"in a?String(a.value).trim():s;return{display:s,value:i}}}).filter(a=>a!==void 0);const n=String(r).trim();return[{display:n,value:n}]}function D(e){return e!==null&&typeof e=="object"}function we(e){return D(e)&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function _e(e){return D(e)&&Object.prototype.toString.call(e)==="[object Blob]"}function Se(e){return Object.prototype.toString.call(e)==="[object Date]"}function pe(e){return typeof e=="string"}function Ct(e){return(D(e)||Array.isArray(e))&&!we(e)&&!_e(e)&&!pe(e)}function ke(e){return e?(e.getHours()*60*60+e.getMinutes()*60+e.getSeconds())*1e3+e.getMilliseconds():0}function be(e=!0){let t=Date.now();return(e?"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx":"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g,n=>{const a=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(n==="x"?a:a&3|8).toString(16)})}function Pt(e){if(!e)return"``";if(e=String(e),e.search(/[\\`]/)===-1)return`\`${e}\``;const t=["`"];for(let r=0,n=e.length;r<n;r++){const a=e[r];(a==="\\"||a==="`")&&t.push("\\"),t.push(a)}return t.push("`"),t.join("")}function yt(e){if(typeof crypto<"u"&&crypto.subtle&&typeof crypto.subtle.digest=="function")try{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(X(e)))}catch{return Promise.resolve(X(e))}return Promise.resolve(X(e))}function X(e){let n=2166136261;for(let b=0;b<e.length;b++)n^=e.charCodeAt(b),n=n*16777619>>>0;const a=n.toString(16).padStart(8,"0"),s=((n^2863311530)>>>0).toString(16).padStart(8,"0"),i=((n^1431655765)>>>0).toString(16).padStart(8,"0"),c=((n^3435973836)>>>0).toString(16).padStart(8,"0"),l=a+s+i+c;return(l+l+l+l).substring(0,128)}let Y,ve;function $(e,t=!0){let r=Rt(e.$auditRecord);r&&(Ce(r),t&&Pe(r)),e.$auditRecord=r}function Rt(e){if(!e)return;let t;if(Array.isArray(e))t=e;else if(D(e)){const r=e;if(r.auditEvents||r.mlAuditEvents)return r;t=[e]}return{auditEvents:t}}function Ce(e){const t=Lt();return e.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.sessionid=t}),e}function Pe(e){const t=typeof window<"u"?decodeURIComponent(window.location.href):"http://localhost";return e?.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.url=t}),e}function Lt(){return(!Y||Ut())&&(Y=be()),ve=new Date,Y}function Ut(){return new Date().getTime()-ve.getTime()>600*1e3}async function Ot(e,t=!0){const r={event:C.None,$auditRecord:e};return $(r,t),u("api/v1/audit.notify",r)}const $t={notify:Ot};async function It(e,t,r){const n=e.items?.length||0,a=10,s={query:{...t,action:"aggregate",aggregations:{[e.name]:{skip:n,count:a}}},$auditRecord:{auditEvents:[r]}};$(s);const i=await u("api/v1/query",s),c=await y(i),{aggregations:l}=c,h=l[0];return h.$hasMore=h.items.length>a,h.items=[...e.items,...h.items],Promise.resolve(h)}async function At(e){const t=e||d.app,r=new URLSearchParams({app:t||""});return _("api/v1/app",r)}async function ye(){const{app:e}=d,t=new URLSearchParams({app:e||"",preLogin:"true"});return _("api/v1/app",t)}function Dt(){let{backendUrl:e,app:t,useCredentials:r}=d;if(typeof window<"u"){if(e||(e=window.location.origin),!t){const n=window.location.pathname.match(/\/app(?:-debug)?\/([^/#]+)/);n&&(t=n[1])}p({...d,backendUrl:e,app:t})}return r?(p({...d,useCredentials:!0,useSSO:!1,autoOAuthProvider:void 0,autoSAMLProvider:void 0,bearerToken:void 0,useSAML:void 0}),Promise.resolve({})):ye().then(n=>{const{autoOAuthProvider:a,autoSAMLProvider:s}=d,i=!a&&!n.autoOAuthProvider&&!s&&!n.autoSAMLProvider;return p({...d,autoOAuthProvider:a||n.autoOAuthProvider,autoSAMLProvider:s||n.autoSAMLProvider,useCredentials:i,useSSO:i}),n}).catch(n=>{throw f("atomic:fetchAppPreLogin error",n),n})}async function Ft(e,t,r={}){const n=`api/v1/search.dataset/${e}/${t}`,a=await u(n,{parameters:r}),s=t[0].toLowerCase()+t.slice(1),i=a.datasets[s];if("errorCode"in i&&"errorMessage"in i)throw new Error(i.errorMessage);return i}async function Nt(e,t){const r=`api/v1/search.dataset/${e}`,{parameters:n={},datasets:a=[]}=t;return(await u(r,{parameters:n,datasets:a})).datasets}async function qt(e){return await _(`api/v1/search.dataset/${e}`)}async function Bt(e,t=!0,r){try{return(await u("api/v1/labels",{action:"list",q:e,public:t,locale:r,localize:!1})).labels}catch(n){throw f("Error in fetchLabels",n),n}}async function Qt(){try{const{app:e=""}=d,t=new URLSearchParams({app:e,action:"getUserRights"});return _("api/v1/labels",t)}catch(e){throw f("Error in getUserRights",e),e}}async function jt(e,t,r=!0){try{const n={action:"add",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:C.Label_AddDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"addToLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw f("Error in add",n),n}}async function Vt(e,t,r=!0){try{const n={action:"remove",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:C.Label_RemoveDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"removeFromLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw f("Error in remove",n),n}}async function xt(e,t,r=!0){try{const n={action:"rename",labels:e,newLabel:t,public:r,auditEvents:{type:C.Label_Rename,detail:{public:r,oldlabel:e?e.toString():null,label:t}}};return u("api/v1/labels",n)}catch(n){throw f("Error in rename",n),n}}async function Gt(e,t=!0){try{const r={action:"delete",labels:e,public:t,auditEvents:{type:C.Label_Delete,detail:{public:t,label:e?e.toString():null}}};return u("api/v1/labels",r)}catch(r){throw f("Error in deleteLabels",r),r}}async function Mt(e,t,r=!0){try{const n={action:"bulkAdd",labels:e,query:t,public:r,auditEvents:{type:C.Label_Add,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw f("Error in bulkAdd",n),n}}async function zt(e,t,r=!0){try{const n={action:"bulkRemove",labels:e,query:t,public:r,auditEvents:{type:C.Label_Delete,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw f("Error in bulkRemove",n),n}}const Ht={getUserRights:Qt,add:jt,remove:Vt,rename:xt,delete:Gt,bulkAdd:Mt,bulkRemove:zt};async function Jt(e,t){if(typeof window>"u")return u("api/v1/preview",{action:"get",id:e,query:t});const r=`${window.location.origin}${window.location.pathname}`,n={name:t?.name,text:t?.text};return u("api/v1/preview",{action:"get",id:e,query:n,browserUrl:r})}async function Wt(e){const t=new Headers;t.append("content-type","text");const r=await fetch(e,{method:"GET",headers:t});y(r)}async function K(){const e=new URLSearchParams({action:"get",noAutoAuthentication:"true"});return _("api/v1/principal",e)}async function Re(e){const t={noAutoAuthentication:"true",...e},r=new URLSearchParams;return Object.entries(t).forEach(([n,a])=>{a!==void 0&&r.append(n,String(a))}),_("api/v1/principal/list",r)}async function Le(e){if(!e)return Promise.reject(new Error("userid is required"));const t=new URLSearchParams({action:"userid",noAutoAuthentication:"true",userid:e});return _("api/v1/principal",t)}async function Ue(e){if(e.length===0)return Promise.reject(new Error("userids is required"));const t=new URLSearchParams({noAutoAuthentication:"true",userids:[...e].join(",")});return _("api/v1/principal/userids",t)}const Xt={principal:{get:K,list:Re,userid:Le,userids:Ue}},Oe=11;async function Yt(e,t,r){const a=await u("api/v1/query",{query:e,$auditRecord:t,queryIntentData:r});a.aggregations.forEach(i=>{i.$hasMore=!1,!i.isDistribution&&!i.isTree&&i.items&&(i.$hasMore=i.items.length===Oe),i.isTree&&i.items&&V(i)}),a.records?.map(i=>Object.assign(i,{value:i.title,type:"default"}));const s={...a,nextPage:a.page<Math.ceil(a.rowCount/a.pageSize)?a.page+1:void 0,previousPage:a.page>1?a.page-1:void 0};return Promise.resolve(s)}async function Kt(e,t,r){const{app:n=""}=d,a={methods:[],mode:t,propagateErrors:!0,$auditRecord:{auditEvents:[r]}};for(const c of e)a.methods.push({method:"query",app:n,query:c});const s=await u("api/v1/multi",a);s.results.forEach(c=>{c.aggregations.forEach(l=>{l.$hasMore=!1,!l.isDistribution&&!l.isTree&&l.items&&(l.$hasMore=l.items.length===Oe),l.isTree&&V(l)})}),s.results.forEach(c=>c.records?.map(l=>Object.assign(l,{value:l.title,type:"default"})));const i=s.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}));return Promise.resolve(i)}function V(e,t="",r=0){let n=[];return e.items&&e.items.forEach(a=>{let s=t?`${t}/${a.value}`:a.value,i=r+1;n.push({path:s,level:i}),a.$path=s,a.$level=i,a.hasChildren?n=n.concat(V(a,s,i)):a.hasChildren=!1}),n}async function Zt({model:e,appName:t,query:r,article:n}){const{webservice:a,format:s,maxcount:i,exportedColumns:c,export:l}=e,h={app:t,webservice:a,query:r,type:l,format:s,maxcount:i,exportedColumns:c,$auditRecord:{auditEvents:[{type:"Search_ExportCSV",detail:{resultid:n?n.id:void 0}}]}};return $(h),await u("api/v1/search.queryexport",h,{responseType:"blob"})}async function Et(e){return(await u("api/v1/queryintent",{query:e}))?.intents}async function Tt(e,t,r){return(await u("api/v1/similardocuments",{sourceDocumentId:e,query:{name:t}},{signal:r})).data}async function er(e,t){return(await u("api/v1/query.links",{webservice:e,query:t}))?.links?.map(a=>({...a,query:t}))}function tr(e,t){if(typeof e=="number")return`${e}`;if(Se(e))return rr(e);if(typeof e=="boolean")return e?"true":"false";if(e===null)return"null";if(Array.isArray(e)){const r=[];return e.forEach(n=>{r.length>0&&r.push(","),n?typeof n=="string"?r.push(n):r.push(n.display||n.value||""):r.push("null")}),r.splice(0,0,"["),r.push("]"),r.join("")}return e}function rr(e){if(!e)return"";try{if(ke(e)===0)return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit"}).format(e);{const t=new Intl.DateTimeFormat("en-CA").format(e),r=new Intl.DateTimeFormat("en-CA",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(e);return`${t} ${r}`}}catch{return"Invalid date"}}async function nr(e,t,r,n,a){const{app:s}=d,i={app:s||"",suggestQuery:e,text:t,filter:r,kinds:n,showSource:a};try{return(await u("api/v1/search.suggest",i)).suggests}catch(c){throw console.error("Error fetching suggestions:",c),c}}async function ar(e,t,r,n){const{app:a}=d;return(await u("api/v1/suggestquery",{app:a||"",suggestQuery:e,text:t,query:r,kinds:n})).suggests}async function or(e,t,r){if(!t)return Promise.resolve([]);const{app:n}=d,s=await u("api/v1/suggestfield",{app:n||"",text:e,fields:t,query:r});return s.suggests.forEach(i=>{i.display=tr(i.display)}),s.suggests}async function sr(e,t,r,n,a,s){return u("api/v1/doc.textchunks",{id:e,textChunks:t,highlights:r,query:n,leftSentencesCount:a,rightSentencesCount:s})}async function ir(){const{app:e}=d,t=new URLSearchParams({app:e||"",action:"load"});return _("api/v1/usersettings",t)}async function $e(e,t){const r={action:"save",userSettings:e,$auditRecord:{auditEvents:[t]}};return $(r),u("api/v1/usersettings",r)}async function cr(e,t){const n={action:"patch",userSettings:e,$auditRecord:t?{auditEvents:[t]}:void 0};return $(n),u("api/v1/usersettings",n)}async function lr(){return $e({},{type:"UserSettings_Reset"})}async function ur(e,t){return u("api/v2/security/password/change",{newPassword:e,currentPassword:t})}async function dr(e){const t="api/v2/security/password/ask-reset-email",n={changePasswordRedirectUrl:`${window.location.origin}/login?mode=changepassword`,userName:e};return u(t,n)}async function fr(e){return await _(`api/v2/user-profile/${e}`)}async function hr(e){return await u("api/v2/user-profile",e)}async function gr(e,t,r){return await de(`api/v2/user-profile/${e.data?.id}/${t}/${r}`,e)}async function mr(e,t,r){try{return(await ue(`api/v2/user-profile/${e.data?.id}/${t}/${r}`)).success===!0}catch{return!1}}async function wr(){return await _("api/v2/version")}const R=1e4,Ie=async()=>{const{autoOAuthProvider:e}=d;if(!e)throw new Error("autoOAuthProvider is not configured in globalConfig");if(typeof window>"u")try{const{signal:r}=v(R);return await u("security.oauth",{action:"getcode",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"},{signal:r})}catch(r){throw f("Failed to authenticate with OAuth",r),r}const t={action:"getcode",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const{signal:r}=v(R),n=await u("api/v1/security.oauth",t,{signal:r});if(n.redirectUrl){const a=new URL(n.redirectUrl,window.location.origin);(a.protocol==="https:"||a.protocol==="http:")&&(window.location.href=a.href)}return n}catch(r){throw f("Failed to authenticate with OAuth",r),r}},Ae=async()=>{const{autoSAMLProvider:e}=d;if(!e)throw new Error("autoSAMLProvider is not configured in globalConfig");if(typeof window>"u")try{const{signal:r}=v(R);return await u("security.saml",{action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"},{signal:r})}catch(r){throw f("Failed to authenticate with SAML",r),r}const t={action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const{signal:r}=v(R),n=await u("api/v1/security.saml",t,{signal:r});if(n.redirectUrl){const a=new URL(n.redirectUrl,window.location.origin);(a.protocol==="https:"||a.protocol==="http:")&&(window.location.href=a.href)}return n}catch(r){throw f("Failed to authenticate with SAML",r),r}},Z={store:{},getItem(e){return this.store[e]??null},setItem(e,t){this.store[e]=t.toString()},removeItem(e){delete this.store[e]},clear(){this.store={}}},E=Z;function _r(e){return typeof window>"u"||!window.localStorage?Z.getItem(e):window.localStorage.getItem(e)}function Sr(e){typeof window>"u"||!window.localStorage?Z.removeItem(e):window.localStorage.removeItem(e)}function pr(e){return typeof window>"u"||!window.sessionStorage?E.getItem(e):window.sessionStorage.getItem(e)}function kr(e,t){typeof window>"u"||!window.sessionStorage?E.setItem(e,t):window.sessionStorage.setItem(e,t)}function br(e){typeof window>"u"||!window.sessionStorage?E.removeItem(e):window.sessionStorage.removeItem(e)}const F=e=>kr("sinequa-credentials",JSON.stringify({data:{csrfToken:e}})),De=async()=>{try{const{signal:e}=v(R),t=await _("api/v1/challenge?action=getCsrfToken&suppressErrors=true",void 0,{signal:e});if(t?.csrfToken)return F(t.csrfToken),t.csrfToken;throw new Error("No CSRF token returned")}catch(e){throw f("Failed to get CSRF token",e),e}};async function Fe(e){if(e){const{username:t,password:r}=e,n={action:"get",tokenInCookie:!0,user:t,password:r,noUserOverride:!0,noAutoAuthentication:!0};try{const{signal:a}=v(R),s=await u("api/v1/security.webtoken",n,{signal:a});return s?.csrfToken?(F(s.csrfToken),s.csrfToken):null}catch(a){throw f("Failed to get JWT",a),a}}else{const t={action:"get",tokenInCookie:!0,noUserOverride:!0,noAutoAuthentication:!1},{bearerToken:r}=d;if(!r)throw new Error("Bearer token is required in globalConfig for credentialless JWT retrieval.");const n=new Headers;n.append("Sinequa-Force-Camel-Case","true"),n.append("accept","application/json"),n.append("Content-Type","application/json"),n.append("Authorization",`Bearer ${r}`);try{const{signal:a}=v(R),s=await u("api/v1/security.webtoken",t,{headers:n,signal:a});return s?.csrfToken?(F(s.csrfToken),s.csrfToken):null}catch(a){throw f("Failed to get JWT without credentials",a),a}}}const x=()=>{const e=pr("sinequa-credentials");if(e)try{const n=JSON.parse(e).data?.csrfToken;if(n)return n}catch(r){A("Failed to parse session storage credentials, falling back to local storage",r)}const t=_r("csrfToken");return t||null},vr=async e=>{if(e)k("Attempting authentication using credentials"),p({useCredentials:!0,useSSO:!1});else{let c=null;try{k("Attempting to retrieve CSRF token from the backend"),c=await De(),U("CSRF token retrieval result",c?"success":"failed")}catch{}try{if(c===null){const{autoOAuthProvider:l,autoSAMLProvider:h,useSAML:b}=d;if(l&&!b)return k("Initiating OAuth authentication flow"),await Ie(),m(!1),!1;if(h)return k("Initiating SAML authentication flow"),await Ae(),m(!1),!1;k("No direct authentication method available, will try SSO then credentials"),p({useCredentials:!0,useSSO:!0})}else return k("User authenticated via existing token"),m(!0),!0}catch(l){throw f("Unexpected error during authentication",l),m(!1),l}return!1}if(d.useCredentials&&d.useSSO)try{if(k("Checking if user is authenticated via SSO"),await K())return k("User authenticated using SSO"),p({useCredentials:!1,useSSO:!0}),m(!0),!0}catch(c){if(c?.status===401)return k("SSO authentication failed with 401, falling back to credentials"),p({useCredentials:!0,useSSO:!1}),!1;throw f("SSO authentication failed with unexpected error",c),m(!1),c}const{useSSO:r}=d,n=x();if(n||r)return k("user already authenticated",n),p({isRedirectUrl:!1}),m(!0),!0;const{useCredentials:a}=d,{username:s,password:i}=e||{};if(a&&(!s||!i))return f("Credentials are required for authentication"),m(!1),!1;if(s&&i)try{k("authentication using credentials..."),p({useCredentials:!0,useSSO:!1});const{userOverrideActive:c,useroverride:l}=d;return p({userOverrideActive:!1,useroverride:void 0}),await Fe({username:s,password:i}),p({userOverrideActive:c,useroverride:l}),m(!0),!0}catch(c){throw m(!1),c}return m(!1),f("No authentication method available. Please provide credentials or configure OAuth/SAML."),!1},Ne=async()=>{const e=new URLSearchParams({action:"deleteWebTokenCookie",noUserOverride:"true",noAutoAuthentication:"true"}),{signal:t}=v(R);return _("api/v1/challenge",e,{signal:t})};async function Cr(){const{userOverrideActive:e}=d;if(qe(),!e)try{const{methodresult:t,logoutUrl:r}=await Ne();if(t==="ok")return r;f("logout failed")}catch(t){f("logout failed",t)}}function qe(){Sr("csrfToken"),br("sinequa-credentials"),m(!1)}const Pr=()=>!!x();o.API=Xt,o.ApiError=P,o.Audit=$t,o.AuditEventType=C,o.DidYouMeanKind=fe,o.EngineType=g,o.EngineTypeModifier=S,o.LogLevel=z,o.MINIMUM_COMPATIBLE_SERVER_API_VERSION=mt,o.RFMDisplay=he,o.ServerError=H,o.TimeoutError=le,o.UnauthorizedError=j,o.addAuditAdditionalInfo=$,o.addConcepts=We,o.addSessionId=Ce,o.addUrl=Pe,o.aggItemRegex=T,o.aggregationItemStrictCompare=Qe,o.appInitializerFn=Dt,o.bisect=Ve,o.buildPathsAndLevels=V,o.clearSessionTokens=qe,o.configureLogger=lt,o.createHeaders=O,o.createTimeoutController=v,o.createUserProfile=hr,o.debug=U,o.del=ue,o.deleteUserProfileProperty=mr,o.deleteUserSettings=lr,o.deleteWebTokenCookie=Ne,o.emitAuthenticatedEvent=m,o.error=f,o.escapeExpr=Pt,o.expiresSoon=ft,o.extraColumns=pt,o.fetchAggregation=It,o.fetchApp=At,o.fetchAppPreLogin=ye,o.fetchBulkQuery=Kt,o.fetchChangePassword=ur,o.fetchDataset=Ft,o.fetchDatasetList=qt,o.fetchDatasets=Nt,o.fetchLabels=Bt,o.fetchPreview=Jt,o.fetchPreviewUrl=Wt,o.fetchPrincipal=K,o.fetchPrincipalList=Re,o.fetchPrincipalUserid=Le,o.fetchPrincipalUserids=Ue,o.fetchQuery=Yt,o.fetchQueryExport=Zt,o.fetchQueryIntent=Et,o.fetchSendPasswordResetEmail=dr,o.fetchSimilarDocuments=Tt,o.fetchSponsoredLinks=er,o.fetchSuggest=nr,o.fetchSuggestField=or,o.fetchSuggestQuery=ar,o.fetchTextChunks=sr,o.fetchUserProfile=fr,o.fetchUserSettings=ir,o.fetchVersion=wr,o.filter=kt,o.get=_,o.getConcepts=Ke,o.getCsrfToken=De,o.getFiltersFromURI=G,o.getFiltersFromUrl=tt,o.getHelpIndexUrl=it,o.getIdFromUrl=nt,o.getJWToken=Fe,o.getMetadata=bt,o.getMetadataWithValues=vt,o.getOffsetFromDates=ce,o.getQueryPageFromUrl=at,o.getQueryParamsFromUrl=Te,o.getQueryTabFromUrl=ot,o.getQueryTextFromUrl=rt,o.getRelativeDate=Ze,o.getTime=ke,o.getToken=x,o.getUrlParamsFromQueryParams=et,o.globalConfig=d,o.guid=be,o.handleResponse=y,o.info=k,o.isArrayBuffer=we,o.isAuthenticated=Pr,o.isBlob=_e,o.isDate=Se,o.isExpired=dt,o.isJsonable=Ct,o.isNotInputEvent=Ee,o.isObject=D,o.isString=pe,o.labels=Ht,o.login=vr,o.logout=Cr,o.makeColumn=w,o.notify=ct,o.openParentNodes=te,o.parseText=I,o.parseValueAndOperatorFromItem=ee,o.patch=de,o.patchUserProfile=gr,o.patchUserSettings=cr,o.post=u,o.put=ut,o.queryParamsFromUrl=L,o.removeConcept=Xe,o.removeConcepts=Ye,o.resolveToColumnName=gt,o.rewriteText=N,o.saveUserSettings=$e,o.setGlobalConfig=p,o.setToken=F,o.sha512=yt,o.suggestionsToTreeAggregationNodes=je,o.sysLang=st,o.toDate=W,o.translateAggregationToDateOptions=Be,o.tryOAuthAuthentication=Ie,o.trySAMLAuthentication=Ae,o.warn=A,o.withRetry=ht,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(o,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(o=typeof globalThis<"u"?globalThis:o||self,m(o.atomic={}))})(this,(function(o){"use strict";function m(e){if(typeof CustomEvent>"u"||typeof dispatchEvent>"u")return;const t=new CustomEvent("authenticated",{bubbles:!0,cancelable:!1,detail:{authenticated:e}});dispatchEvent(t)}const d={loginPath:"/login",createRoutes:!1};function p(e){Object.assign(d,e)}const T=/.*:\(?([><=\d\-.AND ]+)\)?/;function Be(e,t){return!e?.items||e?.items?.length===0?[]:e.items.reduce((a,s)=>{if(!s.value||s.value==="")return a;const i=ee(s,e.column);return a.push({operator:i.operator,value:i.value,display:s.display||i.display,filters:i.filters,disabled:s.count===0,hidden:s.count===0&&e.isDistribution?!t:!1}),a},[])}function ee(e,t){const r=t,n=e.value.match(T);if(n?.[1]){const s=(n?.[1].split(" AND ")).map(i=>{const c=i.indexOf(">=")!==-1?"gte":"lt",l=i.substring(i.indexOf(" ")+1);return{field:r,operator:c,value:l,display:e.display||e.value}});if(s.length===2)return{field:r,operator:"and",filters:s,value:e.value,display:s[0].display||s[0].value};if(s.length===1)return{...s[0],field:r};throw new Error("Failed to parse distribution expression")}return{field:r,operator:"eq",value:e.value,display:e.display}}function Qe(e,t,r){return e.valuesAreExpressions?t.display===r.display:t.value===r.value}function te(e){return e.items&&(e.items=e.items.map(t=>te(t))),e.items&&e.items.some(t=>t.$selected||t.$opened)&&(e.$opened=!0),e}function je(e,t){const r=[];if(e.length>0){const n=new Map,s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,""),i=new RegExp("\\b"+s,"i");e.forEach(c=>{if(c.display.length>1){const l=c.display.normalize("NFD").replace(/[\u0300-\u036f]/g,""),h=i.exec(l);re(r,n,"/",c.display,+(c.frequency||0),1,(h?.index||0)+t.length)}})}return r}function re(e,t,r,n,a,s,i){const c=n.indexOf("/",r.length),l=n.substring(0,c+1);let h=t.get(l);if(!h){const b=l.replace(/^\/|\/$/g,"");h={value:n.substring(r.length,c),count:a,items:[],hasChildren:!1,$level:s,$opened:i>=l.length,$path:b},t.set(l,h),e.push(h)}l.length<n.length&&(h.hasChildren=!0,re(h.items,t,l,n,a,s+1,i))}function Ve(e,t){return e.reduce((r,n)=>(t(n)?r.true.push(n):r.false.push(n),r),{true:[],false:[]})}const xe=/(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g,Ge=2,ne=3,Me=5,ae=6,ze=8,oe=9,He=11,se=12,Je=14,ie=15;function I(e){if(!e)return[];const t=[],r=e.matchAll(xe);for(let n of r)n[ne]?t.push({type:"group",value:n[ne],op:n[Ge]}):n[ae]?t.push({type:"adjacent",value:n[ae],op:n[Me]}):n[oe]?t.push({type:"exact",value:n[oe],op:n[ze]}):n[se]?t.push({type:"regex",value:n[se],op:n[He]}):n[ie]&&t.push({type:"token",value:n[ie],op:n[Je]});return t}function N(e){return e.map(t=>{const r=t.op||"";switch(t.type){case"group":return`${r}(${t.value})`;case"adjacent":return`${r}[${t.value}]`;case"exact":return`${r}"${t.value}"`;case"regex":return`${r}/${t.value}/`;case"token":return`${r}${t.value}`}}).join(" ")}function We(e,t,r){let n=I(e);for(let a of t)n.push({type:"adjacent",value:a,op:r});return N(n)}function Xe(e,t){const r=I(t),n=r.findIndex(a=>a.value===e);return n!==-1?(r.splice(n,1),t=N(r)):t}function Ye(e){const t=I(e).filter(r=>r.type!=="adjacent");return N(t)}function Ke(e){return I(e).filter(t=>t.type==="adjacent").map(t=>t.value)}function Ze(e,t,r){const n=new Intl.RelativeTimeFormat(e,{numeric:"auto"}),{offset:a,unit:s,isFuture:i}=ce(t,r);return n.format(a*(i?1:-1),s)}function ce(e,t){const r=new Date(e),n=t?new Date(t):new Date,a=Math.abs(n.getTime()-r.getTime());return{offset:Math.floor(a/(1e3*60*60*24)),unit:"day",isFuture:r>n}}function Ee(e){const t=e.target;return t&&t.nodeName!=="INPUT"&&t.nodeName!=="TEXTAREA"}function Te(e){if(e===void 0)return;const{q:t,f:r,p:n,s:a,t:s,n:i,b:c}=L(e),[l]=e.split("?");return{path:l,text:t,filters:r?G(r):void 0,page:n?parseInt(n,10):void 0,sort:a,tab:s,name:i,basket:c}}function et(e){if(!e)return"";const{text:t,filters:r,page:n,sort:a,tab:s,name:i,basket:c}=e,l={};t&&(l.q=t),r&&(l.f=JSON.stringify(r)),n&&(l.p=n.toString()),a&&(l.s=a),s&&(l.t=s),i&&(l.n=i),c&&(l.b=c);const h=new URLSearchParams(l).toString();return h||""}function tt(e){if(e===void 0)return[];const{f:t}=L(e);return G(t)}function G(e){const t=decodeURIComponent(e);try{return JSON.parse(t??"[]")}catch{return console.error(`Error parsing filters from URI: ${e}`),[]}}function L(e){const t=e.split("?")[1];if(t===void 0)return{};const r=new URLSearchParams(t);return Object.fromEntries(r)}function rt(e){const{q:t=""}=L(e);return t}function nt(e){const{id:t}=L(e);return decodeURIComponent(t)}function at(e){const{p:t="0"}=L(e);return parseInt(t,10)}function ot(e){const{t}=L(e);return t}function st(e,t){if(!e)return e;let r=0;const n=e.length;let a=0;if(e[a]==="["){for(;a<n&&/[0-9]/.test(e[a]);)a++;e[a]==="]"&&(r=a+1)}const s=M(e,r,!1);if(!s)return e;const i=t.charCodeAt(0),c=t.charCodeAt(1);let l=s;for(;l;)if(i===l.lang1&&c===l.lang2){const b=M(e,l.end+4,!0);return e.substring(b.start,b.end)}else l=M(e,l.end+4,!1);const h=e.substring(s.start,s.end);return h||e}function M(e,t,r){for(let n=t,a=e.length-3;n<a;n++)if(e[n]==="["&&e[n+3]==="]")return{start:t,end:n,lang1:e.charCodeAt(n+1),lang2:e.charCodeAt(n+2)};if(r)return{start:t,end:e.length,lang1:-1,lang2:-1}}function it(e,t){const{useLocale:r,useLocaleAsPrefix:n,indexFile:a,path:s,folder:i}=t,c=r?`${e}/`:null,l=n?`${e}.${a}`:a??"";return[s,i,`${c||""}${l}`].filter(h=>h!==void 0).join("/")}function q(e){const t=new CustomEvent("notification",{bubbles:!0,cancelable:!1,detail:e});dispatchEvent(t)}const ct={success:(e,t)=>{q({type:"success",message:e,options:t})},info:(e,t)=>{q({type:"info",message:e,options:t})},warning:(e,t)=>{q({type:"warning",message:e,options:t})},error:(e,t)=>{q({type:"error",message:e,options:t})}};var z=(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))(z||{});let B={level:1,enableConsoleOutput:!0};function lt(e){B={...B,...e}}function Q(e,t,r){if(e<B.level)return;const a=`${`[${z[e]}]`} ${t}`;if(B.enableConsoleOutput)switch(e){case 0:console.debug(a,r||"");break;case 1:console.info(a,r||"");break;case 2:console.warn(a,r||"");break;case 3:console.error(a,r||"");break}}function U(e,t){Q(0,e,t)}function k(e,t){Q(1,e,t)}function A(e,t){Q(2,e,t)}function f(e,t){Q(3,e,t)}function O(e){const t=x(),r=new Headers(e);r.append("Sinequa-Force-Camel-Case","true"),r.append("accept","application/json"),t&&r.append("Sinequa-csrf-token",t);const{userOverride:n,userOverrideActive:a,bearerToken:s}=d;return s&&r.append("Authorization",`Bearer ${s}`),n&&a&&(r.append("sinequa-override-user",n.username),r.append("sinequa-override-domain",n.domain)),r}class P extends Error{status;constructor(t,r){super(t),this.name="ApiError",this.status=r}}class H extends P{constructor(t="Server error"){super(t,500),this.name="ServerError"}}class le extends P{constructor(t="Request timed out"){super(t,408),this.name="TimeoutError"}}class j extends P{constructor(t="Unauthorized access"){super(t,401),this.name="UnauthorizedError"}}async function y(e,t="json"){const r=e.headers.get("sinequa-jwt-refresh");if(r!==null&&F(r),e.status===200)switch(t){case"arraybuffer":return await e.arrayBuffer();case"blob":return await e.blob();case"text":return await e.text();default:return await e.json()}if(e.status===401){if(d.userOverrideActive){let n={};try{n=await e.clone().json()}catch{}throw A("Unauthorized access attempt with user override",{endpoint:e.url,error:n}),new j(n.errorMessage??n.message??"Unauthorized... User override failed.")}return await J(e,401)}return e.status===500?(f("Server error occurred",{endpoint:e.url}),await J(e,500)):(A(`Unexpected response status: ${e.status}`,{endpoint:e.url}),await J(e,e.status))}async function J(e,t){try{const{done:r,value:n}=await e.body?.getReader().read()||{done:!0,value:void 0};if(r||!n)throw t===401?new j:t===500?new H:new P(`Request failed with status ${t}`,t);const a=JSON.parse(new TextDecoder().decode(n));throw new Error(a.errorMessage||a.message||`Request failed with status ${t}`,{cause:{errorCode:a.errorCode,errorCodeTest:a.errorCodeTest}})}catch(r){throw r instanceof P?r:t===401?new j(r.message):t===500?new H(r.message):new P(r.message??`Request failed with status ${t}`,t)}}async function ue(e,t,r){const n=O(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"",i=a?`${a}/${e}${s}`:`${e}${s}`;U(`Making DELETE request to: ${i}`);try{const c=await fetch(i,{method:"DELETE",credentials:"include",headers:n});return y(c,r?.responseType)}catch(c){throw f("Error making DELETE request:",c),c}}async function _(e,t,r){const n=O(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"";e.startsWith("plugin")&&(e=`api/v1/${e}`);const i=a?`${a}/${e}${s}`:`${e}${s}`;U(`Making GET request to: ${i}`);try{const c=await fetch(i,{method:"GET",credentials:"include",headers:n,signal:r?.signal});return y(c,r?.responseType)}catch(c){throw f("Error making GET request:",c),c}}async function de(e,t,r){const n=O(r?.headers);n.append("content-type","application/json");const{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},c=s?`${s}/${e}`:`${e}`;U(`Making PATCH request to: ${c}`);try{const l=await fetch(c,{method:"PATCH",headers:n,credentials:"include",body:JSON.stringify(i)});return y(l,r?.responseType)}catch(l){throw f("Error making PATCH request:",l),l}}async function u(e,t,r){const n=O(r?.headers),{app:a,backendUrl:s}=d;n.has("Content-Type")||n.set("Content-Type","application/json");const i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0};e.startsWith("plugin")&&(e=`api/v1/${e}`);const c=s?`${s}/${e}`:`${e}`;U(`Making POST request to: ${c}`);try{const l=await fetch(c,{method:"POST",headers:n,credentials:"include",body:JSON.stringify(i),signal:r?.signal});return y(l,r?.responseType)}catch(l){throw f("Error making POST request:",l),l}}async function ut(e,t,r){const n=O(r?.headers),{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},c=`${s}/${e}`;U(`Making PUT request to: ${c}`);try{const l=await fetch(c,{method:"PUT",headers:n,credentials:"include",body:JSON.stringify(i)});return y(l,r?.responseType)}catch(l){throw f("Error making PUT request:",l),l}}function v(e){const t=new AbortController,{signal:r}=t;return e&&setTimeout(()=>{r.aborted||t.abort(new le(`Request timed out after ${e}ms`))},e),{controller:t,signal:r}}function W(e){if(!e)return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function dt(e){const t=W(e);return!!t&&t.getTime()<=Date.now()}function ft(e,t=7){const r=W(e);if(!r)return!1;const n=Date.now(),a=n+t*24*60*60*1e3,s=r.getTime();return s>n&&s<=a}async function ht(e,t=0,r=1e3){let n;for(let a=0;a<=t;a++)try{return await e()}catch(s){if(n=s,s instanceof P&&s.status>=400&&s.status<500&&s.status!==429||s instanceof DOMException&&s.name==="AbortError")throw s;a<t&&(A(`Retrying request (${a+1}/${t})`,{error:s}),await new Promise(i=>setTimeout(i,r)))}throw n}function gt(e,t,r){if(!e||!t)return;if(r){const s=Object.keys(t.queries).find(l=>l===r?.toLowerCase());let i;s&&(i=t.queries[s]);const c=(i?.columnsInfo?.columns||[])?.find(l=>l.aliases?.split(",")?.includes(e));if(c)return c.name}const n=t.indexes?._?.columns,a=Object.entries(n).find(s=>s[1].aliases?.includes(e));if(a)return a[0]}var C=(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.Change_Password_Failed="change.password.failed",e.Change_Password_Success_Form="change.password.success.form",e.Forgot_Password_Request="forgot.password.request",e.Login_Denied="login.denied",e.Login_Success_Form="login.success.form",e.Send_Reset_Password_Link="send.reset.password.link",e.Xrest_ChangePassword="xrest.changepassword",e))(C||{}),g=(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))(g||{}),S=(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))(S||{});const mt="1.0";var fe=(e=>(e[e.Original=0]="Original",e[e.Corrected=1]="Corrected",e))(fe||{}),he=(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))(he||{});function wt(e){if(!e)return g.none;switch(e.toLocaleLowerCase()){case"bool":case"boolean":return g.bool;case"date":return g.date;case"datetime":return g.dateTime;case"time":return g.time;case"unsigned":return g.unsigned;case"integer":return g.integer;case"float":return g.float;case"double":return g.double;case"dates":return g.dates;case"datetimes":return g.dateTimes;case"times":return g.times;case"varchar":return g.varchar;case"binary":return g.binary;case"string":return g.string;case"csv":return g.csv;default:return g.none}}function _t(e){switch(e){case"a":return S.a;case"c":return S.c;case"d":return S.d;case"e":return S.e;case"i":return S.i;case"l":return S.l;case"n":return S.n;case"t":return S.t;case"x":return S.x;case"z":return S.z;default:return S.none}}function St(e){let t=S.none;if(e)for(const r of e)t|=_t(r);return t}function w(e,t,r,n){const a=wt(t),s=St(r||"");return{name:e,type:t,typeModifier:r,eType:a,eTypeModifier:s,aliases:n}}const pt={id:w("id","string"),text:w("text","varchar"),documentlanguages:w("documentlanguages","csv","ci",["language"]),databasealias:w("databasealias","varchar"),globalrelevance:w("globalrelevance","double"),matchingpartnames:w("matchingpartnames","csv"),matchlocations:w("matchlocations","csv"),matchlocationsperpartname:w("matchlocationsperpartname","varchar"),extracts:w("extracts","csv"),extractsperpartname:w("extractsperpartname","varchar"),extractslocations:w("extractslocations","csv"),documentweight:w("documentweight","varchar"),groupcount:w("groupcount","integer"),accesslists:w("accesslists","varchar",void 0,["accessLists"])};function ge(e){return e.filter(t=>!!t)}const kt={eq:(e,t)=>({field:e,operator:"eq",value:t}),neq:(e,t)=>({field:e,operator:"neq",value:t}),gt:(e,t)=>({field:e,operator:"gt",value:t}),gte:(e,t)=>({field:e,operator:"gte",value:t}),lt:(e,t)=>({field:e,operator:"lt",value:t}),lte:(e,t)=>({field:e,operator:"lte",value:t}),like:(e,t)=>({field:e,operator:"like",value:t}),contains:(e,t)=>({field:e,operator:"contains",value:t}),regex:(e,t)=>({field:e,operator:"regex",value:t}),isNull:e=>({field:e,operator:"null"}),isNotNull:e=>({field:e,operator:"notnull"}),in:(e,t)=>({field:e,operator:"in",values:t}),between:(e,t,r)=>({field:e,operator:"between",start:t,end:r}),and:(...e)=>me("and",e),or:(...e)=>me("or",e),not:(...e)=>{const t=ge(e);return t.length?{operator:"not",filters:t}:void 0}};function me(e,t){const r=ge(t);return r.length===0?void 0:r.length===1?r[0]:{operator:e,filters:r}}function bt(e,t){let r=e[t];return r===void 0?[]:(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r)?r.map(n=>{if(typeof n=="string")return n.trim();if(typeof n=="object"&&n!==null&&"display"in n)return n.display.trim()}).filter(n=>n!==void 0):[String(r).trim()])}function vt(e,t){let r=e[t];if(r===void 0)return[];if(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r))return r.map(a=>{if(typeof a=="string")return{display:a.trim(),value:a.trim()};if(typeof a=="object"&&a!==null&&"display"in a){const s=a.display.trim(),i="value"in a?String(a.value).trim():s;return{display:s,value:i}}}).filter(a=>a!==void 0);const n=String(r).trim();return[{display:n,value:n}]}function D(e){return e!==null&&typeof e=="object"}function we(e){return D(e)&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function _e(e){return D(e)&&Object.prototype.toString.call(e)==="[object Blob]"}function Se(e){return Object.prototype.toString.call(e)==="[object Date]"}function pe(e){return typeof e=="string"}function Ct(e){return(D(e)||Array.isArray(e))&&!we(e)&&!_e(e)&&!pe(e)}function ke(e){return e?(e.getHours()*60*60+e.getMinutes()*60+e.getSeconds())*1e3+e.getMilliseconds():0}function be(e=!0){let t=Date.now();return(e?"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx":"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g,n=>{const a=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(n==="x"?a:a&3|8).toString(16)})}function Pt(e){if(!e)return"``";if(e=String(e),e.search(/[\\`]/)===-1)return`\`${e}\``;const t=["`"];for(let r=0,n=e.length;r<n;r++){const a=e[r];(a==="\\"||a==="`")&&t.push("\\"),t.push(a)}return t.push("`"),t.join("")}function yt(e){if(typeof crypto<"u"&&crypto.subtle&&typeof crypto.subtle.digest=="function")try{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(X(e)))}catch{return Promise.resolve(X(e))}return Promise.resolve(X(e))}function X(e){let n=2166136261;for(let b=0;b<e.length;b++)n^=e.charCodeAt(b),n=n*16777619>>>0;const a=n.toString(16).padStart(8,"0"),s=((n^2863311530)>>>0).toString(16).padStart(8,"0"),i=((n^1431655765)>>>0).toString(16).padStart(8,"0"),c=((n^3435973836)>>>0).toString(16).padStart(8,"0"),l=a+s+i+c;return(l+l+l+l).substring(0,128)}let Y,ve;function $(e,t=!0){let r=Rt(e.$auditRecord);r&&(Ce(r),t&&Pe(r)),e.$auditRecord=r}function Rt(e){if(!e)return;let t;if(Array.isArray(e))t=e;else if(D(e)){const r=e;if(r.auditEvents||r.mlAuditEvents)return r;t=[e]}return{auditEvents:t}}function Ce(e){const t=Lt();return e.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.sessionid=t}),e}function Pe(e){const t=typeof window<"u"?decodeURIComponent(window.location.href):"http://localhost";return e?.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.url=t}),e}function Lt(){return(!Y||Ut())&&(Y=be()),ve=new Date,Y}function Ut(){return new Date().getTime()-ve.getTime()>600*1e3}async function Ot(e,t=!0){const r={event:C.None,$auditRecord:e};return $(r,t),u("api/v1/audit.notify",r)}const $t={notify:Ot};async function It(e,t,r){const n=e.items?.length||0,a=10,s={query:{...t,action:"aggregate",aggregations:{[e.name]:{skip:n,count:a}}},$auditRecord:{auditEvents:[r]}};$(s);const i=await u("api/v1/query",s),c=await y(i),{aggregations:l}=c,h=l[0];return h.$hasMore=h.items.length>a,h.items=[...e.items,...h.items],Promise.resolve(h)}async function At(e){const t=e||d.app,r=new URLSearchParams({app:t||""});return _("api/v1/app",r)}async function ye(){const{app:e}=d,t=new URLSearchParams({app:e||"",preLogin:"true"});return _("api/v1/app",t)}function Dt(){let{backendUrl:e,app:t,useCredentials:r}=d;if(typeof window<"u"){if(e||(e=window.location.origin),!t){const n=window.location.pathname.match(/\/app(?:-debug)?\/([^/#]+)/);n&&(t=n[1])}p({...d,backendUrl:e,app:t})}return r?(p({...d,useCredentials:!0,useSSO:!1,autoOAuthProvider:void 0,autoSAMLProvider:void 0,bearerToken:void 0,useSAML:void 0}),Promise.resolve({})):ye().then(n=>{const{autoOAuthProvider:a,autoSAMLProvider:s}=d,i=!a&&!n.autoOAuthProvider&&!s&&!n.autoSAMLProvider;return p({...d,autoOAuthProvider:a||n.autoOAuthProvider,autoSAMLProvider:s||n.autoSAMLProvider,useCredentials:i,useSSO:i}),n}).catch(n=>{throw f("atomic:fetchAppPreLogin error",n),n})}async function Ft(e,t,r={}){const n=`api/v1/search.dataset/${e}/${t}`,a=await u(n,{parameters:r}),s=t[0].toLowerCase()+t.slice(1),i=a.datasets[s];if("errorCode"in i&&"errorMessage"in i)throw new Error(i.errorMessage);return i}async function Nt(e,t){const r=`api/v1/search.dataset/${e}`,{parameters:n={},datasets:a=[]}=t;return(await u(r,{parameters:n,datasets:a})).datasets}async function qt(e){return await _(`api/v1/search.dataset/${e}`)}async function Bt(e,t=!0,r){try{return(await u("api/v1/labels",{action:"list",q:e,public:t,locale:r,localize:!1})).labels}catch(n){throw f("Error in fetchLabels",n),n}}async function Qt(){try{const{app:e=""}=d,t=new URLSearchParams({app:e,action:"getUserRights"});return _("api/v1/labels",t)}catch(e){throw f("Error in getUserRights",e),e}}async function jt(e,t,r=!0){try{const n={action:"add",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:C.Label_AddDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"addToLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw f("Error in add",n),n}}async function Vt(e,t,r=!0){try{const n={action:"remove",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:C.Label_RemoveDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"removeFromLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw f("Error in remove",n),n}}async function xt(e,t,r=!0){try{const n={action:"rename",labels:e,newLabel:t,public:r,auditEvents:{type:C.Label_Rename,detail:{public:r,oldlabel:e?e.toString():null,label:t}}};return u("api/v1/labels",n)}catch(n){throw f("Error in rename",n),n}}async function Gt(e,t=!0){try{const r={action:"delete",labels:e,public:t,auditEvents:{type:C.Label_Delete,detail:{public:t,label:e?e.toString():null}}};return u("api/v1/labels",r)}catch(r){throw f("Error in deleteLabels",r),r}}async function Mt(e,t,r=!0){try{const n={action:"bulkAdd",labels:e,query:t,public:r,auditEvents:{type:C.Label_Add,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw f("Error in bulkAdd",n),n}}async function zt(e,t,r=!0){try{const n={action:"bulkRemove",labels:e,query:t,public:r,auditEvents:{type:C.Label_Delete,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw f("Error in bulkRemove",n),n}}const Ht={getUserRights:Qt,add:jt,remove:Vt,rename:xt,delete:Gt,bulkAdd:Mt,bulkRemove:zt};async function Jt(e,t){if(typeof window>"u")return u("api/v1/preview",{action:"get",id:e,query:t});const r=`${window.location.origin}${window.location.pathname}`,n={name:t?.name,text:t?.text};return u("api/v1/preview",{action:"get",id:e,query:n,browserUrl:r})}async function Wt(e){const t=new Headers;t.append("content-type","text");const r=await fetch(e,{method:"GET",headers:t});y(r)}async function K(){const e=new URLSearchParams({action:"get",noAutoAuthentication:"true"});return _("api/v1/principal",e)}async function Re(e){const t={noAutoAuthentication:"true",...e},r=new URLSearchParams;return Object.entries(t).forEach(([n,a])=>{a!==void 0&&r.append(n,String(a))}),_("api/v1/principal/list",r)}async function Le(e){if(!e)return Promise.reject(new Error("userid is required"));const t=new URLSearchParams({action:"userid",noAutoAuthentication:"true",userid:e});return _("api/v1/principal",t)}async function Ue(e){if(e.length===0)return Promise.reject(new Error("userids is required"));const t=new URLSearchParams({noAutoAuthentication:"true",userids:[...e].join(",")});return _("api/v1/principal/userids",t)}const Xt={principal:{get:K,list:Re,userid:Le,userids:Ue}},Oe=11;async function Yt(e,t,r){const a=await u("api/v1/query",{query:e,$auditRecord:t,queryIntentData:r});a.aggregations.forEach(i=>{i.$hasMore=!1,!i.isDistribution&&!i.isTree&&i.items&&(i.$hasMore=i.items.length===Oe),i.isTree&&i.items&&V(i)}),a.records?.map(i=>Object.assign(i,{value:i.title,type:"default"}));const s={...a,nextPage:a.page<Math.ceil(a.rowCount/a.pageSize)?a.page+1:void 0,previousPage:a.page>1?a.page-1:void 0};return Promise.resolve(s)}async function Kt(e,t,r){const{app:n=""}=d,a={methods:[],mode:t,propagateErrors:!0,$auditRecord:{auditEvents:[r]}};for(const c of e)a.methods.push({method:"query",app:n,query:c});const s=await u("api/v1/multi",a);s.results.forEach(c=>{c.aggregations.forEach(l=>{l.$hasMore=!1,!l.isDistribution&&!l.isTree&&l.items&&(l.$hasMore=l.items.length===Oe),l.isTree&&V(l)})}),s.results.forEach(c=>c.records?.map(l=>Object.assign(l,{value:l.title,type:"default"})));const i=s.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}));return Promise.resolve(i)}function V(e,t="",r=0){let n=[];return e.items&&e.items.forEach(a=>{let s=t?`${t}/${a.value}`:a.value,i=r+1;n.push({path:s,level:i}),a.$path=s,a.$level=i,a.hasChildren?n=n.concat(V(a,s,i)):a.hasChildren=!1}),n}async function Zt({model:e,appName:t,query:r,article:n}){const{webservice:a,format:s,maxcount:i,exportedColumns:c,export:l}=e,h={app:t,webservice:a,query:r,type:l,format:s,maxcount:i,exportedColumns:c,$auditRecord:{auditEvents:[{type:"Search_ExportCSV",detail:{resultid:n?n.id:void 0}}]}};return $(h),await u("api/v1/search.queryexport",h,{responseType:"blob"})}async function Et(e){return(await u("api/v1/queryintent",{query:e}))?.intents}async function Tt(e,t,r){return(await u("api/v1/similardocuments",{sourceDocumentId:e,query:{name:t}},{signal:r})).data}async function er(e,t){return(await u("api/v1/query.links",{webservice:e,query:t}))?.links?.map(a=>({...a,query:t}))}function tr(e,t){if(typeof e=="number")return`${e}`;if(Se(e))return rr(e);if(typeof e=="boolean")return e?"true":"false";if(e===null)return"null";if(Array.isArray(e)){const r=[];return e.forEach(n=>{r.length>0&&r.push(","),n?typeof n=="string"?r.push(n):r.push(n.display||n.value||""):r.push("null")}),r.splice(0,0,"["),r.push("]"),r.join("")}return e}function rr(e){if(!e)return"";try{if(ke(e)===0)return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit"}).format(e);{const t=new Intl.DateTimeFormat("en-CA").format(e),r=new Intl.DateTimeFormat("en-CA",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(e);return`${t} ${r}`}}catch{return"Invalid date"}}async function nr(e,t,r,n,a){const{app:s}=d,i={app:s||"",suggestQuery:e,text:t,filter:r,kinds:n,showSource:a};try{return(await u("api/v1/search.suggest",i)).suggests}catch(c){throw console.error("Error fetching suggestions:",c),c}}async function ar(e,t,r,n){const{app:a}=d;return(await u("api/v1/suggestquery",{app:a||"",suggestQuery:e,text:t,query:r,kinds:n})).suggests}async function or(e,t,r){if(!t)return Promise.resolve([]);const{app:n}=d,s=await u("api/v1/suggestfield",{app:n||"",text:e,fields:t,query:r});return s.suggests.forEach(i=>{i.display=tr(i.display)}),s.suggests}async function sr(e,t,r,n,a,s){return u("api/v1/doc.textchunks",{id:e,textChunks:t,highlights:r,query:n,leftSentencesCount:a,rightSentencesCount:s})}async function ir(){const{app:e}=d,t=new URLSearchParams({app:e||"",action:"load"});return _("api/v1/usersettings",t)}async function $e(e,t){const r={action:"save",userSettings:e,$auditRecord:{auditEvents:[t]}};return $(r),u("api/v1/usersettings",r)}async function cr(e,t){const n={action:"patch",userSettings:e,$auditRecord:t?{auditEvents:[t]}:void 0};return $(n),u("api/v1/usersettings",n)}async function lr(){return $e({},{type:"UserSettings_Reset"})}async function ur(e,t){return u("api/v2/security/password/change",{newPassword:e,currentPassword:t})}async function dr(e){const t="api/v2/security/password/ask-reset-email",n={changePasswordRedirectUrl:`${window.location.origin}/login?mode=changepassword`,userName:e};return u(t,n)}async function fr(e){return await _(`api/v2/user-profile/${e}`)}async function hr(e){return await u("api/v2/user-profile",e)}async function gr(e,t,r){return await de(`api/v2/user-profile/${e.data?.id}/${t}/${r}`,e)}async function mr(e,t,r){try{return(await ue(`api/v2/user-profile/${e.data?.id}/${t}/${r}`)).success===!0}catch{return!1}}async function wr(){return await _("api/v2/version")}const R=1e4,Ie=async()=>{const{autoOAuthProvider:e}=d;if(!e)throw new Error("autoOAuthProvider is not configured in globalConfig");if(typeof window>"u")try{const{signal:r}=v(R);return await u("security.oauth",{action:"getcode",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"},{signal:r})}catch(r){throw f("Failed to authenticate with OAuth",r),r}const t={action:"getcode",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const{signal:r}=v(R),n=await u("api/v1/security.oauth",t,{signal:r});if(n.redirectUrl){const a=new URL(n.redirectUrl,window.location.origin);(a.protocol==="https:"||a.protocol==="http:")&&(window.location.href=a.href)}return n}catch(r){throw f("Failed to authenticate with OAuth",r),r}},Ae=async()=>{const{autoSAMLProvider:e}=d;if(!e)throw new Error("autoSAMLProvider is not configured in globalConfig");if(typeof window>"u")try{const{signal:r}=v(R);return await u("security.saml",{action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"},{signal:r})}catch(r){throw f("Failed to authenticate with SAML",r),r}const t={action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const{signal:r}=v(R),n=await u("api/v1/security.saml",t,{signal:r});if(n.redirectUrl){const a=new URL(n.redirectUrl,window.location.origin);(a.protocol==="https:"||a.protocol==="http:")&&(window.location.href=a.href)}return n}catch(r){throw f("Failed to authenticate with SAML",r),r}},Z={store:{},getItem(e){return this.store[e]??null},setItem(e,t){this.store[e]=t.toString()},removeItem(e){delete this.store[e]},clear(){this.store={}}},E=Z;function _r(e){return typeof window>"u"||!window.localStorage?Z.getItem(e):window.localStorage.getItem(e)}function Sr(e){typeof window>"u"||!window.localStorage?Z.removeItem(e):window.localStorage.removeItem(e)}function pr(e){return typeof window>"u"||!window.sessionStorage?E.getItem(e):window.sessionStorage.getItem(e)}function kr(e,t){typeof window>"u"||!window.sessionStorage?E.setItem(e,t):window.sessionStorage.setItem(e,t)}function br(e){typeof window>"u"||!window.sessionStorage?E.removeItem(e):window.sessionStorage.removeItem(e)}const F=e=>kr("sinequa-credentials",JSON.stringify({data:{csrfToken:e}})),De=async()=>{try{const{signal:e}=v(R),t=await _("api/v1/challenge?action=getCsrfToken&suppressErrors=true",void 0,{signal:e});if(t?.csrfToken)return F(t.csrfToken),t.csrfToken;throw new Error("No CSRF token returned")}catch(e){throw f("Failed to get CSRF token",e),e}};async function Fe(e){if(e){const{username:t,password:r}=e,n={action:"get",tokenInCookie:!0,user:t,password:r,noUserOverride:!0,noAutoAuthentication:!0};try{const{signal:a}=v(R),s=await u("api/v1/security.webtoken",n,{signal:a});return s?.csrfToken?(F(s.csrfToken),s.csrfToken):null}catch(a){throw f("Failed to get JWT",a),a}}else{const t={action:"get",tokenInCookie:!0,noUserOverride:!0,noAutoAuthentication:!1},{bearerToken:r}=d;if(!r)throw new Error("Bearer token is required in globalConfig for credentialless JWT retrieval.");const n=new Headers;n.append("Sinequa-Force-Camel-Case","true"),n.append("accept","application/json"),n.append("Content-Type","application/json"),n.append("Authorization",`Bearer ${r}`);try{const{signal:a}=v(R),s=await u("api/v1/security.webtoken",t,{headers:n,signal:a});return s?.csrfToken?(F(s.csrfToken),s.csrfToken):null}catch(a){throw f("Failed to get JWT without credentials",a),a}}}const x=()=>{const e=pr("sinequa-credentials");if(e)try{const n=JSON.parse(e).data?.csrfToken;if(n)return n}catch(r){A("Failed to parse session storage credentials, falling back to local storage",r)}const t=_r("csrfToken");return t||null},vr=async e=>{if(e)k("Attempting authentication using credentials"),p({useCredentials:!0,useSSO:!1});else{let c=null;try{k("Attempting to retrieve CSRF token from the backend"),c=await De(),U("CSRF token retrieval result",c?"success":"failed")}catch{}try{if(c===null){const{autoOAuthProvider:l,autoSAMLProvider:h,useSAML:b}=d;if(l&&!b)return k("Initiating OAuth authentication flow"),await Ie(),m(!1),!1;if(h)return k("Initiating SAML authentication flow"),await Ae(),m(!1),!1;k("No direct authentication method available, will try SSO then credentials"),p({useCredentials:!0,useSSO:!0})}else return k("User authenticated via existing token"),m(!0),!0}catch(l){throw f("Unexpected error during authentication",l),m(!1),l}return!1}if(d.useCredentials&&d.useSSO)try{if(k("Checking if user is authenticated via SSO"),await K())return k("User authenticated using SSO"),p({useCredentials:!1,useSSO:!0}),m(!0),!0}catch(c){if(c?.status===401)return k("SSO authentication failed with 401, falling back to credentials"),p({useCredentials:!0,useSSO:!1}),!1;throw f("SSO authentication failed with unexpected error",c),m(!1),c}const{useSSO:r}=d,n=x();if(n||r)return k("user already authenticated",n),p({isRedirectUrl:!1}),m(!0),!0;const{useCredentials:a}=d,{username:s,password:i}=e||{};if(a&&(!s||!i))return f("Credentials are required for authentication"),m(!1),!1;if(s&&i)try{k("authentication using credentials..."),p({useCredentials:!0,useSSO:!1});const{userOverrideActive:c,useroverride:l}=d;return p({userOverrideActive:!1,useroverride:void 0}),await Fe({username:s,password:i}),p({userOverrideActive:c,useroverride:l}),m(!0),!0}catch(c){throw m(!1),c}return m(!1),f("No authentication method available. Please provide credentials or configure OAuth/SAML."),!1},Ne=async()=>{const e=new URLSearchParams({action:"deleteWebTokenCookie",noUserOverride:"true",noAutoAuthentication:"true"}),{signal:t}=v(R);return _("api/v1/challenge",e,{signal:t})};async function Cr(){const{userOverrideActive:e}=d;if(qe(),!e)try{const{methodresult:t,logoutUrl:r}=await Ne();if(t==="ok")return r;f("logout failed")}catch(t){f("logout failed",t)}}function qe(){Sr("csrfToken"),br("sinequa-credentials"),m(!1)}const Pr=()=>!!x();o.API=Xt,o.ApiError=P,o.Audit=$t,o.AuditEventType=C,o.DidYouMeanKind=fe,o.EngineType=g,o.EngineTypeModifier=S,o.LogLevel=z,o.MINIMUM_COMPATIBLE_SERVER_API_VERSION=mt,o.RFMDisplay=he,o.ServerError=H,o.TimeoutError=le,o.UnauthorizedError=j,o.addAuditAdditionalInfo=$,o.addConcepts=We,o.addSessionId=Ce,o.addUrl=Pe,o.aggItemRegex=T,o.aggregationItemStrictCompare=Qe,o.appInitializerFn=Dt,o.bisect=Ve,o.buildPathsAndLevels=V,o.clearSessionTokens=qe,o.configureLogger=lt,o.createHeaders=O,o.createTimeoutController=v,o.createUserProfile=hr,o.debug=U,o.del=ue,o.deleteUserProfileProperty=mr,o.deleteUserSettings=lr,o.deleteWebTokenCookie=Ne,o.emitAuthenticatedEvent=m,o.error=f,o.escapeExpr=Pt,o.expiresSoon=ft,o.extraColumns=pt,o.fetchAggregation=It,o.fetchApp=At,o.fetchAppPreLogin=ye,o.fetchBulkQuery=Kt,o.fetchChangePassword=ur,o.fetchDataset=Ft,o.fetchDatasetList=qt,o.fetchDatasets=Nt,o.fetchLabels=Bt,o.fetchPreview=Jt,o.fetchPreviewUrl=Wt,o.fetchPrincipal=K,o.fetchPrincipalList=Re,o.fetchPrincipalUserid=Le,o.fetchPrincipalUserids=Ue,o.fetchQuery=Yt,o.fetchQueryExport=Zt,o.fetchQueryIntent=Et,o.fetchSendPasswordResetEmail=dr,o.fetchSimilarDocuments=Tt,o.fetchSponsoredLinks=er,o.fetchSuggest=nr,o.fetchSuggestField=or,o.fetchSuggestQuery=ar,o.fetchTextChunks=sr,o.fetchUserProfile=fr,o.fetchUserSettings=ir,o.fetchVersion=wr,o.filter=kt,o.get=_,o.getConcepts=Ke,o.getCsrfToken=De,o.getFiltersFromURI=G,o.getFiltersFromUrl=tt,o.getHelpIndexUrl=it,o.getIdFromUrl=nt,o.getJWToken=Fe,o.getMetadata=bt,o.getMetadataWithValues=vt,o.getOffsetFromDates=ce,o.getQueryPageFromUrl=at,o.getQueryParamsFromUrl=Te,o.getQueryTabFromUrl=ot,o.getQueryTextFromUrl=rt,o.getRelativeDate=Ze,o.getTime=ke,o.getToken=x,o.getUrlParamsFromQueryParams=et,o.globalConfig=d,o.guid=be,o.handleResponse=y,o.info=k,o.isArrayBuffer=we,o.isAuthenticated=Pr,o.isBlob=_e,o.isDate=Se,o.isExpired=dt,o.isJsonable=Ct,o.isNotInputEvent=Ee,o.isObject=D,o.isString=pe,o.labels=Ht,o.login=vr,o.logout=Cr,o.makeColumn=w,o.notify=ct,o.openParentNodes=te,o.parseText=I,o.parseValueAndOperatorFromItem=ee,o.patch=de,o.patchUserProfile=gr,o.patchUserSettings=cr,o.post=u,o.put=ut,o.queryParamsFromUrl=L,o.removeConcept=Xe,o.removeConcepts=Ye,o.resolveToColumnName=gt,o.rewriteText=N,o.saveUserSettings=$e,o.setGlobalConfig=p,o.setToken=F,o.sha512=yt,o.suggestionsToTreeAggregationNodes=je,o.sysLang=st,o.toDate=W,o.translateAggregationToDateOptions=Be,o.tryOAuthAuthentication=Ie,o.trySAMLAuthentication=Ae,o.warn=A,o.withRetry=ht,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-filters.d.ts","sourceRoot":"","sources":["../../../src/types/filters/legacy-filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"legacy-filters.d.ts","sourceRoot":"","sources":["../../../src/types/filters/legacy-filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -5,7 +5,7 @@ export type DateFilter = {
|
|
|
5
5
|
label?: string;
|
|
6
6
|
operator?: FilterOperator;
|
|
7
7
|
value?: string;
|
|
8
|
-
filters?: LegacyFilter
|
|
8
|
+
filters?: LegacyFilter[];
|
|
9
9
|
display?: string;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
hidden?: boolean;
|
|
@@ -40,7 +40,7 @@ export declare function parseValueAndOperatorFromItem(item: AggregationItem, agg
|
|
|
40
40
|
* @param second - Second aggregation item to compare.
|
|
41
41
|
* @returns A boolean indicating whether the two aggregation items are strictly equal.
|
|
42
42
|
*/
|
|
43
|
-
export declare function aggregationItemStrictCompare(aggregation: Pick<Aggregation,
|
|
43
|
+
export declare function aggregationItemStrictCompare(aggregation: Pick<Aggregation, "valuesAreExpressions">, first: Pick<AggregationItem, "value" | "display">, second: Pick<AggregationItem, "value" | "display">): boolean;
|
|
44
44
|
/**
|
|
45
45
|
* Recursively opens parent nodes in a tree structure if any of their child nodes are selected or opened.
|
|
46
46
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregations.d.ts","sourceRoot":"","sources":["../../src/utils/aggregations.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"aggregations.d.ts","sourceRoot":"","sources":["../../src/utils/aggregations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,IAAI,GACJ,OAAO,GACP,KAAK,CAAC,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAExD,eAAO,MAAM,YAAY,QAA+B,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,WAAW,EACxB,iCAAiC,EAAE,OAAO,GACzC,UAAU,EAAE,CA4Bd;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,eAAe,EACrB,iBAAiB,EAAE,MAAM,GACxB,YAAY,CA+Bd;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,sBAAsB,CAAC,EACtD,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,SAAS,CAAC,EACjD,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,SAAS,CAAC,GACjD,OAAO,CAGT;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,mBAAmB,GACxB,mBAAmB,CAQrB;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,UAAU,EAAE,EACtB,UAAU,EAAE,MAAM,GACjB,mBAAmB,EAAE,CA+BvB"}
|