LocalCDN-Firefox-Chrome-Brave/resources/algoliasearch/4.8.2/algoliasearch.min.jsm

2 lines
29 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).algoliasearch=t()}(this,function(){"use strict";function t(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function g(n){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?t(Object(a),!0).forEach(function(e){var t,r;t=n,e=a[r=e],r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(a)):t(Object(a)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(a,e))})}return n}function d(e,t){if(null==e)return{};var r,n=function(e,t){if(null==e)return{};for(var r,n={},a=Object.keys(e),o=0;o<a.length;o++)r=a[o],0<=t.indexOf(r)||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols)for(var a=Object.getOwnPropertySymbols(e),o=0;o<a.length;o++)r=a[o],0<=t.indexOf(r)||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,a=!1,o=void 0;try{for(var u,s=e[Symbol.iterator]();!(n=(u=s.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(a)throw o}}return r}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function v(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function p(e){var o=0<arguments.length&&void 0!==e?e:{serializable:!0},u={};return{get:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},e=JSON.stringify(e);if(e in u)return Promise.resolve(o.serializable?JSON.parse(u[e]):u[e]);var n=t(),a=r&&r.miss||function(){return Promise.resolve()};return n.then(function(e){return a(e)}).then(function(){return n})},set:function(e,t){return u[JSON.stringify(e)]=o.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete:function(e){return delete u[JSON.stringify(e)],Promise.resolve()},clear:function(){return u={},Promise.resolve()}}}function h(e,t,r){var n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers:function(){return e===P.WithinHeaders?n:{}},queryParameters:function(){return e===P.WithinQueryParameters?n:{}}}}function s(r){var n=0;return r(function t(){return n++,new Promise(function(e){setTimeout(function(){e(r(t))},Math.min(100*n,1e3))})})}function m(e,t){var r=1<arguments.length&&void 0!==t?t:function(e,t){return Promise.resolve()};return Object.assign(e,{wait:function(t){return m(e.then(function(e){return Promise.all([r(e,t),e])}).then(function(e){return e[1]}))}})}function y(t,r){return r&&Object.keys(r).forEach(function(e){t[e]=r[e](t)}),t}function b(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var a=0;return e.replace(/%s/g,function(){return encodeURIComponent(r[a++])})}var P={WithinQueryParameters:0,WithinHeaders:1};function O(e,t){var r=e||{},n=r.data||{};return Object.keys(r).forEach(function(e){-1===["timeout","headers","queryParameters","data","cacheable"].indexOf(e)&&(n[e]=r[e])}),{data:0<Object.entries(n).length?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}var w={Read:1,Write:2,Any:3},a=1,j=2,I=3;function x(e,t){t=1<arguments.length&&void 0!==t?t:a;return g(g({},e),{},{status:t,lastUpdate:Date.now()})}function q(e){return"string"==typeof e?{protocol:"https",url:e,accept:w.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||w.Any}}var o="DELETE",u="GET",D="POST";function S(t,n){return Promise.all(n.map(function(e){return t.get(e,function(){return Promise.resolve(x(e))})})).then(function(e){var t=e.filter(function(e){return(e=e).status===a||12e4<Date.now()-e.lastUpdate}),r=e.filter(function(e){return(e=e).status===I&&Date.now()-e.lastUpdate<=12e4}),t=[].concat(v(t),v(r));return{getTimeout:function(e,t){return(0===r.length&&0===e?1:r.length+3+e)*t},statelessHosts:0<t.length?t.map(q):n}})}function T(s,e,i,c){function f(r,n){var a=r.pop();if(void 0===a)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",transporterStackTrace:R(d)};function o(e){return e={request:t,response:e,host:a,triesLeft:r.length},d.push(e),e}var t={data:l,headers:p,method:h,url:function(e,t,r){r=N(r),t="".concat(e.protocol,"://").concat(e.url,"/").concat("/"===t.charAt(0)?t.substr(1):t);return r.length&&(t+="?".concat(r)),t}(a,i.path,m),connectTimeout:n(y,s.timeouts.connect),responseTimeout:n(y,c.timeout)},u={onSucess:function(t){try{return JSON.parse(t.content)}catch(e){throw{name:"DeserializationError",message:e.message,response:t}}},onRetry:function(e){var t=o(e);return e.isTimedOut&&y++,Promise.all([s.logger.info("Retryable failure",A(t)),s.hostsCache.set(a,x(a,e.isTimedOut?I:j))]).then(function(){return f(r,n)})},onFail:function(e){throw o(e),function(e,t){var r=e.content,n=e.status,a=r;try{a=JSON.parse(r).message}catch(e){}return{name:"ApiError",message:a,status:n,transporterStackTrace:t}}(e,R(d))}};return s.requester.send(t).then(function(e){return r=u,a=(n=t=e).status,n.isTimedOut||(e=n.isTimedOut,n=n.status,!e&&0==~~n)||2!=~~(a/100)&&4!=~~(a/100)?r.onRetry(t):2==~~(t.status/100)?r.onSucess(t):r.onFail(t);var t,r,n,a})}var t,r,n,d=[],l=function(e,t){if(e.method!==u&&(void 0!==e.data||void 0!==t.data)){t=Array.isArray(e.data)?e.data:g(g({},e.data),t.data);return JSON.stringify(t)}}(i,c),p=(t=c,r=g(g({},s.headers),t.headers),n={},Object.keys(r).forEach(function(e){var t=r[e];n[e.toLowerCase()]=t}),n),h=i.method,t=i.method!==u?{}:g(g({},i.data),c.data),m=g(g(g({"x-algolia-agent":s.userAgent.value},s.queryParameters),t),c.queryParameters),y=0;return S(s.hostsCache,e).then(function(e){return f(v(e.statelessHosts).reverse(),e.getTimeout)})}function k(e){var t=e.hostsCache,r=e.logger,n=e.requester,a=e.requestsCache,o=e.responsesCache,u=e.timeouts,s=e.userAgent,i=e.hosts,c=e.queryParameters,f={hostsCache:t,logger:r,requester:n,requestsCache:a,responsesCache:o,timeouts:u,userAgent:s,headers:e.headers,queryParameters:c,hosts:i.map(q),read:function(e,t){function r(){return T(f,f.hosts.filter(function(e){return 0!=(e.accept&w.Read)}),e,n)}var n=O(t,f.timeouts.read);if(!0!==(void 0!==n.cacheable?n:e).cacheable)return r();var a={request:e,mappedRequestOptions:n,transporter:{queryParameters:f.queryParameters,headers:f.headers}};return f.responsesCache.get(a,function(){return f.requestsCache.get(a,function(){return f.requestsCache.set(a,r()).then(function(e){return Promise.all([f.requestsCache.delete(a),e])},function(e){return Promise.all([f.requestsCache.delete(a),Promise.reject(e)])}).then(function(e){e=l(e,2);return e[0],e[1]})})},{miss:function(e){return f.responsesCache.set(a,e)}})},write:function(e,t){return T(f,f.hosts.filter(function(e){return 0!=(e.accept&w.Write)}),e,O(t,f.timeouts.write))}};return f}function N(r){return Object.keys(r).map(function(e){return b("%s=%s",e,(t=r[e],"[object Object]"===Object.prototype.toString.call(t)||"[object Array]"===Object.prototype.toString.call(t)?JSON.stringify(r[e]):r[e]));var t}).join("&")}function R(e){return e.map(A)}function A(e){var t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return g(g({},e),{},{request:g(g({},e.request),{},{headers:g(g({},e.request.headers),t)})})}function E(r){return function(e,t){return r.transporter.write({method:D,path:"2/abtests",data:e},t)}}function C(r){return function(e,t){return r.transporter.write({method:o,path:b("2/abtests/%s",e)},t)}}function U(r){return function(e,t){return r.transporter.read({method:u,path:b("2/abtests/%s",e)},t)}}function J(t){return function(e){return t.transporter.read({method:u,path:"2/abtests"},e)}}function z(r){return function(e,t){return r.transporter.write({method:D,path:b("2/abtests/%s/stop",e)},t)}}function F(t){return function(e){return t.transporter.read({method:u,path:"1/strategies/personalization"},e)}}function H(r){return function(e,t){return r.transporter.write({method:D,path:"1/strategies/personalization",data:e},t)}}function n(n){return function t(r){return n.request(r).then(function(e){if(void 0!==n.batch&&n.batch(e.hits),!n.shouldStop(e))return e.cursor?t({cursor:e.cursor}):t({page:(r.page||0)+1})})}({})}function M(n){return function(e,t){var r=t||{},t=r.queryParameters,r=d(r,["queryParameters"]),t=g({acl:e},void 0!==t?{queryParameters:t}:{});return m(n.transporter.write({method:D,path:"1/keys",data:t},r),function(e,r){return s(function(t){return He(n)(e.key,r).catch(function(e){if(404!==e.status)throw e;return t()})})})}}function K(n){return function(e,t,r){r=O(r);return r.queryParameters["X-Algolia-User-ID"]=e,n.transporter.write({method:D,path:"1/clusters/mapping",data:{cluster:t}},r)}}function W(n){return function(e,t,r){return n.transporter.write({method:D,path:"1/clusters/mapping/batch",data:{users:e,cluster:t}},r)}}function B(n){return function(r,e,t){return m(n.transporter.write({method:D,path:b("1/indexes/%s/operation",r),data:{operation:"copy",destination:e}},t),function(e,t){return Me(n)(r,{methods:{waitTask:Ze}}).waitTask(e.taskID,t)})}}function Q(n){return function(e,t,r){return B(n)(e,t,g(g({},r),{},{scope:[i.Rules]}))}}function G(n){return function(e,t,r){return B(n)(e,t,g(g({},r),{},{scope:[i.Settings]}))}}function L(n){return function(e,t,r){return B(n)(e,t,g(g({},r),{},{scope:[i.Synonyms]}))}}function V(n){return function(r,e){return m(n.transporter.write({method:o,path:b("1/keys/%s",r)},e),function(e,t){return s(function(e){return He(n)(r,t).then(e).catch(function(e){if(404!==e.status)throw e})})})}}function _(t){return function(e){return t.transporter.read({method:u,path:"1/logs"},e)}}function X(t){return function(e){return t.transporter.read({method:u,path:"1/clusters/mapping/top"},e)}}function Y(r){return function(e,t){return r.transporter.read({method:u,path:b("1/clusters/mapping/%s",e)},t)}}function Z(r){return function(e){var t=e||{},e=t.retrieveMappings,t=d(t,["retrieveMappings"]);return!0===e&&(t.getClusters=!0),r.transporter.read({method:u,path:"1/clusters/mapping/pending"},t)}}function $(t){return function(e){return t.transporter.read({method:u,path:"1/keys"},e)}}function ee(t){return function(e){return t.transporter.read({method:u,path:"1/clusters"},e)}}function te(t){return function(e){return t.transporter.read({method:u,path:"1/indexes"},e)}}function re(t){return function(e){return t.transporter.read({method:u,path:"1/clusters/mapping"},e)}}function ne(n){return function(r,e,t){return m(n.transporter.write({method:D,path:b("1/indexes/%s/operation",r),data:{operation:"move",destination:e}},t),function(e,t){return Me(n)(r,{methods:{waitTask:Ze}}).waitTask(e.taskID,t)})}}function ae(n){return function(e,t){return m(n.transporter.write({method:D,path:"1/indexes/*/batch",data:{requests:e}},t),function(t,r){return Promise.all(Object.keys(t.taskID).map(function(e){return Me(n)(e,{methods:{waitTask:Ze}}).waitTask(t.taskID[e],r)}))})}}function oe(r){return function(e,t){return r.transporter.read({method:D,path:"1/indexes/*/objects",data:{requests:e}},t)}}function ue(r){return function(e,t){e=e.map(function(e){return g(g({},e),{},{params:N(e.params||{})})});return r.transporter.read({method:D,path:"1/indexes/*/queries",data:{requests:e},cacheable:!0},t)}}function se(o){return function(e,a){return Promise.all(e.map(function(e){var t=e.params,r=t.facetName,n=t.facetQuery,t=d(t,["facetName","facetQuery"]);return Me(o)(e.indexName,{methods:{searchForFacetValues:_e}}).searchForFacetValues(r,n,g(g({},a),t))}))}}function ie(r){return function(e,t){t=O(t);return t.queryParameters["X-Algolia-User-ID"]=e,r.transporter.write({method:o,path:"1/clusters/mapping"},t)}}function ce(a){return function(n,e){return m(a.transporter.write({method:D,path:b("1/keys/%s/restore",n)},e),function(e,r){return s(function(t){return He(a)(n,r).catch(function(e){if(404!==e.status)throw e;return t()})})})}}function fe(r){return function(e,t){return r.transporter.read({method:D,path:"1/clusters/mapping/search",data:{query:e}},t)}}function de(u){return function(n,e){var a=Object.assign({},e),t=e||{},e=t.queryParameters,t=d(t,["queryParameters"]),e=e?{queryParameters:e}:{},o=["acl","indexes","referers","restrictSources","queryParameters","description","maxQueriesPerIPPerHour","maxHitsPerQuery"];return m(u.transporter.write({method:"PUT",path:b("1/keys/%s",n),data:e},t),function(e,t){return s(function(r){return He(u)(n,t).then(function(e){return t=e,Object.keys(a).filter(function(e){return-1!==o.indexOf(e)}).every(function(e){return t[e]===a[e]})?Promise.resolve():r();var t})})})}}function le(r){return function(e,t){return m(r.transporter.write({method:D,path:b("1/indexes/%s/batch",r.indexName),data:{requests:e}},t),function(e,t){return Ze(r)(e.taskID,t)})}}function pe(r){return function(t){return n(g(g({shouldStop:function(e){return void 0===e.cursor}},t),{},{request:function(e){return r.transporter.read({method:D,path:b("1/indexes/%s/browse",r.indexName),data:e},t)}}))}}function he(r){return function(e){var t=g({hitsPerPage:1e3},e);return n(g(g({shouldStop:function(e){return e.hits.length<t.hitsPerPage}},t),{},{request:function(e){return Xe(r)("",g(g({},t),e)).then(function(e){return g(g({},e),{},{hits:e.hits.map(function(e){return delete e._highlightResult,e})})})}}))}}function me(r){return function(e){var t=g({hitsPerPage:1e3},e);return n(g(g({shouldStop:function(e){return e.hits.length<t.hitsPerPage}},t),{},{request:function(e){return Ye(r)("",g(g({},t),e)).then(function(e){return g(g({},e),{},{hits:e.hits.map(function(e){return delete e._highlightResult,e})})})}}))}}function c(c){return function(a,o,e){var e=e||{},u=e.batchSize,s=d(e,["batchSize"]),i={taskIDs:[],objectIDs:[]};return m(function t(e){for(var r=[],n=0<arguments.length&&void 0!==e?e:0;n<a.length&&(r.push(a[n]),r.length!==(u||1e3));n++);return 0===r.length?Promise.resolve(i):le(c)(r.map(function(e){return{action:o,body:e}}),s).then(function(e){return i.objectIDs=i.objectIDs.concat(e.objectIDs),i.taskIDs.push(e.taskID),t(++n)})}(),function(e,t){return Promise.all(e.taskIDs.map(function(e){return Ze(c)(e,t)}))})}}function ye(r){return function(e){return m(r.transporter.write({method:D,path:b("1/indexes/%s/clear",r.indexName)},e),function(e,t){return Ze(r)(e.taskID,t)})}}function ge(r){return function(e){var t=e||{},e=t.forwardToReplicas,t=O(d(t,["forwardToReplicas"]));return e&&(t.queryParameters.forwardToReplicas=1),m(r.transporter.write({method:D,path:b("1/indexes/%s/rules/clear",r.indexName)},t),function(e,t){return Ze(r)(e.taskID,t)})}}function ve(r){return function(e){var t=e||{},e=t.forwardToReplicas,t=O(d(t,["forwardToReplicas"]));return e&&(t.queryParameters.forwardToReplicas=1),m(r.transporter.write({method:D,path:b("1/indexes/%s/synonyms/clear",r.indexName)},t),function(e,t){return Ze(r)(e.taskID,t)})}}function be(r){return function(e,t){return m(r.transporter.write({method:D,path:b("1/indexes/%s/deleteByQuery",r.indexName),data:e},t),function(e,t){return Ze(r)(e.taskID,t)})}}function Pe(r){return function(e){return m(r.transporter.write({method:o,path:b("1/indexes/%s",r.indexName)},e),function(e,t){return Ze(r)(e.taskID,t)})}}function Oe(r){return function(e,t){return m(Ke(r)([e],t).then(function(e){return{taskID:e.taskIDs[0]}}),function(e,t){return Ze(r)(e.taskID,t)})}}function we(n){return function(e,t){var r=t||{},t=r.forwardToReplicas,r=O(d(r,["forwardToReplicas"]));return t&&(r.queryParameters.forwardToReplicas=1),m(n.transporter.write({method:o,path:b("1/indexes/%s/rules/%s",n.indexName,e)},r),function(e,t){return Ze(n)(e.taskID,t)})}}function je(n){return function(e,t){var r=t||{},t=r.forwardToReplicas,r=O(d(r,["forwardToReplicas"]));return t&&(r.queryParameters.forwardToReplicas=1),m(n.transporter.write({method:o,path:b("1/indexes/%s/synonyms/%s",n.indexName,e)},r),function(e,t){return Ze(n)(e.taskID,t)})}}function Ie(t){return function(e){return We(t)(e).then(function(){return!0}).catch(function(e){if(404!==e.status)throw e;return!1})}}function xe(n){return function(e,t,r){return n.transporter.read({method:D,path:b("1/answers/%s/prediction",n.indexName),data:{query:e,queryLanguages:t},cacheable:!0},r)}}function qe(n){return function(u,e){var e=e||{},t=e.query,s=e.paginate,r=d(e,["query","paginate"]),i=0;return function o(){return Ve(n)(t||"",g(g({},r),{},{page:i})).then(function(e){for(var t=0,r=Object.entries(e.hits);t<r.length;t++){var n=l(r[t],2),a=n[0],n=n[1];if(u(n))return{object:n,position:parseInt(a,10),page:i}}if(i++,!1===s||i>=e.nbPages)throw{name:"ObjectNotFoundError",message:"Object not found."};return o()})}()}}function De(r){return function(e,t){return r.transporter.read({method:u,path:b("1/indexes/%s/%s",r.indexName,e)},t)}}function Se(){return function(e,t){for(var r=0,n=Object.entries(e.hits);r<n.length;r++){var a=l(n[r],2),o=a[0];if(a[1].objectID===t)return parseInt(o,10)}return-1}}function Te(n){return function(e,t){var t=t||{},r=t.attributesToRetrieve,t=d(t,["attributesToRetrieve"]),e=e.map(function(e){return g({indexName:n.indexName,objectID:e},r?{attributesToRetrieve:r}:{})});return n.transporter.read({method:D,path:"1/indexes/*/objects",data:{requests:e}},t)}}function ke(r){return function(e,t){return r.transporter.read({method:u,path:b("1/indexes/%s/rules/%s",r.indexName,e)},t)}}function Ne(r){return function(e,t){return r.transporter.read({method:u,path:b("1/indexes/%s/synonyms/%s",r.indexName,e)},t)}}function Re(r){return function(e,t){return m(Be(r)([e],t).then(function(e){return{objectID:e.objectIDs[0],taskID:e.taskIDs[0]}}),function(e,t){return Ze(r)(e.taskID,t)})}}function Ae(f){return function(t,e){function r(e,t,r,n){return m(f.transporter.write({method:D,path:b("1/indexes/%s/operation",e),data:{operation:r,destination:t}},n),function(e,t){return Ze(f)(e.taskID,t)})}var e=e||{},n=e.safe,a=e.autoGenerateObjectIDIfNotExist,o=e.batchSize,u=d(e,["safe","autoGenerateObjectIDIfNotExist","batchSize"]),e=Math.random().toString(36).substring(7),s="".concat(f.indexName,"_tmp_").concat(e),i=Qe({appId:f.appId,transporter:f.transporter,indexName:s}),c=[],e=r(f.indexName,s,"copy",g(g({},u),{},{scope:["settings","synonyms","rules"]}));return c.push(e),m((n?e.wait(u):e).then(function(){var e=i(t,g(g({},u),{},{autoGenerateObjectIDIfNotExist:a,batchSize:o}));return c.push(e),n?e.wait(u):e}).then(function(){var e=r(s,f.indexName,"move",u);return c.push(e),n?e.wait(u):e}).then(function(){return Promise.all(c)}).then(function(e){var t=l(e,3),r=t[0],e=t[1],t=t[2];return{objectIDs:e.objectIDs,taskIDs:[r.taskID].concat(v(e.taskIDs),[t.taskID])}}),function(e,t){return Promise.all(c.map(function(e){return e.wait(t)}))})}}function Ee(r){return function(e,t){return Ge(r)(e,g(g({},t),{},{clearExistingRules:!0}))}}function Ce(r){return function(e,t){return Le(r)(e,g(g({},t),{},{clearExistingSynonyms:!0}))}}function Ue(r){return function(e,t){return m(Qe(r)([e],t).then(function(e){return{objectID:e.objectIDs[0],taskID:e.taskIDs[0]}}),function(e,t){return Ze(r)(e.taskID,t)})}}function Je(r){return function(e,t){return Ge(r)([e],t)}}function ze(r){return function(e,t){return Le(r)([e],t)}}function Fe(n){return function(e,t){var r=t||{},t=r.forwardToReplicas,r=O(d(r,["forwardToReplicas"]));return t&&(r.queryParameters.forwardToReplicas=1),m(n.transporter.write({method:"PUT",path:b("1/indexes/%s/settings",n.indexName),data:e},r),function(e,t){return Ze(n)(e.taskID,t)})}}var He=function(r){return function(e,t){return r.transporter.read({method:u,path:b("1/keys/%s",e)},t)}},Me=function(r){return function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return y({transporter:r.transporter,appId:r.appId,indexName:e},t.methods)}},Ke=function(r){return function(e,t){e=e.map(function(e){return{objectID:e}});return c(r)(e,f.DeleteObject,t)}},We=function(t){return function(e){return t.transporter.read({method:u,path:b("1/indexes/%s/settings",t.indexName),data:{getVersion:2}},e)}},Be=function(n){return function(e,t){var r=t||{},t=r.createIfNotExists,r=d(r,["createIfNotExists"]),t=t?f.PartialUpdateObject:f.PartialUpdateObjectNoCreate;return c(n)(e,t,r)}},Qe=function(i){return function(e,t){var r=t||{},t=r.autoGenerateObjectIDIfNotExist,r=d(r,["autoGenerateObjectIDIfNotExist"]),t=t?f.AddObject:f.UpdateObject;if(t===f.UpdateObject){var n=!0,a=!1,o=void 0;try{for(var u,s=e[Symbol.iterator]();!(n=(u=s.next()).done);n=!0)if(void 0===u.value.objectID)return m(Promise.reject({name:"MissingObjectIDError",message:"All objects must have an unique objectID (like a primary key) to be valid. Algolia is also able to generate objectIDs automatically but *it's not recommended*. To do it, use the `{'autoGenerateObjectIDIfNotExist': true}` option."}))}catch(e){a=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(a)throw o}}}return c(i)(e,t,r)}},Ge=function(a){return function(e,t){var r=t||{},n=r.forwardToReplicas,t=r.clearExistingRules,r=O(d(r,["forwardToReplicas","clearExistingRules"]));return n&&(r.queryParameters.forwardToReplicas=1),t&&(r.queryParameters.clearExistingRules=1),m(a.transporter.write({method:D,path:b("1/indexes/%s/rules/batch",a.indexName),data:e},r),function(e,t){return Ze(a)(e.taskID,t)})}},Le=function(o){return function(e,t){var r=t||{},n=r.forwardToReplicas,a=r.clearExistingSynonyms,t=r.replaceExistingSynonyms,r=O(d(r,["forwardToReplicas","clearExistingSynonyms","replaceExistingSynonyms"]));return n&&(r.queryParameters.forwardToReplicas=1),(t||a)&&(r.queryParameters.replaceExistingSynonyms=1),m(o.transporter.write({method:D,path:b("1/indexes/%s/synonyms/batch",o.indexName),data:e},r),function(e,t){return Ze(o)(e.taskID,t)})}},Ve=function(r){return function(e,t){return r.transporter.read({method:D,path:b("1/indexes/%s/query",r.indexName),data:{query:e},cacheable:!0},t)}},_e=function(n){return function(e,t,r){return n.transporter.read({method:D,path:b("1/indexes/%s/facets/%s/query",n.indexName,e),data:{facetQuery:t},cacheable:!0},r)}},Xe=function(r){return function(e,t){return r.transporter.read({method:D,path:b("1/indexes/%s/rules/search",r.indexName),data:{query:e}},t)}},Ye=function(r){return function(e,t){return r.transporter.read({method:D,path:b("1/indexes/%s/synonyms/search",r.indexName),data:{query:e}},t)}},Ze=function(a){return function(e,n){return s(function(t){return r=a,function(e,t){return r.transporter.read({method:u,path:b("1/indexes/%s/task/%s",r.indexName,e.toString())},t)}(e,n).then(function(e){return"published"!==e.status?t():void 0});var r})}},f={AddObject:"addObject",UpdateObject:"updateObject",PartialUpdateObject:"partialUpdateObject",PartialUpdateObjectNoCreate:"partialUpdateObjectNoCreate",DeleteObject:"deleteObject",DeleteIndex:"delete",ClearIndex:"clear"},i={Settings:"settings",Synonyms:"synonyms",Rules:"rules"};function e(e,t,r){var n,a,o,u,s,i={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:{send:function(o){return new Promise(function(r){var n=new XMLHttpRequest;n.open(o.method,o.url,!0),Object.keys(o.headers).forEach(function(e){return n.setRequestHeader(e,o.headers[e])});function e(e,t){return setTimeout(function(){n.abort(),r({status:0,content:t,isTimedOut:!0})},1e3*e)}var t,a=e(o.connectTimeout,"Connection timeout");n.onreadystatechange=function(){n.readyState>n.OPENED&&void 0===t&&(clearTimeout(a),t=e(o.responseTimeout,"Socket timeout"))},n.onerror=function(){0===n.status&&(clearTimeout(a),clearTimeout(t),r({content:n.responseText||"Network request failed",status:n.status,isTimedOut:!1}))},n.onload=function(){clearTimeout(a),clearTimeout(t),r({content:n.responseText,status:n.status,isTimedOut:!1})},n.send(o.data)})}},logger:{debug:function(e,t){return Promise.resolve()},info:function(e,t){return Promise.resolve()},error:function(e,t){return console.error(e,t),Promise.resolve()}},responsesCache:p(),requestsCache:p({serializable:!3}),hostsCache:function n(e){var a=v(e.caches),o=a.shift();return void 0===o?{get:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return t().then(function(e){return Promise.all([e,r.miss(e)])}).then(function(e){return l(e,1)[0]})},set:function(e,t){return Promise.resolve(t)},delete:function(e){return Promise.resolve()},clear:function(){return Promise.resolve()}}:{get:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return o.get(e,t,r).catch(function(){return n({caches:a}).get(e,t,r)})},set:function(e,t){return o.set(e,t).catch(function(){return n({caches:a}).set(e,t)})},delete:function(e){return o.delete(e).catch(function(){return n({caches:a}).delete(e)})},clear:function(){return o.clear().catch(function(){return n({caches:a}).clear()})}}}({caches:[(a={key:"".concat("4.8.2","-").concat(e)},u="algoliasearch-client-js-".concat(a.key),{get:function(t,r){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return Promise.resolve().then(function(){var e=JSON.stringify(t),e=f()[e];return Promise.all([e||r(),void 0!==e])}).then(function(e){var t=l(e,2),e=t[0],t=t[1];return Promise.all([e,t||n.miss(e)])}).then(function(e){return l(e,1)[0]})},set:function(t,r){return Promise.resolve().then(function(){var e=f();return e[JSON.stringify(t)]=r,c().setItem(u,JSON.stringify(e)),r})},delete:function(t){return Promise.resolve().then(function(){var e=f();delete e[JSON.stringify(t)],c().setItem(u,JSON.stringify(e))})},clear:function(){return Promise.resolve().then(function(){c().removeItem(u)})}}),p()]}),userAgent:(n={value:"Algolia for JavaScript (".concat("4.8.2",")"),add:function(e){e="; ".concat(e.segment).concat(void 0!==e.version?" (".concat(e.version,")"):"");return-1===n.value.indexOf(e)&&(n.value="".concat(n.value).concat(e)),n}}).add({segment:"Browser"})};function c(){return void 0===o&&(o=a.localStorage||window.localStorage),o}function f(){return JSON.parse(c().getItem(u)||"{}")}return t=g(g(g({},i),r),{},{methods:{search:ue,searchForFacetValues:se,multipleBatch:ae,multipleGetObjects:oe,multipleQueries:ue,copyIndex:B,copySettings:G,copySynonyms:L,copyRules:Q,moveIndex:ne,listIndices:te,getLogs:_,listClusters:ee,multipleSearchForFacetValues:se,getApiKey:He,addApiKey:M,listApiKeys:$,updateApiKey:de,deleteApiKey:V,restoreApiKey:ce,assignUserID:K,assignUserIDs:W,getUserID:Y,searchUserIDs:fe,listUserIDs:re,getTopUserIDs:X,removeUserID:ie,hasPendingMappings:Z,initIndex:function(t){return function(e){return Me(t)(e,{methods:{batch:le,delete:Pe,findAnswers:xe,getObject:De,getObjects:Te,saveObject:Ue,saveObjects:Qe,search:Ve,searchForFacetValues:_e,waitTask:Ze,setSettings:Fe,getSettings:We,partialUpdateObject:Re,partialUpdateObjects:Be,deleteObject:Oe,deleteObjects:Ke,deleteBy:be,clearObjects:ye,browseObjects:pe,getObjectPosition:Se,findObject:qe,exists:Ie,saveSynonym:ze,saveSynonyms:Le,getSynonym:Ne,searchSynonyms:Ye,browseSynonyms:me,deleteSynonym:je,clearSynonyms:ve,replaceAllObjects:Ae,replaceAllSynonyms:Ce,searchRules:Xe,getRule:ke,deleteRule:we,saveRule:Je,saveRules:Ge,replaceAllRules:Ee,browseRules:he,clearRules:ge}})}},initAnalytics:function(){return function(e){return t=g(g(g({},i),e),{},{methods:{addABTest:E,getABTest:U,getABTests:J,stopABTest:z,deleteABTest:C}}),r=t.region||"us",e=h(P.WithinHeaders,t.appId,t.apiKey),e=k(g(g({hosts:[{url:"analytics.".concat(r,".algolia.com")}]},t),{},{headers:g(g(g({},e.headers()),{"content-type":"application/json"}),t.headers),queryParameters:g(g({},e.queryParameters()),t.queryParameters)})),y({appId:t.appId,transporter:e},t.methods);var t,r}},initRecommendation:function(){return function(e){return t=g(g(g({},i),e),{},{methods:{getPersonalizationStrategy:F,setPersonalizationStrategy:H}}),r=t.region||"us",e=h(P.WithinHeaders,t.appId,t.apiKey),e=k(g(g({hosts:[{url:"recommendation.".concat(r,".algolia.com")}]},t),{},{headers:g(g(g({},e.headers()),{"content-type":"application/json"}),t.headers),queryParameters:g(g({},e.queryParameters()),t.queryParameters)})),y({appId:t.appId,transporter:e},t.methods);var t,r}}}}),e=t.appId,r=h(void 0!==t.authMode?t.authMode:P.WithinHeaders,e,t.apiKey),y({transporter:s=k(g(g({hosts:[{url:"".concat(e,"-dsn.algolia.net"),accept:w.Read},{url:"".concat(e,".algolia.net"),accept:w.Write}].concat(function(e){for(var t=e.length-1;0<t;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}([{url:"".concat(e,"-1.algolianet.com")},{url:"".concat(e,"-2.algolianet.com")},{url:"".concat(e,"-3.algolianet.com")}]))},t),{},{headers:g(g(g({},r.headers()),{"content-type":"application/x-www-form-urlencoded"}),t.headers),queryParameters:g(g({},r.queryParameters()),t.queryParameters)})),appId:e,addAlgoliaAgent:function(e,t){s.userAgent.add({segment:e,version:t})},clearCache:function(){return Promise.all([s.requestsCache.clear(),s.responsesCache.clear()]).then(function(){})}},t.methods)}return e.version="4.8.2",e});