Socket
Socket
Sign inDemoInstall

@meilisearch/instant-meilisearch

Package Overview
Dependencies
Maintainers
6
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meilisearch/instant-meilisearch - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0-beta.0

dist/types/client/agents.d.ts

61

dist/instant-meilisearch.cjs.js

@@ -178,6 +178,6 @@ 'use strict';

}
function getFacetsFromDefaultDistribution(facetsDistribution) {
return Object.keys(facetsDistribution).reduce(function (cache, facet) {
function getFacetsFromDefaultDistribution(facetDistribution) {
return Object.keys(facetDistribution).reduce(function (cache, facet) {
var _a;
var facetValues = Object.keys(facetsDistribution[facet]);
var facetValues = Object.keys(facetDistribution[facet]);
return __assign(__assign({}, cache), (_a = {}, _a[facet] = facetValues, _a));

@@ -199,4 +199,4 @@ }, {});

/**
* Assign missing filters to facetsDistribution.
* All facet passed as filter should appear in the facetsDistribution.
* Assign missing filters to facetDistribution.
* All facets passed as filter should appear in the facetDistribution.
* If not present, the facet is added with 0 as value.

@@ -236,7 +236,6 @@ *

query: '',
facetsDistribution: {},
facetDistribution: {},
limit: 0,
offset: 0,
exhaustiveNbHits: false,
nbHits: 0,
estimatedTotalHits: 0,
processingTimeMs: 0

@@ -283,8 +282,8 @@ };

.search(searchContext.query, searchParams)
// Add missing facets back into facetsDistribution
// Add missing facets back into facetDistribution
];
case 1:
searchResponse = _a.sent();
// Add missing facets back into facetsDistribution
searchResponse.facetsDistribution = addMissingFacets(facetsCache, searchResponse.facetsDistribution);
// Add missing facets back into facetDistribution
searchResponse.facetDistribution = addMissingFacets(facetsCache, searchResponse.facetDistribution);
// Cache response

@@ -538,3 +537,3 @@ cache.setEntry(key, searchResponse);

if (facets === null || facets === void 0 ? void 0 : facets.length) {
meiliSearchParams.facetsDistribution = facets;
meiliSearchParams.facets = facets;
}

@@ -743,3 +742,3 @@ // Attributes To Crop

if (Object.keys(hit).length > 0) {
var formattedHit = hit._formatted; hit._matchesInfo; var documentFields = __rest(hit, ["_formatted", "_matchesInfo"]);
var formattedHit = hit._formatted; hit._matchesPosition; var documentFields = __rest(hit, ["_formatted", "_matchesPosition"]);
var adaptedHit = Object.assign(documentFields, adaptFormattedFields(formattedHit));

@@ -768,12 +767,7 @@ if (primaryKey) {

var searchResponseOptionals = {};
var facets = searchResponse.facetsDistribution;
var facets = searchResponse.facetDistribution;
var pagination = searchContext.pagination;
var exhaustiveFacetsCount = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.exhaustiveFacetsCount;
if (exhaustiveFacetsCount) {
searchResponseOptionals.exhaustiveFacetsCount = exhaustiveFacetsCount;
}
var nbPages = ceiledDivision(searchResponse.hits.length, pagination.hitsPerPage);
var hits = adaptHits(searchResponse.hits, searchContext, pagination);
var exhaustiveNbHits = searchResponse.exhaustiveNbHits;
var nbHits = searchResponse.nbHits;
var estimatedTotalHits = searchResponse.estimatedTotalHits;
var processingTimeMs = searchResponse.processingTimeMs;

@@ -783,3 +777,3 @@ var query = searchResponse.query;

// Create response object compliant with InstantSearch
var adaptedSearchResponse = __assign({ index: searchContext.indexUid, hitsPerPage: hitsPerPage, page: page, facets: facets, nbPages: nbPages, exhaustiveNbHits: exhaustiveNbHits, nbHits: nbHits, processingTimeMS: processingTimeMs, query: query, hits: hits, params: '' }, searchResponseOptionals);
var adaptedSearchResponse = __assign({ index: searchContext.indexUid, hitsPerPage: hitsPerPage, page: page, facets: facets, nbPages: nbPages, nbHits: estimatedTotalHits, processingTimeMS: processingTimeMs, query: query, hits: hits, params: '', exhaustiveNbHits: false }, searchResponseOptionals);
return {

@@ -850,6 +844,6 @@ results: [adaptedSearchResponse]

function cacheFirstFacetsDistribution(defaultFacetDistribution, searchResponse) {
function cacheFirstFacetDistribution(defaultFacetDistribution, searchResponse) {
if (searchResponse.query === '' &&
Object.keys(defaultFacetDistribution).length === 0) {
return searchResponse.facetsDistribution;
return searchResponse.facetDistribution;
}

@@ -859,2 +853,10 @@ return defaultFacetDistribution;

var PACKAGE_VERSION = '0.8.0-beta.0';
var constructClientAgents = function (clientAgents) {
if (clientAgents === void 0) { clientAgents = []; }
var instantMeilisearchAgent = "Meilisearch instant-meilisearch (v".concat(PACKAGE_VERSION, ")");
return clientAgents.concat(instantMeilisearchAgent);
};
/**

@@ -875,3 +877,8 @@ * Instanciate SearchClient required by instantsearch.js.

var defaultFacetDistribution = {};
var meilisearchClient = new meilisearch.MeiliSearch({ host: hostUrl, apiKey: apiKey });
var clientAgents = constructClientAgents(instantMeiliSearchOptions.clientAgents);
var meilisearchClient = new meilisearch.MeiliSearch({
host: hostUrl,
apiKey: apiKey,
clientAgents: clientAgents
});
return {

@@ -894,3 +901,3 @@ /**

// Cache first facets distribution of the instantMeilisearch instance
// Needed to add in the facetsDistribution the fields that were not returned
// Needed to add in the facetDistribution the fields that were not returned
// When the user sets `keepZeroFacets` to true.

@@ -901,5 +908,5 @@ ];

// Cache first facets distribution of the instantMeilisearch instance
// Needed to add in the facetsDistribution the fields that were not returned
// Needed to add in the facetDistribution the fields that were not returned
// When the user sets `keepZeroFacets` to true.
defaultFacetDistribution = cacheFirstFacetsDistribution(defaultFacetDistribution, searchResponse);
defaultFacetDistribution = cacheFirstFacetDistribution(defaultFacetDistribution, searchResponse);
adaptedSearchResponse = adaptSearchResponse(searchResponse, searchContext);

@@ -906,0 +913,0 @@ return [2 /*return*/, adaptedSearchResponse];

@@ -15,3 +15,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("meilisearch"),e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function n(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{s(r.next(t))}catch(t){a(t)}}function u(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}s((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[]};function u(t){var n=function(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})):o(t)})).flat(2):[]}(t);return n.filter((function(t){return void 0!==t})).reduce((function(t,n){var r,a=n.filterName,o=n.value,u=t[a]||[];return t=e(e({},t),((r={})[a]=i(i([],u),[o]),r))}),{})}function s(t,n){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,n){var i,a=Object.keys(r[n]);return e(e({},t),((i={})[n]=a,i))}),{})):u(null==n?void 0:n.filter);var r}var l={hits:[],query:"",facetsDistribution:{},limit:0,offset:0,exhaustiveNbHits:!1,nbHits:0,processingTimeMs:0};function c(t){return{searchResponse:function(e,i,a){return n(this,void 0,void 0,(function(){var n,o,u,c,f,h,p,g;return r(this,(function(r){switch(r.label){case 0:return n=e.placeholderSearch,o=e.query,n||o?(u=e.pagination,c=e.finitePagination?{}:u,f=t.formatKey([i,e.indexUid,e.query,c]),(h=t.getEntry(f))?[2,h]:(p=s(e,i),[4,a.index(e.indexUid).search(e.query,i)])):[2,l];case 1:return(g=r.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var n in t){e[n]||(e[n]={});for(var r=0,i=t[n];r<i.length;r++){var a=i[r];Object.keys(e[n]).includes(a)||(e[n][a]=0)}}return e}(p,g.facetsDistribution),t.setEntry(f,g),[2,g]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function p(t){if(t){var e,n,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(e=i),null==a&&null==o||(n=null!=a?a:o),r&&"string"==typeof r){var u=r.split(","),s=u[0],l=u[1],c=u[2],p=u[3],g=[parseFloat(s),parseFloat(l),parseFloat(c),parseFloat(p)],d=g[0],v=g[1],y=g[2],b=g[3];n=function(t,e,n,r){var i=t*Math.PI/180,a=n*Math.PI/180,o=(n-t)*Math.PI/180,u=(r-e)*Math.PI/180,s=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371e3}(d,v,y,b)/2,e=function(t,e,n,r){t=h(t),e=h(e);var i=Math.cos(t)*Math.cos(e),a=Math.cos(t)*Math.sin(e),o=Math.sin(t);n=h(n),r=h(r);var u=i+Math.cos(n)*Math.cos(r),s=a+Math.cos(n)*Math.sin(r),l=o+Math.sin(n),c=Math.sqrt(u*u+s*s),p=Math.atan2(s,u),g=Math.atan2(l,c);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(g+=Math.PI,p+=Math.PI):(g=f(g),p=f(p)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(l)<Math.pow(10,-9)&&(g=0,p=0),"".concat(g,",").concat(p)}(d,v,y,b)}if(null!=e&&null!=n){var m=e.split(","),P=m[0],M=m[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(n,")")}}}}function g(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function d(t){return""===t?[]:"string"==typeof t?[t]:t}function v(t,e,n){return function(t,e,n){var r=n.trim(),a=d(t),o=d(e);return i(i(i([],a),o),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(g(n||[]),g(e||[]),t||"")}function y(t){var e={},n=null==t?void 0:t.facets;(null==n?void 0:n.length)&&(e.facetsDistribution=n);var r=null==t?void 0:t.attributesToSnippet;r&&(e.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(e.cropMarker=i);var a=null==t?void 0:t.attributesToRetrieve;a&&(e.attributesToRetrieve=a);var o=v(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);o.length&&(e.filter=o),a&&(e.attributesToCrop=a),e.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;e.highlightPreTag=u||"__ais-highlight__";var s=null==t?void 0:t.highlightPostTag;e.highlightPostTag=s||"__/ais-highlight__";var l=t.placeholderSearch,c=t.query,f=t.pagination;if(!l&&""===c||0===f.paginationTotalHits)e.limit=0;else if(t.finitePagination)e.limit=f.paginationTotalHits;else{var h=(f.page+1)*f.hitsPerPage+1;h>f.paginationTotalHits?e.limit=f.paginationTotalHits:e.limit=h}var g=t.sort;(null==g?void 0:g.length)&&(e.sort=[g]);var d=p(function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,s=t.insidePolygon;return n&&(e.aroundLatLng=n),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(e.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(e.minimumAroundRadius=o),u&&(e.insideBoundingBox=u),s&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t));return(null==d?void 0:d.filter)&&(e.filter?e.filter.unshift(d.filter):e.filter=[d.filter]),e}function b(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function m(t){return Array.isArray(t)?t.map((function(t){return m(t)})):"object"!=typeof(e=t)||Array.isArray(e)||null===e?{value:b(t)}:Object.keys(t).reduce((function(e,n){return e[n]=m(t[n]),e}),{});var e}function P(t,e,n){var r=e.primaryKey,i=n.hitsPerPage,a=function(t,e,n){if(n<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=e*n;return t.slice(r,r+n)}(t,n.page,i).map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesInfo;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesInfo"]),i=Object.assign(n,function(t){if(!t)return{};var e=m(t);return{_highlightResult:e,_snippetResult:e}}(e));return r&&(i.objectID=t[r]),i}return t}));return a=function(t){for(var e=0;e<t.length;e++)t[e]._geo&&(t[e]._geoloc={lat:t[e]._geo.lat,lng:t[e]._geo.lng},t[e].objectID="".concat(e+1e6*Math.random()),delete t[e]._geo);return t}(a)}function M(t,n){var r={},i=t.facetsDistribution,a=n.pagination,o=null==t?void 0:t.exhaustiveFacetsCount;o&&(r.exhaustiveFacetsCount=o);var u,s,l=(u=t.hits.length,(s=a.hitsPerPage)>0?Math.ceil(u/s):0),c=P(t.hits,n,a),f=t.exhaustiveNbHits,h=t.nbHits,p=t.processingTimeMs,g=t.query,d=a.hitsPerPage,v=a.page;return{results:[e({index:n.indexUid,hitsPerPage:d,page:v,facets:i,nbPages:l,exhaustiveNbHits:f,nbHits:h,processingTimeMS:p,query:g,hits:c,params:""},r)]}}function w(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(n){return e[t]}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)}}}exports.instantMeiliSearch=function(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u=c(w()),s={},l=new t.MeiliSearch({host:i,apiKey:a});return{search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,c,f;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),u=t.params,s=function(t){var e=t.paginationTotalHits,n=t.hitsPerPage;return{paginationTotalHits:null!=e?e:200,hitsPerPage:void 0===n?20:n,page:t.page||0}}({paginationTotalHits:n.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return e(e(e({},n),u),{sort:o.join(":")||"",indexUid:a,pagination:s,defaultFacetDistribution:r,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination})}(n,o,s),a=y(i),[4,u.searchResponse(i,a,l)];case 1:return c=r.sent(),s=function(t,e){return""===e.query&&0===Object.keys(t).length?e.facetsDistribution:t}(s,c),[2,M(c,i)];case 2:throw f=r.sent(),console.error(f),new Error(f);case 3:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}};
***************************************************************************** */function n(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{s(r.next(t))}catch(t){a(t)}}function u(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}s((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[]};function u(t){var n=function(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})):o(t)})).flat(2):[]}(t);return n.filter((function(t){return void 0!==t})).reduce((function(t,n){var r,a=n.filterName,o=n.value,u=t[a]||[];return t=e(e({},t),((r={})[a]=i(i([],u),[o]),r))}),{})}function s(t,n){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,n){var i,a=Object.keys(r[n]);return e(e({},t),((i={})[n]=a,i))}),{})):u(null==n?void 0:n.filter);var r}var c={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function l(t){return{searchResponse:function(e,i,a){return n(this,void 0,void 0,(function(){var n,o,u,l,f,h,p,g;return r(this,(function(r){switch(r.label){case 0:return n=e.placeholderSearch,o=e.query,n||o?(u=e.pagination,l=e.finitePagination?{}:u,f=t.formatKey([i,e.indexUid,e.query,l]),(h=t.getEntry(f))?[2,h]:(p=s(e,i),[4,a.index(e.indexUid).search(e.query,i)])):[2,c];case 1:return(g=r.sent()).facetDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var n in t){e[n]||(e[n]={});for(var r=0,i=t[n];r<i.length;r++){var a=i[r];Object.keys(e[n]).includes(a)||(e[n][a]=0)}}return e}(p,g.facetDistribution),t.setEntry(f,g),[2,g]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function p(t){if(t){var e,n,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(e=i),null==a&&null==o||(n=null!=a?a:o),r&&"string"==typeof r){var u=r.split(","),s=u[0],c=u[1],l=u[2],p=u[3],g=[parseFloat(s),parseFloat(c),parseFloat(l),parseFloat(p)],d=g[0],v=g[1],y=g[2],b=g[3];n=function(t,e,n,r){var i=t*Math.PI/180,a=n*Math.PI/180,o=(n-t)*Math.PI/180,u=(r-e)*Math.PI/180,s=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371e3}(d,v,y,b)/2,e=function(t,e,n,r){t=h(t),e=h(e);var i=Math.cos(t)*Math.cos(e),a=Math.cos(t)*Math.sin(e),o=Math.sin(t);n=h(n),r=h(r);var u=i+Math.cos(n)*Math.cos(r),s=a+Math.cos(n)*Math.sin(r),c=o+Math.sin(n),l=Math.sqrt(u*u+s*s),p=Math.atan2(s,u),g=Math.atan2(c,l);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(g+=Math.PI,p+=Math.PI):(g=f(g),p=f(p)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(g=0,p=0),"".concat(g,",").concat(p)}(d,v,y,b)}if(null!=e&&null!=n){var m=e.split(","),P=m[0],M=m[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(n,")")}}}}function g(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function d(t){return""===t?[]:"string"==typeof t?[t]:t}function v(t,e,n){return function(t,e,n){var r=n.trim(),a=d(t),o=d(e);return i(i(i([],a),o),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(g(n||[]),g(e||[]),t||"")}function y(t){var e={},n=null==t?void 0:t.facets;(null==n?void 0:n.length)&&(e.facets=n);var r=null==t?void 0:t.attributesToSnippet;r&&(e.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(e.cropMarker=i);var a=null==t?void 0:t.attributesToRetrieve;a&&(e.attributesToRetrieve=a);var o=v(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);o.length&&(e.filter=o),a&&(e.attributesToCrop=a),e.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;e.highlightPreTag=u||"__ais-highlight__";var s=null==t?void 0:t.highlightPostTag;e.highlightPostTag=s||"__/ais-highlight__";var c=t.placeholderSearch,l=t.query,f=t.pagination;if(!c&&""===l||0===f.paginationTotalHits)e.limit=0;else if(t.finitePagination)e.limit=f.paginationTotalHits;else{var h=(f.page+1)*f.hitsPerPage+1;h>f.paginationTotalHits?e.limit=f.paginationTotalHits:e.limit=h}var g=t.sort;(null==g?void 0:g.length)&&(e.sort=[g]);var d=p(function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,s=t.insidePolygon;return n&&(e.aroundLatLng=n),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(e.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(e.minimumAroundRadius=o),u&&(e.insideBoundingBox=u),s&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t));return(null==d?void 0:d.filter)&&(e.filter?e.filter.unshift(d.filter):e.filter=[d.filter]),e}function b(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function m(t){return Array.isArray(t)?t.map((function(t){return m(t)})):"object"!=typeof(e=t)||Array.isArray(e)||null===e?{value:b(t)}:Object.keys(t).reduce((function(e,n){return e[n]=m(t[n]),e}),{});var e}function P(t,e,n){var r=e.primaryKey,i=n.hitsPerPage,a=function(t,e,n){if(n<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=e*n;return t.slice(r,r+n)}(t,n.page,i).map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesPosition"]),i=Object.assign(n,function(t){if(!t)return{};var e=m(t);return{_highlightResult:e,_snippetResult:e}}(e));return r&&(i.objectID=t[r]),i}return t}));return a=function(t){for(var e=0;e<t.length;e++)t[e]._geo&&(t[e]._geoloc={lat:t[e]._geo.lat,lng:t[e]._geo.lng},t[e].objectID="".concat(e+1e6*Math.random()),delete t[e]._geo);return t}(a)}function M(t,n){var r,i,a=t.facetDistribution,o=n.pagination,u=(r=t.hits.length,(i=o.hitsPerPage)>0?Math.ceil(r/i):0),s=P(t.hits,n,o),c=t.estimatedTotalHits,l=t.processingTimeMs,f=t.query,h=o.hitsPerPage,p=o.page;return{results:[e({index:n.indexUid,hitsPerPage:h,page:p,facets:a,nbPages:u,nbHits:c,processingTimeMS:l,query:f,hits:s,params:"",exhaustiveNbHits:!1},{})]}}function w(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(n){return e[t]}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)}}}exports.instantMeiliSearch=function(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u=l(w()),s={},c=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.8.0-beta.0",")");return t.concat(e)}(o.clientAgents),f=new t.MeiliSearch({host:i,apiKey:a,clientAgents:c});return{search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,c,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),u=t.params,s=function(t){var e=t.paginationTotalHits,n=t.hitsPerPage;return{paginationTotalHits:null!=e?e:200,hitsPerPage:void 0===n?20:n,page:t.page||0}}({paginationTotalHits:n.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return e(e(e({},n),u),{sort:o.join(":")||"",indexUid:a,pagination:s,defaultFacetDistribution:r,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination})}(n,o,s),a=y(i),[4,u.searchResponse(i,a,f)];case 1:return c=r.sent(),s=function(t,e){return""===e.query&&0===Object.keys(t).length?e.facetDistribution:t}(s,c),[2,M(c,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}};
//# sourceMappingURL=instant-meilisearch.cjs.min.js.map

@@ -174,6 +174,6 @@ import { MeiliSearch } from 'meilisearch';

}
function getFacetsFromDefaultDistribution(facetsDistribution) {
return Object.keys(facetsDistribution).reduce(function (cache, facet) {
function getFacetsFromDefaultDistribution(facetDistribution) {
return Object.keys(facetDistribution).reduce(function (cache, facet) {
var _a;
var facetValues = Object.keys(facetsDistribution[facet]);
var facetValues = Object.keys(facetDistribution[facet]);
return __assign(__assign({}, cache), (_a = {}, _a[facet] = facetValues, _a));

@@ -195,4 +195,4 @@ }, {});

/**
* Assign missing filters to facetsDistribution.
* All facet passed as filter should appear in the facetsDistribution.
* Assign missing filters to facetDistribution.
* All facets passed as filter should appear in the facetDistribution.
* If not present, the facet is added with 0 as value.

@@ -232,7 +232,6 @@ *

query: '',
facetsDistribution: {},
facetDistribution: {},
limit: 0,
offset: 0,
exhaustiveNbHits: false,
nbHits: 0,
estimatedTotalHits: 0,
processingTimeMs: 0

@@ -279,8 +278,8 @@ };

.search(searchContext.query, searchParams)
// Add missing facets back into facetsDistribution
// Add missing facets back into facetDistribution
];
case 1:
searchResponse = _a.sent();
// Add missing facets back into facetsDistribution
searchResponse.facetsDistribution = addMissingFacets(facetsCache, searchResponse.facetsDistribution);
// Add missing facets back into facetDistribution
searchResponse.facetDistribution = addMissingFacets(facetsCache, searchResponse.facetDistribution);
// Cache response

@@ -534,3 +533,3 @@ cache.setEntry(key, searchResponse);

if (facets === null || facets === void 0 ? void 0 : facets.length) {
meiliSearchParams.facetsDistribution = facets;
meiliSearchParams.facets = facets;
}

@@ -739,3 +738,3 @@ // Attributes To Crop

if (Object.keys(hit).length > 0) {
var formattedHit = hit._formatted; hit._matchesInfo; var documentFields = __rest(hit, ["_formatted", "_matchesInfo"]);
var formattedHit = hit._formatted; hit._matchesPosition; var documentFields = __rest(hit, ["_formatted", "_matchesPosition"]);
var adaptedHit = Object.assign(documentFields, adaptFormattedFields(formattedHit));

@@ -764,12 +763,7 @@ if (primaryKey) {

var searchResponseOptionals = {};
var facets = searchResponse.facetsDistribution;
var facets = searchResponse.facetDistribution;
var pagination = searchContext.pagination;
var exhaustiveFacetsCount = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.exhaustiveFacetsCount;
if (exhaustiveFacetsCount) {
searchResponseOptionals.exhaustiveFacetsCount = exhaustiveFacetsCount;
}
var nbPages = ceiledDivision(searchResponse.hits.length, pagination.hitsPerPage);
var hits = adaptHits(searchResponse.hits, searchContext, pagination);
var exhaustiveNbHits = searchResponse.exhaustiveNbHits;
var nbHits = searchResponse.nbHits;
var estimatedTotalHits = searchResponse.estimatedTotalHits;
var processingTimeMs = searchResponse.processingTimeMs;

@@ -779,3 +773,3 @@ var query = searchResponse.query;

// Create response object compliant with InstantSearch
var adaptedSearchResponse = __assign({ index: searchContext.indexUid, hitsPerPage: hitsPerPage, page: page, facets: facets, nbPages: nbPages, exhaustiveNbHits: exhaustiveNbHits, nbHits: nbHits, processingTimeMS: processingTimeMs, query: query, hits: hits, params: '' }, searchResponseOptionals);
var adaptedSearchResponse = __assign({ index: searchContext.indexUid, hitsPerPage: hitsPerPage, page: page, facets: facets, nbPages: nbPages, nbHits: estimatedTotalHits, processingTimeMS: processingTimeMs, query: query, hits: hits, params: '', exhaustiveNbHits: false }, searchResponseOptionals);
return {

@@ -846,6 +840,6 @@ results: [adaptedSearchResponse]

function cacheFirstFacetsDistribution(defaultFacetDistribution, searchResponse) {
function cacheFirstFacetDistribution(defaultFacetDistribution, searchResponse) {
if (searchResponse.query === '' &&
Object.keys(defaultFacetDistribution).length === 0) {
return searchResponse.facetsDistribution;
return searchResponse.facetDistribution;
}

@@ -855,2 +849,10 @@ return defaultFacetDistribution;

var PACKAGE_VERSION = '0.8.0-beta.0';
var constructClientAgents = function (clientAgents) {
if (clientAgents === void 0) { clientAgents = []; }
var instantMeilisearchAgent = "Meilisearch instant-meilisearch (v".concat(PACKAGE_VERSION, ")");
return clientAgents.concat(instantMeilisearchAgent);
};
/**

@@ -871,3 +873,8 @@ * Instanciate SearchClient required by instantsearch.js.

var defaultFacetDistribution = {};
var meilisearchClient = new MeiliSearch({ host: hostUrl, apiKey: apiKey });
var clientAgents = constructClientAgents(instantMeiliSearchOptions.clientAgents);
var meilisearchClient = new MeiliSearch({
host: hostUrl,
apiKey: apiKey,
clientAgents: clientAgents
});
return {

@@ -890,3 +897,3 @@ /**

// Cache first facets distribution of the instantMeilisearch instance
// Needed to add in the facetsDistribution the fields that were not returned
// Needed to add in the facetDistribution the fields that were not returned
// When the user sets `keepZeroFacets` to true.

@@ -897,5 +904,5 @@ ];

// Cache first facets distribution of the instantMeilisearch instance
// Needed to add in the facetsDistribution the fields that were not returned
// Needed to add in the facetDistribution the fields that were not returned
// When the user sets `keepZeroFacets` to true.
defaultFacetDistribution = cacheFirstFacetsDistribution(defaultFacetDistribution, searchResponse);
defaultFacetDistribution = cacheFirstFacetDistribution(defaultFacetDistribution, searchResponse);
adaptedSearchResponse = adaptSearchResponse(searchResponse, searchContext);

@@ -902,0 +909,0 @@ return [2 /*return*/, adaptedSearchResponse];

@@ -15,3 +15,3 @@ import{MeiliSearch as t}from"meilisearch";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var n=function(){return(n=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t}).apply(this,arguments)};function e(t,n,e,r){return new(e||(e=Promise))((function(i,a){function o(t){try{s(r.next(t))}catch(t){a(t)}}function u(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(o,u)}s((r=r.apply(t,n||[])).next())}))}function r(t,n){var e,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;o;)try{if(e=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=n.call(t,o)}catch(t){a=[6,t],r=0}finally{e=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var n=t.match(/([^=]*)="?([^\\"]*)"?$/);return n?(n[0],[{filterName:n[1],value:n[2]}]):[]};function u(t){var e=function(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})):o(t)})).flat(2):[]}(t);return e.filter((function(t){return void 0!==t})).reduce((function(t,e){var r,a=e.filterName,o=e.value,u=t[a]||[];return t=n(n({},t),((r={})[a]=i(i([],u),[o]),r))}),{})}function s(t,e){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,e){var i,a=Object.keys(r[e]);return n(n({},t),((i={})[e]=a,i))}),{})):u(null==e?void 0:e.filter);var r}var l={hits:[],query:"",facetsDistribution:{},limit:0,offset:0,exhaustiveNbHits:!1,nbHits:0,processingTimeMs:0};function c(t){return{searchResponse:function(n,i,a){return e(this,void 0,void 0,(function(){var e,o,u,c,f,h,p,g;return r(this,(function(r){switch(r.label){case 0:return e=n.placeholderSearch,o=n.query,e||o?(u=n.pagination,c=n.finitePagination?{}:u,f=t.formatKey([i,n.indexUid,n.query,c]),(h=t.getEntry(f))?[2,h]:(p=s(n,i),[4,a.index(n.indexUid).search(n.query,i)])):[2,l];case 1:return(g=r.sent()).facetsDistribution=function(t,n){if(n=n||{},t&&Object.keys(t).length>0)for(var e in t){n[e]||(n[e]={});for(var r=0,i=t[e];r<i.length;r++){var a=i[r];Object.keys(n[e]).includes(a)||(n[e][a]=0)}}return n}(p,g.facetsDistribution),t.setEntry(f,g),[2,g]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function p(t){if(t){var n,e,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(n=i),null==a&&null==o||(e=null!=a?a:o),r&&"string"==typeof r){var u=r.split(","),s=u[0],l=u[1],c=u[2],p=u[3],g=[parseFloat(s),parseFloat(l),parseFloat(c),parseFloat(p)],d=g[0],v=g[1],y=g[2],b=g[3];e=function(t,n,e,r){var i=t*Math.PI/180,a=e*Math.PI/180,o=(e-t)*Math.PI/180,u=(r-n)*Math.PI/180,s=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371e3}(d,v,y,b)/2,n=function(t,n,e,r){t=h(t),n=h(n);var i=Math.cos(t)*Math.cos(n),a=Math.cos(t)*Math.sin(n),o=Math.sin(t);e=h(e),r=h(r);var u=i+Math.cos(e)*Math.cos(r),s=a+Math.cos(e)*Math.sin(r),l=o+Math.sin(e),c=Math.sqrt(u*u+s*s),p=Math.atan2(s,u),g=Math.atan2(l,c);return n<r||n>r&&n>Math.PI&&r<-Math.PI?(g+=Math.PI,p+=Math.PI):(g=f(g),p=f(p)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(l)<Math.pow(10,-9)&&(g=0,p=0),"".concat(g,",").concat(p)}(d,v,y,b)}if(null!=n&&null!=e){var m=n.split(","),P=m[0],M=m[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(e,")")}}}}function g(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function d(t){return""===t?[]:"string"==typeof t?[t]:t}function v(t,n,e){return function(t,n,e){var r=e.trim(),a=d(t),o=d(n);return i(i(i([],a),o),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(g(e||[]),g(n||[]),t||"")}function y(t){var n={},e=null==t?void 0:t.facets;(null==e?void 0:e.length)&&(n.facetsDistribution=e);var r=null==t?void 0:t.attributesToSnippet;r&&(n.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(n.cropMarker=i);var a=null==t?void 0:t.attributesToRetrieve;a&&(n.attributesToRetrieve=a);var o=v(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);o.length&&(n.filter=o),a&&(n.attributesToCrop=a),n.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;n.highlightPreTag=u||"__ais-highlight__";var s=null==t?void 0:t.highlightPostTag;n.highlightPostTag=s||"__/ais-highlight__";var l=t.placeholderSearch,c=t.query,f=t.pagination;if(!l&&""===c||0===f.paginationTotalHits)n.limit=0;else if(t.finitePagination)n.limit=f.paginationTotalHits;else{var h=(f.page+1)*f.hitsPerPage+1;h>f.paginationTotalHits?n.limit=f.paginationTotalHits:n.limit=h}var g=t.sort;(null==g?void 0:g.length)&&(n.sort=[g]);var d=p(function(t){var n={},e=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,s=t.insidePolygon;return e&&(n.aroundLatLng=e),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(n.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(n.minimumAroundRadius=o),u&&(n.insideBoundingBox=u),s&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),n}(t));return(null==d?void 0:d.filter)&&(n.filter?n.filter.unshift(d.filter):n.filter=[d.filter]),n}function b(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function m(t){return Array.isArray(t)?t.map((function(t){return m(t)})):"object"!=typeof(n=t)||Array.isArray(n)||null===n?{value:b(t)}:Object.keys(t).reduce((function(n,e){return n[e]=m(t[e]),n}),{});var n}function P(t,n,e){var r=n.primaryKey,i=e.hitsPerPage,a=function(t,n,e){if(e<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=n*e;return t.slice(r,r+e)}(t,e.page,i).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesInfo;var e=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]])}return e}(t,["_formatted","_matchesInfo"]),i=Object.assign(e,function(t){if(!t)return{};var n=m(t);return{_highlightResult:n,_snippetResult:n}}(n));return r&&(i.objectID=t[r]),i}return t}));return a=function(t){for(var n=0;n<t.length;n++)t[n]._geo&&(t[n]._geoloc={lat:t[n]._geo.lat,lng:t[n]._geo.lng},t[n].objectID="".concat(n+1e6*Math.random()),delete t[n]._geo);return t}(a)}function M(t,e){var r={},i=t.facetsDistribution,a=e.pagination,o=null==t?void 0:t.exhaustiveFacetsCount;o&&(r.exhaustiveFacetsCount=o);var u,s,l=(u=t.hits.length,(s=a.hitsPerPage)>0?Math.ceil(u/s):0),c=P(t.hits,e,a),f=t.exhaustiveNbHits,h=t.nbHits,p=t.processingTimeMs,g=t.query,d=a.hitsPerPage,v=a.page;return{results:[n({index:e.indexUid,hitsPerPage:d,page:v,facets:i,nbPages:l,exhaustiveNbHits:f,nbHits:h,processingTimeMS:p,query:g,hits:c,params:""},r)]}}function w(t){void 0===t&&(t={});var n=t;return{getEntry:function(t){if(n[t])try{return JSON.parse(n[t])}catch(e){return n[t]}},formatKey:function(t){return t.reduce((function(t,n){return t+JSON.stringify(n)}),"")},setEntry:function(t,e){n[t]=JSON.stringify(e)}}}function x(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u=c(w()),s={},l=new t({host:i,apiKey:a});return{search:function(t){return e(this,void 0,void 0,(function(){var e,i,a,c,f;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=t[0],i=function(t,e,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),u=t.params,s=function(t){var n=t.paginationTotalHits,e=t.hitsPerPage;return{paginationTotalHits:null!=n?n:200,hitsPerPage:void 0===e?20:e,page:t.page||0}}({paginationTotalHits:e.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return n(n(n({},e),u),{sort:o.join(":")||"",indexUid:a,pagination:s,defaultFacetDistribution:r,placeholderSearch:!1!==e.placeholderSearch,keepZeroFacets:!!e.keepZeroFacets,finitePagination:!!e.finitePagination})}(e,o,s),a=y(i),[4,u.searchResponse(i,a,l)];case 1:return c=r.sent(),s=function(t,n){return""===n.query&&0===Object.keys(t).length?n.facetsDistribution:t}(s,c),[2,M(c,i)];case 2:throw f=r.sent(),console.error(f),new Error(f);case 3:return[2]}}))}))},searchForFacetValues:function(t){return e(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){n(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}}export{x as instantMeiliSearch};
***************************************************************************** */var n=function(){return(n=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t}).apply(this,arguments)};function e(t,n,e,r){return new(e||(e=Promise))((function(i,a){function o(t){try{s(r.next(t))}catch(t){a(t)}}function u(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(o,u)}s((r=r.apply(t,n||[])).next())}))}function r(t,n){var e,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;o;)try{if(e=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=n.call(t,o)}catch(t){a=[6,t],r=0}finally{e=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var n=t.match(/([^=]*)="?([^\\"]*)"?$/);return n?(n[0],[{filterName:n[1],value:n[2]}]):[]};function u(t){var e=function(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})):o(t)})).flat(2):[]}(t);return e.filter((function(t){return void 0!==t})).reduce((function(t,e){var r,a=e.filterName,o=e.value,u=t[a]||[];return t=n(n({},t),((r={})[a]=i(i([],u),[o]),r))}),{})}function s(t,e){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,e){var i,a=Object.keys(r[e]);return n(n({},t),((i={})[e]=a,i))}),{})):u(null==e?void 0:e.filter);var r}var c={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function l(t){return{searchResponse:function(n,i,a){return e(this,void 0,void 0,(function(){var e,o,u,l,f,h,p,g;return r(this,(function(r){switch(r.label){case 0:return e=n.placeholderSearch,o=n.query,e||o?(u=n.pagination,l=n.finitePagination?{}:u,f=t.formatKey([i,n.indexUid,n.query,l]),(h=t.getEntry(f))?[2,h]:(p=s(n,i),[4,a.index(n.indexUid).search(n.query,i)])):[2,c];case 1:return(g=r.sent()).facetDistribution=function(t,n){if(n=n||{},t&&Object.keys(t).length>0)for(var e in t){n[e]||(n[e]={});for(var r=0,i=t[e];r<i.length;r++){var a=i[r];Object.keys(n[e]).includes(a)||(n[e][a]=0)}}return n}(p,g.facetDistribution),t.setEntry(f,g),[2,g]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function p(t){if(t){var n,e,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(n=i),null==a&&null==o||(e=null!=a?a:o),r&&"string"==typeof r){var u=r.split(","),s=u[0],c=u[1],l=u[2],p=u[3],g=[parseFloat(s),parseFloat(c),parseFloat(l),parseFloat(p)],d=g[0],v=g[1],y=g[2],m=g[3];e=function(t,n,e,r){var i=t*Math.PI/180,a=e*Math.PI/180,o=(e-t)*Math.PI/180,u=(r-n)*Math.PI/180,s=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371e3}(d,v,y,m)/2,n=function(t,n,e,r){t=h(t),n=h(n);var i=Math.cos(t)*Math.cos(n),a=Math.cos(t)*Math.sin(n),o=Math.sin(t);e=h(e),r=h(r);var u=i+Math.cos(e)*Math.cos(r),s=a+Math.cos(e)*Math.sin(r),c=o+Math.sin(e),l=Math.sqrt(u*u+s*s),p=Math.atan2(s,u),g=Math.atan2(c,l);return n<r||n>r&&n>Math.PI&&r<-Math.PI?(g+=Math.PI,p+=Math.PI):(g=f(g),p=f(p)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(g=0,p=0),"".concat(g,",").concat(p)}(d,v,y,m)}if(null!=n&&null!=e){var b=n.split(","),P=b[0],M=b[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(e,")")}}}}function g(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function d(t){return""===t?[]:"string"==typeof t?[t]:t}function v(t,n,e){return function(t,n,e){var r=e.trim(),a=d(t),o=d(n);return i(i(i([],a),o),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(g(e||[]),g(n||[]),t||"")}function y(t){var n={},e=null==t?void 0:t.facets;(null==e?void 0:e.length)&&(n.facets=e);var r=null==t?void 0:t.attributesToSnippet;r&&(n.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(n.cropMarker=i);var a=null==t?void 0:t.attributesToRetrieve;a&&(n.attributesToRetrieve=a);var o=v(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);o.length&&(n.filter=o),a&&(n.attributesToCrop=a),n.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;n.highlightPreTag=u||"__ais-highlight__";var s=null==t?void 0:t.highlightPostTag;n.highlightPostTag=s||"__/ais-highlight__";var c=t.placeholderSearch,l=t.query,f=t.pagination;if(!c&&""===l||0===f.paginationTotalHits)n.limit=0;else if(t.finitePagination)n.limit=f.paginationTotalHits;else{var h=(f.page+1)*f.hitsPerPage+1;h>f.paginationTotalHits?n.limit=f.paginationTotalHits:n.limit=h}var g=t.sort;(null==g?void 0:g.length)&&(n.sort=[g]);var d=p(function(t){var n={},e=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,s=t.insidePolygon;return e&&(n.aroundLatLng=e),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(n.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(n.minimumAroundRadius=o),u&&(n.insideBoundingBox=u),s&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),n}(t));return(null==d?void 0:d.filter)&&(n.filter?n.filter.unshift(d.filter):n.filter=[d.filter]),n}function m(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function b(t){return Array.isArray(t)?t.map((function(t){return b(t)})):"object"!=typeof(n=t)||Array.isArray(n)||null===n?{value:m(t)}:Object.keys(t).reduce((function(n,e){return n[e]=b(t[e]),n}),{});var n}function P(t,n,e){var r=n.primaryKey,i=e.hitsPerPage,a=function(t,n,e){if(e<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=n*e;return t.slice(r,r+e)}(t,e.page,i).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesPosition;var e=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]])}return e}(t,["_formatted","_matchesPosition"]),i=Object.assign(e,function(t){if(!t)return{};var n=b(t);return{_highlightResult:n,_snippetResult:n}}(n));return r&&(i.objectID=t[r]),i}return t}));return a=function(t){for(var n=0;n<t.length;n++)t[n]._geo&&(t[n]._geoloc={lat:t[n]._geo.lat,lng:t[n]._geo.lng},t[n].objectID="".concat(n+1e6*Math.random()),delete t[n]._geo);return t}(a)}function M(t,e){var r,i,a=t.facetDistribution,o=e.pagination,u=(r=t.hits.length,(i=o.hitsPerPage)>0?Math.ceil(r/i):0),s=P(t.hits,e,o),c=t.estimatedTotalHits,l=t.processingTimeMs,f=t.query,h=o.hitsPerPage,p=o.page;return{results:[n({index:e.indexUid,hitsPerPage:h,page:p,facets:a,nbPages:u,nbHits:c,processingTimeMS:l,query:f,hits:s,params:"",exhaustiveNbHits:!1},{})]}}function w(t){void 0===t&&(t={});var n=t;return{getEntry:function(t){if(n[t])try{return JSON.parse(n[t])}catch(e){return n[t]}},formatKey:function(t){return t.reduce((function(t,n){return t+JSON.stringify(n)}),"")},setEntry:function(t,e){n[t]=JSON.stringify(e)}}}function T(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u=l(w()),s={},c=function(t){void 0===t&&(t=[]);var n="Meilisearch instant-meilisearch (v".concat("0.8.0-beta.0",")");return t.concat(n)}(o.clientAgents),f=new t({host:i,apiKey:a,clientAgents:c});return{search:function(t){return e(this,void 0,void 0,(function(){var e,i,a,c,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=t[0],i=function(t,e,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),u=t.params,s=function(t){var n=t.paginationTotalHits,e=t.hitsPerPage;return{paginationTotalHits:null!=n?n:200,hitsPerPage:void 0===e?20:e,page:t.page||0}}({paginationTotalHits:e.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return n(n(n({},e),u),{sort:o.join(":")||"",indexUid:a,pagination:s,defaultFacetDistribution:r,placeholderSearch:!1!==e.placeholderSearch,keepZeroFacets:!!e.keepZeroFacets,finitePagination:!!e.finitePagination})}(e,o,s),a=y(i),[4,u.searchResponse(i,a,f)];case 1:return c=r.sent(),s=function(t,n){return""===n.query&&0===Object.keys(t).length?n.facetDistribution:t}(s,c),[2,M(c,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return e(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){n(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}}export{T as instantMeiliSearch};
//# sourceMappingURL=instant-meilisearch.esm.min.js.map

@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t){var e={exports:{}};return t(e,e.exports),e.exports}o((function(t){!function(t){!function(e){var n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),s="FormData"in t,o="ArrayBuffer"in t;if(o)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function v(t){var e=new FileReader,n=p(e);return e.readAsArrayBuffer(t),n}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t,e,n,r=f(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=p(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,e){t=c(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},d.prototype.delete=function(t){delete this.map[c(t)]},d.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},d.prototype.set=function(t,e){this.map[c(t)]=h(e)},d.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),l(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),l(t)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var n,r,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=(n=e.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),e}function x(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},x.error=function(){var t=new x(null,{status:0,statusText:""});return t.type="error",t};var T=[301,302,303,307,308];x.redirect=function(t,e){if(-1===T.indexOf(e))throw new RangeError("Invalid status code");return new x(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function R(t,n){return new Promise((function(r,s){var o=new w(t,n);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function a(){u.abort()}u.onload=function(){var t,e,n={status:u.status,statusText:u.statusText,headers:(t=u.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}})),e)};n.url="responseURL"in u?u.responseURL:n.headers.get("X-Request-URL");var i="response"in u?u.response:u.responseText;r(new x(i,n))},u.onerror=function(){s(new TypeError("Network request failed"))},u.ontimeout=function(){s(new TypeError("Network request failed"))},u.onabort=function(){s(new e.DOMException("Aborted","AbortError"))},u.open(o.method,o.url,!0),"include"===o.credentials?u.withCredentials=!0:"omit"===o.credentials&&(u.withCredentials=!1),"responseType"in u&&i&&(u.responseType="blob"),o.headers.forEach((function(t,e){u.setRequestHeader(e,t)})),o.signal&&(o.signal.addEventListener("abort",a),u.onreadystatechange=function(){4===u.readyState&&o.signal.removeEventListener("abort",a)}),u.send(void 0===o._bodyInit?null:o._bodyInit)}))}R.polyfill=!0,t.fetch||(t.fetch=R,t.Headers=d,t.Request=w,t.Response=x),e.Headers=d,e.Request=w,e.Response=x,e.fetch=R,Object.defineProperty(e,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:s)}));var u=o((function(t,e){!function(t){
***************************************************************************** */var e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function i(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(t){var e={exports:{}};return t(e,e.exports),e.exports}s((function(t){!function(t){!function(e){var n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function v(t){var e=new FileReader,n=p(e);return e.readAsArrayBuffer(t),n}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t,e,n,r=f(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=p(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,e){t=c(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},d.prototype.delete=function(t){delete this.map[c(t)]},d.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},d.prototype.set=function(t,e){this.map[c(t)]=h(e)},d.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),l(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),l(t)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var n,r,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=(n=e.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),e}function x(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},x.error=function(){var t=new x(null,{status:0,statusText:""});return t.type="error",t};var T=[301,302,303,307,308];x.redirect=function(t,e){if(-1===T.indexOf(e))throw new RangeError("Invalid status code");return new x(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function R(t,n){return new Promise((function(r,o){var s=new w(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,n={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}})),e)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;r(new x(i,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}R.polyfill=!0,t.fetch||(t.fetch=R,t.Headers=d,t.Request=w,t.Response=x),e.Headers=d,e.Request=w,e.Response=x,e.fetch=R,Object.defineProperty(e,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:o)}));var a=s((function(t,e){!function(t){
/*! *****************************************************************************

@@ -29,3 +29,3 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){t.done?n(t.value):i(t.value).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(t){return function(e){return a([t,e])}}function a(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}var o=function(t){function e(n,r,i,s){var o,u,a,c=this;return(c=t.call(this,n)||this).name="MeiliSearchCommunicationError",c.type="MeiliSearchCommunicationError",r instanceof Response&&(c.message=r.statusText,c.statusCode=r.status),r instanceof Error&&(c.errno=r.errno,c.code=r.code),s?(c.stack=s,c.stack=null===(o=c.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,c.name),c.stack=null===(u=c.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),c.stack=null===(a=c.stack)||void 0===a?void 0:a.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(c,e),c}return n(e,t),e}(Error),u=function(t){function e(e,n){var r=t.call(this,e.message)||this;return r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Object.setPrototypeOf(r,u.prototype),Error.captureStackTrace&&Error.captureStackTrace(r,u),r}return n(e,t),e}(Error);function a(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new o(t.statusText,t,t.url);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function c(t,e,n){if("MeiliSearchApiError"!==t.type)throw new o(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),l=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function d(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function f(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}function p(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function v(t){return t.endsWith("/")||(t+="/"),t}function y(t){try{return t=v(t=p(t))}catch(t){throw new h("The provided host is not valid.")}}var b=function(){function t(t){this.headers=Object.assign({},t.headers||{}),this.headers["Content-Type"]="application/json",t.apiKey&&(this.headers.Authorization="Bearer ".concat(t.apiKey));try{var e=y(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,o=t.params,u=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,l,d,f;return s(this,(function(s){switch(s.label){case 0:t=new URL(n,this.url),o&&(i=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return i.set(t,o[t])})),t.search=i.toString()),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return a(t)}))];case 2:return[4,s.sent().text()];case 3:l=s.sent();try{return[2,JSON.parse(l)]}catch(t){return[2]}return[3,5];case 4:return d=s.sent(),f=d.stack,c(d,f,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),g=function(){function t(t){this.httpRequest=new b(t)}return t.prototype.getClientTask=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getClientTasks=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="tasks",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getIndexTask=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(t,"/tasks/").concat(e),[4,this.httpRequest.get(n)];case 1:return[2,r.sent()]}}))}))},t.prototype.getIndexTasks=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(t,"/tasks"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForClientTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<o?[4,this.getClientTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,f(a)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new l("timeout of ".concat(o,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForClientTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n,r,i,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,r=t,s.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForClientTask(i,{timeOutMs:o,intervalMs:a})]):[3,4];case 2:u=s.sent(),e.push(u),s.label=3;case 3:return n++,[3,1];case 4:return[2,{results:e}]}}))}))},t.prototype.waitForIndexTask=function(t,e,n){var r=void 0===n?{}:n,o=r.timeOutMs,u=void 0===o?5e3:o,a=r.intervalMs,c=void 0===a?50:a;return i(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){switch(i.label){case 0:n=Date.now(),i.label=1;case 1:return Date.now()-n<u?[4,this.getIndexTask(t,e)]:[3,4];case 2:return r=i.sent(),["enqueued","processing"].includes(r.status)?[4,f(c)]:[2,r];case 3:return i.sent(),[3,1];case 4:throw new l("timeout of ".concat(u,"ms has exceeded on process ").concat(e," when waiting for pending update to resolve."))}}))}))},t}(),w=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new b(t),this.tasks=new g(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,d(r(r({},e),{q:t})),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var o,u,a,c,l;return i(this,void 0,void 0,(function(){var i,f,p;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),f=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},p=r(r({q:t},e),{filter:f(null==e?void 0:e.filter),sort:null===(o=null==e?void 0:e.sort)||void 0===o?void 0:o.join(","),facetsDistribution:null===(u=null==e?void 0:e.facetsDistribution)||void 0===u?void 0:u.join(","),attributesToRetrieve:null===(a=null==e?void 0:e.attributesToRetrieve)||void 0===a?void 0:a.join(","),attributesToCrop:null===(c=null==e?void 0:e.attributesToCrop)||void 0===c?void 0:c.join(","),attributesToHighlight:null===(l=null==e?void 0:e.attributesToHighlight)||void 0===l?void 0:l.join(",")}),[4,this.httpRequest.get(i,d(p),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i="indexes",[2,new b(n).post(i,r(r({},e),{uid:t}))]}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getIndexTasks(this.uid)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getIndexTask(this.uid,t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/documents"),void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSettings=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),m=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new b(t),this.tasks=new g(t)}return t.prototype.index=function(t){return new w(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new w(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new w(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(){return i(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){switch(e.label){case 0:return[4,this.getRawIndexes()];case 1:return[2,e.sent().map((function(e){return new w(t.config,e.uid,e.primaryKey)}))]}}))}))},t.prototype.getRawIndexes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,w.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,new w(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new w(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getClientTasks()];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getClientTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="keys",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateKey=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="health",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="health",[4,this.httpRequest.get(t)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="version",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="dumps",[4,this.httpRequest.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="dumps/".concat(t,"/status"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e){var n=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(n.stack,"."))},t}());t.HttpRequests=b,t.Index=w,t.MeiliSearch=m,t.MeiliSearchApiError=u,t.MeiliSearchCommunicationError=o,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=l,t.addProtocolIfNotPresent=p,t.addTrailingSlash=v,t.default=m,t.httpErrorHandler=c,t.httpResponseErrorHandler=a,t.removeUndefinedFromObject=d,t.sleep=f,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));function a(t){return t.replace(/:(.*)/i,'="$1"')}var c=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[]};function h(t){var n=function(t){return"string"==typeof t?c(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return c(t)})):c(t)})).flat(2):[]}(t);return n.filter((function(t){return void 0!==t})).reduce((function(t,n){var r,s=n.filterName,o=n.value,u=t[s]||[];return t=e(e({},t),((r={})[s]=i(i([],u),[o]),r))}),{})}function l(t,n){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,n){var i,s=Object.keys(r[n]);return e(e({},t),((i={})[n]=s,i))}),{})):h(null==n?void 0:n.filter);var r}var d={hits:[],query:"",facetsDistribution:{},limit:0,offset:0,exhaustiveNbHits:!1,nbHits:0,processingTimeMs:0};function f(t){return{searchResponse:function(e,i,s){return n(this,void 0,void 0,(function(){var n,o,u,a,c,h,f,p;return r(this,(function(r){switch(r.label){case 0:return n=e.placeholderSearch,o=e.query,n||o?(u=e.pagination,a=e.finitePagination?{}:u,c=t.formatKey([i,e.indexUid,e.query,a]),(h=t.getEntry(c))?[2,h]:(f=l(e,i),[4,s.index(e.indexUid).search(e.query,i)])):[2,d];case 1:return(p=r.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var n in t){e[n]||(e[n]={});for(var r=0,i=t[n];r<i.length;r++){var s=i[r];Object.keys(e[n]).includes(s)||(e[n][s]=0)}}return e}(f,p.facetsDistribution),t.setEntry(c,p),[2,p]}}))}))}}}function p(t){return 180*t/Math.PI}function v(t){return t*Math.PI/180}function y(t){if(t){var e,n,r=t.insideBoundingBox,i=t.aroundLatLng,s=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(e=i),null==s&&null==o||(n=null!=s?s:o),r&&"string"==typeof r){var u=r.split(","),a=u[0],c=u[1],h=u[2],l=u[3],d=[parseFloat(a),parseFloat(c),parseFloat(h),parseFloat(l)],f=d[0],y=d[1],b=d[2],g=d[3];n=function(t,e,n,r){var i=t*Math.PI/180,s=n*Math.PI/180,o=(n-t)*Math.PI/180,u=(r-e)*Math.PI/180,a=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(s)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))*6371e3}(f,y,b,g)/2,e=function(t,e,n,r){t=v(t),e=v(e);var i=Math.cos(t)*Math.cos(e),s=Math.cos(t)*Math.sin(e),o=Math.sin(t);n=v(n),r=v(r);var u=i+Math.cos(n)*Math.cos(r),a=s+Math.cos(n)*Math.sin(r),c=o+Math.sin(n),h=Math.sqrt(u*u+a*a),l=Math.atan2(a,u),d=Math.atan2(c,h);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(d+=Math.PI,l+=Math.PI):(d=p(d),l=p(l)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(a)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(d=0,l=0),"".concat(d,",").concat(l)}(f,y,b,g)}if(null!=e&&null!=n){var w=e.split(","),m=w[0],x=w[1];return m=Number.parseFloat(m).toFixed(5),x=Number.parseFloat(x).toFixed(5),{filter:"_geoRadius(".concat(m,", ").concat(x,", ").concat(n,")")}}}}function b(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function g(t){return""===t?[]:"string"==typeof t?[t]:t}function w(t,e,n){return function(t,e,n){var r=n.trim(),s=g(t),o=g(e);return i(i(i([],s),o),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(b(n||[]),b(e||[]),t||"")}function m(t){var e={},n=null==t?void 0:t.facets;(null==n?void 0:n.length)&&(e.facetsDistribution=n);var r=null==t?void 0:t.attributesToSnippet;r&&(e.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(e.cropMarker=i);var s=null==t?void 0:t.attributesToRetrieve;s&&(e.attributesToRetrieve=s);var o=w(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);o.length&&(e.filter=o),s&&(e.attributesToCrop=s),e.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;e.highlightPreTag=u||"__ais-highlight__";var a=null==t?void 0:t.highlightPostTag;e.highlightPostTag=a||"__/ais-highlight__";var c=t.placeholderSearch,h=t.query,l=t.pagination;if(!c&&""===h||0===l.paginationTotalHits)e.limit=0;else if(t.finitePagination)e.limit=l.paginationTotalHits;else{var d=(l.page+1)*l.hitsPerPage+1;d>l.paginationTotalHits?e.limit=l.paginationTotalHits:e.limit=d}var f=t.sort;(null==f?void 0:f.length)&&(e.sort=[f]);var p=y(function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,s=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,a=t.insidePolygon;return n&&(e.aroundLatLng=n),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(e.aroundRadius=i),s&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(e.minimumAroundRadius=o),u&&(e.insideBoundingBox=u),a&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t));return(null==p?void 0:p.filter)&&(e.filter?e.filter.unshift(p.filter):e.filter=[p.filter]),e}function x(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function T(t){return Array.isArray(t)?t.map((function(t){return T(t)})):"object"!=typeof(e=t)||Array.isArray(e)||null===e?{value:x(t)}:Object.keys(t).reduce((function(e,n){return e[n]=T(t[n]),e}),{});var e}function R(t,e,n){var r=e.primaryKey,i=n.hitsPerPage,s=function(t,e,n){if(n<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=e*n;return t.slice(r,r+n)}(t,n.page,i).map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesInfo;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesInfo"]),i=Object.assign(n,function(t){if(!t)return{};var e=T(t);return{_highlightResult:e,_snippetResult:e}}(e));return r&&(i.objectID=t[r]),i}return t}));return s=function(t){for(var e=0;e<t.length;e++)t[e]._geo&&(t[e]._geoloc={lat:t[e]._geo.lat,lng:t[e]._geo.lng},t[e].objectID="".concat(e+1e6*Math.random()),delete t[e]._geo);return t}(s)}function k(t,n){var r={},i=t.facetsDistribution,s=n.pagination,o=null==t?void 0:t.exhaustiveFacetsCount;o&&(r.exhaustiveFacetsCount=o);var u,a,c=(u=t.hits.length,(a=s.hitsPerPage)>0?Math.ceil(u/a):0),h=R(t.hits,n,s),l=t.exhaustiveNbHits,d=t.nbHits,f=t.processingTimeMs,p=t.query,v=s.hitsPerPage,y=s.page;return{results:[e({index:n.indexUid,hitsPerPage:v,page:y,facets:i,nbPages:c,exhaustiveNbHits:l,nbHits:d,processingTimeMS:f,query:p,hits:h,params:""},r)]}}function M(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(n){return e[t]}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)}}}t.instantMeiliSearch=function(t,i,s){void 0===i&&(i=""),void 0===s&&(s={});var o=f(M()),a={},c=new u.MeiliSearch({host:t,apiKey:i});return{search:function(t){return n(this,void 0,void 0,(function(){var n,i,u,h,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),s=i[0],o=i.slice(1),u=t.params,a=function(t){var e=t.paginationTotalHits,n=t.hitsPerPage;return{paginationTotalHits:null!=e?e:200,hitsPerPage:void 0===n?20:n,page:t.page||0}}({paginationTotalHits:n.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return e(e(e({},n),u),{sort:o.join(":")||"",indexUid:s,pagination:a,defaultFacetDistribution:r,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination})}(n,s,a),u=m(i),[4,o.searchResponse(i,u,c)];case 1:return h=r.sent(),a=function(t,e){return""===e.query&&0===Object.keys(t).length?e.facetsDistribution:t}(a,h),[2,k(h,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}},Object.defineProperty(t,"__esModule",{value:!0})}));
var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?n(t.value):i(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return u([t,e])}}function u(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}var s=function(t){function e(n,r,i,o){var s,a,u,c=this;return c=t.call(this,n)||this,Object.setPrototypeOf(c,e.prototype),c.name="MeiliSearchCommunicationError",r instanceof Response&&(c.message=r.statusText,c.statusCode=r.status),r instanceof Error&&(c.errno=r.errno,c.code=r.code),o?(c.stack=o,c.stack=null===(s=c.stack)||void 0===s?void 0:s.replace(/(TypeError|FetchError)/,c.name),c.stack=null===(a=c.stack)||void 0===a?void 0:a.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),c.stack=null===(u=c.stack)||void 0===u?void 0:u.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(c,e),c}return n(e,t),e}(Error),a=function(t){function e(e,n){var r=t.call(this,e.message)||this;return Object.setPrototypeOf(r,a.prototype),r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,a),r}return n(e,t),e}(Error);function u(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new s(t.statusText,t,t.url);case 4:throw new a(e,t.status);case 5:return[2,t]}}))}))}function c(t,e,n){if("MeiliSearchApiError"!==t.name)throw new s(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),l=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function d(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function f(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}function p(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function v(t){return t.endsWith("/")||(t+="/"),t}var y="0.27.0-beta.1";function b(t){try{return t=v(t=p(t))}catch(t){throw new h("The provided host is not valid.")}}function g(t){var e="X-Meilisearch-Client",n="Meilisearch JavaScript (v".concat(y,")"),r="Content-Type";t.headers=t.headers||{};var i=Object.assign({},t.headers);if(t.apiKey&&(i.Authorization="Bearer ".concat(t.apiKey)),t.headers[r]||(i["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var o=t.clientAgents.concat(n);i[e]=o.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new h('Meilisearch: The header "'.concat(e,'" should be an array of string(s).\n'));i[e]=n}return i}var w=function(){function t(t){this.headers=g(t);try{var e=b(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,s=t.params,a=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,l,d;return o(this,(function(o){switch(o.label){case 0:t=new URL(n,this.url),s&&(i=new URLSearchParams,Object.keys(s).filter((function(t){return null!==s[t]})).map((function(t){return i.set(t,s[t])})),t.search=i.toString()),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(a),headers:this.headers})).then((function(t){return u(t)}))];case 2:return[4,o.sent().json().catch((function(){}))];case 3:return[2,o.sent()];case 4:return l=o.sent(),d=l.stack,c(l,d,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),m=function(){function t(t){this.httpRequest=new w(t)}return t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTasks=function(t){var e,n,r;return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var i,s;return o(this,(function(o){switch(o.label){case 0:return i="tasks",s={indexUid:null===(e=null==t?void 0:t.indexUid)||void 0===e?void 0:e.join(","),type:null===(n=null==t?void 0:t.type)||void 0===n?void 0:n.join(","),status:null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.join(","),from:t.from,limit:t.limit},[4,this.httpRequest.get(i,d(s))];case 1:return[2,o.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<s?[4,this.getTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,f(u)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new l("timeout of ".concat(s,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){var e,n,r,i,a;return o(this,(function(o){switch(o.label){case 0:e=[],n=0,r=t,o.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForTask(i,{timeOutMs:s,intervalMs:u})]):[3,4];case 2:a=o.sent(),e.push(a),o.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t}(),x=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new w(t),this.tasks=new m(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return o(this,(function(o){switch(o.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,d(r({q:t},e)),void 0,n)];case 1:return[2,o.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var s,a,u,c,l;return i(this,void 0,void 0,(function(){var i,f,p;return o(this,(function(o){switch(o.label){case 0:return i="indexes/".concat(this.uid,"/search"),f=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},p=r(r({q:t},e),{filter:f(null==e?void 0:e.filter),sort:null===(s=null==e?void 0:e.sort)||void 0===s?void 0:s.join(","),facets:null===(a=null==e?void 0:e.facets)||void 0===a?void 0:a.join(","),attributesToRetrieve:null===(u=null==e?void 0:e.attributesToRetrieve)||void 0===u?void 0:u.join(","),attributesToCrop:null===(c=null==e?void 0:e.attributesToCrop)||void 0===c?void 0:c.join(","),attributesToHighlight:null===(l=null==e?void 0:e.attributesToHighlight)||void 0===l?void 0:l.join(",")}),[4,this.httpRequest.get(i,d(p),n)];case 1:return[2,o.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var i;return o(this,(function(o){return i="indexes",[2,new w(n).post(i,r(r({},e),{uid:t}))]}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(r(r({},t),{indexUid:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n;return o(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/documents"),n=function(){var e;if(Array.isArray(null==t?void 0:t.fields))return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}(),[4,this.httpRequest.get(e,d(r(r({},t),{fields:n})))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,s,a;return o(this,(function(o){switch(o.label){case 0:r=[],i=0,o.label=1;case 1:return i<t.length?(a=(s=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:a.apply(s,[o.sent()]),o.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,s,a;return o(this,(function(o){switch(o.label){case 0:r=[],i=0,o.label=1;case 1:return i<t.length?(a=(s=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:a.apply(s,[o.sent()]),o.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSettings=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),T=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new w(t),this.tasks=new m(t)}return t.prototype.index=function(t){return new x(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new x(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new x(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n,i=this;return o(this,(function(o){switch(o.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=o.sent(),n=e.results.map((function(t){return new x(i.config,t.uid,t.primaryKey)})),[2,r(r({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,x.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,new x(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new x(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateKey=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="health",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="health",[4,this.httpRequest.get(t)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="version",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="dumps",[4,this.httpRequest.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e,n){var r=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(r.stack,"."))},t}());t.Index=x,t.MeiliSearch=T,t.MeiliSearchApiError=a,t.MeiliSearchCommunicationError=s,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=l,t.default=T,t.httpErrorHandler=c,t.httpResponseErrorHandler=u,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));function u(t){return t.replace(/:(.*)/i,'="$1"')}var c=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[]};function h(t){var n=function(t){return"string"==typeof t?c(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return c(t)})):c(t)})).flat(2):[]}(t);return n.filter((function(t){return void 0!==t})).reduce((function(t,n){var r,o=n.filterName,s=n.value,a=t[o]||[];return t=e(e({},t),((r={})[o]=i(i([],a),[s]),r))}),{})}function l(t,n){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,n){var i,o=Object.keys(r[n]);return e(e({},t),((i={})[n]=o,i))}),{})):h(null==n?void 0:n.filter);var r}var d={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function f(t){return{searchResponse:function(e,i,o){return n(this,void 0,void 0,(function(){var n,s,a,u,c,h,f,p;return r(this,(function(r){switch(r.label){case 0:return n=e.placeholderSearch,s=e.query,n||s?(a=e.pagination,u=e.finitePagination?{}:a,c=t.formatKey([i,e.indexUid,e.query,u]),(h=t.getEntry(c))?[2,h]:(f=l(e,i),[4,o.index(e.indexUid).search(e.query,i)])):[2,d];case 1:return(p=r.sent()).facetDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var n in t){e[n]||(e[n]={});for(var r=0,i=t[n];r<i.length;r++){var o=i[r];Object.keys(e[n]).includes(o)||(e[n][o]=0)}}return e}(f,p.facetDistribution),t.setEntry(c,p),[2,p]}}))}))}}}function p(t){return 180*t/Math.PI}function v(t){return t*Math.PI/180}function y(t){if(t){var e,n,r=t.insideBoundingBox,i=t.aroundLatLng,o=t.aroundRadius,s=t.minimumAroundRadius;if(i&&(e=i),null==o&&null==s||(n=null!=o?o:s),r&&"string"==typeof r){var a=r.split(","),u=a[0],c=a[1],h=a[2],l=a[3],d=[parseFloat(u),parseFloat(c),parseFloat(h),parseFloat(l)],f=d[0],y=d[1],b=d[2],g=d[3];n=function(t,e,n,r){var i=t*Math.PI/180,o=n*Math.PI/180,s=(n-t)*Math.PI/180,a=(r-e)*Math.PI/180,u=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(o)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u))*6371e3}(f,y,b,g)/2,e=function(t,e,n,r){t=v(t),e=v(e);var i=Math.cos(t)*Math.cos(e),o=Math.cos(t)*Math.sin(e),s=Math.sin(t);n=v(n),r=v(r);var a=i+Math.cos(n)*Math.cos(r),u=o+Math.cos(n)*Math.sin(r),c=s+Math.sin(n),h=Math.sqrt(a*a+u*u),l=Math.atan2(u,a),d=Math.atan2(c,h);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(d+=Math.PI,l+=Math.PI):(d=p(d),l=p(l)),Math.abs(a)<Math.pow(10,-9)&&Math.abs(u)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(d=0,l=0),"".concat(d,",").concat(l)}(f,y,b,g)}if(null!=e&&null!=n){var w=e.split(","),m=w[0],x=w[1];return m=Number.parseFloat(m).toFixed(5),x=Number.parseFloat(x).toFixed(5),{filter:"_geoRadius(".concat(m,", ").concat(x,", ").concat(n,")")}}}}function b(t){return"string"==typeof t?u(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return u(t)})).filter((function(t){return t})):u(t)})).filter((function(t){return t})):[]}function g(t){return""===t?[]:"string"==typeof t?[t]:t}function w(t,e,n){return function(t,e,n){var r=n.trim(),o=g(t),s=g(e);return i(i(i([],o),s),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(b(n||[]),b(e||[]),t||"")}function m(t){var e={},n=null==t?void 0:t.facets;(null==n?void 0:n.length)&&(e.facets=n);var r=null==t?void 0:t.attributesToSnippet;r&&(e.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(e.cropMarker=i);var o=null==t?void 0:t.attributesToRetrieve;o&&(e.attributesToRetrieve=o);var s=w(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);s.length&&(e.filter=s),o&&(e.attributesToCrop=o),e.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var a=null==t?void 0:t.highlightPreTag;e.highlightPreTag=a||"__ais-highlight__";var u=null==t?void 0:t.highlightPostTag;e.highlightPostTag=u||"__/ais-highlight__";var c=t.placeholderSearch,h=t.query,l=t.pagination;if(!c&&""===h||0===l.paginationTotalHits)e.limit=0;else if(t.finitePagination)e.limit=l.paginationTotalHits;else{var d=(l.page+1)*l.hitsPerPage+1;d>l.paginationTotalHits?e.limit=l.paginationTotalHits:e.limit=d}var f=t.sort;(null==f?void 0:f.length)&&(e.sort=[f]);var p=y(function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,o=t.aroundPrecision,s=t.minimumAroundRadius,a=t.insideBoundingBox,u=t.insidePolygon;return n&&(e.aroundLatLng=n),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(e.aroundRadius=i),o&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),s&&(e.minimumAroundRadius=s),a&&(e.insideBoundingBox=a),u&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t));return(null==p?void 0:p.filter)&&(e.filter?e.filter.unshift(p.filter):e.filter=[p.filter]),e}function x(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function T(t){return Array.isArray(t)?t.map((function(t){return T(t)})):"object"!=typeof(e=t)||Array.isArray(e)||null===e?{value:x(t)}:Object.keys(t).reduce((function(e,n){return e[n]=T(t[n]),e}),{});var e}function R(t,e,n){var r=e.primaryKey,i=n.hitsPerPage,o=function(t,e,n){if(n<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=e*n;return t.slice(r,r+n)}(t,n.page,i).map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesPosition"]),i=Object.assign(n,function(t){if(!t)return{};var e=T(t);return{_highlightResult:e,_snippetResult:e}}(e));return r&&(i.objectID=t[r]),i}return t}));return o=function(t){for(var e=0;e<t.length;e++)t[e]._geo&&(t[e]._geoloc={lat:t[e]._geo.lat,lng:t[e]._geo.lng},t[e].objectID="".concat(e+1e6*Math.random()),delete t[e]._geo);return t}(o)}function A(t,n){var r,i,o=t.facetDistribution,s=n.pagination,a=(r=t.hits.length,(i=s.hitsPerPage)>0?Math.ceil(r/i):0),u=R(t.hits,n,s),c=t.estimatedTotalHits,h=t.processingTimeMs,l=t.query,d=s.hitsPerPage,f=s.page;return{results:[e({index:n.indexUid,hitsPerPage:d,page:f,facets:o,nbPages:a,nbHits:c,processingTimeMS:h,query:l,hits:u,params:"",exhaustiveNbHits:!1},{})]}}function k(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(n){return e[t]}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)}}}t.instantMeiliSearch=function(t,i,o){void 0===i&&(i=""),void 0===o&&(o={});var s=f(k()),u={},c=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.8.0-beta.0",")");return t.concat(e)}(o.clientAgents),h=new a.MeiliSearch({host:t,apiKey:i,clientAgents:c});return{search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,c,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),o=i[0],s=i.slice(1),a=t.params,u=function(t){var e=t.paginationTotalHits,n=t.hitsPerPage;return{paginationTotalHits:null!=e?e:200,hitsPerPage:void 0===n?20:n,page:t.page||0}}({paginationTotalHits:n.paginationTotalHits,hitsPerPage:null==a?void 0:a.hitsPerPage,page:null==a?void 0:a.page});return e(e(e({},n),a),{sort:s.join(":")||"",indexUid:o,pagination:u,defaultFacetDistribution:r,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination})}(n,o,u),a=m(i),[4,s.searchResponse(i,a,h)];case 1:return c=r.sent(),u=function(t,e){return""===e.query&&0===Object.keys(t).length?e.facetDistribution:t}(u,c),[2,A(c,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=instant-meilisearch.umd.min.js.map

@@ -13,4 +13,4 @@ import { Filter, FacetsDistribution, FacetsCache, MeiliSearchParams, SearchContext } from '../../types';

/**
* Assign missing filters to facetsDistribution.
* All facet passed as filter should appear in the facetsDistribution.
* Assign missing filters to facetDistribution.
* All facets passed as filter should appear in the facetDistribution.
* If not present, the facet is added with 0 as value.

@@ -17,0 +17,0 @@ *

@@ -7,5 +7,5 @@ export declare const searchResponse: {

processingTimeMs: number;
nbHits: number;
estimatedTotalHits: number;
exhaustiveNbHits: boolean;
};
//# sourceMappingURL=utils.d.ts.map
import { FacetsDistribution } from '../types';
export declare function cacheFirstFacetsDistribution(defaultFacetDistribution: FacetsDistribution, searchResponse: any): FacetsDistribution;
export declare function cacheFirstFacetDistribution(defaultFacetDistribution: FacetsDistribution, searchResponse: any): FacetsDistribution;
//# sourceMappingURL=first-facets-distribution.d.ts.map

@@ -1,6 +0,6 @@

// Type definitions for @meilisearch/instant-meilisearch 0.7.1
// Type definitions for @meilisearch/instant-meilisearch 0.8.0-beta.0
// Project: https://github.com/meilisearch/instant-meilisearch.git
// Definitions by: Clementine Urquizar <https://github.com/meilisearch>
// Definitions: https://github.com/meilisearch/instant-meilisearch.git
// TypeScript Version: ^4.6.3
// TypeScript Version: ^4.6.4

@@ -7,0 +7,0 @@ export * from './client';

@@ -21,2 +21,3 @@ import type { SearchResponse as MeiliSearchResponse, FacetsDistribution } from 'meilisearch';

finitePagination?: boolean;
clientAgents?: string[];
};

@@ -23,0 +24,0 @@ export declare type SearchCacheInterface = {

{
"name": "@meilisearch/instant-meilisearch",
"version": "0.7.1",
"version": "0.8.0-beta.0",
"private": false,

@@ -60,8 +60,8 @@ "description": "The search client to use Meilisearch with InstantSearch.",

"dependencies": {
"meilisearch": "0.25.1"
"meilisearch": "^0.27.0-beta.1"
},
"devDependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.8",
"@babel/preset-env": "^7.16.11",
"@babel/cli": "^7.17.10",
"@babel/core": "^7.17.12",
"@babel/preset-env": "^7.17.10",
"@rollup/plugin-commonjs": "^17.1.0",

@@ -95,3 +95,3 @@ "@rollup/plugin-node-resolve": "^11.2.0",

"eslint-plugin-vue": "^7.7.0",
"instantsearch.js": "^4.40.2",
"instantsearch.js": "^4.40.5",
"jest": "^27.2.2",

@@ -108,5 +108,5 @@ "jest-watch-typeahead": "^0.6.3",

"ts-jest": "^27.0.7",
"tslib": "^2.3.1",
"typescript": "^4.6.3"
"tslib": "^2.4.0",
"typescript": "^4.6.4"
}
}

@@ -256,3 +256,3 @@ <p align="center">

This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0).
This package only guarantees the compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0).

@@ -950,3 +950,3 @@ **Node / NPM versions**:

- 🤷‍♀️ rootPath: The prefix path to use if the first level is not the root level.
- ✅ templates: The templates to use for the widget.- ✅ templates: The templates to use for the widget.
- ✅ templates: The templates to use for the widget.
- ✅ cssClasses: The CSS classes to override.

@@ -953,0 +953,0 @@

@@ -65,6 +65,6 @@ import {

function getFacetsFromDefaultDistribution(
facetsDistribution: FacetsDistribution
facetDistribution: FacetsDistribution
): FacetsCache {
return Object.keys(facetsDistribution).reduce((cache: any, facet) => {
const facetValues = Object.keys(facetsDistribution[facet])
return Object.keys(facetDistribution).reduce((cache: any, facet) => {
const facetValues = Object.keys(facetDistribution[facet])
return {

@@ -95,4 +95,4 @@ ...cache,

/**
* Assign missing filters to facetsDistribution.
* All facet passed as filter should appear in the facetsDistribution.
* Assign missing filters to facetDistribution.
* All facets passed as filter should appear in the facetDistribution.
* If not present, the facet is added with 0 as value.

@@ -99,0 +99,0 @@ *

@@ -25,3 +25,3 @@ import type { MeiliSearchParams, SearchContext } from '../../types'

if (facets?.length) {
meiliSearchParams.facetsDistribution = facets
meiliSearchParams.facets = facets
}

@@ -28,0 +28,0 @@

@@ -13,7 +13,6 @@ import {

query: '',
facetsDistribution: {},
facetDistribution: {},
limit: 0,
offset: 0,
exhaustiveNbHits: false,
nbHits: 0,
estimatedTotalHits: 0,
processingTimeMs: 0,

@@ -73,6 +72,6 @@ }

// Add missing facets back into facetsDistribution
searchResponse.facetsDistribution = addMissingFacets(
// Add missing facets back into facetDistribution
searchResponse.facetDistribution = addMissingFacets(
facetsCache,
searchResponse.facetsDistribution
searchResponse.facetDistribution
)

@@ -79,0 +78,0 @@

@@ -24,3 +24,7 @@ import type { PaginationContext, SearchContext } from '../../types'

if (Object.keys(hit).length > 0) {
const { _formatted: formattedHit, _matchesInfo, ...documentFields } = hit
const {
_formatted: formattedHit,
_matchesPosition,
...documentFields
} = hit

@@ -27,0 +31,0 @@ const adaptedHit: Record<string, any> = Object.assign(

@@ -24,10 +24,5 @@ import type {

const facets = searchResponse.facetsDistribution
const facets = searchResponse.facetDistribution
const { pagination } = searchContext
const exhaustiveFacetsCount = searchResponse?.exhaustiveFacetsCount
if (exhaustiveFacetsCount) {
searchResponseOptionals.exhaustiveFacetsCount = exhaustiveFacetsCount
}
const nbPages = ceiledDivision(

@@ -39,4 +34,3 @@ searchResponse.hits.length,

const exhaustiveNbHits = searchResponse.exhaustiveNbHits
const nbHits = searchResponse.nbHits
const estimatedTotalHits = searchResponse.estimatedTotalHits
const processingTimeMs = searchResponse.processingTimeMs

@@ -54,4 +48,3 @@ const query = searchResponse.query

nbPages,
exhaustiveNbHits,
nbHits,
nbHits: estimatedTotalHits,
processingTimeMS: processingTimeMs,

@@ -61,2 +54,3 @@ query,

params: '',
exhaustiveNbHits: false,
...searchResponseOptionals,

@@ -63,0 +57,0 @@ }

@@ -7,4 +7,4 @@ export const searchResponse = {

processingTimeMs: 0,
nbHits: 0,
estimatedTotalHits: 0,
exhaustiveNbHits: false,
}
import { FacetsDistribution } from '../types'
export function cacheFirstFacetsDistribution(
export function cacheFirstFacetDistribution(
defaultFacetDistribution: FacetsDistribution,

@@ -11,5 +11,5 @@ searchResponse: any

) {
return searchResponse.facetsDistribution
return searchResponse.facetDistribution
}
return defaultFacetDistribution
}

@@ -15,3 +15,4 @@ import { MeiliSearch } from 'meilisearch'

import { createSearchContext } from '../contexts'
import { SearchCache, cacheFirstFacetsDistribution } from '../cache/'
import { SearchCache, cacheFirstFacetDistribution } from '../cache/'
import { constructClientAgents } from './agents'

@@ -35,4 +36,12 @@ /**

let defaultFacetDistribution: any = {}
const meilisearchClient = new MeiliSearch({ host: hostUrl, apiKey: apiKey })
const clientAgents = constructClientAgents(
instantMeiliSearchOptions.clientAgents
)
const meilisearchClient = new MeiliSearch({
host: hostUrl,
apiKey: apiKey,
clientAgents,
})
return {

@@ -65,5 +74,5 @@ /**

// Cache first facets distribution of the instantMeilisearch instance
// Needed to add in the facetsDistribution the fields that were not returned
// Needed to add in the facetDistribution the fields that were not returned
// When the user sets `keepZeroFacets` to true.
defaultFacetDistribution = cacheFirstFacetsDistribution(
defaultFacetDistribution = cacheFirstFacetDistribution(
defaultFacetDistribution,

@@ -70,0 +79,0 @@ searchResponse

import type {
MeiliSearch,
SearchResponse as MeiliSearchResponse,

@@ -37,2 +36,3 @@ FacetsDistribution,

finitePagination?: boolean
clientAgents?: string[]
}

@@ -39,0 +39,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc