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.6.0 to 0.6.1

28

dist/instant-meilisearch.cjs.js

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

/**
* Transform InstantSearch filter to MeiliSearch filter.
* Transform InstantSearch filter to Meilisearch filter.
* Change sign from `:` to `=` in nested filter object.

@@ -471,3 +471,3 @@ * example: [`genres:comedy`] becomes [`genres=comedy`]

/**
* Adapt instantsearch.js filters to MeiliSearch filters by
* Adapt instantsearch.js filters to Meilisearch filters by
* combining and transforming all provided filters.

@@ -488,3 +488,3 @@ *

* Adapt search request from instantsearch.js
* to search request compliant with MeiliSearch
* to search request compliant with Meilisearch
*

@@ -495,3 +495,3 @@ * @param {SearchContext} searchContext

function adaptSearchParams(searchContext) {
// Creates search params object compliant with MeiliSearch
// Creates search params object compliant with Meilisearch
var meiliSearchParams = {};

@@ -571,3 +571,3 @@ // Facets

/**
* Replace `em` tags in highlighted MeiliSearch hits to
* Replace `em` tags in highlighted Meilisearch hits to
* provided tags by instantsearch.js.

@@ -583,3 +583,3 @@ *

if (postTag === void 0) { postTag = '__/ais-highlight__'; }
// Highlight is applied by MeiliSearch (<em> tags)
// Highlight is applied by Meilisearch (<em> tags)
// We replace the <em> by the expected tag for InstantSearch

@@ -621,3 +621,3 @@ var stringifiedValue = isString(value) ? value : JSON.stringify(value);

function adaptHighlight(hit, preTag, postTag) {
// hit is the `_formatted` object returned by MeiliSearch.
// hit is the `_formatted` object returned by Meilisearch.
// It contains all the highlighted and croped attributes

@@ -637,3 +637,3 @@ if (!hit._formatted)

function addEllipsis(value, formatValue, ellipsis) {
// Manage ellpsis on cropped values until this feature is implemented https://roadmap.meilisearch.com/c/69-policy-for-cropped-values?utm_medium=social&utm_source=portal_share in MeiliSearch
// Manage ellpsis on cropped values until this feature is implemented https://roadmap.meilisearch.com/c/69-policy-for-cropped-values?utm_medium=social&utm_source=portal_share in Meilisearch
var ellipsedValue = formatValue;

@@ -643,3 +643,3 @@ if (isString(formatValue) &&

if (formatValue[0] === formatValue[0].toLowerCase() && // beginning of a sentence
formatValue.startsWith('<em>') === false // beginning of the document field, otherwise MeiliSearch would crop around the highlight
formatValue.startsWith('<em>') === false // beginning of the document field, otherwise Meilisearch would crop around the highlight
) {

@@ -676,3 +676,3 @@ ellipsedValue = "".concat(ellipsis).concat(formatValue.trim());

function adaptSnippet(hit, attributes, ellipsis) {
// hit is the `_formatted` object returned by MeiliSearch.
// hit is the `_formatted` object returned by Meilisearch.
// It contains all the highlighted and croped attributes

@@ -706,3 +706,3 @@ var formattedHit = hit._formatted;

/**
* Adapt MeiliSearch formating to formating compliant with instantsearch.js.
* Adapt Meilisearch formating to formating compliant with instantsearch.js.
*

@@ -771,3 +771,3 @@ * @param {Record<string} formattedHit

/**
* Adapt search response from MeiliSearch
* Adapt search response from Meilisearch
* to search response compliant with instantsearch.js

@@ -868,3 +868,3 @@ *

return [4 /*yield*/, searchResolver.searchResponse(searchContext, adaptedSearchRequest, this.MeiliSearchClient)
// Adapt the MeiliSearch responsne to a compliant instantsearch.js response
// Adapt the Meilisearch responsne to a compliant instantsearch.js response
];

@@ -889,3 +889,3 @@ case 1:

case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
reject(new Error('SearchForFacetValues is not compatible with MeiliSearch'));
reject(new Error('SearchForFacetValues is not compatible with Meilisearch'));
resolve([]); // added here to avoid compilation error

@@ -892,0 +892,0 @@ })];

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

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

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

/**
* Transform InstantSearch filter to MeiliSearch filter.
* Transform InstantSearch filter to Meilisearch filter.
* Change sign from `:` to `=` in nested filter object.

@@ -467,3 +467,3 @@ * example: [`genres:comedy`] becomes [`genres=comedy`]

/**
* Adapt instantsearch.js filters to MeiliSearch filters by
* Adapt instantsearch.js filters to Meilisearch filters by
* combining and transforming all provided filters.

@@ -484,3 +484,3 @@ *

* Adapt search request from instantsearch.js
* to search request compliant with MeiliSearch
* to search request compliant with Meilisearch
*

@@ -491,3 +491,3 @@ * @param {SearchContext} searchContext

function adaptSearchParams(searchContext) {
// Creates search params object compliant with MeiliSearch
// Creates search params object compliant with Meilisearch
var meiliSearchParams = {};

@@ -567,3 +567,3 @@ // Facets

/**
* Replace `em` tags in highlighted MeiliSearch hits to
* Replace `em` tags in highlighted Meilisearch hits to
* provided tags by instantsearch.js.

@@ -579,3 +579,3 @@ *

if (postTag === void 0) { postTag = '__/ais-highlight__'; }
// Highlight is applied by MeiliSearch (<em> tags)
// Highlight is applied by Meilisearch (<em> tags)
// We replace the <em> by the expected tag for InstantSearch

@@ -617,3 +617,3 @@ var stringifiedValue = isString(value) ? value : JSON.stringify(value);

function adaptHighlight(hit, preTag, postTag) {
// hit is the `_formatted` object returned by MeiliSearch.
// hit is the `_formatted` object returned by Meilisearch.
// It contains all the highlighted and croped attributes

@@ -633,3 +633,3 @@ if (!hit._formatted)

function addEllipsis(value, formatValue, ellipsis) {
// Manage ellpsis on cropped values until this feature is implemented https://roadmap.meilisearch.com/c/69-policy-for-cropped-values?utm_medium=social&utm_source=portal_share in MeiliSearch
// Manage ellpsis on cropped values until this feature is implemented https://roadmap.meilisearch.com/c/69-policy-for-cropped-values?utm_medium=social&utm_source=portal_share in Meilisearch
var ellipsedValue = formatValue;

@@ -639,3 +639,3 @@ if (isString(formatValue) &&

if (formatValue[0] === formatValue[0].toLowerCase() && // beginning of a sentence
formatValue.startsWith('<em>') === false // beginning of the document field, otherwise MeiliSearch would crop around the highlight
formatValue.startsWith('<em>') === false // beginning of the document field, otherwise Meilisearch would crop around the highlight
) {

@@ -672,3 +672,3 @@ ellipsedValue = "".concat(ellipsis).concat(formatValue.trim());

function adaptSnippet(hit, attributes, ellipsis) {
// hit is the `_formatted` object returned by MeiliSearch.
// hit is the `_formatted` object returned by Meilisearch.
// It contains all the highlighted and croped attributes

@@ -702,3 +702,3 @@ var formattedHit = hit._formatted;

/**
* Adapt MeiliSearch formating to formating compliant with instantsearch.js.
* Adapt Meilisearch formating to formating compliant with instantsearch.js.
*

@@ -767,3 +767,3 @@ * @param {Record<string} formattedHit

/**
* Adapt search response from MeiliSearch
* Adapt search response from Meilisearch
* to search response compliant with instantsearch.js

@@ -864,3 +864,3 @@ *

return [4 /*yield*/, searchResolver.searchResponse(searchContext, adaptedSearchRequest, this.MeiliSearchClient)
// Adapt the MeiliSearch responsne to a compliant instantsearch.js response
// Adapt the Meilisearch responsne to a compliant instantsearch.js response
];

@@ -885,3 +885,3 @@ case 1:

case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
reject(new Error('SearchForFacetValues is not compatible with MeiliSearch'));
reject(new Error('SearchForFacetValues is not compatible with Meilisearch'));
resolve([]); // added here to avoid compilation error

@@ -888,0 +888,0 @@ })];

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

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

@@ -28,3 +28,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";

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

@@ -5,0 +5,0 @@ *

import type { MeiliSearchParams, SearchContext } from '../../types';
/**
* Adapt search request from instantsearch.js
* to search request compliant with MeiliSearch
* to search request compliant with Meilisearch
*

@@ -6,0 +6,0 @@ * @param {SearchContext} searchContext

import { SearchContext } from '../../../types';
/**
* Adapt MeiliSearch formating to formating compliant with instantsearch.js.
* Adapt Meilisearch formating to formating compliant with instantsearch.js.
*

@@ -5,0 +5,0 @@ * @param {Record<string} formattedHit

import type { SearchContext, MeiliSearchResponse, AlgoliaSearchResponse, PaginationContext } from '../../types';
/**
* Adapt search response from MeiliSearch
* Adapt search response from Meilisearch
* to search response compliant with instantsearch.js

@@ -5,0 +5,0 @@ *

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

// Type definitions for @meilisearch/instant-meilisearch 0.6.0
// Type definitions for @meilisearch/instant-meilisearch 0.6.1
// Project: https://github.com/meilisearch/instant-meilisearch.git

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

{
"name": "@meilisearch/instant-meilisearch",
"version": "0.6.0",
"version": "0.6.1",
"private": false,
"description": "The search client to use MeiliSearch with InstantSearch.",
"description": "The search client to use Meilisearch with InstantSearch.",
"scripts": {

@@ -11,8 +11,5 @@ "cleanup": "shx rm -rf dist/",

"test:build": "yarn build && jest --runInBand --selectProjects build",
"test:e2e:all": "sh scripts/e2e.sh",
"test:e2e:local": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress run --env playground=reactlocal --spec 'cypress/integration/local-ui.spec.js'\"",
"test:e2e:local:watch": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress open --env playground=reactlocal\"",
"test:e2e": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress run --env playground=local \"",
"test:e2e:watch": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress open --env playground=local\"",
"test:all": "yarn test:e2e:all && yarn test && test:build",
"test:e2e": "concurrently --kill-others -s first \"yarn playground:vue\" \"cypress run --env playground=vue\"",
"test:e2e:watch": "concurrently --kill-others -s first \"yarn playground:vue\" \"cypress open --env playground=vue\"",
"cy:open": "cypress open",

@@ -63,3 +60,3 @@ "playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue serve",

"dependencies": {
"meilisearch": "0.24.0"
"meilisearch": "0.25.0"
},

@@ -66,0 +63,0 @@ "devDependencies": {

<p align="center">
<img src="https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/logo.svg" alt="Instant-MeiliSearch" width="200" height="200" />
<img src="https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/logo.svg" alt="Instant-Meilisearch" width="200" height="200" />
</p>
<h1 align="center">Instant MeiliSearch</h1>
<h1 align="center">Instant Meilisearch</h1>
<h4 align="center">
<a href="https://github.com/meilisearch/MeiliSearch">MeiliSearch</a> |
<a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> |
<a href="https://docs.meilisearch.com">Documentation</a> |

@@ -20,11 +20,11 @@ <a href="https://slack.meilisearch.com">Slack</a> |

<a href="https://github.com/meilisearch/instant-meilisearch/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
<a href="https://github.com/meilisearch/MeiliSearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
<a href="https://github.com/meilisearch/meilisearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
<a href="https://app.bors.tech/repositories/28908"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
</p>
<p align="center">⚡ How to integrate a front-end search bar in your website using MeiliSearch</p>
<p align="center">⚡ How to integrate a front-end search bar in your website using Meilisearch</p>
**MeiliSearch** is an open-source search engine. [Discover what MeiliSearch is!](https://github.com/meilisearch/MeiliSearch)
**Meilisearch** is an open-source search engine. [Discover what Meilisearch is!](https://github.com/meilisearch/meilisearch)
This library is a plugin to establish the communication between your [MeiliSearch](https://github.com/meilisearch/MeiliSearch) instance and the open-source [InstantSearch](https://github.com/algolia/instantsearch.js) tools (powered by Algolia) for your front-end application.<br>
This library is a plugin to establish the communication between your [Meilisearch](https://github.com/meilisearch/meilisearch) instance and the open-source [InstantSearch](https://github.com/algolia/instantsearch.js) tools (powered by Algolia) for your front-end application.<br>
Instead of reinventing the wheel, we have opted to reuse the InstantSearch library for our own front-end tooling. We will contribute upstream any improvements that may result from our adoption of InstantSearch.

@@ -38,3 +38,3 @@

NB: If you don't have any MeiliSearch instance running and containing your data, you should take a look at this [getting started page](https://docs.meilisearch.com/learn/tutorials/getting_started.html).
NB: If you don't have any Meilisearch instance running and containing your data, you should take a look at this [getting started page](https://docs.meilisearch.com/learn/tutorials/getting_started.html).

@@ -46,3 +46,3 @@ ## Table of Contents <!-- omit in toc -->

- [⚡️ Example with InstantSearch](#-example-with-instantSearch)
- [🤖 Compatibility with MeiliSearch and InstantSearch](#-compatibility-with-meilisearch-and-instantsearch)
- [🤖 Compatibility with Meilisearch and InstantSearch](#-compatibility-with-meilisearch-and-instantsearch)
- [📜 API Resources](#-api-resources)

@@ -63,3 +63,3 @@ - [⚙️ Development Workflow and Contributing](#️-development-workflow-and-contributing)

InstantMeiliSearch is a client for `instantsearch.js`. It does not create any UI component by itself.<br>
`instant-meilisearch` is a client for `instantsearch.js`. It does not create any UI component by itself.<br>
To be able to create a search interface, you'll need to [install `instantsearch.js`](https://www.algolia.com/doc/guides/building-search-ui/installation/js/) as well.

@@ -76,3 +76,3 @@

'https://integration-demos.meilisearch.com',
'SEJe5jmM54f7afa09d0500b1fcc5bbeda8e4667453f5af2707c7fd62db6e4727701be0ae'
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47'
)

@@ -88,3 +88,3 @@ ```

'https://integration-demos.meilisearch.com',
'SEJe5jmM54f7afa09d0500b1fcc5bbeda8e4667453f5af2707c7fd62db6e4727701be0ae',
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47',
{

@@ -103,4 +103,4 @@ paginationTotalHits: 30, // default: 200.

The default value of `hitsPerPage` is set to `20` but it can be changed with [`InsantSearch.configure`](https://www.algolia.com/doc/api-reference/widgets/configure/js/#examples).<br>
⚠️ MeiliSearch is not designed for pagination and this can lead to performances issues, so the usage of the pagination widget is not encouraged. However, the `paginationTotalHits` parameter lets you implement this pagination with less performance issue as possible: depending on your dataset (the size of each document and the number of documents) you might decrease the value of `paginationTotalHits`.<br>
More information about MeiliSearch and the pagination [here](https://github.com/meilisearch/documentation/issues/561).
⚠️ Meilisearch is not designed for pagination and this can lead to performances issues, so the usage of the pagination widget is not encouraged. However, the `paginationTotalHits` parameter lets you implement this pagination with less performance issue as possible: depending on your dataset (the size of each document and the number of documents) you might decrease the value of `paginationTotalHits`.<br>
More information about Meilisearch and the pagination [here](https://github.com/meilisearch/documentation/issues/561).
- `primaryKey` (`undefined` by default): Specify the field in your documents containing the [unique identifier](https://docs.meilisearch.com/learn/core_concepts/documents.html#primary-field). By adding this option, we avoid instantSearch errors that are thrown in the browser console. In `React` particularly, this option removes the `Each child in a list should have a unique "key" prop` error.

@@ -112,3 +112,3 @@

InstantSearch requires that you provide an indexName. The indexName corresponds to the [index `uid`](https://docs.meilisearch.com/learn/core_concepts/indexes.html#indexes) in which your document are stored in MeiliSearch.
InstantSearch requires that you provide an indexName. The indexName corresponds to the [index `uid`](https://docs.meilisearch.com/learn/core_concepts/indexes.html#indexes) in which your document are stored in Meilisearch.

@@ -144,3 +144,3 @@ In `index.html`:

'https://integration-demos.meilisearch.com',
'SEJe5jmM54f7afa09d0500b1fcc5bbeda8e4667453f5af2707c7fd62db6e4727701be0ae'
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47'
),

@@ -179,3 +179,3 @@ })

- The open-source InstantSearch library is widely used and well documented in the [Algolia documentation](https://www.algolia.com/doc/api-reference/widgets/js/). It provides all the widgets to customize and improve your search bar environment in your website.
- The [MeiliSearch documentation](https://docs.meilisearch.com/).
- The [Meilisearch documentation](https://docs.meilisearch.com/).
- If you use React, check out [meilisearch-react](https://github.com/meilisearch/meilisearch-react/)

@@ -186,3 +186,3 @@ - If you use Vue, check out [meilisearch-vue](https://github.com/meilisearch/meilisearch-vue/)

## 🤖 Compatibility with MeiliSearch and InstantSearch
## 🤖 Compatibility with Meilisearch and InstantSearch

@@ -193,5 +193,5 @@ **Supported InstantSearch.js versions**:

**Supported MeiliSearch versions**:
**Supported Meilisearch versions**:
This package only guarantees the compatibility with the [version v0.25.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.25.0).
This package only guarantees the compatibility with the [version v0.26.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.26.0).

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

List of all the components that are available in [instantSearch](https://github.com/algolia/instantsearch.js) and their compatibility with [MeiliSearch](https://github.com/meilisearch/meilisearch/).
List of all the components that are available in [instantSearch](https://github.com/algolia/instantsearch.js) and their compatibility with [Meilisearch](https://github.com/meilisearch/meilisearch/).

@@ -211,7 +211,7 @@ ### Table Of Widgets

- ✅ [InstantSearch](#-instantsearch)
- ❌[index](#-index)
- ❌ [index](#-index)
- ✅ [SearchBox](#-searchbox)
- ✅ [Configure](#-configure)
- ❌[ConfigureRelatedItems](#-configure-related-items)
- ❌[Autocomplete](#-autocomplete)
- ❌ [ConfigureRelatedItems](#-configure-related-items)
- ❌ [Autocomplete](#-autocomplete)
- ✅ [Voice Search](#-voice-search)

@@ -226,5 +226,5 @@ - ✅ [Insight](#-insight)

- ✅ [Geo Search](#-geo-search)
- ❌[Answers](#-answers)
- ❌ [Answers](#-answers)
- ✅ [RefinementList](#-refinementlist)
- ❌[HierarchicalMenu](#-hierarchicalmenu)
- ✅ [HierarchicalMenu](#-hierarchicalmenu)
- ✅ [RangeSlider](#-rangeslider)

@@ -237,13 +237,13 @@ - ✅ [Menu](#-menu)

- ✅ [NumericMenu](#-numericmenu)
- ❌[RatingMenu](#-ratingmenu)
- ✅ [RatingMenu](#-ratingmenu)
- ✅ [ClearRefinements](#-clearrefinements)
- ✅ [Pagination](#-pagination)
- ✅ [HitsPerPage](#-hitsperpage)
- ❌[Breadcrumb](#-breadcrumb)
- ✅ [Breadcrumb](#-breadcrumb)
- ✅ [Stats](#-stats)
- ❌[Analytics](#-analytics)
- ❌[QueryRuleCustomData](#-queryrulecustomdata)
- ❌[QueryRuleContext](#-queryrulecontext)
- ❌ [Analytics](#-analytics)
- ❌ [QueryRuleCustomData](#-queryrulecustomdata)
- ❌ [QueryRuleContext](#-queryrulecontext)
- ✅ [SortBy](#-sortby)
- ❌[RelevantSort](#-relevantsort)
- ❌ [RelevantSort](#-relevantsort)
- ✅ [Routing](#-routing)

@@ -259,4 +259,4 @@

- ✅ IndexName: [`uid` of your index](https://docs.meilisearch.com/learn/core_concepts/indexes.html#indexes). _required_
- ✅ SearchClient: Search client, in our case instantMeiliSearch. See [customization](#customization) for details on options. _required_
- ❌ numberLocale: Does not work with both Algoliasearch and InstantMeiliSearch.
- ✅ SearchClient: Search client, in our case instant-meilisearch. See [customization](#customization) for details on options. _required_
- ❌ numberLocale: Does not work with both Algoliasearch and instant-meilisearch.
- ✅ searchFunction: Surcharge the search function provided by the search client.

@@ -274,3 +274,3 @@ - ✅ initialUiState: Determine the search state on app start.

'https://integration-demos.meilisearch.com',
'SEJe5jmM54f7afa09d0500b1fcc5bbeda8e4667453f5af2707c7fd62db6e4727701be0ae',
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47',
{

@@ -291,3 +291,3 @@ // ... InstantMeiliSearch options

Not compatible as MeiliSearch does not support federated search on multiple indexes.
Not compatible as Meilisearch does not support federated search on multiple indexes.

@@ -306,4 +306,4 @@ If you'd like to see federated search implemented please vote for it in the [roadmap](https://roadmap.meilisearch.com/c/74-multi-index-search?utm_medium=social&utm_source=portal_share).

- ✅ searchAsYouType: Whether result appears as you type or after pressing enter.
- ❌ showReset: Does not work with both algoliaSearch and instantMeiliSearche
- ❌ showSubmit: Does not work with both algoliaSearch and instantMeiliSearch
- ❌ showReset: Does not work with both algoliasearch and instant-meilisearch
- ❌ showSubmit: Does not work with both algoliasearch and instant-meilisearch
- ✅ showLoadingIndicator: Whether to show the spinning loader.

@@ -332,3 +332,3 @@ - ✅ queryHook: A function that is called just before the search is triggered.

We also suggest looking at [MeiliSearch's search parameters](https://docs.meilisearch.com/reference/features/search_parameters.html) to determine how they act.
We also suggest looking at [Meilisearch's search parameters](https://docs.meilisearch.com/reference/features/search_parameters.html) to determine how they act.

@@ -338,3 +338,3 @@ ```js

hitsPerPage: 6,
// other algoliaSearch parameters
// other algoliasearch parameters
})

@@ -347,3 +347,3 @@ ```

No compatibility with MeiliSearch because the component uses [sumOrFiltersScores](https://www.algolia.com/doc/api-reference/api-parameters/sumOrFiltersScores/) and [optionalFilters](https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/) search parameters that do not exist in MeiliSearch.
No compatibility with Meilisearch because the component uses [sumOrFiltersScores](https://www.algolia.com/doc/api-reference/api-parameters/sumOrFiltersScores/) and [optionalFilters](https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/) search parameters that do not exist in Meilisearch.

@@ -367,3 +367,3 @@ ### Panel

InstantMeiliSearch is not compatible with the autocomplete package.
InstantMeilisearch is not compatible with the autocomplete package.

@@ -402,3 +402,3 @@ ### ✅ Voice Search

It works only on widgets that are compatible with instantMeiliSearch.
It works only on widgets that are compatible with `instant-meilisearch`.

@@ -443,4 +443,4 @@ ### ✅ Hits

- ✅ cssClasses: The CSS classes to override.
- ❌ showPrevious: Does not work with both Algoliasearch and InstantMeiliSearch.
- ❌ cache: Not added in InstantMeiliSearch.
- ❌ showPrevious: Does not work with both Algoliasearch and InstantMeilisearch.
- ❌ cache: Not added in InstantMeilisearch.

@@ -484,3 +484,3 @@ ```js

Snippeting is called `cropping` in MeiliSearch, [more about it here](https://docs.meilisearch.com/reference/features/search_parameters.html#attributes-to-retrieve). It is possible to change the size of the snippeting by adding its character size in the attributesToSnippet parameter. <br>
Snippeting is called `cropping` in Meilisearch, [more about it here](https://docs.meilisearch.com/reference/features/search_parameters.html#attributes-to-retrieve). It is possible to change the size of the snippeting by adding its character size in the attributesToSnippet parameter. <br>
For example: `"description:40"`.

@@ -528,3 +528,3 @@

[See our playground for a working exemple](./playgrounds/geo-javascript/src/app.js) and this section in our [contributing guide](./CONTRIBUTING.md#-geo-search-playground) to set up your `MeiliSearch`.
[See our playground for a working exemple](./playgrounds/geo-javascript/src/app.js) and this section in our [contributing guide](./CONTRIBUTING.md#-geo-search-playground) to set up your `Meilisearch`.

@@ -599,3 +599,3 @@ #### Requirements

[Read the guide on how GeoSearch works in MeiliSearch](https://docs.meilisearch.com/reference/features/geosearch.html#geosearch).
[Read the guide on how GeoSearch works in Meilisearch](https://docs.meilisearch.com/reference/features/geosearch.html#geosearch).

@@ -606,3 +606,3 @@ ### ❌ Answers

No compatibility because MeiliSearch does not support this experimental feature.
No compatibility because Meilisearch does not support this experimental feature.

@@ -621,3 +621,3 @@ ### ✅ RefinementList

- ✅ showMoreLimit: The maximum number of displayed items. Does not work when showMoreLimit > limit.
- ❌ searchable: Whether to add a search input to let the user search for more facet values. Not supported by MeiliSearch. If you'd like to see it implemented [please vote](https://roadmap.meilisearch.com/c/64-search-for-facet-values?utm_medium=social&utm_source=portal_share).
- ❌ searchable: Whether to add a search input to let the user search for more facet values. Not supported by Meilisearch. If you'd like to see it implemented [please vote](https://roadmap.meilisearch.com/c/64-search-for-facet-values?utm_medium=social&utm_source=portal_share).
- ❌ searchablePlaceholder: The value of the search input’s placeholder. Not supported, see `searchable`.

@@ -640,12 +640,49 @@ - ❌ searchableIsAlwaysActive: When false, disables the facet search input. Not supported, see `searchable`.

### ❌ HierarchicalMenu
### ✅ HierarchicalMenu
[Hierarchical menu references](https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/)
The `hierarchicalMenu` widget is used to create a navigation based on a hierarchy of facet attributes. It is commonly used for categories with subcategories.
The `hierarchicalMenu` widget is used to create navigation based on a hierarchy of facet attributes. It is commonly used for categories with subcategories. See [usage](#hierarchical-menu-usage) below.
No compatibility because MeiliSearch does not support hierarchical facets.
- ✅ container: The CSS Selector or HTMLElement to insert the refinements. _required_
- ✅ attribute: The name of the attributes to generate the menu with. _required_.
- ✅ limit: How many facet values to retrieve.
- ✅ showMore: Whether to display a button that expands the number of items.
- ✅ showMoreLimit: The maximum number of displayed items (min `2`).
- ❌ separator: The level separator used in the records. (default `>`).
- 🤷‍♀️ rootPath: The prefix path to use if the first level is not the root level.
- ❌ showParentLevel: Whether to show the siblings of the selected parent level of the current refined value.
- ✅ sortBy: How to sort refinements. [See guide](https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/#widget-param-sortby)
- ✅ templates: The templates to use for the widget.- ✅ templates: The templates to use for the widget.
- ✅ cssClasses: The CSS classes to override.
If you'd like get nested facets/hierarchical facets implemented, please vote for it in the [roadmap](https://roadmap.meilisearch.com/c/97-nested-facets?utm_medium=social&utm_source=portal_share).
#### Hierarchical Menu Usage
To make it work with Meilisearch your documents must have a specific structure, an explanation of the structure can [be found here](https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/#requirements).
Contrary to `instantsearch.js`, the hierarchical fields are added in [`filterableAttributes`](https://docs.meilisearch.com/reference/api/filterable_attributes.html#update-filterable-attributes).
Example:
Give the following document structure:
```json
{
"id": 1,
"name": "Basic T-shirt",
"categories.lvl0": "Men",
"categories.lvl1": "Men > clothes",
"categories.lvl2": "Men > clothes > t-shirt"
}
```
You have to add the fields `categories.lvl0`, `categories.lvl1` and `categories.lvl2` in the `filterableAttributes` in your Meilisearch settings.
```json
{
"filterableAttributes": [
"categories.lvl0",
"categories.lvl1",
"categories.lvl2"
]
}
```
### ✅ RangeSlider

@@ -671,3 +708,3 @@

Min and max of attributes are not returned from MeiliSearch and thus **must be set manually**.
Min and max of attributes are not returned from Meilisearch and thus **must be set manually**.

@@ -753,3 +790,3 @@ ```js

⚠️ Not compatible with MeiliSearch by default, needs a workaround. See workaround in [RangeSlider](#rangeslider) section.
⚠️ Not compatible with Meilisearch by default, needs a workaround. See workaround in [RangeSlider](#-rangeslider) section.

@@ -798,3 +835,3 @@ ### ✅ MenuSelect

### ❌ RatingMenu
### ✅ RatingMenu

@@ -805,4 +842,10 @@ [Rating menu references](https://www.algolia.com/doc/api-reference/widgets/rating-menu/js/)

No compatibility because MeiliSearch does not support integers as facet and instantSearch uses facets information to showcase the UI elements.
- ✅ container: The CSS Selector or HTMLElement to insert the widget into. _required_
- ✅ attribute: The name of the attribute in the document. _required_.
- ✅ max: The maximum value for the rating. This value is exclusive, which means the number of stars will be the provided value, minus one.
- ✅ templates: The templates to use for the widget.
- ✅ cssClasses: The CSS classes to override.
Contrary to `instantsearch.js`, To be able to use `RatingMenu` the field containing the rating has to be added in the [`filterableAttributes`](https://docs.meilisearch.com/reference/api/filterable_attributes.html#update-filterable-attributes) setting in your index settings.
### ✅ ClearRefinements

@@ -858,11 +901,15 @@

### ❌ Breadcrumb
### ✅ Breadcrumb
[Breadcrumb references](https://www.algolia.com/doc/api-reference/widgets/breadcrumb/js/)
The `breadcrumb` widget is a secondary navigation scheme that lets the user see where the current page is in relation to the facet’s hierarchy.
The `breadcrumb` widget is a secondary navigation scheme that lets the user see where the current page is in relation to the facet’s hierarchy. The `HierarchicalMenu` widget has the same requirements, see its [usage](#hierarchical-menu-usage) to make breadcrumb work.
No compatibility because MeiliSearch does not support hierarchical facets.
- ✅ container: The CSS Selector or HTMLElement to insert the refinements. _required_
- ✅ attribute: The name of the attributes to generate the menu with. _required_.
- ❌ separator: The level separator used in the records. (default `>`).
- 🤷‍♀️ rootPath: The prefix path to use if the first level is not the root level.
- ✅ templates: The templates to use for the widget.- ✅ templates: The templates to use for the widget.
- ✅ cssClasses: The CSS classes to override.
If you'd like get nested facets implemented, please vote for it in the [roadmap](https://roadmap.meilisearch.com/c/97-nested-facets?utm_medium=social&utm_source=portal_share).

@@ -897,3 +944,3 @@ ### ✅ Stats

No compatibility because MeiliSearch does not support Rules.
No compatibility because Meilisearch does not support Rules.

@@ -906,3 +953,3 @@ ### ❌ QueryRuleContext

No compatibility because MeiliSearch does not support Rules.
No compatibility because Meilisearch does not support Rules.

@@ -994,2 +1041,2 @@ ### ✅ SortBy

**MeiliSearch** provides and maintains many **SDKs and Integration tools** like this one. We want to provide everyone with an **amazing search experience for any kind of project**. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the [integration-guides](https://github.com/meilisearch/integration-guides) repository.
**Meilisearch** provides and maintains many **SDKs and Integration tools** like this one. We want to provide everyone with an **amazing search experience for any kind of project**. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the [integration-guides](https://github.com/meilisearch/integration-guides) repository.

@@ -5,3 +5,3 @@ import type { Filter, SearchContext } from '../../types'

/**
* Transform InstantSearch filter to MeiliSearch filter.
* Transform InstantSearch filter to Meilisearch filter.
* Change sign from `:` to `=` in nested filter object.

@@ -80,3 +80,3 @@ * example: [`genres:comedy`] becomes [`genres=comedy`]

/**
* Adapt instantsearch.js filters to MeiliSearch filters by
* Adapt instantsearch.js filters to Meilisearch filters by
* combining and transforming all provided filters.

@@ -83,0 +83,0 @@ *

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

* Adapt search request from instantsearch.js
* to search request compliant with MeiliSearch
* to search request compliant with Meilisearch
*

@@ -20,3 +20,3 @@ * @param {SearchContext} searchContext

): MeiliSearchParams {
// Creates search params object compliant with MeiliSearch
// Creates search params object compliant with Meilisearch
const meiliSearchParams: Record<string, any> = {}

@@ -23,0 +23,0 @@

@@ -6,3 +6,3 @@ import { adaptHighlight } from './highlight-adapter'

/**
* Adapt MeiliSearch formating to formating compliant with instantsearch.js.
* Adapt Meilisearch formating to formating compliant with instantsearch.js.
*

@@ -9,0 +9,0 @@ * @param {Record<string} formattedHit

import { isString } from '../../../utils'
/**
* Replace `em` tags in highlighted MeiliSearch hits to
* Replace `em` tags in highlighted Meilisearch hits to
* provided tags by instantsearch.js.

@@ -16,3 +16,3 @@ *

): string {
// Highlight is applied by MeiliSearch (<em> tags)
// Highlight is applied by Meilisearch (<em> tags)
// We replace the <em> by the expected tag for InstantSearch

@@ -67,3 +67,3 @@ const stringifiedValue = isString(value) ? value : JSON.stringify(value)

): Record<string, any> {
// hit is the `_formatted` object returned by MeiliSearch.
// hit is the `_formatted` object returned by Meilisearch.
// It contains all the highlighted and croped attributes

@@ -70,0 +70,0 @@

@@ -8,3 +8,3 @@ import { isString } from '../../../utils'

function addEllipsis(value: any, formatValue: string, ellipsis: string): any {
// Manage ellpsis on cropped values until this feature is implemented https://roadmap.meilisearch.com/c/69-policy-for-cropped-values?utm_medium=social&utm_source=portal_share in MeiliSearch
// Manage ellpsis on cropped values until this feature is implemented https://roadmap.meilisearch.com/c/69-policy-for-cropped-values?utm_medium=social&utm_source=portal_share in Meilisearch

@@ -19,3 +19,3 @@ let ellipsedValue = formatValue

formatValue[0] === formatValue[0].toLowerCase() && // beginning of a sentence
formatValue.startsWith('<em>') === false // beginning of the document field, otherwise MeiliSearch would crop around the highlight
formatValue.startsWith('<em>') === false // beginning of the document field, otherwise Meilisearch would crop around the highlight
) {

@@ -57,3 +57,3 @@ ellipsedValue = `${ellipsis}${formatValue.trim()}`

): Record<string, any> {
// hit is the `_formatted` object returned by MeiliSearch.
// hit is the `_formatted` object returned by Meilisearch.
// It contains all the highlighted and croped attributes

@@ -60,0 +60,0 @@

@@ -11,3 +11,3 @@ import type {

/**
* Adapt search response from MeiliSearch
* Adapt search response from Meilisearch
* to search response compliant with instantsearch.js

@@ -14,0 +14,0 @@ *

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

// Adapt search request to MeiliSearch compliant search request
// Adapt search request to Meilisearch compliant search request
const adaptedSearchRequest = adaptSearchParams(searchContext)

@@ -77,3 +77,3 @@

// Adapt the MeiliSearch responsne to a compliant instantsearch.js response
// Adapt the Meilisearch responsne to a compliant instantsearch.js response
const adaptedSearchResponse = adaptSearchResponse<T>(

@@ -93,3 +93,3 @@ searchResponse,

reject(
new Error('SearchForFacetValues is not compatible with MeiliSearch')
new Error('SearchForFacetValues is not compatible with Meilisearch')
)

@@ -136,5 +136,5 @@ resolve([]) // added here to avoid compilation error

hitsPerPage:
searchContext.hitsPerPage === undefined ? 20 : searchContext.hitsPerPage, // 20 is the MeiliSearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
searchContext.hitsPerPage === undefined ? 20 : searchContext.hitsPerPage, // 20 is the Meilisearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
page: params?.page || 0, // default page is 0 if none is provided
}
}

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

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