/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@algolia/client-personalization@5.50.1/dist/builds/browser.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-personalization"]={})}(this,(function(e){"use strict";function t(e){let t,r=`algolia-client-js-${e.key}`;function a(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function s(){return JSON.parse(a().getItem(r)||"{}")}function o(e){a().setItem(r,JSON.stringify(e))}return{get:(t,r,a={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){let t=e.timeToLive?1e3*e.timeToLive:null,r=s(),a=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));o(a),t&&o(Object.fromEntries(Object.entries(a).filter((([,e])=>{let r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),s()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||a.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{let o=s();return o[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},a().setItem(r,JSON.stringify(o)),t})),delete:e=>Promise.resolve().then((()=>{let t=s();delete t[JSON.stringify(e)],a().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{a().removeItem(r)}))}}function r(e){let t=[...e.caches],a=t.shift();return void 0===a?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,s,o={miss:()=>Promise.resolve()})=>a.get(e,s,o).catch((()=>r({caches:t}).get(e,s,o))),set:(e,s)=>a.set(e,s).catch((()=>r({caches:t}).set(e,s))),delete:e=>a.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>a.clear().catch((()=>r({caches:t}).clear()))}}function a(e={serializable:!0}){let t={};return{get(r,a,s={miss:()=>Promise.resolve()}){let o=JSON.stringify(r);if(o in t)return Promise.resolve(e.serializable?JSON.parse(t[o]):t[o]);let i=a();return i.then((e=>s.miss(e))).then((()=>i))},set:(r,a)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}function s({algoliaAgents:e,client:t,version:r}){let a=function(e){let t={value:`Algolia for JavaScript (${e})`,add(e){let r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>a.add(e))),a}var o=12e4;function i(e,t="up"){let r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>o},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=o}}}var n=class extends Error{name="AlgoliaError";constructor(e,t){super(e),t&&(this.name=t)}},l=class extends n{stackTrace;constructor(e,t,r){super(e,r),this.stackTrace=t}},u=class extends l{constructor(e){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",e,"RetryError")}},c=class extends l{status;constructor(e,t,r,a="ApiError"){super(e,r,a),this.status=t}},m=class extends n{response;constructor(e,t){super(e,"DeserializationError"),this.response=t}},h=class extends c{error;constructor(e,t,r,a){super(e,t,a,"DetailedApiError"),this.error=r}};function p(e,t,r){let a=function(e){return Object.keys(e).filter((t=>void 0!==e[t])).sort().map((t=>`${t}=${encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[t])?e[t].join(","):e[t]).replace(/\+/g,"%20")}`)).join("&")}(r),s=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return a.length&&(s+=`?${a}`),s}function d(e){let t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function g({hosts:e,hostsCache:t,baseHeaders:r,logger:a,baseQueryParameters:s,algoliaAgent:o,timeouts:n,requester:l,requestsCache:g,responsesCache:f,compress:y,compression:P}){async function w(g,f,w){let v=[],T=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;let r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(g,f),q=function(e,t,r){let a={Accept:"application/json",...e,...t,...r},s={};return Object.keys(a).forEach((e=>{let t=a[e];s[e.toLowerCase()]=t})),s}(r,g.headers,f.headers),b="gzip"===P&&void 0!==T&&T.length>750&&("POST"===g.method||"PUT"===g.method);b&&void 0===y&&a.info("Compression is disabled because no compress method is available.");let O=b&&void 0!==y,S=O?await y(T):T;O&&(q["content-encoding"]="gzip");let E="GET"===g.method?{...g.data,...f.data}:{},z={...s,...g.queryParameters,...E};if(o.value&&(z["x-algolia-agent"]=o.value),f&&f.queryParameters)for(let e of Object.keys(f.queryParameters))f.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(f.queryParameters[e])?z[e]=f.queryParameters[e].toString():z[e]=f.queryParameters[e];let k=0,A=async(e,r)=>{let s=e.pop();if(void 0===s)throw new u(function(e){return e.map((e=>d(e)))}(v));let o={...n,...f.timeouts},y={data:S,headers:q,method:g.method,url:p(s,g.path,z),connectTimeout:r(k,o.connect),responseTimeout:r(k,w?o.read:o.write)},P=t=>{let r={request:y,response:t,host:s,triesLeft:e.length};return v.push(r),r},T=await l.send(y);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&!~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(T)){let o=P(T);return T.isTimedOut&&k++,a.info("Retryable failure",d(o)),await t.set(s,i(s,T.isTimedOut?"timed out":"down")),A(e,r)}if(function({status:e}){return 2==~~(e/100)}(T))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(T);throw P(T),function({content:e,status:t},r){try{let a=JSON.parse(e);return"error"in a?new h(a.message,t,a.error,r):new c(a.message,t,r)}catch{}return new c(e,t,r)}(T,v)},C=e.filter((e=>"readWrite"===e.accept||(w?"read"===e.accept:"write"===e.accept))),j=await async function(e){let r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(i(e))))))),a=r.filter((e=>e.isUp())),s=r.filter((e=>e.isTimedOut())),o=[...a,...s];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===s.length&&0===e?1:s.length+3+e)*t}}(C);return A([...j.hosts].reverse(),j.getTimeout)}return{hostsCache:t,requester:l,timeouts:n,logger:a,algoliaAgent:o,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){let a=()=>w(e,t,o),o=e.useReadTransporter||"GET"===e.method;if(!0!==(t.cacheable||e.cacheable))return a();let i={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return f.get(i,(()=>g.get(i,(()=>g.set(i,a()).then((e=>Promise.all([g.delete(i),e])),(e=>Promise.all([g.delete(i),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>f.set(i,e)})},requestsCache:g,responsesCache:f}}var f="5.50.1",y=["eu","us"];function P(e){return[{url:"personalization.{region}.algolia.com".replace("{region}",e),accept:"readWrite",protocol:"https"}]}e.apiClientVersion=f,e.personalizationClient=function(e,o,i,n){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!o||"string"!=typeof o)throw new Error("`apiKey` is missing.");if(!i||i&&("string"!=typeof i||!y.includes(i)))throw new Error(`\`region\` is required and must be one of the following: ${y.join(", ")}`);let{compression:l,...u}=n||{};return function({appId:e,apiKey:t,authMode:r,algoliaAgents:a,region:o,...i}){let n=function(e,t,r="WithinHeaders"){let a={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?a:{},queryParameters:()=>"WithinQueryParameters"===r?a:{}}}(e,t,r),l=g({hosts:P(o),...i,algoliaAgent:s({algoliaAgents:a,client:"Personalization",version:f}),baseHeaders:{"content-type":"text/plain",...n.headers(),...i.baseHeaders},baseQueryParameters:{...n.queryParameters(),...i.baseQueryParameters}});return{transporter:l,appId:e,apiKey:t,clearCache:()=>Promise.all([l.requestsCache.clear(),l.responsesCache.clear()]).then((()=>{})),get _ua(){return l.algoliaAgent.value},addAlgoliaAgent(e,t){l.algoliaAgent.add({segment:e,version:t})},setClientApiKey({apiKey:e}){r&&"WithinHeaders"!==r?l.baseQueryParameters["x-algolia-api-key"]=e:l.baseHeaders["x-algolia-api-key"]=e},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let a={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return l.request(a,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let a={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return l.request(a,r)},customPost({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let s={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return l.request(s,a)},customPut({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let s={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return l.request(s,a)},deleteUserProfile({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let r={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return l.request(r,t)},getPersonalizationStrategy:e=>l.request({method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}},e),getUserTokenProfile({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let r={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return l.request(r,t)},setPersonalizationStrategy(e,t){if(!e)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!e.eventsScoring)throw new Error("Parameter `personalizationStrategyParams.eventsScoring` is required when calling `setPersonalizationStrategy`.");if(!e.facetsScoring)throw new Error("Parameter `personalizationStrategyParams.facetsScoring` is required when calling `setPersonalizationStrategy`.");if(!e.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let r={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:e};return l.request(r,t)}}}({appId:e,apiKey:o,region:i,timeouts:{connect:1e3,read:2e3,write:3e4},logger:{debug:(e,t)=>Promise.resolve(),info:(e,t)=>Promise.resolve(),error:(e,t)=>Promise.resolve()},requester:{send:function(e){return new Promise((t=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));let a,s=(e,a)=>setTimeout((()=>{r.abort(),t({status:0,content:a,isTimedOut:!0})}),e),o=s(e.connectTimeout,"Connection timeout");r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===a&&(clearTimeout(o),a=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(o),clearTimeout(a),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(o),clearTimeout(a),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:a(),requestsCache:a({serializable:!1}),hostsCache:r({caches:[t({key:`${f}-${e}`}),a()]}),...u})}}));
//# sourceMappingURL=/sm/79ede1efd3fd657ef99a7ae95ab8a0ef2bed731b61b110eb8240f83d6c0acf25.map