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.5.2 to 0.5.3

22

dist/instant-meilisearch.cjs.js

@@ -125,3 +125,3 @@ 'use strict';

var query = _a.query, facets = _a.facets, facetFilters = _a.facetFilters, attributesToCrop = _a.attributesToSnippet, attributesToRetrieve = _a.attributesToRetrieve, attributesToHighlight = _a.attributesToHighlight, _c = _a.filters, filters = _c === void 0 ? '' : _c, _d = _a.numericFilters, numericFilters = _d === void 0 ? [] : _d;
var paginationTotalHits = _b.paginationTotalHits, placeholderSearch = _b.placeholderSearch;
var paginationTotalHits = _b.paginationTotalHits, placeholderSearch = _b.placeholderSearch, sort = _b.sort;
var limit = paginationTotalHits;

@@ -131,3 +131,3 @@ var meilisearchFilters = facetFiltersToMeiliSearchFilter(facetFilters);

// Creates search params object compliant with MeiliSearch
return __assign(__assign(__assign(__assign(__assign({ q: query }, ((facets === null || facets === void 0 ? void 0 : facets.length) && { facetsDistribution: facets })), (attributesToCrop && { attributesToCrop: attributesToCrop })), (attributesToRetrieve && { attributesToRetrieve: attributesToRetrieve })), (filter && { filter: filter })), { attributesToHighlight: attributesToHighlight || ['*'], limit: (!placeholderSearch && query === '') || !limit ? 0 : limit });
return __assign(__assign(__assign(__assign(__assign(__assign({ q: query }, ((facets === null || facets === void 0 ? void 0 : facets.length) && { facetsDistribution: facets })), (attributesToCrop && { attributesToCrop: attributesToCrop })), (attributesToRetrieve && { attributesToRetrieve: attributesToRetrieve })), (filter.length && { filter: filter })), { attributesToHighlight: attributesToHighlight || ['*'], limit: (!placeholderSearch && query === '') || !limit ? 0 : limit }), ((sort === null || sort === void 0 ? void 0 : sort.length) && { sort: [sort] }));
};

@@ -308,9 +308,10 @@

return __awaiter(this, void 0, void 0, function () {
var isSearchRequest, instantSearchParams, indexUid, paginationTotalHits, primaryKey, placeholderSearch, page, hitsPerPage, client, context, msSearchParams, cachedFacet, searchResponse, ISresponse, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
var isSearchRequest, instantSearchParams, indexName, _a, indexUid, sortByArray, paginationTotalHits, primaryKey, placeholderSearch, page, hitsPerPage, client, context, msSearchParams, cachedFacet, searchResponse, ISresponse, e_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a.trys.push([0, 2, , 3]);
_b.trys.push([0, 2, , 3]);
isSearchRequest = instantSearchRequests[0];
instantSearchParams = isSearchRequest.params, indexUid = isSearchRequest.indexName;
instantSearchParams = isSearchRequest.params, indexName = isSearchRequest.indexName;
_a = indexName.split(':'), indexUid = _a[0], sortByArray = _a.slice(1);
paginationTotalHits = options.paginationTotalHits, primaryKey = options.primaryKey, placeholderSearch = options.placeholderSearch;

@@ -325,3 +326,4 @@ page = instantSearchParams.page, hitsPerPage = instantSearchParams.hitsPerPage;

hitsPerPage: hitsPerPage === undefined ? 20 : hitsPerPage,
page: page || 0, // default page is 0 if none is provided
page: page || 0,
sort: sortByArray.join(':') || '',
};

@@ -336,3 +338,3 @@ msSearchParams = adaptToMeiliSearchParams(instantSearchParams, context);

case 1:
searchResponse = _a.sent();
searchResponse = _b.sent();
// Add the checked facet attributes in facetsDistribution and give them a value of 0

@@ -343,3 +345,3 @@ searchResponse.facetsDistribution = addMissingFacetZeroFields(cachedFacet, searchResponse.facetsDistribution);

case 2:
e_1 = _a.sent();
e_1 = _b.sent();
console.error(e_1);

@@ -346,0 +348,0 @@ throw new Error(e_1);

@@ -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,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}s((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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 r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t}var a=function(t){return t.replace(/:(.*)/i,'="$1"')},o=function(t,r){var n=t.query,o=t.facets,u=t.facetFilters,s=t.attributesToSnippet,c=t.attributesToRetrieve,l=t.attributesToHighlight,f=t.filters,p=void 0===f?"":f,h=t.numericFilters,g=void 0===h?[]:h,v=r.paginationTotalHits,y=r.placeholderSearch,b=v,d=function(t,e,r){var n=[r.join(" AND "),e.trim()].filter((function(t){return t})).join(" AND ").trim();return Array.isArray(t)&&n?i(i([],t),[[n]]):"string"==typeof t&&n?[t,[n]]:t}(function(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)})):a(t)})):[]}(u),p,g);return e(e(e(e(e({q:n},(null==o?void 0:o.length)&&{facetsDistribution:o}),s&&{attributesToCrop:s}),c&&{attributesToRetrieve:c}),d&&{filter:d}),{attributesToHighlight:l||["*"],limit:!y&&""===n||!b?0:b})},u=function(t,e){var r=e.hitsPerPage;return r>0?Math.ceil(t/r):0},s=function(t,e){var r=e.page,n=e.hitsPerPage,i=r*n;return t.splice(i,n)};function c(t){return"string"==typeof t||t instanceof String}var l=function(t,e,r){return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",c(t)?t.replace(/<em>/g,e).replace(/<\/em>/g,r):JSON.stringify(t)},f=function(t){var e=t.formattedHit,r=t.highlightPreTag,n=t.highlightPostTag;return Object.keys(e).reduce((function(t,i){return t[i]={value:l(e[i],r,n)},t}),{})},p=function(t,e,r,n){var i=t;return void 0!==e&&c(i)&&i&&(i[0]===i[0].toLowerCase()&&!1===i.startsWith("<em>")&&(i=""+e+i),!1==!!i.match(/[.!?]$/)&&(i=""+i+e)),l(i,r,n)},h=function(t){var e=t.formattedHit,r=t.attributesToSnippet,n=t.snippetEllipsisText,i=t.highlightPreTag,a=t.highlightPostTag;return void 0===r?null:(r=r.map((function(t){return t.split(":")[0]})),Object.keys(e).reduce((function(t,o){return r.includes(o)&&(t[o]={value:p(e[o],n,i,a)}),t}),{}))},g=function(t,r,n){var i=n.primaryKey;return s(t,n).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesInfo;var a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesInfo"]);return e(e(e({},a),function(t,r){return!t||t.length?{}:{_highlightResult:f(e({formattedHit:t},r)),_snippetResult:h(e({formattedHit:t},r))}}(n,r)),i&&{objectID:t[i]})}return t}))},v=function(t,r,n,i){var a=r.exhaustiveFacetsCount,o=r.exhaustiveNbHits,s=r.facetsDistribution,c=r.nbHits,l=r.processingTimeMs,f=r.query,p=r.hits,h=i.hitsPerPage,v=i.page;return{results:[e(e(e({index:t,hitsPerPage:h},s&&{facets:s}),a&&{exhaustiveFacetsCount:a}),{page:v,nbPages:u(p.length,i),exhaustiveNbHits:o,nbHits:c,processingTimeMS:l,query:f,hits:g(p,n,i)})]}},y=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[void 0]},b=function(t){var r=function(t){return"string"==typeof t?y(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return y(t)})):y(t)})).flat(2):[void 0]}(t);return r.filter((function(t){return void 0!==t})).reduce((function(t,r){var n,a=r.filterName,o=r.value,u=t[a]||[];return t=e(e({},t),((n={})[a]=i(i([],u),[o]),n))}),{})};exports.adaptToISHits=g,exports.adaptToISResponse=v,exports.adaptToMeiliSearchParams=o,exports.createHighlighResult=f,exports.createSnippetResult=h,exports.getNumberPages=u,exports.instantMeiliSearch=function(e,i,a){return void 0===a&&(a={}),{MeiliSearchClient:new t.MeiliSearch({host:e,apiKey:i}),search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,u,s,c,l,f,p,h,g,y,d,m;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=t[0],r=e.params,i=e.indexName,u=a.paginationTotalHits,s=a.primaryKey,c=a.placeholderSearch,l=r.page,f=r.hitsPerPage,p=this.MeiliSearchClient,g=o(r,h={client:p,paginationTotalHits:u||200,primaryKey:s||void 0,placeholderSearch:!1!==c,hitsPerPage:void 0===f?20:f,page:l||0}),y=b(g.filter),[4,p.index(i).search(g.q,g)];case 1:return(d=n.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var r in t)for(var n=0,i=t[r];n<i.length;n++){var a=i[n];e[r]&&Object.keys(e[r]).includes(a)||(e[r]=e[r]||{},e[r][a]=0)}return e}(y,d.facetsDistribution),[2,v(i,d,r,h)];case 2:throw m=n.sent(),console.error(m),new Error(m);case 3:return[2]}}))}))}}},exports.isString=c,exports.paginateHits=s,exports.replaceHighlightTags=l,exports.snippetValue=p;
***************************************************************************** */function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{u(n.next(t))}catch(t){a(t)}}function s(t){try{u(n.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,s)}u((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function i(t,e){for(var r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t}var a=function(t){return t.replace(/:(.*)/i,'="$1"')},o=function(t,r){var n=t.query,o=t.facets,s=t.facetFilters,u=t.attributesToSnippet,c=t.attributesToRetrieve,l=t.attributesToHighlight,f=t.filters,p=void 0===f?"":f,h=t.numericFilters,g=void 0===h?[]:h,v=r.paginationTotalHits,y=r.placeholderSearch,b=r.sort,d=v,m=function(t,e,r){var n=[r.join(" AND "),e.trim()].filter((function(t){return t})).join(" AND ").trim();return Array.isArray(t)&&n?i(i([],t),[[n]]):"string"==typeof t&&n?[t,[n]]:t}(function(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)})):a(t)})):[]}(s),p,g);return e(e(e(e(e(e({q:n},(null==o?void 0:o.length)&&{facetsDistribution:o}),u&&{attributesToCrop:u}),c&&{attributesToRetrieve:c}),m.length&&{filter:m}),{attributesToHighlight:l||["*"],limit:!y&&""===n||!d?0:d}),(null==b?void 0:b.length)&&{sort:[b]})},s=function(t,e){var r=e.hitsPerPage;return r>0?Math.ceil(t/r):0},u=function(t,e){var r=e.page,n=e.hitsPerPage,i=r*n;return t.splice(i,n)};function c(t){return"string"==typeof t||t instanceof String}var l=function(t,e,r){return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",c(t)?t.replace(/<em>/g,e).replace(/<\/em>/g,r):JSON.stringify(t)},f=function(t){var e=t.formattedHit,r=t.highlightPreTag,n=t.highlightPostTag;return Object.keys(e).reduce((function(t,i){return t[i]={value:l(e[i],r,n)},t}),{})},p=function(t,e,r,n){var i=t;return void 0!==e&&c(i)&&i&&(i[0]===i[0].toLowerCase()&&!1===i.startsWith("<em>")&&(i=""+e+i),!1==!!i.match(/[.!?]$/)&&(i=""+i+e)),l(i,r,n)},h=function(t){var e=t.formattedHit,r=t.attributesToSnippet,n=t.snippetEllipsisText,i=t.highlightPreTag,a=t.highlightPostTag;return void 0===r?null:(r=r.map((function(t){return t.split(":")[0]})),Object.keys(e).reduce((function(t,o){return r.includes(o)&&(t[o]={value:p(e[o],n,i,a)}),t}),{}))},g=function(t,r,n){var i=n.primaryKey;return u(t,n).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesInfo;var a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesInfo"]);return e(e(e({},a),function(t,r){return!t||t.length?{}:{_highlightResult:f(e({formattedHit:t},r)),_snippetResult:h(e({formattedHit:t},r))}}(n,r)),i&&{objectID:t[i]})}return t}))},v=function(t,r,n,i){var a=r.exhaustiveFacetsCount,o=r.exhaustiveNbHits,u=r.facetsDistribution,c=r.nbHits,l=r.processingTimeMs,f=r.query,p=r.hits,h=i.hitsPerPage,v=i.page;return{results:[e(e(e({index:t,hitsPerPage:h},u&&{facets:u}),a&&{exhaustiveFacetsCount:a}),{page:v,nbPages:s(p.length,i),exhaustiveNbHits:o,nbHits:c,processingTimeMS:l,query:f,hits:g(p,n,i)})]}},y=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[void 0]},b=function(t){var r=function(t){return"string"==typeof t?y(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return y(t)})):y(t)})).flat(2):[void 0]}(t);return r.filter((function(t){return void 0!==t})).reduce((function(t,r){var n,a=r.filterName,o=r.value,s=t[a]||[];return t=e(e({},t),((n={})[a]=i(i([],s),[o]),n))}),{})};exports.adaptToISHits=g,exports.adaptToISResponse=v,exports.adaptToMeiliSearchParams=o,exports.createHighlighResult=f,exports.createSnippetResult=h,exports.getNumberPages=s,exports.instantMeiliSearch=function(e,i,a){return void 0===a&&(a={}),{MeiliSearchClient:new t.MeiliSearch({host:e,apiKey:i}),search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,s,u,c,l,f,p,h,g,y,d,m,x,P,T;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=t[0],r=e.params,i=e.indexName,s=i.split(":"),u=s[0],c=s.slice(1),l=a.paginationTotalHits,f=a.primaryKey,p=a.placeholderSearch,h=r.page,g=r.hitsPerPage,y=this.MeiliSearchClient,d={client:y,paginationTotalHits:l||200,primaryKey:f||void 0,placeholderSearch:!1!==p,hitsPerPage:void 0===g?20:g,page:h||0,sort:c.join(":")||""},m=o(r,d),x=b(m.filter),[4,y.index(u).search(m.q,m)];case 1:return(P=n.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var r in t)for(var n=0,i=t[r];n<i.length;n++){var a=i[n];e[r]&&Object.keys(e[r]).includes(a)||(e[r]=e[r]||{},e[r][a]=0)}return e}(x,P.facetsDistribution),[2,v(u,P,r,d)];case 2:throw T=n.sent(),console.error(T),new Error(T);case 3:return[2]}}))}))}}},exports.isString=c,exports.paginateHits=u,exports.replaceHighlightTags=l,exports.snippetValue=p;
//# sourceMappingURL=instant-meilisearch.cjs.min.js.map

@@ -121,3 +121,3 @@ import { MeiliSearch } from 'meilisearch';

var query = _a.query, facets = _a.facets, facetFilters = _a.facetFilters, attributesToCrop = _a.attributesToSnippet, attributesToRetrieve = _a.attributesToRetrieve, attributesToHighlight = _a.attributesToHighlight, _c = _a.filters, filters = _c === void 0 ? '' : _c, _d = _a.numericFilters, numericFilters = _d === void 0 ? [] : _d;
var paginationTotalHits = _b.paginationTotalHits, placeholderSearch = _b.placeholderSearch;
var paginationTotalHits = _b.paginationTotalHits, placeholderSearch = _b.placeholderSearch, sort = _b.sort;
var limit = paginationTotalHits;

@@ -127,3 +127,3 @@ var meilisearchFilters = facetFiltersToMeiliSearchFilter(facetFilters);

// Creates search params object compliant with MeiliSearch
return __assign(__assign(__assign(__assign(__assign({ q: query }, ((facets === null || facets === void 0 ? void 0 : facets.length) && { facetsDistribution: facets })), (attributesToCrop && { attributesToCrop: attributesToCrop })), (attributesToRetrieve && { attributesToRetrieve: attributesToRetrieve })), (filter && { filter: filter })), { attributesToHighlight: attributesToHighlight || ['*'], limit: (!placeholderSearch && query === '') || !limit ? 0 : limit });
return __assign(__assign(__assign(__assign(__assign(__assign({ q: query }, ((facets === null || facets === void 0 ? void 0 : facets.length) && { facetsDistribution: facets })), (attributesToCrop && { attributesToCrop: attributesToCrop })), (attributesToRetrieve && { attributesToRetrieve: attributesToRetrieve })), (filter.length && { filter: filter })), { attributesToHighlight: attributesToHighlight || ['*'], limit: (!placeholderSearch && query === '') || !limit ? 0 : limit }), ((sort === null || sort === void 0 ? void 0 : sort.length) && { sort: [sort] }));
};

@@ -304,9 +304,10 @@

return __awaiter(this, void 0, void 0, function () {
var isSearchRequest, instantSearchParams, indexUid, paginationTotalHits, primaryKey, placeholderSearch, page, hitsPerPage, client, context, msSearchParams, cachedFacet, searchResponse, ISresponse, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
var isSearchRequest, instantSearchParams, indexName, _a, indexUid, sortByArray, paginationTotalHits, primaryKey, placeholderSearch, page, hitsPerPage, client, context, msSearchParams, cachedFacet, searchResponse, ISresponse, e_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a.trys.push([0, 2, , 3]);
_b.trys.push([0, 2, , 3]);
isSearchRequest = instantSearchRequests[0];
instantSearchParams = isSearchRequest.params, indexUid = isSearchRequest.indexName;
instantSearchParams = isSearchRequest.params, indexName = isSearchRequest.indexName;
_a = indexName.split(':'), indexUid = _a[0], sortByArray = _a.slice(1);
paginationTotalHits = options.paginationTotalHits, primaryKey = options.primaryKey, placeholderSearch = options.placeholderSearch;

@@ -321,3 +322,4 @@ page = instantSearchParams.page, hitsPerPage = instantSearchParams.hitsPerPage;

hitsPerPage: hitsPerPage === undefined ? 20 : hitsPerPage,
page: page || 0, // default page is 0 if none is provided
page: page || 0,
sort: sortByArray.join(':') || '',
};

@@ -332,3 +334,3 @@ msSearchParams = adaptToMeiliSearchParams(instantSearchParams, context);

case 1:
searchResponse = _a.sent();
searchResponse = _b.sent();
// Add the checked facet attributes in facetsDistribution and give them a value of 0

@@ -339,3 +341,3 @@ searchResponse.facetsDistribution = addMissingFacetZeroFields(cachedFacet, searchResponse.facetsDistribution);

case 2:
e_1 = _a.sent();
e_1 = _b.sent();
console.error(e_1);

@@ -342,0 +344,0 @@ throw new Error(e_1);

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

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(){return(e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{c(n.next(t))}catch(t){a(t)}}function u(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}c((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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 r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t}var a=function(t){return t.replace(/:(.*)/i,'="$1"')},o=function(t,r){var n=t.query,o=t.facets,u=t.facetFilters,c=t.attributesToSnippet,s=t.attributesToRetrieve,l=t.attributesToHighlight,f=t.filters,h=void 0===f?"":f,p=t.numericFilters,g=void 0===p?[]:p,v=r.paginationTotalHits,y=r.placeholderSearch,b=v,m=function(t,e,r){var n=[r.join(" AND "),e.trim()].filter((function(t){return t})).join(" AND ").trim();return Array.isArray(t)&&n?i(i([],t),[[n]]):"string"==typeof t&&n?[t,[n]]:t}(function(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)})):a(t)})):[]}(u),h,g);return e(e(e(e(e({q:n},(null==o?void 0:o.length)&&{facetsDistribution:o}),c&&{attributesToCrop:c}),s&&{attributesToRetrieve:s}),m&&{filter:m}),{attributesToHighlight:l||["*"],limit:!y&&""===n||!b?0:b})},u=function(t,e){var r=e.hitsPerPage;return r>0?Math.ceil(t/r):0},c=function(t,e){var r=e.page,n=e.hitsPerPage,i=r*n;return t.splice(i,n)};function s(t){return"string"==typeof t||t instanceof String}var l=function(t,e,r){return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",s(t)?t.replace(/<em>/g,e).replace(/<\/em>/g,r):JSON.stringify(t)},f=function(t){var e=t.formattedHit,r=t.highlightPreTag,n=t.highlightPostTag;return Object.keys(e).reduce((function(t,i){return t[i]={value:l(e[i],r,n)},t}),{})},h=function(t,e,r,n){var i=t;return void 0!==e&&s(i)&&i&&(i[0]===i[0].toLowerCase()&&!1===i.startsWith("<em>")&&(i=""+e+i),!1==!!i.match(/[.!?]$/)&&(i=""+i+e)),l(i,r,n)},p=function(t){var e=t.formattedHit,r=t.attributesToSnippet,n=t.snippetEllipsisText,i=t.highlightPreTag,a=t.highlightPostTag;return void 0===r?null:(r=r.map((function(t){return t.split(":")[0]})),Object.keys(e).reduce((function(t,o){return r.includes(o)&&(t[o]={value:h(e[o],n,i,a)}),t}),{}))},g=function(t,r,n){var i=n.primaryKey;return c(t,n).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesInfo;var a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesInfo"]);return e(e(e({},a),function(t,r){return!t||t.length?{}:{_highlightResult:f(e({formattedHit:t},r)),_snippetResult:p(e({formattedHit:t},r))}}(n,r)),i&&{objectID:t[i]})}return t}))},v=function(t,r,n,i){var a=r.exhaustiveFacetsCount,o=r.exhaustiveNbHits,c=r.facetsDistribution,s=r.nbHits,l=r.processingTimeMs,f=r.query,h=r.hits,p=i.hitsPerPage,v=i.page;return{results:[e(e(e({index:t,hitsPerPage:p},c&&{facets:c}),a&&{exhaustiveFacetsCount:a}),{page:v,nbPages:u(h.length,i),exhaustiveNbHits:o,nbHits:s,processingTimeMS:l,query:f,hits:g(h,n,i)})]}},y=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[void 0]},b=function(t){var r=function(t){return"string"==typeof t?y(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return y(t)})):y(t)})).flat(2):[void 0]}(t);return r.filter((function(t){return void 0!==t})).reduce((function(t,r){var n,a=r.filterName,o=r.value,u=t[a]||[];return t=e(e({},t),((n={})[a]=i(i([],u),[o]),n))}),{})};function m(e,i,a){return void 0===a&&(a={}),{MeiliSearchClient:new t({host:e,apiKey:i}),search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,u,c,s,l,f,h,p,g,y,m,d;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=t[0],r=e.params,i=e.indexName,u=a.paginationTotalHits,c=a.primaryKey,s=a.placeholderSearch,l=r.page,f=r.hitsPerPage,h=this.MeiliSearchClient,g=o(r,p={client:h,paginationTotalHits:u||200,primaryKey:c||void 0,placeholderSearch:!1!==s,hitsPerPage:void 0===f?20:f,page:l||0}),y=b(g.filter),[4,h.index(i).search(g.q,g)];case 1:return(m=n.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var r in t)for(var n=0,i=t[r];n<i.length;n++){var a=i[n];e[r]&&Object.keys(e[r]).includes(a)||(e[r]=e[r]||{},e[r][a]=0)}return e}(y,m.facetsDistribution),[2,v(i,m,r,p)];case 2:throw d=n.sent(),console.error(d),new Error(d);case 3:return[2]}}))}))}}}export{g as adaptToISHits,v as adaptToISResponse,o as adaptToMeiliSearchParams,f as createHighlighResult,p as createSnippetResult,u as getNumberPages,m as instantMeiliSearch,s as isString,c as paginateHits,l as replaceHighlightTags,h as snippetValue};
***************************************************************************** */var e=function(){return(e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}s((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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 r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t}var a=function(t){return t.replace(/:(.*)/i,'="$1"')},o=function(t,r){var n=t.query,o=t.facets,u=t.facetFilters,s=t.attributesToSnippet,c=t.attributesToRetrieve,l=t.attributesToHighlight,f=t.filters,h=void 0===f?"":f,p=t.numericFilters,g=void 0===p?[]:p,v=r.paginationTotalHits,y=r.placeholderSearch,b=r.sort,m=v,d=function(t,e,r){var n=[r.join(" AND "),e.trim()].filter((function(t){return t})).join(" AND ").trim();return Array.isArray(t)&&n?i(i([],t),[[n]]):"string"==typeof t&&n?[t,[n]]:t}(function(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)})):a(t)})):[]}(u),h,g);return e(e(e(e(e(e({q:n},(null==o?void 0:o.length)&&{facetsDistribution:o}),s&&{attributesToCrop:s}),c&&{attributesToRetrieve:c}),d.length&&{filter:d}),{attributesToHighlight:l||["*"],limit:!y&&""===n||!m?0:m}),(null==b?void 0:b.length)&&{sort:[b]})},u=function(t,e){var r=e.hitsPerPage;return r>0?Math.ceil(t/r):0},s=function(t,e){var r=e.page,n=e.hitsPerPage,i=r*n;return t.splice(i,n)};function c(t){return"string"==typeof t||t instanceof String}var l=function(t,e,r){return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",c(t)?t.replace(/<em>/g,e).replace(/<\/em>/g,r):JSON.stringify(t)},f=function(t){var e=t.formattedHit,r=t.highlightPreTag,n=t.highlightPostTag;return Object.keys(e).reduce((function(t,i){return t[i]={value:l(e[i],r,n)},t}),{})},h=function(t,e,r,n){var i=t;return void 0!==e&&c(i)&&i&&(i[0]===i[0].toLowerCase()&&!1===i.startsWith("<em>")&&(i=""+e+i),!1==!!i.match(/[.!?]$/)&&(i=""+i+e)),l(i,r,n)},p=function(t){var e=t.formattedHit,r=t.attributesToSnippet,n=t.snippetEllipsisText,i=t.highlightPreTag,a=t.highlightPostTag;return void 0===r?null:(r=r.map((function(t){return t.split(":")[0]})),Object.keys(e).reduce((function(t,o){return r.includes(o)&&(t[o]={value:h(e[o],n,i,a)}),t}),{}))},g=function(t,r,n){var i=n.primaryKey;return s(t,n).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesInfo;var a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesInfo"]);return e(e(e({},a),function(t,r){return!t||t.length?{}:{_highlightResult:f(e({formattedHit:t},r)),_snippetResult:p(e({formattedHit:t},r))}}(n,r)),i&&{objectID:t[i]})}return t}))},v=function(t,r,n,i){var a=r.exhaustiveFacetsCount,o=r.exhaustiveNbHits,s=r.facetsDistribution,c=r.nbHits,l=r.processingTimeMs,f=r.query,h=r.hits,p=i.hitsPerPage,v=i.page;return{results:[e(e(e({index:t,hitsPerPage:p},s&&{facets:s}),a&&{exhaustiveFacetsCount:a}),{page:v,nbPages:u(h.length,i),exhaustiveNbHits:o,nbHits:c,processingTimeMS:l,query:f,hits:g(h,n,i)})]}},y=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[void 0]},b=function(t){var r=function(t){return"string"==typeof t?y(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return y(t)})):y(t)})).flat(2):[void 0]}(t);return r.filter((function(t){return void 0!==t})).reduce((function(t,r){var n,a=r.filterName,o=r.value,u=t[a]||[];return t=e(e({},t),((n={})[a]=i(i([],u),[o]),n))}),{})};function m(e,i,a){return void 0===a&&(a={}),{MeiliSearchClient:new t({host:e,apiKey:i}),search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,u,s,c,l,f,h,p,g,y,m,d,P,w,O;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=t[0],r=e.params,i=e.indexName,u=i.split(":"),s=u[0],c=u.slice(1),l=a.paginationTotalHits,f=a.primaryKey,h=a.placeholderSearch,p=r.page,g=r.hitsPerPage,y=this.MeiliSearchClient,m={client:y,paginationTotalHits:l||200,primaryKey:f||void 0,placeholderSearch:!1!==h,hitsPerPage:void 0===g?20:g,page:p||0,sort:c.join(":")||""},d=o(r,m),P=b(d.filter),[4,y.index(s).search(d.q,d)];case 1:return(w=n.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var r in t)for(var n=0,i=t[r];n<i.length;n++){var a=i[n];e[r]&&Object.keys(e[r]).includes(a)||(e[r]=e[r]||{},e[r][a]=0)}return e}(P,w.facetsDistribution),[2,v(s,w,r,m)];case 2:throw O=n.sent(),console.error(O),new Error(O);case 3:return[2]}}))}))}}}export{g as adaptToISHits,v as adaptToISResponse,o as adaptToMeiliSearchParams,f as createHighlighResult,p as createSnippetResult,u as getNumberPages,m as instantMeiliSearch,c as isString,s as paginateHits,l as replaceHighlightTags,h as snippetValue};
//# 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,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{a(n.next(t))}catch(t){s(t)}}function u(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}a((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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 r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];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 r="URLSearchParams"in t,n="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 f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(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 l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function v(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:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=v(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):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=l(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?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=l(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=p(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.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 r=this.map[t];this.map[t]=r?r+", "+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 r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var r,n,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=(r=e.method||this.method||"GET",n=r.toUpperCase(),g.indexOf(n)>-1?n:r),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 r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),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 r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function R(t,r){return new Promise((function(n,s){var o=new w(t,r);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,r={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 r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in u?u.responseURL:r.headers.get("X-Request-URL");var i="response"in u?u.response:u.responseText;n(new x(i,r))},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,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{a(n.next(t))}catch(t){s(t)}}function u(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}a((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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 r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];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 r="URLSearchParams"in t,n="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 f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(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 l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function v(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:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=v(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):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=l(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?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=l(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=p(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.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 r=this.map[t];this.map[t]=r?r+", "+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 r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var r,n,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=(r=e.method||this.method||"GET",n=r.toUpperCase(),g.indexOf(n)>-1?n:r),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 r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),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 R=[301,302,303,307,308];x.redirect=function(t,e){if(-1===R.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 r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function T(t,r){return new Promise((function(n,s){var o=new w(t,r);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,r={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 r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in u?u.responseURL:r.headers.get("X-Request-URL");var i="response"in u?u.response:u.responseText;n(new x(i,r))},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)}))}T.polyfill=!0,t.fetch||(t.fetch=T,t.Headers=d,t.Request=w,t.Response=x),e.Headers=d,e.Request=w,e.Response=x,e.fetch=T,Object.defineProperty(e,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:s)}));var u=o((function(t,e){!function(t){
/*! *****************************************************************************

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

***************************************************************************** */
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,r,n){function i(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,s){function o(t){try{a(n.next(t))}catch(t){s(t)}}function u(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){t.done?r(t.value):i(t.value).then(o,u)}a((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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(r){var n=t.call(this,r)||this;return n.name="MeiliSearchError",n.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(n,e),n}return r(e,t),e}(Error),u=function(t){function e(r){var n=t.call(this,r)||this;return n.name="MeiliSearchTimeOutError",n.type=n.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(n,e),n}return r(e,t),e}(Error);function a(t){return Object.entries(t).reduce((function(t,e){var r=e[0],n=e[1];return void 0!==n&&(t[r]=n),t}),{})}function c(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()]}}))}))}var h=function(t){function e(r,n){var i=t.call(this,r)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",n instanceof Response&&(i.message=n.statusText,i.statusCode=n.status),n instanceof Error&&(i.errno=n.errno,i.code=n.code),Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return r(e,t),e}(Error),f=function(t){function e(e,r){var n=t.call(this,e.message)||this;return n.type="MeiliSearchApiError",n.name="MeiliSearchApiError",n.errorCode=e.errorCode,n.errorType=e.errorType,n.errorLink=e.errorLink,n.message=e.message,n.httpStatus=r,Error.captureStackTrace&&Error.captureStackTrace(n,f),n}return r(e,t),e}(Error);function d(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:if(t.ok)return[3,5];e=void 0,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,t.json()];case 2:return e=r.sent(),[3,4];case 3:throw r.sent(),new h(t.statusText,t);case 4:throw new f(e,t.status);case 5:return[2,t]}}))}))}function l(t){if("MeiliSearchApiError"!==t.type)throw new h(t.message,t);throw t}var p=function(){function t(t){this.headers=n(n(n({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=new URL(t.host)}return t.addTrailingSlash=function(t){return t.endsWith("/")||(t+="/"),t},t.prototype.request=function(t){var e=t.method,r=t.url,o=t.params,u=t.body,a=t.config;return i(this,void 0,void 0,(function(){var t,i,c;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),t=new URL(r,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()),[4,fetch(t.toString(),n(n({},a),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return d(t)}))];case 1:return[4,s.sent().text()];case 2:c=s.sent();try{return[2,JSON.parse(c)]}catch(t){return[2]}return[3,4];case 3:return l(s.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,r){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:r})];case 1:return[2,n.sent()]}}))}))},t.prototype.post=function(t,e,r,n){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:r,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,r,n){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:r,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,r,n){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:r,config:n})];case 1:return[2,i.sent()]}}))}))},t}(),y=function(){function t(t,e,r){this.uid=e,this.primaryKey=r,this.httpRequest=new p(t)}return t.prototype.waitForPendingUpdate=function(t,e){var r=void 0===e?{}:e,n=r.timeOutMs,o=void 0===n?5e3:n,a=r.intervalMs,h=void 0===a?50:a;return i(this,void 0,void 0,(function(){var e,r;return s(this,(function(n){switch(n.label){case 0:e=Date.now(),n.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return r=n.sent(),["enqueued","processing"].includes(r.status)?[4,c(h)]:[2,r];case 3:return n.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.search=function(t,e,r){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",[4,this.httpRequest.post(i,a(n(n({},e),{q:t})),void 0,r)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,r){return i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",u=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new o("The filter query parameter should be in string format when using searchGet")},c=n(n({q:t},e),{filter:u(null==e?void 0:e.filter),facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(i,a(c),r)];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(r){switch(r.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return e=r.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(e,r,o){return void 0===o&&(o={}),i(this,void 0,void 0,(function(){var i,u;return s(this,(function(s){switch(s.label){case 0:return i="indexes",[4,new p(e).post(i,n(n({},o),{uid:r}))];case 1:return u=s.sent(),[2,new t(e,r,u.primaryKey)]}}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e,r;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return r=n.sent(),this.primaryKey=r.primaryKey,[2,this]}}))}))},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/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIfExists=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]),[4,this.delete()];case 1:return e.sent(),[2,!0];case 2:if("index_not_found"===(t=e.sent()).errorCode)return[2,!1];throw t;case 3:return[2]}}))}))},t.prototype.getAllUpdateStatus=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getUpdateStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,r.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/"+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,r;return s(this,(function(i){switch(i.label){case 0:return e="indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(r=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,n(n({},t),void 0!==r?{attributesToRetrieve:r}:{}))];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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/documents/"+t,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var r;return s(this,(function(n){switch(n.label){case 0:return r="indexes/"+this.uid+"/documents",[4,this.httpRequest.post(r,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var r;return s(this,(function(n){switch(n.label){case 0:return r="indexes/"+this.uid+"/documents",[4,this.httpRequest.put(r,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/documents/"+t,[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/documents/delete-batch",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+this.uid+"/settings/filterable-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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),v=function(){function t(t){t.host=p.addTrailingSlash(t.host),this.config=t,this.httpRequest=new p(t)}return t.prototype.index=function(t){return new y(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).fetchInfo()]}))}))},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var r;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getIndex(t)];case 1:return[2,n.sent()];case 2:if("index_not_found"===(r=n.sent()).errorCode)return[2,this.createIndex(t,e)];throw new f(r,r.status);case 3:return[2]}}))}))},t.prototype.listIndexes=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(r){switch(r.label){case 0:return[4,y.create(this.config,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,new y(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).delete()]}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return r.sent(),[2,!0];case 2:if("index_not_found"===(e=r.sent()).errorCode)return[2,!1];throw e;case 3:return[2]}}))}))},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.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.stats=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.version=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(r){switch(r.label){case 0:return e="dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t}();t.MeiliSearch=v,Object.defineProperty(t,"__esModule",{value:!0})}(e)})),a=function(t){return t.replace(/:(.*)/i,'="$1"')},c=function(t,r){var n=t.query,s=t.facets,o=t.facetFilters,u=t.attributesToSnippet,c=t.attributesToRetrieve,h=t.attributesToHighlight,f=t.filters,d=void 0===f?"":f,l=t.numericFilters,p=void 0===l?[]:l,y=r.paginationTotalHits,v=r.placeholderSearch,b=y,g=function(t,e,r){var n=[r.join(" AND "),e.trim()].filter((function(t){return t})).join(" AND ").trim();return Array.isArray(t)&&n?i(i([],t),[[n]]):"string"==typeof t&&n?[t,[n]]:t}(function(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)})):a(t)})):[]}(o),d,p);return e(e(e(e(e({q:n},(null==s?void 0:s.length)&&{facetsDistribution:s}),u&&{attributesToCrop:u}),c&&{attributesToRetrieve:c}),g&&{filter:g}),{attributesToHighlight:h||["*"],limit:!v&&""===n||!b?0:b})},h=function(t,e){var r=e.hitsPerPage;return r>0?Math.ceil(t/r):0},f=function(t,e){var r=e.page,n=e.hitsPerPage,i=r*n;return t.splice(i,n)};function d(t){return"string"==typeof t||t instanceof String}var l=function(t,e,r){return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",d(t)?t.replace(/<em>/g,e).replace(/<\/em>/g,r):JSON.stringify(t)},p=function(t){var e=t.formattedHit,r=t.highlightPreTag,n=t.highlightPostTag;return Object.keys(e).reduce((function(t,i){return t[i]={value:l(e[i],r,n)},t}),{})},y=function(t,e,r,n){var i=t;return void 0!==e&&d(i)&&i&&(i[0]===i[0].toLowerCase()&&!1===i.startsWith("<em>")&&(i=""+e+i),!1==!!i.match(/[.!?]$/)&&(i=""+i+e)),l(i,r,n)},v=function(t){var e=t.formattedHit,r=t.attributesToSnippet,n=t.snippetEllipsisText,i=t.highlightPreTag,s=t.highlightPostTag;return void 0===r?null:(r=r.map((function(t){return t.split(":")[0]})),Object.keys(e).reduce((function(t,o){return r.includes(o)&&(t[o]={value:y(e[o],n,i,s)}),t}),{}))},b=function(t,r,n){var i=n.primaryKey;return f(t,n).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesInfo;var s=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesInfo"]);return e(e(e({},s),function(t,r){return!t||t.length?{}:{_highlightResult:p(e({formattedHit:t},r)),_snippetResult:v(e({formattedHit:t},r))}}(n,r)),i&&{objectID:t[i]})}return t}))},g=function(t,r,n,i){var s=r.exhaustiveFacetsCount,o=r.exhaustiveNbHits,u=r.facetsDistribution,a=r.nbHits,c=r.processingTimeMs,f=r.query,d=r.hits,l=i.hitsPerPage,p=i.page;return{results:[e(e(e({index:t,hitsPerPage:l},u&&{facets:u}),s&&{exhaustiveFacetsCount:s}),{page:p,nbPages:h(d.length,i),exhaustiveNbHits:o,nbHits:a,processingTimeMS:c,query:f,hits:b(d,n,i)})]}},w=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[void 0]},m=function(t){var r=function(t){return"string"==typeof t?w(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return w(t)})):w(t)})).flat(2):[void 0]}(t);return r.filter((function(t){return void 0!==t})).reduce((function(t,r){var n,s=r.filterName,o=r.value,u=t[s]||[];return t=e(e({},t),((n={})[s]=i(i([],u),[o]),n))}),{})};t.adaptToISHits=b,t.adaptToISResponse=g,t.adaptToMeiliSearchParams=c,t.createHighlighResult=p,t.createSnippetResult=v,t.getNumberPages=h,t.instantMeiliSearch=function(t,e,i){return void 0===i&&(i={}),{MeiliSearchClient:new u.MeiliSearch({host:t,apiKey:e}),search:function(t){return r(this,void 0,void 0,(function(){var e,r,s,o,u,a,h,f,d,l,p,y,v,b;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=t[0],r=e.params,s=e.indexName,o=i.paginationTotalHits,u=i.primaryKey,a=i.placeholderSearch,h=r.page,f=r.hitsPerPage,d=this.MeiliSearchClient,p=c(r,l={client:d,paginationTotalHits:o||200,primaryKey:u||void 0,placeholderSearch:!1!==a,hitsPerPage:void 0===f?20:f,page:h||0}),y=m(p.filter),[4,d.index(s).search(p.q,p)];case 1:return(v=n.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var r in t)for(var n=0,i=t[r];n<i.length;n++){var s=i[n];e[r]&&Object.keys(e[r]).includes(s)||(e[r]=e[r]||{},e[r][s]=0)}return e}(y,v.facetsDistribution),[2,g(s,v,r,l)];case 2:throw b=n.sent(),console.error(b),new Error(b);case 3:return[2]}}))}))}}},t.isString=d,t.paginateHits=f,t.replaceHighlightTags=l,t.snippetValue=y,Object.defineProperty(t,"__esModule",{value:!0})}));
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,r,n){function i(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,s){function o(t){try{a(n.next(t))}catch(t){s(t)}}function u(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){t.done?r(t.value):i(t.value).then(o,u)}a((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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(r){var n=t.call(this,r)||this;return n.name="MeiliSearchError",n.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(n,e),n}return r(e,t),e}(Error),u=function(t){function e(r){var n=t.call(this,r)||this;return n.name="MeiliSearchTimeOutError",n.type=n.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(n,e),n}return r(e,t),e}(Error);function a(t){return Object.entries(t).reduce((function(t,e){var r=e[0],n=e[1];return void 0!==n&&(t[r]=n),t}),{})}function c(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()]}}))}))}var h=function(t){function e(r,n){var i=t.call(this,r)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",n instanceof Response&&(i.message=n.statusText,i.statusCode=n.status),n instanceof Error&&(i.errno=n.errno,i.code=n.code),Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return r(e,t),e}(Error),f=function(t){function e(e,r){var n=t.call(this,e.message)||this;return n.type="MeiliSearchApiError",n.name="MeiliSearchApiError",n.errorCode=e.errorCode,n.errorType=e.errorType,n.errorLink=e.errorLink,n.message=e.message,n.httpStatus=r,Error.captureStackTrace&&Error.captureStackTrace(n,f),n}return r(e,t),e}(Error);function d(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:if(t.ok)return[3,5];e=void 0,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,t.json()];case 2:return e=r.sent(),[3,4];case 3:throw r.sent(),new h(t.statusText,t);case 4:throw new f(e,t.status);case 5:return[2,t]}}))}))}function l(t){if("MeiliSearchApiError"!==t.type)throw new h(t.message,t);throw t}var p=function(){function t(t){this.headers=n(n(n({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=new URL(t.host)}return t.addTrailingSlash=function(t){return t.endsWith("/")||(t+="/"),t},t.prototype.request=function(t){var e=t.method,r=t.url,o=t.params,u=t.body,a=t.config;return i(this,void 0,void 0,(function(){var t,i,c;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),t=new URL(r,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()),[4,fetch(t.toString(),n(n({},a),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return d(t)}))];case 1:return[4,s.sent().text()];case 2:c=s.sent();try{return[2,JSON.parse(c)]}catch(t){return[2]}return[3,4];case 3:return l(s.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,r){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:r})];case 1:return[2,n.sent()]}}))}))},t.prototype.post=function(t,e,r,n){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:r,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,r,n){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:r,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,r,n){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:r,config:n})];case 1:return[2,i.sent()]}}))}))},t}(),y=function(){function t(t,e,r){this.uid=e,this.primaryKey=r,this.httpRequest=new p(t)}return t.prototype.waitForPendingUpdate=function(t,e){var r=void 0===e?{}:e,n=r.timeOutMs,o=void 0===n?5e3:n,a=r.intervalMs,h=void 0===a?50:a;return i(this,void 0,void 0,(function(){var e,r;return s(this,(function(n){switch(n.label){case 0:e=Date.now(),n.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return r=n.sent(),["enqueued","processing"].includes(r.status)?[4,c(h)]:[2,r];case 3:return n.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.search=function(t,e,r){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",[4,this.httpRequest.post(i,a(n(n({},e),{q:t})),void 0,r)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,r){return i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",u=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new o("The filter query parameter should be in string format when using searchGet")},c=n(n({q:t},e),{filter:u(null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)?e.sort.join(","):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(i,a(c),r)];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(r){switch(r.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return e=r.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(e,r,o){return void 0===o&&(o={}),i(this,void 0,void 0,(function(){var i,u;return s(this,(function(s){switch(s.label){case 0:return i="indexes",[4,new p(e).post(i,n(n({},o),{uid:r}))];case 1:return u=s.sent(),[2,new t(e,r,u.primaryKey)]}}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e,r;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return r=n.sent(),this.primaryKey=r.primaryKey,[2,this]}}))}))},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/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIfExists=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]),[4,this.delete()];case 1:return e.sent(),[2,!0];case 2:if("index_not_found"===(t=e.sent()).errorCode)return[2,!1];throw t;case 3:return[2]}}))}))},t.prototype.getAllUpdateStatus=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getUpdateStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,r.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/"+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,r;return s(this,(function(i){switch(i.label){case 0:return e="indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(r=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,n(n({},t),void 0!==r?{attributesToRetrieve:r}:{}))];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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/documents/"+t,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var r;return s(this,(function(n){switch(n.label){case 0:return r="indexes/"+this.uid+"/documents",[4,this.httpRequest.post(r,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var r;return s(this,(function(n){switch(n.label){case 0:return r="indexes/"+this.uid+"/documents",[4,this.httpRequest.put(r,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/documents/"+t,[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/documents/delete-batch",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+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/"+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(r){switch(r.label){case 0:return e="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.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/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),v=function(){function t(t){t.host=p.addTrailingSlash(t.host),this.config=t,this.httpRequest=new p(t)}return t.prototype.index=function(t){return new y(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).fetchInfo()]}))}))},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var r;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getIndex(t)];case 1:return[2,n.sent()];case 2:if("index_not_found"===(r=n.sent()).errorCode)return[2,this.createIndex(t,e)];throw new f(r,r.status);case 3:return[2]}}))}))},t.prototype.listIndexes=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(r){switch(r.label){case 0:return[4,y.create(this.config,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,new y(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).delete()]}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return r.sent(),[2,!0];case 2:if("index_not_found"===(e=r.sent()).errorCode)return[2,!1];throw e;case 3:return[2]}}))}))},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.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.stats=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.version=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(r){switch(r.label){case 0:return e="dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t}();t.MeiliSearch=v,Object.defineProperty(t,"__esModule",{value:!0})}(e)})),a=function(t){return t.replace(/:(.*)/i,'="$1"')},c=function(t,r){var n=t.query,s=t.facets,o=t.facetFilters,u=t.attributesToSnippet,c=t.attributesToRetrieve,h=t.attributesToHighlight,f=t.filters,d=void 0===f?"":f,l=t.numericFilters,p=void 0===l?[]:l,y=r.paginationTotalHits,v=r.placeholderSearch,b=r.sort,g=y,w=function(t,e,r){var n=[r.join(" AND "),e.trim()].filter((function(t){return t})).join(" AND ").trim();return Array.isArray(t)&&n?i(i([],t),[[n]]):"string"==typeof t&&n?[t,[n]]:t}(function(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)})):a(t)})):[]}(o),d,p);return e(e(e(e(e(e({q:n},(null==s?void 0:s.length)&&{facetsDistribution:s}),u&&{attributesToCrop:u}),c&&{attributesToRetrieve:c}),w.length&&{filter:w}),{attributesToHighlight:h||["*"],limit:!v&&""===n||!g?0:g}),(null==b?void 0:b.length)&&{sort:[b]})},h=function(t,e){var r=e.hitsPerPage;return r>0?Math.ceil(t/r):0},f=function(t,e){var r=e.page,n=e.hitsPerPage,i=r*n;return t.splice(i,n)};function d(t){return"string"==typeof t||t instanceof String}var l=function(t,e,r){return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",d(t)?t.replace(/<em>/g,e).replace(/<\/em>/g,r):JSON.stringify(t)},p=function(t){var e=t.formattedHit,r=t.highlightPreTag,n=t.highlightPostTag;return Object.keys(e).reduce((function(t,i){return t[i]={value:l(e[i],r,n)},t}),{})},y=function(t,e,r,n){var i=t;return void 0!==e&&d(i)&&i&&(i[0]===i[0].toLowerCase()&&!1===i.startsWith("<em>")&&(i=""+e+i),!1==!!i.match(/[.!?]$/)&&(i=""+i+e)),l(i,r,n)},v=function(t){var e=t.formattedHit,r=t.attributesToSnippet,n=t.snippetEllipsisText,i=t.highlightPreTag,s=t.highlightPostTag;return void 0===r?null:(r=r.map((function(t){return t.split(":")[0]})),Object.keys(e).reduce((function(t,o){return r.includes(o)&&(t[o]={value:y(e[o],n,i,s)}),t}),{}))},b=function(t,r,n){var i=n.primaryKey;return f(t,n).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesInfo;var s=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesInfo"]);return e(e(e({},s),function(t,r){return!t||t.length?{}:{_highlightResult:p(e({formattedHit:t},r)),_snippetResult:v(e({formattedHit:t},r))}}(n,r)),i&&{objectID:t[i]})}return t}))},g=function(t,r,n,i){var s=r.exhaustiveFacetsCount,o=r.exhaustiveNbHits,u=r.facetsDistribution,a=r.nbHits,c=r.processingTimeMs,f=r.query,d=r.hits,l=i.hitsPerPage,p=i.page;return{results:[e(e(e({index:t,hitsPerPage:l},u&&{facets:u}),s&&{exhaustiveFacetsCount:s}),{page:p,nbPages:h(d.length,i),exhaustiveNbHits:o,nbHits:a,processingTimeMS:c,query:f,hits:b(d,n,i)})]}},w=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[void 0]},m=function(t){var r=function(t){return"string"==typeof t?w(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return w(t)})):w(t)})).flat(2):[void 0]}(t);return r.filter((function(t){return void 0!==t})).reduce((function(t,r){var n,s=r.filterName,o=r.value,u=t[s]||[];return t=e(e({},t),((n={})[s]=i(i([],u),[o]),n))}),{})};t.adaptToISHits=b,t.adaptToISResponse=g,t.adaptToMeiliSearchParams=c,t.createHighlighResult=p,t.createSnippetResult=v,t.getNumberPages=h,t.instantMeiliSearch=function(t,e,i){return void 0===i&&(i={}),{MeiliSearchClient:new u.MeiliSearch({host:t,apiKey:e}),search:function(t){return r(this,void 0,void 0,(function(){var e,r,s,o,u,a,h,f,d,l,p,y,v,b,w,x,R;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=t[0],r=e.params,s=e.indexName,o=s.split(":"),u=o[0],a=o.slice(1),h=i.paginationTotalHits,f=i.primaryKey,d=i.placeholderSearch,l=r.page,p=r.hitsPerPage,y=this.MeiliSearchClient,v={client:y,paginationTotalHits:h||200,primaryKey:f||void 0,placeholderSearch:!1!==d,hitsPerPage:void 0===p?20:p,page:l||0,sort:a.join(":")||""},b=c(r,v),w=m(b.filter),[4,y.index(u).search(b.q,b)];case 1:return(x=n.sent()).facetsDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var r in t)for(var n=0,i=t[r];n<i.length;n++){var s=i[n];e[r]&&Object.keys(e[r]).includes(s)||(e[r]=e[r]||{},e[r][s]=0)}return e}(w,x.facetsDistribution),[2,g(u,x,r,v)];case 2:throw R=n.sent(),console.error(R),new Error(R);case 3:return[2]}}))}))}}},t.isString=d,t.paginateHits=f,t.replaceHighlightTags=l,t.snippetValue=y,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=instant-meilisearch.umd.min.js.map

@@ -1,2 +0,2 @@

// Type definitions for @meilisearch/instant-meilisearch 0.5.2
// Type definitions for @meilisearch/instant-meilisearch 0.5.3
// Project: https://github.com/meilisearch/instant-meilisearch.git

@@ -3,0 +3,0 @@ // Definitions by: Clementine Urquizar <https://github.com/meilisearch>

@@ -19,2 +19,3 @@ import * as MStypes from 'meilisearch';

facetFilters?: Filter;
sort?: string;
};

@@ -51,2 +52,3 @@ export declare type ISSearchRequest = {

placeholderSearch: boolean;
sort?: string;
};

@@ -53,0 +55,0 @@ export declare type FormattedHit = {

{
"name": "@meilisearch/instant-meilisearch",
"version": "0.5.2",
"version": "0.5.3",
"private": false,

@@ -15,2 +15,3 @@ "description": "The search client to use MeiliSearch with InstantSearch.",

"test:all": "yarn test:e2e:all && yarn test && test:build",
"cy:open": "cypress open",
"playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue serve",

@@ -56,8 +57,8 @@ "playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react start",

"dependencies": {
"meilisearch": "^0.20.0"
"meilisearch": "^0.20.1"
},
"devDependencies": {
"@babel/cli": "^7.14.8",
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@rollup/plugin-commonjs": "^17.1.0",

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

"eslint-plugin-vue": "^7.7.0",
"instantsearch.js": "^4.16.1",
"instantsearch.js": "^4.30.0",
"jest": "^26.6.3",

@@ -92,0 +93,0 @@ "jest-watch-typeahead": "^0.6.3",

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

This package only guarantees the compatibility with the [version v0.21.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.21.0).
This package only guarantees the compatibility with the [version v0.22.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.22.0).

@@ -193,2 +193,43 @@ **Node / NPM versions**:

### Table Of Widgets
- ✅ [InstantSearch](#-instantsearch)
- ❌[index](#-index)
- ✅ [SearchBox](#-searchbox)
- ✅ [Configure](#-configure)
- ❌[ConfigureRelatedItems](#-configure-related-items)
- ❌[Autocomplete](#-autocomplete)
- ✅ [Voice Search](#-voice-search)
- ✅ [Insight](#-insight)
- ✅ [Middleware](#-middleware)
- ✅ [RenderState](#-renderstate)
- ✅ [Hits](#-hits)
- ✅ [InfiniteHits](#-infinitehits)
- ✅ [Highlight](#-highlight)
- ✅ [Snippet](#-snippet)
- ❌[Geo Search](#-geo-search)
- ❌[Answers](#-answers)
- ✅ [RefinementList](#-refinementlist)
- ❌[HierarchicalMenu](#-hierarchicalmenu)
- ✅ [RangeSlider](#-rangeslider)
- ✅ [Menu](#-menu)
- ✅ [currentRefinements](#-currentrefinements)
- ✅ [RangeInput](#-rangeinput)
- ✅ [MenuSelect](#-menuselect)
- ✅ [ToggleRefinement](#-togglerefinement)
- ✅ [NumericMenu](#-numericmenu)
- ❌[RatingMenu](#-ratingmenu)
- ✅ [ClearRefinements](#-clearrefinements)
- ✅ [Pagination](#-pagination)
- ✅ [HitsPerPage](#-hitsperpage)
- ❌[Breadcrumb](#-breadcrumb)
- ✅ [Stats](#-stats)
- ❌[Analytics](#-analytics)
- ❌[QueryRuleCustomData](#-queryrulecustomdata)
- ❌[QueryRuleContext](#-queryrulecontext)
- ✅ [SortBy](#-sortby)
- ❌[RelevantSort](#-relevantsort)
- ✅ [Routing](#-routing)
### ✅ InstantSearch

@@ -526,3 +567,3 @@

Example:
Example:
Given the attribute `id` that has not been added in `filterableAttributes`:

@@ -744,12 +785,68 @@

### ❌ SortBy
### ✅ SortBy
[Sort by references](https://www.algolia.com/doc/api-reference/widgets/sort-by/js/)
The sortBy widget displays a list of indices, allowing a user to change the way hits are sorted (with replica indices). Another common use case is to let the user switch between different indices.
The `SortBy` widget is used to create multiple sort formulas. Allowing a user to change the way hits are sorted.
No compatibility because MeiliSearch does not support hierarchical facets.
- ✅ container: The CSS Selector or HTMLElement to insert the widget into. _required_
- ✅ items: The list of different sorting possibilities. _required_
- ✅ cssClasses: The CSS classes to override.
- ✅ transformItems: function receiving the items, called before displaying them.
If you'd like to get the "SortBy" feature, please vote for it in the [roadmap]https://roadmap.meilisearch.com/c/32-sort-by?utm_medium=social&utm_source=portal_share).
The usage of the `SortBy` widget differs from the one found in Algolia's documentation. In instant-meilisearch the following is possible:
- Sort using different indexes.
- Different `sort` rules on the same index.
The items list is composed of objects containing every sort possibility you want to provide to your user. Each object must contain two fields:
- `label`: What is showcased on the user interface ex: `Sort by Ascending Price`
- `value`: The sort formula.
#### Sort formula
A sort formula is expressed like this: `index:attribute:order`.
`index` is mandatory, and when adding `attribute:order`, they must always be added together.
When sorting on an attribute, the attribute has to be added to the [`sortableAttributes`](https://docs.meilisearch.com/reference/api/sortable_attributes.html) setting on your index.
Example:
```js
[
{ label: 'Sort By Price', value: 'clothes:price:asc' }
]
```
In this scenario, in the `clothes` index, we want the price to be sorted in an ascending way. For this formula to be valid, `price` must be added to the `sortableAttributes` settings of the `clothes` index.
#### Relevancy
The impact sorting has on the returned hits is determined by the [`ranking-rules`](https://docs.meilisearch.com/learn/core_concepts/relevancy.html#ranking-rules) ordered list of each index. The `sort` ranking-rule position in the list makes sorting documents more or less important than other rules. If you want to change the sort impact on the relevancy, it is possible to change it in the [ranking-rule setting](https://docs.meilisearch.com/learn/core_concepts/relevancy.html#relevancy). For example, to favor exhaustivity over relevancy.
See [relevancy guide](https://docs.meilisearch.com/learn/core_concepts/relevancy.html#relevancy).
#### Example
```js
instantsearch.widgets.sortBy({
container: '#sort-by',
items: [
{ value: 'clothes', label: 'Relevant' }, // default index
{
value: 'clothes:price:asc', // Sort on descending price
label: 'Ascending price using query time sort',
},
{
value: 'clothes:price:asc', // Sort on ascending price
label: 'Descending price using query time sort',
},
{
value: 'clothes-sorted', // different index with different ranking rules.
label: 'Custom sort using a different index',
},
],
}),
```
### ❌ RelevantSort

@@ -756,0 +853,0 @@

@@ -54,3 +54,3 @@ import { AdaptToMeiliSearchParams, Filter } from '../types'

},
{ paginationTotalHits, placeholderSearch }
{ paginationTotalHits, placeholderSearch, sort }
) {

@@ -67,6 +67,7 @@ const limit = paginationTotalHits

...(attributesToRetrieve && { attributesToRetrieve }),
...(filter && { filter: filter }),
...(filter.length && { filter: filter }),
attributesToHighlight: attributesToHighlight || ['*'],
limit: (!placeholderSearch && query === '') || !limit ? 0 : limit,
...(sort?.length && { sort: [sort] }),
}
}

@@ -16,7 +16,7 @@ import { MeiliSearch } from 'meilisearch'

const isSearchRequest = instantSearchRequests[0]
const {
params: instantSearchParams,
indexName: indexUid,
} = isSearchRequest
const { params: instantSearchParams, indexName } = isSearchRequest
// Split index name and possible sorting rules
const [indexUid, ...sortByArray] = indexName.split(':')
const { paginationTotalHits, primaryKey, placeholderSearch } = options

@@ -32,2 +32,3 @@ const { page, hitsPerPage } = instantSearchParams

page: page || 0, // default page is 0 if none is provided
sort: sortByArray.join(':') || '',
}

@@ -40,3 +41,2 @@

)
const cachedFacet = cacheFilters(msSearchParams.filter)

@@ -43,0 +43,0 @@

@@ -26,2 +26,3 @@ import * as MStypes from 'meilisearch'

facetFilters?: Filter
sort?: string
}

@@ -69,2 +70,3 @@

placeholderSearch: boolean
sort?: string
}

@@ -71,0 +73,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

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