diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b125d..34d2a2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ### Current Version +- Calling `index.clear()` on a persistent Index does not stack to the task queue by default (which executes on commit), instead it will execute immediately and return a Promise +- Added new tokenizer `tolerant`, inherits from `strict` but also matches simple typos like missing letters and swapped letters +- Improved Redis Cleanup - Resolver: Support Result Highlighting ### v0.8.2 diff --git a/README.md b/README.md index a339577..9f6d942 100644 --- a/README.md +++ b/README.md @@ -1171,6 +1171,7 @@ index.remove(0).update(1, 'foo').add(2, 'foobar'); tokenize "strict" / "exact"
+ "tolerant"
"forward"
"reverse" / "bidirectional
"full" @@ -1434,6 +1435,13 @@ Try to choose the most upper of these tokenizer which covers your requirements: 2n - 1 + + "tolerant" + index the full term by also being tolerant against typos like swapped letters and missing letters + foobra
foboar
foobr
fooba + 1 + 2(n - 2) + + "full" index every consecutive partial @@ -1510,9 +1518,9 @@ Encoding is one of the most important task and heavily influence: FlexSearch provides several methods to achieve fuzziness to make queries more tolerant: -1. Use a tokenizer: `forward`, `reverse` or `full` -2. Don't forget to use any of the builtin encoder `simple` > `balance` > `advanced` > `extra` > `soundex` (sorted by fuzziness) -3. Use one of the language specific presets e.g. `/lang/en.js` for en-US specific content +1. Use a tokenizer: `tolerant`, `forward`, `reverse` or `full` +2. Consider using any of the builtin encoder `normalize` > `balance` > `advanced` > `extra` > `soundex` (sorted by fuzziness) +3. Use one of the language-specific presets e.g. `/lang/en.js` for en-US specific content 4. Enable suggestions by passing the search option `suggest: true` Additionally, you can apply custom `Mapper`, `Replacer`, `Stemmer`, `Filter` or by assigning a custom `normalize(str)`, `prepare(str)` or `finalize(arr)` function to the Encoder. diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index f314411..d1eff5b 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.202 (Bundle/Debug) + * FlexSearch.js v0.8.203 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -7,30 +7,30 @@ */ (function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f; var w; -function H(a, b, c) { - const e = typeof c, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { - if (c) { - if ("function" === d && e === d) { +function H(a, c, b) { + const e = typeof b, d = typeof a; + if (e !== "undefined") { + if (d !== "undefined") { + if (b) { + if (d === "function" && e === d) { return function(k) { - return a(c(k)); + return a(b(k)); }; } - b = a.constructor; - if (b === c.constructor) { - if (b === Array) { - return c.concat(a); + c = a.constructor; + if (c === b.constructor) { + if (c === Array) { + return b.concat(a); } - if (b === Map) { - var f = new Map(c); + if (c === Map) { + var f = new Map(b); for (var g of a) { f.set(g[0], g[1]); } return f; } - if (b === Set) { - g = new Set(c); + if (c === Set) { + g = new Set(b); for (f of a.values()) { g.add(f); } @@ -40,35 +40,35 @@ function H(a, b, c) { } return a; } - return c; + return b; } - return "undefined" === d ? b : a; + return d === "undefined" ? c : a; } -function aa(a, b) { - return "undefined" === typeof a ? b : a; +function aa(a, c) { + return typeof a === "undefined" ? c : a; } function I() { return Object.create(null); } function N(a) { - return "string" === typeof a; + return typeof a === "string"; } function ba(a) { - return "object" === typeof a; + return typeof a === "object"; } function ca(a) { - const b = []; - for (const c of a.keys()) { - b.push(c); + const c = []; + for (const b of a.keys()) { + c.push(b); } - return b; + return c; } -function da(a, b) { - if (N(b)) { - a = a[b]; +function da(a, c) { + if (N(c)) { + a = a[c]; } else { - for (let c = 0; a && c < b.length; c++) { - a = a[b[c]]; + for (let b = 0; a && b < c.length; b++) { + a = a[c[b]]; } } return a; @@ -89,27 +89,27 @@ function la(a = {}) { w = la.prototype; w.assign = function(a) { this.normalize = H(a.normalize, !0, this.normalize); - let b = a.include, c = b || a.exclude || a.split, e; - if (c || "" === c) { - if ("object" === typeof c && c.constructor !== RegExp) { + let c = a.include, b = c || a.exclude || a.split, e; + if (b || b === "") { + if (typeof b === "object" && b.constructor !== RegExp) { let d = ""; - e = !b; - b || (d += "\\p{Z}"); - c.letter && (d += "\\p{L}"); - c.number && (d += "\\p{N}", e = !!b); - c.symbol && (d += "\\p{S}"); - c.punctuation && (d += "\\p{P}"); - c.control && (d += "\\p{C}"); - if (c = c.char) { - d += "object" === typeof c ? c.join("") : c; + e = !c; + c || (d += "\\p{Z}"); + b.letter && (d += "\\p{L}"); + b.number && (d += "\\p{N}", e = !!c); + b.symbol && (d += "\\p{S}"); + b.punctuation && (d += "\\p{P}"); + b.control && (d += "\\p{C}"); + if (b = b.char) { + d += typeof b === "object" ? b.join("") : b; } try { - this.split = new RegExp("[" + (b ? "^" : "") + d + "]+", "u"); + this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); } catch (f) { - console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; + console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = c, e = !1 === c || 2 > "a1a".split(c).length; + this.split = b, e = b === !1 || "a1a".split(b).length < 2; } this.numeric = H(a.numeric, e); } else { @@ -122,23 +122,23 @@ w.assign = function(a) { } this.prepare = H(a.prepare, null, this.prepare); this.finalize = H(a.finalize, null, this.finalize); - c = a.filter; - this.filter = "function" === typeof c ? c : H(c && new Set(c), null, this.filter); + b = a.filter; + this.filter = typeof b === "function" ? b : H(b && new Set(b), null, this.filter); this.dedupe = H(a.dedupe, !0, this.dedupe); - 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.matcher = H((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = H((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = H((b = a.stemmer) && new Map(b), null, this.stemmer); this.replacer = H(a.replacer, null, this.replacer); this.minlength = H(a.minlength, 1, this.minlength); this.maxlength = H(a.maxlength, 1024, this.maxlength); this.rtl = H(a.rtl, !1, this.rtl); - if (this.cache = c = H(a.cache, !0, this.cache)) { - this.I = null, this.R = "number" === typeof c ? c : 2e5, this.C = new Map(), this.H = new Map(), this.M = this.L = 128; + if (this.cache = b = H(a.cache, !0, this.cache)) { + this.F = null, this.L = typeof b === "number" ? b : 2e5, this.B = new Map(), this.D = new Map(), this.I = this.H = 128; } this.h = ""; - this.N = null; - this.B = ""; - this.O = null; + this.J = null; + this.A = ""; + this.K = null; if (this.matcher) { for (const d of this.matcher.keys()) { this.h += (this.h ? "|" : "") + d; @@ -146,254 +146,254 @@ w.assign = function(a) { } if (this.stemmer) { for (const d of this.stemmer.keys()) { - this.B += (this.B ? "|" : "") + d; + this.A += (this.A ? "|" : "") + d; } } return this; }; -w.addStemmer = function(a, b) { +w.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, b); - this.B += (this.B ? "|" : "") + a; - this.O = null; - this.cache && Q(this); + this.stemmer.set(a, c); + this.A += (this.A ? "|" : "") + a; + this.K = null; + this.cache && ma(this); return this; }; w.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); - this.cache && Q(this); + typeof a === "function" ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); + this.cache && ma(this); return this; }; -w.addMapper = function(a, b) { - if ("object" === typeof a) { - return this.addReplacer(a, b); +w.addMapper = function(a, c) { + if (typeof a === "object") { + return this.addReplacer(a, c); } - if (1 < a.length) { - return this.addMatcher(a, b); + if (a.length > 1) { + return this.addMatcher(a, c); } this.mapper || (this.mapper = new Map()); - this.mapper.set(a, b); - this.cache && Q(this); + this.mapper.set(a, c); + this.cache && ma(this); return this; }; -w.addMatcher = function(a, b) { - if ("object" === typeof a) { - return this.addReplacer(a, b); +w.addMatcher = function(a, c) { + if (typeof a === "object") { + return this.addReplacer(a, c); } - if (2 > a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, b); + if (a.length < 2 && (this.dedupe || this.mapper)) { + return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, b); + this.matcher.set(a, c); this.h += (this.h ? "|" : "") + a; - this.N = null; - this.cache && Q(this); + this.J = null; + this.cache && ma(this); return this; }; -w.addReplacer = function(a, b) { - if ("string" === typeof a) { - return this.addMatcher(a, b); +w.addReplacer = function(a, c) { + if (typeof a === "string") { + return this.addMatcher(a, c); } this.replacer || (this.replacer = []); - this.replacer.push(a, b); - this.cache && Q(this); + this.replacer.push(a, c); + this.cache && ma(this); return this; }; -w.encode = function(a, b) { - if (this.cache && a.length <= this.L) { - if (this.I) { - if (this.C.has(a)) { - return this.C.get(a); +w.encode = function(a, c) { + if (this.cache && a.length <= this.H) { + if (this.F) { + if (this.B.has(a)) { + return this.B.get(a); } } else { - this.I = setTimeout(Q, 50, this); + this.F = setTimeout(ma, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase()); + this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(ia, "$1 $2").replace(ja, "$1 $2").replace(ha, "$1 ")); - const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let e = [], d = I(), f, g, k = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let l = 0, m, r; l < k.length; l++) { - if ((m = r = k[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { - if (b) { - if (d[m]) { - continue; - } - d[m] = 1; - } else { - if (f === m) { - continue; - } - f = m; - } + this.numeric && a.length > 3 && (a = a.replace(ia, "$1 $2").replace(ja, "$1 $2").replace(ha, "$1 ")); + const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let e = [], d = I(), f, g, k = this.split || this.split === "" ? a.split(this.split) : [a]; + for (let l = 0, n, q; l < k.length; l++) { + if ((n = q = k[l]) && !(n.length < this.minlength || n.length > this.maxlength)) { if (c) { - e.push(m); + if (d[n]) { + continue; + } + d[n] = 1; } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(m) : !this.filter.has(m))) { - if (this.cache && m.length <= this.M) { - if (this.I) { - var h = this.H.get(m); - if (h || "" === h) { + if (f === n) { + continue; + } + f = n; + } + if (b) { + e.push(n); + } else { + if (!this.filter || (typeof this.filter === "function" ? this.filter(n) : !this.filter.has(n))) { + if (this.cache && n.length <= this.I) { + if (this.F) { + var h = this.D.get(n); + if (h || h === "") { h && e.push(h); continue; } } else { - this.I = setTimeout(Q, 50, this); + this.F = setTimeout(ma, 50, this); } } if (this.stemmer) { - this.O || (this.O = new RegExp("(?!^)(" + this.B + ")$")); - let t; - for (; t !== m && 2 < m.length;) { - t = m, m = m.replace(this.O, q => this.stemmer.get(q)); + this.K || (this.K = new RegExp("(?!^)(" + this.A + ")$")); + let u; + for (; u !== n && n.length > 2;) { + u = n, n = n.replace(this.K, r => this.stemmer.get(r)); } } - if (m && (this.mapper || this.dedupe && 1 < m.length)) { + if (n && (this.mapper || this.dedupe && n.length > 1)) { h = ""; - for (let t = 0, q = "", u, n; t < m.length; t++) { - u = m.charAt(t), u === q && this.dedupe || ((n = this.mapper && this.mapper.get(u)) || "" === n ? n === q && this.dedupe || !(q = n) || (h += n) : h += q = u); + for (let u = 0, r = "", t, m; u < n.length; u++) { + t = n.charAt(u), t === r && this.dedupe || ((m = this.mapper && this.mapper.get(t)) || m === "" ? m === r && this.dedupe || !(r = m) || (h += m) : h += r = t); } - m = h; + n = h; } - this.matcher && 1 < m.length && (this.N || (this.N = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.N, t => this.matcher.get(t))); - if (m && this.replacer) { - for (h = 0; m && h < this.replacer.length; h += 2) { - m = m.replace(this.replacer[h], this.replacer[h + 1]); + this.matcher && n.length > 1 && (this.J || (this.J = new RegExp("(" + this.h + ")", "g")), n = n.replace(this.J, u => this.matcher.get(u))); + if (n && this.replacer) { + for (h = 0; n && h < this.replacer.length; h += 2) { + n = n.replace(this.replacer[h], this.replacer[h + 1]); } } - this.cache && r.length <= this.M && (this.H.set(r, m), this.H.size > this.R && (this.H.clear(), this.M = this.M / 1.1 | 0)); - if (m) { - if (m !== r) { - if (b) { - if (d[m]) { + this.cache && q.length <= this.I && (this.D.set(q, n), this.D.size > this.L && (this.D.clear(), this.I = this.I / 1.1 | 0)); + if (n) { + if (n !== q) { + if (c) { + if (d[n]) { continue; } - d[m] = 1; + d[n] = 1; } else { - if (g === m) { + if (g === n) { continue; } - g = m; + g = n; } } - e.push(m); + e.push(n); } } } } } this.finalize && (e = this.finalize(e) || e); - this.cache && a.length <= this.L && (this.C.set(a, e), this.C.size > this.R && (this.C.clear(), this.L = this.L / 1.1 | 0)); + this.cache && a.length <= this.H && (this.B.set(a, e), this.B.size > this.L && (this.B.clear(), this.H = this.H / 1.1 | 0)); return e; }; -function Q(a) { - a.I = null; - a.C.clear(); - a.H.clear(); +function ma(a) { + a.F = null; + a.B.clear(); + a.D.clear(); } -;function ma(a, b, c) { - c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : c = a); - c && (a = c.query || a, b = c.limit || b); - let e = "" + (b || 0); - c && (e += (c.offset || 0) + !!c.context + !!c.suggest + (!1 !== c.resolve) + (c.resolution || this.resolution) + (c.boost || 0)); +;function na(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : b = a); + b && (a = b.query || a, c = b.limit || c); + let e = "" + (c || 0); + b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (b.resolve !== !1) + (b.resolution || this.resolution) + (b.boost || 0)); a = ("" + a).toLowerCase(); - this.cache || (this.cache = new na()); + this.cache || (this.cache = new oa()); let d = this.cache.get(a + e); if (!d) { - const f = c && c.cache; - f && (c.cache = !1); - d = this.search(a, b, c); - f && (c.cache = f); + const f = b && b.cache; + f && (b.cache = !1); + d = this.search(a, c, b); + f && (b.cache = f); this.cache.set(a + e, d); } return d; } -function na(a) { - this.limit = a && !0 !== a ? a : 1000; +function oa(a) { + this.limit = a && a !== !0 ? a : 1000; this.cache = new Map(); this.h = ""; } -na.prototype.set = function(a, b) { - this.cache.set(this.h = a, b); +oa.prototype.set = function(a, c) { + this.cache.set(this.h = a, c); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -na.prototype.get = function(a) { - const b = this.cache.get(a); - b && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, b)); - return b; +oa.prototype.get = function(a) { + const c = this.cache.get(a); + c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c)); + return c; }; -na.prototype.remove = function(a) { - for (const b of this.cache) { - const c = b[0]; - b[1].includes(a) && this.cache.delete(c); +oa.prototype.remove = function(a) { + for (const c of this.cache) { + const b = c[0]; + c[1].includes(a) && this.cache.delete(b); } }; -na.prototype.clear = function() { +oa.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const qa = {normalize:!1, numeric:!1, dedupe:!1}; -const ra = {}; -const sa = 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"]]); -const ta = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), ua = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const va = {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 wa = {Exact:qa, Default:ra, Normalize:ra, LatinBalance:{mapper:sa}, LatinAdvanced:{mapper:sa, matcher:ta, replacer:ua}, LatinExtra:{mapper:sa, replacer:ua.concat([/(?!^)[aeo]/g, ""]), matcher:ta}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let c = 0; c < a.length; c++) { - var b = a[c]; - let e = b.charAt(0), d = va[e]; - for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = va[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { +const ra = {normalize:!1, numeric:!1, dedupe:!1}; +const sa = {}; +const ta = 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"]]); +const ua = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), va = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const wa = {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 xa = {Exact:ra, Default:sa, Normalize:sa, LatinBalance:{mapper:ta}, LatinAdvanced:{mapper:ta, matcher:ua, replacer:va}, LatinExtra:{mapper:ta, replacer:va.concat([/(?!^)[aeo]/g, ""]), matcher:ua}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { + for (let b = 0; b < a.length; b++) { + var c = a[b]; + let e = c.charAt(0), d = wa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), g === "h" || g === "w" || !(g = wa[g]) || g === d || (e += g, d = g, e.length !== 4)); f++) { } - a[c] = e; + a[b] = e; } -}}, CJK:{split:""}, LatinExact:qa, LatinDefault:ra, LatinSimple:ra}; -function xa(a, b, c, e) { +}}, CJK:{split:""}, LatinExact:ra, LatinDefault:sa, LatinSimple:sa}; +function Aa(a, c, b, e) { let d = []; for (let f = 0, g; f < a.index.length; f++) { - if (g = a.index[f], b >= g.length) { - b -= g.length; + if (g = a.index[f], c >= g.length) { + c -= g.length; } else { - b = g[e ? "splice" : "slice"](b, c); - const k = b.length; - if (k && (d = d.length ? d.concat(b) : b, c -= k, e && (a.length -= k), !c)) { + c = g[e ? "splice" : "slice"](c, b); + const k = c.length; + if (k && (d = d.length ? d.concat(c) : c, b -= k, e && (a.length -= k), !b)) { break; } - b = 0; + c = 0; } } return d; } -function Aa(a) { - if (!this || this.constructor !== Aa) { - return new Aa(a); +function Ba(a) { + if (!this || this.constructor !== Ba) { + return new Ba(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; - const b = this; - return new Proxy([], {get(c, e) { - if ("length" === e) { - return b.length; + const c = this; + return new Proxy([], {get(b, e) { + if (e === "length") { + return c.length; } - if ("push" === e) { + if (e === "push") { return function(d) { - b.index[b.index.length - 1].push(d); - b.length++; + c.index[c.index.length - 1].push(d); + c.length++; }; } - if ("pop" === e) { + if (e === "pop") { return function() { - if (b.length) { - return b.length--, b.index[b.index.length - 1].pop(); + if (c.length) { + return c.length--, c.index[c.index.length - 1].pop(); } }; } - if ("indexOf" === e) { + if (e === "indexOf") { return function(d) { let f = 0; - for (let g = 0, k, h; g < b.index.length; g++) { - k = b.index[g]; + for (let g = 0, k, h; g < c.index.length; g++) { + k = c.index[g]; h = k.indexOf(d); - if (0 <= h) { + if (h >= 0) { return f + h; } f += k.length; @@ -401,46 +401,61 @@ function Aa(a) { return -1; }; } - if ("includes" === e) { + if (e === "includes") { return function(d) { - for (let f = 0; f < b.index.length; f++) { - if (b.index[f].includes(d)) { + for (let f = 0; f < c.index.length; f++) { + if (c.index[f].includes(d)) { return !0; } } return !1; }; } - if ("slice" === e) { + if (e === "slice") { return function(d, f) { - return xa(b, d || 0, f || b.length, !1); + return Aa(c, d || 0, f || c.length, !1); }; } - if ("splice" === e) { + if (e === "splice") { return function(d, f) { - return xa(b, d || 0, f || b.length, !0); + return Aa(c, d || 0, f || c.length, !0); }; } - if ("constructor" === e) { + if (e === "constructor") { return Array; } - if ("symbol" !== typeof e) { - return (c = b.index[e / 2 ** 31 | 0]) && c[e]; + if (typeof e !== "symbol") { + return (b = c.index[e / 2 ** 31 | 0]) && b[e]; } - }, set(c, e, d) { - c = e / 2 ** 31 | 0; - (b.index[c] || (b.index[c] = []))[e] = d; - b.length++; + }, set(b, e, d) { + b = e / 2 ** 31 | 0; + (c.index[b] || (c.index[b] = []))[e] = d; + c.length++; return !0; }}); } -Aa.prototype.clear = function() { +Ba.prototype.clear = function() { this.index.length = 0; }; -Aa.prototype.destroy = function() { - this.proxy = this.index = null; +Ba.prototype.push = function() { }; -Aa.prototype.push = function() { +function Q(a = 8) { + if (!this || this.constructor !== Q) { + return new Q(a); + } + this.index = I(); + this.h = []; + this.size = 0; + a > 32 ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); +} +Q.prototype.get = function(a) { + const c = this.index[this.B(a)]; + return c && c.get(a); +}; +Q.prototype.set = function(a, c) { + var b = this.B(a); + let e = this.index[b]; + e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = new Map([[a, c]]), this.h.push(e), this.size++); }; function R(a = 8) { if (!this || this.constructor !== R) { @@ -449,164 +464,146 @@ function R(a = 8) { this.index = I(); this.h = []; this.size = 0; - 32 < a ? (this.C = Ba, this.B = BigInt(a)) : (this.C = Ca, this.B = a); + a > 32 ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); } -R.prototype.get = function(a) { - const b = this.index[this.C(a)]; - return b && b.get(a); +R.prototype.add = function(a) { + var c = this.B(a); + let b = this.index[c]; + b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = new Set([a]), this.h.push(b), this.size++); }; -R.prototype.set = function(a, b) { - var c = this.C(a); - let e = this.index[c]; - e ? (c = e.size, e.set(a, b), (c -= e.size) && this.size++) : (this.index[c] = e = new Map([[a, b]]), this.h.push(e), this.size++); +w = Q.prototype; +w.has = R.prototype.has = function(a) { + const c = this.index[this.B(a)]; + return c && c.has(a); }; -function S(a = 8) { - if (!this || this.constructor !== S) { - return new S(a); - } - this.index = I(); - this.h = []; - this.size = 0; - 32 < a ? (this.C = Ba, this.B = BigInt(a)) : (this.C = Ca, this.B = a); -} -S.prototype.add = function(a) { - var b = this.C(a); - let c = this.index[b]; - c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); +w.delete = R.prototype.delete = function(a) { + const c = this.index[this.B(a)]; + c && c.delete(a) && this.size--; }; -w = R.prototype; -w.has = S.prototype.has = function(a) { - const b = this.index[this.C(a)]; - return b && b.has(a); -}; -w.delete = S.prototype.delete = function(a) { - const b = this.index[this.C(a)]; - b && b.delete(a) && this.size--; -}; -w.clear = S.prototype.clear = function() { +w.clear = R.prototype.clear = function() { this.index = I(); this.h = []; this.size = 0; }; -w.values = S.prototype.values = function*() { +w.values = R.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { - for (let b of this.h[a].values()) { - yield b; + for (let c of this.h[a].values()) { + yield c; } } }; -w.keys = S.prototype.keys = function*() { +w.keys = R.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { - for (let b of this.h[a].keys()) { - yield b; + for (let c of this.h[a].keys()) { + yield c; } } }; -w.entries = S.prototype.entries = function*() { +w.entries = R.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { - for (let b of this.h[a].entries()) { - yield b; + for (let c of this.h[a].entries()) { + yield c; } } }; +function Da(a) { + let c = 2 ** this.A - 1; + if (typeof a == "number") { + return a & c; + } + let b = 0, e = this.A + 1; + for (let d = 0; d < a.length; d++) { + b = (b * e ^ a.charCodeAt(d)) & c; + } + return this.A === 32 ? b + 2 ** 31 : b; +} function Ca(a) { - let b = 2 ** this.B - 1; - if ("number" == typeof a) { - return a & b; + let c = BigInt(2) ** this.A - BigInt(1); + var b = typeof a; + if (b === "bigint") { + return a & c; } - let c = 0, e = this.B + 1; + if (b === "number") { + return BigInt(a) & c; + } + b = BigInt(0); + let e = this.A + BigInt(1); for (let d = 0; d < a.length; d++) { - c = (c * e ^ a.charCodeAt(d)) & b; + b = (b * e ^ BigInt(a.charCodeAt(d))) & c; } - return 32 === this.B ? c + 2 ** 31 : c; + return b; } -function Ba(a) { - let b = BigInt(2) ** this.B - BigInt(1); - var c = typeof a; - if ("bigint" === c) { - return a & b; - } - if ("number" === c) { - return BigInt(a) & b; - } - c = BigInt(0); - let e = this.B + BigInt(1); - for (let d = 0; d < a.length; d++) { - c = (c * e ^ BigInt(a.charCodeAt(d))) & b; - } - return c; -} -;let Da, T; -async function Ea(a) { +;let Ea, S; +async function Fa(a) { a = a.data; - var b = a.task; - const c = a.id; + var c = a.task; + const b = a.id; let e = a.args; - switch(b) { + switch(c) { case "init": - T = a.options || {}; - (b = a.factory) ? (Function("return " + b)()(self), Da = new self.FlexSearch.Index(T), delete self.FlexSearch) : Da = new V(T); - postMessage({id:c}); + S = a.options || {}; + (c = a.factory) ? (Function("return " + c)()(self), Ea = new self.FlexSearch.Index(S), delete self.FlexSearch) : Ea = new T(S); + postMessage({id:b}); break; default: let d; - if ("export" === b) { - if (!T.export || "function" !== typeof T.export) { + if (c === "export") { + if (!S.export || typeof S.export !== "function") { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } - e[1] ? (e[0] = T.export, e[2] = 0, e[3] = 1) : e = null; + e[1] ? (e[0] = S.export, e[2] = 0, e[3] = 1) : e = null; } - if ("import" === b) { - if (!T.import || "function" !== typeof T.import) { + if (c === "import") { + if (!S.import || typeof S.import !== "function") { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } - e[0] && (a = await T.import.call(Da, e[0]), Da.import(e[0], a)); + e[0] && (a = await S.import.call(Ea, e[0]), Ea.import(e[0], a)); } else { - (d = e && Da[b].apply(Da, e)) && d.then && (d = await d), d && d.await && (d = await d.await), "search" === b && d.result && (d = d.result); + (d = e && Ea[c].apply(Ea, e)) && d.then && (d = await d), d && d.await && (d = await d.await), c === "search" && d.result && (d = d.result); } - postMessage("search" === b ? {id:c, msg:d} : {id:c}); + postMessage(c === "search" ? {id:b, msg:d} : {id:b}); } } -;function Fa(a) { - Ga.call(a, "add"); - Ga.call(a, "append"); - Ga.call(a, "search"); - Ga.call(a, "update"); - Ga.call(a, "remove"); - Ga.call(a, "searchCache"); +;function Ga(a) { + Ha.call(a, "add"); + Ha.call(a, "append"); + Ha.call(a, "search"); + Ha.call(a, "update"); + Ha.call(a, "remove"); + Ha.call(a, "searchCache"); } -let Ha, Ia, Ja; -function Ka() { - Ha = Ja = 0; +let Ia, Ja, Ka; +function La() { + Ia = Ka = 0; } -function Ga(a) { +function Ha(a) { this[a + "Async"] = function() { - const b = arguments; - var c = b[b.length - 1]; + const c = arguments; + var b = c[c.length - 1]; let e; - "function" === typeof c && (e = c, delete b[b.length - 1]); - Ha ? Ja || (Ja = Date.now() - Ia >= this.priority * this.priority * 3) : (Ha = setTimeout(Ka, 0), Ia = Date.now()); - if (Ja) { + typeof b === "function" && (e = b, delete c[c.length - 1]); + Ia ? Ka || (Ka = Date.now() - Ja >= this.priority * this.priority * 3) : (Ia = setTimeout(La, 0), Ja = Date.now()); + if (Ka) { const f = this; return new Promise(g => { setTimeout(function() { - g(f[a + "Async"].apply(f, b)); + g(f[a + "Async"].apply(f, c)); }, 0); }); } - const d = this[a].apply(this, b); - c = d.then ? d : new Promise(f => f(d)); - e && c.then(e); - return c; + const d = this[a].apply(this, c); + b = d.then ? d : new Promise(f => f(d)); + e && b.then(e); + return b; }; } -;let W = 0; -function La(a = {}, b) { - function c(k) { +;let V = 0; +function Ma(a = {}, c) { + function b(k) { function h(l) { l = l.data || l; - const m = l.id, r = m && f.h[m]; - r && (r(l.msg), delete f.h[m]); + const n = l.id, q = n && f.h[n]; + q && (q(l.msg), delete f.h[n]); } this.worker = k; this.h = I(); @@ -614,109 +611,109 @@ function La(a = {}, b) { d ? this.worker.on("message", h) : this.worker.onmessage = h; if (a.config) { return new Promise(function(l) { - 1e9 < W && (W = 0); - f.h[++W] = function() { + V > 1e9 && (V = 0); + f.h[++V] = function() { l(f); }; - f.worker.postMessage({id:W, task:"init", factory:e, options:a}); + f.worker.postMessage({id:V, task:"init", factory:e, options:a}); }); } this.priority = a.priority || 4; - this.encoder = b || null; + this.encoder = c || null; this.worker.postMessage({task:"init", factory:e, options:a}); return this; } console.warn("Worker is not available on this platform. Please report on Github: https://github.com/nextapps-de/flexsearch/issues"); } - if (!this || this.constructor !== La) { - return new La(a); + if (!this || this.constructor !== Ma) { + return new Ma(a); } - let e = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + let e = typeof self !== "undefined" ? self._factory : typeof window !== "undefined" ? window._factory : null; e && (e = e.toString()); - const d = "undefined" === typeof window, f = this, g = Ma(e, d, a.worker); + const d = typeof window === "undefined", f = this, g = Na(e, d, a.worker); return g.then ? g.then(function(k) { - return c.call(f, k); - }) : c.call(this, g); + return b.call(f, k); + }) : b.call(this, g); } -X("add"); -X("append"); -X("search"); -X("update"); -X("remove"); -X("clear"); -X("export"); -X("import"); -La.prototype.searchCache = ma; -Fa(La.prototype); -function X(a) { - La.prototype[a] = function() { - const b = this, c = [].slice.call(arguments); - var e = c[c.length - 1]; +W("add"); +W("append"); +W("search"); +W("update"); +W("remove"); +W("clear"); +W("export"); +W("import"); +Ma.prototype.searchCache = na; +Ga(Ma.prototype); +function W(a) { + Ma.prototype[a] = function() { + const c = this, b = [].slice.call(arguments); + var e = b[b.length - 1]; let d; - "function" === typeof e && (d = e, c.pop()); + typeof e === "function" && (d = e, b.pop()); e = new Promise(function(f) { - "export" === a && "function" === typeof c[0] && (c[0] = null); - 1e9 < W && (W = 0); - b.h[++W] = f; - b.worker.postMessage({task:a, id:W, args:c}); + a === "export" && typeof b[0] === "function" && (b[0] = null); + V > 1e9 && (V = 0); + c.h[++V] = f; + c.worker.postMessage({task:a, id:V, args:b}); }); return d ? (e.then(d), this) : e; }; } -function Ma(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=" + Ea.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function Na(a, c, b) { + return c ? typeof module !== "undefined" ? 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=" + Fa.toString()], {type:"text/javascript"}))) : new window.Worker(typeof b === "string" ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;Na.prototype.add = function(a, b, c) { - ba(a) && (b = a, a = da(b, this.key)); - if (b && (a || 0 === a)) { - if (!c && this.reg.has(a)) { - return this.update(a, b); +;Oa.prototype.add = function(a, c, b) { + ba(a) && (c = a, a = da(c, this.key)); + if (c && (a || a === 0)) { + if (!b && this.reg.has(a)) { + return this.update(a, c); } for (let k = 0, h; k < this.field.length; k++) { - h = this.G[k]; + h = this.B[k]; var e = this.index.get(this.field[k]); - if ("function" === typeof h) { - var d = h(b); + if (typeof h === "function") { + var d = h(c); d && e.add(a, d, !1, !0); } else { - if (d = h.J, !d || d(b)) { - h.constructor === String ? h = ["" + h] : N(h) && (h = [h]), Oa(b, h, this.K, 0, e, a, h[0], c); + if (d = h.G, !d || d(c)) { + h.constructor === String ? h = ["" + h] : N(h) && (h = [h]), Ra(c, h, this.D, 0, e, a, h[0], b); } } } if (this.tag) { - for (e = 0; e < this.F.length; e++) { - var f = this.F[e], g = this.P[e]; + for (e = 0; e < this.A.length; e++) { + var f = this.A[e], g = this.F[e]; d = this.tag.get(g); let k = I(); - if ("function" === typeof f) { - if (f = f(b), !f) { + if (typeof f === "function") { + if (f = f(c), !f) { continue; } } else { - const h = f.J; - if (h && !h(b)) { + const h = f.G; + if (h && !h(c)) { continue; } f.constructor === String && (f = "" + f); - f = da(b, f); + f = da(c, f); } if (d && f) { N(f) && (f = [f]); - for (let h = 0, l, m; h < f.length; h++) { - if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !c || !m.includes(a))) { - if (m.length === 2 ** 31 - 1) { - g = new Aa(m); + for (let h = 0, l, n; h < f.length; h++) { + if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? n = g : d.set(l, n = []), !b || !n.includes(a))) { + if (n.length === 2 ** 31 - 1) { + g = new Ba(n); if (this.fastupdate) { - for (let r of this.reg.values()) { - r.includes(m) && (r[r.indexOf(m)] = g); + for (let q of this.reg.values()) { + q.includes(n) && (q[q.indexOf(n)] = g); } } - d.set(l, m = g); + d.set(l, n = g); } - m.push(a); - this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m])); + n.push(a); + this.fastupdate && ((g = this.reg.get(a)) ? g.push(n) : this.reg.set(a, [n])); } } } else { @@ -724,56 +721,56 @@ function Ma(a, b, c) { } } } - if (this.store && (!c || !this.store.has(a))) { + if (this.store && (!b || !this.store.has(a))) { let k; - if (this.D) { + if (this.h) { k = I(); - for (let h = 0, l; h < this.D.length; h++) { - l = this.D[h]; - if ((c = l.J) && !c(b)) { + for (let h = 0, l; h < this.h.length; h++) { + l = this.h[h]; + if ((b = l.G) && !b(c)) { continue; } - let m; - if ("function" === typeof l) { - m = l(b); - if (!m) { + let n; + if (typeof l === "function") { + n = l(c); + if (!n) { continue; } - l = [l.U]; + l = [l.O]; } else if (N(l) || l.constructor === String) { - k[l] = b[l]; + k[l] = c[l]; continue; } - Ra(b, k, l, 0, l[0], m); + Sa(c, k, l, 0, l[0], n); } } - this.store.set(a, k || b); + this.store.set(a, k || c); } this.worker && (this.fastupdate || this.reg.add(a)); } return this; }; -function Ra(a, b, c, e, d, f) { +function Sa(a, c, b, e, d, f) { a = a[d]; - if (e === c.length - 1) { - b[d] = f || a; + if (e === b.length - 1) { + c[d] = f || a; } else if (a) { if (a.constructor === Array) { - for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) { - Ra(a, b, c, e, d); + for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { + Sa(a, c, b, e, d); } } else { - b = b[d] || (b[d] = I()), d = c[++e], Ra(a, b, c, e, d); + c = c[d] || (c[d] = I()), d = b[++e], Sa(a, c, b, e, d); } } } -function Oa(a, b, c, e, d, f, g, k) { +function Ra(a, c, b, e, d, f, g, k) { if (a = a[g]) { - if (e === b.length - 1) { + if (e === c.length - 1) { if (a.constructor === Array) { - if (c[e]) { - for (b = 0; b < a.length; b++) { - d.add(f, a[b], !0, !0); + if (b[e]) { + for (c = 0; c < a.length; c++) { + d.add(f, a[c], !0, !0); } return; } @@ -783,247 +780,247 @@ function Oa(a, b, c, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Oa(a, b, c, e, d, f, g, k); + Ra(a, c, b, e, d, f, g, k); } } else { - g = b[++e], Oa(a, b, c, e, d, f, g, k); + g = c[++e], Ra(a, c, b, e, d, f, g, k); } } } } -;function Sa(a, b, c, e) { +;function Ta(a, c, b, e) { if (!a.length) { return a; } - if (1 === a.length) { - return a = a[0], a = c || a.length > b ? a.slice(c, c + b) : a, e ? Ta.call(this, a) : a; + if (a.length === 1) { + return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a, e ? Ua.call(this, a) : a; } let d = []; for (let f = 0, g, k; f < a.length; f++) { if ((g = a[f]) && (k = g.length)) { - if (c) { - if (c >= k) { - c -= k; + if (b) { + if (b >= k) { + b -= k; continue; } - g = g.slice(c, c + b); + g = g.slice(b, b + c); k = g.length; - c = 0; + b = 0; } - k > b && (g = g.slice(0, b), k = b); - if (!d.length && k >= b) { - return e ? Ta.call(this, g) : g; + k > c && (g = g.slice(0, c), k = c); + if (!d.length && k >= c) { + return e ? Ua.call(this, g) : g; } d.push(g); - b -= k; - if (!b) { + c -= k; + if (!c) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? Ta.call(this, d) : d; + d = d.length > 1 ? [].concat.apply([], d) : d[0]; + return e ? Ua.call(this, d) : d; } -;function Ua(a, b, c, e) { +;function Va(a, c, b, e) { var d = e[0]; if (d[0] && d[0].query) { - return a[b].apply(a, d); + return a[c].apply(a, d); } - if (!("and" !== b && "not" !== b || a.result.length || a.await || d.suggest)) { - return 1 < e.length && (d = e[e.length - 1]), (e = d.resolve) ? a.await || a.result : a; + if (!(c !== "and" && c !== "not" || a.result.length || a.await || d.suggest)) { + return e.length > 1 && (d = e[e.length - 1]), (e = d.resolve) ? a.await || a.result : a; } - let f = [], g = 0, k = 0, h, l, m, r, t; - for (b = 0; b < e.length; b++) { - if (d = e[b]) { - var q = void 0; - if (d.constructor === Y) { - q = d.await || d.result; + let f = [], g = 0, k = 0, h, l, n, q, u; + for (c = 0; c < e.length; c++) { + if (d = e[c]) { + var r = void 0; + if (d.constructor === X) { + r = d.await || d.result; } else if (d.then || d.constructor === Array) { - q = d; + r = d; } else { g = d.limit || 0; k = d.offset || 0; - m = d.suggest; - h = ((r = (l = d.resolve) && d.highlight) || d.enrich) && l; - q = d.queue; - let u = d.async || q, n = d.index; - n ? a.index || (a.index = n) : n = a.index; + n = d.suggest; + h = ((q = (l = d.resolve) && d.highlight) || d.enrich) && l; + r = d.queue; + let t = d.async || r, m = d.index; + m ? a.index || (a.index = m) : m = a.index; if (d.query || d.tag) { - if (!n) { + if (!m) { throw Error("Resolver can't apply because the corresponding Index was never specified"); } const p = d.field || d.pluck; if (p) { d.query && (a.query = d.query, a.field = p); - if (!n.index) { + if (!m.index) { throw Error("Resolver can't apply because the corresponding Document Index was not specified"); } - n = n.index.get(p); - if (!n) { + m = m.index.get(p); + if (!m) { throw Error("Resolver can't apply because the specified Document Field '" + p + "' was not found"); } } - if (q && (t || a.await)) { - t = 1; - let y; - const v = a.A.length, D = new Promise(function(B) { - y = B; + if (r && (u || a.await)) { + u = 1; + let x; + const v = a.C.length, A = new Promise(function(C) { + x = C; }); - (function(B, G) { - D.h = function() { + (function(C, G) { + A.h = function() { G.index = null; G.resolve = !1; - let A = u ? B.searchAsync(G) : B.search(G); - if (A.then) { - return A.then(function(E) { - a.A[v] = E = E.result || E; - y(E); + let B = t ? C.searchAsync(G) : C.search(G); + if (B.then) { + return B.then(function(E) { + a.C[v] = E = E.result || E; + x(E); return E; }); } - A = A.result || A; - y(A); - return A; + B = B.result || B; + x(B); + return B; }; - })(n, Object.assign({}, d)); - a.A.push(D); - f[b] = D; + })(m, Object.assign({}, d)); + a.C.push(A); + f[c] = A; continue; } else { - d.resolve = !1, d.index = null, q = u ? n.searchAsync(d) : n.search(d), d.resolve = l, d.index = n; + d.resolve = !1, d.index = null, r = t ? m.searchAsync(d) : m.search(d), d.resolve = l, d.index = m; } } else if (d.and) { - q = Va(d, "and", n); + r = Wa(d, "and", m); } else if (d.or) { - q = Va(d, "or", n); + r = Wa(d, "or", m); } else if (d.not) { - q = Va(d, "not", n); + r = Wa(d, "not", m); } else if (d.xor) { - q = Va(d, "xor", n); + r = Wa(d, "xor", m); } else { continue; } } - q.await ? (t = 1, q = q.await) : q.then ? (t = 1, q = q.then(function(u) { - return u.result || u; - })) : q = q.result || q; - f[b] = q; + r.await ? (u = 1, r = r.await) : r.then ? (u = 1, r = r.then(function(t) { + return t.result || t; + })) : r = r.result || r; + f[c] = r; } } - t && !a.await && (a.await = new Promise(function(u) { - a.return = u; + u && !a.await && (a.await = new Promise(function(t) { + a.return = t; })); - if (t) { - const u = Promise.all(f).then(function(n) { - for (let p = 0; p < a.A.length; p++) { - if (a.A[p] === u) { - a.A[p] = function() { - return c.call(a, n, g, k, h, l, m, r); + if (u) { + const t = Promise.all(f).then(function(m) { + for (let p = 0; p < a.C.length; p++) { + if (a.C[p] === t) { + a.C[p] = function() { + return b.call(a, m, g, k, h, l, n, q); }; break; } } - Wa(a); + Xa(a); }); - a.A.push(u); + a.C.push(t); } else if (a.await) { - a.A.push(function() { - return c.call(a, f, g, k, h, l, m, r); + a.C.push(function() { + return b.call(a, f, g, k, h, l, n, q); }); } else { - return c.call(a, f, g, k, h, l, m, r); + return b.call(a, f, g, k, h, l, n, q); } return l ? a.await || a.result : a; } -function Va(a, b, c) { - a = a[b]; +function Wa(a, c, b) { + a = a[c]; const e = a[0] || a; - e.index || (e.index = c); - c = new Y(e); - 1 < a.length && (c = c[b].apply(c, a.slice(1))); - return c; + e.index || (e.index = b); + b = new X(e); + a.length > 1 && (b = b[c].apply(b, a.slice(1))); + return b; } -;Y.prototype.or = function() { - return Ua(this, "or", Xa, arguments); +;X.prototype.or = function() { + return Va(this, "or", Ya, arguments); }; -function Xa(a, b, c, e, d, f, g) { - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ya(a, b, c, !1, this.h), c = 0)); +function Ya(a, c, b, e, d, f, g) { + a.length && (this.result.length && a.push(this.result), a.length < 2 ? this.result = a[0] : (this.result = Za(a, c, b, !1, this.h), b = 0)); d && (this.await = null); - return d ? this.resolve(b, c, e, g) : this; + return d ? this.resolve(c, b, e, g) : this; } -;Y.prototype.and = function() { - return Ua(this, "and", Za, arguments); +;X.prototype.and = function() { + return Va(this, "and", $a, arguments); }; -function Za(a, b, c, e, d, f, g) { +function $a(a, c, b, e, d, f, g) { if (!f && !this.result.length) { return d ? this.result : this; } let k; if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { + if (this.result.length && a.unshift(this.result), a.length < 2) { this.result = a[0]; } else { let h = 0; - for (let l = 0, m, r; l < a.length; l++) { - if ((m = a[l]) && (r = m.length)) { - h < r && (h = r); + for (let l = 0, n, q; l < a.length; l++) { + if ((n = a[l]) && (q = n.length)) { + h < q && (h = q); } else if (!f) { h = 0; break; } } - h ? (this.result = $a(a, h, b, c, f, this.h, d), k = !0) : this.result = []; + h ? (this.result = ab(a, h, c, b, f, this.h, d), k = !0) : this.result = []; } } else { f || (this.result = a); } d && (this.await = null); - return d ? this.resolve(b, c, e, g, k) : this; + return d ? this.resolve(c, b, e, g, k) : this; } -;Y.prototype.xor = function() { - return Ua(this, "xor", ab, arguments); +;X.prototype.xor = function() { + return Va(this, "xor", bb, arguments); }; -function ab(a, b, c, e, d, f, g) { +function bb(a, c, b, e, d, f, g) { if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { + if (this.result.length && a.unshift(this.result), a.length < 2) { this.result = a[0]; } else { a: { - f = c; + f = b; var k = this.h; const h = [], l = I(); - let m = 0; - for (let r = 0, t; r < a.length; r++) { - if (t = a[r]) { - m < t.length && (m = t.length); - for (let q = 0, u; q < t.length; q++) { - if (u = t[q]) { - for (let n = 0, p; n < u.length; n++) { - p = u[n], l[p] = l[p] ? 2 : 1; + let n = 0; + for (let q = 0, u; q < a.length; q++) { + if (u = a[q]) { + n < u.length && (n = u.length); + for (let r = 0, t; r < u.length; r++) { + if (t = u[r]) { + for (let m = 0, p; m < t.length; m++) { + p = t[m], l[p] = l[p] ? 2 : 1; } } } } } - for (let r = 0, t, q = 0; r < m; r++) { - for (let u = 0, n; u < a.length; u++) { - if (n = a[u]) { - if (t = n[r]) { - for (let p = 0, y; p < t.length; p++) { - if (y = t[p], 1 === l[y]) { + for (let q = 0, u, r = 0; q < n; q++) { + for (let t = 0, m; t < a.length; t++) { + if (m = a[t]) { + if (u = m[q]) { + for (let p = 0, x; p < u.length; p++) { + if (x = u[p], l[x] === 1) { if (f) { f--; } else { if (d) { - if (h.push(y), h.length === b) { + if (h.push(x), h.length === c) { a = h; break a; } } else { - const v = r + (u ? k : 0); + const v = q + (t ? k : 0); h[v] || (h[v] = []); - h[v].push(y); - if (++q === b) { + h[v].push(x); + if (++r === c) { a = h; break a; } @@ -1044,34 +1041,34 @@ function ab(a, b, c, e, d, f, g) { f || (this.result = a); } d && (this.await = null); - return d ? this.resolve(b, c, e, g, k) : this; + return d ? this.resolve(c, b, e, g, k) : this; } -;Y.prototype.not = function() { - return Ua(this, "not", bb, arguments); +;X.prototype.not = function() { + return Va(this, "not", cb, arguments); }; -function bb(a, b, c, e, d, f, g) { +function cb(a, c, b, e, d, f, g) { if (!f && !this.result.length) { return d ? this.result : this; } if (a.length && this.result.length) { a: { - f = c; + f = b; var k = []; a = new Set(a.flat().flat()); - for (let h = 0, l, m = 0; h < this.result.length; h++) { + for (let h = 0, l, n = 0; h < this.result.length; h++) { if (l = this.result[h]) { - for (let r = 0, t; r < l.length; r++) { - if (t = l[r], !a.has(t)) { + for (let q = 0, u; q < l.length; q++) { + if (u = l[q], !a.has(u)) { if (f) { f--; } else { if (d) { - if (k.push(t), k.length === b) { + if (k.push(u), k.length === c) { a = k; break a; } } else { - if (k[h] || (k[h] = []), k[h].push(t), ++m === b) { + if (k[h] || (k[h] = []), k[h].push(u), ++n === c) { a = k; break a; } @@ -1087,214 +1084,214 @@ function bb(a, b, c, e, d, f, g) { k = !0; } d && (this.await = null); - return d ? this.resolve(b, c, e, g, k) : this; + return d ? this.resolve(c, b, e, g, k) : this; } -;function cb(a, b, c, e, d) { +;function db(a, c, b, e, d) { let f, g, k; - "string" === typeof d ? (f = d, d = "") : f = d.template; + typeof d === "string" ? (f = d, d = "") : f = d.template; if (!f) { throw Error('No template pattern was specified by the search option "highlight"'); } g = f.indexOf("$1"); - if (-1 === g) { + if (g === -1) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } k = f.substring(g + 2); g = f.substring(0, g); - let h = d && d.boundary, l = !d || !1 !== d.clip, m = d && d.merge && k && g && new RegExp(k + " " + g, "g"); + let h = d && d.boundary, l = !d || d.clip !== !1, n = d && d.merge && k && g && new RegExp(k + " " + g, "g"); d = d && d.ellipsis; - var r = 0; - if ("object" === typeof d) { - var t = d.template; - r = t.length - 2; + var q = 0; + if (typeof d === "object") { + var u = d.template; + q = u.length - 2; d = d.pattern; } - "string" !== typeof d && (d = !1 === d ? "" : "..."); - r && (d = t.replace("$1", d)); - t = d.length - r; - let q, u; - "object" === typeof h && (q = h.before, 0 === q && (q = -1), u = h.after, 0 === u && (u = -1), h = h.total || 9e5); - r = new Map(); - for (let Pa = 0, ea, gb, oa; Pa < b.length; Pa++) { - let pa; + typeof d !== "string" && (d = d === !1 ? "" : "..."); + q && (d = u.replace("$1", d)); + u = d.length - q; + let r, t; + typeof h === "object" && (r = h.before, r === 0 && (r = -1), t = h.after, t === 0 && (t = -1), h = h.total || 9e5); + q = new Map(); + for (let Pa = 0, ea, gb, pa; Pa < c.length; Pa++) { + let qa; if (e) { - pa = b, oa = e; + qa = c, pa = e; } else { - var n = b[Pa]; - oa = n.field; - if (!oa) { + var m = c[Pa]; + pa = m.field; + if (!pa) { continue; } - pa = n.result; + qa = m.result; } - gb = c.get(oa); + gb = b.get(pa); ea = gb.encoder; - n = r.get(ea); - "string" !== typeof n && (n = ea.encode(a), r.set(ea, n)); - for (let ya = 0; ya < pa.length; ya++) { - var p = pa[ya].doc; + m = q.get(ea); + typeof m !== "string" && (m = ea.encode(a), q.set(ea, m)); + for (let ya = 0; ya < qa.length; ya++) { + var p = qa[ya].doc; if (!p) { continue; } - p = da(p, oa); + p = da(p, pa); if (!p) { continue; } - var y = p.trim().split(/\s+/); - if (!y.length) { + var x = p.trim().split(/\s+/); + if (!x.length) { continue; } p = ""; var v = []; let za = []; - var D = -1, B = -1, G = 0; - for (var A = 0; A < y.length; A++) { - var E = y[A], z = ea.encode(E); - z = 1 < z.length ? z.join(" ") : z[0]; - let x; + var A = -1, C = -1, G = 0; + for (var B = 0; B < x.length; B++) { + var E = x[B], z = ea.encode(E); + z = z.length > 1 ? z.join(" ") : z[0]; + let y; if (z && E) { - var C = E.length, K = (ea.split ? E.replace(ea.split, "") : E).length - z.length, F = "", L = 0; - for (var O = 0; O < n.length; O++) { - var P = n[O]; + var D = E.length, K = (ea.split ? E.replace(ea.split, "") : E).length - z.length, F = "", L = 0; + for (var O = 0; O < m.length; O++) { + var P = m[O]; if (P) { var M = P.length; M += K; - L && M <= L || (P = z.indexOf(P), -1 < P && (F = (P ? E.substring(0, P) : "") + g + E.substring(P, P + M) + k + (P + M < C ? E.substring(P + M) : ""), L = M, x = !0)); + L && M <= L || (P = z.indexOf(P), P > -1 && (F = (P ? E.substring(0, P) : "") + g + E.substring(P, P + M) + k + (P + M < D ? E.substring(P + M) : ""), L = M, y = !0)); } } - F && (h && (0 > D && (D = p.length + (p ? 1 : 0)), B = p.length + (p ? 1 : 0) + F.length, G += C, za.push(v.length), v.push({match:F})), p += (p ? " " : "") + F); + F && (h && (A < 0 && (A = p.length + (p ? 1 : 0)), C = p.length + (p ? 1 : 0) + F.length, G += D, za.push(v.length), v.push({match:F})), p += (p ? " " : "") + F); } - if (!x) { - E = y[A], p += (p ? " " : "") + E, h && v.push({text:E}); + if (!y) { + E = x[B], p += (p ? " " : "") + E, h && v.push({text:E}); } else if (h && G >= h) { break; } } G = za.length * (f.length - 2); - if (q || u || h && p.length - G > h) { - if (G = h + G - 2 * t, A = B - D, 0 < q && (A += q), 0 < u && (A += u), A <= G) { - y = q ? D - (0 < q ? q : 0) : D - ((G - A) / 2 | 0), v = u ? B + (0 < u ? u : 0) : y + G, l || (0 < y && " " !== p.charAt(y) && " " !== p.charAt(y - 1) && (y = p.indexOf(" ", y), 0 > y && (y = 0)), v < p.length && " " !== p.charAt(v - 1) && " " !== p.charAt(v) && (v = p.lastIndexOf(" ", v), v < B ? v = B : ++v)), p = (y ? d : "") + p.substring(y, v) + (v < p.length ? d : ""); + if (r || t || h && p.length - G > h) { + if (G = h + G - u * 2, B = C - A, r > 0 && (B += r), t > 0 && (B += t), B <= G) { + x = r ? A - (r > 0 ? r : 0) : A - ((G - B) / 2 | 0), v = t ? C + (t > 0 ? t : 0) : x + G, l || (x > 0 && p.charAt(x) !== " " && p.charAt(x - 1) !== " " && (x = p.indexOf(" ", x), x < 0 && (x = 0)), v < p.length && p.charAt(v - 1) !== " " && p.charAt(v) !== " " && (v = p.lastIndexOf(" ", v), v < C ? v = C : ++v)), p = (x ? d : "") + p.substring(x, v) + (v < p.length ? d : ""); } else { - B = []; - D = {}; - G = {}; + C = []; A = {}; + G = {}; + B = {}; E = {}; z = {}; - F = K = C = 0; + F = K = D = 0; for (O = L = 1;;) { var U = void 0; - for (let x = 0, J; x < za.length; x++) { - J = za[x]; + for (let y = 0, J; y < za.length; y++) { + J = za[y]; if (F) { if (K !== F) { - if (A[x + 1]) { + if (B[y + 1]) { continue; } J += F; - if (D[J]) { - C -= t; - G[x + 1] = 1; - A[x + 1] = 1; + if (A[J]) { + D -= u; + G[y + 1] = 1; + B[y + 1] = 1; continue; } if (J >= v.length - 1) { if (J >= v.length) { - A[x + 1] = 1; - J >= y.length && (G[x + 1] = 1); + B[y + 1] = 1; + J >= x.length && (G[y + 1] = 1); continue; } - C -= t; + D -= u; } p = v[J].text; - if (M = u && z[x]) { - if (0 < M) { + if (M = t && z[y]) { + if (M > 0) { if (p.length > M) { - if (A[x + 1] = 1, l) { + if (B[y + 1] = 1, l) { p = p.substring(0, M); } else { continue; } } (M -= p.length) || (M = -1); - z[x] = M; + z[y] = M; } else { - A[x + 1] = 1; + B[y + 1] = 1; continue; } } - if (C + p.length + 1 <= h) { - p = " " + p, B[x] += p; + if (D + p.length + 1 <= h) { + p = " " + p, C[y] += p; } else if (l) { - U = h - C - 1, 0 < U && (p = " " + p.substring(0, U), B[x] += p), A[x + 1] = 1; + U = h - D - 1, U > 0 && (p = " " + p.substring(0, U), C[y] += p), B[y + 1] = 1; } else { - A[x + 1] = 1; + B[y + 1] = 1; continue; } } else { - if (A[x]) { + if (B[y]) { continue; } J -= K; - if (D[J]) { - C -= t; - A[x] = 1; - G[x] = 1; + if (A[J]) { + D -= u; + B[y] = 1; + G[y] = 1; continue; } - if (0 >= J) { - if (0 > J) { - A[x] = 1; - G[x] = 1; + if (J <= 0) { + if (J < 0) { + B[y] = 1; + G[y] = 1; continue; } - C -= t; + D -= u; } p = v[J].text; - if (M = q && E[x]) { - if (0 < M) { + if (M = r && E[y]) { + if (M > 0) { if (p.length > M) { - if (A[x] = 1, l) { + if (B[y] = 1, l) { p = p.substring(p.length - M); } else { continue; } } (M -= p.length) || (M = -1); - E[x] = M; + E[y] = M; } else { - A[x] = 1; + B[y] = 1; continue; } } - if (C + p.length + 1 <= h) { - p += " ", B[x] = p + B[x]; + if (D + p.length + 1 <= h) { + p += " ", C[y] = p + C[y]; } else if (l) { - U = p.length + 1 - (h - C), 0 <= U && U < p.length && (p = p.substring(U) + " ", B[x] = p + B[x]), A[x] = 1; + U = p.length + 1 - (h - D), U >= 0 && U < p.length && (p = p.substring(U) + " ", C[y] = p + C[y]), B[y] = 1; } else { - A[x] = 1; + B[y] = 1; continue; } } } else { p = v[J].match; - q && (E[x] = q); - u && (z[x] = u); - x && C++; + r && (E[y] = r); + t && (z[y] = t); + y && D++; let Qa; - J ? !x && t && (C += t) : (G[x] = 1, A[x] = 1); - J >= y.length - 1 ? Qa = 1 : J < v.length - 1 && v[J + 1].match ? Qa = 1 : t && (C += t); - C -= f.length - 2; - if (!x || C + p.length <= h) { - B[x] = p; + J ? !y && u && (D += u) : (G[y] = 1, B[y] = 1); + J >= x.length - 1 ? Qa = 1 : J < v.length - 1 && v[J + 1].match ? Qa = 1 : u && (D += u); + D -= f.length - 2; + if (!y || D + p.length <= h) { + C[y] = p; } else { - U = L = O = G[x] = 0; + U = L = O = G[y] = 0; break; } - Qa && (G[x + 1] = 1, A[x + 1] = 1); + Qa && (G[y + 1] = 1, B[y + 1] = 1); } - C += p.length; - U = D[J] = 1; + D += p.length; + U = A[J] = 1; } if (U) { K === F ? F++ : K++; @@ -1307,39 +1304,39 @@ function bb(a, b, c, e, d, f, g) { } } p = ""; - for (let x = 0, J; x < B.length; x++) { - J = (x && G[x] ? " " : (x && !d ? " " : "") + d) + B[x], p += J; + for (let y = 0, J; y < C.length; y++) { + J = (y && G[y] ? " " : (y && !d ? " " : "") + d) + C[y], p += J; } - d && !G[B.length] && (p += d); + d && !G[C.length] && (p += d); } } - m && (p = p.replace(m, " ")); - pa[ya].highlight = p; + n && (p = p.replace(n, " ")); + qa[ya].highlight = p; } if (e) { break; } } - return b; + return c; } -;function Y(a, b) { - if (!this || this.constructor !== Y) { - return new Y(a, b); +;function X(a, c) { + if (!this || this.constructor !== X) { + return new X(a, c); } - let c = 0, e, d, f, g, k; + let b = 0, e, d, f, g, k; if (a && a.index) { const h = a; - b = h.index; - c = h.boost || 0; + c = h.index; + b = h.boost || 0; if (d = h.query) { f = h.field || h.pluck; const l = h.resolve; a = h.async || h.queue; h.resolve = !1; h.index = null; - a = a ? b.searchAsync(h) : b.search(h); + a = a ? c.searchAsync(h) : c.search(h); h.resolve = l; - h.index = b; + h.index = c; a = a.result || a; } else { a = []; @@ -1348,8 +1345,8 @@ function bb(a, b, c, e, d, f, g) { if (a && a.then) { const h = this; a = a.then(function(l) { - h.A[0] = h.result = l.result || l; - Wa(h); + h.C[0] = h.result = l.result || l; + Xa(h); }); e = [a]; a = []; @@ -1357,140 +1354,140 @@ function bb(a, b, c, e, d, f, g) { k = l; }); } - this.index = b || null; + this.index = c || null; this.result = a || []; - this.h = c; - this.A = e || []; + this.h = b; + this.C = e || []; this.await = g || null; this.return = k || null; this.query = d || ""; this.field = f || ""; } -w = Y.prototype; +w = X.prototype; w.limit = function(a) { if (this.await) { - const b = this; - this.A.push(function() { - b.limit(a); - return b.result; + const c = this; + this.C.push(function() { + c.limit(a); + return c.result; }); } else { if (this.result.length) { - const b = []; - for (let c = 0, e; c < this.result.length; c++) { - if (e = this.result[c]) { + const c = []; + for (let b = 0, e; b < this.result.length; b++) { + if (e = this.result[b]) { if (e.length <= a) { - if (b[c] = e, a -= e.length, !a) { + if (c[b] = e, a -= e.length, !a) { break; } } else { - b[c] = e.slice(0, a); + c[b] = e.slice(0, a); break; } } } - this.result = b; + this.result = c; } } return this; }; w.offset = function(a) { if (this.await) { - const b = this; - this.A.push(function() { - b.offset(a); - return b.result; + const c = this; + this.C.push(function() { + c.offset(a); + return c.result; }); } else { if (this.result.length) { - const b = []; - for (let c = 0, e; c < this.result.length; c++) { - if (e = this.result[c]) { - e.length <= a ? a -= e.length : (b[c] = e.slice(a), a = 0); + const c = []; + for (let b = 0, e; b < this.result.length; b++) { + if (e = this.result[b]) { + e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0); } } - this.result = b; + this.result = c; } } return this; }; w.boost = function(a) { if (this.await) { - const b = this; - this.A.push(function() { - b.boost(a); - return b.result; + const c = this; + this.C.push(function() { + c.boost(a); + return c.result; }); } else { this.h += a; } return this; }; -function Wa(a, b) { - let c = a.result; +function Xa(a, c) { + let b = a.result; var e = a.await; a.await = null; - for (let d = 0, f; d < a.A.length; d++) { - if (f = a.A[d]) { - if ("function" === typeof f) { - c = f(), a.A[d] = c = c.result || c, d--; + for (let d = 0, f; d < a.C.length; d++) { + if (f = a.C[d]) { + if (typeof f === "function") { + b = f(), a.C[d] = b = b.result || b, d--; } else if (f.h) { - c = f.h(), a.A[d] = c = c.result || c, d--; + b = f.h(), a.C[d] = b = b.result || b, d--; } else if (f.then) { return a.await = e; } } } e = a.return; - a.A = []; + a.C = []; a.return = null; - b || e(c); - return c; + c || e(b); + return b; } -w.resolve = function(a, b, c, e, d) { - let f = this.await ? Wa(this, !0) : this.result; +w.resolve = function(a, c, b, e, d) { + let f = this.await ? Xa(this, !0) : this.result; if (f.then) { const g = this; return f.then(function() { - return g.resolve(a, b, c, e, d); + return g.resolve(a, c, b, e, d); }); } - f.length && ("object" === typeof a ? (e = a.highlight, c = !!e || a.enrich, b = a.offset, a = a.limit) : c = !!e || c, f = d ? c ? Ta.call(this.index, f) : f : Sa.call(this.index, f, a || 100, b, c)); + f.length && (typeof a === "object" ? (e = a.highlight, b = !!e || a.enrich, c = a.offset, a = a.limit) : b = !!e || b, f = d ? b ? Ua.call(this.index, f) : f : Ta.call(this.index, f, a || 100, c, b)); return this.finalize(f, e); }; -w.finalize = function(a, b) { +w.finalize = function(a, c) { if (a.then) { const e = this; return a.then(function(d) { - return e.finalize(d, b); + return e.finalize(d, c); }); } - b && !this.query && console.warn('There was no query specified for highlighting. Please specify a query within the last resolver stage like { query: "...", resolve: true, highlight: ... }.'); - b && a.length && this.query && (a = cb(this.query, a, this.index.index, this.field, b)); - const c = this.return; - this.index = this.result = this.A = this.await = this.return = null; + c && !this.query && console.warn('There was no query specified for highlighting. Please specify a query within the last resolver stage like { query: "...", resolve: true, highlight: ... }.'); + c && a.length && this.query && (a = db(this.query, a, this.index.index, this.field, c)); + const b = this.return; + this.index = this.result = this.C = this.await = this.return = null; this.query = this.field = ""; - c && c(a); + b && b(a); return a; }; -function $a(a, b, c, e, d, f, g) { +function ab(a, c, b, e, d, f, g) { const k = a.length; - let h = [], l, m; + let h = [], l, n; l = I(); - for (let r = 0, t, q, u, n; r < b; r++) { + for (let q = 0, u, r, t, m; q < c; q++) { for (let p = 0; p < k; p++) { - if (u = a[p], r < u.length && (t = u[r])) { - for (let y = 0; y < t.length; y++) { - q = t[y]; - (m = l[q]) ? l[q]++ : (m = 0, l[q] = 1); - n = h[m] || (h[m] = []); + if (t = a[p], q < t.length && (u = t[q])) { + for (let x = 0; x < u.length; x++) { + r = u[x]; + (n = l[r]) ? l[r]++ : (n = 0, l[r] = 1); + m = h[n] || (h[n] = []); if (!g) { - let v = r + (p || !d ? 0 : f || 0); - n = n[v] || (n[v] = []); + let v = q + (p || !d ? 0 : f || 0); + m = m[v] || (m[v] = []); } - n.push(q); - if (g && c && m === k - 1 && n.length - e === c) { - return e ? n.slice(e) : n; + m.push(r); + if (g && b && n === k - 1 && m.length - e === b) { + return e ? m.slice(e) : m; } } } @@ -1498,29 +1495,29 @@ function $a(a, b, c, e, d, f, g) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Ya(h, c, e, g, f) : (h = h[0]) && c && h.length > c || e ? h.slice(e, c + e) : h; + h = h.length > 1 ? Za(h, b, e, g, f) : (h = h[0]) && b && h.length > b || e ? h.slice(e, b + e) : h; } else { if (a < k) { return []; } h = h[a - 1]; - if (c || e) { + if (b || e) { if (g) { - if (h.length > c || e) { - h = h.slice(e, c + e); + if (h.length > b || e) { + h = h.slice(e, b + e); } } else { d = []; - for (let r = 0, t; r < h.length; r++) { - if (t = h[r]) { - if (e && t.length > e) { - e -= t.length; + for (let q = 0, u; q < h.length; q++) { + if (u = h[q]) { + if (e && u.length > e) { + e -= u.length; } else { - if (c && t.length > c || e) { - t = t.slice(e, c + e), c -= t.length, e && (e -= t.length); + if (b && u.length > b || e) { + u = u.slice(e, b + e), b -= u.length, e && (e -= u.length); } - d.push(t); - if (!c) { + d.push(u); + if (!b) { break; } } @@ -1533,20 +1530,20 @@ function $a(a, b, c, e, d, f, g) { } return h; } -function Ya(a, b, c, e, d) { +function Za(a, c, b, e, d) { const f = [], g = I(); let k; var h = a.length; let l; if (e) { - for (d = h - 1; 0 <= d; d--) { + for (d = h - 1; d >= 0; d--) { if (l = (e = a[d]) && e.length) { for (h = 0; h < l; h++) { if (k = e[h], !g[k]) { - if (g[k] = 1, c) { - c--; + if (g[k] = 1, b) { + b--; } else { - if (f.push(k), f.length === b) { + if (f.push(k), f.length === c) { return f; } } @@ -1555,18 +1552,18 @@ function Ya(a, b, c, e, d) { } } } else { - for (let m = h - 1, r, t = 0; 0 <= m; m--) { - r = a[m]; - for (let q = 0; q < r.length; q++) { - if (l = (e = r[q]) && e.length) { - for (let u = 0; u < l; u++) { - if (k = e[u], !g[k]) { - if (g[k] = 1, c) { - c--; + for (let n = h - 1, q, u = 0; n >= 0; n--) { + q = a[n]; + for (let r = 0; r < q.length; r++) { + if (l = (e = q[r]) && e.length) { + for (let t = 0; t < l; t++) { + if (k = e[t], !g[k]) { + if (g[k] = 1, b) { + b--; } else { - let n = (q + (m < h - 1 ? d || 0 : 0)) / (m + 1) | 0; - (f[n] || (f[n] = [])).push(k); - if (++t === b) { + let m = (r + (n < h - 1 ? d || 0 : 0)) / (n + 1) | 0; + (f[m] || (f[m] = [])).push(k); + if (++u === c) { return f; } } @@ -1578,75 +1575,75 @@ function Ya(a, b, c, e, d) { } return f; } -function db(a, b, c) { +function eb(a, c, b) { const e = I(), d = []; - for (let f = 0, g; f < b.length; f++) { - g = b[f]; + for (let f = 0, g; f < c.length; f++) { + g = c[f]; for (let k = 0; k < g.length; k++) { e[g[k]] = 1; } } - if (c) { + if (b) { for (let f = 0, g; f < a.length; f++) { g = a[f], e[g] && (d.push(g), e[g] = 0); } } else { for (let f = 0, g, k; f < a.result.length; f++) { - for (g = a.result[f], b = 0; b < g.length; b++) { - k = g[b], e[k] && ((d[f] || (d[f] = [])).push(k), e[k] = 0); + for (g = a.result[f], c = 0; c < g.length; c++) { + k = g[c], e[k] && ((d[f] || (d[f] = [])).push(k), e[k] = 0); } } } return d; } ;I(); -Na.prototype.search = function(a, b, c, e) { - c || (!b && ba(a) ? (c = a, a = "") : ba(b) && (c = b, b = 0)); +Oa.prototype.search = function(a, c, b, e) { + b || (!c && ba(a) ? (b = a, a = "") : ba(c) && (b = c, c = 0)); let d = []; var f = []; let g; - let k, h, l, m, r; - let t = 0, q = !0, u; - if (c) { - c.constructor === Array && (c = {index:c}); - a = c.query || a; - g = c.pluck; - k = c.merge; - l = c.boost; - r = g || c.field || (r = c.index) && (r.index ? null : r); - var n = this.tag && c.tag; - h = c.suggest; - q = !1 !== c.resolve; - m = c.cache; - this.store && c.highlight && !q ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && c.enrich && !q && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - u = q && this.store && c.highlight; - var p = !!u || q && this.store && c.enrich; - b = c.limit || b; - var y = c.offset || 0; - b || (b = q ? 100 : 0); - if (n && (!this.db || !e)) { - n.constructor !== Array && (n = [n]); + let k, h, l, n, q; + let u = 0, r = !0, t; + if (b) { + b.constructor === Array && (b = {index:b}); + a = b.query || a; + g = b.pluck; + k = b.merge; + l = b.boost; + q = g || b.field || (q = b.index) && (q.index ? null : q); + var m = this.tag && b.tag; + h = b.suggest; + r = b.resolve !== !1; + n = b.cache; + this.store && b.highlight && !r ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !r && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + t = r && this.store && b.highlight; + var p = !!t || r && this.store && b.enrich; + c = b.limit || c; + var x = b.offset || 0; + c || (c = r ? 100 : 0); + if (m && (!this.db || !e)) { + m.constructor !== Array && (m = [m]); var v = []; - for (let E = 0, z; E < n.length; E++) { - z = n[E]; + for (let E = 0, z; E < m.length; E++) { + z = m[E]; if (N(z)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } if (z.field && z.tag) { - var D = z.tag; - if (D.constructor === Array) { - for (var B = 0; B < D.length; B++) { - v.push(z.field, D[B]); + var A = z.tag; + if (A.constructor === Array) { + for (var C = 0; C < A.length; C++) { + v.push(z.field, A[C]); } } else { - v.push(z.field, D); + v.push(z.field, A); } } else { - D = Object.keys(z); - for (let C = 0, K, F; C < D.length; C++) { - if (K = D[C], F = z[K], F.constructor === Array) { - for (B = 0; B < F.length; B++) { - v.push(K, F[B]); + A = Object.keys(z); + for (let D = 0, K, F; D < A.length; D++) { + if (K = A[D], F = z[K], F.constructor === Array) { + for (C = 0; C < F.length; C++) { + v.push(K, F[C]); } } else { v.push(K, F); @@ -1657,245 +1654,245 @@ Na.prototype.search = function(a, b, c, e) { if (!v.length) { throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); } - n = v; + m = v; if (!a) { f = []; if (v.length) { - for (n = 0; n < v.length; n += 2) { + for (m = 0; m < v.length; m += 2) { if (this.db) { - e = this.index.get(v[n]); + e = this.index.get(v[m]); if (!e) { - console.warn("Tag '" + v[n] + ":" + v[n + 1] + "' will be skipped because there is no field '" + v[n] + "'."); + console.warn("Tag '" + v[m] + ":" + v[m + 1] + "' will be skipped because there is no field '" + v[m] + "'."); continue; } - f.push(e = e.db.tag(v[n + 1], b, y, p)); + f.push(e = e.db.tag(v[m + 1], c, x, p)); } else { - e = eb.call(this, v[n], v[n + 1], b, y, p); + e = fb.call(this, v[m], v[m + 1], c, x, p); } - d.push(q ? {field:v[n], tag:v[n + 1], result:e} : [e]); + d.push(r ? {field:v[m], tag:v[m + 1], result:e} : [e]); } } if (f.length) { const E = this; return Promise.all(f).then(function(z) { - for (let C = 0; C < z.length; C++) { - q ? d[C].result = z[C] : d[C] = z[C]; + for (let D = 0; D < z.length; D++) { + r ? d[D].result = z[D] : d[D] = z[D]; } - return q ? d : new Y(1 < d.length ? $a(d, 1, 0, 0, h, l) : d[0], E); + return r ? d : new X(d.length > 1 ? ab(d, 1, 0, 0, h, l) : d[0], E); }); } - return q ? d : new Y(1 < d.length ? $a(d, 1, 0, 0, h, l) : d[0], this); + return r ? d : new X(d.length > 1 ? ab(d, 1, 0, 0, h, l) : d[0], this); } } - if (!q && !g) { - if (r = r || this.field) { - N(r) ? g = r : (r.constructor === Array && 1 === r.length && (r = r[0]), g = r.field || r.index); + if (!r && !g) { + if (q = q || this.field) { + N(q) ? g = q : (q.constructor === Array && q.length === 1 && (q = q[0]), g = q.field || q.index); } if (!g) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - r && r.constructor !== Array && (r = [r]); + q && q.constructor !== Array && (q = [q]); } - r || (r = this.field); + q || (q = this.field); let G; v = (this.worker || this.db) && !e && []; - for (let E = 0, z, C, K; E < r.length; E++) { - C = r[E]; - if (this.db && this.tag && !this.G[E]) { + for (let E = 0, z, D, K; E < q.length; E++) { + D = q[E]; + if (this.db && this.tag && !this.B[E]) { continue; } let F; - N(C) || (F = C, C = F.field, a = F.query || a, b = aa(F.limit, b), y = aa(F.offset, y), h = aa(F.suggest, h), u = q && this.store && aa(F.highlight, u), p = !!u || q && this.store && aa(F.enrich, p), m = aa(F.cache, m)); + N(D) || (F = D, D = F.field, a = F.query || a, c = aa(F.limit, c), x = aa(F.offset, x), h = aa(F.suggest, h), t = r && this.store && aa(F.highlight, t), p = !!t || r && this.store && aa(F.enrich, p), n = aa(F.cache, n)); if (e) { z = e[E]; } else { - D = F || c || {}; - B = D.enrich; - var A = this.index.get(C); - n && (this.db && (D.tag = n, G = A.db.support_tag_search, D.field = r), !G && B && (D.enrich = !1)); - z = m ? A.searchCache(a, b, D) : A.search(a, b, D); - B && (D.enrich = B); + A = F || b || {}; + C = A.enrich; + var B = this.index.get(D); + m && (this.db && (A.tag = m, G = B.db.support_tag_search, A.field = q), !G && C && (A.enrich = !1)); + z = n ? B.searchCache(a, c, A) : B.search(a, c, A); + C && (A.enrich = C); if (v) { v[E] = z; continue; } } K = (z = z.result || z) && z.length; - if (n && K) { - D = []; - B = 0; + if (m && K) { + A = []; + C = 0; if (this.db && e) { if (!G) { - for (A = r.length; A < e.length; A++) { - let L = e[A]; + for (B = q.length; B < e.length; B++) { + let L = e[B]; if (L && L.length) { - B++, D.push(L); + C++, A.push(L); } else if (!h) { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } } } else { - for (let L = 0, O, P; L < n.length; L += 2) { - O = this.tag.get(n[L]); + for (let L = 0, O, P; L < m.length; L += 2) { + O = this.tag.get(m[L]); if (!O) { - if (console.warn("Tag '" + n[L] + ":" + n[L + 1] + "' will be skipped because there is no field '" + n[L] + "'."), h) { + if (console.warn("Tag '" + m[L] + ":" + m[L + 1] + "' will be skipped because there is no field '" + m[L] + "'."), h) { continue; } else { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } - if (P = (O = O && O.get(n[L + 1])) && O.length) { - B++, D.push(O); + if (P = (O = O && O.get(m[L + 1])) && O.length) { + C++, A.push(O); } else if (!h) { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } } - if (B) { - z = db(z, D, q); + if (C) { + z = eb(z, A, r); K = z.length; if (!K && !h) { - return q ? z : new Y(z, this); + return r ? z : new X(z, this); } - B--; + C--; } } if (K) { - f[t] = C, d.push(z), t++; - } else if (1 === r.length) { - return q ? d : new Y(d, this); + f[u] = D, d.push(z), u++; + } else if (q.length === 1) { + return r ? d : new X(d, this); } } if (v) { - if (this.db && n && n.length && !G) { - for (p = 0; p < n.length; p += 2) { - f = this.index.get(n[p]); + if (this.db && m && m.length && !G) { + for (p = 0; p < m.length; p += 2) { + f = this.index.get(m[p]); if (!f) { - if (console.warn("Tag '" + n[p] + ":" + n[p + 1] + "' was not found because there is no field '" + n[p] + "'."), h) { + if (console.warn("Tag '" + m[p] + ":" + m[p + 1] + "' was not found because there is no field '" + m[p] + "'."), h) { continue; } else { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } - v.push(f.db.tag(n[p + 1], b, y, !1)); + v.push(f.db.tag(m[p + 1], c, x, !1)); } } const E = this; return Promise.all(v).then(function(z) { - c && (c.resolve = q); - z.length && (z = E.search(a, b, c, z)); + b && (b.resolve = r); + z.length && (z = E.search(a, c, b, z)); return z; }); } - if (!t) { - return q ? d : new Y(d, this); + if (!u) { + return r ? d : new X(d, this); } if (g && (!p || !this.store)) { - return d = d[0], q ? d : new Y(d, this); + return d = d[0], r ? d : new X(d, this); } v = []; - for (y = 0; y < f.length; y++) { - n = d[y]; - p && n.length && "undefined" === typeof n[0].doc && (this.db ? v.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = Ta.call(this, n)); + for (x = 0; x < f.length; x++) { + m = d[x]; + p && m.length && typeof m[0].doc === "undefined" && (this.db ? v.push(m = this.index.get(this.field[0]).db.enrich(m)) : m = Ua.call(this, m)); if (g) { - return q ? u ? cb(a, n, this.index, g, u) : n : new Y(n, this); + return r ? t ? db(a, m, this.index, g, t) : m : new X(m, this); } - d[y] = {field:f[y], result:n}; + d[x] = {field:f[x], result:m}; } if (p && this.db && v.length) { const E = this; return Promise.all(v).then(function(z) { - for (let C = 0; C < z.length; C++) { - d[C].result = z[C]; + for (let D = 0; D < z.length; D++) { + d[D].result = z[D]; } - u && (d = cb(a, d, E.index, g, u)); - return k ? fb(d) : d; + t && (d = db(a, d, E.index, g, t)); + return k ? hb(d) : d; }); } - u && (d = cb(a, d, this.index, g, u)); - return k ? fb(d) : d; + t && (d = db(a, d, this.index, g, t)); + return k ? hb(d) : d; }; -function fb(a) { - const b = [], c = I(), e = I(); - for (let d = 0, f, g, k, h, l, m, r; d < a.length; d++) { +function hb(a) { + const c = [], b = I(), e = I(); + for (let d = 0, f, g, k, h, l, n, q; d < a.length; d++) { f = a[d]; g = f.field; k = f.result; - for (let t = 0; t < k.length; t++) { - if (l = k[t], "object" !== typeof l ? l = {id:h = l} : h = l.id, (m = c[h]) ? m.push(g) : (l.field = c[h] = [g], b.push(l)), r = l.highlight) { - m = e[h], m || (e[h] = m = {}, l.highlight = m), m[g] = r; + for (let u = 0; u < k.length; u++) { + if (l = k[u], typeof l !== "object" ? l = {id:h = l} : h = l.id, (n = b[h]) ? n.push(g) : (l.field = b[h] = [g], c.push(l)), q = l.highlight) { + n = e[h], n || (e[h] = n = {}, l.highlight = n), n[g] = q; } } } - return b; + return c; } -function eb(a, b, c, e, d) { +function fb(a, c, b, e, d) { a = this.tag.get(a); if (!a) { return []; } - a = a.get(b); + a = a.get(c); if (!a) { return []; } - b = a.length - e; - if (0 < b) { - if (c && b > c || e) { - a = a.slice(e, e + c); + c = a.length - e; + if (c > 0) { + if (b && c > b || e) { + a = a.slice(e, e + b); } - d && (a = Ta.call(this, a)); + d && (a = Ua.call(this, a)); } return a; } -function Ta(a) { +function Ua(a) { if (!this || !this.store) { return a; } if (this.db) { return this.index.get(this.field[0]).db.enrich(a); } - const b = Array(a.length); - for (let c = 0, e; c < a.length; c++) { - e = a[c], b[c] = {id:e, doc:this.store.get(e)}; + 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 b; + return c; } -;function Na(a) { - if (!this || this.constructor !== Na) { - return new Na(a); +;function Oa(a) { + if (!this || this.constructor !== Oa) { + return new Oa(a); } - const b = a.document || a.doc || a; - let c, e; - this.G = []; + const c = a.document || a.doc || a; + let b, e; + this.B = []; this.field = []; - this.K = []; - this.key = (c = b.key || b.id) && hb(c, this.K) || "id"; + this.D = []; + this.key = (b = c.key || c.id) && ib(b, this.D) || "id"; (e = a.keystore || 0) && (this.keystore = e); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? e ? new S(e) : new Set() : e ? new R(e) : new Map(); - this.D = (c = b.store || null) && c && !0 !== c && []; - this.store = c && (e ? new R(e) : new Map()); - this.cache = (c = a.cache || null) && new na(c); + this.reg = !this.fastupdate || a.worker || a.db ? e ? new R(e) : new Set() : e ? new Q(e) : new Map(); + this.h = (b = c.store || null) && b && b !== !0 && []; + this.store = b ? e ? new Q(e) : new Map() : null; + this.cache = (b = a.cache || null) && new oa(b); a.cache = !1; this.worker = a.worker || !1; this.priority = a.priority || 4; - this.index = ib.call(this, a, b); + this.index = jb.call(this, a, c); this.tag = null; - if (c = b.tag) { - if ("string" === typeof c && (c = [c]), c.length) { + if (b = c.tag) { + if (typeof b === "string" && (b = [b]), b.length) { this.tag = new Map(); + this.A = []; this.F = []; - this.P = []; - for (let d = 0, f, g; d < c.length; d++) { - f = c[d]; + for (let d = 0, f, g; d < b.length; d++) { + f = b[d]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = hb(g, this.K), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].J = f.filter)); - this.P[d] = g; + f.custom ? this.A[d] = f.custom : (this.A[d] = ib(g, this.D), f.filter && (typeof this.A[d] === "string" && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter)); + this.F[d] = g; this.tag.set(g, new Map()); } } @@ -1922,56 +1919,56 @@ function Ta(a) { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -w = Na.prototype; +w = Oa.prototype; w.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } - let b = this.field; + let c = this.field; if (this.tag) { - for (let f = 0, g; f < this.P.length; f++) { - g = this.P[f]; - var c = void 0; - this.index.set(g, c = new V({}, this.reg)); - b === this.field && (b = b.slice(0)); - b.push(g); - c.tag = this.tag.get(g); + for (let f = 0, g; f < this.F.length; f++) { + g = this.F[f]; + var b = void 0; + this.index.set(g, b = new T({}, this.reg)); + c === this.field && (c = c.slice(0)); + c.push(g); + b.tag = this.tag.get(g); } } - c = []; + b = []; const e = {db:a.db, type:a.type, fastupdate:a.fastupdate}; - for (let f = 0, g, k; f < b.length; f++) { - e.field = k = b[f]; + for (let f = 0, g, k; f < c.length; f++) { + e.field = k = c[f]; g = this.index.get(k); const h = new a.constructor(a.id, e); h.id = a.id; - c[f] = h.mount(g); + b[f] = h.mount(g); g.document = !0; f ? g.bypass = !0 : g.store = this.store; } const d = this; - return this.db = Promise.all(c).then(function() { + return this.db = Promise.all(b).then(function() { d.db = !0; }); }; -w.commit = async function(a, b) { - const c = []; +w.commit = async function(a, c) { + const b = []; for (const e of this.index.values()) { - c.push(e.commit(a, b)); + b.push(e.commit(a, c)); } - await Promise.all(c); + await Promise.all(b); this.reg.clear(); }; w.destroy = function() { const a = []; - for (const b of this.index.values()) { - a.push(b.destroy()); + for (const c of this.index.values()) { + a.push(c.destroy()); } return Promise.all(a); }; -function ib(a, b) { - const c = new Map(); - let e = b.index || b.field || b; +function jb(a, c) { + const b = new Map(); + let e = c.index || c.field || c; N(e) && (e = [e]); for (let f = 0, g, k; f < e.length; f++) { g = e[f]; @@ -1979,50 +1976,50 @@ function ib(a, b) { k = ba(k) ? Object.assign({}, a, k) : a; if (this.worker) { var d = void 0; - d = (d = k.encoder) && d.encode ? d : new la("string" === typeof d ? wa[d] : d || {}); - d = new La(k, d); - c.set(g, d); + d = (d = k.encoder) && d.encode ? d : new la(typeof d === "string" ? xa[d] : d || {}); + d = new Ma(k, d); + b.set(g, d); } - this.worker || c.set(g, new V(k, this.reg)); - k.custom ? this.G[f] = k.custom : (this.G[f] = hb(g, this.K), k.filter && ("string" === typeof this.G[f] && (this.G[f] = new String(this.G[f])), this.G[f].J = k.filter)); + this.worker || b.set(g, new T(k, this.reg)); + k.custom ? this.B[f] = k.custom : (this.B[f] = ib(g, this.D), k.filter && (typeof this.B[f] === "string" && (this.B[f] = new String(this.B[f])), this.B[f].G = k.filter)); this.field[f] = g; } - if (this.D) { - a = b.store; + if (this.h) { + a = c.store; N(a) && (a = [a]); for (let f = 0, g, k; f < a.length; f++) { - g = a[f], k = g.field || g, g.custom ? (this.D[f] = g.custom, g.custom.U = k) : (this.D[f] = hb(k, this.K), g.filter && ("string" === typeof this.D[f] && (this.D[f] = new String(this.D[f])), this.D[f].J = g.filter)); + g = a[f], k = g.field || g, g.custom ? (this.h[f] = g.custom, g.custom.O = k) : (this.h[f] = ib(k, this.D), g.filter && (typeof this.h[f] === "string" && (this.h[f] = new String(this.h[f])), this.h[f].G = g.filter)); } } - return c; + return b; } -function hb(a, b) { - const c = a.split(":"); +function ib(a, c) { + const b = a.split(":"); let e = 0; - for (let d = 0; d < c.length; d++) { - a = c[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[e] = !0), a && (c[e++] = a); + for (let d = 0; d < b.length; d++) { + a = b[d], a[a.length - 1] === "]" && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); } - e < c.length && (c.length = e); - return 1 < e ? c : c[0]; + e < b.length && (b.length = e); + return e > 1 ? b : b[0]; } -w.append = function(a, b) { - return this.add(a, b, !0); +w.append = function(a, c) { + return this.add(a, c, !0); }; -w.update = function(a, b) { - return this.remove(a).add(a, b); +w.update = function(a, c) { + return this.remove(a).add(a, c); }; w.remove = function(a) { ba(a) && (a = da(a, this.key)); - for (var b of this.index.values()) { - b.remove(a, !0); + for (var c of this.index.values()) { + c.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (let c of this.tag.values()) { - for (let e of c) { - b = e[0]; + for (let b of this.tag.values()) { + for (let e of b) { + c = e[0]; const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : c.delete(b)); + f > -1 && (d.length > 1 ? d.splice(f, 1) : b.delete(c)); } } } @@ -2034,13 +2031,13 @@ w.remove = function(a) { }; w.clear = function() { const a = []; - for (const b of this.index.values()) { - const c = b.clear(); - c.then && a.push(c); + for (const c of this.index.values()) { + const b = c.clear(); + b.then && a.push(b); } if (this.tag) { - for (const b of this.tag.values()) { - b.clear(); + for (const c of this.tag.values()) { + c.clear(); } } this.store && this.store.clear(); @@ -2057,151 +2054,151 @@ w.cleanup = function() { return this; }; w.get = function(a) { - return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { - return b[0] && b[0].doc || null; + return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) { + return c[0] && c[0].doc || null; }) : this.store.get(a) || null; }; -w.set = function(a, b) { - "object" === typeof a && (b = a, a = da(b, this.key)); - this.store.set(a, b); +w.set = function(a, c) { + typeof a === "object" && (c = a, a = da(c, this.key)); + this.store.set(a, c); return this; }; -w.searchCache = ma; -w.export = jb; -w.import = kb; -Fa(Na.prototype); -function lb(a, b = 0) { - let c = [], e = []; - b && (b = 250000 / b * 5000 | 0); +w.searchCache = na; +w.export = kb; +w.import = lb; +Ga(Oa.prototype); +function mb(a, c = 0) { + let b = [], e = []; + c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { - e.push(d), e.length === b && (c.push(e), e = []); - } - e.length && c.push(e); - return c; -} -function mb(a, b) { - b || (b = new Map()); - for (let c = 0, e; c < a.length; c++) { - e = a[c], b.set(e[0], e[1]); + e.push(d), e.length === c && (b.push(e), e = []); } + e.length && b.push(e); return b; } -function nb(a, b = 0) { - let c = [], e = []; - b && (b = 250000 / b * 1000 | 0); - for (const d of a.entries()) { - e.push([d[0], lb(d[1])[0]]), e.length === b && (c.push(e), e = []); +function nb(a, c) { + c || (c = new Map()); + for (let b = 0, e; b < a.length; b++) { + e = a[b], c.set(e[0], e[1]); } - e.length && c.push(e); return c; } -function ob(a, b) { - b || (b = new Map()); - for (let c = 0, e, d; c < a.length; c++) { - e = a[c], d = b.get(e[0]), b.set(e[0], mb(e[1], d)); +function ob(a, c = 0) { + let b = [], e = []; + c && (c = 250000 / c * 1000 | 0); + for (const d of a.entries()) { + e.push([d[0], mb(d[1])[0]]), e.length === c && (b.push(e), e = []); } + e.length && b.push(e); return b; } -function pb(a) { - let b = [], c = []; +function pb(a, c) { + c || (c = new Map()); + for (let b = 0, e, d; b < a.length; b++) { + e = a[b], d = c.get(e[0]), c.set(e[0], nb(e[1], d)); + } + return c; +} +function qb(a) { + let c = [], b = []; for (const e of a.keys()) { - c.push(e), 250000 === c.length && (b.push(c), c = []); + b.push(e), b.length === 250000 && (c.push(b), b = []); } - c.length && b.push(c); - return b; + b.length && c.push(b); + return c; } -function qb(a, b) { - b || (b = new Set()); - for (let c = 0; c < a.length; c++) { - b.add(a[c]); +function rb(a, c) { + c || (c = new Set()); + for (let b = 0; b < a.length; b++) { + c.add(a[b]); } - return b; + return c; } -function rb(a, b, c, e, d, f, g = 0) { +function sb(a, c, b, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { - return this.export(a, b, d, f + 1); + return this.export(a, c, d, f + 1); } - if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { + if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return rb.call(l, a, b, c, k ? e : null, d, f, g + 1); + return sb.call(l, a, c, b, k ? e : null, d, f, g + 1); }); } - return rb.call(this, a, b, c, k ? e : null, d, f, g + 1); + return sb.call(this, a, c, b, k ? e : null, d, f, g + 1); } -function jb(a, b, c = 0, e = 0) { - if (c < this.field.length) { - const g = this.field[c]; - if ((b = this.index.get(g).export(a, g, c, e = 1)) && b.then) { +function kb(a, c, b = 0, e = 0) { + if (b < this.field.length) { + const g = this.field[b]; + if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { const k = this; - return b.then(function() { - return k.export(a, g, c + 1); + return c.then(function() { + return k.export(a, g, b + 1); }); } - return this.export(a, g, c + 1); + return this.export(a, g, b + 1); } let d, f; switch(e) { case 0: d = "reg"; - f = pb(this.reg); - b = null; + f = qb(this.reg); + c = null; break; case 1: d = "tag"; - f = this.tag && nb(this.tag, this.reg.size); - b = null; + f = this.tag && ob(this.tag, this.reg.size); + c = null; break; case 2: d = "doc"; - f = this.store && lb(this.store); - b = null; + f = this.store && mb(this.store); + c = null; break; default: return; } - return rb.call(this, a, b, d, f, c, e); + return sb.call(this, a, c, d, f || null, b, e); } -function kb(a, b) { - var c = a.split("."); - "json" === c[c.length - 1] && c.pop(); - const e = 2 < c.length ? c[0] : ""; - c = 2 < c.length ? c[2] : c[1]; +function lb(a, c) { + var b = a.split("."); + b[b.length - 1] === "json" && b.pop(); + const e = b.length > 2 ? b[0] : ""; + b = b.length > 2 ? b[2] : b[1]; if (this.worker && e) { return this.index.get(e).import(a); } - if (b) { - "string" === typeof b && (b = JSON.parse(b)); + if (c) { + typeof c === "string" && (c = JSON.parse(c)); if (e) { - return this.index.get(e).import(c, b); + return this.index.get(e).import(b, c); } - switch(c) { + switch(b) { case "reg": this.fastupdate = !1; - this.reg = qb(b, this.reg); + this.reg = rb(c, this.reg); for (let d = 0, f; d < this.field.length; d++) { f = this.index.get(this.field[d]), f.fastupdate = !1, f.reg = this.reg; } if (this.worker) { - b = []; + c = []; for (const d of this.index.values()) { - b.push(d.import(a)); + c.push(d.import(a)); } - return Promise.all(b); + return Promise.all(c); } break; case "tag": - this.tag = ob(b, this.tag); + this.tag = pb(c, this.tag); break; case "doc": - this.store = mb(b, this.store); + this.store = nb(c, this.store); } } } -function sb(a, b) { - let c = ""; +function tb(a, c) { + let b = ""; for (const e of a.entries()) { a = e[0]; const d = e[1]; @@ -2210,55 +2207,55 @@ function sb(a, b) { k = d[g] || [""]; let h = ""; for (let l = 0; l < k.length; l++) { - h += (h ? "," : "") + ("string" === b ? '"' + k[l] + '"' : k[l]); + h += (h ? "," : "") + (c === "string" ? '"' + k[l] + '"' : k[l]); } h = "[" + h + "]"; f += (f ? "," : "") + h; } f = '["' + a + '",[' + f + "]]"; - c += (c ? "," : "") + f; + b += (b ? "," : "") + f; } - return c; + return b; } -;V.prototype.remove = function(a, b) { - const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); - if (c) { +;T.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, f; e < c.length; e++) { - if ((d = c[e]) && (f = d.length)) { + for (let e = 0, d, f; e < b.length; e++) { + if ((d = b[e]) && (f = d.length)) { if (d[f - 1] === a) { d.pop(); } else { const g = d.indexOf(a); - 0 <= g && d.splice(g, 1); + g >= 0 && d.splice(g, 1); } } } } else { - tb(this.map, a), this.depth && tb(this.ctx, a); + ub(this.map, a), this.depth && ub(this.ctx, a); } - b || this.reg.delete(a); + c || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.S && ub(this)); + this.db && (this.commit_task.push({del:a}), this.M && vb(this)); this.cache && this.cache.remove(a); return this; }; -function tb(a, b) { - let c = 0; - var e = "undefined" === typeof b; +function ub(a, c) { + let b = 0; + var e = typeof c === "undefined"; if (a.constructor === Array) { for (let d = 0, f, g, k; d < a.length; d++) { if ((f = a[d]) && f.length) { if (e) { return 1; } - g = f.indexOf(b); - if (0 <= g) { - if (1 < f.length) { + g = f.indexOf(c); + if (g >= 0) { + if (f.length > 1) { return f.splice(g, 1), 1; } delete a[d]; - if (c) { + if (b) { return 1; } k = 1; @@ -2266,70 +2263,80 @@ function tb(a, b) { if (k) { return 1; } - c++; + b++; } } } } else { for (let d of a.entries()) { - e = d[0], tb(d[1], b) ? c++ : a.delete(e); + e = d[0], ub(d[1], c) ? b++ : a.delete(e); } } - return c; + return b; } -;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -V.prototype.add = function(a, b, c, e) { - if (b && (a || 0 === a)) { - if (!e && !c && this.reg.has(a)) { - return this.update(a, b); +;const wb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +T.prototype.add = function(a, c, b, e) { + if (c && (a || a === 0)) { + if (!e && !b && this.reg.has(a)) { + return this.update(a, c); } e = this.depth; - b = this.encoder.encode(b, !e); - const l = b.length; + c = this.encoder.encode(c, !e); + const l = c.length; if (l) { - const m = I(), r = I(), t = this.resolution; - for (let q = 0; q < l; q++) { - let u = b[this.rtl ? l - 1 - q : q]; - var d = u.length; - if (d && (e || !r[u])) { - var f = this.score ? this.score(b, u, q, null, 0) : wb(t, l, q), g = ""; + const n = I(), q = I(), u = this.resolution; + for (let r = 0; r < l; r++) { + let t = c[this.rtl ? l - 1 - r : r]; + var d = t.length; + if (d && (e || !q[t])) { + var f = this.score ? this.score(c, t, r, null, 0) : xb(u, l, r), g = ""; switch(this.tokenize) { + case "tolerant": + Y(this, q, t, f, a, b); + if (d > 2) { + for (let m = 1, p, x, v, A; m < d - 1; m++) { + p = t.charAt(m), x = t.charAt(m + 1), v = t.substring(0, m) + x, A = t.substring(m + 2), g = v + p + A, q[g] || Y(this, q, g, f, a, b), g = v + A, q[g] || Y(this, q, g, f, a, b); + } + } + break; case "full": - if (2 < d) { - for (let n = 0, p; n < d; n++) { - for (f = d; f > n; f--) { - g = u.substring(n, f); - p = this.rtl ? d - 1 - n : n; - var k = this.score ? this.score(b, u, q, g, p) : wb(t, l, q, d, p); - xb(this, r, g, k, a, c); + if (d > 2) { + for (let m = 0, p; m < d; m++) { + for (f = d; f > m; f--) { + if (g = t.substring(m, f), !q[g]) { + p = this.rtl ? d - 1 - m : m; + var k = this.score ? this.score(c, t, r, g, p) : xb(u, l, r, d, p); + Y(this, q, g, k, a, b); + } } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (k = d - 1; 0 < k; k--) { - g = u[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(b, u, q, g, k) : wb(t, l, q, d, k); - xb(this, r, g, h, a, c); + if (d > 1) { + for (k = d - 1; k > 0; k--) { + if (g = t[this.rtl ? d - 1 - k : k] + g, !q[g]) { + var h = this.score ? this.score(c, t, r, g, k) : xb(u, l, r, d, k); + Y(this, q, g, h, a, b); + } } g = ""; } case "forward": - if (1 < d) { + if (d > 1) { for (k = 0; k < d; k++) { - g += u[this.rtl ? d - 1 - k : k], xb(this, r, g, f, a, c); + g += t[this.rtl ? d - 1 - k : k], q[g] || Y(this, q, g, f, a, b); } break; } default: - if (xb(this, r, u, f, a, c), e && 1 < l && q < l - 1) { - for (d = I(), g = this.T, f = u, k = Math.min(e + 1, this.rtl ? q + 1 : l - q), d[f] = 1, h = 1; h < k; h++) { - if ((u = b[this.rtl ? l - 1 - q - h : q + h]) && !d[u]) { - d[u] = 1; - const n = this.score ? this.score(b, f, q, u, h - 1) : wb(g + (l / 2 > g ? 0 : 1), l, q, k - 1, h - 1), p = this.bidirectional && u > f; - xb(this, m, p ? f : u, n, a, c, p ? u : f); + if (Y(this, q, t, f, a, b), e && l > 1 && r < l - 1) { + for (d = I(), g = this.N, f = t, k = Math.min(e + 1, this.rtl ? r + 1 : l - r), d[f] = 1, h = 1; h < k; h++) { + if ((t = c[this.rtl ? l - 1 - r - h : r + h]) && !d[t]) { + d[t] = 1; + const m = this.score ? this.score(c, f, r, t, h - 1) : xb(g + (l / 2 > g ? 0 : 1), l, r, k - 1, h - 1), p = this.bidirectional && t > f; + Y(this, n, p ? f : t, m, a, b, p ? t : f); } } } @@ -2338,109 +2345,109 @@ V.prototype.add = function(a, b, c, e) { } this.fastupdate || this.reg.add(a); } else { - b = ""; + c = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.S && ub(this)); + this.db && (c || this.commit_task.push({del:a}), this.M && vb(this)); return this; }; -function xb(a, b, c, e, d, f, g) { +function Y(a, c, b, e, d, f, g) { let k = g ? a.ctx : a.map, h; - if (!b[c] || g && !(h = b[c])[g]) { - if (g ? (b = h || (b[c] = I()), b[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : b[c] = 1, (h = k.get(c)) ? k = h : k.set(c, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { + if (!c[b] || g && !(h = c[b])[g]) { + if (g ? (c = h || (c[b] = I()), c[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { if (k.length === 2 ** 31 - 1) { - b = new Aa(k); + c = new Ba(k); if (a.fastupdate) { for (let l of a.reg.values()) { - l.includes(k) && (l[l.indexOf(k)] = b); + l.includes(k) && (l[l.indexOf(k)] = c); } } - h[e] = k = b; + h[e] = k = c; } k.push(d); a.fastupdate && ((e = a.reg.get(d)) ? e.push(k) : a.reg.set(d, [k])); } } } -function wb(a, b, c, e, d) { - return c && 1 < a ? b + (e || 0) <= a ? c + (d || 0) : (a - 1) / (b + (e || 0)) * (c + (d || 0)) + 1 | 0 : 0; +function xb(a, c, b, e, d) { + return b && a > 1 ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;V.prototype.search = function(a, b, c) { - c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); - if (c && c.cache) { - return c.cache = !1, a = this.searchCache(a, b, c), c.cache = !0, a; +;T.prototype.search = function(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = "")); + if (b && b.cache) { + return b.cache = !1, a = this.searchCache(a, c, b), b.cache = !0, a; } - let e = [], d, f, g, k = 0, h, l, m, r, t; - c && (a = c.query || a, b = c.limit || b, k = c.offset || 0, f = c.context, g = c.suggest, t = (h = c.resolve) && c.enrich, m = c.boost, r = c.resolution, l = this.db && c.tag); - "undefined" === typeof h && (h = this.resolve); - f = this.depth && !1 !== f; - let q = this.encoder.encode(a, !f); - d = q.length; - b = b || (h ? 100 : 0); - if (1 === d) { - return yb.call(this, q[0], "", b, k, h, t, l); + let e = [], d, f, g, k = 0, h, l, n, q, u; + b && (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, u = (h = b.resolve) && b.enrich, n = b.boost, q = b.resolution, l = this.db && b.tag); + typeof h === "undefined" && (h = this.resolve); + f = this.depth && f !== !1; + let r = this.encoder.encode(a, !f); + d = r.length; + c = c || (h ? 100 : 0); + if (d === 1) { + return yb.call(this, r[0], "", c, k, h, u, l); } - if (2 === d && f && !g) { - return yb.call(this, q[1], q[0], b, k, h, t, l); + if (d === 2 && f && !g) { + return yb.call(this, r[1], r[0], c, k, h, u, l); } - let u = I(), n = 0, p; - f && (p = q[0], n = 1); - r || 0 === r || (r = p ? this.T : this.resolution); + let t = I(), m = 0, p; + f && (p = r[0], m = 1); + q || q === 0 || (q = p ? this.N : this.resolution); if (this.db) { - if (this.db.search && (c = this.db.search(this, q, b, k, g, h, t, l), !1 !== c)) { - return c; + if (this.db.search && (b = this.db.search(this, r, c, k, g, h, u, l), b !== !1)) { + return b; } - const y = this; + const x = this; return async function() { - for (let v, D; n < d; n++) { - if ((D = q[n]) && !u[D]) { - u[D] = 1; - v = await zb(y, D, p, 0, 0, !1, !1); - if (v = Ab(v, e, g, r)) { + for (let v, A; m < d; m++) { + if ((A = r[m]) && !t[A]) { + t[A] = 1; + v = await zb(x, A, p, 0, 0, !1, !1); + if (v = Ab(v, e, g, q)) { e = v; break; } - p && (g && v && e.length || (p = D)); + p && (g && v && e.length || (p = A)); } - g && p && n === d - 1 && !e.length && (r = y.resolution, p = "", n = -1, u = I()); + g && p && m === d - 1 && !e.length && (q = x.resolution, p = "", m = -1, t = I()); } - return Bb(e, r, b, k, g, m, h); + return Bb(e, q, c, k, g, n, h); }(); } - for (let y, v; n < d; n++) { - if ((v = q[n]) && !u[v]) { - u[v] = 1; - y = zb(this, v, p, 0, 0, !1, !1); - if (y = Ab(y, e, g, r)) { - e = y; + for (let x, v; m < d; m++) { + if ((v = r[m]) && !t[v]) { + t[v] = 1; + x = zb(this, v, p, 0, 0, !1, !1); + if (x = Ab(x, e, g, q)) { + e = x; break; } - p && (g && y && e.length || (p = v)); + p && (g && x && e.length || (p = v)); } - g && p && n === d - 1 && !e.length && (r = this.resolution, p = "", n = -1, u = I()); + g && p && m === d - 1 && !e.length && (q = this.resolution, p = "", m = -1, t = I()); } - return Bb(e, r, b, k, g, m, h); + return Bb(e, q, c, k, g, n, h); }; -function Bb(a, b, c, e, d, f, g) { +function Bb(a, c, b, e, d, f, g) { let k = a.length, h = a; - if (1 < k) { - h = $a(a, b, c, e, d, f, g); - } else if (1 === k) { - return g ? Sa.call(null, a[0], c, e) : new Y(a[0], this); + if (k > 1) { + h = ab(a, c, b, e, d, f, g); + } else if (k === 1) { + return g ? Ta.call(null, a[0], b, e) : new X(a[0], this); } - return g ? h : new Y(h, this); + return g ? h : new X(h, this); } -function yb(a, b, c, e, d, f, g) { - a = zb(this, a, b, c, e, d, f, g); +function yb(a, c, b, e, d, f, g) { + a = zb(this, a, c, b, e, d, f, g); return this.db ? a.then(function(k) { - return d ? k || [] : new Y(k, this); - }) : a && a.length ? d ? Sa.call(this, a, c, e) : new Y(a, this) : d ? [] : new Y([], this); + return d ? k || [] : new X(k, this); + }) : a && a.length ? d ? Ta.call(this, a, b, e) : new X(a, this) : d ? [] : new X([], this); } -function Ab(a, b, c, e) { +function Ab(a, c, b, e) { let d = []; if (a && a.length) { if (a.length <= e) { - b.push(a); + c.push(a); return; } for (let f = 0, g; f < e; f++) { @@ -2449,73 +2456,73 @@ function Ab(a, b, c, e) { } } if (d.length) { - b.push(d); + c.push(d); return; } } - if (!c) { + if (!b) { return d; } } -function zb(a, b, c, e, d, f, g, k) { +function zb(a, c, b, e, d, f, g, k) { let h; - c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); + b && (h = a.bidirectional && c > b) && (h = b, b = c, c = h); if (a.db) { - return a.db.get(b, c, e, d, f, g, k); + return a.db.get(c, b, e, d, f, g, k); } - a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); + a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function V(a, b) { - if (!this || this.constructor !== V) { - return new V(a); +;function T(a, c) { + if (!this || this.constructor !== T) { + return new T(a); } if (a) { - var c = N(a) ? a : a.preset; - c && (vb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, vb[c], a)); + var b = N(a) ? a : a.preset; + b && (wb[b] || console.warn("Preset not found: " + b), a = Object.assign({}, wb[b], a)); } else { a = {}; } - c = a.context; - const e = !0 === c ? {depth:1} : c || {}, d = N(a.encoder) ? wa[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new la(d) : {encode:d}; + b = a.context; + const e = b === !0 ? {depth:1} : b || {}, d = N(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || {}; + this.encoder = d.encode ? d : typeof d === "object" ? new la(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; - this.depth = "strict" === c && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict"; + this.depth = b === "strict" && e.depth || 0; + this.bidirectional = e.bidirectional !== !1; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - (c = a.keystore || 0) && (this.keystore = c); - this.map = c ? new R(c) : new Map(); - this.ctx = c ? new R(c) : new Map(); - this.reg = b || (this.fastupdate ? c ? new R(c) : new Map() : c ? new S(c) : new Set()); - this.T = e.resolution || 3; + e && e.depth && this.tokenize !== "strict" && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + (b = a.keystore || 0) && (this.keystore = b); + this.map = b ? new Q(b) : new Map(); + this.ctx = b ? new Q(b) : new Map(); + this.reg = c || (this.fastupdate ? b ? new Q(b) : new Map() : b ? new R(b) : new Set()); + this.N = e.resolution || 3; this.rtl = d.rtl || a.rtl || !1; - this.cache = (c = a.cache || null) && new na(c); - this.resolve = !1 !== a.resolve; - if (c = a.db) { - this.db = this.mount(c); + this.cache = (b = a.cache || null) && new oa(b); + this.resolve = a.resolve !== !1; + if (b = a.db) { + this.db = this.mount(b); } - this.S = !1 !== a.commit; + this.M = a.commit !== !1; this.commit_task = []; this.commit_timer = null; this.priority = a.priority || 4; } -w = V.prototype; +w = T.prototype; w.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -w.commit = function(a, b) { +w.commit = function(a, c) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.commit(this, a, b); + return this.db.commit(this, a, c); }; w.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function ub(a) { +function vb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2528,31 +2535,31 @@ w.clear = function() { this.cache && this.cache.clear(); return this.db ? (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [], this.db.clear()) : this; }; -w.append = function(a, b) { - return this.add(a, b, !0); +w.append = function(a, c) { + return this.add(a, c, !0); }; w.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -w.update = function(a, b) { - const c = this, e = this.remove(a); - return e && e.then ? e.then(() => c.add(a, b)) : this.add(a, b); +w.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); }; w.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - tb(this.map); - this.depth && tb(this.ctx); + ub(this.map); + this.depth && ub(this.ctx); return this; }; -w.searchCache = ma; -w.export = function(a, b, c = 0, e = 0) { +w.searchCache = na; +w.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = pb(this.reg); + f = qb(this.reg); break; case 1: d = "cfg"; @@ -2560,64 +2567,64 @@ w.export = function(a, b, c = 0, e = 0) { break; case 2: d = "map"; - f = lb(this.map, this.reg.size); + f = mb(this.map, this.reg.size); break; case 3: d = "ctx"; - f = nb(this.ctx, this.reg.size); + f = ob(this.ctx, this.reg.size); break; default: return; } - return rb.call(this, a, b, d, f, c, e); + return sb.call(this, a, c, d, f, b, e); }; -w.import = function(a, b) { - if (b) { - switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { +w.import = function(a, c) { + if (c) { + switch(typeof c === "string" && (c = JSON.parse(c)), a = a.split("."), a[a.length - 1] === "json" && a.pop(), a.length === 3 && a.shift(), a = a.length > 1 ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = qb(b, this.reg); + this.reg = rb(c, this.reg); break; case "map": - this.map = mb(b, this.map); + this.map = nb(c, this.map); break; case "ctx": - this.ctx = ob(b, this.ctx); + this.ctx = pb(c, this.ctx); } } }; w.serialize = function(a = !0) { - let b = "", c = "", e = ""; + let c = "", b = "", e = ""; if (this.reg.size) { let f; for (var d of this.reg.keys()) { - f || (f = typeof d), b += (b ? "," : "") + ("string" === f ? '"' + d + '"' : d); + f || (f = typeof d), c += (c ? "," : "") + (f === "string" ? '"' + d + '"' : d); } - b = "index.reg=new Set([" + b + "]);"; - c = sb(this.map, f); - c = "index.map=new Map([" + c + "]);"; + c = "index.reg=new Set([" + c + "]);"; + b = tb(this.map, f); + b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let k = sb(g[1], f); + let k = tb(g[1], f); k = "new Map([" + k + "])"; k = '["' + d + '",' + k + "]"; e += (e ? "," : "") + k; } e = "index.ctx=new Map([" + e + "]);"; } - return a ? "function inject(index){" + b + c + e + "}" : b + c + e; + return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -Fa(V.prototype); -const Cb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Db = ["map", "ctx", "tag", "reg", "cfg"], Eb = I(); -function Fb(a, b = {}) { +Ga(T.prototype); +const Cb = typeof window !== "undefined" && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Db = ["map", "ctx", "tag", "reg", "cfg"], Eb = I(); +function Fb(a, c = {}) { if (!this || this.constructor !== Fb) { - return new Fb(a, b); + return new Fb(a, c); } - "object" === typeof a && (b = a, a = a.name); + typeof a === "object" && (c = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); - this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; - this.type = b.type; + this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; + this.type = c.type; this.fastupdate = this.support_tag_search = !1; this.db = null; this.h = {}; @@ -2638,18 +2645,18 @@ w.open = function() { navigator.storage && navigator.storage.persist(); Eb[a.id] || (Eb[a.id] = []); Eb[a.id].push(a.field); - const b = Cb.open(a.id, 1); - b.onupgradeneeded = function() { - const c = a.db = this.result; + const c = Cb.open(a.id, 1); + c.onupgradeneeded = function() { + const b = a.db = this.result; for (let e = 0, d; e < Db.length; e++) { d = Db[e]; for (let f = 0, g; f < Eb[a.id].length; f++) { - g = Eb[a.id][f], c.objectStoreNames.contains(d + ("reg" !== d ? g ? ":" + g : "" : "")) || c.createObjectStore(d + ("reg" !== d ? g ? ":" + g : "" : "")); + g = Eb[a.id][f], b.objectStoreNames.contains(d + (d !== "reg" ? g ? ":" + g : "" : "")) || b.createObjectStore(d + (d !== "reg" ? g ? ":" + g : "" : "")); } } }; - return a.db = Z(b, function(c) { - a.db = c; + return a.db = Z(c, function(b) { + a.db = b; a.db.onversionchange = function() { a.close(); }; @@ -2665,20 +2672,20 @@ w.destroy = function() { }; w.clear = function() { const a = []; - for (let c = 0, e; c < Db.length; c++) { - e = Db[c]; + for (let b = 0, e; b < Db.length; b++) { + e = Db[b]; for (let d = 0, f; d < Eb[this.id].length; d++) { - f = Eb[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); + f = Eb[this.id][d], a.push(e + (e !== "reg" ? f ? ":" + f : "" : "")); } } - const b = this.db.transaction(a, "readwrite"); - for (let c = 0; c < a.length; c++) { - b.objectStore(a[c]).clear(); + const c = this.db.transaction(a, "readwrite"); + for (let b = 0; b < a.length; b++) { + c.objectStore(a[b]).clear(); } - return Z(b); + return Z(c); }; -w.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { - a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); +w.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { + a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a); const g = this; return Z(a).then(function(k) { let h = []; @@ -2686,21 +2693,21 @@ w.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { return h; } if (d) { - if (!c && !e && 1 === k.length) { + if (!b && !e && k.length === 1) { return k[0]; } - for (let l = 0, m; l < k.length; l++) { - if ((m = k[l]) && m.length) { - if (e >= m.length) { - e -= m.length; + for (let l = 0, n; l < k.length; l++) { + if ((n = k[l]) && n.length) { + if (e >= n.length) { + e -= n.length; continue; } - const r = c ? e + Math.min(m.length - e, c) : m.length; - for (let t = e; t < r; t++) { - h.push(m[t]); + const q = b ? e + Math.min(n.length - e, b) : n.length; + for (let u = e; u < q; u++) { + h.push(n[u]); } e = 0; - if (h.length === c) { + if (h.length === b) { break; } } @@ -2710,27 +2717,27 @@ w.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { return k; }); }; -w.tag = function(a, b = 0, c = 0, e = !1) { +w.tag = function(a, c = 0, b = 0, e = !1) { a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); const d = this; return Z(a).then(function(f) { - if (!f || !f.length || c >= f.length) { + if (!f || !f.length || b >= f.length) { return []; } - if (!b && !c) { + if (!c && !b) { return f; } - f = f.slice(c, c + b); + f = f.slice(b, b + c); return e ? d.enrich(f) : f; }); }; w.enrich = function(a) { - "object" !== typeof a && (a = [a]); - const b = this.db.transaction("reg", "readonly").objectStore("reg"), c = []; + typeof a !== "object" && (a = [a]); + const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = []; for (let e = 0; e < a.length; e++) { - c[e] = Z(b.get(a[e])); + b[e] = Z(c.get(a[e])); } - return Promise.all(c).then(function(e) { + return Promise.all(b).then(function(e) { for (let d = 0; d < e.length; d++) { e[d] = {id:a[d], doc:e[d] ? JSON.parse(e[d]) : null}; } @@ -2739,30 +2746,30 @@ w.enrich = function(a) { }; w.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Z(a).then(function(b) { - return !!b; + return Z(a).then(function(c) { + return !!c; }); }; w.search = null; w.info = function() { }; -w.transaction = function(a, b, c) { - a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; - let e = this.h[a + ":" + b]; +w.transaction = function(a, c, b) { + a += a !== "reg" ? this.field ? ":" + this.field : "" : ""; + let e = this.h[a + ":" + c]; if (e) { - return c.call(this, e); + return b.call(this, e); } - let d = this.db.transaction(a, b); - this.h[a + ":" + b] = e = d.objectStore(a); - const f = c.call(this, e); - this.h[a + ":" + b] = null; + let d = this.db.transaction(a, c); + this.h[a + ":" + c] = e = d.objectStore(a); + const f = b.call(this, e); + this.h[a + ":" + c] = null; return Z(d).finally(function() { d = e = null; return f; }); }; -w.commit = async function(a, b, c) { - if (b) { +w.commit = async function(a, c, b) { + if (c) { await this.clear(), a.commit_task = []; } else { let e = a.commit_task; @@ -2770,30 +2777,30 @@ w.commit = async function(a, b, c) { for (let d = 0, f; d < e.length; d++) { if (f = e[d], f.clear) { await this.clear(); - b = !0; + c = !0; break; } else { e[d] = f.del; } } - b || (c || (e = e.concat(ca(a.reg))), e.length && await this.remove(e)); + c || (b || (e = e.concat(ca(a.reg))), e.length && await this.remove(e)); } a.reg.size && (await this.transaction("map", "readwrite", function(e) { for (const d of a.map) { const f = d[0], g = d[1]; - g.length && (b ? e.put(g, f) : e.get(f).onsuccess = function() { + g.length && (c ? e.put(g, f) : e.get(f).onsuccess = function() { let k = this.result; var h; if (k && k.length) { const l = Math.max(k.length, g.length); - for (let m = 0, r, t; m < l; m++) { - if ((t = g[m]) && t.length) { - if ((r = k[m]) && r.length) { - for (h = 0; h < t.length; h++) { - r.push(t[h]); + for (let n = 0, q, u; n < l; n++) { + if ((u = g[n]) && u.length) { + if ((q = k[n]) && q.length) { + for (h = 0; h < u.length; h++) { + q.push(u[h]); } } else { - k[m] = t; + k[n] = u; } h = 1; } @@ -2809,34 +2816,34 @@ w.commit = async function(a, b, c) { const f = d[0], g = d[1]; for (const k of g) { const h = k[0], l = k[1]; - l.length && (b ? e.put(l, f + ":" + h) : e.get(f + ":" + h).onsuccess = function() { - let m = this.result; - var r; - if (m && m.length) { - const t = Math.max(m.length, l.length); - for (let q = 0, u, n; q < t; q++) { - if ((n = l[q]) && n.length) { - if ((u = m[q]) && u.length) { - for (r = 0; r < n.length; r++) { - u.push(n[r]); + l.length && (c ? e.put(l, f + ":" + h) : e.get(f + ":" + h).onsuccess = function() { + let n = this.result; + var q; + if (n && n.length) { + const u = Math.max(n.length, l.length); + for (let r = 0, t, m; r < u; r++) { + if ((m = l[r]) && m.length) { + if ((t = n[r]) && t.length) { + for (q = 0; q < m.length; q++) { + t.push(m[q]); } } else { - m[q] = n; + n[r] = m; } - r = 1; + q = 1; } } } else { - m = l, r = 1; + n = l, q = 1; } - r && e.put(m, f + ":" + h); + q && e.put(n, f + ":" + h); }); } } }), a.store ? await this.transaction("reg", "readwrite", function(e) { for (const d of a.store) { const f = d[0], g = d[1]; - e.put("object" === typeof g ? JSON.stringify(g) : 1, f); + e.put(typeof g === "object" ? JSON.stringify(g) : 1, f); } }) : a.bypass || await this.transaction("reg", "readwrite", function(e) { for (const d of a.reg.keys()) { @@ -2853,14 +2860,14 @@ w.commit = async function(a, b, c) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function Gb(a, b, c) { +function Gb(a, c, b) { const e = a.value; let d, f = 0; for (let g = 0, k; g < e.length; g++) { - if (k = c ? e : e[g]) { - for (let h = 0, l, m; h < b.length; h++) { - if (m = b[h], l = k.indexOf(m), 0 <= l) { - if (d = 1, 1 < k.length) { + if (k = b ? e : e[g]) { + for (let h = 0, l, n; h < c.length; h++) { + if (n = c[h], l = k.indexOf(n), l >= 0) { + if (d = 1, k.length > 1) { k.splice(l, 1); } else { e[g] = []; @@ -2870,7 +2877,7 @@ function Gb(a, b, c) { } f += k.length; } - if (c) { + if (b) { break; } } @@ -2878,42 +2885,42 @@ function Gb(a, b, c) { a.continue(); } w.remove = function(a) { - "object" !== typeof a && (a = [a]); - return Promise.all([this.transaction("map", "readwrite", function(b) { - b.openCursor().onsuccess = function() { - const c = this.result; - c && Gb(c, a); + typeof a !== "object" && (a = [a]); + return Promise.all([this.transaction("map", "readwrite", function(c) { + c.openCursor().onsuccess = function() { + const b = this.result; + b && Gb(b, a); }; - }), this.transaction("ctx", "readwrite", function(b) { - b.openCursor().onsuccess = function() { - const c = this.result; - c && Gb(c, a); + }), this.transaction("ctx", "readwrite", function(c) { + c.openCursor().onsuccess = function() { + const b = this.result; + b && Gb(b, a); }; - }), this.transaction("tag", "readwrite", function(b) { - b.openCursor().onsuccess = function() { - const c = this.result; - c && Gb(c, a, !0); + }), this.transaction("tag", "readwrite", function(c) { + c.openCursor().onsuccess = function() { + const b = this.result; + b && Gb(b, a, !0); }; - }), this.transaction("reg", "readwrite", function(b) { - for (let c = 0; c < a.length; c++) { - b.delete(a[c]); + }), this.transaction("reg", "readwrite", function(c) { + for (let b = 0; b < a.length; b++) { + c.delete(a[b]); } })]); }; -function Z(a, b) { - return new Promise((c, e) => { +function Z(a, c) { + return new Promise((b, e) => { a.onsuccess = a.oncomplete = function() { - b && b(this.result); - b = null; - c(this.result); + c && c(this.result); + c = null; + b(this.result); }; a.onerror = a.onblocked = e; a = null; }); } -;const Hb = {Index:V, Charset:wa, Encoder:la, Document:Na, Worker:La, Resolver:Y, IndexedDB:Fb, Language:{}}, Ib = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +;const Hb = {Index:T, Charset:xa, Encoder:la, Document:Oa, Worker:Ma, Resolver:X, IndexedDB:Fb, Language:{}}, Ib = typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : self; let Jb; (Jb = Ib.define) && Jb.amd ? Jb([], function() { return Hb; -}) : "object" === typeof Ib.exports ? Ib.exports = Hb : Ib.FlexSearch = Hb; +}) : typeof Ib.exports === "object" ? Ib.exports = Hb : Ib.FlexSearch = Hb; }(this||self)); diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index e5a781c..de92a60 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,107 +1,107 @@ /**! - * FlexSearch.js v0.8.202 (Bundle) + * FlexSearch.js v0.8.203 (Bundle) * 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 w;function H(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function aa(a,b){return"undefined"===typeof a?b:a}function I(){return Object.create(null)} -function M(a){return"string"===typeof a}function ba(a){return"object"===typeof a}function ca(a){const b=[];for(const c of a.keys())b.push(c);return b}function ea(a,b){if(M(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=H(a.numeric,e)}else{try{this.split=H(this.split,fa)}catch(d){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);c=a.filter;this.filter="function"===typeof c?c:H(c&&new Set(c),null,this.filter);this.dedupe=H(a.dedupe,!0,this.dedupe);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,1024,this.maxlength);this.rtl=H(a.rtl,!1,this.rtl);if(this.cache=c=H(a.cache,!0,this.cache))this.I=null,this.R="number"===typeof c?c:2E5,this.C=new Map,this.H=new Map,this.M=this.L=128;this.h="";this.N=null;this.B="";this.O=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.B+= -(this.B?"|":"")+d;return this};w.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.B+=(this.B?"|":"")+a;this.O=null;this.cache&&Q(this);return this};w.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&Q(this);return this}; -w.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.N=null;this.cache&&Q(this);return this}; -w.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&Q(this);return this}; -w.encode=function(a,b){if(this.cache&&a.length<=this.L)if(this.I){if(this.C.has(a))return this.C.get(a)}else this.I=setTimeout(Q,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(b){if(d[m])continue;d[m]=1}else{if(f===m)continue;f=m}if(c)e.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.M)if(this.I){var k=this.H.get(m);if(k||""===k){k&&e.push(k);continue}}else this.I=setTimeout(Q,50,this);if(this.stemmer){this.O||(this.O=new RegExp("(?!^)("+ -this.B+")$"));let t;for(;t!==m&&2this.stemmer.get(r))}if(m&&(this.mapper||this.dedupe&&1this.matcher.get(t)));if(m&&this.replacer)for(k=0;m&&kthis.R&&(this.H.clear(),this.M=this.M/1.1|0));if(m){if(m!==q)if(b){if(d[m])continue;d[m]=1}else{if(g===m)continue;g=m}e.push(m)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.L&&(this.C.set(a,e),this.C.size>this.R&&(this.C.clear(),this.L=this.L/1.1|0));return e};function Q(a){a.I=null;a.C.clear();a.H.clear()};function ma(a,b,c){c||(b||"object"!==typeof a?"object"===typeof b&&(c=b,b=0):c=a);c&&(a=c.query||a,b=c.limit||b);let e=""+(b||0);c&&(e+=(c.offset||0)+!!c.context+!!c.suggest+(!1!==c.resolve)+(c.resolution||this.resolution)+(c.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new R);let d=this.cache.get(a+e);if(!d){const f=c&&c.cache;f&&(c.cache=!1);d=this.search(a,b,c);f&&(c.cache=f);this.cache.set(a+e,d)}return d}function R(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""} -R.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};R.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};R.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};R.prototype.clear=function(){this.cache.clear();this.h=""};const na={normalize:!1,numeric:!1,dedupe:!1};const qa={};const ra=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"]]);const sa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ta=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ua={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 va={Exact:na,Default:qa,Normalize:qa,LatinBalance:{mapper:ra},LatinAdvanced:{mapper:ra,matcher:sa,replacer:ta},LatinExtra:{mapper:ra,replacer:ta.concat([/(?!^)[aeo]/g,""]),matcher:sa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} -function xa(a){if(!this||this.constructor!==xa)return new xa(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,h,k;g=this.priority*this.priority*3):(Ha=setTimeout(Ka,0),Ia=Date.now());if(Ja){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let W=0; -function La(a={},b){function c(h){function k(l){l=l.data||l;const m=l.id,q=m&&f.h[m];q&&(q(l.msg),delete f.h[m])}this.worker=h;this.h=I();if(this.worker){d?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(l){1E9b?a.slice(c,c+b):a,e?Ta.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}g=g.slice(c,c+b);h=g.length;c=0}h>b&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?Ta.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ya(a,b,c,!1,this.h),c=0));d&&(this.await=null);return d?this.resolve(b,c,e,g):this};Y.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,b,c,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let h;if(a.length)if(this.result.length&&a.unshift(this.result),2>a.length)this.result=a[0];else{let k=0;for(let l=0,m,q;la.length)this.result=a[0];else{a:{f=c;var h=this.h;const k=[],l=I();let m=0;for(let q=0,t;qD&&(D=n.length+(n?1:0)),B=n.length+(n?1:0)+F.length,G+=C,za.push(v.length),v.push({match:F})),n+=(n?" ":"")+F)}if(!x)E=y[A],n+=(n?" ":"")+E,k&&v.push({text:E});else if(k&&G>=k)break}G=za.length*(f.length-2);if(r||u||k&&n.length-G>k)if(G=k+G-2*t,A=B-D,0y&&(y=0)),v=v.length-1){if(J>= -v.length){A[x+1]=1;J>=y.length&&(G[x+1]=1);continue}C-=t}n=v[J].text;if(L=u&&z[x])if(0L)if(A[x+1]=1,l)n=n.substring(0,L);else continue;(L-=n.length)||(L=-1);z[x]=L}else{A[x+1]=1;continue}if(C+n.length+1<=k)n=" "+n,B[x]+=n;else if(l)U=k-C-1,0=J){if(0>J){A[x]=1;G[x]=1;continue}C-=t}n=v[J].text;if(L=r&&E[x])if(0L)if(A[x]=1,l)n=n.substring(n.length- -L);else continue;(L-=n.length)||(L=-1);E[x]=L}else{A[x]=1;continue}if(C+n.length+1<=k)n+=" ",B[x]=n+B[x];else if(l)U=n.length+1-(k-C),0<=U&&U=y.length-1?Qa=1:Jc||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+ -e)}else{d=[];for(let q=0,t;qe)e-=t.length;else{if(c&&t.length>c||e)t=t.slice(e,c+e),c-=t.length,e&&(e-=t.length);d.push(t);if(!c)break}k=d}}return k} -function Ya(a,b,c,e,d){const f=[],g=I();let h;var k=a.length;let l;if(e)for(d=k-1;0<=d;d--){if(l=(e=a[d])&&e.length)for(k=0;kc||e)a=a.slice(e,e+c);d&&(a=Ta.call(this,a))}return a} -function Ta(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);const b=Array(a.length);for(let c=0,e;c1)return this.addMatcher(a,b);this.mapper||(this.mapper=new Map);this.mapper.set(a,b);this.cache&&Q(this);return this};w.addMatcher=function(a,b){if(typeof a==="object")return this.addReplacer(a,b);if(a.length<2&&(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.J=null;this.cache&&Q(this);return this}; +w.addReplacer=function(a,b){if(typeof a==="string")return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&Q(this);return this}; +w.encode=function(a,b){if(this.cache&&a.length<=this.H)if(this.F){if(this.B.has(a))return this.B.get(a)}else this.F=setTimeout(Q,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(ia,"$1 $2").replace(ja,"$1 $2").replace(ha,"$1 "));const c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let e= +[],d=I(),f,g,h=this.split||this.split===""?a.split(this.split):[a];for(let l=0,m,n;lthis.maxlength)){if(b){if(d[m])continue;d[m]=1}else{if(f===m)continue;f=m}if(c)e.push(m);else if(!this.filter||(typeof this.filter==="function"?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.I)if(this.F){var k=this.D.get(m);if(k||k===""){k&&e.push(k);continue}}else this.F=setTimeout(Q,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+ +this.A+")$"));let u;for(;u!==m&&m.length>2;)u=m,m=m.replace(this.K,r=>this.stemmer.get(r))}if(m&&(this.mapper||this.dedupe&&m.length>1)){k="";for(let u=0,r="",t,p;u1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),m=m.replace(this.J,u=>this.matcher.get(u)));if(m&&this.replacer)for(k=0;m&&kthis.L&&(this.D.clear(),this.I=this.I/1.1|0));if(m){if(m!==n)if(b){if(d[m])continue;d[m]=1}else{if(g===m)continue;g=m}e.push(m)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.H&&(this.B.set(a,e),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0));return e};function Q(a){a.F=null;a.B.clear();a.D.clear()};function ma(a,b,c){c||(b||typeof a!=="object"?typeof b==="object"&&(c=b,b=0):c=a);c&&(a=c.query||a,b=c.limit||b);let e=""+(b||0);c&&(e+=(c.offset||0)+!!c.context+!!c.suggest+(c.resolve!==!1)+(c.resolution||this.resolution)+(c.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new na);let d=this.cache.get(a+e);if(!d){const f=c&&c.cache;f&&(c.cache=!1);d=this.search(a,b,c);f&&(c.cache=f);this.cache.set(a+e,d)}return d}function na(a){this.limit=a&&a!==!0?a:1E3;this.cache=new Map;this.h=""} +na.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};na.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};na.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};na.prototype.clear=function(){this.cache.clear();this.h=""};const oa={normalize:!1,numeric:!1,dedupe:!1};const ra={};const sa=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"]]);const ta=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ua=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const va={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 wa={Exact:oa,Default:ra,Normalize:ra,LatinBalance:{mapper:sa},LatinAdvanced:{mapper:sa,matcher:ta,replacer:ua},LatinExtra:{mapper:sa,replacer:ua.concat([/(?!^)[aeo]/g,""]),matcher:ta},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} +function Aa(a){if(!this||this.constructor!==Aa)return new Aa(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if(e==="length")return b.length;if(e==="push")return function(d){b.index[b.index.length-1].push(d);b.length++};if(e==="pop")return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if(e==="indexOf")return function(d){let f=0;for(let g=0,h,k;g=0)return f+k;f+=h.length}return-1}; +if(e==="includes")return function(d){for(let f=0;f32?(this.B=Ba,this.A=BigInt(a)):(this.B=Ca,this.A=a)}R.prototype.get=function(a){const b=this.index[this.B(a)];return b&&b.get(a)};R.prototype.set=function(a,b){var c=this.B(a);let e=this.index[c];e?(c=e.size,e.set(a,b),(c-=e.size)&&this.size++):(this.index[c]=e=new Map([[a,b]]),this.h.push(e),this.size++)}; +function S(a=8){if(!this||this.constructor!==S)return new S(a);this.index=I();this.h=[];this.size=0;a>32?(this.B=Ba,this.A=BigInt(a)):(this.B=Ca,this.A=a)}S.prototype.add=function(a){var b=this.B(a);let c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c),this.size++)};w=R.prototype;w.has=S.prototype.has=function(a){const b=this.index[this.B(a)];return b&&b.has(a)}; +w.delete=S.prototype.delete=function(a){const b=this.index[this.B(a)];b&&b.delete(a)&&this.size--};w.clear=S.prototype.clear=function(){this.index=I();this.h=[];this.size=0};w.values=S.prototype.values=function*(){for(let a=0;a=this.priority*this.priority*3):(Ia=setTimeout(La,0),Ja=Date.now());if(Ka){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let V=0; +function Ma(a={},b){function c(h){function k(l){l=l.data||l;const m=l.id,n=m&&f.h[m];n&&(n(l.msg),delete f.h[m])}this.worker=h;this.h=I();if(this.worker){d?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(l){V>1E9&&(V=0);f.h[++V]=function(){l(f)};f.worker.postMessage({id:V,task:"init",factory:e,options:a})});this.priority=a.priority||4;this.encoder=b||null;this.worker.postMessage({task:"init",factory:e,options:a});return this}}if(!this||this.constructor!==Ma)return new Ma(a); +let e=typeof self!=="undefined"?self._factory:typeof window!=="undefined"?window._factory:null;e&&(e=e.toString());const d=typeof window==="undefined",f=this,g=Na(e,d,a.worker);return g.then?g.then(function(h){return c.call(f,h)}):c.call(this,g)}W("add");W("append");W("search");W("update");W("remove");W("clear");W("export");W("import");Ma.prototype.searchCache=ma;Ga(Ma.prototype); +function W(a){Ma.prototype[a]=function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;typeof e==="function"&&(d=e,c.pop());e=new Promise(function(f){a==="export"&&typeof c[0]==="function"&&(c[0]=null);V>1E9&&(V=0);b.h[++V]=f;b.worker.postMessage({task:a,id:V,args:c})});return d?(e.then(d),this):e}} +function Na(a,b,c){return b?typeof module!=="undefined"?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="+Fa.toString()],{type:"text/javascript"}))):new window.Worker(typeof c==="string"?c:(0,eval)("import.meta.url").replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", +"module/worker/worker.js"),{type:"module"})};Oa.prototype.add=function(a,b,c){ba(a)&&(b=a,a=ea(b,this.key));if(b&&(a||a===0)){if(!c&&this.reg.has(a))return this.update(a,b);for(let h=0,k;hb?a.slice(c,c+b):a,e?Ua.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}g=g.slice(c,c+b);h=g.length;c=0}h>b&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?Ua.call(this,g):g;d.push(g);b-=h;if(!b)break}d=d.length>1?[].concat.apply([],d):d[0];return e?Ua.call(this,d):d};function Va(a,b,c,e){var d=e[0];if(d[0]&&d[0].query)return a[b].apply(a,d);if(!(b!=="and"&&b!=="not"||a.result.length||a.await||d.suggest))return e.length>1&&(d=e[e.length-1]),(e=d.resolve)?a.await||a.result:a;let f=[],g=0,h=0,k,l,m,n,u;for(b=0;b1&&(c=c[b].apply(c,a.slice(1)));return c};X.prototype.or=function(){return Va(this,"or",Ya,arguments)};function Ya(a,b,c,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Za(a,b,c,!1,this.h),c=0));d&&(this.await=null);return d?this.resolve(b,c,e,g):this};X.prototype.and=function(){return Va(this,"and",$a,arguments)};function $a(a,b,c,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let h;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let k=0;for(let l=0,m,n;l1?z.join(" "):z[0];let y;if(z&&E){var D=E.length,K=(da.split? +E.replace(da.split,""):E).length-z.length,F="",N=0;for(var O=0;O-1&&(F=(P?E.substring(0,P):"")+g+E.substring(P,P+L)+h+(P+L=k)break}G=za.length*(f.length-2);if(r||t||k&&q.length-G>k)if(G=k+G-u*2,B=C-A,r>0&& +(B+=r),t>0&&(B+=t),B<=G)x=r?A-(r>0?r:0):A-((G-B)/2|0),v=t?C+(t>0?t:0):x+G,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-1){if(J>= +v.length){B[y+1]=1;J>=x.length&&(G[y+1]=1);continue}D-=u}q=v[J].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(B[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{B[y+1]=1;continue}if(D+q.length+1<=k)q=" "+q,C[y]+=q;else if(l)U=k-D-1,U>0&&(q=" "+q.substring(0,U),C[y]+=q),B[y+1]=1;else{B[y+1]=1;continue}}else{if(B[y])continue;J-=K;if(A[J]){D-=u;B[y]=1;G[y]=1;continue}if(J<=0){if(J<0){B[y]=1;G[y]=1;continue}D-=u}q=v[J].text;if(L=r&&E[y])if(L>0){if(q.length>L)if(B[y]=1,l)q=q.substring(q.length- +L);else continue;(L-=q.length)||(L=-1);E[y]=L}else{B[y]=1;continue}if(D+q.length+1<=k)q+=" ",C[y]=q+C[y];else if(l)U=q.length+1-(k-D),U>=0&&U=x.length-1?Qa=1:J1?Za(k,c,e,g,f):(k=k[0])&&c&&k.length>c||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+ +e)}else{d=[];for(let n=0,u;ne)e-=u.length;else{if(c&&u.length>c||e)u=u.slice(e,c+e),c-=u.length,e&&(e-=u.length);d.push(u);if(!c)break}k=d}}return k} +function Za(a,b,c,e,d){const f=[],g=I();let h;var k=a.length;let l;if(e)for(d=k-1;d>=0;d--){if(l=(e=a[d])&&e.length)for(k=0;k=0;m--){n=a[m];for(let r=0;r1?ab(d,1,0,0,k,l):d[0],E)})}return r?d:new X(d.length>1?ab(d,1,0,0,k,l):d[0],this)}}r||g||!(n=n||this.field)||(M(n)?g=n:(n.constructor===Array&&n.length===1&&(n=n[0]),g=n.field||n.index));n&&n.constructor!==Array&&(n=[n])}n||(n=this.field);let G;v=(this.worker||this.db)&&!e&&[];for(let E=0,z,D,K;E0){if(c&&b>c||e)a=a.slice(e,e+c);d&&(a=Ua.call(this,a))}return a} +function Ua(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);const b=Array(a.length);for(let c=0,e;c1?c:c[0]}w.append=function(a,b){return this.add(a,b,!0)}; +w.update=function(a,b){return this.remove(a).add(a,b)};w.remove=function(a){ba(a)&&(a=ea(a,this.key));for(var b of this.index.values())b.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(let c of this.tag.values())for(let e of c){b=e[0];const d=e[1],f=d.indexOf(a);f>-1&&(d.length>1?d.splice(f,1):c.delete(b))}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; w.clear=function(){const a=[];for(const b of this.index.values()){const c=b.clear();c.then&&a.push(c)}if(this.tag)for(const b of this.tag.values())b.clear();this.store&&this.store.clear();this.cache&&this.cache.clear();return a.length?Promise.all(a):this};w.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.reg.has(a)};w.cleanup=function(){for(const a of this.index.values())a.cleanup();return this}; -w.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};w.set=function(a,b){"object"===typeof a&&(b=a,a=ea(b,this.key));this.store.set(a,b);return this};w.searchCache=ma;w.export=jb;w.import=kb;Fa(Na.prototype);function lb(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function mb(a,b){b||(b=new Map);for(let c=0,e;cp;f--){g=u.substring(p,f);n=this.rtl?d-1-p:p;var h=this.score?this.score(b,u,r,g,n):wb(t, -l,r,d,n);xb(this,q,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,r,h-1,k-1),n=this.bidirectional&&u>f;xb(this,m,n?f:u,p,a,c,n?u:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.S&&ub(this));return this}; -function xb(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=I()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new xa(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function wb(a,b,c,e,d){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function V(a,b){if(!this||this.constructor!==V)return new V(a);if(a){var c=M(a)?a:a.preset;c&&(a=Object.assign({},vb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=M(a.encoder)?va[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new la(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.T=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new R(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.S=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}w=V.prototype; -w.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};w.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};w.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function ub(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} +w.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};w.set=function(a,b){typeof a==="object"&&(b=a,a=ea(b,this.key));this.store.set(a,b);return this};w.searchCache=ma;w.export=kb;w.import=lb;Ga(Oa.prototype);function mb(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function nb(a,b){b||(b=new Map);for(let c=0,e;c2?c[0]:"";c=c.length>2?c[2]:c[1];if(this.worker&&e)return this.index.get(e).import(a);if(b){typeof b==="string"&&(b=JSON.parse(b));if(e)return this.index.get(e).import(c,b);switch(c){case "reg":this.fastupdate=!1;this.reg=rb(b,this.reg);for(let d=0,f;d=0&&d.splice(g,1)}}else ub(this.map,a),this.depth&&ub(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.M&&vb(this));this.cache&&this.cache.remove(a);return this}; +function ub(a,b){let c=0;var e=typeof b==="undefined";if(a.constructor===Array)for(let d=0,f,g,h;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(c)return 1;h=1}else{if(h)return 1;c++}}}else for(let d of a.entries())e=d[0],ub(d[1],b)?c++:a.delete(e);return c};const wb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,b,c,e){if(b&&(a||a===0)){if(!e&&!c&&this.reg.has(a))return this.update(a,b);e=this.depth;b=this.encoder.encode(b,!e);const l=b.length;if(l){const m=I(),n=I(),u=this.resolution;for(let r=0;r2)for(let p=1,q,x,v,A;p2){for(let p=0,q;pp;f--)if(g=t.substring(p,f),!n[g]){q=this.rtl?d-1-p:p;var h=this.score?this.score(b,t,r,g,q):xb(u,l,r,d,q);Y(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(d>1){for(h=d-1;h>0;h--)if(g=t[this.rtl?d-1-h:h]+g,!n[g]){var k=this.score?this.score(b,t,r,g,h):xb(u,l,r,d,h);Y(this,n,g,k,a,c)}g=""}case "forward":if(d>1){for(h=0;h1&&rg?0:1),l,r,h-1,k-1),q=this.bidirectional&&t>f;Y(this,m,q?f:t,p,a,c,q?t:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.M&&vb(this));return this}; +function Y(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=I()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new Aa(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} +function xb(a,b,c,e,d){return c&&a>1?b+(e||0)<=a?c+(d||0):(a-1)/(b+(e||0))*(c+(d||0))+1|0:0};T.prototype.search=function(a,b,c){c||(b||typeof a!=="object"?typeof b==="object"&&(c=b,b=0):(c=a,a=""));if(c&&c.cache)return c.cache=!1,a=this.searchCache(a,b,c),c.cache=!0,a;let e=[],d,f,g,h=0,k,l,m,n,u;c&&(a=c.query||a,b=c.limit||b,h=c.offset||0,f=c.context,g=c.suggest,u=(k=c.resolve)&&c.enrich,m=c.boost,n=c.resolution,l=this.db&&c.tag);typeof k==="undefined"&&(k=this.resolve);f=this.depth&&f!==!1;let r=this.encoder.encode(a,!f);d=r.length;b=b||(k?100:0);if(d===1)return yb.call(this,r[0],"",b, +h,k,u,l);if(d===2&&f&&!g)return yb.call(this,r[1],r[0],b,h,k,u,l);let t=I(),p=0,q;f&&(q=r[0],p=1);n||n===0||(n=q?this.N:this.resolution);if(this.db){if(this.db.search&&(c=this.db.search(this,r,b,h,g,k,u,l),c!==!1))return c;const x=this;return async function(){for(let v,A;p1)k=ab(a,b,c,e,d,f,g);else if(h===1)return g?Ta.call(null,a[0],c,e):new X(a[0],this);return g?k:new X(k,this)} +function yb(a,b,c,e,d,f,g){a=zb(this,a,b,c,e,d,f,g);return this.db?a.then(function(h){return d?h||[]:new X(h,this)}):a&&a.length?d?Ta.call(this,a,c,e):new X(a,this):d?[]:new X([],this)}function Ab(a,b,c,e){let d=[];if(a&&a.length){if(a.length<=e){b.push(a);return}for(let f=0,g;fc)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function T(a,b){if(!this||this.constructor!==T)return new T(a);if(a){var c=M(a)?a:a.preset;c&&(a=Object.assign({},wb[c],a))}else a={};c=a.context;const e=c===!0?{depth:1}:c||{},d=M(a.encoder)?wa[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:typeof d==="object"?new la(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&c!=="default"&&c!=="exact"&&c||"strict";this.depth=c==="strict"&&e.depth||0;this.bidirectional=e.bidirectional!==!1;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new R(c):new Map;this.ctx=c?new R(c):new Map;this.reg=b||(this.fastupdate?c?new R(c):new Map:c?new S(c):new Set);this.N=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new na(c);this.resolve=a.resolve!==!1;if(c=a.db)this.db=this.mount(c);this.M=a.commit!==!1;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}w=T.prototype; +w.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};w.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};w.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function vb(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this};w.append=function(a,b){return this.add(a,b,!0)};w.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};w.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; -w.cleanup=function(){if(!this.fastupdate)return this;tb(this.map);this.depth&&tb(this.ctx);return this};w.searchCache=ma;w.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=pb(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=lb(this.map,this.reg.size);break;case 3:d="ctx";f=nb(this.ctx,this.reg.size);break;default:return}return rb.call(this,a,b,d,f,c,e)}; -w.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length){e-=m.length;continue}const q=c?e+Math.min(m.length-e,c):m.length;for(let t=e;t1?a[1]:a[0],a){case "reg":this.fastupdate=!1;this.reg=rb(b,this.reg);break;case "map":this.map=nb(b,this.map);break;case "ctx":this.ctx=pb(b,this.ctx)}}; +w.serialize=function(a=!0){let b="",c="",e="";if(this.reg.size){let f;for(var d of this.reg.keys())f||(f=typeof d),b+=(b?",":"")+(f==="string"?'"'+d+'"':d);b="index.reg=new Set(["+b+"]);";c=tb(this.map,f);c="index.map=new Map(["+c+"]);";for(const g of this.ctx.entries()){d=g[0];let h=tb(g[1],f);h="new Map(["+h+"])";h='["'+d+'",'+h+"]";e+=(e?",":"")+h}e="index.ctx=new Map(["+e+"]);"}return a?"function inject(index){"+b+c+e+"}":b+c+e};Ga(T.prototype);const Cb=typeof window!=="undefined"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Db=["map","ctx","tag","reg","cfg"],Eb=I(); +function Fb(a,b={}){if(!this||this.constructor!==Fb)return new Fb(a,b);typeof a==="object"&&(b=a,a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.type=b.type;this.fastupdate=this.support_tag_search=!1;this.db=null;this.h={}}w=Fb.prototype;w.mount=function(a){if(a.index)return a.mount(this);a.db=this;return this.open()}; +w.open=function(){if(this.db)return this.db;let a=this;navigator.storage&&navigator.storage.persist();Eb[a.id]||(Eb[a.id]=[]);Eb[a.id].push(a.field);const b=Cb.open(a.id,1);b.onupgradeneeded=function(){const c=a.db=this.result;for(let e=0,d;e=m.length){e-=m.length;continue}const n=c?e+Math.min(m.length-e,c):m.length;for(let u=e;u=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; -w.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};const Hb={Index:V,Charset:va,Encoder:la,Document:Na,Worker:La,Resolver:Y,IndexedDB:Fb,Language:{}},Ib="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let Jb;(Jb=Ib.define)&&Jb.amd?Jb([],function(){return Hb}):"object"===typeof Ib.exports?Ib.exports=Hb:Ib.FlexSearch=Hb;}(this||self)); +for(let m=0,n,u;m=0)if(d=1,h.length>1)h.splice(l,1);else{e[g]=[];break}f+=h.length}if(c)break}f?d&&a.update(e):a.delete();a.continue()} +w.remove=function(a){typeof a!=="object"&&(a=[a]);return Promise.all([this.transaction("map","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&Gb(c,a)}}),this.transaction("ctx","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&Gb(c,a)}}),this.transaction("tag","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&Gb(c,a,!0)}}),this.transaction("reg","readwrite",function(b){for(let c=0;c{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};const Hb={Index:T,Charset:wa,Encoder:la,Document:Oa,Worker:Ma,Resolver:X,IndexedDB:Fb,Language:{}},Ib=typeof self!=="undefined"?self:typeof global!=="undefined"?global:self;let Jb;(Jb=Ib.define)&&Jb.amd?Jb([],function(){return Hb}):typeof Ib.exports==="object"?Ib.exports=Hb:Ib.FlexSearch=Hb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index 0753e7e..0fc284b 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,35 +1,35 @@ /**! - * FlexSearch.js v0.8.202 (Bundle/Module/Debug) + * FlexSearch.js v0.8.203 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var w; -function H(a, b, c) { - const e = typeof c, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { - if (c) { - if ("function" === d && e === d) { +function H(a, c, b) { + const e = typeof b, d = typeof a; + if (e !== "undefined") { + if (d !== "undefined") { + if (b) { + if (d === "function" && e === d) { return function(k) { - return a(c(k)); + return a(b(k)); }; } - b = a.constructor; - if (b === c.constructor) { - if (b === Array) { - return c.concat(a); + c = a.constructor; + if (c === b.constructor) { + if (c === Array) { + return b.concat(a); } - if (b === Map) { - var f = new Map(c); + if (c === Map) { + var f = new Map(b); for (var g of a) { f.set(g[0], g[1]); } return f; } - if (b === Set) { - g = new Set(c); + if (c === Set) { + g = new Set(b); for (f of a.values()) { g.add(f); } @@ -39,35 +39,35 @@ function H(a, b, c) { } return a; } - return c; + return b; } - return "undefined" === d ? b : a; + return d === "undefined" ? c : a; } -function aa(a, b) { - return "undefined" === typeof a ? b : a; +function aa(a, c) { + return typeof a === "undefined" ? c : a; } function I() { return Object.create(null); } function N(a) { - return "string" === typeof a; + return typeof a === "string"; } function ba(a) { - return "object" === typeof a; + return typeof a === "object"; } function ca(a) { - const b = []; - for (const c of a.keys()) { - b.push(c); + const c = []; + for (const b of a.keys()) { + c.push(b); } - return b; + return c; } -function da(a, b) { - if (N(b)) { - a = a[b]; +function da(a, c) { + if (N(c)) { + a = a[c]; } else { - for (let c = 0; a && c < b.length; c++) { - a = a[b[c]]; + for (let b = 0; a && b < c.length; b++) { + a = a[c[b]]; } } return a; @@ -88,27 +88,27 @@ function la(a = {}) { w = la.prototype; w.assign = function(a) { this.normalize = H(a.normalize, !0, this.normalize); - let b = a.include, c = b || a.exclude || a.split, e; - if (c || "" === c) { - if ("object" === typeof c && c.constructor !== RegExp) { + let c = a.include, b = c || a.exclude || a.split, e; + if (b || b === "") { + if (typeof b === "object" && b.constructor !== RegExp) { let d = ""; - e = !b; - b || (d += "\\p{Z}"); - c.letter && (d += "\\p{L}"); - c.number && (d += "\\p{N}", e = !!b); - c.symbol && (d += "\\p{S}"); - c.punctuation && (d += "\\p{P}"); - c.control && (d += "\\p{C}"); - if (c = c.char) { - d += "object" === typeof c ? c.join("") : c; + e = !c; + c || (d += "\\p{Z}"); + b.letter && (d += "\\p{L}"); + b.number && (d += "\\p{N}", e = !!c); + b.symbol && (d += "\\p{S}"); + b.punctuation && (d += "\\p{P}"); + b.control && (d += "\\p{C}"); + if (b = b.char) { + d += typeof b === "object" ? b.join("") : b; } try { - this.split = new RegExp("[" + (b ? "^" : "") + d + "]+", "u"); + this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); } catch (f) { - console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; + console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = c, e = !1 === c || 2 > "a1a".split(c).length; + this.split = b, e = b === !1 || "a1a".split(b).length < 2; } this.numeric = H(a.numeric, e); } else { @@ -121,23 +121,23 @@ w.assign = function(a) { } this.prepare = H(a.prepare, null, this.prepare); this.finalize = H(a.finalize, null, this.finalize); - c = a.filter; - this.filter = "function" === typeof c ? c : H(c && new Set(c), null, this.filter); + b = a.filter; + this.filter = typeof b === "function" ? b : H(b && new Set(b), null, this.filter); this.dedupe = H(a.dedupe, !0, this.dedupe); - 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.matcher = H((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = H((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = H((b = a.stemmer) && new Map(b), null, this.stemmer); this.replacer = H(a.replacer, null, this.replacer); this.minlength = H(a.minlength, 1, this.minlength); this.maxlength = H(a.maxlength, 1024, this.maxlength); this.rtl = H(a.rtl, !1, this.rtl); - if (this.cache = c = H(a.cache, !0, this.cache)) { - this.I = null, this.R = "number" === typeof c ? c : 2e5, this.C = new Map(), this.H = new Map(), this.M = this.L = 128; + if (this.cache = b = H(a.cache, !0, this.cache)) { + this.F = null, this.L = typeof b === "number" ? b : 2e5, this.B = new Map(), this.D = new Map(), this.I = this.H = 128; } this.h = ""; - this.N = null; - this.B = ""; - this.O = null; + this.J = null; + this.A = ""; + this.K = null; if (this.matcher) { for (const d of this.matcher.keys()) { this.h += (this.h ? "|" : "") + d; @@ -145,254 +145,254 @@ w.assign = function(a) { } if (this.stemmer) { for (const d of this.stemmer.keys()) { - this.B += (this.B ? "|" : "") + d; + this.A += (this.A ? "|" : "") + d; } } return this; }; -w.addStemmer = function(a, b) { +w.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, b); - this.B += (this.B ? "|" : "") + a; - this.O = null; - this.cache && Q(this); + this.stemmer.set(a, c); + this.A += (this.A ? "|" : "") + a; + this.K = null; + this.cache && ma(this); return this; }; w.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); - this.cache && Q(this); + typeof a === "function" ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); + this.cache && ma(this); return this; }; -w.addMapper = function(a, b) { - if ("object" === typeof a) { - return this.addReplacer(a, b); +w.addMapper = function(a, c) { + if (typeof a === "object") { + return this.addReplacer(a, c); } - if (1 < a.length) { - return this.addMatcher(a, b); + if (a.length > 1) { + return this.addMatcher(a, c); } this.mapper || (this.mapper = new Map()); - this.mapper.set(a, b); - this.cache && Q(this); + this.mapper.set(a, c); + this.cache && ma(this); return this; }; -w.addMatcher = function(a, b) { - if ("object" === typeof a) { - return this.addReplacer(a, b); +w.addMatcher = function(a, c) { + if (typeof a === "object") { + return this.addReplacer(a, c); } - if (2 > a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, b); + if (a.length < 2 && (this.dedupe || this.mapper)) { + return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, b); + this.matcher.set(a, c); this.h += (this.h ? "|" : "") + a; - this.N = null; - this.cache && Q(this); + this.J = null; + this.cache && ma(this); return this; }; -w.addReplacer = function(a, b) { - if ("string" === typeof a) { - return this.addMatcher(a, b); +w.addReplacer = function(a, c) { + if (typeof a === "string") { + return this.addMatcher(a, c); } this.replacer || (this.replacer = []); - this.replacer.push(a, b); - this.cache && Q(this); + this.replacer.push(a, c); + this.cache && ma(this); return this; }; -w.encode = function(a, b) { - if (this.cache && a.length <= this.L) { - if (this.I) { - if (this.C.has(a)) { - return this.C.get(a); +w.encode = function(a, c) { + if (this.cache && a.length <= this.H) { + if (this.F) { + if (this.B.has(a)) { + return this.B.get(a); } } else { - this.I = setTimeout(Q, 50, this); + this.F = setTimeout(ma, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase()); + this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(ia, "$1 $2").replace(ja, "$1 $2").replace(ha, "$1 ")); - const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let e = [], d = I(), f, g, k = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let l = 0, m, r; l < k.length; l++) { - if ((m = r = k[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { - if (b) { - if (d[m]) { - continue; - } - d[m] = 1; - } else { - if (f === m) { - continue; - } - f = m; - } + this.numeric && a.length > 3 && (a = a.replace(ia, "$1 $2").replace(ja, "$1 $2").replace(ha, "$1 ")); + const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let e = [], d = I(), f, g, k = this.split || this.split === "" ? a.split(this.split) : [a]; + for (let l = 0, n, q; l < k.length; l++) { + if ((n = q = k[l]) && !(n.length < this.minlength || n.length > this.maxlength)) { if (c) { - e.push(m); + if (d[n]) { + continue; + } + d[n] = 1; } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(m) : !this.filter.has(m))) { - if (this.cache && m.length <= this.M) { - if (this.I) { - var h = this.H.get(m); - if (h || "" === h) { + if (f === n) { + continue; + } + f = n; + } + if (b) { + e.push(n); + } else { + if (!this.filter || (typeof this.filter === "function" ? this.filter(n) : !this.filter.has(n))) { + if (this.cache && n.length <= this.I) { + if (this.F) { + var h = this.D.get(n); + if (h || h === "") { h && e.push(h); continue; } } else { - this.I = setTimeout(Q, 50, this); + this.F = setTimeout(ma, 50, this); } } if (this.stemmer) { - this.O || (this.O = new RegExp("(?!^)(" + this.B + ")$")); - let t; - for (; t !== m && 2 < m.length;) { - t = m, m = m.replace(this.O, q => this.stemmer.get(q)); + this.K || (this.K = new RegExp("(?!^)(" + this.A + ")$")); + let u; + for (; u !== n && n.length > 2;) { + u = n, n = n.replace(this.K, r => this.stemmer.get(r)); } } - if (m && (this.mapper || this.dedupe && 1 < m.length)) { + if (n && (this.mapper || this.dedupe && n.length > 1)) { h = ""; - for (let t = 0, q = "", u, n; t < m.length; t++) { - u = m.charAt(t), u === q && this.dedupe || ((n = this.mapper && this.mapper.get(u)) || "" === n ? n === q && this.dedupe || !(q = n) || (h += n) : h += q = u); + for (let u = 0, r = "", t, m; u < n.length; u++) { + t = n.charAt(u), t === r && this.dedupe || ((m = this.mapper && this.mapper.get(t)) || m === "" ? m === r && this.dedupe || !(r = m) || (h += m) : h += r = t); } - m = h; + n = h; } - this.matcher && 1 < m.length && (this.N || (this.N = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.N, t => this.matcher.get(t))); - if (m && this.replacer) { - for (h = 0; m && h < this.replacer.length; h += 2) { - m = m.replace(this.replacer[h], this.replacer[h + 1]); + this.matcher && n.length > 1 && (this.J || (this.J = new RegExp("(" + this.h + ")", "g")), n = n.replace(this.J, u => this.matcher.get(u))); + if (n && this.replacer) { + for (h = 0; n && h < this.replacer.length; h += 2) { + n = n.replace(this.replacer[h], this.replacer[h + 1]); } } - this.cache && r.length <= this.M && (this.H.set(r, m), this.H.size > this.R && (this.H.clear(), this.M = this.M / 1.1 | 0)); - if (m) { - if (m !== r) { - if (b) { - if (d[m]) { + this.cache && q.length <= this.I && (this.D.set(q, n), this.D.size > this.L && (this.D.clear(), this.I = this.I / 1.1 | 0)); + if (n) { + if (n !== q) { + if (c) { + if (d[n]) { continue; } - d[m] = 1; + d[n] = 1; } else { - if (g === m) { + if (g === n) { continue; } - g = m; + g = n; } } - e.push(m); + e.push(n); } } } } } this.finalize && (e = this.finalize(e) || e); - this.cache && a.length <= this.L && (this.C.set(a, e), this.C.size > this.R && (this.C.clear(), this.L = this.L / 1.1 | 0)); + this.cache && a.length <= this.H && (this.B.set(a, e), this.B.size > this.L && (this.B.clear(), this.H = this.H / 1.1 | 0)); return e; }; -function Q(a) { - a.I = null; - a.C.clear(); - a.H.clear(); +function ma(a) { + a.F = null; + a.B.clear(); + a.D.clear(); } -;function ma(a, b, c) { - c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : c = a); - c && (a = c.query || a, b = c.limit || b); - let e = "" + (b || 0); - c && (e += (c.offset || 0) + !!c.context + !!c.suggest + (!1 !== c.resolve) + (c.resolution || this.resolution) + (c.boost || 0)); +;function na(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : b = a); + b && (a = b.query || a, c = b.limit || c); + let e = "" + (c || 0); + b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (b.resolve !== !1) + (b.resolution || this.resolution) + (b.boost || 0)); a = ("" + a).toLowerCase(); - this.cache || (this.cache = new na()); + this.cache || (this.cache = new oa()); let d = this.cache.get(a + e); if (!d) { - const f = c && c.cache; - f && (c.cache = !1); - d = this.search(a, b, c); - f && (c.cache = f); + const f = b && b.cache; + f && (b.cache = !1); + d = this.search(a, c, b); + f && (b.cache = f); this.cache.set(a + e, d); } return d; } -function na(a) { - this.limit = a && !0 !== a ? a : 1000; +function oa(a) { + this.limit = a && a !== !0 ? a : 1000; this.cache = new Map(); this.h = ""; } -na.prototype.set = function(a, b) { - this.cache.set(this.h = a, b); +oa.prototype.set = function(a, c) { + this.cache.set(this.h = a, c); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -na.prototype.get = function(a) { - const b = this.cache.get(a); - b && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, b)); - return b; +oa.prototype.get = function(a) { + const c = this.cache.get(a); + c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c)); + return c; }; -na.prototype.remove = function(a) { - for (const b of this.cache) { - const c = b[0]; - b[1].includes(a) && this.cache.delete(c); +oa.prototype.remove = function(a) { + for (const c of this.cache) { + const b = c[0]; + c[1].includes(a) && this.cache.delete(b); } }; -na.prototype.clear = function() { +oa.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const qa = {normalize:!1, numeric:!1, dedupe:!1}; -const ra = {}; -const sa = 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"]]); -const ta = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), ua = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const va = {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 wa = {Exact:qa, Default:ra, Normalize:ra, LatinBalance:{mapper:sa}, LatinAdvanced:{mapper:sa, matcher:ta, replacer:ua}, LatinExtra:{mapper:sa, replacer:ua.concat([/(?!^)[aeo]/g, ""]), matcher:ta}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let c = 0; c < a.length; c++) { - var b = a[c]; - let e = b.charAt(0), d = va[e]; - for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = va[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { +const ra = {normalize:!1, numeric:!1, dedupe:!1}; +const sa = {}; +const ta = 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"]]); +const ua = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), va = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const wa = {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 xa = {Exact:ra, Default:sa, Normalize:sa, LatinBalance:{mapper:ta}, LatinAdvanced:{mapper:ta, matcher:ua, replacer:va}, LatinExtra:{mapper:ta, replacer:va.concat([/(?!^)[aeo]/g, ""]), matcher:ua}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { + for (let b = 0; b < a.length; b++) { + var c = a[b]; + let e = c.charAt(0), d = wa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), g === "h" || g === "w" || !(g = wa[g]) || g === d || (e += g, d = g, e.length !== 4)); f++) { } - a[c] = e; + a[b] = e; } -}}, CJK:{split:""}, LatinExact:qa, LatinDefault:ra, LatinSimple:ra}; -function xa(a, b, c, e) { +}}, CJK:{split:""}, LatinExact:ra, LatinDefault:sa, LatinSimple:sa}; +function Aa(a, c, b, e) { let d = []; for (let f = 0, g; f < a.index.length; f++) { - if (g = a.index[f], b >= g.length) { - b -= g.length; + if (g = a.index[f], c >= g.length) { + c -= g.length; } else { - b = g[e ? "splice" : "slice"](b, c); - const k = b.length; - if (k && (d = d.length ? d.concat(b) : b, c -= k, e && (a.length -= k), !c)) { + c = g[e ? "splice" : "slice"](c, b); + const k = c.length; + if (k && (d = d.length ? d.concat(c) : c, b -= k, e && (a.length -= k), !b)) { break; } - b = 0; + c = 0; } } return d; } -function Aa(a) { - if (!this || this.constructor !== Aa) { - return new Aa(a); +function Ba(a) { + if (!this || this.constructor !== Ba) { + return new Ba(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; - const b = this; - return new Proxy([], {get(c, e) { - if ("length" === e) { - return b.length; + const c = this; + return new Proxy([], {get(b, e) { + if (e === "length") { + return c.length; } - if ("push" === e) { + if (e === "push") { return function(d) { - b.index[b.index.length - 1].push(d); - b.length++; + c.index[c.index.length - 1].push(d); + c.length++; }; } - if ("pop" === e) { + if (e === "pop") { return function() { - if (b.length) { - return b.length--, b.index[b.index.length - 1].pop(); + if (c.length) { + return c.length--, c.index[c.index.length - 1].pop(); } }; } - if ("indexOf" === e) { + if (e === "indexOf") { return function(d) { let f = 0; - for (let g = 0, k, h; g < b.index.length; g++) { - k = b.index[g]; + for (let g = 0, k, h; g < c.index.length; g++) { + k = c.index[g]; h = k.indexOf(d); - if (0 <= h) { + if (h >= 0) { return f + h; } f += k.length; @@ -400,46 +400,61 @@ function Aa(a) { return -1; }; } - if ("includes" === e) { + if (e === "includes") { return function(d) { - for (let f = 0; f < b.index.length; f++) { - if (b.index[f].includes(d)) { + for (let f = 0; f < c.index.length; f++) { + if (c.index[f].includes(d)) { return !0; } } return !1; }; } - if ("slice" === e) { + if (e === "slice") { return function(d, f) { - return xa(b, d || 0, f || b.length, !1); + return Aa(c, d || 0, f || c.length, !1); }; } - if ("splice" === e) { + if (e === "splice") { return function(d, f) { - return xa(b, d || 0, f || b.length, !0); + return Aa(c, d || 0, f || c.length, !0); }; } - if ("constructor" === e) { + if (e === "constructor") { return Array; } - if ("symbol" !== typeof e) { - return (c = b.index[e / 2 ** 31 | 0]) && c[e]; + if (typeof e !== "symbol") { + return (b = c.index[e / 2 ** 31 | 0]) && b[e]; } - }, set(c, e, d) { - c = e / 2 ** 31 | 0; - (b.index[c] || (b.index[c] = []))[e] = d; - b.length++; + }, set(b, e, d) { + b = e / 2 ** 31 | 0; + (c.index[b] || (c.index[b] = []))[e] = d; + c.length++; return !0; }}); } -Aa.prototype.clear = function() { +Ba.prototype.clear = function() { this.index.length = 0; }; -Aa.prototype.destroy = function() { - this.proxy = this.index = null; +Ba.prototype.push = function() { }; -Aa.prototype.push = function() { +function Q(a = 8) { + if (!this || this.constructor !== Q) { + return new Q(a); + } + this.index = I(); + this.h = []; + this.size = 0; + a > 32 ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); +} +Q.prototype.get = function(a) { + const c = this.index[this.B(a)]; + return c && c.get(a); +}; +Q.prototype.set = function(a, c) { + var b = this.B(a); + let e = this.index[b]; + e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = new Map([[a, c]]), this.h.push(e), this.size++); }; function R(a = 8) { if (!this || this.constructor !== R) { @@ -448,164 +463,146 @@ function R(a = 8) { this.index = I(); this.h = []; this.size = 0; - 32 < a ? (this.C = Ba, this.B = BigInt(a)) : (this.C = Ca, this.B = a); + a > 32 ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); } -R.prototype.get = function(a) { - const b = this.index[this.C(a)]; - return b && b.get(a); +R.prototype.add = function(a) { + var c = this.B(a); + let b = this.index[c]; + b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = new Set([a]), this.h.push(b), this.size++); }; -R.prototype.set = function(a, b) { - var c = this.C(a); - let e = this.index[c]; - e ? (c = e.size, e.set(a, b), (c -= e.size) && this.size++) : (this.index[c] = e = new Map([[a, b]]), this.h.push(e), this.size++); +w = Q.prototype; +w.has = R.prototype.has = function(a) { + const c = this.index[this.B(a)]; + return c && c.has(a); }; -function S(a = 8) { - if (!this || this.constructor !== S) { - return new S(a); - } - this.index = I(); - this.h = []; - this.size = 0; - 32 < a ? (this.C = Ba, this.B = BigInt(a)) : (this.C = Ca, this.B = a); -} -S.prototype.add = function(a) { - var b = this.C(a); - let c = this.index[b]; - c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); +w.delete = R.prototype.delete = function(a) { + const c = this.index[this.B(a)]; + c && c.delete(a) && this.size--; }; -w = R.prototype; -w.has = S.prototype.has = function(a) { - const b = this.index[this.C(a)]; - return b && b.has(a); -}; -w.delete = S.prototype.delete = function(a) { - const b = this.index[this.C(a)]; - b && b.delete(a) && this.size--; -}; -w.clear = S.prototype.clear = function() { +w.clear = R.prototype.clear = function() { this.index = I(); this.h = []; this.size = 0; }; -w.values = S.prototype.values = function*() { +w.values = R.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { - for (let b of this.h[a].values()) { - yield b; + for (let c of this.h[a].values()) { + yield c; } } }; -w.keys = S.prototype.keys = function*() { +w.keys = R.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { - for (let b of this.h[a].keys()) { - yield b; + for (let c of this.h[a].keys()) { + yield c; } } }; -w.entries = S.prototype.entries = function*() { +w.entries = R.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { - for (let b of this.h[a].entries()) { - yield b; + for (let c of this.h[a].entries()) { + yield c; } } }; +function Da(a) { + let c = 2 ** this.A - 1; + if (typeof a == "number") { + return a & c; + } + let b = 0, e = this.A + 1; + for (let d = 0; d < a.length; d++) { + b = (b * e ^ a.charCodeAt(d)) & c; + } + return this.A === 32 ? b + 2 ** 31 : b; +} function Ca(a) { - let b = 2 ** this.B - 1; - if ("number" == typeof a) { - return a & b; + let c = BigInt(2) ** this.A - BigInt(1); + var b = typeof a; + if (b === "bigint") { + return a & c; } - let c = 0, e = this.B + 1; + if (b === "number") { + return BigInt(a) & c; + } + b = BigInt(0); + let e = this.A + BigInt(1); for (let d = 0; d < a.length; d++) { - c = (c * e ^ a.charCodeAt(d)) & b; + b = (b * e ^ BigInt(a.charCodeAt(d))) & c; } - return 32 === this.B ? c + 2 ** 31 : c; + return b; } -function Ba(a) { - let b = BigInt(2) ** this.B - BigInt(1); - var c = typeof a; - if ("bigint" === c) { - return a & b; - } - if ("number" === c) { - return BigInt(a) & b; - } - c = BigInt(0); - let e = this.B + BigInt(1); - for (let d = 0; d < a.length; d++) { - c = (c * e ^ BigInt(a.charCodeAt(d))) & b; - } - return c; -} -;let Da, T; -async function Ea(a) { +;let Ea, S; +async function Fa(a) { a = a.data; - var b = a.task; - const c = a.id; + var c = a.task; + const b = a.id; let e = a.args; - switch(b) { + switch(c) { case "init": - T = a.options || {}; - (b = a.factory) ? (Function("return " + b)()(self), Da = new self.FlexSearch.Index(T), delete self.FlexSearch) : Da = new V(T); - postMessage({id:c}); + S = a.options || {}; + (c = a.factory) ? (Function("return " + c)()(self), Ea = new self.FlexSearch.Index(S), delete self.FlexSearch) : Ea = new T(S); + postMessage({id:b}); break; default: let d; - if ("export" === b) { - if (!T.export || "function" !== typeof T.export) { + if (c === "export") { + if (!S.export || typeof S.export !== "function") { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } - e[1] ? (e[0] = T.export, e[2] = 0, e[3] = 1) : e = null; + e[1] ? (e[0] = S.export, e[2] = 0, e[3] = 1) : e = null; } - if ("import" === b) { - if (!T.import || "function" !== typeof T.import) { + if (c === "import") { + if (!S.import || typeof S.import !== "function") { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } - e[0] && (a = await T.import.call(Da, e[0]), Da.import(e[0], a)); + e[0] && (a = await S.import.call(Ea, e[0]), Ea.import(e[0], a)); } else { - (d = e && Da[b].apply(Da, e)) && d.then && (d = await d), d && d.await && (d = await d.await), "search" === b && d.result && (d = d.result); + (d = e && Ea[c].apply(Ea, e)) && d.then && (d = await d), d && d.await && (d = await d.await), c === "search" && d.result && (d = d.result); } - postMessage("search" === b ? {id:c, msg:d} : {id:c}); + postMessage(c === "search" ? {id:b, msg:d} : {id:b}); } } -;function Fa(a) { - Ga.call(a, "add"); - Ga.call(a, "append"); - Ga.call(a, "search"); - Ga.call(a, "update"); - Ga.call(a, "remove"); - Ga.call(a, "searchCache"); +;function Ga(a) { + Ha.call(a, "add"); + Ha.call(a, "append"); + Ha.call(a, "search"); + Ha.call(a, "update"); + Ha.call(a, "remove"); + Ha.call(a, "searchCache"); } -let Ha, Ia, Ja; -function Ka() { - Ha = Ja = 0; +let Ia, Ja, Ka; +function La() { + Ia = Ka = 0; } -function Ga(a) { +function Ha(a) { this[a + "Async"] = function() { - const b = arguments; - var c = b[b.length - 1]; + const c = arguments; + var b = c[c.length - 1]; let e; - "function" === typeof c && (e = c, delete b[b.length - 1]); - Ha ? Ja || (Ja = Date.now() - Ia >= this.priority * this.priority * 3) : (Ha = setTimeout(Ka, 0), Ia = Date.now()); - if (Ja) { + typeof b === "function" && (e = b, delete c[c.length - 1]); + Ia ? Ka || (Ka = Date.now() - Ja >= this.priority * this.priority * 3) : (Ia = setTimeout(La, 0), Ja = Date.now()); + if (Ka) { const f = this; return new Promise(g => { setTimeout(function() { - g(f[a + "Async"].apply(f, b)); + g(f[a + "Async"].apply(f, c)); }, 0); }); } - const d = this[a].apply(this, b); - c = d.then ? d : new Promise(f => f(d)); - e && c.then(e); - return c; + const d = this[a].apply(this, c); + b = d.then ? d : new Promise(f => f(d)); + e && b.then(e); + return b; }; } -;let W = 0; -function La(a = {}, b) { - function c(k) { +;let V = 0; +function Ma(a = {}, c) { + function b(k) { function h(l) { l = l.data || l; - const m = l.id, r = m && f.h[m]; - r && (r(l.msg), delete f.h[m]); + const n = l.id, q = n && f.h[n]; + q && (q(l.msg), delete f.h[n]); } this.worker = k; this.h = I(); @@ -613,109 +610,109 @@ function La(a = {}, b) { d ? this.worker.on("message", h) : this.worker.onmessage = h; if (a.config) { return new Promise(function(l) { - 1e9 < W && (W = 0); - f.h[++W] = function() { + V > 1e9 && (V = 0); + f.h[++V] = function() { l(f); }; - f.worker.postMessage({id:W, task:"init", factory:e, options:a}); + f.worker.postMessage({id:V, task:"init", factory:e, options:a}); }); } this.priority = a.priority || 4; - this.encoder = b || null; + this.encoder = c || null; this.worker.postMessage({task:"init", factory:e, options:a}); return this; } console.warn("Worker is not available on this platform. Please report on Github: https://github.com/nextapps-de/flexsearch/issues"); } - if (!this || this.constructor !== La) { - return new La(a); + if (!this || this.constructor !== Ma) { + return new Ma(a); } - let e = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + let e = typeof self !== "undefined" ? self._factory : typeof window !== "undefined" ? window._factory : null; e && (e = e.toString()); - const d = "undefined" === typeof window, f = this, g = Ma(e, d, a.worker); + const d = typeof window === "undefined", f = this, g = Na(e, d, a.worker); return g.then ? g.then(function(k) { - return c.call(f, k); - }) : c.call(this, g); + return b.call(f, k); + }) : b.call(this, g); } -X("add"); -X("append"); -X("search"); -X("update"); -X("remove"); -X("clear"); -X("export"); -X("import"); -La.prototype.searchCache = ma; -Fa(La.prototype); -function X(a) { - La.prototype[a] = function() { - const b = this, c = [].slice.call(arguments); - var e = c[c.length - 1]; +W("add"); +W("append"); +W("search"); +W("update"); +W("remove"); +W("clear"); +W("export"); +W("import"); +Ma.prototype.searchCache = na; +Ga(Ma.prototype); +function W(a) { + Ma.prototype[a] = function() { + const c = this, b = [].slice.call(arguments); + var e = b[b.length - 1]; let d; - "function" === typeof e && (d = e, c.pop()); + typeof e === "function" && (d = e, b.pop()); e = new Promise(function(f) { - "export" === a && "function" === typeof c[0] && (c[0] = null); - 1e9 < W && (W = 0); - b.h[++W] = f; - b.worker.postMessage({task:a, id:W, args:c}); + a === "export" && typeof b[0] === "function" && (b[0] = null); + V > 1e9 && (V = 0); + c.h[++V] = f; + c.worker.postMessage({task:a, id:V, args:b}); }); return d ? (e.then(d), this) : e; }; } -function Ma(a, b, c) { - return b ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + Ea.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function Na(a, c, b) { + return c ? typeof module !== "undefined" ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + Fa.toString()], {type:"text/javascript"}))) : new window.Worker(typeof b === "string" ? b : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;Na.prototype.add = function(a, b, c) { - ba(a) && (b = a, a = da(b, this.key)); - if (b && (a || 0 === a)) { - if (!c && this.reg.has(a)) { - return this.update(a, b); +;Qa.prototype.add = function(a, c, b) { + ba(a) && (c = a, a = da(c, this.key)); + if (c && (a || a === 0)) { + if (!b && this.reg.has(a)) { + return this.update(a, c); } for (let k = 0, h; k < this.field.length; k++) { - h = this.G[k]; + h = this.B[k]; var e = this.index.get(this.field[k]); - if ("function" === typeof h) { - var d = h(b); + if (typeof h === "function") { + var d = h(c); d && e.add(a, d, !1, !0); } else { - if (d = h.J, !d || d(b)) { - h.constructor === String ? h = ["" + h] : N(h) && (h = [h]), Qa(b, h, this.K, 0, e, a, h[0], c); + if (d = h.G, !d || d(c)) { + h.constructor === String ? h = ["" + h] : N(h) && (h = [h]), Ra(c, h, this.D, 0, e, a, h[0], b); } } } if (this.tag) { - for (e = 0; e < this.F.length; e++) { - var f = this.F[e], g = this.P[e]; + for (e = 0; e < this.A.length; e++) { + var f = this.A[e], g = this.F[e]; d = this.tag.get(g); let k = I(); - if ("function" === typeof f) { - if (f = f(b), !f) { + if (typeof f === "function") { + if (f = f(c), !f) { continue; } } else { - const h = f.J; - if (h && !h(b)) { + const h = f.G; + if (h && !h(c)) { continue; } f.constructor === String && (f = "" + f); - f = da(b, f); + f = da(c, f); } if (d && f) { N(f) && (f = [f]); - for (let h = 0, l, m; h < f.length; h++) { - if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !c || !m.includes(a))) { - if (m.length === 2 ** 31 - 1) { - g = new Aa(m); + for (let h = 0, l, n; h < f.length; h++) { + if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? n = g : d.set(l, n = []), !b || !n.includes(a))) { + if (n.length === 2 ** 31 - 1) { + g = new Ba(n); if (this.fastupdate) { - for (let r of this.reg.values()) { - r.includes(m) && (r[r.indexOf(m)] = g); + for (let q of this.reg.values()) { + q.includes(n) && (q[q.indexOf(n)] = g); } } - d.set(l, m = g); + d.set(l, n = g); } - m.push(a); - this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m])); + n.push(a); + this.fastupdate && ((g = this.reg.get(a)) ? g.push(n) : this.reg.set(a, [n])); } } } else { @@ -723,56 +720,56 @@ function Ma(a, b, c) { } } } - if (this.store && (!c || !this.store.has(a))) { + if (this.store && (!b || !this.store.has(a))) { let k; - if (this.D) { + if (this.h) { k = I(); - for (let h = 0, l; h < this.D.length; h++) { - l = this.D[h]; - if ((c = l.J) && !c(b)) { + for (let h = 0, l; h < this.h.length; h++) { + l = this.h[h]; + if ((b = l.G) && !b(c)) { continue; } - let m; - if ("function" === typeof l) { - m = l(b); - if (!m) { + let n; + if (typeof l === "function") { + n = l(c); + if (!n) { continue; } - l = [l.U]; + l = [l.O]; } else if (N(l) || l.constructor === String) { - k[l] = b[l]; + k[l] = c[l]; continue; } - Ra(b, k, l, 0, l[0], m); + Sa(c, k, l, 0, l[0], n); } } - this.store.set(a, k || b); + this.store.set(a, k || c); } this.worker && (this.fastupdate || this.reg.add(a)); } return this; }; -function Ra(a, b, c, e, d, f) { +function Sa(a, c, b, e, d, f) { a = a[d]; - if (e === c.length - 1) { - b[d] = f || a; + if (e === b.length - 1) { + c[d] = f || a; } else if (a) { if (a.constructor === Array) { - for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) { - Ra(a, b, c, e, d); + for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { + Sa(a, c, b, e, d); } } else { - b = b[d] || (b[d] = I()), d = c[++e], Ra(a, b, c, e, d); + c = c[d] || (c[d] = I()), d = b[++e], Sa(a, c, b, e, d); } } } -function Qa(a, b, c, e, d, f, g, k) { +function Ra(a, c, b, e, d, f, g, k) { if (a = a[g]) { - if (e === b.length - 1) { + if (e === c.length - 1) { if (a.constructor === Array) { - if (c[e]) { - for (b = 0; b < a.length; b++) { - d.add(f, a[b], !0, !0); + if (b[e]) { + for (c = 0; c < a.length; c++) { + d.add(f, a[c], !0, !0); } return; } @@ -782,247 +779,247 @@ function Qa(a, b, c, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Qa(a, b, c, e, d, f, g, k); + Ra(a, c, b, e, d, f, g, k); } } else { - g = b[++e], Qa(a, b, c, e, d, f, g, k); + g = c[++e], Ra(a, c, b, e, d, f, g, k); } } } } -;function Sa(a, b, c, e) { +;function Ta(a, c, b, e) { if (!a.length) { return a; } - if (1 === a.length) { - return a = a[0], a = c || a.length > b ? a.slice(c, c + b) : a, e ? Ta.call(this, a) : a; + if (a.length === 1) { + return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a, e ? Ua.call(this, a) : a; } let d = []; for (let f = 0, g, k; f < a.length; f++) { if ((g = a[f]) && (k = g.length)) { - if (c) { - if (c >= k) { - c -= k; + if (b) { + if (b >= k) { + b -= k; continue; } - g = g.slice(c, c + b); + g = g.slice(b, b + c); k = g.length; - c = 0; + b = 0; } - k > b && (g = g.slice(0, b), k = b); - if (!d.length && k >= b) { - return e ? Ta.call(this, g) : g; + k > c && (g = g.slice(0, c), k = c); + if (!d.length && k >= c) { + return e ? Ua.call(this, g) : g; } d.push(g); - b -= k; - if (!b) { + c -= k; + if (!c) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? Ta.call(this, d) : d; + d = d.length > 1 ? [].concat.apply([], d) : d[0]; + return e ? Ua.call(this, d) : d; } -;function Ua(a, b, c, e) { +;function Va(a, c, b, e) { var d = e[0]; if (d[0] && d[0].query) { - return a[b].apply(a, d); + return a[c].apply(a, d); } - if (!("and" !== b && "not" !== b || a.result.length || a.await || d.suggest)) { - return 1 < e.length && (d = e[e.length - 1]), (e = d.resolve) ? a.await || a.result : a; + if (!(c !== "and" && c !== "not" || a.result.length || a.await || d.suggest)) { + return e.length > 1 && (d = e[e.length - 1]), (e = d.resolve) ? a.await || a.result : a; } - let f = [], g = 0, k = 0, h, l, m, r, t; - for (b = 0; b < e.length; b++) { - if (d = e[b]) { - var q = void 0; - if (d.constructor === Y) { - q = d.await || d.result; + let f = [], g = 0, k = 0, h, l, n, q, u; + for (c = 0; c < e.length; c++) { + if (d = e[c]) { + var r = void 0; + if (d.constructor === X) { + r = d.await || d.result; } else if (d.then || d.constructor === Array) { - q = d; + r = d; } else { g = d.limit || 0; k = d.offset || 0; - m = d.suggest; - h = ((r = (l = d.resolve) && d.highlight) || d.enrich) && l; - q = d.queue; - let u = d.async || q, n = d.index; - n ? a.index || (a.index = n) : n = a.index; + n = d.suggest; + h = ((q = (l = d.resolve) && d.highlight) || d.enrich) && l; + r = d.queue; + let t = d.async || r, m = d.index; + m ? a.index || (a.index = m) : m = a.index; if (d.query || d.tag) { - if (!n) { + if (!m) { throw Error("Resolver can't apply because the corresponding Index was never specified"); } const p = d.field || d.pluck; if (p) { d.query && (a.query = d.query, a.field = p); - if (!n.index) { + if (!m.index) { throw Error("Resolver can't apply because the corresponding Document Index was not specified"); } - n = n.index.get(p); - if (!n) { + m = m.index.get(p); + if (!m) { throw Error("Resolver can't apply because the specified Document Field '" + p + "' was not found"); } } - if (q && (t || a.await)) { - t = 1; - let y; - const v = a.A.length, D = new Promise(function(B) { - y = B; + if (r && (u || a.await)) { + u = 1; + let x; + const v = a.C.length, A = new Promise(function(C) { + x = C; }); - (function(B, G) { - D.h = function() { + (function(C, G) { + A.h = function() { G.index = null; G.resolve = !1; - let A = u ? B.searchAsync(G) : B.search(G); - if (A.then) { - return A.then(function(E) { - a.A[v] = E = E.result || E; - y(E); + let B = t ? C.searchAsync(G) : C.search(G); + if (B.then) { + return B.then(function(E) { + a.C[v] = E = E.result || E; + x(E); return E; }); } - A = A.result || A; - y(A); - return A; + B = B.result || B; + x(B); + return B; }; - })(n, Object.assign({}, d)); - a.A.push(D); - f[b] = D; + })(m, Object.assign({}, d)); + a.C.push(A); + f[c] = A; continue; } else { - d.resolve = !1, d.index = null, q = u ? n.searchAsync(d) : n.search(d), d.resolve = l, d.index = n; + d.resolve = !1, d.index = null, r = t ? m.searchAsync(d) : m.search(d), d.resolve = l, d.index = m; } } else if (d.and) { - q = Va(d, "and", n); + r = Wa(d, "and", m); } else if (d.or) { - q = Va(d, "or", n); + r = Wa(d, "or", m); } else if (d.not) { - q = Va(d, "not", n); + r = Wa(d, "not", m); } else if (d.xor) { - q = Va(d, "xor", n); + r = Wa(d, "xor", m); } else { continue; } } - q.await ? (t = 1, q = q.await) : q.then ? (t = 1, q = q.then(function(u) { - return u.result || u; - })) : q = q.result || q; - f[b] = q; + r.await ? (u = 1, r = r.await) : r.then ? (u = 1, r = r.then(function(t) { + return t.result || t; + })) : r = r.result || r; + f[c] = r; } } - t && !a.await && (a.await = new Promise(function(u) { - a.return = u; + u && !a.await && (a.await = new Promise(function(t) { + a.return = t; })); - if (t) { - const u = Promise.all(f).then(function(n) { - for (let p = 0; p < a.A.length; p++) { - if (a.A[p] === u) { - a.A[p] = function() { - return c.call(a, n, g, k, h, l, m, r); + if (u) { + const t = Promise.all(f).then(function(m) { + for (let p = 0; p < a.C.length; p++) { + if (a.C[p] === t) { + a.C[p] = function() { + return b.call(a, m, g, k, h, l, n, q); }; break; } } - Wa(a); + Xa(a); }); - a.A.push(u); + a.C.push(t); } else if (a.await) { - a.A.push(function() { - return c.call(a, f, g, k, h, l, m, r); + a.C.push(function() { + return b.call(a, f, g, k, h, l, n, q); }); } else { - return c.call(a, f, g, k, h, l, m, r); + return b.call(a, f, g, k, h, l, n, q); } return l ? a.await || a.result : a; } -function Va(a, b, c) { - a = a[b]; +function Wa(a, c, b) { + a = a[c]; const e = a[0] || a; - e.index || (e.index = c); - c = new Y(e); - 1 < a.length && (c = c[b].apply(c, a.slice(1))); - return c; + e.index || (e.index = b); + b = new X(e); + a.length > 1 && (b = b[c].apply(b, a.slice(1))); + return b; } -;Y.prototype.or = function() { - return Ua(this, "or", Xa, arguments); +;X.prototype.or = function() { + return Va(this, "or", Ya, arguments); }; -function Xa(a, b, c, e, d, f, g) { - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ya(a, b, c, !1, this.h), c = 0)); +function Ya(a, c, b, e, d, f, g) { + a.length && (this.result.length && a.push(this.result), a.length < 2 ? this.result = a[0] : (this.result = Za(a, c, b, !1, this.h), b = 0)); d && (this.await = null); - return d ? this.resolve(b, c, e, g) : this; + return d ? this.resolve(c, b, e, g) : this; } -;Y.prototype.and = function() { - return Ua(this, "and", Za, arguments); +;X.prototype.and = function() { + return Va(this, "and", $a, arguments); }; -function Za(a, b, c, e, d, f, g) { +function $a(a, c, b, e, d, f, g) { if (!f && !this.result.length) { return d ? this.result : this; } let k; if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { + if (this.result.length && a.unshift(this.result), a.length < 2) { this.result = a[0]; } else { let h = 0; - for (let l = 0, m, r; l < a.length; l++) { - if ((m = a[l]) && (r = m.length)) { - h < r && (h = r); + for (let l = 0, n, q; l < a.length; l++) { + if ((n = a[l]) && (q = n.length)) { + h < q && (h = q); } else if (!f) { h = 0; break; } } - h ? (this.result = $a(a, h, b, c, f, this.h, d), k = !0) : this.result = []; + h ? (this.result = ab(a, h, c, b, f, this.h, d), k = !0) : this.result = []; } } else { f || (this.result = a); } d && (this.await = null); - return d ? this.resolve(b, c, e, g, k) : this; + return d ? this.resolve(c, b, e, g, k) : this; } -;Y.prototype.xor = function() { - return Ua(this, "xor", ab, arguments); +;X.prototype.xor = function() { + return Va(this, "xor", bb, arguments); }; -function ab(a, b, c, e, d, f, g) { +function bb(a, c, b, e, d, f, g) { if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { + if (this.result.length && a.unshift(this.result), a.length < 2) { this.result = a[0]; } else { a: { - f = c; + f = b; var k = this.h; const h = [], l = I(); - let m = 0; - for (let r = 0, t; r < a.length; r++) { - if (t = a[r]) { - m < t.length && (m = t.length); - for (let q = 0, u; q < t.length; q++) { - if (u = t[q]) { - for (let n = 0, p; n < u.length; n++) { - p = u[n], l[p] = l[p] ? 2 : 1; + let n = 0; + for (let q = 0, u; q < a.length; q++) { + if (u = a[q]) { + n < u.length && (n = u.length); + for (let r = 0, t; r < u.length; r++) { + if (t = u[r]) { + for (let m = 0, p; m < t.length; m++) { + p = t[m], l[p] = l[p] ? 2 : 1; } } } } } - for (let r = 0, t, q = 0; r < m; r++) { - for (let u = 0, n; u < a.length; u++) { - if (n = a[u]) { - if (t = n[r]) { - for (let p = 0, y; p < t.length; p++) { - if (y = t[p], 1 === l[y]) { + for (let q = 0, u, r = 0; q < n; q++) { + for (let t = 0, m; t < a.length; t++) { + if (m = a[t]) { + if (u = m[q]) { + for (let p = 0, x; p < u.length; p++) { + if (x = u[p], l[x] === 1) { if (f) { f--; } else { if (d) { - if (h.push(y), h.length === b) { + if (h.push(x), h.length === c) { a = h; break a; } } else { - const v = r + (u ? k : 0); + const v = q + (t ? k : 0); h[v] || (h[v] = []); - h[v].push(y); - if (++q === b) { + h[v].push(x); + if (++r === c) { a = h; break a; } @@ -1043,34 +1040,34 @@ function ab(a, b, c, e, d, f, g) { f || (this.result = a); } d && (this.await = null); - return d ? this.resolve(b, c, e, g, k) : this; + return d ? this.resolve(c, b, e, g, k) : this; } -;Y.prototype.not = function() { - return Ua(this, "not", bb, arguments); +;X.prototype.not = function() { + return Va(this, "not", cb, arguments); }; -function bb(a, b, c, e, d, f, g) { +function cb(a, c, b, e, d, f, g) { if (!f && !this.result.length) { return d ? this.result : this; } if (a.length && this.result.length) { a: { - f = c; + f = b; var k = []; a = new Set(a.flat().flat()); - for (let h = 0, l, m = 0; h < this.result.length; h++) { + for (let h = 0, l, n = 0; h < this.result.length; h++) { if (l = this.result[h]) { - for (let r = 0, t; r < l.length; r++) { - if (t = l[r], !a.has(t)) { + for (let q = 0, u; q < l.length; q++) { + if (u = l[q], !a.has(u)) { if (f) { f--; } else { if (d) { - if (k.push(t), k.length === b) { + if (k.push(u), k.length === c) { a = k; break a; } } else { - if (k[h] || (k[h] = []), k[h].push(t), ++m === b) { + if (k[h] || (k[h] = []), k[h].push(u), ++n === c) { a = k; break a; } @@ -1086,214 +1083,214 @@ function bb(a, b, c, e, d, f, g) { k = !0; } d && (this.await = null); - return d ? this.resolve(b, c, e, g, k) : this; + return d ? this.resolve(c, b, e, g, k) : this; } -;function cb(a, b, c, e, d) { +;function eb(a, c, b, e, d) { let f, g, k; - "string" === typeof d ? (f = d, d = "") : f = d.template; + typeof d === "string" ? (f = d, d = "") : f = d.template; if (!f) { throw Error('No template pattern was specified by the search option "highlight"'); } g = f.indexOf("$1"); - if (-1 === g) { + if (g === -1) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } k = f.substring(g + 2); g = f.substring(0, g); - let h = d && d.boundary, l = !d || !1 !== d.clip, m = d && d.merge && k && g && new RegExp(k + " " + g, "g"); + let h = d && d.boundary, l = !d || d.clip !== !1, n = d && d.merge && k && g && new RegExp(k + " " + g, "g"); d = d && d.ellipsis; - var r = 0; - if ("object" === typeof d) { - var t = d.template; - r = t.length - 2; + var q = 0; + if (typeof d === "object") { + var u = d.template; + q = u.length - 2; d = d.pattern; } - "string" !== typeof d && (d = !1 === d ? "" : "..."); - r && (d = t.replace("$1", d)); - t = d.length - r; - let q, u; - "object" === typeof h && (q = h.before, 0 === q && (q = -1), u = h.after, 0 === u && (u = -1), h = h.total || 9e5); - r = new Map(); - for (let Oa = 0, ea, db, oa; Oa < b.length; Oa++) { - let pa; + typeof d !== "string" && (d = d === !1 ? "" : "..."); + q && (d = u.replace("$1", d)); + u = d.length - q; + let r, t; + typeof h === "object" && (r = h.before, r === 0 && (r = -1), t = h.after, t === 0 && (t = -1), h = h.total || 9e5); + q = new Map(); + for (let Oa = 0, ea, db, pa; Oa < c.length; Oa++) { + let qa; if (e) { - pa = b, oa = e; + qa = c, pa = e; } else { - var n = b[Oa]; - oa = n.field; - if (!oa) { + var m = c[Oa]; + pa = m.field; + if (!pa) { continue; } - pa = n.result; + qa = m.result; } - db = c.get(oa); + db = b.get(pa); ea = db.encoder; - n = r.get(ea); - "string" !== typeof n && (n = ea.encode(a), r.set(ea, n)); - for (let ya = 0; ya < pa.length; ya++) { - var p = pa[ya].doc; + m = q.get(ea); + typeof m !== "string" && (m = ea.encode(a), q.set(ea, m)); + for (let ya = 0; ya < qa.length; ya++) { + var p = qa[ya].doc; if (!p) { continue; } - p = da(p, oa); + p = da(p, pa); if (!p) { continue; } - var y = p.trim().split(/\s+/); - if (!y.length) { + var x = p.trim().split(/\s+/); + if (!x.length) { continue; } p = ""; var v = []; let za = []; - var D = -1, B = -1, G = 0; - for (var A = 0; A < y.length; A++) { - var E = y[A], z = ea.encode(E); - z = 1 < z.length ? z.join(" ") : z[0]; - let x; + var A = -1, C = -1, G = 0; + for (var B = 0; B < x.length; B++) { + var E = x[B], z = ea.encode(E); + z = z.length > 1 ? z.join(" ") : z[0]; + let y; if (z && E) { - var C = E.length, K = (ea.split ? E.replace(ea.split, "") : E).length - z.length, F = "", L = 0; - for (var O = 0; O < n.length; O++) { - var P = n[O]; + var D = E.length, K = (ea.split ? E.replace(ea.split, "") : E).length - z.length, F = "", L = 0; + for (var O = 0; O < m.length; O++) { + var P = m[O]; if (P) { var M = P.length; M += K; - L && M <= L || (P = z.indexOf(P), -1 < P && (F = (P ? E.substring(0, P) : "") + g + E.substring(P, P + M) + k + (P + M < C ? E.substring(P + M) : ""), L = M, x = !0)); + L && M <= L || (P = z.indexOf(P), P > -1 && (F = (P ? E.substring(0, P) : "") + g + E.substring(P, P + M) + k + (P + M < D ? E.substring(P + M) : ""), L = M, y = !0)); } } - F && (h && (0 > D && (D = p.length + (p ? 1 : 0)), B = p.length + (p ? 1 : 0) + F.length, G += C, za.push(v.length), v.push({match:F})), p += (p ? " " : "") + F); + F && (h && (A < 0 && (A = p.length + (p ? 1 : 0)), C = p.length + (p ? 1 : 0) + F.length, G += D, za.push(v.length), v.push({match:F})), p += (p ? " " : "") + F); } - if (!x) { - E = y[A], p += (p ? " " : "") + E, h && v.push({text:E}); + if (!y) { + E = x[B], p += (p ? " " : "") + E, h && v.push({text:E}); } else if (h && G >= h) { break; } } G = za.length * (f.length - 2); - if (q || u || h && p.length - G > h) { - if (G = h + G - 2 * t, A = B - D, 0 < q && (A += q), 0 < u && (A += u), A <= G) { - y = q ? D - (0 < q ? q : 0) : D - ((G - A) / 2 | 0), v = u ? B + (0 < u ? u : 0) : y + G, l || (0 < y && " " !== p.charAt(y) && " " !== p.charAt(y - 1) && (y = p.indexOf(" ", y), 0 > y && (y = 0)), v < p.length && " " !== p.charAt(v - 1) && " " !== p.charAt(v) && (v = p.lastIndexOf(" ", v), v < B ? v = B : ++v)), p = (y ? d : "") + p.substring(y, v) + (v < p.length ? d : ""); + if (r || t || h && p.length - G > h) { + if (G = h + G - u * 2, B = C - A, r > 0 && (B += r), t > 0 && (B += t), B <= G) { + x = r ? A - (r > 0 ? r : 0) : A - ((G - B) / 2 | 0), v = t ? C + (t > 0 ? t : 0) : x + G, l || (x > 0 && p.charAt(x) !== " " && p.charAt(x - 1) !== " " && (x = p.indexOf(" ", x), x < 0 && (x = 0)), v < p.length && p.charAt(v - 1) !== " " && p.charAt(v) !== " " && (v = p.lastIndexOf(" ", v), v < C ? v = C : ++v)), p = (x ? d : "") + p.substring(x, v) + (v < p.length ? d : ""); } else { - B = []; - D = {}; - G = {}; + C = []; A = {}; + G = {}; + B = {}; E = {}; z = {}; - F = K = C = 0; + F = K = D = 0; for (O = L = 1;;) { var U = void 0; - for (let x = 0, J; x < za.length; x++) { - J = za[x]; + for (let y = 0, J; y < za.length; y++) { + J = za[y]; if (F) { if (K !== F) { - if (A[x + 1]) { + if (B[y + 1]) { continue; } J += F; - if (D[J]) { - C -= t; - G[x + 1] = 1; - A[x + 1] = 1; + if (A[J]) { + D -= u; + G[y + 1] = 1; + B[y + 1] = 1; continue; } if (J >= v.length - 1) { if (J >= v.length) { - A[x + 1] = 1; - J >= y.length && (G[x + 1] = 1); + B[y + 1] = 1; + J >= x.length && (G[y + 1] = 1); continue; } - C -= t; + D -= u; } p = v[J].text; - if (M = u && z[x]) { - if (0 < M) { + if (M = t && z[y]) { + if (M > 0) { if (p.length > M) { - if (A[x + 1] = 1, l) { + if (B[y + 1] = 1, l) { p = p.substring(0, M); } else { continue; } } (M -= p.length) || (M = -1); - z[x] = M; + z[y] = M; } else { - A[x + 1] = 1; + B[y + 1] = 1; continue; } } - if (C + p.length + 1 <= h) { - p = " " + p, B[x] += p; + if (D + p.length + 1 <= h) { + p = " " + p, C[y] += p; } else if (l) { - U = h - C - 1, 0 < U && (p = " " + p.substring(0, U), B[x] += p), A[x + 1] = 1; + U = h - D - 1, U > 0 && (p = " " + p.substring(0, U), C[y] += p), B[y + 1] = 1; } else { - A[x + 1] = 1; + B[y + 1] = 1; continue; } } else { - if (A[x]) { + if (B[y]) { continue; } J -= K; - if (D[J]) { - C -= t; - A[x] = 1; - G[x] = 1; + if (A[J]) { + D -= u; + B[y] = 1; + G[y] = 1; continue; } - if (0 >= J) { - if (0 > J) { - A[x] = 1; - G[x] = 1; + if (J <= 0) { + if (J < 0) { + B[y] = 1; + G[y] = 1; continue; } - C -= t; + D -= u; } p = v[J].text; - if (M = q && E[x]) { - if (0 < M) { + if (M = r && E[y]) { + if (M > 0) { if (p.length > M) { - if (A[x] = 1, l) { + if (B[y] = 1, l) { p = p.substring(p.length - M); } else { continue; } } (M -= p.length) || (M = -1); - E[x] = M; + E[y] = M; } else { - A[x] = 1; + B[y] = 1; continue; } } - if (C + p.length + 1 <= h) { - p += " ", B[x] = p + B[x]; + if (D + p.length + 1 <= h) { + p += " ", C[y] = p + C[y]; } else if (l) { - U = p.length + 1 - (h - C), 0 <= U && U < p.length && (p = p.substring(U) + " ", B[x] = p + B[x]), A[x] = 1; + U = p.length + 1 - (h - D), U >= 0 && U < p.length && (p = p.substring(U) + " ", C[y] = p + C[y]), B[y] = 1; } else { - A[x] = 1; + B[y] = 1; continue; } } } else { p = v[J].match; - q && (E[x] = q); - u && (z[x] = u); - x && C++; + r && (E[y] = r); + t && (z[y] = t); + y && D++; let Pa; - J ? !x && t && (C += t) : (G[x] = 1, A[x] = 1); - J >= y.length - 1 ? Pa = 1 : J < v.length - 1 && v[J + 1].match ? Pa = 1 : t && (C += t); - C -= f.length - 2; - if (!x || C + p.length <= h) { - B[x] = p; + J ? !y && u && (D += u) : (G[y] = 1, B[y] = 1); + J >= x.length - 1 ? Pa = 1 : J < v.length - 1 && v[J + 1].match ? Pa = 1 : u && (D += u); + D -= f.length - 2; + if (!y || D + p.length <= h) { + C[y] = p; } else { - U = L = O = G[x] = 0; + U = L = O = G[y] = 0; break; } - Pa && (G[x + 1] = 1, A[x + 1] = 1); + Pa && (G[y + 1] = 1, B[y + 1] = 1); } - C += p.length; - U = D[J] = 1; + D += p.length; + U = A[J] = 1; } if (U) { K === F ? F++ : K++; @@ -1306,39 +1303,39 @@ function bb(a, b, c, e, d, f, g) { } } p = ""; - for (let x = 0, J; x < B.length; x++) { - J = (x && G[x] ? " " : (x && !d ? " " : "") + d) + B[x], p += J; + for (let y = 0, J; y < C.length; y++) { + J = (y && G[y] ? " " : (y && !d ? " " : "") + d) + C[y], p += J; } - d && !G[B.length] && (p += d); + d && !G[C.length] && (p += d); } } - m && (p = p.replace(m, " ")); - pa[ya].highlight = p; + n && (p = p.replace(n, " ")); + qa[ya].highlight = p; } if (e) { break; } } - return b; + return c; } -;function Y(a, b) { - if (!this || this.constructor !== Y) { - return new Y(a, b); +;function X(a, c) { + if (!this || this.constructor !== X) { + return new X(a, c); } - let c = 0, e, d, f, g, k; + let b = 0, e, d, f, g, k; if (a && a.index) { const h = a; - b = h.index; - c = h.boost || 0; + c = h.index; + b = h.boost || 0; if (d = h.query) { f = h.field || h.pluck; const l = h.resolve; a = h.async || h.queue; h.resolve = !1; h.index = null; - a = a ? b.searchAsync(h) : b.search(h); + a = a ? c.searchAsync(h) : c.search(h); h.resolve = l; - h.index = b; + h.index = c; a = a.result || a; } else { a = []; @@ -1347,8 +1344,8 @@ function bb(a, b, c, e, d, f, g) { if (a && a.then) { const h = this; a = a.then(function(l) { - h.A[0] = h.result = l.result || l; - Wa(h); + h.C[0] = h.result = l.result || l; + Xa(h); }); e = [a]; a = []; @@ -1356,140 +1353,140 @@ function bb(a, b, c, e, d, f, g) { k = l; }); } - this.index = b || null; + this.index = c || null; this.result = a || []; - this.h = c; - this.A = e || []; + this.h = b; + this.C = e || []; this.await = g || null; this.return = k || null; this.query = d || ""; this.field = f || ""; } -w = Y.prototype; +w = X.prototype; w.limit = function(a) { if (this.await) { - const b = this; - this.A.push(function() { - b.limit(a); - return b.result; + const c = this; + this.C.push(function() { + c.limit(a); + return c.result; }); } else { if (this.result.length) { - const b = []; - for (let c = 0, e; c < this.result.length; c++) { - if (e = this.result[c]) { + const c = []; + for (let b = 0, e; b < this.result.length; b++) { + if (e = this.result[b]) { if (e.length <= a) { - if (b[c] = e, a -= e.length, !a) { + if (c[b] = e, a -= e.length, !a) { break; } } else { - b[c] = e.slice(0, a); + c[b] = e.slice(0, a); break; } } } - this.result = b; + this.result = c; } } return this; }; w.offset = function(a) { if (this.await) { - const b = this; - this.A.push(function() { - b.offset(a); - return b.result; + const c = this; + this.C.push(function() { + c.offset(a); + return c.result; }); } else { if (this.result.length) { - const b = []; - for (let c = 0, e; c < this.result.length; c++) { - if (e = this.result[c]) { - e.length <= a ? a -= e.length : (b[c] = e.slice(a), a = 0); + const c = []; + for (let b = 0, e; b < this.result.length; b++) { + if (e = this.result[b]) { + e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0); } } - this.result = b; + this.result = c; } } return this; }; w.boost = function(a) { if (this.await) { - const b = this; - this.A.push(function() { - b.boost(a); - return b.result; + const c = this; + this.C.push(function() { + c.boost(a); + return c.result; }); } else { this.h += a; } return this; }; -function Wa(a, b) { - let c = a.result; +function Xa(a, c) { + let b = a.result; var e = a.await; a.await = null; - for (let d = 0, f; d < a.A.length; d++) { - if (f = a.A[d]) { - if ("function" === typeof f) { - c = f(), a.A[d] = c = c.result || c, d--; + for (let d = 0, f; d < a.C.length; d++) { + if (f = a.C[d]) { + if (typeof f === "function") { + b = f(), a.C[d] = b = b.result || b, d--; } else if (f.h) { - c = f.h(), a.A[d] = c = c.result || c, d--; + b = f.h(), a.C[d] = b = b.result || b, d--; } else if (f.then) { return a.await = e; } } } e = a.return; - a.A = []; + a.C = []; a.return = null; - b || e(c); - return c; + c || e(b); + return b; } -w.resolve = function(a, b, c, e, d) { - let f = this.await ? Wa(this, !0) : this.result; +w.resolve = function(a, c, b, e, d) { + let f = this.await ? Xa(this, !0) : this.result; if (f.then) { const g = this; return f.then(function() { - return g.resolve(a, b, c, e, d); + return g.resolve(a, c, b, e, d); }); } - f.length && ("object" === typeof a ? (e = a.highlight, c = !!e || a.enrich, b = a.offset, a = a.limit) : c = !!e || c, f = d ? c ? Ta.call(this.index, f) : f : Sa.call(this.index, f, a || 100, b, c)); + f.length && (typeof a === "object" ? (e = a.highlight, b = !!e || a.enrich, c = a.offset, a = a.limit) : b = !!e || b, f = d ? b ? Ua.call(this.index, f) : f : Ta.call(this.index, f, a || 100, c, b)); return this.finalize(f, e); }; -w.finalize = function(a, b) { +w.finalize = function(a, c) { if (a.then) { const e = this; return a.then(function(d) { - return e.finalize(d, b); + return e.finalize(d, c); }); } - b && !this.query && console.warn('There was no query specified for highlighting. Please specify a query within the last resolver stage like { query: "...", resolve: true, highlight: ... }.'); - b && a.length && this.query && (a = cb(this.query, a, this.index.index, this.field, b)); - const c = this.return; - this.index = this.result = this.A = this.await = this.return = null; + c && !this.query && console.warn('There was no query specified for highlighting. Please specify a query within the last resolver stage like { query: "...", resolve: true, highlight: ... }.'); + c && a.length && this.query && (a = eb(this.query, a, this.index.index, this.field, c)); + const b = this.return; + this.index = this.result = this.C = this.await = this.return = null; this.query = this.field = ""; - c && c(a); + b && b(a); return a; }; -function $a(a, b, c, e, d, f, g) { +function ab(a, c, b, e, d, f, g) { const k = a.length; - let h = [], l, m; + let h = [], l, n; l = I(); - for (let r = 0, t, q, u, n; r < b; r++) { + for (let q = 0, u, r, t, m; q < c; q++) { for (let p = 0; p < k; p++) { - if (u = a[p], r < u.length && (t = u[r])) { - for (let y = 0; y < t.length; y++) { - q = t[y]; - (m = l[q]) ? l[q]++ : (m = 0, l[q] = 1); - n = h[m] || (h[m] = []); + if (t = a[p], q < t.length && (u = t[q])) { + for (let x = 0; x < u.length; x++) { + r = u[x]; + (n = l[r]) ? l[r]++ : (n = 0, l[r] = 1); + m = h[n] || (h[n] = []); if (!g) { - let v = r + (p || !d ? 0 : f || 0); - n = n[v] || (n[v] = []); + let v = q + (p || !d ? 0 : f || 0); + m = m[v] || (m[v] = []); } - n.push(q); - if (g && c && m === k - 1 && n.length - e === c) { - return e ? n.slice(e) : n; + m.push(r); + if (g && b && n === k - 1 && m.length - e === b) { + return e ? m.slice(e) : m; } } } @@ -1497,29 +1494,29 @@ function $a(a, b, c, e, d, f, g) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Ya(h, c, e, g, f) : (h = h[0]) && c && h.length > c || e ? h.slice(e, c + e) : h; + h = h.length > 1 ? Za(h, b, e, g, f) : (h = h[0]) && b && h.length > b || e ? h.slice(e, b + e) : h; } else { if (a < k) { return []; } h = h[a - 1]; - if (c || e) { + if (b || e) { if (g) { - if (h.length > c || e) { - h = h.slice(e, c + e); + if (h.length > b || e) { + h = h.slice(e, b + e); } } else { d = []; - for (let r = 0, t; r < h.length; r++) { - if (t = h[r]) { - if (e && t.length > e) { - e -= t.length; + for (let q = 0, u; q < h.length; q++) { + if (u = h[q]) { + if (e && u.length > e) { + e -= u.length; } else { - if (c && t.length > c || e) { - t = t.slice(e, c + e), c -= t.length, e && (e -= t.length); + if (b && u.length > b || e) { + u = u.slice(e, b + e), b -= u.length, e && (e -= u.length); } - d.push(t); - if (!c) { + d.push(u); + if (!b) { break; } } @@ -1532,20 +1529,20 @@ function $a(a, b, c, e, d, f, g) { } return h; } -function Ya(a, b, c, e, d) { +function Za(a, c, b, e, d) { const f = [], g = I(); let k; var h = a.length; let l; if (e) { - for (d = h - 1; 0 <= d; d--) { + for (d = h - 1; d >= 0; d--) { if (l = (e = a[d]) && e.length) { for (h = 0; h < l; h++) { if (k = e[h], !g[k]) { - if (g[k] = 1, c) { - c--; + if (g[k] = 1, b) { + b--; } else { - if (f.push(k), f.length === b) { + if (f.push(k), f.length === c) { return f; } } @@ -1554,18 +1551,18 @@ function Ya(a, b, c, e, d) { } } } else { - for (let m = h - 1, r, t = 0; 0 <= m; m--) { - r = a[m]; - for (let q = 0; q < r.length; q++) { - if (l = (e = r[q]) && e.length) { - for (let u = 0; u < l; u++) { - if (k = e[u], !g[k]) { - if (g[k] = 1, c) { - c--; + for (let n = h - 1, q, u = 0; n >= 0; n--) { + q = a[n]; + for (let r = 0; r < q.length; r++) { + if (l = (e = q[r]) && e.length) { + for (let t = 0; t < l; t++) { + if (k = e[t], !g[k]) { + if (g[k] = 1, b) { + b--; } else { - let n = (q + (m < h - 1 ? d || 0 : 0)) / (m + 1) | 0; - (f[n] || (f[n] = [])).push(k); - if (++t === b) { + let m = (r + (n < h - 1 ? d || 0 : 0)) / (n + 1) | 0; + (f[m] || (f[m] = [])).push(k); + if (++u === c) { return f; } } @@ -1577,75 +1574,75 @@ function Ya(a, b, c, e, d) { } return f; } -function eb(a, b, c) { +function fb(a, c, b) { const e = I(), d = []; - for (let f = 0, g; f < b.length; f++) { - g = b[f]; + for (let f = 0, g; f < c.length; f++) { + g = c[f]; for (let k = 0; k < g.length; k++) { e[g[k]] = 1; } } - if (c) { + if (b) { for (let f = 0, g; f < a.length; f++) { g = a[f], e[g] && (d.push(g), e[g] = 0); } } else { for (let f = 0, g, k; f < a.result.length; f++) { - for (g = a.result[f], b = 0; b < g.length; b++) { - k = g[b], e[k] && ((d[f] || (d[f] = [])).push(k), e[k] = 0); + for (g = a.result[f], c = 0; c < g.length; c++) { + k = g[c], e[k] && ((d[f] || (d[f] = [])).push(k), e[k] = 0); } } } return d; } ;I(); -Na.prototype.search = function(a, b, c, e) { - c || (!b && ba(a) ? (c = a, a = "") : ba(b) && (c = b, b = 0)); +Qa.prototype.search = function(a, c, b, e) { + b || (!c && ba(a) ? (b = a, a = "") : ba(c) && (b = c, c = 0)); let d = []; var f = []; let g; - let k, h, l, m, r; - let t = 0, q = !0, u; - if (c) { - c.constructor === Array && (c = {index:c}); - a = c.query || a; - g = c.pluck; - k = c.merge; - l = c.boost; - r = g || c.field || (r = c.index) && (r.index ? null : r); - var n = this.tag && c.tag; - h = c.suggest; - q = !1 !== c.resolve; - m = c.cache; - this.store && c.highlight && !q ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && c.enrich && !q && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - u = q && this.store && c.highlight; - var p = !!u || q && this.store && c.enrich; - b = c.limit || b; - var y = c.offset || 0; - b || (b = q ? 100 : 0); - if (n && (!this.db || !e)) { - n.constructor !== Array && (n = [n]); + let k, h, l, n, q; + let u = 0, r = !0, t; + if (b) { + b.constructor === Array && (b = {index:b}); + a = b.query || a; + g = b.pluck; + k = b.merge; + l = b.boost; + q = g || b.field || (q = b.index) && (q.index ? null : q); + var m = this.tag && b.tag; + h = b.suggest; + r = b.resolve !== !1; + n = b.cache; + this.store && b.highlight && !r ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !r && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + t = r && this.store && b.highlight; + var p = !!t || r && this.store && b.enrich; + c = b.limit || c; + var x = b.offset || 0; + c || (c = r ? 100 : 0); + if (m && (!this.db || !e)) { + m.constructor !== Array && (m = [m]); var v = []; - for (let E = 0, z; E < n.length; E++) { - z = n[E]; + for (let E = 0, z; E < m.length; E++) { + z = m[E]; if (N(z)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } if (z.field && z.tag) { - var D = z.tag; - if (D.constructor === Array) { - for (var B = 0; B < D.length; B++) { - v.push(z.field, D[B]); + var A = z.tag; + if (A.constructor === Array) { + for (var C = 0; C < A.length; C++) { + v.push(z.field, A[C]); } } else { - v.push(z.field, D); + v.push(z.field, A); } } else { - D = Object.keys(z); - for (let C = 0, K, F; C < D.length; C++) { - if (K = D[C], F = z[K], F.constructor === Array) { - for (B = 0; B < F.length; B++) { - v.push(K, F[B]); + A = Object.keys(z); + for (let D = 0, K, F; D < A.length; D++) { + if (K = A[D], F = z[K], F.constructor === Array) { + for (C = 0; C < F.length; C++) { + v.push(K, F[C]); } } else { v.push(K, F); @@ -1656,245 +1653,245 @@ Na.prototype.search = function(a, b, c, e) { if (!v.length) { throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); } - n = v; + m = v; if (!a) { f = []; if (v.length) { - for (n = 0; n < v.length; n += 2) { + for (m = 0; m < v.length; m += 2) { if (this.db) { - e = this.index.get(v[n]); + e = this.index.get(v[m]); if (!e) { - console.warn("Tag '" + v[n] + ":" + v[n + 1] + "' will be skipped because there is no field '" + v[n] + "'."); + console.warn("Tag '" + v[m] + ":" + v[m + 1] + "' will be skipped because there is no field '" + v[m] + "'."); continue; } - f.push(e = e.db.tag(v[n + 1], b, y, p)); + f.push(e = e.db.tag(v[m + 1], c, x, p)); } else { - e = fb.call(this, v[n], v[n + 1], b, y, p); + e = gb.call(this, v[m], v[m + 1], c, x, p); } - d.push(q ? {field:v[n], tag:v[n + 1], result:e} : [e]); + d.push(r ? {field:v[m], tag:v[m + 1], result:e} : [e]); } } if (f.length) { const E = this; return Promise.all(f).then(function(z) { - for (let C = 0; C < z.length; C++) { - q ? d[C].result = z[C] : d[C] = z[C]; + for (let D = 0; D < z.length; D++) { + r ? d[D].result = z[D] : d[D] = z[D]; } - return q ? d : new Y(1 < d.length ? $a(d, 1, 0, 0, h, l) : d[0], E); + return r ? d : new X(d.length > 1 ? ab(d, 1, 0, 0, h, l) : d[0], E); }); } - return q ? d : new Y(1 < d.length ? $a(d, 1, 0, 0, h, l) : d[0], this); + return r ? d : new X(d.length > 1 ? ab(d, 1, 0, 0, h, l) : d[0], this); } } - if (!q && !g) { - if (r = r || this.field) { - N(r) ? g = r : (r.constructor === Array && 1 === r.length && (r = r[0]), g = r.field || r.index); + if (!r && !g) { + if (q = q || this.field) { + N(q) ? g = q : (q.constructor === Array && q.length === 1 && (q = q[0]), g = q.field || q.index); } if (!g) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - r && r.constructor !== Array && (r = [r]); + q && q.constructor !== Array && (q = [q]); } - r || (r = this.field); + q || (q = this.field); let G; v = (this.worker || this.db) && !e && []; - for (let E = 0, z, C, K; E < r.length; E++) { - C = r[E]; - if (this.db && this.tag && !this.G[E]) { + for (let E = 0, z, D, K; E < q.length; E++) { + D = q[E]; + if (this.db && this.tag && !this.B[E]) { continue; } let F; - N(C) || (F = C, C = F.field, a = F.query || a, b = aa(F.limit, b), y = aa(F.offset, y), h = aa(F.suggest, h), u = q && this.store && aa(F.highlight, u), p = !!u || q && this.store && aa(F.enrich, p), m = aa(F.cache, m)); + N(D) || (F = D, D = F.field, a = F.query || a, c = aa(F.limit, c), x = aa(F.offset, x), h = aa(F.suggest, h), t = r && this.store && aa(F.highlight, t), p = !!t || r && this.store && aa(F.enrich, p), n = aa(F.cache, n)); if (e) { z = e[E]; } else { - D = F || c || {}; - B = D.enrich; - var A = this.index.get(C); - n && (this.db && (D.tag = n, G = A.db.support_tag_search, D.field = r), !G && B && (D.enrich = !1)); - z = m ? A.searchCache(a, b, D) : A.search(a, b, D); - B && (D.enrich = B); + A = F || b || {}; + C = A.enrich; + var B = this.index.get(D); + m && (this.db && (A.tag = m, G = B.db.support_tag_search, A.field = q), !G && C && (A.enrich = !1)); + z = n ? B.searchCache(a, c, A) : B.search(a, c, A); + C && (A.enrich = C); if (v) { v[E] = z; continue; } } K = (z = z.result || z) && z.length; - if (n && K) { - D = []; - B = 0; + if (m && K) { + A = []; + C = 0; if (this.db && e) { if (!G) { - for (A = r.length; A < e.length; A++) { - let L = e[A]; + for (B = q.length; B < e.length; B++) { + let L = e[B]; if (L && L.length) { - B++, D.push(L); + C++, A.push(L); } else if (!h) { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } } } else { - for (let L = 0, O, P; L < n.length; L += 2) { - O = this.tag.get(n[L]); + for (let L = 0, O, P; L < m.length; L += 2) { + O = this.tag.get(m[L]); if (!O) { - if (console.warn("Tag '" + n[L] + ":" + n[L + 1] + "' will be skipped because there is no field '" + n[L] + "'."), h) { + if (console.warn("Tag '" + m[L] + ":" + m[L + 1] + "' will be skipped because there is no field '" + m[L] + "'."), h) { continue; } else { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } - if (P = (O = O && O.get(n[L + 1])) && O.length) { - B++, D.push(O); + if (P = (O = O && O.get(m[L + 1])) && O.length) { + C++, A.push(O); } else if (!h) { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } } - if (B) { - z = eb(z, D, q); + if (C) { + z = fb(z, A, r); K = z.length; if (!K && !h) { - return q ? z : new Y(z, this); + return r ? z : new X(z, this); } - B--; + C--; } } if (K) { - f[t] = C, d.push(z), t++; - } else if (1 === r.length) { - return q ? d : new Y(d, this); + f[u] = D, d.push(z), u++; + } else if (q.length === 1) { + return r ? d : new X(d, this); } } if (v) { - if (this.db && n && n.length && !G) { - for (p = 0; p < n.length; p += 2) { - f = this.index.get(n[p]); + if (this.db && m && m.length && !G) { + for (p = 0; p < m.length; p += 2) { + f = this.index.get(m[p]); if (!f) { - if (console.warn("Tag '" + n[p] + ":" + n[p + 1] + "' was not found because there is no field '" + n[p] + "'."), h) { + if (console.warn("Tag '" + m[p] + ":" + m[p + 1] + "' was not found because there is no field '" + m[p] + "'."), h) { continue; } else { - return q ? d : new Y(d, this); + return r ? d : new X(d, this); } } - v.push(f.db.tag(n[p + 1], b, y, !1)); + v.push(f.db.tag(m[p + 1], c, x, !1)); } } const E = this; return Promise.all(v).then(function(z) { - c && (c.resolve = q); - z.length && (z = E.search(a, b, c, z)); + b && (b.resolve = r); + z.length && (z = E.search(a, c, b, z)); return z; }); } - if (!t) { - return q ? d : new Y(d, this); + if (!u) { + return r ? d : new X(d, this); } if (g && (!p || !this.store)) { - return d = d[0], q ? d : new Y(d, this); + return d = d[0], r ? d : new X(d, this); } v = []; - for (y = 0; y < f.length; y++) { - n = d[y]; - p && n.length && "undefined" === typeof n[0].doc && (this.db ? v.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = Ta.call(this, n)); + for (x = 0; x < f.length; x++) { + m = d[x]; + p && m.length && typeof m[0].doc === "undefined" && (this.db ? v.push(m = this.index.get(this.field[0]).db.enrich(m)) : m = Ua.call(this, m)); if (g) { - return q ? u ? cb(a, n, this.index, g, u) : n : new Y(n, this); + return r ? t ? eb(a, m, this.index, g, t) : m : new X(m, this); } - d[y] = {field:f[y], result:n}; + d[x] = {field:f[x], result:m}; } if (p && this.db && v.length) { const E = this; return Promise.all(v).then(function(z) { - for (let C = 0; C < z.length; C++) { - d[C].result = z[C]; + for (let D = 0; D < z.length; D++) { + d[D].result = z[D]; } - u && (d = cb(a, d, E.index, g, u)); - return k ? gb(d) : d; + t && (d = eb(a, d, E.index, g, t)); + return k ? hb(d) : d; }); } - u && (d = cb(a, d, this.index, g, u)); - return k ? gb(d) : d; + t && (d = eb(a, d, this.index, g, t)); + return k ? hb(d) : d; }; -function gb(a) { - const b = [], c = I(), e = I(); - for (let d = 0, f, g, k, h, l, m, r; d < a.length; d++) { +function hb(a) { + const c = [], b = I(), e = I(); + for (let d = 0, f, g, k, h, l, n, q; d < a.length; d++) { f = a[d]; g = f.field; k = f.result; - for (let t = 0; t < k.length; t++) { - if (l = k[t], "object" !== typeof l ? l = {id:h = l} : h = l.id, (m = c[h]) ? m.push(g) : (l.field = c[h] = [g], b.push(l)), r = l.highlight) { - m = e[h], m || (e[h] = m = {}, l.highlight = m), m[g] = r; + for (let u = 0; u < k.length; u++) { + if (l = k[u], typeof l !== "object" ? l = {id:h = l} : h = l.id, (n = b[h]) ? n.push(g) : (l.field = b[h] = [g], c.push(l)), q = l.highlight) { + n = e[h], n || (e[h] = n = {}, l.highlight = n), n[g] = q; } } } - return b; + return c; } -function fb(a, b, c, e, d) { +function gb(a, c, b, e, d) { a = this.tag.get(a); if (!a) { return []; } - a = a.get(b); + a = a.get(c); if (!a) { return []; } - b = a.length - e; - if (0 < b) { - if (c && b > c || e) { - a = a.slice(e, e + c); + c = a.length - e; + if (c > 0) { + if (b && c > b || e) { + a = a.slice(e, e + b); } - d && (a = Ta.call(this, a)); + d && (a = Ua.call(this, a)); } return a; } -function Ta(a) { +function Ua(a) { if (!this || !this.store) { return a; } if (this.db) { return this.index.get(this.field[0]).db.enrich(a); } - const b = Array(a.length); - for (let c = 0, e; c < a.length; c++) { - e = a[c], b[c] = {id:e, doc:this.store.get(e)}; + 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 b; + return c; } -;function Na(a) { - if (!this || this.constructor !== Na) { - return new Na(a); +;function Qa(a) { + if (!this || this.constructor !== Qa) { + return new Qa(a); } - const b = a.document || a.doc || a; - let c, e; - this.G = []; + const c = a.document || a.doc || a; + let b, e; + this.B = []; this.field = []; - this.K = []; - this.key = (c = b.key || b.id) && hb(c, this.K) || "id"; + this.D = []; + this.key = (b = c.key || c.id) && ib(b, this.D) || "id"; (e = a.keystore || 0) && (this.keystore = e); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? e ? new S(e) : new Set() : e ? new R(e) : new Map(); - this.D = (c = b.store || null) && c && !0 !== c && []; - this.store = c && (e ? new R(e) : new Map()); - this.cache = (c = a.cache || null) && new na(c); + this.reg = !this.fastupdate || a.worker || a.db ? e ? new R(e) : new Set() : e ? new Q(e) : new Map(); + this.h = (b = c.store || null) && b && b !== !0 && []; + this.store = b ? e ? new Q(e) : new Map() : null; + this.cache = (b = a.cache || null) && new oa(b); a.cache = !1; this.worker = a.worker || !1; this.priority = a.priority || 4; - this.index = ib.call(this, a, b); + this.index = jb.call(this, a, c); this.tag = null; - if (c = b.tag) { - if ("string" === typeof c && (c = [c]), c.length) { + if (b = c.tag) { + if (typeof b === "string" && (b = [b]), b.length) { this.tag = new Map(); + this.A = []; this.F = []; - this.P = []; - for (let d = 0, f, g; d < c.length; d++) { - f = c[d]; + for (let d = 0, f, g; d < b.length; d++) { + f = b[d]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = hb(g, this.K), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].J = f.filter)); - this.P[d] = g; + f.custom ? this.A[d] = f.custom : (this.A[d] = ib(g, this.D), f.filter && (typeof this.A[d] === "string" && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter)); + this.F[d] = g; this.tag.set(g, new Map()); } } @@ -1921,56 +1918,56 @@ function Ta(a) { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -w = Na.prototype; +w = Qa.prototype; w.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } - let b = this.field; + let c = this.field; if (this.tag) { - for (let f = 0, g; f < this.P.length; f++) { - g = this.P[f]; - var c = void 0; - this.index.set(g, c = new V({}, this.reg)); - b === this.field && (b = b.slice(0)); - b.push(g); - c.tag = this.tag.get(g); + for (let f = 0, g; f < this.F.length; f++) { + g = this.F[f]; + var b = void 0; + this.index.set(g, b = new T({}, this.reg)); + c === this.field && (c = c.slice(0)); + c.push(g); + b.tag = this.tag.get(g); } } - c = []; + b = []; const e = {db:a.db, type:a.type, fastupdate:a.fastupdate}; - for (let f = 0, g, k; f < b.length; f++) { - e.field = k = b[f]; + for (let f = 0, g, k; f < c.length; f++) { + e.field = k = c[f]; g = this.index.get(k); const h = new a.constructor(a.id, e); h.id = a.id; - c[f] = h.mount(g); + b[f] = h.mount(g); g.document = !0; f ? g.bypass = !0 : g.store = this.store; } const d = this; - return this.db = Promise.all(c).then(function() { + return this.db = Promise.all(b).then(function() { d.db = !0; }); }; -w.commit = async function(a, b) { - const c = []; +w.commit = async function(a, c) { + const b = []; for (const e of this.index.values()) { - c.push(e.commit(a, b)); + b.push(e.commit(a, c)); } - await Promise.all(c); + await Promise.all(b); this.reg.clear(); }; w.destroy = function() { const a = []; - for (const b of this.index.values()) { - a.push(b.destroy()); + for (const c of this.index.values()) { + a.push(c.destroy()); } return Promise.all(a); }; -function ib(a, b) { - const c = new Map(); - let e = b.index || b.field || b; +function jb(a, c) { + const b = new Map(); + let e = c.index || c.field || c; N(e) && (e = [e]); for (let f = 0, g, k; f < e.length; f++) { g = e[f]; @@ -1978,50 +1975,50 @@ function ib(a, b) { k = ba(k) ? Object.assign({}, a, k) : a; if (this.worker) { var d = void 0; - d = (d = k.encoder) && d.encode ? d : new la("string" === typeof d ? wa[d] : d || {}); - d = new La(k, d); - c.set(g, d); + d = (d = k.encoder) && d.encode ? d : new la(typeof d === "string" ? xa[d] : d || {}); + d = new Ma(k, d); + b.set(g, d); } - this.worker || c.set(g, new V(k, this.reg)); - k.custom ? this.G[f] = k.custom : (this.G[f] = hb(g, this.K), k.filter && ("string" === typeof this.G[f] && (this.G[f] = new String(this.G[f])), this.G[f].J = k.filter)); + this.worker || b.set(g, new T(k, this.reg)); + k.custom ? this.B[f] = k.custom : (this.B[f] = ib(g, this.D), k.filter && (typeof this.B[f] === "string" && (this.B[f] = new String(this.B[f])), this.B[f].G = k.filter)); this.field[f] = g; } - if (this.D) { - a = b.store; + if (this.h) { + a = c.store; N(a) && (a = [a]); for (let f = 0, g, k; f < a.length; f++) { - g = a[f], k = g.field || g, g.custom ? (this.D[f] = g.custom, g.custom.U = k) : (this.D[f] = hb(k, this.K), g.filter && ("string" === typeof this.D[f] && (this.D[f] = new String(this.D[f])), this.D[f].J = g.filter)); + g = a[f], k = g.field || g, g.custom ? (this.h[f] = g.custom, g.custom.O = k) : (this.h[f] = ib(k, this.D), g.filter && (typeof this.h[f] === "string" && (this.h[f] = new String(this.h[f])), this.h[f].G = g.filter)); } } - return c; + return b; } -function hb(a, b) { - const c = a.split(":"); +function ib(a, c) { + const b = a.split(":"); let e = 0; - for (let d = 0; d < c.length; d++) { - a = c[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[e] = !0), a && (c[e++] = a); + for (let d = 0; d < b.length; d++) { + a = b[d], a[a.length - 1] === "]" && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); } - e < c.length && (c.length = e); - return 1 < e ? c : c[0]; + e < b.length && (b.length = e); + return e > 1 ? b : b[0]; } -w.append = function(a, b) { - return this.add(a, b, !0); +w.append = function(a, c) { + return this.add(a, c, !0); }; -w.update = function(a, b) { - return this.remove(a).add(a, b); +w.update = function(a, c) { + return this.remove(a).add(a, c); }; w.remove = function(a) { ba(a) && (a = da(a, this.key)); - for (var b of this.index.values()) { - b.remove(a, !0); + for (var c of this.index.values()) { + c.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (let c of this.tag.values()) { - for (let e of c) { - b = e[0]; + for (let b of this.tag.values()) { + for (let e of b) { + c = e[0]; const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : c.delete(b)); + f > -1 && (d.length > 1 ? d.splice(f, 1) : b.delete(c)); } } } @@ -2033,13 +2030,13 @@ w.remove = function(a) { }; w.clear = function() { const a = []; - for (const b of this.index.values()) { - const c = b.clear(); - c.then && a.push(c); + for (const c of this.index.values()) { + const b = c.clear(); + b.then && a.push(b); } if (this.tag) { - for (const b of this.tag.values()) { - b.clear(); + for (const c of this.tag.values()) { + c.clear(); } } this.store && this.store.clear(); @@ -2056,151 +2053,151 @@ w.cleanup = function() { return this; }; w.get = function(a) { - return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { - return b[0] && b[0].doc || null; + return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) { + return c[0] && c[0].doc || null; }) : this.store.get(a) || null; }; -w.set = function(a, b) { - "object" === typeof a && (b = a, a = da(b, this.key)); - this.store.set(a, b); +w.set = function(a, c) { + typeof a === "object" && (c = a, a = da(c, this.key)); + this.store.set(a, c); return this; }; -w.searchCache = ma; -w.export = jb; -w.import = kb; -Fa(Na.prototype); -function lb(a, b = 0) { - let c = [], e = []; - b && (b = 250000 / b * 5000 | 0); +w.searchCache = na; +w.export = kb; +w.import = lb; +Ga(Qa.prototype); +function mb(a, c = 0) { + let b = [], e = []; + c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { - e.push(d), e.length === b && (c.push(e), e = []); - } - e.length && c.push(e); - return c; -} -function mb(a, b) { - b || (b = new Map()); - for (let c = 0, e; c < a.length; c++) { - e = a[c], b.set(e[0], e[1]); + e.push(d), e.length === c && (b.push(e), e = []); } + e.length && b.push(e); return b; } -function nb(a, b = 0) { - let c = [], e = []; - b && (b = 250000 / b * 1000 | 0); - for (const d of a.entries()) { - e.push([d[0], lb(d[1])[0]]), e.length === b && (c.push(e), e = []); +function nb(a, c) { + c || (c = new Map()); + for (let b = 0, e; b < a.length; b++) { + e = a[b], c.set(e[0], e[1]); } - e.length && c.push(e); return c; } -function ob(a, b) { - b || (b = new Map()); - for (let c = 0, e, d; c < a.length; c++) { - e = a[c], d = b.get(e[0]), b.set(e[0], mb(e[1], d)); +function ob(a, c = 0) { + let b = [], e = []; + c && (c = 250000 / c * 1000 | 0); + for (const d of a.entries()) { + e.push([d[0], mb(d[1])[0]]), e.length === c && (b.push(e), e = []); } + e.length && b.push(e); return b; } -function pb(a) { - let b = [], c = []; +function pb(a, c) { + c || (c = new Map()); + for (let b = 0, e, d; b < a.length; b++) { + e = a[b], d = c.get(e[0]), c.set(e[0], nb(e[1], d)); + } + return c; +} +function qb(a) { + let c = [], b = []; for (const e of a.keys()) { - c.push(e), 250000 === c.length && (b.push(c), c = []); + b.push(e), b.length === 250000 && (c.push(b), b = []); } - c.length && b.push(c); - return b; + b.length && c.push(b); + return c; } -function qb(a, b) { - b || (b = new Set()); - for (let c = 0; c < a.length; c++) { - b.add(a[c]); +function rb(a, c) { + c || (c = new Set()); + for (let b = 0; b < a.length; b++) { + c.add(a[b]); } - return b; + return c; } -function rb(a, b, c, e, d, f, g = 0) { +function sb(a, c, b, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { - return this.export(a, b, d, f + 1); + return this.export(a, c, d, f + 1); } - if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { + if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return rb.call(l, a, b, c, k ? e : null, d, f, g + 1); + return sb.call(l, a, c, b, k ? e : null, d, f, g + 1); }); } - return rb.call(this, a, b, c, k ? e : null, d, f, g + 1); + return sb.call(this, a, c, b, k ? e : null, d, f, g + 1); } -function jb(a, b, c = 0, e = 0) { - if (c < this.field.length) { - const g = this.field[c]; - if ((b = this.index.get(g).export(a, g, c, e = 1)) && b.then) { +function kb(a, c, b = 0, e = 0) { + if (b < this.field.length) { + const g = this.field[b]; + if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { const k = this; - return b.then(function() { - return k.export(a, g, c + 1); + return c.then(function() { + return k.export(a, g, b + 1); }); } - return this.export(a, g, c + 1); + return this.export(a, g, b + 1); } let d, f; switch(e) { case 0: d = "reg"; - f = pb(this.reg); - b = null; + f = qb(this.reg); + c = null; break; case 1: d = "tag"; - f = this.tag && nb(this.tag, this.reg.size); - b = null; + f = this.tag && ob(this.tag, this.reg.size); + c = null; break; case 2: d = "doc"; - f = this.store && lb(this.store); - b = null; + f = this.store && mb(this.store); + c = null; break; default: return; } - return rb.call(this, a, b, d, f, c, e); + return sb.call(this, a, c, d, f || null, b, e); } -function kb(a, b) { - var c = a.split("."); - "json" === c[c.length - 1] && c.pop(); - const e = 2 < c.length ? c[0] : ""; - c = 2 < c.length ? c[2] : c[1]; +function lb(a, c) { + var b = a.split("."); + b[b.length - 1] === "json" && b.pop(); + const e = b.length > 2 ? b[0] : ""; + b = b.length > 2 ? b[2] : b[1]; if (this.worker && e) { return this.index.get(e).import(a); } - if (b) { - "string" === typeof b && (b = JSON.parse(b)); + if (c) { + typeof c === "string" && (c = JSON.parse(c)); if (e) { - return this.index.get(e).import(c, b); + return this.index.get(e).import(b, c); } - switch(c) { + switch(b) { case "reg": this.fastupdate = !1; - this.reg = qb(b, this.reg); + this.reg = rb(c, this.reg); for (let d = 0, f; d < this.field.length; d++) { f = this.index.get(this.field[d]), f.fastupdate = !1, f.reg = this.reg; } if (this.worker) { - b = []; + c = []; for (const d of this.index.values()) { - b.push(d.import(a)); + c.push(d.import(a)); } - return Promise.all(b); + return Promise.all(c); } break; case "tag": - this.tag = ob(b, this.tag); + this.tag = pb(c, this.tag); break; case "doc": - this.store = mb(b, this.store); + this.store = nb(c, this.store); } } } -function sb(a, b) { - let c = ""; +function tb(a, c) { + let b = ""; for (const e of a.entries()) { a = e[0]; const d = e[1]; @@ -2209,55 +2206,55 @@ function sb(a, b) { k = d[g] || [""]; let h = ""; for (let l = 0; l < k.length; l++) { - h += (h ? "," : "") + ("string" === b ? '"' + k[l] + '"' : k[l]); + h += (h ? "," : "") + (c === "string" ? '"' + k[l] + '"' : k[l]); } h = "[" + h + "]"; f += (f ? "," : "") + h; } f = '["' + a + '",[' + f + "]]"; - c += (c ? "," : "") + f; + b += (b ? "," : "") + f; } - return c; + return b; } -;V.prototype.remove = function(a, b) { - const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); - if (c) { +;T.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, f; e < c.length; e++) { - if ((d = c[e]) && (f = d.length)) { + for (let e = 0, d, f; e < b.length; e++) { + if ((d = b[e]) && (f = d.length)) { if (d[f - 1] === a) { d.pop(); } else { const g = d.indexOf(a); - 0 <= g && d.splice(g, 1); + g >= 0 && d.splice(g, 1); } } } } else { - tb(this.map, a), this.depth && tb(this.ctx, a); + ub(this.map, a), this.depth && ub(this.ctx, a); } - b || this.reg.delete(a); + c || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.S && ub(this)); + this.db && (this.commit_task.push({del:a}), this.M && vb(this)); this.cache && this.cache.remove(a); return this; }; -function tb(a, b) { - let c = 0; - var e = "undefined" === typeof b; +function ub(a, c) { + let b = 0; + var e = typeof c === "undefined"; if (a.constructor === Array) { for (let d = 0, f, g, k; d < a.length; d++) { if ((f = a[d]) && f.length) { if (e) { return 1; } - g = f.indexOf(b); - if (0 <= g) { - if (1 < f.length) { + g = f.indexOf(c); + if (g >= 0) { + if (f.length > 1) { return f.splice(g, 1), 1; } delete a[d]; - if (c) { + if (b) { return 1; } k = 1; @@ -2265,70 +2262,80 @@ function tb(a, b) { if (k) { return 1; } - c++; + b++; } } } } else { for (let d of a.entries()) { - e = d[0], tb(d[1], b) ? c++ : a.delete(e); + e = d[0], ub(d[1], c) ? b++ : a.delete(e); } } - return c; + return b; } -;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -V.prototype.add = function(a, b, c, e) { - if (b && (a || 0 === a)) { - if (!e && !c && this.reg.has(a)) { - return this.update(a, b); +;const wb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +T.prototype.add = function(a, c, b, e) { + if (c && (a || a === 0)) { + if (!e && !b && this.reg.has(a)) { + return this.update(a, c); } e = this.depth; - b = this.encoder.encode(b, !e); - const l = b.length; + c = this.encoder.encode(c, !e); + const l = c.length; if (l) { - const m = I(), r = I(), t = this.resolution; - for (let q = 0; q < l; q++) { - let u = b[this.rtl ? l - 1 - q : q]; - var d = u.length; - if (d && (e || !r[u])) { - var f = this.score ? this.score(b, u, q, null, 0) : wb(t, l, q), g = ""; + const n = I(), q = I(), u = this.resolution; + for (let r = 0; r < l; r++) { + let t = c[this.rtl ? l - 1 - r : r]; + var d = t.length; + if (d && (e || !q[t])) { + var f = this.score ? this.score(c, t, r, null, 0) : xb(u, l, r), g = ""; switch(this.tokenize) { + case "tolerant": + Y(this, q, t, f, a, b); + if (d > 2) { + for (let m = 1, p, x, v, A; m < d - 1; m++) { + p = t.charAt(m), x = t.charAt(m + 1), v = t.substring(0, m) + x, A = t.substring(m + 2), g = v + p + A, q[g] || Y(this, q, g, f, a, b), g = v + A, q[g] || Y(this, q, g, f, a, b); + } + } + break; case "full": - if (2 < d) { - for (let n = 0, p; n < d; n++) { - for (f = d; f > n; f--) { - g = u.substring(n, f); - p = this.rtl ? d - 1 - n : n; - var k = this.score ? this.score(b, u, q, g, p) : wb(t, l, q, d, p); - xb(this, r, g, k, a, c); + if (d > 2) { + for (let m = 0, p; m < d; m++) { + for (f = d; f > m; f--) { + if (g = t.substring(m, f), !q[g]) { + p = this.rtl ? d - 1 - m : m; + var k = this.score ? this.score(c, t, r, g, p) : xb(u, l, r, d, p); + Y(this, q, g, k, a, b); + } } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (k = d - 1; 0 < k; k--) { - g = u[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(b, u, q, g, k) : wb(t, l, q, d, k); - xb(this, r, g, h, a, c); + if (d > 1) { + for (k = d - 1; k > 0; k--) { + if (g = t[this.rtl ? d - 1 - k : k] + g, !q[g]) { + var h = this.score ? this.score(c, t, r, g, k) : xb(u, l, r, d, k); + Y(this, q, g, h, a, b); + } } g = ""; } case "forward": - if (1 < d) { + if (d > 1) { for (k = 0; k < d; k++) { - g += u[this.rtl ? d - 1 - k : k], xb(this, r, g, f, a, c); + g += t[this.rtl ? d - 1 - k : k], q[g] || Y(this, q, g, f, a, b); } break; } default: - if (xb(this, r, u, f, a, c), e && 1 < l && q < l - 1) { - for (d = I(), g = this.T, f = u, k = Math.min(e + 1, this.rtl ? q + 1 : l - q), d[f] = 1, h = 1; h < k; h++) { - if ((u = b[this.rtl ? l - 1 - q - h : q + h]) && !d[u]) { - d[u] = 1; - const n = this.score ? this.score(b, f, q, u, h - 1) : wb(g + (l / 2 > g ? 0 : 1), l, q, k - 1, h - 1), p = this.bidirectional && u > f; - xb(this, m, p ? f : u, n, a, c, p ? u : f); + if (Y(this, q, t, f, a, b), e && l > 1 && r < l - 1) { + for (d = I(), g = this.N, f = t, k = Math.min(e + 1, this.rtl ? r + 1 : l - r), d[f] = 1, h = 1; h < k; h++) { + if ((t = c[this.rtl ? l - 1 - r - h : r + h]) && !d[t]) { + d[t] = 1; + const m = this.score ? this.score(c, f, r, t, h - 1) : xb(g + (l / 2 > g ? 0 : 1), l, r, k - 1, h - 1), p = this.bidirectional && t > f; + Y(this, n, p ? f : t, m, a, b, p ? t : f); } } } @@ -2337,109 +2344,109 @@ V.prototype.add = function(a, b, c, e) { } this.fastupdate || this.reg.add(a); } else { - b = ""; + c = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.S && ub(this)); + this.db && (c || this.commit_task.push({del:a}), this.M && vb(this)); return this; }; -function xb(a, b, c, e, d, f, g) { +function Y(a, c, b, e, d, f, g) { let k = g ? a.ctx : a.map, h; - if (!b[c] || g && !(h = b[c])[g]) { - if (g ? (b = h || (b[c] = I()), b[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : b[c] = 1, (h = k.get(c)) ? k = h : k.set(c, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { + if (!c[b] || g && !(h = c[b])[g]) { + if (g ? (c = h || (c[b] = I()), c[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { if (k.length === 2 ** 31 - 1) { - b = new Aa(k); + c = new Ba(k); if (a.fastupdate) { for (let l of a.reg.values()) { - l.includes(k) && (l[l.indexOf(k)] = b); + l.includes(k) && (l[l.indexOf(k)] = c); } } - h[e] = k = b; + h[e] = k = c; } k.push(d); a.fastupdate && ((e = a.reg.get(d)) ? e.push(k) : a.reg.set(d, [k])); } } } -function wb(a, b, c, e, d) { - return c && 1 < a ? b + (e || 0) <= a ? c + (d || 0) : (a - 1) / (b + (e || 0)) * (c + (d || 0)) + 1 | 0 : 0; +function xb(a, c, b, e, d) { + return b && a > 1 ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;V.prototype.search = function(a, b, c) { - c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); - if (c && c.cache) { - return c.cache = !1, a = this.searchCache(a, b, c), c.cache = !0, a; +;T.prototype.search = function(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = "")); + if (b && b.cache) { + return b.cache = !1, a = this.searchCache(a, c, b), b.cache = !0, a; } - let e = [], d, f, g, k = 0, h, l, m, r, t; - c && (a = c.query || a, b = c.limit || b, k = c.offset || 0, f = c.context, g = c.suggest, t = (h = c.resolve) && c.enrich, m = c.boost, r = c.resolution, l = this.db && c.tag); - "undefined" === typeof h && (h = this.resolve); - f = this.depth && !1 !== f; - let q = this.encoder.encode(a, !f); - d = q.length; - b = b || (h ? 100 : 0); - if (1 === d) { - return yb.call(this, q[0], "", b, k, h, t, l); + let e = [], d, f, g, k = 0, h, l, n, q, u; + b && (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, u = (h = b.resolve) && b.enrich, n = b.boost, q = b.resolution, l = this.db && b.tag); + typeof h === "undefined" && (h = this.resolve); + f = this.depth && f !== !1; + let r = this.encoder.encode(a, !f); + d = r.length; + c = c || (h ? 100 : 0); + if (d === 1) { + return yb.call(this, r[0], "", c, k, h, u, l); } - if (2 === d && f && !g) { - return yb.call(this, q[1], q[0], b, k, h, t, l); + if (d === 2 && f && !g) { + return yb.call(this, r[1], r[0], c, k, h, u, l); } - let u = I(), n = 0, p; - f && (p = q[0], n = 1); - r || 0 === r || (r = p ? this.T : this.resolution); + let t = I(), m = 0, p; + f && (p = r[0], m = 1); + q || q === 0 || (q = p ? this.N : this.resolution); if (this.db) { - if (this.db.search && (c = this.db.search(this, q, b, k, g, h, t, l), !1 !== c)) { - return c; + if (this.db.search && (b = this.db.search(this, r, c, k, g, h, u, l), b !== !1)) { + return b; } - const y = this; + const x = this; return async function() { - for (let v, D; n < d; n++) { - if ((D = q[n]) && !u[D]) { - u[D] = 1; - v = await zb(y, D, p, 0, 0, !1, !1); - if (v = Ab(v, e, g, r)) { + for (let v, A; m < d; m++) { + if ((A = r[m]) && !t[A]) { + t[A] = 1; + v = await zb(x, A, p, 0, 0, !1, !1); + if (v = Ab(v, e, g, q)) { e = v; break; } - p && (g && v && e.length || (p = D)); + p && (g && v && e.length || (p = A)); } - g && p && n === d - 1 && !e.length && (r = y.resolution, p = "", n = -1, u = I()); + g && p && m === d - 1 && !e.length && (q = x.resolution, p = "", m = -1, t = I()); } - return Bb(e, r, b, k, g, m, h); + return Bb(e, q, c, k, g, n, h); }(); } - for (let y, v; n < d; n++) { - if ((v = q[n]) && !u[v]) { - u[v] = 1; - y = zb(this, v, p, 0, 0, !1, !1); - if (y = Ab(y, e, g, r)) { - e = y; + for (let x, v; m < d; m++) { + if ((v = r[m]) && !t[v]) { + t[v] = 1; + x = zb(this, v, p, 0, 0, !1, !1); + if (x = Ab(x, e, g, q)) { + e = x; break; } - p && (g && y && e.length || (p = v)); + p && (g && x && e.length || (p = v)); } - g && p && n === d - 1 && !e.length && (r = this.resolution, p = "", n = -1, u = I()); + g && p && m === d - 1 && !e.length && (q = this.resolution, p = "", m = -1, t = I()); } - return Bb(e, r, b, k, g, m, h); + return Bb(e, q, c, k, g, n, h); }; -function Bb(a, b, c, e, d, f, g) { +function Bb(a, c, b, e, d, f, g) { let k = a.length, h = a; - if (1 < k) { - h = $a(a, b, c, e, d, f, g); - } else if (1 === k) { - return g ? Sa.call(null, a[0], c, e) : new Y(a[0], this); + if (k > 1) { + h = ab(a, c, b, e, d, f, g); + } else if (k === 1) { + return g ? Ta.call(null, a[0], b, e) : new X(a[0], this); } - return g ? h : new Y(h, this); + return g ? h : new X(h, this); } -function yb(a, b, c, e, d, f, g) { - a = zb(this, a, b, c, e, d, f, g); +function yb(a, c, b, e, d, f, g) { + a = zb(this, a, c, b, e, d, f, g); return this.db ? a.then(function(k) { - return d ? k || [] : new Y(k, this); - }) : a && a.length ? d ? Sa.call(this, a, c, e) : new Y(a, this) : d ? [] : new Y([], this); + return d ? k || [] : new X(k, this); + }) : a && a.length ? d ? Ta.call(this, a, b, e) : new X(a, this) : d ? [] : new X([], this); } -function Ab(a, b, c, e) { +function Ab(a, c, b, e) { let d = []; if (a && a.length) { if (a.length <= e) { - b.push(a); + c.push(a); return; } for (let f = 0, g; f < e; f++) { @@ -2448,73 +2455,73 @@ function Ab(a, b, c, e) { } } if (d.length) { - b.push(d); + c.push(d); return; } } - if (!c) { + if (!b) { return d; } } -function zb(a, b, c, e, d, f, g, k) { +function zb(a, c, b, e, d, f, g, k) { let h; - c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); + b && (h = a.bidirectional && c > b) && (h = b, b = c, c = h); if (a.db) { - return a.db.get(b, c, e, d, f, g, k); + return a.db.get(c, b, e, d, f, g, k); } - a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); + a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function V(a, b) { - if (!this || this.constructor !== V) { - return new V(a); +;function T(a, c) { + if (!this || this.constructor !== T) { + return new T(a); } if (a) { - var c = N(a) ? a : a.preset; - c && (vb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, vb[c], a)); + var b = N(a) ? a : a.preset; + b && (wb[b] || console.warn("Preset not found: " + b), a = Object.assign({}, wb[b], a)); } else { a = {}; } - c = a.context; - const e = !0 === c ? {depth:1} : c || {}, d = N(a.encoder) ? wa[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new la(d) : {encode:d}; + b = a.context; + const e = b === !0 ? {depth:1} : b || {}, d = N(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || {}; + this.encoder = d.encode ? d : typeof d === "object" ? new la(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; - this.depth = "strict" === c && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict"; + this.depth = b === "strict" && e.depth || 0; + this.bidirectional = e.bidirectional !== !1; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - (c = a.keystore || 0) && (this.keystore = c); - this.map = c ? new R(c) : new Map(); - this.ctx = c ? new R(c) : new Map(); - this.reg = b || (this.fastupdate ? c ? new R(c) : new Map() : c ? new S(c) : new Set()); - this.T = e.resolution || 3; + e && e.depth && this.tokenize !== "strict" && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + (b = a.keystore || 0) && (this.keystore = b); + this.map = b ? new Q(b) : new Map(); + this.ctx = b ? new Q(b) : new Map(); + this.reg = c || (this.fastupdate ? b ? new Q(b) : new Map() : b ? new R(b) : new Set()); + this.N = e.resolution || 3; this.rtl = d.rtl || a.rtl || !1; - this.cache = (c = a.cache || null) && new na(c); - this.resolve = !1 !== a.resolve; - if (c = a.db) { - this.db = this.mount(c); + this.cache = (b = a.cache || null) && new oa(b); + this.resolve = a.resolve !== !1; + if (b = a.db) { + this.db = this.mount(b); } - this.S = !1 !== a.commit; + this.M = a.commit !== !1; this.commit_task = []; this.commit_timer = null; this.priority = a.priority || 4; } -w = V.prototype; +w = T.prototype; w.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -w.commit = function(a, b) { +w.commit = function(a, c) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.commit(this, a, b); + return this.db.commit(this, a, c); }; w.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function ub(a) { +function vb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2527,31 +2534,31 @@ w.clear = function() { this.cache && this.cache.clear(); return this.db ? (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [], this.db.clear()) : this; }; -w.append = function(a, b) { - return this.add(a, b, !0); +w.append = function(a, c) { + return this.add(a, c, !0); }; w.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -w.update = function(a, b) { - const c = this, e = this.remove(a); - return e && e.then ? e.then(() => c.add(a, b)) : this.add(a, b); +w.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); }; w.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - tb(this.map); - this.depth && tb(this.ctx); + ub(this.map); + this.depth && ub(this.ctx); return this; }; -w.searchCache = ma; -w.export = function(a, b, c = 0, e = 0) { +w.searchCache = na; +w.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = pb(this.reg); + f = qb(this.reg); break; case 1: d = "cfg"; @@ -2559,64 +2566,64 @@ w.export = function(a, b, c = 0, e = 0) { break; case 2: d = "map"; - f = lb(this.map, this.reg.size); + f = mb(this.map, this.reg.size); break; case 3: d = "ctx"; - f = nb(this.ctx, this.reg.size); + f = ob(this.ctx, this.reg.size); break; default: return; } - return rb.call(this, a, b, d, f, c, e); + return sb.call(this, a, c, d, f, b, e); }; -w.import = function(a, b) { - if (b) { - switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { +w.import = function(a, c) { + if (c) { + switch(typeof c === "string" && (c = JSON.parse(c)), a = a.split("."), a[a.length - 1] === "json" && a.pop(), a.length === 3 && a.shift(), a = a.length > 1 ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = qb(b, this.reg); + this.reg = rb(c, this.reg); break; case "map": - this.map = mb(b, this.map); + this.map = nb(c, this.map); break; case "ctx": - this.ctx = ob(b, this.ctx); + this.ctx = pb(c, this.ctx); } } }; w.serialize = function(a = !0) { - let b = "", c = "", e = ""; + let c = "", b = "", e = ""; if (this.reg.size) { let f; for (var d of this.reg.keys()) { - f || (f = typeof d), b += (b ? "," : "") + ("string" === f ? '"' + d + '"' : d); + f || (f = typeof d), c += (c ? "," : "") + (f === "string" ? '"' + d + '"' : d); } - b = "index.reg=new Set([" + b + "]);"; - c = sb(this.map, f); - c = "index.map=new Map([" + c + "]);"; + c = "index.reg=new Set([" + c + "]);"; + b = tb(this.map, f); + b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let k = sb(g[1], f); + let k = tb(g[1], f); k = "new Map([" + k + "])"; k = '["' + d + '",' + k + "]"; e += (e ? "," : "") + k; } e = "index.ctx=new Map([" + e + "]);"; } - return a ? "function inject(index){" + b + c + e + "}" : b + c + e; + return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -Fa(V.prototype); -const Cb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Db = ["map", "ctx", "tag", "reg", "cfg"], Eb = I(); -function Fb(a, b = {}) { +Ga(T.prototype); +const Cb = typeof window !== "undefined" && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Db = ["map", "ctx", "tag", "reg", "cfg"], Eb = I(); +function Fb(a, c = {}) { if (!this || this.constructor !== Fb) { - return new Fb(a, b); + return new Fb(a, c); } - "object" === typeof a && (b = a, a = a.name); + typeof a === "object" && (c = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); - this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; - this.type = b.type; + this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; + this.type = c.type; this.fastupdate = this.support_tag_search = !1; this.db = null; this.h = {}; @@ -2637,18 +2644,18 @@ w.open = function() { navigator.storage && navigator.storage.persist(); Eb[a.id] || (Eb[a.id] = []); Eb[a.id].push(a.field); - const b = Cb.open(a.id, 1); - b.onupgradeneeded = function() { - const c = a.db = this.result; + const c = Cb.open(a.id, 1); + c.onupgradeneeded = function() { + const b = a.db = this.result; for (let e = 0, d; e < Db.length; e++) { d = Db[e]; for (let f = 0, g; f < Eb[a.id].length; f++) { - g = Eb[a.id][f], c.objectStoreNames.contains(d + ("reg" !== d ? g ? ":" + g : "" : "")) || c.createObjectStore(d + ("reg" !== d ? g ? ":" + g : "" : "")); + g = Eb[a.id][f], b.objectStoreNames.contains(d + (d !== "reg" ? g ? ":" + g : "" : "")) || b.createObjectStore(d + (d !== "reg" ? g ? ":" + g : "" : "")); } } }; - return a.db = Z(b, function(c) { - a.db = c; + return a.db = Z(c, function(b) { + a.db = b; a.db.onversionchange = function() { a.close(); }; @@ -2664,20 +2671,20 @@ w.destroy = function() { }; w.clear = function() { const a = []; - for (let c = 0, e; c < Db.length; c++) { - e = Db[c]; + for (let b = 0, e; b < Db.length; b++) { + e = Db[b]; for (let d = 0, f; d < Eb[this.id].length; d++) { - f = Eb[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); + f = Eb[this.id][d], a.push(e + (e !== "reg" ? f ? ":" + f : "" : "")); } } - const b = this.db.transaction(a, "readwrite"); - for (let c = 0; c < a.length; c++) { - b.objectStore(a[c]).clear(); + const c = this.db.transaction(a, "readwrite"); + for (let b = 0; b < a.length; b++) { + c.objectStore(a[b]).clear(); } - return Z(b); + return Z(c); }; -w.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { - a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); +w.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { + a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a); const g = this; return Z(a).then(function(k) { let h = []; @@ -2685,21 +2692,21 @@ w.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { return h; } if (d) { - if (!c && !e && 1 === k.length) { + if (!b && !e && k.length === 1) { return k[0]; } - for (let l = 0, m; l < k.length; l++) { - if ((m = k[l]) && m.length) { - if (e >= m.length) { - e -= m.length; + for (let l = 0, n; l < k.length; l++) { + if ((n = k[l]) && n.length) { + if (e >= n.length) { + e -= n.length; continue; } - const r = c ? e + Math.min(m.length - e, c) : m.length; - for (let t = e; t < r; t++) { - h.push(m[t]); + const q = b ? e + Math.min(n.length - e, b) : n.length; + for (let u = e; u < q; u++) { + h.push(n[u]); } e = 0; - if (h.length === c) { + if (h.length === b) { break; } } @@ -2709,27 +2716,27 @@ w.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { return k; }); }; -w.tag = function(a, b = 0, c = 0, e = !1) { +w.tag = function(a, c = 0, b = 0, e = !1) { a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); const d = this; return Z(a).then(function(f) { - if (!f || !f.length || c >= f.length) { + if (!f || !f.length || b >= f.length) { return []; } - if (!b && !c) { + if (!c && !b) { return f; } - f = f.slice(c, c + b); + f = f.slice(b, b + c); return e ? d.enrich(f) : f; }); }; w.enrich = function(a) { - "object" !== typeof a && (a = [a]); - const b = this.db.transaction("reg", "readonly").objectStore("reg"), c = []; + typeof a !== "object" && (a = [a]); + const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = []; for (let e = 0; e < a.length; e++) { - c[e] = Z(b.get(a[e])); + b[e] = Z(c.get(a[e])); } - return Promise.all(c).then(function(e) { + return Promise.all(b).then(function(e) { for (let d = 0; d < e.length; d++) { e[d] = {id:a[d], doc:e[d] ? JSON.parse(e[d]) : null}; } @@ -2738,30 +2745,30 @@ w.enrich = function(a) { }; w.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Z(a).then(function(b) { - return !!b; + return Z(a).then(function(c) { + return !!c; }); }; w.search = null; w.info = function() { }; -w.transaction = function(a, b, c) { - a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; - let e = this.h[a + ":" + b]; +w.transaction = function(a, c, b) { + a += a !== "reg" ? this.field ? ":" + this.field : "" : ""; + let e = this.h[a + ":" + c]; if (e) { - return c.call(this, e); + return b.call(this, e); } - let d = this.db.transaction(a, b); - this.h[a + ":" + b] = e = d.objectStore(a); - const f = c.call(this, e); - this.h[a + ":" + b] = null; + let d = this.db.transaction(a, c); + this.h[a + ":" + c] = e = d.objectStore(a); + const f = b.call(this, e); + this.h[a + ":" + c] = null; return Z(d).finally(function() { d = e = null; return f; }); }; -w.commit = async function(a, b, c) { - if (b) { +w.commit = async function(a, c, b) { + if (c) { await this.clear(), a.commit_task = []; } else { let e = a.commit_task; @@ -2769,30 +2776,30 @@ w.commit = async function(a, b, c) { for (let d = 0, f; d < e.length; d++) { if (f = e[d], f.clear) { await this.clear(); - b = !0; + c = !0; break; } else { e[d] = f.del; } } - b || (c || (e = e.concat(ca(a.reg))), e.length && await this.remove(e)); + c || (b || (e = e.concat(ca(a.reg))), e.length && await this.remove(e)); } a.reg.size && (await this.transaction("map", "readwrite", function(e) { for (const d of a.map) { const f = d[0], g = d[1]; - g.length && (b ? e.put(g, f) : e.get(f).onsuccess = function() { + g.length && (c ? e.put(g, f) : e.get(f).onsuccess = function() { let k = this.result; var h; if (k && k.length) { const l = Math.max(k.length, g.length); - for (let m = 0, r, t; m < l; m++) { - if ((t = g[m]) && t.length) { - if ((r = k[m]) && r.length) { - for (h = 0; h < t.length; h++) { - r.push(t[h]); + for (let n = 0, q, u; n < l; n++) { + if ((u = g[n]) && u.length) { + if ((q = k[n]) && q.length) { + for (h = 0; h < u.length; h++) { + q.push(u[h]); } } else { - k[m] = t; + k[n] = u; } h = 1; } @@ -2808,34 +2815,34 @@ w.commit = async function(a, b, c) { const f = d[0], g = d[1]; for (const k of g) { const h = k[0], l = k[1]; - l.length && (b ? e.put(l, f + ":" + h) : e.get(f + ":" + h).onsuccess = function() { - let m = this.result; - var r; - if (m && m.length) { - const t = Math.max(m.length, l.length); - for (let q = 0, u, n; q < t; q++) { - if ((n = l[q]) && n.length) { - if ((u = m[q]) && u.length) { - for (r = 0; r < n.length; r++) { - u.push(n[r]); + l.length && (c ? e.put(l, f + ":" + h) : e.get(f + ":" + h).onsuccess = function() { + let n = this.result; + var q; + if (n && n.length) { + const u = Math.max(n.length, l.length); + for (let r = 0, t, m; r < u; r++) { + if ((m = l[r]) && m.length) { + if ((t = n[r]) && t.length) { + for (q = 0; q < m.length; q++) { + t.push(m[q]); } } else { - m[q] = n; + n[r] = m; } - r = 1; + q = 1; } } } else { - m = l, r = 1; + n = l, q = 1; } - r && e.put(m, f + ":" + h); + q && e.put(n, f + ":" + h); }); } } }), a.store ? await this.transaction("reg", "readwrite", function(e) { for (const d of a.store) { const f = d[0], g = d[1]; - e.put("object" === typeof g ? JSON.stringify(g) : 1, f); + e.put(typeof g === "object" ? JSON.stringify(g) : 1, f); } }) : a.bypass || await this.transaction("reg", "readwrite", function(e) { for (const d of a.reg.keys()) { @@ -2852,14 +2859,14 @@ w.commit = async function(a, b, c) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function Gb(a, b, c) { +function Gb(a, c, b) { const e = a.value; let d, f = 0; for (let g = 0, k; g < e.length; g++) { - if (k = c ? e : e[g]) { - for (let h = 0, l, m; h < b.length; h++) { - if (m = b[h], l = k.indexOf(m), 0 <= l) { - if (d = 1, 1 < k.length) { + if (k = b ? e : e[g]) { + for (let h = 0, l, n; h < c.length; h++) { + if (n = c[h], l = k.indexOf(n), l >= 0) { + if (d = 1, k.length > 1) { k.splice(l, 1); } else { e[g] = []; @@ -2869,7 +2876,7 @@ function Gb(a, b, c) { } f += k.length; } - if (c) { + if (b) { break; } } @@ -2877,39 +2884,39 @@ function Gb(a, b, c) { a.continue(); } w.remove = function(a) { - "object" !== typeof a && (a = [a]); - return Promise.all([this.transaction("map", "readwrite", function(b) { - b.openCursor().onsuccess = function() { - const c = this.result; - c && Gb(c, a); + typeof a !== "object" && (a = [a]); + return Promise.all([this.transaction("map", "readwrite", function(c) { + c.openCursor().onsuccess = function() { + const b = this.result; + b && Gb(b, a); }; - }), this.transaction("ctx", "readwrite", function(b) { - b.openCursor().onsuccess = function() { - const c = this.result; - c && Gb(c, a); + }), this.transaction("ctx", "readwrite", function(c) { + c.openCursor().onsuccess = function() { + const b = this.result; + b && Gb(b, a); }; - }), this.transaction("tag", "readwrite", function(b) { - b.openCursor().onsuccess = function() { - const c = this.result; - c && Gb(c, a, !0); + }), this.transaction("tag", "readwrite", function(c) { + c.openCursor().onsuccess = function() { + const b = this.result; + b && Gb(b, a, !0); }; - }), this.transaction("reg", "readwrite", function(b) { - for (let c = 0; c < a.length; c++) { - b.delete(a[c]); + }), this.transaction("reg", "readwrite", function(c) { + for (let b = 0; b < a.length; b++) { + c.delete(a[b]); } })]); }; -function Z(a, b) { - return new Promise((c, e) => { +function Z(a, c) { + return new Promise((b, e) => { a.onsuccess = a.oncomplete = function() { - b && b(this.result); - b = null; - c(this.result); + c && c(this.result); + c = null; + b(this.result); }; a.onerror = a.onblocked = e; a = null; }); } -;export default {Index:V, Charset:wa, Encoder:la, Document:Na, Worker:La, Resolver:Y, IndexedDB:Fb, Language:{}}; +;export default {Index:T, Charset:xa, Encoder:la, Document:Qa, Worker:Ma, Resolver:X, IndexedDB:Fb, Language:{}}; -export const Index=V;export const Charset=wa;export const Encoder=la;export const Document=Na;export const Worker=La;export const Resolver=Y;export const IndexedDB=Fb;export const Language={}; \ No newline at end of file +export const Index=T;export const Charset=xa;export const Encoder=la;export const Document=Qa;export const Worker=Ma;export const Resolver=X;export const IndexedDB=Fb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index bb7cb8f..99712ba 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,108 +1,108 @@ /**! - * FlexSearch.js v0.8.202 (Bundle/Module) + * FlexSearch.js v0.8.203 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var w;function H(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function aa(a,b){return"undefined"===typeof a?b:a}function I(){return Object.create(null)} -function M(a){return"string"===typeof a}function ba(a){return"object"===typeof a}function ca(a){const b=[];for(const c of a.keys())b.push(c);return b}function ea(a,b){if(M(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=H(a.numeric,e)}else{try{this.split=H(this.split,fa)}catch(d){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);c=a.filter;this.filter="function"===typeof c?c:H(c&&new Set(c),null,this.filter);this.dedupe=H(a.dedupe,!0,this.dedupe);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,1024,this.maxlength);this.rtl=H(a.rtl,!1,this.rtl);if(this.cache=c=H(a.cache,!0,this.cache))this.I=null,this.R="number"===typeof c?c:2E5,this.C=new Map,this.H=new Map,this.M=this.L=128;this.h="";this.N=null;this.B="";this.O=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.B+= -(this.B?"|":"")+d;return this};w.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.B+=(this.B?"|":"")+a;this.O=null;this.cache&&Q(this);return this};w.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&Q(this);return this}; -w.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.N=null;this.cache&&Q(this);return this}; -w.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&Q(this);return this}; -w.encode=function(a,b){if(this.cache&&a.length<=this.L)if(this.I){if(this.C.has(a))return this.C.get(a)}else this.I=setTimeout(Q,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(b){if(d[m])continue;d[m]=1}else{if(f===m)continue;f=m}if(c)e.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.M)if(this.I){var k=this.H.get(m);if(k||""===k){k&&e.push(k);continue}}else this.I=setTimeout(Q,50,this);if(this.stemmer){this.O||(this.O=new RegExp("(?!^)("+ -this.B+")$"));let t;for(;t!==m&&2this.stemmer.get(r))}if(m&&(this.mapper||this.dedupe&&1this.matcher.get(t)));if(m&&this.replacer)for(k=0;m&&kthis.R&&(this.H.clear(),this.M=this.M/1.1|0));if(m){if(m!==q)if(b){if(d[m])continue;d[m]=1}else{if(g===m)continue;g=m}e.push(m)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.L&&(this.C.set(a,e),this.C.size>this.R&&(this.C.clear(),this.L=this.L/1.1|0));return e};function Q(a){a.I=null;a.C.clear();a.H.clear()};function ma(a,b,c){c||(b||"object"!==typeof a?"object"===typeof b&&(c=b,b=0):c=a);c&&(a=c.query||a,b=c.limit||b);let e=""+(b||0);c&&(e+=(c.offset||0)+!!c.context+!!c.suggest+(!1!==c.resolve)+(c.resolution||this.resolution)+(c.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new R);let d=this.cache.get(a+e);if(!d){const f=c&&c.cache;f&&(c.cache=!1);d=this.search(a,b,c);f&&(c.cache=f);this.cache.set(a+e,d)}return d}function R(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""} -R.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};R.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};R.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};R.prototype.clear=function(){this.cache.clear();this.h=""};const na={normalize:!1,numeric:!1,dedupe:!1};const qa={};const ra=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"]]);const sa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ta=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ua={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 va={Exact:na,Default:qa,Normalize:qa,LatinBalance:{mapper:ra},LatinAdvanced:{mapper:ra,matcher:sa,replacer:ta},LatinExtra:{mapper:ra,replacer:ta.concat([/(?!^)[aeo]/g,""]),matcher:sa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} -function xa(a){if(!this||this.constructor!==xa)return new xa(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,h,k;g=this.priority*this.priority*3):(Ha=setTimeout(Ka,0),Ia=Date.now());if(Ja){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let W=0; -function La(a={},b){function c(h){function k(l){l=l.data||l;const m=l.id,q=m&&f.h[m];q&&(q(l.msg),delete f.h[m])}this.worker=h;this.h=I();if(this.worker){d?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(l){1E9b?a.slice(c,c+b):a,e?Ta.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}g=g.slice(c,c+b);h=g.length;c=0}h>b&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?Ta.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ya(a,b,c,!1,this.h),c=0));d&&(this.await=null);return d?this.resolve(b,c,e,g):this};Y.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,b,c,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let h;if(a.length)if(this.result.length&&a.unshift(this.result),2>a.length)this.result=a[0];else{let k=0;for(let l=0,m,q;la.length)this.result=a[0];else{a:{f=c;var h=this.h;const k=[],l=I();let m=0;for(let q=0,t;qD&&(D=n.length+(n?1:0)),B=n.length+(n?1:0)+F.length,G+=C,za.push(v.length),v.push({match:F})),n+=(n?" ":"")+F)}if(!x)E=y[A],n+=(n?" ":"")+E,k&&v.push({text:E});else if(k&&G>=k)break}G=za.length*(f.length-2);if(r||u||k&&n.length-G>k)if(G=k+G-2*t,A=B-D,0y&&(y=0)),v=v.length-1){if(J>= -v.length){A[x+1]=1;J>=y.length&&(G[x+1]=1);continue}C-=t}n=v[J].text;if(L=u&&z[x])if(0L)if(A[x+1]=1,l)n=n.substring(0,L);else continue;(L-=n.length)||(L=-1);z[x]=L}else{A[x+1]=1;continue}if(C+n.length+1<=k)n=" "+n,B[x]+=n;else if(l)U=k-C-1,0=J){if(0>J){A[x]=1;G[x]=1;continue}C-=t}n=v[J].text;if(L=r&&E[x])if(0L)if(A[x]=1,l)n=n.substring(n.length- -L);else continue;(L-=n.length)||(L=-1);E[x]=L}else{A[x]=1;continue}if(C+n.length+1<=k)n+=" ",B[x]=n+B[x];else if(l)U=n.length+1-(k-C),0<=U&&U=y.length-1?Pa=1:Jc||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+ -e)}else{d=[];for(let q=0,t;qe)e-=t.length;else{if(c&&t.length>c||e)t=t.slice(e,c+e),c-=t.length,e&&(e-=t.length);d.push(t);if(!c)break}k=d}}return k} -function Ya(a,b,c,e,d){const f=[],g=I();let h;var k=a.length;let l;if(e)for(d=k-1;0<=d;d--){if(l=(e=a[d])&&e.length)for(k=0;kc||e)a=a.slice(e,e+c);d&&(a=Ta.call(this,a))}return a} -function Ta(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);const b=Array(a.length);for(let c=0,e;c1)return this.addMatcher(a,b);this.mapper||(this.mapper=new Map);this.mapper.set(a,b);this.cache&&Q(this);return this};w.addMatcher=function(a,b){if(typeof a==="object")return this.addReplacer(a,b);if(a.length<2&&(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.J=null;this.cache&&Q(this);return this}; +w.addReplacer=function(a,b){if(typeof a==="string")return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&Q(this);return this}; +w.encode=function(a,b){if(this.cache&&a.length<=this.H)if(this.F){if(this.B.has(a))return this.B.get(a)}else this.F=setTimeout(Q,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(ia,"$1 $2").replace(ja,"$1 $2").replace(ha,"$1 "));const c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let e= +[],d=I(),f,g,h=this.split||this.split===""?a.split(this.split):[a];for(let l=0,m,n;lthis.maxlength)){if(b){if(d[m])continue;d[m]=1}else{if(f===m)continue;f=m}if(c)e.push(m);else if(!this.filter||(typeof this.filter==="function"?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.I)if(this.F){var k=this.D.get(m);if(k||k===""){k&&e.push(k);continue}}else this.F=setTimeout(Q,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+ +this.A+")$"));let u;for(;u!==m&&m.length>2;)u=m,m=m.replace(this.K,r=>this.stemmer.get(r))}if(m&&(this.mapper||this.dedupe&&m.length>1)){k="";for(let u=0,r="",t,p;u1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),m=m.replace(this.J,u=>this.matcher.get(u)));if(m&&this.replacer)for(k=0;m&&kthis.L&&(this.D.clear(),this.I=this.I/1.1|0));if(m){if(m!==n)if(b){if(d[m])continue;d[m]=1}else{if(g===m)continue;g=m}e.push(m)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.H&&(this.B.set(a,e),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0));return e};function Q(a){a.F=null;a.B.clear();a.D.clear()};function ma(a,b,c){c||(b||typeof a!=="object"?typeof b==="object"&&(c=b,b=0):c=a);c&&(a=c.query||a,b=c.limit||b);let e=""+(b||0);c&&(e+=(c.offset||0)+!!c.context+!!c.suggest+(c.resolve!==!1)+(c.resolution||this.resolution)+(c.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new na);let d=this.cache.get(a+e);if(!d){const f=c&&c.cache;f&&(c.cache=!1);d=this.search(a,b,c);f&&(c.cache=f);this.cache.set(a+e,d)}return d}function na(a){this.limit=a&&a!==!0?a:1E3;this.cache=new Map;this.h=""} +na.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};na.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};na.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};na.prototype.clear=function(){this.cache.clear();this.h=""};const oa={normalize:!1,numeric:!1,dedupe:!1};const ra={};const sa=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"]]);const ta=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ua=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const va={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 wa={Exact:oa,Default:ra,Normalize:ra,LatinBalance:{mapper:sa},LatinAdvanced:{mapper:sa,matcher:ta,replacer:ua},LatinExtra:{mapper:sa,replacer:ua.concat([/(?!^)[aeo]/g,""]),matcher:ta},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} +function Aa(a){if(!this||this.constructor!==Aa)return new Aa(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if(e==="length")return b.length;if(e==="push")return function(d){b.index[b.index.length-1].push(d);b.length++};if(e==="pop")return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if(e==="indexOf")return function(d){let f=0;for(let g=0,h,k;g=0)return f+k;f+=h.length}return-1}; +if(e==="includes")return function(d){for(let f=0;f32?(this.B=Ba,this.A=BigInt(a)):(this.B=Ca,this.A=a)}R.prototype.get=function(a){const b=this.index[this.B(a)];return b&&b.get(a)};R.prototype.set=function(a,b){var c=this.B(a);let e=this.index[c];e?(c=e.size,e.set(a,b),(c-=e.size)&&this.size++):(this.index[c]=e=new Map([[a,b]]),this.h.push(e),this.size++)}; +function S(a=8){if(!this||this.constructor!==S)return new S(a);this.index=I();this.h=[];this.size=0;a>32?(this.B=Ba,this.A=BigInt(a)):(this.B=Ca,this.A=a)}S.prototype.add=function(a){var b=this.B(a);let c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c),this.size++)};w=R.prototype;w.has=S.prototype.has=function(a){const b=this.index[this.B(a)];return b&&b.has(a)}; +w.delete=S.prototype.delete=function(a){const b=this.index[this.B(a)];b&&b.delete(a)&&this.size--};w.clear=S.prototype.clear=function(){this.index=I();this.h=[];this.size=0};w.values=S.prototype.values=function*(){for(let a=0;a=this.priority*this.priority*3):(Ia=setTimeout(La,0),Ja=Date.now());if(Ka){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let V=0; +function Ma(a={},b){function c(h){function k(l){l=l.data||l;const m=l.id,n=m&&f.h[m];n&&(n(l.msg),delete f.h[m])}this.worker=h;this.h=I();if(this.worker){d?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(l){V>1E9&&(V=0);f.h[++V]=function(){l(f)};f.worker.postMessage({id:V,task:"init",factory:e,options:a})});this.priority=a.priority||4;this.encoder=b||null;this.worker.postMessage({task:"init",factory:e,options:a});return this}}if(!this||this.constructor!==Ma)return new Ma(a); +let e=typeof self!=="undefined"?self._factory:typeof window!=="undefined"?window._factory:null;e&&(e=e.toString());const d=typeof window==="undefined",f=this,g=Na(e,d,a.worker);return g.then?g.then(function(h){return c.call(f,h)}):c.call(this,g)}W("add");W("append");W("search");W("update");W("remove");W("clear");W("export");W("import");Ma.prototype.searchCache=ma;Ga(Ma.prototype); +function W(a){Ma.prototype[a]=function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;typeof e==="function"&&(d=e,c.pop());e=new Promise(function(f){a==="export"&&typeof c[0]==="function"&&(c[0]=null);V>1E9&&(V=0);b.h[++V]=f;b.worker.postMessage({task:a,id:V,args:c})});return d?(e.then(d),this):e}} +function Na(a,b,c){return b?typeof module!=="undefined"?new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js"):import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Fa.toString()],{type:"text/javascript"}))):new window.Worker(typeof c==="string"?c:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", +"module/worker/worker.js"),{type:"module"})};Qa.prototype.add=function(a,b,c){ba(a)&&(b=a,a=ea(b,this.key));if(b&&(a||a===0)){if(!c&&this.reg.has(a))return this.update(a,b);for(let h=0,k;hb?a.slice(c,c+b):a,e?Ua.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}g=g.slice(c,c+b);h=g.length;c=0}h>b&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?Ua.call(this,g):g;d.push(g);b-=h;if(!b)break}d=d.length>1?[].concat.apply([],d):d[0];return e?Ua.call(this,d):d};function Va(a,b,c,e){var d=e[0];if(d[0]&&d[0].query)return a[b].apply(a,d);if(!(b!=="and"&&b!=="not"||a.result.length||a.await||d.suggest))return e.length>1&&(d=e[e.length-1]),(e=d.resolve)?a.await||a.result:a;let f=[],g=0,h=0,k,l,m,n,u;for(b=0;b1&&(c=c[b].apply(c,a.slice(1)));return c};X.prototype.or=function(){return Va(this,"or",Ya,arguments)};function Ya(a,b,c,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Za(a,b,c,!1,this.h),c=0));d&&(this.await=null);return d?this.resolve(b,c,e,g):this};X.prototype.and=function(){return Va(this,"and",$a,arguments)};function $a(a,b,c,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let h;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let k=0;for(let l=0,m,n;l1?z.join(" "):z[0];let y;if(z&&E){var D=E.length,K=(da.split? +E.replace(da.split,""):E).length-z.length,F="",N=0;for(var O=0;O-1&&(F=(P?E.substring(0,P):"")+g+E.substring(P,P+L)+h+(P+L=k)break}G=za.length*(f.length-2);if(r||t||k&&q.length-G>k)if(G=k+G-u*2,B=C-A,r>0&& +(B+=r),t>0&&(B+=t),B<=G)x=r?A-(r>0?r:0):A-((G-B)/2|0),v=t?C+(t>0?t:0):x+G,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-1){if(J>= +v.length){B[y+1]=1;J>=x.length&&(G[y+1]=1);continue}D-=u}q=v[J].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(B[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{B[y+1]=1;continue}if(D+q.length+1<=k)q=" "+q,C[y]+=q;else if(l)U=k-D-1,U>0&&(q=" "+q.substring(0,U),C[y]+=q),B[y+1]=1;else{B[y+1]=1;continue}}else{if(B[y])continue;J-=K;if(A[J]){D-=u;B[y]=1;G[y]=1;continue}if(J<=0){if(J<0){B[y]=1;G[y]=1;continue}D-=u}q=v[J].text;if(L=r&&E[y])if(L>0){if(q.length>L)if(B[y]=1,l)q=q.substring(q.length- +L);else continue;(L-=q.length)||(L=-1);E[y]=L}else{B[y]=1;continue}if(D+q.length+1<=k)q+=" ",C[y]=q+C[y];else if(l)U=q.length+1-(k-D),U>=0&&U=x.length-1?Pa=1:J1?Za(k,c,e,g,f):(k=k[0])&&c&&k.length>c||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+ +e)}else{d=[];for(let n=0,u;ne)e-=u.length;else{if(c&&u.length>c||e)u=u.slice(e,c+e),c-=u.length,e&&(e-=u.length);d.push(u);if(!c)break}k=d}}return k} +function Za(a,b,c,e,d){const f=[],g=I();let h;var k=a.length;let l;if(e)for(d=k-1;d>=0;d--){if(l=(e=a[d])&&e.length)for(k=0;k=0;m--){n=a[m];for(let r=0;r1?ab(d,1,0,0,k,l):d[0],E)})}return r?d:new X(d.length>1?ab(d,1,0,0,k,l):d[0],this)}}r||g||!(n=n||this.field)||(M(n)?g=n:(n.constructor===Array&&n.length===1&&(n=n[0]),g=n.field||n.index));n&&n.constructor!==Array&&(n=[n])}n||(n=this.field);let G;v=(this.worker||this.db)&&!e&&[];for(let E=0,z,D,K;E0){if(c&&b>c||e)a=a.slice(e,e+c);d&&(a=Ua.call(this,a))}return a} +function Ua(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);const b=Array(a.length);for(let c=0,e;c1?c:c[0]}w.append=function(a,b){return this.add(a,b,!0)}; +w.update=function(a,b){return this.remove(a).add(a,b)};w.remove=function(a){ba(a)&&(a=ea(a,this.key));for(var b of this.index.values())b.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(let c of this.tag.values())for(let e of c){b=e[0];const d=e[1],f=d.indexOf(a);f>-1&&(d.length>1?d.splice(f,1):c.delete(b))}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; w.clear=function(){const a=[];for(const b of this.index.values()){const c=b.clear();c.then&&a.push(c)}if(this.tag)for(const b of this.tag.values())b.clear();this.store&&this.store.clear();this.cache&&this.cache.clear();return a.length?Promise.all(a):this};w.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.reg.has(a)};w.cleanup=function(){for(const a of this.index.values())a.cleanup();return this}; -w.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};w.set=function(a,b){"object"===typeof a&&(b=a,a=ea(b,this.key));this.store.set(a,b);return this};w.searchCache=ma;w.export=jb;w.import=kb;Fa(Na.prototype);function lb(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function mb(a,b){b||(b=new Map);for(let c=0,e;cp;f--){g=u.substring(p,f);n=this.rtl?d-1-p:p;var h=this.score?this.score(b,u,r,g,n):wb(t, -l,r,d,n);xb(this,q,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,r,h-1,k-1),n=this.bidirectional&&u>f;xb(this,m,n?f:u,p,a,c,n?u:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.S&&ub(this));return this}; -function xb(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=I()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new xa(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function wb(a,b,c,e,d){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function V(a,b){if(!this||this.constructor!==V)return new V(a);if(a){var c=M(a)?a:a.preset;c&&(a=Object.assign({},vb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=M(a.encoder)?va[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new la(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.T=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new R(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.S=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}w=V.prototype; -w.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};w.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};w.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function ub(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} +w.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};w.set=function(a,b){typeof a==="object"&&(b=a,a=ea(b,this.key));this.store.set(a,b);return this};w.searchCache=ma;w.export=kb;w.import=lb;Ga(Qa.prototype);function mb(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function nb(a,b){b||(b=new Map);for(let c=0,e;c2?c[0]:"";c=c.length>2?c[2]:c[1];if(this.worker&&e)return this.index.get(e).import(a);if(b){typeof b==="string"&&(b=JSON.parse(b));if(e)return this.index.get(e).import(c,b);switch(c){case "reg":this.fastupdate=!1;this.reg=rb(b,this.reg);for(let d=0,f;d=0&&d.splice(g,1)}}else ub(this.map,a),this.depth&&ub(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.M&&vb(this));this.cache&&this.cache.remove(a);return this}; +function ub(a,b){let c=0;var e=typeof b==="undefined";if(a.constructor===Array)for(let d=0,f,g,h;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(c)return 1;h=1}else{if(h)return 1;c++}}}else for(let d of a.entries())e=d[0],ub(d[1],b)?c++:a.delete(e);return c};const wb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,b,c,e){if(b&&(a||a===0)){if(!e&&!c&&this.reg.has(a))return this.update(a,b);e=this.depth;b=this.encoder.encode(b,!e);const l=b.length;if(l){const m=I(),n=I(),u=this.resolution;for(let r=0;r2)for(let p=1,q,x,v,A;p2){for(let p=0,q;pp;f--)if(g=t.substring(p,f),!n[g]){q=this.rtl?d-1-p:p;var h=this.score?this.score(b,t,r,g,q):xb(u,l,r,d,q);Y(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(d>1){for(h=d-1;h>0;h--)if(g=t[this.rtl?d-1-h:h]+g,!n[g]){var k=this.score?this.score(b,t,r,g,h):xb(u,l,r,d,h);Y(this,n,g,k,a,c)}g=""}case "forward":if(d>1){for(h=0;h1&&rg?0:1),l,r,h-1,k-1),q=this.bidirectional&&t>f;Y(this,m,q?f:t,p,a,c,q?t:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.M&&vb(this));return this}; +function Y(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=I()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new Aa(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} +function xb(a,b,c,e,d){return c&&a>1?b+(e||0)<=a?c+(d||0):(a-1)/(b+(e||0))*(c+(d||0))+1|0:0};T.prototype.search=function(a,b,c){c||(b||typeof a!=="object"?typeof b==="object"&&(c=b,b=0):(c=a,a=""));if(c&&c.cache)return c.cache=!1,a=this.searchCache(a,b,c),c.cache=!0,a;let e=[],d,f,g,h=0,k,l,m,n,u;c&&(a=c.query||a,b=c.limit||b,h=c.offset||0,f=c.context,g=c.suggest,u=(k=c.resolve)&&c.enrich,m=c.boost,n=c.resolution,l=this.db&&c.tag);typeof k==="undefined"&&(k=this.resolve);f=this.depth&&f!==!1;let r=this.encoder.encode(a,!f);d=r.length;b=b||(k?100:0);if(d===1)return yb.call(this,r[0],"",b, +h,k,u,l);if(d===2&&f&&!g)return yb.call(this,r[1],r[0],b,h,k,u,l);let t=I(),p=0,q;f&&(q=r[0],p=1);n||n===0||(n=q?this.N:this.resolution);if(this.db){if(this.db.search&&(c=this.db.search(this,r,b,h,g,k,u,l),c!==!1))return c;const x=this;return async function(){for(let v,A;p1)k=ab(a,b,c,e,d,f,g);else if(h===1)return g?Ta.call(null,a[0],c,e):new X(a[0],this);return g?k:new X(k,this)} +function yb(a,b,c,e,d,f,g){a=zb(this,a,b,c,e,d,f,g);return this.db?a.then(function(h){return d?h||[]:new X(h,this)}):a&&a.length?d?Ta.call(this,a,c,e):new X(a,this):d?[]:new X([],this)}function Ab(a,b,c,e){let d=[];if(a&&a.length){if(a.length<=e){b.push(a);return}for(let f=0,g;fc)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function T(a,b){if(!this||this.constructor!==T)return new T(a);if(a){var c=M(a)?a:a.preset;c&&(a=Object.assign({},wb[c],a))}else a={};c=a.context;const e=c===!0?{depth:1}:c||{},d=M(a.encoder)?wa[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:typeof d==="object"?new la(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&c!=="default"&&c!=="exact"&&c||"strict";this.depth=c==="strict"&&e.depth||0;this.bidirectional=e.bidirectional!==!1;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new R(c):new Map;this.ctx=c?new R(c):new Map;this.reg=b||(this.fastupdate?c?new R(c):new Map:c?new S(c):new Set);this.N=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new na(c);this.resolve=a.resolve!==!1;if(c=a.db)this.db=this.mount(c);this.M=a.commit!==!1;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}w=T.prototype; +w.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};w.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};w.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function vb(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this};w.append=function(a,b){return this.add(a,b,!0)};w.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};w.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; -w.cleanup=function(){if(!this.fastupdate)return this;tb(this.map);this.depth&&tb(this.ctx);return this};w.searchCache=ma;w.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=pb(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=lb(this.map,this.reg.size);break;case 3:d="ctx";f=nb(this.ctx,this.reg.size);break;default:return}return rb.call(this,a,b,d,f,c,e)}; -w.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length){e-=m.length;continue}const q=c?e+Math.min(m.length-e,c):m.length;for(let t=e;t1?a[1]:a[0],a){case "reg":this.fastupdate=!1;this.reg=rb(b,this.reg);break;case "map":this.map=nb(b,this.map);break;case "ctx":this.ctx=pb(b,this.ctx)}}; +w.serialize=function(a=!0){let b="",c="",e="";if(this.reg.size){let f;for(var d of this.reg.keys())f||(f=typeof d),b+=(b?",":"")+(f==="string"?'"'+d+'"':d);b="index.reg=new Set(["+b+"]);";c=tb(this.map,f);c="index.map=new Map(["+c+"]);";for(const g of this.ctx.entries()){d=g[0];let h=tb(g[1],f);h="new Map(["+h+"])";h='["'+d+'",'+h+"]";e+=(e?",":"")+h}e="index.ctx=new Map(["+e+"]);"}return a?"function inject(index){"+b+c+e+"}":b+c+e};Ga(T.prototype);const Cb=typeof window!=="undefined"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Db=["map","ctx","tag","reg","cfg"],Eb=I(); +function Fb(a,b={}){if(!this||this.constructor!==Fb)return new Fb(a,b);typeof a==="object"&&(b=a,a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.type=b.type;this.fastupdate=this.support_tag_search=!1;this.db=null;this.h={}}w=Fb.prototype;w.mount=function(a){if(a.index)return a.mount(this);a.db=this;return this.open()}; +w.open=function(){if(this.db)return this.db;let a=this;navigator.storage&&navigator.storage.persist();Eb[a.id]||(Eb[a.id]=[]);Eb[a.id].push(a.field);const b=Cb.open(a.id,1);b.onupgradeneeded=function(){const c=a.db=this.result;for(let e=0,d;e=m.length){e-=m.length;continue}const n=c?e+Math.min(m.length-e,c):m.length;for(let u=e;u=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; -w.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};export default {Index:V,Charset:va,Encoder:la,Document:Na,Worker:La,Resolver:Y,IndexedDB:Fb,Language:{}}; -export const Index=V;export const Charset=va;export const Encoder=la;export const Document=Na;export const Worker=La;export const Resolver=Y;export const IndexedDB=Fb;export const Language={}; \ No newline at end of file +for(let m=0,n,u;m=0)if(d=1,h.length>1)h.splice(l,1);else{e[g]=[];break}f+=h.length}if(c)break}f?d&&a.update(e):a.delete();a.continue()} +w.remove=function(a){typeof a!=="object"&&(a=[a]);return Promise.all([this.transaction("map","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&Gb(c,a)}}),this.transaction("ctx","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&Gb(c,a)}}),this.transaction("tag","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&Gb(c,a,!0)}}),this.transaction("reg","readwrite",function(b){for(let c=0;c{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};export default {Index:T,Charset:wa,Encoder:la,Document:Qa,Worker:Ma,Resolver:X,IndexedDB:Fb,Language:{}}; +export const Index=T;export const Charset=wa;export const Encoder=la;export const Document=Qa;export const Worker=Ma;export const Resolver=X;export const IndexedDB=Fb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index bbab09a..0821941 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,18 +1,18 @@ /**! - * FlexSearch.js v0.8.202 (Bundle/Debug) + * FlexSearch.js v0.8.203 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function(self){'use strict'; -var A; +var B; function I(a, c, b) { const e = typeof b, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { + if (e !== "undefined") { + if (d !== "undefined") { if (b) { - if ("function" === d && e === d) { + if (d === "function" && e === d) { return function(h) { return a(b(h)); }; @@ -42,21 +42,21 @@ function I(a, c, b) { } return b; } - return "undefined" === d ? c : a; + return d === "undefined" ? c : a; } function J(a, c) { - return "undefined" === typeof a ? c : a; + return typeof a === "undefined" ? c : a; } function M() { return Object.create(null); } function P(a) { - return "string" === typeof a; + return typeof a === "string"; } function R(a) { - return "object" === typeof a; + return typeof a === "object"; } -function S(a, c) { +function aa(a, c) { if (P(c)) { a = a[c]; } else { @@ -66,10 +66,10 @@ function S(a, c) { } return a; } -;const aa = /[^\p{L}\p{N}]+/u, da = /(\d{3})/g, ea = /(\D)(\d{3})/g, fa = /(\d{3})(\D)/g, ha = /[\u0300-\u036f]/g; -function ka(a = {}) { - if (!this || this.constructor !== ka) { - return new ka(...arguments); +;const ba = /[^\p{L}\p{N}]+/u, ea = /(\d{3})/g, fa = /(\D)(\d{3})/g, ha = /(\d{3})(\D)/g, ka = /[\u0300-\u036f]/g; +function la(a = {}) { + if (!this || this.constructor !== la) { + return new la(...arguments); } if (arguments.length) { for (a = 0; a < arguments.length; a++) { @@ -79,12 +79,12 @@ function ka(a = {}) { this.assign(a); } } -A = ka.prototype; -A.assign = function(a) { +B = la.prototype; +B.assign = function(a) { this.normalize = I(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { + if (b || b === "") { + if (typeof b === "object" && b.constructor !== RegExp) { let d = ""; e = !c; c || (d += "\\p{Z}"); @@ -94,7 +94,7 @@ A.assign = function(a) { b.punctuation && (d += "\\p{P}"); b.control && (d += "\\p{C}"); if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; + d += typeof b === "object" ? b.join("") : b; } try { this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); @@ -102,12 +102,12 @@ A.assign = function(a) { console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = b, e = !1 === b || 2 > "a1a".split(b).length; + this.split = b, e = b === !1 || "a1a".split(b).length < 2; } this.numeric = I(a.numeric, e); } else { try { - this.split = I(this.split, aa); + this.split = I(this.split, ba); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } @@ -116,7 +116,7 @@ A.assign = function(a) { this.prepare = I(a.prepare, null, this.prepare); this.finalize = I(a.finalize, null, this.finalize); b = a.filter; - this.filter = "function" === typeof b ? b : I(b && new Set(b), null, this.filter); + this.filter = typeof b === "function" ? b : I(b && new Set(b), null, this.filter); this.dedupe = I(a.dedupe, !0, this.dedupe); this.matcher = I((b = a.matcher) && new Map(b), null, this.matcher); this.mapper = I((b = a.mapper) && new Map(b), null, this.mapper); @@ -126,12 +126,12 @@ A.assign = function(a) { this.maxlength = I(a.maxlength, 1024, this.maxlength); this.rtl = I(a.rtl, !1, this.rtl); if (this.cache = b = I(a.cache, !0, this.cache)) { - this.H = null, this.O = "number" === typeof b ? b : 2e5, this.F = new Map(), this.G = new Map(), this.L = this.K = 128; + this.D = null, this.K = typeof b === "number" ? b : 2e5, this.B = new Map(), this.C = new Map(), this.H = this.G = 128; } this.h = ""; - this.M = null; - this.C = ""; - this.N = null; + this.I = null; + this.A = ""; + this.J = null; if (this.matcher) { for (const d of this.matcher.keys()) { this.h += (this.h ? "|" : "") + d; @@ -139,76 +139,76 @@ A.assign = function(a) { } if (this.stemmer) { for (const d of this.stemmer.keys()) { - this.C += (this.C ? "|" : "") + d; + this.A += (this.A ? "|" : "") + d; } } return this; }; -A.addStemmer = function(a, c) { +B.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); - this.C += (this.C ? "|" : "") + a; - this.N = null; - this.cache && T(this); + this.A += (this.A ? "|" : "") + a; + this.J = null; + this.cache && S(this); return this; }; -A.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); - this.cache && T(this); +B.addFilter = function(a) { + typeof a === "function" ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); + this.cache && S(this); return this; }; -A.addMapper = function(a, c) { - if ("object" === typeof a) { +B.addMapper = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (1 < a.length) { + if (a.length > 1) { return this.addMatcher(a, c); } this.mapper || (this.mapper = new Map()); this.mapper.set(a, c); - this.cache && T(this); + this.cache && S(this); return this; }; -A.addMatcher = function(a, c) { - if ("object" === typeof a) { +B.addMatcher = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (2 > a.length && (this.dedupe || this.mapper)) { + if (a.length < 2 && (this.dedupe || this.mapper)) { return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); this.matcher.set(a, c); this.h += (this.h ? "|" : "") + a; - this.M = null; - this.cache && T(this); + this.I = null; + this.cache && S(this); return this; }; -A.addReplacer = function(a, c) { - if ("string" === typeof a) { +B.addReplacer = function(a, c) { + if (typeof a === "string") { return this.addMatcher(a, c); } this.replacer || (this.replacer = []); this.replacer.push(a, c); - this.cache && T(this); + this.cache && S(this); return this; }; -A.encode = function(a, c) { - if (this.cache && a.length <= this.K) { - if (this.H) { - if (this.F.has(a)) { - return this.F.get(a); +B.encode = function(a, c) { + if (this.cache && a.length <= this.G) { + if (this.D) { + if (this.B.has(a)) { + return this.B.get(a); } } else { - this.H = setTimeout(T, 50, this); + this.D = setTimeout(S, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ha ? a.normalize("NFKD").replace(ha, "").toLowerCase() : a.toLowerCase()); + this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(ea, "$1 $2").replace(fa, "$1 $2").replace(da, "$1 ")); + this.numeric && a.length > 3 && (a = a.replace(fa, "$1 $2").replace(ha, "$1 $2").replace(ea, "$1 ")); const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let e = [], d = M(), f, g, h = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let n = 0, l, D; n < h.length; n++) { - if ((l = D = h[n]) && !(l.length < this.minlength || l.length > this.maxlength)) { + let e = [], d = M(), f, g, h = this.split || this.split === "" ? a.split(this.split) : [a]; + for (let n = 0, l, z; n < h.length; n++) { + if ((l = z = h[n]) && !(l.length < this.minlength || l.length > this.maxlength)) { if (c) { if (d[l]) { continue; @@ -223,41 +223,41 @@ A.encode = function(a, c) { if (b) { e.push(l); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(l) : !this.filter.has(l))) { - if (this.cache && l.length <= this.L) { - if (this.H) { - var k = this.G.get(l); - if (k || "" === k) { + if (!this.filter || (typeof this.filter === "function" ? this.filter(l) : !this.filter.has(l))) { + if (this.cache && l.length <= this.H) { + if (this.D) { + var k = this.C.get(l); + if (k || k === "") { k && e.push(k); continue; } } else { - this.H = setTimeout(T, 50, this); + this.D = setTimeout(S, 50, this); } } if (this.stemmer) { - this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")); - let w; - for (; w !== l && 2 < l.length;) { - w = l, l = l.replace(this.N, t => this.stemmer.get(t)); + this.J || (this.J = new RegExp("(?!^)(" + this.A + ")$")); + let x; + for (; x !== l && l.length > 2;) { + x = l, l = l.replace(this.J, u => this.stemmer.get(u)); } } - if (l && (this.mapper || this.dedupe && 1 < l.length)) { + if (l && (this.mapper || this.dedupe && l.length > 1)) { k = ""; - for (let w = 0, t = "", p, x; w < l.length; w++) { - p = l.charAt(w), p === t && this.dedupe || ((x = this.mapper && this.mapper.get(p)) || "" === x ? x === t && this.dedupe || !(t = x) || (k += x) : k += t = p); + for (let x = 0, u = "", p, w; x < l.length; x++) { + p = l.charAt(x), p === u && this.dedupe || ((w = this.mapper && this.mapper.get(p)) || w === "" ? w === u && this.dedupe || !(u = w) || (k += w) : k += u = p); } l = k; } - this.matcher && 1 < l.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), l = l.replace(this.M, w => this.matcher.get(w))); + this.matcher && l.length > 1 && (this.I || (this.I = new RegExp("(" + this.h + ")", "g")), l = l.replace(this.I, x => this.matcher.get(x))); if (l && this.replacer) { for (k = 0; l && k < this.replacer.length; k += 2) { l = l.replace(this.replacer[k], this.replacer[k + 1]); } } - this.cache && D.length <= this.L && (this.G.set(D, l), this.G.size > this.O && (this.G.clear(), this.L = this.L / 1.1 | 0)); + this.cache && z.length <= this.H && (this.C.set(z, l), this.C.size > this.K && (this.C.clear(), this.H = this.H / 1.1 | 0)); if (l) { - if (l !== D) { + if (l !== z) { if (c) { if (d[l]) { continue; @@ -277,21 +277,21 @@ A.encode = function(a, c) { } } this.finalize && (e = this.finalize(e) || e); - this.cache && a.length <= this.K && (this.F.set(a, e), this.F.size > this.O && (this.F.clear(), this.K = this.K / 1.1 | 0)); + this.cache && a.length <= this.G && (this.B.set(a, e), this.B.size > this.K && (this.B.clear(), this.G = this.G / 1.1 | 0)); return e; }; -function T(a) { - a.H = null; - a.F.clear(); - a.G.clear(); +function S(a) { + a.D = null; + a.B.clear(); + a.C.clear(); } -;function la(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : b = a); +;function ma(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : b = a); b && (a = b.query || a, c = b.limit || c); let e = "" + (c || 0); - b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (!1 !== b.resolve) + (b.resolution || this.resolution) + (b.boost || 0)); + b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (b.resolve !== !1) + (b.resolution || this.resolution) + (b.boost || 0)); a = ("" + a).toLowerCase(); - this.cache || (this.cache = new W()); + this.cache || (this.cache = new T()); let d = this.cache.get(a + e); if (!d) { const f = b && b.cache; @@ -302,64 +302,64 @@ function T(a) { } return d; } -function W(a) { - this.limit = a && !0 !== a ? a : 1000; +function T(a) { + this.limit = a && a !== !0 ? a : 1000; this.cache = new Map(); this.h = ""; } -W.prototype.set = function(a, c) { +T.prototype.set = function(a, c) { this.cache.set(this.h = a, c); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -W.prototype.get = function(a) { +T.prototype.get = function(a) { const c = this.cache.get(a); c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c)); return c; }; -W.prototype.remove = function(a) { +T.prototype.remove = function(a) { for (const c of this.cache) { const b = c[0]; c[1].includes(a) && this.cache.delete(b); } }; -W.prototype.clear = function() { +T.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const ma = {normalize:!1, numeric:!1, dedupe:!1}; -const na = {}; -const oa = 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"]]); -const pa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const ra = {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 sa = {Exact:ma, Default:na, Normalize:na, LatinBalance:{mapper:oa}, LatinAdvanced:{mapper:oa, matcher:pa, replacer:qa}, LatinExtra:{mapper:oa, replacer:qa.concat([/(?!^)[aeo]/g, ""]), matcher:pa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { +const na = {normalize:!1, numeric:!1, dedupe:!1}; +const oa = {}; +const pa = 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"]]); +const qa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), ra = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const sa = {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 va = {Exact:na, Default:oa, Normalize:oa, LatinBalance:{mapper:pa}, LatinAdvanced:{mapper:pa, matcher:qa, replacer:ra}, LatinExtra:{mapper:pa, replacer:ra.concat([/(?!^)[aeo]/g, ""]), matcher:qa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = ra[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ra[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = sa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), g === "h" || g === "w" || !(g = sa[g]) || g === d || (e += g, d = g, e.length !== 4)); f++) { } a[b] = e; } -}}, CJK:{split:""}, LatinExact:ma, LatinDefault:na, LatinSimple:na}; -function va(a) { - X.call(a, "add"); - X.call(a, "append"); - X.call(a, "search"); - X.call(a, "update"); - X.call(a, "remove"); - X.call(a, "searchCache"); +}}, CJK:{split:""}, LatinExact:na, LatinDefault:oa, LatinSimple:oa}; +function wa(a) { + U.call(a, "add"); + U.call(a, "append"); + U.call(a, "search"); + U.call(a, "update"); + U.call(a, "remove"); + U.call(a, "searchCache"); } -let wa, xa, ya; -function za() { - wa = ya = 0; +let xa, ya, za; +function Aa() { + xa = za = 0; } -function X(a) { +function U(a) { this[a + "Async"] = function() { const c = arguments; var b = c[c.length - 1]; let e; - "function" === typeof b && (e = b, delete c[c.length - 1]); - wa ? ya || (ya = Date.now() - xa >= this.priority * this.priority * 3) : (wa = setTimeout(za, 0), xa = Date.now()); - if (ya) { + typeof b === "function" && (e = b, delete c[c.length - 1]); + xa ? za || (za = Date.now() - ya >= this.priority * this.priority * 3) : (xa = setTimeout(Aa, 0), ya = Date.now()); + if (za) { const f = this; return new Promise(g => { setTimeout(function() { @@ -373,40 +373,40 @@ function X(a) { return b; }; } -;Y.prototype.add = function(a, c, b) { - R(a) && (c = a, a = S(c, this.key)); - if (c && (a || 0 === a)) { +;X.prototype.add = function(a, c, b) { + R(a) && (c = a, a = aa(c, this.key)); + if (c && (a || a === 0)) { if (!b && this.reg.has(a)) { return this.update(a, c); } for (let h = 0, k; h < this.field.length; h++) { - k = this.D[h]; + k = this.B[h]; var e = this.index.get(this.field[h]); - if ("function" === typeof k) { + if (typeof k === "function") { var d = k(c); d && e.add(a, d, !1, !0); } else { - if (d = k.I, !d || d(c)) { - k.constructor === String ? k = ["" + k] : P(k) && (k = [k]), Aa(c, k, this.J, 0, e, a, k[0], b); + if (d = k.F, !d || d(c)) { + k.constructor === String ? k = ["" + k] : P(k) && (k = [k]), Ba(c, k, this.C, 0, e, a, k[0], b); } } } if (this.tag) { - for (e = 0; e < this.B.length; e++) { - var f = this.B[e], g = this.R[e]; + for (e = 0; e < this.A.length; e++) { + var f = this.A[e], g = this.D[e]; d = this.tag.get(g); let h = M(); - if ("function" === typeof f) { + if (typeof f === "function") { if (f = f(c), !f) { continue; } } else { - const k = f.I; + const k = f.F; if (k && !k(c)) { continue; } f.constructor === String && (f = "" + f); - f = S(c, f); + f = aa(c, f); } if (d && f) { P(f) && (f = [f]); @@ -420,25 +420,25 @@ function X(a) { } if (this.store && (!b || !this.store.has(a))) { let h; - if (this.A) { + if (this.h) { h = M(); - for (let k = 0, n; k < this.A.length; k++) { - n = this.A[k]; - if ((b = n.I) && !b(c)) { + for (let k = 0, n; k < this.h.length; k++) { + n = this.h[k]; + if ((b = n.F) && !b(c)) { continue; } let l; - if ("function" === typeof n) { + if (typeof n === "function") { l = n(c); if (!l) { continue; } - n = [n.S]; + n = [n.M]; } else if (P(n) || n.constructor === String) { h[n] = c[n]; continue; } - Ba(c, h, n, 0, n[0], l); + Ca(c, h, n, 0, n[0], l); } } this.store.set(a, h || c); @@ -446,21 +446,21 @@ function X(a) { } return this; }; -function Ba(a, c, b, e, d, f) { +function Ca(a, c, b, e, d, f) { a = a[d]; if (e === b.length - 1) { c[d] = f || a; } else if (a) { if (a.constructor === Array) { for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - Ba(a, c, b, e, d); + Ca(a, c, b, e, d); } } else { - c = c[d] || (c[d] = M()), d = b[++e], Ba(a, c, b, e, d); + c = c[d] || (c[d] = M()), d = b[++e], Ca(a, c, b, e, d); } } } -function Aa(a, c, b, e, d, f, g, h) { +function Ba(a, c, b, e, d, f, g, h) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -476,19 +476,19 @@ function Aa(a, c, b, e, d, f, g, h) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Aa(a, c, b, e, d, f, g, h); + Ba(a, c, b, e, d, f, g, h); } } else { - g = c[++e], Aa(a, c, b, e, d, f, g, h); + g = c[++e], Ba(a, c, b, e, d, f, g, h); } } } } -;function Ca(a, c, b) { +;function Da(a, c, b) { if (!a.length) { return a; } - if (1 === a.length) { + if (a.length === 1) { return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a; } let e = []; @@ -514,56 +514,56 @@ function Aa(a, c, b, e, d, f, g, h) { } } } - return e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return e = e.length > 1 ? [].concat.apply([], e) : e[0]; } -;function Da(a, c, b, e, d) { +;function Ea(a, c, b, e, d) { let f, g, h; - "string" === typeof d ? (f = d, d = "") : f = d.template; + typeof d === "string" ? (f = d, d = "") : f = d.template; if (!f) { throw Error('No template pattern was specified by the search option "highlight"'); } g = f.indexOf("$1"); - if (-1 === g) { + if (g === -1) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } h = f.substring(g + 2); g = f.substring(0, g); - let k = d && d.boundary, n = !d || !1 !== d.clip, l = d && d.merge && h && g && new RegExp(h + " " + g, "g"); + let k = d && d.boundary, n = !d || d.clip !== !1, l = d && d.merge && h && g && new RegExp(h + " " + g, "g"); d = d && d.ellipsis; - var D = 0; - if ("object" === typeof d) { - var w = d.template; - D = w.length - 2; + var z = 0; + if (typeof d === "object") { + var x = d.template; + z = x.length - 2; d = d.pattern; } - "string" !== typeof d && (d = !1 === d ? "" : "..."); - D && (d = w.replace("$1", d)); - w = d.length - D; - let t, p; - "object" === typeof k && (t = k.before, 0 === t && (t = -1), p = k.after, 0 === p && (p = -1), k = k.total || 9e5); - D = new Map(); - for (let ta = 0, U, Ka, ba; ta < c.length; ta++) { - let ca; + typeof d !== "string" && (d = d === !1 ? "" : "..."); + z && (d = x.replace("$1", d)); + x = d.length - z; + let u, p; + typeof k === "object" && (u = k.before, u === 0 && (u = -1), p = k.after, p === 0 && (p = -1), k = k.total || 9e5); + z = new Map(); + for (let ta = 0, V, Ka, ca; ta < c.length; ta++) { + let da; if (e) { - ca = c, ba = e; + da = c, ca = e; } else { - var x = c[ta]; - ba = x.field; - if (!ba) { + var w = c[ta]; + ca = w.field; + if (!ca) { continue; } - ca = x.result; + da = w.result; } - Ka = b.get(ba); - U = Ka.encoder; - x = D.get(U); - "string" !== typeof x && (x = U.encode(a), D.set(U, x)); - for (let ia = 0; ia < ca.length; ia++) { - var m = ca[ia].doc; + Ka = b.get(ca); + V = Ka.encoder; + w = z.get(V); + typeof w !== "string" && (w = V.encode(a), z.set(V, w)); + for (let ia = 0; ia < da.length; ia++) { + var m = da[ia].doc; if (!m) { continue; } - m = S(m, ba); + m = aa(m, ca); if (!m) { continue; } @@ -572,44 +572,44 @@ function Aa(a, c, b, e, d, f, g, h) { continue; } m = ""; - var u = []; + var t = []; let ja = []; - var F = -1, z = -1, r = 0; + var C = -1, A = -1, r = 0; for (var y = 0; y < v.length; y++) { - var E = v[y], B = U.encode(E); - B = 1 < B.length ? B.join(" ") : B[0]; + var F = v[y], D = V.encode(F); + D = D.length > 1 ? D.join(" ") : D[0]; let q; - if (B && E) { - var C = E.length, K = (U.split ? E.replace(U.split, "") : E).length - B.length, L = "", Q = 0; - for (var V = 0; V < x.length; V++) { - var N = x[V]; + if (D && F) { + var E = F.length, K = (V.split ? F.replace(V.split, "") : F).length - D.length, L = "", Q = 0; + for (var W = 0; W < w.length; W++) { + var N = w[W]; if (N) { var H = N.length; H += K; - Q && H <= Q || (N = B.indexOf(N), -1 < N && (L = (N ? E.substring(0, N) : "") + g + E.substring(N, N + H) + h + (N + H < C ? E.substring(N + H) : ""), Q = H, q = !0)); + Q && H <= Q || (N = D.indexOf(N), N > -1 && (L = (N ? F.substring(0, N) : "") + g + F.substring(N, N + H) + h + (N + H < E ? F.substring(N + H) : ""), Q = H, q = !0)); } } - L && (k && (0 > F && (F = m.length + (m ? 1 : 0)), z = m.length + (m ? 1 : 0) + L.length, r += C, ja.push(u.length), u.push({match:L})), m += (m ? " " : "") + L); + L && (k && (C < 0 && (C = m.length + (m ? 1 : 0)), A = m.length + (m ? 1 : 0) + L.length, r += E, ja.push(t.length), t.push({match:L})), m += (m ? " " : "") + L); } if (!q) { - E = v[y], m += (m ? " " : "") + E, k && u.push({text:E}); + F = v[y], m += (m ? " " : "") + F, k && t.push({text:F}); } else if (k && r >= k) { break; } } r = ja.length * (f.length - 2); - if (t || p || k && m.length - r > k) { - if (r = k + r - 2 * w, y = z - F, 0 < t && (y += t), 0 < p && (y += p), y <= r) { - v = t ? F - (0 < t ? t : 0) : F - ((r - y) / 2 | 0), u = p ? z + (0 < p ? p : 0) : v + r, n || (0 < v && " " !== m.charAt(v) && " " !== m.charAt(v - 1) && (v = m.indexOf(" ", v), 0 > v && (v = 0)), u < m.length && " " !== m.charAt(u - 1) && " " !== m.charAt(u) && (u = m.lastIndexOf(" ", u), u < z ? u = z : ++u)), m = (v ? d : "") + m.substring(v, u) + (u < m.length ? d : ""); + if (u || p || k && m.length - r > k) { + if (r = k + r - x * 2, y = A - C, u > 0 && (y += u), p > 0 && (y += p), y <= r) { + v = u ? C - (u > 0 ? u : 0) : C - ((r - y) / 2 | 0), t = p ? A + (p > 0 ? p : 0) : v + r, n || (v > 0 && m.charAt(v) !== " " && m.charAt(v - 1) !== " " && (v = m.indexOf(" ", v), v < 0 && (v = 0)), t < m.length && m.charAt(t - 1) !== " " && m.charAt(t) !== " " && (t = m.lastIndexOf(" ", t), t < A ? t = A : ++t)), m = (v ? d : "") + m.substring(v, t) + (t < m.length ? d : ""); } else { - z = []; - F = {}; + A = []; + C = {}; r = {}; y = {}; - E = {}; - B = {}; - L = K = C = 0; - for (V = Q = 1;;) { + F = {}; + D = {}; + L = K = E = 0; + for (W = Q = 1;;) { var O = void 0; for (let q = 0, G; q < ja.length; q++) { G = ja[q]; @@ -619,23 +619,23 @@ function Aa(a, c, b, e, d, f, g, h) { continue; } G += L; - if (F[G]) { - C -= w; + if (C[G]) { + E -= x; r[q + 1] = 1; y[q + 1] = 1; continue; } - if (G >= u.length - 1) { - if (G >= u.length) { + if (G >= t.length - 1) { + if (G >= t.length) { y[q + 1] = 1; G >= v.length && (r[q + 1] = 1); continue; } - C -= w; + E -= x; } - m = u[G].text; - if (H = p && B[q]) { - if (0 < H) { + m = t[G].text; + if (H = p && D[q]) { + if (H > 0) { if (m.length > H) { if (y[q + 1] = 1, n) { m = m.substring(0, H); @@ -644,16 +644,16 @@ function Aa(a, c, b, e, d, f, g, h) { } } (H -= m.length) || (H = -1); - B[q] = H; + D[q] = H; } else { y[q + 1] = 1; continue; } } - if (C + m.length + 1 <= k) { - m = " " + m, z[q] += m; + if (E + m.length + 1 <= k) { + m = " " + m, A[q] += m; } else if (n) { - O = k - C - 1, 0 < O && (m = " " + m.substring(0, O), z[q] += m), y[q + 1] = 1; + O = k - E - 1, O > 0 && (m = " " + m.substring(0, O), A[q] += m), y[q + 1] = 1; } else { y[q + 1] = 1; continue; @@ -663,23 +663,23 @@ function Aa(a, c, b, e, d, f, g, h) { continue; } G -= K; - if (F[G]) { - C -= w; + if (C[G]) { + E -= x; y[q] = 1; r[q] = 1; continue; } - if (0 >= G) { - if (0 > G) { + if (G <= 0) { + if (G < 0) { y[q] = 1; r[q] = 1; continue; } - C -= w; + E -= x; } - m = u[G].text; - if (H = t && E[q]) { - if (0 < H) { + m = t[G].text; + if (H = u && F[q]) { + if (H > 0) { if (m.length > H) { if (y[q] = 1, n) { m = m.substring(m.length - H); @@ -688,60 +688,60 @@ function Aa(a, c, b, e, d, f, g, h) { } } (H -= m.length) || (H = -1); - E[q] = H; + F[q] = H; } else { y[q] = 1; continue; } } - if (C + m.length + 1 <= k) { - m += " ", z[q] = m + z[q]; + if (E + m.length + 1 <= k) { + m += " ", A[q] = m + A[q]; } else if (n) { - O = m.length + 1 - (k - C), 0 <= O && O < m.length && (m = m.substring(O) + " ", z[q] = m + z[q]), y[q] = 1; + O = m.length + 1 - (k - E), O >= 0 && O < m.length && (m = m.substring(O) + " ", A[q] = m + A[q]), y[q] = 1; } else { y[q] = 1; continue; } } } else { - m = u[G].match; - t && (E[q] = t); - p && (B[q] = p); - q && C++; + m = t[G].match; + u && (F[q] = u); + p && (D[q] = p); + q && E++; let ua; - G ? !q && w && (C += w) : (r[q] = 1, y[q] = 1); - G >= v.length - 1 ? ua = 1 : G < u.length - 1 && u[G + 1].match ? ua = 1 : w && (C += w); - C -= f.length - 2; - if (!q || C + m.length <= k) { - z[q] = m; + G ? !q && x && (E += x) : (r[q] = 1, y[q] = 1); + G >= v.length - 1 ? ua = 1 : G < t.length - 1 && t[G + 1].match ? ua = 1 : x && (E += x); + E -= f.length - 2; + if (!q || E + m.length <= k) { + A[q] = m; } else { - O = Q = V = r[q] = 0; + O = Q = W = r[q] = 0; break; } ua && (r[q + 1] = 1, y[q + 1] = 1); } - C += m.length; - O = F[G] = 1; + E += m.length; + O = C[G] = 1; } if (O) { K === L ? L++ : K++; } else { - K === L ? Q = 0 : V = 0; - if (!Q && !V) { + K === L ? Q = 0 : W = 0; + if (!Q && !W) { break; } Q ? (K++, L = K) : L++; } } m = ""; - for (let q = 0, G; q < z.length; q++) { - G = (q && r[q] ? " " : (q && !d ? " " : "") + d) + z[q], m += G; + for (let q = 0, G; q < A.length; q++) { + G = (q && r[q] ? " " : (q && !d ? " " : "") + d) + A[q], m += G; } - d && !r[z.length] && (m += d); + d && !r[A.length] && (m += d); } } l && (m = m.replace(l, " ")); - ca[ia].highlight = m; + da[ia].highlight = m; } if (e) { break; @@ -749,7 +749,7 @@ function Aa(a, c, b, e, d, f, g, h) { } return c; } -;function Ea(a, c) { +;function Fa(a, c) { const b = M(), e = []; for (let d = 0, f; d < c.length; d++) { f = c[d]; @@ -763,55 +763,55 @@ function Aa(a, c, b, e, d, f, g, h) { return e; } ;M(); -Y.prototype.search = function(a, c, b, e) { +X.prototype.search = function(a, c, b, e) { b || (!c && R(a) ? (b = a, a = "") : R(c) && (b = c, c = 0)); let d = []; var f = []; let g; let h, k, n, l; - let D = 0, w = !0, t; + let z = 0, x = !0, u; if (b) { b.constructor === Array && (b = {index:b}); a = b.query || a; var p = b.pluck; - var x = b.merge; + var w = b.merge; n = p || b.field || (n = b.index) && (n.index ? null : n); l = this.tag && b.tag; h = b.suggest; - w = !0; + x = !0; k = b.cache; - this.store && b.highlight && !w ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !w && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - t = w && this.store && b.highlight; - g = !!t || w && this.store && b.enrich; + this.store && b.highlight && !x ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !x && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + u = x && this.store && b.highlight; + g = !!u || x && this.store && b.enrich; c = b.limit || c; var m = b.offset || 0; - c || (c = w ? 100 : 0); + c || (c = x ? 100 : 0); if (l) { l.constructor !== Array && (l = [l]); var v = []; - for (let z = 0, r; z < l.length; z++) { - r = l[z]; + for (let A = 0, r; A < l.length; A++) { + r = l[A]; if (P(r)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } if (r.field && r.tag) { - var u = r.tag; - if (u.constructor === Array) { - for (var F = 0; F < u.length; F++) { - v.push(r.field, u[F]); + var t = r.tag; + if (t.constructor === Array) { + for (var C = 0; C < t.length; C++) { + v.push(r.field, t[C]); } } else { - v.push(r.field, u); + v.push(r.field, t); } } else { - u = Object.keys(r); - for (let y = 0, E, B; y < u.length; y++) { - if (E = u[y], B = r[E], B.constructor === Array) { - for (F = 0; F < B.length; F++) { - v.push(E, B[F]); + t = Object.keys(r); + for (let y = 0, F, D; y < t.length; y++) { + if (F = t[y], D = r[F], D.constructor === Array) { + for (C = 0; C < D.length; C++) { + v.push(F, D[C]); } } else { - v.push(E, B); + v.push(F, D); } } } @@ -824,12 +824,12 @@ Y.prototype.search = function(a, c, b, e) { f = []; if (v.length) { for (p = 0; p < v.length; p += 2) { - x = Fa.call(this, v[p], v[p + 1], c, m, g), d.push({field:v[p], tag:v[p + 1], result:x}); + w = Ga.call(this, v[p], v[p + 1], c, m, g), d.push({field:v[p], tag:v[p + 1], result:w}); } } - return f.length ? Promise.all(f).then(function(z) { - for (let r = 0; r < z.length; r++) { - d[r].result = z[r]; + return f.length ? Promise.all(f).then(function(A) { + for (let r = 0; r < A.length; r++) { + d[r].result = A[r]; } return d; }) : d; @@ -839,67 +839,67 @@ Y.prototype.search = function(a, c, b, e) { } n || (n = this.field); v = !1; - for (let z = 0, r, y, E; z < n.length; z++) { - y = n[z]; - let B; - P(y) || (B = y, y = B.field, a = B.query || a, c = J(B.limit, c), m = J(B.offset, m), h = J(B.suggest, h), t = w && this.store && J(B.highlight, t), g = !!t || w && this.store && J(B.enrich, g), k = J(B.cache, k)); + for (let A = 0, r, y, F; A < n.length; A++) { + y = n[A]; + let D; + P(y) || (D = y, y = D.field, a = D.query || a, c = J(D.limit, c), m = J(D.offset, m), h = J(D.suggest, h), u = x && this.store && J(D.highlight, u), g = !!u || x && this.store && J(D.enrich, g), k = J(D.cache, k)); if (e) { - r = e[z]; + r = e[A]; } else { - u = B || b || {}; - F = u.enrich; - const C = this.index.get(y); - l && F && (u.enrich = !1); - r = k ? C.searchCache(a, c, u) : C.search(a, c, u); - F && (u.enrich = F); + t = D || b || {}; + C = t.enrich; + const E = this.index.get(y); + l && C && (t.enrich = !1); + r = k ? E.searchCache(a, c, t) : E.search(a, c, t); + C && (t.enrich = C); if (v) { - v[z] = r; + v[A] = r; continue; } } - E = (r = r.result || r) && r.length; - if (l && E) { - u = []; - F = 0; - for (let C = 0, K, L; C < l.length; C += 2) { - K = this.tag.get(l[C]); + F = (r = r.result || r) && r.length; + if (l && F) { + t = []; + C = 0; + for (let E = 0, K, L; E < l.length; E += 2) { + K = this.tag.get(l[E]); if (!K) { - if (console.warn("Tag '" + l[C] + ":" + l[C + 1] + "' will be skipped because there is no field '" + l[C] + "'."), h) { + if (console.warn("Tag '" + l[E] + ":" + l[E + 1] + "' will be skipped because there is no field '" + l[E] + "'."), h) { continue; } else { return d; } } - if (L = (K = K && K.get(l[C + 1])) && K.length) { - F++, u.push(K); + if (L = (K = K && K.get(l[E + 1])) && K.length) { + C++, t.push(K); } else if (!h) { return d; } } - if (F) { - r = Ea(r, u); - E = r.length; - if (!E && !h) { + if (C) { + r = Fa(r, t); + F = r.length; + if (!F && !h) { return r; } - F--; + C--; } } - if (E) { - f[D] = y, d.push(r), D++; - } else if (1 === n.length) { + if (F) { + f[z] = y, d.push(r), z++; + } else if (n.length === 1) { return d; } } if (v) { - const z = this; + const A = this; return Promise.all(v).then(function(r) { - b && (b.resolve = w); - r.length && (r = z.search(a, c, b, r)); + b && (b.resolve = x); + r.length && (r = A.search(a, c, b, r)); return r; }); } - if (!D) { + if (!z) { return d; } if (p && (!g || !this.store)) { @@ -908,30 +908,30 @@ Y.prototype.search = function(a, c, b, e) { v = []; for (m = 0; m < f.length; m++) { e = d[m]; - g && e.length && "undefined" === typeof e[0].doc && (e = Ga.call(this, e)); + g && e.length && typeof e[0].doc === "undefined" && (e = Ha.call(this, e)); if (p) { - return t ? Da(a, e, this.index, p, t) : e; + return u ? Ea(a, e, this.index, p, u) : e; } d[m] = {field:f[m], result:e}; } - t && (d = Da(a, d, this.index, p, t)); - return x ? Ha(d) : d; + u && (d = Ea(a, d, this.index, p, u)); + return w ? Ia(d) : d; }; -function Ha(a) { +function Ia(a) { const c = [], b = M(), e = M(); - for (let d = 0, f, g, h, k, n, l, D; d < a.length; d++) { + for (let d = 0, f, g, h, k, n, l, z; d < a.length; d++) { f = a[d]; g = f.field; h = f.result; - for (let w = 0; w < h.length; w++) { - if (n = h[w], "object" !== typeof n ? n = {id:k = n} : k = n.id, (l = b[k]) ? l.push(g) : (n.field = b[k] = [g], c.push(n)), D = n.highlight) { - l = e[k], l || (e[k] = l = {}, n.highlight = l), l[g] = D; + for (let x = 0; x < h.length; x++) { + if (n = h[x], typeof n !== "object" ? n = {id:k = n} : k = n.id, (l = b[k]) ? l.push(g) : (n.field = b[k] = [g], c.push(n)), z = n.highlight) { + l = e[k], l || (e[k] = l = {}, n.highlight = l), l[g] = z; } } } return c; } -function Fa(a, c, b, e, d) { +function Ga(a, c, b, e, d) { a = this.tag.get(a); if (!a) { return []; @@ -941,15 +941,15 @@ function Fa(a, c, b, e, d) { return []; } c = a.length - e; - if (0 < c) { + if (c > 0) { if (b && c > b || e) { a = a.slice(e, e + b); } - d && (a = Ga.call(this, a)); + d && (a = Ha.call(this, a)); } return a; } -function Ga(a) { +function Ha(a) { if (!this || !this.store) { return a; } @@ -959,73 +959,73 @@ function Ga(a) { } return c; } -;function Y(a) { - if (!this || this.constructor !== Y) { - return new Y(a); +;function X(a) { + if (!this || this.constructor !== X) { + return new X(a); } const c = a.document || a.doc || a; var b; - this.D = []; + this.B = []; this.field = []; - this.J = []; - this.key = (b = c.key || c.id) && Ia(b, this.J) || "id"; + this.C = []; + this.key = (b = c.key || c.id) && Ja(b, this.C) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); - this.A = (b = c.store || null) && b && !0 !== b && []; - this.store = b && new Map(); - this.cache = (b = a.cache || null) && new W(b); + this.h = (b = c.store || null) && b && b !== !0 && []; + this.store = b ? new Map() : null; + this.cache = (b = a.cache || null) && new T(b); a.cache = !1; this.priority = a.priority || 4; b = new Map(); let e = c.index || c.field || c; P(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], P(f) || (g = f, f = f.field), g = R(g) ? Object.assign({}, a, g) : a, b.set(f, new Z(g, this.reg)), g.custom ? this.D[d] = g.custom : (this.D[d] = Ia(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)), this.field[d] = f; + f = e[d], P(f) || (g = f, f = f.field), g = R(g) ? Object.assign({}, a, g) : a, b.set(f, new Y(g, this.reg)), g.custom ? this.B[d] = g.custom : (this.B[d] = Ja(f, this.C), g.filter && (typeof this.B[d] === "string" && (this.B[d] = new String(this.B[d])), this.B[d].F = g.filter)), this.field[d] = f; } - if (this.A) { + if (this.h) { a = c.store; P(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.S = g) : (this.A[d] = Ia(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.h[d] = f.custom, f.custom.M = g) : (this.h[d] = Ja(g, this.C), f.filter && (typeof this.h[d] === "string" && (this.h[d] = new String(this.h[d])), this.h[d].F = f.filter)); } } this.index = b; this.tag = null; if (b = c.tag) { - if ("string" === typeof b && (b = [b]), b.length) { + if (typeof b === "string" && (b = [b]), b.length) { this.tag = new Map(); - this.B = []; - this.R = []; + this.A = []; + this.D = []; for (let d = 0, f, g; d < b.length; d++) { f = b[d]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = Ia(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); - this.R[d] = g; + f.custom ? this.A[d] = f.custom : (this.A[d] = Ja(g, this.C), f.filter && (typeof this.A[d] === "string" && (this.A[d] = new String(this.A[d])), this.A[d].F = f.filter)); + this.D[d] = g; this.tag.set(g, new Map()); } } } } -function Ia(a, c) { +function Ja(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { - a = b[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); + a = b[d], a[a.length - 1] === "]" && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); } e < b.length && (b.length = e); - return 1 < e ? b : b[0]; + return e > 1 ? b : b[0]; } -A = Y.prototype; -A.append = function(a, c) { +B = X.prototype; +B.append = function(a, c) { return this.add(a, c, !0); }; -A.update = function(a, c) { +B.update = function(a, c) { return this.remove(a).add(a, c); }; -A.remove = function(a) { - R(a) && (a = S(a, this.key)); +B.remove = function(a) { + R(a) && (a = aa(a, this.key)); for (var c of this.index.values()) { c.remove(a, !0); } @@ -1035,7 +1035,7 @@ A.remove = function(a) { for (let e of b) { c = e[0]; const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : b.delete(c)); + f > -1 && (d.length > 1 ? d.splice(f, 1) : b.delete(c)); } } } @@ -1045,7 +1045,7 @@ A.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -A.clear = function() { +B.clear = function() { const a = []; for (const c of this.index.values()) { const b = c.clear(); @@ -1060,28 +1060,28 @@ A.clear = function() { this.cache && this.cache.clear(); return a.length ? Promise.all(a) : this; }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.cleanup = function() { +B.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -A.get = function(a) { +B.get = function(a) { return this.store.get(a) || null; }; -A.set = function(a, c) { - "object" === typeof a && (c = a, a = S(c, this.key)); +B.set = function(a, c) { + typeof a === "object" && (c = a, a = aa(c, this.key)); this.store.set(a, c); return this; }; -A.searchCache = la; -A.export = Ja; -A.import = La; -va(Y.prototype); -function Ma(a, c = 0) { +B.searchCache = ma; +B.export = La; +B.import = Ma; +wa(X.prototype); +function Na(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -1090,45 +1090,45 @@ function Ma(a, c = 0) { e.length && b.push(e); return b; } -function Na(a, c) { +function Oa(a, c) { c || (c = new Map()); for (let b = 0, e; b < a.length; b++) { e = a[b], c.set(e[0], e[1]); } return c; } -function Oa(a, c = 0) { +function Pa(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], Ma(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], Na(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function Pa(a, c) { +function Qa(a, c) { c || (c = new Map()); for (let b = 0, e, d; b < a.length; b++) { - e = a[b], d = c.get(e[0]), c.set(e[0], Na(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], Oa(e[1], d)); } return c; } -function Qa(a) { +function Ra(a) { let c = [], b = []; for (const e of a.keys()) { - b.push(e), 250000 === b.length && (c.push(b), b = []); + b.push(e), b.length === 250000 && (c.push(b), b = []); } b.length && c.push(b); return c; } -function Ra(a, c) { +function Sa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); } return c; } -function Sa(a, c, b, e, d, f, g = 0) { +function Ta(a, c, b, e, d, f, g = 0) { const h = e && e.constructor === Array; var k = h ? e.shift() : e; if (!k) { @@ -1137,12 +1137,12 @@ function Sa(a, c, b, e, d, f, g = 0) { if ((k = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(k))) && k.then) { const n = this; return k.then(function() { - return Sa.call(n, a, c, b, h ? e : null, d, f, g + 1); + return Ta.call(n, a, c, b, h ? e : null, d, f, g + 1); }); } - return Sa.call(this, a, c, b, h ? e : null, d, f, g + 1); + return Ta.call(this, a, c, b, h ? e : null, d, f, g + 1); } -function Ja(a, c, b = 0, e = 0) { +function La(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { @@ -1157,51 +1157,51 @@ function Ja(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = Qa(this.reg); + f = Ra(this.reg); c = null; break; case 1: d = "tag"; - f = this.tag && Oa(this.tag, this.reg.size); + f = this.tag && Pa(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = this.store && Ma(this.store); + f = this.store && Na(this.store); c = null; break; default: return; } - return Sa.call(this, a, c, d, f, b, e); + return Ta.call(this, a, c, d, f || null, b, e); } -function La(a, c) { +function Ma(a, c) { var b = a.split("."); - "json" === b[b.length - 1] && b.pop(); - a = 2 < b.length ? b[0] : ""; - b = 2 < b.length ? b[2] : b[1]; + b[b.length - 1] === "json" && b.pop(); + a = b.length > 2 ? b[0] : ""; + b = b.length > 2 ? b[2] : b[1]; if (c) { - "string" === typeof c && (c = JSON.parse(c)); + typeof c === "string" && (c = JSON.parse(c)); if (a) { return this.index.get(a).import(b, c); } switch(b) { case "reg": this.fastupdate = !1; - this.reg = Ra(c, this.reg); + this.reg = Sa(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = Pa(c, this.tag); + this.tag = Qa(c, this.tag); break; case "doc": - this.store = Na(c, this.store); + this.store = Oa(c, this.store); } } } -function Ta(a, c) { +function Ua(a, c) { let b = ""; for (const e of a.entries()) { a = e[0]; @@ -1211,7 +1211,7 @@ function Ta(a, c) { h = d[g] || [""]; let k = ""; for (let n = 0; n < h.length; n++) { - k += (k ? "," : "") + ("string" === c ? '"' + h[n] + '"' : h[n]); + k += (k ? "," : "") + (c === "string" ? '"' + h[n] + '"' : h[n]); } k = "[" + k + "]"; f += (f ? "," : "") + k; @@ -1221,7 +1221,7 @@ function Ta(a, c) { } return b; } -;Z.prototype.remove = function(a, c) { +;Y.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) { @@ -1231,21 +1231,21 @@ function Ta(a, c) { d.pop(); } else { const g = d.indexOf(a); - 0 <= g && d.splice(g, 1); + g >= 0 && d.splice(g, 1); } } } } else { - Ua(this.map, a), this.depth && Ua(this.ctx, a); + Va(this.map, a), this.depth && Va(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Ua(a, c) { +function Va(a, c) { let b = 0; - var e = "undefined" === typeof c; + var e = typeof c === "undefined"; if (a.constructor === Array) { for (let d = 0, f, g, h; d < a.length; d++) { if ((f = a[d]) && f.length) { @@ -1253,8 +1253,8 @@ function Ua(a, c) { return 1; } g = f.indexOf(c); - if (0 <= g) { - if (1 < f.length) { + if (g >= 0) { + if (f.length > 1) { return f.splice(g, 1), 1; } delete a[d]; @@ -1272,14 +1272,14 @@ function Ua(a, c) { } } else { for (let d of a.entries()) { - e = d[0], Ua(d[1], c) ? b++ : a.delete(e); + e = d[0], Va(d[1], c) ? b++ : a.delete(e); } } return b; } -;const Va = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -Z.prototype.add = function(a, c, b, e) { - if (c && (a || 0 === a)) { +;const Wa = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +Y.prototype.add = function(a, c, b, e) { + if (c && (a || a === 0)) { if (!e && !b && this.reg.has(a)) { return this.update(a, c); } @@ -1287,49 +1287,59 @@ Z.prototype.add = function(a, c, b, e) { c = this.encoder.encode(c, !e); const n = c.length; if (n) { - const l = M(), D = M(), w = this.resolution; - for (let t = 0; t < n; t++) { - let p = c[this.rtl ? n - 1 - t : t]; + const l = M(), z = M(), x = this.resolution; + for (let u = 0; u < n; u++) { + let p = c[this.rtl ? n - 1 - u : u]; var d = p.length; - if (d && (e || !D[p])) { - var f = this.score ? this.score(c, p, t, null, 0) : Wa(w, n, t), g = ""; + if (d && (e || !z[p])) { + var f = this.score ? this.score(c, p, u, null, 0) : Xa(x, n, u), g = ""; switch(this.tokenize) { + case "tolerant": + Z(this, z, p, f, a, b); + if (d > 2) { + for (let w = 1, m, v, t, C; w < d - 1; w++) { + m = p.charAt(w), v = p.charAt(w + 1), t = p.substring(0, w) + v, C = p.substring(w + 2), g = t + m + C, z[g] || Z(this, z, g, f, a, b), g = t + C, z[g] || Z(this, z, g, f, a, b); + } + } + break; case "full": - if (2 < d) { - for (let x = 0, m; x < d; x++) { - for (f = d; f > x; f--) { - g = p.substring(x, f); - m = this.rtl ? d - 1 - x : x; - var h = this.score ? this.score(c, p, t, g, m) : Wa(w, n, t, d, m); - Xa(this, D, g, h, a, b); + if (d > 2) { + for (let w = 0, m; w < d; w++) { + for (f = d; f > w; f--) { + if (g = p.substring(w, f), !z[g]) { + m = this.rtl ? d - 1 - w : w; + var h = this.score ? this.score(c, p, u, g, m) : Xa(x, n, u, d, m); + Z(this, z, g, h, a, b); + } } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - g = p[this.rtl ? d - 1 - h : h] + g; - var k = this.score ? this.score(c, p, t, g, h) : Wa(w, n, t, d, h); - Xa(this, D, g, k, a, b); + if (d > 1) { + for (h = d - 1; h > 0; h--) { + if (g = p[this.rtl ? d - 1 - h : h] + g, !z[g]) { + var k = this.score ? this.score(c, p, u, g, h) : Xa(x, n, u, d, h); + Z(this, z, g, k, a, b); + } } g = ""; } case "forward": - if (1 < d) { + if (d > 1) { for (h = 0; h < d; h++) { - g += p[this.rtl ? d - 1 - h : h], Xa(this, D, g, f, a, b); + g += p[this.rtl ? d - 1 - h : h], z[g] || Z(this, z, g, f, a, b); } break; } default: - if (Xa(this, D, p, f, a, b), e && 1 < n && t < n - 1) { - for (d = M(), g = this.P, f = p, h = Math.min(e + 1, this.rtl ? t + 1 : n - t), d[f] = 1, k = 1; k < h; k++) { - if ((p = c[this.rtl ? n - 1 - t - k : t + k]) && !d[p]) { + if (Z(this, z, p, f, a, b), e && n > 1 && u < n - 1) { + for (d = M(), g = this.L, f = p, h = Math.min(e + 1, this.rtl ? u + 1 : n - u), d[f] = 1, k = 1; k < h; k++) { + if ((p = c[this.rtl ? n - 1 - u - k : u + k]) && !d[p]) { d[p] = 1; - const x = this.score ? this.score(c, f, t, p, k - 1) : Wa(g + (n / 2 > g ? 0 : 1), n, t, h - 1, k - 1), m = this.bidirectional && p > f; - Xa(this, l, m ? f : p, x, a, b, m ? p : f); + const w = this.score ? this.score(c, f, u, p, k - 1) : Xa(g + (n / 2 > g ? 0 : 1), n, u, h - 1, k - 1), m = this.bidirectional && p > f; + Z(this, l, m ? f : p, w, a, b, m ? p : f); } } } @@ -1341,17 +1351,17 @@ Z.prototype.add = function(a, c, b, e) { } return this; }; -function Xa(a, c, b, e, d, f, g) { +function Z(a, c, b, e, d, f, g) { let h = g ? a.ctx : a.map, k; if (!c[b] || g && !(k = c[b])[g]) { g ? (c = k || (c[b] = M()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))); } } -function Wa(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 Xa(a, c, b, e, d) { + return b && a > 1 ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;Z.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); +;Y.prototype.search = function(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = "")); if (b && b.cache) { return b.cache = !1, c = this.searchCache(a, c, b), b.cache = !0, c; } @@ -1365,16 +1375,16 @@ function Wa(a, c, b, e, d) { var h = !0; var k = b.resolution; } - "undefined" === typeof h && (h = !0); - f = this.depth && !1 !== f; + typeof h === "undefined" && (h = !0); + f = this.depth && f !== !1; b = this.encoder.encode(a, !f); a = b.length; c = c || (h ? 100 : 0); - if (1 === a) { - return g = d, (d = Ya(this, b[0], "")) && d.length ? Ca.call(this, d, c, g) : []; + if (a === 1) { + return g = d, (d = Ya(this, b[0], "")) && d.length ? Da.call(this, d, c, g) : []; } - if (2 === a && f && !g) { - return g = d, (d = Ya(this, b[1], b[0])) && d.length ? Ca.call(this, d, c, g) : []; + if (a === 2 && f && !g) { + return g = d, (d = Ya(this, b[1], b[0])) && d.length ? Da.call(this, d, c, g) : []; } h = M(); var n = 0; @@ -1382,39 +1392,39 @@ function Wa(a, c, b, e, d) { var l = b[0]; n = 1; } - k || 0 === k || (k = l ? this.P : this.resolution); - for (let p, x; n < a; n++) { - if ((x = b[n]) && !h[x]) { - h[x] = 1; - p = Ya(this, x, l); + k || k === 0 || (k = l ? this.L : this.resolution); + for (let p, w; n < a; n++) { + if ((w = b[n]) && !h[w]) { + h[w] = 1; + p = Ya(this, w, l); a: { f = p; - var D = e, w = g, t = k; + var z = e, x = g, u = k; let m = []; if (f && f.length) { - if (f.length <= t) { - D.push(f); + if (f.length <= u) { + z.push(f); p = void 0; break a; } - for (let v = 0, u; v < t; v++) { - if (u = f[v]) { - m[v] = u; + for (let v = 0, t; v < u; v++) { + if (t = f[v]) { + m[v] = t; } } if (m.length) { - D.push(m); + z.push(m); p = void 0; break a; } } - p = w ? void 0 : m; + p = x ? void 0 : m; } if (p) { e = p; break; } - l && (g && p && e.length || (l = x)); + l && (g && p && e.length || (l = w)); } g && l && n === a - 1 && !e.length && (k = this.resolution, l = "", n = -1, h = M()); } @@ -1422,18 +1432,18 @@ function Wa(a, c, b, e, d) { b = e; e = b.length; l = b; - if (1 < e) { + if (e > 1) { b: { e = g; l = b.length; g = []; a = M(); - for (let p = 0, x, m, v, u; p < k; p++) { + for (let p = 0, w, m, v, t; p < k; p++) { for (n = 0; n < l; n++) { - if (v = b[n], p < v.length && (x = v[p])) { - for (f = 0; f < x.length; f++) { - if (m = x[f], (h = a[m]) ? a[m]++ : (h = 0, a[m] = 1), u = g[h] || (g[h] = []), u.push(m), c && h === l - 1 && u.length - d === c) { - l = d ? u.slice(d) : u; + if (v = b[n], p < v.length && (w = v[p])) { + for (f = 0; f < w.length; f++) { + if (m = w[f], (h = a[m]) ? a[m]++ : (h = 0, a[m] = 1), t = g[h] || (g[h] = []), t.push(m), c && h === l - 1 && t.length - d === c) { + l = d ? t.slice(d) : t; break b; } } @@ -1442,9 +1452,9 @@ function Wa(a, c, b, e, d) { } if (b = g.length) { if (e) { - if (1 < g.length) { + if (g.length > 1) { c: { - for (b = [], k = M(), e = g.length, h = e - 1; 0 <= h; h--) { + for (b = [], k = M(), e = g.length, h = e - 1; h >= 0; h--) { if (a = (e = g[h]) && e.length) { for (n = 0; n < a; n++) { if (l = e[n], !k[l]) { @@ -1479,8 +1489,8 @@ function Wa(a, c, b, e, d) { } l = g; } - } else if (1 === e) { - c = Ca.call(null, b[0], c, d); + } else if (e === 1) { + c = Da.call(null, b[0], c, d); break a; } c = l; @@ -1493,68 +1503,68 @@ function Ya(a, c, b) { a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function Z(a, c) { - if (!this || this.constructor !== Z) { - return new Z(a); +;function Y(a, c) { + if (!this || this.constructor !== Y) { + return new Y(a); } if (a) { var b = P(a) ? a : a.preset; - b && (Va[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Va[b], a)); + b && (Wa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Wa[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = P(a.encoder) ? sa[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new ka(d) : {encode:d}; + const e = b === !0 ? {depth:1} : b || {}, d = P(a.encoder) ? va[a.encoder] : a.encode || a.encoder || {}; + this.encoder = d.encode ? d : typeof d === "object" ? new la(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict"; + this.depth = b === "strict" && e.depth || 0; + this.bidirectional = e.bidirectional !== !1; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + e && e.depth && this.tokenize !== "strict" && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); b = !1; this.map = new Map(); this.ctx = new Map(); this.reg = c || (this.fastupdate ? new Map() : new Set()); - this.P = e.resolution || 3; + this.L = e.resolution || 3; this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new W(b); + this.cache = (b = a.cache || null) && new T(b); this.priority = a.priority || 4; } -A = Z.prototype; -A.clear = function() { +B = Y.prototype; +B.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -A.append = function(a, c) { +B.append = function(a, c) { return this.add(a, c, !0); }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.update = function(a, c) { +B.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); }; -A.cleanup = function() { +B.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Ua(this.map); - this.depth && Ua(this.ctx); + Va(this.map); + this.depth && Va(this.ctx); return this; }; -A.searchCache = la; -A.export = function(a, c, b = 0, e = 0) { +B.searchCache = ma; +B.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = Qa(this.reg); + f = Ra(this.reg); break; case 1: d = "cfg"; @@ -1562,45 +1572,45 @@ A.export = function(a, c, b = 0, e = 0) { break; case 2: d = "map"; - f = Ma(this.map, this.reg.size); + f = Na(this.map, this.reg.size); break; case 3: d = "ctx"; - f = Oa(this.ctx, this.reg.size); + f = Pa(this.ctx, this.reg.size); break; default: return; } - return Sa.call(this, a, c, d, f, b, e); + return Ta.call(this, a, c, d, f, b, e); }; -A.import = function(a, c) { +B.import = function(a, c) { if (c) { - switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { + switch(typeof c === "string" && (c = JSON.parse(c)), a = a.split("."), a[a.length - 1] === "json" && a.pop(), a.length === 3 && a.shift(), a = a.length > 1 ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = Ra(c, this.reg); + this.reg = Sa(c, this.reg); break; case "map": - this.map = Na(c, this.map); + this.map = Oa(c, this.map); break; case "ctx": - this.ctx = Pa(c, this.ctx); + this.ctx = Qa(c, this.ctx); } } }; -A.serialize = function(a = !0) { +B.serialize = function(a = !0) { let c = "", b = "", e = ""; if (this.reg.size) { let f; for (var d of this.reg.keys()) { - f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); + f || (f = typeof d), c += (c ? "," : "") + (f === "string" ? '"' + d + '"' : d); } c = "index.reg=new Set([" + c + "]);"; - b = Ta(this.map, f); + b = Ua(this.map, f); b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let h = Ta(g[1], f); + let h = Ua(g[1], f); h = "new Map([" + h + "])"; h = '["' + d + '",' + h + "]"; e += (e ? "," : "") + h; @@ -1609,11 +1619,11 @@ A.serialize = function(a = !0) { } return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -va(Z.prototype); +wa(Y.prototype); M(); -const Za = {Index:Z, Charset:sa, Encoder:ka, Document:Y, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, $a = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +const Za = {Index:Y, Charset:va, Encoder:la, Document:X, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, $a = typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : self; let ab; (ab = $a.define) && ab.amd ? ab([], function() { return Za; -}) : "object" === typeof $a.exports ? $a.exports = Za : $a.FlexSearch = Za; +}) : typeof $a.exports === "object" ? $a.exports = Za : $a.FlexSearch = Za; }(this||self)); diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index b019ff3..9c5bd02 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,57 +1,57 @@ /**! - * FlexSearch.js v0.8.202 (Bundle) + * FlexSearch.js v0.8.203 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function(self){'use strict';var A;function I(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 f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function J(a,c){return"undefined"===typeof a?c:a}function N(){return Object.create(null)} -function P(a){return"string"===typeof a}function R(a){return"object"===typeof a}function S(a,c){if(P(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=I(a.numeric,e)}else{try{this.split=I(this.split,aa)}catch(d){this.split=/\s+/}this.numeric=I(a.numeric,I(this.numeric,!0))}this.prepare=I(a.prepare,null,this.prepare);this.finalize=I(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:I(b&&new Set(b),null,this.filter);this.dedupe=I(a.dedupe,!0,this.dedupe);this.matcher=I((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=I((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=I((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=I(a.replacer,null,this.replacer);this.minlength=I(a.minlength,1,this.minlength);this.maxlength=I(a.maxlength,1024,this.maxlength);this.rtl=I(a.rtl,!1,this.rtl);if(this.cache=b=I(a.cache,!0,this.cache))this.H=null,this.O="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.C="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.C+= -(this.C?"|":"")+d;return this};A.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.C+=(this.C?"|":"")+a;this.N=null;this.cache&&T(this);return this};A.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&T(this);return this}; -A.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.h+=(this.h?"|":"")+a;this.M=null;this.cache&&T(this);return this}; -A.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&T(this);return this}; -A.encode=function(a,c){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(T,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.maxlength)){if(c){if(d[l])continue;d[l]=1}else{if(f===l)continue;f=l}if(b)e.push(l);else if(!this.filter||("function"===typeof this.filter?this.filter(l):!this.filter.has(l))){if(this.cache&&l.length<=this.L)if(this.H){var k=this.G.get(l);if(k||""===k){k&&e.push(k);continue}}else this.H=setTimeout(T,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ -this.C+")$"));let w;for(;w!==l&&2this.stemmer.get(t))}if(l&&(this.mapper||this.dedupe&&1this.matcher.get(w)));if(l&&this.replacer)for(k=0;l&&kthis.O&&(this.G.clear(),this.L=this.L/1.1|0));if(l){if(l!==C)if(c){if(d[l])continue;d[l]=1}else{if(g===l)continue;g=l}e.push(l)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.O&&(this.F.clear(),this.K=this.K/1.1|0));return e};function T(a){a.H=null;a.F.clear();a.G.clear()};function la(a,c,b){b||(c||"object"!==typeof a?"object"===typeof c&&(b=c,c=0):b=a);b&&(a=b.query||a,c=b.limit||c);let e=""+(c||0);b&&(e+=(b.offset||0)+!!b.context+!!b.suggest+(!1!==b.resolve)+(b.resolution||this.resolution)+(b.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new W);let d=this.cache.get(a+e);if(!d){const f=b&&b.cache;f&&(b.cache=!1);d=this.search(a,c,b);f&&(b.cache=f);this.cache.set(a+e,d)}return d}function W(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""} -W.prototype.set=function(a,c){this.cache.set(this.h=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};W.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};W.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};W.prototype.clear=function(){this.cache.clear();this.h=""};const ma={normalize:!1,numeric:!1,dedupe:!1};const na={};const oa=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"]]);const pa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ra={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 sa={Exact:ma,Default:na,Normalize:na,LatinBalance:{mapper:oa},LatinAdvanced:{mapper:oa,matcher:pa,replacer:qa},LatinExtra:{mapper:oa,replacer:qa.concat([/(?!^)[aeo]/g,""]),matcher:pa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b=this.priority*this.priority*3):(wa=setTimeout(za,0),xa=Date.now());if(ya){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};Y.prototype.add=function(a,c,b){R(a)&&(c=a,a=S(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hc?a.slice(b,b+c):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}f=f.slice(b,b+c);g=f.length;b=0}g>c&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1E&&(E=m.length+(m?1:0)),z=m.length+(m?1:0)+L.length,r+=F,ja.push(u.length),u.push({match:L})),m+=(m?" ":"")+L)}if(!q)D=v[y],m+=(m?" ":"")+D,k&&u.push({text:D});else if(k&&r>=k)break}r=ja.length*(f.length-2);if(t||p||k&&m.length-r>k)if(r=k+r-2*w,y=z-E,0v&&(v=0)),u=u.length-1){if(G>=u.length){y[q+1]= -1;G>=v.length&&(r[q+1]=1);continue}F-=w}m=u[G].text;if(H=p&&B[q])if(0H)if(y[q+1]=1,n)m=m.substring(0,H);else continue;(H-=m.length)||(H=-1);B[q]=H}else{y[q+1]=1;continue}if(F+m.length+1<=k)m=" "+m,z[q]+=m;else if(n)O=k-F-1,0=G){if(0>G){y[q]=1;r[q]=1;continue}F-=w}m=u[G].text;if(H=t&&D[q])if(0H)if(y[q]=1,n)m=m.substring(m.length- -H);else continue;(H-=m.length)||(H=-1);D[q]=H}else{y[q]=1;continue}if(F+m.length+1<=k)m+=" ",z[q]=m+z[q];else if(n)O=m.length+1-(k-F),0<=O&&O=v.length-1?ua=1:Gb||e)a=a.slice(e,e+b);d&&(a=Ga.call(this,a))}return a}function Ga(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bx;f--){g=p.substring(x,f);m=this.rtl?d-1-x:x;var h=this.score?this.score(c,p,t,g,m):Wa(w, -n,t,d,m);Xa(this,C,g,h,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),n,t,h-1,k-1),m=this.bidirectional&&p>f;Xa(this,l,m?f:p,x,a,b,m?p:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Xa(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=N()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))} -function Wa(a,c,b,e,d){return b&&1c||d?g.slice(d,c+d):g;g=b}else{if(b< -l){l=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}l=g}else if(1===e){c=Ca.call(null,b[0],c,d);break a}c=l}return c};function Ya(a,c,b){let e;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};function Z(a,c){if(!this||this.constructor!==Z)return new Z(a);if(a){var b=P(a)?a:a.preset;b&&(a=Object.assign({},Va[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=P(a.encoder)?sa[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ka(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.P=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new W(b);this.priority=a.priority||4}A=Z.prototype;A.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};A.append=function(a,c){return this.add(a,c,!0)};A.contain=function(a){return this.reg.has(a)}; -A.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)};A.cleanup=function(){if(!this.fastupdate)return this;Ua(this.map);this.depth&&Ua(this.ctx);return this};A.searchCache=la;A.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=Qa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=Ma(this.map,this.reg.size);break;case 3:d="ctx";f=Oa(this.ctx,this.reg.size);break;default:return}return Sa.call(this,a,c,d,f,b,e)}; -A.import=function(a,c){if(c)switch("string"===typeof c&&(c=JSON.parse(c)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=11)return this.addMatcher(a,c);this.mapper||(this.mapper=new Map);this.mapper.set(a,c);this.cache&&S(this);return this};B.addMatcher=function(a,c){if(typeof a==="object")return this.addReplacer(a,c);if(a.length<2&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.I=null;this.cache&&S(this);return this}; +B.addReplacer=function(a,c){if(typeof a==="string")return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&S(this);return this}; +B.encode=function(a,c){if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(S,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(fa,"$1 $2").replace(ha,"$1 $2").replace(ea,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let e= +[],d=N(),f,g,h=this.split||this.split===""?a.split(this.split):[a];for(let n=0,l,z;nthis.maxlength)){if(c){if(d[l])continue;d[l]=1}else{if(f===l)continue;f=l}if(b)e.push(l);else if(!this.filter||(typeof this.filter==="function"?this.filter(l):!this.filter.has(l))){if(this.cache&&l.length<=this.H)if(this.D){var k=this.C.get(l);if(k||k===""){k&&e.push(k);continue}}else this.D=setTimeout(S,50,this);if(this.stemmer){this.J||(this.J=new RegExp("(?!^)("+ +this.A+")$"));let x;for(;x!==l&&l.length>2;)x=l,l=l.replace(this.J,u=>this.stemmer.get(u))}if(l&&(this.mapper||this.dedupe&&l.length>1)){k="";for(let x=0,u="",p,w;x1&&(this.I||(this.I=new RegExp("("+this.h+")","g")),l=l.replace(this.I,x=>this.matcher.get(x)));if(l&&this.replacer)for(k=0;l&&kthis.K&&(this.C.clear(),this.H=this.H/1.1|0));if(l){if(l!==z)if(c){if(d[l])continue;d[l]=1}else{if(g===l)continue;g=l}e.push(l)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.G&&(this.B.set(a,e),this.B.size>this.K&&(this.B.clear(),this.G=this.G/1.1|0));return e};function S(a){a.D=null;a.B.clear();a.C.clear()};function ma(a,c,b){b||(c||typeof a!=="object"?typeof c==="object"&&(b=c,c=0):b=a);b&&(a=b.query||a,c=b.limit||c);let e=""+(c||0);b&&(e+=(b.offset||0)+!!b.context+!!b.suggest+(b.resolve!==!1)+(b.resolution||this.resolution)+(b.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new T);let d=this.cache.get(a+e);if(!d){const f=b&&b.cache;f&&(b.cache=!1);d=this.search(a,c,b);f&&(b.cache=f);this.cache.set(a+e,d)}return d}function T(a){this.limit=a&&a!==!0?a:1E3;this.cache=new Map;this.h=""} +T.prototype.set=function(a,c){this.cache.set(this.h=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};T.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};T.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};T.prototype.clear=function(){this.cache.clear();this.h=""};const na={normalize:!1,numeric:!1,dedupe:!1};const oa={};const pa=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"]]);const qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const sa={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 va={Exact:na,Default:oa,Normalize:oa,LatinBalance:{mapper:pa},LatinAdvanced:{mapper:pa,matcher:qa,replacer:ra},LatinExtra:{mapper:pa,replacer:ra.concat([/(?!^)[aeo]/g,""]),matcher:qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b=this.priority*this.priority*3):(xa=setTimeout(Aa,0),ya=Date.now());if(za){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};X.prototype.add=function(a,c,b){R(a)&&(c=a,a=aa(c,this.key));if(c&&(a||a===0)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hc?a.slice(b,b+c):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}f=f.slice(b,b+c);g=f.length;b=0}g>c&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=e.length>1?[].concat.apply([],e):e[0]};function Ea(a,c,b,e,d){let f,g,h;typeof d==="string"?(f=d,d=""):f=d.template;g=f.indexOf("$1");h=f.substring(g+2);g=f.substring(0,g);let k=d&&d.boundary,n=!d||d.clip!==!1,l=d&&d.merge&&h&&g&&new RegExp(h+" "+g,"g");d=d&&d.ellipsis;var z=0;if(typeof d==="object"){var x=d.template;z=x.length-2;d=d.pattern}typeof d!=="string"&&(d=d===!1?"":"...");z&&(d=x.replace("$1",d));x=d.length-z;let u,p;typeof k==="object"&&(u=k.before,u===0&&(u=-1),p=k.after,p===0&&(p=-1),k=k.total||9E5);z=new Map;for(let ta=0, +V,Ka,ca;ta1?D.join(" "):D[0];let q;if(D&&E){var F=E.length,K=(V.split?E.replace(V.split, +""):E).length-D.length,L="",Q=0;for(var W=0;W-1&&(L=(M?E.substring(0,M):"")+g+E.substring(M,M+H)+h+(M+H=k)break}t=ja.length*(f.length-2);if(u||p||k&&m.length-t>k)if(t=k+t-x*2,y=A-C,u>0&&(y+=u),p>0&&(y+=p), +y<=t)v=u?C-(u>0?u:0):C-((t-y)/2|0),r=p?A+(p>0?p:0):v+t,n||(v>0&&m.charAt(v)!==" "&&m.charAt(v-1)!==" "&&(v=m.indexOf(" ",v),v<0&&(v=0)),r=r.length-1){if(G>=r.length){y[q+1]= +1;G>=v.length&&(t[q+1]=1);continue}F-=x}m=r[G].text;if(H=p&&D[q])if(H>0){if(m.length>H)if(y[q+1]=1,n)m=m.substring(0,H);else continue;(H-=m.length)||(H=-1);D[q]=H}else{y[q+1]=1;continue}if(F+m.length+1<=k)m=" "+m,A[q]+=m;else if(n)O=k-F-1,O>0&&(m=" "+m.substring(0,O),A[q]+=m),y[q+1]=1;else{y[q+1]=1;continue}}else{if(y[q])continue;G-=K;if(C[G]){F-=x;y[q]=1;t[q]=1;continue}if(G<=0){if(G<0){y[q]=1;t[q]=1;continue}F-=x}m=r[G].text;if(H=u&&E[q])if(H>0){if(m.length>H)if(y[q]=1,n)m=m.substring(m.length- +H);else continue;(H-=m.length)||(H=-1);E[q]=H}else{y[q]=1;continue}if(F+m.length+1<=k)m+=" ",A[q]=m+A[q];else if(n)O=m.length+1-(k-F),O>=0&&O=v.length-1?ua=1:G0){if(b&&c>b||e)a=a.slice(e,e+b);d&&(a=Ha.call(this,a))}return a}function Ha(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;b1?b:b[0]}B=X.prototype;B.append=function(a,c){return this.add(a,c,!0)};B.update=function(a,c){return this.remove(a).add(a,c)}; +B.remove=function(a){R(a)&&(a=aa(a,this.key));for(var c of this.index.values())c.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(let b of this.tag.values())for(let e of b){c=e[0];const d=e[1],f=d.indexOf(a);f>-1&&(d.length>1?d.splice(f,1):b.delete(c))}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +B.clear=function(){const a=[];for(const c of this.index.values()){const b=c.clear();b.then&&a.push(b)}if(this.tag)for(const c of this.tag.values())c.clear();this.store&&this.store.clear();this.cache&&this.cache.clear();return a.length?Promise.all(a):this};B.contain=function(a){return this.reg.has(a)};B.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};B.get=function(a){return this.store.get(a)||null}; +B.set=function(a,c){typeof a==="object"&&(c=a,a=aa(c,this.key));this.store.set(a,c);return this};B.searchCache=ma;B.export=La;B.import=Ma;wa(X.prototype);function Na(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|0);for(const d of a.entries())e.push(d),e.length===c&&(b.push(e),e=[]);e.length&&b.push(e);return b}function Oa(a,c){c||(c=new Map);for(let b=0,e;b2?b[0]:"";b=b.length>2?b[2]:b[1];if(c){typeof c==="string"&&(c=JSON.parse(c));if(a)return this.index.get(a).import(b,c);switch(b){case "reg":this.fastupdate=!1;this.reg=Sa(c,this.reg);for(let e=0,d;e=0&&d.splice(g,1)}}else Va(this.map,a),this.depth&&Va(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Va(a,c){let b=0;var e=typeof c==="undefined";if(a.constructor===Array)for(let d=0,f,g,h;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;h=1}else{if(h)return 1;b++}}}else for(let d of a.entries())e=d[0],Va(d[1],c)?b++:a.delete(e);return b};const Wa={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};Y.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const n=c.length;if(n){const l=N(),z=N(),x=this.resolution;for(let u=0;u2)for(let w=1,m,v,r,C;w2){for(let w=0,m;ww;f--)if(g=p.substring(w,f),!z[g]){m=this.rtl?d-1-w:w;var h=this.score?this.score(c,p,u,g,m):Xa(x,n,u,d,m);Z(this,z,g,h,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(h=d-1;h>0;h--)if(g=p[this.rtl?d-1-h:h]+g,!z[g]){var k=this.score?this.score(c,p,u,g,h):Xa(x,n,u,d,h);Z(this,z,g,k,a,b)}g=""}case "forward":if(d>1){for(h=0;h1&&ug?0:1),n,u,h-1,k-1),m=this.bidirectional&&p>f;Z(this,l,m?f:p,w,a,b,m?p:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function Z(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=N()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function Xa(a,c,b,e,d){return b&&a>1?c+(e||0)<=a?b+(d||0):(a-1)/(c+(e||0))*(b+(d||0))+1|0:0};Y.prototype.search=function(a,c,b){b||(c||typeof a!=="object"?typeof c==="object"&&(b=c,c=0):(b=a,a=""));if(b&&b.cache)return b.cache=!1,c=this.searchCache(a,c,b),b.cache=!0,c;var e=[],d=0;if(b){a=b.query||a;c=b.limit||c;d=b.offset||0;var f=b.context;var g=b.suggest;var h=!0;var k=b.resolution}typeof h==="undefined"&&(h=!0);f=this.depth&&f!==!1;b=this.encoder.encode(a,!f);a=b.length;c=c||(h?100:0);if(a===1)return g=d,(d=Ya(this,b[0],""))&&d.length?Da.call(this,d,c,g):[];if(a===2&&f&&!g)return g=d, +(d=Ya(this,b[1],b[0]))&&d.length?Da.call(this,d,c,g):[];h=N();var n=0;if(f){var l=b[0];n=1}k||k===0||(k=l?this.L:this.resolution);for(let p,w;n1)b:{e=g;l=b.length;g=[];a=N();for(let p=0,w,m,v,r;p1)c:for(b=[],k=N(),e=g.length,h=e-1;h>=0;h--){if(a=(e=g[h])&&e.length)for(n=0;nc||d?g.slice(d,c+d):g;g=b}else{if(b< +l){l=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}l=g}else if(e===1){c=Da.call(null,b[0],c,d);break a}c=l}return c};function Ya(a,c,b){let e;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};function Y(a,c){if(!this||this.constructor!==Y)return new Y(a);if(a){var b=P(a)?a:a.preset;b&&(a=Object.assign({},Wa[b],a))}else a={};b=a.context;const e=b===!0?{depth:1}:b||{},d=P(a.encoder)?va[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:typeof d==="object"?new la(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&b!=="default"&&b!=="exact"&&b||"strict";this.depth=b==="strict"&&e.depth||0;this.bidirectional=e.bidirectional!==!1;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.L=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new T(b);this.priority=a.priority||4}B=Y.prototype;B.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};B.append=function(a,c){return this.add(a,c,!0)};B.contain=function(a){return this.reg.has(a)}; +B.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)};B.cleanup=function(){if(!this.fastupdate)return this;Va(this.map);this.depth&&Va(this.ctx);return this};B.searchCache=ma;B.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=Ra(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=Na(this.map,this.reg.size);break;case 3:d="ctx";f=Pa(this.ctx,this.reg.size);break;default:return}return Ta.call(this,a,c,d,f,b,e)}; +B.import=function(a,c){if(c)switch(typeof c==="string"&&(c=JSON.parse(c)),a=a.split("."),a[a.length-1]==="json"&&a.pop(),a.length===3&&a.shift(),a=a.length>1?a[1]:a[0],a){case "reg":this.fastupdate=!1;this.reg=Sa(c,this.reg);break;case "map":this.map=Oa(c,this.map);break;case "ctx":this.ctx=Qa(c,this.ctx)}}; +B.serialize=function(a=!0){let c="",b="",e="";if(this.reg.size){let f;for(var d of this.reg.keys())f||(f=typeof d),c+=(c?",":"")+(f==="string"?'"'+d+'"':d);c="index.reg=new Set(["+c+"]);";b=Ua(this.map,f);b="index.map=new Map(["+b+"]);";for(const g of this.ctx.entries()){d=g[0];let h=Ua(g[1],f);h="new Map(["+h+"])";h='["'+d+'",'+h+"]";e+=(e?",":"")+h}e="index.ctx=new Map(["+e+"]);"}return a?"function inject(index){"+c+b+e+"}":c+b+e};wa(Y.prototype);N();const Za={Index:Y,Charset:va,Encoder:la,Document:X,Worker:null,Resolver:null,IndexedDB:null,Language:{}},$a=typeof self!=="undefined"?self:typeof global!=="undefined"?global:self;let ab;(ab=$a.define)&&ab.amd?ab([],function(){return Za}):typeof $a.exports==="object"?$a.exports=Za:$a.FlexSearch=Za;}(this||self)); diff --git a/dist/flexsearch.compact.module.debug.js b/dist/flexsearch.compact.module.debug.js index 37a81dd..bed5378 100644 --- a/dist/flexsearch.compact.module.debug.js +++ b/dist/flexsearch.compact.module.debug.js @@ -1,17 +1,17 @@ /**! - * FlexSearch.js v0.8.202 (Bundle/Debug) + * FlexSearch.js v0.8.203 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var A; +var B; function I(a, c, b) { const e = typeof b, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { + if (e !== "undefined") { + if (d !== "undefined") { if (b) { - if ("function" === d && e === d) { + if (d === "function" && e === d) { return function(h) { return a(b(h)); }; @@ -41,21 +41,21 @@ function I(a, c, b) { } return b; } - return "undefined" === d ? c : a; + return d === "undefined" ? c : a; } function J(a, c) { - return "undefined" === typeof a ? c : a; + return typeof a === "undefined" ? c : a; } function M() { return Object.create(null); } function P(a) { - return "string" === typeof a; + return typeof a === "string"; } function R(a) { - return "object" === typeof a; + return typeof a === "object"; } -function S(a, c) { +function aa(a, c) { if (P(c)) { a = a[c]; } else { @@ -65,10 +65,10 @@ function S(a, c) { } return a; } -;const aa = /[^\p{L}\p{N}]+/u, da = /(\d{3})/g, ea = /(\D)(\d{3})/g, fa = /(\d{3})(\D)/g, ha = /[\u0300-\u036f]/g; -function ka(a = {}) { - if (!this || this.constructor !== ka) { - return new ka(...arguments); +;const ba = /[^\p{L}\p{N}]+/u, ea = /(\d{3})/g, fa = /(\D)(\d{3})/g, ha = /(\d{3})(\D)/g, ka = /[\u0300-\u036f]/g; +function la(a = {}) { + if (!this || this.constructor !== la) { + return new la(...arguments); } if (arguments.length) { for (a = 0; a < arguments.length; a++) { @@ -78,12 +78,12 @@ function ka(a = {}) { this.assign(a); } } -A = ka.prototype; -A.assign = function(a) { +B = la.prototype; +B.assign = function(a) { this.normalize = I(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { + if (b || b === "") { + if (typeof b === "object" && b.constructor !== RegExp) { let d = ""; e = !c; c || (d += "\\p{Z}"); @@ -93,7 +93,7 @@ A.assign = function(a) { b.punctuation && (d += "\\p{P}"); b.control && (d += "\\p{C}"); if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; + d += typeof b === "object" ? b.join("") : b; } try { this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); @@ -101,12 +101,12 @@ A.assign = function(a) { console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = b, e = !1 === b || 2 > "a1a".split(b).length; + this.split = b, e = b === !1 || "a1a".split(b).length < 2; } this.numeric = I(a.numeric, e); } else { try { - this.split = I(this.split, aa); + this.split = I(this.split, ba); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } @@ -115,7 +115,7 @@ A.assign = function(a) { this.prepare = I(a.prepare, null, this.prepare); this.finalize = I(a.finalize, null, this.finalize); b = a.filter; - this.filter = "function" === typeof b ? b : I(b && new Set(b), null, this.filter); + this.filter = typeof b === "function" ? b : I(b && new Set(b), null, this.filter); this.dedupe = I(a.dedupe, !0, this.dedupe); this.matcher = I((b = a.matcher) && new Map(b), null, this.matcher); this.mapper = I((b = a.mapper) && new Map(b), null, this.mapper); @@ -125,12 +125,12 @@ A.assign = function(a) { this.maxlength = I(a.maxlength, 1024, this.maxlength); this.rtl = I(a.rtl, !1, this.rtl); if (this.cache = b = I(a.cache, !0, this.cache)) { - this.H = null, this.O = "number" === typeof b ? b : 2e5, this.F = new Map(), this.G = new Map(), this.L = this.K = 128; + this.D = null, this.K = typeof b === "number" ? b : 2e5, this.B = new Map(), this.C = new Map(), this.H = this.G = 128; } this.h = ""; - this.M = null; - this.C = ""; - this.N = null; + this.I = null; + this.A = ""; + this.J = null; if (this.matcher) { for (const d of this.matcher.keys()) { this.h += (this.h ? "|" : "") + d; @@ -138,76 +138,76 @@ A.assign = function(a) { } if (this.stemmer) { for (const d of this.stemmer.keys()) { - this.C += (this.C ? "|" : "") + d; + this.A += (this.A ? "|" : "") + d; } } return this; }; -A.addStemmer = function(a, c) { +B.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); - this.C += (this.C ? "|" : "") + a; - this.N = null; - this.cache && T(this); + this.A += (this.A ? "|" : "") + a; + this.J = null; + this.cache && S(this); return this; }; -A.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); - this.cache && T(this); +B.addFilter = function(a) { + typeof a === "function" ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); + this.cache && S(this); return this; }; -A.addMapper = function(a, c) { - if ("object" === typeof a) { +B.addMapper = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (1 < a.length) { + if (a.length > 1) { return this.addMatcher(a, c); } this.mapper || (this.mapper = new Map()); this.mapper.set(a, c); - this.cache && T(this); + this.cache && S(this); return this; }; -A.addMatcher = function(a, c) { - if ("object" === typeof a) { +B.addMatcher = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (2 > a.length && (this.dedupe || this.mapper)) { + if (a.length < 2 && (this.dedupe || this.mapper)) { return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); this.matcher.set(a, c); this.h += (this.h ? "|" : "") + a; - this.M = null; - this.cache && T(this); + this.I = null; + this.cache && S(this); return this; }; -A.addReplacer = function(a, c) { - if ("string" === typeof a) { +B.addReplacer = function(a, c) { + if (typeof a === "string") { return this.addMatcher(a, c); } this.replacer || (this.replacer = []); this.replacer.push(a, c); - this.cache && T(this); + this.cache && S(this); return this; }; -A.encode = function(a, c) { - if (this.cache && a.length <= this.K) { - if (this.H) { - if (this.F.has(a)) { - return this.F.get(a); +B.encode = function(a, c) { + if (this.cache && a.length <= this.G) { + if (this.D) { + if (this.B.has(a)) { + return this.B.get(a); } } else { - this.H = setTimeout(T, 50, this); + this.D = setTimeout(S, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ha ? a.normalize("NFKD").replace(ha, "").toLowerCase() : a.toLowerCase()); + this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(ea, "$1 $2").replace(fa, "$1 $2").replace(da, "$1 ")); + this.numeric && a.length > 3 && (a = a.replace(fa, "$1 $2").replace(ha, "$1 $2").replace(ea, "$1 ")); const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let e = [], d = M(), f, g, h = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let n = 0, l, D; n < h.length; n++) { - if ((l = D = h[n]) && !(l.length < this.minlength || l.length > this.maxlength)) { + let e = [], d = M(), f, g, h = this.split || this.split === "" ? a.split(this.split) : [a]; + for (let n = 0, l, z; n < h.length; n++) { + if ((l = z = h[n]) && !(l.length < this.minlength || l.length > this.maxlength)) { if (c) { if (d[l]) { continue; @@ -222,41 +222,41 @@ A.encode = function(a, c) { if (b) { e.push(l); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(l) : !this.filter.has(l))) { - if (this.cache && l.length <= this.L) { - if (this.H) { - var k = this.G.get(l); - if (k || "" === k) { + if (!this.filter || (typeof this.filter === "function" ? this.filter(l) : !this.filter.has(l))) { + if (this.cache && l.length <= this.H) { + if (this.D) { + var k = this.C.get(l); + if (k || k === "") { k && e.push(k); continue; } } else { - this.H = setTimeout(T, 50, this); + this.D = setTimeout(S, 50, this); } } if (this.stemmer) { - this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")); - let w; - for (; w !== l && 2 < l.length;) { - w = l, l = l.replace(this.N, t => this.stemmer.get(t)); + this.J || (this.J = new RegExp("(?!^)(" + this.A + ")$")); + let x; + for (; x !== l && l.length > 2;) { + x = l, l = l.replace(this.J, u => this.stemmer.get(u)); } } - if (l && (this.mapper || this.dedupe && 1 < l.length)) { + if (l && (this.mapper || this.dedupe && l.length > 1)) { k = ""; - for (let w = 0, t = "", p, x; w < l.length; w++) { - p = l.charAt(w), p === t && this.dedupe || ((x = this.mapper && this.mapper.get(p)) || "" === x ? x === t && this.dedupe || !(t = x) || (k += x) : k += t = p); + for (let x = 0, u = "", p, w; x < l.length; x++) { + p = l.charAt(x), p === u && this.dedupe || ((w = this.mapper && this.mapper.get(p)) || w === "" ? w === u && this.dedupe || !(u = w) || (k += w) : k += u = p); } l = k; } - this.matcher && 1 < l.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), l = l.replace(this.M, w => this.matcher.get(w))); + this.matcher && l.length > 1 && (this.I || (this.I = new RegExp("(" + this.h + ")", "g")), l = l.replace(this.I, x => this.matcher.get(x))); if (l && this.replacer) { for (k = 0; l && k < this.replacer.length; k += 2) { l = l.replace(this.replacer[k], this.replacer[k + 1]); } } - this.cache && D.length <= this.L && (this.G.set(D, l), this.G.size > this.O && (this.G.clear(), this.L = this.L / 1.1 | 0)); + this.cache && z.length <= this.H && (this.C.set(z, l), this.C.size > this.K && (this.C.clear(), this.H = this.H / 1.1 | 0)); if (l) { - if (l !== D) { + if (l !== z) { if (c) { if (d[l]) { continue; @@ -276,21 +276,21 @@ A.encode = function(a, c) { } } this.finalize && (e = this.finalize(e) || e); - this.cache && a.length <= this.K && (this.F.set(a, e), this.F.size > this.O && (this.F.clear(), this.K = this.K / 1.1 | 0)); + this.cache && a.length <= this.G && (this.B.set(a, e), this.B.size > this.K && (this.B.clear(), this.G = this.G / 1.1 | 0)); return e; }; -function T(a) { - a.H = null; - a.F.clear(); - a.G.clear(); +function S(a) { + a.D = null; + a.B.clear(); + a.C.clear(); } -;function la(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : b = a); +;function ma(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : b = a); b && (a = b.query || a, c = b.limit || c); let e = "" + (c || 0); - b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (!1 !== b.resolve) + (b.resolution || this.resolution) + (b.boost || 0)); + b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (b.resolve !== !1) + (b.resolution || this.resolution) + (b.boost || 0)); a = ("" + a).toLowerCase(); - this.cache || (this.cache = new W()); + this.cache || (this.cache = new T()); let d = this.cache.get(a + e); if (!d) { const f = b && b.cache; @@ -301,64 +301,64 @@ function T(a) { } return d; } -function W(a) { - this.limit = a && !0 !== a ? a : 1000; +function T(a) { + this.limit = a && a !== !0 ? a : 1000; this.cache = new Map(); this.h = ""; } -W.prototype.set = function(a, c) { +T.prototype.set = function(a, c) { this.cache.set(this.h = a, c); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -W.prototype.get = function(a) { +T.prototype.get = function(a) { const c = this.cache.get(a); c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c)); return c; }; -W.prototype.remove = function(a) { +T.prototype.remove = function(a) { for (const c of this.cache) { const b = c[0]; c[1].includes(a) && this.cache.delete(b); } }; -W.prototype.clear = function() { +T.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const ma = {normalize:!1, numeric:!1, dedupe:!1}; -const na = {}; -const oa = 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"]]); -const pa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const ra = {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 ua = {Exact:ma, Default:na, Normalize:na, LatinBalance:{mapper:oa}, LatinAdvanced:{mapper:oa, matcher:pa, replacer:qa}, LatinExtra:{mapper:oa, replacer:qa.concat([/(?!^)[aeo]/g, ""]), matcher:pa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { +const na = {normalize:!1, numeric:!1, dedupe:!1}; +const oa = {}; +const pa = 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"]]); +const qa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), ra = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const ua = {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 va = {Exact:na, Default:oa, Normalize:oa, LatinBalance:{mapper:pa}, LatinAdvanced:{mapper:pa, matcher:qa, replacer:ra}, LatinExtra:{mapper:pa, replacer:ra.concat([/(?!^)[aeo]/g, ""]), matcher:qa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = ra[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ra[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = ua[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), g === "h" || g === "w" || !(g = ua[g]) || g === d || (e += g, d = g, e.length !== 4)); f++) { } a[b] = e; } -}}, CJK:{split:""}, LatinExact:ma, LatinDefault:na, LatinSimple:na}; -function va(a) { - X.call(a, "add"); - X.call(a, "append"); - X.call(a, "search"); - X.call(a, "update"); - X.call(a, "remove"); - X.call(a, "searchCache"); +}}, CJK:{split:""}, LatinExact:na, LatinDefault:oa, LatinSimple:oa}; +function wa(a) { + U.call(a, "add"); + U.call(a, "append"); + U.call(a, "search"); + U.call(a, "update"); + U.call(a, "remove"); + U.call(a, "searchCache"); } -let wa, xa, ya; -function za() { - wa = ya = 0; +let xa, ya, za; +function Aa() { + xa = za = 0; } -function X(a) { +function U(a) { this[a + "Async"] = function() { const c = arguments; var b = c[c.length - 1]; let e; - "function" === typeof b && (e = b, delete c[c.length - 1]); - wa ? ya || (ya = Date.now() - xa >= this.priority * this.priority * 3) : (wa = setTimeout(za, 0), xa = Date.now()); - if (ya) { + typeof b === "function" && (e = b, delete c[c.length - 1]); + xa ? za || (za = Date.now() - ya >= this.priority * this.priority * 3) : (xa = setTimeout(Aa, 0), ya = Date.now()); + if (za) { const f = this; return new Promise(g => { setTimeout(function() { @@ -372,40 +372,40 @@ function X(a) { return b; }; } -;Y.prototype.add = function(a, c, b) { - R(a) && (c = a, a = S(c, this.key)); - if (c && (a || 0 === a)) { +;X.prototype.add = function(a, c, b) { + R(a) && (c = a, a = aa(c, this.key)); + if (c && (a || a === 0)) { if (!b && this.reg.has(a)) { return this.update(a, c); } for (let h = 0, k; h < this.field.length; h++) { - k = this.D[h]; + k = this.B[h]; var e = this.index.get(this.field[h]); - if ("function" === typeof k) { + if (typeof k === "function") { var d = k(c); d && e.add(a, d, !1, !0); } else { - if (d = k.I, !d || d(c)) { - k.constructor === String ? k = ["" + k] : P(k) && (k = [k]), Aa(c, k, this.J, 0, e, a, k[0], b); + if (d = k.F, !d || d(c)) { + k.constructor === String ? k = ["" + k] : P(k) && (k = [k]), Ba(c, k, this.C, 0, e, a, k[0], b); } } } if (this.tag) { - for (e = 0; e < this.B.length; e++) { - var f = this.B[e], g = this.R[e]; + for (e = 0; e < this.A.length; e++) { + var f = this.A[e], g = this.D[e]; d = this.tag.get(g); let h = M(); - if ("function" === typeof f) { + if (typeof f === "function") { if (f = f(c), !f) { continue; } } else { - const k = f.I; + const k = f.F; if (k && !k(c)) { continue; } f.constructor === String && (f = "" + f); - f = S(c, f); + f = aa(c, f); } if (d && f) { P(f) && (f = [f]); @@ -419,25 +419,25 @@ function X(a) { } if (this.store && (!b || !this.store.has(a))) { let h; - if (this.A) { + if (this.h) { h = M(); - for (let k = 0, n; k < this.A.length; k++) { - n = this.A[k]; - if ((b = n.I) && !b(c)) { + for (let k = 0, n; k < this.h.length; k++) { + n = this.h[k]; + if ((b = n.F) && !b(c)) { continue; } let l; - if ("function" === typeof n) { + if (typeof n === "function") { l = n(c); if (!l) { continue; } - n = [n.S]; + n = [n.M]; } else if (P(n) || n.constructor === String) { h[n] = c[n]; continue; } - Ba(c, h, n, 0, n[0], l); + Ca(c, h, n, 0, n[0], l); } } this.store.set(a, h || c); @@ -445,21 +445,21 @@ function X(a) { } return this; }; -function Ba(a, c, b, e, d, f) { +function Ca(a, c, b, e, d, f) { a = a[d]; if (e === b.length - 1) { c[d] = f || a; } else if (a) { if (a.constructor === Array) { for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - Ba(a, c, b, e, d); + Ca(a, c, b, e, d); } } else { - c = c[d] || (c[d] = M()), d = b[++e], Ba(a, c, b, e, d); + c = c[d] || (c[d] = M()), d = b[++e], Ca(a, c, b, e, d); } } } -function Aa(a, c, b, e, d, f, g, h) { +function Ba(a, c, b, e, d, f, g, h) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -475,19 +475,19 @@ function Aa(a, c, b, e, d, f, g, h) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Aa(a, c, b, e, d, f, g, h); + Ba(a, c, b, e, d, f, g, h); } } else { - g = c[++e], Aa(a, c, b, e, d, f, g, h); + g = c[++e], Ba(a, c, b, e, d, f, g, h); } } } } -;function Ca(a, c, b) { +;function Da(a, c, b) { if (!a.length) { return a; } - if (1 === a.length) { + if (a.length === 1) { return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a; } let e = []; @@ -513,56 +513,56 @@ function Aa(a, c, b, e, d, f, g, h) { } } } - return e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return e = e.length > 1 ? [].concat.apply([], e) : e[0]; } -;function Da(a, c, b, e, d) { +;function Ea(a, c, b, e, d) { let f, g, h; - "string" === typeof d ? (f = d, d = "") : f = d.template; + typeof d === "string" ? (f = d, d = "") : f = d.template; if (!f) { throw Error('No template pattern was specified by the search option "highlight"'); } g = f.indexOf("$1"); - if (-1 === g) { + if (g === -1) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } h = f.substring(g + 2); g = f.substring(0, g); - let k = d && d.boundary, n = !d || !1 !== d.clip, l = d && d.merge && h && g && new RegExp(h + " " + g, "g"); + let k = d && d.boundary, n = !d || d.clip !== !1, l = d && d.merge && h && g && new RegExp(h + " " + g, "g"); d = d && d.ellipsis; - var D = 0; - if ("object" === typeof d) { - var w = d.template; - D = w.length - 2; + var z = 0; + if (typeof d === "object") { + var x = d.template; + z = x.length - 2; d = d.pattern; } - "string" !== typeof d && (d = !1 === d ? "" : "..."); - D && (d = w.replace("$1", d)); - w = d.length - D; - let t, p; - "object" === typeof k && (t = k.before, 0 === t && (t = -1), p = k.after, 0 === p && (p = -1), k = k.total || 9e5); - D = new Map(); - for (let sa = 0, U, Ha, ba; sa < c.length; sa++) { - let ca; + typeof d !== "string" && (d = d === !1 ? "" : "..."); + z && (d = x.replace("$1", d)); + x = d.length - z; + let u, p; + typeof k === "object" && (u = k.before, u === 0 && (u = -1), p = k.after, p === 0 && (p = -1), k = k.total || 9e5); + z = new Map(); + for (let sa = 0, V, Ha, ca; sa < c.length; sa++) { + let da; if (e) { - ca = c, ba = e; + da = c, ca = e; } else { - var x = c[sa]; - ba = x.field; - if (!ba) { + var w = c[sa]; + ca = w.field; + if (!ca) { continue; } - ca = x.result; + da = w.result; } - Ha = b.get(ba); - U = Ha.encoder; - x = D.get(U); - "string" !== typeof x && (x = U.encode(a), D.set(U, x)); - for (let ia = 0; ia < ca.length; ia++) { - var m = ca[ia].doc; + Ha = b.get(ca); + V = Ha.encoder; + w = z.get(V); + typeof w !== "string" && (w = V.encode(a), z.set(V, w)); + for (let ia = 0; ia < da.length; ia++) { + var m = da[ia].doc; if (!m) { continue; } - m = S(m, ba); + m = aa(m, ca); if (!m) { continue; } @@ -571,44 +571,44 @@ function Aa(a, c, b, e, d, f, g, h) { continue; } m = ""; - var u = []; + var t = []; let ja = []; - var F = -1, z = -1, r = 0; + var C = -1, A = -1, r = 0; for (var y = 0; y < v.length; y++) { - var E = v[y], B = U.encode(E); - B = 1 < B.length ? B.join(" ") : B[0]; + var F = v[y], D = V.encode(F); + D = D.length > 1 ? D.join(" ") : D[0]; let q; - if (B && E) { - var C = E.length, K = (U.split ? E.replace(U.split, "") : E).length - B.length, L = "", Q = 0; - for (var V = 0; V < x.length; V++) { - var N = x[V]; + if (D && F) { + var E = F.length, K = (V.split ? F.replace(V.split, "") : F).length - D.length, L = "", Q = 0; + for (var W = 0; W < w.length; W++) { + var N = w[W]; if (N) { var H = N.length; H += K; - Q && H <= Q || (N = B.indexOf(N), -1 < N && (L = (N ? E.substring(0, N) : "") + g + E.substring(N, N + H) + h + (N + H < C ? E.substring(N + H) : ""), Q = H, q = !0)); + Q && H <= Q || (N = D.indexOf(N), N > -1 && (L = (N ? F.substring(0, N) : "") + g + F.substring(N, N + H) + h + (N + H < E ? F.substring(N + H) : ""), Q = H, q = !0)); } } - L && (k && (0 > F && (F = m.length + (m ? 1 : 0)), z = m.length + (m ? 1 : 0) + L.length, r += C, ja.push(u.length), u.push({match:L})), m += (m ? " " : "") + L); + L && (k && (C < 0 && (C = m.length + (m ? 1 : 0)), A = m.length + (m ? 1 : 0) + L.length, r += E, ja.push(t.length), t.push({match:L})), m += (m ? " " : "") + L); } if (!q) { - E = v[y], m += (m ? " " : "") + E, k && u.push({text:E}); + F = v[y], m += (m ? " " : "") + F, k && t.push({text:F}); } else if (k && r >= k) { break; } } r = ja.length * (f.length - 2); - if (t || p || k && m.length - r > k) { - if (r = k + r - 2 * w, y = z - F, 0 < t && (y += t), 0 < p && (y += p), y <= r) { - v = t ? F - (0 < t ? t : 0) : F - ((r - y) / 2 | 0), u = p ? z + (0 < p ? p : 0) : v + r, n || (0 < v && " " !== m.charAt(v) && " " !== m.charAt(v - 1) && (v = m.indexOf(" ", v), 0 > v && (v = 0)), u < m.length && " " !== m.charAt(u - 1) && " " !== m.charAt(u) && (u = m.lastIndexOf(" ", u), u < z ? u = z : ++u)), m = (v ? d : "") + m.substring(v, u) + (u < m.length ? d : ""); + if (u || p || k && m.length - r > k) { + if (r = k + r - x * 2, y = A - C, u > 0 && (y += u), p > 0 && (y += p), y <= r) { + v = u ? C - (u > 0 ? u : 0) : C - ((r - y) / 2 | 0), t = p ? A + (p > 0 ? p : 0) : v + r, n || (v > 0 && m.charAt(v) !== " " && m.charAt(v - 1) !== " " && (v = m.indexOf(" ", v), v < 0 && (v = 0)), t < m.length && m.charAt(t - 1) !== " " && m.charAt(t) !== " " && (t = m.lastIndexOf(" ", t), t < A ? t = A : ++t)), m = (v ? d : "") + m.substring(v, t) + (t < m.length ? d : ""); } else { - z = []; - F = {}; + A = []; + C = {}; r = {}; y = {}; - E = {}; - B = {}; - L = K = C = 0; - for (V = Q = 1;;) { + F = {}; + D = {}; + L = K = E = 0; + for (W = Q = 1;;) { var O = void 0; for (let q = 0, G; q < ja.length; q++) { G = ja[q]; @@ -618,23 +618,23 @@ function Aa(a, c, b, e, d, f, g, h) { continue; } G += L; - if (F[G]) { - C -= w; + if (C[G]) { + E -= x; r[q + 1] = 1; y[q + 1] = 1; continue; } - if (G >= u.length - 1) { - if (G >= u.length) { + if (G >= t.length - 1) { + if (G >= t.length) { y[q + 1] = 1; G >= v.length && (r[q + 1] = 1); continue; } - C -= w; + E -= x; } - m = u[G].text; - if (H = p && B[q]) { - if (0 < H) { + m = t[G].text; + if (H = p && D[q]) { + if (H > 0) { if (m.length > H) { if (y[q + 1] = 1, n) { m = m.substring(0, H); @@ -643,16 +643,16 @@ function Aa(a, c, b, e, d, f, g, h) { } } (H -= m.length) || (H = -1); - B[q] = H; + D[q] = H; } else { y[q + 1] = 1; continue; } } - if (C + m.length + 1 <= k) { - m = " " + m, z[q] += m; + if (E + m.length + 1 <= k) { + m = " " + m, A[q] += m; } else if (n) { - O = k - C - 1, 0 < O && (m = " " + m.substring(0, O), z[q] += m), y[q + 1] = 1; + O = k - E - 1, O > 0 && (m = " " + m.substring(0, O), A[q] += m), y[q + 1] = 1; } else { y[q + 1] = 1; continue; @@ -662,23 +662,23 @@ function Aa(a, c, b, e, d, f, g, h) { continue; } G -= K; - if (F[G]) { - C -= w; + if (C[G]) { + E -= x; y[q] = 1; r[q] = 1; continue; } - if (0 >= G) { - if (0 > G) { + if (G <= 0) { + if (G < 0) { y[q] = 1; r[q] = 1; continue; } - C -= w; + E -= x; } - m = u[G].text; - if (H = t && E[q]) { - if (0 < H) { + m = t[G].text; + if (H = u && F[q]) { + if (H > 0) { if (m.length > H) { if (y[q] = 1, n) { m = m.substring(m.length - H); @@ -687,60 +687,60 @@ function Aa(a, c, b, e, d, f, g, h) { } } (H -= m.length) || (H = -1); - E[q] = H; + F[q] = H; } else { y[q] = 1; continue; } } - if (C + m.length + 1 <= k) { - m += " ", z[q] = m + z[q]; + if (E + m.length + 1 <= k) { + m += " ", A[q] = m + A[q]; } else if (n) { - O = m.length + 1 - (k - C), 0 <= O && O < m.length && (m = m.substring(O) + " ", z[q] = m + z[q]), y[q] = 1; + O = m.length + 1 - (k - E), O >= 0 && O < m.length && (m = m.substring(O) + " ", A[q] = m + A[q]), y[q] = 1; } else { y[q] = 1; continue; } } } else { - m = u[G].match; - t && (E[q] = t); - p && (B[q] = p); - q && C++; + m = t[G].match; + u && (F[q] = u); + p && (D[q] = p); + q && E++; let ta; - G ? !q && w && (C += w) : (r[q] = 1, y[q] = 1); - G >= v.length - 1 ? ta = 1 : G < u.length - 1 && u[G + 1].match ? ta = 1 : w && (C += w); - C -= f.length - 2; - if (!q || C + m.length <= k) { - z[q] = m; + G ? !q && x && (E += x) : (r[q] = 1, y[q] = 1); + G >= v.length - 1 ? ta = 1 : G < t.length - 1 && t[G + 1].match ? ta = 1 : x && (E += x); + E -= f.length - 2; + if (!q || E + m.length <= k) { + A[q] = m; } else { - O = Q = V = r[q] = 0; + O = Q = W = r[q] = 0; break; } ta && (r[q + 1] = 1, y[q + 1] = 1); } - C += m.length; - O = F[G] = 1; + E += m.length; + O = C[G] = 1; } if (O) { K === L ? L++ : K++; } else { - K === L ? Q = 0 : V = 0; - if (!Q && !V) { + K === L ? Q = 0 : W = 0; + if (!Q && !W) { break; } Q ? (K++, L = K) : L++; } } m = ""; - for (let q = 0, G; q < z.length; q++) { - G = (q && r[q] ? " " : (q && !d ? " " : "") + d) + z[q], m += G; + for (let q = 0, G; q < A.length; q++) { + G = (q && r[q] ? " " : (q && !d ? " " : "") + d) + A[q], m += G; } - d && !r[z.length] && (m += d); + d && !r[A.length] && (m += d); } } l && (m = m.replace(l, " ")); - ca[ia].highlight = m; + da[ia].highlight = m; } if (e) { break; @@ -748,7 +748,7 @@ function Aa(a, c, b, e, d, f, g, h) { } return c; } -;function Ea(a, c) { +;function Fa(a, c) { const b = M(), e = []; for (let d = 0, f; d < c.length; d++) { f = c[d]; @@ -762,55 +762,55 @@ function Aa(a, c, b, e, d, f, g, h) { return e; } ;M(); -Y.prototype.search = function(a, c, b, e) { +X.prototype.search = function(a, c, b, e) { b || (!c && R(a) ? (b = a, a = "") : R(c) && (b = c, c = 0)); let d = []; var f = []; let g; let h, k, n, l; - let D = 0, w = !0, t; + let z = 0, x = !0, u; if (b) { b.constructor === Array && (b = {index:b}); a = b.query || a; var p = b.pluck; - var x = b.merge; + var w = b.merge; n = p || b.field || (n = b.index) && (n.index ? null : n); l = this.tag && b.tag; h = b.suggest; - w = !0; + x = !0; k = b.cache; - this.store && b.highlight && !w ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !w && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - t = w && this.store && b.highlight; - g = !!t || w && this.store && b.enrich; + this.store && b.highlight && !x ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !x && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + u = x && this.store && b.highlight; + g = !!u || x && this.store && b.enrich; c = b.limit || c; var m = b.offset || 0; - c || (c = w ? 100 : 0); + c || (c = x ? 100 : 0); if (l) { l.constructor !== Array && (l = [l]); var v = []; - for (let z = 0, r; z < l.length; z++) { - r = l[z]; + for (let A = 0, r; A < l.length; A++) { + r = l[A]; if (P(r)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } if (r.field && r.tag) { - var u = r.tag; - if (u.constructor === Array) { - for (var F = 0; F < u.length; F++) { - v.push(r.field, u[F]); + var t = r.tag; + if (t.constructor === Array) { + for (var C = 0; C < t.length; C++) { + v.push(r.field, t[C]); } } else { - v.push(r.field, u); + v.push(r.field, t); } } else { - u = Object.keys(r); - for (let y = 0, E, B; y < u.length; y++) { - if (E = u[y], B = r[E], B.constructor === Array) { - for (F = 0; F < B.length; F++) { - v.push(E, B[F]); + t = Object.keys(r); + for (let y = 0, F, D; y < t.length; y++) { + if (F = t[y], D = r[F], D.constructor === Array) { + for (C = 0; C < D.length; C++) { + v.push(F, D[C]); } } else { - v.push(E, B); + v.push(F, D); } } } @@ -823,12 +823,12 @@ Y.prototype.search = function(a, c, b, e) { f = []; if (v.length) { for (p = 0; p < v.length; p += 2) { - x = Fa.call(this, v[p], v[p + 1], c, m, g), d.push({field:v[p], tag:v[p + 1], result:x}); + w = Ga.call(this, v[p], v[p + 1], c, m, g), d.push({field:v[p], tag:v[p + 1], result:w}); } } - return f.length ? Promise.all(f).then(function(z) { - for (let r = 0; r < z.length; r++) { - d[r].result = z[r]; + return f.length ? Promise.all(f).then(function(A) { + for (let r = 0; r < A.length; r++) { + d[r].result = A[r]; } return d; }) : d; @@ -838,67 +838,67 @@ Y.prototype.search = function(a, c, b, e) { } n || (n = this.field); v = !1; - for (let z = 0, r, y, E; z < n.length; z++) { - y = n[z]; - let B; - P(y) || (B = y, y = B.field, a = B.query || a, c = J(B.limit, c), m = J(B.offset, m), h = J(B.suggest, h), t = w && this.store && J(B.highlight, t), g = !!t || w && this.store && J(B.enrich, g), k = J(B.cache, k)); + for (let A = 0, r, y, F; A < n.length; A++) { + y = n[A]; + let D; + P(y) || (D = y, y = D.field, a = D.query || a, c = J(D.limit, c), m = J(D.offset, m), h = J(D.suggest, h), u = x && this.store && J(D.highlight, u), g = !!u || x && this.store && J(D.enrich, g), k = J(D.cache, k)); if (e) { - r = e[z]; + r = e[A]; } else { - u = B || b || {}; - F = u.enrich; - const C = this.index.get(y); - l && F && (u.enrich = !1); - r = k ? C.searchCache(a, c, u) : C.search(a, c, u); - F && (u.enrich = F); + t = D || b || {}; + C = t.enrich; + const E = this.index.get(y); + l && C && (t.enrich = !1); + r = k ? E.searchCache(a, c, t) : E.search(a, c, t); + C && (t.enrich = C); if (v) { - v[z] = r; + v[A] = r; continue; } } - E = (r = r.result || r) && r.length; - if (l && E) { - u = []; - F = 0; - for (let C = 0, K, L; C < l.length; C += 2) { - K = this.tag.get(l[C]); + F = (r = r.result || r) && r.length; + if (l && F) { + t = []; + C = 0; + for (let E = 0, K, L; E < l.length; E += 2) { + K = this.tag.get(l[E]); if (!K) { - if (console.warn("Tag '" + l[C] + ":" + l[C + 1] + "' will be skipped because there is no field '" + l[C] + "'."), h) { + if (console.warn("Tag '" + l[E] + ":" + l[E + 1] + "' will be skipped because there is no field '" + l[E] + "'."), h) { continue; } else { return d; } } - if (L = (K = K && K.get(l[C + 1])) && K.length) { - F++, u.push(K); + if (L = (K = K && K.get(l[E + 1])) && K.length) { + C++, t.push(K); } else if (!h) { return d; } } - if (F) { - r = Ea(r, u); - E = r.length; - if (!E && !h) { + if (C) { + r = Fa(r, t); + F = r.length; + if (!F && !h) { return r; } - F--; + C--; } } - if (E) { - f[D] = y, d.push(r), D++; - } else if (1 === n.length) { + if (F) { + f[z] = y, d.push(r), z++; + } else if (n.length === 1) { return d; } } if (v) { - const z = this; + const A = this; return Promise.all(v).then(function(r) { - b && (b.resolve = w); - r.length && (r = z.search(a, c, b, r)); + b && (b.resolve = x); + r.length && (r = A.search(a, c, b, r)); return r; }); } - if (!D) { + if (!z) { return d; } if (p && (!g || !this.store)) { @@ -907,30 +907,30 @@ Y.prototype.search = function(a, c, b, e) { v = []; for (m = 0; m < f.length; m++) { e = d[m]; - g && e.length && "undefined" === typeof e[0].doc && (e = Ga.call(this, e)); + g && e.length && typeof e[0].doc === "undefined" && (e = Ia.call(this, e)); if (p) { - return t ? Da(a, e, this.index, p, t) : e; + return u ? Ea(a, e, this.index, p, u) : e; } d[m] = {field:f[m], result:e}; } - t && (d = Da(a, d, this.index, p, t)); - return x ? Ia(d) : d; + u && (d = Ea(a, d, this.index, p, u)); + return w ? Ja(d) : d; }; -function Ia(a) { +function Ja(a) { const c = [], b = M(), e = M(); - for (let d = 0, f, g, h, k, n, l, D; d < a.length; d++) { + for (let d = 0, f, g, h, k, n, l, z; d < a.length; d++) { f = a[d]; g = f.field; h = f.result; - for (let w = 0; w < h.length; w++) { - if (n = h[w], "object" !== typeof n ? n = {id:k = n} : k = n.id, (l = b[k]) ? l.push(g) : (n.field = b[k] = [g], c.push(n)), D = n.highlight) { - l = e[k], l || (e[k] = l = {}, n.highlight = l), l[g] = D; + for (let x = 0; x < h.length; x++) { + if (n = h[x], typeof n !== "object" ? n = {id:k = n} : k = n.id, (l = b[k]) ? l.push(g) : (n.field = b[k] = [g], c.push(n)), z = n.highlight) { + l = e[k], l || (e[k] = l = {}, n.highlight = l), l[g] = z; } } } return c; } -function Fa(a, c, b, e, d) { +function Ga(a, c, b, e, d) { a = this.tag.get(a); if (!a) { return []; @@ -940,15 +940,15 @@ function Fa(a, c, b, e, d) { return []; } c = a.length - e; - if (0 < c) { + if (c > 0) { if (b && c > b || e) { a = a.slice(e, e + b); } - d && (a = Ga.call(this, a)); + d && (a = Ia.call(this, a)); } return a; } -function Ga(a) { +function Ia(a) { if (!this || !this.store) { return a; } @@ -958,73 +958,73 @@ function Ga(a) { } return c; } -;function Y(a) { - if (!this || this.constructor !== Y) { - return new Y(a); +;function X(a) { + if (!this || this.constructor !== X) { + return new X(a); } const c = a.document || a.doc || a; var b; - this.D = []; + this.B = []; this.field = []; - this.J = []; - this.key = (b = c.key || c.id) && Ja(b, this.J) || "id"; + this.C = []; + this.key = (b = c.key || c.id) && Ka(b, this.C) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); - this.A = (b = c.store || null) && b && !0 !== b && []; - this.store = b && new Map(); - this.cache = (b = a.cache || null) && new W(b); + this.h = (b = c.store || null) && b && b !== !0 && []; + this.store = b ? new Map() : null; + this.cache = (b = a.cache || null) && new T(b); a.cache = !1; this.priority = a.priority || 4; b = new Map(); let e = c.index || c.field || c; P(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], P(f) || (g = f, f = f.field), g = R(g) ? Object.assign({}, a, g) : a, b.set(f, new Z(g, this.reg)), g.custom ? this.D[d] = g.custom : (this.D[d] = Ja(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)), this.field[d] = f; + f = e[d], P(f) || (g = f, f = f.field), g = R(g) ? Object.assign({}, a, g) : a, b.set(f, new Y(g, this.reg)), g.custom ? this.B[d] = g.custom : (this.B[d] = Ka(f, this.C), g.filter && (typeof this.B[d] === "string" && (this.B[d] = new String(this.B[d])), this.B[d].F = g.filter)), this.field[d] = f; } - if (this.A) { + if (this.h) { a = c.store; P(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.S = g) : (this.A[d] = Ja(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.h[d] = f.custom, f.custom.M = g) : (this.h[d] = Ka(g, this.C), f.filter && (typeof this.h[d] === "string" && (this.h[d] = new String(this.h[d])), this.h[d].F = f.filter)); } } this.index = b; this.tag = null; if (b = c.tag) { - if ("string" === typeof b && (b = [b]), b.length) { + if (typeof b === "string" && (b = [b]), b.length) { this.tag = new Map(); - this.B = []; - this.R = []; + this.A = []; + this.D = []; for (let d = 0, f, g; d < b.length; d++) { f = b[d]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = Ja(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); - this.R[d] = g; + f.custom ? this.A[d] = f.custom : (this.A[d] = Ka(g, this.C), f.filter && (typeof this.A[d] === "string" && (this.A[d] = new String(this.A[d])), this.A[d].F = f.filter)); + this.D[d] = g; this.tag.set(g, new Map()); } } } } -function Ja(a, c) { +function Ka(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { - a = b[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); + a = b[d], a[a.length - 1] === "]" && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); } e < b.length && (b.length = e); - return 1 < e ? b : b[0]; + return e > 1 ? b : b[0]; } -A = Y.prototype; -A.append = function(a, c) { +B = X.prototype; +B.append = function(a, c) { return this.add(a, c, !0); }; -A.update = function(a, c) { +B.update = function(a, c) { return this.remove(a).add(a, c); }; -A.remove = function(a) { - R(a) && (a = S(a, this.key)); +B.remove = function(a) { + R(a) && (a = aa(a, this.key)); for (var c of this.index.values()) { c.remove(a, !0); } @@ -1034,7 +1034,7 @@ A.remove = function(a) { for (let e of b) { c = e[0]; const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : b.delete(c)); + f > -1 && (d.length > 1 ? d.splice(f, 1) : b.delete(c)); } } } @@ -1044,7 +1044,7 @@ A.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -A.clear = function() { +B.clear = function() { const a = []; for (const c of this.index.values()) { const b = c.clear(); @@ -1059,28 +1059,28 @@ A.clear = function() { this.cache && this.cache.clear(); return a.length ? Promise.all(a) : this; }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.cleanup = function() { +B.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -A.get = function(a) { +B.get = function(a) { return this.store.get(a) || null; }; -A.set = function(a, c) { - "object" === typeof a && (c = a, a = S(c, this.key)); +B.set = function(a, c) { + typeof a === "object" && (c = a, a = aa(c, this.key)); this.store.set(a, c); return this; }; -A.searchCache = la; -A.export = Ka; -A.import = La; -va(Y.prototype); -function Ma(a, c = 0) { +B.searchCache = ma; +B.export = La; +B.import = Ma; +wa(X.prototype); +function Na(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -1089,45 +1089,45 @@ function Ma(a, c = 0) { e.length && b.push(e); return b; } -function Na(a, c) { +function Oa(a, c) { c || (c = new Map()); for (let b = 0, e; b < a.length; b++) { e = a[b], c.set(e[0], e[1]); } return c; } -function Oa(a, c = 0) { +function Pa(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], Ma(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], Na(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function Pa(a, c) { +function Qa(a, c) { c || (c = new Map()); for (let b = 0, e, d; b < a.length; b++) { - e = a[b], d = c.get(e[0]), c.set(e[0], Na(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], Oa(e[1], d)); } return c; } -function Qa(a) { +function Ra(a) { let c = [], b = []; for (const e of a.keys()) { - b.push(e), 250000 === b.length && (c.push(b), b = []); + b.push(e), b.length === 250000 && (c.push(b), b = []); } b.length && c.push(b); return c; } -function Ra(a, c) { +function Sa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); } return c; } -function Sa(a, c, b, e, d, f, g = 0) { +function Ta(a, c, b, e, d, f, g = 0) { const h = e && e.constructor === Array; var k = h ? e.shift() : e; if (!k) { @@ -1136,12 +1136,12 @@ function Sa(a, c, b, e, d, f, g = 0) { if ((k = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(k))) && k.then) { const n = this; return k.then(function() { - return Sa.call(n, a, c, b, h ? e : null, d, f, g + 1); + return Ta.call(n, a, c, b, h ? e : null, d, f, g + 1); }); } - return Sa.call(this, a, c, b, h ? e : null, d, f, g + 1); + return Ta.call(this, a, c, b, h ? e : null, d, f, g + 1); } -function Ka(a, c, b = 0, e = 0) { +function La(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { @@ -1156,51 +1156,51 @@ function Ka(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = Qa(this.reg); + f = Ra(this.reg); c = null; break; case 1: d = "tag"; - f = this.tag && Oa(this.tag, this.reg.size); + f = this.tag && Pa(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = this.store && Ma(this.store); + f = this.store && Na(this.store); c = null; break; default: return; } - return Sa.call(this, a, c, d, f, b, e); + return Ta.call(this, a, c, d, f || null, b, e); } -function La(a, c) { +function Ma(a, c) { var b = a.split("."); - "json" === b[b.length - 1] && b.pop(); - a = 2 < b.length ? b[0] : ""; - b = 2 < b.length ? b[2] : b[1]; + b[b.length - 1] === "json" && b.pop(); + a = b.length > 2 ? b[0] : ""; + b = b.length > 2 ? b[2] : b[1]; if (c) { - "string" === typeof c && (c = JSON.parse(c)); + typeof c === "string" && (c = JSON.parse(c)); if (a) { return this.index.get(a).import(b, c); } switch(b) { case "reg": this.fastupdate = !1; - this.reg = Ra(c, this.reg); + this.reg = Sa(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = Pa(c, this.tag); + this.tag = Qa(c, this.tag); break; case "doc": - this.store = Na(c, this.store); + this.store = Oa(c, this.store); } } } -function Ta(a, c) { +function Ua(a, c) { let b = ""; for (const e of a.entries()) { a = e[0]; @@ -1210,7 +1210,7 @@ function Ta(a, c) { h = d[g] || [""]; let k = ""; for (let n = 0; n < h.length; n++) { - k += (k ? "," : "") + ("string" === c ? '"' + h[n] + '"' : h[n]); + k += (k ? "," : "") + (c === "string" ? '"' + h[n] + '"' : h[n]); } k = "[" + k + "]"; f += (f ? "," : "") + k; @@ -1220,7 +1220,7 @@ function Ta(a, c) { } return b; } -;Z.prototype.remove = function(a, c) { +;Y.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) { @@ -1230,21 +1230,21 @@ function Ta(a, c) { d.pop(); } else { const g = d.indexOf(a); - 0 <= g && d.splice(g, 1); + g >= 0 && d.splice(g, 1); } } } } else { - Ua(this.map, a), this.depth && Ua(this.ctx, a); + Va(this.map, a), this.depth && Va(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Ua(a, c) { +function Va(a, c) { let b = 0; - var e = "undefined" === typeof c; + var e = typeof c === "undefined"; if (a.constructor === Array) { for (let d = 0, f, g, h; d < a.length; d++) { if ((f = a[d]) && f.length) { @@ -1252,8 +1252,8 @@ function Ua(a, c) { return 1; } g = f.indexOf(c); - if (0 <= g) { - if (1 < f.length) { + if (g >= 0) { + if (f.length > 1) { return f.splice(g, 1), 1; } delete a[d]; @@ -1271,14 +1271,14 @@ function Ua(a, c) { } } else { for (let d of a.entries()) { - e = d[0], Ua(d[1], c) ? b++ : a.delete(e); + e = d[0], Va(d[1], c) ? b++ : a.delete(e); } } return b; } -;const Va = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -Z.prototype.add = function(a, c, b, e) { - if (c && (a || 0 === a)) { +;const Wa = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +Y.prototype.add = function(a, c, b, e) { + if (c && (a || a === 0)) { if (!e && !b && this.reg.has(a)) { return this.update(a, c); } @@ -1286,49 +1286,59 @@ Z.prototype.add = function(a, c, b, e) { c = this.encoder.encode(c, !e); const n = c.length; if (n) { - const l = M(), D = M(), w = this.resolution; - for (let t = 0; t < n; t++) { - let p = c[this.rtl ? n - 1 - t : t]; + const l = M(), z = M(), x = this.resolution; + for (let u = 0; u < n; u++) { + let p = c[this.rtl ? n - 1 - u : u]; var d = p.length; - if (d && (e || !D[p])) { - var f = this.score ? this.score(c, p, t, null, 0) : Wa(w, n, t), g = ""; + if (d && (e || !z[p])) { + var f = this.score ? this.score(c, p, u, null, 0) : Xa(x, n, u), g = ""; switch(this.tokenize) { + case "tolerant": + Z(this, z, p, f, a, b); + if (d > 2) { + for (let w = 1, m, v, t, C; w < d - 1; w++) { + m = p.charAt(w), v = p.charAt(w + 1), t = p.substring(0, w) + v, C = p.substring(w + 2), g = t + m + C, z[g] || Z(this, z, g, f, a, b), g = t + C, z[g] || Z(this, z, g, f, a, b); + } + } + break; case "full": - if (2 < d) { - for (let x = 0, m; x < d; x++) { - for (f = d; f > x; f--) { - g = p.substring(x, f); - m = this.rtl ? d - 1 - x : x; - var h = this.score ? this.score(c, p, t, g, m) : Wa(w, n, t, d, m); - Xa(this, D, g, h, a, b); + if (d > 2) { + for (let w = 0, m; w < d; w++) { + for (f = d; f > w; f--) { + if (g = p.substring(w, f), !z[g]) { + m = this.rtl ? d - 1 - w : w; + var h = this.score ? this.score(c, p, u, g, m) : Xa(x, n, u, d, m); + Z(this, z, g, h, a, b); + } } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - g = p[this.rtl ? d - 1 - h : h] + g; - var k = this.score ? this.score(c, p, t, g, h) : Wa(w, n, t, d, h); - Xa(this, D, g, k, a, b); + if (d > 1) { + for (h = d - 1; h > 0; h--) { + if (g = p[this.rtl ? d - 1 - h : h] + g, !z[g]) { + var k = this.score ? this.score(c, p, u, g, h) : Xa(x, n, u, d, h); + Z(this, z, g, k, a, b); + } } g = ""; } case "forward": - if (1 < d) { + if (d > 1) { for (h = 0; h < d; h++) { - g += p[this.rtl ? d - 1 - h : h], Xa(this, D, g, f, a, b); + g += p[this.rtl ? d - 1 - h : h], z[g] || Z(this, z, g, f, a, b); } break; } default: - if (Xa(this, D, p, f, a, b), e && 1 < n && t < n - 1) { - for (d = M(), g = this.P, f = p, h = Math.min(e + 1, this.rtl ? t + 1 : n - t), d[f] = 1, k = 1; k < h; k++) { - if ((p = c[this.rtl ? n - 1 - t - k : t + k]) && !d[p]) { + if (Z(this, z, p, f, a, b), e && n > 1 && u < n - 1) { + for (d = M(), g = this.L, f = p, h = Math.min(e + 1, this.rtl ? u + 1 : n - u), d[f] = 1, k = 1; k < h; k++) { + if ((p = c[this.rtl ? n - 1 - u - k : u + k]) && !d[p]) { d[p] = 1; - const x = this.score ? this.score(c, f, t, p, k - 1) : Wa(g + (n / 2 > g ? 0 : 1), n, t, h - 1, k - 1), m = this.bidirectional && p > f; - Xa(this, l, m ? f : p, x, a, b, m ? p : f); + const w = this.score ? this.score(c, f, u, p, k - 1) : Xa(g + (n / 2 > g ? 0 : 1), n, u, h - 1, k - 1), m = this.bidirectional && p > f; + Z(this, l, m ? f : p, w, a, b, m ? p : f); } } } @@ -1340,17 +1350,17 @@ Z.prototype.add = function(a, c, b, e) { } return this; }; -function Xa(a, c, b, e, d, f, g) { +function Z(a, c, b, e, d, f, g) { let h = g ? a.ctx : a.map, k; if (!c[b] || g && !(k = c[b])[g]) { g ? (c = k || (c[b] = M()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))); } } -function Wa(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 Xa(a, c, b, e, d) { + return b && a > 1 ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;Z.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); +;Y.prototype.search = function(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = "")); if (b && b.cache) { return b.cache = !1, c = this.searchCache(a, c, b), b.cache = !0, c; } @@ -1364,16 +1374,16 @@ function Wa(a, c, b, e, d) { var h = !0; var k = b.resolution; } - "undefined" === typeof h && (h = !0); - f = this.depth && !1 !== f; + typeof h === "undefined" && (h = !0); + f = this.depth && f !== !1; b = this.encoder.encode(a, !f); a = b.length; c = c || (h ? 100 : 0); - if (1 === a) { - return g = d, (d = Ya(this, b[0], "")) && d.length ? Ca.call(this, d, c, g) : []; + if (a === 1) { + return g = d, (d = Ya(this, b[0], "")) && d.length ? Da.call(this, d, c, g) : []; } - if (2 === a && f && !g) { - return g = d, (d = Ya(this, b[1], b[0])) && d.length ? Ca.call(this, d, c, g) : []; + if (a === 2 && f && !g) { + return g = d, (d = Ya(this, b[1], b[0])) && d.length ? Da.call(this, d, c, g) : []; } h = M(); var n = 0; @@ -1381,39 +1391,39 @@ function Wa(a, c, b, e, d) { var l = b[0]; n = 1; } - k || 0 === k || (k = l ? this.P : this.resolution); - for (let p, x; n < a; n++) { - if ((x = b[n]) && !h[x]) { - h[x] = 1; - p = Ya(this, x, l); + k || k === 0 || (k = l ? this.L : this.resolution); + for (let p, w; n < a; n++) { + if ((w = b[n]) && !h[w]) { + h[w] = 1; + p = Ya(this, w, l); a: { f = p; - var D = e, w = g, t = k; + var z = e, x = g, u = k; let m = []; if (f && f.length) { - if (f.length <= t) { - D.push(f); + if (f.length <= u) { + z.push(f); p = void 0; break a; } - for (let v = 0, u; v < t; v++) { - if (u = f[v]) { - m[v] = u; + for (let v = 0, t; v < u; v++) { + if (t = f[v]) { + m[v] = t; } } if (m.length) { - D.push(m); + z.push(m); p = void 0; break a; } } - p = w ? void 0 : m; + p = x ? void 0 : m; } if (p) { e = p; break; } - l && (g && p && e.length || (l = x)); + l && (g && p && e.length || (l = w)); } g && l && n === a - 1 && !e.length && (k = this.resolution, l = "", n = -1, h = M()); } @@ -1421,18 +1431,18 @@ function Wa(a, c, b, e, d) { b = e; e = b.length; l = b; - if (1 < e) { + if (e > 1) { b: { e = g; l = b.length; g = []; a = M(); - for (let p = 0, x, m, v, u; p < k; p++) { + for (let p = 0, w, m, v, t; p < k; p++) { for (n = 0; n < l; n++) { - if (v = b[n], p < v.length && (x = v[p])) { - for (f = 0; f < x.length; f++) { - if (m = x[f], (h = a[m]) ? a[m]++ : (h = 0, a[m] = 1), u = g[h] || (g[h] = []), u.push(m), c && h === l - 1 && u.length - d === c) { - l = d ? u.slice(d) : u; + if (v = b[n], p < v.length && (w = v[p])) { + for (f = 0; f < w.length; f++) { + if (m = w[f], (h = a[m]) ? a[m]++ : (h = 0, a[m] = 1), t = g[h] || (g[h] = []), t.push(m), c && h === l - 1 && t.length - d === c) { + l = d ? t.slice(d) : t; break b; } } @@ -1441,9 +1451,9 @@ function Wa(a, c, b, e, d) { } if (b = g.length) { if (e) { - if (1 < g.length) { + if (g.length > 1) { c: { - for (b = [], k = M(), e = g.length, h = e - 1; 0 <= h; h--) { + for (b = [], k = M(), e = g.length, h = e - 1; h >= 0; h--) { if (a = (e = g[h]) && e.length) { for (n = 0; n < a; n++) { if (l = e[n], !k[l]) { @@ -1478,8 +1488,8 @@ function Wa(a, c, b, e, d) { } l = g; } - } else if (1 === e) { - c = Ca.call(null, b[0], c, d); + } else if (e === 1) { + c = Da.call(null, b[0], c, d); break a; } c = l; @@ -1492,68 +1502,68 @@ function Ya(a, c, b) { a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function Z(a, c) { - if (!this || this.constructor !== Z) { - return new Z(a); +;function Y(a, c) { + if (!this || this.constructor !== Y) { + return new Y(a); } if (a) { var b = P(a) ? a : a.preset; - b && (Va[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Va[b], a)); + b && (Wa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Wa[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = P(a.encoder) ? ua[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new ka(d) : {encode:d}; + const e = b === !0 ? {depth:1} : b || {}, d = P(a.encoder) ? va[a.encoder] : a.encode || a.encoder || {}; + this.encoder = d.encode ? d : typeof d === "object" ? new la(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict"; + this.depth = b === "strict" && e.depth || 0; + this.bidirectional = e.bidirectional !== !1; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + e && e.depth && this.tokenize !== "strict" && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); b = !1; this.map = new Map(); this.ctx = new Map(); this.reg = c || (this.fastupdate ? new Map() : new Set()); - this.P = e.resolution || 3; + this.L = e.resolution || 3; this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new W(b); + this.cache = (b = a.cache || null) && new T(b); this.priority = a.priority || 4; } -A = Z.prototype; -A.clear = function() { +B = Y.prototype; +B.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -A.append = function(a, c) { +B.append = function(a, c) { return this.add(a, c, !0); }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.update = function(a, c) { +B.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); }; -A.cleanup = function() { +B.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Ua(this.map); - this.depth && Ua(this.ctx); + Va(this.map); + this.depth && Va(this.ctx); return this; }; -A.searchCache = la; -A.export = function(a, c, b = 0, e = 0) { +B.searchCache = ma; +B.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = Qa(this.reg); + f = Ra(this.reg); break; case 1: d = "cfg"; @@ -1561,45 +1571,45 @@ A.export = function(a, c, b = 0, e = 0) { break; case 2: d = "map"; - f = Ma(this.map, this.reg.size); + f = Na(this.map, this.reg.size); break; case 3: d = "ctx"; - f = Oa(this.ctx, this.reg.size); + f = Pa(this.ctx, this.reg.size); break; default: return; } - return Sa.call(this, a, c, d, f, b, e); + return Ta.call(this, a, c, d, f, b, e); }; -A.import = function(a, c) { +B.import = function(a, c) { if (c) { - switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { + switch(typeof c === "string" && (c = JSON.parse(c)), a = a.split("."), a[a.length - 1] === "json" && a.pop(), a.length === 3 && a.shift(), a = a.length > 1 ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = Ra(c, this.reg); + this.reg = Sa(c, this.reg); break; case "map": - this.map = Na(c, this.map); + this.map = Oa(c, this.map); break; case "ctx": - this.ctx = Pa(c, this.ctx); + this.ctx = Qa(c, this.ctx); } } }; -A.serialize = function(a = !0) { +B.serialize = function(a = !0) { let c = "", b = "", e = ""; if (this.reg.size) { let f; for (var d of this.reg.keys()) { - f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); + f || (f = typeof d), c += (c ? "," : "") + (f === "string" ? '"' + d + '"' : d); } c = "index.reg=new Set([" + c + "]);"; - b = Ta(this.map, f); + b = Ua(this.map, f); b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let h = Ta(g[1], f); + let h = Ua(g[1], f); h = "new Map([" + h + "])"; h = '["' + d + '",' + h + "]"; e += (e ? "," : "") + h; @@ -1608,8 +1618,8 @@ A.serialize = function(a = !0) { } return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -va(Z.prototype); +wa(Y.prototype); M(); -export default {Index:Z, Charset:ua, Encoder:ka, Document:Y, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +export default {Index:Y, Charset:va, Encoder:la, Document:X, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=Z;export const Charset=ua;export const Encoder=ka;export const Document=Y;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +export const Index=Y;export const Charset=va;export const Encoder=la;export const Document=X;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index b7c91f8..68fc78b 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,58 +1,58 @@ /**! - * FlexSearch.js v0.8.202 (Bundle) + * FlexSearch.js v0.8.203 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var A;function I(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 f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function J(a,c){return"undefined"===typeof a?c:a}function N(){return Object.create(null)} -function P(a){return"string"===typeof a}function R(a){return"object"===typeof a}function S(a,c){if(P(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=I(a.numeric,e)}else{try{this.split=I(this.split,aa)}catch(d){this.split=/\s+/}this.numeric=I(a.numeric,I(this.numeric,!0))}this.prepare=I(a.prepare,null,this.prepare);this.finalize=I(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:I(b&&new Set(b),null,this.filter);this.dedupe=I(a.dedupe,!0,this.dedupe);this.matcher=I((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=I((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=I((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=I(a.replacer,null,this.replacer);this.minlength=I(a.minlength,1,this.minlength);this.maxlength=I(a.maxlength,1024,this.maxlength);this.rtl=I(a.rtl,!1,this.rtl);if(this.cache=b=I(a.cache,!0,this.cache))this.H=null,this.O="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.C="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.C+= -(this.C?"|":"")+d;return this};A.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.C+=(this.C?"|":"")+a;this.N=null;this.cache&&T(this);return this};A.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&T(this);return this}; -A.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.h+=(this.h?"|":"")+a;this.M=null;this.cache&&T(this);return this}; -A.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&T(this);return this}; -A.encode=function(a,c){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(T,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.maxlength)){if(c){if(d[l])continue;d[l]=1}else{if(f===l)continue;f=l}if(b)e.push(l);else if(!this.filter||("function"===typeof this.filter?this.filter(l):!this.filter.has(l))){if(this.cache&&l.length<=this.L)if(this.H){var k=this.G.get(l);if(k||""===k){k&&e.push(k);continue}}else this.H=setTimeout(T,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ -this.C+")$"));let w;for(;w!==l&&2this.stemmer.get(t))}if(l&&(this.mapper||this.dedupe&&1this.matcher.get(w)));if(l&&this.replacer)for(k=0;l&&kthis.O&&(this.G.clear(),this.L=this.L/1.1|0));if(l){if(l!==C)if(c){if(d[l])continue;d[l]=1}else{if(g===l)continue;g=l}e.push(l)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.O&&(this.F.clear(),this.K=this.K/1.1|0));return e};function T(a){a.H=null;a.F.clear();a.G.clear()};function la(a,c,b){b||(c||"object"!==typeof a?"object"===typeof c&&(b=c,c=0):b=a);b&&(a=b.query||a,c=b.limit||c);let e=""+(c||0);b&&(e+=(b.offset||0)+!!b.context+!!b.suggest+(!1!==b.resolve)+(b.resolution||this.resolution)+(b.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new W);let d=this.cache.get(a+e);if(!d){const f=b&&b.cache;f&&(b.cache=!1);d=this.search(a,c,b);f&&(b.cache=f);this.cache.set(a+e,d)}return d}function W(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""} -W.prototype.set=function(a,c){this.cache.set(this.h=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};W.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};W.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};W.prototype.clear=function(){this.cache.clear();this.h=""};const ma={normalize:!1,numeric:!1,dedupe:!1};const na={};const oa=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"]]);const pa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ra={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 ua={Exact:ma,Default:na,Normalize:na,LatinBalance:{mapper:oa},LatinAdvanced:{mapper:oa,matcher:pa,replacer:qa},LatinExtra:{mapper:oa,replacer:qa.concat([/(?!^)[aeo]/g,""]),matcher:pa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b=this.priority*this.priority*3):(wa=setTimeout(za,0),xa=Date.now());if(ya){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};Y.prototype.add=function(a,c,b){R(a)&&(c=a,a=S(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hc?a.slice(b,b+c):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}f=f.slice(b,b+c);g=f.length;b=0}g>c&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1E&&(E=m.length+(m?1:0)),z=m.length+(m?1:0)+L.length,r+=F,ja.push(u.length),u.push({match:L})),m+=(m?" ":"")+L)}if(!q)D=v[y],m+=(m?" ":"")+D,k&&u.push({text:D});else if(k&&r>=k)break}r=ja.length*(f.length-2);if(t||p||k&&m.length-r>k)if(r=k+r-2*w,y=z-E,0v&&(v=0)),u=u.length-1){if(G>=u.length){y[q+1]= -1;G>=v.length&&(r[q+1]=1);continue}F-=w}m=u[G].text;if(H=p&&B[q])if(0H)if(y[q+1]=1,n)m=m.substring(0,H);else continue;(H-=m.length)||(H=-1);B[q]=H}else{y[q+1]=1;continue}if(F+m.length+1<=k)m=" "+m,z[q]+=m;else if(n)O=k-F-1,0=G){if(0>G){y[q]=1;r[q]=1;continue}F-=w}m=u[G].text;if(H=t&&D[q])if(0H)if(y[q]=1,n)m=m.substring(m.length- -H);else continue;(H-=m.length)||(H=-1);D[q]=H}else{y[q]=1;continue}if(F+m.length+1<=k)m+=" ",z[q]=m+z[q];else if(n)O=m.length+1-(k-F),0<=O&&O=v.length-1?ta=1:Gb||e)a=a.slice(e,e+b);d&&(a=Ga.call(this,a))}return a}function Ga(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bx;f--){g=p.substring(x,f);m=this.rtl?d-1-x:x;var h=this.score?this.score(c,p,t,g,m):Wa(w, -n,t,d,m);Xa(this,C,g,h,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),n,t,h-1,k-1),m=this.bidirectional&&p>f;Xa(this,l,m?f:p,x,a,b,m?p:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Xa(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=N()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))} -function Wa(a,c,b,e,d){return b&&1c||d?g.slice(d,c+d):g;g=b}else{if(b< -l){l=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}l=g}else if(1===e){c=Ca.call(null,b[0],c,d);break a}c=l}return c};function Ya(a,c,b){let e;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};function Z(a,c){if(!this||this.constructor!==Z)return new Z(a);if(a){var b=P(a)?a:a.preset;b&&(a=Object.assign({},Va[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=P(a.encoder)?ua[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ka(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.P=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new W(b);this.priority=a.priority||4}A=Z.prototype;A.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};A.append=function(a,c){return this.add(a,c,!0)};A.contain=function(a){return this.reg.has(a)}; -A.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)};A.cleanup=function(){if(!this.fastupdate)return this;Ua(this.map);this.depth&&Ua(this.ctx);return this};A.searchCache=la;A.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=Qa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=Ma(this.map,this.reg.size);break;case 3:d="ctx";f=Oa(this.ctx,this.reg.size);break;default:return}return Sa.call(this,a,c,d,f,b,e)}; -A.import=function(a,c){if(c)switch("string"===typeof c&&(c=JSON.parse(c)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=11)return this.addMatcher(a,c);this.mapper||(this.mapper=new Map);this.mapper.set(a,c);this.cache&&S(this);return this};B.addMatcher=function(a,c){if(typeof a==="object")return this.addReplacer(a,c);if(a.length<2&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.I=null;this.cache&&S(this);return this}; +B.addReplacer=function(a,c){if(typeof a==="string")return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&S(this);return this}; +B.encode=function(a,c){if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(S,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(fa,"$1 $2").replace(ha,"$1 $2").replace(ea,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let e= +[],d=N(),f,g,h=this.split||this.split===""?a.split(this.split):[a];for(let n=0,l,z;nthis.maxlength)){if(c){if(d[l])continue;d[l]=1}else{if(f===l)continue;f=l}if(b)e.push(l);else if(!this.filter||(typeof this.filter==="function"?this.filter(l):!this.filter.has(l))){if(this.cache&&l.length<=this.H)if(this.D){var k=this.C.get(l);if(k||k===""){k&&e.push(k);continue}}else this.D=setTimeout(S,50,this);if(this.stemmer){this.J||(this.J=new RegExp("(?!^)("+ +this.A+")$"));let x;for(;x!==l&&l.length>2;)x=l,l=l.replace(this.J,u=>this.stemmer.get(u))}if(l&&(this.mapper||this.dedupe&&l.length>1)){k="";for(let x=0,u="",p,w;x1&&(this.I||(this.I=new RegExp("("+this.h+")","g")),l=l.replace(this.I,x=>this.matcher.get(x)));if(l&&this.replacer)for(k=0;l&&kthis.K&&(this.C.clear(),this.H=this.H/1.1|0));if(l){if(l!==z)if(c){if(d[l])continue;d[l]=1}else{if(g===l)continue;g=l}e.push(l)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.G&&(this.B.set(a,e),this.B.size>this.K&&(this.B.clear(),this.G=this.G/1.1|0));return e};function S(a){a.D=null;a.B.clear();a.C.clear()};function ma(a,c,b){b||(c||typeof a!=="object"?typeof c==="object"&&(b=c,c=0):b=a);b&&(a=b.query||a,c=b.limit||c);let e=""+(c||0);b&&(e+=(b.offset||0)+!!b.context+!!b.suggest+(b.resolve!==!1)+(b.resolution||this.resolution)+(b.boost||0));a=(""+a).toLowerCase();this.cache||(this.cache=new T);let d=this.cache.get(a+e);if(!d){const f=b&&b.cache;f&&(b.cache=!1);d=this.search(a,c,b);f&&(b.cache=f);this.cache.set(a+e,d)}return d}function T(a){this.limit=a&&a!==!0?a:1E3;this.cache=new Map;this.h=""} +T.prototype.set=function(a,c){this.cache.set(this.h=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};T.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};T.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};T.prototype.clear=function(){this.cache.clear();this.h=""};const na={normalize:!1,numeric:!1,dedupe:!1};const oa={};const pa=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"]]);const qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ua={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 va={Exact:na,Default:oa,Normalize:oa,LatinBalance:{mapper:pa},LatinAdvanced:{mapper:pa,matcher:qa,replacer:ra},LatinExtra:{mapper:pa,replacer:ra.concat([/(?!^)[aeo]/g,""]),matcher:qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b=this.priority*this.priority*3):(xa=setTimeout(Aa,0),ya=Date.now());if(za){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};X.prototype.add=function(a,c,b){R(a)&&(c=a,a=aa(c,this.key));if(c&&(a||a===0)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hc?a.slice(b,b+c):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}f=f.slice(b,b+c);g=f.length;b=0}g>c&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=e.length>1?[].concat.apply([],e):e[0]};function Ea(a,c,b,e,d){let f,g,h;typeof d==="string"?(f=d,d=""):f=d.template;g=f.indexOf("$1");h=f.substring(g+2);g=f.substring(0,g);let k=d&&d.boundary,n=!d||d.clip!==!1,l=d&&d.merge&&h&&g&&new RegExp(h+" "+g,"g");d=d&&d.ellipsis;var z=0;if(typeof d==="object"){var x=d.template;z=x.length-2;d=d.pattern}typeof d!=="string"&&(d=d===!1?"":"...");z&&(d=x.replace("$1",d));x=d.length-z;let u,p;typeof k==="object"&&(u=k.before,u===0&&(u=-1),p=k.after,p===0&&(p=-1),k=k.total||9E5);z=new Map;for(let sa=0, +V,Ha,ca;sa1?D.join(" "):D[0];let q;if(D&&E){var F=E.length,K=(V.split?E.replace(V.split, +""):E).length-D.length,L="",Q=0;for(var W=0;W-1&&(L=(M?E.substring(0,M):"")+g+E.substring(M,M+H)+h+(M+H=k)break}t=ja.length*(f.length-2);if(u||p||k&&m.length-t>k)if(t=k+t-x*2,y=A-C,u>0&&(y+=u),p>0&&(y+=p), +y<=t)v=u?C-(u>0?u:0):C-((t-y)/2|0),r=p?A+(p>0?p:0):v+t,n||(v>0&&m.charAt(v)!==" "&&m.charAt(v-1)!==" "&&(v=m.indexOf(" ",v),v<0&&(v=0)),r=r.length-1){if(G>=r.length){y[q+1]= +1;G>=v.length&&(t[q+1]=1);continue}F-=x}m=r[G].text;if(H=p&&D[q])if(H>0){if(m.length>H)if(y[q+1]=1,n)m=m.substring(0,H);else continue;(H-=m.length)||(H=-1);D[q]=H}else{y[q+1]=1;continue}if(F+m.length+1<=k)m=" "+m,A[q]+=m;else if(n)O=k-F-1,O>0&&(m=" "+m.substring(0,O),A[q]+=m),y[q+1]=1;else{y[q+1]=1;continue}}else{if(y[q])continue;G-=K;if(C[G]){F-=x;y[q]=1;t[q]=1;continue}if(G<=0){if(G<0){y[q]=1;t[q]=1;continue}F-=x}m=r[G].text;if(H=u&&E[q])if(H>0){if(m.length>H)if(y[q]=1,n)m=m.substring(m.length- +H);else continue;(H-=m.length)||(H=-1);E[q]=H}else{y[q]=1;continue}if(F+m.length+1<=k)m+=" ",A[q]=m+A[q];else if(n)O=m.length+1-(k-F),O>=0&&O=v.length-1?ta=1:G0){if(b&&c>b||e)a=a.slice(e,e+b);d&&(a=Ia.call(this,a))}return a}function Ia(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;b1?b:b[0]}B=X.prototype;B.append=function(a,c){return this.add(a,c,!0)};B.update=function(a,c){return this.remove(a).add(a,c)}; +B.remove=function(a){R(a)&&(a=aa(a,this.key));for(var c of this.index.values())c.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(let b of this.tag.values())for(let e of b){c=e[0];const d=e[1],f=d.indexOf(a);f>-1&&(d.length>1?d.splice(f,1):b.delete(c))}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +B.clear=function(){const a=[];for(const c of this.index.values()){const b=c.clear();b.then&&a.push(b)}if(this.tag)for(const c of this.tag.values())c.clear();this.store&&this.store.clear();this.cache&&this.cache.clear();return a.length?Promise.all(a):this};B.contain=function(a){return this.reg.has(a)};B.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};B.get=function(a){return this.store.get(a)||null}; +B.set=function(a,c){typeof a==="object"&&(c=a,a=aa(c,this.key));this.store.set(a,c);return this};B.searchCache=ma;B.export=La;B.import=Ma;wa(X.prototype);function Na(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|0);for(const d of a.entries())e.push(d),e.length===c&&(b.push(e),e=[]);e.length&&b.push(e);return b}function Oa(a,c){c||(c=new Map);for(let b=0,e;b2?b[0]:"";b=b.length>2?b[2]:b[1];if(c){typeof c==="string"&&(c=JSON.parse(c));if(a)return this.index.get(a).import(b,c);switch(b){case "reg":this.fastupdate=!1;this.reg=Sa(c,this.reg);for(let e=0,d;e=0&&d.splice(g,1)}}else Va(this.map,a),this.depth&&Va(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Va(a,c){let b=0;var e=typeof c==="undefined";if(a.constructor===Array)for(let d=0,f,g,h;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;h=1}else{if(h)return 1;b++}}}else for(let d of a.entries())e=d[0],Va(d[1],c)?b++:a.delete(e);return b};const Wa={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};Y.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const n=c.length;if(n){const l=N(),z=N(),x=this.resolution;for(let u=0;u2)for(let w=1,m,v,r,C;w2){for(let w=0,m;ww;f--)if(g=p.substring(w,f),!z[g]){m=this.rtl?d-1-w:w;var h=this.score?this.score(c,p,u,g,m):Xa(x,n,u,d,m);Z(this,z,g,h,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(h=d-1;h>0;h--)if(g=p[this.rtl?d-1-h:h]+g,!z[g]){var k=this.score?this.score(c,p,u,g,h):Xa(x,n,u,d,h);Z(this,z,g,k,a,b)}g=""}case "forward":if(d>1){for(h=0;h1&&ug?0:1),n,u,h-1,k-1),m=this.bidirectional&&p>f;Z(this,l,m?f:p,w,a,b,m?p:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function Z(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=N()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function Xa(a,c,b,e,d){return b&&a>1?c+(e||0)<=a?b+(d||0):(a-1)/(c+(e||0))*(b+(d||0))+1|0:0};Y.prototype.search=function(a,c,b){b||(c||typeof a!=="object"?typeof c==="object"&&(b=c,c=0):(b=a,a=""));if(b&&b.cache)return b.cache=!1,c=this.searchCache(a,c,b),b.cache=!0,c;var e=[],d=0;if(b){a=b.query||a;c=b.limit||c;d=b.offset||0;var f=b.context;var g=b.suggest;var h=!0;var k=b.resolution}typeof h==="undefined"&&(h=!0);f=this.depth&&f!==!1;b=this.encoder.encode(a,!f);a=b.length;c=c||(h?100:0);if(a===1)return g=d,(d=Ya(this,b[0],""))&&d.length?Da.call(this,d,c,g):[];if(a===2&&f&&!g)return g=d, +(d=Ya(this,b[1],b[0]))&&d.length?Da.call(this,d,c,g):[];h=N();var n=0;if(f){var l=b[0];n=1}k||k===0||(k=l?this.L:this.resolution);for(let p,w;n1)b:{e=g;l=b.length;g=[];a=N();for(let p=0,w,m,v,r;p1)c:for(b=[],k=N(),e=g.length,h=e-1;h>=0;h--){if(a=(e=g[h])&&e.length)for(n=0;nc||d?g.slice(d,c+d):g;g=b}else{if(b< +l){l=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}l=g}else if(e===1){c=Da.call(null,b[0],c,d);break a}c=l}return c};function Ya(a,c,b){let e;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};function Y(a,c){if(!this||this.constructor!==Y)return new Y(a);if(a){var b=P(a)?a:a.preset;b&&(a=Object.assign({},Wa[b],a))}else a={};b=a.context;const e=b===!0?{depth:1}:b||{},d=P(a.encoder)?va[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:typeof d==="object"?new la(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&b!=="default"&&b!=="exact"&&b||"strict";this.depth=b==="strict"&&e.depth||0;this.bidirectional=e.bidirectional!==!1;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.L=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new T(b);this.priority=a.priority||4}B=Y.prototype;B.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};B.append=function(a,c){return this.add(a,c,!0)};B.contain=function(a){return this.reg.has(a)}; +B.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)};B.cleanup=function(){if(!this.fastupdate)return this;Va(this.map);this.depth&&Va(this.ctx);return this};B.searchCache=ma;B.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=Ra(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=Na(this.map,this.reg.size);break;case 3:d="ctx";f=Pa(this.ctx,this.reg.size);break;default:return}return Ta.call(this,a,c,d,f,b,e)}; +B.import=function(a,c){if(c)switch(typeof c==="string"&&(c=JSON.parse(c)),a=a.split("."),a[a.length-1]==="json"&&a.pop(),a.length===3&&a.shift(),a=a.length>1?a[1]:a[0],a){case "reg":this.fastupdate=!1;this.reg=Sa(c,this.reg);break;case "map":this.map=Oa(c,this.map);break;case "ctx":this.ctx=Qa(c,this.ctx)}}; +B.serialize=function(a=!0){let c="",b="",e="";if(this.reg.size){let f;for(var d of this.reg.keys())f||(f=typeof d),c+=(c?",":"")+(f==="string"?'"'+d+'"':d);c="index.reg=new Set(["+c+"]);";b=Ua(this.map,f);b="index.map=new Map(["+b+"]);";for(const g of this.ctx.entries()){d=g[0];let h=Ua(g[1],f);h="new Map(["+h+"])";h='["'+d+'",'+h+"]";e+=(e?",":"")+h}e="index.ctx=new Map(["+e+"]);"}return a?"function inject(index){"+c+b+e+"}":c+b+e};wa(Y.prototype);N();export default {Index:Y,Charset:va,Encoder:la,Document:X,Worker:null,Resolver:null,IndexedDB:null,Language:{}}; +export const Index=Y;export const Charset=va;export const Encoder=la;export const Document=X;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.es5.debug.js b/dist/flexsearch.es5.debug.js index 5bb9d76..c693486 100644 --- a/dist/flexsearch.es5.debug.js +++ b/dist/flexsearch.es5.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.202 (ES5/Debug) + * FlexSearch.js v0.8.203 (ES5/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -14,16 +14,16 @@ function aa(a) { }; } function B(a) { - var b = "undefined" != typeof Symbol && Symbol.iterator && a[Symbol.iterator]; + var b = typeof Symbol != "undefined" && Symbol.iterator && a[Symbol.iterator]; if (b) { return b.call(a); } - if ("number" == typeof a.length) { + if (typeof a.length == "number") { return {next:aa(a)}; } throw Error(String(a) + " is not an iterable or ArrayLike"); } -var ca = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) { +var ca = typeof Object.defineProperties == "function" ? Object.defineProperty : function(a, b, c) { if (a == Array.prototype || a == Object.prototype) { return a; } @@ -56,12 +56,12 @@ function H(a, b) { a = a[a.length - 1]; d = c[a]; b = b(d); - b != d && null != b && ca(c, a, {configurable:!0, writable:!0, value:b}); + b != d && b != null && ca(c, a, {configurable:!0, writable:!0, value:b}); } } } var fa; -if ("function" == typeof Object.setPrototypeOf) { +if (typeof Object.setPrototypeOf == "function") { fa = Object.setPrototypeOf; } else { var ha; @@ -85,28 +85,28 @@ if ("function" == typeof Object.setPrototypeOf) { } var ka = fa; function la() { - this.F = !1; + this.D = !1; this.A = null; this.B = void 0; this.h = 1; this.I = 0; - this.D = null; + this.C = null; } function ma(a) { - if (a.F) { + if (a.D) { throw new TypeError("Generator is already running"); } - a.F = !0; + a.D = !0; } la.prototype.H = function(a) { this.B = a; }; function na(a, b) { - a.D = {oa:b, pa:!0}; + a.C = {ja:b, ka:!0}; a.h = a.I; } la.prototype.return = function(a) { - this.D = {return:a}; + this.C = {return:a}; this.h = this.I; }; function K(a, b, c) { @@ -135,7 +135,7 @@ function ra(a, b, c, d) { throw new TypeError("Iterator result " + e + " is not an object"); } if (!e.done) { - return a.h.F = !1, e; + return a.h.D = !1, e; } var f = e.value; } catch (h) { @@ -150,18 +150,18 @@ function sa(a) { try { var b = a.A(a.h); if (b) { - return a.h.F = !1, {value:b.value, done:!1}; + return a.h.D = !1, {value:b.value, done:!1}; } } catch (c) { a.h.B = void 0, na(a.h, c); } } - a.h.F = !1; - if (a.h.D) { - b = a.h.D; - a.h.D = null; - if (b.pa) { - throw b.oa; + a.h.D = !1; + if (a.h.C) { + b = a.h.C; + a.h.C = null; + if (b.ka) { + throw b.ja; } return {value:b.return, done:!0}; } @@ -224,7 +224,7 @@ H("Symbol", function(a) { c.prototype.toString = function() { return this.h; }; - var d = "jscomp_symbol_" + (1E9 * Math.random() >>> 0) + "_", e = 0; + var d = "jscomp_symbol_" + (Math.random() * 1E9 >>> 0) + "_", e = 0; return b; }); H("Symbol.iterator", function(a) { @@ -234,7 +234,7 @@ H("Symbol.iterator", function(a) { a = Symbol("Symbol.iterator"); for (var b = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), c = 0; c < b.length; c++) { var d = ea[b[c]]; - "function" === typeof d && "function" != typeof d.prototype[a] && ca(d.prototype, a, {configurable:!0, writable:!0, value:function() { + typeof d === "function" && typeof d.prototype[a] != "function" && ca(d.prototype, a, {configurable:!0, writable:!0, value:function() { return xa(aa(this)); }}); } @@ -252,8 +252,8 @@ H("Promise", function(a) { this.A = 0; this.B = void 0; this.h = []; - this.N = !1; - var g = this.D(); + this.K = !1; + var g = this.C(); try { h(g.resolve, g.reject); } catch (k) { @@ -272,11 +272,11 @@ H("Promise", function(a) { return a; } c.prototype.A = function(h) { - if (null == this.h) { + if (this.h == null) { this.h = []; var g = this; this.B(function() { - g.F(); + g.D(); }); } this.h.push(h); @@ -285,7 +285,7 @@ H("Promise", function(a) { c.prototype.B = function(h) { e(h, 0); }; - c.prototype.F = function() { + c.prototype.D = function() { for (; this.h && this.h.length;) { var h = this.h; this.h = []; @@ -295,37 +295,37 @@ H("Promise", function(a) { try { k(); } catch (m) { - this.D(m); + this.C(m); } } } this.h = null; }; - c.prototype.D = function(h) { + c.prototype.C = function(h) { this.B(function() { throw h; }); }; - b.prototype.D = function() { + b.prototype.C = function() { function h(m) { return function(l) { k || (k = !0, m.call(g, l)); }; } var g = this, k = !1; - return {resolve:h(this.ja), reject:h(this.F)}; + return {resolve:h(this.ea), reject:h(this.D)}; }; - b.prototype.ja = function(h) { + b.prototype.ea = function(h) { if (h === this) { - this.F(new TypeError("A Promise cannot resolve to itself")); + this.D(new TypeError("A Promise cannot resolve to itself")); } else { if (h instanceof b) { - this.la(h); + this.ga(h); } else { a: { switch(typeof h) { case "object": - var g = null != h; + var g = h != null; break a; case "function": g = !0; @@ -334,59 +334,59 @@ H("Promise", function(a) { g = !1; } } - g ? this.ia(h) : this.I(h); + g ? this.da(h) : this.I(h); } } }; - b.prototype.ia = function(h) { + b.prototype.da = function(h) { var g = void 0; try { g = h.then; } catch (k) { - this.F(k); + this.D(k); return; } - "function" == typeof g ? this.ma(g, h) : this.I(h); + typeof g == "function" ? this.ha(g, h) : this.I(h); }; - b.prototype.F = function(h) { - this.O(2, h); + b.prototype.D = function(h) { + this.L(2, h); }; b.prototype.I = function(h) { - this.O(1, h); + this.L(1, h); }; - b.prototype.O = function(h, g) { - if (0 != this.A) { + b.prototype.L = function(h, g) { + if (this.A != 0) { throw Error("Cannot settle(" + h + ", " + g + "): Promise already settled in state" + this.A); } this.A = h; this.B = g; - 2 === this.A && this.ka(); - this.U(); + this.A === 2 && this.fa(); + this.P(); }; - b.prototype.ka = function() { + b.prototype.fa = function() { var h = this; e(function() { - if (h.ha()) { + if (h.ca()) { var g = ea.console; - "undefined" !== typeof g && g.error(h.B); + typeof g !== "undefined" && g.error(h.B); } }, 1); }; - b.prototype.ha = function() { - if (this.N) { + b.prototype.ca = function() { + if (this.K) { return !1; } var h = ea.CustomEvent, g = ea.Event, k = ea.dispatchEvent; - if ("undefined" === typeof k) { + if (typeof k === "undefined") { return !0; } - "function" === typeof h ? h = new h("unhandledrejection", {cancelable:!0}) : "function" === typeof g ? h = new g("unhandledrejection", {cancelable:!0}) : (h = ea.document.createEvent("CustomEvent"), h.initCustomEvent("unhandledrejection", !1, !0, h)); + typeof h === "function" ? h = new h("unhandledrejection", {cancelable:!0}) : typeof g === "function" ? h = new g("unhandledrejection", {cancelable:!0}) : (h = ea.document.createEvent("CustomEvent"), h.initCustomEvent("unhandledrejection", !1, !0, h)); h.promise = this; h.reason = this.B; return k(h); }; - b.prototype.U = function() { - if (null != this.h) { + b.prototype.P = function() { + if (this.h != null) { for (var h = 0; h < this.h.length; ++h) { f.A(this.h[h]); } @@ -394,12 +394,12 @@ H("Promise", function(a) { } }; var f = new c(); - b.prototype.la = function(h) { - var g = this.D(); - h.V(g.resolve, g.reject); + b.prototype.ga = function(h) { + var g = this.C(); + h.R(g.resolve, g.reject); }; - b.prototype.ma = function(h, g) { - var k = this.D(); + b.prototype.ha = function(h, g) { + var k = this.C(); try { h.call(g, k.resolve, k.reject); } catch (m) { @@ -408,11 +408,11 @@ H("Promise", function(a) { }; b.prototype.then = function(h, g) { function k(n, q) { - return "function" == typeof n ? function(t) { + return typeof n == "function" ? function(t) { try { m(n(t)); - } catch (v) { - l(v); + } catch (u) { + l(u); } } : q; } @@ -420,13 +420,13 @@ H("Promise", function(a) { m = n; l = q; }); - this.V(k(h, m), k(g, l)); + this.R(k(h, m), k(g, l)); return p; }; b.prototype.catch = function(h) { return this.then(void 0, h); }; - b.prototype.V = function(h, g) { + b.prototype.R = function(h, g) { function k() { switch(m.A) { case 1: @@ -440,8 +440,8 @@ H("Promise", function(a) { } } var m = this; - null == this.h ? f.A(k) : this.h.push(k); - this.N = !0; + this.h == null ? f.A(k) : this.h.push(k); + this.K = !0; }; b.resolve = d; b.reject = function(h) { @@ -452,7 +452,7 @@ H("Promise", function(a) { b.race = function(h) { return new b(function(g, k) { for (var m = B(h), l = m.next(); !l.done; l = m.next()) { - d(l.value).V(g, k); + d(l.value).R(g, k); } }); }; @@ -460,15 +460,15 @@ H("Promise", function(a) { var g = B(h), k = g.next(); return k.done ? d([]) : new b(function(m, l) { function p(t) { - return function(v) { - n[t] = v; + return function(u) { + n[t] = u; q--; - 0 == q && m(n); + q == 0 && m(n); }; } var n = [], q = 0; do { - n.push(void 0), q++, d(k.value).V(p(n.length - 1), l), k = g.next(); + n.push(void 0), q++, d(k.value).R(p(n.length - 1), l), k = g.next(); } while (!k.done); }); }; @@ -520,7 +520,7 @@ H("WeakMap", function(a) { } function d(k) { var m = typeof k; - return "object" === m && null !== k || "function" === m; + return m === "object" && k !== null || m === "function"; } function e(k) { if (!za(k, h)) { @@ -544,12 +544,12 @@ H("WeakMap", function(a) { } try { var k = Object.seal({}), m = Object.seal({}), l = new a([[k, 2], [m, 3]]); - if (2 != l.get(k) || 3 != l.get(m)) { + if (l.get(k) != 2 || l.get(m) != 3) { return !1; } l.delete(k); l.set(m, 4); - return !l.has(k) && 4 == l.get(m); + return !l.has(k) && l.get(m) == 4; } catch (p) { return !1; } @@ -586,14 +586,14 @@ H("WeakMap", function(a) { H("Map", function(a) { function b() { var g = {}; - return g.K = g.next = g.head = g; + return g.J = g.next = g.head = g; } function c(g, k) { var m = g[1]; return xa(function() { if (m) { for (; m.head != g[1];) { - m = m.K; + m = m.J; } for (; m.next != m.head;) { return m = m.next, {done:!1, value:k(m)}; @@ -605,7 +605,7 @@ H("Map", function(a) { } function d(g, k) { var m = k && typeof k; - "object" == m || "function" == m ? f.has(k) ? m = f.get(k) : (m = "" + ++h, f.set(k, m)) : m = "p_" + k; + m == "object" || m == "function" ? f.has(k) ? m = f.get(k) : (m = "" + ++h, f.set(k, m)) : m = "p_" + k; var l = g[0][m]; if (l && za(g[0], m)) { for (g = 0; g < l.length; g++) { @@ -629,20 +629,20 @@ H("Map", function(a) { } } if (function() { - if (!a || "function" != typeof a || !a.prototype.entries || "function" != typeof Object.seal) { + if (!a || typeof a != "function" || !a.prototype.entries || typeof Object.seal != "function") { return !1; } try { var g = Object.seal({x:4}), k = new a(B([[g, "s"]])); - if ("s" != k.get(g) || 1 != k.size || k.get({x:4}) || k.set({x:4}, "t") != k || 2 != k.size) { + if (k.get(g) != "s" || k.size != 1 || k.get({x:4}) || k.set({x:4}, "t") != k || k.size != 2) { return !1; } var m = k.entries(), l = m.next(); - if (l.done || l.value[0] != g || "s" != l.value[1]) { + if (l.done || l.value[0] != g || l.value[1] != "s") { return !1; } l = m.next(); - return l.done || 4 != l.value[0].x || "t" != l.value[1] || !m.next().done ? !1 : !0; + return l.done || l.value[0].x != 4 || l.value[1] != "t" || !m.next().done ? !1 : !0; } catch (p) { return !1; } @@ -651,19 +651,19 @@ H("Map", function(a) { } var f = new WeakMap(); e.prototype.set = function(g, k) { - g = 0 === g ? 0 : g; + g = g === 0 ? 0 : g; var m = d(this, g); m.list || (m.list = this[0][m.id] = []); - m.G ? m.G.value = k : (m.G = {next:this[1], K:this[1].K, head:this[1], key:g, value:k}, m.list.push(m.G), this[1].K.next = m.G, this[1].K = m.G, this.size++); + m.G ? m.G.value = k : (m.G = {next:this[1], J:this[1].J, head:this[1], key:g, value:k}, m.list.push(m.G), this[1].J.next = m.G, this[1].J = m.G, this.size++); return this; }; e.prototype.delete = function(g) { g = d(this, g); - return g.G && g.list ? (g.list.splice(g.index, 1), g.list.length || delete this[0][g.id], g.G.K.next = g.G.next, g.G.next.K = g.G.K, g.G.head = null, this.size--, !0) : !1; + return g.G && g.list ? (g.list.splice(g.index, 1), g.list.length || delete this[0][g.id], g.G.J.next = g.G.next, g.G.next.J = g.G.J, g.G.head = null, this.size--, !0) : !1; }; e.prototype.clear = function() { this[0] = {}; - this[1] = this[1].K = b(); + this[1] = this[1].J = b(); this.size = 0; }; e.prototype.has = function(g) { @@ -708,12 +708,12 @@ H("Set", function(a) { this.size = this.h.size; } if (function() { - if (!a || "function" != typeof a || !a.prototype.entries || "function" != typeof Object.seal) { + if (!a || typeof a != "function" || !a.prototype.entries || typeof Object.seal != "function") { return !1; } try { var c = Object.seal({x:4}), d = new a(B([c])); - if (!d.has(c) || 1 != d.size || d.add(c) != d || 1 != d.size || d.add({x:4}) != d || 2 != d.size) { + if (!d.has(c) || d.size != 1 || d.add(c) != d || d.size != 1 || d.add({x:4}) != d || d.size != 2) { return !1; } var e = d.entries(), f = e.next(); @@ -721,7 +721,7 @@ H("Set", function(a) { return !1; } f = e.next(); - return f.done || f.value[0] == c || 4 != f.value[0].x || f.value[1] != f.value[0] ? !1 : e.next().done; + return f.done || f.value[0] == c || f.value[0].x != 4 || f.value[1] != f.value[0] ? !1 : e.next().done; } catch (h) { return !1; } @@ -729,7 +729,7 @@ H("Set", function(a) { return a; } b.prototype.add = function(c) { - c = 0 === c ? 0 : c; + c = c === 0 ? 0 : c; this.h.set(c, c); this.size = this.h.size; return this; @@ -764,7 +764,7 @@ H("Set", function(a) { }); H("Object.is", function(a) { return a ? a : function(b, c) { - return b === c ? 0 !== b || 1 / b === 1 / c : b !== b && c !== c; + return b === c ? b !== 0 || 1 / b === 1 / c : b !== b && c !== c; }; }); H("Array.prototype.includes", function(a) { @@ -773,7 +773,7 @@ H("Array.prototype.includes", function(a) { d instanceof String && (d = String(d)); var e = d.length; c = c || 0; - for (0 > c && (c = Math.max(c + e, 0)); c < e; c++) { + for (c < 0 && (c = Math.max(c + e, 0)); c < e; c++) { var f = d[c]; if (f === b || Object.is(f, b)) { return !0; @@ -784,13 +784,13 @@ H("Array.prototype.includes", function(a) { }); H("String.prototype.includes", function(a) { return a ? a : function(b, c) { - if (null == this) { + if (this == null) { throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); } if (b instanceof RegExp) { throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); } - return -1 !== this.indexOf(b, c || 0); + return this.indexOf(b, c || 0) !== -1; }; }); H("Array.prototype.entries", function(a) { @@ -800,7 +800,7 @@ H("Array.prototype.entries", function(a) { }); }; }); -var Aa = "function" == typeof Object.assign ? Object.assign : function(a, b) { +var Aa = typeof Object.assign == "function" ? Object.assign : function(a, b) { for (var c = 1; c < arguments.length; c++) { var d = arguments[c]; if (d) { @@ -816,10 +816,10 @@ H("Object.assign", function(a) { }); H("Array.prototype.flat", function(a) { return a ? a : function(b) { - b = void 0 === b ? 1 : b; + b = b === void 0 ? 1 : b; var c = []; Array.prototype.forEach.call(this, function(d) { - Array.isArray(d) && 0 < b ? (d = Array.prototype.flat.call(d, b - 1), c.push.apply(c, d)) : c.push(d); + Array.isArray(d) && b > 0 ? (d = Array.prototype.flat.call(d, b - 1), c.push.apply(c, d)) : c.push(d); }); return c; }; @@ -839,10 +839,10 @@ H("Promise.prototype.finally", function(a) { }); function P(a, b, c) { var d = typeof c, e = typeof a; - if ("undefined" !== d) { - if ("undefined" !== e) { + if (d !== "undefined") { + if (e !== "undefined") { if (c) { - if ("function" === e && d === e) { + if (e === "function" && d === e) { return function(f) { return a(c(f)); }; @@ -874,19 +874,19 @@ function P(a, b, c) { } return c; } - return "undefined" === e ? b : a; + return e === "undefined" ? b : a; } function Ba(a, b) { - return "undefined" === typeof a ? b : a; + return typeof a === "undefined" ? b : a; } function S() { return Object.create(null); } function T(a) { - return "string" === typeof a; + return typeof a === "string"; } function Ca(a) { - return "object" === typeof a; + return typeof a === "object"; } function Da(a) { var b = []; @@ -908,7 +908,7 @@ function Ea(a, b) { } ;var Fa = /[^\p{L}\p{N}]+/u, Ga = /(\d{3})/g, Ha = /(\D)(\d{3})/g, Ia = /(\d{3})(\D)/g, Ja = /[\u0300-\u036f]/g; function Ka(a) { - a = void 0 === a ? {} : a; + a = a === void 0 ? {} : a; if (!this || this.constructor !== Ka) { var b = Function.prototype.bind, c = b.apply, d = [null], e = d.concat; if (arguments instanceof Array) { @@ -934,8 +934,8 @@ w = Ka.prototype; w.assign = function(a) { this.normalize = P(a.normalize, !0, this.normalize); var b = a.include, c = b || a.exclude || a.split; - if (c || "" === c) { - if ("object" === typeof c && c.constructor !== RegExp) { + if (c || c === "") { + if (typeof c === "object" && c.constructor !== RegExp) { var d = ""; var e = !b; b || (d += "\\p{Z}"); @@ -945,7 +945,7 @@ w.assign = function(a) { c.punctuation && (d += "\\p{P}"); c.control && (d += "\\p{C}"); if (c = c.char) { - d += "object" === typeof c ? c.join("") : c; + d += typeof c === "object" ? c.join("") : c; } try { this.split = new RegExp("[" + (b ? "^" : "") + d + "]+", "u"); @@ -953,7 +953,7 @@ w.assign = function(a) { console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = c, e = !1 === c || 2 > "a1a".split(c).length; + this.split = c, e = c === !1 || "a1a".split(c).length < 2; } this.numeric = P(a.numeric, e); } else { @@ -967,7 +967,7 @@ w.assign = function(a) { this.prepare = P(a.prepare, null, this.prepare); this.finalize = P(a.finalize, null, this.finalize); c = a.filter; - this.filter = "function" === typeof c ? c : P(c && new Set(c), null, this.filter); + this.filter = typeof c === "function" ? c : P(c && new Set(c), null, this.filter); this.dedupe = P(a.dedupe, !0, this.dedupe); this.matcher = P((c = a.matcher) && new Map(c), null, this.matcher); this.mapper = P((c = a.mapper) && new Map(c), null, this.mapper); @@ -977,12 +977,12 @@ w.assign = function(a) { this.maxlength = P(a.maxlength, 1024, this.maxlength); this.rtl = P(a.rtl, !1, this.rtl); if (this.cache = c = P(a.cache, !0, this.cache)) { - this.F = null, this.U = "number" === typeof c ? c : 2e5, this.B = new Map(), this.D = new Map(), this.I = this.H = 128; + this.D = null, this.P = typeof c === "number" ? c : 2e5, this.B = new Map(), this.C = new Map(), this.I = this.H = 128; } this.h = ""; - this.N = null; + this.K = null; this.A = ""; - this.O = null; + this.L = null; if (this.matcher) { for (a = B(this.matcher.keys()), b = a.next(); !b.done; b = a.next()) { this.h += (this.h ? "|" : "") + b.value; @@ -999,20 +999,20 @@ w.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; - this.O = null; + this.L = null; this.cache && La(this); return this; }; w.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); + typeof a === "function" ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); this.cache && La(this); return this; }; w.addMapper = function(a, b) { - if ("object" === typeof a) { + if (typeof a === "object") { return this.addReplacer(a, b); } - if (1 < a.length) { + if (a.length > 1) { return this.addMatcher(a, b); } this.mapper || (this.mapper = new Map()); @@ -1021,21 +1021,21 @@ w.addMapper = function(a, b) { return this; }; w.addMatcher = function(a, b) { - if ("object" === typeof a) { + if (typeof a === "object") { return this.addReplacer(a, b); } - if (2 > a.length && (this.dedupe || this.mapper)) { + if (a.length < 2 && (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.N = null; + this.K = null; this.cache && La(this); return this; }; w.addReplacer = function(a, b) { - if ("string" === typeof a) { + if (typeof a === "string") { return this.addMatcher(a, b); } this.replacer || (this.replacer = []); @@ -1046,18 +1046,18 @@ w.addReplacer = function(a, b) { w.encode = function(a, b) { var c = this; if (this.cache && a.length <= this.H) { - if (this.F) { + if (this.D) { if (this.B.has(a)) { return this.B.get(a); } } else { - this.F = setTimeout(La, 50, this); + this.D = setTimeout(La, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = Ja ? a.normalize("NFKD").replace(Ja, "").toLowerCase() : a.toLowerCase()); + this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = Ja ? a.normalize("NFKD").replace(Ja, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(Ha, "$1 $2").replace(Ia, "$1 $2").replace(Ga, "$1 ")); - for (var d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer), e = [], f = S(), h, g, k = this.split || "" === this.split ? a.split(this.split) : [a], m = 0, l = void 0, p = void 0; m < k.length; m++) { + this.numeric && a.length > 3 && (a = a.replace(Ha, "$1 $2").replace(Ia, "$1 $2").replace(Ga, "$1 ")); + for (var d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer), e = [], f = S(), h, g, k = this.split || this.split === "" ? a.split(this.split) : [a], m = 0, l = void 0, p = void 0; m < k.length; m++) { if ((l = p = k[m]) && !(l.length < this.minlength || l.length > this.maxlength)) { if (b) { if (f[l]) { @@ -1073,33 +1073,33 @@ w.encode = function(a, b) { if (d) { e.push(l); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(l) : !this.filter.has(l))) { + if (!this.filter || (typeof this.filter === "function" ? this.filter(l) : !this.filter.has(l))) { if (this.cache && l.length <= this.I) { - if (this.F) { - var n = this.D.get(l); - if (n || "" === n) { + if (this.D) { + var n = this.C.get(l); + if (n || n === "") { n && e.push(n); continue; } } else { - this.F = setTimeout(La, 50, this); + this.D = setTimeout(La, 50, this); } } if (this.stemmer) { - for (this.O || (this.O = new RegExp("(?!^)(" + this.A + ")$")), n = void 0; n !== l && 2 < l.length;) { - n = l, l = l.replace(this.O, function(z) { + for (this.L || (this.L = new RegExp("(?!^)(" + this.A + ")$")), n = void 0; n !== l && l.length > 2;) { + n = l, l = l.replace(this.L, function(z) { return c.stemmer.get(z); }); } } - if (l && (this.mapper || this.dedupe && 1 < l.length)) { + if (l && (this.mapper || this.dedupe && l.length > 1)) { n = ""; - for (var q = 0, t = "", v = void 0, u = void 0; q < l.length; q++) { - v = l.charAt(q), v === t && this.dedupe || ((u = this.mapper && this.mapper.get(v)) || "" === u ? u === t && this.dedupe || !(t = u) || (n += u) : n += t = v); + for (var q = 0, t = "", u = void 0, v = void 0; q < l.length; q++) { + u = l.charAt(q), u === t && this.dedupe || ((v = this.mapper && this.mapper.get(u)) || v === "" ? v === t && this.dedupe || !(t = v) || (n += v) : n += t = u); } l = n; } - this.matcher && 1 < l.length && (this.N || (this.N = new RegExp("(" + this.h + ")", "g")), l = l.replace(this.N, function(z) { + this.matcher && l.length > 1 && (this.K || (this.K = new RegExp("(" + this.h + ")", "g")), l = l.replace(this.K, function(z) { return c.matcher.get(z); })); if (l && this.replacer) { @@ -1107,7 +1107,7 @@ w.encode = function(a, b) { l = l.replace(this.replacer[n], this.replacer[n + 1]); } } - this.cache && p.length <= this.I && (this.D.set(p, l), this.D.size > this.U && (this.D.clear(), this.I = this.I / 1.1 | 0)); + this.cache && p.length <= this.I && (this.C.set(p, l), this.C.size > this.P && (this.C.clear(), this.I = this.I / 1.1 | 0)); if (l) { if (l !== p) { if (b) { @@ -1129,21 +1129,21 @@ w.encode = function(a, b) { } } this.finalize && (e = this.finalize(e) || e); - this.cache && a.length <= this.H && (this.B.set(a, e), this.B.size > this.U && (this.B.clear(), this.H = this.H / 1.1 | 0)); + this.cache && a.length <= this.H && (this.B.set(a, e), this.B.size > this.P && (this.B.clear(), this.H = this.H / 1.1 | 0)); return e; }; function La(a) { - a.F = null; + a.D = null; a.B.clear(); - a.D.clear(); + a.C.clear(); } ;function Ma(a, b, c) { - c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : c = a); + c || (b || typeof a !== "object" ? typeof b === "object" && (c = b, b = 0) : c = a); c && (a = c.query || a, b = c.limit || b); var d = "" + (b || 0); if (c) { var e = c; - d += (e.offset || 0) + !!e.context + !!e.suggest + (!1 !== e.resolve) + (e.resolution || this.resolution) + (e.boost || 0); + d += (e.offset || 0) + !!e.context + !!e.suggest + (e.resolve !== !1) + (e.resolution || this.resolution) + (e.boost || 0); } a = ("" + a).toLowerCase(); this.cache || (this.cache = new Na()); @@ -1158,7 +1158,7 @@ function La(a) { return e; } function Na(a) { - this.limit = a && !0 !== a ? a : 1000; + this.limit = a && a !== !0 ? a : 1000; this.cache = new Map(); this.h = ""; } @@ -1189,7 +1189,7 @@ var Ra = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t" var Ta = {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 Ua = {Exact:Oa, Default:Pa, Normalize:Pa, LatinBalance:{mapper:Qa}, LatinAdvanced:{mapper:Qa, matcher:Ra, replacer:Sa}, LatinExtra:{mapper:Qa, replacer:Sa.concat([/(?!^)[aeo]/g, ""]), matcher:Ra}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (var b = 0; b < a.length; b++) { - for (var c = a[b], d = c.charAt(0), e = Ta[d], f = 1, h; f < c.length && (h = c.charAt(f), "h" === h || "w" === h || !(h = Ta[h]) || h === e || (d += h, e = h, 4 !== d.length)); f++) { + for (var c = a[b], d = c.charAt(0), e = Ta[d], f = 1, h; f < c.length && (h = c.charAt(f), h === "h" || h === "w" || !(h = Ta[h]) || h === e || (d += h, e = h, d.length !== 4)); f++) { } a[b] = d; } @@ -1218,28 +1218,28 @@ function Wa(a) { this.length = a ? a.length : 0; var b = this; return new Proxy([], {get:function(c, d) { - if ("length" === d) { + if (d === "length") { return b.length; } - if ("push" === d) { + if (d === "push") { return function(e) { b.index[b.index.length - 1].push(e); b.length++; }; } - if ("pop" === d) { + if (d === "pop") { return function() { if (b.length) { return b.length--, b.index[b.index.length - 1].pop(); } }; } - if ("indexOf" === d) { + if (d === "indexOf") { return function(e) { for (var f = 0, h = 0, g, k; h < b.index.length; h++) { g = b.index[h]; k = g.indexOf(e); - if (0 <= k) { + if (k >= 0) { return f + k; } f += g.length; @@ -1247,7 +1247,7 @@ function Wa(a) { return -1; }; } - if ("includes" === d) { + if (d === "includes") { return function(e) { for (var f = 0; f < b.index.length; f++) { if (b.index[f].includes(e)) { @@ -1257,24 +1257,24 @@ function Wa(a) { return !1; }; } - if ("slice" === d) { + if (d === "slice") { return function(e, f) { return Va(b, e || 0, f || b.length, !1); }; } - if ("splice" === d) { + if (d === "splice") { return function(e, f) { return Va(b, e || 0, f || b.length, !0); }; } - if ("constructor" === d) { + if (d === "constructor") { return Array; } - if ("symbol" !== typeof d) { - return (c = b.index[d / Math.pow(2, 31) | 0]) && c[d]; + if (typeof d !== "symbol") { + return (c = b.index[d / 2147483648 | 0]) && c[d]; } }, set:function(c, d, e) { - c = d / Math.pow(2, 31) | 0; + c = d / 2147483648 | 0; (b.index[c] || (b.index[c] = []))[d] = e; b.length++; return !0; @@ -1283,20 +1283,17 @@ function Wa(a) { Wa.prototype.clear = function() { this.index.length = 0; }; -Wa.prototype.destroy = function() { - this.proxy = this.index = null; -}; Wa.prototype.push = function() { }; function Xa(a) { - a = void 0 === a ? 8 : a; + a = a === void 0 ? 8 : a; if (!this || this.constructor !== Xa) { return new Xa(a); } this.index = S(); this.h = []; this.size = 0; - 32 < a ? (this.A = Ya, this.B = BigInt(a)) : (this.A = Za, this.B = a); + a > 32 ? (this.A = Ya, this.B = BigInt(a)) : (this.A = Za, this.B = a); } Xa.prototype.get = function(a) { var b = this.A(a); @@ -1307,14 +1304,14 @@ Xa.prototype.set = function(a, b) { d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.h.push(d), this.size++); }; function X(a) { - a = void 0 === a ? 8 : a; + a = a === void 0 ? 8 : a; if (!this || this.constructor !== X) { return new X(a); } this.index = S(); this.h = []; this.size = 0; - 32 < a ? (this.A = Ya, this.B = BigInt(a)) : (this.A = Za, this.B = a); + a > 32 ? (this.A = Ya, this.B = BigInt(a)) : (this.A = Za, this.B = a); } X.prototype.add = function(a) { var b = this.A(a), c = this.index[b]; @@ -1414,13 +1411,13 @@ w.entries = X.prototype.entries = function bb() { }; function Za(a) { var b = Math.pow(2, this.B) - 1; - if ("number" == typeof a) { + if (typeof a == "number") { return a & b; } for (var c = 0, d = this.B + 1, e = 0; e < a.length; e++) { c = (c * d ^ a.charCodeAt(e)) & b; } - return 32 === this.B ? c + Math.pow(2, 31) : c; + return this.B === 32 ? c + 2147483648 : c; } function Ya() { throw Error("The keystore is limited to 32 for EcmaScript5"); @@ -1447,14 +1444,14 @@ function eb(a) { }g.h = 0; break; case 2: - if ("export" === b) { - if (!db.export || "function" !== typeof db.export) { + if (b === "export") { + if (!db.export || typeof db.export !== "function") { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } d[1] ? (d[0] = db.export, d[2] = 0, d[3] = 1) : d = null; } - if ("import" === b) { - if (!db.import || "function" !== typeof db.import) { + if (b === "import") { + if (!db.import || typeof db.import !== "function") { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } if (!d[0]) { @@ -1480,13 +1477,13 @@ function eb(a) { case 9: f = g.B; case 8: - "search" === b && f.result && (f = f.result); + b === "search" && f.result && (f = f.result); g.h = 5; break; case 11: h = g.B, cb.import(d[0], h); case 5: - postMessage("search" === b ? {id:c, msg:f} : {id:c}), g.h = 0; + postMessage(b === "search" ? {id:c, msg:f} : {id:c}), g.h = 0; } }); } @@ -1505,7 +1502,7 @@ function kb() { function gb(a) { this[a + "Async"] = function() { var b = arguments, c = b[b.length - 1]; - if ("function" === typeof c) { + if (typeof c === "function") { var d = c; delete b[b.length - 1]; } @@ -1540,7 +1537,7 @@ function mb(a, b) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { return new Promise(function(m) { - 1e9 < lb && (lb = 0); + lb > 1e9 && (lb = 0); f.h[++lb] = function() { m(f); }; @@ -1554,13 +1551,13 @@ function mb(a, b) { } console.warn("Worker is not available on this platform. Please report on Github: https://github.com/nextapps-de/flexsearch/issues"); } - a = void 0 === a ? {} : a; + a = a === void 0 ? {} : a; if (!this || this.constructor !== mb) { return new mb(a); } - var d = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + var d = typeof self !== "undefined" ? self._factory : typeof window !== "undefined" ? window._factory : null; d && (d = d.toString()); - var e = "undefined" === typeof window, f = this, h = nb(d, e, a.worker); + var e = typeof window === "undefined", f = this, h = nb(d, e, a.worker); return h.then ? h.then(function(g) { return c.call(f, g); }) : c.call(this, h); @@ -1578,13 +1575,13 @@ fb(mb.prototype); function ob(a) { mb.prototype[a] = function() { var b = this, c = [].slice.call(arguments), d = c[c.length - 1]; - if ("function" === typeof d) { + if (typeof d === "function") { var e = d; c.pop(); } d = new Promise(function(f) { - "export" === a && "function" === typeof c[0] && (c[0] = null); - 1e9 < lb && (lb = 0); + a === "export" && typeof c[0] === "function" && (c[0] = null); + lb > 1e9 && (lb = 0); b.h[++lb] = f; b.worker.postMessage({task:a, id:lb, args:c}); }); @@ -1592,39 +1589,39 @@ function ob(a) { }; } function nb(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=" + eb.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", + return b ? typeof module !== "undefined" ? 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=" + eb.toString()], {type:"text/javascript"}))) : new window.Worker(typeof c === "string" ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } ;pb.prototype.add = function(a, b, c) { Ca(a) && (b = a, a = Ea(b, this.key)); - if (b && (a || 0 === a)) { + if (b && (a || a === 0)) { if (!c && this.reg.has(a)) { return this.update(a, b); } for (var d = 0, e; d < this.field.length; d++) { - e = this.M[d]; + e = this.B[d]; var f = this.index.get(this.field[d]); - if ("function" === typeof e) { + if (typeof e === "function") { (e = e(b)) && f.add(a, e, !1, !0); } else { - var h = e.S; + var h = e.O; if (!h || h(b)) { - e.constructor === String ? e = ["" + e] : T(e) && (e = [e]), qb(b, e, this.T, 0, f, a, e[0], c); + e.constructor === String ? e = ["" + e] : T(e) && (e = [e]), qb(b, e, this.C, 0, f, a, e[0], c); } } } if (this.tag) { - for (d = 0; d < this.L.length; d++) { - h = this.L[d]; - var g = this.ba[d]; + for (d = 0; d < this.A.length; d++) { + h = this.A[d]; + var g = this.D[d]; f = this.tag.get(g); e = S(); - if ("function" === typeof h) { + if (typeof h === "function") { if (h = h(b), !h) { continue; } } else { - var k = h.S; + var k = h.O; if (k && !k(b)) { continue; } @@ -1639,7 +1636,7 @@ function nb(a, b, c) { var l; (l = f.get(m)) ? k = l : f.set(m, k = []); if (!c || !k.includes(a)) { - if (k.length === Math.pow(2, 31) - 1) { + if (k.length === 2147483647) { l = new Wa(k); if (this.fastupdate) { for (var p = B(this.reg.values()), n = p.next(); !n.done; n = p.next()) { @@ -1659,17 +1656,17 @@ function nb(a, b, c) { } } if (this.store && (!c || !this.store.has(a))) { - if (this.J) { + if (this.h) { var q = S(); - for (c = 0; c < this.J.length; c++) { - if (d = this.J[c], f = d.S, !f || f(b)) { + for (c = 0; c < this.h.length; c++) { + if (d = this.h[c], f = d.O, !f || f(b)) { f = void 0; - if ("function" === typeof d) { + if (typeof d === "function") { f = d(b); if (!f) { continue; } - d = [d.na]; + d = [d.ia]; } else if (T(d) || d.constructor === String) { q[d] = b[d]; continue; @@ -1726,7 +1723,7 @@ function qb(a, b, c, d, e, f, h, g) { if (!a.length) { return a; } - if (1 === a.length) { + if (a.length === 1) { return a = a[0], a = c || a.length > b ? a.slice(c, c + b) : a, d ? tb.call(this, a) : a; } for (var e = [], f = 0, h = void 0, g = void 0; f < a.length; f++) { @@ -1751,7 +1748,7 @@ function qb(a, b, c, d, e, f, h, g) { } } } - e = 1 < e.length ? [].concat.apply([], e) : e[0]; + e = e.length > 1 ? [].concat.apply([], e) : e[0]; return d ? tb.call(this, e) : e; } ;function ub(a, b, c, d) { @@ -1759,12 +1756,12 @@ function qb(a, b, c, d, e, f, h, g) { if (e[0] && e[0].query) { return a[b].apply(a, e); } - if (!("and" !== b && "not" !== b || a.result.length || a.await || e.suggest)) { - return 1 < d.length && (e = d[d.length - 1]), (d = e.resolve) ? a.await || a.result : a; + if (!(b !== "and" && b !== "not" || a.result.length || a.await || e.suggest)) { + return d.length > 1 && (e = d[d.length - 1]), (d = e.resolve) ? a.await || a.result : a; } var f = [], h = 0, g = 0, k, m; b = {}; - for (e = 0; e < d.length; b = {aa:void 0, $:void 0, ca:void 0, fa:void 0}, e++) { + for (e = 0; e < d.length; b = {X:void 0, W:void 0, Y:void 0, aa:void 0}, e++) { var l = d[e]; if (l) { var p = void 0; @@ -1778,57 +1775,57 @@ function qb(a, b, c, d, e, f, h, g) { var n = l.suggest; var q = ((m = (k = l.resolve) && l.highlight) || l.enrich) && k; p = l.queue; - b.ca = l.async || p; + b.Y = l.async || p; var t = l.index; t ? a.index || (a.index = t) : t = a.index; if (l.query || l.tag) { if (!t) { throw Error("Resolver can't apply because the corresponding Index was never specified"); } - var v = l.field || l.pluck; - if (v) { - l.query && (a.query = l.query, a.field = v); + var u = l.field || l.pluck; + if (u) { + l.query && (a.query = l.query, a.field = u); if (!t.index) { throw Error("Resolver can't apply because the corresponding Document Index was not specified"); } - t = t.index.get(v); + t = t.index.get(u); if (!t) { - throw Error("Resolver can't apply because the specified Document Field '" + v + "' was not found"); + throw Error("Resolver can't apply because the specified Document Field '" + u + "' was not found"); } } - if (p && (u || a.await)) { - var u = 1; - b.aa = void 0; - b.fa = a.C.length; - b.$ = new Promise(function(x) { + if (p && (v || a.await)) { + var v = 1; + b.X = void 0; + b.aa = a.F.length; + b.W = new Promise(function(x) { return function(C) { - x.aa = C; + x.X = C; }; }(b)); (function(x) { return function(C, D) { - x.$.H = function() { + x.W.H = function() { D.index = null; D.resolve = !1; - var r = x.ca ? C.searchAsync(D) : C.search(D); + var r = x.Y ? C.searchAsync(D) : C.search(D); if (r.then) { return r.then(function(y) { - a.C[x.fa] = y = y.result || y; - (0,x.aa)(y); + a.F[x.aa] = y = y.result || y; + (0,x.X)(y); return y; }); } r = r.result || r; - (0,x.aa)(r); + (0,x.X)(r); return r; }; }; })(b)(t, Object.assign({}, l)); - a.C.push(b.$); - f[e] = b.$; + a.F.push(b.W); + f[e] = b.W; continue; } else { - l.resolve = !1, l.index = null, p = b.ca ? t.searchAsync(l) : t.search(l), l.resolve = k, l.index = t; + l.resolve = !1, l.index = null, p = b.Y ? t.searchAsync(l) : t.search(l), l.resolve = k, l.index = t; } } else if (l.and) { p = vb(l, "and", t); @@ -1842,20 +1839,20 @@ function qb(a, b, c, d, e, f, h, g) { continue; } } - p.await ? (u = 1, p = p.await) : p.then ? (u = 1, p = p.then(function(x) { + p.await ? (v = 1, p = p.await) : p.then ? (v = 1, p = p.then(function(x) { return x.result || x; })) : p = p.result || p; f[e] = p; } } - u && !a.await && (a.await = new Promise(function(x) { + v && !a.await && (a.await = new Promise(function(x) { a.return = x; })); - if (u) { + if (v) { var z = Promise.all(f).then(function(x) { - for (var C = 0; C < a.C.length; C++) { - if (a.C[C] === z) { - a.C[C] = function() { + for (var C = 0; C < a.F.length; C++) { + if (a.F[C] === z) { + a.F[C] = function() { return c.call(a, x, h, g, q, k, n, m); }; break; @@ -1863,9 +1860,9 @@ function qb(a, b, c, d, e, f, h, g) { } wb(a); }); - a.C.push(z); + a.F.push(z); } else if (a.await) { - a.C.push(function() { + a.F.push(function() { return c.call(a, f, h, g, q, k, n, m); }); } else { @@ -1878,14 +1875,14 @@ function vb(a, b, c) { var d = a[0] || a; d.index || (d.index = c); c = new Z(d); - 1 < a.length && (c = c[b].apply(c, a.slice(1))); + a.length > 1 && (c = c[b].apply(c, a.slice(1))); return c; } ;Z.prototype.or = function() { return ub(this, "or", xb, arguments); }; function xb(a, b, c, d, e, f, h) { - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = yb(a, b, c, !1, this.h), c = 0)); + a.length && (this.result.length && a.push(this.result), a.length < 2 ? this.result = a[0] : (this.result = yb(a, b, c, !1, this.h), c = 0)); e && (this.await = null); return e ? this.resolve(b, c, d, h) : this; } @@ -1897,7 +1894,7 @@ function zb(a, b, c, d, e, f, h) { return e ? this.result : this; } if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { + if (this.result.length && a.unshift(this.result), a.length < 2) { this.result = a[0]; } else { for (var g = 0, k = 0, m = void 0, l = void 0; k < a.length; k++) { @@ -1926,7 +1923,7 @@ function zb(a, b, c, d, e, f, h) { }; function Bb(a, b, c, d, e, f, h) { if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { + if (this.result.length && a.unshift(this.result), a.length < 2) { this.result = a[0]; } else { a: { @@ -1937,8 +1934,8 @@ function Bb(a, b, c, d, e, f, h) { l < n.length && (l = n.length); for (var q = 0, t; q < n.length; q++) { if (t = n[q]) { - for (var v = 0, u; v < t.length; v++) { - u = t[v], m[u] = m[u] ? 2 : 1; + for (var u = 0, v; u < t.length; u++) { + v = t[u], m[v] = m[v] ? 2 : 1; } } } @@ -1948,20 +1945,20 @@ function Bb(a, b, c, d, e, f, h) { for (q = 0; q < a.length; q++) { if (t = a[q]) { if (t = t[p]) { - for (v = 0; v < t.length; v++) { - if (u = t[v], 1 === m[u]) { + for (u = 0; u < t.length; u++) { + if (v = t[u], m[v] === 1) { if (f) { f--; } else { if (e) { - if (k.push(u), k.length === b) { + if (k.push(v), k.length === b) { a = k; break a; } } else { var z = p + (q ? g : 0); k[z] || (k[z] = []); - k[z].push(u); + k[z].push(v); if (++n === b) { a = k; break a; @@ -2029,7 +2026,7 @@ function Cb(a, b, c, d, e, f, h) { return e ? this.resolve(b, c, d, h, g) : this; } ;function Db(a, b, c, d, e) { - if ("string" === typeof e) { + if (typeof e === "string") { var f = e; e = ""; } else { @@ -2039,46 +2036,46 @@ function Cb(a, b, c, d, e, f, h) { throw Error('No template pattern was specified by the search option "highlight"'); } var h = f.indexOf("$1"); - if (-1 === h) { + if (h === -1) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } var g = f.substring(h + 2); h = f.substring(0, h); - var k = e && e.boundary, m = !e || !1 !== e.clip, l = e && e.merge && g && h && new RegExp(g + " " + h, "g"); + var k = e && e.boundary, m = !e || e.clip !== !1, l = e && e.merge && g && h && new RegExp(g + " " + h, "g"); e = e && e.ellipsis; var p = 0; - if ("object" === typeof e) { + if (typeof e === "object") { var n = e.template; p = n.length - 2; e = e.pattern; } - "string" !== typeof e && (e = !1 === e ? "" : "..."); + typeof e !== "string" && (e = e === !1 ? "" : "..."); p && (e = n.replace("$1", e)); n = e.length - p; - if ("object" === typeof k) { + if (typeof k === "object") { var q = k.before; - 0 === q && (q = -1); + q === 0 && (q = -1); var t = k.after; - 0 === t && (t = -1); + t === 0 && (t = -1); k = k.total || 9e5; } p = new Map(); - for (var v, u = 0, z, x; u < b.length; u++) { + for (var u, v = 0, z, x; v < b.length; v++) { if (d) { var C = b; x = d; } else { - C = b[u]; + C = b[v]; x = C.field; if (!x) { continue; } C = C.result; } - v = c.get(x); - z = v.encoder; - v = p.get(z); - "string" !== typeof v && (v = z.encode(a), p.set(z, v)); + u = c.get(x); + z = u.encoder; + u = p.get(z); + typeof u !== "string" && (u = z.encode(a), p.set(z, u)); for (var D = 0; D < C.length; D++) { var r = C[D].doc; if (r && (r = Ea(r, x))) { @@ -2087,18 +2084,18 @@ function Cb(a, b, c, d, e, f, h) { r = ""; for (var F = [], U = [], G = -1, N = -1, Q = 0, E = 0; E < y.length; E++) { var R = y[E], W = z.encode(R); - W = 1 < W.length ? W.join(" ") : W[0]; + W = W.length > 1 ? W.join(" ") : W[0]; var O = void 0; if (W && R) { - for (var L = R.length, M = (z.split ? R.replace(z.split, "") : R).length - W.length, ba = "", oa = 0, A = 0; A < v.length; A++) { - var I = v[A]; + for (var L = R.length, M = (z.split ? R.replace(z.split, "") : R).length - W.length, ba = "", oa = 0, A = 0; A < u.length; A++) { + var I = u[A]; if (I) { var J = I.length; J += M; - oa && J <= oa || (I = W.indexOf(I), -1 < I && (ba = (I ? R.substring(0, I) : "") + h + R.substring(I, I + J) + g + (I + J < L ? R.substring(I + J) : ""), oa = J, O = !0)); + oa && J <= oa || (I = W.indexOf(I), I > -1 && (ba = (I ? R.substring(0, I) : "") + h + R.substring(I, I + J) + g + (I + J < L ? R.substring(I + J) : ""), oa = J, O = !0)); } } - ba && (k && (0 > G && (G = r.length + (r ? 1 : 0)), N = r.length + (r ? 1 : 0) + ba.length, Q += L, U.push(F.length), F.push({match:ba})), r += (r ? " " : "") + ba); + ba && (k && (G < 0 && (G = r.length + (r ? 1 : 0)), N = r.length + (r ? 1 : 0) + ba.length, Q += L, U.push(F.length), F.push({match:ba})), r += (r ? " " : "") + ba); } if (!O) { R = y[E], r += (r ? " " : "") + R, k && F.push({text:R}); @@ -2108,8 +2105,8 @@ function Cb(a, b, c, d, e, f, h) { } Q = U.length * (f.length - 2); if (q || t || k && r.length - Q > k) { - if (Q = k + Q - 2 * n, E = N - G, 0 < q && (E += q), 0 < t && (E += t), E <= Q) { - y = q ? G - (0 < q ? q : 0) : G - ((Q - E) / 2 | 0), F = t ? N + (0 < t ? t : 0) : y + Q, m || (0 < y && " " !== r.charAt(y) && " " !== r.charAt(y - 1) && (y = r.indexOf(" ", y), 0 > y && (y = 0)), F < r.length && " " !== r.charAt(F - 1) && " " !== r.charAt(F) && (F = r.lastIndexOf(" ", F), F < N ? F = N : ++F)), r = (y ? e : "") + r.substring(y, F) + (F < r.length ? e : ""); + if (Q = k + Q - n * 2, E = N - G, q > 0 && (E += q), t > 0 && (E += t), E <= Q) { + y = q ? G - (q > 0 ? q : 0) : G - ((Q - E) / 2 | 0), F = t ? N + (t > 0 ? t : 0) : y + Q, m || (y > 0 && r.charAt(y) !== " " && r.charAt(y - 1) !== " " && (y = r.indexOf(" ", y), y < 0 && (y = 0)), F < r.length && r.charAt(F - 1) !== " " && r.charAt(F) !== " " && (F = r.lastIndexOf(" ", F), F < N ? F = N : ++F)), r = (y ? e : "") + r.substring(y, F) + (F < r.length ? e : ""); } else { N = []; Q = {}; @@ -2145,7 +2142,7 @@ function Cb(a, b, c, d, e, f, h) { r = F[J].text; var V = t && W[A]; if (V) { - if (0 < V) { + if (V > 0) { if (r.length > V) { if (E[A + 1] = 1, m) { r = r.substring(0, V); @@ -2163,7 +2160,7 @@ function Cb(a, b, c, d, e, f, h) { if (O + r.length + 1 <= k) { r = " " + r, N[A] += r; } else if (m) { - I = k - O - 1, 0 < I && (r = " " + r.substring(0, I), N[A] += r), E[A + 1] = 1; + I = k - O - 1, I > 0 && (r = " " + r.substring(0, I), N[A] += r), E[A + 1] = 1; } else { E[A + 1] = 1; continue; @@ -2179,8 +2176,8 @@ function Cb(a, b, c, d, e, f, h) { G[A] = 1; continue; } - if (0 >= J) { - if (0 > J) { + if (J <= 0) { + if (J < 0) { E[A] = 1; G[A] = 1; continue; @@ -2189,7 +2186,7 @@ function Cb(a, b, c, d, e, f, h) { } r = F[J].text; if (V = q && R[A]) { - if (0 < V) { + if (V > 0) { if (r.length > V) { if (E[A] = 1, m) { r = r.substring(r.length - V); @@ -2207,7 +2204,7 @@ function Cb(a, b, c, d, e, f, h) { if (O + r.length + 1 <= k) { r += " ", N[A] = r + N[A]; } else if (m) { - I = r.length + 1 - (k - O), 0 <= I && I < r.length && (r = r.substring(I) + " ", N[A] = r + N[A]), E[A] = 1; + I = r.length + 1 - (k - O), I >= 0 && I < r.length && (r = r.substring(I) + " ", N[A] = r + N[A]), E[A] = 1; } else { E[A] = 1; continue; @@ -2287,7 +2284,7 @@ function Cb(a, b, c, d, e, f, h) { if (a && a.then) { var k = this; a = a.then(function(p) { - k.C[0] = k.result = p.result || p; + k.F[0] = k.result = p.result || p; wb(k); }); var m = [a]; @@ -2299,7 +2296,7 @@ function Cb(a, b, c, d, e, f, h) { this.index = b || null; this.result = a || []; this.h = c; - this.C = m || []; + this.F = m || []; this.await = l || null; this.return = e || null; this.query = d || ""; @@ -2309,7 +2306,7 @@ w = Z.prototype; w.limit = function(a) { if (this.await) { var b = this; - this.C.push(function() { + this.F.push(function() { b.limit(a); return b.result; }); @@ -2335,7 +2332,7 @@ w.limit = function(a) { w.offset = function(a) { if (this.await) { var b = this; - this.C.push(function() { + this.F.push(function() { b.offset(a); return b.result; }); @@ -2354,7 +2351,7 @@ w.offset = function(a) { w.boost = function(a) { if (this.await) { var b = this; - this.C.push(function() { + this.F.push(function() { b.boost(a); return b.result; }); @@ -2366,19 +2363,19 @@ w.boost = function(a) { function wb(a, b) { var c = a.result, d = a.await; a.await = null; - for (var e = 0, f; e < a.C.length; e++) { - if (f = a.C[e]) { - if ("function" === typeof f) { - c = f(), a.C[e] = c = c.result || c, e--; + for (var e = 0, f; e < a.F.length; e++) { + if (f = a.F[e]) { + if (typeof f === "function") { + c = f(), a.F[e] = c = c.result || c, e--; } else if (f.H) { - c = f.H(), a.C[e] = c = c.result || c, e--; + c = f.H(), a.F[e] = c = c.result || c, e--; } else if (f.then) { return a.await = d; } } } d = a.return; - a.C = []; + a.F = []; a.return = null; b || d(c); return c; @@ -2391,7 +2388,7 @@ w.resolve = function(a, b, c, d, e) { return h.resolve(a, b, c, d, e); }); } - f.length && ("object" === typeof a ? (d = a.highlight, c = !!d || a.enrich, b = a.offset, a = a.limit) : c = !!d || c, f = e ? c ? tb.call(this.index, f) : f : sb.call(this.index, f, a || 100, b, c)); + f.length && (typeof a === "object" ? (d = a.highlight, c = !!d || a.enrich, b = a.offset, a = a.limit) : c = !!d || c, f = e ? c ? tb.call(this.index, f) : f : sb.call(this.index, f, a || 100, b, c)); return this.finalize(f, d); }; w.finalize = function(a, b) { @@ -2404,7 +2401,7 @@ w.finalize = function(a, b) { b && !this.query && console.warn('There was no query specified for highlighting. Please specify a query within the last resolver stage like { query: "...", resolve: true, highlight: ... }.'); b && a.length && this.query && (a = Db(this.query, a, this.index.index, this.field, b)); var d = this.return; - this.index = this.result = this.C = this.await = this.return = null; + this.index = this.result = this.F = this.await = this.return = null; this.query = this.field = ""; d && d(a); return a; @@ -2414,18 +2411,18 @@ function Ab(a, b, c, d, e, f, h) { var m = S(); for (var l = 0, p = void 0, n, q; l < b; l++) { for (var t = 0; t < g; t++) { - var v = a[t]; - if (l < v.length && (p = v[l])) { - for (var u = 0; u < p.length; u++) { - n = p[u]; - (v = m[n]) ? m[n]++ : (v = 0, m[n] = 1); - q = k[v] || (k[v] = []); + var u = a[t]; + if (l < u.length && (p = u[l])) { + for (var v = 0; v < p.length; v++) { + n = p[v]; + (u = m[n]) ? m[n]++ : (u = 0, m[n] = 1); + q = k[u] || (k[u] = []); if (!h) { var z = l + (t || !e ? 0 : f || 0); q = q[z] || (q[z] = []); } q.push(n); - if (h && c && v === g - 1 && q.length - d === c) { + if (h && c && u === g - 1 && q.length - d === c) { return d ? q.slice(d) : q; } } @@ -2434,7 +2431,7 @@ function Ab(a, b, c, d, e, f, h) { } if (a = k.length) { if (e) { - k = 1 < k.length ? yb(k, c, d, h, f) : (k = k[0]) && c && k.length > c || d ? k.slice(d, c + d) : k; + k = k.length > 1 ? yb(k, c, d, h, f) : (k = k[0]) && c && k.length > c || d ? k.slice(d, c + d) : k; } else { if (a < g) { return []; @@ -2472,7 +2469,7 @@ function Ab(a, b, c, d, e, f, h) { function yb(a, b, c, d, e) { var f = [], h = S(), g = a.length, k; if (d) { - for (e = g - 1; 0 <= e; e--) { + for (e = g - 1; e >= 0; e--) { if (k = (d = a[e]) && d.length) { for (g = 0; g < k; g++) { var m = d[g]; @@ -2489,7 +2486,7 @@ function yb(a, b, c, d, e) { } } } else { - for (var l = g - 1, p, n = 0; 0 <= l; l--) { + for (var l = g - 1, p, n = 0; l >= 0; l--) { p = a[l]; for (var q = 0; q < p.length; q++) { if (k = (d = p[q]) && d.length) { @@ -2498,8 +2495,8 @@ function yb(a, b, c, d, e) { if (h[m] = 1, c) { c--; } else { - var v = (q + (l < g - 1 ? e || 0 : 0)) / (l + 1) | 0; - (f[v] || (f[v] = [])).push(m); + var u = (q + (l < g - 1 ? e || 0 : 0)) / (l + 1) | 0; + (f[u] || (f[u] = [])).push(m); if (++n === b) { return f; } @@ -2545,11 +2542,11 @@ pb.prototype.search = function(a, b, c, d) { var p = k || c.field || (p = c.index) && (p.index ? null : p); var n = this.tag && c.tag; var q = c.suggest; - g = !1 !== c.resolve; + g = c.resolve !== !1; var t = c.cache; this.store && c.highlight && !g ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && c.enrich && !g && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - var v = g && this.store && c.highlight; - var u = !!v || g && this.store && c.enrich; + var u = g && this.store && c.highlight; + var v = !!u || g && this.store && c.enrich; b = c.limit || b; var z = c.offset || 0; b || (b = g ? 100 : 0); @@ -2598,9 +2595,9 @@ pb.prototype.search = function(a, b, c, d) { console.warn("Tag '" + x[n] + ":" + x[n + 1] + "' will be skipped because there is no field '" + x[n] + "'."); continue; } - f.push(d = d.db.tag(x[n + 1], b, z, u)); + f.push(d = d.db.tag(x[n + 1], b, z, v)); } else { - d = Fb.call(this, x[n], x[n + 1], b, z, u); + d = Fb.call(this, x[n], x[n + 1], b, z, v); } e.push(g ? {field:x[n], tag:x[n + 1], result:d} : [d]); } @@ -2611,15 +2608,15 @@ pb.prototype.search = function(a, b, c, d) { for (var M = 0; M < L.length; M++) { g ? e[M].result = L[M] : e[M] = L[M]; } - return g ? e : new Z(1 < e.length ? Ab(e, 1, 0, 0, q, l) : e[0], N); + return g ? e : new Z(e.length > 1 ? Ab(e, 1, 0, 0, q, l) : e[0], N); }); } - return g ? e : new Z(1 < e.length ? Ab(e, 1, 0, 0, q, l) : e[0], this); + return g ? e : new Z(e.length > 1 ? Ab(e, 1, 0, 0, q, l) : e[0], this); } } if (!g && !k) { if (p = p || this.field) { - T(p) ? k = p : (p.constructor === Array && 1 === p.length && (p = p[0]), k = p.field || p.index); + T(p) ? k = p : (p.constructor === Array && p.length === 1 && (p = p[0]), k = p.field || p.index); } if (!k) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); @@ -2631,9 +2628,9 @@ pb.prototype.search = function(a, b, c, d) { x = (this.worker || this.db) && !d && []; C = 0; for (y = D = r = void 0; C < p.length; C++) { - if (D = p[C], !this.db || !this.tag || this.M[C]) { + if (D = p[C], !this.db || !this.tag || this.B[C]) { r = void 0; - T(D) || (r = D, D = r.field, a = r.query || a, b = Ba(r.limit, b), z = Ba(r.offset, z), q = Ba(r.suggest, q), v = g && this.store && Ba(r.highlight, v), u = !!v || g && this.store && Ba(r.enrich, u), t = Ba(r.cache, t)); + T(D) || (r = D, D = r.field, a = r.query || a, b = Ba(r.limit, b), z = Ba(r.offset, z), q = Ba(r.suggest, q), u = g && this.store && Ba(r.highlight, u), v = !!u || g && this.store && Ba(r.enrich, v), t = Ba(r.cache, t)); if (d) { r = d[C]; } else { @@ -2699,23 +2696,23 @@ pb.prototype.search = function(a, b, c, d) { } if (y) { f[h] = D, e.push(r), h++; - } else if (1 === p.length) { + } else if (p.length === 1) { return g ? e : new Z(e, this); } } } if (x) { if (this.db && n && n.length && !Q) { - for (u = 0; u < n.length; u += 2) { - f = this.index.get(n[u]); + for (v = 0; v < n.length; v += 2) { + f = this.index.get(n[v]); if (!f) { - if (console.warn("Tag '" + n[u] + ":" + n[u + 1] + "' was not found because there is no field '" + n[u] + "'."), q) { + if (console.warn("Tag '" + n[v] + ":" + n[v + 1] + "' was not found because there is no field '" + n[v] + "'."), q) { continue; } else { return g ? e : new Z(e, this); } } - x.push(f.db.tag(n[u + 1], b, z, !1)); + x.push(f.db.tag(n[v + 1], b, z, !1)); } } var W = this; @@ -2728,29 +2725,29 @@ pb.prototype.search = function(a, b, c, d) { if (!h) { return g ? e : new Z(e, this); } - if (k && (!u || !this.store)) { + if (k && (!v || !this.store)) { return e = e[0], g ? e : new Z(e, this); } x = []; for (z = 0; z < f.length; z++) { n = e[z]; - u && n.length && "undefined" === typeof n[0].doc && (this.db ? x.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = tb.call(this, n)); + v && n.length && typeof n[0].doc === "undefined" && (this.db ? x.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = tb.call(this, n)); if (k) { - return g ? v ? Db(a, n, this.index, k, v) : n : new Z(n, this); + return g ? u ? Db(a, n, this.index, k, u) : n : new Z(n, this); } e[z] = {field:f[z], result:n}; } - if (u && this.db && x.length) { + if (v && this.db && x.length) { var O = this; return Promise.all(x).then(function(L) { for (var M = 0; M < L.length; M++) { e[M].result = L[M]; } - v && (e = Db(a, e, O.index, k, v)); + u && (e = Db(a, e, O.index, k, u)); return m ? Gb(e) : e; }); } - v && (e = Db(a, e, this.index, k, v)); + u && (e = Db(a, e, this.index, k, u)); return m ? Gb(e) : e; }; function Gb(a) { @@ -2759,7 +2756,7 @@ function Gb(a) { h = f.field; f = f.result; for (var p = 0; p < f.length; p++) { - if (k = f[p], "object" !== typeof k ? k = {id:g = k} : g = k.id, (m = c[g]) ? m.push(h) : (k.field = c[g] = [h], b.push(k)), l = k.highlight) { + if (k = f[p], typeof k !== "object" ? k = {id:g = k} : g = k.id, (m = c[g]) ? m.push(h) : (k.field = c[g] = [h], b.push(k)), l = k.highlight) { m = d[g], m || (d[g] = m = {}, k.highlight = m), m[h] = l; } } @@ -2776,7 +2773,7 @@ function Fb(a, b, c, d, e) { return []; } b = a.length - d; - if (0 < b) { + if (b > 0) { if (c && b > c || d) { a = a.slice(d, d + c); } @@ -2801,15 +2798,15 @@ function tb(a) { return new pb(a); } var b = a.document || a.doc || a, c, d; - this.M = []; + this.B = []; this.field = []; - this.T = []; - this.key = (c = b.key || b.id) && Hb(c, this.T) || "id"; + this.C = []; + this.key = (c = b.key || b.id) && Hb(c, this.C) || "id"; (d = a.keystore || 0) && (this.keystore = d); this.fastupdate = !!a.fastupdate; this.reg = !this.fastupdate || a.worker || a.db ? d ? new X(d) : new Set() : d ? new Xa(d) : new Map(); - this.J = (c = b.store || null) && c && !0 !== c && []; - this.store = c && (d ? new Xa(d) : new Map()); + this.h = (c = b.store || null) && c && c !== !0 && []; + this.store = c ? d ? new Xa(d) : new Map() : null; this.cache = (c = a.cache || null) && new Na(c); a.cache = !1; this.worker = a.worker || !1; @@ -2817,10 +2814,10 @@ function tb(a) { this.index = Ib.call(this, a, b); this.tag = null; if (c = b.tag) { - if ("string" === typeof c && (c = [c]), c.length) { + if (typeof c === "string" && (c = [c]), c.length) { this.tag = new Map(); - this.L = []; - this.ba = []; + this.A = []; + this.D = []; b = 0; for (var e = d = void 0; b < c.length; b++) { d = c[b]; @@ -2828,8 +2825,8 @@ function tb(a) { if (!e) { throw Error("The tag field from the document descriptor is undefined."); } - d.custom ? this.L[b] = d.custom : (this.L[b] = Hb(e, this.T), d.filter && ("string" === typeof this.L[b] && (this.L[b] = new String(this.L[b])), this.L[b].S = d.filter)); - this.ba[b] = e; + d.custom ? this.A[b] = d.custom : (this.A[b] = Hb(e, this.C), d.filter && (typeof this.A[b] === "string" && (this.A[b] = new String(this.A[b])), this.A[b].O = d.filter)); + this.D[b] = e; this.tag.set(e, new Map()); } } @@ -2864,8 +2861,8 @@ w.mount = function(a) { } var b = this.field; if (this.tag) { - for (var c = 0, d = void 0; c < this.ba.length; c++) { - d = this.ba[c]; + for (var c = 0, d = void 0; c < this.D.length; c++) { + d = this.D[c]; var e = void 0; this.index.set(d, e = new Y({}, this.reg)); b === this.field && (b = b.slice(0)); @@ -2894,7 +2891,7 @@ w.mount = function(a) { w.commit = function(a, b) { var c = this, d, e, f, h; return wa(function(g) { - if (1 == g.h) { + if (g.h == 1) { d = []; e = B(c.index.values()); for (f = e.next(); !f.done; f = e.next()) { @@ -2920,27 +2917,27 @@ function Ib(a, b) { T(f) || (h = f, f = f.field); h = Ca(h) ? Object.assign({}, a, h) : a; if (this.worker) { - var g = (g = h.encoder) && g.encode ? g : new Ka("string" === typeof g ? Ua[g] : g || {}); + var g = (g = h.encoder) && g.encode ? g : new Ka(typeof g === "string" ? Ua[g] : g || {}); g = new mb(h, g); c.set(f, g); } this.worker || c.set(f, new Y(h, this.reg)); - h.custom ? this.M[e] = h.custom : (this.M[e] = Hb(f, this.T), h.filter && ("string" === typeof this.M[e] && (this.M[e] = new String(this.M[e])), this.M[e].S = h.filter)); + h.custom ? this.B[e] = h.custom : (this.B[e] = Hb(f, this.C), h.filter && (typeof this.B[e] === "string" && (this.B[e] = new String(this.B[e])), this.B[e].O = h.filter)); this.field[e] = f; } - if (this.J) { + if (this.h) { for (a = b.store, T(a) && (a = [a]), b = 0; b < a.length; b++) { - d = a[b], e = d.field || d, d.custom ? (this.J[b] = d.custom, d.custom.na = e) : (this.J[b] = Hb(e, this.T), d.filter && ("string" === typeof this.J[b] && (this.J[b] = new String(this.J[b])), this.J[b].S = d.filter)); + d = a[b], e = d.field || d, d.custom ? (this.h[b] = d.custom, d.custom.ia = e) : (this.h[b] = Hb(e, this.C), d.filter && (typeof this.h[b] === "string" && (this.h[b] = new String(this.h[b])), this.h[b].O = d.filter)); } } return c; } function Hb(a, b) { for (var c = a.split(":"), d = 0, e = 0; e < c.length; e++) { - a = c[e], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a); + a = c[e], a[a.length - 1] === "]" && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a); } d < c.length && (c.length = d); - return 1 < d ? c : c[0]; + return d > 1 ? c : c[0]; } w.append = function(a, b) { return this.add(a, b, !0); @@ -2962,7 +2959,7 @@ w.remove = function(a) { e = f[0]; f = f[1]; var h = f.indexOf(a); - -1 < h && (1 < f.length ? f.splice(h, 1) : c.delete(e)); + h > -1 && (f.length > 1 ? f.splice(h, 1) : c.delete(e)); } } } @@ -3000,7 +2997,7 @@ w.get = function(a) { }) : this.store.get(a) || null; }; w.set = function(a, b) { - "object" === typeof a && (b = a, a = Ea(b, this.key)); + typeof a === "object" && (b = a, a = Ea(b, this.key)); this.store.set(a, b); return this; }; @@ -3009,7 +3006,7 @@ w.export = Jb; w.import = Kb; fb(pb.prototype); function Lb(a, b) { - b = void 0 === b ? 0 : b; + b = b === void 0 ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 5000 | 0); a = B(a.entries()); @@ -3027,7 +3024,7 @@ function Mb(a, b) { return b; } function Nb(a, b) { - b = void 0 === b ? 0 : b; + b = b === void 0 ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 1000 | 0); a = B(a.entries()); @@ -3048,7 +3045,7 @@ function Pb(a) { var b = [], c = []; a = B(a.keys()); for (var d = a.next(); !d.done; d = a.next()) { - c.push(d.value), 250000 === c.length && (b.push(c), c = []); + c.push(d.value), c.length === 250000 && (b.push(c), c = []); } c.length && b.push(c); return b; @@ -3061,7 +3058,7 @@ function Qb(a, b) { return b; } function Rb(a, b, c, d, e, f, h) { - h = void 0 === h ? 0 : h; + h = h === void 0 ? 0 : h; var g = d && d.constructor === Array, k = g ? d.shift() : d; if (!k) { return this.export(a, b, e, f + 1); @@ -3075,8 +3072,8 @@ function Rb(a, b, c, d, e, f, h) { return Rb.call(this, a, b, c, g ? d : null, e, f, h + 1); } function Jb(a, b, c, d) { - c = void 0 === c ? 0 : c; - d = void 0 === d ? 0 : d; + c = c === void 0 ? 0 : c; + d = d === void 0 ? 0 : d; if (c < this.field.length) { var e = this.field[c]; if ((b = this.index.get(e).export(a, e, c, d = 1)) && b.then) { @@ -3106,18 +3103,18 @@ function Jb(a, b, c, d) { default: return; } - return Rb.call(this, a, b, h, g, c, d); + return Rb.call(this, a, b, h, g || null, c, d); } function Kb(a, b) { var c = a.split("."); - "json" === c[c.length - 1] && c.pop(); - var d = 2 < c.length ? c[0] : ""; - c = 2 < c.length ? c[2] : c[1]; + c[c.length - 1] === "json" && c.pop(); + var d = c.length > 2 ? c[0] : ""; + c = c.length > 2 ? c[2] : c[1]; if (this.worker && d) { return this.index.get(d).import(a); } if (b) { - "string" === typeof b && (b = JSON.parse(b)); + typeof b === "string" && (b = JSON.parse(b)); if (d) { return this.index.get(d).import(c, b); } @@ -3155,7 +3152,7 @@ function Sb(a, b) { for (var f = "", h = 0, g; h < e.length; h++) { g = e[h] || [""]; for (var k = "", m = 0; m < g.length; m++) { - k += (k ? "," : "") + ("string" === b ? '"' + g[m] + '"' : g[m]); + k += (k ? "," : "") + (b === "string" ? '"' + g[m] + '"' : g[m]); } k = "[" + k + "]"; f += (f ? "," : "") + k; @@ -3175,7 +3172,7 @@ function Sb(a, b) { e.pop(); } else { var h = e.indexOf(a); - 0 <= h && e.splice(h, 1); + h >= 0 && e.splice(h, 1); } } } @@ -3184,12 +3181,12 @@ function Sb(a, b) { } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.ea && Ub(this)); + this.db && (this.commit_task.push({del:a}), this.$ && Ub(this)); this.cache && this.cache.remove(a); return this; }; function Tb(a, b) { - var c = 0, d = "undefined" === typeof b; + var c = 0, d = typeof b === "undefined"; if (a.constructor === Array) { for (var e = 0, f = void 0, h, g = void 0; e < a.length; e++) { if ((f = a[e]) && f.length) { @@ -3197,8 +3194,8 @@ function Tb(a, b) { return 1; } h = f.indexOf(b); - if (0 <= h) { - if (1 < f.length) { + if (h >= 0) { + if (f.length > 1) { return f.splice(h, 1), 1; } delete a[e]; @@ -3223,7 +3220,7 @@ function Tb(a, b) { } ;var Vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; Y.prototype.add = function(a, b, c, d) { - if (b && (a || 0 === a)) { + if (b && (a || a === 0)) { if (!d && !c && this.reg.has(a)) { return this.update(a, b); } @@ -3236,38 +3233,46 @@ Y.prototype.add = function(a, b, c, d) { if (l && (d || !h[m])) { var p = this.score ? this.score(b, m, k, null, 0) : Wb(g, e, k), n = ""; switch(this.tokenize) { + case "tolerant": + Xb(this, h, m, p, a, c); + if (l > 2) { + for (var q = 1, t, u; q < l - 1; q++) { + n = m.charAt(q), t = m.charAt(q + 1), t = m.substring(0, q) + t, u = m.substring(q + 2), n = t + n + u, h[n] || Xb(this, h, n, p, a, c), n = t + u, h[n] || Xb(this, h, n, p, a, c); + } + } + break; case "full": - if (2 < l) { - p = 0; - for (var q; p < l; p++) { - for (var t = l; t > p; t--) { - n = m.substring(p, t), q = this.rtl ? l - 1 - p : p, q = this.score ? this.score(b, m, k, n, q) : Wb(g, e, k, l, q), Xb(this, h, n, q, a, c); + if (l > 2) { + for (p = 0; p < l; p++) { + for (q = l; q > p; q--) { + n = m.substring(p, q), h[n] || (t = this.rtl ? l - 1 - p : p, t = this.score ? this.score(b, m, k, n, t) : Wb(g, e, k, l, t), Xb(this, h, n, t, a, c)); } } break; } case "bidirectional": case "reverse": - if (1 < l) { - for (t = l - 1; 0 < t; t--) { - n = m[this.rtl ? l - 1 - t : t] + n, q = this.score ? this.score(b, m, k, n, t) : Wb(g, e, k, l, t), Xb(this, h, n, q, a, c); + if (l > 1) { + for (q = l - 1; q > 0; q--) { + n = m[this.rtl ? l - 1 - q : q] + n, h[n] || (t = this.score ? this.score(b, m, k, n, q) : Wb(g, e, k, l, q), Xb(this, h, n, t, a, c)); } n = ""; } case "forward": - if (1 < l) { - for (t = 0; t < l; t++) { - n += m[this.rtl ? l - 1 - t : t], Xb(this, h, n, p, a, c); + if (l > 1) { + for (q = 0; q < l; q++) { + n += m[this.rtl ? l - 1 - q : q], h[n] || Xb(this, h, n, p, a, c); } break; } default: - if (Xb(this, h, m, p, a, c), d && 1 < e && k < e - 1) { - for (l = S(), n = this.ga, p = m, t = Math.min(d + 1, this.rtl ? k + 1 : e - k), q = l[p] = 1; q < t; q++) { - if ((m = b[this.rtl ? e - 1 - k - q : k + q]) && !l[m]) { + if (Xb(this, h, m, p, a, c), d && e > 1 && k < e - 1) { + for (l = S(), n = this.ba, p = m, q = Math.min(d + 1, this.rtl ? k + 1 : e - k), t = l[p] = 1; t < q; t++) { + if ((m = b[this.rtl ? e - 1 - k - t : k + t]) && !l[m]) { l[m] = 1; - var v = this.score ? this.score(b, p, k, m, q - 1) : Wb(n + (e / 2 > n ? 0 : 1), e, k, t - 1, q - 1), u = this.bidirectional && m > p; - Xb(this, f, u ? p : m, v, a, c, u ? m : p); + u = this.score ? this.score(b, p, k, m, t - 1) : Wb(n + (e / 2 > n ? 0 : 1), e, k, q - 1, t - 1); + var v = this.bidirectional && m > p; + Xb(this, f, v ? p : m, u, a, c, v ? m : p); } } } @@ -3279,14 +3284,14 @@ Y.prototype.add = function(a, b, c, d) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.ea && Ub(this)); + this.db && (b || this.commit_task.push({del:a}), this.$ && Ub(this)); return this; }; function Xb(a, b, c, d, e, f, h) { var g = h ? a.ctx : a.map, k; if (!b[c] || h && !(k = b[c])[h]) { if (h ? (b = k || (b[c] = S()), b[h] = 1, (k = g.get(h)) ? g = k : g.set(h, g = new Map())) : b[c] = 1, (k = g.get(c)) ? g = k : g.set(c, g = k = []), g = g[d] || (g[d] = []), !f || !g.includes(e)) { - if (g.length === Math.pow(2, 31) - 1) { + if (g.length === 2147483647) { b = new Wa(g); if (a.fastupdate) { for (c = B(a.reg.values()), f = c.next(); !f.done; f = c.next()) { @@ -3301,10 +3306,10 @@ function Xb(a, b, c, d, e, f, h) { } } function Wb(a, b, c, d, e) { - return c && 1 < a ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0; + return c && a > 1 ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0; } ;Y.prototype.search = function(a, b, c) { - c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); + c || (b || typeof a !== "object" ? typeof b === "object" && (c = b, b = 0) : (c = a, a = "")); if (c && c.cache) { return c.cache = !1, a = this.searchCache(a, b, c), c.cache = !0, a; } @@ -3320,25 +3325,25 @@ function Wb(a, b, c, d, e) { var l = c.resolution; var p = this.db && c.tag; } - "undefined" === typeof f && (f = this.resolve); - h = this.depth && !1 !== h; + typeof f === "undefined" && (f = this.resolve); + h = this.depth && h !== !1; var n = this.encoder.encode(a, !h); var q = n.length; b = b || (f ? 100 : 0); - if (1 === q) { + if (q === 1) { return Yb.call(this, n[0], "", b, e, f, k, p); } - if (2 === q && h && !g) { + if (q === 2 && h && !g) { return Yb.call(this, n[1], n[0], b, e, f, k, p); } - var t = S(), v = 0; + var t = S(), u = 0; if (h) { - var u = n[0]; - v = 1; + var v = n[0]; + u = 1; } - l || 0 === l || (l = u ? this.ga : this.resolution); + l || l === 0 || (l = v ? this.ba : this.resolution); if (this.db) { - if (this.db.search && (c = this.db.search(this, n, b, e, g, f, k, p), !1 !== c)) { + if (this.db.search && (c = this.db.search(this, n, b, e, g, f, k, p), c !== !1)) { return c; } var z = this; @@ -3349,17 +3354,17 @@ function Wb(a, b, c, d, e) { case 1: C = x = void 0; case 2: - if (!(v < q)) { + if (!(u < q)) { D.h = 4; break; } - C = n[v]; + C = n[u]; if (!C || t[C]) { D.h = 5; break; } t[C] = 1; - return K(D, Zb(z, C, u, 0, 0, !1, !1), 6); + return K(D, Zb(z, C, v, 0, 0, !1, !1), 6); case 6: x = D.B; if (x = $b(x, d, g, l)) { @@ -3367,10 +3372,10 @@ function Wb(a, b, c, d, e) { D.h = 4; break; } - u && (g && x && d.length || (u = C)); + v && (g && x && d.length || (v = C)); case 5: - g && u && v === q - 1 && !d.length && (l = z.resolution, u = "", v = -1, t = S()); - v++; + g && v && u === q - 1 && !d.length && (l = z.resolution, v = "", u = -1, t = S()); + u++; D.h = 2; break; case 4: @@ -3379,25 +3384,25 @@ function Wb(a, b, c, d, e) { }); }(); } - for (a = c = void 0; v < q; v++) { - if ((a = n[v]) && !t[a]) { + for (a = c = void 0; u < q; u++) { + if ((a = n[u]) && !t[a]) { t[a] = 1; - c = Zb(this, a, u, 0, 0, !1, !1); + c = Zb(this, a, v, 0, 0, !1, !1); if (c = $b(c, d, g, l)) { d = c; break; } - u && (g && c && d.length || (u = a)); + v && (g && c && d.length || (v = a)); } - g && u && v === q - 1 && !d.length && (l = this.resolution, u = "", v = -1, t = S()); + g && v && u === q - 1 && !d.length && (l = this.resolution, v = "", u = -1, t = S()); } return ac(d, l, b, e, g, m, f); }; function ac(a, b, c, d, e, f, h) { var g = a.length, k = a; - if (1 < g) { + if (g > 1) { k = Ab(a, b, c, d, e, f, h); - } else if (1 === g) { + } else if (g === 1) { return h ? sb.call(null, a[0], c, d) : new Z(a[0], this); } return h ? k : new Z(k, this); @@ -3449,27 +3454,27 @@ function Zb(a, b, c, d, e, f, h, g) { a = {}; } c = a.context; - var d = !0 === c ? {depth:1} : c || {}, e = T(a.encoder) ? Ua[a.encoder] : a.encode || a.encoder || {}; - this.encoder = e.encode ? e : "object" === typeof e ? new Ka(e) : {encode:e}; + var d = c === !0 ? {depth:1} : c || {}, e = T(a.encoder) ? Ua[a.encoder] : a.encode || a.encoder || {}; + this.encoder = e.encode ? e : typeof e === "object" ? new Ka(e) : {encode:e}; this.resolution = a.resolution || 9; - this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; - this.depth = "strict" === c && d.depth || 0; - this.bidirectional = !1 !== d.bidirectional; + this.tokenize = c = (c = a.tokenize) && c !== "default" && c !== "exact" && c || "strict"; + this.depth = c === "strict" && d.depth || 0; + this.bidirectional = d.bidirectional !== !1; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - d && d.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + d && d.depth && this.tokenize !== "strict" && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); (c = a.keystore || 0) && (this.keystore = c); this.map = c ? new Xa(c) : new Map(); this.ctx = c ? new Xa(c) : new Map(); this.reg = b || (this.fastupdate ? c ? new Xa(c) : new Map() : c ? new X(c) : new Set()); - this.ga = d.resolution || 3; + this.ba = d.resolution || 3; this.rtl = e.rtl || a.rtl || !1; this.cache = (c = a.cache || null) && new Na(c); - this.resolve = !1 !== a.resolve; + this.resolve = a.resolve !== !1; if (c = a.db) { this.db = this.mount(c); } - this.ea = !1 !== a.commit; + this.$ = a.commit !== !1; this.commit_task = []; this.commit_timer = null; this.priority = a.priority || 4; @@ -3522,8 +3527,8 @@ w.cleanup = function() { }; w.searchCache = Ma; w.export = function(a, b, c, d) { - c = void 0 === c ? 0 : c; - d = void 0 === d ? 0 : d; + c = c === void 0 ? 0 : c; + d = d === void 0 ? 0 : d; switch(d) { case 0: var e = "reg"; @@ -3548,7 +3553,7 @@ w.export = function(a, b, c, d) { }; w.import = function(a, b) { if (b) { - switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { + switch(typeof b === "string" && (b = JSON.parse(b)), a = a.split("."), a[a.length - 1] === "json" && a.pop(), a.length === 3 && a.shift(), a = a.length > 1 ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; this.reg = Qb(b, this.reg); @@ -3562,13 +3567,13 @@ w.import = function(a, b) { } }; w.serialize = function(a) { - a = void 0 === a ? !0 : a; + a = a === void 0 ? !0 : a; var b = "", c = "", d = ""; if (this.reg.size) { var e; c = B(this.reg.keys()); for (var f = c.next(); !f.done; f = c.next()) { - f = f.value, e || (e = typeof f), b += (b ? "," : "") + ("string" === e ? '"' + f + '"' : f); + f = f.value, e || (e = typeof f), b += (b ? "," : "") + (e === "string" ? '"' + f + '"' : f); } b = "index.reg=new Set([" + b + "]);"; c = Sb(this.map, e); @@ -3587,13 +3592,13 @@ w.serialize = function(a) { return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; fb(Y.prototype); -var bc = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), cc = ["map", "ctx", "tag", "reg", "cfg"], dc = S(); +var bc = typeof window !== "undefined" && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), cc = ["map", "ctx", "tag", "reg", "cfg"], dc = S(); function ec(a, b) { - b = void 0 === b ? {} : b; + b = b === void 0 ? {} : b; if (!this || this.constructor !== ec) { return new ec(a, b); } - "object" === typeof a && (b = a, a = a.name); + typeof a === "object" && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; @@ -3623,7 +3628,7 @@ w.open = function() { for (var c = a.db = this.result, d = 0, e; d < cc.length; d++) { e = cc[d]; for (var f = 0, h; f < dc[a.id].length; f++) { - h = dc[a.id][f], c.objectStoreNames.contains(e + ("reg" !== e ? h ? ":" + h : "" : "")) || c.createObjectStore(e + ("reg" !== e ? h ? ":" + h : "" : "")); + h = dc[a.id][f], c.objectStoreNames.contains(e + (e !== "reg" ? h ? ":" + h : "" : "")) || c.createObjectStore(e + (e !== "reg" ? h ? ":" + h : "" : "")); } } }; @@ -3646,7 +3651,7 @@ w.clear = function() { for (var a = [], b = 0, c; b < cc.length; b++) { c = cc[b]; for (var d = 0, e; d < dc[this.id].length; d++) { - e = dc[this.id][d], a.push(c + ("reg" !== c ? e ? ":" + e : "" : "")); + e = dc[this.id][d], a.push(c + (c !== "reg" ? e ? ":" + e : "" : "")); } } b = this.db.transaction(a, "readwrite"); @@ -3656,10 +3661,10 @@ w.clear = function() { return fc(b); }; w.get = function(a, b, c, d, e, f) { - c = void 0 === c ? 0 : c; - d = void 0 === d ? 0 : d; - e = void 0 === e ? !0 : e; - f = void 0 === f ? !1 : f; + c = c === void 0 ? 0 : c; + d = d === void 0 ? 0 : d; + e = e === void 0 ? !0 : e; + f = f === void 0 ? !1 : f; a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); var h = this; return fc(a).then(function(g) { @@ -3668,7 +3673,7 @@ w.get = function(a, b, c, d, e, f) { return k; } if (e) { - if (!c && !d && 1 === g.length) { + if (!c && !d && g.length === 1) { return g[0]; } for (var m = 0, l = void 0; m < g.length; m++) { @@ -3692,9 +3697,9 @@ w.get = function(a, b, c, d, e, f) { }); }; w.tag = function(a, b, c, d) { - b = void 0 === b ? 0 : b; - c = void 0 === c ? 0 : c; - d = void 0 === d ? !1 : d; + b = b === void 0 ? 0 : b; + c = c === void 0 ? 0 : c; + d = d === void 0 ? !1 : d; a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); var e = this; return fc(a).then(function(f) { @@ -3709,7 +3714,7 @@ w.tag = function(a, b, c, d) { }); }; w.enrich = function(a) { - "object" !== typeof a && (a = [a]); + typeof a !== "object" && (a = [a]); for (var b = this.db.transaction("reg", "readonly").objectStore("reg"), c = [], d = 0; d < a.length; d++) { c[d] = fc(b.get(a[d])); } @@ -3730,7 +3735,7 @@ w.search = null; w.info = function() { }; w.transaction = function(a, b, c) { - a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; + a += a !== "reg" ? this.field ? ":" + this.field : "" : ""; var d = this.h[a + ":" + b]; if (d) { return c.call(this, d); @@ -3795,58 +3800,58 @@ w.commit = function(a, b, c) { a.commit_task = []; case 3: return a.reg.size ? K(g, d.transaction("map", "readwrite", function(k) { - for (var m = B(a.map), l = m.next(), p = {}; !l.done; p = {P:void 0, Y:void 0}, l = m.next()) { - l = l.value, p.Y = l[0], p.P = l[1], p.P.length && (b ? k.put(p.P, p.Y) : k.get(p.Y).onsuccess = function(n) { + for (var m = B(a.map), l = m.next(), p = {}; !l.done; p = {M:void 0, U:void 0}, l = m.next()) { + l = l.value, p.U = l[0], p.M = l[1], p.M.length && (b ? k.put(p.M, p.U) : k.get(p.U).onsuccess = function(n) { return function() { var q = this.result, t; if (q && q.length) { - for (var v = Math.max(q.length, n.P.length), u = 0, z; u < v; u++) { - if ((z = n.P[u]) && z.length) { - if ((t = q[u]) && t.length) { + for (var u = Math.max(q.length, n.M.length), v = 0, z; v < u; v++) { + if ((z = n.M[v]) && z.length) { + if ((t = q[v]) && t.length) { for (var x = 0; x < z.length; x++) { t.push(z[x]); } } else { - q[u] = z; + q[v] = z; } t = 1; } } } else { - q = n.P, t = 1; + q = n.M, t = 1; } - t && k.put(q, n.Y); + t && k.put(q, n.U); }; }(p)); } }), 13) : g.return(); case 13: return K(g, d.transaction("ctx", "readwrite", function(k) { - for (var m = B(a.ctx), l = m.next(), p = {}; !l.done; p = {W:void 0}, l = m.next()) { + for (var m = B(a.ctx), l = m.next(), p = {}; !l.done; p = {S:void 0}, l = m.next()) { l = l.value; - p.W = l[0]; + p.S = l[0]; l = B(l[1]); - for (var n = l.next(), q = {}; !n.done; q = {R:void 0, Z:void 0}, n = l.next()) { - n = n.value, q.Z = n[0], q.R = n[1], q.R.length && (b ? k.put(q.R, p.W + ":" + q.Z) : k.get(p.W + ":" + q.Z).onsuccess = function(t, v) { + for (var n = l.next(), q = {}; !n.done; q = {N:void 0, V:void 0}, n = l.next()) { + n = n.value, q.V = n[0], q.N = n[1], q.N.length && (b ? k.put(q.N, p.S + ":" + q.V) : k.get(p.S + ":" + q.V).onsuccess = function(t, u) { return function() { - var u = this.result, z; - if (u && u.length) { - for (var x = Math.max(u.length, t.R.length), C = 0, D; C < x; C++) { - if ((D = t.R[C]) && D.length) { - if ((z = u[C]) && z.length) { + var v = this.result, z; + if (v && v.length) { + for (var x = Math.max(v.length, t.N.length), C = 0, D; C < x; C++) { + if ((D = t.N[C]) && D.length) { + if ((z = v[C]) && z.length) { for (var r = 0; r < D.length; r++) { z.push(D[r]); } } else { - u[C] = D; + v[C] = D; } z = 1; } } } else { - u = t.R, z = 1; + v = t.N, z = 1; } - z && k.put(u, v.W + ":" + t.Z); + z && k.put(v, u.S + ":" + t.V); }; }(q, p)); } @@ -3859,7 +3864,7 @@ w.commit = function(a, b, c) { var p = l.value; l = p[0]; p = p[1]; - k.put("object" === typeof p ? JSON.stringify(p) : 1, l); + k.put(typeof p === "object" ? JSON.stringify(p) : 1, l); } }), 16); } @@ -3878,12 +3883,12 @@ w.commit = function(a, b, c) { break; } return K(g, d.transaction("tag", "readwrite", function(k) { - for (var m = B(a.tag), l = m.next(), p = {}; !l.done; p = {X:void 0, da:void 0}, l = m.next()) { - l = l.value, p.da = l[0], p.X = l[1], p.X.length && (k.get(p.da).onsuccess = function(n) { + for (var m = B(a.tag), l = m.next(), p = {}; !l.done; p = {T:void 0, Z:void 0}, l = m.next()) { + l = l.value, p.Z = l[0], p.T = l[1], p.T.length && (k.get(p.Z).onsuccess = function(n) { return function() { var q = this.result; - q = q && q.length ? q.concat(n.X) : n.X; - k.put(q, n.da); + q = q && q.length ? q.concat(n.T) : n.T; + k.put(q, n.Z); }; }(p)); } @@ -3893,12 +3898,12 @@ w.commit = function(a, b, c) { } }); }; -function gc(a, b, c) { +function hc(a, b, c) { for (var d = a.value, e, f = 0, h = 0, g; h < d.length; h++) { if (g = c ? d : d[h]) { for (var k = 0, m; k < b.length; k++) { - if (m = b[k], m = g.indexOf(m), 0 <= m) { - if (e = 1, 1 < g.length) { + if (m = b[k], m = g.indexOf(m), m >= 0) { + if (e = 1, g.length > 1) { g.splice(m, 1); } else { d[h] = []; @@ -3916,21 +3921,21 @@ function gc(a, b, c) { a.continue(); } w.remove = function(a) { - "object" !== typeof a && (a = [a]); + typeof a !== "object" && (a = [a]); return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && gc(c, a); + c && hc(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && gc(c, a); + c && hc(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && gc(c, a, !0); + c && hc(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (var c = 0; c < a.length; c++) { @@ -3949,8 +3954,8 @@ function fc(a, b) { a = null; }); } -;var hc = {Index:Y, Charset:Ua, Encoder:Ka, Document:pb, Worker:mb, Resolver:Z, IndexedDB:ec, Language:{}}, ic = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self, jc; -(jc = ic.define) && jc.amd ? jc([], function() { - return hc; -}) : "object" === typeof ic.exports ? ic.exports = hc : ic.FlexSearch = hc; +;var ic = {Index:Y, Charset:Ua, Encoder:Ka, Document:pb, Worker:mb, Resolver:Z, IndexedDB:ec, Language:{}}, jc = typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : self, kc; +(kc = jc.define) && kc.amd ? kc([], function() { + return ic; +}) : typeof jc.exports === "object" ? jc.exports = ic : jc.FlexSearch = ic; }(this||self)); diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index a64d7ea..b1d1466 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,146 +1,145 @@ /**! - * FlexSearch.js v0.8.202 (ES5) + * FlexSearch.js v0.8.203 (ES5) * 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 w;function aa(a){var b=0;return function(){return b>>0)+"_",e=0;return b}); -H("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c>>0)+"_",e=0;return b}); +H("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;cc&&(c=Math.max(c+e,0));c"a1a".split(c).length; -this.numeric=P(a.numeric,e)}else{try{this.split=P(this.split,Fa)}catch(f){this.split=/\s+/}this.numeric=P(a.numeric,P(this.numeric,!0))}this.prepare=P(a.prepare,null,this.prepare);this.finalize=P(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:P(c&&new Set(c),null,this.filter);this.dedupe=P(a.dedupe,!0,this.dedupe);this.matcher=P((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=P((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=P((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=P(a.replacer,null,this.replacer);this.minlength=P(a.minlength,1,this.minlength);this.maxlength=P(a.maxlength,1024,this.maxlength);this.rtl=P(a.rtl,!1,this.rtl);if(this.cache=c=P(a.cache,!0,this.cache))this.F=null,this.U="number"===typeof c?c:2E5,this.B=new Map,this.D=new Map,this.I=this.H=128;this.h="";this.N=null;this.A="";this.O=null;if(this.matcher)for(a=B(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=B(this.stemmer.keys()), -b=a.next();!b.done;b=a.next())this.A+=(this.A?"|":"")+b.value;return this};w.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.O=null;this.cache&&La(this);return this};w.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&La(this);return this}; -w.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.N=null;this.cache&&La(this);return this}; -w.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&La(this);return this}; -w.encode=function(a,b){var c=this;if(this.cache&&a.length<=this.H)if(this.F){if(this.B.has(a))return this.B.get(a)}else this.F=setTimeout(La,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Ja?a.normalize("NFKD").replace(Ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(b){if(f[l])continue;f[l]=1}else{if(h===l)continue;h=l}if(d)e.push(l);else if(!this.filter||("function"===typeof this.filter?this.filter(l):!this.filter.has(l))){if(this.cache&&l.length<=this.I)if(this.F){var p=this.D.get(l);if(p||""===p){p&&e.push(p);continue}}else this.F=setTimeout(La,50,this);if(this.stemmer)for(this.O|| -(this.O=new RegExp("(?!^)("+this.A+")$")),p=void 0;p!==l&&2this.U&&(this.D.clear(),this.I=this.I/1.1|0));if(l){if(l!==n)if(b){if(f[l])continue;f[l]=1}else{if(g===l)continue;g=l}e.push(l)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.H&&(this.B.set(a,e),this.B.size>this.U&&(this.B.clear(),this.H=this.H/1.1|0));return e};function La(a){a.F=null;a.B.clear();a.D.clear()};function Ma(a,b,c){c||(b||"object"!==typeof a?"object"===typeof b&&(c=b,b=0):c=a);c&&(a=c.query||a,b=c.limit||b);var d=""+(b||0);if(c){var e=c;d+=(e.offset||0)+!!e.context+!!e.suggest+(!1!==e.resolve)+(e.resolution||this.resolution)+(e.boost||0)}a=(""+a).toLowerCase();this.cache||(this.cache=new Na);e=this.cache.get(a+d);if(!e){var f=c&&c.cache;f&&(c.cache=!1);e=this.search(a,b,c);f&&(c.cache=f);this.cache.set(a+d,e)}return e} -function Na(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}Na.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};Na.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};Na.prototype.remove=function(a){for(var b=B(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)}}; -Na.prototype.clear=function(){this.cache.clear();this.h=""};var Oa={normalize:!1,numeric:!1,dedupe:!1};var Pa={};var Qa=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 Ra=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Sa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];var Ta={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 Ua={Exact:Oa,Default:Pa,Normalize:Pa,LatinBalance:{mapper:Qa},LatinAdvanced:{mapper:Qa,matcher:Ra,replacer:Sa},LatinExtra:{mapper:Qa,replacer:Sa.concat([/(?!^)[aeo]/g,""]),matcher:Ra},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;b=h.length)b-=h.length;else{b=h[d?"splice":"slice"](b,c);if(h=b.length)if(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c)break;b=0}return e} -function Wa(a){if(!this||this.constructor!==Wa)return new Wa(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 f=0,h=0,g,k;h0?(d=Array.prototype.flat.call(d,b-1),c.push.apply(c,d)):c.push(d)});return c}}); +H("Promise.prototype.finally",function(a){return a?a:function(b){return this.then(function(c){return Promise.resolve(b()).then(function(){return c})},function(c){return Promise.resolve(b()).then(function(){throw c;})})}});function P(a,b,c){var d=typeof c,e=typeof a;if(d!=="undefined"){if(e!=="undefined"){if(c){if(e==="function"&&d===e)return function(f){return a(c(f))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){b=new Map(c);d=B(a);for(e=d.next();!e.done;e=d.next())e=e.value,b.set(e[0],e[1]);return b}if(b===Set){b=new Set(c);d=B(a.values());for(e=d.next();!e.done;e=d.next())b.add(e.value);return b}}}return a}return c}return e==="undefined"?b:a} +function Ba(a,b){return typeof a==="undefined"?b:a}function S(){return Object.create(null)}function T(a){return typeof a==="string"}function Ca(a){return typeof a==="object"}function Da(a){var b=[];a=B(a.keys());for(var c=a.next();!c.done;c=a.next())b.push(c.value);return b}function Ea(a,b){if(T(b))a=a[b];else for(var c=0;a&&c1)return this.addMatcher(a,b);this.mapper||(this.mapper=new Map);this.mapper.set(a,b);this.cache&&La(this);return this};w.addMatcher=function(a,b){if(typeof a==="object")return this.addReplacer(a,b);if(a.length<2&&(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.K=null;this.cache&&La(this);return this}; +w.addReplacer=function(a,b){if(typeof a==="string")return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&La(this);return this}; +w.encode=function(a,b){var c=this;if(this.cache&&a.length<=this.H)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(La,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=Ja?a.normalize("NFKD").replace(Ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(Ha,"$1 $2").replace(Ia,"$1 $2").replace(Ga,"$1 "));for(var d=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer), +e=[],f=S(),h,g,k=this.split||this.split===""?a.split(this.split):[a],m=0,l=void 0,p=void 0;mthis.maxlength)){if(b){if(f[l])continue;f[l]=1}else{if(h===l)continue;h=l}if(d)e.push(l);else if(!this.filter||(typeof this.filter==="function"?this.filter(l):!this.filter.has(l))){if(this.cache&&l.length<=this.I)if(this.D){var n=this.C.get(l);if(n||n===""){n&&e.push(n);continue}}else this.D=setTimeout(La,50,this);if(this.stemmer)for(this.L|| +(this.L=new RegExp("(?!^)("+this.A+")$")),n=void 0;n!==l&&l.length>2;)n=l,l=l.replace(this.L,function(z){return c.stemmer.get(z)});if(l&&(this.mapper||this.dedupe&&l.length>1)){n="";for(var q=0,t="",u=void 0,v=void 0;q1&&(this.K||(this.K=new RegExp("("+this.h+")","g")),l=l.replace(this.K,function(z){return c.matcher.get(z)}));if(l&&this.replacer)for(n= +0;l&&nthis.P&&(this.C.clear(),this.I=this.I/1.1|0));if(l){if(l!==p)if(b){if(f[l])continue;f[l]=1}else{if(g===l)continue;g=l}e.push(l)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.H&&(this.B.set(a,e),this.B.size>this.P&&(this.B.clear(),this.H=this.H/1.1|0));return e};function La(a){a.D=null;a.B.clear();a.C.clear()};function Ma(a,b,c){c||(b||typeof a!=="object"?typeof b==="object"&&(c=b,b=0):c=a);c&&(a=c.query||a,b=c.limit||b);var d=""+(b||0);if(c){var e=c;d+=(e.offset||0)+!!e.context+!!e.suggest+(e.resolve!==!1)+(e.resolution||this.resolution)+(e.boost||0)}a=(""+a).toLowerCase();this.cache||(this.cache=new Na);e=this.cache.get(a+d);if(!e){var f=c&&c.cache;f&&(c.cache=!1);e=this.search(a,b,c);f&&(c.cache=f);this.cache.set(a+d,e)}return e} +function Na(a){this.limit=a&&a!==!0?a:1E3;this.cache=new Map;this.h=""}Na.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};Na.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};Na.prototype.remove=function(a){for(var b=B(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)}}; +Na.prototype.clear=function(){this.cache.clear();this.h=""};var Oa={normalize:!1,numeric:!1,dedupe:!1};var Pa={};var Qa=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 Ra=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Sa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];var Ta={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 Ua={Exact:Oa,Default:Pa,Normalize:Pa,LatinBalance:{mapper:Qa},LatinAdvanced:{mapper:Qa,matcher:Ra,replacer:Sa},LatinExtra:{mapper:Qa,replacer:Sa.concat([/(?!^)[aeo]/g,""]),matcher:Ra},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;b=h.length)b-=h.length;else{b=h[d?"splice":"slice"](b,c);if(h=b.length)if(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c)break;b=0}return e} +function Wa(a){if(!this||this.constructor!==Wa)return new Wa(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if(d==="length")return b.length;if(d==="push")return function(e){b.index[b.index.length-1].push(e);b.length++};if(d==="pop")return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if(d==="indexOf")return function(e){for(var f=0,h=0,g,k;h=0)return f+k;f+=g.length}return-1}; +if(d==="includes")return function(e){for(var f=0;f32?(this.A=Ya,this.B=BigInt(a)):(this.A=Za,this.B=a)}Xa.prototype.get=function(a){var b=this.A(a);return(b=this.index[b])&&b.get(a)};Xa.prototype.set=function(a,b){var c=this.A(a),d=this.index[c];d?(c=d.size,d.set(a,b),(c-=d.size)&&this.size++):(this.index[c]=d=new Map([[a,b]]),this.h.push(d),this.size++)}; +function X(a){a=a===void 0?8:a;if(!this||this.constructor!==X)return new X(a);this.index=S();this.h=[];this.size=0;a>32?(this.A=Ya,this.B=BigInt(a)):(this.A=Za,this.B=a)}X.prototype.add=function(a){var b=this.A(a),c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c),this.size++)};w=Xa.prototype;w.has=X.prototype.has=function(a){var b=this.A(a);return(b=this.index[b])&&b.has(a)}; +w.delete=X.prototype.delete=function(a){var b=this.A(a);(b=this.index[b])&&b.delete(a)&&this.size--};w.clear=X.prototype.clear=function(){this.index=S();this.h=[];this.size=0};w.values=X.prototype.values=function $a(){var b,c=this,d,e,f;return ua($a,function(h){switch(h.h){case 1:b=0;case 2:if(!(b=this.priority*this.priority*3):(hb=setTimeout(kb,0),ib=Date.now());if(jb){var e=this;return new Promise(function(h){setTimeout(function(){h(e[a+"Async"].apply(e,b))},0)})}var f=this[a].apply(this,b);c=f.then?f:new Promise(function(h){return h(f)});d&&c.then(d);return c}};var lb=0; -function mb(a,b){function c(g){function k(m){m=m.data||m;var l=m.id,n=l&&f.h[l];n&&(n(m.msg),delete f.h[l])}this.worker=g;this.h=S();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(m){1E9b?a.slice(c,c+b):a,d?tb.call(this,a):a;for(var e=[],f=0,h=void 0,g=void 0;f=g){c-=g;continue}h=h.slice(c,c+b);g=h.length;c=0}g>b&&(h=h.slice(0,b),g=b);if(!e.length&&g>=b)return d?tb.call(this,h):h;e.push(h);b-=g;if(!b)break}e=1a.length?this.result=a[0]:(this.result=yb(a,b,c,!1,this.h),c=0));e&&(this.await=null);return e?this.resolve(b,c,d,h):this};Z.prototype.and=function(){return ub(this,"and",zb,arguments)};function zb(a,b,c,d,e,f,h){if(!f&&!this.result.length)return e?this.result:this;if(a.length)if(this.result.length&&a.unshift(this.result),2>a.length)this.result=a[0];else{for(var g=0,k=0,m=void 0,l=void 0;ka.length)this.result=a[0];else{a:{f=c;var g=this.h;for(var k=[],m=S(),l=0,n=0,p;nG&&(G=r.length+(r?1:0)),N=r.length+(r?1:0)+ba.length,Q+=L,U.push(F.length),F.push({match:ba})),r+=(r?" ":"")+ba)}if(!O)R=y[E],r+=(r?" ":"")+R,k&&F.push({text:R});else if(k&&Q>=k)break}Q=U.length*(f.length-2);if(q||t||k&&r.length-Q>k)if(Q=k+Q-2*p,E=N-G,0y&&(y=0)),F=F.length-1){if(J>=F.length){E[A+1]=1;J>=y.length&&(G[A+1]=1);continue}O-=p}r=F[J].text;var V=t&&W[A];if(V)if(0< -V){if(r.length>V)if(E[A+1]=1,m)r=r.substring(0,V);else continue;(V-=r.length)||(V=-1);W[A]=V}else{E[A+1]=1;continue}if(O+r.length+1<=k)r=" "+r,N[A]+=r;else if(m)I=k-O-1,0=J){if(0>J){E[A]=1;G[A]=1;continue}O-=p}r=F[J].text;if(V=q&&R[A])if(0V)if(E[A]=1,m)r=r.substring(r.length-V);else continue;(V-=r.length)||(V=-1);R[A]=V}else{E[A]=1;continue}if(O+ -r.length+1<=k)r+=" ",N[A]=r+N[A];else if(m)I=r.length+1-(k-O),0<=I&&I=y.length-1?I=1:Jc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d, +function eb(a){var b,c,d,e,f,h;return wa(function(g){switch(g.h){case 1:a=a.data;b=a.task;c=a.id;d=a.args;switch(b){case "init":db=a.options||{};(e=a.factory)?(Function("return "+e)()(self),cb=new self.FlexSearch.Index(db),delete self.FlexSearch):cb=new Y(db);postMessage({id:c});break;default:g.h=2;return}g.h=0;break;case 2:b==="export"&&(d[1]?(d[0]=db.export,d[2]=0,d[3]=1):d=null);if(b==="import"){if(!d[0]){g.h=5;break}return K(g,db.import.call(cb,d[0]),11)}f=d&&cb[b].apply(cb,d);if(!f||!f.then){g.h= +6;break}return K(g,f,7);case 7:f=g.B;case 6:if(!f||!f.await){g.h=8;break}return K(g,f.await,9);case 9:f=g.B;case 8:b==="search"&&f.result&&(f=f.result);g.h=5;break;case 11:h=g.B,cb.import(d[0],h);case 5:postMessage(b==="search"?{id:c,msg:f}:{id:c}),g.h=0}})};function fb(a){gb.call(a,"add");gb.call(a,"append");gb.call(a,"search");gb.call(a,"update");gb.call(a,"remove");gb.call(a,"searchCache")}var hb,ib,jb;function kb(){hb=jb=0} +function gb(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if(typeof c==="function"){var d=c;delete b[b.length-1]}hb?jb||(jb=Date.now()-ib>=this.priority*this.priority*3):(hb=setTimeout(kb,0),ib=Date.now());if(jb){var e=this;return new Promise(function(h){setTimeout(function(){h(e[a+"Async"].apply(e,b))},0)})}var f=this[a].apply(this,b);c=f.then?f:new Promise(function(h){return h(f)});d&&c.then(d);return c}};var lb=0; +function mb(a,b){function c(g){function k(m){m=m.data||m;var l=m.id,p=l&&f.h[l];p&&(p(m.msg),delete f.h[l])}this.worker=g;this.h=S();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(m){lb>1E9&&(lb=0);f.h[++lb]=function(){m(f)};f.worker.postMessage({id:lb,task:"init",factory:d,options:a})});this.priority=a.priority||4;this.encoder=b||null;this.worker.postMessage({task:"init",factory:d,options:a});return this}}a=a===void 0?{}:a;if(!this||this.constructor!== +mb)return new mb(a);var d=typeof self!=="undefined"?self._factory:typeof window!=="undefined"?window._factory:null;d&&(d=d.toString());var e=typeof window==="undefined",f=this,h=nb(d,e,a.worker);return h.then?h.then(function(g){return c.call(f,g)}):c.call(this,h)}ob("add");ob("append");ob("search");ob("update");ob("remove");ob("clear");ob("export");ob("import");mb.prototype.searchCache=Ma;fb(mb.prototype); +function ob(a){mb.prototype[a]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(typeof d==="function"){var e=d;c.pop()}d=new Promise(function(f){a==="export"&&typeof c[0]==="function"&&(c[0]=null);lb>1E9&&(lb=0);b.h[++lb]=f;b.worker.postMessage({task:a,id:lb,args:c})});return e?(d.then(e),this):d}} +function nb(a,b,c){return b?typeof module!=="undefined"?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="+eb.toString()],{type:"text/javascript"}))):new window.Worker(typeof c==="string"?c:(0,eval)("import.meta.url").replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", +"module/worker/worker.js"),{type:"module"})};pb.prototype.add=function(a,b,c){Ca(a)&&(b=a,a=Ea(b,this.key));if(b&&(a||a===0)){if(!c&&this.reg.has(a))return this.update(a,b);for(var d=0,e;db?a.slice(c,c+b):a,d?tb.call(this,a):a;for(var e=[],f=0,h=void 0,g=void 0;f=g){c-=g;continue}h=h.slice(c,c+b);g=h.length;c=0}g>b&&(h=h.slice(0,b),g=b);if(!e.length&&g>=b)return d?tb.call(this,h):h;e.push(h);b-=g;if(!b)break}e=e.length>1?[].concat.apply([],e):e[0];return d?tb.call(this,e):e};function ub(a,b,c,d){var e=d[0];if(e[0]&&e[0].query)return a[b].apply(a,e);if(!(b!=="and"&&b!=="not"||a.result.length||a.await||e.suggest))return d.length>1&&(e=d[d.length-1]),(d=e.resolve)?a.await||a.result:a;var f=[],h=0,g=0,k,m;b={};for(e=0;e1&&(c=c[b].apply(c,a.slice(1)));return c};Z.prototype.or=function(){return ub(this,"or",xb,arguments)};function xb(a,b,c,d,e,f,h){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=yb(a,b,c,!1,this.h),c=0));e&&(this.await=null);return e?this.resolve(b,c,d,h):this};Z.prototype.and=function(){return ub(this,"and",zb,arguments)};function zb(a,b,c,d,e,f,h){if(!f&&!this.result.length)return e?this.result:this;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{for(var g=0,k=0,m=void 0,l=void 0;k1?W.join(" "):W[0];var O=void 0;if(W&&R){for(var L=R.length,M=(z.split?R.replace(z.split,""):R).length-W.length,ba="",na=0,A=0;A-1&&(ba=(I?R.substring(0,I):"")+h+R.substring(I,I+J)+g+(I+J=k)break}Q=U.length*(f.length-2);if(q||t||k&&r.length-Q>k)if(Q=k+Q-n*2,E=N-G,q>0&&(E+=q),t>0&&(E+=t),E<=Q)y=q?G-(q>0?q:0):G-((Q-E)/2|0),F=t?N+(t>0?t:0):y+Q,m|| +(y>0&&r.charAt(y)!==" "&&r.charAt(y-1)!==" "&&(y=r.indexOf(" ",y),y<0&&(y=0)),F=F.length-1){if(J>=F.length){E[A+1]=1;J>=y.length&&(G[A+1]=1);continue}O-=n}r=F[J].text;var V=t&&W[A];if(V)if(V> +0){if(r.length>V)if(E[A+1]=1,m)r=r.substring(0,V);else continue;(V-=r.length)||(V=-1);W[A]=V}else{E[A+1]=1;continue}if(O+r.length+1<=k)r=" "+r,N[A]+=r;else if(m)I=k-O-1,I>0&&(r=" "+r.substring(0,I),N[A]+=r),E[A+1]=1;else{E[A+1]=1;continue}}else{if(E[A])continue;J-=L;if(Q[J]){O-=n;E[A]=1;G[A]=1;continue}if(J<=0){if(J<0){E[A]=1;G[A]=1;continue}O-=n}r=F[J].text;if(V=q&&R[A])if(V>0){if(r.length>V)if(E[A]=1,m)r=r.substring(r.length-V);else continue;(V-=r.length)||(V=-1);R[A]=V}else{E[A]=1;continue}if(O+ +r.length+1<=k)r+=" ",N[A]=r+N[A];else if(m)I=r.length+1-(k-O),I>=0&&I=y.length-1?I=1:J1?yb(k,c,d,h,f):(k=k[0])&&c&&k.length>c||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d, c+d)}else{e=[];for(f=0;fd)d-=h.length;else{if(c&&h.length>c||d)h=h.slice(d,c+d),c-=h.length,d&&(d-=h.length);e.push(h);if(!c)break}k=e}}return k} -function yb(a,b,c,d,e){var f=[],h=S(),g=a.length,k;if(d)for(e=g-1;0<=e;e--){if(k=(d=a[e])&&d.length)for(g=0;gc||d)a=a.slice(d,d+c);e&&(a=tb.call(this,a))}return a} -function tb(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);for(var b=Array(a.length),c=0,d;c=0;e--){if(k=(d=a[e])&&d.length)for(g=0;g=0;l--){p=a[l];for(var q=0;q1?Ab(e,1,0,0,q,l):e[0],N)})}return g?e:new Z(e.length>1?Ab(e,1,0,0,q,l):e[0],this)}}g||k||!(p=p||this.field)||(T(p)?k=p:(p.constructor===Array&&p.length===1&&(p=p[0]),k=p.field||p.index));p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);x=(this.worker||this.db)&&!d&&[];C=0;for(y=D=r=void 0;C0){if(c&&b>c||d)a=a.slice(d,d+c);e&&(a=tb.call(this,a))}return a} +function tb(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);for(var b=Array(a.length),c=0,d;c1?c:c[0]}w.append=function(a,b){return this.add(a,b,!0)}; w.update=function(a,b){return this.remove(a).add(a,b)}; -w.remove=function(a){Ca(a)&&(a=Ea(a,this.key));for(var b=B(this.index.values()),c=b.next();!c.done;c=b.next())c.value.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(b=B(this.tag.values()),c=b.next();!c.done;c=b.next()){c=c.value;for(var d=B(c),e=d.next();!e.done;e=d.next()){var f=e.value;e=f[0];f=f[1];var h=f.indexOf(a);-1-1&&(f.length>1?f.splice(h,1):c.delete(e))}}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; w.clear=function(){for(var a=[],b=B(this.index.values()),c=b.next();!c.done;c=b.next())c=c.value.clear(),c.then&&a.push(c);if(this.tag)for(b=B(this.tag.values()),c=b.next();!c.done;c=b.next())c.value.clear();this.store&&this.store.clear();this.cache&&this.cache.clear();return a.length?Promise.all(a):this};w.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.reg.has(a)}; -w.cleanup=function(){for(var a=B(this.index.values()),b=a.next();!b.done;b=a.next())b.value.cleanup();return this};w.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};w.set=function(a,b){"object"===typeof a&&(b=a,a=Ea(b,this.key));this.store.set(a,b);return this};w.searchCache=Ma;w.export=Jb;w.import=Kb;fb(pb.prototype);function Lb(a,b){b=void 0===b?0:b;var c=[],d=[];b&&(b=25E4/b*5E3|0);a=B(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 Mb(a,b){b||(b=new Map);for(var c=0,d;cn;t--)p=m.substring(n,t),q=this.rtl?l-1-n:n,q=this.score?this.score(b,m,k,p,q):Wb(g,e,k,l,q),Xb(this, -h,p,q,a,c);break}case "bidirectional":case "reverse":if(1p?0:1),e,k,t-1,q-1),v=this.bidirectional&& -m>n;Xb(this,f,v?n:m,u,a,c,v?m:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.ea&&Ub(this));return this}; -function Xb(a,b,c,d,e,f,h){var g=h?a.ctx:a.map,k;if(!b[c]||h&&!(k=b[c])[h])if(h?(b=k||(b[c]=S()),b[h]=1,(k=g.get(h))?g=k:g.set(h,g=new Map)):b[c]=1,(k=g.get(c))?g=k:g.set(c,g=k=[]),g=g[d]||(g[d]=[]),!f||!g.includes(e)){if(g.length===Math.pow(2,31)-1){b=new Wa(g);if(a.fastupdate)for(c=B(a.reg.values()),f=c.next();!f.done;f=c.next())f=f.value,f.includes(g)&&(f[f.indexOf(g)]=b);k[d]=g=b}g.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(g):a.reg.set(e,[g]))}} -function Wb(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,f,h,g);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function Y(a,b){if(!this||this.constructor!==Y)return new Y(a);if(a){var c=T(a)?a:a.preset;c&&(a=Object.assign({},Vb[c],a))}else a={};c=a.context;var d=!0===c?{depth:1}:c||{},e=T(a.encoder)?Ua[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new Ka(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new Xa(c):new Map;this.ctx=c?new Xa(c):new Map;this.reg=b||(this.fastupdate?c?new Xa(c):new Map:c?new X(c):new Set);this.ga=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new Na(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.ea=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}w=Y.prototype; +w.cleanup=function(){for(var a=B(this.index.values()),b=a.next();!b.done;b=a.next())b.value.cleanup();return this};w.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};w.set=function(a,b){typeof a==="object"&&(b=a,a=Ea(b,this.key));this.store.set(a,b);return this};w.searchCache=Ma;w.export=Jb;w.import=Kb;fb(pb.prototype);function Lb(a,b){b=b===void 0?0:b;var c=[],d=[];b&&(b=25E4/b*5E3|0);a=B(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 Mb(a,b){b||(b=new Map);for(var c=0,d;c2?c[0]:"";c=c.length>2?c[2]:c[1];if(this.worker&&d)return this.index.get(d).import(a);if(b){typeof b==="string"&&(b=JSON.parse(b));if(d)return this.index.get(d).import(c,b);switch(c){case "reg":this.fastupdate=!1;this.reg=Qb(b,this.reg);for(b=0;b=0&&e.splice(h,1)}}else Tb(this.map,a),this.depth&&Tb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.$&&Ub(this));this.cache&&this.cache.remove(a);return this}; +function Tb(a,b){var c=0,d=typeof b==="undefined";if(a.constructor===Array)for(var e=0,f=void 0,h,g=void 0;e=0){if(f.length>1)return f.splice(h,1),1;delete a[e];if(c)return 1;g=1}else{if(g)return 1;c++}}}else for(d=B(a.entries()),e=d.next();!e.done;e=d.next())e=e.value,f=e[0],Tb(e[1],b)?c++:a.delete(f);return c};var Vb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};Y.prototype.add=function(a,b,c,d){if(b&&(a||a===0)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);d=this.depth;b=this.encoder.encode(b,!d);var e=b.length;if(e){for(var f=S(),h=S(),g=this.resolution,k=0;k2)for(var q=1,t,u;q2){for(p=0;pp;q--)n=m.substring(p,q),h[n]||(t=this.rtl?l-1-p:p,t=this.score?this.score(b,m,k,n,t):Wb(g,e,k,l,t),Xb(this,h,n,t,a,c));break}case "bidirectional":case "reverse":if(l>1){for(q=l-1;q>0;q--)n=m[this.rtl?l-1-q:q]+n,h[n]||(t=this.score?this.score(b,m,k,n,q):Wb(g,e,k,l,q),Xb(this,h,n,t,a,c));n=""}case "forward":if(l>1){for(q=0;q1&&kn?0:1),e,k,q-1,t-1);var v=this.bidirectional&&m>p;Xb(this,f,v?p:m,u,a,c,v?m:p)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.$&&Ub(this));return this}; +function Xb(a,b,c,d,e,f,h){var g=h?a.ctx:a.map,k;if(!b[c]||h&&!(k=b[c])[h])if(h?(b=k||(b[c]=S()),b[h]=1,(k=g.get(h))?g=k:g.set(h,g=new Map)):b[c]=1,(k=g.get(c))?g=k:g.set(c,g=k=[]),g=g[d]||(g[d]=[]),!f||!g.includes(e)){if(g.length===2147483647){b=new Wa(g);if(a.fastupdate)for(c=B(a.reg.values()),f=c.next();!f.done;f=c.next())f=f.value,f.includes(g)&&(f[f.indexOf(g)]=b);k[d]=g=b}g.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(g):a.reg.set(e,[g]))}} +function Wb(a,b,c,d,e){return c&&a>1?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0};Y.prototype.search=function(a,b,c){c||(b||typeof a!=="object"?typeof b==="object"&&(c=b,b=0):(c=a,a=""));if(c&&c.cache)return c.cache=!1,a=this.searchCache(a,b,c),c.cache=!0,a;var d=[],e=0,f;if(c){a=c.query||a;b=c.limit||b;e=c.offset||0;var h=c.context;var g=c.suggest;var k=(f=c.resolve)&&c.enrich;var m=c.boost;var l=c.resolution;var p=this.db&&c.tag}typeof f==="undefined"&&(f=this.resolve);h=this.depth&&h!==!1;var n=this.encoder.encode(a,!h);var q=n.length;b=b||(f?100:0);if(q===1)return Yb.call(this, +n[0],"",b,e,f,k,p);if(q===2&&h&&!g)return Yb.call(this,n[1],n[0],b,e,f,k,p);var t=S(),u=0;if(h){var v=n[0];u=1}l||l===0||(l=v?this.ba:this.resolution);if(this.db){if(this.db.search&&(c=this.db.search(this,n,b,e,g,f,k,p),c!==!1))return c;var z=this;return function(){var x,C;return wa(function(D){switch(D.h){case 1:C=x=void 0;case 2:if(!(u1)k=Ab(a,b,c,d,e,f,h);else if(g===1)return h?sb.call(null,a[0],c,d):new Z(a[0],this);return h?k:new Z(k,this)}function Yb(a,b,c,d,e,f,h){a=Zb(this,a,b,c,d,e,f,h);return this.db?a.then(function(g){return e?g||[]:new Z(g,this)}):a&&a.length?e?sb.call(this,a,c,d):new Z(a,this):e?[]:new Z([],this)} +function $b(a,b,c,d){var e=[];if(a&&a.length){if(a.length<=d){b.push(a);return}for(var f=0,h;fc)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,f,h,g);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function Y(a,b){if(!this||this.constructor!==Y)return new Y(a);if(a){var c=T(a)?a:a.preset;c&&(a=Object.assign({},Vb[c],a))}else a={};c=a.context;var d=c===!0?{depth:1}:c||{},e=T(a.encoder)?Ua[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:typeof e==="object"?new Ka(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&c!=="default"&&c!=="exact"&&c||"strict";this.depth=c==="strict"&&d.depth||0;this.bidirectional=d.bidirectional!==!1;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new Xa(c):new Map;this.ctx=c?new Xa(c):new Map;this.reg=b||(this.fastupdate?c?new Xa(c):new Map:c?new X(c):new Set);this.ba=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new Na(c);this.resolve=a.resolve!==!1;if(c=a.db)this.db=this.mount(c);this.$=a.commit!==!1;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}w=Y.prototype; w.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};w.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};w.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function Ub(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this};w.append=function(a,b){return this.add(a,b,!0)};w.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};w.update=function(a,b){var c=this,d=this.remove(a);return d&&d.then?d.then(function(){return c.add(a,b)}):this.add(a,b)}; -w.cleanup=function(){if(!this.fastupdate)return this;Tb(this.map);this.depth&&Tb(this.ctx);return this};w.searchCache=Ma;w.export=function(a,b,c,d){c=void 0===c?0:c;d=void 0===d?0:d;switch(d){case 0:var e="reg";var f=Pb(this.reg);break;case 1:e="cfg";f=null;break;case 2:e="map";f=Lb(this.map,this.reg.size);break;case 3:e="ctx";f=Nb(this.ctx,this.reg.size);break;default:return}return Rb.call(this,a,b,e,f,c,d)}; -w.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=11?a[1]:a[0],a){case "reg":this.fastupdate=!1;this.reg=Qb(b,this.reg);break;case "map":this.map=Mb(b,this.map);break;case "ctx":this.ctx=Ob(b,this.ctx)}}; +w.serialize=function(a){a=a===void 0?!0:a;var b="",c="",d="";if(this.reg.size){var e;c=B(this.reg.keys());for(var f=c.next();!f.done;f=c.next())f=f.value,e||(e=typeof f),b+=(b?",":"")+(e==="string"?'"'+f+'"':f);b="index.reg=new Set(["+b+"]);";c=Sb(this.map,e);c="index.map=new Map(["+c+"]);";f=B(this.ctx.entries());for(var h=f.next();!h.done;h=f.next()){var g=h.value;h=g[0];g=Sb(g[1],e);g="new Map(["+g+"])";g='["'+h+'",'+g+"]";d+=(d?",":"")+g}d="index.ctx=new Map(["+d+"]);"}return a?"function inject(index){"+ +b+c+d+"}":b+c+d};fb(Y.prototype);var bc=typeof window!=="undefined"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),cc=["map","ctx","tag","reg","cfg"],dc=S(); +function ec(a,b){b=b===void 0?{}:b;if(!this||this.constructor!==ec)return new ec(a,b);typeof a==="object"&&(b=a,a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.type=b.type;this.fastupdate=this.support_tag_search=!1;this.db=null;this.h={}}w=ec.prototype; w.mount=function(a){if(a.index)return a.mount(this);a.db=this;return this.open()}; -w.open=function(){if(this.db)return this.db;var a=this;navigator.storage&&navigator.storage.persist();dc[a.id]||(dc[a.id]=[]);dc[a.id].push(a.field);var b=bc.open(a.id,1);b.onupgradeneeded=function(){for(var c=a.db=this.result,d=0,e;d=l.length)d-=l.length;else{for(var n=c?d+Math.min(l.length-d,c): -l.length,p=d;p=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; -w.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d=l.length)d-=l.length;else{for(var p=c?d+Math.min(l.length-d,c): +l.length,n=d;n=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; +w.enrich=function(a){typeof a!=="object"&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d=0)if(e=1,g.length>1)g.splice(m,1);else{d[h]=[];break}f+=g.length}if(c)break}f?e&&a.update(d):a.delete();a.continue()} +w.remove=function(a){typeof a!=="object"&&(a=[a]);return Promise.all([this.transaction("map","readwrite",function(b){b.openCursor().onsuccess=function(){var c=this.result;c&&hc(c,a)}}),this.transaction("ctx","readwrite",function(b){b.openCursor().onsuccess=function(){var c=this.result;c&&hc(c,a)}}),this.transaction("tag","readwrite",function(b){b.openCursor().onsuccess=function(){var c=this.result;c&&hc(c,a,!0)}}),this.transaction("reg","readwrite",function(b){for(var c=0;c "a1a".split(b).length; + this.split = b, f = b === !1 || "a1a".split(b).length < 2; } - this.numeric = u(a.numeric, f); + this.numeric = v(a.numeric, f); } else { try { - this.split = u(this.split, A); + this.split = v(this.split, A); } 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(a.numeric, u(this.numeric, !0)); + this.numeric = v(a.numeric, v(this.numeric, !0)); } - this.prepare = u(a.prepare, null, this.prepare); - this.finalize = u(a.finalize, null, this.finalize); + this.prepare = v(a.prepare, null, this.prepare); + this.finalize = v(a.finalize, null, this.finalize); b = a.filter; - this.filter = "function" === typeof b ? b : u(b && new Set(b), null, this.filter); - this.dedupe = u(a.dedupe, !0, this.dedupe); - 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, 1024, this.maxlength); - this.rtl = u(a.rtl, !1, this.rtl); - if (this.cache = b = u(a.cache, !0, this.cache)) { - this.l = null, this.A = "number" === typeof b ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.m = 128; + this.filter = typeof b === "function" ? b : v(b && new Set(b), null, this.filter); + this.dedupe = v(a.dedupe, !0, this.dedupe); + this.matcher = v((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = v((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = v((b = a.stemmer) && new Map(b), null, this.stemmer); + this.replacer = v(a.replacer, null, this.replacer); + this.minlength = v(a.minlength, 1, this.minlength); + this.maxlength = v(a.maxlength, 1024, this.maxlength); + this.rtl = v(a.rtl, !1, this.rtl); + if (this.cache = b = v(a.cache, !0, this.cache)) { + this.l = null, this.A = typeof b === "number" ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.m = 128; } this.g = ""; this.s = null; @@ -125,7 +125,7 @@ r.assign = function(a) { } return this; }; -r.addStemmer = function(a, c) { +u.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); this.h += (this.h ? "|" : "") + a; @@ -133,16 +133,16 @@ r.addStemmer = function(a, c) { this.cache && G(this); return this; }; -r.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); +u.addFilter = function(a) { + typeof a === "function" ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); this.cache && G(this); return this; }; -r.addMapper = function(a, c) { - if ("object" === typeof a) { +u.addMapper = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (1 < a.length) { + if (a.length > 1) { return this.addMatcher(a, c); } this.mapper || (this.mapper = new Map()); @@ -150,11 +150,11 @@ r.addMapper = function(a, c) { this.cache && G(this); return this; }; -r.addMatcher = function(a, c) { - if ("object" === typeof a) { +u.addMatcher = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (2 > a.length && (this.dedupe || this.mapper)) { + if (a.length < 2 && (this.dedupe || this.mapper)) { return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); @@ -164,8 +164,8 @@ r.addMatcher = function(a, c) { this.cache && G(this); return this; }; -r.addReplacer = function(a, c) { - if ("string" === typeof a) { +u.addReplacer = function(a, c) { + if (typeof a === "string") { return this.addMatcher(a, c); } this.replacer || (this.replacer = []); @@ -173,7 +173,7 @@ r.addReplacer = function(a, c) { this.cache && G(this); return this; }; -r.encode = function(a, c) { +u.encode = function(a, c) { if (this.cache && a.length <= this.m) { if (this.l) { if (this.i.has(a)) { @@ -183,33 +183,33 @@ r.encode = function(a, c) { this.l = setTimeout(G, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); + this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(C, "$1 $2").replace(D, "$1 $2").replace(B, "$1 ")); + this.numeric && a.length > 3 && (a = a.replace(C, "$1 $2").replace(D, "$1 $2").replace(B, "$1 ")); const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let f = [], d = x(), h, e, k = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let n = 0, g, w; n < k.length; n++) { - if ((g = w = k[n]) && !(g.length < this.minlength || g.length > this.maxlength)) { + let f = [], d = y(), g, e, k = this.split || this.split === "" ? a.split(this.split) : [a]; + for (let n = 0, h, r; n < k.length; n++) { + if ((h = r = k[n]) && !(h.length < this.minlength || h.length > this.maxlength)) { if (c) { - if (d[g]) { + if (d[h]) { continue; } - d[g] = 1; + d[h] = 1; } else { - if (h === g) { + if (g === h) { continue; } - h = g; + g = h; } if (b) { - f.push(g); + f.push(h); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) { - if (this.cache && g.length <= this.o) { + if (!this.filter || (typeof this.filter === "function" ? this.filter(h) : !this.filter.has(h))) { + if (this.cache && h.length <= this.o) { if (this.l) { - var l = this.j.get(g); - if (l || "" === l) { - l && f.push(l); + var m = this.j.get(h); + if (m || m === "") { + m && f.push(m); continue; } } else { @@ -218,40 +218,40 @@ r.encode = function(a, c) { } if (this.stemmer) { this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")); - let v; - for (; v !== g && 2 < g.length;) { - v = g, g = g.replace(this.u, p => this.stemmer.get(p)); + let w; + for (; w !== h && h.length > 2;) { + w = h, h = h.replace(this.u, q => this.stemmer.get(q)); } } - if (g && (this.mapper || this.dedupe && 1 < g.length)) { - l = ""; - for (let v = 0, p = "", m, q; v < g.length; v++) { - m = g.charAt(v), m === p && this.dedupe || ((q = this.mapper && this.mapper.get(m)) || "" === q ? q === p && this.dedupe || !(p = q) || (l += q) : l += p = m); + if (h && (this.mapper || this.dedupe && h.length > 1)) { + m = ""; + for (let w = 0, q = "", l, p; w < h.length; w++) { + l = h.charAt(w), l === q && this.dedupe || ((p = this.mapper && this.mapper.get(l)) || p === "" ? p === q && this.dedupe || !(q = p) || (m += p) : m += q = l); } - g = l; + h = m; } - this.matcher && 1 < g.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), g = g.replace(this.s, v => this.matcher.get(v))); - if (g && this.replacer) { - for (l = 0; g && l < this.replacer.length; l += 2) { - g = g.replace(this.replacer[l], this.replacer[l + 1]); + this.matcher && h.length > 1 && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), h = h.replace(this.s, w => this.matcher.get(w))); + if (h && this.replacer) { + for (m = 0; h && m < this.replacer.length; m += 2) { + h = h.replace(this.replacer[m], this.replacer[m + 1]); } } - this.cache && w.length <= this.o && (this.j.set(w, g), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); - if (g) { - if (g !== w) { + this.cache && r.length <= this.o && (this.j.set(r, h), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); + if (h) { + if (h !== r) { if (c) { - if (d[g]) { + if (d[h]) { continue; } - d[g] = 1; + d[h] = 1; } else { - if (e === g) { + if (e === h) { continue; } - e = g; + e = h; } } - f.push(g); + f.push(h); } } } @@ -270,69 +270,69 @@ function G(a) { if (!a.length) { return a; } - if (1 === a.length) { + if (a.length === 1) { return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a; } let f = []; - for (let d = 0, h, e; d < a.length; d++) { - if ((h = a[d]) && (e = h.length)) { + for (let d = 0, g, e; d < a.length; d++) { + if ((g = a[d]) && (e = g.length)) { if (b) { if (b >= e) { b -= e; continue; } - h = h.slice(b, b + c); - e = h.length; + g = g.slice(b, b + c); + e = g.length; b = 0; } - e > c && (h = h.slice(0, c), e = c); + e > c && (g = g.slice(0, c), e = c); if (!f.length && e >= c) { - return h; + return g; } - f.push(h); + f.push(g); c -= e; if (!c) { break; } } } - return f = 1 < f.length ? [].concat.apply([], f) : f[0]; + return f = f.length > 1 ? [].concat.apply([], f) : f[0]; } -;x(); -I.prototype.remove = function(a, c) { +;y(); +J.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 f = 0, d, h; f < b.length; f++) { - if ((d = b[f]) && (h = d.length)) { - if (d[h - 1] === a) { + for (let f = 0, d, g; f < b.length; f++) { + if ((d = b[f]) && (g = d.length)) { + if (d[g - 1] === a) { d.pop(); } else { const e = d.indexOf(a); - 0 <= e && d.splice(e, 1); + e >= 0 && d.splice(e, 1); } } } } else { - J(this.map, a), this.depth && J(this.ctx, a); + K(this.map, a), this.depth && K(this.ctx, a); } c || this.reg.delete(a); } return this; }; -function J(a, c) { +function K(a, c) { let b = 0; - var f = "undefined" === typeof c; + var f = typeof c === "undefined"; if (a.constructor === Array) { - for (let d = 0, h, e, k; d < a.length; d++) { - if ((h = a[d]) && h.length) { + for (let d = 0, g, e, k; d < a.length; d++) { + if ((g = a[d]) && g.length) { if (f) { return 1; } - e = h.indexOf(c); - if (0 <= e) { - if (1 < h.length) { - return h.splice(e, 1), 1; + e = g.indexOf(c); + if (e >= 0) { + if (g.length > 1) { + return g.splice(e, 1), 1; } delete a[d]; if (b) { @@ -349,14 +349,14 @@ function J(a, c) { } } else { for (let d of a.entries()) { - f = d[0], J(d[1], c) ? b++ : a.delete(f); + f = d[0], K(d[1], c) ? b++ : a.delete(f); } } return b; } -;const K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -I.prototype.add = function(a, c, b, f) { - if (c && (a || 0 === a)) { +;const L = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +J.prototype.add = function(a, c, b, f) { + if (c && (a || a === 0)) { if (!f && !b && this.reg.has(a)) { return this.update(a, c); } @@ -364,49 +364,59 @@ I.prototype.add = function(a, c, b, f) { c = this.encoder.encode(c, !f); const n = c.length; if (n) { - const g = x(), w = x(), v = this.resolution; - for (let p = 0; p < n; p++) { - let m = c[this.rtl ? n - 1 - p : p]; - var d = m.length; - if (d && (f || !w[m])) { - var h = this.score ? this.score(c, m, p, null, 0) : L(v, n, p), e = ""; + const h = y(), r = y(), w = this.resolution; + for (let q = 0; q < n; q++) { + let l = c[this.rtl ? n - 1 - q : q]; + var d = l.length; + if (d && (f || !r[l])) { + var g = this.score ? this.score(c, l, q, null, 0) : M(w, n, q), e = ""; switch(this.tokenize) { + case "tolerant": + N(this, r, l, g, a, b); + if (d > 2) { + for (let p = 1, t, z, x, I; p < d - 1; p++) { + t = l.charAt(p), z = l.charAt(p + 1), x = l.substring(0, p) + z, I = l.substring(p + 2), e = x + t + I, r[e] || N(this, r, e, g, a, b), e = x + I, r[e] || N(this, r, e, g, a, b); + } + } + break; case "full": - if (2 < d) { - for (let q = 0, t; q < d; q++) { - for (h = d; h > q; h--) { - e = m.substring(q, h); - t = this.rtl ? d - 1 - q : q; - var k = this.score ? this.score(c, m, p, e, t) : L(v, n, p, d, t); - M(this, w, e, k, a, b); + if (d > 2) { + for (let p = 0, t; p < d; p++) { + for (g = d; g > p; g--) { + if (e = l.substring(p, g), !r[e]) { + t = this.rtl ? d - 1 - p : p; + var k = this.score ? this.score(c, l, q, e, t) : M(w, n, q, d, t); + N(this, r, e, k, a, b); + } } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (k = d - 1; 0 < k; k--) { - e = m[this.rtl ? d - 1 - k : k] + e; - var l = this.score ? this.score(c, m, p, e, k) : L(v, n, p, d, k); - M(this, w, e, l, a, b); + if (d > 1) { + for (k = d - 1; k > 0; k--) { + if (e = l[this.rtl ? d - 1 - k : k] + e, !r[e]) { + var m = this.score ? this.score(c, l, q, e, k) : M(w, n, q, d, k); + N(this, r, e, m, a, b); + } } e = ""; } case "forward": - if (1 < d) { + if (d > 1) { for (k = 0; k < d; k++) { - e += m[this.rtl ? d - 1 - k : k], M(this, w, e, h, a, b); + e += l[this.rtl ? d - 1 - k : k], r[e] || N(this, r, e, g, a, b); } break; } default: - if (M(this, w, m, h, a, b), f && 1 < n && p < n - 1) { - for (d = x(), e = this.v, h = m, k = Math.min(f + 1, this.rtl ? p + 1 : n - p), d[h] = 1, l = 1; l < k; l++) { - if ((m = c[this.rtl ? n - 1 - p - l : p + l]) && !d[m]) { - d[m] = 1; - const q = this.score ? this.score(c, h, p, m, l - 1) : L(e + (n / 2 > e ? 0 : 1), n, p, k - 1, l - 1), t = this.bidirectional && m > h; - M(this, g, t ? h : m, q, a, b, t ? m : h); + if (N(this, r, l, g, a, b), f && n > 1 && q < n - 1) { + for (d = y(), e = this.v, g = l, k = Math.min(f + 1, this.rtl ? q + 1 : n - q), d[g] = 1, m = 1; m < k; m++) { + if ((l = c[this.rtl ? n - 1 - q - m : q + m]) && !d[l]) { + d[l] = 1; + const p = this.score ? this.score(c, g, q, l, m - 1) : M(e + (n / 2 > e ? 0 : 1), n, q, k - 1, m - 1), t = this.bidirectional && l > g; + N(this, h, t ? g : l, p, a, b, t ? l : g); } } } @@ -418,96 +428,96 @@ I.prototype.add = function(a, c, b, f) { } return this; }; -function M(a, c, b, f, d, h, e) { - let k = e ? a.ctx : a.map, l; - if (!c[b] || e && !(l = c[b])[e]) { - e ? (c = l || (c[b] = x()), c[e] = 1, (l = k.get(e)) ? k = l : k.set(e, k = new Map())) : c[b] = 1, (l = k.get(b)) ? k = l : k.set(b, k = []), k = k[f] || (k[f] = []), h && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); +function N(a, c, b, f, d, g, e) { + let k = e ? a.ctx : a.map, m; + if (!c[b] || e && !(m = c[b])[e]) { + e ? (c = m || (c[b] = y()), c[e] = 1, (m = k.get(e)) ? k = m : k.set(e, k = new Map())) : c[b] = 1, (m = k.get(b)) ? k = m : k.set(b, k = []), k = k[f] || (k[f] = []), g && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); } } -function L(a, c, b, f, d) { - return b && 1 < a ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function M(a, c, b, f, d) { + return b && a > 1 ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;I.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); +;J.prototype.search = function(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = "")); var f = [], d = 0; if (b) { a = b.query || a; c = b.limit || c; d = b.offset || 0; - var h = b.context; + var g = b.context; var e = b.suggest; var k = !0; - var l = b.resolution; + var m = b.resolution; } - "undefined" === typeof k && (k = !0); - h = this.depth && !1 !== h; - a = this.encoder.encode(a, !h); + typeof k === "undefined" && (k = !0); + g = this.depth && g !== !1; + a = this.encoder.encode(a, !g); b = a.length; c = c || (k ? 100 : 0); - if (1 === b) { - return e = d, (d = N(this, a[0], "")) && d.length ? H.call(this, d, c, e) : []; + if (b === 1) { + return e = d, (d = O(this, a[0], "")) && d.length ? H.call(this, d, c, e) : []; } - if (2 === b && h && !e) { - return e = d, (d = N(this, a[1], a[0])) && d.length ? H.call(this, d, c, e) : []; + if (b === 2 && g && !e) { + return e = d, (d = O(this, a[1], a[0])) && d.length ? H.call(this, d, c, e) : []; } - k = x(); + k = y(); var n = 0; - if (h) { - var g = a[0]; + if (g) { + var h = a[0]; n = 1; } - l || 0 === l || (l = g ? this.v : this.resolution); - for (let m, q; n < b; n++) { - if ((q = a[n]) && !k[q]) { - k[q] = 1; - m = N(this, q, g); + m || m === 0 || (m = h ? this.v : this.resolution); + for (let l, p; n < b; n++) { + if ((p = a[n]) && !k[p]) { + k[p] = 1; + l = O(this, p, h); a: { - h = m; - var w = f, v = e, p = l; + g = l; + var r = f, w = e, q = m; let t = []; - if (h && h.length) { - if (h.length <= p) { - w.push(h); - m = void 0; + if (g && g.length) { + if (g.length <= q) { + r.push(g); + l = void 0; break a; } - for (let y = 0, z; y < p; y++) { - if (z = h[y]) { - t[y] = z; + for (let z = 0, x; z < q; z++) { + if (x = g[z]) { + t[z] = x; } } if (t.length) { - w.push(t); - m = void 0; + r.push(t); + l = void 0; break a; } } - m = v ? void 0 : t; + l = w ? void 0 : t; } - if (m) { - f = m; + if (l) { + f = l; break; } - g && (e && m && f.length || (g = q)); + h && (e && l && f.length || (h = p)); } - e && g && n === b - 1 && !f.length && (l = this.resolution, g = "", n = -1, k = x()); + e && h && n === b - 1 && !f.length && (m = this.resolution, h = "", n = -1, k = y()); } a: { a = f; f = a.length; - g = a; - if (1 < f) { + h = a; + if (f > 1) { b: { f = e; - g = a.length; + h = a.length; e = []; - b = x(); - for (let m = 0, q, t, y, z; m < l; m++) { - for (n = 0; n < g; n++) { - if (y = a[n], m < y.length && (q = y[m])) { - for (h = 0; h < q.length; h++) { - if (t = q[h], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), z = e[k] || (e[k] = []), z.push(t), c && k === g - 1 && z.length - d === c) { - g = d ? z.slice(d) : z; + b = y(); + for (let l = 0, p, t, z, x; l < m; l++) { + for (n = 0; n < h; n++) { + if (z = a[n], l < z.length && (p = z[l])) { + for (g = 0; g < p.length; g++) { + if (t = p[g], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), x = e[k] || (e[k] = []), x.push(t), c && k === h - 1 && x.length - d === c) { + h = d ? x.slice(d) : x; break b; } } @@ -516,16 +526,16 @@ function L(a, c, b, f, d) { } if (a = e.length) { if (f) { - if (1 < e.length) { + if (e.length > 1) { c: { - for (a = [], l = x(), f = e.length, k = f - 1; 0 <= k; k--) { + for (a = [], m = y(), f = e.length, k = f - 1; k >= 0; k--) { if (b = (f = e[k]) && f.length) { for (n = 0; n < b; n++) { - if (g = f[n], !l[g]) { - if (l[g] = 1, d) { + if (h = f[n], !m[h]) { + if (m[h] = 1, d) { d--; } else { - if (a.push(g), a.length === c) { + if (a.push(h), a.length === c) { break c; } } @@ -539,8 +549,8 @@ function L(a, c, b, f, d) { } e = a; } else { - if (a < g) { - g = []; + if (a < h) { + h = []; break b; } e = e[a - 1]; @@ -551,77 +561,77 @@ function L(a, c, b, f, d) { } } } - g = e; + h = e; } - } else if (1 === f) { + } else if (f === 1) { c = H.call(null, a[0], c, d); break a; } - c = g; + c = h; } return c; }; -function N(a, c, b) { +function O(a, c, b) { let f; b && (f = a.bidirectional && c > b) && (f = b, b = c, c = f); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function I(a, c) { - if (!this || this.constructor !== I) { - return new I(a); +;function J(a, c) { + if (!this || this.constructor !== J) { + return new J(a); } if (a) { - var b = "string" === typeof a ? a : a.preset; - b && (K[b] || console.warn("Preset not found: " + b), a = Object.assign({}, K[b], a)); + var b = typeof a === "string" ? a : a.preset; + b && (L[b] || console.warn("Preset not found: " + b), a = Object.assign({}, L[b], a)); } else { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new F(d) : {encode:d}; + const f = b === !0 ? {depth:1} : b || {}, d = a.encode || a.encoder || {}; + this.encoder = d.encode ? d : typeof d === "object" ? new F(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && f.depth || 0; - this.bidirectional = !1 !== f.bidirectional; + this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict"; + this.depth = b === "strict" && f.depth || 0; + this.bidirectional = f.bidirectional !== !1; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - f && f.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + f && f.depth && this.tokenize !== "strict" && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); this.map = new Map(); this.ctx = new Map(); this.reg = c || (this.fastupdate ? new Map() : new Set()); this.v = f.resolution || 3; this.rtl = d.rtl || a.rtl || !1; } -r = I.prototype; -r.clear = function() { +u = J.prototype; +u.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); return this; }; -r.append = function(a, c) { +u.append = function(a, c) { return this.add(a, c, !0); }; -r.contain = function(a) { +u.contain = function(a) { return this.reg.has(a); }; -r.update = function(a, c) { +u.update = function(a, c) { const b = this, f = this.remove(a); return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; -r.cleanup = function() { +u.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - J(this.map); - this.depth && J(this.ctx); + K(this.map); + this.depth && K(this.ctx); return this; }; -x(); -const O = {Index:I, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, P = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; -let Q; -(Q = P.define) && Q.amd ? Q([], function() { - return O; -}) : "object" === typeof P.exports ? P.exports = O : P.FlexSearch = O; +y(); +const P = {Index:J, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Q = typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : self; +let R; +(R = Q.define) && R.amd ? R([], function() { + return P; +}) : typeof Q.exports === "object" ? Q.exports = P : Q.FlexSearch = P; }(this||self)); diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js index 62537a8..4cc624d 100644 --- a/dist/flexsearch.light.min.js +++ b/dist/flexsearch.light.min.js @@ -1,26 +1,27 @@ /**! - * FlexSearch.js v0.8.202 (Light) + * FlexSearch.js v0.8.203 (Light) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function(self){'use strict';var r;function u(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var h=new Map(b);for(var e of a)h.set(e[0],e[1]);return h}if(c===Set){e=new Set(b);for(h of a.values())e.add(h);return e}}}return a}return b}return"undefined"===d?c:a}function x(){return Object.create(null)};const A=/[^\p{L}\p{N}]+/u,B=/(\d{3})/g,C=/(\D)(\d{3})/g,D=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; -this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,A)}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);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);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,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=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};r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; -r.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.s=null;this.cache&&G(this);return this}; -r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; -r.encode=function(a,c){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(c){if(d[g])continue;d[g]=1}else{if(h===g)continue;h=g}if(b)f.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.o)if(this.l){var l=this.j.get(g);if(l||""===l){l&&f.push(l);continue}}else this.l=setTimeout(G,50,this);if(this.stemmer){this.u||(this.u=new RegExp("(?!^)("+ -this.h+")$"));let v;for(;v!==g&&2this.stemmer.get(p))}if(g&&(this.mapper||this.dedupe&&1this.matcher.get(v)));if(g&&this.replacer)for(l=0;g&&lthis.A&&(this.j.clear(),this.o=this.o/1.1|0));if(g){if(g!==w)if(c){if(d[g])continue;d[g]=1}else{if(e===g)continue;e=g}f.push(g)}}}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?a.slice(b,b+c):a;let f=[];for(let d=0,h,e;d=e){b-=e;continue}h=h.slice(b,b+c);e=h.length;b=0}e>c&&(h=h.slice(0,c),e=c);if(!f.length&&e>=c)return h;f.push(h);c-=e;if(!c)break}return f=1q;h--){e=m.substring(q,h);t=this.rtl?d-1-q:q;var k=this.score?this.score(c,m,p,e,t):L(v, -n,p,d,t);M(this,w,e,k,a,b)}break}case "bidirectional":case "reverse":if(1e?0: -1),n,p,k-1,l-1),t=this.bidirectional&&m>h;M(this,g,t?h:m,q,a,b,t?m:h)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,c,b,f,d,h,e){let k=e?a.ctx:a.map,l;if(!c[b]||e&&!(l=c[b])[e])e?(c=l||(c[b]=x()),c[e]=1,(l=k.get(e))?k=l:k.set(e,k=new Map)):c[b]=1,(l=k.get(b))?k=l:k.set(b,k=[]),k=k[f]||(k[f]=[]),h&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function L(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}g=e}else if(1=== -f){c=H.call(null,a[0],c,d);break a}c=g}return c};function N(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function I(a,c){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},d=a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= -a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=d.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,c){return this.add(a,c,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,c){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,c)):this.add(a,c)}; -r.cleanup=function(){if(!this.fastupdate)return this;J(this.map);this.depth&&J(this.ctx);return this};x();const O={Index:I,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}},P="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let Q;(Q=P.define)&&Q.amd?Q([],function(){return O}):"object"===typeof P.exports?P.exports=O:P.FlexSearch=O;}(this||self)); +(function(self){'use strict';var u;function v(a,c,b){const f=typeof b,d=typeof a;if(f!=="undefined"){if(d!=="undefined"){if(b){if(d==="function"&&f===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return d==="undefined"?c:a}function y(){return Object.create(null)};const A=/[^\p{L}\p{N}]+/u,B=/(\d{3})/g,C=/(\D)(\d{3})/g,D=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a1)return this.addMatcher(a,c);this.mapper||(this.mapper=new Map);this.mapper.set(a,c);this.cache&&G(this);return this};u.addMatcher=function(a,c){if(typeof a==="object")return this.addReplacer(a,c);if(a.length<2&&(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.s=null;this.cache&&G(this);return this}; +u.addReplacer=function(a,c){if(typeof a==="string")return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; +u.encode=function(a,c){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(C,"$1 $2").replace(D,"$1 $2").replace(B,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let f=[], +d=y(),g,e,k=this.split||this.split===""?a.split(this.split):[a];for(let n=0,h,r;nthis.maxlength)){if(c){if(d[h])continue;d[h]=1}else{if(g===h)continue;g=h}if(b)f.push(h);else if(!this.filter||(typeof this.filter==="function"?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.o)if(this.l){var m=this.j.get(h);if(m||m===""){m&&f.push(m);continue}}else this.l=setTimeout(G,50,this);if(this.stemmer){this.u||(this.u=new RegExp("(?!^)("+ +this.h+")$"));let w;for(;w!==h&&h.length>2;)w=h,h=h.replace(this.u,q=>this.stemmer.get(q))}if(h&&(this.mapper||this.dedupe&&h.length>1)){m="";for(let w=0,q="",l,p;w1&&(this.s||(this.s=new RegExp("("+this.g+")","g")),h=h.replace(this.s,w=>this.matcher.get(w)));if(h&&this.replacer)for(m=0;h&&mthis.A&&(this.j.clear(),this.o=this.o/1.1|0));if(h){if(h!==r)if(c){if(d[h])continue;d[h]=1}else{if(e===h)continue;e=h}f.push(h)}}}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(a.length===1)return a=a[0],a=b||a.length>c?a.slice(b,b+c):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}g=g.slice(b,b+c);e=g.length;b=0}e>c&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=f.length>1?[].concat.apply([],f):f[0]};y();J.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 f=0,d,g;f=0&&d.splice(e,1)}}else K(this.map,a),this.depth&&K(this.ctx,a);c||this.reg.delete(a)}return this}; +function K(a,c){let b=0;var f=typeof c==="undefined";if(a.constructor===Array)for(let d=0,g,e,k;d=0){if(g.length>1)return g.splice(e,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())f=d[0],K(d[1],c)?b++:a.delete(f);return b};const L={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(a,c,b,f){if(c&&(a||a===0)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);f=this.depth;c=this.encoder.encode(c,!f);const n=c.length;if(n){const h=y(),r=y(),w=this.resolution;for(let q=0;q2)for(let p=1,t,z,x,I;p2){for(let p=0,t;pp;g--)if(e=l.substring(p,g),!r[e]){t=this.rtl?d-1-p:p;var k=this.score?this.score(c,l,q,e,t):M(w,n,q,d,t);N(this,r,e,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--)if(e=l[this.rtl?d-1-k:k]+e,!r[e]){var m=this.score?this.score(c,l,q,e,k):M(w,n,q,d,k);N(this,r,e,m,a,b)}e=""}case "forward":if(d>1){for(k=0;k1&&qe?0:1),n,q,k-1,m-1),t=this.bidirectional&&l>g;N(this,h,t?g:l,p,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function N(a,c,b,f,d,g,e){let k=e?a.ctx:a.map,m;if(!c[b]||e&&!(m=c[b])[e])e?(c=m||(c[b]=y()),c[e]=1,(m=k.get(e))?k=m:k.set(e,k=new Map)):c[b]=1,(m=k.get(b))?k=m:k.set(b,k=[]),k=k[f]||(k[f]=[]),g&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function M(a,c,b,f,d){return b&&a>1?c+(f||0)<=a?b+(d||0):(a-1)/(c+(f||0))*(b+(d||0))+1|0:0};J.prototype.search=function(a,c,b){b||(c||typeof a!=="object"?typeof c==="object"&&(b=c,c=0):(b=a,a=""));var f=[],d=0;if(b){a=b.query||a;c=b.limit||c;d=b.offset||0;var g=b.context;var e=b.suggest;var k=!0;var m=b.resolution}typeof k==="undefined"&&(k=!0);g=this.depth&&g!==!1;a=this.encoder.encode(a,!g);b=a.length;c=c||(k?100:0);if(b===1)return e=d,(d=O(this,a[0],""))&&d.length?H.call(this,d,c,e):[];if(b===2&&g&&!e)return e=d,(d=O(this,a[1],a[0]))&&d.length?H.call(this,d,c,e):[];k=y();var n=0;if(g){var h= +a[0];n=1}m||m===0||(m=h?this.v:this.resolution);for(let l,p;n1)b:{f=e;h=a.length;e=[];b=y();for(let l=0,p,t,z,x;l1)c:for(a=[],m=y(),f=e.length,k=f-1;k>=0;k--){if(b=(f=e[k])&&f.length)for(n=0;nc||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}h=e}else if(f=== +1){c=H.call(null,a[0],c,d);break a}c=h}return c};function O(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function J(a,c){if(!this||this.constructor!==J)return new J(a);if(a){var b=typeof a==="string"?a:a.preset;b&&(a=Object.assign({},L[b],a))}else a={};b=a.context;const f=b===!0?{depth:1}:b||{},d=a.encode||a.encoder||{};this.encoder=d.encode?d:typeof d==="object"?new F(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&b!=="default"&&b!=="exact"&&b||"strict";this.depth=b==="strict"&&f.depth||0;this.bidirectional=f.bidirectional!==!1;this.fastupdate=!!a.fastupdate;this.score= +a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=d.rtl||a.rtl||!1}u=J.prototype;u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};u.append=function(a,c){return this.add(a,c,!0)};u.contain=function(a){return this.reg.has(a)};u.update=function(a,c){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,c)):this.add(a,c)}; +u.cleanup=function(){if(!this.fastupdate)return this;K(this.map);this.depth&&K(this.ctx);return this};y();const P={Index:J,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}},Q=typeof self!=="undefined"?self:typeof global!=="undefined"?global:self;let R;(R=Q.define)&&R.amd?R([],function(){return P}):typeof Q.exports==="object"?Q.exports=P:Q.FlexSearch=P;}(this||self)); diff --git a/dist/flexsearch.light.module.debug.js b/dist/flexsearch.light.module.debug.js index ee373cd..cefe36e 100644 --- a/dist/flexsearch.light.module.debug.js +++ b/dist/flexsearch.light.module.debug.js @@ -1,17 +1,17 @@ /**! - * FlexSearch.js v0.8.202 (Bundle/Debug) + * FlexSearch.js v0.8.203 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var r; -function u(a, c, b) { +var u; +function v(a, c, b) { const f = typeof b, d = typeof a; - if ("undefined" !== f) { - if ("undefined" !== d) { + if (f !== "undefined") { + if (d !== "undefined") { if (b) { - if ("function" === d && f === d) { + if (d === "function" && f === d) { return function(k) { return a(b(k)); }; @@ -22,16 +22,16 @@ function u(a, c, b) { return b.concat(a); } if (c === Map) { - var h = new Map(b); + var g = new Map(b); for (var e of a) { - h.set(e[0], e[1]); + g.set(e[0], e[1]); } - return h; + return g; } if (c === Set) { e = new Set(b); - for (h of a.values()) { - e.add(h); + for (g of a.values()) { + e.add(g); } return e; } @@ -41,9 +41,9 @@ function u(a, c, b) { } return b; } - return "undefined" === d ? c : a; + return d === "undefined" ? c : a; } -function x() { +function y() { return Object.create(null); } ;const A = /[^\p{L}\p{N}]+/u, B = /(\d{3})/g, C = /(\D)(\d{3})/g, D = /(\d{3})(\D)/g, E = /[\u0300-\u036f]/g; @@ -59,12 +59,12 @@ function F(a = {}) { this.assign(a); } } -r = F.prototype; -r.assign = function(a) { - this.normalize = u(a.normalize, !0, this.normalize); +u = F.prototype; +u.assign = function(a) { + this.normalize = v(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, f; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { + if (b || b === "") { + if (typeof b === "object" && b.constructor !== RegExp) { let d = ""; f = !c; c || (d += "\\p{Z}"); @@ -74,39 +74,39 @@ r.assign = function(a) { b.punctuation && (d += "\\p{P}"); b.control && (d += "\\p{C}"); if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; + d += typeof b === "object" ? b.join("") : b; } try { this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); - } catch (h) { + } catch (g) { console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = b, f = !1 === b || 2 > "a1a".split(b).length; + this.split = b, f = b === !1 || "a1a".split(b).length < 2; } - this.numeric = u(a.numeric, f); + this.numeric = v(a.numeric, f); } else { try { - this.split = u(this.split, A); + this.split = v(this.split, A); } 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(a.numeric, u(this.numeric, !0)); + this.numeric = v(a.numeric, v(this.numeric, !0)); } - this.prepare = u(a.prepare, null, this.prepare); - this.finalize = u(a.finalize, null, this.finalize); + this.prepare = v(a.prepare, null, this.prepare); + this.finalize = v(a.finalize, null, this.finalize); b = a.filter; - this.filter = "function" === typeof b ? b : u(b && new Set(b), null, this.filter); - this.dedupe = u(a.dedupe, !0, this.dedupe); - 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, 1024, this.maxlength); - this.rtl = u(a.rtl, !1, this.rtl); - if (this.cache = b = u(a.cache, !0, this.cache)) { - this.l = null, this.A = "number" === typeof b ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.m = 128; + this.filter = typeof b === "function" ? b : v(b && new Set(b), null, this.filter); + this.dedupe = v(a.dedupe, !0, this.dedupe); + this.matcher = v((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = v((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = v((b = a.stemmer) && new Map(b), null, this.stemmer); + this.replacer = v(a.replacer, null, this.replacer); + this.minlength = v(a.minlength, 1, this.minlength); + this.maxlength = v(a.maxlength, 1024, this.maxlength); + this.rtl = v(a.rtl, !1, this.rtl); + if (this.cache = b = v(a.cache, !0, this.cache)) { + this.l = null, this.A = typeof b === "number" ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.m = 128; } this.g = ""; this.s = null; @@ -124,7 +124,7 @@ r.assign = function(a) { } return this; }; -r.addStemmer = function(a, c) { +u.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); this.h += (this.h ? "|" : "") + a; @@ -132,16 +132,16 @@ r.addStemmer = function(a, c) { this.cache && G(this); return this; }; -r.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); +u.addFilter = function(a) { + typeof a === "function" ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); this.cache && G(this); return this; }; -r.addMapper = function(a, c) { - if ("object" === typeof a) { +u.addMapper = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (1 < a.length) { + if (a.length > 1) { return this.addMatcher(a, c); } this.mapper || (this.mapper = new Map()); @@ -149,11 +149,11 @@ r.addMapper = function(a, c) { this.cache && G(this); return this; }; -r.addMatcher = function(a, c) { - if ("object" === typeof a) { +u.addMatcher = function(a, c) { + if (typeof a === "object") { return this.addReplacer(a, c); } - if (2 > a.length && (this.dedupe || this.mapper)) { + if (a.length < 2 && (this.dedupe || this.mapper)) { return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); @@ -163,8 +163,8 @@ r.addMatcher = function(a, c) { this.cache && G(this); return this; }; -r.addReplacer = function(a, c) { - if ("string" === typeof a) { +u.addReplacer = function(a, c) { + if (typeof a === "string") { return this.addMatcher(a, c); } this.replacer || (this.replacer = []); @@ -172,7 +172,7 @@ r.addReplacer = function(a, c) { this.cache && G(this); return this; }; -r.encode = function(a, c) { +u.encode = function(a, c) { if (this.cache && a.length <= this.m) { if (this.l) { if (this.i.has(a)) { @@ -182,33 +182,33 @@ r.encode = function(a, c) { this.l = setTimeout(G, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); + this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(C, "$1 $2").replace(D, "$1 $2").replace(B, "$1 ")); + this.numeric && a.length > 3 && (a = a.replace(C, "$1 $2").replace(D, "$1 $2").replace(B, "$1 ")); const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let f = [], d = x(), h, e, k = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let n = 0, g, w; n < k.length; n++) { - if ((g = w = k[n]) && !(g.length < this.minlength || g.length > this.maxlength)) { + let f = [], d = y(), g, e, k = this.split || this.split === "" ? a.split(this.split) : [a]; + for (let n = 0, h, r; n < k.length; n++) { + if ((h = r = k[n]) && !(h.length < this.minlength || h.length > this.maxlength)) { if (c) { - if (d[g]) { + if (d[h]) { continue; } - d[g] = 1; + d[h] = 1; } else { - if (h === g) { + if (g === h) { continue; } - h = g; + g = h; } if (b) { - f.push(g); + f.push(h); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) { - if (this.cache && g.length <= this.o) { + if (!this.filter || (typeof this.filter === "function" ? this.filter(h) : !this.filter.has(h))) { + if (this.cache && h.length <= this.o) { if (this.l) { - var l = this.j.get(g); - if (l || "" === l) { - l && f.push(l); + var m = this.j.get(h); + if (m || m === "") { + m && f.push(m); continue; } } else { @@ -217,40 +217,40 @@ r.encode = function(a, c) { } if (this.stemmer) { this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")); - let v; - for (; v !== g && 2 < g.length;) { - v = g, g = g.replace(this.u, p => this.stemmer.get(p)); + let w; + for (; w !== h && h.length > 2;) { + w = h, h = h.replace(this.u, q => this.stemmer.get(q)); } } - if (g && (this.mapper || this.dedupe && 1 < g.length)) { - l = ""; - for (let v = 0, p = "", m, q; v < g.length; v++) { - m = g.charAt(v), m === p && this.dedupe || ((q = this.mapper && this.mapper.get(m)) || "" === q ? q === p && this.dedupe || !(p = q) || (l += q) : l += p = m); + if (h && (this.mapper || this.dedupe && h.length > 1)) { + m = ""; + for (let w = 0, q = "", l, p; w < h.length; w++) { + l = h.charAt(w), l === q && this.dedupe || ((p = this.mapper && this.mapper.get(l)) || p === "" ? p === q && this.dedupe || !(q = p) || (m += p) : m += q = l); } - g = l; + h = m; } - this.matcher && 1 < g.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), g = g.replace(this.s, v => this.matcher.get(v))); - if (g && this.replacer) { - for (l = 0; g && l < this.replacer.length; l += 2) { - g = g.replace(this.replacer[l], this.replacer[l + 1]); + this.matcher && h.length > 1 && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), h = h.replace(this.s, w => this.matcher.get(w))); + if (h && this.replacer) { + for (m = 0; h && m < this.replacer.length; m += 2) { + h = h.replace(this.replacer[m], this.replacer[m + 1]); } } - this.cache && w.length <= this.o && (this.j.set(w, g), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); - if (g) { - if (g !== w) { + this.cache && r.length <= this.o && (this.j.set(r, h), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); + if (h) { + if (h !== r) { if (c) { - if (d[g]) { + if (d[h]) { continue; } - d[g] = 1; + d[h] = 1; } else { - if (e === g) { + if (e === h) { continue; } - e = g; + e = h; } } - f.push(g); + f.push(h); } } } @@ -265,73 +265,73 @@ function G(a) { a.i.clear(); a.j.clear(); } -;function H(a, c, b) { +;function I(a, c, b) { if (!a.length) { return a; } - if (1 === a.length) { + if (a.length === 1) { return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a; } let f = []; - for (let d = 0, h, e; d < a.length; d++) { - if ((h = a[d]) && (e = h.length)) { + for (let d = 0, g, e; d < a.length; d++) { + if ((g = a[d]) && (e = g.length)) { if (b) { if (b >= e) { b -= e; continue; } - h = h.slice(b, b + c); - e = h.length; + g = g.slice(b, b + c); + e = g.length; b = 0; } - e > c && (h = h.slice(0, c), e = c); + e > c && (g = g.slice(0, c), e = c); if (!f.length && e >= c) { - return h; + return g; } - f.push(h); + f.push(g); c -= e; if (!c) { break; } } } - return f = 1 < f.length ? [].concat.apply([], f) : f[0]; + return f = f.length > 1 ? [].concat.apply([], f) : f[0]; } -;x(); -I.prototype.remove = function(a, c) { +;y(); +J.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 f = 0, d, h; f < b.length; f++) { - if ((d = b[f]) && (h = d.length)) { - if (d[h - 1] === a) { + for (let f = 0, d, g; f < b.length; f++) { + if ((d = b[f]) && (g = d.length)) { + if (d[g - 1] === a) { d.pop(); } else { const e = d.indexOf(a); - 0 <= e && d.splice(e, 1); + e >= 0 && d.splice(e, 1); } } } } else { - J(this.map, a), this.depth && J(this.ctx, a); + K(this.map, a), this.depth && K(this.ctx, a); } c || this.reg.delete(a); } return this; }; -function J(a, c) { +function K(a, c) { let b = 0; - var f = "undefined" === typeof c; + var f = typeof c === "undefined"; if (a.constructor === Array) { - for (let d = 0, h, e, k; d < a.length; d++) { - if ((h = a[d]) && h.length) { + for (let d = 0, g, e, k; d < a.length; d++) { + if ((g = a[d]) && g.length) { if (f) { return 1; } - e = h.indexOf(c); - if (0 <= e) { - if (1 < h.length) { - return h.splice(e, 1), 1; + e = g.indexOf(c); + if (e >= 0) { + if (g.length > 1) { + return g.splice(e, 1), 1; } delete a[d]; if (b) { @@ -348,14 +348,14 @@ function J(a, c) { } } else { for (let d of a.entries()) { - f = d[0], J(d[1], c) ? b++ : a.delete(f); + f = d[0], K(d[1], c) ? b++ : a.delete(f); } } return b; } -;const K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -I.prototype.add = function(a, c, b, f) { - if (c && (a || 0 === a)) { +;const L = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +J.prototype.add = function(a, c, b, f) { + if (c && (a || a === 0)) { if (!f && !b && this.reg.has(a)) { return this.update(a, c); } @@ -363,49 +363,59 @@ I.prototype.add = function(a, c, b, f) { c = this.encoder.encode(c, !f); const n = c.length; if (n) { - const g = x(), w = x(), v = this.resolution; - for (let p = 0; p < n; p++) { - let m = c[this.rtl ? n - 1 - p : p]; - var d = m.length; - if (d && (f || !w[m])) { - var h = this.score ? this.score(c, m, p, null, 0) : L(v, n, p), e = ""; + const h = y(), r = y(), w = this.resolution; + for (let q = 0; q < n; q++) { + let l = c[this.rtl ? n - 1 - q : q]; + var d = l.length; + if (d && (f || !r[l])) { + var g = this.score ? this.score(c, l, q, null, 0) : M(w, n, q), e = ""; switch(this.tokenize) { + case "tolerant": + N(this, r, l, g, a, b); + if (d > 2) { + for (let p = 1, t, z, x, H; p < d - 1; p++) { + t = l.charAt(p), z = l.charAt(p + 1), x = l.substring(0, p) + z, H = l.substring(p + 2), e = x + t + H, r[e] || N(this, r, e, g, a, b), e = x + H, r[e] || N(this, r, e, g, a, b); + } + } + break; case "full": - if (2 < d) { - for (let q = 0, t; q < d; q++) { - for (h = d; h > q; h--) { - e = m.substring(q, h); - t = this.rtl ? d - 1 - q : q; - var k = this.score ? this.score(c, m, p, e, t) : L(v, n, p, d, t); - M(this, w, e, k, a, b); + if (d > 2) { + for (let p = 0, t; p < d; p++) { + for (g = d; g > p; g--) { + if (e = l.substring(p, g), !r[e]) { + t = this.rtl ? d - 1 - p : p; + var k = this.score ? this.score(c, l, q, e, t) : M(w, n, q, d, t); + N(this, r, e, k, a, b); + } } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (k = d - 1; 0 < k; k--) { - e = m[this.rtl ? d - 1 - k : k] + e; - var l = this.score ? this.score(c, m, p, e, k) : L(v, n, p, d, k); - M(this, w, e, l, a, b); + if (d > 1) { + for (k = d - 1; k > 0; k--) { + if (e = l[this.rtl ? d - 1 - k : k] + e, !r[e]) { + var m = this.score ? this.score(c, l, q, e, k) : M(w, n, q, d, k); + N(this, r, e, m, a, b); + } } e = ""; } case "forward": - if (1 < d) { + if (d > 1) { for (k = 0; k < d; k++) { - e += m[this.rtl ? d - 1 - k : k], M(this, w, e, h, a, b); + e += l[this.rtl ? d - 1 - k : k], r[e] || N(this, r, e, g, a, b); } break; } default: - if (M(this, w, m, h, a, b), f && 1 < n && p < n - 1) { - for (d = x(), e = this.v, h = m, k = Math.min(f + 1, this.rtl ? p + 1 : n - p), d[h] = 1, l = 1; l < k; l++) { - if ((m = c[this.rtl ? n - 1 - p - l : p + l]) && !d[m]) { - d[m] = 1; - const q = this.score ? this.score(c, h, p, m, l - 1) : L(e + (n / 2 > e ? 0 : 1), n, p, k - 1, l - 1), t = this.bidirectional && m > h; - M(this, g, t ? h : m, q, a, b, t ? m : h); + if (N(this, r, l, g, a, b), f && n > 1 && q < n - 1) { + for (d = y(), e = this.v, g = l, k = Math.min(f + 1, this.rtl ? q + 1 : n - q), d[g] = 1, m = 1; m < k; m++) { + if ((l = c[this.rtl ? n - 1 - q - m : q + m]) && !d[l]) { + d[l] = 1; + const p = this.score ? this.score(c, g, q, l, m - 1) : M(e + (n / 2 > e ? 0 : 1), n, q, k - 1, m - 1), t = this.bidirectional && l > g; + N(this, h, t ? g : l, p, a, b, t ? l : g); } } } @@ -417,96 +427,96 @@ I.prototype.add = function(a, c, b, f) { } return this; }; -function M(a, c, b, f, d, h, e) { - let k = e ? a.ctx : a.map, l; - if (!c[b] || e && !(l = c[b])[e]) { - e ? (c = l || (c[b] = x()), c[e] = 1, (l = k.get(e)) ? k = l : k.set(e, k = new Map())) : c[b] = 1, (l = k.get(b)) ? k = l : k.set(b, k = []), k = k[f] || (k[f] = []), h && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); +function N(a, c, b, f, d, g, e) { + let k = e ? a.ctx : a.map, m; + if (!c[b] || e && !(m = c[b])[e]) { + e ? (c = m || (c[b] = y()), c[e] = 1, (m = k.get(e)) ? k = m : k.set(e, k = new Map())) : c[b] = 1, (m = k.get(b)) ? k = m : k.set(b, k = []), k = k[f] || (k[f] = []), g && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); } } -function L(a, c, b, f, d) { - return b && 1 < a ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function M(a, c, b, f, d) { + return b && a > 1 ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;I.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); +;J.prototype.search = function(a, c, b) { + b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = "")); var f = [], d = 0; if (b) { a = b.query || a; c = b.limit || c; d = b.offset || 0; - var h = b.context; + var g = b.context; var e = b.suggest; var k = !0; - var l = b.resolution; + var m = b.resolution; } - "undefined" === typeof k && (k = !0); - h = this.depth && !1 !== h; - a = this.encoder.encode(a, !h); + typeof k === "undefined" && (k = !0); + g = this.depth && g !== !1; + a = this.encoder.encode(a, !g); b = a.length; c = c || (k ? 100 : 0); - if (1 === b) { - return e = d, (d = N(this, a[0], "")) && d.length ? H.call(this, d, c, e) : []; + if (b === 1) { + return e = d, (d = O(this, a[0], "")) && d.length ? I.call(this, d, c, e) : []; } - if (2 === b && h && !e) { - return e = d, (d = N(this, a[1], a[0])) && d.length ? H.call(this, d, c, e) : []; + if (b === 2 && g && !e) { + return e = d, (d = O(this, a[1], a[0])) && d.length ? I.call(this, d, c, e) : []; } - k = x(); + k = y(); var n = 0; - if (h) { - var g = a[0]; + if (g) { + var h = a[0]; n = 1; } - l || 0 === l || (l = g ? this.v : this.resolution); - for (let m, q; n < b; n++) { - if ((q = a[n]) && !k[q]) { - k[q] = 1; - m = N(this, q, g); + m || m === 0 || (m = h ? this.v : this.resolution); + for (let l, p; n < b; n++) { + if ((p = a[n]) && !k[p]) { + k[p] = 1; + l = O(this, p, h); a: { - h = m; - var w = f, v = e, p = l; + g = l; + var r = f, w = e, q = m; let t = []; - if (h && h.length) { - if (h.length <= p) { - w.push(h); - m = void 0; + if (g && g.length) { + if (g.length <= q) { + r.push(g); + l = void 0; break a; } - for (let y = 0, z; y < p; y++) { - if (z = h[y]) { - t[y] = z; + for (let z = 0, x; z < q; z++) { + if (x = g[z]) { + t[z] = x; } } if (t.length) { - w.push(t); - m = void 0; + r.push(t); + l = void 0; break a; } } - m = v ? void 0 : t; + l = w ? void 0 : t; } - if (m) { - f = m; + if (l) { + f = l; break; } - g && (e && m && f.length || (g = q)); + h && (e && l && f.length || (h = p)); } - e && g && n === b - 1 && !f.length && (l = this.resolution, g = "", n = -1, k = x()); + e && h && n === b - 1 && !f.length && (m = this.resolution, h = "", n = -1, k = y()); } a: { a = f; f = a.length; - g = a; - if (1 < f) { + h = a; + if (f > 1) { b: { f = e; - g = a.length; + h = a.length; e = []; - b = x(); - for (let m = 0, q, t, y, z; m < l; m++) { - for (n = 0; n < g; n++) { - if (y = a[n], m < y.length && (q = y[m])) { - for (h = 0; h < q.length; h++) { - if (t = q[h], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), z = e[k] || (e[k] = []), z.push(t), c && k === g - 1 && z.length - d === c) { - g = d ? z.slice(d) : z; + b = y(); + for (let l = 0, p, t, z, x; l < m; l++) { + for (n = 0; n < h; n++) { + if (z = a[n], l < z.length && (p = z[l])) { + for (g = 0; g < p.length; g++) { + if (t = p[g], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), x = e[k] || (e[k] = []), x.push(t), c && k === h - 1 && x.length - d === c) { + h = d ? x.slice(d) : x; break b; } } @@ -515,16 +525,16 @@ function L(a, c, b, f, d) { } if (a = e.length) { if (f) { - if (1 < e.length) { + if (e.length > 1) { c: { - for (a = [], l = x(), f = e.length, k = f - 1; 0 <= k; k--) { + for (a = [], m = y(), f = e.length, k = f - 1; k >= 0; k--) { if (b = (f = e[k]) && f.length) { for (n = 0; n < b; n++) { - if (g = f[n], !l[g]) { - if (l[g] = 1, d) { + if (h = f[n], !m[h]) { + if (m[h] = 1, d) { d--; } else { - if (a.push(g), a.length === c) { + if (a.push(h), a.length === c) { break c; } } @@ -538,8 +548,8 @@ function L(a, c, b, f, d) { } e = a; } else { - if (a < g) { - g = []; + if (a < h) { + h = []; break b; } e = e[a - 1]; @@ -550,74 +560,74 @@ function L(a, c, b, f, d) { } } } - g = e; + h = e; } - } else if (1 === f) { - c = H.call(null, a[0], c, d); + } else if (f === 1) { + c = I.call(null, a[0], c, d); break a; } - c = g; + c = h; } return c; }; -function N(a, c, b) { +function O(a, c, b) { let f; b && (f = a.bidirectional && c > b) && (f = b, b = c, c = f); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function I(a, c) { - if (!this || this.constructor !== I) { - return new I(a); +;function J(a, c) { + if (!this || this.constructor !== J) { + return new J(a); } if (a) { - var b = "string" === typeof a ? a : a.preset; - b && (K[b] || console.warn("Preset not found: " + b), a = Object.assign({}, K[b], a)); + var b = typeof a === "string" ? a : a.preset; + b && (L[b] || console.warn("Preset not found: " + b), a = Object.assign({}, L[b], a)); } else { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new F(d) : {encode:d}; + const f = b === !0 ? {depth:1} : b || {}, d = a.encode || a.encoder || {}; + this.encoder = d.encode ? d : typeof d === "object" ? new F(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && f.depth || 0; - this.bidirectional = !1 !== f.bidirectional; + this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict"; + this.depth = b === "strict" && f.depth || 0; + this.bidirectional = f.bidirectional !== !1; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - f && f.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + f && f.depth && this.tokenize !== "strict" && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); this.map = new Map(); this.ctx = new Map(); this.reg = c || (this.fastupdate ? new Map() : new Set()); this.v = f.resolution || 3; this.rtl = d.rtl || a.rtl || !1; } -r = I.prototype; -r.clear = function() { +u = J.prototype; +u.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); return this; }; -r.append = function(a, c) { +u.append = function(a, c) { return this.add(a, c, !0); }; -r.contain = function(a) { +u.contain = function(a) { return this.reg.has(a); }; -r.update = function(a, c) { +u.update = function(a, c) { const b = this, f = this.remove(a); return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; -r.cleanup = function() { +u.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - J(this.map); - this.depth && J(this.ctx); + K(this.map); + this.depth && K(this.ctx); return this; }; -x(); -export default {Index:I, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +y(); +export default {Index:J, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=I;export const Charset=null;export const Encoder=F;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +export const Index=J;export const Charset=null;export const Encoder=F;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.light.module.min.js b/dist/flexsearch.light.module.min.js index fb3d049..d751ed7 100644 --- a/dist/flexsearch.light.module.min.js +++ b/dist/flexsearch.light.module.min.js @@ -1,27 +1,28 @@ /**! - * FlexSearch.js v0.8.202 (Bundle) + * FlexSearch.js v0.8.203 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var r;function u(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var h=new Map(b);for(var e of a)h.set(e[0],e[1]);return h}if(c===Set){e=new Set(b);for(h of a.values())e.add(h);return e}}}return a}return b}return"undefined"===d?c:a}function x(){return Object.create(null)};const A=/[^\p{L}\p{N}]+/u,B=/(\d{3})/g,C=/(\D)(\d{3})/g,D=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; -this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,A)}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);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);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,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=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};r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; -r.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.s=null;this.cache&&G(this);return this}; -r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; -r.encode=function(a,c){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(c){if(d[g])continue;d[g]=1}else{if(h===g)continue;h=g}if(b)f.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.o)if(this.l){var l=this.j.get(g);if(l||""===l){l&&f.push(l);continue}}else this.l=setTimeout(G,50,this);if(this.stemmer){this.u||(this.u=new RegExp("(?!^)("+ -this.h+")$"));let v;for(;v!==g&&2this.stemmer.get(p))}if(g&&(this.mapper||this.dedupe&&1this.matcher.get(v)));if(g&&this.replacer)for(l=0;g&&lthis.A&&(this.j.clear(),this.o=this.o/1.1|0));if(g){if(g!==w)if(c){if(d[g])continue;d[g]=1}else{if(e===g)continue;e=g}f.push(g)}}}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?a.slice(b,b+c):a;let f=[];for(let d=0,h,e;d=e){b-=e;continue}h=h.slice(b,b+c);e=h.length;b=0}e>c&&(h=h.slice(0,c),e=c);if(!f.length&&e>=c)return h;f.push(h);c-=e;if(!c)break}return f=1q;h--){e=m.substring(q,h);t=this.rtl?d-1-q:q;var k=this.score?this.score(c,m,p,e,t):L(v, -n,p,d,t);M(this,w,e,k,a,b)}break}case "bidirectional":case "reverse":if(1e?0: -1),n,p,k-1,l-1),t=this.bidirectional&&m>h;M(this,g,t?h:m,q,a,b,t?m:h)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,c,b,f,d,h,e){let k=e?a.ctx:a.map,l;if(!c[b]||e&&!(l=c[b])[e])e?(c=l||(c[b]=x()),c[e]=1,(l=k.get(e))?k=l:k.set(e,k=new Map)):c[b]=1,(l=k.get(b))?k=l:k.set(b,k=[]),k=k[f]||(k[f]=[]),h&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function L(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}g=e}else if(1=== -f){c=H.call(null,a[0],c,d);break a}c=g}return c};function N(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function I(a,c){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},d=a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= -a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=d.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,c){return this.add(a,c,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,c){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,c)):this.add(a,c)}; -r.cleanup=function(){if(!this.fastupdate)return this;J(this.map);this.depth&&J(this.ctx);return this};x();export default {Index:I,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}}; -export const Index=I;export const Charset=null;export const Encoder=F;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +var u;function v(a,c,b){const f=typeof b,d=typeof a;if(f!=="undefined"){if(d!=="undefined"){if(b){if(d==="function"&&f===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return d==="undefined"?c:a}function y(){return Object.create(null)};const A=/[^\p{L}\p{N}]+/u,B=/(\d{3})/g,C=/(\D)(\d{3})/g,D=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a1)return this.addMatcher(a,c);this.mapper||(this.mapper=new Map);this.mapper.set(a,c);this.cache&&G(this);return this};u.addMatcher=function(a,c){if(typeof a==="object")return this.addReplacer(a,c);if(a.length<2&&(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.s=null;this.cache&&G(this);return this}; +u.addReplacer=function(a,c){if(typeof a==="string")return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; +u.encode=function(a,c){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(C,"$1 $2").replace(D,"$1 $2").replace(B,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let f=[], +d=y(),g,e,k=this.split||this.split===""?a.split(this.split):[a];for(let n=0,h,r;nthis.maxlength)){if(c){if(d[h])continue;d[h]=1}else{if(g===h)continue;g=h}if(b)f.push(h);else if(!this.filter||(typeof this.filter==="function"?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.o)if(this.l){var m=this.j.get(h);if(m||m===""){m&&f.push(m);continue}}else this.l=setTimeout(G,50,this);if(this.stemmer){this.u||(this.u=new RegExp("(?!^)("+ +this.h+")$"));let w;for(;w!==h&&h.length>2;)w=h,h=h.replace(this.u,q=>this.stemmer.get(q))}if(h&&(this.mapper||this.dedupe&&h.length>1)){m="";for(let w=0,q="",l,p;w1&&(this.s||(this.s=new RegExp("("+this.g+")","g")),h=h.replace(this.s,w=>this.matcher.get(w)));if(h&&this.replacer)for(m=0;h&&mthis.A&&(this.j.clear(),this.o=this.o/1.1|0));if(h){if(h!==r)if(c){if(d[h])continue;d[h]=1}else{if(e===h)continue;e=h}f.push(h)}}}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function I(a,c,b){if(!a.length)return a;if(a.length===1)return a=a[0],a=b||a.length>c?a.slice(b,b+c):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}g=g.slice(b,b+c);e=g.length;b=0}e>c&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=f.length>1?[].concat.apply([],f):f[0]};y();J.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 f=0,d,g;f=0&&d.splice(e,1)}}else K(this.map,a),this.depth&&K(this.ctx,a);c||this.reg.delete(a)}return this}; +function K(a,c){let b=0;var f=typeof c==="undefined";if(a.constructor===Array)for(let d=0,g,e,k;d=0){if(g.length>1)return g.splice(e,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())f=d[0],K(d[1],c)?b++:a.delete(f);return b};const L={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(a,c,b,f){if(c&&(a||a===0)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);f=this.depth;c=this.encoder.encode(c,!f);const n=c.length;if(n){const h=y(),r=y(),w=this.resolution;for(let q=0;q2)for(let p=1,t,z,x,H;p2){for(let p=0,t;pp;g--)if(e=l.substring(p,g),!r[e]){t=this.rtl?d-1-p:p;var k=this.score?this.score(c,l,q,e,t):M(w,n,q,d,t);N(this,r,e,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--)if(e=l[this.rtl?d-1-k:k]+e,!r[e]){var m=this.score?this.score(c,l,q,e,k):M(w,n,q,d,k);N(this,r,e,m,a,b)}e=""}case "forward":if(d>1){for(k=0;k1&&qe?0:1),n,q,k-1,m-1),t=this.bidirectional&&l>g;N(this,h,t?g:l,p,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function N(a,c,b,f,d,g,e){let k=e?a.ctx:a.map,m;if(!c[b]||e&&!(m=c[b])[e])e?(c=m||(c[b]=y()),c[e]=1,(m=k.get(e))?k=m:k.set(e,k=new Map)):c[b]=1,(m=k.get(b))?k=m:k.set(b,k=[]),k=k[f]||(k[f]=[]),g&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function M(a,c,b,f,d){return b&&a>1?c+(f||0)<=a?b+(d||0):(a-1)/(c+(f||0))*(b+(d||0))+1|0:0};J.prototype.search=function(a,c,b){b||(c||typeof a!=="object"?typeof c==="object"&&(b=c,c=0):(b=a,a=""));var f=[],d=0;if(b){a=b.query||a;c=b.limit||c;d=b.offset||0;var g=b.context;var e=b.suggest;var k=!0;var m=b.resolution}typeof k==="undefined"&&(k=!0);g=this.depth&&g!==!1;a=this.encoder.encode(a,!g);b=a.length;c=c||(k?100:0);if(b===1)return e=d,(d=O(this,a[0],""))&&d.length?I.call(this,d,c,e):[];if(b===2&&g&&!e)return e=d,(d=O(this,a[1],a[0]))&&d.length?I.call(this,d,c,e):[];k=y();var n=0;if(g){var h= +a[0];n=1}m||m===0||(m=h?this.v:this.resolution);for(let l,p;n1)b:{f=e;h=a.length;e=[];b=y();for(let l=0,p,t,z,x;l1)c:for(a=[],m=y(),f=e.length,k=f-1;k>=0;k--){if(b=(f=e[k])&&f.length)for(n=0;nc||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}h=e}else if(f=== +1){c=I.call(null,a[0],c,d);break a}c=h}return c};function O(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function J(a,c){if(!this||this.constructor!==J)return new J(a);if(a){var b=typeof a==="string"?a:a.preset;b&&(a=Object.assign({},L[b],a))}else a={};b=a.context;const f=b===!0?{depth:1}:b||{},d=a.encode||a.encoder||{};this.encoder=d.encode?d:typeof d==="object"?new F(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&b!=="default"&&b!=="exact"&&b||"strict";this.depth=b==="strict"&&f.depth||0;this.bidirectional=f.bidirectional!==!1;this.fastupdate=!!a.fastupdate;this.score= +a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=d.rtl||a.rtl||!1}u=J.prototype;u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};u.append=function(a,c){return this.add(a,c,!0)};u.contain=function(a){return this.reg.has(a)};u.update=function(a,c){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,c)):this.add(a,c)}; +u.cleanup=function(){if(!this.fastupdate)return this;K(this.map);this.depth&&K(this.ctx);return this};y();export default {Index:J,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}}; +export const Index=J;export const Charset=null;export const Encoder=F;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/lang/de.min.js b/dist/lang/de.min.js index 480cc66..51937d8 100644 --- a/dist/lang/de.min.js +++ b/dist/lang/de.min.js @@ -1,2 +1,2 @@ (function(self){'use strict';const b=new Map([["_"," "],["\u00e4","ae"],["\u00f6","oe"],["\u00fc","ue"],["\u00df","ss"],["&"," und "],["\u20ac"," EUR "]]),c={prepare:function(a){/[_\u00e4\u00f6\u00fc\u00df&\u20ac]/.test(a)&&(a=a.replace(/[_\u00e4\u00f6\u00fc\u00df&\u20ac]/g,d=>b.get(d)));return a.replace(/str\b/g,"strasse").replace(/(?!\b)strasse\b/g," strasse")},filter:new Set("aber als am an auch auf aus bei bin bis bist da dadurch daher darum das dass dass dein deine dem den der des dessen deshalb die dies dieser dieses doch dort du durch ein eine einem einen einer eines er es euer eure fuer hatte hatten hattest hattet hier hinter ich ihr ihre im in ist ja jede jedem jeden jeder jedes jener jenes jetzt ggf kann kannst koennen koennt machen mein meine mit muss musst musst muessen muesst nach nachdem nein nicht noch nun oder seid sein seine sich sie sind soll sollen sollst sollt sonst soweit sowie und unser unsere unter usw uvm vom von vor wann warum was weiter weitere wenn wer werde werden werdet weshalb wie wieder wieso wir wird wirst wo woher wohin zu zum zur ueber".split(" ")), -stemmer:new Map([["niss",""],["isch",""],["lich",""],["heit",""],["keit",""],["ell",""],["bar",""],["end",""],["ung",""],["est",""],["ern",""],["em",""],["er",""],["en",""],["es",""],["st",""],["ig",""],["ik",""],["e",""],["s",""]])};"undefined"!==typeof module&&module.exports?module.exports=c:self.FlexSearch&&(self.FlexSearch.Language.de=c);}(this||self)); +stemmer:new Map([["niss",""],["isch",""],["lich",""],["heit",""],["keit",""],["ell",""],["bar",""],["end",""],["ung",""],["est",""],["ern",""],["em",""],["er",""],["en",""],["es",""],["st",""],["ig",""],["ik",""],["e",""],["s",""]])};typeof module!=="undefined"&&module.exports?module.exports=c:self.FlexSearch&&(self.FlexSearch.Language.de=c);}(this||self)); diff --git a/dist/lang/en.min.js b/dist/lang/en.min.js index 15bc737..113c321 100644 --- a/dist/lang/en.min.js +++ b/dist/lang/en.min.js @@ -1,2 +1,2 @@ (function(self){'use strict';const a={prepare:function(b){return b.replace(/\u00b4`\u2019\u02bc/g,"'").replace(/&/g," and ").replace(/\$/g," USD ").replace(/\u00a3/g," GBP ").replace(/\bi'm\b/g,"i am").replace(/\b(can't|cannot)\b/g,"can not").replace(/\bwon't\b/g,"will not").replace(/([a-z])'s\b/g,"$1 is has").replace(/([a-z])n't\b/g,"$1 not").replace(/([a-z])'ll\b/g,"$1 will").replace(/([a-z])'re\b/g,"$1 are").replace(/([a-z])'ve\b/g,"$1 have").replace(/([a-z])'d\b/g,"$1 would had")},filter:new Set("a about above after again against all also am an and any are arent as at back be because been before being below between both but by can cannot cant come could couldnt did didnt do does doesnt doing dont down during each even few for from further get go good had hadnt has hasnt have havent having he hed her here heres hers herself hes him himself his how hows i id if ill im in into is isnt it its itself ive just know lets like lot make made me more most mustnt my myself new no nor not now of off on once one only or other ought our ours ourselves out over own same say see shant she shed shell shes should shouldnt so some such take than that thats the their theirs them themselves then there theres these they theyd theyll theyre theyve think this those through time times to too under until up us use very want was wasnt way we wed well were werent weve what whats when whens where wheres which while who whom whos why whys will with wont work would wouldnt ya you youd youll your youre yours yourself yourselves youve".split(" ")), -stemmer:new Map([["ization",""],["biliti",""],["icate",""],["ative",""],["ation",""],["iviti",""],["ement",""],["izer",""],["able",""],["ible",""],["alli",""],["ator",""],["less",""],["logi",""],["ical",""],["ance",""],["ence",""],["ness",""],["ble",""],["ment",""],["eli",""],["bli",""],["ful",""],["ant",""],["ent",""],["ism",""],["ate",""],["iti",""],["ous",""],["ive",""],["ize",""],["ing",""],["ion",""],["ies","y"],["al",""],["ou",""],["er",""],["ed",""],["ic",""],["ly",""],["li",""],["s",""]])};"undefined"!==typeof module&&module.exports?module.exports=a:self.FlexSearch&&(self.FlexSearch.Language.en=a);}(this||self)); +stemmer:new Map([["ization",""],["biliti",""],["icate",""],["ative",""],["ation",""],["iviti",""],["ement",""],["izer",""],["able",""],["ible",""],["alli",""],["ator",""],["less",""],["logi",""],["ical",""],["ance",""],["ence",""],["ness",""],["ble",""],["ment",""],["eli",""],["bli",""],["ful",""],["ant",""],["ent",""],["ism",""],["ate",""],["iti",""],["ous",""],["ive",""],["ize",""],["ing",""],["ion",""],["ies","y"],["al",""],["ou",""],["er",""],["ed",""],["ic",""],["ly",""],["li",""],["s",""]])};typeof module!=="undefined"&&module.exports?module.exports=a:self.FlexSearch&&(self.FlexSearch.Language.en=a);}(this||self)); diff --git a/dist/lang/fr.min.js b/dist/lang/fr.min.js index 3972e96..6bd0d25 100644 --- a/dist/lang/fr.min.js +++ b/dist/lang/fr.min.js @@ -1,3 +1,3 @@ (function(self){'use strict';const a={prepare:function(b){return b.replace(/\u00b4`\u2019\u02bc/g,"'").replace(/_+/g," ").replace(/&/g," et ").replace(/\u20ac/g," EUR ").replace(/\bl'([^\b])/g,"la le $1").replace(/\bt'([^\b])/g,"ta te $1").replace(/\bc'([^\b])/g,"ca ce $1").replace(/\bd'([^\b])/g,"da de $1").replace(/\bj'([^\b])/g,"ja je $1").replace(/\bn'([^\b])/g,"na ne $1").replace(/\bm'([^\b])/g,"ma me $1").replace(/\bs'([^\b])/g,"sa se $1").replace(/\bau\b/g,"a le").replace(/\baux\b/g,"a les").replace(/\bdu\b/g,"de le").replace(/\bdes\b/g, "de les")},filter:new Set("au aux avec ce ces dans de des du elle en et eux il je la le leur lui ma mais me meme mes moi mon ne nos notre nous on ou par pas pour qu que qui sa se ses son sur ta te tes toi ton tu un une vos votre vous c d j l m n s t a y ete etee etees etes etant suis es est sommes etes sont serai seras sera serons serez seront serais serait serions seriez seraient etais etait etions etiez etaient fus fut fumes futes furent sois soit soyons soyez soient fusse fusses fut fussions fussiez fussent ayant eu eue eues eus ai as avons avez ont aurai auras aura aurons aurez auront aurais aurait aurions auriez auraient avais avait avions aviez avaient eut eumes eutes eurent aie aies ait ayons ayez aient eusse eusses eut eussions eussiez eussent ceci cela cela cet cette ici ils les leurs quel quels quelle quelles sans soi".split(" ")), -stemmer:new Map([["lement",""],["ient",""],["nera",""],["ment",""],["ais",""],["ait",""],["ant",""],["ent",""],["iez",""],["ion",""],["nez",""],["ai",""],["es",""],["er",""],["ez",""],["le",""],["na",""],["ne",""],["a",""],["e",""]])};"undefined"!==typeof module&&module.exports?module.exports=a:self.FlexSearch&&(self.FlexSearch.Language.fr=a);}(this||self)); +stemmer:new Map([["lement",""],["ient",""],["nera",""],["ment",""],["ais",""],["ait",""],["ant",""],["ent",""],["iez",""],["ion",""],["nez",""],["ai",""],["es",""],["er",""],["ez",""],["le",""],["na",""],["ne",""],["a",""],["e",""]])};typeof module!=="undefined"&&module.exports?module.exports=a:self.FlexSearch&&(self.FlexSearch.Language.fr=a);}(this||self)); diff --git a/dist/module-debug/document.js b/dist/module-debug/document.js index d97f0a9..5a439c3 100644 --- a/dist/module-debug/document.js +++ b/dist/module-debug/document.js @@ -45,10 +45,17 @@ export default function Document(options) { keystore && (this.keystore = keystore); this.fastupdate = !!options.fastupdate; + /** @type { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } */ this.reg = this.fastupdate && !options.worker && !options.db ? keystore && !0 ? new KeystoreMap(keystore) : new Map() : keystore && !0 ? new KeystoreSet(keystore) : new Set(); this.storetree = (tmp = document.store || null) && tmp && !0 !== tmp && []; - this.store = tmp && (keystore && !0 ? new KeystoreMap(keystore) : new Map()); + /** @type {Map|KeystoreMap} */ + this.store = tmp ? keystore && !0 ? new KeystoreMap(keystore) : new Map() : null; this.cache = (tmp = options.cache || null) && new Cache(tmp); diff --git a/dist/module-debug/document/add.js b/dist/module-debug/document/add.js index 07c5ce9..c79edd9 100644 --- a/dist/module-debug/document/add.js +++ b/dist/module-debug/document/add.js @@ -8,9 +8,9 @@ import Document from "../document.js"; * @param id * @param content * @param {boolean=} _append + * @this Document * @returns {Document|Promise} */ - Document.prototype.add = function (id, content, _append) { if (is_object(id)) { diff --git a/dist/module-debug/document/search.js b/dist/module-debug/document/search.js index 4bbd266..0cdc221 100644 --- a/dist/module-debug/document/search.js +++ b/dist/module-debug/document/search.js @@ -14,6 +14,7 @@ import { highlight_fields } from "./highlight.js"; * @param {number|DocumentSearchOptions=} limit * @param {DocumentSearchOptions=} options * @param {Array=} _promises async recursion + * @this Document * @returns { * DocumentSearchResults| * EnrichedDocumentSearchResults| @@ -326,7 +327,7 @@ Document.prototype.search = function (query, limit, options, _promises) { } if (count) { - res = intersect_union(res, arr, resolve); + res = intersect_union( /** @type {IntermediateSearchResults} */res, arr, resolve); len = res.length; if (!len && !suggest) { @@ -457,7 +458,7 @@ function merge_fields(fields) { tmp = group_field[id]; if (!tmp) { entry.field = group_field[id] = [key]; - final.push( /** @type {MergedDocumentSearchEntry} */entry); + final.push( /** @type {!MergedDocumentSearchEntry} */entry); } else { tmp.push(key); } @@ -503,7 +504,6 @@ function get_tag(tag, key, limit, offset, enrich) { * @return {EnrichedSearchResults|SearchResults|Promise} * @this {Document|Index|WorkerIndex|null} */ - export function apply_enrich(ids) { if (!this || !this.store) return ids; diff --git a/dist/module-debug/encoder.js b/dist/module-debug/encoder.js index c4eb3dc..e149e82 100644 --- a/dist/module-debug/encoder.js +++ b/dist/module-debug/encoder.js @@ -64,10 +64,10 @@ export default function Encoder(options = {}) { if (arguments.length) { for (let i = 0; i < arguments.length; i++) { - this.assign(arguments[i]); + this.assign( /** @type {!EncoderOptions} */arguments[i]); } } else { - this.assign(options); + this.assign( /** @type {!EncoderOptions} */options); } } diff --git a/dist/module-debug/index.js b/dist/module-debug/index.js index 9817cbe..8524e54 100644 --- a/dist/module-debug/index.js +++ b/dist/module-debug/index.js @@ -65,6 +65,12 @@ export default function Index(options, _register) { this.map = tmp && !0 ? new KeystoreMap(tmp) : new Map(); this.ctx = tmp && !0 ? new KeystoreMap(tmp) : new Map(); + /** @type { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } */ this.reg = _register || (this.fastupdate ? tmp && !0 ? new KeystoreMap(tmp) : new Map() : tmp && !0 ? new KeystoreSet(tmp) : new Set()); this.resolution_ctx = context.resolution || 3; this.rtl = encoder.rtl || options.rtl || !1; diff --git a/dist/module-debug/index/add.js b/dist/module-debug/index/add.js index cc6cdc6..d0602be 100644 --- a/dist/module-debug/index/add.js +++ b/dist/module-debug/index/add.js @@ -44,14 +44,34 @@ Index.prototype.add = function (id, content, _append, _skip_update) { switch (this.tokenize) { + case "tolerant": + this.push_index(dupes, term, score, id, _append); + if (2 < term_length) { + for (let x = 1, char_a, char_b, prt_1, prt_2; x < term_length - 1; x++) { + char_a = term.charAt(x); + char_b = term.charAt(x + 1); + prt_1 = term.substring(0, x) + char_b; + prt_2 = term.substring(x + 2); + + token = prt_1 + char_a + prt_2; + dupes[token] || this.push_index(dupes, token, score, id, _append); + + token = prt_1 + prt_2; + dupes[token] || this.push_index(dupes, token, score, id, _append); + } + } + break; + case "full": if (2 < term_length) { for (let x = 0, _x; x < term_length; x++) { for (let y = term_length; y > x; y--) { token = term.substring(x, y); - _x = this.rtl ? term_length - 1 - x : x; - const partial_score = this.score ? this.score(content, term, i, token, _x) : get_score(resolution, word_length, i, term_length, _x); - this.push_index(dupes, token, partial_score, id, _append); + if (!dupes[token]) { + _x = this.rtl ? term_length - 1 - x : x; + const partial_score = this.score ? this.score(content, term, i, token, _x) : get_score(resolution, word_length, i, term_length, _x); + this.push_index(dupes, token, partial_score, id, _append); + } } } break; @@ -63,8 +83,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { if (1 < term_length) { for (let x = term_length - 1; 0 < x; x--) { token = term[this.rtl ? term_length - 1 - x : x] + token; - const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); - this.push_index(dupes, token, partial_score, id, _append); + if (!dupes[token]) { + const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); + this.push_index(dupes, token, partial_score, id, _append); + } } token = ""; } @@ -73,7 +95,7 @@ Index.prototype.add = function (id, content, _append, _skip_update) { if (1 < term_length) { for (let x = 0; x < term_length; x++) { token += term[this.rtl ? term_length - 1 - x : x]; - this.push_index(dupes, token, score, id, _append); + dupes[token] || this.push_index(dupes, token, score, id, _append); } break; } diff --git a/dist/module-debug/index/remove.js b/dist/module-debug/index/remove.js index 072d647..ee7c56c 100644 --- a/dist/module-debug/index/remove.js +++ b/dist/module-debug/index/remove.js @@ -1,6 +1,7 @@ import { is_array } from "../common.js"; import Index, { autoCommit } from "../index.js"; +import { KeystoreMap } from "../keystore.js"; /** * @param {!number|string} id @@ -50,7 +51,7 @@ Index.prototype.remove = function (id, _skip_deletion) { /** * When called without passing ID it just will clean up - * @param {!Map|Array>} map + * @param {!Map|KeystoreMap|Array>} map * @param {!number|string=} id * @return {number} */ diff --git a/dist/module-debug/keystore.js b/dist/module-debug/keystore.js index cfd76db..69e91c4 100644 --- a/dist/module-debug/keystore.js +++ b/dist/module-debug/keystore.js @@ -115,11 +115,6 @@ KeystoreArray.prototype.clear = function () { this.index.length = 0; }; -KeystoreArray.prototype.destroy = function () { - this.index = null; - this.proxy = null; -}; - KeystoreArray.prototype.push = function () {}; /** @@ -141,9 +136,8 @@ function Keystore() { /** * @param bitlength * @constructor - * @implements Keystore + * @implements {Keystore} */ - export function KeystoreMap(bitlength = 8) { if (!this || this.constructor !== KeystoreMap) { diff --git a/dist/module-debug/serialize.js b/dist/module-debug/serialize.js index 69acdcc..babe9bc 100644 --- a/dist/module-debug/serialize.js +++ b/dist/module-debug/serialize.js @@ -1,8 +1,8 @@ import Index from "./index.js"; import Document from "./document.js"; +import { KeystoreMap, KeystoreSet } from "./keystore.js"; import { is_string } from "./common.js"; -import { IntermediateSearchResults } from "./type.js"; const chunk_size_reg = 250000, chunk_size_map = 5000, @@ -10,7 +10,7 @@ const chunk_size_reg = 250000, /** - * @param {Map} map + * @param {Map|KeystoreMap} map * @param {number=} size * @return {Array} */ @@ -34,8 +34,8 @@ function map_to_json(map, size = 0) { /** * @param {Array} json - * @param {Map} map - * @return {Map} + * @param {Map|KeystoreMap} map + * @return {Map|KeystoreMap} */ function json_to_map(json, map) { map || (map = new Map()); @@ -48,7 +48,7 @@ function json_to_map(json, map) { } /** - * @param {Map>} ctx + * @param {Map>|KeystoreMap>} ctx * @param {number=} size * @return {Array} */ @@ -75,8 +75,8 @@ function ctx_to_json(ctx, size = 0) { /** * @param {Array} json - * @param {Map>} ctx - * @return {Map>} + * @param {Map>|KeystoreMap>} ctx + * @return {Map>|KeystoreMap>} */ function json_to_ctx(json, ctx) { ctx || (ctx = new Map()); @@ -89,7 +89,12 @@ function json_to_ctx(json, ctx) { } /** - * @param {Set|Map>} reg + * @param { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } reg * @return {Array>} */ function reg_to_json(reg) { @@ -109,15 +114,24 @@ function reg_to_json(reg) { /** * @param {Array} json - * @param {Set} reg - * @return {Set} + * @param { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } reg + * @return { + * Set| + * KeystoreSet + * } */ function json_to_reg(json, reg) { reg || (reg = new Set()); for (let i = 0; i < json.length; i++) { reg.add(json[i]); } - return reg; + return (/** @type {Set} */reg + ); } /** @@ -200,7 +214,7 @@ export function exportIndex(callback, _field, _index_doc = 0, _index_obj = 0) { /** * @param {string} key - * @param {string|Array} data + * @param {string|Array=} data * @this Index */ @@ -293,7 +307,8 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case 2: key = "doc"; - chunk = this.store && map_to_json(this.store); + chunk = this.store && map_to_json( + /** @type {Map} */this.store); _field = null; break; @@ -302,7 +317,8 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) return; } - return save.call(this, callback, _field, key, chunk, _index_doc, _index_obj); + return save.call(this, callback, _field, key, + /** @type {Array|null} */chunk || null, _index_doc, _index_obj); } } diff --git a/dist/module-min/document.js b/dist/module-min/document.js index 911cbe6..b75bdbc 100644 --- a/dist/module-min/document.js +++ b/dist/module-min/document.js @@ -1 +1 @@ -import{IndexOptions,DocumentOptions,DocumentDescriptor,FieldOptions,StoreOptions,EncoderOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Encoder,{fallback_encoder}from"./encoder.js";import Cache,{searchCache}from"./cache.js";import{is_string,is_object,parse_simple}from"./common.js";import apply_async from"./async.js";import{exportDocument,importDocument}from"./serialize.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import"./document/add.js";import"./document/search.js";import Charset from"./charset.js";export default function Document(a){if(!this||this.constructor!==Document)return new Document(a);const b=a.document||a.doc||a;let c,d;if(this.tree=[],this.field=[],this.marker=[],this.key=(c=b.key||b.id)&&parse_tree(c,this.marker)||"id",d=a.keystore||0,d&&(this.keystore=d),this.fastupdate=!!a.fastupdate,this.reg=!this.fastupdate||a.worker||a.db?d&&!0?new KeystoreSet(d):new Set:d&&!0?new KeystoreMap(d):new Map,this.storetree=(c=b.store||null)&&c&&!0!==c&&[],this.store=c&&(d&&!0?new KeystoreMap(d):new Map),this.cache=(c=a.cache||null)&&new Cache(c),a.cache=!1,this.worker=a.worker||!1,this.priority=a.priority||4,this.index=parse_descriptor.call(this,a,b),(this.tag=null,(c=b.tag)&&("string"==typeof c&&(c=[c]),c.length))){this.tag=new Map,this.tagtree=[],this.tagfield=[];for(let a,b,d=0;de;l--){m=i.substring(e,l),d=this.rtl?k-1-e:e;const n=this.score?this.score(b,i,j,m,d):get_score(h,f,j,k,d);this.push_index(g,m,n,a,c)}break}case"bidirectional":case"reverse":if(1h?0:1),f,j,l-1,e-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1e;l--)if(m=i.substring(e,l),!g[m]){d=this.rtl?k-1-e:e;const l=this.score?this.score(b,i,j,m,d):get_score(h,f,j,k,d);this.push_index(g,m,l,a,c)}break}case"bidirectional":case"reverse":if(1h?0:1),f,j,l-1,e-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1=f.length)b-=f.length;else{const g=f[d?"splice":"slice"](b,c),h=g.length;if(h&&(e=e.length?e.concat(g):g,c-=h,d&&(a.length-=h),!c))break;b=0}return e}export function KeystoreArray(a){if(!this||this.constructor!==KeystoreArray)return new KeystoreArray(a);this.index=a?[a]:[],this.length=a?a.length:0;const b=this;return new Proxy([],{get(a,c){if("length"===c)return b.length;if("push"===c)return function(a){b.index[b.index.length-1].push(a),b.length++};if("pop"===c)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===c)return function(a){let c=0;for(let d,e,f=0;f=f.length)b-=f.length;else{const g=f[d?"splice":"slice"](b,c),h=g.length;if(h&&(e=e.length?e.concat(g):g,c-=h,d&&(a.length-=h),!c))break;b=0}return e}export function KeystoreArray(a){if(!this||this.constructor!==KeystoreArray)return new KeystoreArray(a);this.index=a?[a]:[],this.length=a?a.length:0;const b=this;return new Proxy([],{get(a,c){if("length"===c)return b.length;if("push"===c)return function(a){b.index[b.index.length-1].push(a),b.length++};if("pop"===c)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===c)return function(a){let c=0;for(let d,e,f=0;f| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } */ this.reg = this.fastupdate && !options.worker && !options.db ? keystore && !0 ? new KeystoreMap(keystore) : new Map() : keystore && !0 ? new KeystoreSet(keystore) : new Set(); this.storetree = (tmp = document.store || null) && tmp && !0 !== tmp && []; - this.store = tmp && (keystore && !0 ? new KeystoreMap(keystore) : new Map()); + /** @type {Map|KeystoreMap} */ + this.store = tmp ? keystore && !0 ? new KeystoreMap(keystore) : new Map() : null; this.cache = (tmp = options.cache || null) && new Cache(tmp); diff --git a/dist/module/document/add.js b/dist/module/document/add.js index 5ca4f70..dfbae48 100644 --- a/dist/module/document/add.js +++ b/dist/module/document/add.js @@ -8,9 +8,9 @@ import Document from "../document.js"; * @param id * @param content * @param {boolean=} _append + * @this Document * @returns {Document|Promise} */ - Document.prototype.add = function (id, content, _append) { if (is_object(id)) { diff --git a/dist/module/document/search.js b/dist/module/document/search.js index 01ac810..4f970ef 100644 --- a/dist/module/document/search.js +++ b/dist/module/document/search.js @@ -14,6 +14,7 @@ import { highlight_fields } from "./highlight.js"; * @param {number|DocumentSearchOptions=} limit * @param {DocumentSearchOptions=} options * @param {Array=} _promises async recursion + * @this Document * @returns { * DocumentSearchResults| * EnrichedDocumentSearchResults| @@ -306,7 +307,7 @@ Document.prototype.search = function (query, limit, options, _promises) { } if (count) { - res = intersect_union(res, arr, resolve); + res = intersect_union( /** @type {IntermediateSearchResults} */res, arr, resolve); len = res.length; if (!len && !suggest) { @@ -435,7 +436,7 @@ function merge_fields(fields) { tmp = group_field[id]; if (!tmp) { entry.field = group_field[id] = [key]; - final.push( /** @type {MergedDocumentSearchEntry} */entry); + final.push( /** @type {!MergedDocumentSearchEntry} */entry); } else { tmp.push(key); } @@ -481,7 +482,6 @@ function get_tag(tag, key, limit, offset, enrich) { * @return {EnrichedSearchResults|SearchResults|Promise} * @this {Document|Index|WorkerIndex|null} */ - export function apply_enrich(ids) { if (!this || !this.store) return ids; diff --git a/dist/module/encoder.js b/dist/module/encoder.js index 72329f3..f0ff23b 100644 --- a/dist/module/encoder.js +++ b/dist/module/encoder.js @@ -64,10 +64,10 @@ export default function Encoder(options = {}) { if (arguments.length) { for (let i = 0; i < arguments.length; i++) { - this.assign(arguments[i]); + this.assign( /** @type {!EncoderOptions} */arguments[i]); } } else { - this.assign(options); + this.assign( /** @type {!EncoderOptions} */options); } } diff --git a/dist/module/index.js b/dist/module/index.js index 1c4ecb9..9069761 100644 --- a/dist/module/index.js +++ b/dist/module/index.js @@ -60,6 +60,12 @@ export default function Index(options, _register) { this.map = tmp && !0 ? new KeystoreMap(tmp) : new Map(); this.ctx = tmp && !0 ? new KeystoreMap(tmp) : new Map(); + /** @type { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } */ this.reg = _register || (this.fastupdate ? tmp && !0 ? new KeystoreMap(tmp) : new Map() : tmp && !0 ? new KeystoreSet(tmp) : new Set()); this.resolution_ctx = context.resolution || 3; this.rtl = encoder.rtl || options.rtl || !1; diff --git a/dist/module/index/add.js b/dist/module/index/add.js index cc6cdc6..d0602be 100644 --- a/dist/module/index/add.js +++ b/dist/module/index/add.js @@ -44,14 +44,34 @@ Index.prototype.add = function (id, content, _append, _skip_update) { switch (this.tokenize) { + case "tolerant": + this.push_index(dupes, term, score, id, _append); + if (2 < term_length) { + for (let x = 1, char_a, char_b, prt_1, prt_2; x < term_length - 1; x++) { + char_a = term.charAt(x); + char_b = term.charAt(x + 1); + prt_1 = term.substring(0, x) + char_b; + prt_2 = term.substring(x + 2); + + token = prt_1 + char_a + prt_2; + dupes[token] || this.push_index(dupes, token, score, id, _append); + + token = prt_1 + prt_2; + dupes[token] || this.push_index(dupes, token, score, id, _append); + } + } + break; + case "full": if (2 < term_length) { for (let x = 0, _x; x < term_length; x++) { for (let y = term_length; y > x; y--) { token = term.substring(x, y); - _x = this.rtl ? term_length - 1 - x : x; - const partial_score = this.score ? this.score(content, term, i, token, _x) : get_score(resolution, word_length, i, term_length, _x); - this.push_index(dupes, token, partial_score, id, _append); + if (!dupes[token]) { + _x = this.rtl ? term_length - 1 - x : x; + const partial_score = this.score ? this.score(content, term, i, token, _x) : get_score(resolution, word_length, i, term_length, _x); + this.push_index(dupes, token, partial_score, id, _append); + } } } break; @@ -63,8 +83,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { if (1 < term_length) { for (let x = term_length - 1; 0 < x; x--) { token = term[this.rtl ? term_length - 1 - x : x] + token; - const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); - this.push_index(dupes, token, partial_score, id, _append); + if (!dupes[token]) { + const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); + this.push_index(dupes, token, partial_score, id, _append); + } } token = ""; } @@ -73,7 +95,7 @@ Index.prototype.add = function (id, content, _append, _skip_update) { if (1 < term_length) { for (let x = 0; x < term_length; x++) { token += term[this.rtl ? term_length - 1 - x : x]; - this.push_index(dupes, token, score, id, _append); + dupes[token] || this.push_index(dupes, token, score, id, _append); } break; } diff --git a/dist/module/index/remove.js b/dist/module/index/remove.js index 072d647..ee7c56c 100644 --- a/dist/module/index/remove.js +++ b/dist/module/index/remove.js @@ -1,6 +1,7 @@ import { is_array } from "../common.js"; import Index, { autoCommit } from "../index.js"; +import { KeystoreMap } from "../keystore.js"; /** * @param {!number|string} id @@ -50,7 +51,7 @@ Index.prototype.remove = function (id, _skip_deletion) { /** * When called without passing ID it just will clean up - * @param {!Map|Array>} map + * @param {!Map|KeystoreMap|Array>} map * @param {!number|string=} id * @return {number} */ diff --git a/dist/module/keystore.js b/dist/module/keystore.js index cfd76db..69e91c4 100644 --- a/dist/module/keystore.js +++ b/dist/module/keystore.js @@ -115,11 +115,6 @@ KeystoreArray.prototype.clear = function () { this.index.length = 0; }; -KeystoreArray.prototype.destroy = function () { - this.index = null; - this.proxy = null; -}; - KeystoreArray.prototype.push = function () {}; /** @@ -141,9 +136,8 @@ function Keystore() { /** * @param bitlength * @constructor - * @implements Keystore + * @implements {Keystore} */ - export function KeystoreMap(bitlength = 8) { if (!this || this.constructor !== KeystoreMap) { diff --git a/dist/module/serialize.js b/dist/module/serialize.js index 69acdcc..babe9bc 100644 --- a/dist/module/serialize.js +++ b/dist/module/serialize.js @@ -1,8 +1,8 @@ import Index from "./index.js"; import Document from "./document.js"; +import { KeystoreMap, KeystoreSet } from "./keystore.js"; import { is_string } from "./common.js"; -import { IntermediateSearchResults } from "./type.js"; const chunk_size_reg = 250000, chunk_size_map = 5000, @@ -10,7 +10,7 @@ const chunk_size_reg = 250000, /** - * @param {Map} map + * @param {Map|KeystoreMap} map * @param {number=} size * @return {Array} */ @@ -34,8 +34,8 @@ function map_to_json(map, size = 0) { /** * @param {Array} json - * @param {Map} map - * @return {Map} + * @param {Map|KeystoreMap} map + * @return {Map|KeystoreMap} */ function json_to_map(json, map) { map || (map = new Map()); @@ -48,7 +48,7 @@ function json_to_map(json, map) { } /** - * @param {Map>} ctx + * @param {Map>|KeystoreMap>} ctx * @param {number=} size * @return {Array} */ @@ -75,8 +75,8 @@ function ctx_to_json(ctx, size = 0) { /** * @param {Array} json - * @param {Map>} ctx - * @return {Map>} + * @param {Map>|KeystoreMap>} ctx + * @return {Map>|KeystoreMap>} */ function json_to_ctx(json, ctx) { ctx || (ctx = new Map()); @@ -89,7 +89,12 @@ function json_to_ctx(json, ctx) { } /** - * @param {Set|Map>} reg + * @param { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } reg * @return {Array>} */ function reg_to_json(reg) { @@ -109,15 +114,24 @@ function reg_to_json(reg) { /** * @param {Array} json - * @param {Set} reg - * @return {Set} + * @param { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } reg + * @return { + * Set| + * KeystoreSet + * } */ function json_to_reg(json, reg) { reg || (reg = new Set()); for (let i = 0; i < json.length; i++) { reg.add(json[i]); } - return reg; + return (/** @type {Set} */reg + ); } /** @@ -200,7 +214,7 @@ export function exportIndex(callback, _field, _index_doc = 0, _index_obj = 0) { /** * @param {string} key - * @param {string|Array} data + * @param {string|Array=} data * @this Index */ @@ -293,7 +307,8 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case 2: key = "doc"; - chunk = this.store && map_to_json(this.store); + chunk = this.store && map_to_json( + /** @type {Map} */this.store); _field = null; break; @@ -302,7 +317,8 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) return; } - return save.call(this, callback, _field, key, chunk, _index_doc, _index_obj); + return save.call(this, callback, _field, key, + /** @type {Array|null} */chunk || null, _index_doc, _index_obj); } } diff --git a/doc/persistent.md b/doc/persistent.md index 688d3ac..1cc254d 100644 --- a/doc/persistent.md +++ b/doc/persistent.md @@ -24,7 +24,7 @@ All search capabilities are available on persistent indexes like: - Boost Fields - Custom Encoder - Resolver -- Tokenizer (Strict, Forward, Reverse, Full) +- Tokenizer - Document Store (incl. enrich results) - Worker Threads to run in parallel - Auto-Balanced Cache (top queries + last queries) diff --git a/doc/resolver.md b/doc/resolver.md index 6fc20ff..bd80e3c 100644 --- a/doc/resolver.md +++ b/doc/resolver.md @@ -420,13 +420,13 @@ When tasks are processed consecutively, it will skip specific resolver stages wh When using the parallel workflow by passing `{ async: true }`, all resolver stages will send their requests (including nested tasks) to the DB immediately and calculate the results in the right order as soon as the request resolves. When the overall workload of your applications has some free resources, a parallel request workflow improves performance compared to the consecutive counterpart. -
+

When using the consecutive workflow by passing `{ queue: true }`, all resolver stages will send their requests (including nested tasks) to the DB only when the previous request resolves. The advantage of this variant is when a stage becomes invalid because of the previous result, it can skip the request completely and continue with the next stage. This can reduce the overall workload. -
+
-import { SUPPORT_STORE, SUPPORT_TAGS, SUPPORT_WORKER } from "./config.js"; +import { + SUPPORT_STORE, + SUPPORT_TAGS, + SUPPORT_WORKER +} from "./config.js"; +import { IntermediateSearchResults } from "./type.js"; // <-- COMPILER BLOCK import Index from "./index.js"; import Document from "./document.js"; +import { KeystoreMap, KeystoreSet } from "./keystore.js"; import { is_string } from "./common.js"; -import { IntermediateSearchResults } from "./type.js"; const chunk_size_reg = 250000; const chunk_size_map = 5000; const chunk_size_ctx = 1000; /** - * @param {Map} map + * @param {Map|KeystoreMap} map * @param {number=} size * @return {Array} */ @@ -34,8 +39,8 @@ function map_to_json(map, size = 0){ /** * @param {Array} json - * @param {Map} map - * @return {Map} + * @param {Map|KeystoreMap} map + * @return {Map|KeystoreMap} */ function json_to_map(json, map){ map || (map = new Map()); @@ -47,7 +52,7 @@ function json_to_map(json, map){ } /** - * @param {Map>} ctx + * @param {Map>|KeystoreMap>} ctx * @param {number=} size * @return {Array} */ @@ -72,8 +77,8 @@ function ctx_to_json(ctx, size = 0){ /** * @param {Array} json - * @param {Map>} ctx - * @return {Map>} + * @param {Map>|KeystoreMap>} ctx + * @return {Map>|KeystoreMap>} */ function json_to_ctx(json, ctx){ ctx || (ctx = new Map()); @@ -86,7 +91,12 @@ function json_to_ctx(json, ctx){ } /** - * @param {Set|Map>} reg + * @param { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } reg * @return {Array>} */ function reg_to_json(reg){ @@ -105,15 +115,23 @@ function reg_to_json(reg){ /** * @param {Array} json - * @param {Set} reg - * @return {Set} + * @param { + * Set| + * Map>| + * KeystoreSet| + * KeystoreMap> + * } reg + * @return { + * Set| + * KeystoreSet + * } */ function json_to_reg(json, reg){ reg || (reg = new Set()); for(let i = 0; i < json.length; i++) { reg.add(json[i]); } - return reg; + return /** @type {Set} */ (reg); } /** @@ -228,7 +246,7 @@ export function exportIndex(callback, _field, _index_doc = 0, _index_obj = 0){ /** * @param {string} key - * @param {string|Array} data + * @param {string|Array=} data * @this Index */ @@ -326,7 +344,9 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case SUPPORT_STORE && 2: key = "doc"; - chunk = this.store && map_to_json(this.store); + chunk = this.store && map_to_json( + /** @type {Map} */ (this.store) + ); _field = null; break; @@ -346,7 +366,7 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) callback, _field, key, - chunk, + /** @type {Array|null} */ (chunk || null), _index_doc, _index_obj ); diff --git a/task/build.js b/task/build.js index 3f1b109..c56790a 100644 --- a/task/build.js +++ b/task/build.js @@ -507,3 +507,5 @@ function exec(prompt, callback){ child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); } + +// https://github.com/KimlikDAO/kimlikdao-js/tree/ana/kdjs \ No newline at end of file diff --git a/test/tokenize.js b/test/tokenize.js index 927ffbf..e94bc6a 100644 --- a/test/tokenize.js +++ b/test/tokenize.js @@ -27,6 +27,17 @@ describe("Tokenizer", function(){ expect(index.search("björn mayer")).to.include(0); }); + it("Should have been added properly to the index: Tolerant", function(){ + + let index = new Index({ tokenize: "tolerant" }); + index.add(0, "björn phillipp mayer"); + + expect(index.search("björn phillipp")).to.include(0); + expect(index.search("bjönr mayre")).to.include(0); + expect(index.search("bjön maer")).to.include(0); + expect(index.search("börn myaer")).to.include(0); + }); + it("Should have been added properly to the index: Forward", function(){ let index = new Index({ tokenize: "forward" }); diff --git a/test/types.ts b/test/types.ts index ea6a04d..d1499e9 100644 --- a/test/types.ts +++ b/test/types.ts @@ -36,37 +36,55 @@ async function test_index() { const idx8: DefaultSearchResults = index.searchCache({}); const idx9: Promise = index.searchCacheAsync({}); - const index3 = new Index({ db: new IndexedDB("my-store") }); + (function(){ + const api1: Index = index.clear(); + const api2: boolean = index.contain(1); + const api3: Index = index.add(1, ""); + const api4: Index = index.remove(1); + const api5: Index = index.update(1, ""); + }()); + + const index3: Index = new Index({ db: new IndexedDB("my-store") }); const db1: Promise = index3.db; const db2: IndexedDB = await index3.db; - const idx10: Promise = index3.search({ cache: true }); - const idx11: Promise = index3.searchAsync({ cache: true }, function(res: DefaultSearchResults){}); - const idx12: Promise = index3.commit(); - const idx13: Promise = index3.mount(db2); - const idx14: Promise = index3.searchCache({}); - const idx15: Promise = index3.searchCacheAsync({}); - const idx16: Promise = index3.search({ resolve: true, cache: true }); - const idx17: Promise = index3.searchAsync({ cache: true }); - const idx18: Resolver = index2.searchCache({}); - const idx19: Resolver = index2.searchCacheAsync({}); - const idx20: Resolver = idx5.and({ async: true }); - const idx21: Promise = idx5.and({ queue: true }).resolve(); - const idx22: Promise = idx5.xor({ async: true, resolve: true }); - const idx23: Promise = idx5.and({}).and({ queue: true }).and({ resolve: true }); - const idx24: Resolver = index3.search({ resolve: false }); - const idx25: Promise = index3.search({ resolve: false }).and({}).resolve(); - const idx26: Promise = index3.search({ resolve: false }).and({ resolve: true }); + const idx12: Promise = index3.search({ cache: true }); + const idx13: Promise = index3.searchAsync({ cache: true }, function(res: DefaultSearchResults){}); + const idx14: Promise = index3.commit(); + const idx15: Promise = index3.mount(db2); + const idx16: Promise = index3.searchCache({}); + const idx17: Promise = index3.searchCacheAsync({}); + const idx18: Promise = index3.search({ resolve: true, cache: true }); + const idx19: Promise = index3.searchAsync({ cache: true }); + const idx20: Resolver = index2.searchCache({}); + const idx21: Resolver = index2.searchCacheAsync({}); + const idx22: Resolver = idx5.and({ async: true }); + const idx23: Promise = idx5.and({ queue: true }).resolve(); + const idx24: Promise = idx5.xor({ async: true, resolve: true }); + const idx25: Promise = idx5.and({}).and({ queue: true }).and({ resolve: true }); + const idx26: Resolver = index3.search({ resolve: false }); + const idx27: Promise = index3.search({ resolve: false }).and({}).resolve(); + const idx28: Promise = index3.search({ resolve: false }).and({ resolve: true }); + + (function(){ + const api1: Promise = index3.clear(); + const api2: Promise = index3.contain(1); + const api3: Index = index3.add(1, ""); + const api4: Index = index3.remove(1); + const api5: Index = index3.update(1, ""); + }()); const index4 = await new Worker(); - const idx27: Promise = index4.search({ cache: true }); - const idx28: Promise = index4.searchAsync({ cache: true }, function(res: DefaultSearchResults){}); - const idx29: Promise = index4.searchCache({}); - const idx30: Promise = index4.searchCacheAsync({}); - const idx31: Promise = index4.search({ resolve: true, cache: true }); - const idx32: Promise = index4.searchAsync({ cache: true }); - const idx33: Resolver = index4.search({ resolve: false }); - const idx34: Promise = index4.search({ resolve: false }).and({}).resolve(); - const idx35: Promise = index4.search({ resolve: false }).and({ resolve: true }); + const idx31: Promise = index4.search({ cache: true }); + const idx32: Promise = index4.searchAsync({ cache: true }, function(res: DefaultSearchResults){}); + const idx33: Promise = index4.searchCache({}); + const idx34: Promise = index4.searchCacheAsync({}); + const idx35: Promise = index4.search({ resolve: true, cache: true }); + const idx36: Promise = index4.searchAsync({ cache: true }); + const idx37: Resolver = index4.search({ resolve: false }); + const idx38: Promise = index4.search({ resolve: false }).and({}).resolve(); + const idx39: Promise = index4.search({ resolve: false }).and({ resolve: true }); + const api5: Promise = index4.clear(); + const api6: boolean = index4.contain(1); const res1: Resolver = new Resolver({ index }); const res2: Resolver = res1.and({}, { index }).limit(100); @@ -113,6 +131,17 @@ async function test_index() { // @ts-expect-deprecation const idx_err13: DefaultSearchResults = index.search("query", 100); + + // @ts-expect-error + const idx_err14: Index = index.add(1); + // @ts-expect-error + const idx_err15: Index = index.add(""); + // @ts-expect-error + const idx_err15: Index = index.add({}); + // @ts-expect-error + const idx_err16: Index = index.remove(); + // @ts-expect-error + const idx_err17: Index = index.remove({}); } async function test_document() { @@ -233,6 +262,17 @@ async function test_document() { const doc37: Promise = doc24.and({ queue: true, cache: true }).resolve({ enrich: true }); const doc38: Promise = doc24.and({ queue: true }, { enrich: true, highlight: true, resolve: true }); + (function(){ + const api1: Document = document.clear(); + const api2: boolean = document.contain(1); + const api3: Document = document.add(1, { id: 1, tags: [""], title: "", description: "" }); + const api4: Document = document.add({ id: 1, tags: [""], title: "", description: "" }); + const api5: Document = document.remove(1); + const api6: Document = document.remove({ id: 1, tags: [""], title: "", description: "" }); + const api7: Document = document.update(1, { id: 1, tags: [""], title: "", description: "" }); + const api8: Document = document.update({ id: 1, tags: [""], title: "", description: "" }); + }()); + // highlight on .resolve() is never supported: // @ts-expect-error const err0: EnrichedResults = doc24.resolve({ highlight: "" }); @@ -398,6 +438,18 @@ async function test_persistent() { const doc41: Promise = doc24.and({ cache: true }).resolve({ enrich: true }); const doc42: Promise = doc24.and({}, { enrich: true, highlight: true, resolve: true }); + (function(){ + const api1: Promise = document.clear(); + const api2: Promise = document.contain(1); + const api3: Document = document.add(1, { id: 1, tags: [""], title: "", description: "" }); + const api4: Document = document.add({ id: 1, tags: [""], title: "", description: "" }); + const api5: Document = document.remove(1); + const api6: Document = document.remove({ id: 1, tags: [""], title: "", description: "" }); + const api7: Document = document.update(1, { id: 1, tags: [""], title: "", description: "" }); + const api8: Document = document.update({ id: 1, tags: [""], title: "", description: "" }); + const api9: Promise = document.commit(); + }()); + // highlight on .resolve() is never supported: // @ts-expect-error const err0: EnrichedResults = doc24.resolve({ highlight: "" }); @@ -561,6 +613,17 @@ async function test_worker() { const doc41: Promise = doc24.and({ cache: true }).resolve({ enrich: true }); const doc42: Promise = doc24.and({}, { enrich: true, highlight: true, resolve: true }); + (function(){ + const api1: Promise = document.clear(); + const api2: boolean = document.contain(1); + const api3: Promise> = document.add(1, { id: 1, tags: [""], title: "", description: "" }); + const api4: Promise> = document.add({ id: 1, tags: [""], title: "", description: "" }); + const api5: Promise> = document.remove(1); + const api6: Promise> = document.remove({ id: 1, tags: [""], title: "", description: "" }); + const api7: Promise> = document.update(1, { id: 1, tags: [""], title: "", description: "" }); + const api8: Promise> = document.update({ id: 1, tags: [""], title: "", description: "" }); + }()); + // highlight on .resolve() is never supported: // @ts-expect-error const err0: EnrichedResults = doc24.resolve({ highlight: "" });