/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@algolia/recommend@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/recommend"]={})}(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 o(){return JSON.parse(a().getItem(r)||"{}")}function s(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=o(),a=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));s(a),t&&s(Object.fromEntries(Object.entries(a).filter((([,e])=>{let r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),o()[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 s=o();return s[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},a().setItem(r,JSON.stringify(s)),t})),delete:e=>Promise.resolve().then((()=>{let t=o();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,o,s={miss:()=>Promise.resolve()})=>a.get(e,o,s).catch((()=>r({caches:t}).get(e,o,s))),set:(e,o)=>a.set(e,o).catch((()=>r({caches:t}).set(e,o))),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,o={miss:()=>Promise.resolve()}){let s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);let n=a();return n.then((e=>o.miss(e))).then((()=>n))},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 o({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 s=12e4;function n(e,t="up"){let r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>s},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=s}}}var i=class extends Error{name="AlgoliaError";constructor(e,t){super(e),t&&(this.name=t)}},l=class extends i{stackTrace;constructor(e,t,r){super(e,r),this.stackTrace=t}},c=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")}},m=class extends l{status;constructor(e,t,r,a="ApiError"){super(e,r,a),this.status=t}},u=class extends i{response;constructor(e,t){super(e,"DeserializationError"),this.response=t}},d=class extends m{error;constructor(e,t,r,a){super(e,t,a,"DetailedApiError"),this.error=r}};function h(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),o=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return a.length&&(o+=`?${a}`),o}function p(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:o,algoliaAgent:s,timeouts:i,requester:l,requestsCache:g,responsesCache:f,compress:w,compression:P}){async function y(g,f,y){let q=[],R=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),b=function(e,t,r){let a={Accept:"application/json",...e,...t,...r},o={};return Object.keys(a).forEach((e=>{let t=a[e];o[e.toLowerCase()]=t})),o}(r,g.headers,f.headers),v="gzip"===P&&void 0!==R&&R.length>750&&("POST"===g.method||"PUT"===g.method);v&&void 0===w&&a.info("Compression is disabled because no compress method is available.");let T=v&&void 0!==w,x=T?await w(R):R;T&&(b["content-encoding"]="gzip");let E="GET"===g.method?{...g.data,...f.data}:{},O={...o,...g.queryParameters,...E};if(s.value&&(O["x-algolia-agent"]=s.value),f&&f.queryParameters)for(let e of Object.keys(f.queryParameters))f.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(f.queryParameters[e])?O[e]=f.queryParameters[e].toString():O[e]=f.queryParameters[e];let N=0,I=async(e,r)=>{let o=e.pop();if(void 0===o)throw new c(function(e){return e.map((e=>p(e)))}(q));let s={...i,...f.timeouts},w={data:x,headers:b,method:g.method,url:h(o,g.path,O),connectTimeout:r(N,s.connect),responseTimeout:r(N,y?s.read:s.write)},P=t=>{let r={request:w,response:t,host:o,triesLeft:e.length};return q.push(r),r},R=await l.send(w);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)}(R)){let s=P(R);return R.isTimedOut&&N++,a.info("Retryable failure",p(s)),await t.set(o,n(o,R.isTimedOut?"timed out":"down")),I(e,r)}if(function({status:e}){return 2==~~(e/100)}(R))return function(e){try{return JSON.parse(e.content)}catch(t){throw new u(t.message,e)}}(R);throw P(R),function({content:e,status:t},r){try{let a=JSON.parse(e);return"error"in a?new d(a.message,t,a.error,r):new m(a.message,t,r)}catch{}return new m(e,t,r)}(R,q)},S=e.filter((e=>"readWrite"===e.accept||(y?"read"===e.accept:"write"===e.accept))),C=await async function(e){let r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),a=r.filter((e=>e.isUp())),o=r.filter((e=>e.isTimedOut())),s=[...a,...o];return{hosts:s.length>0?s:e,getTimeout:(e,t)=>(0===o.length&&0===e?1:o.length+3+e)*t}}(S);return I([...C.hosts].reverse(),C.getTimeout)}return{hostsCache:t,requester:l,timeouts:i,logger:a,algoliaAgent:s,baseHeaders:r,baseQueryParameters:o,hosts:e,request:function(e,t={}){let a=()=>y(e,t,s),s=e.useReadTransporter||"GET"===e.method;if(!0!==(t.cacheable||e.cacheable))return a();let n={request:e,requestOptions:t,transporter:{queryParameters:o,headers:r}};return f.get(n,(()=>g.get(n,(()=>g.set(n,a()).then((e=>Promise.all([g.delete(n),e])),(e=>Promise.all([g.delete(n),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>f.set(n,e)})},requestsCache:g,responsesCache:f}}var f="5.50.1";function w(e){return[{url:`${e}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${e}.algolia.net`,accept:"write",protocol:"https"}].concat(function(e){let t=e;for(let r=e.length-1;r>0;r--){let a=Math.floor(Math.random()*(r+1)),o=e[r];t[r]=e[a],t[a]=o}return t}([{url:`${e}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}e.apiClientVersion=f,e.recommendClient=function(e,s,n){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!s||"string"!=typeof s)throw new Error("`apiKey` is missing.");let{compression:i,...l}=n||{};return function({appId:e,apiKey:t,authMode:r,algoliaAgents:a,...s}){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),i=g({hosts:w(e),...s,algoliaAgent:o({algoliaAgents:a,client:"Recommend",version:f}),baseHeaders:{"content-type":"text/plain",...n.headers(),...s.baseHeaders},baseQueryParameters:{...n.queryParameters(),...s.baseQueryParameters}});return{transporter:i,appId:e,apiKey:t,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},setClientApiKey({apiKey:e}){r&&"WithinHeaders"!==r?i.baseQueryParameters["x-algolia-api-key"]=e:i.baseHeaders["x-algolia-api-key"]=e},batchRecommendRules({indexName:e,model:t,recommendRule:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `batchRecommendRules`.");if(!t)throw new Error("Parameter `model` is required when calling `batchRecommendRules`.");let o={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)),queryParameters:{},headers:{},data:r||{}};return i.request(o,a)},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 i.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 i.request(a,r)},customPost({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let o={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(o,a)},customPut({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let o={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(o,a)},deleteRecommendRule({indexName:e,model:t,objectID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteRecommendRule`.");if(!t)throw new Error("Parameter `model` is required when calling `deleteRecommendRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteRecommendRule`.");let o={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return i.request(o,a)},getRecommendRule({indexName:e,model:t,objectID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getRecommendRule`.");if(!t)throw new Error("Parameter `model` is required when calling `getRecommendRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getRecommendRule`.");let o={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return i.request(o,a)},getRecommendStatus({indexName:e,model:t,taskID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getRecommendStatus`.");if(!t)throw new Error("Parameter `model` is required when calling `getRecommendStatus`.");if(!r)throw new Error("Parameter `taskID` is required when calling `getRecommendStatus`.");let o={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{taskID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return i.request(o,a)},getRecommendations(e,t){if(e&&Array.isArray(e)&&(e={requests:e}),!e)throw new Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!e.requests)throw new Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");let r={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return i.request(r,t)},searchRecommendRules({indexName:e,model:t,searchRecommendRulesParams:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `searchRecommendRules`.");if(!t)throw new Error("Parameter `model` is required when calling `searchRecommendRules`.");let o={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return i.request(o,a)}}}({appId:e,apiKey:s,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,o=(e,a)=>setTimeout((()=>{r.abort(),t({status:0,content:a,isTimedOut:!0})}),e),s=o(e.connectTimeout,"Connection timeout");r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===a&&(clearTimeout(s),a=o(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(s),clearTimeout(a),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(s),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()]}),...l})}}));
//# sourceMappingURL=/sm/54437d35094dca1625696e5c36d0ca3801ff5f4e812baf6cc8b24c59ac41aeff.map