/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/@algolia/recommend@5.55.2/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 s(){return JSON.parse(a().getItem(r)||"{}")}function n(){return new Promise(e=>setTimeout(e,0))}return{get:(t,o,i={miss:()=>Promise.resolve()})=>n().then(()=>{let{namespace:n,changed:l}=function(){let t=e.timeToLive?1e3*e.timeToLive:null,r=s(),a=(new Date).getTime(),n=!1;return{namespace:Object.fromEntries(Object.entries(r).filter(([,e])=>!(!e||void 0===e.timestamp||t&&e.timestamp+t<a)||(n=!0,!1))),changed:n}}(),c=n[JSON.stringify(t)];return l&&function(e){a().setItem(r,JSON.stringify(e))}(n),c?c.value:o().then(e=>i.miss(e).then(()=>e))}),set:(e,t)=>n().then(()=>{let n=s();return n[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},a().setItem(r,JSON.stringify(n)),t}),delete:e=>n().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,n={miss:()=>Promise.resolve()})=>a.get(e,s,n).catch(()=>r({caches:t}).get(e,s,n)),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 n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);let o=a();return o.then(e=>s.miss(e)).then(()=>o)},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}async function*n(e){let t=new TextDecoder("utf-8"),r=[],a=0,s=!1,n=!0;for await(let o of function(e){return Symbol.asyncIterator in e?e:async function*(e){let t=e.getReader();try{for(;;){let{done:e,value:r}=await t.read();if(e)return;yield r}}finally{t.releaseLock()}}(e)}(e)){let e=t.decode(o,{stream:!0}),i=0;for(s&&(s=!1,e.length>0&&"\n"===e[0]&&(i=1));i<e.length;){let t,o,l=e.indexOf("\r",i),c=e.indexOf("\n",i);if(-1===l&&-1===c){let t=e.slice(i);if(r.push(t),a+=t.length,a>10485760)throw new Error("SSE line buffer exceeded 10MB");break}-1!==l&&(-1===c||l<c)?(t=l,l+1<e.length?o="\n"===e[l+1]?2:1:(s=!0,o=1)):(t=c,o=1);let u=e.slice(i,t);r.push(u);let d=1===r.length?r[0]:r.join("");r.length=0,a=0,n&&(d.startsWith("\ufeff")&&(d=d.slice(1)),n=!1),yield d,i=t+o}}let o=t.decode();if(o&&r.push(o),r.length>0){let e=r.join("");n&&e.startsWith("\ufeff")&&(e=e.slice(1)),yield e}}var o=class{data=[];eventType="";lastEventId=null;retry=null;decode(e){if(""===e)return this.dispatch();if(":"===e[0])return null;let t,r,a=e.indexOf(":");switch(-1===a?(t=e,r=""):(t=e.slice(0,a),r=e.slice(a+1)," "===r[0]&&(r=r.slice(1))),t){case"data":this.data.push(r);break;case"event":this.eventType=r;break;case"id":r.includes("\0")||(this.lastEventId=r);break;case"retry":/^[0-9]+$/.test(r)&&(this.retry=parseInt(r,10))}return null}dispatch(){let e=this.eventType;if(this.eventType="",0===this.data.length)return null;let t={data:this.data.join("\n"),event:e,id:this.lastEventId,retry:this.retry};return this.data=[],t}};var i=12e4;function l(e,t="up"){let r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>i},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=i}}}var c=class extends Error{name="AlgoliaError";constructor(e,t){super(e),t&&(this.name=t)}},u=class extends c{stackTrace;constructor(e,t,r){super(e,r),this.stackTrace=t}},d=class extends u{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 u{status;constructor(e,t,r,a="ApiError"){super(e,r,a),this.status=t}},h=class extends c{response;constructor(e,t){super(e,"DeserializationError"),this.response=t}},p=class extends m{error;constructor(e,t,r,a){super(e,t,a,"DetailedApiError"),this.error=r}};function g(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 f(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)}function y(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}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 v({hosts:e,hostsCache:t,baseHeaders:r,logger:a,baseQueryParameters:s,algoliaAgent:i,timeouts:c,requester:u,requestsCache:v,responsesCache:b,compress:R,compression:T}){async function q(e){let r=await Promise.all(e.map(e=>t.get(e,()=>Promise.resolve(l(e))))),a=r.filter(e=>e.isUp()),s=r.filter(e=>e.isTimedOut()),n=[...a,...s];return{hosts:n.length>0?n:e,getTimeout:(e,t)=>(0===s.length&&0===e?1:s.length+3+e)*t}}async function w(n,o,v){let b=[],w=f(n,o),x=y(r,n.headers,o.headers),O="gzip"===T&&void 0!==w&&w.length>750&&("POST"===n.method||"PUT"===n.method);O&&void 0===R&&a.info("Compression is disabled because no compress method is available.");let I=O&&void 0!==R,S=I?await R(w):w;I&&(x["content-encoding"]="gzip");let N="GET"===n.method?{...n.data,...o.data}:{},E={...s,...n.queryParameters,...N};if(i.value&&(E["x-algolia-agent"]=i.value),o&&o.queryParameters)for(let e of Object.keys(o.queryParameters))o.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(o.queryParameters[e])?E[e]=o.queryParameters[e].toString():E[e]=o.queryParameters[e];let j=0,C=async(e,r)=>{let s=e.pop();if(void 0===s)throw new d(function(e){return e.map(e=>P(e))}(b));let i={...c,...o.timeouts},f={data:S,headers:x,method:n.method,url:g(s,n.path,E),connectTimeout:r(j,i.connect),responseTimeout:r(j,v?i.read:i.write)},y=t=>{let r={request:f,response:t,host:s,triesLeft:e.length};return b.push(r),r},R=await u.send(f);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0===~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(R)){let n=y(R);return R.isTimedOut&&j++,a.info("Retryable failure",P(n)),await t.set(s,l(s,R.isTimedOut?"timed out":"down")),C(e,r)}if(function({status:e}){return 2==~~(e/100)}(R))return function(e){if(204!==e.status&&0!==e.content.length)try{return JSON.parse(e.content)}catch(t){throw new h(t.message,e)}}(R);throw y(R),function({content:e,status:t},r){try{let a=JSON.parse(e);return"error"in a?new p(a.message,t,a.error,r):new m(a.message,t,r)}catch{}return new m(e,t,r)}(R,b)},k=e.filter(e=>"readWrite"===e.accept||(v?"read"===e.accept:"write"===e.accept)),D=await q(k);return C([...D.hosts].reverse(),D.getTimeout)}return{hostsCache:t,requester:u,timeouts:c,logger:a,algoliaAgent:i,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){let a=()=>w(e,t,n),n=e.useReadTransporter||"GET"===e.method;if(!0!==(t.cacheable||e.cacheable))return a();let o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return b.get(o,()=>v.get(o,()=>v.set(o,a()).then(e=>Promise.all([v.delete(o),e]),e=>Promise.all([v.delete(o),Promise.reject(e)])).then(([e,t])=>t)),{miss:e=>b.set(o,e)})},requestStream:async function*(t,a={}){if(!u.sendStream)throw new Error("This requester does not support streaming");let l=f(t,a),m=y(r,t.headers,a.headers);m.accept="text/event-stream";let h="GET"===t.method?{...t.data,...a.data}:{},p={...s,...t.queryParameters,...h};if(i.value&&(p["x-algolia-agent"]=i.value),a&&a.queryParameters)for(let e of Object.keys(a.queryParameters))a.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(a.queryParameters[e])?p[e]=a.queryParameters[e].toString():p[e]=a.queryParameters[e];let P=t.useReadTransporter||"GET"===t.method,v=e.filter(e=>"readWrite"===e.accept||(P?"read"===e.accept:"write"===e.accept)),b=(await q(v)).hosts[0];if(!b)throw new d([]);let R={...c,...a.timeouts},T={data:l,headers:m,method:t.method,url:g(b,t.path,p),connectTimeout:R.connect,responseTimeout:P?R.read:R.write},w=await u.sendStream(T);yield*async function*(e){let t=new o;for await(let r of n(e)){let e=t.decode(r);null!==e&&(yield e)}}(w)},requestsCache:v,responsesCache:b}}function b(e,t,r){if(null==r||"string"==typeof r&&0===r.length)throw new Error(`Parameter \`${e}\` is required when calling \`${t}\`.`)}var R="5.55.2";function T(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)),s=e[r];t[r]=e[a],t[a]=s}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=R,e.recommendClient=function(e,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!n||"string"!=typeof n)throw new Error("`apiKey` is missing.");let{compression:i,...l}=o||{};return function({appId:e,apiKey:t,authMode:r,algoliaAgents:a,...n}){let o=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=v({hosts:T(e),...n,algoliaAgent:s({algoliaAgents:a,client:"Recommend",version:R}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.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){b("indexName","batchRecommendRules",e),b("model","batchRecommendRules",t);let s={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(s,a)},customDelete({path:e,parameters:t},r){b("path","customDelete",e);let a={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(a,r)},customGet({path:e,parameters:t},r){b("path","customGet",e);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){b("path","customPost",e);let s={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(s,a)},customPut({path:e,parameters:t,body:r},a){b("path","customPut",e);let s={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(s,a)},deleteRecommendRule({indexName:e,model:t,objectID:r},a){b("indexName","deleteRecommendRule",e),b("model","deleteRecommendRule",t),b("objectID","deleteRecommendRule",r);let s={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(s,a)},getRecommendRule({indexName:e,model:t,objectID:r},a){b("indexName","getRecommendRule",e),b("model","getRecommendRule",t),b("objectID","getRecommendRule",r);let s={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(s,a)},getRecommendStatus({indexName:e,model:t,taskID:r},a){b("indexName","getRecommendStatus",e),b("model","getRecommendStatus",t),b("taskID","getRecommendStatus",r);let s={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(s,a)},getRecommendations(e,t){e&&Array.isArray(e)&&(e={requests:e}),b("getRecommendationsParams","getRecommendations",e),b("getRecommendationsParams.requests","getRecommendations",e.requests);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){b("indexName","searchRecommendRules",e),b("model","searchRecommendRules",t);let s={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(s,a)}}}({appId:e,apiKey:n,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),n=s(e.connectTimeout,"Connection timeout");r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===a&&(clearTimeout(n),a=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(n),clearTimeout(a),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(n),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:`${R}-${e}`}),a()]}),...l})}});
//# sourceMappingURL=/sm/90409c03b40994bb4b05ac217d4439e13abedd2283a9ee66edc6ecf2dc5c33e7.map