=m.length)d-=m.length;else{for(var p=c?d+Math.min(m.length-d,c):m.length,n=d;n=h.length)return[];if(!b&&!c)return h;h=h.slice(c,c+b);return d?e.enrich(h):h})};
-t.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;dm&&!h&&"string"===typeof p&&!isNaN(p)&&(m=k.indexOf(parseInt(p,10)))&&(h=1),0<=m)if(e=1,1"a1a".split(c).length;
+this.numeric=H(a.numeric,e)}else{try{this.split=H(this.split,Ba)}catch(g){this.split=/\s+/}this.numeric=H(a.numeric,H(this.numeric,!0))}this.prepare=H(a.prepare,null,this.prepare);this.finalize=H(a.finalize,null,this.finalize);Ha||(this.mapper=new Map(Aa));this.rtl=H(a.rtl,!1,this.rtl);this.dedupe=H(a.dedupe,!1,this.dedupe);this.filter=H((c=a.filter)&&new Set(c),null,this.filter);this.matcher=H((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=H((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=
+H((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=H(a.replacer,null,this.replacer);this.minlength=H(a.minlength,1,this.minlength);this.maxlength=H(a.maxlength,0,this.maxlength);if(this.cache=c=H(a.cache,!0,this.cache))this.D=null,this.T="number"===typeof c?c:2E5,this.B=new Map,this.C=new Map,this.H=this.G=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(a=w(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=w(this.stemmer.keys()),
+b=a.next();!b.done;b=a.next())this.A+=(this.A?"|":"")+b.value;return this};u.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&N(this);return this};u.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&N(this);return this};
+u.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&N(this);return this};
+u.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&N(this);return this};
+u.encode=function(a){var b=this;if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(N,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Ha?a.normalize("NFKD").replace(Ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.T&&(this.C.clear(),this.H=this.H/1.1|0));f&&d.push(f)}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.G&&(this.B.set(a,d),this.B.size>this.T&&(this.B.clear(),this.G=this.G/1.1|0));return d};function N(a){a.D=null;a.B.clear();a.C.clear()};function Ja(a){var b,c,d,e,g,f,h;return ta(function(k){a=a.data;b=self._index;c=a.args;d=a.task;switch(d){case "init":e=a.options||{};(g=a.factory)?(Function("return "+g)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new O(e);postMessage({id:a.id});break;default:f=a.id,h=b[d].apply(b,c),postMessage("search"===d?{id:f,msg:h}:{id:f})}k.h=0})};var Ka=0;
+function R(a){function b(f){function h(k){k=k.data||k;var l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=f;this.h=I();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++Ka]=function(){k(e)};e.worker.postMessage({id:Ka,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}a=void 0===a?{}:a;if(!this||this.constructor!==R)return new R(a);var c="undefined"!==typeof self?self._factory:
+"undefined"!==typeof window?window._factory:null;c&&(c=c.toString());var d="undefined"===typeof window,e=this,g=La(c,d,a.worker);return g.then?g.then(function(f){return b.call(e,f)}):b.call(this,g)}Ma("add");Ma("append");Ma("search");Ma("update");Ma("remove");
+function Ma(a){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=arguments,d,e,g,f,h;return ta(function(k){d=b;e=[].slice.call(c);g=e[e.length-1];"function"===typeof g&&(f=g,e.splice(e.length-1,1));h=new Promise(function(l){d.h[++Ka]=l;d.worker.postMessage({task:a,id:Ka,args:e})});return f?(h.then(f),k.return(b)):k.return(h)})}}
+function La(a,b,c){return b?"undefined"!==typeof module?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); }):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Ja.toString()],{type:"text/javascript"}))):new window.Worker(K(c)?c:(0,eval)("import.meta.url").replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js",
+"module/worker/worker.js"),{type:"module"})};function Na(a){Oa.call(a,"add");Oa.call(a,"append");Oa.call(a,"search");Oa.call(a,"update");Oa.call(a,"remove")}function Oa(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}b=this[a].apply(this,b);d&&(b.then?b.then(d):d(b));return b}};function Pa(a,b){b=void 0===b?0:b;var c=[],d=[];b&&(b=25E4/b*5E3|0);a=w(a.entries());for(var e=a.next();!e.done;e=a.next())d.push(e.value),d.length===b&&(c.push(d),d=[]);d.length&&c.push(d);return c}function Qa(a,b){b||(b=new Map);for(var c=0,d;c=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e}
+function S(a){if(!this)return new S(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var g=0,f=0,h,k;fc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(g=0;gd)d-=f.length;
+else{if(f.length>c||d)f=f.slice(d,c+d),c-=f.length,d&&(d-=f.length);e.push(f);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,d?W.call(this,a):a;for(var e=[],g=0,f=void 0,h=void 0;g=h){c-=h;continue}cb&&(f=f.slice(0,b),h=b);if(!e.length&&h>=b)return d?W.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=eb(a,c,d,!1,this.h),d=0));return g?this.resolve(c,d,e):this};X.prototype.and=function(){var a=this.result.length;if(!a){var b=arguments[0];if(b){a=!!b.suggest;var c=b.resolve;var d=b.limit;var e=b.offset;var g=b.enrich&&c}}return a?(a=hb(this,"and",arguments),jb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,g):this};
+function jb(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=za(a))return this.result=db(a,b,c,d,f,this.h,g),g?e?W.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(c,d,e):this};X.prototype.xor=function(){var a=hb(this,"xor",arguments);return kb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)};
+function kb(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else return this.result=lb.call(this,a,c,d,g,this.h),g?e?W.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this}
+function lb(a,b,c,d,e){for(var g=[],f=I(),h=0,k=0,l;kc||d)a=a.slice(d,d+c);e&&(a=W.call(this,a));return a}}
+function W(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)};
+Y.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Y.prototype.remove=function(a){for(var b=w(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};var ub={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};var vb=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);var wb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),xb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var yb={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var zb=/[\x00-\x7F]+/g;var Ab=/[\x00-\x7F]+/g;var Bb=/[\x00-\x7F]+/g;var Cb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:ub,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:vb},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:vb,matcher:wb,replacer:xb},LatinExtra:{normalize:!0,dedupe:!0,mapper:vb,replacer:xb.concat([/(?!^)[aeo]/g,""]),matcher:wb},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bn;q--){p=l.substring(n,q);var r=this.score?this.score(b,l,k,p,n):Eb(h,d,k,m,n);Fb(this,g,p,r,a,c)}break}case "reverse":if(1<
+m){for(q=m-1;0p?0:1),d,k,q-1,r-1),t=this.bidirectional&&l>n;Fb(this,e,t?n:l,x,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&
+(b||this.commit_task.push({del:a}),this.ca&&Gb(this));return this};
+function Fb(a,b,c,d,e,g,f){var h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=I()),b[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!g||!h.includes(e)){if(h.length===Math.pow(2,31)-1){b=new S(h);if(a.fastupdate)for(c=w(a.reg.values()),g=c.next();!g.done;g=c.next())g=g.value,g.includes(h)&&(g[g.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}}
+function Eb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,g,f,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};O.prototype.remove=function(a,b){var c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(var d=0,e;de.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Lb(this.map,a),this.depth&&Lb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Gb(this));this.cache&&this.cache.remove(a);return this};
+function Lb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,g;d=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length,p=d;p=g.length)return[];if(!b&&!c)return g;g=g.slice(c,c+b);return d?e.enrich(g):g})};
+u.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;dm&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1 "a1a".split(b).length;
}
- try {
- this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u");
- } catch (g) {
- this.split = /\s+/;
- }
- this.numeric = e;
+ this.numeric = u(a.numeric, e);
} else {
try {
- this.split = u(b, y, this.split);
- } catch (e) {
- this.split = /\s+/;
+ this.split = u(this.split, aa);
+ } catch (d) {
+ console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/;
}
- this.numeric = u(this.numeric, !0);
+ this.numeric = u(a.numeric, u(this.numeric, !0));
}
this.prepare = u(a.prepare, null, this.prepare);
this.finalize = u(a.finalize, null, this.finalize);
- this.rtl = a.rtl || !1;
+ this.rtl = u(a.rtl, !1, this.rtl);
this.dedupe = u(a.dedupe, !1, this.dedupe);
this.filter = u((b = a.filter) && new Set(b), null, this.filter);
this.matcher = u((b = a.matcher) && new Map(b), null, this.matcher);
@@ -100,50 +109,36 @@ t.assign = function(a) {
this.minlength = u(a.minlength, 1, this.minlength);
this.maxlength = u(a.maxlength, 0, this.maxlength);
if (this.cache = b = u(a.cache, !0, this.cache)) {
- this.l = null, this.v = "number" === typeof b ? b : 2e5, this.h = new Map(), this.j = new Map(), this.o = this.m = 128;
+ this.l = null, this.C = "number" === typeof b ? b : 2e5, this.i = new Map(), this.j = new Map(), this.s = this.o = 128;
}
this.g = "";
- this.s = null;
- this.i = "";
- this.u = null;
+ this.v = null;
+ this.h = "";
+ this.A = null;
if (this.matcher) {
- for (const e of this.matcher.keys()) {
- this.g += (this.g ? "|" : "") + e;
+ for (const d of this.matcher.keys()) {
+ this.g += (this.g ? "|" : "") + d;
}
}
if (this.stemmer) {
- for (const e of this.stemmer.keys()) {
- this.i += (this.i ? "|" : "") + e;
+ for (const d of this.stemmer.keys()) {
+ this.h += (this.h ? "|" : "") + d;
}
}
return this;
};
-t.addMatcher = function(a, c) {
- if ("object" === typeof a) {
- return this.addReplacer(a, c);
- }
- if (2 > a.length) {
- return this.addMapper(a, c);
- }
- this.matcher || (this.matcher = new Map());
- this.matcher.set(a, c);
- this.g += (this.g ? "|" : "") + a;
- this.s = null;
- this.cache && F(this);
- return this;
-};
t.addStemmer = function(a, c) {
this.stemmer || (this.stemmer = new Map());
this.stemmer.set(a, c);
- this.i += (this.i ? "|" : "") + a;
- this.u = null;
- this.cache && F(this);
+ this.h += (this.h ? "|" : "") + a;
+ this.A = null;
+ this.cache && B(this);
return this;
};
t.addFilter = function(a) {
this.filter || (this.filter = new Set());
this.filter.add(a);
- this.cache && F(this);
+ this.cache && B(this);
return this;
};
t.addMapper = function(a, c) {
@@ -155,138 +150,503 @@ t.addMapper = function(a, c) {
}
this.mapper || (this.mapper = new Map());
this.mapper.set(a, c);
- this.cache && F(this);
+ this.cache && B(this);
+ return this;
+};
+t.addMatcher = function(a, c) {
+ if ("object" === typeof a) {
+ return this.addReplacer(a, c);
+ }
+ if (2 > a.length && (this.dedupe || this.mapper)) {
+ return this.addMapper(a, c);
+ }
+ this.matcher || (this.matcher = new Map());
+ this.matcher.set(a, c);
+ this.g += (this.g ? "|" : "") + a;
+ this.v = null;
+ this.cache && B(this);
return this;
};
t.addReplacer = function(a, c) {
- "string" === typeof a && (a = new RegExp(a, "g"));
+ if ("string" === typeof a) {
+ return this.addMatcher(a, c);
+ }
this.replacer || (this.replacer = []);
- this.replacer.push(a, c || "");
- this.cache && F(this);
+ this.replacer.push(a, c);
+ this.cache && B(this);
return this;
};
-function F(a) {
- a.h.clear();
- a.j.clear();
-}
t.encode = function(a) {
- if (this.cache && a.length <= this.m) {
+ if (this.cache && a.length <= this.o) {
if (this.l) {
- if (this.h.has(a)) {
- return this.h.get(a);
+ if (this.i.has(a)) {
+ return this.i.get(a);
}
} else {
- this.l = setTimeout(G, 50, this);
+ this.l = setTimeout(B, 50, this);
}
}
- this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : D ? a.normalize("NFKD").replace(D, "").toLowerCase() : a.toLowerCase());
+ this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = y ? a.normalize("NFKD").replace(y, "").toLowerCase() : a.toLowerCase());
this.prepare && (a = this.prepare(a));
- this.numeric && 3 < a.length && (a = a.replace(A, "$1 $2").replace(B, "$1 $2").replace(z, "$1 "));
+ this.numeric && 3 < a.length && (a = a.replace(ca, "$1 $2").replace(da, "$1 $2").replace(ba, "$1 "));
const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer);
let b = [], e = this.split || "" === this.split ? a.split(this.split) : a;
for (let g = 0, f, h; g < e.length; g++) {
- if (!(f = h = e[g])) {
- continue;
- }
- if (f.length < this.minlength) {
- continue;
- }
- if (c) {
- b.push(f);
- continue;
- }
- if (this.filter && this.filter.has(f)) {
- continue;
- }
- if (this.cache && f.length <= this.o) {
- if (this.l) {
- var d = this.j.get(f);
- if (d || "" === d) {
- d && b.push(d);
- continue;
- }
+ if ((f = h = e[g]) && !(f.length < this.minlength)) {
+ if (c) {
+ b.push(f);
} else {
- this.l = setTimeout(G, 50, this);
+ if (!this.filter || !this.filter.has(f)) {
+ if (this.cache && f.length <= this.s) {
+ if (this.l) {
+ var d = this.j.get(f);
+ if (d || "" === d) {
+ d && b.push(d);
+ continue;
+ }
+ } else {
+ this.l = setTimeout(B, 50, this);
+ }
+ }
+ this.stemmer && 2 < f.length && (this.A || (this.A = new RegExp("(?!^)(" + this.h + ")$")), f = f.replace(this.A, k => this.stemmer.get(k)), f.length < this.minlength || this.filter && this.filter.has(f)) && (f = "");
+ if (f && (this.mapper || this.dedupe && 1 < f.length)) {
+ d = "";
+ for (let k = 0, l = "", n, m; k < f.length; k++) {
+ n = f.charAt(k), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (d += m) : d += l = n);
+ }
+ f = d;
+ }
+ this.matcher && 1 < f.length && (this.v || (this.v = new RegExp("(" + this.g + ")", "g")), f = f.replace(this.v, k => this.matcher.get(k)));
+ if (f && this.replacer) {
+ for (d = 0; f && d < this.replacer.length; d += 2) {
+ f = f.replace(this.replacer[d], this.replacer[d + 1]);
+ }
+ }
+ this.cache && h.length <= this.s && (this.j.set(h, f), this.j.size > this.C && (this.j.clear(), this.s = this.s / 1.1 | 0));
+ f && b.push(f);
+ }
}
}
- let k;
- this.stemmer && 2 < f.length && (this.u || (this.u = new RegExp("(?!^)(" + this.i + ")$")), f = f.replace(this.u, r => this.stemmer.get(r)), k = 1);
- f && k && (f.length < this.minlength || this.filter && this.filter.has(f)) && (f = "");
- if (f && (this.mapper || this.dedupe && 1 < f.length)) {
- d = "";
- for (let r = 0, q = "", p, n; r < f.length; r++) {
- p = f.charAt(r), p === q && this.dedupe || ((n = this.mapper && this.mapper.get(p)) || "" === n ? n === q && this.dedupe || !(q = n) || (d += n) : d += q = p);
- }
- f = d;
- }
- this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), f = f.replace(this.s, r => this.matcher.get(r)));
- if (f && this.replacer) {
- for (d = 0; f && d < this.replacer.length; d += 2) {
- f = f.replace(this.replacer[d], this.replacer[d + 1]);
- }
- }
- this.cache && h.length <= this.o && (this.j.set(h, f), this.j.size > this.v && (this.j.clear(), this.o = this.o / 1.1 | 0));
- f && b.push(f);
}
this.finalize && (b = this.finalize(b) || b);
- this.cache && a.length <= this.m && (this.h.set(a, b), this.h.size > this.v && (this.h.clear(), this.m = this.m / 1.1 | 0));
+ this.cache && a.length <= this.o && (this.i.set(a, b), this.i.size > this.C && (this.i.clear(), this.o = this.o / 1.1 | 0));
return b;
};
-function G(a) {
+function B(a) {
a.l = null;
- a.h.clear();
+ a.i.clear();
a.j.clear();
}
-;function H(a) {
+;function C(a, c, b, e, d) {
+ const g = a.length;
+ let f = [], h, k;
+ h = w();
+ for (let l = 0, n, m, r, q; l < c; l++) {
+ for (let p = 0; p < g; p++) {
+ if (r = a[p], l < r.length && (n = r[l])) {
+ for (let v = 0; v < n.length; v++) {
+ m = n[v], (k = h[m]) ? h[m]++ : (k = 0, h[m] = 1), q = f[k] || (f[k] = []), q.push(m);
+ }
+ }
+ }
+ }
+ if (a = f.length) {
+ if (d) {
+ f = 1 < f.length ? D(f, b, e) : (f = f[0]).length > b || e ? f.slice(e, b + e) : f;
+ } else {
+ if (a < g) {
+ return [];
+ }
+ f = f[a - 1];
+ if (b || e) {
+ if (f.length > b || e) {
+ f = f.slice(e, b + e);
+ }
+ }
+ }
+ }
+ return f;
+}
+function D(a, c, b) {
+ const e = [], d = w();
+ let g;
+ var f = a.length;
+ let h;
+ for (let k = f - 1; 0 <= k; k--) {
+ if (h = (f = a[k]) && f.length) {
+ for (let l = 0; l < h; l++) {
+ if (g = f[l], !d[g]) {
+ if (d[g] = 1, b) {
+ b--;
+ } else {
+ if (e.push(g), e.length === c) {
+ return e;
+ }
+ }
+ }
+ }
+ }
+ }
+ return e;
+}
+;function E(a, c, b, e) {
+ if (!a.length) {
+ return a;
+ }
+ if (1 === a.length) {
+ return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? F.call(this, a) : a;
+ }
+ let d = [];
+ for (let g = 0, f, h; g < a.length; g++) {
+ if ((f = a[g]) && (h = f.length)) {
+ if (b) {
+ if (b >= h) {
+ b -= h;
+ continue;
+ }
+ b < h && (f = c ? f.slice(b, b + c) : f.slice(b), h = f.length, b = 0);
+ }
+ h > c && (f = f.slice(0, c), h = c);
+ if (!d.length && h >= c) {
+ return e ? F.call(this, f) : f;
+ }
+ d.push(f);
+ c -= h;
+ if (!c) {
+ break;
+ }
+ }
+ }
+ d = 1 < d.length ? [].concat.apply([], d) : d[0];
+ return e ? F.call(this, d) : d;
+}
+;function G(a, c, b) {
+ var e = b[0];
+ if (e.then) {
+ return Promise.all(b).then(function(n) {
+ return a[c].apply(a, n);
+ });
+ }
+ if (e[0] && e[0].index) {
+ return a[c].apply(a, e);
+ }
+ e = [];
+ let d = [], g = 0, f = 0, h, k, l;
+ for (let n = 0, m; n < b.length; n++) {
+ if (m = b[n]) {
+ let r;
+ if (m.constructor === I) {
+ r = m.result;
+ } else if (m.constructor === Array) {
+ r = m;
+ } else {
+ if (g = m.limit || 0, f = m.offset || 0, l = m.suggest, k = m.resolve, h = m.enrich && k, m.index) {
+ m.resolve = !1, m.enrich = !1, r = m.index.search(m).result, m.resolve = k, m.enrich = h;
+ } else if (m.and) {
+ r = a.and(m.and);
+ } else if (m.or) {
+ r = a.or(m.or);
+ } else if (m.xor) {
+ r = a.xor(m.xor);
+ } else if (m.not) {
+ r = a.not(m.not);
+ } else {
+ continue;
+ }
+ }
+ if (r.then) {
+ d.push(r);
+ } else if (r.length) {
+ e[n] = r;
+ } else if (!l && ("and" === c || "xor" === c)) {
+ e = [];
+ break;
+ }
+ }
+ }
+ return {m:e, u:d, limit:g, offset:f, enrich:h, resolve:k, suggest:l};
+}
+;I.prototype.or = function() {
+ const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g} = G(this, "or", arguments);
+ return J.call(this, a, c, b, e, d, g);
+};
+function J(a, c, b, e, d, g) {
+ if (c.length) {
+ const f = this;
+ return Promise.all(c).then(function(h) {
+ a = [];
+ for (let k = 0, l; k < h.length; k++) {
+ (l = h[k]).length && (a[k] = l);
+ }
+ return J.call(f, a, [], b, e, d, g);
+ });
+ }
+ a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = D(a, b, e), e = 0));
+ return g ? this.resolve(b, e, d) : this;
+}
+;I.prototype.and = function() {
+ let a = this.result.length, c, b, e, d;
+ if (!a) {
+ const g = arguments[0];
+ g && (a = !!g.suggest, d = g.resolve, c = g.limit, b = g.offset, e = g.enrich && d);
+ }
+ if (a) {
+ const {m:g, u:f, limit:h, offset:k, enrich:l, resolve:n, suggest:m} = G(this, "and", arguments);
+ return K.call(this, g, f, h, k, l, n, m);
+ }
+ return d ? this.resolve(c, b, e) : this;
+};
+function K(a, c, b, e, d, g, f) {
+ if (c.length) {
+ const h = this;
+ return Promise.all(c).then(function(k) {
+ a = [];
+ for (let l = 0, n; l < k.length; l++) {
+ (n = k[l]).length && (a[l] = n);
+ }
+ return K.call(h, a, [], b, e, d, g, f);
+ });
+ }
+ if (a.length) {
+ if (this.result.length && a.unshift(this.result), 2 > a.length) {
+ this.result = a[0];
+ } else {
+ if (c = x(a)) {
+ return this.result = C(a, c, b, e, f), g ? d ? F.call(this.index, this.result) : this.result : this;
+ }
+ this.result = [];
+ }
+ } else {
+ f || (this.result = a);
+ }
+ return g ? this.resolve(b, e, d) : this;
+}
+;I.prototype.xor = function() {
+ const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g, suggest:f} = G(this, "xor", arguments);
+ return L.call(this, a, c, b, e, d, g, f);
+};
+function L(a, c, b, e, d, g, f) {
+ if (c.length) {
+ const h = this;
+ return Promise.all(c).then(function(k) {
+ a = [];
+ for (let l = 0, n; l < k.length; l++) {
+ (n = k[l]).length && (a[l] = n);
+ }
+ return L.call(h, a, [], b, e, d, g, f);
+ });
+ }
+ if (a.length) {
+ if (this.result.length && a.unshift(this.result), 2 > a.length) {
+ this.result = a[0];
+ } else {
+ return this.result = ea.call(this, a, b, e, g, this.g), g ? d ? F.call(this.index, this.result) : this.result : this;
+ }
+ } else {
+ f || (this.result = a);
+ }
+ return g ? this.resolve(b, e, d) : this;
+}
+function ea(a, c, b, e, d) {
+ const g = [], f = w();
+ let h = 0;
+ for (let k = 0, l; k < a.length; k++) {
+ if (l = a[k]) {
+ h < l.length && (h = l.length);
+ for (let n = 0, m; n < l.length; n++) {
+ if (m = l[n]) {
+ for (let r = 0, q; r < m.length; r++) {
+ q = m[r], f[q] = f[q] ? 2 : 1;
+ }
+ }
+ }
+ }
+ }
+ for (let k = 0, l, n = 0; k < h; k++) {
+ for (let m = 0, r; m < a.length; m++) {
+ if (r = a[m]) {
+ if (l = r[k]) {
+ for (let q = 0, p; q < l.length; q++) {
+ if (p = l[q], 1 === f[p]) {
+ if (b) {
+ b--;
+ } else {
+ if (e) {
+ if (g.push(p), g.length === c) {
+ return g;
+ }
+ } else {
+ const v = k + (m ? d : 0);
+ g[v] || (g[v] = []);
+ g[v].push(p);
+ if (++n === c) {
+ return g;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return g;
+}
+;I.prototype.not = function() {
+ const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g, suggest:f} = G(this, "not", arguments);
+ return M.call(this, a, c, b, e, d, g, f);
+};
+function M(a, c, b, e, d, g, f) {
+ if (c.length) {
+ const h = this;
+ return Promise.all(c).then(function(k) {
+ a = [];
+ for (let l = 0, n; l < k.length; l++) {
+ (n = k[l]).length && (a[l] = n);
+ }
+ return M.call(h, a, [], b, e, d, g, f);
+ });
+ }
+ if (a.length && this.result.length) {
+ this.result = fa.call(this, a, b, e, g);
+ } else if (g) {
+ return this.resolve(b, e, d);
+ }
+ return g ? d ? F.call(this.index, this.result) : this.result : this;
+}
+function fa(a, c, b, e) {
+ const d = [];
+ a = new Set(a.flat().flat());
+ for (let g = 0, f, h = 0; g < this.result.length; g++) {
+ if (f = this.result[g]) {
+ for (let k = 0, l; k < f.length; k++) {
+ if (l = f[k], !a.has(l)) {
+ if (b) {
+ b--;
+ } else {
+ if (e) {
+ if (d.push(l), d.length === c) {
+ return d;
+ }
+ } else {
+ if (d[g] || (d[g] = []), d[g].push(l), ++h === c) {
+ return d;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return d;
+}
+;function I(a) {
+ if (!this || this.constructor !== I) {
+ return new I(a);
+ }
+ if (a && a.index) {
+ return a.resolve = !1, this.index = a.index, this.g = a.boost || 0, this.result = a.index.search(a).result, this;
+ }
+ this.index = null;
+ this.result = a || [];
+ this.g = 0;
+}
+I.prototype.limit = function(a) {
+ if (this.result.length) {
+ const c = [];
+ let b = 0;
+ for (let e = 0, d; e < this.result.length; e++) {
+ if (d = this.result[e], d.length + b < a) {
+ c[e] = d, b += d.length;
+ } else {
+ c[e] = d.slice(0, a - b);
+ this.result = c;
+ break;
+ }
+ }
+ }
+ return this;
+};
+I.prototype.offset = function(a) {
+ if (this.result.length) {
+ const c = [];
+ let b = 0;
+ for (let e = 0, d; e < this.result.length; e++) {
+ d = this.result[e], d.length + b < a ? b += d.length : (c[e] = d.slice(a - b), b = a);
+ }
+ this.result = c;
+ }
+ return this;
+};
+I.prototype.boost = function(a) {
+ this.g += a;
+ return this;
+};
+I.prototype.resolve = function(a, c, b) {
+ const e = this.result, d = this.index;
+ this.result = this.index = null;
+ return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), E.call(d, e, a || 100, c, b)) : e;
+};
+w();
+function F(a) {
+ if (!this || !this.store) {
+ return a;
+ }
+ const c = Array(a.length);
+ for (let b = 0, e; b < a.length; b++) {
+ e = a[b], c[b] = {id:e, doc:this.store.get(e)};
+ }
+ return c;
+}
+;function N(a) {
this.limit = a && !0 !== a ? a : 1000;
this.cache = new Map();
this.g = "";
}
-H.prototype.set = function(a, c) {
+N.prototype.set = function(a, c) {
this.cache.set(this.g = a, c);
this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
};
-H.prototype.get = function(a) {
+N.prototype.get = function(a) {
const c = this.cache.get(a);
c && this.g !== a && (this.cache.delete(a), this.cache.set(this.g = a, c));
return c;
};
-H.prototype.remove = function(a) {
+N.prototype.remove = function(a) {
for (const c of this.cache) {
const b = c[0];
c[1].includes(a) && this.cache.delete(b);
}
};
-H.prototype.clear = function() {
+N.prototype.clear = function() {
this.cache.clear();
this.g = "";
};
-const I = {normalize:function(a) {
+const ha = {normalize:function(a) {
return a.toLowerCase();
-}, dedupe:!1};
-const J = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
-w();
-K.prototype.add = function(a, c, b, e) {
+}, numeric:!1, dedupe:!1};
+const O = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
+P.prototype.add = function(a, c, b, e) {
if (c && (a || 0 === a)) {
if (!e && !b && this.reg.has(a)) {
return this.update(a, c);
}
c = this.encoder.encode(c);
if (e = c.length) {
- const r = w(), q = w(), p = this.depth, n = this.resolution;
- for (let m = 0; m < e; m++) {
- let l = c[this.rtl ? e - 1 - m : m];
- var d = l.length;
- if (d && (p || !q[l])) {
- var g = this.score ? this.score(c, l, m, null, 0) : L(n, e, m), f = "";
+ const l = w(), n = w(), m = this.depth, r = this.resolution;
+ for (let q = 0; q < e; q++) {
+ let p = c[this.rtl ? e - 1 - q : q];
+ var d = p.length;
+ if (d && (m || !n[p])) {
+ var g = this.score ? this.score(c, p, q, null, 0) : Q(r, e, q), f = "";
switch(this.tokenize) {
case "full":
if (2 < d) {
for (g = 0; g < d; g++) {
for (var h = d; h > g; h--) {
- f = l.substring(g, h);
- var k = this.score ? this.score(c, l, m, f, g) : L(n, e, m, d, g);
- M(this, q, f, k, a, b);
+ f = p.substring(g, h);
+ var k = this.score ? this.score(c, p, q, f, g) : Q(r, e, q, d, g);
+ R(this, n, f, k, a, b);
}
}
break;
@@ -294,24 +654,24 @@ K.prototype.add = function(a, c, b, e) {
case "reverse":
if (1 < d) {
for (h = d - 1; 0 < h; h--) {
- f = l[h] + f, k = this.score ? this.score(c, l, m, f, h) : L(n, e, m, d, h), M(this, q, f, k, a, b);
+ f = p[h] + f, k = this.score ? this.score(c, p, q, f, h) : Q(r, e, q, d, h), R(this, n, f, k, a, b);
}
f = "";
}
case "forward":
if (1 < d) {
for (h = 0; h < d; h++) {
- f += l[h], M(this, q, f, g, a, b);
+ f += p[h], R(this, n, f, g, a, b);
}
break;
}
default:
- if (M(this, q, l, g, a, b), p && 1 < e && m < e - 1) {
- for (d = w(), f = this.A, g = l, h = Math.min(p + 1, e - m), d[g] = 1, k = 1; k < h; k++) {
- if ((l = c[this.rtl ? e - 1 - m - k : m + k]) && !d[l]) {
- d[l] = 1;
- const v = this.score ? this.score(c, g, m, l, k) : L(f + (e / 2 > f ? 0 : 1), e, m, h - 1, k - 1), C = this.bidirectional && l > g;
- M(this, r, C ? g : l, v, a, b, C ? l : g);
+ if (R(this, n, p, g, a, b), m && 1 < e && q < e - 1) {
+ for (d = w(), f = this.B, g = p, h = Math.min(m + 1, e - q), d[g] = 1, k = 1; k < h; k++) {
+ if ((p = c[this.rtl ? e - 1 - q - k : q + k]) && !d[p]) {
+ d[p] = 1;
+ const v = this.score ? this.score(c, g, q, p, k) : Q(f + (e / 2 > f ? 0 : 1), e, q, h - 1, k - 1), A = this.bidirectional && p > g;
+ R(this, l, A ? g : p, v, a, b, A ? p : g);
}
}
}
@@ -323,46 +683,16 @@ K.prototype.add = function(a, c, b, e) {
}
return this;
};
-function M(a, c, b, e, d, g, f) {
+function R(a, c, b, e, d, g, f) {
let h = f ? a.ctx : a.map, k;
if (!c[b] || f && !(k = c[b])[f]) {
f ? (c = k || (c[b] = w()), c[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), g && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h])));
}
}
-function L(a, c, b, e, d) {
+function Q(a, c, b, e, d) {
return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0;
}
-;function N(a, c, b) {
- if (1 === a.length) {
- return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a;
- }
- let e = [];
- for (let d = 0, g, f; d < a.length; d++) {
- if ((g = a[d]) && (f = g.length)) {
- if (b) {
- if (b >= f) {
- b -= f;
- continue;
- }
- b < f && (g = c ? g.slice(b, b + c) : g.slice(b), f = g.length, b = 0);
- }
- if (e.length) {
- f > c && (g = g.slice(0, c), f = g.length);
- } else {
- if (f >= c) {
- return f > c && (g = g.slice(0, c)), g;
- }
- }
- e.push(g);
- c -= f;
- if (!c) {
- break;
- }
- }
- }
- return e.length ? e = 1 < e.length ? [].concat.apply([], e) : e[0] : e;
-}
-;K.prototype.search = function(a, c, b) {
+;P.prototype.search = function(a, c, b) {
b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = ""));
var e = [], d = 0;
if (b) {
@@ -378,150 +708,81 @@ function L(a, c, b, e, d) {
}
b = this.encoder.encode(a);
a = b.length;
- c || !h || (c = 100);
+ c = c || (h ? 100 : 0);
if (1 === a) {
- return O.call(this, b[0], "", c, d);
+ return S.call(this, b[0], "", c, d, h);
}
g = this.depth && !1 !== g;
if (2 === a && g && !f) {
- return O.call(this, b[0], b[1], c, d);
+ return S.call(this, b[0], b[1], c, d, h);
}
- var r = h = 0;
- if (1 < a) {
- var q = w();
- const n = [];
- for (let m = 0, l; m < a; m++) {
- if ((l = b[m]) && !q[l]) {
- if (f || P(this, l)) {
- n.push(l), q[l] = 1;
- } else {
- return e;
- }
- const v = l.length;
- h = Math.max(h, v);
- r = r ? Math.min(r, v) : v;
- }
- }
- b = n;
- a = b.length;
+ h = w();
+ let l = 0;
+ if (1 < a && g) {
+ var n = b[0];
+ l = 1;
}
- if (!a) {
- return e;
- }
- q = 0;
- if (1 === a) {
- return O.call(this, b[0], "", c, d);
- }
- if (2 === a && g && !f) {
- return O.call(this, b[0], b[1], c, d);
- }
- if (1 < a) {
- if (g) {
- var p = b[0];
- q = 1;
- } else {
- 9 < h && 3 < h / r && b.sort(x);
- }
- }
- k || 0 === k || (k = this.resolution);
- for (let n, m; q < a; q++) {
- m = b[q];
- p ? (n = P(this, m, p), n = Q(n, e, f, this.A), f && !1 === n && e.length || (p = m)) : (n = P(this, m, ""), n = Q(n, e, f, k));
- if (n) {
- return n;
- }
- if (f && q === a - 1) {
- g = e.length;
- if (!g) {
- if (p) {
- p = "";
- q = -1;
- continue;
- }
- return e;
- }
- if (1 === g) {
- return N(e[0], c, d);
- }
- }
- }
- a: {
- p = f;
- g = e.length;
- f = [];
- a = w();
- for (let n = 0, m, l, v, C; n < k; n++) {
- for (h = 0; h < g; h++) {
- if (v = e[h], n < v.length && (m = v[n])) {
- for (r = 0; r < m.length; r++) {
- l = m[r], (b = a[l]) ? a[l]++ : (b = 0, a[l] = 1), C = f[b] || (f[b] = []), C.push(l);
+ k || 0 === k || (k = n ? this.B : this.resolution);
+ for (let p, v; l < a; l++) {
+ if ((v = b[l]) && !h[v]) {
+ h[v] = 1;
+ p = T(this, v, n);
+ a: {
+ g = p;
+ var m = e, r = f, q = k;
+ let A = [];
+ if (g && g.length) {
+ if (g.length <= q) {
+ m.push(g);
+ p = void 0;
+ break a;
}
- }
- }
- }
- if (k = f.length) {
- if (p) {
- if (1 < f.length) {
- b: {
- for (k = [], e = w(), p = f.length, b = p - 1; 0 <= b; b--) {
- for (p = f[b], a = p.length, h = 0; h < a; h++) {
- if (g = p[h], !e[g]) {
- if (e[g] = 1, d) {
- d--;
- } else {
- if (k.push(g), k.length === c) {
- break b;
- }
- }
- }
- }
+ for (let H = 0, Y; H < q; H++) {
+ if (Y = g[H]) {
+ A[H] = Y;
}
}
- } else {
- k = (f = f[0]).length > c || d ? f.slice(d, c + d) : f;
- }
- f = k;
- } else {
- if (k < g) {
- e = [];
- break a;
- }
- f = f[k - 1];
- if (c || d) {
- if (f.length > c || d) {
- f = f.slice(d, c + d);
+ if (A.length) {
+ m.push(A);
+ p = void 0;
+ break a;
}
}
+ p = r ? void 0 : A;
}
+ if (p) {
+ e = p;
+ break;
+ }
+ n && (f && p && e.length || (n = v));
}
- e = f;
+ f && n && l === a - 1 && !e.length && (n = "", l = -1, h = w());
}
- return e;
+ a: {
+ n = e.length;
+ a = e;
+ if (1 < n) {
+ a = C(e, k, c, d, f);
+ } else if (1 === n) {
+ f = E.call(null, e[0], c, d);
+ break a;
+ }
+ f = a;
+ }
+ return f;
};
-function O(a, c, b, e) {
- return (a = P(this, a, c)) && a.length ? N(a, b, e) : [];
+function S(a, c, b, e, d) {
+ a = T(this, a, c);
+ d = !0;
+ return a && a.length ? d ? E.call(this, a, b, e) : new I(a) : d ? [] : new I();
}
-function Q(a, c, b, e) {
- let d = [];
- if (a) {
- e = Math.min(a.length, e);
- for (let g = 0, f; g < e; g++) {
- (f = a[g]) && f && (d[g] = f);
- }
- if (d.length) {
- c.push(d);
- return;
- }
- }
- return !b && d;
-}
-function P(a, c, b) {
+function T(a, c, b) {
let e;
- b && (e = a.bidirectional && c > b);
- a = b ? (a = a.ctx.get(e ? c : b)) && a.get(e ? b : c) : a.map.get(c);
+ b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e);
+ a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c);
return a;
}
-;K.prototype.remove = function(a, c) {
+;P.prototype.remove = function(a, c) {
const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
if (b) {
if (this.fastupdate) {
@@ -536,14 +797,14 @@ function P(a, c, b) {
}
}
} else {
- R(this.map, a), this.depth && R(this.ctx, a);
+ U(this.map, a), this.depth && U(this.ctx, a);
}
c || this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
};
-function R(a, c) {
+function U(a, c) {
let b = 0;
if (a.constructor === Array) {
for (let e = 0, d, g; e < a.length; e++) {
@@ -557,26 +818,26 @@ function R(a, c) {
}
}
} else {
- for (let e of a) {
- const d = e[0], g = R(e[1], c);
+ for (let e of a.entries()) {
+ const d = e[0], g = U(e[1], c);
g ? b += g : a.delete(d);
}
}
return b;
}
-;function K(a, c) {
- if (!this || this.constructor !== K) {
- return new K(a);
+;function P(a, c) {
+ if (!this || this.constructor !== P) {
+ return new P(a);
}
if (a) {
var b = "string" === typeof a ? a : a.preset;
- b && (J[b] || console.warn("Preset not found: " + b), a = Object.assign({}, J[b], a));
+ b && (O[b] || console.warn("Preset not found: " + b), a = Object.assign({}, O[b], a));
} else {
a = {};
}
b = a.context;
- const e = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || I;
- this.encoder = d.encode ? d : "object" === typeof d ? new E(d) : {encode:d};
+ const e = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || ha;
+ this.encoder = d.encode ? d : "object" === typeof d ? new z(d) : {encode:d};
this.resolution = a.resolution || 9;
this.tokenize = b = a.tokenize || "strict";
this.depth = "strict" === b && e.depth || 0;
@@ -587,11 +848,11 @@ function R(a, c) {
this.map = new Map();
this.ctx = new Map();
this.reg = c || (this.fastupdate ? new Map() : new Set());
- this.A = e.resolution || 3;
+ this.B = e.resolution || 3;
this.rtl = d.rtl || a.rtl || !1;
- this.cache = (b = a.cache || null) && new H(b);
+ this.cache = (b = a.cache || null) && new N(b);
}
-t = K.prototype;
+t = P.prototype;
t.clear = function() {
this.map.clear();
this.ctx.clear();
@@ -609,7 +870,7 @@ t.update = function(a, c) {
const b = this, e = this.remove(a);
return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c);
};
-function S(a) {
+function V(a) {
let c = 0;
if (a.constructor === Array) {
for (let b = 0, e; b < a.length; b++) {
@@ -617,7 +878,7 @@ function S(a) {
}
} else {
for (const b of a) {
- const e = b[0], d = S(b[1]);
+ const e = b[0], d = V(b[1]);
d ? c += d : a.delete(e);
}
}
@@ -627,13 +888,13 @@ t.cleanup = function() {
if (!this.fastupdate) {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
- S(this.map);
- this.depth && S(this.ctx);
+ V(this.map);
+ this.depth && V(this.ctx);
return this;
};
t.searchCache = function(a, c, b) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
- this.cache || (this.cache = new H());
+ this.cache || (this.cache = new N());
let e = this.cache.get(a);
if (!e) {
e = this.search(a, c, b);
@@ -648,9 +909,9 @@ t.searchCache = function(a, c, b) {
}
return e;
};
-const T = {Index:K, Charset:null, Encoder:E, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, U = self;
-let V;
-(V = U.define) && V.amd ? V([], function() {
- return T;
-}) : "object" === typeof U.exports ? U.exports = T : U.FlexSearch = T;
+const W = {Index:P, Charset:null, Encoder:z, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, X = self;
+let Z;
+(Z = X.define) && Z.amd ? Z([], function() {
+ return W;
+}) : "object" === typeof X.exports ? X.exports = W : X.FlexSearch = W;
}(this||self));
diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js
index 43024cb..92b6ffc 100644
--- a/dist/flexsearch.light.min.js
+++ b/dist/flexsearch.light.min.js
@@ -1,28 +1,34 @@
/**!
- * FlexSearch.js v0.8.103 (Light)
+ * FlexSearch.js v0.8.105 (Light)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
-(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var t;function u(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)}function x(a,c){return c.length-a.length};const y=/[^\p{L}\p{N}]+/u,z=/(\d{3})/g,A=/(\D)(\d{3})/g,B=/(\d{3})(\D)/g,D="".normalize&&/[\u0300-\u036f]/g;function E(a){if(!this||this.constructor!==E)return new E(...arguments);for(let c=0;ca.length)return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&F(this);return this};t.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.i+=(this.i?"|":"")+a;this.u=null;this.cache&&F(this);return this};
-t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&F(this);return this};t.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1this.stemmer.get(r)),k=1);f&&k&&(f.lengththis.matcher.get(r)));if(f&&this.replacer)for(d=0;f&&dthis.v&&(this.j.clear(),this.o=this.o/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.h.set(a,b),this.h.size>this.v&&(this.h.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.h.clear();a.j.clear()};function H(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.g=""}H.prototype.set=function(a,c){this.cache.set(this.g=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};H.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};H.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
-H.prototype.clear=function(){this.cache.clear();this.g=""};const I={normalize:function(a){return a.toLowerCase()},dedupe:!1};const J={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};w();K.prototype.add=function(a,c,b,e){if(c&&(a||0===a)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(e=c.length){const r=w(),q=w(),p=this.depth,n=this.resolution;for(let m=0;mg;h--){f=l.substring(g,h);var k=this.score?this.score(c,l,m,f,g):L(n,e,m,d,g);M(this,q,f,k,a,b)}break}case "reverse":if(1<
-d){for(h=d-1;0f?0:1),e,m,h-1,k-1),C=this.bidirectional&&l>g;M(this,r,C?g:l,v,a,b,C?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
-function M(a,c,b,e,d,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=w()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function L(a,c,b,e,d){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,g,f;d=f){b-=f;continue}bc&&(g=g.slice(0,c),f=g.length);else if(f>=c)return f>c&&(g=g.slice(0,c)),g;e.push(g);c-=f;if(!c)break}return e.length?e=1c||d?f.slice(d,c+d):f;f=k}else{if(kc||d)f=f.slice(d,
-c+d)}e=f}return e};function O(a,c,b,e){return(a=P(this,a,c))&&a.length?N(a,b,e):[]}function Q(a,c,b,e){let d=[];if(a){e=Math.min(a.length,e);for(let g=0,f;gb);a=b?(a=a.ctx.get(e?c:b))&&a.get(e?b:c):a.map.get(c);return a};K.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else R(this.map,a),this.depth&&R(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
-function R(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,g;eb.add(a,c)):this.add(a,c)};
-function S(a){let c=0;if(a.constructor===Array)for(let b=0,e;b"a1a".split(b).length;
+this.numeric=u(a.numeric,e)}else{try{this.split=u(this.split,y)}catch(d){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);this.rtl=u(a.rtl,!1,this.rtl);this.dedupe=u(a.dedupe,!1,this.dedupe);this.filter=u((b=a.filter)&&new Set(b),null,this.filter);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b),
+null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,0,this.maxlength);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.C="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.s=this.o=128;this.g="";this.v=null;this.h="";this.A=null;if(this.matcher)for(const d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+=(this.h?"|":"")+d;return this};
+t.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.A=null;this.cache&&C(this);return this};t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&C(this);return this};t.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.v=null;this.cache&&C(this);return this};t.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&C(this);return this};
+t.encode=function(a){if(this.cache&&a.length<=this.o)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(C,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=z?a.normalize("NFKD").replace(z,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),f.lengththis.matcher.get(k)));if(f&&this.replacer)for(d=0;f&&dthis.C&&
+(this.j.clear(),this.s=this.s/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.o&&(this.i.set(a,b),this.i.size>this.C&&(this.i.clear(),this.o=this.o/1.1|0));return b};function C(a){a.l=null;a.i.clear();a.j.clear()};function D(a,c,b,e,d){const g=a.length;let f=[],h,k;h=w();for(let l=0,n,m,r,q;l