typesense-instantsearch-adapter
Version:
Adapter to use InstantSearch UI widgets with Typesense Search
2 lines • 146 kB
JavaScript
/*! For license information please see typesense-instantsearch-adapter.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TypesenseInstantSearchAdapter=t():e.TypesenseInstantSearchAdapter=t()}(self,(()=>(()=>{var e={3065:function(e,t,n){var r,o;!function(i,a){"use strict";r=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function o(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(t,n){for(var o=0;o<r.length;o++){var i=r[o];this[i]=o<t?e:this.methodFactory(i,t,n)}this.log=this.debug}function s(e,n,r){return function(){typeof console!==t&&(a.call(this,n,r),this[e].apply(this,arguments))}}function u(r,a,u){return function(r){return"debug"===r&&(r="log"),typeof console!==t&&("trace"===r&&n?i:void 0!==console[r]?o(console,r):void 0!==console.log?o(console,"log"):e)}(r)||s.apply(this,arguments)}function c(e,n,o){var i,s=this;n=null==n?"WARN":n;var c="loglevel";function l(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(c)+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(e){}return void 0===s.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=o||u,s.getLevel=function(){return i},s.setLevel=function(n,o){if("string"==typeof n&&void 0!==s.levels[n.toUpperCase()]&&(n=s.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(i=n,!1!==o&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),a.call(s,n,e),typeof console===t&&n<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){n=e,l()||s.setLevel(e,!1)},s.resetLevel=function(){s.setLevel(n,!1),function(){if(typeof window!==t&&c){try{return void window.localStorage.removeItem(c)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var d=l();null==d&&(d=n),s.setLevel(d,!1)}var l=new c,d={};l.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=d[e];return t||(t=d[e]=new c(e,l.getLevel(),l.methodFactory)),t};var f=typeof window!==t?window.log:void 0;return l.noConflict=function(){return typeof window!==t&&window.log===l&&(window.log=f),l},l.getLoggers=function(){return d},l.default=l,l},void 0===(o=r.call(t,n,t,e))||(e.exports=o)}()},8567:(e,t,n)=>{"use strict";t._t=void 0;var r=n(3301),o=r.__importDefault(n(5641));o.default;var i=r.__importDefault(n(8557));t._t=i.default;r.__importStar(n(4410));o.default,i.default},5300:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(612)),i=function(){function e(e,t){this.name=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=i},612:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o="/aliases",i=function(){function e(e){this.apiCall=e}return e.prototype.upsert=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.put(this.endpointPath(e),t)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(o)]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH,"/").concat(encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return o},enumerable:!1,configurable:!0}),e}();t.default=i},800:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(9813)),i=r.__importDefault(n(3614)),a=r.__importDefault(n(4145)),s=function(){function e(e){this.apiCall=e,this.individualAnalyticsRules={},this.apiCall=e,this._analyticsRules=new o.default(this.apiCall),this._analyticsEvents=new a.default(this.apiCall)}return e.prototype.rules=function(e){return void 0===e?this._analyticsRules:(void 0===this.individualAnalyticsRules[e]&&(this.individualAnalyticsRules[e]=new i.default(e,this.apiCall)),this.individualAnalyticsRules[e])},e.prototype.events=function(){return this._analyticsEvents},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics"},enumerable:!1,configurable:!0}),e}();t.default=s},4145:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.create=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.post(this.endpointPath(),e)]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics/events"},enumerable:!1,configurable:!0}),e}();t.default=o},3614:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(9813)),i=function(){function e(e,t){this.name=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=i},9813:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.upsert=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.put(this.endpointPath(e),t)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics/rules"},enumerable:!1,configurable:!0}),e}();t.default=o},5996:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(6425)),i=n(5978),a=n(7205),s=n(4410),u=r.__importDefault(n(7796)),c=!0,l="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,d=function(){function e(e){this.configuration=e,this.apiKey=this.configuration.apiKey,this.nodes=null==this.configuration.nodes?this.configuration.nodes:JSON.parse(JSON.stringify(this.configuration.nodes)),this.nearestNode=null==this.configuration.nearestNode?this.configuration.nearestNode:JSON.parse(JSON.stringify(this.configuration.nearestNode)),this.connectionTimeoutSeconds=this.configuration.connectionTimeoutSeconds,this.healthcheckIntervalSeconds=this.configuration.healthcheckIntervalSeconds,this.numRetriesPerRequest=this.configuration.numRetries,this.retryIntervalSeconds=this.configuration.retryIntervalSeconds,this.sendApiKeyAsQueryParam=this.configuration.sendApiKeyAsQueryParam,this.additionalUserHeaders=this.configuration.additionalHeaders,this.logger=this.configuration.logger,this.initializeMetadataForNodes(),this.currentNodeIndex=-1}return e.prototype.get=function(e,t,n){void 0===t&&(t={});var o=void 0===n?{}:n,i=o.abortSignal,a=void 0===i?null:i,s=o.responseType,u=void 0===s?void 0:s;return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.performRequest("get",e,{queryParameters:t,abortSignal:a,responseType:u})]}))}))},e.prototype.delete=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.performRequest("delete",e,{queryParameters:t})]}))}))},e.prototype.post=function(e,t,n,o){return void 0===t&&(t={}),void 0===n&&(n={}),void 0===o&&(o={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(r){return[2,this.performRequest("post",e,{queryParameters:n,bodyParameters:t,additionalHeaders:o})]}))}))},e.prototype.put=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(r){return[2,this.performRequest("put",e,{queryParameters:n,bodyParameters:t})]}))}))},e.prototype.patch=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(r){return[2,this.performRequest("patch",e,{queryParameters:n,bodyParameters:t})]}))}))},e.prototype.getAdapter=function(){if(this.configuration.axiosAdapter)return"function"==typeof this.configuration.axiosAdapter?this.configuration.axiosAdapter:"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent?o.default.getAdapter(this.configuration.axiosAdapter).bind(globalThis):o.default.getAdapter(this.configuration.axiosAdapter)},e.prototype.performRequest=function(e,t,n){var s,u,d,f,h=n.queryParameters,p=void 0===h?null:h,y=n.bodyParameters,v=void 0===y?null:y,g=n.additionalHeaders,m=void 0===g?{}:g,_=n.abortSignal,b=void 0===_?null:_,w=n.responseType,O=void 0===w?void 0:w,S=n.skipConnectionTimeout,C=void 0!==S&&S,P=n.enableKeepAlive,R=void 0===P?void 0:P;return r.__awaiter(this,void 0,void 0,(function(){var n,h,y,g,_,w,S,P;return r.__generator(this,(function(E){switch(E.label){case 0:this.configuration.validate(),(n=!0===(null==p?void 0:p.conversation_stream)&&"get"===e.toLowerCase())&&(this.logger.debug("Request: Performing streaming request to ".concat(t)),l||"undefined"==typeof fetch||(this.logger.debug("Using fetch adapter for browser streaming"),O="stream")),h=Date.now(),g=!1,this.logger.debug("Request #".concat(h,": Performing ").concat(e.toUpperCase()," request: ").concat(t)),_=function(_){var S,P,E,j,A,T,N;return r.__generator(this,(function(x){switch(x.label){case 0:if(S=w.getNextNode(h),w.logger.debug("Request #".concat(h,": Attempting ").concat(e.toUpperCase()," request Try #").concat(_," to Node ").concat(S.index)),b&&b.aborted)return[2,{value:Promise.reject(new Error("Request aborted by caller."))}];P=void 0,x.label=1;case 1:return x.trys.push([1,3,5,6]),(E={method:e,url:w.uriFor(t,S),headers:Object.assign({},w.defaultHeaders(),m,w.additionalUserHeaders),maxContentLength:1/0,maxBodyLength:1/0,validateStatus:function(e){return e>0},transformResponse:[function(e,t){var n=e;return void 0!==t&&"string"==typeof e&&t["content-type"]&&t["content-type"].startsWith("application/json")&&(n=JSON.parse(e)),n}]}).adapter=n&&!l?"fetch":w.getAdapter(),!0!==C&&(E.timeout=1e3*w.connectionTimeoutSeconds),p&&0!==Object.keys(p).length&&(E.params=p),w.sendApiKeyAsQueryParam&&(E.params=E.params||{},E.params["x-typesense-api-key"]=w.apiKey),w.configuration.httpAgent?(w.logger.debug("Request #".concat(h,": Using custom httpAgent")),E.httpAgent=w.configuration.httpAgent):!0===R&&(l?(w.logger.debug("Request #".concat(h,": Enabling KeepAlive")),E.httpAgent=new i.Agent({keepAlive:!0})):w.logger.warn("Request #".concat(h,": Cannot use custom httpAgent in a browser environment to enable keepAlive"))),w.configuration.httpsAgent?(w.logger.debug("Request #".concat(h,": Using custom httpsAgent")),E.httpsAgent=w.configuration.httpsAgent):!0===R&&(l?(w.logger.debug("Request #".concat(h,": Enabling keepAlive")),E.httpsAgent=new a.Agent({keepAlive:!0})):w.logger.warn("Request #".concat(h,": Cannot use custom httpAgent in a browser environment to enable keepAlive"))),w.configuration.paramsSerializer&&(w.logger.debug("Request #".concat(h,": Using custom paramsSerializer")),E.paramsSerializer=w.configuration.paramsSerializer),v&&("string"==typeof v&&0!==v.length||"object"==typeof v&&0!==Object.keys(v).length)&&(E.data=v),b&&(j=o.default.CancelToken,A=j.source(),P=function(){g=!0,A.cancel()},b.addEventListener("abort",P),E.cancelToken=A.token),n?(E.responseType="stream",l||(E.headers=r.__assign(r.__assign({},E.headers),{Accept:"text/event-stream"}))):O&&(E.responseType=O),[4,(0,o.default)(E)];case 2:if((T=x.sent()).status>=1&&T.status<=499&&w.setNodeHealthcheck(S,c),w.logger.debug("Request #".concat(h,": Request to Node ").concat(S.index," was made. Response Code was ").concat(T.status,".")),T.status>=200&&T.status<300)return n?[2,{value:w.handleStreamingResponse(T)}]:[2,{value:Promise.resolve(T.data)}];if(T.status<500)return[2,{value:Promise.reject(w.customErrorForResponse(T,null===(s=T.data)||void 0===s?void 0:s.message,E.data))}];throw w.customErrorForResponse(T,null===(u=T.data)||void 0===u?void 0:u.message,E.data);case 3:return N=x.sent(),g||w.setNodeHealthcheck(S,!1),y=N,w.logger.warn("Request #".concat(h,": Request to Node ").concat(S.index,' failed due to "').concat(null!==(d=null==N?void 0:N.code)&&void 0!==d?d:""," ").concat(N.message).concat(null==N.response?"":" - "+JSON.stringify(null===(f=N.response)||void 0===f?void 0:f.data),'"')),g?[2,{value:Promise.reject(new Error("Request aborted by caller."))}]:(n&&w.invokeOnErrorCallback(N),_<w.numRetriesPerRequest+1?(w.logger.warn("Request #".concat(h,": Sleeping for ").concat(w.retryIntervalSeconds,"s and then retrying request...")),[4,w.timer(w.retryIntervalSeconds)]):(w.logger.debug("Request #".concat(h,": No retries left. Raising last error")),[2,{value:Promise.reject(y)}]));case 4:return x.sent(),[3,6];case 5:return b&&P&&b.removeEventListener("abort",P),[7];case 6:return[2]}}))},w=this,S=1,E.label=1;case 1:return S<=this.numRetriesPerRequest+1?[5,_(S)]:[3,4];case 2:if("object"==typeof(P=E.sent()))return[2,P.value];E.label=3;case 3:return S++,[3,1];case 4:return this.logger.debug("Request #".concat(h,": No retries left. Raising last error")),[2,Promise.reject(y)]}}))}))},e.prototype.processStreamingLine=function(e){if(!e.trim()||"data: [DONE]"===e)return null;if(e.startsWith("data: "))return this.processDataLine(e.slice(6).trim());if(e.trim().startsWith("{"))try{var t=JSON.parse(e.trim());return t&&"object"==typeof t?(t.conversation_id||(t.conversation_id="unknown"),t.message||""===t.message||(t.message=""),t):{conversation_id:"unknown",message:JSON.stringify(t)}}catch(t){return{conversation_id:"unknown",message:e.trim()}}return{conversation_id:"unknown",message:e.trim()}},e.prototype.processDataLine=function(e){if(!e)return null;if(e.startsWith("{"))try{var t=JSON.parse(e);return t&&"object"==typeof t?(t.conversation_id||(t.conversation_id="unknown"),t.message||""===t.message||(t.message=""),t):{conversation_id:"unknown",message:JSON.stringify(t)}}catch(t){return{conversation_id:"unknown",message:e}}return{conversation_id:"unknown",message:e}},e.prototype.handleStreamingResponse=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return this.logger.debug("Handling streaming response. Environment: ".concat(l?"Node.js":"Browser")),l&&e.data?[2,this.handleNodeStreaming(e)]:l?(this.logger.debug("Processing non-streaming response"),this.invokeOnCompleteCallback(e.data),[2,Promise.resolve(e.data)]):[2,this.handleBrowserStreaming(e)]}))}))},e.prototype.handleNodeStreaming=function(e){var t=this;return this.logger.debug("Processing Node.js stream"),new Promise((function(n,r){var o=e.data,i=[],a="";o.on("data",(function(e){var n;try{var o=e.toString(),s=(a+=o).split("\n");a=null!==(n=s.pop())&&void 0!==n?n:"",t.processStreamLines(s,i)}catch(e){r(e)}})),o.on("end",(function(){if(a.trim().length>0){var r=a.split("\n");t.processStreamLines(r,i)}t.finalizeStreamResult(i,n,e)})),o.on("error",(function(e){t.logger.error("Stream error: ".concat(e)),t.invokeOnErrorCallback(e),r(e)}))}))},e.prototype.handleBrowserStreaming=function(e){var t=this;return this.logger.debug("Processing browser stream"),new Promise((function(n,o){return r.__awaiter(t,void 0,void 0,(function(){return r.__generator(this,(function(t){try{return e.data&&"function"==typeof e.data.getReader?[2,this.handleBrowserReadableStream(e.data,n,o,e)]:"string"==typeof e.data?[2,this.handleBrowserStringResponse(e.data,n,e)]:"object"==typeof e.data&&null!==e.data?(this.logger.debug("No stream found, but data object is available"),this.invokeOnCompleteCallback(e.data),[2,n(e.data)]):(this.logger.error("No usable data found in response"),[2,o(new Error("No usable data found in response"))])}catch(e){this.logger.error("Error processing streaming response: ".concat(e)),this.invokeOnErrorCallback(e),o(e)}return[2]}))}))}))},e.prototype.handleBrowserReadableStream=function(e,t,n,o){return r.__awaiter(this,void 0,void 0,(function(){var i,a,s,u,c,l,d,f,h,p;return r.__generator(this,(function(r){switch(r.label){case 0:this.logger.debug("Found ReadableStream in response.data"),i=e.getReader(),a=[],s="",r.label=1;case 1:r.trys.push([1,5,,6]),r.label=2;case 2:return[4,i.read()];case 3:return u=r.sent(),c=u.done,l=u.value,c?(this.logger.debug("Stream reading complete"),s.trim()&&(d=s.split("\n"),this.processStreamLines(d,a)),[3,4]):(f=(new TextDecoder).decode(l),this.logger.debug("Received chunk: ".concat(f.length," bytes")),h=(s+=f).split("\n"),s=h.pop()||"",this.processStreamLines(h,a),[3,2]);case 4:return this.finalizeStreamResult(a,t,o),[3,6];case 5:return p=r.sent(),n(p),[3,6];case 6:return[2]}}))}))},e.prototype.handleBrowserStringResponse=function(e,t,n){this.logger.debug("Processing text response as stream data");var r=[],o=e.split("\n");if(this.processStreamLines(o,r),r.length>0){var i=this.combineStreamingChunks(r);this.invokeOnCompleteCallback(i),t(i)}else this.logger.debug("No chunks processed, returning original API response"),this.invokeOnCompleteCallback(n.data),t(n.data)},e.prototype.processStreamLines=function(e,t){for(var n=0,r=e;n<r.length;n++){var o=r[n];if(o.trim()&&"data: [DONE]"!==o){var i=this.processStreamingLine(o);null!==i&&(this.invokeOnChunkCallback(i),t.push(i))}}},e.prototype.finalizeStreamResult=function(e,t,n){if(e.length>0){var r=this.combineStreamingChunks(e);this.logger.debug("Stream processing complete"),this.invokeOnCompleteCallback(r),t(r)}else this.logger.debug("No chunks processed, returning original API response"),this.invokeOnCompleteCallback(n.data),t(n.data)},e.prototype.combineStreamingChunks=function(e){if(0===e.length)return{};if(1===e.length)return e[0];var t=this.getMessageChunks(e);if(t.length>0)return this.combineMessageChunks(e,t);var n=e[e.length-1];return this.isCompleteSearchResponse(n)?n:this.attemptChunksMerge(e,n)},e.prototype.getMessageChunks=function(e){return e.filter((function(e){return"object"==typeof e&&null!==e&&"message"in e}))},e.prototype.combineMessageChunks=function(e,t){this.logger.debug("Found ".concat(t.length," message chunks to combine"));var n=e[e.length-1];if("object"==typeof n&&null!==n&&("hits"in n||"found"in n))return this.logger.debug("Last chunk appears to be a complete search response"),n;var o=t.map((function(e){return e.message})).join(""),i=e.find((function(e){return"object"==typeof e&&null!==e&&("hits"in e||"found"in e||"request_params"in e)}));return i?r.__assign(r.__assign({},i),{message:o}):{message:o}},e.prototype.isCompleteSearchResponse=function(e){return"object"==typeof e&&null!==e&&Object.keys(e).length>0&&("found"in e||"hits"in e||"page"in e||"search_time_ms"in e)},e.prototype.attemptChunksMerge=function(e,t){try{for(var n={},o=0,i=e;o<i.length;o++){var a=i[o];"object"==typeof a&&null!==a&&(n=r.__assign(r.__assign({},n),a))}if(Object.keys(n).length>0)return n}catch(e){this.logger.warn("Failed to merge chunks: ".concat(e))}return t},e.prototype.getNextNode=function(e){if(void 0===e&&(e=0),null!=this.nearestNode){if(this.logger.debug("Request #".concat(e,": Nodes Health: Node ").concat(this.nearestNode.index," is ").concat(!0===this.nearestNode.isHealthy?"Healthy":"Unhealthy")),!0===this.nearestNode.isHealthy||this.nodeDueForHealthcheck(this.nearestNode,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(this.nearestNode.index)),this.nearestNode;this.logger.debug("Request #".concat(e,": Falling back to individual nodes"))}this.logger.debug("Request #".concat(e,": Nodes Health: ").concat(this.nodes.map((function(e){return"Node ".concat(e.index," is ").concat(!0===e.isHealthy?"Healthy":"Unhealthy")})).join(" || ")));for(var t=this.nodes[0],n=0;n<=this.nodes.length;n++)if(this.currentNodeIndex=(this.currentNodeIndex+1)%this.nodes.length,!0===(t=this.nodes[this.currentNodeIndex]).isHealthy||this.nodeDueForHealthcheck(t,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(t.index)),t;return this.logger.debug("Request #".concat(e,": No healthy nodes were found. Returning the next node, Node ").concat(t.index)),t},e.prototype.nodeDueForHealthcheck=function(e,t){void 0===t&&(t=0);var n=Date.now()-e.lastAccessTimestamp>1e3*this.healthcheckIntervalSeconds;return n&&this.logger.debug("Request #".concat(t,": Node ").concat(e.index," has exceeded healtcheckIntervalSeconds of ").concat(this.healthcheckIntervalSeconds,". Adding it back into rotation.")),n},e.prototype.initializeMetadataForNodes=function(){var e=this;null!=this.nearestNode&&(this.nearestNode.index="nearestNode",this.setNodeHealthcheck(this.nearestNode,c)),this.nodes.forEach((function(t,n){t.index=n,e.setNodeHealthcheck(t,c)}))},e.prototype.setNodeHealthcheck=function(e,t){e.isHealthy=t,e.lastAccessTimestamp=Date.now()},e.prototype.uriFor=function(e,t){return null!=t.url?"".concat(t.url).concat(e):"".concat(t.protocol,"://").concat(t.host,":").concat(t.port).concat(t.path).concat(e)},e.prototype.defaultHeaders=function(){var e={};return this.sendApiKeyAsQueryParam||(e["X-TYPESENSE-API-KEY"]=this.apiKey),e["Content-Type"]="application/json",e},e.prototype.timer=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,1e3*e)}))]}))}))},e.prototype.customErrorForResponse=function(e,t,n){var r="Request failed with HTTP code ".concat(e.status);return"string"==typeof t&&""!==t.trim()&&(r+=" | Server said: ".concat(t)),new u.default(r,n,e.status),400===e.status?new s.RequestMalformed(r):401===e.status?new s.RequestUnauthorized(r):404===e.status?new s.ObjectNotFound(r):409===e.status?new s.ObjectAlreadyExists(r):422===e.status?new s.ObjectUnprocessable(r):e.status>=500&&e.status<=599?new s.ServerError(r):new s.HTTPError(r)},e.prototype.invokeOnChunkCallback=function(e){var t;if(null===(t=this.configuration.streamConfig)||void 0===t?void 0:t.onChunk)try{this.configuration.streamConfig.onChunk(e)}catch(e){this.logger.warn("Error in onChunk callback: ".concat(e))}},e.prototype.invokeOnCompleteCallback=function(e){var t;if(null===(t=this.configuration.streamConfig)||void 0===t?void 0:t.onComplete)try{this.configuration.streamConfig.onComplete(e)}catch(e){this.logger.warn("Error in onComplete callback: ".concat(e))}},e.prototype.invokeOnErrorCallback=function(e){var t;if(null===(t=this.configuration.streamConfig)||void 0===t?void 0:t.onError){var n=e instanceof Error?e:new Error(String(e));try{this.configuration.streamConfig.onError(n)}catch(e){this.logger.warn("Error in onError callback: ".concat(e))}}},e}();t.default=d},5641:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(5706)),i=r.__importDefault(n(5996)),a=r.__importDefault(n(7361)),s=r.__importDefault(n(2626)),u=r.__importDefault(n(612)),c=r.__importDefault(n(5300)),l=r.__importDefault(n(326)),d=r.__importDefault(n(2275)),f=r.__importDefault(n(3343)),h=r.__importDefault(n(657)),p=r.__importDefault(n(4955)),y=r.__importDefault(n(8231)),v=r.__importDefault(n(3684)),g=r.__importDefault(n(8621)),m=r.__importDefault(n(5156)),_=r.__importDefault(n(3777)),b=r.__importDefault(n(800)),w=r.__importDefault(n(3533)),O=r.__importDefault(n(4646)),S=r.__importDefault(n(8700)),C=r.__importDefault(n(8313)),P=r.__importDefault(n(2786)),R=function(){function e(e){var t;e.sendApiKeyAsQueryParam=null!==(t=e.sendApiKeyAsQueryParam)&&void 0!==t&&t,this.configuration=new o.default(e),this.apiCall=new i.default(this.configuration),this.debug=new f.default(this.apiCall),this.metrics=new h.default(this.apiCall),this.stats=new p.default(this.apiCall),this.health=new y.default(this.apiCall),this.operations=new v.default(this.apiCall),this.multiSearch=new g.default(this.apiCall,this.configuration),this._collections=new a.default(this.apiCall),this.individualCollections={},this._aliases=new u.default(this.apiCall),this.individualAliases={},this._keys=new l.default(this.apiCall),this.individualKeys={},this._presets=new m.default(this.apiCall),this.individualPresets={},this._stopwords=new w.default(this.apiCall),this.individualStopwords={},this.analytics=new b.default(this.apiCall),this.stemming=new P.default(this.apiCall),this._conversations=new S.default(this.apiCall),this.individualConversations={}}return e.prototype.collections=function(e){return void 0===e?this._collections:(void 0===this.individualCollections[e]&&(this.individualCollections[e]=new s.default(e,this.apiCall,this.configuration)),this.individualCollections[e])},e.prototype.aliases=function(e){return void 0===e?this._aliases:(void 0===this.individualAliases[e]&&(this.individualAliases[e]=new c.default(e,this.apiCall)),this.individualAliases[e])},e.prototype.keys=function(e){return void 0===e?this._keys:(void 0===this.individualKeys[e]&&(this.individualKeys[e]=new d.default(e,this.apiCall)),this.individualKeys[e])},e.prototype.presets=function(e){return void 0===e?this._presets:(void 0===this.individualPresets[e]&&(this.individualPresets[e]=new _.default(e,this.apiCall)),this.individualPresets[e])},e.prototype.stopwords=function(e){return void 0===e?this._stopwords:(void 0===this.individualStopwords[e]&&(this.individualStopwords[e]=new O.default(e,this.apiCall)),this.individualStopwords[e])},e.prototype.conversations=function(e){return void 0===e?this._conversations:(void 0===this.individualConversations[e]&&(this.individualConversations[e]=new C.default(e,this.apiCall)),this.individualConversations[e])},e}();t.default=R},2626:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(7361)),i=r.__importDefault(n(9078)),a=n(4410),s=r.__importDefault(n(3629)),u=r.__importDefault(n(6582)),c=r.__importDefault(n(1104)),l=r.__importDefault(n(6821)),d=n(9459),f=function(){function e(e,t,n){this.name=e,this.apiCall=t,this.configuration=n,this.individualDocuments={},this.individualOverrides={},this.individualSynonyms={},this.name=e,this.apiCall=t,this.configuration=n,this._documents=new i.default(this.name,this.apiCall,this.configuration),this._overrides=new s.default(this.name,this.apiCall),this._synonyms=new c.default(this.name,this.apiCall)}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.update=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.patch(this.endpointPath(),e)]}))}))},e.prototype.delete=function(e){return void 0===e&&(e={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.delete(this.endpointPath(),e)]}))}))},e.prototype.exists=function(){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.retrieve()];case 1:return t.sent(),[2,!0];case 2:if((e=t.sent())instanceof a.ObjectNotFound)return[2,!1];throw e;case 3:return[2]}}))}))},e.prototype.documents=function(e){return e?(void 0===this.individualDocuments[e]&&(this.individualDocuments[e]=new d.Document(this.name,e,this.apiCall)),this.individualDocuments[e]):this._documents},e.prototype.overrides=function(e){return void 0===e?this._overrides:(void 0===this.individualOverrides[e]&&(this.individualOverrides[e]=new u.default(this.name,e,this.apiCall)),this.individualOverrides[e])},e.prototype.synonyms=function(e){return void 0===e?this._synonyms:(void 0===this.individualSynonyms[e]&&(this.individualSynonyms[e]=new l.default(this.name,e,this.apiCall)),this.individualSynonyms[e])},e.prototype.endpointPath=function(){return"".concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=f},7361:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o="/collections",i=function(){function e(e){this.apiCall=e}return e.prototype.create=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.post(o,e,t)]}))}))},e.prototype.retrieve=function(e){return void 0===e&&(e={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.get(o,e)]}))}))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return o},enumerable:!1,configurable:!0}),e}();t.default=i},5706:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importStar(n(3065)),i=n(4410),a=function(){function e(e){var t=this;this.nodes=e.nodes||[],this.nodes=this.nodes.map((function(e){return t.setDefaultPathInNode(e)})).map((function(e){return t.setDefaultPortInNode(e)})).map((function(e){return r.__assign({},e)})),null==e.randomizeNodes&&(e.randomizeNodes=!0),!0===e.randomizeNodes&&this.shuffleArray(this.nodes),this.nearestNode=e.nearestNode,this.nearestNode=this.setDefaultPathInNode(this.nearestNode),this.nearestNode=this.setDefaultPortInNode(this.nearestNode),this.connectionTimeoutSeconds=e.connectionTimeoutSeconds||e.timeoutSeconds||5,this.healthcheckIntervalSeconds=e.healthcheckIntervalSeconds||60,this.numRetries=(void 0!==e.numRetries&&e.numRetries>=0?e.numRetries:this.nodes.length+(null==this.nearestNode?0:1))||3,this.retryIntervalSeconds=e.retryIntervalSeconds||.1,this.apiKey=e.apiKey,this.sendApiKeyAsQueryParam=e.sendApiKeyAsQueryParam,this.cacheSearchResultsForSeconds=e.cacheSearchResultsForSeconds||0,this.useServerSideSearchCache=e.useServerSideSearchCache||!1,this.axiosAdapter=e.axiosAdapter,this.logger=e.logger||o,this.logLevel=e.logLevel||"warn",this.logger.setLevel(this.logLevel),this.additionalHeaders=e.additionalHeaders,this.httpAgent=e.httpAgent,this.httpsAgent=e.httpsAgent,this.paramsSerializer=e.paramsSerializer,this.streamConfig=e.streamConfig,this.showDeprecationWarnings(e),this.validate()}return e.prototype.validate=function(){if(null==this.nodes||0===this.nodes.length||this.validateNodes())throw new i.MissingConfigurationError("Ensure that nodes[].protocol, nodes[].host and nodes[].port are set");if(null!=this.nearestNode&&this.isNodeMissingAnyParameters(this.nearestNode))throw new i.MissingConfigurationError("Ensure that nearestNodes.protocol, nearestNodes.host and nearestNodes.port are set");if(null==this.apiKey)throw new i.MissingConfigurationError("Ensure that apiKey is set");return!0},e.prototype.validateNodes=function(){var e=this;return this.nodes.some((function(t){return e.isNodeMissingAnyParameters(t)}))},e.prototype.isNodeMissingAnyParameters=function(e){return!["protocol","host","port","path"].every((function(t){return e.hasOwnProperty(t)}))&&null==e.url},e.prototype.setDefaultPathInNode=function(e){return null==e||e.hasOwnProperty("path")||(e.path=""),e},e.prototype.setDefaultPortInNode=function(e){if(null!=e&&!e.hasOwnProperty("port")&&e.hasOwnProperty("protocol"))switch(e.protocol){case"https":e.port=443;break;case"http":e.port=80}return e},e.prototype.showDeprecationWarnings=function(e){e.timeoutSeconds&&this.logger.warn("Deprecation warning: timeoutSeconds is now renamed to connectionTimeoutSeconds"),e.masterNode&&this.logger.warn("Deprecation warning: masterNode is now consolidated to nodes, starting with Typesense Server v0.12"),e.readReplicaNodes&&this.logger.warn("Deprecation warning: readReplicaNodes is now consolidated to nodes, starting with Typesense Server v0.12")},e.prototype.shuffleArray=function(e){for(var t,n=e.length-1;n>0;n--){var r=Math.floor(Math.random()*(n+1));t=[e[r],e[n]],e[n]=t[0],e[r]=t[1]}},e}();t.default=a},8313:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(8700)),i=function(){function e(e,t){this.id=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.update=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.put(this.endpointPath(),e)]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();t.default=i},5168:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(2783)),i=function(){function e(e,t){this.id=e,this.apiCall=t}return e.prototype.update=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.put(this.endpointPath(),e)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();t.default=i},2783:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.create=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.post(this.endpointPath(),e)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/conversations/models"},enumerable:!1,configurable:!0}),e}();t.default=o},8700:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(2783)),i=r.__importDefault(n(5168)),a="/conversations",s=function(){function e(e){this.apiCall=e,this.individualConversationModels={},this.apiCall=e,this._conversationsModels=new o.default(this.apiCall)}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(a)]}))}))},e.prototype.models=function(e){return void 0===e?this._conversationsModels:(void 0===this.individualConversationModels[e]&&(this.individualConversationModels[e]=new i.default(e,this.apiCall)),this.individualConversationModels[e])},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return a},enumerable:!1,configurable:!0}),e}();t.default=s},3343:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(){function e(e){this.apiCall=e}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get("/debug")]}))}))},e}();t.default=o},9459:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Document=void 0;var r=n(3301),o=r.__importDefault(n(7361)),i=r.__importDefault(n(9078)),a=function(){function e(e,t,n){this.collectionName=e,this.documentId=t,this.apiCall=n}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.delete(this.endpointPath(),e)]}))}))},e.prototype.update=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.patch(this.endpointPath(),e,t)]}))}))},e.prototype.endpointPath=function(){return"".concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.collectionName)).concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.documentId))},e}();t.Document=a},9078:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=n(4410),i=n(6124),a="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,s=function(e){function t(t,n,r){return e.call(this,t,n,r)||this}return r.__extends(t,e),t.prototype.create=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){if(!e)throw new Error("No document provided");return[2,this.apiCall.post(this.endpointPath(),e,t)]}))}))},t.prototype.upsert=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){if(!e)throw new Error("No document provided");return[2,this.apiCall.post(this.endpointPath(),e,Object.assign({},t,{action:"upsert"}))]}))}))},t.prototype.update=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){if(!e)throw new Error("No document provided");return null!=t.filter_by?[2,this.apiCall.patch(this.endpointPath(),e,Object.assign({},t))]:[2,this.apiCall.post(this.endpointPath(),e,Object.assign({},t,{action:"update"}))]}))}))},t.prototype.delete=function(e){return void 0===e&&(e={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.delete(this.endpointPath(),e)]}))}))},t.prototype.createMany=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return this.configuration.logger.warn("createMany is deprecated and will be removed in a future version. Use import instead, which now takes both an array of documents or a JSONL string of documents"),[2,this.import(e,t)]}))}))},t.prototype.import=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){var n,i,s,u;return r.__generator(this,(function(r){switch(r.label){case 0:if(Array.isArray(e)){if(0===e.length)throw new o.RequestMalformed("No documents provided");try{n=e.map((function(e){return JSON.stringify(e)})).join("\n")}catch(e){if(e instanceof RangeError&&e.message.includes("Too many properties to enumerate"))throw new Error("".concat(e,"\n It looks like you have reached a Node.js limit that restricts the number of keys in an Object: https://stackoverflow.com/questions/9282869/are-there-limits-to-the-number-of-properties-in-a-javascript-object\n\n Please try reducing the number of keys in your document, or using CURL to import your data.\n "));throw new Error(e)}}else if(null==(c=n=e)||""===c||0===c.length)throw new o.RequestMalformed("No documents provided");return[4,this.apiCall.performRequest("post",this.endpointPath("import"),{queryParameters:t,bodyParameters:n,additionalHeaders:{"Content-Type":"text/plain"},skipConnectionTimeout:!0,enableKeepAlive:!!a})];case 1:if(i=r.sent(),Array.isArray(e)){if(s=i.split("\n").map((function(e){return JSON.parse(e)})),(u=s.filter((function(e){return!1===e.success}))).length>0)throw new o.ImportError("".concat(s.length-u.length," documents imported successfully, ").concat(u.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),s,{documentsInJSONLFormat:n,options:t,failedItems:u,successCount:s.length-u.length});return[2,s]}return[2,i]}var c}))}))},t.prototype.importStream=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,void 0,(function(){var n,i,s;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,this.apiCall.performRequest("post",this.endpointPath("import"),{queryParameters:t,bodyParameters:e,additionalHeaders:{"Content-Type":"text/plain"},skipConnectionTimeout:!0,enableKeepAlive:!!a})];case 1:if(n=r.sent(),i=n.split("\n").map((function(e){return JSON.parse(e)})),(s=i.filter((function(e){return!1===e.success}))).length>0)throw new o.ImportError("".concat(i.length-s.length," documents imported successfully, ").concat(s.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),i,{documentsInJSONLFormat:e,options:t,failedItems:s,successCount:i.length-s.length});return[2,i]}}))}))},t.prototype.export=function(e){return void 0===e&&(e={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.get(this.endpointPath("export"),e)]}))}))},t.prototype.exportStream=function(e){return void 0===e&&(e={}),r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.get(this.endpointPath("export"),e,{responseType:"stream"})]}))}))},t}(i.SearchOnlyDocuments);t.default=s},2144:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},8331:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(t,n,r){var o=e.call(this,t)||this;return o.importResults=n,o.payload=r,o}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},2426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},6731:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},8280:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},2703:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},8274:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},6909:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},1081:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t}(r.__importDefault(n(7796)).default);t.default=o},7796:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(e){function t(t,n,r){var o=this.constructor,i=e.call(this,t)||this;return i.name=o.name,i.httpBody=n,i.httpStatus=r,Object.setPrototypeOf(i,o.prototype),i}return r.__extends(t,e),t}(Error);t.default=o},4410:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ImportError=t.TypesenseError=t.ServerError=t.RequestUnauthorized=t.RequestMalformed=t.ObjectUnprocessable=t.ObjectNotFound=t.ObjectAlreadyExists=t.MissingConfigurationError=t.HTTPError=void 0;var r=n(3301),o=r.__importDefault(n(2144));t.HTTPError=o.default;var i=r.__importDefault(n(2426));t.MissingConfigurationError=i.default;var a=r.__importDefault(n(6731));t.ObjectAlreadyExists=a.default;var s=r.__importDefault(n(8280));t.ObjectNotFound=s.default;var u=r.__importDefault(n(2703));t.ObjectUnprocessable=u.default;var c=r.__importDefault(n(8274));t.RequestMalformed=c.default;var l=r.__importDefault(n(6909));t.RequestUnauthorized=l.default;var d=r.__importDefault(n(1081));t.ServerError=d.default;var f=r.__importDefault(n(8331));t.ImportError=f.default;var h=r.__importDefault(n(7796));t.TypesenseError=h.default},8231:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(){function e(e){this.apiCall=e}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get("/health")]}))}))},e}();t.default=o},2275:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(326)),i=function(){function e(e,t){this.id=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();t.default=i},326:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=n(3529),i=n(7353),a="/keys",s=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.create=function(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.post(e.RESOURCEPATH,t)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(a)]}))}))},e.prototype.generateScopedSearchKey=function(e,t){var n=(0,i.normalizeArrayableParams)(t),r=JSON.stringify(n),a=Buffer.from((0,o.createHmac)("sha256",e).update(r).digest("base64")),s=e.substr(0,4),u="".concat(a).concat(s).concat(r);return Buffer.from(u).toString("base64")},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return a},enumerable:!1,configurable:!0}),e}();t.default=s},657:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(){function e(e){this.apiCall=e}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get("/metrics.json")]}))}))},e}();t.default=o},8621:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=r.__importDefault(n(875)),i=n(7353),a=function(){function e(e,t,n){void 0===n&&(n=!1),this.apiCall=e,this.configuration=t,this.useTextContentType=n,this.requestWithCache=new o.default}return e.prototype.clearCache=function(){this.requestWithCache.clearCache()},e.prototype.perform=function(e,t,n){void 0===t&&(t={});var o=(void 0===n?{}:n).cacheSearchResultsForSeconds,a=void 0===o?this.configuration.cacheSearchResultsForSeconds:o;return r.__awaiter(this,void 0,void 0,(function(){var n,o,s,u,c;return r.__generator(this,(function(l){return n={},this.useTextContentType&&(n["content-type"]="text/plain"),o={},!0===this.configuration.useServerSideSearchCache&&(o.use_cache=!0),s=r.__assign(r.__assign({},t),o),u=r.__assign(r.__assign({},e),{searches:e.searches.map(i.normalizeArrayableParams)}),c=(0,i.normalizeArrayableParams)(s),[2,this.requestWithCache.perform(this.apiCall,this.apiCall.post,["/multi_search",u,c,n],{cacheResponseForSeconds:a})]}))}))},e}();t.default=a},3684:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),o=function(){function e(e){this.apiCall=e}return e.prototype.perform=function(e,t){return void 0===t&&(t={}),r.__awaiter(this,void 0,vo