itemsjs
Version:
Created to perform fast search on small json dataset (up to 1000 elements).
1 lines • 61 kB
JavaScript
function t(){return t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},t.apply(this,arguments)}var e="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self,n=e||r||Function("return this")(),o=n.Symbol,i=Object.prototype,s=i.hasOwnProperty,a=i.toString,u=o?o.toStringTag:void 0,c=Object.prototype.toString,f="[object Null]",l="[object Undefined]",h=o?o.toStringTag:void 0;function d(t){return null==t?void 0===t?l:f:h&&h in Object(t)?function(t){var e=s.call(t,u),r=t[u];try{t[u]=void 0;var n=!0}catch(t){}var o=a.call(t);return n&&(e?t[u]=r:delete t[u]),o}(t):function(t){return c.call(t)}(t)}function p(t){return null!=t&&"object"==typeof t}var g="[object Symbol]";function w(t){return"symbol"==typeof t||p(t)&&d(t)==g}function v(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var y=Array.isArray,_=1/0,b=o?o.prototype:void 0,m=b?b.toString:void 0;function j(t){if("string"==typeof t)return t;if(y(t))return v(t,j)+"";if(w(t))return m?m.call(t):"";var e=t+"";return"0"==e&&1/t==-_?"-0":e}function S(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function O(t){return t}var x="[object AsyncFunction]",A="[object Function]",k="[object GeneratorFunction]",E="[object Proxy]";function z(t){if(!S(t))return!1;var e=d(t);return e==A||e==k||e==x||e==E}var F,P=n["__core-js_shared__"],T=(F=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+F:"",N=Function.prototype.toString;function M(t){if(null!=t){try{return N.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var I=/^\[object .+?Constructor\]$/,D=RegExp("^"+Function.prototype.toString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!S(t)||(e=t,T&&T in e))&&(z(t)?D:I).test(M(t));var e}(r)?r:void 0}var W,R,C,V=$(n,"WeakMap"),U=Object.create,q=function(){function t(){}return function(e){if(!S(e))return{};if(U)return U(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),B=Date.now,J=function(){try{var t=$(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),L=J,H=L?function(t,e){return L(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:O,G=(W=H,R=0,C=0,function(){var t=B(),e=16-(t-C);if(C=t,e>0){if(++R>=800)return arguments[0]}else R=0;return W.apply(void 0,arguments)});function Z(t){return t!=t}function Y(t,e){return!(null==t||!t.length)&&function(t,e,r){return e==e?function(t,e,r){for(var n=-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}(t,e):function(t,e,r,n){for(var o=t.length,i=-1;++i<o;)if(e(t[i],i,t))return i;return-1}(t,Z)}(t,e)>-1}var K=9007199254740991,Q=/^(?:0|[1-9]\d*)$/;function X(t,e){var r=typeof t;return!!(e=null==e?K:e)&&("number"==r||"symbol"!=r&&Q.test(t))&&t>-1&&t%1==0&&t<e}function tt(t,e,r){"__proto__"==e&&L?L(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function et(t,e){return t===e||t!=t&&e!=e}var rt=Object.prototype.hasOwnProperty;function nt(t,e,r){var n=t[e];rt.call(t,e)&&et(n,r)&&(void 0!==r||e in t)||tt(t,e,r)}function ot(t,e,r,n){var o=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],u=n?n(r[a],t[a],a,r,t):void 0;void 0===u&&(u=t[a]),o?tt(r,a,u):nt(r,a,u)}return r}var it=Math.max,st=9007199254740991;function at(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=st}function ut(t){return null!=t&&at(t.length)&&!z(t)}var ct=Object.prototype;function ft(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ct)}function lt(t){return p(t)&&"[object Arguments]"==d(t)}var ht=Object.prototype,dt=ht.hasOwnProperty,pt=ht.propertyIsEnumerable,gt=lt(function(){return arguments}())?lt:function(t){return p(t)&&dt.call(t,"callee")&&!pt.call(t,"callee")},wt="object"==typeof exports&&exports&&!exports.nodeType&&exports,vt=wt&&"object"==typeof module&&module&&!module.nodeType&&module,yt=vt&&vt.exports===wt?n.Buffer:void 0,_t=(yt?yt.isBuffer:void 0)||function(){return!1},bt={};function mt(t){return function(e){return t(e)}}bt["[object Float32Array]"]=bt["[object Float64Array]"]=bt["[object Int8Array]"]=bt["[object Int16Array]"]=bt["[object Int32Array]"]=bt["[object Uint8Array]"]=bt["[object Uint8ClampedArray]"]=bt["[object Uint16Array]"]=bt["[object Uint32Array]"]=!0,bt["[object Arguments]"]=bt["[object Array]"]=bt["[object ArrayBuffer]"]=bt["[object Boolean]"]=bt["[object DataView]"]=bt["[object Date]"]=bt["[object Error]"]=bt["[object Function]"]=bt["[object Map]"]=bt["[object Number]"]=bt["[object Object]"]=bt["[object RegExp]"]=bt["[object Set]"]=bt["[object String]"]=bt["[object WeakMap]"]=!1;var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,St=jt&&"object"==typeof module&&module&&!module.nodeType&&module,Ot=St&&St.exports===jt&&e.process,xt=function(){try{return St&&St.require&&St.require("util").types||Ot&&Ot.binding&&Ot.binding("util")}catch(t){}}(),At=xt&&xt.isTypedArray,kt=At?mt(At):function(t){return p(t)&&at(t.length)&&!!bt[d(t)]},Et=Object.prototype.hasOwnProperty;function zt(t,e){var r=y(t),n=!r&>(t),o=!r&&!n&&_t(t),i=!r&&!n&&!o&&kt(t),s=r||n||o||i,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],u=a.length;for(var c in t)!e&&!Et.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||X(c,u))||a.push(c);return a}function Ft(t,e){return function(r){return t(e(r))}}var Pt=Ft(Object.keys,Object),Tt=Object.prototype.hasOwnProperty;function Nt(t){return ut(t)?zt(t):function(t){if(!ft(t))return Pt(t);var e=[];for(var r in Object(t))Tt.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}var Mt=Object.prototype.hasOwnProperty;function It(t){return ut(t)?zt(t,!0):function(t){if(!S(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ft(t),r=[];for(var n in t)("constructor"!=n||!e&&Mt.call(t,n))&&r.push(n);return r}(t)}var Dt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$t=/^\w*$/;function Wt(t,e){if(y(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!w(t))||$t.test(t)||!Dt.test(t)||null!=e&&t in Object(e)}var Rt=$(Object,"create"),Ct=Object.prototype.hasOwnProperty,Vt=Object.prototype.hasOwnProperty;function Ut(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function qt(t,e){for(var r=t.length;r--;)if(et(t[r][0],e))return r;return-1}Ut.prototype.clear=function(){this.__data__=Rt?Rt(null):{},this.size=0},Ut.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ut.prototype.get=function(t){var e=this.__data__;if(Rt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Ct.call(e,t)?e[t]:void 0},Ut.prototype.has=function(t){var e=this.__data__;return Rt?void 0!==e[t]:Vt.call(e,t)},Ut.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Rt&&void 0===e?"__lodash_hash_undefined__":e,this};var Bt=Array.prototype.splice;function Jt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Jt.prototype.clear=function(){this.__data__=[],this.size=0},Jt.prototype.delete=function(t){var e=this.__data__,r=qt(e,t);return!(r<0||(r==e.length-1?e.pop():Bt.call(e,r,1),--this.size,0))},Jt.prototype.get=function(t){var e=this.__data__,r=qt(e,t);return r<0?void 0:e[r][1]},Jt.prototype.has=function(t){return qt(this.__data__,t)>-1},Jt.prototype.set=function(t,e){var r=this.__data__,n=qt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Lt=$(n,"Map");function Ht(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Gt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Zt(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=t.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(Zt.Cache||Gt),r}Gt.prototype.clear=function(){this.size=0,this.__data__={hash:new Ut,map:new(Lt||Jt),string:new Ut}},Gt.prototype.delete=function(t){var e=Ht(this,t).delete(t);return this.size-=e?1:0,e},Gt.prototype.get=function(t){return Ht(this,t).get(t)},Gt.prototype.has=function(t){return Ht(this,t).has(t)},Gt.prototype.set=function(t,e){var r=Ht(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Zt.Cache=Gt;var Yt,Kt,Qt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Xt=/\\(\\)?/g,te=(Yt=Zt(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Qt,function(t,r,n,o){e.push(n?o.replace(Xt,"$1"):r||t)}),e},function(t){return 500===Kt.size&&Kt.clear(),t}),Kt=Yt.cache,Yt);function ee(t,e){return y(t)?t:Wt(t,e)?[t]:te(function(t){return null==t?"":j(t)}(t))}var re=1/0;function ne(t){if("string"==typeof t||w(t))return t;var e=t+"";return"0"==e&&1/t==-re?"-0":e}function oe(t,e){for(var r=0,n=(e=ee(e,t)).length;null!=t&&r<n;)t=t[ne(e[r++])];return r&&r==n?t:void 0}function ie(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var se=Ft(Object.getPrototypeOf,Object);function ae(t){var e=this.__data__=new Jt(t);this.size=e.size}ae.prototype.clear=function(){this.__data__=new Jt,this.size=0},ae.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ae.prototype.get=function(t){return this.__data__.get(t)},ae.prototype.has=function(t){return this.__data__.has(t)},ae.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Jt){var n=r.__data__;if(!Lt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Gt(n)}return r.set(t,e),this.size=r.size,this};var ue="object"==typeof exports&&exports&&!exports.nodeType&&exports,ce=ue&&"object"==typeof module&&module&&!module.nodeType&&module,fe=ce&&ce.exports===ue?n.Buffer:void 0,le=fe?fe.allocUnsafe:void 0;function he(){return[]}var de=Object.prototype.propertyIsEnumerable,pe=Object.getOwnPropertySymbols,ge=pe?function(t){return null==t?[]:(t=Object(t),function(e,r){for(var n=-1,o=null==e?0:e.length,i=0,s=[];++n<o;){var a=e[n];de.call(t,a)&&(s[i++]=a)}return s}(pe(t)))}:he,we=ge,ve=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ie(e,we(t)),t=se(t);return e}:he;function ye(t,e,r){var n=e(t);return y(t)?n:ie(n,r(t))}function _e(t){return ye(t,Nt,we)}function be(t){return ye(t,It,ve)}var me=$(n,"DataView"),je=$(n,"Promise"),Se=$(n,"Set"),Oe="[object Map]",xe="[object Promise]",Ae="[object Set]",ke="[object WeakMap]",Ee="[object DataView]",ze=M(me),Fe=M(Lt),Pe=M(je),Te=M(Se),Ne=M(V),Me=d;(me&&Me(new me(new ArrayBuffer(1)))!=Ee||Lt&&Me(new Lt)!=Oe||je&&Me(je.resolve())!=xe||Se&&Me(new Se)!=Ae||V&&Me(new V)!=ke)&&(Me=function(t){var e=d(t),r="[object Object]"==e?t.constructor:void 0,n=r?M(r):"";if(n)switch(n){case ze:return Ee;case Fe:return Oe;case Pe:return xe;case Te:return Ae;case Ne:return ke}return e});var Ie=Me,De=Object.prototype.hasOwnProperty,$e=n.Uint8Array;function We(t){var e=new t.constructor(t.byteLength);return new $e(e).set(new $e(t)),e}var Re=/\w*$/,Ce=o?o.prototype:void 0,Ve=Ce?Ce.valueOf:void 0,Ue="[object Boolean]",qe="[object Date]",Be="[object Map]",Je="[object Number]",Le="[object RegExp]",He="[object Set]",Ge="[object String]",Ze="[object Symbol]",Ye="[object ArrayBuffer]",Ke="[object DataView]",Qe="[object Float32Array]",Xe="[object Float64Array]",tr="[object Int8Array]",er="[object Int16Array]",rr="[object Int32Array]",nr="[object Uint8Array]",or="[object Uint8ClampedArray]",ir="[object Uint16Array]",sr="[object Uint32Array]",ar=xt&&xt.isMap,ur=ar?mt(ar):function(t){return p(t)&&"[object Map]"==Ie(t)},cr=xt&&xt.isSet,fr=cr?mt(cr):function(t){return p(t)&&"[object Set]"==Ie(t)},lr=1,hr=2,dr=4,pr="[object Arguments]",gr="[object Function]",wr="[object GeneratorFunction]",vr="[object Object]",yr={};function _r(t,e,r,n,o,i){var s,a=e&lr,u=e&hr,c=e&dr;if(r&&(s=o?r(t,n,o,i):r(t)),void 0!==s)return s;if(!S(t))return t;var f=y(t);if(f){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&De.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,s)}else{var l=Ie(t),h=l==gr||l==wr;if(_t(t))return function(t,e){if(e)return t.slice();var r=t.length,n=le?le(r):new t.constructor(r);return t.copy(n),n}(t,a);if(l==vr||l==pr||h&&!o){if(s=u||h?{}:function(t){return"function"!=typeof t.constructor||ft(t)?{}:q(se(t))}(t),!a)return u?function(t,e){return ot(t,ve(t),e)}(t,function(t,e){return t&&ot(e,It(e),t)}(s,t)):function(t,e){return ot(t,we(t),e)}(t,function(t,e){return t&&ot(e,Nt(e),t)}(s,t))}else{if(!yr[l])return o?t:{};s=function(t,e,r){var n,o,i=t.constructor;switch(e){case Ye:return We(t);case Ue:case qe:return new i(+t);case Ke:return function(t,e){var r=e?We(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case Qe:case Xe:case tr:case er:case rr:case nr:case or:case ir:case sr:return function(t,e){var r=e?We(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,r);case Be:return new i;case Je:case Ge:return new i(t);case Le:return(o=new(n=t).constructor(n.source,Re.exec(n))).lastIndex=n.lastIndex,o;case He:return new i;case Ze:return Ve?Object(Ve.call(t)):{}}}(t,l,a)}}i||(i=new ae);var d=i.get(t);if(d)return d;i.set(t,s),fr(t)?t.forEach(function(n){s.add(_r(n,e,r,n,t,i))}):ur(t)&&t.forEach(function(n,o){s.set(o,_r(n,e,r,o,t,i))});var p=f?void 0:(c?u?be:_e:u?It:Nt)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r););}(p||t,function(n,o){p&&(n=t[o=n]),nt(s,o,_r(n,e,r,o,t,i))}),s}function br(t){return _r(t,4)}function mr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Gt;++e<r;)this.add(t[e])}function jr(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Sr(t,e){return t.has(e)}yr[pr]=yr["[object Array]"]=yr["[object ArrayBuffer]"]=yr["[object DataView]"]=yr["[object Boolean]"]=yr["[object Date]"]=yr["[object Float32Array]"]=yr["[object Float64Array]"]=yr["[object Int8Array]"]=yr["[object Int16Array]"]=yr["[object Int32Array]"]=yr["[object Map]"]=yr["[object Number]"]=yr[vr]=yr["[object RegExp]"]=yr["[object Set]"]=yr["[object String]"]=yr["[object Symbol]"]=yr["[object Uint8Array]"]=yr["[object Uint8ClampedArray]"]=yr["[object Uint16Array]"]=yr["[object Uint32Array]"]=!0,yr["[object Error]"]=yr[gr]=yr["[object WeakMap]"]=!1,mr.prototype.add=mr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},mr.prototype.has=function(t){return this.__data__.has(t)};var Or=1,xr=2;function Ar(t,e,r,n,o,i){var s=r&Or,a=t.length,u=e.length;if(a!=u&&!(s&&u>a))return!1;var c=i.get(t),f=i.get(e);if(c&&f)return c==e&&f==t;var l=-1,h=!0,d=r&xr?new mr:void 0;for(i.set(t,e),i.set(e,t);++l<a;){var p=t[l],g=e[l];if(n)var w=s?n(g,p,l,e,t,i):n(p,g,l,t,e,i);if(void 0!==w){if(w)continue;h=!1;break}if(d){if(!jr(e,function(t,e){if(!Sr(d,e)&&(p===t||o(p,t,r,n,i)))return d.push(e)})){h=!1;break}}else if(p!==g&&!o(p,g,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h}function kr(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Er(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var zr=1,Fr=2,Pr="[object Boolean]",Tr="[object Date]",Nr="[object Error]",Mr="[object Map]",Ir="[object Number]",Dr="[object RegExp]",$r="[object Set]",Wr="[object String]",Rr="[object Symbol]",Cr="[object ArrayBuffer]",Vr="[object DataView]",Ur=o?o.prototype:void 0,qr=Ur?Ur.valueOf:void 0,Br=1,Jr=Object.prototype.hasOwnProperty,Lr=1,Hr="[object Arguments]",Gr="[object Array]",Zr="[object Object]",Yr=Object.prototype.hasOwnProperty;function Kr(t,e,r,n,o){return t===e||(null==t||null==e||!p(t)&&!p(e)?t!=t&&e!=e:function(t,e,r,n,o,i){var s=y(t),a=y(e),u=s?Gr:Ie(t),c=a?Gr:Ie(e),f=(u=u==Hr?Zr:u)==Zr,l=(c=c==Hr?Zr:c)==Zr,h=u==c;if(h&&_t(t)){if(!_t(e))return!1;s=!0,f=!1}if(h&&!f)return i||(i=new ae),s||kt(t)?Ar(t,e,r,n,o,i):function(t,e,r,n,o,i,s){switch(r){case Vr:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Cr:return!(t.byteLength!=e.byteLength||!i(new $e(t),new $e(e)));case Pr:case Tr:case Ir:return et(+t,+e);case Nr:return t.name==e.name&&t.message==e.message;case Dr:case Wr:return t==e+"";case Mr:var a=kr;case $r:if(a||(a=Er),t.size!=e.size&&!(n&zr))return!1;var u=s.get(t);if(u)return u==e;n|=Fr,s.set(t,e);var c=Ar(a(t),a(e),n,o,i,s);return s.delete(t),c;case Rr:if(qr)return qr.call(t)==qr.call(e)}return!1}(t,e,u,r,n,o,i);if(!(r&Lr)){var d=f&&Yr.call(t,"__wrapped__"),p=l&&Yr.call(e,"__wrapped__");if(d||p){var g=d?t.value():t,w=p?e.value():e;return i||(i=new ae),o(g,w,r,n,i)}}return!!h&&(i||(i=new ae),function(t,e,r,n,o,i){var s=r&Br,a=_e(t),u=a.length;if(u!=_e(e).length&&!s)return!1;for(var c=u;c--;){var f=a[c];if(!(s?f in e:Jr.call(e,f)))return!1}var l=i.get(t),h=i.get(e);if(l&&h)return l==e&&h==t;var d=!0;i.set(t,e),i.set(e,t);for(var p=s;++c<u;){var g=t[f=a[c]],w=e[f];if(n)var v=s?n(w,g,f,e,t,i):n(g,w,f,t,e,i);if(!(void 0===v?g===w||o(g,w,r,n,i):v)){d=!1;break}p||(p="constructor"==f)}if(d&&!p){var y=t.constructor,_=e.constructor;y==_||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof _&&_ instanceof _||(d=!1)}return i.delete(t),i.delete(e),d}(t,e,r,n,o,i))}(t,e,r,n,Kr,o))}var Qr=1,Xr=2;function tn(t){return t==t&&!S(t)}function en(t,e){return function(r){return null!=r&&r[t]===e&&(void 0!==e||t in Object(r))}}function rn(t,e){return null!=t&&e in Object(t)}var nn=1,on=2;function sn(t){return"function"==typeof t?t:null==t?O:"object"==typeof t?y(t)?function(t,e){return Wt(t)&&tn(e)?en(ne(t),e):function(r){var n=function(t,e,r){var n=null==t?void 0:oe(t,e);return void 0===n?void 0:n}(r,t);return void 0===n&&n===e?function(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=ee(e,t)).length,i=!1;++n<o;){var s=ne(e[n]);if(!(i=null!=t&&r(t,s)))break;t=t[s]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&at(o)&&X(s,o)&&(y(t)||gt(t))}(t,e,rn)}(r,t):Kr(e,n,nn|on)}}(t[0],t[1]):(o=function(t){for(var e=Nt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,tn(o)]}return e}(n=t),1==o.length&&o[0][2]?en(o[0][0],o[0][1]):function(t){return t===n||function(t,e,r,n){var o=r.length,i=o;if(null==t)return!i;for(t=Object(t);o--;){var s=r[o];if(s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++o<i;){var a=(s=r[o])[0],u=t[a],c=s[1];if(s[2]){if(void 0===u&&!(a in t))return!1}else{var f=new ae;if(!Kr(c,u,Qr|Xr,void 0,f))return!1}}return!0}(t,0,o)}):Wt(e=t)?(r=ne(e),function(t){return null==t?void 0:t[r]}):function(t){return function(e){return oe(e,t)}}(e);var e,r,n,o}function an(t,e){return t&&function(t,e,r){for(var n=-1,o=Object(t),i=r(t),s=i.length;s--;){var a=i[++n];if(!1===e(o[a],a,o))break}return t}(t,e,Nt)}var un,cn=(un=an,function(t,e){if(null==t)return t;if(!ut(t))return un(t,e);for(var r=t.length,n=-1,o=Object(t);++n<r&&!1!==e(o[n],n,o););return t});function fn(t,e){var r=-1,n=ut(t)?Array(t.length):[];return cn(t,function(t,o,i){n[++r]=e(t,o,i)}),n}function ln(t,e){return t>e}var hn=Math.min;function dn(t){return function(t){return p(t)&&ut(t)}(t)?t:[]}var pn=function(t,e){return G(function(t,e,r){return e=it(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=it(n.length-e,0),s=Array(i);++o<i;)s[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(s),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}(t,void 0,O),t+"")}(function(t){var e=v(t,dn);return e.length&&e[0]===t[0]?function(t,e,r){for(var n=Y,o=t[0].length,i=t.length,s=i,a=Array(i),u=Infinity,c=[];s--;){var f=t[s];u=hn(f.length,u),a[s]=o>=120&&f.length>=120?new mr(s&&f):void 0}f=t[0];var l=-1,h=a[0];t:for(;++l<o&&c.length<u;){var d=f[l],p=d;if(d=0!==d?d:0,!(h?Sr(h,p):n(c,p,r))){for(s=i;--s;){var g=a[s];if(!(g?Sr(g,p):n(t[s],p,r)))continue t}h&&h.push(p),c.push(d)}}return c}(e):[]}),gn=pn;function wn(t,e){return t<e}function vn(t,e,r){for(var n=-1,o=t.length;++n<o;){var i=t[n],s=e(i);if(null!=s&&(void 0===a?s==s&&!w(s):r(s,a)))var a=s,u=i}return u}function yn(t,e){return t&&t.length?vn(t,sn(e),ln):void 0}function _n(t,e){for(var r,n=-1,o=t.length;++n<o;){var i=e(t[n]);void 0!==i&&(r=void 0===r?i:r+i)}return r}function bn(t,e){return function(t,e){var r=null==t?0:t.length;return r?_n(t,e)/r:NaN}(t,sn(e))}function mn(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=w(t),s=void 0!==e,a=null===e,u=e==e,c=w(e);if(!a&&!c&&!i&&t>e||i&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!o)return 1;if(!n&&!i&&!c&&t<e||c&&r&&o&&!n&&!i||a&&r&&o||!s&&o||!u)return-1}return 0}function jn(t,e,r,n){return null==t?[]:(y(e)||(e=null==e?[]:[e]),y(r=n?void 0:r)||(r=null==r?[]:[r]),function(t,e,r){e=e.length?v(e,function(t){return y(t)?function(e){return oe(e,1===t.length?t[0]:t)}:t}):[O];var n=-1;return e=v(e,mt(sn)),function(t,e){var n=t.length;for(t.sort(function(t,e){return function(t,e,r){for(var n=-1,o=t.criteria,i=e.criteria,s=o.length,a=r.length;++n<s;){var u=mn(o[n],i[n]);if(u)return n>=a?u:u*("desc"==r[n]?-1:1)}return t.index-e.index}(t,e,r)});n--;)t[n]=t[n].value;return t}(fn(t,function(t,r,o){return{criteria:v(e,function(e){return e(t)}),index:++n,value:t}}))}(t,e,r))}function Sn(t,e){return t&&t.length?_n(t,sn(e)):0}function On(t){if(this.words=[],t)if(Symbol&&Symbol.iterator&&void 0!==t[Symbol.iterator]){const e=t[Symbol.iterator]();let r=e.next();for(;!r.done;)this.add(r.value),r=e.next()}else for(let e=0;e<t.length;e++)this.add(t[e])}On.fromWords=function(t){const e=Object.create(On.prototype);return e.words=t,e},On.prototype.add=function(t){this.resize(t),this.words[t>>>5]|=1<<t},On.prototype.flip=function(t){this.resize(t),this.words[t>>>5]^=1<<t},On.prototype.clear=function(){this.words.length=0},On.prototype.remove=function(t){this.resize(t),this.words[t>>>5]&=~(1<<t)},On.prototype.isEmpty=function(t){const e=this.words.length;for(let t=0;t<e;t++)if(0!==this.words[t])return!1;return!0},On.prototype.has=function(t){return 0!=(this.words[t>>>5]&1<<t)},On.prototype.checkedAdd=function(t){this.resize(t);const e=this.words[t>>>5],r=e|1<<t;return this.words[t>>>5]=r,(r^e)>>>t},On.prototype.trim=function(t){let e=this.words.length;for(;e>0&&0===this.words[e-1];)e--;this.words.length=e},On.prototype.resize=function(t){const e=t+32>>>5;for(let t=this.words.length;t<e;t++)this.words[t]=0},On.prototype.hammingWeight=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},On.prototype.hammingWeight4=function(t,e,r,n){return 16843009*((t=(t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)+(e=(e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)+(r=(r=(858993459&(r-=r>>>1&1431655765))+(r>>>2&858993459))+(r>>>4)&252645135)+(n=(n=(858993459&(n-=n>>>1&1431655765))+(n>>>2&858993459))+(n>>>4)&252645135))>>>24},On.prototype.size=function(){let t=0;const e=this.words.length,r=this.words;for(let n=0;n<e;n++)t+=this.hammingWeight(r[n]);return t},On.prototype.array=function(){const t=new Array(this.size());let e=0;const r=this.words.length;for(let n=0;n<r;++n){let r=this.words[n];for(;0!=r;){const o=r&-r;t[e++]=(n<<5)+this.hammingWeight(o-1|0),r^=o}}return t},On.prototype.forEach=function(t){const e=this.words.length;for(let r=0;r<e;++r){let e=this.words[r];for(;0!=e;){const n=e&-e;t((r<<5)+this.hammingWeight(n-1|0)),e^=n}}},On.prototype[Symbol.iterator]=function(){const t=this.words.length;let e=0,r=this.words[e],n=this.hammingWeight,o=this.words;return{[Symbol.iterator](){return this},next(){for(;e<t;){if(0!==r){const t=r&-r,o=(e<<5)+n(t-1|0);return r^=t,{done:!1,value:o}}e++,e<t&&(r=o[e])}return{done:!0,value:void 0}}}},On.prototype.clone=function(){const t=Object.create(On.prototype);return t.words=this.words.slice(),t},On.prototype.intersects=function(t){const e=Math.min(this.words.length,t.words.length);for(let r=0;r<e;++r)if(0!=(this.words[r]&t.words[r]))return!0;return!1},On.prototype.intersection=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]&=t.words[r],this.words[r+1]&=t.words[r+1],this.words[r+2]&=t.words[r+2],this.words[r+3]&=t.words[r+3],this.words[r+4]&=t.words[r+4],this.words[r+5]&=t.words[r+5],this.words[r+6]&=t.words[r+6],this.words[r+7]&=t.words[r+7];for(;r<e;++r)this.words[r]&=t.words[r];const n=this.words.length;for(r=e;r<n;++r)this.words[r]=0;return this},On.prototype.intersection_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(let n=0;n<e;++n)r+=this.hammingWeight(this.words[n]&t.words[n]);return r},On.prototype.new_intersection=function(t){const e=Object.create(On.prototype),r=Math.min(this.words.length,t.words.length);e.words=new Array(r);let n=0;for(;n+7<r;n+=8)e.words[n]=this.words[n]&t.words[n],e.words[n+1]=this.words[n+1]&t.words[n+1],e.words[n+2]=this.words[n+2]&t.words[n+2],e.words[n+3]=this.words[n+3]&t.words[n+3],e.words[n+4]=this.words[n+4]&t.words[n+4],e.words[n+5]=this.words[n+5]&t.words[n+5],e.words[n+6]=this.words[n+6]&t.words[n+6],e.words[n+7]=this.words[n+7]&t.words[n+7];for(;n<r;++n)e.words[n]=this.words[n]&t.words[n];return e},On.prototype.equals=function(t){const e=Math.min(this.words.length,t.words.length);for(let r=0;r<e;++r)if(this.words[r]!=t.words[r])return!1;if(this.words.length<t.words.length){const e=t.words.length;for(let r=this.words.length;r<e;++r)if(0!=t.words[r])return!1}else if(t.words.length<this.words.length){const e=this.words.length;for(let r=t.words.length;r<e;++r)if(0!=this.words[r])return!1}return!0},On.prototype.difference=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]&=~t.words[r],this.words[r+1]&=~t.words[r+1],this.words[r+2]&=~t.words[r+2],this.words[r+3]&=~t.words[r+3],this.words[r+4]&=~t.words[r+4],this.words[r+5]&=~t.words[r+5],this.words[r+6]&=~t.words[r+6],this.words[r+7]&=~t.words[r+7];for(;r<e;++r)this.words[r]&=~t.words[r];return this},On.prototype.new_difference=function(t){return this.clone().difference(t)},On.prototype.difference2=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)t.words[r]=this.words[r]&~t.words[r],t.words[r+1]=this.words[r+1]&~t.words[r+1],t.words[r+2]=this.words[r+2]&~t.words[r+2],t.words[r+3]=this.words[r+3]&~t.words[r+3],t.words[r+4]=this.words[r+4]&~t.words[r+4],t.words[r+5]=this.words[r+5]&~t.words[r+5],t.words[r+6]=this.words[r+6]&~t.words[r+6],t.words[r+7]=this.words[r+7]&~t.words[r+7];for(;r<e;++r)t.words[r]=this.words[r]&~t.words[r];for(r=this.words.length-1;r>=e;--r)t.words[r]=this.words[r];return t.words.length=this.words.length,t},On.prototype.difference_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0,n=0;for(;n<e;++n)r+=this.hammingWeight(this.words[n]&~t.words[n]);const o=this.words.length;for(;n<o;++n)r+=this.hammingWeight(this.words[n]);return r},On.prototype.change=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]^=t.words[r],this.words[r+1]^=t.words[r+1],this.words[r+2]^=t.words[r+2],this.words[r+3]^=t.words[r+3],this.words[r+4]^=t.words[r+4],this.words[r+5]^=t.words[r+5],this.words[r+6]^=t.words[r+6],this.words[r+7]^=t.words[r+7];for(;r<e;++r)this.words[r]^=t.words[r];for(r=t.words.length-1;r>=e;--r)this.words[r]=t.words[r];return this},On.prototype.new_change=function(t){const e=Object.create(On.prototype),r=Math.max(this.words.length,t.words.length);e.words=new Array(r);const n=Math.min(this.words.length,t.words.length);let o=0;for(;o+7<n;o+=8)e.words[o]=this.words[o]^t.words[o],e.words[o+1]=this.words[o+1]^t.words[o+1],e.words[o+2]=this.words[o+2]^t.words[o+2],e.words[o+3]=this.words[o+3]^t.words[o+3],e.words[o+4]=this.words[o+4]^t.words[o+4],e.words[o+5]=this.words[o+5]^t.words[o+5],e.words[o+6]=this.words[o+6]^t.words[o+6],e.words[o+7]=this.words[o+7]^t.words[o+7];for(;o<n;++o)e.words[o]=this.words[o]^t.words[o];const i=this.words.length;for(o=n;o<i;++o)e.words[o]=this.words[o];const s=t.words.length;for(o=n;o<s;++o)e.words[o]=t.words[o];return e},On.prototype.change_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0,n=0;for(;n<e;++n)r+=this.hammingWeight(this.words[n]^t.words[n]);const o=this.words.length>t.words.length?this:t,i=o.words.length;for(;n<i;++n)r+=this.hammingWeight(o.words[n]);return r},On.prototype.toString=function(){return"{"+this.array().join(",")+"}"},On.prototype.union=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]|=t.words[r],this.words[r+1]|=t.words[r+1],this.words[r+2]|=t.words[r+2],this.words[r+3]|=t.words[r+3],this.words[r+4]|=t.words[r+4],this.words[r+5]|=t.words[r+5],this.words[r+6]|=t.words[r+6],this.words[r+7]|=t.words[r+7];for(;r<e;++r)this.words[r]|=t.words[r];if(this.words.length<t.words.length){this.resize((t.words.length<<5)-1);const r=t.words.length;for(let n=e;n<r;++n)this.words[n]=t.words[n]}return this},On.prototype.new_union=function(t){const e=Object.create(On.prototype),r=Math.max(this.words.length,t.words.length);e.words=new Array(r);const n=Math.min(this.words.length,t.words.length);let o=0;for(;o+7<n;o+=8)e.words[o]=this.words[o]|t.words[o],e.words[o+1]=this.words[o+1]|t.words[o+1],e.words[o+2]=this.words[o+2]|t.words[o+2],e.words[o+3]=this.words[o+3]|t.words[o+3],e.words[o+4]=this.words[o+4]|t.words[o+4],e.words[o+5]=this.words[o+5]|t.words[o+5],e.words[o+6]=this.words[o+6]|t.words[o+6],e.words[o+7]=this.words[o+7]|t.words[o+7];for(;o<n;++o)e.words[o]=this.words[o]|t.words[o];const i=this.words.length;for(o=n;o<i;++o)e.words[o]=this.words[o];const s=t.words.length;for(o=n;o<s;++o)e.words[o]=t.words[o];return e},On.prototype.union_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(let n=0;n<e;++n)r+=this.hammingWeight(this.words[n]|t.words[n]);if(this.words.length<t.words.length){const e=t.words.length;for(let n=this.words.length;n<e;++n)r+=this.hammingWeight(0|t.words[n])}else{const e=this.words.length;for(let n=t.words.length;n<e;++n)r+=this.hammingWeight(0|this.words[n])}return r};var xn=On,An=function(t,e){if(!t||"object"!=typeof t)throw new Error("Invalid facets_data provided.");if(!e||"object"!=typeof e)return null;var r=Object.entries(e).flatMap(function(t){var e=t[0],r=t[1];return Array.isArray(r)?r.map(function(t){return{field:e,filter:t}}):[]});return 0===r.length?null:r.reduce(function(e,r){var n,o=(null==(n=t[r.field])?void 0:n[r.filter])||new xn([]);return e.new_union(o)},new xn([]))},kn=function(e,r,n){var o,i,s,a=1;return o=e.bits_data_temp,i=function(e,o){var i,s,u,c,f,l,h;n[o]&&(i=n[o].order,s=n[o].sort,u=n[o].size,c=n[o].title,f=n[o].show_facet_stats||!1,l=!1!==n[o].chosen_filters_on_top,h=n[o].hide_zero_doc_count||!1);var d,p,g,w,v,_=Object.entries(e).map(function(t){var e=[];r&&r.filters&&r.filters[o]&&(e=r.filters[o]);var n=t[1].array().length,i=e.some(function(e){return String(e)===String(t[0])});if(!h||0!==n||i)return{key:t[0],doc_count:n,selected:i}}).filter(Boolean);if(y(s)?(d=s||["key"],p=i||["asc"]):("term"===s||"key"===s?(d=["key"],p=[i||"asc"]):(d=["doc_count","key"],p=[i||"desc","asc"]),l&&(d.unshift("selected"),p.unshift("desc"))),_=(_=jn(_,d,p)).slice(0,u||10),f){var b=[];Object.entries(e).forEach(function(t){if(isNaN(t[0]))throw new Error("You cant use chars to calculate the facet_stats.");t[1].array().length>0&&t[1].forEach(function(){b.push(parseInt(t[0]))})}),g={min:(w=b,w&&w.length?vn(w,sn(void 0),wn):void 0),max:yn(b),avg:bn(b),sum:Sn(b)}}return t({name:o,title:c||(v=o,v.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,function(t){return t.toUpperCase()})),position:a++,buckets:_},f&&{facet_stats:g})},s={},i=sn(i),an(o,function(t,e,r){tt(s,e,i(t,e,r))}),s};function En(t,e){var r=[];return t.forEach(function(t){e.forEach(function(e){r.push(t.concat(e))})}),r}function zn(t){return!!~t.search(/\(|\)/)}function Fn(t,e){for(var r=e.split(" "+t+" "),n=[],o=[],i=0;i<r.length;i++)if(zn(r[i])||o.length>0){o.push(r[i]);var s=""+o;(s.match(/\(/g)||[]).length===(s.match(/\)/g)||[]).length&&(n.push(o.join(" "+t+" ")),o=[])}else n.push(r[i]);return n}var Pn=function t(e){return function(t){for(var e=t[0],r=1;r<t.length;r++)e=e.concat(t[r]);return e}(Fn("OR",(r=e=function(t){if("("===t.charAt(0))for(var e=0,r=0;r<t.length;r++)if("("===t.charAt(r)?e++:")"===t.charAt(r)&&e--,0===e)return r!==t.length-1?t:t.substring(1,t.length-1);return t}(e),e=r.replace(/[\s]+/g," "))).map(function(e){for(var r=Fn("AND",e),n=[],o=[],i=0;i<r.length;i++)zn(r[i])?n.push(t(r[i])):o.push(r[i]);return n.push([o]),function(t){for(var e=[[]],r=0;r<t.length;r++)e=En(e,t[r]);return e}(n)}));var r},Tn=function(t){return"boolean"==typeof t?t?"AND":"OR":"string"==typeof t&&"OR"===t.toUpperCase()?"OR":"AND"},Nn=function(e,r){var n=r&&r.aggregations||{},o=Object.create(null),i=!1,s=t({},n);return Object.keys(e||{}).forEach(function(r){var a,u,c=n[r];if(c){var f=null==(a=e[r])?void 0:a.selected;Array.isArray(f)&&f.length&&(o[r]=f,i=!0);var l=null==(u=e[r])?void 0:u.options;if(l){var h={};if(void 0!==l.conjunction){var d=Tn(l.conjunction);h.conjunction="AND"===d}"number"==typeof l.size&&(h.size=l.size),"key"===l.sortBy?(h.sort="key",h.order=l.sortDir||c.order):"count"===l.sortBy?(h.sort=void 0,h.order=l.sortDir||c.order):l.sortDir&&(h.order=l.sortDir),"boolean"==typeof l.hideZero&&(h.hide_zero_doc_count=l.hideZero),"boolean"==typeof l.chosenOnTop&&(h.chosen_filters_on_top=l.chosenOnTop),"boolean"==typeof l.showStats&&(h.show_facet_stats=l.showStats),Object.keys(h).length&&(s[r]=t({},n[r],h))}}}),{hasFilters:i,filters:i?o:void 0,aggregations:s}};function Mn(t,e,r,n,o){var i=function(t){return"number"==typeof t?t:parseInt(t,10)},s=i((e=e||Object.create(null)).per_page);(!Number.isFinite(s)||s<0)&&(s=12);var a=i(e.page);(!Number.isFinite(a)||a<1)&&(a=1),0===s&&(a=1);var u=e.is_all_filtered_items||!1;if(!1===r.native_search_enabled&&e.query)throw new Error('The "query" option is not working once native search is disabled');var c,f,l,h=0,d=(new Date).getTime(),p=o.bits_ids();if(e._ids)c=new xn(e._ids),f=e._ids;else if(e.ids)f=o.internal_ids_from_ids_map(e.ids),e.filter&&(f=t.filter(function(t){return f.includes(t._id)}).filter(e.filter).map(function(t){return t._id})),c=new xn(f);else if(n&&(e.query||e.filter)){var g=(new Date).getTime();f=n.search(e.query,e.filter),h=(new Date).getTime()-g,c=new xn(f)}var w=(new Date).getTime(),v=o.search(e,{query_ids:c});if(w=(new Date).getTime()-w,c&&(p=c),v.ids&&(p=p.new_intersection(v.ids)),v.not_ids&&(p=p.new_difference(v.not_ids)),0===s&&!u&&!e.sort&&!f){var y=p.array(),_=(new Date).getTime()-d;return{pagination:{per_page:s,page:a,total:y.length},timings:{total:_,facets:w,search:h,sorting:0},data:{items:[],allFilteredItems:null,aggregations:kn(v,e,r.aggregations)}}}var b,m,j=!1,S=(new Date).getTime(),O=p.array();e.sort?m=function(t,e,r){if(r&&r[e]&&(e=r[e]),e.field){var n=Array.isArray(e.field)?e.field:[e.field],o=Array.isArray(e.order)?e.order:[e.order||"asc"],i=[],s=[];return n.forEach(function(t,e){i.push(function(e){return null==e[t]?1:0}),s.push("asc"),i.push(t),s.push(o[e]||"asc")}),jn(t,i,s)}return t}(m=O.map(function(t){return o.get_item(t)}),e.sort,r.sortings):f?(m=(O=f.filter(function(t){return p.has(t)})).slice((a-1)*s,a*s).map(function(t){return o.get_item(t)}),j=!0):m=O.map(function(t){return o.get_item(t)}),j||(l=u?m:null,m=m.slice((a-1)*s,a*s)),b=(new Date).getTime()-S;var x=(new Date).getTime()-d;return{pagination:{per_page:s,page:a,total:O.length},timings:{total:x,facets:w,search:h,sorting:b},data:{items:m,allFilteredItems:l,aggregations:kn(v,e,r.aggregations)}}}var In=function(t){var e={exports:{}};return function(t,e){!function(){var e,r,n,o,i,s,a,u,c,f,l,h,d,p,g,w,v,y,_,b,m,j,S,O,x,A,k,E,z=function(t){var e=new z.Index;return e.pipeline.add(z.trimmer,z.stopWordFilter,z.stemmer),t&&t.call(e,e),e};z.version="1.0.0",z.utils={},z.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),z.utils.asString=function(t){return null==t?"":t.toString()},z.EventEmitter=function(){this.events={}},z.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),r=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");r.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},z.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var r=this.events[t].indexOf(e);this.events[t].splice(r,1),this.events[t].length||delete this.events[t]}},z.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},z.EventEmitter.prototype.hasHandler=function(t){return t in this.events},z.tokenizer=function(t){return arguments.length&&null!=t&&null!=t?Array.isArray(t)?t.map(function(t){return z.utils.asString(t).toLowerCase()}):t.toString().trim().toLowerCase().split(z.tokenizer.separator):[]},z.tokenizer.separator=/[\s\-]+/,z.tokenizer.load=function(t){var e=this.registeredFunctions[t];if(!e)throw new Error("Cannot load un-registered function: "+t);return e},z.tokenizer.label="default",z.tokenizer.registeredFunctions={default:z.tokenizer},z.tokenizer.registerFunction=function(t,e){e in this.registeredFunctions&&z.utils.warn("Overwriting existing tokenizer: "+e),t.label=e,this.registeredFunctions[e]=t},z.Pipeline=function(){this._stack=[]},z.Pipeline.registeredFunctions={},z.Pipeline.registerFunction=function(t,e){e in this.registeredFunctions&&z.utils.warn("Overwriting existing registered function: "+e),t.label=e,z.Pipeline.registeredFunctions[t.label]=t},z.Pipeline.warnIfFunctionNotRegistered=function(t){t.label&&t.label in this.registeredFunctions||z.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",t)},z.Pipeline.load=function(t){var e=new z.Pipeline;return t.forEach(function(t){var r=z.Pipeline.registeredFunctions[t];if(!r)throw new Error("Cannot load un-registered function: "+t);e.add(r)}),e},z.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(t){z.Pipeline.warnIfFunctionNotRegistered(t),this._stack.push(t)},this)},z.Pipeline.prototype.after=function(t,e){z.Pipeline.warnIfFunctionNotRegistered(e);var r=this._stack.indexOf(t);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r+=1,0,e)},z.Pipeline.prototype.before=function(t,e){z.Pipeline.warnIfFunctionNotRegistered(e);var r=this._stack.indexOf(t);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r,0,e)},z.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);-1!=e&&this._stack.splice(e,1)},z.Pipeline.prototype.run=function(t){for(var e=[],r=t.length,n=this._stack.length,o=0;o<r;o++){for(var i=t[o],s=0;s<n&&void 0!==(i=this._stack[s](i,o,t))&&""!==i;s++);void 0!==i&&""!==i&&e.push(i)}return e},z.Pipeline.prototype.reset=function(){this._stack=[]},z.Pipeline.prototype.toJSON=function(){return this._stack.map(function(t){return z.Pipeline.warnIfFunctionNotRegistered(t),t.label})},z.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},z.Vector.Node=function(t,e,r){this.idx=t,this.val=e,this.next=r},z.Vector.prototype.insert=function(t,e){this._magnitude=void 0;var r=this.list;if(!r)return this.list=new z.Vector.Node(t,e,r),this.length++;if(t<r.idx)return this.list=new z.Vector.Node(t,e,r),this.length++;for(var n=r,o=r.next;null!=o;){if(t<o.idx)return n.next=new z.Vector.Node(t,e,o),this.length++;n=o,o=o.next}return n.next=new z.Vector.Node(t,e,o),this.length++},z.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var t,e=this.list,r=0;e;)r+=(t=e.val)*t,e=e.next;return this._magnitude=Math.sqrt(r)},z.Vector.prototype.dot=function(t){for(var e=this.list,r=t.list,n=0;e&&r;)e.idx<r.idx?e=e.next:(e.idx>r.idx||(n+=e.val*r.val,e=e.next),r=r.next);return n},z.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},z.SortedSet=function(){this.length=0,this.elements=[]},z.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},z.SortedSet.prototype.add=function(){var t,e;for(t=0;t<arguments.length;t++)~this.indexOf(e=arguments[t])||this.elements.splice(this.locationFor(e),0,e);this.length=this.elements.length},z.SortedSet.prototype.toArray=function(){return this.elements.slice()},z.SortedSet.prototype.map=function(t,e){return this.elements.map(t,e)},z.SortedSet.prototype.forEach=function(t,e){return this.elements.forEach(t,e)},z.SortedSet.prototype.indexOf=function(t){for(var e=0,r=this.elements.length,n=r-e,o=e+Math.floor(n/2),i=this.elements[o];n>1;){if(i===t)return o;i<t&&(e=o),i>t&&(r=o),n=r-e,o=e+Math.floor(n/2),i=this.elements[o]}return i===t?o:-1},z.SortedSet.prototype.locationFor=function(t){for(var e=0,r=this.elements.length,n=r-e,o=e+Math.floor(n/2),i=this.elements[o];n>1;)i<t&&(e=o),i>t&&(r=o),n=r-e,o=e+Math.floor(n/2),i=this.elements[o];return i>t?o:i<t?o+1:void 0},z.SortedSet.prototype.intersect=function(t){for(var e=new z.SortedSet,r=0,n=0,o=this.length,i=t.length,s=this.elements,a=t.elements;!(r>o-1||n>i-1);)s[r]!==a[n]?s[r]<a[n]?r++:s[r]>a[n]&&n++:(e.add(s[r]),r++,n++);return e},z.SortedSet.prototype.clone=function(){var t=new z.SortedSet;return t.elements=this.toArray(),t.length=t.elements.length,t},z.SortedSet.prototype.union=function(t){var e,r,n;this.length>=t.length?(e=this,r=t):(e=t,r=this),n=e.clone();for(var o=0,i=r.toArray();o<i.length;o++)n.add(i[o]);return n},z.SortedSet.prototype.toJSON=function(){return this.toArray()},z.Index=function(){this._fields=[],this._ref="id",this.pipeline=new z.Pipeline,this.documentStore=new z.Store,this.tokenStore=new z.TokenStore,this.corpusTokens=new z.SortedSet,this.eventEmitter=new z.EventEmitter,this.tokenizerFn=z.tokenizer,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},z.Index.prototype.on=function(){var t=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,t)},z.Index.prototype.off=function(t,e){return this.eventEmitter.removeListener(t,e)},z.Index.load=function(t){t.version!==z.version&&z.utils.warn("version mismatch: current "+z.version+" importing "+t.version);var e=new this;return e._fields=t.fields,e._ref=t.ref,e.tokenizer(z.tokenizer.load(t.tokenizer)),e.documentStore=z.Store.load(t.documentStore),e.tokenStore=z.TokenStore.load(t.tokenStore),e.corpusTokens=z.SortedSet.load(t.corpusTokens),e.pipeline=z.Pipeline.load(t.pipeline),e},z.Index.prototype.field=function(t,e){return this._fields.push({name:t,boost:(e=e||{}).boost||1}),this},z.Index.prototype.ref=function(t){return this._ref=t,this},z.Index.prototype.tokenizer=function(t){return t.label&&t.label in z.tokenizer.registeredFunctions||z.utils.warn("Function is not a registered tokenizer. This may cause problems when serialising the index"),this.tokenizerFn=t,this},z.Index.prototype.add=function(t,e){var r={},n=new z.SortedSet,o=t[this._ref];e=void 0===e||e,this._fields.forEach(function(e){var o=this.pipeline.run(this.tokenizerFn(t[e.name]));r[e.name]=o;for(var i=0;i<o.length;i++){var s=o[i];n.add(s),this.corpusTokens.add(s)}},this),this.documentStore.set(o,n);for(var i=0;i<n.length;i++){for(var s=n.elements[i],a=0,u=0;u<this._fields.length;u++){var c=this._fields[u],f=r[c.name],l=f.length;if(l){for(var h=0,d=0;d<l;d++)f[d]===s&&h++;a+=h/l*c.boost}}this.tokenStore.add(s,{ref:o,tf:a})}e&&this.eventEmitter.emit("add",t,this)},z.Index.prototype.remove=function(t,e){var r=t[this._ref];if(e=void 0===e||e,this.documentStore.has(r)){var n=this.documentStore.get(r);this.documentStore.remove(r),n.forEach(function(t){this.tokenStore.remove(t,r)},this),e&&this.eventEmitter.emit("remove",t,this)}},z.Index.prototype.update=function(t,e){e=void 0===e||e,this.remove(t,!1),this.add(t,!1),e&&this.eventEmitter.emit("update",t,this)},z.Index.prototype.idf=function(t){var e="@"+t;if(Object.prototype.hasOwnProperty.call(this._idfCache,e))return this._idfCache[e];var r=this.tokenStore.count(t),n=1;return r>0&&(n=1+Math.log(this.documentStore.length/r)),this._idfCache[e]=n},z.Index.prototype.search=function(t){var e=this.pipeline.run(this.tokenizerFn(t)),r=new z.Vector,n=[],o=this._fields.reduce(function(t,e){return t+e.boost},0);return e.some(function(t){return this.tokenStore.has(t)},this)?(e.forEach(function(t,e,i){var s=1/i.length*this._fields.length*o,a=this,u=this.tokenStore.expand(t).reduce(function(e,n){var o=a.corpusTokens.indexOf(n),i=a.idf(n),u=1,c=new z.SortedSet;if(n!==t){var f=Math.max(3,n.length-t.length);u=1/Math.log(f)}o>-1&&r.insert(o,s*i*u);for(var l=a.tokenStore.get(n),h=Object.keys(l),d=h.length,p=0;p<d;p++)c.add(l[h[p]].ref);return e.union(c)},new z.SortedSet);n.push(u)},this),n.reduce(function(t,e){return t.intersect(e)}).map(function(t){return{ref:t,score:r.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})):[]},z.Index.prototype.documentVector=function(t){for(var e=this.documentStore.get(t),r=e.length,n=new z.Vector,o=0;o<r;o++){var i=e.elements[o],s=this.tokenStore.get(i)[t].tf,a=this.idf(i);n.insert(this.corpusTokens.indexOf(i),s*a)}return n},z.Index.prototype.toJSON=function(){return{version:z.version,fields:this._fields,ref:this._ref,tokenizer:this.tokenizerFn.label,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},z.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},z.Store=function(){this.store={},this.length=0},z.Store.load=function(t){var e=new this;return e.length=t.length,e.store=Object.keys(t.store).reduce(function(e,r){return e[r]=z.SortedSet.load(t.store[r]),e},{}),e},z.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},z.Store.prototype.get=function(t){return this.store[t]},z.Store.prototype.has=function(t){return t in this.store},z.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},z.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},z.stemmer=(e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},r={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},s="^("+(o="[^aeiou][^aeiouy]*")+")?"+(i=(n="[aeiouy]")+"[aeiou]*")+o+"("+i+")?$",a="^("+o+")?"+i+o+i+o,u="^("+o+")?"+n,c=new RegExp("^("+o+")?"+i+o),f=new RegExp(a),l=new RegExp(s),h=new RegExp(u),d=/^(.+?)(ss|i)es$/,p=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,w=/^(.+?)(ed|ing)$/,v=/.$/,y=/(at|bl|iz)$/,_=new RegExp("([^aeiouylsz])\\1$"),b=new RegExp("^"+o+n+"[^aeiouwxy]$"),m=/^(.+?[^aeiou])y$/,j=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,S=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,O=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,x=/^(.+?)(s|t)(ion)$/,A=/^(.+?)e$/,k=/ll$/,E=new RegExp("^"+o+n+"[^aeiouwxy]$"),function(t){var n,o,i,s,a,u,z;if(t.length<3)return t;if("y"==(i=t.substr(0,1))&&(t=i.toUpperCase()+t.substr(1)),a=p,(s=d).test(t)?t=t.replace(s,"$1$2"):a.test(t)&&(t=t.replace(a,"$1$2")),a=w,(s=g).test(t)){var F=s.exec(t);(s=c).test(F[1])&&(t=t.replace(s=v,""))}else a.test(t)&&(F=a.exec(t),(a=h).test(n=F[1])&&(u=_,z=b,(a=y).test(t=n)?t+="e":u.test(t)?t=t.replace(s=v,""):z.test(t)&&(t+="e")));return(s=m).test(t)&&(t=(n=(F=s.exec(t))[1])+"i"),(s=j).test(t)&&(o=(F=s.exec(t))[2],(s=c).test(n=F[1])&&(t=n+e[o])),(s=S).test(t)&&(o=(F=s.exec(t))[2],(s=c).test(n=F[1])&&(t=n+r[o])),a=x,(s=O).test(t)?(F=s.exec(t),(s=f).test(n=F[1])&&(t=n)):a.test(t)&&(F=a.exec(t),(a=f).test(n=F[1]+F[2])&&(t=n)),(s=A).test(t)&&(F=s.exec(t),a=l,u=E,((s=f).test(n=F[1])||a.test(n)&&!u.test(n))&&(t=n)),a=f,(s=k).test(t)&&a.test(t)&&(t=t.replace(s=v,"")),"y"==i&&(t=i.toLowerCase()+t.substr(1)),t}),z.Pipeline.registerFunction(z.stemmer,"stemmer"),z.generateStopWordFilter=function(t){var e=t.reduce(function(t,e){return t[e]=e,t},{});return function(t){if(t&&e[t]!==t)return t}},z.stopWordFilter=z.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),z.Pipeline.registerFunction(z.stopWordFilter,"stopWordFilter"),z.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},z.Pipeline.registerFunction(z.trimmer,"trim