algoliasearch
Version:
A fully-featured and blazing-fast JavaScript API client to interact with Algolia API.
11 lines (10 loc) • 165 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.algoliasearch = {}));
})(this, (function (exports) { 'use strict';
function C(d){let m,P=`algolia-client-js-${d.key}`;function T(){return m===void 0&&(m=d.localStorage||window.localStorage),m}function g(){return JSON.parse(T().getItem(P)||"{}")}function I(e){T().setItem(P,JSON.stringify(e));}function h(){return new Promise(e=>setTimeout(e,0))}function r(){let e=d.timeToLive?d.timeToLive*1e3:null,t=g(),s=new Date().getTime(),a=false;return {namespace:Object.fromEntries(Object.entries(t).filter(([,o])=>!o||o.timestamp===void 0||e&&o.timestamp+e<s?(a=true,false):true)),changed:a}}return {get(e,t,s={miss:()=>Promise.resolve()}){return h().then(()=>{let{namespace:a,changed:n}=r(),o=a[JSON.stringify(e)];return n&&I(a),o?o.value:t().then(c=>s.miss(c).then(()=>c))})},set(e,t){return h().then(()=>{let s=g();return s[JSON.stringify(e)]={timestamp:new Date().getTime(),value:t},T().setItem(P,JSON.stringify(s)),t})},delete(e){return h().then(()=>{let t=g();delete t[JSON.stringify(e)],T().setItem(P,JSON.stringify(t));})},clear(){return Promise.resolve().then(()=>{T().removeItem(P);})}}}function Ne(){return {get(d,m,P={miss:()=>Promise.resolve()}){return m().then(g=>Promise.all([g,P.miss(g)])).then(([g])=>g)},set(d,m){return Promise.resolve(m)},delete(d){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(d){let m=[...d.caches],P=m.shift();return P===void 0?Ne():{get(T,g,I={miss:()=>Promise.resolve()}){return P.get(T,g,I).catch(()=>R({caches:m}).get(T,g,I))},set(T,g){return P.set(T,g).catch(()=>R({caches:m}).set(T,g))},delete(T){return P.delete(T).catch(()=>R({caches:m}).delete(T))},clear(){return P.clear().catch(()=>R({caches:m}).clear())}}}function W(d={serializable:true}){let m={};return {get(P,T,g={miss:()=>Promise.resolve()}){let I=JSON.stringify(P);if(I in m)return Promise.resolve(d.serializable?JSON.parse(m[I]):m[I]);let h=T();return h.then(r=>g.miss(r)).then(()=>h)},set(P,T){return m[JSON.stringify(P)]=d.serializable?JSON.stringify(T):T,Promise.resolve(T)},delete(P){return delete m[JSON.stringify(P)],Promise.resolve()},clear(){return m={},Promise.resolve()}}}var Q=800;function Ge(d){let m={value:`Algolia for JavaScript (${d})`,add(P){let T=`; ${P.segment}${P.version!==void 0?` (${P.version})`:""}`;return m.value.indexOf(T)===-1&&(m.value=`${m.value}${T}`),m}};return m}function E(d,m,P="WithinHeaders"){let T={"x-algolia-api-key":m,"x-algolia-application-id":d};return {headers(){return P==="WithinHeaders"?T:{}},queryParameters(){return P==="WithinQueryParameters"?T:{}}}}function w({func:d,validate:m,aggregator:P,error:T,timeout:g=()=>0}){let I=h=>new Promise((r,e)=>{d(h).then(async t=>(P&&await P(t),await m(t)?r(t):T&&await T.validate(t)?e(new Error(await T.message(t))):setTimeout(()=>{I(t).then(r).catch(e);},await g()))).catch(t=>{e(t);});});return I()}function D({algoliaAgents:d,client:m,version:P}){let T=Ge(P).add({segment:m,version:P});return d.forEach(g=>T.add(g)),T}function b(){return {debug(d,m){return Promise.resolve()},info(d,m){return Promise.resolve()},error(d,m){return Promise.resolve()}}}var Be=10*1024*1024;async function*je(d){let m=d.getReader();try{for(;;){let{done:P,value:T}=await m.read();if(P)return;yield T;}}finally{m.releaseLock();}}function Le(d){return Symbol.asyncIterator in d?d:je(d)}async function*Fe(d){let m=new TextDecoder("utf-8"),P=[],T=0,g=false,I=true;for await(let r of Le(d)){let e=m.decode(r,{stream:true}),t=0;for(g&&(g=false,e.length>0&&e[0]===`
`&&(t=1));t<e.length;){let s=e.indexOf("\r",t),a=e.indexOf(`
`,t);if(s===-1&&a===-1){let p=e.slice(t);if(P.push(p),T+=p.length,T>Be)throw new Error("SSE line buffer exceeded 10MB");break}let n,o;s!==-1&&(a===-1||s<a)?(n=s,s+1<e.length?o=e[s+1]===`
`?2:1:(g=true,o=1)):(n=a,o=1);let c=e.slice(t,n);P.push(c);let u=P.length===1?P[0]:P.join("");P.length=0,T=0,I&&(u.startsWith("\uFEFF")&&(u=u.slice(1)),I=false),yield u,t=n+o;}}let h=m.decode();if(h&&P.push(h),P.length>0){let r=P.join("");I&&r.startsWith("\uFEFF")&&(r=r.slice(1)),yield r;}}var Ve=class{data=[];eventType="";lastEventId=null;retry=null;decode(d){if(d==="")return this.dispatch();if(d[0]===":")return null;let m=d.indexOf(":"),P,T;switch(m===-1?(P=d,T=""):(P=d.slice(0,m),T=d.slice(m+1),T[0]===" "&&(T=T.slice(1))),P){case "data":this.data.push(T);break;case "event":this.eventType=T;break;case "id":T.includes("\0")||(this.lastEventId=T);break;case "retry":/^[0-9]+$/.test(T)&&(this.retry=parseInt(T,10));break}return null}dispatch(){let d=this.eventType;if(this.eventType="",this.data.length===0)return null;let m={data:this.data.join(`
`),event:d,id:this.lastEventId,retry:this.retry};return this.data=[],m}};async function*_e(d){let m=new Ve;for await(let P of Fe(d)){let T=m.decode(P);T!==null&&(yield T);}}var Qe=750,re=120*1e3;function se(d,m="up"){let P=Date.now();function T(){return m==="up"||Date.now()-P>re}function g(){return m==="timed out"&&Date.now()-P<=re}return {...d,status:m,lastUpdate:P,isUp:T,isTimedOut:g}}var ce=class extends Error{name="AlgoliaError";constructor(d,m){super(d),m&&(this.name=m);}};var ue=class extends ce{stackTrace;constructor(d,m,P){super(d,P),this.stackTrace=m;}},ae=class extends ue{constructor(d){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",d,"RetryError");}},V=class extends ue{status;constructor(d,m,P,T="ApiError"){super(d,P,T),this.status=m;}},ze=class extends ce{response;constructor(d,m){super(d,"DeserializationError"),this.response=m;}},$e=class extends V{error;constructor(d,m,P,T){super(d,m,T,"DetailedApiError"),this.error=P;}};function z(d){let m=d;for(let P=d.length-1;P>0;P--){let T=Math.floor(Math.random()*(P+1)),g=d[P];m[P]=d[T],m[T]=g;}return m}function oe(d,m,P){let T=Me(P),g=`${d.protocol}://${d.url}${d.port?`:${d.port}`:""}/${m.charAt(0)==="/"?m.substring(1):m}`;return T.length&&(g+=`?${T}`),g}function Me(d){return Object.keys(d).filter(m=>d[m]!==void 0).sort().map(m=>`${m}=${encodeURIComponent(Object.prototype.toString.call(d[m])==="[object Array]"?d[m].join(","):d[m]).replace(/\+/g,"%20")}`).join("&")}function ne(d,m){if(d.method==="GET"||d.data===void 0&&m.data===void 0)return;let P=Array.isArray(d.data)?d.data:{...d.data,...m.data};return JSON.stringify(P)}function ie(d,m,P){let T={Accept:"application/json",...d,...m,...P},g={};return Object.keys(T).forEach(I=>{let h=T[I];g[I.toLowerCase()]=h;}),g}function he(d){if(!(d.status===204||d.content.length===0))try{return JSON.parse(d.content)}catch(m){throw new ze(m.message,d)}}function Ke(d){return {status:d.status,headers:d.headers,content:d.content,data:he(d)}}function Xe({content:d,status:m},P){try{let T=JSON.parse(d);return "error"in T?new $e(T.message,m,T.error,P):new V(T.message,m,P)}catch{}return new V(d,m,P)}function Je({isTimedOut:d,status:m}){return !d&&~~m===0}function Ye({isTimedOut:d,status:m}){return d||Je({isTimedOut:d,status:m})||~~(m/100)!==2&&~~(m/100)!==4}function Ze({status:d}){return ~~(d/100)===2}function et(d){return d.map(m=>de(m))}function de(d){let m=d.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...d,request:{...d.request,headers:{...d.request.headers,...m}}}}function A({hosts:d,hostsCache:m,baseHeaders:P,logger:T,baseQueryParameters:g,algoliaAgent:I,timeouts:h,requester:r,requestsCache:e,responsesCache:t,compress:s,compression:a}){async function n(q){let l=await Promise.all(q.map(v=>m.get(v,()=>Promise.resolve(se(v))))),y=l.filter(v=>v.isUp()),f=l.filter(v=>v.isTimedOut()),S=[...y,...f];return {hosts:S.length>0?S:q,getTimeout(v,U){return (f.length===0&&v===0?1:f.length+3+v)*U}}}async function o(q,l,y){let f=[],S=ne(q,l),H=ie(P,q.headers,l.headers),v=a==="gzip"&&S!==void 0&&S.length>Qe&&(q.method==="POST"||q.method==="PUT");v&&s===void 0&&T.info("Compression is disabled because no compress method is available.");let U=v&&s!==void 0,j=U?await s(S):S;U&&(H["content-encoding"]="gzip");let N=q.method==="GET"?{...q.data,...l.data}:{},G={...g,...q.queryParameters,...N};if(I.value&&(G["x-algolia-agent"]=I.value),l&&l.queryParameters)for(let x of Object.keys(l.queryParameters))!l.queryParameters[x]||Object.prototype.toString.call(l.queryParameters[x])==="[object Object]"?G[x]=l.queryParameters[x]:G[x]=l.queryParameters[x].toString();let L=0,_=async(x,$)=>{let F=x.pop();if(F===void 0)throw new ae(et(f));let M={...h,...l.timeouts},Z={data:j,headers:H,method:q.method,url:oe(F,q.path,G),connectTimeout:$(L,M.connect),responseTimeout:$(L,y?M.read:M.write)},ee=K=>{let te={request:Z,response:K,host:F,triesLeft:x.length};return f.push(te),te},B=await r.send(Z);if(Ye(B)){let K=ee(B);return B.isTimedOut&&L++,T.info("Retryable failure",de(K)),await m.set(F,se(F,B.isTimedOut?"timed out":"down")),_(x,$)}if(Ze(B))return B;throw ee(B),Xe(B,f)},O=d.filter(x=>x.accept==="readWrite"||(y?x.accept==="read":x.accept==="write")),Y=await n(O);return _([...Y.hosts].reverse(),Y.getTimeout)}function c(q,l={}){let y=()=>o(q,l,f).then(v=>he(v)),f=q.useReadTransporter||q.method==="GET";if((l.cacheable||q.cacheable)!==true)return y();let H={request:q,requestOptions:l,transporter:{queryParameters:g,headers:P}};return t.get(H,()=>e.get(H,()=>e.set(H,y()).then(v=>Promise.all([e.delete(H),v]),v=>Promise.all([e.delete(H),Promise.reject(v)])).then(([v,U])=>U)),{miss:v=>t.set(H,v)})}function u(q,l={}){let y=q.useReadTransporter||q.method==="GET";return o(q,l,y).then(f=>Ke(f))}async function*p(q,l={}){if(!r.sendStream)throw new Error("This requester does not support streaming");let y=ne(q,l),f=ie(P,q.headers,l.headers);f.accept="text/event-stream";let S=q.method==="GET"?{...q.data,...l.data}:{},H={...g,...q.queryParameters,...S};if(I.value&&(H["x-algolia-agent"]=I.value),l&&l.queryParameters)for(let O of Object.keys(l.queryParameters))!l.queryParameters[O]||Object.prototype.toString.call(l.queryParameters[O])==="[object Object]"?H[O]=l.queryParameters[O]:H[O]=l.queryParameters[O].toString();let v=q.useReadTransporter||q.method==="GET",U=d.filter(O=>O.accept==="readWrite"||(v?O.accept==="read":O.accept==="write")),N=(await n(U)).hosts[0];if(!N)throw new ae([]);let G={...h,...l.timeouts},L={data:y,headers:f,method:q.method,url:oe(N,q.path,H),connectTimeout:G.connect,responseTimeout:v?G.read:G.write},_=await r.sendStream(L);yield*_e(_);}return {hostsCache:m,requester:r,timeouts:h,logger:T,algoliaAgent:I,baseHeaders:P,baseQueryParameters:g,hosts:d,request:c,requestWithHttpInfo:u,requestStream:p,requestsCache:e,responsesCache:t}}function i(d,m,P){if(P==null||typeof P=="string"&&P.length===0)throw new Error(`Parameter \`${d}\` is required when calling \`${m}\`.`)}function tt(d){let m={};for(let P of d.trim().split(/[\r\n]+/)){let T=P.indexOf(": ");T>0&&(m[P.slice(0,T).toLowerCase()]=P.slice(T+2));}return m}function k(){function d(m){return new Promise(P=>{let T=new XMLHttpRequest;T.open(m.method,m.url,true),Object.keys(m.headers).forEach(r=>T.setRequestHeader(r,m.headers[r]));let g=(r,e)=>setTimeout(()=>{T.abort(),P({status:0,content:e,isTimedOut:true});},r),I=g(m.connectTimeout,"Connection timeout"),h;T.onreadystatechange=()=>{T.readyState>T.OPENED&&h===void 0&&(clearTimeout(I),h=g(m.responseTimeout,"Socket timeout"));},T.onerror=()=>{T.status===0&&(clearTimeout(I),clearTimeout(h),P({content:T.responseText||"Network request failed",status:T.status,isTimedOut:false}));},T.onload=()=>{clearTimeout(I),clearTimeout(h),P({content:T.responseText,headers:tt(T.getAllResponseHeaders()),status:T.status,isTimedOut:false});},T.send(m.data);})}return {send:d}}var Pe="1.22.0",me=["de","us"];function rt(d){return [{url:d?"analytics.{region}.algolia.com".replace("{region}",d):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function st({appId:d,apiKey:m,authMode:P,algoliaAgents:T,region:g,...I}){let h=E(d,m,P),r=A({hosts:rt(g),...I,algoliaAgent:D({algoliaAgents:T,client:"AbtestingV3",version:Pe}),baseHeaders:{"content-type":"text/plain",...h.headers(),...I.baseHeaders},baseQueryParameters:{...h.queryParameters(),...I.baseQueryParameters}});return {transporter:r,appId:d,apiKey:m,clearCache(){return Promise.all([r.requestsCache.clear(),r.responsesCache.clear()]).then(()=>{})},get _ua(){return r.algoliaAgent.value},addAlgoliaAgent(e,t){r.algoliaAgent.add({segment:e,version:t});},setClientApiKey({apiKey:e}){!P||P==="WithinHeaders"?r.baseHeaders["x-algolia-api-key"]=e:r.baseQueryParameters["x-algolia-api-key"]=e;},addABTests(e,t){i("addABTestsRequest","addABTests",e),i("addABTestsRequest.name","addABTests",e.name),i("addABTestsRequest.variants","addABTests",e.variants),i("addABTestsRequest.metrics","addABTests",e.metrics),i("addABTestsRequest.endAt","addABTests",e.endAt);let o={method:"POST",path:"/3/abtests",queryParameters:{},headers:{},data:e};return r.request(o,t)},addABTestsWithHTTPInfo(e,t){i("addABTestsRequest","addABTestsWithHTTPInfo",e),i("addABTestsRequest.name","addABTestsWithHTTPInfo",e.name),i("addABTestsRequest.variants","addABTestsWithHTTPInfo",e.variants),i("addABTestsRequest.metrics","addABTestsWithHTTPInfo",e.metrics),i("addABTestsRequest.endAt","addABTestsWithHTTPInfo",e.endAt);let o={method:"POST",path:"/3/abtests",queryParameters:{},headers:{},data:e};return r.requestWithHttpInfo(o,t)},customDelete({path:e,parameters:t},s){i("path","customDelete",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customDeleteWithHTTPInfo({path:e,parameters:t},s){i("path","customDeleteWithHTTPInfo",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customGet({path:e,parameters:t},s){i("path","customGet",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customGetWithHTTPInfo({path:e,parameters:t},s){i("path","customGetWithHTTPInfo",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customPost({path:e,parameters:t,body:s},a){i("path","customPost",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPostWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPostWithHTTPInfo",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},customPut({path:e,parameters:t,body:s},a){i("path","customPut",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPutWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPutWithHTTPInfo",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},deleteABTest({id:e},t){i("id","deleteABTest",e);let o={method:"DELETE",path:"/3/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.request(o,t)},deleteABTestWithHTTPInfo({id:e},t){i("id","deleteABTestWithHTTPInfo",e);let o={method:"DELETE",path:"/3/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.requestWithHttpInfo(o,t)},estimateABTest(e,t){i("estimateABTestRequest","estimateABTest",e),i("estimateABTestRequest.configuration","estimateABTest",e.configuration),i("estimateABTestRequest.variants","estimateABTest",e.variants);let o={method:"POST",path:"/3/abtests/estimate",queryParameters:{},headers:{},data:e};return r.request(o,t)},estimateABTestWithHTTPInfo(e,t){i("estimateABTestRequest","estimateABTestWithHTTPInfo",e),i("estimateABTestRequest.configuration","estimateABTestWithHTTPInfo",e.configuration),i("estimateABTestRequest.variants","estimateABTestWithHTTPInfo",e.variants);let o={method:"POST",path:"/3/abtests/estimate",queryParameters:{},headers:{},data:e};return r.requestWithHttpInfo(o,t)},getABTest({id:e},t){i("id","getABTest",e);let o={method:"GET",path:"/3/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.request(o,t)},getABTestWithHTTPInfo({id:e},t){i("id","getABTestWithHTTPInfo",e);let o={method:"GET",path:"/3/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.requestWithHttpInfo(o,t)},getTimeseries({id:e,startDate:t,endDate:s,metric:a},n){i("id","getTimeseries",e);let o="/3/abtests/{id}/timeseries".replace("{id}",encodeURIComponent(e)),c={},u={};t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.metric=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getTimeseriesWithHTTPInfo({id:e,startDate:t,endDate:s,metric:a},n){i("id","getTimeseriesWithHTTPInfo",e);let o="/3/abtests/{id}/timeseries".replace("{id}",encodeURIComponent(e)),c={},u={};t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.metric=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},listABTests({offset:e,limit:t,indexPrefix:s,indexSuffix:a,direction:n}={},o=void 0){let c="/3/abtests",u={},p={};e!==void 0&&(p.offset=e.toString()),t!==void 0&&(p.limit=t.toString()),s!==void 0&&(p.indexPrefix=s.toString()),a!==void 0&&(p.indexSuffix=a.toString()),n!==void 0&&(p.direction=n.toString());let q={method:"GET",path:c,queryParameters:p,headers:u};return r.request(q,o)},listABTestsWithHTTPInfo({offset:e,limit:t,indexPrefix:s,indexSuffix:a,direction:n}={},o=void 0){let c="/3/abtests",u={},p={};e!==void 0&&(p.offset=e.toString()),t!==void 0&&(p.limit=t.toString()),s!==void 0&&(p.indexPrefix=s.toString()),a!==void 0&&(p.indexSuffix=a.toString()),n!==void 0&&(p.direction=n.toString());let q={method:"GET",path:c,queryParameters:p,headers:u};return r.requestWithHttpInfo(q,o)},stopABTest({id:e},t){i("id","stopABTest",e);let o={method:"POST",path:"/3/abtests/{id}/stop".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.request(o,t)},stopABTestWithHTTPInfo({id:e},t){i("id","stopABTestWithHTTPInfo",e);let o={method:"POST",path:"/3/abtests/{id}/stop".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.requestWithHttpInfo(o,t)}}}function qe(d,m,P,T){if(!d||typeof d!="string")throw new Error("`appId` is missing.");if(!m||typeof m!="string")throw new Error("`apiKey` is missing.");if(P&&(typeof P!="string"||!me.includes(P)))throw new Error(`\`region\` must be one of the following: ${me.join(", ")}`);let{compression:g,...I}=T||{};return st({appId:d,apiKey:m,region:P,timeouts:{connect:1e3,read:2e3,write:3e4},logger:b(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:W(),requestsCache:W({serializable:false}),hostsCache:R({caches:[C({key:`${Pe}-${d}`}),W()]}),...I})}var le="5.56.0",pe=["de","us"];function at(d){return [{url:d?"analytics.{region}.algolia.com".replace("{region}",d):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function ot({appId:d,apiKey:m,authMode:P,algoliaAgents:T,region:g,...I}){let h=E(d,m,P),r=A({hosts:at(g),...I,algoliaAgent:D({algoliaAgents:T,client:"Abtesting",version:le}),baseHeaders:{"content-type":"text/plain",...h.headers(),...I.baseHeaders},baseQueryParameters:{...h.queryParameters(),...I.baseQueryParameters}});return {transporter:r,appId:d,apiKey:m,clearCache(){return Promise.all([r.requestsCache.clear(),r.responsesCache.clear()]).then(()=>{})},get _ua(){return r.algoliaAgent.value},addAlgoliaAgent(e,t){r.algoliaAgent.add({segment:e,version:t});},setClientApiKey({apiKey:e}){!P||P==="WithinHeaders"?r.baseHeaders["x-algolia-api-key"]=e:r.baseQueryParameters["x-algolia-api-key"]=e;},addABTests(e,t){i("addABTestsRequest","addABTests",e),i("addABTestsRequest.name","addABTests",e.name),i("addABTestsRequest.variants","addABTests",e.variants),i("addABTestsRequest.endAt","addABTests",e.endAt);let o={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:e};return r.request(o,t)},addABTestsWithHTTPInfo(e,t){i("addABTestsRequest","addABTestsWithHTTPInfo",e),i("addABTestsRequest.name","addABTestsWithHTTPInfo",e.name),i("addABTestsRequest.variants","addABTestsWithHTTPInfo",e.variants),i("addABTestsRequest.endAt","addABTestsWithHTTPInfo",e.endAt);let o={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:e};return r.requestWithHttpInfo(o,t)},customDelete({path:e,parameters:t},s){i("path","customDelete",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customDeleteWithHTTPInfo({path:e,parameters:t},s){i("path","customDeleteWithHTTPInfo",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customGet({path:e,parameters:t},s){i("path","customGet",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customGetWithHTTPInfo({path:e,parameters:t},s){i("path","customGetWithHTTPInfo",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customPost({path:e,parameters:t,body:s},a){i("path","customPost",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPostWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPostWithHTTPInfo",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},customPut({path:e,parameters:t,body:s},a){i("path","customPut",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPutWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPutWithHTTPInfo",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},deleteABTest({id:e},t){i("id","deleteABTest",e);let o={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.request(o,t)},deleteABTestWithHTTPInfo({id:e},t){i("id","deleteABTestWithHTTPInfo",e);let o={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.requestWithHttpInfo(o,t)},estimateABTest(e,t){i("estimateABTestRequest","estimateABTest",e),i("estimateABTestRequest.configuration","estimateABTest",e.configuration),i("estimateABTestRequest.variants","estimateABTest",e.variants);let o={method:"POST",path:"/2/abtests/estimate",queryParameters:{},headers:{},data:e};return r.request(o,t)},estimateABTestWithHTTPInfo(e,t){i("estimateABTestRequest","estimateABTestWithHTTPInfo",e),i("estimateABTestRequest.configuration","estimateABTestWithHTTPInfo",e.configuration),i("estimateABTestRequest.variants","estimateABTestWithHTTPInfo",e.variants);let o={method:"POST",path:"/2/abtests/estimate",queryParameters:{},headers:{},data:e};return r.requestWithHttpInfo(o,t)},getABTest({id:e},t){i("id","getABTest",e);let o={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.request(o,t)},getABTestWithHTTPInfo({id:e},t){i("id","getABTestWithHTTPInfo",e);let o={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.requestWithHttpInfo(o,t)},listABTests({offset:e,limit:t,indexPrefix:s,indexSuffix:a}={},n=void 0){let o="/2/abtests",c={},u={};e!==void 0&&(u.offset=e.toString()),t!==void 0&&(u.limit=t.toString()),s!==void 0&&(u.indexPrefix=s.toString()),a!==void 0&&(u.indexSuffix=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},listABTestsWithHTTPInfo({offset:e,limit:t,indexPrefix:s,indexSuffix:a}={},n=void 0){let o="/2/abtests",c={},u={};e!==void 0&&(u.offset=e.toString()),t!==void 0&&(u.limit=t.toString()),s!==void 0&&(u.indexPrefix=s.toString()),a!==void 0&&(u.indexSuffix=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},stopABTest({id:e},t){i("id","stopABTest",e);let o={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.request(o,t)},stopABTestWithHTTPInfo({id:e},t){i("id","stopABTestWithHTTPInfo",e);let o={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.requestWithHttpInfo(o,t)}}}function Te(d,m,P,T){if(!d||typeof d!="string")throw new Error("`appId` is missing.");if(!m||typeof m!="string")throw new Error("`apiKey` is missing.");if(P&&(typeof P!="string"||!pe.includes(P)))throw new Error(`\`region\` must be one of the following: ${pe.join(", ")}`);let{compression:g,...I}=T||{};return ot({appId:d,apiKey:m,region:P,timeouts:{connect:1e3,read:2e3,write:3e4},logger:b(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:W(),requestsCache:W({serializable:false}),hostsCache:R({caches:[C({key:`${le}-${d}`}),W()]}),...I})}var ge="5.56.0",fe=["de","us"];function nt(d){return [{url:d?"analytics.{region}.algolia.com".replace("{region}",d):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function it({appId:d,apiKey:m,authMode:P,algoliaAgents:T,region:g,...I}){let h=E(d,m,P),r=A({hosts:nt(g),...I,algoliaAgent:D({algoliaAgents:T,client:"Analytics",version:ge}),baseHeaders:{"content-type":"text/plain",...h.headers(),...I.baseHeaders},baseQueryParameters:{...h.queryParameters(),...I.baseQueryParameters}});return {transporter:r,appId:d,apiKey:m,clearCache(){return Promise.all([r.requestsCache.clear(),r.responsesCache.clear()]).then(()=>{})},get _ua(){return r.algoliaAgent.value},addAlgoliaAgent(e,t){r.algoliaAgent.add({segment:e,version:t});},setClientApiKey({apiKey:e}){!P||P==="WithinHeaders"?r.baseHeaders["x-algolia-api-key"]=e:r.baseQueryParameters["x-algolia-api-key"]=e;},customDelete({path:e,parameters:t},s){i("path","customDelete",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customDeleteWithHTTPInfo({path:e,parameters:t},s){i("path","customDeleteWithHTTPInfo",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customGet({path:e,parameters:t},s){i("path","customGet",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customGetWithHTTPInfo({path:e,parameters:t},s){i("path","customGetWithHTTPInfo",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customPost({path:e,parameters:t,body:s},a){i("path","customPost",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPostWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPostWithHTTPInfo",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},customPut({path:e,parameters:t,body:s},a){i("path","customPut",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPutWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPutWithHTTPInfo",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},getAddToCartRate({index:e,startDate:t,endDate:s,tags:a},n){i("index","getAddToCartRate",e);let o="/2/conversions/addToCartRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getAddToCartRateWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getAddToCartRateWithHTTPInfo",e);let o="/2/conversions/addToCartRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getAverageClickPosition({index:e,startDate:t,endDate:s,tags:a},n){i("index","getAverageClickPosition",e);let o="/2/clicks/averageClickPosition",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getAverageClickPositionWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getAverageClickPositionWithHTTPInfo",e);let o="/2/clicks/averageClickPosition",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getClickPositions({index:e,startDate:t,endDate:s,tags:a},n){i("index","getClickPositions",e);let o="/2/clicks/positions",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getClickPositionsWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getClickPositionsWithHTTPInfo",e);let o="/2/clicks/positions",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getClickThroughRate({index:e,startDate:t,endDate:s,tags:a},n){i("index","getClickThroughRate",e);let o="/2/clicks/clickThroughRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getClickThroughRateWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getClickThroughRateWithHTTPInfo",e);let o="/2/clicks/clickThroughRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getConversionRate({index:e,startDate:t,endDate:s,tags:a},n){i("index","getConversionRate",e);let o="/2/conversions/conversionRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getConversionRateWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getConversionRateWithHTTPInfo",e);let o="/2/conversions/conversionRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getNoClickRate({index:e,startDate:t,endDate:s,tags:a},n){i("index","getNoClickRate",e);let o="/2/searches/noClickRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getNoClickRateWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getNoClickRateWithHTTPInfo",e);let o="/2/searches/noClickRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getNoResultsRate({index:e,startDate:t,endDate:s,tags:a},n){i("index","getNoResultsRate",e);let o="/2/searches/noResultRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getNoResultsRateWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getNoResultsRateWithHTTPInfo",e);let o="/2/searches/noResultRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getPurchaseRate({index:e,startDate:t,endDate:s,tags:a},n){i("index","getPurchaseRate",e);let o="/2/conversions/purchaseRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getPurchaseRateWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getPurchaseRateWithHTTPInfo",e);let o="/2/conversions/purchaseRate",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getRevenue({index:e,startDate:t,endDate:s,tags:a},n){i("index","getRevenue",e);let o="/2/conversions/revenue",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getRevenueWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getRevenueWithHTTPInfo",e);let o="/2/conversions/revenue",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getSearchesCount({index:e,startDate:t,endDate:s,tags:a},n){i("index","getSearchesCount",e);let o="/2/searches/count",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getSearchesCountWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getSearchesCountWithHTTPInfo",e);let o="/2/searches/count",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)},getSearchesNoClicks({index:e,startDate:t,endDate:s,limit:a,offset:n,tags:o},c){i("index","getSearchesNoClicks",e);let u="/2/searches/noClicks",p={},q={};e!==void 0&&(q.index=e.toString()),t!==void 0&&(q.startDate=t.toString()),s!==void 0&&(q.endDate=s.toString()),a!==void 0&&(q.limit=a.toString()),n!==void 0&&(q.offset=n.toString()),o!==void 0&&(q.tags=o.toString());let l={method:"GET",path:u,queryParameters:q,headers:p};return r.request(l,c)},getSearchesNoClicksWithHTTPInfo({index:e,startDate:t,endDate:s,limit:a,offset:n,tags:o},c){i("index","getSearchesNoClicksWithHTTPInfo",e);let u="/2/searches/noClicks",p={},q={};e!==void 0&&(q.index=e.toString()),t!==void 0&&(q.startDate=t.toString()),s!==void 0&&(q.endDate=s.toString()),a!==void 0&&(q.limit=a.toString()),n!==void 0&&(q.offset=n.toString()),o!==void 0&&(q.tags=o.toString());let l={method:"GET",path:u,queryParameters:q,headers:p};return r.requestWithHttpInfo(l,c)},getSearchesNoResults({index:e,startDate:t,endDate:s,limit:a,offset:n,tags:o},c){i("index","getSearchesNoResults",e);let u="/2/searches/noResults",p={},q={};e!==void 0&&(q.index=e.toString()),t!==void 0&&(q.startDate=t.toString()),s!==void 0&&(q.endDate=s.toString()),a!==void 0&&(q.limit=a.toString()),n!==void 0&&(q.offset=n.toString()),o!==void 0&&(q.tags=o.toString());let l={method:"GET",path:u,queryParameters:q,headers:p};return r.request(l,c)},getSearchesNoResultsWithHTTPInfo({index:e,startDate:t,endDate:s,limit:a,offset:n,tags:o},c){i("index","getSearchesNoResultsWithHTTPInfo",e);let u="/2/searches/noResults",p={},q={};e!==void 0&&(q.index=e.toString()),t!==void 0&&(q.startDate=t.toString()),s!==void 0&&(q.endDate=s.toString()),a!==void 0&&(q.limit=a.toString()),n!==void 0&&(q.offset=n.toString()),o!==void 0&&(q.tags=o.toString());let l={method:"GET",path:u,queryParameters:q,headers:p};return r.requestWithHttpInfo(l,c)},getStatus({index:e},t){i("index","getStatus",e);let s="/2/status",a={},n={};e!==void 0&&(n.index=e.toString());let o={method:"GET",path:s,queryParameters:n,headers:a};return r.request(o,t)},getStatusWithHTTPInfo({index:e},t){i("index","getStatusWithHTTPInfo",e);let s="/2/status",a={},n={};e!==void 0&&(n.index=e.toString());let o={method:"GET",path:s,queryParameters:n,headers:a};return r.requestWithHttpInfo(o,t)},getTopCountries({index:e,startDate:t,endDate:s,limit:a,offset:n,tags:o},c){i("index","getTopCountries",e);let u="/2/countries",p={},q={};e!==void 0&&(q.index=e.toString()),t!==void 0&&(q.startDate=t.toString()),s!==void 0&&(q.endDate=s.toString()),a!==void 0&&(q.limit=a.toString()),n!==void 0&&(q.offset=n.toString()),o!==void 0&&(q.tags=o.toString());let l={method:"GET",path:u,queryParameters:q,headers:p};return r.request(l,c)},getTopCountriesWithHTTPInfo({index:e,startDate:t,endDate:s,limit:a,offset:n,tags:o},c){i("index","getTopCountriesWithHTTPInfo",e);let u="/2/countries",p={},q={};e!==void 0&&(q.index=e.toString()),t!==void 0&&(q.startDate=t.toString()),s!==void 0&&(q.endDate=s.toString()),a!==void 0&&(q.limit=a.toString()),n!==void 0&&(q.offset=n.toString()),o!==void 0&&(q.tags=o.toString());let l={method:"GET",path:u,queryParameters:q,headers:p};return r.requestWithHttpInfo(l,c)},getTopFilterAttributes({index:e,search:t,startDate:s,endDate:a,limit:n,offset:o,tags:c},u){i("index","getTopFilterAttributes",e);let p="/2/filters",q={},l={};e!==void 0&&(l.index=e.toString()),t!==void 0&&(l.search=t.toString()),s!==void 0&&(l.startDate=s.toString()),a!==void 0&&(l.endDate=a.toString()),n!==void 0&&(l.limit=n.toString()),o!==void 0&&(l.offset=o.toString()),c!==void 0&&(l.tags=c.toString());let y={method:"GET",path:p,queryParameters:l,headers:q};return r.request(y,u)},getTopFilterAttributesWithHTTPInfo({index:e,search:t,startDate:s,endDate:a,limit:n,offset:o,tags:c},u){i("index","getTopFilterAttributesWithHTTPInfo",e);let p="/2/filters",q={},l={};e!==void 0&&(l.index=e.toString()),t!==void 0&&(l.search=t.toString()),s!==void 0&&(l.startDate=s.toString()),a!==void 0&&(l.endDate=a.toString()),n!==void 0&&(l.limit=n.toString()),o!==void 0&&(l.offset=o.toString()),c!==void 0&&(l.tags=c.toString());let y={method:"GET",path:p,queryParameters:l,headers:q};return r.requestWithHttpInfo(y,u)},getTopFilterForAttribute({attribute:e,index:t,search:s,startDate:a,endDate:n,limit:o,offset:c,tags:u},p){i("attribute","getTopFilterForAttribute",e),i("index","getTopFilterForAttribute",t);let q="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),l={},y={};t!==void 0&&(y.index=t.toString()),s!==void 0&&(y.search=s.toString()),a!==void 0&&(y.startDate=a.toString()),n!==void 0&&(y.endDate=n.toString()),o!==void 0&&(y.limit=o.toString()),c!==void 0&&(y.offset=c.toString()),u!==void 0&&(y.tags=u.toString());let f={method:"GET",path:q,queryParameters:y,headers:l};return r.request(f,p)},getTopFilterForAttributeWithHTTPInfo({attribute:e,index:t,search:s,startDate:a,endDate:n,limit:o,offset:c,tags:u},p){i("attribute","getTopFilterForAttributeWithHTTPInfo",e),i("index","getTopFilterForAttributeWithHTTPInfo",t);let q="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),l={},y={};t!==void 0&&(y.index=t.toString()),s!==void 0&&(y.search=s.toString()),a!==void 0&&(y.startDate=a.toString()),n!==void 0&&(y.endDate=n.toString()),o!==void 0&&(y.limit=o.toString()),c!==void 0&&(y.offset=c.toString()),u!==void 0&&(y.tags=u.toString());let f={method:"GET",path:q,queryParameters:y,headers:l};return r.requestWithHttpInfo(f,p)},getTopFiltersNoResults({index:e,search:t,startDate:s,endDate:a,limit:n,offset:o,tags:c},u){i("index","getTopFiltersNoResults",e);let p="/2/filters/noResults",q={},l={};e!==void 0&&(l.index=e.toString()),t!==void 0&&(l.search=t.toString()),s!==void 0&&(l.startDate=s.toString()),a!==void 0&&(l.endDate=a.toString()),n!==void 0&&(l.limit=n.toString()),o!==void 0&&(l.offset=o.toString()),c!==void 0&&(l.tags=c.toString());let y={method:"GET",path:p,queryParameters:l,headers:q};return r.request(y,u)},getTopFiltersNoResultsWithHTTPInfo({index:e,search:t,startDate:s,endDate:a,limit:n,offset:o,tags:c},u){i("index","getTopFiltersNoResultsWithHTTPInfo",e);let p="/2/filters/noResults",q={},l={};e!==void 0&&(l.index=e.toString()),t!==void 0&&(l.search=t.toString()),s!==void 0&&(l.startDate=s.toString()),a!==void 0&&(l.endDate=a.toString()),n!==void 0&&(l.limit=n.toString()),o!==void 0&&(l.offset=o.toString()),c!==void 0&&(l.tags=c.toString());let y={method:"GET",path:p,queryParameters:l,headers:q};return r.requestWithHttpInfo(y,u)},getTopHits({index:e,search:t,clickAnalytics:s,revenueAnalytics:a,startDate:n,endDate:o,limit:c,offset:u,tags:p},q){i("index","getTopHits",e);let l="/2/hits",y={},f={};e!==void 0&&(f.index=e.toString()),t!==void 0&&(f.search=t.toString()),s!==void 0&&(f.clickAnalytics=s.toString()),a!==void 0&&(f.revenueAnalytics=a.toString()),n!==void 0&&(f.startDate=n.toString()),o!==void 0&&(f.endDate=o.toString()),c!==void 0&&(f.limit=c.toString()),u!==void 0&&(f.offset=u.toString()),p!==void 0&&(f.tags=p.toString());let S={method:"GET",path:l,queryParameters:f,headers:y};return r.request(S,q)},getTopHitsWithHTTPInfo({index:e,search:t,clickAnalytics:s,revenueAnalytics:a,startDate:n,endDate:o,limit:c,offset:u,tags:p},q){i("index","getTopHitsWithHTTPInfo",e);let l="/2/hits",y={},f={};e!==void 0&&(f.index=e.toString()),t!==void 0&&(f.search=t.toString()),s!==void 0&&(f.clickAnalytics=s.toString()),a!==void 0&&(f.revenueAnalytics=a.toString()),n!==void 0&&(f.startDate=n.toString()),o!==void 0&&(f.endDate=o.toString()),c!==void 0&&(f.limit=c.toString()),u!==void 0&&(f.offset=u.toString()),p!==void 0&&(f.tags=p.toString());let S={method:"GET",path:l,queryParameters:f,headers:y};return r.requestWithHttpInfo(S,q)},getTopSearches({index:e,clickAnalytics:t,revenueAnalytics:s,startDate:a,endDate:n,orderBy:o,direction:c,limit:u,offset:p,tags:q},l){i("index","getTopSearches",e);let y="/2/searches",f={},S={};e!==void 0&&(S.index=e.toString()),t!==void 0&&(S.clickAnalytics=t.toString()),s!==void 0&&(S.revenueAnalytics=s.toString()),a!==void 0&&(S.startDate=a.toString()),n!==void 0&&(S.endDate=n.toString()),o!==void 0&&(S.orderBy=o.toString()),c!==void 0&&(S.direction=c.toString()),u!==void 0&&(S.limit=u.toString()),p!==void 0&&(S.offset=p.toString()),q!==void 0&&(S.tags=q.toString());let H={method:"GET",path:y,queryParameters:S,headers:f};return r.request(H,l)},getTopSearchesWithHTTPInfo({index:e,clickAnalytics:t,revenueAnalytics:s,startDate:a,endDate:n,orderBy:o,direction:c,limit:u,offset:p,tags:q},l){i("index","getTopSearchesWithHTTPInfo",e);let y="/2/searches",f={},S={};e!==void 0&&(S.index=e.toString()),t!==void 0&&(S.clickAnalytics=t.toString()),s!==void 0&&(S.revenueAnalytics=s.toString()),a!==void 0&&(S.startDate=a.toString()),n!==void 0&&(S.endDate=n.toString()),o!==void 0&&(S.orderBy=o.toString()),c!==void 0&&(S.direction=c.toString()),u!==void 0&&(S.limit=u.toString()),p!==void 0&&(S.offset=p.toString()),q!==void 0&&(S.tags=q.toString());let H={method:"GET",path:y,queryParameters:S,headers:f};return r.requestWithHttpInfo(H,l)},getUsersCount({index:e,startDate:t,endDate:s,tags:a},n){i("index","getUsersCount",e);let o="/2/users/count",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.request(p,n)},getUsersCountWithHTTPInfo({index:e,startDate:t,endDate:s,tags:a},n){i("index","getUsersCountWithHTTPInfo",e);let o="/2/users/count",c={},u={};e!==void 0&&(u.index=e.toString()),t!==void 0&&(u.startDate=t.toString()),s!==void 0&&(u.endDate=s.toString()),a!==void 0&&(u.tags=a.toString());let p={method:"GET",path:o,queryParameters:u,headers:c};return r.requestWithHttpInfo(p,n)}}}function Ie(d,m,P,T){if(!d||typeof d!="string")throw new Error("`appId` is missing.");if(!m||typeof m!="string")throw new Error("`apiKey` is missing.");if(P&&(typeof P!="string"||!fe.includes(P)))throw new Error(`\`region\` must be one of the following: ${fe.join(", ")}`);let{compression:g,...I}=T||{};return it({appId:d,apiKey:m,region:P,timeouts:{connect:1e3,read:2e3,write:3e4},logger:b(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:W(),requestsCache:W({serializable:false}),hostsCache:R({caches:[C({key:`${ge}-${d}`}),W()]}),...I})}var Se="5.56.0",ye=["de","us"];function ct(d){return [{url:d?"insights.{region}.algolia.io".replace("{region}",d):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function ut({appId:d,apiKey:m,authMode:P,algoliaAgents:T,region:g,...I}){let h=E(d,m,P),r=A({hosts:ct(g),...I,algoliaAgent:D({algoliaAgents:T,client:"Insights",version:Se}),baseHeaders:{"content-type":"text/plain",...h.headers(),...I.baseHeaders},baseQueryParameters:{...h.queryParameters(),...I.baseQueryParameters}});return {transporter:r,appId:d,apiKey:m,clearCache(){return Promise.all([r.requestsCache.clear(),r.responsesCache.clear()]).then(()=>{})},get _ua(){return r.algoliaAgent.value},addAlgoliaAgent(e,t){r.algoliaAgent.add({segment:e,version:t});},setClientApiKey({apiKey:e}){!P||P==="WithinHeaders"?r.baseHeaders["x-algolia-api-key"]=e:r.baseQueryParameters["x-algolia-api-key"]=e;},customDelete({path:e,parameters:t},s){i("path","customDelete",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customDeleteWithHTTPInfo({path:e,parameters:t},s){i("path","customDeleteWithHTTPInfo",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customGet({path:e,parameters:t},s){i("path","customGet",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.request(c,s)},customGetWithHTTPInfo({path:e,parameters:t},s){i("path","customGetWithHTTPInfo",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return r.requestWithHttpInfo(c,s)},customPost({path:e,parameters:t,body:s},a){i("path","customPost",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPostWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPostWithHTTPInfo",e);let u={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},customPut({path:e,parameters:t,body:s},a){i("path","customPut",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.request(u,a)},customPutWithHTTPInfo({path:e,parameters:t,body:s},a){i("path","customPutWithHTTPInfo",e);let u={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:s||{}};return r.requestWithHttpInfo(u,a)},deleteUserToken({userToken:e},t){i("userToken","deleteUserToken",e);let o={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.request(o,t)},deleteUserTokenWithHTTPInfo({userToken:e},t){i("userToken","deleteUserTokenWithHTTPInfo",e);let o={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return r.requestWithHttpInfo(o,t)},pushEvents(e,t){i("insightsEvents","pushEvents",e),i("insightsEvents.events","pushEvents",e.events);let o={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return r.request(o,t)},pushEventsWithHTTPInfo(e,t){i("insightsEvents","pushEventsWithHTTPInfo",e),i("insightsEvents.events","pushEventsWithHTTPInfo",e.events);let o={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return r.requestWithHttpInfo(o,t)}}}function He(d,m,P,T){if(!d||typeof d!="string")throw new Error("`appId` is missing.");if(!m||typeof m!="string")throw new Error("`apiKey` is missing.");if(P&&(typeof P!="string"||!ye.includes(P)))throw new Error(`\`region\` must be one of the following: ${ye.join(", ")}`);let{compression:g,...I}=T||{};return ut({appId:d,apiKey:m,region:P,timeouts:{connect:1e3,read:2e3,write:3e4},logger:b(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:W(),requestsCache:W({serializable:false}),hostsCache:R({caches:[C({key:`${Se}-${d}`}),W()]}),...I})}var ve="5.56.0",We=["eu","us"];function ht(d){return [{url:"personalization.{region}.algolia.com