/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/@searchkit/instantsearch-client@4.15.0/dist/umd/index.global.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var SearchkitInstantsearchClientDefault=(()=>{var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var y=(s,e)=>{for(var t in e)l(s,t,{get:e[t],enumerable:!0})},S=(s,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of f(e))!d.call(s,r)&&r!==t&&l(s,r,{get:()=>e[r],enumerable:!(a=g(e,r))||a.enumerable});return s};var m=s=>S(l({},"__esModule",{value:!0}),s);var C={};y(C,{default:()=>k});function E(s){var e,t;return{hits:[],nbHits:0,nbPages:0,page:0,processingTimeMS:0,hitsPerPage:((e=s.params)==null?void 0:e.hitsPerPage)??20,exhaustiveNbHits:!0,query:((t=s.params)==null?void 0:t.query)??"",params:"",index:s.indexName}}function c(s){return s.handleInstantSearchRequests!==void 0}var p=class{constructor(e,t){this.config=e;this.requestOptions=t;if(this.cache=[],!c(this.config)&&!this.config.url)throw new Error("Searchkit Instantsearch Client: url is required");if(!c(this.config)&&this.requestOptions)throw new Error("Searchkit Instantsearch Client: requestOptions is not supported when used with url. Add the request options to @searchkit/api instead.")}clearCache(){return this.cache=[],Promise.resolve(void 0)}getHeaders(){let e={};return!c(this.config)&&this.config.headers&&(e=typeof this.config.headers=="function"?this.config.headers():this.config.headers),e}handleError(e,t){var r,i;return this.config&&!c(this.config)&&((i=(r=this.config).onError)==null?void 0:i.call(r,e))||console.error("Searchkit InstantSearch Client error:",e.message),{results:t.map(o=>E(o))}}async search(e){let t=JSON.stringify(e),a=this.cache[t];if(a)return a;try{if(c(this.config)){let o=await this.config.handleInstantSearchRequests(e,this.requestOptions);return this.cache[t]=o,o}let r=await fetch(this.config.url,{body:JSON.stringify(e),headers:{"Content-Type":"application/json",...this.getHeaders()},method:"POST"});if(!r.ok){let o=this.handleError(new Error(`Search request failed with status ${r.status}: ${r.statusText}`),e);return this.cache[t]=o,o}let i=await r.json();return this.cache[t]=i,i}catch(r){let i=this.handleError(r instanceof Error?r:new Error(String(r)),e);return this.cache[t]=i,i}}async searchForFacetValues(e){var a,r,i,o;let t=e.map(n=>({...n,params:{...n.params,hitsPerPage:0}}));try{if(c(this.config))return(await this.config.handleInstantSearchRequests(t)).results;let n=await fetch(this.config.url,{body:JSON.stringify(t),headers:{"Content-Type":"application/json",...this.getHeaders()},method:"POST"});if(!n.ok){let h=new Error(`Search request failed with status ${n.status}: ${n.statusText}`);return this.config&&!c(this.config)&&((r=(a=this.config).onError)==null?void 0:r.call(a,h))||console.error("Searchkit InstantSearch Client error:",h.message),[]}return(await n.json()).results}catch(n){let u=n instanceof Error?n:new Error(String(n));return this.config&&!c(this.config)&&((o=(i=this.config).onError)==null?void 0:o.call(i,u))||console.error("Searchkit InstantSearch Client error:",u.message),[]}}},w=(s,e)=>new p(s,e),k=w;return m(C);})();
var SearchkitInstantsearchClient = SearchkitInstantsearchClientDefault.default
//# sourceMappingURL=index.global.js.map