Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/client-abtesting

Package Overview
Dependencies
Maintainers
86
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-abtesting - npm Package Compare versions

Comparing version 5.5.3 to 5.6.0

2

dist/browser.d.ts

@@ -429,3 +429,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.5.3";
declare const apiClientVersion = "5.6.0";
declare const REGIONS: readonly ["de", "us"];

@@ -432,0 +432,0 @@ type Region = (typeof REGIONS)[number];

// builds/browser.ts
import {
createNullLogger,
createMemoryCache,

@@ -14,3 +15,3 @@ createFallbackableCache,

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.5.3";
var apiClientVersion = "5.6.0";
var REGIONS = ["de", "us"];

@@ -390,2 +391,3 @@ function getDefaultHosts(region) {

},
logger: createNullLogger(),
requester: createXhrRequester(),

@@ -392,0 +394,0 @@ algoliaAgents: [{ segment: "Browser" }],

@@ -1,2 +0,2 @@

function L(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function W(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function n(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a))}function f(){let a=t.timeToLive?t.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(i),!a)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let l=new Date().getTime();return!(d.timestamp+a<l)}));m(u)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(f(),n()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function Y(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,n,m={miss:()=>Promise.resolve()}){return s.get(r,n,m).catch(()=>E({caches:e}).get(r,n,m))},set(r,n){return s.set(r,n).catch(()=>E({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>E({caches:e}).delete(r))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return{get(s,r,n={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let f=r();return f.then(a=>n.miss(a)).then(()=>f)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var k=2*60*1e3;function H(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>k}function n(){return e==="timed out"&&Date.now()-s<=k}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var $=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},j=class extends ${stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Z=class extends j{constructor(t){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",t,"RetryError")}},x=class extends j{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},ee=class extends ${response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},te=class extends x{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function re(t,e,s){let r=se(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function se(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function oe(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ae(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(m=>{let f=r[m];n[m.toLowerCase()]=f}),n}function ne(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new te(r.message,e,r.error,s):new x(r.message,e,s)}catch{}return new x(t,e,s)}function ce({isTimedOut:t,status:e}){return!t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return~~(t/100)===2}function me(t){return t.map(e=>J(e))}function J(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function Q({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:m,requester:f,requestsCache:a,responsesCache:o}){async function i(l){let c=await Promise.all(l.map(p=>e.get(p,()=>Promise.resolve(H(p))))),P=c.filter(p=>p.isUp()),h=c.filter(p=>p.isTimedOut()),q=[...P,...h];return{hosts:q.length>0?q:l,getTimeout(p,y){return(h.length===0&&p===0?1:h.length+3+p)*y}}}async function u(l,c,P=!0){let h=[],q=oe(l,c),T=ae(s,l.headers,c.headers),p=l.method==="GET"?{...l.data,...c.data}:{},y={...r,...l.queryParameters,...p};if(n.value&&(y["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let g of Object.keys(c.queryParameters))!c.queryParameters[g]||Object.prototype.toString.call(c.queryParameters[g])==="[object Object]"?y[g]=c.queryParameters[g]:y[g]=c.queryParameters[g].toString();let R=0,D=async(g,S)=>{let w=g.pop();if(w===void 0)throw new Z(me(h));let B={...m,...c.timeouts},_={data:q,headers:T,method:l.method,url:re(w,l.path,y),connectTimeout:S(R,B.connect),responseTimeout:S(R,P?B.read:B.write)},I=b=>{let U={request:_,response:b,host:w,triesLeft:g.length};return h.push(U),U},A=await f.send(_);if(ue(A)){let b=I(A);return A.isTimedOut&&R++,console.log("Retryable failure",J(b)),await e.set(w,H(w,A.isTimedOut?"timed out":"down")),D(g,S)}if(le(A))return ne(A);throw I(A),ie(A,h)},V=t.filter(g=>g.accept==="readWrite"||(P?g.accept==="read":g.accept==="write")),N=await i(V);return D([...N.hosts].reverse(),N.getTimeout)}function d(l,c={}){let P=l.useReadTransporter||l.method==="GET";if(!P)return u(l,c,P);let h=()=>u(l,c);if((c.cacheable||l.cacheable)!==!0)return h();let T={request:l,requestOptions:c,transporter:{queryParameters:r,headers:s}};return o.get(T,()=>a.get(T,()=>a.set(T,h()).then(p=>Promise.all([a.delete(T),p]),p=>Promise.all([a.delete(T),Promise.reject(p)])).then(([p,y])=>y)),{miss:p=>o.set(T,p)})}return{hostsCache:e,requester:f,timeouts:m,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:d,requestsCache:a,responsesCache:o}}function de(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function G({algoliaAgents:t,client:e,version:s}){let r=de(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var M=1e3,z=2e3,F=3e4;function X(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0})},a),m=n(e.connectTimeout,"Connection timeout"),f;r.onreadystatechange=()=>{r.readyState>r.OPENED&&f===void 0&&(clearTimeout(m),f=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(f),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(m),clearTimeout(f),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var v="5.5.3",C=["de","us"];function he(t){return[{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:n,...m}){let f=L(t,e,s),a=Q({hosts:he(n),...m,algoliaAgent:G({algoliaAgents:r,client:"Abtesting",version:v}),baseHeaders:{"content-type":"text/plain",...f.headers(),...m.baseHeaders},baseQueryParameters:{...f.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},addABTests(o,i){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,i)},customDelete({path:o,parameters:i},u){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let P={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(P,u)},customGet({path:o,parameters:i},u){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let P={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(P,u)},customPost({path:o,parameters:i,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let h={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:u||{}};return a.request(h,d)},customPut({path:o,parameters:i,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let h={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:u||{}};return a.request(h,d)},deleteABTest({id:o},i){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},getABTest({id:o},i){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},listABTests({offset:o,limit:i,indexPrefix:u,indexSuffix:d}={},l=void 0){let c="/2/abtests",P={},h={};o!==void 0&&(h.offset=o.toString()),i!==void 0&&(h.limit=i.toString()),u!==void 0&&(h.indexPrefix=u.toString()),d!==void 0&&(h.indexSuffix=d.toString());let q={method:"GET",path:c,queryParameters:h,headers:P};return a.request(q,l)},scheduleABTest(o,i){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,i)},stopABTest({id:o},i){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)}}}function Ke(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!C.includes(s)))throw new Error(`\`region\` must be one of the following: ${C.join(", ")}`);return K({appId:t,apiKey:e,region:s,timeouts:{connect:M,read:z,write:F},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:E({caches:[W({key:`${v}-${t}`}),O()]}),...r})}export{Ke as abtestingClient,v as apiClientVersion};
function W(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a))}function p(){let a=t.timeToLive?t.timeToLive*1e3:null,o=i(),n=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let u=Object.fromEntries(Object.entries(n).filter(([,d])=>{let P=new Date().getTime();return!(d.timestamp+a<P)}));m(u)}return{get(a,o,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||n.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(n)),o})},delete(a){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function ee(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>q({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>q({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>q({caches:e}).delete(r))},clear(){return s.clear().catch(()=>q({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return{get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(a=>i.miss(a)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var $=1e3,j=2e3,J=3e4;function te(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function Q(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function G({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function M(){return{debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var k=2*60*1e3;function H(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>k}function i(){return e==="timed out"&&Date.now()-s<=k}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var z=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},F=class extends z{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},re=class extends F{constructor(t){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",t,"RetryError")}},C=class extends F{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},se=class extends z{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function ie(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ce(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p}),i}function ue(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return!t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return~~(t/100)===2}function pe(t){return t.map(e=>X(e))}function X(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function K({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:o,responsesCache:n}){async function u(c){let l=await Promise.all(c.map(h=>e.get(h,()=>Promise.resolve(H(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),w=[...f,...T];return{hosts:w.length>0?w:c,getTimeout(h,A){return(T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(c,l,f=!0){let T=[],w=ie(c,l),y=ce(s,c.headers,l.headers),h=c.method==="GET"?{...c.data,...l.data}:{},A={...i,...c.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let g of Object.keys(l.queryParameters))!l.queryParameters[g]||Object.prototype.toString.call(l.queryParameters[g])==="[object Object]"?A[g]=l.queryParameters[g]:A[g]=l.queryParameters[g].toString();let v=0,N=async(g,b)=>{let R=g.pop();if(R===void 0)throw new re(pe(T));let B={...p,...l.timeouts},I={data:w,headers:y,method:c.method,url:ae(R,c.path,A),connectTimeout:b(v,B.connect),responseTimeout:b(v,f?B.read:B.write)},U=x=>{let L={request:I,response:x,host:R,triesLeft:g.length};return T.push(L),L},E=await a.send(I);if(de(E)){let x=U(E);return E.isTimedOut&&v++,r.info("Retryable failure",X(x)),await e.set(R,H(R,E.isTimedOut?"timed out":"down")),N(g,b)}if(he(E))return ue(E);throw U(E),le(E,T)},Z=t.filter(g=>g.accept==="readWrite"||(f?g.accept==="read":g.accept==="write")),D=await u(Z);return N([...D.hosts].reverse(),D.getTimeout)}function P(c,l={}){let f=c.useReadTransporter||c.method==="GET";if(!f)return d(c,l,f);let T=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return T();let y={request:c,requestOptions:l,transporter:{queryParameters:i,headers:s}};return n.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>n.set(y,h)})}return{hostsCache:e,requester:a,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:P,requestsCache:o,responsesCache:n}}function V(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let i=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0})},a),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var S="5.6.0",_=["de","us"];function fe(t){return[{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=Q(t,e,s),a=K({hosts:fe(i),...m,algoliaAgent:G({algoliaAgents:r,client:"Abtesting",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,n){a.algoliaAgent.add({segment:o,version:n})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},addABTests(o,n){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,n)},customDelete({path:o,parameters:n},u){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return a.request(l,u)},customGet({path:o,parameters:n},u){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return a.request(l,u)},customPost({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},customPut({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},deleteABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},getABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},listABTests({offset:o,limit:n,indexPrefix:u,indexSuffix:d}={},P=void 0){let c="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),n!==void 0&&(f.limit=n.toString()),u!==void 0&&(f.indexPrefix=u.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:c,queryParameters:f,headers:l};return a.request(T,P)},scheduleABTest(o,n){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,n)},stopABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)}}}function Ye(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:$,read:j,write:J},logger:M(),requester:V(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:q({caches:[W({key:`${S}-${t}`}),O()]}),...r})}export{Ye as abtestingClient,S as apiClientVersion};
//# sourceMappingURL=browser.min.js.map

@@ -7,7 +7,7 @@ (function (global, factory) {

function L(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return {headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function W(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function n(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a));}function f(){let a=t.timeToLive?t.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(i),!a)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let l=new Date().getTime();return !(d.timestamp+a<l)}));m(u);}return {get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(f(),n()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function Y(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,n,m={miss:()=>Promise.resolve()}){return s.get(r,n,m).catch(()=>E({caches:e}).get(r,n,m))},set(r,n){return s.set(r,n).catch(()=>E({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>E({caches:e}).delete(r))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return {get(s,r,n={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let f=r();return f.then(a=>n.miss(a)).then(()=>f)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var k=2*60*1e3;function H(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>k}function n(){return e==="timed out"&&Date.now()-s<=k}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var $=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},j=class extends ${stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},Z=class extends j{constructor(t){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",t,"RetryError");}},x=class extends j{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},ee=class extends ${response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},te=class extends x{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function re(t,e,s){let r=se(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function se(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function oe(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ae(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(m=>{let f=r[m];n[m.toLowerCase()]=f;}),n}function ne(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new te(r.message,e,r.error,s):new x(r.message,e,s)}catch{}return new x(t,e,s)}function ce({isTimedOut:t,status:e}){return !t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return ~~(t/100)===2}function me(t){return t.map(e=>J(e))}function J(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function Q({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:m,requester:f,requestsCache:a,responsesCache:o}){async function i(l){let c=await Promise.all(l.map(p=>e.get(p,()=>Promise.resolve(H(p))))),P=c.filter(p=>p.isUp()),h=c.filter(p=>p.isTimedOut()),q=[...P,...h];return {hosts:q.length>0?q:l,getTimeout(p,y){return (h.length===0&&p===0?1:h.length+3+p)*y}}}async function u(l,c,P=!0){let h=[],q=oe(l,c),T=ae(s,l.headers,c.headers),p=l.method==="GET"?{...l.data,...c.data}:{},y={...r,...l.queryParameters,...p};if(n.value&&(y["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let g of Object.keys(c.queryParameters))!c.queryParameters[g]||Object.prototype.toString.call(c.queryParameters[g])==="[object Object]"?y[g]=c.queryParameters[g]:y[g]=c.queryParameters[g].toString();let R=0,D=async(g,S)=>{let w=g.pop();if(w===void 0)throw new Z(me(h));let B={...m,...c.timeouts},_={data:q,headers:T,method:l.method,url:re(w,l.path,y),connectTimeout:S(R,B.connect),responseTimeout:S(R,P?B.read:B.write)},I=b=>{let U={request:_,response:b,host:w,triesLeft:g.length};return h.push(U),U},A=await f.send(_);if(ue(A)){let b=I(A);return A.isTimedOut&&R++,console.log("Retryable failure",J(b)),await e.set(w,H(w,A.isTimedOut?"timed out":"down")),D(g,S)}if(le(A))return ne(A);throw I(A),ie(A,h)},V=t.filter(g=>g.accept==="readWrite"||(P?g.accept==="read":g.accept==="write")),N=await i(V);return D([...N.hosts].reverse(),N.getTimeout)}function d(l,c={}){let P=l.useReadTransporter||l.method==="GET";if(!P)return u(l,c,P);let h=()=>u(l,c);if((c.cacheable||l.cacheable)!==!0)return h();let T={request:l,requestOptions:c,transporter:{queryParameters:r,headers:s}};return o.get(T,()=>a.get(T,()=>a.set(T,h()).then(p=>Promise.all([a.delete(T),p]),p=>Promise.all([a.delete(T),Promise.reject(p)])).then(([p,y])=>y)),{miss:p=>o.set(T,p)})}return {hostsCache:e,requester:f,timeouts:m,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:d,requestsCache:a,responsesCache:o}}function de(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function G({algoliaAgents:t,client:e,version:s}){let r=de(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var M=1e3,z=2e3,F=3e4;function X(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0});},a),m=n(e.connectTimeout,"Connection timeout"),f;r.onreadystatechange=()=>{r.readyState>r.OPENED&&f===void 0&&(clearTimeout(m),f=n(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(f),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(m),clearTimeout(f),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}var v="5.5.3",C=["de","us"];function he(t){return [{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:n,...m}){let f=L(t,e,s),a=Q({hosts:he(n),...m,algoliaAgent:G({algoliaAgents:r,client:"Abtesting",version:v}),baseHeaders:{"content-type":"text/plain",...f.headers(),...m.baseHeaders},baseQueryParameters:{...f.queryParameters(),...m.baseQueryParameters}});return {transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o;},addABTests(o,i){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,i)},customDelete({path:o,parameters:i},u){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let P={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(P,u)},customGet({path:o,parameters:i},u){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let P={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(P,u)},customPost({path:o,parameters:i,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let h={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:u||{}};return a.request(h,d)},customPut({path:o,parameters:i,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let h={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:u||{}};return a.request(h,d)},deleteABTest({id:o},i){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},getABTest({id:o},i){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},listABTests({offset:o,limit:i,indexPrefix:u,indexSuffix:d}={},l=void 0){let c="/2/abtests",P={},h={};o!==void 0&&(h.offset=o.toString()),i!==void 0&&(h.limit=i.toString()),u!==void 0&&(h.indexPrefix=u.toString()),d!==void 0&&(h.indexSuffix=d.toString());let q={method:"GET",path:c,queryParameters:h,headers:P};return a.request(q,l)},scheduleABTest(o,i){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,i)},stopABTest({id:o},i){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)}}}function Ke(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!C.includes(s)))throw new Error(`\`region\` must be one of the following: ${C.join(", ")}`);return K({appId:t,apiKey:e,region:s,timeouts:{connect:M,read:z,write:F},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:E({caches:[W({key:`${v}-${t}`}),O()]}),...r})}
function W(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a));}function p(){let a=t.timeToLive?t.timeToLive*1e3:null,o=i(),n=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let u=Object.fromEntries(Object.entries(n).filter(([,d])=>{let P=new Date().getTime();return !(d.timestamp+a<P)}));m(u);}return {get(a,o,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||n.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(n)),o})},delete(a){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function ee(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>q({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>q({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>q({caches:e}).delete(r))},clear(){return s.clear().catch(()=>q({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return {get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(a=>i.miss(a)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var $=1e3,j=2e3,J=3e4;function te(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function Q(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return {headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function G({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function M(){return {debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var k=2*60*1e3;function H(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>k}function i(){return e==="timed out"&&Date.now()-s<=k}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var z=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},F=class extends z{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},re=class extends F{constructor(t){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",t,"RetryError");}},C=class extends F{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},se=class extends z{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function ie(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ce(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p;}),i}function ue(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return !t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return ~~(t/100)===2}function pe(t){return t.map(e=>X(e))}function X(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function K({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:o,responsesCache:n}){async function u(c){let l=await Promise.all(c.map(h=>e.get(h,()=>Promise.resolve(H(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),w=[...f,...T];return {hosts:w.length>0?w:c,getTimeout(h,A){return (T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(c,l,f=!0){let T=[],w=ie(c,l),y=ce(s,c.headers,l.headers),h=c.method==="GET"?{...c.data,...l.data}:{},A={...i,...c.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let g of Object.keys(l.queryParameters))!l.queryParameters[g]||Object.prototype.toString.call(l.queryParameters[g])==="[object Object]"?A[g]=l.queryParameters[g]:A[g]=l.queryParameters[g].toString();let v=0,N=async(g,b)=>{let R=g.pop();if(R===void 0)throw new re(pe(T));let B={...p,...l.timeouts},I={data:w,headers:y,method:c.method,url:ae(R,c.path,A),connectTimeout:b(v,B.connect),responseTimeout:b(v,f?B.read:B.write)},U=x=>{let L={request:I,response:x,host:R,triesLeft:g.length};return T.push(L),L},E=await a.send(I);if(de(E)){let x=U(E);return E.isTimedOut&&v++,r.info("Retryable failure",X(x)),await e.set(R,H(R,E.isTimedOut?"timed out":"down")),N(g,b)}if(he(E))return ue(E);throw U(E),le(E,T)},Z=t.filter(g=>g.accept==="readWrite"||(f?g.accept==="read":g.accept==="write")),D=await u(Z);return N([...D.hosts].reverse(),D.getTimeout)}function P(c,l={}){let f=c.useReadTransporter||c.method==="GET";if(!f)return d(c,l,f);let T=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return T();let y={request:c,requestOptions:l,transporter:{queryParameters:i,headers:s}};return n.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>n.set(y,h)})}return {hostsCache:e,requester:a,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:P,requestsCache:o,responsesCache:n}}function V(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let i=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0});},a),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}var S="5.6.0",_=["de","us"];function fe(t){return [{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=Q(t,e,s),a=K({hosts:fe(i),...m,algoliaAgent:G({algoliaAgents:r,client:"Abtesting",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return {transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,n){a.algoliaAgent.add({segment:o,version:n});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o;},addABTests(o,n){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,n)},customDelete({path:o,parameters:n},u){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return a.request(l,u)},customGet({path:o,parameters:n},u){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return a.request(l,u)},customPost({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},customPut({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},deleteABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},getABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},listABTests({offset:o,limit:n,indexPrefix:u,indexSuffix:d}={},P=void 0){let c="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),n!==void 0&&(f.limit=n.toString()),u!==void 0&&(f.indexPrefix=u.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:c,queryParameters:f,headers:l};return a.request(T,P)},scheduleABTest(o,n){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,n)},stopABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)}}}function Ye(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:$,read:j,write:J},logger:M(),requester:V(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:q({caches:[W({key:`${S}-${t}`}),O()]}),...r})}
exports.abtestingClient = Ke;
exports.apiClientVersion = v;
exports.abtestingClient = Ye;
exports.apiClientVersion = S;
}));
// builds/fetch.ts
import {
createNullLogger,
createMemoryCache,

@@ -13,3 +14,3 @@ createNullCache,

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.5.3";
var apiClientVersion = "5.6.0";
var REGIONS = ["de", "us"];

@@ -390,2 +391,3 @@ function getDefaultHosts(region) {

},
logger: createNullLogger(),
algoliaAgents: [{ segment: "Fetch" }],

@@ -392,0 +394,0 @@ requester: createFetchRequester(),

// builds/node.ts
import {
createNullLogger,
createMemoryCache,

@@ -13,3 +14,3 @@ createNullCache,

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.5.3";
var apiClientVersion = "5.6.0";
var REGIONS = ["de", "us"];

@@ -390,2 +391,3 @@ function getDefaultHosts(region) {

},
logger: createNullLogger(),
requester: createHttpRequester(),

@@ -392,0 +394,0 @@ algoliaAgents: [{ segment: "Node.js", version: process.versions.node }],

@@ -429,3 +429,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.5.3";
declare const apiClientVersion = "5.6.0";
declare const REGIONS: readonly ["de", "us"];

@@ -432,0 +432,0 @@ type Region = (typeof REGIONS)[number];

@@ -429,3 +429,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.5.3";
declare const apiClientVersion = "5.6.0";
declare const REGIONS: readonly ["de", "us"];

@@ -432,0 +432,0 @@ type Region = (typeof REGIONS)[number];

// src/abtestingClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.5.3";
var apiClientVersion = "5.6.0";
var REGIONS = ["de", "us"];

@@ -5,0 +5,0 @@ function getDefaultHosts(region) {

{
"version": "5.5.3",
"version": "5.6.0",
"repository": {

@@ -52,12 +52,12 @@ "type": "git",

"dependencies": {
"@algolia/client-common": "5.5.3",
"@algolia/requester-browser-xhr": "5.5.3",
"@algolia/requester-fetch": "5.5.3",
"@algolia/requester-node-http": "5.5.3"
"@algolia/client-common": "5.6.0",
"@algolia/requester-browser-xhr": "5.6.0",
"@algolia/requester-fetch": "5.6.0",
"@algolia/requester-node-http": "5.6.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@types/node": "22.5.5",
"publint": "0.2.11",
"rollup": "4.21.3",
"rollup": "4.22.4",
"tsup": "8.3.0",

@@ -64,0 +64,0 @@ "typescript": "5.6.2"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc