Quartz sync: Mar 1, 2025, 2:26 PM

This commit is contained in:
Anthony Berg
2025-03-01 14:26:36 +01:00
parent 16c38cf522
commit 8fb1f81784
19490 changed files with 2553421 additions and 0 deletions

View File

@@ -0,0 +1,189 @@
# Changelog
### v0.7.0
- Bidirectional Context (the order of words can now vary, does not increase memory when using bidirectional context)
- New memory-friendly strategy for indexes (switchable, saves up to 50% of memory for each index, slightly decrease performance)
- Better scoring calculation (one of the biggest concerns of the old implementation was that the order of arrays processed in the intersection has affected the order of relevance in the final result)
- Fix resolution (the resolution in the old implementation was not fully stretched through the whole range in some cases)
- Skip words (optionally, automatically skip words from the context chain which are too short)
- Hugely improves performance of long queries (up to 450x faster!) and also memory allocation (up to 250x less memory)
- New fast-update strategy (optionally, hugely improves performance of all updates and removals of indexed contents up to 2850x)
- Improved auto-balanced cache (keep and expire cache by popularity)
- Append contents to already existing entries (already indexed documents or contents)
- New method "contain" to check if an ID was already indexed
- Access documents directly from internal store (read/write)
- Suggestions are hugely improved, falls back from context search all the way down to single term match
- Document descriptor has now array support (optionally adds array entries via the new `append` under the hood to provide a unique relevance context for each entry)
- Document storage handler gets improved
- Results from document index now grouped by field (this is one of the few bigger breaking changes which needs migrations of your old code)
- Boolean search has a new concept (use in combination of the new result structure)
- Node.js Worker Threads
- Improved default latin encoders
- New parallelization model and workload distribution
- Improved Export/Import
- Tag Search
- Offset pagination
- Enhanced Field Search
- Improved sorting by relevance (score)
- Added Context Scoring (context index has its own resolution)
- Enhanced charset normalization
- Improved bundler (support for inline WebWorker)
These features have been removed:
- Where-Clause
- Index Information `index.info()`
- Paging Cursor (was replaced by `offset`)
#### Migration Quick Overview
> The "async" options was removed, instead you can call each method in its async version, e.g. `index.addAsync` or `index.searchAsync`.
> Define document fields as object keys is not longer supported due to the unification of all option payloads.
A full configuration example for a context-based index:
```js
var index = new Index({
tokenize: "strict",
resolution: 9,
minlength: 3,
optimize: true,
fastupdate: true,
cache: 100,
context: {
depth: 1,
resolution: 3,
bidirectional: true
}
});
```
The `resolution` could be set also for the contextual index.
A full configuration example for a document based index:
```js
const index = new Document({
tokenize: "forward",
optimize: true,
resolution: 9,
cache: 100,
worker: true,
document: {
id: "id",
tag: "tag",
store: [
"title", "content"
],
index: [{
field: "title",
tokenize: "forward",
optimize: true,
resolution: 9
},{
field: "content",
tokenize: "strict",
optimize: true,
resolution: 9,
minlength: 3,
context: {
depth: 1,
resolution: 3
}
}]
}
});
```
A full configuration example for a document search:
```js
index.search({
enrich: true,
bool: "and",
tag: ["cat", "dog"],
index: [{
field: "title",
query: "some query",
limit: 100,
suggest: true
},{
field: "content",
query: "same or other query",
limit: 100,
suggest: true
}]
});
```
#### Where Clause Replacement
Old Syntax:
```js
const result = index.where({
cat: "comedy",
year: "2018"
});
```
Equivalent Syntax (0.7.x):
```js
const data = Object.values(index.store);
```
The line above retrieves data from the document store (just useful when not already available in your runtime).
```js
const result = data.filter(function(item){
return item.cat === "comedy" && item.year === "2018";
});
```
Also considering using the <a href="https://github.com/nextapps-de/flexsearch#tags">Tag-Search</a> feature, which partially replaces the Where-Clause with a huge performance boost.
### v0.6.0
- Pagination
### v0.5.3
- Logical Operator
### v0.5.2
- Intersect Partial Results
### v0.5.1
- Customizable Scoring Resolution
### v0.5.0
- Where / Find Documents
- Document Tags
- Custom Sort
### v0.4.0
- Index Documents (Field-Search)
### v0.3.6
- Right-To-Left Support
- CJK Word Splitting Support
### v0.3.5
- Promise Support
### v0.3.4
- Export / Import Indexes (Serialize)
### v0.3.0
- Profiler Support

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,978 @@
/**!
* FlexSearch.js v0.7.41 (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';try{if(module)self=module}catch(e){}self._factory=_f;
var t;
function u(a) {
return "undefined" !== typeof a ? a : !0;
}
function v(a) {
const b = Array(a);
for (let c = 0; c < a; c++) {
b[c] = x();
}
return b;
}
function x() {
return Object.create(null);
}
function aa(a, b) {
return b.length - a.length;
}
function C(a) {
return "string" === typeof a;
}
function D(a) {
return "object" === typeof a;
}
function E(a) {
return "function" === typeof a;
}
;function ba(a, b) {
var c = ca;
if (a && (b && (a = F(a, b)), this.H && (a = F(a, this.H)), this.J && 1 < a.length && (a = F(a, this.J)), c || "" === c)) {
b = a.split(c);
if (this.filter) {
a = this.filter;
c = b.length;
const d = [];
for (let e = 0, f = 0; e < c; e++) {
const h = b[e];
h && !a[h] && (d[f++] = h);
}
a = d;
} else {
a = b;
}
return a;
}
return a;
}
const ca = /[\p{Z}\p{S}\p{P}\p{C}]+/u, da = /[\u0300-\u036f]/g;
function ea(a, b) {
const c = Object.keys(a), d = c.length, e = [];
let f = "", h = 0;
for (let g = 0, k, m; g < d; g++) {
k = c[g], (m = a[k]) ? (e[h++] = G(b ? "(?!\\b)" + k + "(\\b|_)" : k), e[h++] = m) : f += (f ? "|" : "") + k;
}
f && (e[h++] = G(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), e[h] = "");
return e;
}
function F(a, b) {
for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
}
return a;
}
function G(a) {
return new RegExp(a, "g");
}
function fa(a) {
let b = "", c = "";
for (let d = 0, e = a.length, f; d < e; d++) {
(f = a[d]) !== c && (b += c = f);
}
return b;
}
;var ia = {encode:ha, F:!1, G:""};
function ha(a) {
return ba.call(this, ("" + a).toLowerCase(), !1);
}
;const ja = {}, I = {};
function ka(a) {
J(a, "add");
J(a, "append");
J(a, "search");
J(a, "update");
J(a, "remove");
}
function J(a, b) {
a[b + "Async"] = function() {
const c = this, d = arguments;
var e = d[d.length - 1];
let f;
E(e) && (f = e, delete d[d.length - 1]);
e = new Promise(function(h) {
setTimeout(function() {
c.async = !0;
const g = c[b].apply(c, d);
c.async = !1;
h(g);
});
});
return f ? (e.then(f), this) : e;
};
}
;function la(a, b, c, d) {
const e = a.length;
let f = [], h, g, k = 0;
d && (d = []);
for (let m = e - 1; 0 <= m; m--) {
const n = a[m], w = n.length, q = x();
let r = !h;
for (let l = 0; l < w; l++) {
const p = n[l], A = p.length;
if (A) {
for (let B = 0, z, y; B < A; B++) {
if (y = p[B], h) {
if (h[y]) {
if (!m) {
if (c) {
c--;
} else {
if (f[k++] = y, k === b) {
return f;
}
}
}
if (m || d) {
q[y] = 1;
}
r = !0;
}
if (d && (z = (g[y] || 0) + 1, g[y] = z, z < e)) {
const H = d[z - 2] || (d[z - 2] = []);
H[H.length] = y;
}
} else {
q[y] = 1;
}
}
}
}
if (d) {
h || (g = q);
} else if (!r) {
return [];
}
h = q;
}
if (d) {
for (let m = d.length - 1, n, w; 0 <= m; m--) {
n = d[m];
w = n.length;
for (let q = 0, r; q < w; q++) {
if (r = n[q], !h[r]) {
if (c) {
c--;
} else {
if (f[k++] = r, k === b) {
return f;
}
}
h[r] = 1;
}
}
}
}
return f;
}
function ma(a, b) {
const c = x(), d = x(), e = [];
for (let f = 0; f < a.length; f++) {
c[a[f]] = 1;
}
for (let f = 0, h; f < b.length; f++) {
h = b[f];
for (let g = 0, k; g < h.length; g++) {
k = h[g], c[k] && !d[k] && (d[k] = 1, e[e.length] = k);
}
}
return e;
}
;function K(a) {
this.l = !0 !== a && a;
this.cache = x();
this.h = [];
}
function na(a, b, c) {
D(a) && (a = a.query);
let d = this.cache.get(a);
d || (d = this.search(a, b, c), this.cache.set(a, d));
return d;
}
K.prototype.set = function(a, b) {
if (!this.cache[a]) {
var c = this.h.length;
c === this.l ? delete this.cache[this.h[c - 1]] : c++;
for (--c; 0 < c; c--) {
this.h[c] = this.h[c - 1];
}
this.h[0] = a;
}
this.cache[a] = b;
};
K.prototype.get = function(a) {
const b = this.cache[a];
if (this.l && b && (a = this.h.indexOf(a))) {
const c = this.h[a - 1];
this.h[a - 1] = this.h[a];
this.h[a] = c;
}
return b;
};
const oa = {memory:{charset:"latin:extra", D:3, B:4, m:!1}, performance:{D:3, B:3, s:!1, context:{depth:2, D:1}}, match:{charset:"latin:extra", G:"reverse"}, score:{charset:"latin:advanced", D:20, B:3, context:{depth:3, D:9}}, "default":{}};
function qa(a, b, c, d, e, f, h, g) {
setTimeout(function() {
const k = a(c ? c + "." + d : d, JSON.stringify(h));
k && k.then ? k.then(function() {
b.export(a, b, c, e, f + 1, g);
}) : b.export(a, b, c, e, f + 1, g);
});
}
;function L(a, b) {
if (!(this instanceof L)) {
return new L(a);
}
var c;
if (a) {
if (C(a)) {
oa[a] || console.warn("Preset not found: " + a), a = oa[a];
} else {
if (c = a.preset) {
c[c] || console.warn("Preset not found: " + c), a = Object.assign({}, c[c], a);
}
}
c = a.charset;
var d = a.lang;
C(c) && (-1 === c.indexOf(":") && (c += ":default"), c = I[c]);
C(d) && (d = ja[d]);
} else {
a = {};
}
let e, f, h = a.context || {};
this.encode = a.encode || c && c.encode || ha;
this.register = b || x();
this.D = e = a.resolution || 9;
this.G = b = c && c.G || a.tokenize || "strict";
this.depth = "strict" === b && h.depth;
this.l = u(h.bidirectional);
this.s = f = u(a.optimize);
this.m = u(a.fastupdate);
this.B = a.minlength || 1;
this.C = a.boost;
this.map = f ? v(e) : x();
this.A = e = h.resolution || 1;
this.h = f ? v(e) : x();
this.F = c && c.F || a.rtl;
this.H = (b = a.matcher || d && d.H) && ea(b, !1);
this.J = (b = a.stemmer || d && d.J) && ea(b, !0);
if (c = b = a.filter || d && d.filter) {
c = b;
d = x();
for (let g = 0, k = c.length; g < k; g++) {
d[c[g]] = 1;
}
c = d;
}
this.filter = c;
this.cache = (b = a.cache) && new K(b);
}
t = L.prototype;
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.add = function(a, b, c, d) {
if (b && (a || 0 === a)) {
if (!d && !c && this.register[a]) {
return this.update(a, b);
}
b = this.encode(b);
if (d = b.length) {
const m = x(), n = x(), w = this.depth, q = this.D;
for (let r = 0; r < d; r++) {
let l = b[this.F ? d - 1 - r : r];
var e = l.length;
if (l && e >= this.B && (w || !n[l])) {
var f = M(q, d, r), h = "";
switch(this.G) {
case "full":
if (2 < e) {
for (f = 0; f < e; f++) {
for (var g = e; g > f; g--) {
if (g - f >= this.B) {
var k = M(q, d, r, e, f);
h = l.substring(f, g);
N(this, n, h, k, a, c);
}
}
}
break;
}
case "reverse":
if (1 < e) {
for (g = e - 1; 0 < g; g--) {
h = l[g] + h, h.length >= this.B && N(this, n, h, M(q, d, r, e, g), a, c);
}
h = "";
}
case "forward":
if (1 < e) {
for (g = 0; g < e; g++) {
h += l[g], h.length >= this.B && N(this, n, h, f, a, c);
}
break;
}
default:
if (this.C && (f = Math.min(f / this.C(b, l, r) | 0, q - 1)), N(this, n, l, f, a, c), w && 1 < d && r < d - 1) {
for (e = x(), h = this.A, f = l, g = Math.min(w + 1, d - r), e[f] = 1, k = 1; k < g; k++) {
if ((l = b[this.F ? d - 1 - r - k : r + k]) && l.length >= this.B && !e[l]) {
e[l] = 1;
const p = this.l && l > f;
N(this, m, p ? f : l, M(h + (d / 2 > h ? 0 : 1), d, r, g - 1, k - 1), a, c, p ? l : f);
}
}
}
}
}
}
this.m || (this.register[a] = 1);
}
}
return this;
};
function M(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;
}
function N(a, b, c, d, e, f, h) {
let g = h ? a.h : a.map;
if (!b[c] || h && !b[c][h]) {
a.s && (g = g[d]), h ? (b = b[c] || (b[c] = x()), b[h] = 1, g = g[h] || (g[h] = x())) : b[c] = 1, g = g[c] || (g[c] = []), a.s || (g = g[d] || (g[d] = [])), f && g.includes(e) || (g[g.length] = e, a.m && (a = a.register[e] || (a.register[e] = []), a[a.length] = g));
}
}
t.search = function(a, b, c) {
c || (!b && D(a) ? (c = a, a = c.query) : D(b) && (c = b));
let d = [], e;
let f, h = 0;
if (c) {
a = c.query || a;
b = c.limit;
h = c.offset || 0;
var g = c.context;
f = c.suggest;
}
if (a && (a = this.encode("" + a), e = a.length, 1 < e)) {
c = x();
var k = [];
for (let n = 0, w = 0, q; n < e; n++) {
if ((q = a[n]) && q.length >= this.B && !c[q]) {
if (this.s || f || this.map[q]) {
k[w++] = q, c[q] = 1;
} else {
return d;
}
}
}
a = k;
e = a.length;
}
if (!e) {
return d;
}
b || (b = 100);
g = this.depth && 1 < e && !1 !== g;
c = 0;
let m;
g ? (m = a[0], c = 1) : 1 < e && a.sort(aa);
for (let n, w; c < e; c++) {
w = a[c];
g ? (n = ra(this, d, f, b, h, 2 === e, w, m), f && !1 === n && d.length || (m = w)) : n = ra(this, d, f, b, h, 1 === e, w);
if (n) {
return n;
}
if (f && c === e - 1) {
k = d.length;
if (!k) {
if (g) {
g = 0;
c = -1;
continue;
}
return d;
}
if (1 === k) {
return sa(d[0], b, h);
}
}
}
return la(d, b, h, f);
};
function ra(a, b, c, d, e, f, h, g) {
let k = [], m = g ? a.h : a.map;
a.s || (m = ta(m, h, g, a.l));
if (m) {
let n = 0;
const w = Math.min(m.length, g ? a.A : a.D);
for (let q = 0, r = 0, l, p; q < w; q++) {
if (l = m[q]) {
if (a.s && (l = ta(l, h, g, a.l)), e && l && f && (p = l.length, p <= e ? (e -= p, l = null) : (l = l.slice(e), e = 0)), l && (k[n++] = l, f && (r += l.length, r >= d))) {
break;
}
}
}
if (n) {
if (f) {
return sa(k, d, 0);
}
b[b.length] = k;
return;
}
}
return !c && k;
}
function sa(a, b, c) {
a = 1 === a.length ? a[0] : [].concat.apply([], a);
return c || a.length > b ? a.slice(c, c + b) : a;
}
function ta(a, b, c, d) {
c ? (d = d && b > c, a = (a = a[d ? b : c]) && a[d ? c : b]) : a = a[b];
return a;
}
t.contain = function(a) {
return !!this.register[a];
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a, b) {
const c = this.register[a];
if (c) {
if (this.m) {
for (let d = 0, e; d < c.length; d++) {
e = c[d], e.splice(e.indexOf(a), 1);
}
} else {
O(this.map, a, this.D, this.s), this.depth && O(this.h, a, this.A, this.s);
}
b || delete this.register[a];
if (this.cache) {
b = this.cache;
for (let d = 0, e, f; d < b.h.length; d++) {
f = b.h[d], e = b.cache[f], e.includes(a) && (b.h.splice(d--, 1), delete b.cache[f]);
}
}
}
return this;
};
function O(a, b, c, d, e) {
let f = 0;
if (a.constructor === Array) {
if (e) {
b = a.indexOf(b), -1 !== b ? 1 < a.length && (a.splice(b, 1), f++) : f++;
} else {
e = Math.min(a.length, c);
for (let h = 0, g; h < e; h++) {
if (g = a[h]) {
f = O(g, b, c, d, e), d || f || delete a[h];
}
}
}
} else {
for (let h in a) {
(f = O(a[h], b, c, d, e)) || delete a[h];
}
}
return f;
}
t.searchCache = na;
t.export = function(a, b, c, d, e, f) {
let h = !0;
"undefined" === typeof f && (h = new Promise(m => {
f = m;
}));
let g, k;
switch(e || (e = 0)) {
case 0:
g = "reg";
if (this.m) {
k = x();
for (let m in this.register) {
k[m] = 1;
}
} else {
k = this.register;
}
break;
case 1:
g = "cfg";
k = {doc:0, opt:this.s ? 1 : 0};
break;
case 2:
g = "map";
k = this.map;
break;
case 3:
g = "ctx";
k = this.h;
break;
default:
"undefined" === typeof c && f && f();
return;
}
qa(a, b || this, c, g, d, e, k, f);
return h;
};
t.import = function(a, b) {
if (b) {
switch(C(b) && (b = JSON.parse(b)), a) {
case "cfg":
this.s = !!b.opt;
break;
case "reg":
this.m = !1;
this.register = b;
break;
case "map":
this.map = b;
break;
case "ctx":
this.h = b;
}
}
};
ka(L.prototype);
function ua(a) {
a = a.data;
var b = self._index;
const c = a.args;
var d = a.task;
switch(d) {
case "init":
d = a.options || {};
a = a.factory;
b = d.encode;
d.cache = !1;
b && 0 === b.indexOf("function") && (d.encode = Function("return " + b)());
a ? (Function("return " + a)()(self), self._index = new self.FlexSearch.Index(d), delete self.FlexSearch) : self._index = new L(d);
break;
default:
a = a.id, b = b[d].apply(b, c), postMessage("search" === d ? {id:a, msg:b} : {id:a});
}
}
;let va = 0;
function P(a) {
if (!(this instanceof P)) {
return new P(a);
}
var b;
a ? E(b = a.encode) && (a.encode = b.toString()) : a = {};
(b = (self || window)._factory) && (b = b.toString());
const c = "undefined" === typeof window && self.exports, d = this;
this.o = wa(b, c, a.worker);
this.h = x();
if (this.o) {
if (c) {
this.o.on("message", function(e) {
d.h[e.id](e.msg);
delete d.h[e.id];
});
} else {
this.o.onmessage = function(e) {
e = e.data;
d.h[e.id](e.msg);
delete d.h[e.id];
};
}
this.o.postMessage({task:"init", factory:b, options:a});
}
}
Q("add");
Q("append");
Q("search");
Q("update");
Q("remove");
function Q(a) {
P.prototype[a] = P.prototype[a + "Async"] = function() {
const b = this, c = [].slice.call(arguments);
var d = c[c.length - 1];
let e;
E(d) && (e = d, c.splice(c.length - 1, 1));
d = new Promise(function(f) {
setTimeout(function() {
b.h[++va] = f;
b.o.postMessage({task:a, id:va, args:c});
});
});
return e ? (d.then(e), this) : d;
};
}
function wa(a, b, c) {
let d;
try {
d = b ? new (require("worker_threads")["Worker"])(__dirname + "/node/node.js") : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + ua.toString()], {type:"text/javascript"}))) : new Worker(C(c) ? c : "worker/worker.js", {type:"module"});
} catch (e) {
}
return d;
}
;function S(a) {
if (!(this instanceof S)) {
return new S(a);
}
var b = a.document || a.doc || a, c;
this.K = [];
this.h = [];
this.A = [];
this.register = x();
this.key = (c = b.key || b.id) && T(c, this.A) || "id";
this.m = u(a.fastupdate);
this.C = (c = b.store) && !0 !== c && [];
this.store = c && x();
this.I = (c = b.tag) && T(c, this.A);
this.l = c && x();
this.cache = (c = a.cache) && new K(c);
a.cache = !1;
this.o = a.worker;
this.async = !1;
c = x();
let d = b.index || b.field || b;
C(d) && (d = [d]);
for (let e = 0, f, h; e < d.length; e++) {
f = d[e], C(f) || (h = f, f = f.field), h = D(h) ? Object.assign({}, a, h) : a, this.o && (c[f] = new P(h), c[f].o || (this.o = !1)), this.o || (c[f] = new L(h, this.register)), this.K[e] = T(f, this.A), this.h[e] = f;
}
if (this.C) {
for (a = b.store, C(a) && (a = [a]), b = 0; b < a.length; b++) {
this.C[b] = T(a[b], this.A);
}
}
this.index = c;
}
function T(a, b) {
const c = a.split(":");
let d = 0;
for (let e = 0; e < c.length; e++) {
a = c[e], 0 <= a.indexOf("[]") && (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];
}
function U(a, b) {
if (C(b)) {
a = a[b];
} else {
for (let c = 0; a && c < b.length; c++) {
a = a[b[c]];
}
}
return a;
}
function V(a, b, c, d, e) {
a = a[e];
if (d === c.length - 1) {
b[e] = a;
} else if (a) {
if (a.constructor === Array) {
for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) {
V(a, b, c, d, e);
}
} else {
b = b[e] || (b[e] = x()), e = c[++d], V(a, b, c, d, e);
}
}
}
function X(a, b, c, d, e, f, h, g) {
if (a = a[h]) {
if (d === b.length - 1) {
if (a.constructor === Array) {
if (c[d]) {
for (b = 0; b < a.length; b++) {
e.add(f, a[b], !0, !0);
}
return;
}
a = a.join(" ");
}
e.add(f, a, g, !0);
} else {
if (a.constructor === Array) {
for (h = 0; h < a.length; h++) {
X(a, b, c, d, e, f, h, g);
}
} else {
h = b[++d], X(a, b, c, d, e, f, h, g);
}
}
}
}
t = S.prototype;
t.add = function(a, b, c) {
D(a) && (b = a, a = U(b, this.key));
if (b && (a || 0 === a)) {
if (!c && this.register[a]) {
return this.update(a, b);
}
for (let d = 0, e, f; d < this.h.length; d++) {
f = this.h[d], e = this.K[d], C(e) && (e = [e]), X(b, e, this.A, 0, this.index[f], a, e[0], c);
}
if (this.I) {
let d = U(b, this.I), e = x();
C(d) && (d = [d]);
for (let f = 0, h, g; f < d.length; f++) {
if (h = d[f], !e[h] && (e[h] = 1, g = this.l[h] || (this.l[h] = []), !c || !g.includes(a))) {
if (g[g.length] = a, this.m) {
const k = this.register[a] || (this.register[a] = []);
k[k.length] = g;
}
}
}
}
if (this.store && (!c || !this.store[a])) {
let d;
if (this.C) {
d = x();
for (let e = 0, f; e < this.C.length; e++) {
f = this.C[e], C(f) ? d[f] = b[f] : V(b, d, f, 0, f[0]);
}
}
this.store[a] = d || b;
}
}
return this;
};
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a) {
D(a) && (a = U(a, this.key));
if (this.register[a]) {
for (var b = 0; b < this.h.length && (this.index[this.h[b]].remove(a, !this.o), !this.m); b++) {
}
if (this.I && !this.m) {
for (let c in this.l) {
b = this.l[c];
const d = b.indexOf(a);
-1 !== d && (1 < b.length ? b.splice(d, 1) : delete this.l[c]);
}
}
this.store && delete this.store[a];
delete this.register[a];
}
return this;
};
t.search = function(a, b, c, d) {
c || (!b && D(a) ? (c = a, a = "") : D(b) && (c = b, b = 0));
let e = [], f = [], h, g, k, m, n, w, q = 0;
if (c) {
if (c.constructor === Array) {
k = c, c = null;
} else {
a = c.query || a;
k = (h = c.pluck) || c.index || c.field;
m = c.tag;
g = this.store && c.enrich;
n = "and" === c.bool;
b = c.limit || b || 100;
w = c.offset || 0;
if (m && (C(m) && (m = [m]), !a)) {
for (let l = 0, p; l < m.length; l++) {
if (p = xa.call(this, m[l], b, w, g)) {
e[e.length] = p, q++;
}
}
return q ? e : [];
}
C(k) && (k = [k]);
}
}
k || (k = this.h);
n = n && (1 < k.length || m && 1 < m.length);
const r = !d && (this.o || this.async) && [];
for (let l = 0, p, A, B; l < k.length; l++) {
let z;
A = k[l];
C(A) || (z = A, A = z.field, a = z.query || a, b = z.limit || b, g = z.enrich || g);
if (r) {
r[l] = this.index[A].searchAsync(a, b, z || c);
} else {
d ? p = d[l] : p = this.index[A].search(a, b, z || c);
B = p && p.length;
if (m && B) {
const y = [];
let H = 0;
n && (y[0] = [p]);
for (let W = 0, pa, R; W < m.length; W++) {
if (pa = m[W], B = (R = this.l[pa]) && R.length) {
H++, y[y.length] = n ? [R] : R;
}
}
H && (p = n ? la(y, b || 100, w || 0) : ma(p, y), B = p.length);
}
if (B) {
f[q] = A, e[q++] = p;
} else if (n) {
return [];
}
}
}
if (r) {
const l = this;
return new Promise(function(p) {
Promise.all(r).then(function(A) {
p(l.search(a, b, c, A));
});
});
}
if (!q) {
return [];
}
if (h && (!g || !this.store)) {
return e[0];
}
for (let l = 0, p; l < f.length; l++) {
p = e[l];
p.length && g && (p = ya.call(this, p));
if (h) {
return p;
}
e[l] = {field:f[l], result:p};
}
return e;
};
function xa(a, b, c, d) {
let e = this.l[a], f = e && e.length - c;
if (f && 0 < f) {
if (f > b || c) {
e = e.slice(c, c + b);
}
d && (e = ya.call(this, e));
return {tag:a, result:e};
}
}
function ya(a) {
const b = Array(a.length);
for (let c = 0, d; c < a.length; c++) {
d = a[c], b[c] = {id:d, doc:this.store[d]};
}
return b;
}
t.contain = function(a) {
return !!this.register[a];
};
t.get = function(a) {
return this.store[a];
};
t.set = function(a, b) {
this.store[a] = b;
return this;
};
t.searchCache = na;
t.export = function(a, b, c, d, e, f) {
let h;
"undefined" === typeof f && (h = new Promise(g => {
f = g;
}));
e || (e = 0);
d || (d = 0);
if (d < this.h.length) {
const g = this.h[d], k = this.index[g];
b = this;
setTimeout(function() {
k.export(a, b, e ? g : "", d, e++, f) || (d++, e = 1, b.export(a, b, g, d, e, f));
});
} else {
let g, k;
switch(e) {
case 1:
g = "tag";
k = this.l;
c = null;
break;
case 2:
g = "store";
k = this.store;
c = null;
break;
default:
f();
return;
}
qa(a, this, c, g, d, e, k, f);
}
return h;
};
t.import = function(a, b) {
if (b) {
switch(C(b) && (b = JSON.parse(b)), a) {
case "tag":
this.l = b;
break;
case "reg":
this.m = !1;
this.register = b;
for (let d = 0, e; d < this.h.length; d++) {
e = this.index[this.h[d]], e.register = b, e.m = !1;
}
break;
case "store":
this.store = b;
break;
default:
a = a.split(".");
const c = a[0];
a = a[1];
c && a && this.index[c].import(a, b);
}
}
};
ka(S.prototype);
var Aa = {encode:za, F:!1, G:""};
const Ba = [G("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), "a", G("[\u00e8\u00e9\u00ea\u00eb]"), "e", G("[\u00ec\u00ed\u00ee\u00ef]"), "i", G("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), "o", G("[\u00f9\u00fa\u00fb\u00fc\u0171]"), "u", G("[\u00fd\u0177\u00ff]"), "y", G("\u00f1"), "n", G("[\u00e7c]"), "k", G("\u00df"), "s", G(" & "), " and "];
function za(a) {
var b = a = "" + a;
b.normalize && (b = b.normalize("NFD").replace(da, ""));
return ba.call(this, b.toLowerCase(), !a.normalize && Ba);
}
;var Da = {encode:Ca, F:!1, G:"strict"};
const Ea = /[^a-z0-9]+/, Fa = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
function Ca(a) {
a = za.call(this, a).join(" ");
const b = [];
if (a) {
const c = a.split(Ea), d = c.length;
for (let e = 0, f, h = 0; e < d; e++) {
if ((a = c[e]) && (!this.filter || !this.filter[a])) {
f = a[0];
let g = Fa[f] || f, k = g;
for (let m = 1; m < a.length; m++) {
f = a[m];
const n = Fa[f] || f;
n && n !== k && (g += n, k = n);
}
b[h++] = g;
}
}
}
return b;
}
;var Ha = {encode:Ga, F:!1, G:""};
const Ia = [G("ae"), "a", G("oe"), "o", G("sh"), "s", G("th"), "t", G("ph"), "f", G("pf"), "f", G("(?![aeo])h(?![aeo])"), "", G("(?!^[aeo])h(?!^[aeo])"), ""];
function Ga(a, b) {
a && (a = Ca.call(this, a).join(" "), 2 < a.length && (a = F(a, Ia)), b || (1 < a.length && (a = fa(a)), a && (a = a.split(" "))));
return a || [];
}
;var Ka = {encode:Ja, F:!1, G:""};
const La = G("(?!\\b)[aeo]");
function Ja(a) {
a && (a = Ga.call(this, a, !0), 1 < a.length && (a = a.replace(La, "")), 1 < a.length && (a = fa(a)), a && (a = a.split(" ")));
return a || [];
}
;I["latin:default"] = ia;
I["latin:simple"] = Aa;
I["latin:balance"] = Da;
I["latin:advanced"] = Ha;
I["latin:extra"] = Ka;
const Y = {Index:L, Document:S, Worker:P, registerCharset:function(a, b) {
I[a] = b;
}, registerLanguage:function(a, b) {
ja[a] = b;
}};
let Z;
(Z = self.define) && Z.amd ? Z([], function() {
return Y;
}) : self.exports ? self.exports = Y : self.FlexSearch = Y;
}(this));

View File

@@ -0,0 +1,34 @@
/**!
* FlexSearch.js v0.7.41 (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';try{if(module)self=module}catch(e){}self._factory=_f;var t;function u(a){return"undefined"!==typeof a?a:!0}function v(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=x();return b}function x(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a}function E(a){return"function"===typeof a};function ba(a,b){var c=ca;if(a&&(b&&(a=F(a,b)),this.H&&(a=F(a,this.H)),this.J&&1<a.length&&(a=F(a,this.J)),c||""===c)){b=a.split(c);if(this.filter){a=this.filter;c=b.length;const d=[];for(let e=0,f=0;e<c;e++){const h=b[e];h&&!a[h]&&(d[f++]=h)}a=d}else a=b;return a}return a}const ca=/[\p{Z}\p{S}\p{P}\p{C}]+/u,da=/[\u0300-\u036f]/g;
function ea(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",h=0;for(let g=0,k,m;g<d;g++)k=c[g],(m=a[k])?(e[h++]=G(b?"(?!\\b)"+k+"(\\b|_)":k),e[h++]=m):f+=(f?"|":"")+k;f&&(e[h++]=G(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[h]="");return e}function F(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function G(a){return new RegExp(a,"g")}function fa(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};var ia={encode:ha,F:!1,G:""};function ha(a){return ba.call(this,(""+a).toLowerCase(),!1)};const ja={},I={};function ka(a){J(a,"add");J(a,"append");J(a,"search");J(a,"update");J(a,"remove")}function J(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;E(e)&&(f=e,delete d[d.length-1]);e=new Promise(function(h){setTimeout(function(){c.async=!0;const g=c[b].apply(c,d);c.async=!1;h(g)})});return f?(e.then(f),this):e}};function la(a,b,c,d){const e=a.length;let f=[],h,g,k=0;d&&(d=[]);for(let m=e-1;0<=m;m--){const n=a[m],w=n.length,q=x();let r=!h;for(let l=0;l<w;l++){const p=n[l],A=p.length;if(A)for(let B=0,z,y;B<A;B++)if(y=p[B],h){if(h[y]){if(!m)if(c)c--;else if(f[k++]=y,k===b)return f;if(m||d)q[y]=1;r=!0}if(d&&(z=(g[y]||0)+1,g[y]=z,z<e)){const H=d[z-2]||(d[z-2]=[]);H[H.length]=y}}else q[y]=1}if(d)h||(g=q);else if(!r)return[];h=q}if(d)for(let m=d.length-1,n,w;0<=m;m--){n=d[m];w=n.length;for(let q=0,r;q<w;q++)if(r=
n[q],!h[r]){if(c)c--;else if(f[k++]=r,k===b)return f;h[r]=1}}return f}function ma(a,b){const c=x(),d=x(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,h;f<b.length;f++){h=b[f];for(let g=0,k;g<h.length;g++)k=h[g],c[k]&&!d[k]&&(d[k]=1,e[e.length]=k)}return e};function K(a){this.l=!0!==a&&a;this.cache=x();this.h=[]}function na(a,b,c){D(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}K.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};K.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const pa={memory:{charset:"latin:extra",D:3,B:4,m:!1},performance:{D:3,B:3,s:!1,context:{depth:2,D:1}},match:{charset:"latin:extra",G:"reverse"},score:{charset:"latin:advanced",D:20,B:3,context:{depth:3,D:9}},"default":{}};function qa(a,b,c,d,e,f,h,g){setTimeout(function(){const k=a(c?c+"."+d:d,JSON.stringify(h));k&&k.then?k.then(function(){b.export(a,b,c,e,f+1,g)}):b.export(a,b,c,e,f+1,g)})};function L(a,b){if(!(this instanceof L))return new L(a);var c;if(a){C(a)?a=pa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=I[c]);C(d)&&(d=ja[d])}else a={};let e,f,h=a.context||{};this.encode=a.encode||c&&c.encode||ha;this.register=b||x();this.D=e=a.resolution||9;this.G=b=c&&c.G||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.l=u(h.bidirectional);this.s=f=u(a.optimize);this.m=u(a.fastupdate);this.B=a.minlength||1;this.C=
a.boost;this.map=f?v(e):x();this.A=e=h.resolution||1;this.h=f?v(e):x();this.F=c&&c.F||a.rtl;this.H=(b=a.matcher||d&&d.H)&&ea(b,!1);this.J=(b=a.stemmer||d&&d.J)&&ea(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=x();for(let g=0,k=c.length;g<k;g++)d[c[g]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new K(b)}t=L.prototype;t.append=function(a,b){return this.add(a,b,!0)};
t.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(d=b.length){const m=x(),n=x(),w=this.depth,q=this.D;for(let r=0;r<d;r++){let l=b[this.F?d-1-r:r];var e=l.length;if(l&&e>=this.B&&(w||!n[l])){var f=M(q,d,r),h="";switch(this.G){case "full":if(2<e){for(f=0;f<e;f++)for(var g=e;g>f;g--)if(g-f>=this.B){var k=M(q,d,r,e,f);h=l.substring(f,g);N(this,n,h,k,a,c)}break}case "reverse":if(1<e){for(g=e-1;0<g;g--)h=l[g]+h,h.length>=this.B&&N(this,n,
h,M(q,d,r,e,g),a,c);h=""}case "forward":if(1<e){for(g=0;g<e;g++)h+=l[g],h.length>=this.B&&N(this,n,h,f,a,c);break}default:if(this.C&&(f=Math.min(f/this.C(b,l,r)|0,q-1)),N(this,n,l,f,a,c),w&&1<d&&r<d-1)for(e=x(),h=this.A,f=l,g=Math.min(w+1,d-r),e[f]=1,k=1;k<g;k++)if((l=b[this.F?d-1-r-k:r+k])&&l.length>=this.B&&!e[l]){e[l]=1;const p=this.l&&l>f;N(this,m,p?f:l,M(h+(d/2>h?0:1),d,r,g-1,k-1),a,c,p?l:f)}}}}this.m||(this.register[a]=1)}}return this};
function M(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}function N(a,b,c,d,e,f,h){let g=h?a.h:a.map;if(!b[c]||h&&!b[c][h])a.s&&(g=g[d]),h?(b=b[c]||(b[c]=x()),b[h]=1,g=g[h]||(g[h]=x())):b[c]=1,g=g[c]||(g[c]=[]),a.s||(g=g[d]||(g[d]=[])),f&&g.includes(e)||(g[g.length]=e,a.m&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=g))}
t.search=function(a,b,c){c||(!b&&D(a)?(c=a,a=c.query):D(b)&&(c=b));let d=[],e;let f,h=0;if(c){a=c.query||a;b=c.limit;h=c.offset||0;var g=c.context;f=c.suggest}if(a&&(a=this.encode(""+a),e=a.length,1<e)){c=x();var k=[];for(let n=0,w=0,q;n<e;n++)if((q=a[n])&&q.length>=this.B&&!c[q])if(this.s||f||this.map[q])k[w++]=q,c[q]=1;else return d;a=k;e=a.length}if(!e)return d;b||(b=100);g=this.depth&&1<e&&!1!==g;c=0;let m;g?(m=a[0],c=1):1<e&&a.sort(aa);for(let n,w;c<e;c++){w=a[c];g?(n=ra(this,d,f,b,h,2===e,w,
m),f&&!1===n&&d.length||(m=w)):n=ra(this,d,f,b,h,1===e,w);if(n)return n;if(f&&c===e-1){k=d.length;if(!k){if(g){g=0;c=-1;continue}return d}if(1===k)return sa(d[0],b,h)}}return la(d,b,h,f)};
function ra(a,b,c,d,e,f,h,g){let k=[],m=g?a.h:a.map;a.s||(m=ta(m,h,g,a.l));if(m){let n=0;const w=Math.min(m.length,g?a.A:a.D);for(let q=0,r=0,l,p;q<w;q++)if(l=m[q])if(a.s&&(l=ta(l,h,g,a.l)),e&&l&&f&&(p=l.length,p<=e?(e-=p,l=null):(l=l.slice(e),e=0)),l&&(k[n++]=l,f&&(r+=l.length,r>=d)))break;if(n){if(f)return sa(k,d,0);b[b.length]=k;return}}return!c&&k}function sa(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ta(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a,b){const c=this.register[a];if(c){if(this.m)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else O(this.map,a,this.D,this.s),this.depth&&O(this.h,a,this.A,this.s);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],e.includes(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
function O(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let h=0,g;h<e;h++)if(g=a[h])f=O(g,b,c,d,e),d||f||delete a[h]}else for(let h in a)(f=O(a[h],b,c,d,e))||delete a[h];return f}t.searchCache=na;
t.export=function(a,b,c,d,e,f){let h=!0;"undefined"===typeof f&&(h=new Promise(m=>{f=m}));let g,k;switch(e||(e=0)){case 0:g="reg";if(this.m){k=x();for(let m in this.register)k[m]=1}else k=this.register;break;case 1:g="cfg";k={doc:0,opt:this.s?1:0};break;case 2:g="map";k=this.map;break;case 3:g="ctx";k=this.h;break;default:"undefined"===typeof c&&f&&f();return}qa(a,b||this,c,g,d,e,k,f);return h};
t.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "cfg":this.s=!!b.opt;break;case "reg":this.m=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};ka(L.prototype);function ua(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let va=0;function P(a){if(!(this instanceof P))return new P(a);var b;a?E(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c="undefined"===typeof window&&self.exports,d=this;this.o=wa(b,c,a.worker);this.h=x();if(this.o){if(c)this.o.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.o.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.o.postMessage({task:"init",factory:b,options:a})}}Q("add");Q("append");Q("search");
Q("update");Q("remove");function Q(a){P.prototype[a]=P.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;E(d)&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){setTimeout(function(){b.h[++va]=f;b.o.postMessage({task:a,id:va,args:c})})});return e?(d.then(e),this):d}}
function wa(a,b,c){let d;try{d=b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+ua.toString()],{type:"text/javascript"}))):new Worker(C(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function S(a){if(!(this instanceof S))return new S(a);var b=a.document||a.doc||a,c;this.K=[];this.h=[];this.A=[];this.register=x();this.key=(c=b.key||b.id)&&T(c,this.A)||"id";this.m=u(a.fastupdate);this.C=(c=b.store)&&!0!==c&&[];this.store=c&&x();this.I=(c=b.tag)&&T(c,this.A);this.l=c&&x();this.cache=(c=a.cache)&&new K(c);a.cache=!1;this.o=a.worker;this.async=!1;c=x();let d=b.index||b.field||b;C(d)&&(d=[d]);for(let e=0,f,h;e<d.length;e++)f=d[e],C(f)||(h=f,f=f.field),h=D(h)?Object.assign({},a,h):a,
this.o&&(c[f]=new P(h),c[f].o||(this.o=!1)),this.o||(c[f]=new L(h,this.register)),this.K[e]=T(f,this.A),this.h[e]=f;if(this.C)for(a=b.store,C(a)&&(a=[a]),b=0;b<a.length;b++)this.C[b]=T(a[b],this.A);this.index=c}function T(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(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]}function U(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function V(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)V(a,b,c,d,e);else b=b[e]||(b[e]=x()),e=c[++d],V(a,b,c,d,e)}function X(a,b,c,d,e,f,h,g){if(a=a[h])if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,g,!0)}else if(a.constructor===Array)for(h=0;h<a.length;h++)X(a,b,c,d,e,f,h,g);else h=b[++d],X(a,b,c,d,e,f,h,g)}t=S.prototype;
t.add=function(a,b,c){D(a)&&(b=a,a=U(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.K[d],C(e)&&(e=[e]),X(b,e,this.A,0,this.index[f],a,e[0],c);if(this.I){let d=U(b,this.I),e=x();C(d)&&(d=[d]);for(let f=0,h,g;f<d.length;f++)if(h=d[f],!e[h]&&(e[h]=1,g=this.l[h]||(this.l[h]=[]),!c||!g.includes(a)))if(g[g.length]=a,this.m){const k=this.register[a]||(this.register[a]=[]);k[k.length]=g}}if(this.store&&(!c||!this.store[a])){let d;
if(this.C){d=x();for(let e=0,f;e<this.C.length;e++)f=this.C[e],C(f)?d[f]=b[f]:V(b,d,f,0,f[0])}this.store[a]=d||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a){D(a)&&(a=U(a,this.key));if(this.register[a]){for(var b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.o),!this.m);b++);if(this.I&&!this.m)for(let c in this.l){b=this.l[c];const d=b.indexOf(a);-1!==d&&(1<b.length?b.splice(d,1):delete this.l[c])}this.store&&delete this.store[a];delete this.register[a]}return this};
t.search=function(a,b,c,d){c||(!b&&D(a)?(c=a,a=""):D(b)&&(c=b,b=0));let e=[],f=[],h,g,k,m,n,w,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{a=c.query||a;k=(h=c.pluck)||c.index||c.field;m=c.tag;g=this.store&&c.enrich;n="and"===c.bool;b=c.limit||b||100;w=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=xa.call(this,m[l],b,w,g))e[e.length]=p,q++;return q?e:[]}C(k)&&(k=[k])}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const r=!d&&(this.o||this.async)&&[];for(let l=0,p,A,B;l<
k.length;l++){let z;A=k[l];C(A)||(z=A,A=z.field,a=z.query||a,b=z.limit||b,g=z.enrich||g);if(r)r[l]=this.index[A].searchAsync(a,b,z||c);else{d?p=d[l]:p=this.index[A].search(a,b,z||c);B=p&&p.length;if(m&&B){const y=[];let H=0;n&&(y[0]=[p]);for(let W=0,oa,R;W<m.length;W++)if(oa=m[W],B=(R=this.l[oa])&&R.length)H++,y[y.length]=n?[R]:R;H&&(p=n?la(y,b||100,w||0):ma(p,y),B=p.length)}if(B)f[q]=A,e[q++]=p;else if(n)return[]}}if(r){const l=this;return new Promise(function(p){Promise.all(r).then(function(A){p(l.search(a,
b,c,A))})})}if(!q)return[];if(h&&(!g||!this.store))return e[0];for(let l=0,p;l<f.length;l++){p=e[l];p.length&&g&&(p=ya.call(this,p));if(h)return p;e[l]={field:f[l],result:p}}return e};function xa(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=ya.call(this,e));return{tag:a,result:e}}}function ya(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store[d]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};
t.set=function(a,b){this.store[a]=b;return this};t.searchCache=na;t.export=function(a,b,c,d,e,f){let h;"undefined"===typeof f&&(h=new Promise(g=>{f=g}));e||(e=0);d||(d=0);if(d<this.h.length){const g=this.h[d],k=this.index[g];b=this;setTimeout(function(){k.export(a,b,e?g:"",d,e++,f)||(d++,e=1,b.export(a,b,g,d,e,f))})}else{let g,k;switch(e){case 1:g="tag";k=this.l;c=null;break;case 2:g="store";k=this.store;c=null;break;default:f();return}qa(a,this,c,g,d,e,k,f)}return h};
t.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.m=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.index[this.h[d]],e.register=b,e.m=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};ka(S.prototype);var Aa={encode:za,F:!1,G:""};const Ba=[G("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",G("[\u00e8\u00e9\u00ea\u00eb]"),"e",G("[\u00ec\u00ed\u00ee\u00ef]"),"i",G("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",G("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",G("[\u00fd\u0177\u00ff]"),"y",G("\u00f1"),"n",G("[\u00e7c]"),"k",G("\u00df"),"s",G(" & ")," and "];function za(a){var b=a=""+a;b.normalize&&(b=b.normalize("NFD").replace(da,""));return ba.call(this,b.toLowerCase(),!a.normalize&&Ba)};var Da={encode:Ca,F:!1,G:"strict"};const Ea=/[^a-z0-9]+/,Fa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ca(a){a=za.call(this,a).join(" ");const b=[];if(a){const c=a.split(Ea),d=c.length;for(let e=0,f,h=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let g=Fa[f]||f,k=g;for(let m=1;m<a.length;m++){f=a[m];const n=Fa[f]||f;n&&n!==k&&(g+=n,k=n)}b[h++]=g}}return b};var Ha={encode:Ga,F:!1,G:""};const Ia=[G("ae"),"a",G("oe"),"o",G("sh"),"s",G("th"),"t",G("ph"),"f",G("pf"),"f",G("(?![aeo])h(?![aeo])"),"",G("(?!^[aeo])h(?!^[aeo])"),""];function Ga(a,b){a&&(a=Ca.call(this,a).join(" "),2<a.length&&(a=F(a,Ia)),b||(1<a.length&&(a=fa(a)),a&&(a=a.split(" "))));return a||[]};var Ka={encode:Ja,F:!1,G:""};const La=G("(?!\\b)[aeo]");function Ja(a){a&&(a=Ga.call(this,a,!0),1<a.length&&(a=a.replace(La,"")),1<a.length&&(a=fa(a)),a&&(a=a.split(" ")));return a||[]};I["latin:default"]=ia;I["latin:simple"]=Aa;I["latin:balance"]=Da;I["latin:advanced"]=Ha;I["latin:extra"]=Ka;const Y={Index:L,Document:S,Worker:P,registerCharset:function(a,b){I[a]=b},registerLanguage:function(a,b){ja[a]=b}};let Z;(Z=self.define)&&Z.amd?Z([],function(){return Y}):self.exports?self.exports=Y:self.FlexSearch=Y;}(this));

View File

@@ -0,0 +1,973 @@
/**!
* FlexSearch.js v0.7.41 (Bundle.module)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
var t;
function u(a) {
return "undefined" !== typeof a ? a : !0;
}
function v(a) {
const b = Array(a);
for (let c = 0; c < a; c++) {
b[c] = x();
}
return b;
}
function x() {
return Object.create(null);
}
function aa(a, b) {
return b.length - a.length;
}
function C(a) {
return "string" === typeof a;
}
function D(a) {
return "object" === typeof a;
}
function E(a) {
return "function" === typeof a;
}
;function F(a, b) {
var c = ba;
if (a && (b && (a = G(a, b)), this.H && (a = G(a, this.H)), this.J && 1 < a.length && (a = G(a, this.J)), c || "" === c)) {
b = a.split(c);
if (this.filter) {
a = this.filter;
c = b.length;
const d = [];
for (let e = 0, f = 0; e < c; e++) {
const h = b[e];
h && !a[h] && (d[f++] = h);
}
a = d;
} else {
a = b;
}
return a;
}
return a;
}
const ba = /[\p{Z}\p{S}\p{P}\p{C}]+/u, ca = /[\u0300-\u036f]/g;
function I(a, b) {
const c = Object.keys(a), d = c.length, e = [];
let f = "", h = 0;
for (let g = 0, k, m; g < d; g++) {
k = c[g], (m = a[k]) ? (e[h++] = J(b ? "(?!\\b)" + k + "(\\b|_)" : k), e[h++] = m) : f += (f ? "|" : "") + k;
}
f && (e[h++] = J(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), e[h] = "");
return e;
}
function G(a, b) {
for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
}
return a;
}
function J(a) {
return new RegExp(a, "g");
}
function da(a) {
let b = "", c = "";
for (let d = 0, e = a.length, f; d < e; d++) {
(f = a[d]) !== c && (b += c = f);
}
return b;
}
;var fa = {encode:ea, F:!1, G:""};
function ea(a) {
return F.call(this, ("" + a).toLowerCase(), !1);
}
;const ha = {}, K = {};
function ia(a) {
L(a, "add");
L(a, "append");
L(a, "search");
L(a, "update");
L(a, "remove");
}
function L(a, b) {
a[b + "Async"] = function() {
const c = this, d = arguments;
var e = d[d.length - 1];
let f;
E(e) && (f = e, delete d[d.length - 1]);
e = new Promise(function(h) {
setTimeout(function() {
c.async = !0;
const g = c[b].apply(c, d);
c.async = !1;
h(g);
});
});
return f ? (e.then(f), this) : e;
};
}
;function ja(a, b, c, d) {
const e = a.length;
let f = [], h, g, k = 0;
d && (d = []);
for (let m = e - 1; 0 <= m; m--) {
const n = a[m], w = n.length, q = x();
let r = !h;
for (let l = 0; l < w; l++) {
const p = n[l], A = p.length;
if (A) {
for (let B = 0, z, y; B < A; B++) {
if (y = p[B], h) {
if (h[y]) {
if (!m) {
if (c) {
c--;
} else {
if (f[k++] = y, k === b) {
return f;
}
}
}
if (m || d) {
q[y] = 1;
}
r = !0;
}
if (d && (z = (g[y] || 0) + 1, g[y] = z, z < e)) {
const H = d[z - 2] || (d[z - 2] = []);
H[H.length] = y;
}
} else {
q[y] = 1;
}
}
}
}
if (d) {
h || (g = q);
} else if (!r) {
return [];
}
h = q;
}
if (d) {
for (let m = d.length - 1, n, w; 0 <= m; m--) {
n = d[m];
w = n.length;
for (let q = 0, r; q < w; q++) {
if (r = n[q], !h[r]) {
if (c) {
c--;
} else {
if (f[k++] = r, k === b) {
return f;
}
}
h[r] = 1;
}
}
}
}
return f;
}
function ka(a, b) {
const c = x(), d = x(), e = [];
for (let f = 0; f < a.length; f++) {
c[a[f]] = 1;
}
for (let f = 0, h; f < b.length; f++) {
h = b[f];
for (let g = 0, k; g < h.length; g++) {
k = h[g], c[k] && !d[k] && (d[k] = 1, e[e.length] = k);
}
}
return e;
}
;function M(a) {
this.l = !0 !== a && a;
this.cache = x();
this.h = [];
}
function la(a, b, c) {
D(a) && (a = a.query);
let d = this.cache.get(a);
d || (d = this.search(a, b, c), this.cache.set(a, d));
return d;
}
M.prototype.set = function(a, b) {
if (!this.cache[a]) {
var c = this.h.length;
c === this.l ? delete this.cache[this.h[c - 1]] : c++;
for (--c; 0 < c; c--) {
this.h[c] = this.h[c - 1];
}
this.h[0] = a;
}
this.cache[a] = b;
};
M.prototype.get = function(a) {
const b = this.cache[a];
if (this.l && b && (a = this.h.indexOf(a))) {
const c = this.h[a - 1];
this.h[a - 1] = this.h[a];
this.h[a] = c;
}
return b;
};
const ma = {memory:{charset:"latin:extra", D:3, B:4, m:!1}, performance:{D:3, B:3, s:!1, context:{depth:2, D:1}}, match:{charset:"latin:extra", G:"reverse"}, score:{charset:"latin:advanced", D:20, B:3, context:{depth:3, D:9}}, "default":{}};
function oa(a, b, c, d, e, f, h, g) {
setTimeout(function() {
const k = a(c ? c + "." + d : d, JSON.stringify(h));
k && k.then ? k.then(function() {
b.export(a, b, c, e, f + 1, g);
}) : b.export(a, b, c, e, f + 1, g);
});
}
;function N(a, b) {
if (!(this instanceof N)) {
return new N(a);
}
var c;
if (a) {
if (C(a)) {
ma[a] || console.warn("Preset not found: " + a), a = ma[a];
} else {
if (c = a.preset) {
c[c] || console.warn("Preset not found: " + c), a = Object.assign({}, c[c], a);
}
}
c = a.charset;
var d = a.lang;
C(c) && (-1 === c.indexOf(":") && (c += ":default"), c = K[c]);
C(d) && (d = ha[d]);
} else {
a = {};
}
let e, f, h = a.context || {};
this.encode = a.encode || c && c.encode || ea;
this.register = b || x();
this.D = e = a.resolution || 9;
this.G = b = c && c.G || a.tokenize || "strict";
this.depth = "strict" === b && h.depth;
this.l = u(h.bidirectional);
this.s = f = u(a.optimize);
this.m = u(a.fastupdate);
this.B = a.minlength || 1;
this.C = a.boost;
this.map = f ? v(e) : x();
this.A = e = h.resolution || 1;
this.h = f ? v(e) : x();
this.F = c && c.F || a.rtl;
this.H = (b = a.matcher || d && d.H) && I(b, !1);
this.J = (b = a.stemmer || d && d.J) && I(b, !0);
if (c = b = a.filter || d && d.filter) {
c = b;
d = x();
for (let g = 0, k = c.length; g < k; g++) {
d[c[g]] = 1;
}
c = d;
}
this.filter = c;
this.cache = (b = a.cache) && new M(b);
}
t = N.prototype;
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.add = function(a, b, c, d) {
if (b && (a || 0 === a)) {
if (!d && !c && this.register[a]) {
return this.update(a, b);
}
b = this.encode(b);
if (d = b.length) {
const m = x(), n = x(), w = this.depth, q = this.D;
for (let r = 0; r < d; r++) {
let l = b[this.F ? d - 1 - r : r];
var e = l.length;
if (l && e >= this.B && (w || !n[l])) {
var f = O(q, d, r), h = "";
switch(this.G) {
case "full":
if (2 < e) {
for (f = 0; f < e; f++) {
for (var g = e; g > f; g--) {
if (g - f >= this.B) {
var k = O(q, d, r, e, f);
h = l.substring(f, g);
P(this, n, h, k, a, c);
}
}
}
break;
}
case "reverse":
if (1 < e) {
for (g = e - 1; 0 < g; g--) {
h = l[g] + h, h.length >= this.B && P(this, n, h, O(q, d, r, e, g), a, c);
}
h = "";
}
case "forward":
if (1 < e) {
for (g = 0; g < e; g++) {
h += l[g], h.length >= this.B && P(this, n, h, f, a, c);
}
break;
}
default:
if (this.C && (f = Math.min(f / this.C(b, l, r) | 0, q - 1)), P(this, n, l, f, a, c), w && 1 < d && r < d - 1) {
for (e = x(), h = this.A, f = l, g = Math.min(w + 1, d - r), e[f] = 1, k = 1; k < g; k++) {
if ((l = b[this.F ? d - 1 - r - k : r + k]) && l.length >= this.B && !e[l]) {
e[l] = 1;
const p = this.l && l > f;
P(this, m, p ? f : l, O(h + (d / 2 > h ? 0 : 1), d, r, g - 1, k - 1), a, c, p ? l : f);
}
}
}
}
}
}
this.m || (this.register[a] = 1);
}
}
return this;
};
function O(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;
}
function P(a, b, c, d, e, f, h) {
let g = h ? a.h : a.map;
if (!b[c] || h && !b[c][h]) {
a.s && (g = g[d]), h ? (b = b[c] || (b[c] = x()), b[h] = 1, g = g[h] || (g[h] = x())) : b[c] = 1, g = g[c] || (g[c] = []), a.s || (g = g[d] || (g[d] = [])), f && g.includes(e) || (g[g.length] = e, a.m && (a = a.register[e] || (a.register[e] = []), a[a.length] = g));
}
}
t.search = function(a, b, c) {
c || (!b && D(a) ? (c = a, a = c.query) : D(b) && (c = b));
let d = [], e;
let f, h = 0;
if (c) {
a = c.query || a;
b = c.limit;
h = c.offset || 0;
var g = c.context;
f = c.suggest;
}
if (a && (a = this.encode("" + a), e = a.length, 1 < e)) {
c = x();
var k = [];
for (let n = 0, w = 0, q; n < e; n++) {
if ((q = a[n]) && q.length >= this.B && !c[q]) {
if (this.s || f || this.map[q]) {
k[w++] = q, c[q] = 1;
} else {
return d;
}
}
}
a = k;
e = a.length;
}
if (!e) {
return d;
}
b || (b = 100);
g = this.depth && 1 < e && !1 !== g;
c = 0;
let m;
g ? (m = a[0], c = 1) : 1 < e && a.sort(aa);
for (let n, w; c < e; c++) {
w = a[c];
g ? (n = pa(this, d, f, b, h, 2 === e, w, m), f && !1 === n && d.length || (m = w)) : n = pa(this, d, f, b, h, 1 === e, w);
if (n) {
return n;
}
if (f && c === e - 1) {
k = d.length;
if (!k) {
if (g) {
g = 0;
c = -1;
continue;
}
return d;
}
if (1 === k) {
return qa(d[0], b, h);
}
}
}
return ja(d, b, h, f);
};
function pa(a, b, c, d, e, f, h, g) {
let k = [], m = g ? a.h : a.map;
a.s || (m = ra(m, h, g, a.l));
if (m) {
let n = 0;
const w = Math.min(m.length, g ? a.A : a.D);
for (let q = 0, r = 0, l, p; q < w; q++) {
if (l = m[q]) {
if (a.s && (l = ra(l, h, g, a.l)), e && l && f && (p = l.length, p <= e ? (e -= p, l = null) : (l = l.slice(e), e = 0)), l && (k[n++] = l, f && (r += l.length, r >= d))) {
break;
}
}
}
if (n) {
if (f) {
return qa(k, d, 0);
}
b[b.length] = k;
return;
}
}
return !c && k;
}
function qa(a, b, c) {
a = 1 === a.length ? a[0] : [].concat.apply([], a);
return c || a.length > b ? a.slice(c, c + b) : a;
}
function ra(a, b, c, d) {
c ? (d = d && b > c, a = (a = a[d ? b : c]) && a[d ? c : b]) : a = a[b];
return a;
}
t.contain = function(a) {
return !!this.register[a];
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a, b) {
const c = this.register[a];
if (c) {
if (this.m) {
for (let d = 0, e; d < c.length; d++) {
e = c[d], e.splice(e.indexOf(a), 1);
}
} else {
Q(this.map, a, this.D, this.s), this.depth && Q(this.h, a, this.A, this.s);
}
b || delete this.register[a];
if (this.cache) {
b = this.cache;
for (let d = 0, e, f; d < b.h.length; d++) {
f = b.h[d], e = b.cache[f], e.includes(a) && (b.h.splice(d--, 1), delete b.cache[f]);
}
}
}
return this;
};
function Q(a, b, c, d, e) {
let f = 0;
if (a.constructor === Array) {
if (e) {
b = a.indexOf(b), -1 !== b ? 1 < a.length && (a.splice(b, 1), f++) : f++;
} else {
e = Math.min(a.length, c);
for (let h = 0, g; h < e; h++) {
if (g = a[h]) {
f = Q(g, b, c, d, e), d || f || delete a[h];
}
}
}
} else {
for (let h in a) {
(f = Q(a[h], b, c, d, e)) || delete a[h];
}
}
return f;
}
t.searchCache = la;
t.export = function(a, b, c, d, e, f) {
let h = !0;
"undefined" === typeof f && (h = new Promise(m => {
f = m;
}));
let g, k;
switch(e || (e = 0)) {
case 0:
g = "reg";
if (this.m) {
k = x();
for (let m in this.register) {
k[m] = 1;
}
} else {
k = this.register;
}
break;
case 1:
g = "cfg";
k = {doc:0, opt:this.s ? 1 : 0};
break;
case 2:
g = "map";
k = this.map;
break;
case 3:
g = "ctx";
k = this.h;
break;
default:
"undefined" === typeof c && f && f();
return;
}
oa(a, b || this, c, g, d, e, k, f);
return h;
};
t.import = function(a, b) {
if (b) {
switch(C(b) && (b = JSON.parse(b)), a) {
case "cfg":
this.s = !!b.opt;
break;
case "reg":
this.m = !1;
this.register = b;
break;
case "map":
this.map = b;
break;
case "ctx":
this.h = b;
}
}
};
ia(N.prototype);
function sa(a) {
a = a.data;
var b = self._index;
const c = a.args;
var d = a.task;
switch(d) {
case "init":
d = a.options || {};
a = a.factory;
b = d.encode;
d.cache = !1;
b && 0 === b.indexOf("function") && (d.encode = Function("return " + b)());
a ? (Function("return " + a)()(self), self._index = new self.FlexSearch.Index(d), delete self.FlexSearch) : self._index = new N(d);
break;
default:
a = a.id, b = b[d].apply(b, c), postMessage("search" === d ? {id:a, msg:b} : {id:a});
}
}
;let ta = 0;
function S(a) {
if (!(this instanceof S)) {
return new S(a);
}
var b;
a ? E(b = a.encode) && (a.encode = b.toString()) : a = {};
(b = (self || window)._factory) && (b = b.toString());
const c = "undefined" === typeof window && self.exports, d = this;
this.o = ua(b, c, a.worker);
this.h = x();
if (this.o) {
if (c) {
this.o.on("message", function(e) {
d.h[e.id](e.msg);
delete d.h[e.id];
});
} else {
this.o.onmessage = function(e) {
e = e.data;
d.h[e.id](e.msg);
delete d.h[e.id];
};
}
this.o.postMessage({task:"init", factory:b, options:a});
}
}
T("add");
T("append");
T("search");
T("update");
T("remove");
function T(a) {
S.prototype[a] = S.prototype[a + "Async"] = function() {
const b = this, c = [].slice.call(arguments);
var d = c[c.length - 1];
let e;
E(d) && (e = d, c.splice(c.length - 1, 1));
d = new Promise(function(f) {
setTimeout(function() {
b.h[++ta] = f;
b.o.postMessage({task:a, id:ta, args:c});
});
});
return e ? (d.then(e), this) : d;
};
}
function ua(a, b, c) {
let d;
try {
d = b ? new (require("worker_threads")["Worker"])(__dirname + "/node/node.js") : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + sa.toString()], {type:"text/javascript"}))) : new Worker(C(c) ? c : "worker/worker.js", {type:"module"});
} catch (e) {
}
return d;
}
;function U(a) {
if (!(this instanceof U)) {
return new U(a);
}
var b = a.document || a.doc || a, c;
this.K = [];
this.h = [];
this.A = [];
this.register = x();
this.key = (c = b.key || b.id) && V(c, this.A) || "id";
this.m = u(a.fastupdate);
this.C = (c = b.store) && !0 !== c && [];
this.store = c && x();
this.I = (c = b.tag) && V(c, this.A);
this.l = c && x();
this.cache = (c = a.cache) && new M(c);
a.cache = !1;
this.o = a.worker;
this.async = !1;
c = x();
let d = b.index || b.field || b;
C(d) && (d = [d]);
for (let e = 0, f, h; e < d.length; e++) {
f = d[e], C(f) || (h = f, f = f.field), h = D(h) ? Object.assign({}, a, h) : a, this.o && (c[f] = new S(h), c[f].o || (this.o = !1)), this.o || (c[f] = new N(h, this.register)), this.K[e] = V(f, this.A), this.h[e] = f;
}
if (this.C) {
for (a = b.store, C(a) && (a = [a]), b = 0; b < a.length; b++) {
this.C[b] = V(a[b], this.A);
}
}
this.index = c;
}
function V(a, b) {
const c = a.split(":");
let d = 0;
for (let e = 0; e < c.length; e++) {
a = c[e], 0 <= a.indexOf("[]") && (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];
}
function X(a, b) {
if (C(b)) {
a = a[b];
} else {
for (let c = 0; a && c < b.length; c++) {
a = a[b[c]];
}
}
return a;
}
function Y(a, b, c, d, e) {
a = a[e];
if (d === c.length - 1) {
b[e] = a;
} else if (a) {
if (a.constructor === Array) {
for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) {
Y(a, b, c, d, e);
}
} else {
b = b[e] || (b[e] = x()), e = c[++d], Y(a, b, c, d, e);
}
}
}
function Z(a, b, c, d, e, f, h, g) {
if (a = a[h]) {
if (d === b.length - 1) {
if (a.constructor === Array) {
if (c[d]) {
for (b = 0; b < a.length; b++) {
e.add(f, a[b], !0, !0);
}
return;
}
a = a.join(" ");
}
e.add(f, a, g, !0);
} else {
if (a.constructor === Array) {
for (h = 0; h < a.length; h++) {
Z(a, b, c, d, e, f, h, g);
}
} else {
h = b[++d], Z(a, b, c, d, e, f, h, g);
}
}
}
}
t = U.prototype;
t.add = function(a, b, c) {
D(a) && (b = a, a = X(b, this.key));
if (b && (a || 0 === a)) {
if (!c && this.register[a]) {
return this.update(a, b);
}
for (let d = 0, e, f; d < this.h.length; d++) {
f = this.h[d], e = this.K[d], C(e) && (e = [e]), Z(b, e, this.A, 0, this.index[f], a, e[0], c);
}
if (this.I) {
let d = X(b, this.I), e = x();
C(d) && (d = [d]);
for (let f = 0, h, g; f < d.length; f++) {
if (h = d[f], !e[h] && (e[h] = 1, g = this.l[h] || (this.l[h] = []), !c || !g.includes(a))) {
if (g[g.length] = a, this.m) {
const k = this.register[a] || (this.register[a] = []);
k[k.length] = g;
}
}
}
}
if (this.store && (!c || !this.store[a])) {
let d;
if (this.C) {
d = x();
for (let e = 0, f; e < this.C.length; e++) {
f = this.C[e], C(f) ? d[f] = b[f] : Y(b, d, f, 0, f[0]);
}
}
this.store[a] = d || b;
}
}
return this;
};
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a) {
D(a) && (a = X(a, this.key));
if (this.register[a]) {
for (var b = 0; b < this.h.length && (this.index[this.h[b]].remove(a, !this.o), !this.m); b++) {
}
if (this.I && !this.m) {
for (let c in this.l) {
b = this.l[c];
const d = b.indexOf(a);
-1 !== d && (1 < b.length ? b.splice(d, 1) : delete this.l[c]);
}
}
this.store && delete this.store[a];
delete this.register[a];
}
return this;
};
t.search = function(a, b, c, d) {
c || (!b && D(a) ? (c = a, a = "") : D(b) && (c = b, b = 0));
let e = [], f = [], h, g, k, m, n, w, q = 0;
if (c) {
if (c.constructor === Array) {
k = c, c = null;
} else {
a = c.query || a;
k = (h = c.pluck) || c.index || c.field;
m = c.tag;
g = this.store && c.enrich;
n = "and" === c.bool;
b = c.limit || b || 100;
w = c.offset || 0;
if (m && (C(m) && (m = [m]), !a)) {
for (let l = 0, p; l < m.length; l++) {
if (p = va.call(this, m[l], b, w, g)) {
e[e.length] = p, q++;
}
}
return q ? e : [];
}
C(k) && (k = [k]);
}
}
k || (k = this.h);
n = n && (1 < k.length || m && 1 < m.length);
const r = !d && (this.o || this.async) && [];
for (let l = 0, p, A, B; l < k.length; l++) {
let z;
A = k[l];
C(A) || (z = A, A = z.field, a = z.query || a, b = z.limit || b, g = z.enrich || g);
if (r) {
r[l] = this.index[A].searchAsync(a, b, z || c);
} else {
d ? p = d[l] : p = this.index[A].search(a, b, z || c);
B = p && p.length;
if (m && B) {
const y = [];
let H = 0;
n && (y[0] = [p]);
for (let W = 0, na, R; W < m.length; W++) {
if (na = m[W], B = (R = this.l[na]) && R.length) {
H++, y[y.length] = n ? [R] : R;
}
}
H && (p = n ? ja(y, b || 100, w || 0) : ka(p, y), B = p.length);
}
if (B) {
f[q] = A, e[q++] = p;
} else if (n) {
return [];
}
}
}
if (r) {
const l = this;
return new Promise(function(p) {
Promise.all(r).then(function(A) {
p(l.search(a, b, c, A));
});
});
}
if (!q) {
return [];
}
if (h && (!g || !this.store)) {
return e[0];
}
for (let l = 0, p; l < f.length; l++) {
p = e[l];
p.length && g && (p = wa.call(this, p));
if (h) {
return p;
}
e[l] = {field:f[l], result:p};
}
return e;
};
function va(a, b, c, d) {
let e = this.l[a], f = e && e.length - c;
if (f && 0 < f) {
if (f > b || c) {
e = e.slice(c, c + b);
}
d && (e = wa.call(this, e));
return {tag:a, result:e};
}
}
function wa(a) {
const b = Array(a.length);
for (let c = 0, d; c < a.length; c++) {
d = a[c], b[c] = {id:d, doc:this.store[d]};
}
return b;
}
t.contain = function(a) {
return !!this.register[a];
};
t.get = function(a) {
return this.store[a];
};
t.set = function(a, b) {
this.store[a] = b;
return this;
};
t.searchCache = la;
t.export = function(a, b, c, d, e, f) {
let h;
"undefined" === typeof f && (h = new Promise(g => {
f = g;
}));
e || (e = 0);
d || (d = 0);
if (d < this.h.length) {
const g = this.h[d], k = this.index[g];
b = this;
setTimeout(function() {
k.export(a, b, e ? g : "", d, e++, f) || (d++, e = 1, b.export(a, b, g, d, e, f));
});
} else {
let g, k;
switch(e) {
case 1:
g = "tag";
k = this.l;
c = null;
break;
case 2:
g = "store";
k = this.store;
c = null;
break;
default:
f();
return;
}
oa(a, this, c, g, d, e, k, f);
}
return h;
};
t.import = function(a, b) {
if (b) {
switch(C(b) && (b = JSON.parse(b)), a) {
case "tag":
this.l = b;
break;
case "reg":
this.m = !1;
this.register = b;
for (let d = 0, e; d < this.h.length; d++) {
e = this.index[this.h[d]], e.register = b, e.m = !1;
}
break;
case "store":
this.store = b;
break;
default:
a = a.split(".");
const c = a[0];
a = a[1];
c && a && this.index[c].import(a, b);
}
}
};
ia(U.prototype);
var ya = {encode:xa, F:!1, G:""};
const za = [J("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), "a", J("[\u00e8\u00e9\u00ea\u00eb]"), "e", J("[\u00ec\u00ed\u00ee\u00ef]"), "i", J("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), "o", J("[\u00f9\u00fa\u00fb\u00fc\u0171]"), "u", J("[\u00fd\u0177\u00ff]"), "y", J("\u00f1"), "n", J("[\u00e7c]"), "k", J("\u00df"), "s", J(" & "), " and "];
function xa(a) {
var b = a = "" + a;
b.normalize && (b = b.normalize("NFD").replace(ca, ""));
return F.call(this, b.toLowerCase(), !a.normalize && za);
}
;var Ba = {encode:Aa, F:!1, G:"strict"};
const Ca = /[^a-z0-9]+/, Da = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
function Aa(a) {
a = xa.call(this, a).join(" ");
const b = [];
if (a) {
const c = a.split(Ca), d = c.length;
for (let e = 0, f, h = 0; e < d; e++) {
if ((a = c[e]) && (!this.filter || !this.filter[a])) {
f = a[0];
let g = Da[f] || f, k = g;
for (let m = 1; m < a.length; m++) {
f = a[m];
const n = Da[f] || f;
n && n !== k && (g += n, k = n);
}
b[h++] = g;
}
}
}
return b;
}
;var Fa = {encode:Ea, F:!1, G:""};
const Ga = [J("ae"), "a", J("oe"), "o", J("sh"), "s", J("th"), "t", J("ph"), "f", J("pf"), "f", J("(?![aeo])h(?![aeo])"), "", J("(?!^[aeo])h(?!^[aeo])"), ""];
function Ea(a, b) {
a && (a = Aa.call(this, a).join(" "), 2 < a.length && (a = G(a, Ga)), b || (1 < a.length && (a = da(a)), a && (a = a.split(" "))));
return a || [];
}
;var Ia = {encode:Ha, F:!1, G:""};
const Ja = J("(?!\\b)[aeo]");
function Ha(a) {
a && (a = Ea.call(this, a, !0), 1 < a.length && (a = a.replace(Ja, "")), 1 < a.length && (a = da(a)), a && (a = a.split(" ")));
return a || [];
}
;K["latin:default"] = fa;
K["latin:simple"] = ya;
K["latin:balance"] = Ba;
K["latin:advanced"] = Fa;
K["latin:extra"] = Ia;
export default {Index:N, Document:U, Worker:S, registerCharset:function(a, b) {
K[a] = b;
}, registerLanguage:function(a, b) {
ha[a] = b;
}};

View File

@@ -0,0 +1,34 @@
/**!
* FlexSearch.js v0.7.41 (Bundle.module)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
var t;function u(a){return"undefined"!==typeof a?a:!0}function v(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=x();return b}function x(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a}function E(a){return"function"===typeof a};function F(a,b){var c=ba;if(a&&(b&&(a=G(a,b)),this.H&&(a=G(a,this.H)),this.J&&1<a.length&&(a=G(a,this.J)),c||""===c)){b=a.split(c);if(this.filter){a=this.filter;c=b.length;const d=[];for(let e=0,f=0;e<c;e++){const h=b[e];h&&!a[h]&&(d[f++]=h)}a=d}else a=b;return a}return a}const ba=/[\p{Z}\p{S}\p{P}\p{C}]+/u,ca=/[\u0300-\u036f]/g;
function I(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",h=0;for(let g=0,k,m;g<d;g++)k=c[g],(m=a[k])?(e[h++]=J(b?"(?!\\b)"+k+"(\\b|_)":k),e[h++]=m):f+=(f?"|":"")+k;f&&(e[h++]=J(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[h]="");return e}function G(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function J(a){return new RegExp(a,"g")}function da(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};var fa={encode:ea,F:!1,G:""};function ea(a){return F.call(this,(""+a).toLowerCase(),!1)};const ha={},K={};function ia(a){L(a,"add");L(a,"append");L(a,"search");L(a,"update");L(a,"remove")}function L(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;E(e)&&(f=e,delete d[d.length-1]);e=new Promise(function(h){setTimeout(function(){c.async=!0;const g=c[b].apply(c,d);c.async=!1;h(g)})});return f?(e.then(f),this):e}};function ja(a,b,c,d){const e=a.length;let f=[],h,g,k=0;d&&(d=[]);for(let m=e-1;0<=m;m--){const n=a[m],w=n.length,q=x();let r=!h;for(let l=0;l<w;l++){const p=n[l],A=p.length;if(A)for(let B=0,z,y;B<A;B++)if(y=p[B],h){if(h[y]){if(!m)if(c)c--;else if(f[k++]=y,k===b)return f;if(m||d)q[y]=1;r=!0}if(d&&(z=(g[y]||0)+1,g[y]=z,z<e)){const H=d[z-2]||(d[z-2]=[]);H[H.length]=y}}else q[y]=1}if(d)h||(g=q);else if(!r)return[];h=q}if(d)for(let m=d.length-1,n,w;0<=m;m--){n=d[m];w=n.length;for(let q=0,r;q<w;q++)if(r=
n[q],!h[r]){if(c)c--;else if(f[k++]=r,k===b)return f;h[r]=1}}return f}function ka(a,b){const c=x(),d=x(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,h;f<b.length;f++){h=b[f];for(let g=0,k;g<h.length;g++)k=h[g],c[k]&&!d[k]&&(d[k]=1,e[e.length]=k)}return e};function M(a){this.l=!0!==a&&a;this.cache=x();this.h=[]}function la(a,b,c){D(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}M.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};M.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const na={memory:{charset:"latin:extra",D:3,B:4,m:!1},performance:{D:3,B:3,s:!1,context:{depth:2,D:1}},match:{charset:"latin:extra",G:"reverse"},score:{charset:"latin:advanced",D:20,B:3,context:{depth:3,D:9}},"default":{}};function oa(a,b,c,d,e,f,h,g){setTimeout(function(){const k=a(c?c+"."+d:d,JSON.stringify(h));k&&k.then?k.then(function(){b.export(a,b,c,e,f+1,g)}):b.export(a,b,c,e,f+1,g)})};function N(a,b){if(!(this instanceof N))return new N(a);var c;if(a){C(a)?a=na[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=K[c]);C(d)&&(d=ha[d])}else a={};let e,f,h=a.context||{};this.encode=a.encode||c&&c.encode||ea;this.register=b||x();this.D=e=a.resolution||9;this.G=b=c&&c.G||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.l=u(h.bidirectional);this.s=f=u(a.optimize);this.m=u(a.fastupdate);this.B=a.minlength||1;this.C=
a.boost;this.map=f?v(e):x();this.A=e=h.resolution||1;this.h=f?v(e):x();this.F=c&&c.F||a.rtl;this.H=(b=a.matcher||d&&d.H)&&I(b,!1);this.J=(b=a.stemmer||d&&d.J)&&I(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=x();for(let g=0,k=c.length;g<k;g++)d[c[g]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new M(b)}t=N.prototype;t.append=function(a,b){return this.add(a,b,!0)};
t.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(d=b.length){const m=x(),n=x(),w=this.depth,q=this.D;for(let r=0;r<d;r++){let l=b[this.F?d-1-r:r];var e=l.length;if(l&&e>=this.B&&(w||!n[l])){var f=O(q,d,r),h="";switch(this.G){case "full":if(2<e){for(f=0;f<e;f++)for(var g=e;g>f;g--)if(g-f>=this.B){var k=O(q,d,r,e,f);h=l.substring(f,g);P(this,n,h,k,a,c)}break}case "reverse":if(1<e){for(g=e-1;0<g;g--)h=l[g]+h,h.length>=this.B&&P(this,n,
h,O(q,d,r,e,g),a,c);h=""}case "forward":if(1<e){for(g=0;g<e;g++)h+=l[g],h.length>=this.B&&P(this,n,h,f,a,c);break}default:if(this.C&&(f=Math.min(f/this.C(b,l,r)|0,q-1)),P(this,n,l,f,a,c),w&&1<d&&r<d-1)for(e=x(),h=this.A,f=l,g=Math.min(w+1,d-r),e[f]=1,k=1;k<g;k++)if((l=b[this.F?d-1-r-k:r+k])&&l.length>=this.B&&!e[l]){e[l]=1;const p=this.l&&l>f;P(this,m,p?f:l,O(h+(d/2>h?0:1),d,r,g-1,k-1),a,c,p?l:f)}}}}this.m||(this.register[a]=1)}}return this};
function O(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}function P(a,b,c,d,e,f,h){let g=h?a.h:a.map;if(!b[c]||h&&!b[c][h])a.s&&(g=g[d]),h?(b=b[c]||(b[c]=x()),b[h]=1,g=g[h]||(g[h]=x())):b[c]=1,g=g[c]||(g[c]=[]),a.s||(g=g[d]||(g[d]=[])),f&&g.includes(e)||(g[g.length]=e,a.m&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=g))}
t.search=function(a,b,c){c||(!b&&D(a)?(c=a,a=c.query):D(b)&&(c=b));let d=[],e;let f,h=0;if(c){a=c.query||a;b=c.limit;h=c.offset||0;var g=c.context;f=c.suggest}if(a&&(a=this.encode(""+a),e=a.length,1<e)){c=x();var k=[];for(let n=0,w=0,q;n<e;n++)if((q=a[n])&&q.length>=this.B&&!c[q])if(this.s||f||this.map[q])k[w++]=q,c[q]=1;else return d;a=k;e=a.length}if(!e)return d;b||(b=100);g=this.depth&&1<e&&!1!==g;c=0;let m;g?(m=a[0],c=1):1<e&&a.sort(aa);for(let n,w;c<e;c++){w=a[c];g?(n=pa(this,d,f,b,h,2===e,w,
m),f&&!1===n&&d.length||(m=w)):n=pa(this,d,f,b,h,1===e,w);if(n)return n;if(f&&c===e-1){k=d.length;if(!k){if(g){g=0;c=-1;continue}return d}if(1===k)return qa(d[0],b,h)}}return ja(d,b,h,f)};
function pa(a,b,c,d,e,f,h,g){let k=[],m=g?a.h:a.map;a.s||(m=ra(m,h,g,a.l));if(m){let n=0;const w=Math.min(m.length,g?a.A:a.D);for(let q=0,r=0,l,p;q<w;q++)if(l=m[q])if(a.s&&(l=ra(l,h,g,a.l)),e&&l&&f&&(p=l.length,p<=e?(e-=p,l=null):(l=l.slice(e),e=0)),l&&(k[n++]=l,f&&(r+=l.length,r>=d)))break;if(n){if(f)return qa(k,d,0);b[b.length]=k;return}}return!c&&k}function qa(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ra(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a,b){const c=this.register[a];if(c){if(this.m)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else Q(this.map,a,this.D,this.s),this.depth&&Q(this.h,a,this.A,this.s);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],e.includes(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
function Q(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let h=0,g;h<e;h++)if(g=a[h])f=Q(g,b,c,d,e),d||f||delete a[h]}else for(let h in a)(f=Q(a[h],b,c,d,e))||delete a[h];return f}t.searchCache=la;
t.export=function(a,b,c,d,e,f){let h=!0;"undefined"===typeof f&&(h=new Promise(m=>{f=m}));let g,k;switch(e||(e=0)){case 0:g="reg";if(this.m){k=x();for(let m in this.register)k[m]=1}else k=this.register;break;case 1:g="cfg";k={doc:0,opt:this.s?1:0};break;case 2:g="map";k=this.map;break;case 3:g="ctx";k=this.h;break;default:"undefined"===typeof c&&f&&f();return}oa(a,b||this,c,g,d,e,k,f);return h};
t.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "cfg":this.s=!!b.opt;break;case "reg":this.m=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};ia(N.prototype);function sa(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new N(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let ta=0;function S(a){if(!(this instanceof S))return new S(a);var b;a?E(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c="undefined"===typeof window&&self.exports,d=this;this.o=ua(b,c,a.worker);this.h=x();if(this.o){if(c)this.o.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.o.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.o.postMessage({task:"init",factory:b,options:a})}}T("add");T("append");T("search");
T("update");T("remove");function T(a){S.prototype[a]=S.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;E(d)&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){setTimeout(function(){b.h[++ta]=f;b.o.postMessage({task:a,id:ta,args:c})})});return e?(d.then(e),this):d}}
function ua(a,b,c){let d;try{d=b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+sa.toString()],{type:"text/javascript"}))):new Worker(C(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function U(a){if(!(this instanceof U))return new U(a);var b=a.document||a.doc||a,c;this.K=[];this.h=[];this.A=[];this.register=x();this.key=(c=b.key||b.id)&&V(c,this.A)||"id";this.m=u(a.fastupdate);this.C=(c=b.store)&&!0!==c&&[];this.store=c&&x();this.I=(c=b.tag)&&V(c,this.A);this.l=c&&x();this.cache=(c=a.cache)&&new M(c);a.cache=!1;this.o=a.worker;this.async=!1;c=x();let d=b.index||b.field||b;C(d)&&(d=[d]);for(let e=0,f,h;e<d.length;e++)f=d[e],C(f)||(h=f,f=f.field),h=D(h)?Object.assign({},a,h):a,
this.o&&(c[f]=new S(h),c[f].o||(this.o=!1)),this.o||(c[f]=new N(h,this.register)),this.K[e]=V(f,this.A),this.h[e]=f;if(this.C)for(a=b.store,C(a)&&(a=[a]),b=0;b<a.length;b++)this.C[b]=V(a[b],this.A);this.index=c}function V(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(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]}function X(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function Y(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)Y(a,b,c,d,e);else b=b[e]||(b[e]=x()),e=c[++d],Y(a,b,c,d,e)}function Z(a,b,c,d,e,f,h,g){if(a=a[h])if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,g,!0)}else if(a.constructor===Array)for(h=0;h<a.length;h++)Z(a,b,c,d,e,f,h,g);else h=b[++d],Z(a,b,c,d,e,f,h,g)}t=U.prototype;
t.add=function(a,b,c){D(a)&&(b=a,a=X(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.K[d],C(e)&&(e=[e]),Z(b,e,this.A,0,this.index[f],a,e[0],c);if(this.I){let d=X(b,this.I),e=x();C(d)&&(d=[d]);for(let f=0,h,g;f<d.length;f++)if(h=d[f],!e[h]&&(e[h]=1,g=this.l[h]||(this.l[h]=[]),!c||!g.includes(a)))if(g[g.length]=a,this.m){const k=this.register[a]||(this.register[a]=[]);k[k.length]=g}}if(this.store&&(!c||!this.store[a])){let d;
if(this.C){d=x();for(let e=0,f;e<this.C.length;e++)f=this.C[e],C(f)?d[f]=b[f]:Y(b,d,f,0,f[0])}this.store[a]=d||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a){D(a)&&(a=X(a,this.key));if(this.register[a]){for(var b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.o),!this.m);b++);if(this.I&&!this.m)for(let c in this.l){b=this.l[c];const d=b.indexOf(a);-1!==d&&(1<b.length?b.splice(d,1):delete this.l[c])}this.store&&delete this.store[a];delete this.register[a]}return this};
t.search=function(a,b,c,d){c||(!b&&D(a)?(c=a,a=""):D(b)&&(c=b,b=0));let e=[],f=[],h,g,k,m,n,w,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{a=c.query||a;k=(h=c.pluck)||c.index||c.field;m=c.tag;g=this.store&&c.enrich;n="and"===c.bool;b=c.limit||b||100;w=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=va.call(this,m[l],b,w,g))e[e.length]=p,q++;return q?e:[]}C(k)&&(k=[k])}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const r=!d&&(this.o||this.async)&&[];for(let l=0,p,A,B;l<
k.length;l++){let z;A=k[l];C(A)||(z=A,A=z.field,a=z.query||a,b=z.limit||b,g=z.enrich||g);if(r)r[l]=this.index[A].searchAsync(a,b,z||c);else{d?p=d[l]:p=this.index[A].search(a,b,z||c);B=p&&p.length;if(m&&B){const y=[];let H=0;n&&(y[0]=[p]);for(let W=0,ma,R;W<m.length;W++)if(ma=m[W],B=(R=this.l[ma])&&R.length)H++,y[y.length]=n?[R]:R;H&&(p=n?ja(y,b||100,w||0):ka(p,y),B=p.length)}if(B)f[q]=A,e[q++]=p;else if(n)return[]}}if(r){const l=this;return new Promise(function(p){Promise.all(r).then(function(A){p(l.search(a,
b,c,A))})})}if(!q)return[];if(h&&(!g||!this.store))return e[0];for(let l=0,p;l<f.length;l++){p=e[l];p.length&&g&&(p=wa.call(this,p));if(h)return p;e[l]={field:f[l],result:p}}return e};function va(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=wa.call(this,e));return{tag:a,result:e}}}function wa(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store[d]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};
t.set=function(a,b){this.store[a]=b;return this};t.searchCache=la;t.export=function(a,b,c,d,e,f){let h;"undefined"===typeof f&&(h=new Promise(g=>{f=g}));e||(e=0);d||(d=0);if(d<this.h.length){const g=this.h[d],k=this.index[g];b=this;setTimeout(function(){k.export(a,b,e?g:"",d,e++,f)||(d++,e=1,b.export(a,b,g,d,e,f))})}else{let g,k;switch(e){case 1:g="tag";k=this.l;c=null;break;case 2:g="store";k=this.store;c=null;break;default:f();return}oa(a,this,c,g,d,e,k,f)}return h};
t.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.m=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.index[this.h[d]],e.register=b,e.m=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};ia(U.prototype);var ya={encode:xa,F:!1,G:""};const za=[J("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",J("[\u00e8\u00e9\u00ea\u00eb]"),"e",J("[\u00ec\u00ed\u00ee\u00ef]"),"i",J("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",J("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",J("[\u00fd\u0177\u00ff]"),"y",J("\u00f1"),"n",J("[\u00e7c]"),"k",J("\u00df"),"s",J(" & ")," and "];function xa(a){var b=a=""+a;b.normalize&&(b=b.normalize("NFD").replace(ca,""));return F.call(this,b.toLowerCase(),!a.normalize&&za)};var Ba={encode:Aa,F:!1,G:"strict"};const Ca=/[^a-z0-9]+/,Da={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Aa(a){a=xa.call(this,a).join(" ");const b=[];if(a){const c=a.split(Ca),d=c.length;for(let e=0,f,h=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let g=Da[f]||f,k=g;for(let m=1;m<a.length;m++){f=a[m];const n=Da[f]||f;n&&n!==k&&(g+=n,k=n)}b[h++]=g}}return b};var Fa={encode:Ea,F:!1,G:""};const Ga=[J("ae"),"a",J("oe"),"o",J("sh"),"s",J("th"),"t",J("ph"),"f",J("pf"),"f",J("(?![aeo])h(?![aeo])"),"",J("(?!^[aeo])h(?!^[aeo])"),""];function Ea(a,b){a&&(a=Aa.call(this,a).join(" "),2<a.length&&(a=G(a,Ga)),b||(1<a.length&&(a=da(a)),a&&(a=a.split(" "))));return a||[]};var Ia={encode:Ha,F:!1,G:""};const Ja=J("(?!\\b)[aeo]");function Ha(a){a&&(a=Ea.call(this,a,!0),1<a.length&&(a=a.replace(Ja,"")),1<a.length&&(a=da(a)),a&&(a=a.split(" ")));return a||[]};K["latin:default"]=fa;K["latin:simple"]=ya;K["latin:balance"]=Ba;K["latin:advanced"]=Fa;K["latin:extra"]=Ia;export default {Index:N,Document:U,Worker:S,registerCharset:function(a,b){K[a]=b},registerLanguage:function(a,b){ha[a]=b}};

View File

@@ -0,0 +1,718 @@
/**!
* FlexSearch.js v0.7.41 (Compact)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';
var t;
function v(a) {
return "undefined" !== typeof a ? a : !0;
}
function w(a) {
const b = Array(a);
for (let c = 0; c < a; c++) {
b[c] = z();
}
return b;
}
function z() {
return Object.create(null);
}
function aa(a, b) {
return b.length - a.length;
}
function C(a) {
return "string" === typeof a;
}
function D(a) {
return "object" === typeof a;
}
;function E(a, b) {
var c = ba;
if (a && (b && (a = F(a, b)), this.G && (a = F(a, this.G)), this.H && 1 < a.length && (a = F(a, this.H)), c || "" === c)) {
b = a.split(c);
if (this.filter) {
a = this.filter;
c = b.length;
const e = [];
for (let d = 0, f = 0; d < c; d++) {
const g = b[d];
g && !a[g] && (e[f++] = g);
}
a = e;
} else {
a = b;
}
return a;
}
return a;
}
const ba = /[\p{Z}\p{S}\p{P}\p{C}]+/u, ca = /[\u0300-\u036f]/g;
function H(a, b) {
const c = Object.keys(a), e = c.length, d = [];
let f = "", g = 0;
for (let h = 0, k, m; h < e; h++) {
k = c[h], (m = a[k]) ? (d[g++] = I(b ? "(?!\\b)" + k + "(\\b|_)" : k), d[g++] = m) : f += (f ? "|" : "") + k;
}
f && (d[g++] = I(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), d[g] = "");
return d;
}
function F(a, b) {
for (let c = 0, e = b.length; c < e && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
}
return a;
}
function I(a) {
return new RegExp(a, "g");
}
function J(a) {
let b = "", c = "";
for (let e = 0, d = a.length, f; e < d; e++) {
(f = a[e]) !== c && (b += c = f);
}
return b;
}
;var da = {encode:K, B:!1, C:""};
function K(a) {
return E.call(this, ("" + a).toLowerCase(), !1);
}
;const L = {}, M = {};
function ea(a) {
O(a, "add");
O(a, "append");
O(a, "search");
O(a, "update");
O(a, "remove");
}
function O(a, b) {
a[b + "Async"] = function() {
const c = this, e = arguments;
var d = e[e.length - 1];
let f;
"function" === typeof d && (f = d, delete e[e.length - 1]);
d = new Promise(function(g) {
setTimeout(function() {
c.async = !0;
const h = c[b].apply(c, e);
c.async = !1;
g(h);
});
});
return f ? (d.then(f), this) : d;
};
}
;function fa(a, b, c, e) {
const d = a.length;
let f = [], g, h, k = 0;
e && (e = []);
for (let m = d - 1; 0 <= m; m--) {
const n = a[m], u = n.length, q = z();
let r = !g;
for (let l = 0; l < u; l++) {
const p = n[l], A = p.length;
if (A) {
for (let B = 0, y, x; B < A; B++) {
if (x = p[B], g) {
if (g[x]) {
if (!m) {
if (c) {
c--;
} else {
if (f[k++] = x, k === b) {
return f;
}
}
}
if (m || e) {
q[x] = 1;
}
r = !0;
}
if (e && (y = (h[x] || 0) + 1, h[x] = y, y < d)) {
const G = e[y - 2] || (e[y - 2] = []);
G[G.length] = x;
}
} else {
q[x] = 1;
}
}
}
}
if (e) {
g || (h = q);
} else if (!r) {
return [];
}
g = q;
}
if (e) {
for (let m = e.length - 1, n, u; 0 <= m; m--) {
n = e[m];
u = n.length;
for (let q = 0, r; q < u; q++) {
if (r = n[q], !g[r]) {
if (c) {
c--;
} else {
if (f[k++] = r, k === b) {
return f;
}
}
g[r] = 1;
}
}
}
}
return f;
}
function ha(a, b) {
const c = z(), e = z(), d = [];
for (let f = 0; f < a.length; f++) {
c[a[f]] = 1;
}
for (let f = 0, g; f < b.length; f++) {
g = b[f];
for (let h = 0, k; h < g.length; h++) {
k = g[h], c[k] && !e[k] && (e[k] = 1, d[d.length] = k);
}
}
return d;
}
;const ja = {memory:{charset:"latin:extra", A:3, m:4, D:!1}, performance:{A:3, m:3, s:!1, context:{depth:2, A:1}}, match:{charset:"latin:extra", C:"reverse"}, score:{charset:"latin:advanced", A:20, m:3, context:{depth:3, A:9}}, "default":{}};
function P(a, b) {
if (!(this instanceof P)) {
return new P(a);
}
var c;
let e;
if (a) {
if (C(a)) {
ja[a] || console.warn("Preset not found: " + a), a = ja[a];
} else {
if (c = a.preset) {
c[c] || console.warn("Preset not found: " + c), a = Object.assign({}, c[c], a);
}
}
c = a.charset;
e = a.lang;
C(c) && (-1 === c.indexOf(":") && (c += ":default"), c = M[c]);
C(e) && (e = L[e]);
} else {
a = {};
}
let d, f, g = a.context || {};
this.encode = a.encode || c && c.encode || K;
this.register = b || z();
this.A = d = a.resolution || 9;
this.C = b = c && c.C || a.tokenize || "strict";
this.depth = "strict" === b && g.depth;
this.h = v(g.bidirectional);
this.s = f = v(a.optimize);
this.D = v(a.fastupdate);
this.m = a.minlength || 1;
this.F = a.boost;
this.map = f ? w(d) : z();
this.o = d = g.resolution || 1;
this.l = f ? w(d) : z();
this.B = c && c.B || a.rtl;
this.G = (b = a.matcher || e && e.G) && H(b, !1);
this.H = (b = a.stemmer || e && e.H) && H(b, !0);
if (a = b = a.filter || e && e.filter) {
a = b;
c = z();
for (let h = 0, k = a.length; h < k; h++) {
c[a[h]] = 1;
}
a = c;
}
this.filter = a;
}
t = P.prototype;
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.add = function(a, b, c, e) {
if (b && (a || 0 === a)) {
if (!e && !c && this.register[a]) {
return this.update(a, b);
}
b = this.encode(b);
if (e = b.length) {
const m = z(), n = z(), u = this.depth, q = this.A;
for (let r = 0; r < e; r++) {
let l = b[this.B ? e - 1 - r : r];
var d = l.length;
if (l && d >= this.m && (u || !n[l])) {
var f = Q(q, e, r), g = "";
switch(this.C) {
case "full":
if (2 < d) {
for (f = 0; f < d; f++) {
for (var h = d; h > f; h--) {
if (h - f >= this.m) {
var k = Q(q, e, r, d, f);
g = l.substring(f, h);
S(this, n, g, k, a, c);
}
}
}
break;
}
case "reverse":
if (1 < d) {
for (h = d - 1; 0 < h; h--) {
g = l[h] + g, g.length >= this.m && S(this, n, g, Q(q, e, r, d, h), a, c);
}
g = "";
}
case "forward":
if (1 < d) {
for (h = 0; h < d; h++) {
g += l[h], g.length >= this.m && S(this, n, g, f, a, c);
}
break;
}
default:
if (this.F && (f = Math.min(f / this.F(b, l, r) | 0, q - 1)), S(this, n, l, f, a, c), u && 1 < e && r < e - 1) {
for (d = z(), g = this.o, f = l, h = Math.min(u + 1, e - r), d[f] = 1, k = 1; k < h; k++) {
if ((l = b[this.B ? e - 1 - r - k : r + k]) && l.length >= this.m && !d[l]) {
d[l] = 1;
const p = this.h && l > f;
S(this, m, p ? f : l, Q(g + (e / 2 > g ? 0 : 1), e, r, h - 1, k - 1), a, c, p ? l : f);
}
}
}
}
}
}
this.D || (this.register[a] = 1);
}
}
return this;
};
function Q(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 S(a, b, c, e, d, f, g) {
let h = g ? a.l : a.map;
if (!b[c] || g && !b[c][g]) {
a.s && (h = h[e]), g ? (b = b[c] || (b[c] = z()), b[g] = 1, h = h[g] || (h[g] = z())) : b[c] = 1, h = h[c] || (h[c] = []), a.s || (h = h[e] || (h[e] = [])), f && h.includes(d) || (h[h.length] = d, a.D && (a = a.register[d] || (a.register[d] = []), a[a.length] = h));
}
}
t.search = function(a, b, c) {
c || (!b && D(a) ? (c = a, a = c.query) : D(b) && (c = b));
let e = [], d;
let f, g = 0;
if (c) {
a = c.query || a;
b = c.limit;
g = c.offset || 0;
var h = c.context;
f = c.suggest;
}
if (a && (a = this.encode("" + a), d = a.length, 1 < d)) {
c = z();
var k = [];
for (let n = 0, u = 0, q; n < d; n++) {
if ((q = a[n]) && q.length >= this.m && !c[q]) {
if (this.s || f || this.map[q]) {
k[u++] = q, c[q] = 1;
} else {
return e;
}
}
}
a = k;
d = a.length;
}
if (!d) {
return e;
}
b || (b = 100);
h = this.depth && 1 < d && !1 !== h;
c = 0;
let m;
h ? (m = a[0], c = 1) : 1 < d && a.sort(aa);
for (let n, u; c < d; c++) {
u = a[c];
h ? (n = ka(this, e, f, b, g, 2 === d, u, m), f && !1 === n && e.length || (m = u)) : n = ka(this, e, f, b, g, 1 === d, u);
if (n) {
return n;
}
if (f && c === d - 1) {
k = e.length;
if (!k) {
if (h) {
h = 0;
c = -1;
continue;
}
return e;
}
if (1 === k) {
return la(e[0], b, g);
}
}
}
return fa(e, b, g, f);
};
function ka(a, b, c, e, d, f, g, h) {
let k = [], m = h ? a.l : a.map;
a.s || (m = ma(m, g, h, a.h));
if (m) {
let n = 0;
const u = Math.min(m.length, h ? a.o : a.A);
for (let q = 0, r = 0, l, p; q < u; q++) {
if (l = m[q]) {
if (a.s && (l = ma(l, g, h, a.h)), d && l && f && (p = l.length, p <= d ? (d -= p, l = null) : (l = l.slice(d), d = 0)), l && (k[n++] = l, f && (r += l.length, r >= e))) {
break;
}
}
}
if (n) {
if (f) {
return la(k, e, 0);
}
b[b.length] = k;
return;
}
}
return !c && k;
}
function la(a, b, c) {
a = 1 === a.length ? a[0] : [].concat.apply([], a);
return c || a.length > b ? a.slice(c, c + b) : a;
}
function ma(a, b, c, e) {
c ? (e = e && b > c, a = (a = a[e ? b : c]) && a[e ? c : b]) : a = a[b];
return a;
}
t.contain = function(a) {
return !!this.register[a];
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a, b) {
const c = this.register[a];
if (c) {
if (this.D) {
for (let e = 0, d; e < c.length; e++) {
d = c[e], d.splice(d.indexOf(a), 1);
}
} else {
T(this.map, a, this.A, this.s), this.depth && T(this.l, a, this.o, this.s);
}
b || delete this.register[a];
}
return this;
};
function T(a, b, c, e, d) {
let f = 0;
if (a.constructor === Array) {
if (d) {
b = a.indexOf(b), -1 !== b ? 1 < a.length && (a.splice(b, 1), f++) : f++;
} else {
d = Math.min(a.length, c);
for (let g = 0, h; g < d; g++) {
if (h = a[g]) {
f = T(h, b, c, e, d), e || f || delete a[g];
}
}
}
} else {
for (let g in a) {
(f = T(a[g], b, c, e, d)) || delete a[g];
}
}
return f;
}
ea(P.prototype);
function U(a) {
if (!(this instanceof U)) {
return new U(a);
}
var b = a.document || a.doc || a, c;
this.F = [];
this.h = [];
this.o = [];
this.register = z();
this.key = (c = b.key || b.id) && V(c, this.o) || "id";
this.D = v(a.fastupdate);
this.l = (c = b.store) && !0 !== c && [];
this.store = c && z();
this.async = !1;
c = z();
let e = b.index || b.field || b;
C(e) && (e = [e]);
for (let d = 0, f, g; d < e.length; d++) {
f = e[d], C(f) || (g = f, f = f.field), g = D(g) ? Object.assign({}, a, g) : a, this.I || (c[f] = new P(g, this.register)), this.F[d] = V(f, this.o), this.h[d] = f;
}
if (this.l) {
for (a = b.store, C(a) && (a = [a]), b = 0; b < a.length; b++) {
this.l[b] = V(a[b], this.o);
}
}
this.index = c;
}
function V(a, b) {
const c = a.split(":");
let e = 0;
for (let d = 0; d < c.length; d++) {
a = c[d], 0 <= a.indexOf("[]") && (a = a.substring(0, a.length - 2)) && (b[e] = !0), a && (c[e++] = a);
}
e < c.length && (c.length = e);
return 1 < e ? c : c[0];
}
function na(a, b) {
if (C(b)) {
a = a[b];
} else {
for (let c = 0; a && c < b.length; c++) {
a = a[b[c]];
}
}
return a;
}
function W(a, b, c, e, d) {
a = a[d];
if (e === c.length - 1) {
b[d] = a;
} else if (a) {
if (a.constructor === Array) {
for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) {
W(a, b, c, e, d);
}
} else {
b = b[d] || (b[d] = z()), d = c[++e], W(a, b, c, e, d);
}
}
}
function X(a, b, c, e, d, f, g, h) {
if (a = a[g]) {
if (e === b.length - 1) {
if (a.constructor === Array) {
if (c[e]) {
for (b = 0; b < a.length; b++) {
d.add(f, a[b], !0, !0);
}
return;
}
a = a.join(" ");
}
d.add(f, a, h, !0);
} else {
if (a.constructor === Array) {
for (g = 0; g < a.length; g++) {
X(a, b, c, e, d, f, g, h);
}
} else {
g = b[++e], X(a, b, c, e, d, f, g, h);
}
}
}
}
t = U.prototype;
t.add = function(a, b, c) {
D(a) && (b = a, a = na(b, this.key));
if (b && (a || 0 === a)) {
if (!c && this.register[a]) {
return this.update(a, b);
}
for (let e = 0, d, f; e < this.h.length; e++) {
f = this.h[e], d = this.F[e], C(d) && (d = [d]), X(b, d, this.o, 0, this.index[f], a, d[0], c);
}
if (this.store && (!c || !this.store[a])) {
let e;
if (this.l) {
e = z();
for (let d = 0, f; d < this.l.length; d++) {
f = this.l[d], C(f) ? e[f] = b[f] : W(b, e, f, 0, f[0]);
}
}
this.store[a] = e || b;
}
}
return this;
};
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a) {
D(a) && (a = na(a, this.key));
if (this.register[a]) {
for (let b = 0; b < this.h.length && (this.index[this.h[b]].remove(a, !this.I), !this.D); b++) {
}
this.store && delete this.store[a];
delete this.register[a];
}
return this;
};
t.search = function(a, b, c, e) {
c || (!b && D(a) ? (c = a, a = "") : D(b) && (c = b, b = 0));
let d = [], f = [], g, h, k, m, n, u, q = 0;
if (c) {
if (c.constructor === Array) {
k = c, c = null;
} else {
a = c.query || a;
k = (g = c.pluck) || c.index || c.field;
m = !1;
h = this.store && c.enrich;
n = "and" === c.bool;
b = c.limit || b || 100;
u = c.offset || 0;
if (m && (C(m) && (m = [m]), !a)) {
for (let l = 0, p; l < m.length; l++) {
if (p = oa.call(this, m[l], b, u, h)) {
d[d.length] = p, q++;
}
}
return q ? d : [];
}
C(k) && (k = [k]);
}
}
k || (k = this.h);
n = n && (1 < k.length || m && 1 < m.length);
const r = !e && (this.I || this.async) && [];
for (let l = 0, p, A, B; l < k.length; l++) {
let y;
A = k[l];
C(A) || (y = A, A = y.field, a = y.query || a, b = y.limit || b, h = y.enrich || h);
if (r) {
r[l] = this.index[A].searchAsync(a, b, y || c);
} else {
e ? p = e[l] : p = this.index[A].search(a, b, y || c);
B = p && p.length;
if (m && B) {
const x = [];
let G = 0;
n && (x[0] = [p]);
for (let R = 0, ia, N; R < m.length; R++) {
if (ia = m[R], B = (N = this.J[ia]) && N.length) {
G++, x[x.length] = n ? [N] : N;
}
}
G && (p = n ? fa(x, b || 100, u || 0) : ha(p, x), B = p.length);
}
if (B) {
f[q] = A, d[q++] = p;
} else if (n) {
return [];
}
}
}
if (r) {
const l = this;
return new Promise(function(p) {
Promise.all(r).then(function(A) {
p(l.search(a, b, c, A));
});
});
}
if (!q) {
return [];
}
if (g && (!h || !this.store)) {
return d[0];
}
for (let l = 0, p; l < f.length; l++) {
p = d[l];
p.length && h && (p = pa.call(this, p));
if (g) {
return p;
}
d[l] = {field:f[l], result:p};
}
return d;
};
function oa(a, b, c, e) {
let d = this.J[a], f = d && d.length - c;
if (f && 0 < f) {
if (f > b || c) {
d = d.slice(c, c + b);
}
e && (d = pa.call(this, d));
return {tag:a, result:d};
}
}
function pa(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[e]};
}
return b;
}
t.contain = function(a) {
return !!this.register[a];
};
t.get = function(a) {
return this.store[a];
};
t.set = function(a, b) {
this.store[a] = b;
return this;
};
ea(U.prototype);
var ra = {encode:qa, B:!1, C:""};
const sa = [I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), "a", I("[\u00e8\u00e9\u00ea\u00eb]"), "e", I("[\u00ec\u00ed\u00ee\u00ef]"), "i", I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), "o", I("[\u00f9\u00fa\u00fb\u00fc\u0171]"), "u", I("[\u00fd\u0177\u00ff]"), "y", I("\u00f1"), "n", I("[\u00e7c]"), "k", I("\u00df"), "s", I(" & "), " and "];
function qa(a) {
var b = a = "" + a;
b.normalize && (b = b.normalize("NFD").replace(ca, ""));
return E.call(this, b.toLowerCase(), !a.normalize && sa);
}
;var ua = {encode:ta, B:!1, C:"strict"};
const va = /[^a-z0-9]+/, wa = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
function ta(a) {
a = qa.call(this, a).join(" ");
const b = [];
if (a) {
const c = a.split(va), e = c.length;
for (let d = 0, f, g = 0; d < e; d++) {
if ((a = c[d]) && (!this.filter || !this.filter[a])) {
f = a[0];
let h = wa[f] || f, k = h;
for (let m = 1; m < a.length; m++) {
f = a[m];
const n = wa[f] || f;
n && n !== k && (h += n, k = n);
}
b[g++] = h;
}
}
}
return b;
}
;var ya = {encode:xa, B:!1, C:""};
const za = [I("ae"), "a", I("oe"), "o", I("sh"), "s", I("th"), "t", I("ph"), "f", I("pf"), "f", I("(?![aeo])h(?![aeo])"), "", I("(?!^[aeo])h(?!^[aeo])"), ""];
function xa(a, b) {
a && (a = ta.call(this, a).join(" "), 2 < a.length && (a = F(a, za)), b || (1 < a.length && (a = J(a)), a && (a = a.split(" "))));
return a || [];
}
;var Ba = {encode:Aa, B:!1, C:""};
const Ca = I("(?!\\b)[aeo]");
function Aa(a) {
a && (a = xa.call(this, a, !0), 1 < a.length && (a = a.replace(Ca, "")), 1 < a.length && (a = J(a)), a && (a = a.split(" ")));
return a || [];
}
;M["latin:default"] = da;
M["latin:simple"] = ra;
M["latin:balance"] = ua;
M["latin:advanced"] = ya;
M["latin:extra"] = Ba;
const Y = {Index:P, Document:U, Worker:null, registerCharset:function(a, b) {
M[a] = b;
}, registerLanguage:function(a, b) {
L[a] = b;
}};
let Z;
(Z = self.define) && Z.amd ? Z([], function() {
return Y;
}) : self.exports ? self.exports = Y : self.FlexSearch = Y;
}(this));

View File

@@ -0,0 +1,27 @@
/**!
* FlexSearch.js v0.7.41 (Compact)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';var t;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=z();return b}function z(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a};function E(a,b){var c=ba;if(a&&(b&&(a=F(a,b)),this.G&&(a=F(a,this.G)),this.H&&1<a.length&&(a=F(a,this.H)),c||""===c)){b=a.split(c);if(this.filter){a=this.filter;c=b.length;const e=[];for(let d=0,f=0;d<c;d++){const g=b[d];g&&!a[g]&&(e[f++]=g)}a=e}else a=b;return a}return a}const ba=/[\p{Z}\p{S}\p{P}\p{C}]+/u,ca=/[\u0300-\u036f]/g;
function H(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",g=0;for(let h=0,k,m;h<e;h++)k=c[h],(m=a[k])?(d[g++]=I(b?"(?!\\b)"+k+"(\\b|_)":k),d[g++]=m):f+=(f?"|":"")+k;f&&(d[g++]=I(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[g]="");return d}function F(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function I(a){return new RegExp(a,"g")}function J(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};var da={encode:K,B:!1,C:""};function K(a){return E.call(this,(""+a).toLowerCase(),!1)};const L={},M={};function ea(a){O(a,"add");O(a,"append");O(a,"search");O(a,"update");O(a,"remove")}function O(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,e);c.async=!1;g(h)})});return f?(d.then(f),this):d}};function fa(a,b,c,e){const d=a.length;let f=[],g,h,k=0;e&&(e=[]);for(let m=d-1;0<=m;m--){const n=a[m],u=n.length,q=z();let r=!g;for(let l=0;l<u;l++){const p=n[l],A=p.length;if(A)for(let B=0,y,x;B<A;B++)if(x=p[B],g){if(g[x]){if(!m)if(c)c--;else if(f[k++]=x,k===b)return f;if(m||e)q[x]=1;r=!0}if(e&&(y=(h[x]||0)+1,h[x]=y,y<d)){const G=e[y-2]||(e[y-2]=[]);G[G.length]=x}}else q[x]=1}if(e)g||(h=q);else if(!r)return[];g=q}if(e)for(let m=e.length-1,n,u;0<=m;m--){n=e[m];u=n.length;for(let q=0,r;q<u;q++)if(r=
n[q],!g[r]){if(c)c--;else if(f[k++]=r,k===b)return f;g[r]=1}}return f}function ia(a,b){const c=z(),e=z(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!e[k]&&(e[k]=1,d[d.length]=k)}return d};const ja={memory:{charset:"latin:extra",A:3,m:4,D:!1},performance:{A:3,m:3,s:!1,context:{depth:2,A:1}},match:{charset:"latin:extra",C:"reverse"},score:{charset:"latin:advanced",A:20,m:3,context:{depth:3,A:9}},"default":{}};function P(a,b){if(!(this instanceof P))return new P(a);var c;let e;a?(C(a)?a=ja[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=M[c]),C(e)&&(e=L[e])):a={};let d,f,g=a.context||{};this.encode=a.encode||c&&c.encode||K;this.register=b||z();this.A=d=a.resolution||9;this.C=b=c&&c.C||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.h=v(g.bidirectional);this.s=f=v(a.optimize);this.D=v(a.fastupdate);this.m=a.minlength||1;this.F=a.boost;
this.map=f?w(d):z();this.o=d=g.resolution||1;this.l=f?w(d):z();this.B=c&&c.B||a.rtl;this.G=(b=a.matcher||e&&e.G)&&H(b,!1);this.H=(b=a.stemmer||e&&e.H)&&H(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=z();for(let h=0,k=a.length;h<k;h++)c[a[h]]=1;a=c}this.filter=a}t=P.prototype;t.append=function(a,b){return this.add(a,b,!0)};
t.add=function(a,b,c,e){if(b&&(a||0===a)){if(!e&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(e=b.length){const m=z(),n=z(),u=this.depth,q=this.A;for(let r=0;r<e;r++){let l=b[this.B?e-1-r:r];var d=l.length;if(l&&d>=this.m&&(u||!n[l])){var f=Q(q,e,r),g="";switch(this.C){case "full":if(2<d){for(f=0;f<d;f++)for(var h=d;h>f;h--)if(h-f>=this.m){var k=Q(q,e,r,d,f);g=l.substring(f,h);S(this,n,g,k,a,c)}break}case "reverse":if(1<d){for(h=d-1;0<h;h--)g=l[h]+g,g.length>=this.m&&S(this,n,
g,Q(q,e,r,d,h),a,c);g=""}case "forward":if(1<d){for(h=0;h<d;h++)g+=l[h],g.length>=this.m&&S(this,n,g,f,a,c);break}default:if(this.F&&(f=Math.min(f/this.F(b,l,r)|0,q-1)),S(this,n,l,f,a,c),u&&1<e&&r<e-1)for(d=z(),g=this.o,f=l,h=Math.min(u+1,e-r),d[f]=1,k=1;k<h;k++)if((l=b[this.B?e-1-r-k:r+k])&&l.length>=this.m&&!d[l]){d[l]=1;const p=this.h&&l>f;S(this,m,p?f:l,Q(g+(e/2>g?0:1),e,r,h-1,k-1),a,c,p?l:f)}}}}this.D||(this.register[a]=1)}}return this};
function Q(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 S(a,b,c,e,d,f,g){let h=g?a.l:a.map;if(!b[c]||g&&!b[c][g])a.s&&(h=h[e]),g?(b=b[c]||(b[c]=z()),b[g]=1,h=h[g]||(h[g]=z())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[e]||(h[e]=[])),f&&h.includes(d)||(h[h.length]=d,a.D&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=h))}
t.search=function(a,b,c){c||(!b&&D(a)?(c=a,a=c.query):D(b)&&(c=b));let e=[],d;let f,g=0;if(c){a=c.query||a;b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(""+a),d=a.length,1<d)){c=z();var k=[];for(let n=0,u=0,q;n<d;n++)if((q=a[n])&&q.length>=this.m&&!c[q])if(this.s||f||this.map[q])k[u++]=q,c[q]=1;else return e;a=k;d=a.length}if(!d)return e;b||(b=100);h=this.depth&&1<d&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<d&&a.sort(aa);for(let n,u;c<d;c++){u=a[c];h?(n=ka(this,e,f,b,g,2===d,u,
m),f&&!1===n&&e.length||(m=u)):n=ka(this,e,f,b,g,1===d,u);if(n)return n;if(f&&c===d-1){k=e.length;if(!k){if(h){h=0;c=-1;continue}return e}if(1===k)return la(e[0],b,g)}}return fa(e,b,g,f)};
function ka(a,b,c,e,d,f,g,h){let k=[],m=h?a.l:a.map;a.s||(m=ma(m,g,h,a.h));if(m){let n=0;const u=Math.min(m.length,h?a.o:a.A);for(let q=0,r=0,l,p;q<u;q++)if(l=m[q])if(a.s&&(l=ma(l,g,h,a.h)),d&&l&&f&&(p=l.length,p<=d?(d-=p,l=null):(l=l.slice(d),d=0)),l&&(k[n++]=l,f&&(r+=l.length,r>=e)))break;if(n){if(f)return la(k,e,0);b[b.length]=k;return}}return!c&&k}function la(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ma(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};t.remove=function(a,b){const c=this.register[a];if(c){if(this.D)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else T(this.map,a,this.A,this.s),this.depth&&T(this.l,a,this.o,this.s);b||delete this.register[a]}return this};
function T(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let g=0,h;g<d;g++)if(h=a[g])f=T(h,b,c,e,d),e||f||delete a[g]}else for(let g in a)(f=T(a[g],b,c,e,d))||delete a[g];return f}ea(P.prototype);function U(a){if(!(this instanceof U))return new U(a);var b=a.document||a.doc||a,c;this.F=[];this.h=[];this.o=[];this.register=z();this.key=(c=b.key||b.id)&&V(c,this.o)||"id";this.D=v(a.fastupdate);this.l=(c=b.store)&&!0!==c&&[];this.store=c&&z();this.async=!1;c=z();let e=b.index||b.field||b;C(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],C(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,this.I||(c[f]=new P(g,this.register)),this.F[d]=V(f,this.o),this.h[d]=f;if(this.l)for(a=b.store,C(a)&&(a=
[a]),b=0;b<a.length;b++)this.l[b]=V(a[b],this.o);this.index=c}function V(a,b){const c=a.split(":");let e=0;for(let d=0;d<c.length;d++)a=c[d],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[e]=!0),a&&(c[e++]=a);e<c.length&&(c.length=e);return 1<e?c:c[0]}function na(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function W(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)W(a,b,c,e,d);else b=b[d]||(b[d]=z()),d=c[++e],W(a,b,c,e,d)}function X(a,b,c,e,d,f,g,h){if(a=a[g])if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)X(a,b,c,e,d,f,g,h);else g=b[++e],X(a,b,c,e,d,f,g,h)}t=U.prototype;
t.add=function(a,b,c){D(a)&&(b=a,a=na(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.F[e],C(d)&&(d=[d]),X(b,d,this.o,0,this.index[f],a,d[0],c);if(this.store&&(!c||!this.store[a])){let e;if(this.l){e=z();for(let d=0,f;d<this.l.length;d++)f=this.l[d],C(f)?e[f]=b[f]:W(b,e,f,0,f[0])}this.store[a]=e||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a){D(a)&&(a=na(a,this.key));if(this.register[a]){for(let b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.I),!this.D);b++);this.store&&delete this.store[a];delete this.register[a]}return this};
t.search=function(a,b,c,e){c||(!b&&D(a)?(c=a,a=""):D(b)&&(c=b,b=0));let d=[],f=[],g,h,k,m,n,u,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{a=c.query||a;k=(g=c.pluck)||c.index||c.field;m=!1;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||b||100;u=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=oa.call(this,m[l],b,u,h))d[d.length]=p,q++;return q?d:[]}C(k)&&(k=[k])}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const r=!e&&(this.I||this.async)&&[];for(let l=0,p,A,B;l<
k.length;l++){let y;A=k[l];C(A)||(y=A,A=y.field,a=y.query||a,b=y.limit||b,h=y.enrich||h);if(r)r[l]=this.index[A].searchAsync(a,b,y||c);else{e?p=e[l]:p=this.index[A].search(a,b,y||c);B=p&&p.length;if(m&&B){const x=[];let G=0;n&&(x[0]=[p]);for(let R=0,ha,N;R<m.length;R++)if(ha=m[R],B=(N=this.J[ha])&&N.length)G++,x[x.length]=n?[N]:N;G&&(p=n?fa(x,b||100,u||0):ia(p,x),B=p.length)}if(B)f[q]=A,d[q++]=p;else if(n)return[]}}if(r){const l=this;return new Promise(function(p){Promise.all(r).then(function(A){p(l.search(a,
b,c,A))})})}if(!q)return[];if(g&&(!h||!this.store))return d[0];for(let l=0,p;l<f.length;l++){p=d[l];p.length&&h&&(p=pa.call(this,p));if(g)return p;d[l]={field:f[l],result:p}}return d};function oa(a,b,c,e){let d=this.J[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=pa.call(this,d));return{tag:a,result:d}}}function pa(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[e]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};
t.set=function(a,b){this.store[a]=b;return this};ea(U.prototype);var ra={encode:qa,B:!1,C:""};const sa=[I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",I("[\u00e8\u00e9\u00ea\u00eb]"),"e",I("[\u00ec\u00ed\u00ee\u00ef]"),"i",I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",I("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",I("[\u00fd\u0177\u00ff]"),"y",I("\u00f1"),"n",I("[\u00e7c]"),"k",I("\u00df"),"s",I(" & ")," and "];function qa(a){var b=a=""+a;b.normalize&&(b=b.normalize("NFD").replace(ca,""));return E.call(this,b.toLowerCase(),!a.normalize&&sa)};var ua={encode:ta,B:!1,C:"strict"};const va=/[^a-z0-9]+/,wa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function ta(a){a=qa.call(this,a).join(" ");const b=[];if(a){const c=a.split(va),e=c.length;for(let d=0,f,g=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let h=wa[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=wa[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var ya={encode:xa,B:!1,C:""};const za=[I("ae"),"a",I("oe"),"o",I("sh"),"s",I("th"),"t",I("ph"),"f",I("pf"),"f",I("(?![aeo])h(?![aeo])"),"",I("(?!^[aeo])h(?!^[aeo])"),""];function xa(a,b){a&&(a=ta.call(this,a).join(" "),2<a.length&&(a=F(a,za)),b||(1<a.length&&(a=J(a)),a&&(a=a.split(" "))));return a||[]};var Ba={encode:Aa,B:!1,C:""};const Ca=I("(?!\\b)[aeo]");function Aa(a){a&&(a=xa.call(this,a,!0),1<a.length&&(a=a.replace(Ca,"")),1<a.length&&(a=J(a)),a&&(a=a.split(" ")));return a||[]};M["latin:default"]=da;M["latin:simple"]=ra;M["latin:balance"]=ua;M["latin:advanced"]=ya;M["latin:extra"]=Ba;const Y={Index:P,Document:U,Worker:null,registerCharset:function(a,b){M[a]=b},registerLanguage:function(a,b){L[a]=b}};let Z;(Z=self.define)&&Z.amd?Z([],function(){return Y}):self.exports?self.exports=Y:self.FlexSearch=Y;}(this));

View File

@@ -0,0 +1,714 @@
/**!
* FlexSearch.js v0.7.41 (Compact.module)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';
var t;
function v(a) {
return "undefined" !== typeof a ? a : !0;
}
function w(a) {
const b = Array(a);
for (let c = 0; c < a; c++) {
b[c] = z();
}
return b;
}
function z() {
return Object.create(null);
}
function aa(a, b) {
return b.length - a.length;
}
function C(a) {
return "string" === typeof a;
}
function D(a) {
return "object" === typeof a;
}
;function E(a, b) {
var c = ba;
if (a && (b && (a = F(a, b)), this.G && (a = F(a, this.G)), this.H && 1 < a.length && (a = F(a, this.H)), c || "" === c)) {
b = a.split(c);
if (this.filter) {
a = this.filter;
c = b.length;
const e = [];
for (let d = 0, f = 0; d < c; d++) {
const g = b[d];
g && !a[g] && (e[f++] = g);
}
a = e;
} else {
a = b;
}
return a;
}
return a;
}
const ba = /[\p{Z}\p{S}\p{P}\p{C}]+/u, ca = /[\u0300-\u036f]/g;
function H(a, b) {
const c = Object.keys(a), e = c.length, d = [];
let f = "", g = 0;
for (let h = 0, k, m; h < e; h++) {
k = c[h], (m = a[k]) ? (d[g++] = I(b ? "(?!\\b)" + k + "(\\b|_)" : k), d[g++] = m) : f += (f ? "|" : "") + k;
}
f && (d[g++] = I(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), d[g] = "");
return d;
}
function F(a, b) {
for (let c = 0, e = b.length; c < e && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
}
return a;
}
function I(a) {
return new RegExp(a, "g");
}
function J(a) {
let b = "", c = "";
for (let e = 0, d = a.length, f; e < d; e++) {
(f = a[e]) !== c && (b += c = f);
}
return b;
}
;var da = {encode:K, B:!1, C:""};
function K(a) {
return E.call(this, ("" + a).toLowerCase(), !1);
}
;const L = {}, M = {};
function O(a) {
P(a, "add");
P(a, "append");
P(a, "search");
P(a, "update");
P(a, "remove");
}
function P(a, b) {
a[b + "Async"] = function() {
const c = this, e = arguments;
var d = e[e.length - 1];
let f;
"function" === typeof d && (f = d, delete e[e.length - 1]);
d = new Promise(function(g) {
setTimeout(function() {
c.async = !0;
const h = c[b].apply(c, e);
c.async = !1;
g(h);
});
});
return f ? (d.then(f), this) : d;
};
}
;function Q(a, b, c, e) {
const d = a.length;
let f = [], g, h, k = 0;
e && (e = []);
for (let m = d - 1; 0 <= m; m--) {
const n = a[m], u = n.length, q = z();
let r = !g;
for (let l = 0; l < u; l++) {
const p = n[l], A = p.length;
if (A) {
for (let B = 0, y, x; B < A; B++) {
if (x = p[B], g) {
if (g[x]) {
if (!m) {
if (c) {
c--;
} else {
if (f[k++] = x, k === b) {
return f;
}
}
}
if (m || e) {
q[x] = 1;
}
r = !0;
}
if (e && (y = (h[x] || 0) + 1, h[x] = y, y < d)) {
const G = e[y - 2] || (e[y - 2] = []);
G[G.length] = x;
}
} else {
q[x] = 1;
}
}
}
}
if (e) {
g || (h = q);
} else if (!r) {
return [];
}
g = q;
}
if (e) {
for (let m = e.length - 1, n, u; 0 <= m; m--) {
n = e[m];
u = n.length;
for (let q = 0, r; q < u; q++) {
if (r = n[q], !g[r]) {
if (c) {
c--;
} else {
if (f[k++] = r, k === b) {
return f;
}
}
g[r] = 1;
}
}
}
}
return f;
}
function ea(a, b) {
const c = z(), e = z(), d = [];
for (let f = 0; f < a.length; f++) {
c[a[f]] = 1;
}
for (let f = 0, g; f < b.length; f++) {
g = b[f];
for (let h = 0, k; h < g.length; h++) {
k = g[h], c[k] && !e[k] && (e[k] = 1, d[d.length] = k);
}
}
return d;
}
;const ha = {memory:{charset:"latin:extra", A:3, m:4, D:!1}, performance:{A:3, m:3, s:!1, context:{depth:2, A:1}}, match:{charset:"latin:extra", C:"reverse"}, score:{charset:"latin:advanced", A:20, m:3, context:{depth:3, A:9}}, "default":{}};
function S(a, b) {
if (!(this instanceof S)) {
return new S(a);
}
var c;
let e;
if (a) {
if (C(a)) {
ha[a] || console.warn("Preset not found: " + a), a = ha[a];
} else {
if (c = a.preset) {
c[c] || console.warn("Preset not found: " + c), a = Object.assign({}, c[c], a);
}
}
c = a.charset;
e = a.lang;
C(c) && (-1 === c.indexOf(":") && (c += ":default"), c = M[c]);
C(e) && (e = L[e]);
} else {
a = {};
}
let d, f, g = a.context || {};
this.encode = a.encode || c && c.encode || K;
this.register = b || z();
this.A = d = a.resolution || 9;
this.C = b = c && c.C || a.tokenize || "strict";
this.depth = "strict" === b && g.depth;
this.h = v(g.bidirectional);
this.s = f = v(a.optimize);
this.D = v(a.fastupdate);
this.m = a.minlength || 1;
this.F = a.boost;
this.map = f ? w(d) : z();
this.o = d = g.resolution || 1;
this.l = f ? w(d) : z();
this.B = c && c.B || a.rtl;
this.G = (b = a.matcher || e && e.G) && H(b, !1);
this.H = (b = a.stemmer || e && e.H) && H(b, !0);
if (a = b = a.filter || e && e.filter) {
a = b;
c = z();
for (let h = 0, k = a.length; h < k; h++) {
c[a[h]] = 1;
}
a = c;
}
this.filter = a;
}
t = S.prototype;
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.add = function(a, b, c, e) {
if (b && (a || 0 === a)) {
if (!e && !c && this.register[a]) {
return this.update(a, b);
}
b = this.encode(b);
if (e = b.length) {
const m = z(), n = z(), u = this.depth, q = this.A;
for (let r = 0; r < e; r++) {
let l = b[this.B ? e - 1 - r : r];
var d = l.length;
if (l && d >= this.m && (u || !n[l])) {
var f = T(q, e, r), g = "";
switch(this.C) {
case "full":
if (2 < d) {
for (f = 0; f < d; f++) {
for (var h = d; h > f; h--) {
if (h - f >= this.m) {
var k = T(q, e, r, d, f);
g = l.substring(f, h);
U(this, n, g, k, a, c);
}
}
}
break;
}
case "reverse":
if (1 < d) {
for (h = d - 1; 0 < h; h--) {
g = l[h] + g, g.length >= this.m && U(this, n, g, T(q, e, r, d, h), a, c);
}
g = "";
}
case "forward":
if (1 < d) {
for (h = 0; h < d; h++) {
g += l[h], g.length >= this.m && U(this, n, g, f, a, c);
}
break;
}
default:
if (this.F && (f = Math.min(f / this.F(b, l, r) | 0, q - 1)), U(this, n, l, f, a, c), u && 1 < e && r < e - 1) {
for (d = z(), g = this.o, f = l, h = Math.min(u + 1, e - r), d[f] = 1, k = 1; k < h; k++) {
if ((l = b[this.B ? e - 1 - r - k : r + k]) && l.length >= this.m && !d[l]) {
d[l] = 1;
const p = this.h && l > f;
U(this, m, p ? f : l, T(g + (e / 2 > g ? 0 : 1), e, r, h - 1, k - 1), a, c, p ? l : f);
}
}
}
}
}
}
this.D || (this.register[a] = 1);
}
}
return this;
};
function T(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 U(a, b, c, e, d, f, g) {
let h = g ? a.l : a.map;
if (!b[c] || g && !b[c][g]) {
a.s && (h = h[e]), g ? (b = b[c] || (b[c] = z()), b[g] = 1, h = h[g] || (h[g] = z())) : b[c] = 1, h = h[c] || (h[c] = []), a.s || (h = h[e] || (h[e] = [])), f && h.includes(d) || (h[h.length] = d, a.D && (a = a.register[d] || (a.register[d] = []), a[a.length] = h));
}
}
t.search = function(a, b, c) {
c || (!b && D(a) ? (c = a, a = c.query) : D(b) && (c = b));
let e = [], d;
let f, g = 0;
if (c) {
a = c.query || a;
b = c.limit;
g = c.offset || 0;
var h = c.context;
f = c.suggest;
}
if (a && (a = this.encode("" + a), d = a.length, 1 < d)) {
c = z();
var k = [];
for (let n = 0, u = 0, q; n < d; n++) {
if ((q = a[n]) && q.length >= this.m && !c[q]) {
if (this.s || f || this.map[q]) {
k[u++] = q, c[q] = 1;
} else {
return e;
}
}
}
a = k;
d = a.length;
}
if (!d) {
return e;
}
b || (b = 100);
h = this.depth && 1 < d && !1 !== h;
c = 0;
let m;
h ? (m = a[0], c = 1) : 1 < d && a.sort(aa);
for (let n, u; c < d; c++) {
u = a[c];
h ? (n = ia(this, e, f, b, g, 2 === d, u, m), f && !1 === n && e.length || (m = u)) : n = ia(this, e, f, b, g, 1 === d, u);
if (n) {
return n;
}
if (f && c === d - 1) {
k = e.length;
if (!k) {
if (h) {
h = 0;
c = -1;
continue;
}
return e;
}
if (1 === k) {
return ja(e[0], b, g);
}
}
}
return Q(e, b, g, f);
};
function ia(a, b, c, e, d, f, g, h) {
let k = [], m = h ? a.l : a.map;
a.s || (m = ka(m, g, h, a.h));
if (m) {
let n = 0;
const u = Math.min(m.length, h ? a.o : a.A);
for (let q = 0, r = 0, l, p; q < u; q++) {
if (l = m[q]) {
if (a.s && (l = ka(l, g, h, a.h)), d && l && f && (p = l.length, p <= d ? (d -= p, l = null) : (l = l.slice(d), d = 0)), l && (k[n++] = l, f && (r += l.length, r >= e))) {
break;
}
}
}
if (n) {
if (f) {
return ja(k, e, 0);
}
b[b.length] = k;
return;
}
}
return !c && k;
}
function ja(a, b, c) {
a = 1 === a.length ? a[0] : [].concat.apply([], a);
return c || a.length > b ? a.slice(c, c + b) : a;
}
function ka(a, b, c, e) {
c ? (e = e && b > c, a = (a = a[e ? b : c]) && a[e ? c : b]) : a = a[b];
return a;
}
t.contain = function(a) {
return !!this.register[a];
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a, b) {
const c = this.register[a];
if (c) {
if (this.D) {
for (let e = 0, d; e < c.length; e++) {
d = c[e], d.splice(d.indexOf(a), 1);
}
} else {
V(this.map, a, this.A, this.s), this.depth && V(this.l, a, this.o, this.s);
}
b || delete this.register[a];
}
return this;
};
function V(a, b, c, e, d) {
let f = 0;
if (a.constructor === Array) {
if (d) {
b = a.indexOf(b), -1 !== b ? 1 < a.length && (a.splice(b, 1), f++) : f++;
} else {
d = Math.min(a.length, c);
for (let g = 0, h; g < d; g++) {
if (h = a[g]) {
f = V(h, b, c, e, d), e || f || delete a[g];
}
}
}
} else {
for (let g in a) {
(f = V(a[g], b, c, e, d)) || delete a[g];
}
}
return f;
}
O(S.prototype);
function W(a) {
if (!(this instanceof W)) {
return new W(a);
}
var b = a.document || a.doc || a, c;
this.F = [];
this.h = [];
this.o = [];
this.register = z();
this.key = (c = b.key || b.id) && X(c, this.o) || "id";
this.D = v(a.fastupdate);
this.l = (c = b.store) && !0 !== c && [];
this.store = c && z();
this.async = !1;
c = z();
let e = b.index || b.field || b;
C(e) && (e = [e]);
for (let d = 0, f, g; d < e.length; d++) {
f = e[d], C(f) || (g = f, f = f.field), g = D(g) ? Object.assign({}, a, g) : a, this.I || (c[f] = new S(g, this.register)), this.F[d] = X(f, this.o), this.h[d] = f;
}
if (this.l) {
for (a = b.store, C(a) && (a = [a]), b = 0; b < a.length; b++) {
this.l[b] = X(a[b], this.o);
}
}
this.index = c;
}
function X(a, b) {
const c = a.split(":");
let e = 0;
for (let d = 0; d < c.length; d++) {
a = c[d], 0 <= a.indexOf("[]") && (a = a.substring(0, a.length - 2)) && (b[e] = !0), a && (c[e++] = a);
}
e < c.length && (c.length = e);
return 1 < e ? c : c[0];
}
function la(a, b) {
if (C(b)) {
a = a[b];
} else {
for (let c = 0; a && c < b.length; c++) {
a = a[b[c]];
}
}
return a;
}
function Y(a, b, c, e, d) {
a = a[d];
if (e === c.length - 1) {
b[d] = a;
} else if (a) {
if (a.constructor === Array) {
for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) {
Y(a, b, c, e, d);
}
} else {
b = b[d] || (b[d] = z()), d = c[++e], Y(a, b, c, e, d);
}
}
}
function Z(a, b, c, e, d, f, g, h) {
if (a = a[g]) {
if (e === b.length - 1) {
if (a.constructor === Array) {
if (c[e]) {
for (b = 0; b < a.length; b++) {
d.add(f, a[b], !0, !0);
}
return;
}
a = a.join(" ");
}
d.add(f, a, h, !0);
} else {
if (a.constructor === Array) {
for (g = 0; g < a.length; g++) {
Z(a, b, c, e, d, f, g, h);
}
} else {
g = b[++e], Z(a, b, c, e, d, f, g, h);
}
}
}
}
t = W.prototype;
t.add = function(a, b, c) {
D(a) && (b = a, a = la(b, this.key));
if (b && (a || 0 === a)) {
if (!c && this.register[a]) {
return this.update(a, b);
}
for (let e = 0, d, f; e < this.h.length; e++) {
f = this.h[e], d = this.F[e], C(d) && (d = [d]), Z(b, d, this.o, 0, this.index[f], a, d[0], c);
}
if (this.store && (!c || !this.store[a])) {
let e;
if (this.l) {
e = z();
for (let d = 0, f; d < this.l.length; d++) {
f = this.l[d], C(f) ? e[f] = b[f] : Y(b, e, f, 0, f[0]);
}
}
this.store[a] = e || b;
}
}
return this;
};
t.append = function(a, b) {
return this.add(a, b, !0);
};
t.update = function(a, b) {
return this.remove(a).add(a, b);
};
t.remove = function(a) {
D(a) && (a = la(a, this.key));
if (this.register[a]) {
for (let b = 0; b < this.h.length && (this.index[this.h[b]].remove(a, !this.I), !this.D); b++) {
}
this.store && delete this.store[a];
delete this.register[a];
}
return this;
};
t.search = function(a, b, c, e) {
c || (!b && D(a) ? (c = a, a = "") : D(b) && (c = b, b = 0));
let d = [], f = [], g, h, k, m, n, u, q = 0;
if (c) {
if (c.constructor === Array) {
k = c, c = null;
} else {
a = c.query || a;
k = (g = c.pluck) || c.index || c.field;
m = !1;
h = this.store && c.enrich;
n = "and" === c.bool;
b = c.limit || b || 100;
u = c.offset || 0;
if (m && (C(m) && (m = [m]), !a)) {
for (let l = 0, p; l < m.length; l++) {
if (p = ma.call(this, m[l], b, u, h)) {
d[d.length] = p, q++;
}
}
return q ? d : [];
}
C(k) && (k = [k]);
}
}
k || (k = this.h);
n = n && (1 < k.length || m && 1 < m.length);
const r = !e && (this.I || this.async) && [];
for (let l = 0, p, A, B; l < k.length; l++) {
let y;
A = k[l];
C(A) || (y = A, A = y.field, a = y.query || a, b = y.limit || b, h = y.enrich || h);
if (r) {
r[l] = this.index[A].searchAsync(a, b, y || c);
} else {
e ? p = e[l] : p = this.index[A].search(a, b, y || c);
B = p && p.length;
if (m && B) {
const x = [];
let G = 0;
n && (x[0] = [p]);
for (let R = 0, fa, N; R < m.length; R++) {
if (fa = m[R], B = (N = this.J[fa]) && N.length) {
G++, x[x.length] = n ? [N] : N;
}
}
G && (p = n ? Q(x, b || 100, u || 0) : ea(p, x), B = p.length);
}
if (B) {
f[q] = A, d[q++] = p;
} else if (n) {
return [];
}
}
}
if (r) {
const l = this;
return new Promise(function(p) {
Promise.all(r).then(function(A) {
p(l.search(a, b, c, A));
});
});
}
if (!q) {
return [];
}
if (g && (!h || !this.store)) {
return d[0];
}
for (let l = 0, p; l < f.length; l++) {
p = d[l];
p.length && h && (p = na.call(this, p));
if (g) {
return p;
}
d[l] = {field:f[l], result:p};
}
return d;
};
function ma(a, b, c, e) {
let d = this.J[a], f = d && d.length - c;
if (f && 0 < f) {
if (f > b || c) {
d = d.slice(c, c + b);
}
e && (d = na.call(this, d));
return {tag:a, result:d};
}
}
function na(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[e]};
}
return b;
}
t.contain = function(a) {
return !!this.register[a];
};
t.get = function(a) {
return this.store[a];
};
t.set = function(a, b) {
this.store[a] = b;
return this;
};
O(W.prototype);
var pa = {encode:oa, B:!1, C:""};
const qa = [I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), "a", I("[\u00e8\u00e9\u00ea\u00eb]"), "e", I("[\u00ec\u00ed\u00ee\u00ef]"), "i", I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), "o", I("[\u00f9\u00fa\u00fb\u00fc\u0171]"), "u", I("[\u00fd\u0177\u00ff]"), "y", I("\u00f1"), "n", I("[\u00e7c]"), "k", I("\u00df"), "s", I(" & "), " and "];
function oa(a) {
var b = a = "" + a;
b.normalize && (b = b.normalize("NFD").replace(ca, ""));
return E.call(this, b.toLowerCase(), !a.normalize && qa);
}
;var sa = {encode:ra, B:!1, C:"strict"};
const ta = /[^a-z0-9]+/, ua = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
function ra(a) {
a = oa.call(this, a).join(" ");
const b = [];
if (a) {
const c = a.split(ta), e = c.length;
for (let d = 0, f, g = 0; d < e; d++) {
if ((a = c[d]) && (!this.filter || !this.filter[a])) {
f = a[0];
let h = ua[f] || f, k = h;
for (let m = 1; m < a.length; m++) {
f = a[m];
const n = ua[f] || f;
n && n !== k && (h += n, k = n);
}
b[g++] = h;
}
}
}
return b;
}
;var wa = {encode:va, B:!1, C:""};
const xa = [I("ae"), "a", I("oe"), "o", I("sh"), "s", I("th"), "t", I("ph"), "f", I("pf"), "f", I("(?![aeo])h(?![aeo])"), "", I("(?!^[aeo])h(?!^[aeo])"), ""];
function va(a, b) {
a && (a = ra.call(this, a).join(" "), 2 < a.length && (a = F(a, xa)), b || (1 < a.length && (a = J(a)), a && (a = a.split(" "))));
return a || [];
}
;var za = {encode:ya, B:!1, C:""};
const Aa = I("(?!\\b)[aeo]");
function ya(a) {
a && (a = va.call(this, a, !0), 1 < a.length && (a = a.replace(Aa, "")), 1 < a.length && (a = J(a)), a && (a = a.split(" ")));
return a || [];
}
;M["latin:default"] = da;
M["latin:simple"] = pa;
M["latin:balance"] = sa;
M["latin:advanced"] = wa;
M["latin:extra"] = za;
export default {Index:S, Document:W, Worker:null, registerCharset:function(a, b) {
M[a] = b;
}, registerLanguage:function(a, b) {
L[a] = b;
}};
}(this));

View File

@@ -0,0 +1,27 @@
/**!
* FlexSearch.js v0.7.41 (Compact.module)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';var t;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=z();return b}function z(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a};function E(a,b){var c=ba;if(a&&(b&&(a=F(a,b)),this.G&&(a=F(a,this.G)),this.H&&1<a.length&&(a=F(a,this.H)),c||""===c)){b=a.split(c);if(this.filter){a=this.filter;c=b.length;const e=[];for(let d=0,f=0;d<c;d++){const g=b[d];g&&!a[g]&&(e[f++]=g)}a=e}else a=b;return a}return a}const ba=/[\p{Z}\p{S}\p{P}\p{C}]+/u,ca=/[\u0300-\u036f]/g;
function H(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",g=0;for(let h=0,k,m;h<e;h++)k=c[h],(m=a[k])?(d[g++]=I(b?"(?!\\b)"+k+"(\\b|_)":k),d[g++]=m):f+=(f?"|":"")+k;f&&(d[g++]=I(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[g]="");return d}function F(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function I(a){return new RegExp(a,"g")}function J(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};var da={encode:K,B:!1,C:""};function K(a){return E.call(this,(""+a).toLowerCase(),!1)};const L={},M={};function O(a){P(a,"add");P(a,"append");P(a,"search");P(a,"update");P(a,"remove")}function P(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,e);c.async=!1;g(h)})});return f?(d.then(f),this):d}};function Q(a,b,c,e){const d=a.length;let f=[],g,h,k=0;e&&(e=[]);for(let m=d-1;0<=m;m--){const n=a[m],u=n.length,q=z();let r=!g;for(let l=0;l<u;l++){const p=n[l],A=p.length;if(A)for(let B=0,y,x;B<A;B++)if(x=p[B],g){if(g[x]){if(!m)if(c)c--;else if(f[k++]=x,k===b)return f;if(m||e)q[x]=1;r=!0}if(e&&(y=(h[x]||0)+1,h[x]=y,y<d)){const G=e[y-2]||(e[y-2]=[]);G[G.length]=x}}else q[x]=1}if(e)g||(h=q);else if(!r)return[];g=q}if(e)for(let m=e.length-1,n,u;0<=m;m--){n=e[m];u=n.length;for(let q=0,r;q<u;q++)if(r=
n[q],!g[r]){if(c)c--;else if(f[k++]=r,k===b)return f;g[r]=1}}return f}function fa(a,b){const c=z(),e=z(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!e[k]&&(e[k]=1,d[d.length]=k)}return d};const ha={memory:{charset:"latin:extra",A:3,m:4,D:!1},performance:{A:3,m:3,s:!1,context:{depth:2,A:1}},match:{charset:"latin:extra",C:"reverse"},score:{charset:"latin:advanced",A:20,m:3,context:{depth:3,A:9}},"default":{}};function S(a,b){if(!(this instanceof S))return new S(a);var c;let e;a?(C(a)?a=ha[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=M[c]),C(e)&&(e=L[e])):a={};let d,f,g=a.context||{};this.encode=a.encode||c&&c.encode||K;this.register=b||z();this.A=d=a.resolution||9;this.C=b=c&&c.C||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.h=v(g.bidirectional);this.s=f=v(a.optimize);this.D=v(a.fastupdate);this.m=a.minlength||1;this.F=a.boost;
this.map=f?w(d):z();this.o=d=g.resolution||1;this.l=f?w(d):z();this.B=c&&c.B||a.rtl;this.G=(b=a.matcher||e&&e.G)&&H(b,!1);this.H=(b=a.stemmer||e&&e.H)&&H(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=z();for(let h=0,k=a.length;h<k;h++)c[a[h]]=1;a=c}this.filter=a}t=S.prototype;t.append=function(a,b){return this.add(a,b,!0)};
t.add=function(a,b,c,e){if(b&&(a||0===a)){if(!e&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(e=b.length){const m=z(),n=z(),u=this.depth,q=this.A;for(let r=0;r<e;r++){let l=b[this.B?e-1-r:r];var d=l.length;if(l&&d>=this.m&&(u||!n[l])){var f=T(q,e,r),g="";switch(this.C){case "full":if(2<d){for(f=0;f<d;f++)for(var h=d;h>f;h--)if(h-f>=this.m){var k=T(q,e,r,d,f);g=l.substring(f,h);U(this,n,g,k,a,c)}break}case "reverse":if(1<d){for(h=d-1;0<h;h--)g=l[h]+g,g.length>=this.m&&U(this,n,
g,T(q,e,r,d,h),a,c);g=""}case "forward":if(1<d){for(h=0;h<d;h++)g+=l[h],g.length>=this.m&&U(this,n,g,f,a,c);break}default:if(this.F&&(f=Math.min(f/this.F(b,l,r)|0,q-1)),U(this,n,l,f,a,c),u&&1<e&&r<e-1)for(d=z(),g=this.o,f=l,h=Math.min(u+1,e-r),d[f]=1,k=1;k<h;k++)if((l=b[this.B?e-1-r-k:r+k])&&l.length>=this.m&&!d[l]){d[l]=1;const p=this.h&&l>f;U(this,m,p?f:l,T(g+(e/2>g?0:1),e,r,h-1,k-1),a,c,p?l:f)}}}}this.D||(this.register[a]=1)}}return this};
function T(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 U(a,b,c,e,d,f,g){let h=g?a.l:a.map;if(!b[c]||g&&!b[c][g])a.s&&(h=h[e]),g?(b=b[c]||(b[c]=z()),b[g]=1,h=h[g]||(h[g]=z())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[e]||(h[e]=[])),f&&h.includes(d)||(h[h.length]=d,a.D&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=h))}
t.search=function(a,b,c){c||(!b&&D(a)?(c=a,a=c.query):D(b)&&(c=b));let e=[],d;let f,g=0;if(c){a=c.query||a;b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(""+a),d=a.length,1<d)){c=z();var k=[];for(let n=0,u=0,q;n<d;n++)if((q=a[n])&&q.length>=this.m&&!c[q])if(this.s||f||this.map[q])k[u++]=q,c[q]=1;else return e;a=k;d=a.length}if(!d)return e;b||(b=100);h=this.depth&&1<d&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<d&&a.sort(aa);for(let n,u;c<d;c++){u=a[c];h?(n=ia(this,e,f,b,g,2===d,u,
m),f&&!1===n&&e.length||(m=u)):n=ia(this,e,f,b,g,1===d,u);if(n)return n;if(f&&c===d-1){k=e.length;if(!k){if(h){h=0;c=-1;continue}return e}if(1===k)return ja(e[0],b,g)}}return Q(e,b,g,f)};
function ia(a,b,c,e,d,f,g,h){let k=[],m=h?a.l:a.map;a.s||(m=ka(m,g,h,a.h));if(m){let n=0;const u=Math.min(m.length,h?a.o:a.A);for(let q=0,r=0,l,p;q<u;q++)if(l=m[q])if(a.s&&(l=ka(l,g,h,a.h)),d&&l&&f&&(p=l.length,p<=d?(d-=p,l=null):(l=l.slice(d),d=0)),l&&(k[n++]=l,f&&(r+=l.length,r>=e)))break;if(n){if(f)return ja(k,e,0);b[b.length]=k;return}}return!c&&k}function ja(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ka(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};t.remove=function(a,b){const c=this.register[a];if(c){if(this.D)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else V(this.map,a,this.A,this.s),this.depth&&V(this.l,a,this.o,this.s);b||delete this.register[a]}return this};
function V(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let g=0,h;g<d;g++)if(h=a[g])f=V(h,b,c,e,d),e||f||delete a[g]}else for(let g in a)(f=V(a[g],b,c,e,d))||delete a[g];return f}O(S.prototype);function W(a){if(!(this instanceof W))return new W(a);var b=a.document||a.doc||a,c;this.F=[];this.h=[];this.o=[];this.register=z();this.key=(c=b.key||b.id)&&X(c,this.o)||"id";this.D=v(a.fastupdate);this.l=(c=b.store)&&!0!==c&&[];this.store=c&&z();this.async=!1;c=z();let e=b.index||b.field||b;C(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],C(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,this.I||(c[f]=new S(g,this.register)),this.F[d]=X(f,this.o),this.h[d]=f;if(this.l)for(a=b.store,C(a)&&(a=
[a]),b=0;b<a.length;b++)this.l[b]=X(a[b],this.o);this.index=c}function X(a,b){const c=a.split(":");let e=0;for(let d=0;d<c.length;d++)a=c[d],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[e]=!0),a&&(c[e++]=a);e<c.length&&(c.length=e);return 1<e?c:c[0]}function la(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function Y(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)Y(a,b,c,e,d);else b=b[d]||(b[d]=z()),d=c[++e],Y(a,b,c,e,d)}function Z(a,b,c,e,d,f,g,h){if(a=a[g])if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)Z(a,b,c,e,d,f,g,h);else g=b[++e],Z(a,b,c,e,d,f,g,h)}t=W.prototype;
t.add=function(a,b,c){D(a)&&(b=a,a=la(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.F[e],C(d)&&(d=[d]),Z(b,d,this.o,0,this.index[f],a,d[0],c);if(this.store&&(!c||!this.store[a])){let e;if(this.l){e=z();for(let d=0,f;d<this.l.length;d++)f=this.l[d],C(f)?e[f]=b[f]:Y(b,e,f,0,f[0])}this.store[a]=e||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a){D(a)&&(a=la(a,this.key));if(this.register[a]){for(let b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.I),!this.D);b++);this.store&&delete this.store[a];delete this.register[a]}return this};
t.search=function(a,b,c,e){c||(!b&&D(a)?(c=a,a=""):D(b)&&(c=b,b=0));let d=[],f=[],g,h,k,m,n,u,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{a=c.query||a;k=(g=c.pluck)||c.index||c.field;m=!1;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||b||100;u=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=ma.call(this,m[l],b,u,h))d[d.length]=p,q++;return q?d:[]}C(k)&&(k=[k])}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const r=!e&&(this.I||this.async)&&[];for(let l=0,p,A,B;l<
k.length;l++){let y;A=k[l];C(A)||(y=A,A=y.field,a=y.query||a,b=y.limit||b,h=y.enrich||h);if(r)r[l]=this.index[A].searchAsync(a,b,y||c);else{e?p=e[l]:p=this.index[A].search(a,b,y||c);B=p&&p.length;if(m&&B){const x=[];let G=0;n&&(x[0]=[p]);for(let R=0,ea,N;R<m.length;R++)if(ea=m[R],B=(N=this.J[ea])&&N.length)G++,x[x.length]=n?[N]:N;G&&(p=n?Q(x,b||100,u||0):fa(p,x),B=p.length)}if(B)f[q]=A,d[q++]=p;else if(n)return[]}}if(r){const l=this;return new Promise(function(p){Promise.all(r).then(function(A){p(l.search(a,
b,c,A))})})}if(!q)return[];if(g&&(!h||!this.store))return d[0];for(let l=0,p;l<f.length;l++){p=d[l];p.length&&h&&(p=na.call(this,p));if(g)return p;d[l]={field:f[l],result:p}}return d};function ma(a,b,c,e){let d=this.J[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=na.call(this,d));return{tag:a,result:d}}}function na(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[e]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};
t.set=function(a,b){this.store[a]=b;return this};O(W.prototype);var pa={encode:oa,B:!1,C:""};const qa=[I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",I("[\u00e8\u00e9\u00ea\u00eb]"),"e",I("[\u00ec\u00ed\u00ee\u00ef]"),"i",I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",I("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",I("[\u00fd\u0177\u00ff]"),"y",I("\u00f1"),"n",I("[\u00e7c]"),"k",I("\u00df"),"s",I(" & ")," and "];function oa(a){var b=a=""+a;b.normalize&&(b=b.normalize("NFD").replace(ca,""));return E.call(this,b.toLowerCase(),!a.normalize&&qa)};var sa={encode:ra,B:!1,C:"strict"};const ta=/[^a-z0-9]+/,ua={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function ra(a){a=oa.call(this,a).join(" ");const b=[];if(a){const c=a.split(ta),e=c.length;for(let d=0,f,g=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let h=ua[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=ua[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var wa={encode:va,B:!1,C:""};const xa=[I("ae"),"a",I("oe"),"o",I("sh"),"s",I("th"),"t",I("ph"),"f",I("pf"),"f",I("(?![aeo])h(?![aeo])"),"",I("(?!^[aeo])h(?!^[aeo])"),""];function va(a,b){a&&(a=ra.call(this,a).join(" "),2<a.length&&(a=F(a,xa)),b||(1<a.length&&(a=J(a)),a&&(a=a.split(" "))));return a||[]};var za={encode:ya,B:!1,C:""};const Aa=I("(?!\\b)[aeo]");function ya(a){a&&(a=va.call(this,a,!0),1<a.length&&(a=a.replace(Aa,"")),1<a.length&&(a=J(a)),a&&(a=a.split(" ")));return a||[]};M["latin:default"]=da;M["latin:simple"]=pa;M["latin:balance"]=sa;M["latin:advanced"]=wa;M["latin:extra"]=za;export default {Index:S,Document:W,Worker:null,registerCharset:function(a,b){M[a]=b},registerLanguage:function(a,b){L[a]=b}};}(this));

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
/**!
* FlexSearch.js v0.7.41 (Es5)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';var t;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}var v="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var x=ba(this);function y(a,b){if(b)a:{var c=x;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))break a;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&v(c,a,{configurable:!0,writable:!0,value:b})}}
y("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+e++,g)}function c(g,f){this.h=g;v(this,"description",{configurable:!0,writable:!0,value:f})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",e=0;return b});
y("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<b.length;c++){var d=x[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&v(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
function da(a,b){a instanceof String&&(a+="");var c=0,d=!1,e={next:function(){if(!d&&c<a.length){var g=c++;return{value:b(g,a[g]),done:!1}}d=!0;return{done:!0,value:void 0}}};e[Symbol.iterator]=function(){return e};return e}y("Array.prototype.keys",function(a){return a?a:function(){return da(this,function(b){return b})}});
function ea(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if("number"==typeof a.length)return{next:aa(a)};throw Error(String(a)+" is not an iterable or ArrayLike");}
y("Promise",function(a){function b(f){this.l=0;this.m=void 0;this.h=[];this.M=!1;var h=this.o();try{f(h.resolve,h.reject)}catch(k){h.reject(k)}}function c(){this.h=null}function d(f){return f instanceof b?f:new b(function(h){h(f)})}if(a)return a;c.prototype.l=function(f){if(null==this.h){this.h=[];var h=this;this.m(function(){h.D()})}this.h.push(f)};var e=x.setTimeout;c.prototype.m=function(f){e(f,0)};c.prototype.D=function(){for(;this.h&&this.h.length;){var f=this.h;this.h=[];for(var h=0;h<f.length;++h){var k=
f[h];f[h]=null;try{k()}catch(l){this.o(l)}}}this.h=null};c.prototype.o=function(f){this.m(function(){throw f;})};b.prototype.o=function(){function f(l){return function(m){k||(k=!0,l.call(h,m))}}var h=this,k=!1;return{resolve:f(this.S),reject:f(this.D)}};b.prototype.S=function(f){if(f===this)this.D(new TypeError("A Promise cannot resolve to itself"));else if(f instanceof b)this.U(f);else{a:switch(typeof f){case "object":var h=null!=f;break a;case "function":h=!0;break a;default:h=!1}h?this.R(f):this.I(f)}};
b.prototype.R=function(f){var h=void 0;try{h=f.then}catch(k){this.D(k);return}"function"==typeof h?this.V(h,f):this.I(f)};b.prototype.D=function(f){this.N(2,f)};b.prototype.I=function(f){this.N(1,f)};b.prototype.N=function(f,h){if(0!=this.l)throw Error("Cannot settle("+f+", "+h+"): Promise already settled in state"+this.l);this.l=f;this.m=h;2===this.l&&this.T();this.O()};b.prototype.T=function(){var f=this;e(function(){if(f.P()){var h=x.console;"undefined"!==typeof h&&h.error(f.m)}},1)};b.prototype.P=
function(){if(this.M)return!1;var f=x.CustomEvent,h=x.Event,k=x.dispatchEvent;if("undefined"===typeof k)return!0;"function"===typeof f?f=new f("unhandledrejection",{cancelable:!0}):"function"===typeof h?f=new h("unhandledrejection",{cancelable:!0}):(f=x.document.createEvent("CustomEvent"),f.initCustomEvent("unhandledrejection",!1,!0,f));f.promise=this;f.reason=this.m;return k(f)};b.prototype.O=function(){if(null!=this.h){for(var f=0;f<this.h.length;++f)g.l(this.h[f]);this.h=null}};var g=new c;b.prototype.U=
function(f){var h=this.o();f.J(h.resolve,h.reject)};b.prototype.V=function(f,h){var k=this.o();try{f.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(f,h){function k(n,q){return"function"==typeof n?function(r){try{l(n(r))}catch(u){m(u)}}:q}var l,m,p=new b(function(n,q){l=n;m=q});this.J(k(f,l),k(h,m));return p};b.prototype.catch=function(f){return this.then(void 0,f)};b.prototype.J=function(f,h){function k(){switch(l.l){case 1:f(l.m);break;case 2:h(l.m);break;default:throw Error("Unexpected state: "+
l.l);}}var l=this;null==this.h?g.l(k):this.h.push(k);this.M=!0};b.resolve=d;b.reject=function(f){return new b(function(h,k){k(f)})};b.race=function(f){return new b(function(h,k){for(var l=ea(f),m=l.next();!m.done;m=l.next())d(m.value).J(h,k)})};b.all=function(f){var h=ea(f),k=h.next();return k.done?d([]):new b(function(l,m){function p(r){return function(u){n[r]=u;q--;0==q&&l(n)}}var n=[],q=0;do n.push(void 0),q++,d(k.value).J(p(n.length-1),m),k=h.next();while(!k.done)})};return b});
y("Object.is",function(a){return a?a:function(b,c){return b===c?0!==b||1/b===1/c:b!==b&&c!==c}});y("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;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++){var g=d[c];if(g===b||Object.is(g,b))return!0}return!1}});
y("String.prototype.includes",function(a){return a?a:function(b,c){if(null==this)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)}});
var fa="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(a[e]=d[e])}return a};y("Object.assign",function(a){return a||fa});function C(a){return"undefined"!==typeof a?a:!0}function ha(a){for(var b=Array(a),c=0;c<a;c++)b[c]=D();return b}function D(){return Object.create(null)}function ia(a,b){return b.length-a.length}function E(a){return"string"===typeof a}function F(a){return"object"===typeof a}function G(a){return"function"===typeof a};function ja(a,b){var c=ka;if(a&&(b&&(a=I(a,b)),this.K&&(a=I(a,this.K)),this.L&&1<a.length&&(a=I(a,this.L)),c||""===c)){a=a.split(c);if(this.filter){b=this.filter;c=a.length;for(var d=[],e=0,g=0;e<c;e++){var f=a[e];f&&!b[f]&&(d[g++]=f)}a=d}return a}return a}var ka=/[\p{Z}\p{S}\p{P}\p{C}]+/u,la=/[\u0300-\u036f]/g;
function ma(a,b){for(var c=Object.keys(a),d=c.length,e=[],g="",f=0,h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(e[f++]=J(b?"(?!\\b)"+k+"(\\b|_)":k),e[f++]=l):g+=(g?"|":"")+k;g&&(e[f++]=J(b?"(?!\\b)("+g+")(\\b|_)":"("+g+")"),e[f]="");return e}function I(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function J(a){return new RegExp(a,"g")}function na(a){for(var b="",c="",d=0,e=a.length,g=void 0;d<e;d++)(g=a[d])!==c&&(b+=c=g);return b};var pa={encode:oa,G:!1,H:""};function oa(a){return ja.call(this,(""+a).toLowerCase(),!1)};var qa={},K={};function ra(a){L(a,"add");L(a,"append");L(a,"search");L(a,"update");L(a,"remove")}function L(a,b){a[b+"Async"]=function(){var c=this,d=arguments,e=d[d.length-1];if(G(e)){var g=e;delete d[d.length-1]}e=new Promise(function(f){setTimeout(function(){c.async=!0;var h=c[b].apply(c,d);c.async=!1;f(h)})});return g?(e.then(g),this):e}};function sa(a,b,c,d){var e=a.length,g=[],f,h=0;d&&(d=[]);for(var k=e-1;0<=k;k--){for(var l=a[k],m=l.length,p=D(),n=!B,q=0;q<m;q++){var r=l[q],u=r.length;if(u)for(var A=0,w,z;A<u;A++)if(z=r[A],B){if(B[z]){if(!k)if(c)c--;else if(g[h++]=z,h===b)return g;if(k||d)p[z]=1;n=!0}d&&(w=(f[z]||0)+1,f[z]=w,w<e&&(w=d[w-2]||(d[w-2]=[]),w[w.length]=z))}else p[z]=1}if(d)B||(f=p);else if(!n)return[];var B=p}if(d)for(a=d.length-1;0<=a;a--)for(e=d[a],f=e.length,k=0;k<f;k++)if(l=e[k],!B[l]){if(c)c--;else if(g[h++]=l,
h===b)return g;B[l]=1}return g}function ta(a,b){for(var c=D(),d=D(),e=[],g=0;g<a.length;g++)c[a[g]]=1;for(a=0;a<b.length;a++){g=b[a];for(var f=0,h;f<g.length;f++)h=g[f],c[h]&&!d[h]&&(d[h]=1,e[e.length]=h)}return e};function M(a){this.l=!0!==a&&a;this.cache=D();this.h=[]}function ua(a,b,c){F(a)&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}M.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};M.prototype.get=function(a){var b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){var c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};var va={memory:{charset:"latin:extra",F:3,C:4,s:!1},performance:{F:3,C:3,B:!1,context:{depth:2,F:1}},match:{charset:"latin:extra",H:"reverse"},score:{charset:"latin:advanced",F:20,C:3,context:{depth:3,F:9}},"default":{}};function wa(a,b,c,d,e,g,f,h){setTimeout(function(){var k=a(c?c+"."+d:d,JSON.stringify(f));k&&k.then?k.then(function(){b.export(a,b,c,e,g+1,h)}):b.export(a,b,c,e,g+1,h)})};function N(a,b){if(!(this instanceof N))return new N(a);var c;if(a){E(a)?a=va[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;E(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=K[c]);E(d)&&(d=qa[d])}else a={};var e,g,f=a.context||{};this.encode=a.encode||c&&c.encode||oa;this.register=b||D();this.F=e=a.resolution||9;this.H=b=c&&c.H||a.tokenize||"strict";this.depth="strict"===b&&f.depth;this.l=C(f.bidirectional);this.B=g=C(a.optimize);this.s=C(a.fastupdate);this.C=a.minlength||1;this.o=
a.boost;this.map=g?ha(e):D();this.m=e=f.resolution||1;this.h=g?ha(e):D();this.G=c&&c.G||a.rtl;this.K=(b=a.matcher||d&&d.K)&&ma(b,!1);this.L=(b=a.stemmer||d&&d.L)&&ma(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=D();f=0;for(e=c.length;f<e;f++)d[c[f]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new M(b)}t=N.prototype;t.append=function(a,b){return this.add(a,b,!0)};
t.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(d=b.length){for(var e=D(),g=D(),f=this.depth,h=this.F,k=0;k<d;k++){var l=b[this.G?d-1-k:k],m=l.length;if(l&&m>=this.C&&(f||!g[l])){var p=O(h,d,k),n="";switch(this.H){case "full":if(2<m){for(p=0;p<m;p++)for(var q=m;q>p;q--)if(q-p>=this.C){var r=O(h,d,k,m,p);n=l.substring(p,q);P(this,g,n,r,a,c)}break}case "reverse":if(1<m){for(q=m-1;0<q;q--)n=l[q]+n,n.length>=this.C&&P(this,g,n,O(h,d,k,
m,q),a,c);n=""}case "forward":if(1<m){for(q=0;q<m;q++)n+=l[q],n.length>=this.C&&P(this,g,n,p,a,c);break}default:if(this.o&&(p=Math.min(p/this.o(b,l,k)|0,h-1)),P(this,g,l,p,a,c),f&&1<d&&k<d-1)for(m=D(),n=this.m,p=l,q=Math.min(f+1,d-k),r=m[p]=1;r<q;r++)if((l=b[this.G?d-1-k-r:k+r])&&l.length>=this.C&&!m[l]){m[l]=1;var u=this.l&&l>p;P(this,e,u?p:l,O(n+(d/2>n?0:1),d,k,q-1,r-1),a,c,u?l:p)}}}}this.s||(this.register[a]=1)}}return this};
function O(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}function P(a,b,c,d,e,g,f){var h=f?a.h:a.map;if(!b[c]||f&&!b[c][f])a.B&&(h=h[d]),f?(b=b[c]||(b[c]=D()),b[f]=1,h=h[f]||(h[f]=D())):b[c]=1,h=h[c]||(h[c]=[]),a.B||(h=h[d]||(h[d]=[])),g&&h.includes(e)||(h[h.length]=e,a.s&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
t.search=function(a,b,c){c||(!b&&F(a)?(c=a,a=c.query):F(b)&&(c=b));var d=[],e=0;if(c){a=c.query||a;b=c.limit;e=c.offset||0;var g=c.context;var f=c.suggest}if(a){a=this.encode(""+a);var h=a.length;if(1<h){c=D();for(var k=[],l=0,m=0,p;l<h;l++)if((p=a[l])&&p.length>=this.C&&!c[p])if(this.B||f||this.map[p])k[m++]=p,c[p]=1;else return d;a=k;h=a.length}}if(!h)return d;b||(b=100);g=this.depth&&1<h&&!1!==g;c=0;if(g){var n=a[0];c=1}else 1<h&&a.sort(ia);for(;c<h;c++){l=a[c];g?(k=xa(this,d,f,b,e,2===h,l,n),
f&&!1===k&&d.length||(n=l)):k=xa(this,d,f,b,e,1===h,l);if(k)return k;if(f&&c===h-1){k=d.length;if(!k){if(g){g=0;c=-1;continue}return d}if(1===k)return ya(d[0],b,e)}}return sa(d,b,e,f)};
function xa(a,b,c,d,e,g,f,h){var k=[],l=h?a.h:a.map;a.B||(l=za(l,f,h,a.l));if(l){for(var m=0,p=Math.min(l.length,h?a.m:a.F),n=0,q=0,r,u;n<p;n++)if(r=l[n])if(a.B&&(r=za(r,f,h,a.l)),e&&r&&g&&(u=r.length,u<=e?(e-=u,r=null):(r=r.slice(e),e=0)),r&&(k[m++]=r,g&&(q+=r.length,q>=d)))break;if(m){if(g)return ya(k,d,0);b[b.length]=k;return}}return!c&&k}function ya(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function za(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a,b){var c=this.register[a];if(c){if(this.s)for(var d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else Q(this.map,a,this.F,this.B),this.depth&&Q(this.h,a,this.m,this.B);b||delete this.register[a];if(this.cache)for(b=this.cache,c=0;c<b.h.length;c++)e=b.h[c],d=b.cache[e],d.includes(a)&&(b.h.splice(c--,1),delete b.cache[e])}return this};
function Q(a,b,c,d,e){var g=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),g++):g++;else{e=Math.min(a.length,c);for(var f=0,h;f<e;f++)if(h=a[f])g=Q(h,b,c,d,e),d||g||delete a[f]}else for(f in a)(g=Q(a[f],b,c,d,e))||delete a[f];return g}t.searchCache=ua;
t.export=function(a,b,c,d,e,g){var f=!0;"undefined"===typeof g&&(f=new Promise(function(m){g=m}));switch(e||(e=0)){case 0:var h="reg";if(this.s){var k=D();for(var l in this.register)k[l]=1}else k=this.register;break;case 1:h="cfg";k={doc:0,opt:this.B?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.h;break;default:"undefined"===typeof c&&g&&g();return}wa(a,b||this,c,h,d,e,k,g);return f};
t.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.s=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};ra(N.prototype);function Aa(a){a=a.data;var b=self._index,c=a.args,d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new N(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};var Ba=0;function R(a){if(!(this instanceof R))return new R(a);var b;a?G(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());var c="undefined"===typeof window&&self.exports,d=this;this.A=Ca(b,c,a.worker);this.h=D();if(this.A){if(c)this.A.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.A.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.A.postMessage({task:"init",factory:b,options:a})}}S("add");S("append");S("search");
S("update");S("remove");function S(a){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(G(d)){var e=d;c.splice(c.length-1,1)}d=new Promise(function(g){setTimeout(function(){b.h[++Ba]=g;b.A.postMessage({task:a,id:Ba,args:c})})});return e?(d.then(e),this):d}}
function Ca(a,b,c){try{var d=b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+Aa.toString()],{type:"text/javascript"}))):new Worker(E(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=D();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.s=C(a.fastupdate);this.o=(c=b.store)&&!0!==c&&[];this.store=c&&D();this.D=(c=b.tag)&&U(c,this.m);this.l=c&&D();this.cache=(c=a.cache)&&new M(c);a.cache=!1;this.A=a.worker;this.async=!1;c=D();var d=b.index||b.field||b;E(d)&&(d=[d]);for(var e=0,g,f=void 0;e<d.length;e++)g=d[e],E(g)||(f=g,g=g.field),f=F(f)?Object.assign({},
a,f):a,this.A&&(c[g]=new R(f),c[g].A||(this.A=!1)),this.A||(c[g]=new N(f,this.register)),this.I[e]=U(g,this.m),this.h[e]=g;if(this.o)for(a=b.store,E(a)&&(a=[a]),b=0;b<a.length;b++)this.o[b]=U(a[b],this.m);this.index=c}function U(a,b){for(var c=a.split(":"),d=0,e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(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]}function V(a,b){if(E(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function W(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)W(a,b,c,d,e);else b=b[e]||(b[e]=D()),e=c[++d],W(a,b,c,d,e)}function X(a,b,c,d,e,g,f,h){if(a=a[f])if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(g,a[b],!0,!0);return}a=a.join(" ")}e.add(g,a,h,!0)}else if(a.constructor===Array)for(f=0;f<a.length;f++)X(a,b,c,d,e,g,f,h);else f=b[++d],X(a,b,c,d,e,g,f,h)}t=T.prototype;
t.add=function(a,b,c){F(a)&&(b=a,a=V(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(var d=0,e,g;d<this.h.length;d++)g=this.h[d],e=this.I[d],E(e)&&(e=[e]),X(b,e,this.m,0,this.index[g],a,e[0],c);if(this.D){d=V(b,this.D);e=D();E(d)&&(d=[d]);g=0;for(var f;g<d.length;g++)if(f=d[g],!e[f]&&(e[f]=1,f=this.l[f]||(this.l[f]=[]),!c||!f.includes(a)))if(f[f.length]=a,this.s){var h=this.register[a]||(this.register[a]=[]);h[h.length]=f}}if(this.store&&(!c||!this.store[a])){if(this.o){var k=
D();for(c=0;c<this.o.length;c++)d=this.o[c],E(d)?k[d]=b[d]:W(b,k,d,0,d[0])}this.store[a]=k||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
t.remove=function(a){F(a)&&(a=V(a,this.key));if(this.register[a]){for(var b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.A),!this.s);b++);if(this.D&&!this.s)for(var c in this.l){b=this.l[c];var d=b.indexOf(a);-1!==d&&(1<b.length?b.splice(d,1):delete this.l[c])}this.store&&delete this.store[a];delete this.register[a]}return this};
t.search=function(a,b,c,d){c||(!b&&F(a)?(c=a,a=""):F(b)&&(c=b,b=0));var e=[],g=[],f,h=0;if(c)if(c.constructor===Array){var k=c;c=null}else{a=c.query||a;k=(f=c.pluck)||c.index||c.field;var l=c.tag;var m=this.store&&c.enrich;var p="and"===c.bool;b=c.limit||b||100;var n=c.offset||0;if(l&&(E(l)&&(l=[l]),!a)){g=0;for(f=void 0;g<l.length;g++)if(f=Da.call(this,l[g],b,n,m))e[e.length]=f,h++;return h?e:[]}E(k)&&(k=[k])}k||(k=this.h);p=p&&(1<k.length||l&&1<l.length);for(var q=!d&&(this.A||this.async)&&[],r=
0,u=void 0,A=void 0,w=void 0;r<k.length;r++)if(w=void 0,A=k[r],E(A)||(w=A,A=w.field,a=w.query||a,b=w.limit||b,m=w.enrich||m),q)q[r]=this.index[A].searchAsync(a,b,w||c);else{d?u=d[r]:u=this.index[A].search(a,b,w||c);w=u&&u.length;if(l&&w){var z=[],B=0;p&&(z[0]=[u]);var Y=0,H=void 0;for(H=void 0;Y<l.length;Y++)if(H=l[Y],w=(H=this.l[H])&&H.length)B++,z[z.length]=p?[H]:H;B&&(u=p?sa(z,b||100,n||0):ta(u,z),w=u.length)}if(w)g[h]=A,e[h++]=u;else if(p)return[]}if(q){var Ka=this;return new Promise(function(La){Promise.all(q).then(function(Ma){La(Ka.search(a,
b,c,Ma))})})}if(!h)return[];if(f&&(!m||!this.store))return e[0];l=0;for(n=void 0;l<g.length;l++){n=e[l];n.length&&m&&(n=Ea.call(this,n));if(f)return n;e[l]={field:g[l],result:n}}return e};function Da(a,b,c,d){var e=this.l[a],g=e&&e.length-c;if(g&&0<g){if(g>b||c)e=e.slice(c,c+b);d&&(e=Ea.call(this,e));return{tag:a,result:e}}}function Ea(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store[d]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};
t.set=function(a,b){this.store[a]=b;return this};t.searchCache=ua;t.export=function(a,b,c,d,e,g){var f;"undefined"===typeof g&&(f=new Promise(function(p){g=p}));e||(e=0);d||(d=0);if(d<this.h.length){var h=this.h[d],k=this.index[h];b=this;setTimeout(function(){k.export(a,b,e?h:"",d,e++,g)||(d++,e=1,b.export(a,b,h,d,e,g))})}else{switch(e){case 1:var l="tag";var m=this.l;c=null;break;case 2:l="store";m=this.store;c=null;break;default:g();return}wa(a,this,c,l,d,e,m,g)}return f};
t.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.s=!1;this.register=b;a=0;for(var c;a<this.h.length;a++)c=this.index[this.h[a]],c.register=b,c.s=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};ra(T.prototype);var Ga={encode:Fa,G:!1,H:""},Ha=[J("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",J("[\u00e8\u00e9\u00ea\u00eb]"),"e",J("[\u00ec\u00ed\u00ee\u00ef]"),"i",J("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",J("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",J("[\u00fd\u0177\u00ff]"),"y",J("\u00f1"),"n",J("[\u00e7c]"),"k",J("\u00df"),"s",J(" & ")," and "];function Fa(a){var b=a=""+a;b.normalize&&(b=b.normalize("NFD").replace(la,""));return ja.call(this,b.toLowerCase(),!a.normalize&&Ha)};var Ja={encode:Ia,G:!1,H:"strict"},Na=/[^a-z0-9]+/,Oa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ia(a){a=Fa.call(this,a).join(" ");var b=[];if(a)for(var c=a.split(Na),d=c.length,e=0,g,f=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){g=a[0];for(var h=Oa[g]||g,k=h,l=1;l<a.length;l++)g=a[l],(g=Oa[g]||g)&&g!==k&&(h+=g,k=g);b[f++]=h}return b};var Qa={encode:Pa,G:!1,H:""},Ra=[J("ae"),"a",J("oe"),"o",J("sh"),"s",J("th"),"t",J("ph"),"f",J("pf"),"f",J("(?![aeo])h(?![aeo])"),"",J("(?!^[aeo])h(?!^[aeo])"),""];function Pa(a,b){a&&(a=Ia.call(this,a).join(" "),2<a.length&&(a=I(a,Ra)),b||(1<a.length&&(a=na(a)),a&&(a=a.split(" "))));return a||[]};var Ta={encode:Sa,G:!1,H:""},Ua=J("(?!\\b)[aeo]");function Sa(a){a&&(a=Pa.call(this,a,!0),1<a.length&&(a=a.replace(Ua,"")),1<a.length&&(a=na(a)),a&&(a=a.split(" ")));return a||[]};K["latin:default"]=pa;K["latin:simple"]=Ga;K["latin:balance"]=Ja;K["latin:advanced"]=Qa;K["latin:extra"]=Ta;var Z={Index:N,Document:T,Worker:R,registerCharset:function(a,b){K[a]=b},registerLanguage:function(a,b){qa[a]=b}},Va;(Va=self.define)&&Va.amd?Va([],function(){return Z}):self.exports?self.exports=Z:self.FlexSearch=Z;}(this));

View File

@@ -0,0 +1,372 @@
/**!
* FlexSearch.js v0.7.41 (Light)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';
function t(a) {
return "undefined" !== typeof a ? a : !0;
}
function v(a) {
const b = Array(a);
for (let c = 0; c < a; c++) {
b[c] = y();
}
return b;
}
function y() {
return Object.create(null);
}
function z(a, b) {
return b.length - a.length;
}
;const A = /[\p{Z}\p{S}\p{P}\p{C}]+/u;
function B(a, b) {
const c = Object.keys(a), d = c.length, e = [];
let h = "", f = 0;
for (let g = 0, l, n; g < d; g++) {
l = c[g], (n = a[l]) ? (e[f++] = new RegExp(b ? "(?!\\b)" + l + "(\\b|_)" : l, "g"), e[f++] = n) : h += (h ? "|" : "") + l;
}
h && (e[f++] = new RegExp(b ? "(?!\\b)(" + h + ")(\\b|_)" : "(" + h + ")", "g"), e[f] = "");
return e;
}
function C(a, b) {
for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
}
return a;
}
;function E(a) {
if (a = ("" + a).toLowerCase()) {
if (this.o && (a = C(a, this.o)), this.A && 1 < a.length && (a = C(a, this.A)), A || "" === A) {
const b = a.split(A);
if (this.filter) {
a = this.filter;
const c = b.length, d = [];
for (let e = 0, h = 0; e < c; e++) {
const f = b[e];
f && !a[f] && (d[h++] = f);
}
a = d;
} else {
a = b;
}
}
}
return a;
}
;const F = {}, G = {};
function H(a, b, c, d) {
const e = a.length;
let h = [], f, g, l = 0;
d && (d = []);
for (let n = e - 1; 0 <= n; n--) {
const m = a[n], r = m.length, p = y();
let q = !f;
for (let k = 0; k < r; k++) {
const u = m[k], L = u.length;
if (L) {
for (let D = 0, x, w; D < L; D++) {
if (w = u[D], f) {
if (f[w]) {
if (!n) {
if (c) {
c--;
} else {
if (h[l++] = w, l === b) {
return h;
}
}
}
if (n || d) {
p[w] = 1;
}
q = !0;
}
if (d && (x = (g[w] || 0) + 1, g[w] = x, x < e)) {
const M = d[x - 2] || (d[x - 2] = []);
M[M.length] = w;
}
} else {
p[w] = 1;
}
}
}
}
if (d) {
f || (g = p);
} else if (!q) {
return [];
}
f = p;
}
if (d) {
for (let n = d.length - 1, m, r; 0 <= n; n--) {
m = d[n];
r = m.length;
for (let p = 0, q; p < r; p++) {
if (q = m[p], !f[q]) {
if (c) {
c--;
} else {
if (h[l++] = q, l === b) {
return h;
}
}
f[q] = 1;
}
}
}
}
return h;
}
;function I(a, b) {
if (!(this instanceof I)) {
return new I(a);
}
let c;
if (a) {
var d = a.charset;
c = a.lang;
"string" === typeof d && (-1 === d.indexOf(":") && (d += ":default"), d = G[d]);
"string" === typeof c && (c = F[c]);
} else {
a = {};
}
let e, h, f = a.context || {};
this.encode = a.encode || d && d.encode || E;
this.register = b || y();
this.s = e = a.resolution || 9;
this.B = b = d && d.B || a.tokenize || "strict";
this.i = "strict" === b && f.depth;
this.j = t(f.bidirectional);
this.g = h = t(a.optimize);
this.m = t(a.fastupdate);
this.h = a.minlength || 1;
this.C = a.boost;
this.map = h ? v(e) : y();
this.v = e = f.resolution || 1;
this.l = h ? v(e) : y();
this.u = d && d.u || a.rtl;
this.o = (b = a.matcher || c && c.o) && B(b, !1);
this.A = (b = a.stemmer || c && c.A) && B(b, !0);
if (a = b = a.filter || c && c.filter) {
a = b;
d = y();
for (let g = 0, l = a.length; g < l; g++) {
d[a[g]] = 1;
}
a = d;
}
this.filter = a;
}
I.prototype.append = function(a, b) {
return this.add(a, b, !0);
};
I.prototype.add = function(a, b, c, d) {
if (b && (a || 0 === a)) {
if (!d && !c && this.register[a]) {
return this.update(a, b);
}
b = this.encode(b);
if (d = b.length) {
const n = y(), m = y(), r = this.i, p = this.s;
for (let q = 0; q < d; q++) {
let k = b[this.u ? d - 1 - q : q];
var e = k.length;
if (k && e >= this.h && (r || !m[k])) {
var h = J(p, d, q), f = "";
switch(this.B) {
case "full":
if (2 < e) {
for (h = 0; h < e; h++) {
for (var g = e; g > h; g--) {
if (g - h >= this.h) {
var l = J(p, d, q, e, h);
f = k.substring(h, g);
K(this, m, f, l, a, c);
}
}
}
break;
}
case "reverse":
if (1 < e) {
for (g = e - 1; 0 < g; g--) {
f = k[g] + f, f.length >= this.h && K(this, m, f, J(p, d, q, e, g), a, c);
}
f = "";
}
case "forward":
if (1 < e) {
for (g = 0; g < e; g++) {
f += k[g], f.length >= this.h && K(this, m, f, h, a, c);
}
break;
}
default:
if (this.C && (h = Math.min(h / this.C(b, k, q) | 0, p - 1)), K(this, m, k, h, a, c), r && 1 < d && q < d - 1) {
for (e = y(), f = this.v, h = k, g = Math.min(r + 1, d - q), e[h] = 1, l = 1; l < g; l++) {
if ((k = b[this.u ? d - 1 - q - l : q + l]) && k.length >= this.h && !e[k]) {
e[k] = 1;
const u = this.j && k > h;
K(this, n, u ? h : k, J(f + (d / 2 > f ? 0 : 1), d, q, g - 1, l - 1), a, c, u ? k : h);
}
}
}
}
}
}
this.m || (this.register[a] = 1);
}
}
return this;
};
function J(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;
}
function K(a, b, c, d, e, h, f) {
let g = f ? a.l : a.map;
if (!b[c] || f && !b[c][f]) {
a.g && (g = g[d]), f ? (b = b[c] || (b[c] = y()), b[f] = 1, g = g[f] || (g[f] = y())) : b[c] = 1, g = g[c] || (g[c] = []), a.g || (g = g[d] || (g[d] = [])), h && g.includes(e) || (g[g.length] = e, a.m && (a = a.register[e] || (a.register[e] = []), a[a.length] = g));
}
}
I.prototype.search = function(a, b, c) {
c || (b || "object" !== typeof a ? "object" === typeof b && (c = b) : (c = a, a = c.query));
let d = [], e;
let h, f = 0;
if (c) {
a = c.query || a;
b = c.limit;
f = c.offset || 0;
var g = c.context;
h = !1;
}
if (a && (a = this.encode("" + a), e = a.length, 1 < e)) {
c = y();
var l = [];
for (let m = 0, r = 0, p; m < e; m++) {
if ((p = a[m]) && p.length >= this.h && !c[p]) {
if (this.g || h || this.map[p]) {
l[r++] = p, c[p] = 1;
} else {
return d;
}
}
}
a = l;
e = a.length;
}
if (!e) {
return d;
}
b || (b = 100);
g = this.i && 1 < e && !1 !== g;
c = 0;
let n;
g ? (n = a[0], c = 1) : 1 < e && a.sort(z);
for (let m, r; c < e; c++) {
r = a[c];
g ? (m = N(this, d, h, b, f, 2 === e, r, n), h && !1 === m && d.length || (n = r)) : m = N(this, d, h, b, f, 1 === e, r);
if (m) {
return m;
}
if (h && c === e - 1) {
l = d.length;
if (!l) {
if (g) {
g = 0;
c = -1;
continue;
}
return d;
}
if (1 === l) {
return O(d[0], b, f);
}
}
}
return H(d, b, f, h);
};
function N(a, b, c, d, e, h, f, g) {
let l = [], n = g ? a.l : a.map;
a.g || (n = P(n, f, g, a.j));
if (n) {
let m = 0;
const r = Math.min(n.length, g ? a.v : a.s);
for (let p = 0, q = 0, k, u; p < r; p++) {
if (k = n[p]) {
if (a.g && (k = P(k, f, g, a.j)), e && k && h && (u = k.length, u <= e ? (e -= u, k = null) : (k = k.slice(e), e = 0)), k && (l[m++] = k, h && (q += k.length, q >= d))) {
break;
}
}
}
if (m) {
if (h) {
return O(l, d, 0);
}
b[b.length] = l;
return;
}
}
return !c && l;
}
function O(a, b, c) {
a = 1 === a.length ? a[0] : [].concat.apply([], a);
return c || a.length > b ? a.slice(c, c + b) : a;
}
function P(a, b, c, d) {
c ? (d = d && b > c, a = (a = a[d ? b : c]) && a[d ? c : b]) : a = a[b];
return a;
}
I.prototype.contain = function(a) {
return !!this.register[a];
};
I.prototype.update = function(a, b) {
return this.remove(a).add(a, b);
};
I.prototype.remove = function(a, b) {
const c = this.register[a];
if (c) {
if (this.m) {
for (let d = 0, e; d < c.length; d++) {
e = c[d], e.splice(e.indexOf(a), 1);
}
} else {
Q(this.map, a, this.s, this.g), this.i && Q(this.l, a, this.v, this.g);
}
b || delete this.register[a];
}
return this;
};
function Q(a, b, c, d, e) {
let h = 0;
if (a.constructor === Array) {
if (e) {
b = a.indexOf(b), -1 !== b ? 1 < a.length && (a.splice(b, 1), h++) : h++;
} else {
e = Math.min(a.length, c);
for (let f = 0, g; f < e; f++) {
if (g = a[f]) {
h = Q(g, b, c, d, e), d || h || delete a[f];
}
}
}
} else {
for (let f in a) {
(h = Q(a[f], b, c, d, e)) || delete a[f];
}
}
return h;
}
;const R = {Index:I, Document:null, Worker:null, registerCharset:function(a, b) {
G[a] = b;
}, registerLanguage:function(a, b) {
F[a] = b;
}};
let S;
(S = self.define) && S.amd ? S([], function() {
return R;
}) : self.exports ? self.exports = R : self.FlexSearch = R;
}(this));

View File

@@ -0,0 +1,18 @@
/**!
* FlexSearch.js v0.7.41 (Light)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';function t(a){return"undefined"!==typeof a?a:!0}function v(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function z(a,b){return b.length-a.length};const A=/[\p{Z}\p{S}\p{P}\p{C}]+/u;function B(a,b){const c=Object.keys(a),d=c.length,e=[];let h="",f=0;for(let g=0,l,n;g<d;g++)l=c[g],(n=a[l])?(e[f++]=new RegExp(b?"(?!\\b)"+l+"(\\b|_)":l,"g"),e[f++]=n):h+=(h?"|":"")+l;h&&(e[f++]=new RegExp(b?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[f]="");return e}function C(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a};function E(a){if(a=(""+a).toLowerCase())if(this.o&&(a=C(a,this.o)),this.A&&1<a.length&&(a=C(a,this.A)),A||""===A){const b=a.split(A);if(this.filter){a=this.filter;const c=b.length,d=[];for(let e=0,h=0;e<c;e++){const f=b[e];f&&!a[f]&&(d[h++]=f)}a=d}else a=b}return a};const F={},G={};function H(a,b,c,d){const e=a.length;let h=[],f,g,l=0;d&&(d=[]);for(let n=e-1;0<=n;n--){const m=a[n],r=m.length,p=y();let q=!f;for(let k=0;k<r;k++){const u=m[k],L=u.length;if(L)for(let D=0,x,w;D<L;D++)if(w=u[D],f){if(f[w]){if(!n)if(c)c--;else if(h[l++]=w,l===b)return h;if(n||d)p[w]=1;q=!0}if(d&&(x=(g[w]||0)+1,g[w]=x,x<e)){const M=d[x-2]||(d[x-2]=[]);M[M.length]=w}}else p[w]=1}if(d)f||(g=p);else if(!q)return[];f=p}if(d)for(let n=d.length-1,m,r;0<=n;n--){m=d[n];r=m.length;for(let p=0,q;p<r;p++)if(q=
m[p],!f[q]){if(c)c--;else if(h[l++]=q,l===b)return h;f[q]=1}}return h};function I(a,b){if(!(this instanceof I))return new I(a);let c;if(a){var d=a.charset;c=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=G[d]);"string"===typeof c&&(c=F[c])}else a={};let e,h,f=a.context||{};this.encode=a.encode||d&&d.encode||E;this.register=b||y();this.s=e=a.resolution||9;this.B=b=d&&d.B||a.tokenize||"strict";this.i="strict"===b&&f.depth;this.j=t(f.bidirectional);this.g=h=t(a.optimize);this.m=t(a.fastupdate);this.h=a.minlength||1;this.C=a.boost;this.map=h?v(e):y();
this.v=e=f.resolution||1;this.l=h?v(e):y();this.u=d&&d.u||a.rtl;this.o=(b=a.matcher||c&&c.o)&&B(b,!1);this.A=(b=a.stemmer||c&&c.A)&&B(b,!0);if(a=b=a.filter||c&&c.filter){a=b;d=y();for(let g=0,l=a.length;g<l;g++)d[a[g]]=1;a=d}this.filter=a}I.prototype.append=function(a,b){return this.add(a,b,!0)};
I.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(d=b.length){const n=y(),m=y(),r=this.i,p=this.s;for(let q=0;q<d;q++){let k=b[this.u?d-1-q:q];var e=k.length;if(k&&e>=this.h&&(r||!m[k])){var h=J(p,d,q),f="";switch(this.B){case "full":if(2<e){for(h=0;h<e;h++)for(var g=e;g>h;g--)if(g-h>=this.h){var l=J(p,d,q,e,h);f=k.substring(h,g);K(this,m,f,l,a,c)}break}case "reverse":if(1<e){for(g=e-1;0<g;g--)f=k[g]+f,f.length>=this.h&&K(this,
m,f,J(p,d,q,e,g),a,c);f=""}case "forward":if(1<e){for(g=0;g<e;g++)f+=k[g],f.length>=this.h&&K(this,m,f,h,a,c);break}default:if(this.C&&(h=Math.min(h/this.C(b,k,q)|0,p-1)),K(this,m,k,h,a,c),r&&1<d&&q<d-1)for(e=y(),f=this.v,h=k,g=Math.min(r+1,d-q),e[h]=1,l=1;l<g;l++)if((k=b[this.u?d-1-q-l:q+l])&&k.length>=this.h&&!e[k]){e[k]=1;const u=this.j&&k>h;K(this,n,u?h:k,J(f+(d/2>f?0:1),d,q,g-1,l-1),a,c,u?k:h)}}}}this.m||(this.register[a]=1)}}return this};
function J(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}function K(a,b,c,d,e,h,f){let g=f?a.l:a.map;if(!b[c]||f&&!b[c][f])a.g&&(g=g[d]),f?(b=b[c]||(b[c]=y()),b[f]=1,g=g[f]||(g[f]=y())):b[c]=1,g=g[c]||(g[c]=[]),a.g||(g=g[d]||(g[d]=[])),h&&g.includes(e)||(g[g.length]=e,a.m&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=g))}
I.prototype.search=function(a,b,c){c||(b||"object"!==typeof a?"object"===typeof b&&(c=b):(c=a,a=c.query));let d=[],e;let h,f=0;if(c){a=c.query||a;b=c.limit;f=c.offset||0;var g=c.context;h=!1}if(a&&(a=this.encode(""+a),e=a.length,1<e)){c=y();var l=[];for(let m=0,r=0,p;m<e;m++)if((p=a[m])&&p.length>=this.h&&!c[p])if(this.g||h||this.map[p])l[r++]=p,c[p]=1;else return d;a=l;e=a.length}if(!e)return d;b||(b=100);g=this.i&&1<e&&!1!==g;c=0;let n;g?(n=a[0],c=1):1<e&&a.sort(z);for(let m,r;c<e;c++){r=a[c];g?
(m=N(this,d,h,b,f,2===e,r,n),h&&!1===m&&d.length||(n=r)):m=N(this,d,h,b,f,1===e,r);if(m)return m;if(h&&c===e-1){l=d.length;if(!l){if(g){g=0;c=-1;continue}return d}if(1===l)return O(d[0],b,f)}}return H(d,b,f,h)};
function N(a,b,c,d,e,h,f,g){let l=[],n=g?a.l:a.map;a.g||(n=P(n,f,g,a.j));if(n){let m=0;const r=Math.min(n.length,g?a.v:a.s);for(let p=0,q=0,k,u;p<r;p++)if(k=n[p])if(a.g&&(k=P(k,f,g,a.j)),e&&k&&h&&(u=k.length,u<=e?(e-=u,k=null):(k=k.slice(e),e=0)),k&&(l[m++]=k,h&&(q+=k.length,q>=d)))break;if(m){if(h)return O(l,d,0);b[b.length]=l;return}}return!c&&l}function O(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function P(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}I.prototype.contain=function(a){return!!this.register[a]};I.prototype.update=function(a,b){return this.remove(a).add(a,b)};I.prototype.remove=function(a,b){const c=this.register[a];if(c){if(this.m)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else Q(this.map,a,this.s,this.g),this.i&&Q(this.l,a,this.v,this.g);b||delete this.register[a]}return this};
function Q(a,b,c,d,e){let h=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),h++):h++;else{e=Math.min(a.length,c);for(let f=0,g;f<e;f++)if(g=a[f])h=Q(g,b,c,d,e),d||h||delete a[f]}else for(let f in a)(h=Q(a[f],b,c,d,e))||delete a[f];return h};const R={Index:I,Document:null,Worker:null,registerCharset:function(a,b){G[a]=b},registerLanguage:function(a,b){F[a]=b}};let S;(S=self.define)&&S.amd?S([],function(){return R}):self.exports?self.exports=R:self.FlexSearch=R;}(this));

View File

@@ -0,0 +1,367 @@
/**!
* FlexSearch.js v0.7.41 (Light.module)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
function t(a) {
return "undefined" !== typeof a ? a : !0;
}
function v(a) {
const b = Array(a);
for (let c = 0; c < a; c++) {
b[c] = y();
}
return b;
}
function y() {
return Object.create(null);
}
function z(a, b) {
return b.length - a.length;
}
;const A = /[\p{Z}\p{S}\p{P}\p{C}]+/u;
function B(a, b) {
const c = Object.keys(a), d = c.length, e = [];
let h = "", f = 0;
for (let g = 0, l, n; g < d; g++) {
l = c[g], (n = a[l]) ? (e[f++] = new RegExp(b ? "(?!\\b)" + l + "(\\b|_)" : l, "g"), e[f++] = n) : h += (h ? "|" : "") + l;
}
h && (e[f++] = new RegExp(b ? "(?!\\b)(" + h + ")(\\b|_)" : "(" + h + ")", "g"), e[f] = "");
return e;
}
function C(a, b) {
for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
}
return a;
}
;function E(a) {
if (a = ("" + a).toLowerCase()) {
if (this.o && (a = C(a, this.o)), this.A && 1 < a.length && (a = C(a, this.A)), A || "" === A) {
const b = a.split(A);
if (this.filter) {
a = this.filter;
const c = b.length, d = [];
for (let e = 0, h = 0; e < c; e++) {
const f = b[e];
f && !a[f] && (d[h++] = f);
}
a = d;
} else {
a = b;
}
}
}
return a;
}
;const F = {}, G = {};
function H(a, b, c, d) {
const e = a.length;
let h = [], f, g, l = 0;
d && (d = []);
for (let n = e - 1; 0 <= n; n--) {
const m = a[n], r = m.length, p = y();
let q = !f;
for (let k = 0; k < r; k++) {
const u = m[k], J = u.length;
if (J) {
for (let D = 0, x, w; D < J; D++) {
if (w = u[D], f) {
if (f[w]) {
if (!n) {
if (c) {
c--;
} else {
if (h[l++] = w, l === b) {
return h;
}
}
}
if (n || d) {
p[w] = 1;
}
q = !0;
}
if (d && (x = (g[w] || 0) + 1, g[w] = x, x < e)) {
const K = d[x - 2] || (d[x - 2] = []);
K[K.length] = w;
}
} else {
p[w] = 1;
}
}
}
}
if (d) {
f || (g = p);
} else if (!q) {
return [];
}
f = p;
}
if (d) {
for (let n = d.length - 1, m, r; 0 <= n; n--) {
m = d[n];
r = m.length;
for (let p = 0, q; p < r; p++) {
if (q = m[p], !f[q]) {
if (c) {
c--;
} else {
if (h[l++] = q, l === b) {
return h;
}
}
f[q] = 1;
}
}
}
}
return h;
}
;function I(a, b) {
if (!(this instanceof I)) {
return new I(a);
}
let c;
if (a) {
var d = a.charset;
c = a.lang;
"string" === typeof d && (-1 === d.indexOf(":") && (d += ":default"), d = G[d]);
"string" === typeof c && (c = F[c]);
} else {
a = {};
}
let e, h, f = a.context || {};
this.encode = a.encode || d && d.encode || E;
this.register = b || y();
this.s = e = a.resolution || 9;
this.B = b = d && d.B || a.tokenize || "strict";
this.i = "strict" === b && f.depth;
this.j = t(f.bidirectional);
this.g = h = t(a.optimize);
this.m = t(a.fastupdate);
this.h = a.minlength || 1;
this.C = a.boost;
this.map = h ? v(e) : y();
this.v = e = f.resolution || 1;
this.l = h ? v(e) : y();
this.u = d && d.u || a.rtl;
this.o = (b = a.matcher || c && c.o) && B(b, !1);
this.A = (b = a.stemmer || c && c.A) && B(b, !0);
if (a = b = a.filter || c && c.filter) {
a = b;
d = y();
for (let g = 0, l = a.length; g < l; g++) {
d[a[g]] = 1;
}
a = d;
}
this.filter = a;
}
I.prototype.append = function(a, b) {
return this.add(a, b, !0);
};
I.prototype.add = function(a, b, c, d) {
if (b && (a || 0 === a)) {
if (!d && !c && this.register[a]) {
return this.update(a, b);
}
b = this.encode(b);
if (d = b.length) {
const n = y(), m = y(), r = this.i, p = this.s;
for (let q = 0; q < d; q++) {
let k = b[this.u ? d - 1 - q : q];
var e = k.length;
if (k && e >= this.h && (r || !m[k])) {
var h = L(p, d, q), f = "";
switch(this.B) {
case "full":
if (2 < e) {
for (h = 0; h < e; h++) {
for (var g = e; g > h; g--) {
if (g - h >= this.h) {
var l = L(p, d, q, e, h);
f = k.substring(h, g);
M(this, m, f, l, a, c);
}
}
}
break;
}
case "reverse":
if (1 < e) {
for (g = e - 1; 0 < g; g--) {
f = k[g] + f, f.length >= this.h && M(this, m, f, L(p, d, q, e, g), a, c);
}
f = "";
}
case "forward":
if (1 < e) {
for (g = 0; g < e; g++) {
f += k[g], f.length >= this.h && M(this, m, f, h, a, c);
}
break;
}
default:
if (this.C && (h = Math.min(h / this.C(b, k, q) | 0, p - 1)), M(this, m, k, h, a, c), r && 1 < d && q < d - 1) {
for (e = y(), f = this.v, h = k, g = Math.min(r + 1, d - q), e[h] = 1, l = 1; l < g; l++) {
if ((k = b[this.u ? d - 1 - q - l : q + l]) && k.length >= this.h && !e[k]) {
e[k] = 1;
const u = this.j && k > h;
M(this, n, u ? h : k, L(f + (d / 2 > f ? 0 : 1), d, q, g - 1, l - 1), a, c, u ? k : h);
}
}
}
}
}
}
this.m || (this.register[a] = 1);
}
}
return this;
};
function L(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;
}
function M(a, b, c, d, e, h, f) {
let g = f ? a.l : a.map;
if (!b[c] || f && !b[c][f]) {
a.g && (g = g[d]), f ? (b = b[c] || (b[c] = y()), b[f] = 1, g = g[f] || (g[f] = y())) : b[c] = 1, g = g[c] || (g[c] = []), a.g || (g = g[d] || (g[d] = [])), h && g.includes(e) || (g[g.length] = e, a.m && (a = a.register[e] || (a.register[e] = []), a[a.length] = g));
}
}
I.prototype.search = function(a, b, c) {
c || (b || "object" !== typeof a ? "object" === typeof b && (c = b) : (c = a, a = c.query));
let d = [], e;
let h, f = 0;
if (c) {
a = c.query || a;
b = c.limit;
f = c.offset || 0;
var g = c.context;
h = !1;
}
if (a && (a = this.encode("" + a), e = a.length, 1 < e)) {
c = y();
var l = [];
for (let m = 0, r = 0, p; m < e; m++) {
if ((p = a[m]) && p.length >= this.h && !c[p]) {
if (this.g || h || this.map[p]) {
l[r++] = p, c[p] = 1;
} else {
return d;
}
}
}
a = l;
e = a.length;
}
if (!e) {
return d;
}
b || (b = 100);
g = this.i && 1 < e && !1 !== g;
c = 0;
let n;
g ? (n = a[0], c = 1) : 1 < e && a.sort(z);
for (let m, r; c < e; c++) {
r = a[c];
g ? (m = N(this, d, h, b, f, 2 === e, r, n), h && !1 === m && d.length || (n = r)) : m = N(this, d, h, b, f, 1 === e, r);
if (m) {
return m;
}
if (h && c === e - 1) {
l = d.length;
if (!l) {
if (g) {
g = 0;
c = -1;
continue;
}
return d;
}
if (1 === l) {
return O(d[0], b, f);
}
}
}
return H(d, b, f, h);
};
function N(a, b, c, d, e, h, f, g) {
let l = [], n = g ? a.l : a.map;
a.g || (n = P(n, f, g, a.j));
if (n) {
let m = 0;
const r = Math.min(n.length, g ? a.v : a.s);
for (let p = 0, q = 0, k, u; p < r; p++) {
if (k = n[p]) {
if (a.g && (k = P(k, f, g, a.j)), e && k && h && (u = k.length, u <= e ? (e -= u, k = null) : (k = k.slice(e), e = 0)), k && (l[m++] = k, h && (q += k.length, q >= d))) {
break;
}
}
}
if (m) {
if (h) {
return O(l, d, 0);
}
b[b.length] = l;
return;
}
}
return !c && l;
}
function O(a, b, c) {
a = 1 === a.length ? a[0] : [].concat.apply([], a);
return c || a.length > b ? a.slice(c, c + b) : a;
}
function P(a, b, c, d) {
c ? (d = d && b > c, a = (a = a[d ? b : c]) && a[d ? c : b]) : a = a[b];
return a;
}
I.prototype.contain = function(a) {
return !!this.register[a];
};
I.prototype.update = function(a, b) {
return this.remove(a).add(a, b);
};
I.prototype.remove = function(a, b) {
const c = this.register[a];
if (c) {
if (this.m) {
for (let d = 0, e; d < c.length; d++) {
e = c[d], e.splice(e.indexOf(a), 1);
}
} else {
Q(this.map, a, this.s, this.g), this.i && Q(this.l, a, this.v, this.g);
}
b || delete this.register[a];
}
return this;
};
function Q(a, b, c, d, e) {
let h = 0;
if (a.constructor === Array) {
if (e) {
b = a.indexOf(b), -1 !== b ? 1 < a.length && (a.splice(b, 1), h++) : h++;
} else {
e = Math.min(a.length, c);
for (let f = 0, g; f < e; f++) {
if (g = a[f]) {
h = Q(g, b, c, d, e), d || h || delete a[f];
}
}
}
} else {
for (let f in a) {
(h = Q(a[f], b, c, d, e)) || delete a[f];
}
}
return h;
}
;export default {Index:I, Document:null, Worker:null, registerCharset:function(a, b) {
G[a] = b;
}, registerLanguage:function(a, b) {
F[a] = b;
}};

View File

@@ -0,0 +1,18 @@
/**!
* FlexSearch.js v0.7.41 (Light.module)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
function t(a){return"undefined"!==typeof a?a:!0}function v(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function z(a,b){return b.length-a.length};const A=/[\p{Z}\p{S}\p{P}\p{C}]+/u;function B(a,b){const c=Object.keys(a),d=c.length,e=[];let h="",f=0;for(let g=0,l,n;g<d;g++)l=c[g],(n=a[l])?(e[f++]=new RegExp(b?"(?!\\b)"+l+"(\\b|_)":l,"g"),e[f++]=n):h+=(h?"|":"")+l;h&&(e[f++]=new RegExp(b?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[f]="");return e}function C(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a};function E(a){if(a=(""+a).toLowerCase())if(this.o&&(a=C(a,this.o)),this.A&&1<a.length&&(a=C(a,this.A)),A||""===A){const b=a.split(A);if(this.filter){a=this.filter;const c=b.length,d=[];for(let e=0,h=0;e<c;e++){const f=b[e];f&&!a[f]&&(d[h++]=f)}a=d}else a=b}return a};const F={},G={};function H(a,b,c,d){const e=a.length;let h=[],f,g,l=0;d&&(d=[]);for(let n=e-1;0<=n;n--){const m=a[n],r=m.length,p=y();let q=!f;for(let k=0;k<r;k++){const u=m[k],J=u.length;if(J)for(let D=0,x,w;D<J;D++)if(w=u[D],f){if(f[w]){if(!n)if(c)c--;else if(h[l++]=w,l===b)return h;if(n||d)p[w]=1;q=!0}if(d&&(x=(g[w]||0)+1,g[w]=x,x<e)){const K=d[x-2]||(d[x-2]=[]);K[K.length]=w}}else p[w]=1}if(d)f||(g=p);else if(!q)return[];f=p}if(d)for(let n=d.length-1,m,r;0<=n;n--){m=d[n];r=m.length;for(let p=0,q;p<r;p++)if(q=
m[p],!f[q]){if(c)c--;else if(h[l++]=q,l===b)return h;f[q]=1}}return h};function I(a,b){if(!(this instanceof I))return new I(a);let c;if(a){var d=a.charset;c=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=G[d]);"string"===typeof c&&(c=F[c])}else a={};let e,h,f=a.context||{};this.encode=a.encode||d&&d.encode||E;this.register=b||y();this.s=e=a.resolution||9;this.B=b=d&&d.B||a.tokenize||"strict";this.i="strict"===b&&f.depth;this.j=t(f.bidirectional);this.g=h=t(a.optimize);this.m=t(a.fastupdate);this.h=a.minlength||1;this.C=a.boost;this.map=h?v(e):y();
this.v=e=f.resolution||1;this.l=h?v(e):y();this.u=d&&d.u||a.rtl;this.o=(b=a.matcher||c&&c.o)&&B(b,!1);this.A=(b=a.stemmer||c&&c.A)&&B(b,!0);if(a=b=a.filter||c&&c.filter){a=b;d=y();for(let g=0,l=a.length;g<l;g++)d[a[g]]=1;a=d}this.filter=a}I.prototype.append=function(a,b){return this.add(a,b,!0)};
I.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(d=b.length){const n=y(),m=y(),r=this.i,p=this.s;for(let q=0;q<d;q++){let k=b[this.u?d-1-q:q];var e=k.length;if(k&&e>=this.h&&(r||!m[k])){var h=L(p,d,q),f="";switch(this.B){case "full":if(2<e){for(h=0;h<e;h++)for(var g=e;g>h;g--)if(g-h>=this.h){var l=L(p,d,q,e,h);f=k.substring(h,g);M(this,m,f,l,a,c)}break}case "reverse":if(1<e){for(g=e-1;0<g;g--)f=k[g]+f,f.length>=this.h&&M(this,
m,f,L(p,d,q,e,g),a,c);f=""}case "forward":if(1<e){for(g=0;g<e;g++)f+=k[g],f.length>=this.h&&M(this,m,f,h,a,c);break}default:if(this.C&&(h=Math.min(h/this.C(b,k,q)|0,p-1)),M(this,m,k,h,a,c),r&&1<d&&q<d-1)for(e=y(),f=this.v,h=k,g=Math.min(r+1,d-q),e[h]=1,l=1;l<g;l++)if((k=b[this.u?d-1-q-l:q+l])&&k.length>=this.h&&!e[k]){e[k]=1;const u=this.j&&k>h;M(this,n,u?h:k,L(f+(d/2>f?0:1),d,q,g-1,l-1),a,c,u?k:h)}}}}this.m||(this.register[a]=1)}}return this};
function L(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}function M(a,b,c,d,e,h,f){let g=f?a.l:a.map;if(!b[c]||f&&!b[c][f])a.g&&(g=g[d]),f?(b=b[c]||(b[c]=y()),b[f]=1,g=g[f]||(g[f]=y())):b[c]=1,g=g[c]||(g[c]=[]),a.g||(g=g[d]||(g[d]=[])),h&&g.includes(e)||(g[g.length]=e,a.m&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=g))}
I.prototype.search=function(a,b,c){c||(b||"object"!==typeof a?"object"===typeof b&&(c=b):(c=a,a=c.query));let d=[],e;let h,f=0;if(c){a=c.query||a;b=c.limit;f=c.offset||0;var g=c.context;h=!1}if(a&&(a=this.encode(""+a),e=a.length,1<e)){c=y();var l=[];for(let m=0,r=0,p;m<e;m++)if((p=a[m])&&p.length>=this.h&&!c[p])if(this.g||h||this.map[p])l[r++]=p,c[p]=1;else return d;a=l;e=a.length}if(!e)return d;b||(b=100);g=this.i&&1<e&&!1!==g;c=0;let n;g?(n=a[0],c=1):1<e&&a.sort(z);for(let m,r;c<e;c++){r=a[c];g?
(m=N(this,d,h,b,f,2===e,r,n),h&&!1===m&&d.length||(n=r)):m=N(this,d,h,b,f,1===e,r);if(m)return m;if(h&&c===e-1){l=d.length;if(!l){if(g){g=0;c=-1;continue}return d}if(1===l)return O(d[0],b,f)}}return H(d,b,f,h)};
function N(a,b,c,d,e,h,f,g){let l=[],n=g?a.l:a.map;a.g||(n=P(n,f,g,a.j));if(n){let m=0;const r=Math.min(n.length,g?a.v:a.s);for(let p=0,q=0,k,u;p<r;p++)if(k=n[p])if(a.g&&(k=P(k,f,g,a.j)),e&&k&&h&&(u=k.length,u<=e?(e-=u,k=null):(k=k.slice(e),e=0)),k&&(l[m++]=k,h&&(q+=k.length,q>=d)))break;if(m){if(h)return O(l,d,0);b[b.length]=l;return}}return!c&&l}function O(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function P(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}I.prototype.contain=function(a){return!!this.register[a]};I.prototype.update=function(a,b){return this.remove(a).add(a,b)};I.prototype.remove=function(a,b){const c=this.register[a];if(c){if(this.m)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else Q(this.map,a,this.s,this.g),this.i&&Q(this.l,a,this.v,this.g);b||delete this.register[a]}return this};
function Q(a,b,c,d,e){let h=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),h++):h++;else{e=Math.min(a.length,c);for(let f=0,g;f<e;f++)if(g=a[f])h=Q(g,b,c,d,e),d||h||delete a[f]}else for(let f in a)(h=Q(a[f],b,c,d,e))||delete a[f];return h};export default {Index:I,Document:null,Worker:null,registerCharset:function(a,b){G[a]=b},registerLanguage:function(a,b){F[a]=b}};

View File

@@ -0,0 +1 @@
(function(self){'use strict';const a=/[\x00-\x7F]+/g;self.FlexSearch.registerCharset("arabic:default",{encode:function(b){return this.g(b.replace(a," "),!1," ",!1)},h:!0});}(this));

View File

@@ -0,0 +1,2 @@
(function(self){'use strict';self.FlexSearch.registerLanguage("at",{filter:"aber als am an auch auf aus bei bin bis bist da dadurch daher darum das da\u00df 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 f\u00fcr hatte hatten hattest hattet hier hinter ich ihr ihre im in ist ja jede jedem jeden jeder jedes jener jenes jetzt kann kannst k\u00f6nnen k\u00f6nnt machen mein meine mit mu\u00df mu\u00dft musst m\u00fcssen m\u00fc\u00dft nach nachdem nein nicht nun oder seid sein seine sich sie sind soll sollen sollst sollt sonst soweit sowie und unser unsere unter 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 \u00fcber".split(" "),
h:{niss:"",isch:"",lich:"",heit:"",keit:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""},g:{}});}(this));

View File

@@ -0,0 +1 @@
(function(self){'use strict';const a=/[\x00-\x7F]+/g;self.FlexSearch.registerCharset("cjk:default",{encode:function(b){return this.g(b.replace(a,""),!1,"",!1)},h:!1,i:"strict"});}(this));

View File

@@ -0,0 +1 @@
(function(self){'use strict';const a=/[\x00-\x7F]+/g;self.FlexSearch.registerCharset("cyrillic:default",{encode:function(b){return this.g(b.replace(a," "),!1," ",!1)},h:!1});}(this));

View File

@@ -0,0 +1,2 @@
(function(self){'use strict';self.FlexSearch.registerLanguage("de",{filter:"aber als am an auch auf aus bei bin bis bist da dadurch daher darum das da\u00df 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 f\u00fcr hatte hatten hattest hattet hier hinter ich ihr ihre im in ist ja jede jedem jeden jeder jedes jener jenes jetzt kann kannst k\u00f6nnen k\u00f6nnt machen mein meine mit mu\u00df mu\u00dft musst m\u00fcssen m\u00fc\u00dft nach nachdem nein nicht nun oder seid sein seine sich sie sind soll sollen sollst sollt sonst soweit sowie und unser unsere unter 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 \u00fcber".split(" "),
h:{niss:"",isch:"",lich:"",heit:"",keit:"",ell:"",bar:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""},g:{}});}(this));

View File

@@ -0,0 +1,2 @@
(function(self){'use strict';self.FlexSearch.registerLanguage("en",{filter:"a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "),
h:{ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""},g:{}});}(this));

View File

@@ -0,0 +1,2 @@
(function(self){'use strict';const b=/[\u0300-\u036f]/g;function l(a){return new RegExp(a,"g")};const p=/[\W_]+/,r=[l("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",l("[\u00e8\u00e9\u00ea\u00eb]"),"e",l("[\u00ec\u00ed\u00ee\u00ef]"),"i",l("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",l("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",l("[\u00fd\u0177\u00ff]"),"y",l("\u00f1"),"n",l("[\u00e7c]"),"k",l("\u00df"),"s",l(" & ")," and "];const t=/[^a-z0-9]+/,u={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};const v=[l("ae"),"a",l("oe"),"o",l("sh"),"s",l("th"),"t",l("ph"),"f",l("pf"),"f"];self.FlexSearch.registerCharset("latin:advanced",{encode:function(a,h){if(a){var e=this.h,f=a;f.normalize&&(f=f.normalize("NFD").replace(b,""));a=e.call(this,f.toLowerCase(),!a.normalize&&r,p,!1).join(" ");e=[];if(a){f=a.split(t);const c=f.length;for(let g=0,d,w=0;g<c;g++)if((a=f[g])&&(!this.filter||!this.filter[a])){d=a[0];let m=u[d]||d,q=m;for(let n=1;n<a.length;n++){d=a[n];const k=u[d]||d;k&&k!==q&&(m+=k,q=k)}e[w++]=m}}a=e.join(" ");if(2<a.length)for(let c=0,g=v.length;c<g&&(a=a.replace(v[c],v[c+
1]),a);c+=2);if(!h){if(1<a.length){e=h="";for(let c=0,g=a.length,d;c<g;c++)(d=a[c])!==e&&(h+=e=d);a=h}a&&(a=a.split(" "))}}return a},l:!1,m:""});}(this));

View File

@@ -0,0 +1 @@
(function(self){'use strict';const b=/[\u0300-\u036f]/g;function l(a){return new RegExp(a,"g")};const n=/[\W_]+/,p=[l("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",l("[\u00e8\u00e9\u00ea\u00eb]"),"e",l("[\u00ec\u00ed\u00ee\u00ef]"),"i",l("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",l("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",l("[\u00fd\u0177\u00ff]"),"y",l("\u00f1"),"n",l("[\u00e7c]"),"k",l("\u00df"),"s",l(" & ")," and "];const q=/[^a-z0-9]+/,r={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};self.FlexSearch.registerCharset("latin:balance",{encode:function(a){var e=this.h,c=a;c.normalize&&(c=c.normalize("NFD").replace(b,""));a=e.call(this,c.toLowerCase(),!a.normalize&&p,n,!1).join(" ");e=[];if(a){c=a.split(q);const t=c.length;for(let g=0,d,u=0;g<t;g++)if((a=c[g])&&(!this.filter||!this.filter[a])){d=a[0];let h=r[d]||d,m=h;for(let k=1;k<a.length;k++){d=a[k];const f=r[d]||d;f&&f!==m&&(h+=f,m=f)}e[u++]=h}}return e},l:!1,m:"strict"});}(this));

View File

@@ -0,0 +1 @@
(function(self){'use strict';const b=/[\u0300-\u036f]/g;const c=/[\W_]+/;self.FlexSearch.registerCharset("latin:default",{encode:function(a){var d=this.g;a.normalize&&(a=a.normalize("NFD").replace(b,""));return d.call(this,a.toLowerCase(),!1,c,!1)},h:!1,i:""});}(this));

View File

@@ -0,0 +1,2 @@
(function(self){'use strict';const b=/[\u0300-\u036f]/g;function k(a){return new RegExp(a,"g")};const n=/[\W_]+/,q=[k("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",k("[\u00e8\u00e9\u00ea\u00eb]"),"e",k("[\u00ec\u00ed\u00ee\u00ef]"),"i",k("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",k("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",k("[\u00fd\u0177\u00ff]"),"y",k("\u00f1"),"n",k("[\u00e7c]"),"k",k("\u00df"),"s",k(" & ")," and "];const r=/[^a-z0-9]+/,t={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};const u=[k("ae"),"a",k("oe"),"o",k("sh"),"s",k("th"),"t",k("ph"),"f",k("pf"),"f"];const v=k("(?!\\b)[aeiouy]");self.FlexSearch.registerCharset("latin:extra",{encode:function(a){if(a){if(a){var f=this.h,c=a;c.normalize&&(c=c.normalize("NFD").replace(b,""));a=f.call(this,c.toLowerCase(),!a.normalize&&q,n,!1).join(" ");f=[];if(a){c=a.split(r);const d=c.length;for(let g=0,e,w=0;g<d;g++)if((a=c[g])&&(!this.filter||!this.filter[a])){e=a[0];let l=t[e]||e,p=l;for(let m=1;m<a.length;m++){e=a[m];const h=t[e]||e;h&&h!==p&&(l+=h,p=h)}f[w++]=l}}a=f.join(" ");if(2<a.length)for(let d=0,g=u.length;d<g&&(a=a.replace(u[d],
u[d+1]),a);d+=2);}1<a.length&&(a=a.replace(v,""));if(1<a.length){c=f="";for(let d=0,g=a.length,e;d<g;d++)(e=a[d])!==c&&(f+=c=e);a=f}a&&(a=a.split(" "))}return a},l:!1,m:""});}(this));

View File

@@ -0,0 +1 @@
(function(self){'use strict';const a=/[\u0300-\u036f]/g;function d(b){return new RegExp(b,"g")};const e=/[\W_]+/,f=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("[\u00e7c]"),"k",d("\u00df"),"s",d(" & ")," and "];self.FlexSearch.registerCharset("latin:simple",{encode:function(b){var g=this.g,c=b;c.normalize&&(c=c.normalize("NFD").replace(a,""));return g.call(this,c.toLowerCase(),!b.normalize&&f,e,!1)},h:!1,i:""});}(this));

View File

@@ -0,0 +1,2 @@
(function(self){'use strict';self.FlexSearch.registerLanguage("us",{filter:"a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "),
h:{ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""},g:{}});}(this));

View File

@@ -0,0 +1,51 @@
import { IndexInterface, DocumentInterface } from "./type.js";
//import { promise as Promise } from "./polyfill.js";
import { is_function, is_object, is_string } from "./common.js";
export default function (prototype) {
register(prototype, "add");
register(prototype, "append");
register(prototype, "search");
register(prototype, "update");
register(prototype, "remove");
}
function register(prototype, key) {
prototype[key + "Async"] = function () {
/** @type {IndexInterface|DocumentInterface} */
const self = this,
args = /*[].slice.call*/arguments,
arg = args[args.length - 1];
let callback;
if (is_function(arg)) {
callback = arg;
delete args[args.length - 1];
}
const promise = new Promise(function (resolve) {
setTimeout(function () {
self.async = !0;
const res = self[key].apply(self, args);
self.async = !1;
resolve(res);
});
});
if (callback) {
promise.then(callback);
return this;
} else {
return promise;
}
};
}

View File

@@ -0,0 +1,168 @@
import { IndexInterface, DocumentInterface } from "./type.js";
import { create_object, is_object } from "./common.js";
/**
* @param {boolean|number=} limit
* @constructor
*/
function CacheClass(limit) {
/** @private */
this.limit = !0 !== limit && limit;
/** @private */
this.cache = create_object();
/** @private */
this.queue = [];
//this.clear();
}
export default CacheClass;
/**
* @param {string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @this {IndexInterface}
* @returns {Array<number|string>}
*/
export function searchCache(query, limit, options) {
if (is_object(query)) {
query = query.query;
}
let cache = this.cache.get(query);
if (!cache) {
cache = this.search(query, limit, options);
this.cache.set(query, cache);
}
return cache;
}
// CacheClass.prototype.clear = function(){
//
// /** @private */
// this.cache = create_object();
//
// /** @private */
// this.queue = [];
// };
CacheClass.prototype.set = function (key, value) {
if (!this.cache[key]) {
// it is just a shame that native function array.shift() performs so bad
// const length = this.queue.length;
//
// this.queue[length] = key;
//
// if(length === this.limit){
//
// delete this.cache[this.queue.shift()];
// }
// the same bad performance
// this.queue.unshift(key);
//
// if(this.queue.length === this.limit){
//
// this.queue.pop();
// }
// fast implementation variant
// let length = this.queue.length;
//
// if(length === this.limit){
//
// length--;
//
// delete this.cache[this.queue[0]];
//
// for(let x = 0; x < length; x++){
//
// this.queue[x] = this.queue[x + 1];
// }
// }
//
// this.queue[length] = key;
// current fastest implementation variant
// theoretically that should not perform better compared to the example above
let length = this.queue.length;
if (length === this.limit) {
delete this.cache[this.queue[length - 1]];
} else {
length++;
}
for (let x = length - 1; 0 < x; x--) {
this.queue[x] = this.queue[x - 1];
}
this.queue[0] = key;
}
this.cache[key] = value;
};
CacheClass.prototype.get = function (key) {
const cache = this.cache[key];
if (this.limit && cache) {
// probably the indexOf() method performs faster when matched content is on front (left-to-right)
// using lastIndexOf() does not help, it performs almost slower
const pos = this.queue.indexOf(key);
// if(pos < this.queue.length - 1){
//
// const tmp = this.queue[pos];
// this.queue[pos] = this.queue[pos + 1];
// this.queue[pos + 1] = tmp;
// }
if (pos) {
const tmp = this.queue[pos - 1];
this.queue[pos - 1] = this.queue[pos];
this.queue[pos] = tmp;
}
}
return cache;
};
CacheClass.prototype.del = function (id) {
for (let i = 0, item, key; i < this.queue.length; i++) {
key = this.queue[i];
item = this.cache[key];
if (item.includes(id)) {
this.queue.splice(i--, 1);
delete this.cache[key];
}
}
};

View File

@@ -0,0 +1,78 @@
export function parse_option(value, default_value) {
return "undefined" != typeof value ? value : default_value;
}
/**
* @param {!number} count
* @returns {Array<Object>}
*/
export function create_object_array(count) {
const array = Array(count);
for (let i = 0; i < count; i++) {
array[i] = create_object();
}
return array;
}
export function create_arrays(count) {
const array = Array(count);
for (let i = 0; i < count; i++) {
array[i] = [];
}
return array;
}
/**
* @param {!Object} obj
* @returns {Array<string>}
*/
export function get_keys(obj) {
return Object.keys(obj);
}
export function create_object() {
return Object.create(null);
}
export function concat(arrays) {
return [].concat.apply([], arrays);
}
export function sort_by_length_down(a, b) {
return b.length - a.length;
}
export function is_array(val) {
return val.constructor === Array;
}
export function is_string(val) {
return "string" == typeof val;
}
export function is_object(val) {
return "object" == typeof val;
}
export function is_function(val) {
return "function" == typeof val;
}

View File

@@ -0,0 +1,731 @@
/**!
* FlexSearch.js
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
import Index from "./index.js";
import { DocumentInterface } from "./type.js";
import Cache, { searchCache } from "./cache.js";
import { create_object, is_array, is_string, is_object, parse_option, get_keys } from "./common.js";
import apply_async from "./async.js";
import { intersect, intersect_union } from "./intersect.js";
import { exportDocument, importDocument } from "./serialize.js";
import WorkerIndex from "./worker/index.js";
/**
* @constructor
* @implements {DocumentInterface}
* @param {Object=} options
* @return {Document}
*/
function Document(options) {
if (!(this instanceof Document)) {
return new Document(options);
}
const document = options.document || options.doc || options;
let opt;
this.tree = [];
this.field = [];
this.marker = [];
this.register = create_object();
this.key = (opt = document.key || document.id) && parse_tree(opt, this.marker) || "id";
this.fastupdate = parse_option(options.fastupdate, /* append: */ /* skip update: */ /* skip_update: */!0);
this.storetree = (opt = document.store) && !0 !== opt && [];
this.store = opt && create_object();
// TODO case-insensitive tags
this.tag = (opt = document.tag) && parse_tree(opt, this.marker);
this.tagindex = opt && create_object();
this.cache = (opt = options.cache) && new Cache(opt);
// do not apply cache again for the indexes
options.cache = !1;
this.worker = options.worker;
// this switch is used by recall of promise callbacks
this.async = !1;
/** @export */
this.index = parse_descriptor.call(this, options, document);
}
export default Document;
/**
* @this Document
*/
function parse_descriptor(options, document) {
const index = create_object();
let field = document.index || document.field || document;
if (is_string(field)) {
field = [field];
}
for (let i = 0, key, opt; i < field.length; i++) {
key = field[i];
if (!is_string(key)) {
opt = key;
key = key.field;
}
opt = is_object(opt) ? Object.assign({}, options, opt) : options;
if (this.worker) {
index[key] = new WorkerIndex(opt);
if (!index[key].worker) {
this.worker = !1;
}
}
if (!this.worker) {
index[key] = new Index(opt, this.register);
}
this.tree[i] = parse_tree(key, this.marker);
this.field[i] = key;
}
if (this.storetree) {
let store = document.store;
if (is_string(store)) {
store = [store];
}
for (let i = 0; i < store.length; i++) {
this.storetree[i] = parse_tree(store[i], this.marker);
}
}
return index;
}
function parse_tree(key, marker) {
const tree = key.split(":");
let count = 0;
for (let i = 0; i < tree.length; i++) {
key = tree[i];
if (0 <= key.indexOf("[]")) {
key = key.substring(0, key.length - 2);
if (key) {
marker[count] = !0;
}
}
if (key) {
tree[count++] = key;
}
}
if (count < tree.length) {
tree.length = count;
}
return 1 < count ? tree : tree[0];
}
// TODO support generic function created from string when tree depth > 1
function parse_simple(obj, tree) {
if (is_string(tree)) {
obj = obj[tree];
} else {
for (let i = 0; obj && i < tree.length; i++) {
obj = obj[tree[i]];
}
}
return obj;
}
// TODO support generic function created from string when tree depth > 1
function store_value(obj, store, tree, pos, key) {
obj = obj[key];
// reached target field
if (pos === tree.length - 1) {
// store target value
store[key] = obj;
} else if (obj) {
if (is_array(obj)) {
store = store[key] = Array(obj.length);
for (let i = 0; i < obj.length; i++) {
// do not increase pos (an array is not a field)
store_value(obj, store, tree, pos, i);
}
} else {
store = store[key] || (store[key] = create_object());
key = tree[++pos];
store_value(obj, store, tree, pos, key);
}
}
}
function add_index(obj, tree, marker, pos, index, id, key, _append) {
obj = obj[key];
if (obj) {
// reached target field
if (pos === tree.length - 1) {
// handle target value
if (is_array(obj)) {
// append array contents so each entry gets a new scoring context
if (marker[pos]) {
for (let i = 0; i < obj.length; i++) {
index.add(id, obj[i], !0, !0);
}
return;
}
// or join array contents and use one scoring context
obj = obj.join(" ");
}
index.add(id, obj, _append, !0);
} else {
if (is_array(obj)) {
for (let i = 0; i < obj.length; i++) {
// do not increase index, an array is not a field
add_index(obj, tree, marker, pos, index, id, i, _append);
}
} else {
key = tree[++pos];
add_index(obj, tree, marker, pos, index, id, key, _append);
}
}
}
}
/**
*
* @param id
* @param content
* @param {boolean=} _append
* @returns {Document|Promise}
*/
Document.prototype.add = function (id, content, _append) {
if (is_object(id)) {
content = id;
id = parse_simple(content, this.key);
}
if (content && (id || 0 === id)) {
if (!_append && this.register[id]) {
return this.update(id, content);
}
for (let i = 0, tree, field; i < this.field.length; i++) {
field = this.field[i];
tree = this.tree[i];
if (is_string(tree)) {
tree = [tree];
}
add_index(content, tree, this.marker, 0, this.index[field], id, tree[0], _append);
}
if (this.tag) {
let tag = parse_simple(content, this.tag),
dupes = create_object();
if (is_string(tag)) {
tag = [tag];
}
for (let i = 0, key, arr; i < tag.length; i++) {
key = tag[i];
if (!dupes[key]) {
dupes[key] = 1;
arr = this.tagindex[key] || (this.tagindex[key] = []);
if (!_append || !arr.includes(id)) {
arr[arr.length] = id;
// add a reference to the register for fast updates
if (this.fastupdate) {
const tmp = this.register[id] || (this.register[id] = []);
tmp[tmp.length] = arr;
}
}
}
}
}
// TODO: how to handle store when appending contents?
if (this.store && (!_append || !this.store[id])) {
let store;
if (this.storetree) {
store = create_object();
for (let i = 0, tree; i < this.storetree.length; i++) {
tree = this.storetree[i];
if (is_string(tree)) {
store[tree] = content[tree];
} else {
store_value(content, store, tree, 0, tree[0]);
}
}
}
this.store[id] = store || content;
}
}
return this;
};
Document.prototype.append = function (id, content) {
return this.add(id, content, !0);
};
Document.prototype.update = function (id, content) {
return this.remove(id).add(id, content);
};
Document.prototype.remove = function (id) {
if (is_object(id)) {
id = parse_simple(id, this.key);
}
if (this.register[id]) {
for (let i = 0; i < this.field.length; i++) {
// workers does not share the register
this.index[this.field[i]].remove(id, !this.worker);
if (this.fastupdate) {
// when fastupdate was enabled all ids are removed
break;
}
}
if (this.tag) {
// when fastupdate was enabled all ids are already removed
if (!this.fastupdate) {
for (let key in this.tagindex) {
const tag = this.tagindex[key],
pos = tag.indexOf(id);
if (-1 !== pos) {
if (1 < tag.length) {
tag.splice(pos, 1);
} else {
delete this.tagindex[key];
}
}
}
}
}
if (this.store) {
delete this.store[id];
}
delete this.register[id];
}
return this;
};
/**
* @param {!string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @param {Array<Array>=} _resolve For internal use only.
* @returns {Promise|Array}
*/
Document.prototype.search = function (query, limit, options, _resolve) {
if (!options) {
if (!limit && is_object(query)) {
options = /** @type {Object} */query;
query = "";
} else if (is_object(limit)) {
options = /** @type {Object} */limit;
limit = 0;
}
}
let result = [],
result_field = [],
pluck,
enrich,
field,
tag,
bool,
offset,
count = 0;
if (options) {
if (is_array(options)) {
field = options;
options = null;
} else {
query = options.query || query;
pluck = options.pluck;
field = pluck || options.index || options.field /*|| (is_string(options) && [options])*/;
tag = options.tag;
enrich = this.store && options.enrich;
bool = "and" === options.bool;
limit = options.limit || limit || 100;
offset = options.offset || 0;
if (tag) {
if (is_string(tag)) {
tag = [tag];
}
// when tags is used and no query was set,
// then just return the tag indexes
if (!query) {
for (let i = 0, res; i < tag.length; i++) {
res = get_tag.call(this, tag[i], limit, offset, enrich);
if (res) {
result[result.length] = res;
count++;
}
}
return count ? result : [];
}
}
if (is_string(field)) {
field = [field];
}
}
}
field || (field = this.field);
bool = bool && (1 < field.length || tag && 1 < tag.length);
const promises = !_resolve && (this.worker || this.async) && [];
// TODO solve this in one loop below
for (let i = 0, res, key, len; i < field.length; i++) {
let field_options;
key = field[i];
if (!is_string(key)) {
field_options = key;
key = field_options.field;
query = field_options.query || query;
limit = field_options.limit || limit;
enrich = field_options.enrich || enrich;
}
if (promises) {
promises[i] = this.index[key].searchAsync(query, limit, field_options || options);
// just collect and continue
continue;
} else if (_resolve) {
res = _resolve[i];
} else {
// inherit options also when search? it is just for laziness, Object.assign() has a cost
res = this.index[key].search(query, limit, field_options || options);
}
len = res && res.length;
if (tag && len) {
const arr = [];
let count = 0;
if (bool) {
// prepare for intersection
arr[0] = [res];
}
for (let y = 0, key, res; y < tag.length; y++) {
key = tag[y];
res = this.tagindex[key];
len = res && res.length;
if (len) {
count++;
arr[arr.length] = bool ? [res] : res;
}
}
if (count) {
if (bool) {
res = intersect(arr, limit || 100, offset || 0);
} else {
res = intersect_union(res, arr);
}
len = res.length;
}
}
if (len) {
result_field[count] = key;
result[count++] = res;
} else if (bool) {
return [];
}
}
if (promises) {
const self = this;
// anyone knows a better workaround of optionally having async promises?
// the promise.all() needs to be wrapped into additional promise,
// otherwise the recursive callback wouldn't run before return
return new Promise(function (resolve) {
Promise.all(promises).then(function (result) {
resolve(self.search(query, limit, options, result));
});
});
}
if (!count) {
// fast path "not found"
return [];
}
if (pluck && (!enrich || !this.store)) {
// fast path optimization
return result[0];
}
for (let i = 0, res; i < result_field.length; i++) {
res = result[i];
if (res.length) {
if (enrich) {
res = apply_enrich.call(this, res);
}
}
if (pluck) {
return res;
}
result[i] = {
field: result_field[i],
result: res
};
}
return result;
};
/**
* @this Document
*/
function get_tag(key, limit, offset) {
let res = this.tagindex[key],
len = res && res.length - offset;
}
/**
* @this Document
*/
function apply_enrich(res) {
const arr = Array(res.length);
for (let x = 0, id; x < res.length; x++) {
id = res[x];
arr[x] = {
id: id,
doc: this.store[id]
};
}
return arr;
}
Document.prototype.contain = function (id) {
return !!this.register[id];
};
Document.prototype.get = function (id) {
return this.store[id];
};
Document.prototype.set = function (id, data) {
this.store[id] = data;
return this;
};
Document.prototype.searchCache = searchCache;
Document.prototype.export = exportDocument;
Document.prototype.import = importDocument;
apply_async(Document.prototype);

View File

@@ -0,0 +1,35 @@
import { searchCache } from "./cache";
/**
* @constructor
* @abstract
*/
function Engine(index) {
//if(this.constructor === Engine){
if (this instanceof Engine) {
throw new Error("Can't instantiate abstract class!");
}
index.prototype.searchCache = searchCache;
index.prototype.addAsync = addAsync;
index.prototype.appendAsync = appendAsync;
index.prototype.searchAsync = searchAsync;
index.prototype.updateAsync = updateAsync;
index.prototype.removeAsync = removeAsync;
}
Engine.prototype.searchCache = searchCache;
Engine.prototype.addAsync = addAsync;
Engine.prototype.appendAsync = appendAsync;
Engine.prototype.searchAsync = searchAsync;
Engine.prototype.updateAsync = updateAsync;
Engine.prototype.removeAsync = removeAsync;

View File

@@ -0,0 +1,22 @@
export const global_lang = {};
export const global_charset = {};
/**
* @param {!string} name
* @param {Object} charset
*/
export function registerCharset(name, charset) {
global_charset[name] = charset;
}
/**
* @param {!string} name
* @param {Object} lang
*/
export function registerLanguage(name, lang) {
global_lang[name] = lang;
}

View File

@@ -0,0 +1,784 @@
/**!
* FlexSearch.js
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
import { IndexInterface } from "./type.js";
import { encode as default_encoder } from "./lang/latin/default.js";
import { create_object, create_object_array, concat, sort_by_length_down, is_array, is_string, is_object, parse_option } from "./common.js";
import { pipeline, init_stemmer_or_matcher, init_filter } from "./lang.js";
import { global_lang, global_charset } from "./global.js";
import apply_async from "./async.js";
import { intersect } from "./intersect.js";
import Cache, { searchCache } from "./cache.js";
import apply_preset from "./preset.js";
import { exportIndex, importIndex } from "./serialize.js";
/**
* @constructor
* @implements IndexInterface
* @param {Object=} options
* @param {Object=} _register
* @return {Index}
*/
function Index(options, _register) {
if (!(this instanceof Index)) {
return new Index(options);
}
let charset, lang, tmp;
if (options) {
options = apply_preset(options);
charset = options.charset;
lang = options.lang;
if (is_string(charset)) {
if (-1 === charset.indexOf(":")) {
charset += ":default";
}
charset = global_charset[charset];
}
if (is_string(lang)) {
lang = global_lang[lang];
}
} else {
options = {};
}
let resolution,
optimize,
context = options.context || {};
this.encode = options.encode || charset && charset.encode || default_encoder;
this.register = _register || create_object();
this.resolution = resolution = options.resolution || 9;
this.tokenize = tmp = charset && charset.tokenize || options.tokenize || "strict";
this.depth = "strict" === tmp && context.depth;
this.bidirectional = parse_option(context.bidirectional, /* append: */ /* skip update: */ /* skip_update: */!0);
this.optimize = optimize = parse_option(options.optimize, !0);
this.fastupdate = parse_option(options.fastupdate, !0);
this.minlength = options.minlength || 1;
this.boost = options.boost;
// when not using the memory strategy the score array should not pre-allocated to its full length
this.map = optimize ? create_object_array(resolution) : create_object();
this.resolution_ctx = resolution = context.resolution || 1;
this.ctx = optimize ? create_object_array(resolution) : create_object();
this.rtl = charset && charset.rtl || options.rtl;
this.matcher = (tmp = options.matcher || lang && lang.matcher) && init_stemmer_or_matcher(tmp, !1);
this.stemmer = (tmp = options.stemmer || lang && lang.stemmer) && init_stemmer_or_matcher(tmp, !0);
this.filter = (tmp = options.filter || lang && lang.filter) && init_filter(tmp);
this.cache = (tmp = options.cache) && new Cache(tmp);
}
export default Index;
//Index.prototype.pipeline = pipeline;
/**
* @param {!number|string} id
* @param {!string} content
*/
Index.prototype.append = function (id, content) {
return this.add(id, content, !0);
};
// TODO:
// string + number as text
// boolean, null, undefined as ?
/**
* @param {!number|string} id
* @param {!string} content
* @param {boolean=} _append
* @param {boolean=} _skip_update
*/
Index.prototype.add = function (id, content, _append, _skip_update) {
if (content && (id || 0 === id)) {
if (!_skip_update && !_append && this.register[id]) {
return this.update(id, content);
}
content = this.encode("" + content);
const length = content.length;
if (length) {
// check context dupes to skip all contextual redundancy along a document
const dupes_ctx = create_object(),
dupes = create_object(),
depth = this.depth,
resolution = this.resolution;
for (let i = 0; i < length; i++) {
let term = content[this.rtl ? length - 1 - i : i],
term_length = term.length;
// skip dupes will break the context chain
if (term && term_length >= this.minlength && (depth || !dupes[term])) {
let score = get_score(resolution, length, i),
token = "";
switch (this.tokenize) {
case "full":
if (2 < term_length) {
for (let x = 0; x < term_length; x++) {
for (let y = term_length; y > x; y--) {
if (y - x >= this.minlength) {
const partial_score = get_score(resolution, length, i, term_length, x);
token = term.substring(x, y);
this.push_index(dupes, token, partial_score, id, _append);
}
}
}
break;
}
// fallthrough to next case when term length < 3
case "reverse":
// skip last round (this token exist already in "forward")
if (1 < term_length) {
for (let x = term_length - 1; 0 < x; x--) {
token = term[x] + token;
if (token.length >= this.minlength) {
const partial_score = get_score(resolution, length, i, term_length, x);
this.push_index(dupes, token, partial_score, id, _append);
}
}
token = "";
}
// fallthrough to next case to apply forward also
case "forward":
if (1 < term_length) {
for (let x = 0; x < term_length; x++) {
token += term[x];
if (token.length >= this.minlength) {
this.push_index(dupes, token, score, id, _append);
}
}
break;
}
// fallthrough to next case when token has a length of 1
default:
// case "strict":
if (this.boost) {
score = Math.min(0 | score / this.boost(content, term, i), resolution - 1);
}
this.push_index(dupes, term, score, id, _append);
// context is just supported by tokenizer "strict"
if (depth) {
if (1 < length && i < length - 1) {
// check inner dupes to skip repeating words in the current context
const dupes_inner = create_object(),
resolution = this.resolution_ctx,
keyword = term,
size = Math.min(depth + 1, length - i);
dupes_inner[keyword] = 1;
for (let x = 1; x < size; x++) {
term = content[this.rtl ? length - 1 - i - x : i + x];
if (term && term.length >= this.minlength && !dupes_inner[term]) {
dupes_inner[term] = 1;
const context_score = get_score(resolution + (length / 2 > resolution ? 0 : 1), length, i, size - 1, x - 1),
swap = this.bidirectional && term > keyword;
this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword);
}
}
}
}
}
}
}
this.fastupdate || (this.register[id] = 1);
}
}
return this;
};
/**
* @param {number} resolution
* @param {number} length
* @param {number} i
* @param {number=} term_length
* @param {number=} x
* @returns {number}
*/
function get_score(resolution, length, i, term_length, x) {
// console.log("resolution", resolution);
// console.log("length", length);
// console.log("term_length", term_length);
// console.log("i", i);
// console.log("x", x);
// console.log((resolution - 1) / (length + (term_length || 0)) * (i + (x || 0)) + 1);
// the first resolution slot is reserved for the best match,
// when a query matches the first word(s).
// also to stretch score to the whole range of resolution, the
// calculation is shift by one and cut the floating point.
// this needs the resolution "1" to be handled additionally.
// do not stretch the resolution more than the term length will
// improve performance and memory, also it improves scoring in
// most cases between a short document and a long document
return i && 1 < resolution ? length + (term_length || 0) <= resolution ? i + (x || 0) : 0 | (resolution - 1) / (length + (term_length || 0)) * (i + (x || 0)) + 1 : 0;
}
/**
* @private
* @param dupes
* @param value
* @param score
* @param id
* @param {boolean=} append
* @param {string=} keyword
*/
Index.prototype.push_index = function (dupes, value, score, id, append, keyword) {
let arr = keyword ? this.ctx : this.map;
if (!dupes[value] || keyword && !dupes[value][keyword]) {
if (this.optimize) {
arr = arr[score];
}
if (keyword) {
dupes = dupes[value] || (dupes[value] = create_object());
dupes[keyword] = 1;
arr = arr[keyword] || (arr[keyword] = create_object());
} else {
dupes[value] = 1;
}
arr = arr[value] || (arr[value] = []);
if (!this.optimize) {
arr = arr[score] || (arr[score] = []);
}
if (!append || !arr.includes(id)) {
arr[arr.length] = id;
// add a reference to the register for fast updates
if (this.fastupdate) {
const tmp = this.register[id] || (this.register[id] = []);
tmp[tmp.length] = arr;
}
}
}
};
/**
* @param {string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @returns {Array<number|string>}
*/
Index.prototype.search = function (query, limit, options) {
if (!options) {
if (!limit && is_object(query)) {
options = /** @type {Object} */query;
query = options.query;
} else if (is_object(limit)) {
options = /** @type {Object} */limit;
}
}
let result = [],
length,
context,
suggest,
offset = 0;
if (options) {
query = options.query || query;
limit = options.limit;
offset = options.offset || 0;
context = options.context;
suggest = options.suggest;
}
if (query) {
query = /** @type {Array} */this.encode("" + query);
length = query.length;
// TODO: solve this in one single loop below
if (1 < length) {
const dupes = create_object(),
query_new = [];
for (let i = 0, count = 0, term; i < length; i++) {
term = query[i];
if (term && term.length >= this.minlength && !dupes[term]) {
// this fast path can just apply when not in memory-optimized mode
if (!this.optimize && !suggest && !this.map[term]) {
// fast path "not found"
return result;
} else {
query_new[count++] = term;
dupes[term] = 1;
}
}
}
query = query_new;
length = query.length;
}
}
if (!length) {
return result;
}
limit || (limit = 100);
let depth = this.depth && 1 < length && !1 !== context,
index = 0,
keyword;
if (depth) {
keyword = query[0];
index = 1;
} else {
if (1 < length) {
query.sort(sort_by_length_down);
}
}
for (let arr, term; index < length; index++) {
term = query[index];
// console.log(keyword);
// console.log(term);
// console.log("");
if (depth) {
arr = this.add_result(result, suggest, limit, offset, 2 === length, term, keyword);
// console.log(arr);
// console.log(result);
// when suggestion enabled just forward keyword if term was found
// as long as the result is empty forward the pointer also
if (!suggest || !1 !== arr || !result.length) {
keyword = term;
}
} else {
arr = this.add_result(result, suggest, limit, offset, 1 === length, term);
}
if (arr) {
return (/** @type {Array<number|string>} */arr
);
}
// apply suggestions on last loop or fallback
if (suggest && index == length - 1) {
let length = result.length;
if (!length) {
if (depth) {
// fallback to non-contextual search when no result was found
depth = 0;
index = -1;
continue;
}
return result;
} else if (1 === length) {
// fast path optimization
return single_result(result[0], limit, offset);
}
}
}
return intersect(result, limit, offset, suggest);
};
/**
* Returns an array when the result is done (to stop the process immediately),
* returns false when suggestions is enabled and no result was found,
* or returns nothing when a set was pushed successfully to the results
*
* @private
* @param {Array} result
* @param {Array} suggest
* @param {number} limit
* @param {number} offset
* @param {boolean} single_term
* @param {string} term
* @param {string=} keyword
* @return {Array<Array<string|number>>|boolean|undefined}
*/
Index.prototype.add_result = function (result, suggest, limit, offset, single_term, term, keyword) {
let word_arr = [],
arr = keyword ? this.ctx : this.map;
if (!this.optimize) {
arr = get_array(arr, term, keyword, this.bidirectional);
}
if (arr) {
let count = 0;
const arr_len = Math.min(arr.length, keyword ? this.resolution_ctx : this.resolution);
// relevance:
for (let x = 0, size = 0, tmp, len; x < arr_len; x++) {
tmp = arr[x];
if (tmp) {
if (this.optimize) {
tmp = get_array(tmp, term, keyword, this.bidirectional);
}
if (offset) {
if (tmp && single_term) {
len = tmp.length;
if (len <= offset) {
offset -= len;
tmp = null;
} else {
tmp = tmp.slice(offset);
offset = 0;
}
}
}
if (tmp) {
// keep score (sparse array):
//word_arr[x] = tmp;
// simplified score order:
word_arr[count++] = tmp;
if (single_term) {
size += tmp.length;
if (size >= limit) {
// fast path optimization
break;
}
}
}
}
}
if (count) {
if (single_term) {
// fast path optimization
// offset was already applied at this point
return single_result(word_arr, limit, 0);
}
result[result.length] = word_arr;
return;
}
}
// return an empty array will stop the loop,
// to prevent stop when using suggestions return a false value
return !suggest && word_arr;
};
function single_result(result, limit, offset) {
if (1 === result.length) {
result = result[0];
} else {
result = concat(result);
}
return offset || result.length > limit ? result.slice(offset, offset + limit) : result;
}
function get_array(arr, term, keyword, bidirectional) {
if (keyword) {
// the frequency of the starting letter is slightly less
// on the last half of the alphabet (m-z) in almost every latin language,
// so we sort downwards (https://en.wikipedia.org/wiki/Letter_frequency)
const swap = bidirectional && term > keyword;
arr = arr[swap ? term : keyword];
arr = arr && arr[swap ? keyword : term];
} else {
arr = arr[term];
}
return arr;
}
Index.prototype.contain = function (id) {
return !!this.register[id];
};
Index.prototype.update = function (id, content) {
return this.remove(id).add(id, content);
};
/**
* @param {boolean=} _skip_deletion
*/
Index.prototype.remove = function (id, _skip_deletion) {
const refs = this.register[id];
if (refs) {
if (this.fastupdate) {
// fast updates performs really fast but did not fully cleanup the key entries
for (let i = 0, tmp; i < refs.length; i++) {
tmp = refs[i];
tmp.splice(tmp.indexOf(id), 1);
}
} else {
remove_index(this.map, id, this.resolution, this.optimize);
if (this.depth) {
remove_index(this.ctx, id, this.resolution_ctx, this.optimize);
}
}
_skip_deletion || delete this.register[id];
if (this.cache) {
this.cache.del(id);
}
}
return this;
};
/**
* @param map
* @param id
* @param res
* @param optimize
* @param {number=} resolution
* @return {number}
*/
function remove_index(map, id, res, optimize, resolution) {
let count = 0;
if (is_array(map)) {
// the first array is the score array in both strategies
if (!resolution) {
resolution = Math.min(map.length, res);
for (let x = 0, arr; x < resolution; x++) {
arr = map[x];
if (arr) {
count = remove_index(arr, id, res, optimize, resolution);
if (!optimize && !count) {
// when not memory optimized the score index should removed
delete map[x];
}
}
}
} else {
const pos = map.indexOf(id);
if (-1 !== pos) {
// fast path, when length is 1 or lower then the whole field gets deleted
if (1 < map.length) {
map.splice(pos, 1);
count++;
}
} else {
count++;
}
}
} else {
for (let key in map) {
count = remove_index(map[key], id, res, optimize, resolution);
if (!count) {
delete map[key];
}
}
}
return count;
}
Index.prototype.searchCache = searchCache;
Index.prototype.export = exportIndex;
Index.prototype.import = importIndex;
apply_async(Index.prototype);

View File

@@ -0,0 +1,394 @@
import { create_object, concat } from "./common.js";
/**
* Implementation based on Array.includes() provides better performance,
* but it needs at least one word in the query which is less frequent.
* Also on large indexes it does not scale well performance-wise.
* This strategy also lacks of suggestion capabilities (matching & sorting).
*
* @param arrays
* @param limit
* @param offset
* @param {boolean|Array=} suggest
* @returns {Array}
*/
// export function intersect(arrays, limit, offset, suggest) {
//
// const length = arrays.length;
// let result = [];
// let check;
//
// // determine shortest array and collect results
// // from the sparse relevance arrays
//
// let smallest_size;
// let smallest_arr;
// let smallest_index;
//
// for(let x = 0; x < length; x++){
//
// const arr = arrays[x];
// const len = arr.length;
//
// let size = 0;
//
// for(let y = 0, tmp; y < len; y++){
//
// tmp = arr[y];
//
// if(tmp){
//
// size += tmp.length;
// }
// }
//
// if(!smallest_size || (size < smallest_size)){
//
// smallest_size = size;
// smallest_arr = arr;
// smallest_index = x;
// }
// }
//
// smallest_arr = smallest_arr.length === 1 ?
//
// smallest_arr[0]
// :
// concat(smallest_arr);
//
// if(suggest){
//
// suggest = [smallest_arr];
// check = create_object();
// }
//
// let size = 0;
// let steps = 0;
//
// // process terms in reversed order often results in better performance.
// // the outer loop must be the words array, using the
// // smallest array here disables the "fast fail" optimization.
//
// for(let x = length - 1; x >= 0; x--){
//
// if(x !== smallest_index){
//
// steps++;
//
// const word_arr = arrays[x];
// const word_arr_len = word_arr.length;
// const new_arr = [];
//
// let count = 0;
//
// for(let z = 0, id; z < smallest_arr.length; z++){
//
// id = smallest_arr[z];
//
// let found;
//
// // process relevance in forward order (direction is
// // important for adding IDs during the last round)
//
// for(let y = 0; y < word_arr_len; y++){
//
// const arr = word_arr[y];
//
// if(arr.length){
//
// found = arr.includes(id);
//
// if(found){
//
// // check if in last round
//
// if(steps === length - 1){
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[size++] = id;
//
// if(size === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
//
// if(suggest){
//
// check[id] = 1;
// }
// }
//
// break;
// }
// }
// }
//
// if(found){
//
// new_arr[count++] = id;
// }
// }
//
// if(suggest){
//
// suggest[steps] = new_arr;
// }
// else if(!count){
//
// return [];
// }
//
// smallest_arr = new_arr;
// }
// }
//
// if(suggest){
//
// // needs to iterate in reverse direction
//
// for(let x = suggest.length - 1, arr, len; x >= 0; x--){
//
// arr = suggest[x];
// len = arr && arr.length;
//
// if(len){
//
// for(let y = 0, id; y < len; y++){
//
// id = arr[y];
//
// if(!check[id]){
//
// check[id] = 1;
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[size++] = id;
//
// if(size === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
// }
// }
// }
// }
// }
//
// return result;
// }
/**
* Implementation based on Object[key] provides better suggestions
* capabilities and has less performance scaling issues on large indexes.
*
* @param arrays
* @param limit
* @param offset
* @param {boolean|Array=} suggest
* @returns {Array}
*/
export function intersect(arrays, limit, offset, suggest) {
const length = arrays.length;
let result = [],
check,
check_suggest,
size = 0;
if (suggest) {
suggest = [];
}
// process terms in reversed order often has advantage for the fast path "end reached".
// also a reversed order prioritize the order of words from a query.
for (let x = length - 1; 0 <= x; x--) {
const word_arr = arrays[x],
word_arr_len = word_arr.length,
check_new = create_object();
let found = !check;
// process relevance in forward order (direction is
// important for adding IDs during the last round)
for (let y = 0; y < word_arr_len; y++) {
const arr = word_arr[y],
arr_len = arr.length;
if (arr_len) {
// loop through IDs
for (let z = 0, check_idx, id; z < arr_len; z++) {
id = arr[z];
if (check) {
if (check[id]) {
// check if in last round
if (!x) {
if (offset) {
offset--;
} else {
result[size++] = id;
if (size === limit) {
// fast path "end reached"
return result;
}
}
}
if (x || suggest) {
check_new[id] = 1;
}
found = /* append: */ /* skip update: */ /* skip_update: */!0;
}
if (suggest) {
check_idx = (check_suggest[id] || 0) + 1;
check_suggest[id] = check_idx;
// do not adding IDs which are already included in the result (saves one loop)
// the first intersection match has the check index 2, so shift by -2
if (check_idx < length) {
const tmp = suggest[check_idx - 2] || (suggest[check_idx - 2] = []);
tmp[tmp.length] = id;
}
}
} else {
// pre-fill in first round
check_new[id] = 1;
}
}
}
}
if (suggest) {
// re-use the first pre-filled check for suggestions
check || (check_suggest = check_new);
} else if (!found) {
return [];
}
check = check_new;
}
if (suggest) {
// needs to iterate in reverse direction
for (let x = suggest.length - 1, arr, len; 0 <= x; x--) {
arr = suggest[x];
len = arr.length;
for (let y = 0, id; y < len; y++) {
id = arr[y];
if (!check[id]) {
if (offset) {
offset--;
} else {
result[size++] = id;
if (size === limit) {
// fast path "end reached"
return result;
}
}
check[id] = 1;
}
}
}
}
return result;
}
/**
* @param mandatory
* @param arrays
* @returns {Array}
*/
export function intersect_union(mandatory, arrays) {
const check = create_object(),
union = create_object(),
result = [];
for (let x = 0; x < mandatory.length; x++) {
check[mandatory[x]] = 1;
}
for (let x = 0, arr; x < arrays.length; x++) {
arr = arrays[x];
for (let y = 0, id; y < arr.length; y++) {
id = arr[y];
if (check[id]) {
if (!union[id]) {
union[id] = 1;
result[result.length] = id;
}
}
}
}
return result;
}

View File

@@ -0,0 +1,321 @@
import { IndexInterface } from "./type.js";
import { create_object, get_keys } from "./common.js";
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} _collapse
* @returns {string|Array<string>}
* @this IndexInterface
*/
export function pipeline(str, normalize, split, _collapse) {
if (str) {
if (normalize) {
str = replace(str, /** @type {Array<string|RegExp>} */normalize);
}
if (this.matcher) {
str = replace(str, this.matcher);
}
if (this.stemmer && 1 < str.length) {
str = replace(str, this.stemmer);
}
if (_collapse && 1 < str.length) {
str = collapse(str);
}
if (split || "" === split) {
const words = str.split( /** @type {string|RegExp} */split);
return this.filter ? filter(words, this.filter) : words;
}
}
return str;
}
// TODO improve normalize + remove non-delimited chars like in "I'm" + split on whitespace+
export const regex_whitespace = /[\p{Z}\p{S}\p{P}\p{C}]+/u;
// https://github.com/nextapps-de/flexsearch/pull/414
//export const regex_whitespace = /[\s\xA0\u2000-\u200B\u2028\u2029\u3000\ufeff!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/
const regex_normalize = /[\u0300-\u036f]/g;
export function normalize(str) {
if (str.normalize) {
str = str.normalize("NFD").replace(regex_normalize, "");
}
return str;
}
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} _collapse
* @returns {string|Array<string>}
*/
// FlexSearch.prototype.pipeline = function(str, normalize, split, _collapse){
//
// if(str){
//
// if(normalize && str){
//
// str = replace(str, /** @type {Array<string|RegExp>} */ (normalize));
// }
//
// if(str && this.matcher){
//
// str = replace(str, this.matcher);
// }
//
// if(this.stemmer && str.length > 1){
//
// str = replace(str, this.stemmer);
// }
//
// if(_collapse && str.length > 1){
//
// str = collapse(str);
// }
//
// if(str){
//
// if(split || (split === "")){
//
// const words = str.split(/** @type {string|RegExp} */ (split));
//
// return this.filter ? filter(words, this.filter) : words;
// }
// }
// }
//
// return str;
// };
// export function pipeline(str, normalize, matcher, stemmer, split, _filter, _collapse){
//
// if(str){
//
// if(normalize && str){
//
// str = replace(str, normalize);
// }
//
// if(matcher && str){
//
// str = replace(str, matcher);
// }
//
// if(stemmer && str.length > 1){
//
// str = replace(str, stemmer);
// }
//
// if(_collapse && str.length > 1){
//
// str = collapse(str);
// }
//
// if(str){
//
// if(split !== false){
//
// str = str.split(split);
//
// if(_filter){
//
// str = filter(str, _filter);
// }
// }
// }
// }
//
// return str;
// }
/**
* @param {Array<string>} words
* @returns {Object<string, string>}
*/
export function init_filter(words) {
const filter = create_object();
for (let i = 0, length = words.length; i < length; i++) {
filter[words[i]] = 1;
}
return filter;
}
/**
* @param {!Object<string, string>} obj
* @param {boolean} is_stemmer
* @returns {Array}
*/
export function init_stemmer_or_matcher(obj, is_stemmer) {
const keys = get_keys(obj),
length = keys.length,
final = [];
let removal = "",
count = 0;
for (let i = 0, key, tmp; i < length; i++) {
key = keys[i];
tmp = obj[key];
if (tmp) {
final[count++] = regex(is_stemmer ? "(?!\\b)" + key + "(\\b|_)" : key);
final[count++] = tmp;
} else {
removal += (removal ? "|" : "") + key;
}
}
if (removal) {
final[count++] = regex(is_stemmer ? "(?!\\b)(" + removal + ")(\\b|_)" : "(" + removal + ")");
final[count] = "";
}
return final;
}
/**
* @param {!string} str
* @param {Array} regexp
* @returns {string}
*/
export function replace(str, regexp) {
for (let i = 0, len = regexp.length; i < len; i += 2) {
str = str.replace(regexp[i], regexp[i + 1]);
if (!str) {
break;
}
}
return str;
}
/**
* @param {!string} str
* @returns {RegExp}
*/
export function regex(str) {
return new RegExp(str, "g");
}
/**
* Regex: replace(/(?:(\w)(?:\1)*)/g, "$1")
* @param {!string} string
* @returns {string}
*/
export function collapse(string) {
let final = "",
prev = "";
for (let i = 0, len = string.length, char; i < len; i++) {
if ((char = string[i]) !== prev) {
final += prev = char;
}
}
return final;
}
// TODO using fast-swap
export function filter(words, map) {
const length = words.length,
filtered = [];
for (let i = 0, count = 0; i < length; i++) {
const word = words[i];
if (word && !map[word]) {
filtered[count++] = word;
}
}
return filtered;
}
// const chars = {a:1, e:1, i:1, o:1, u:1, y:1};
//
// function collapse_repeating_chars(string){
//
// let collapsed_string = "",
// char_prev = "",
// char_next = "";
//
// for(let i = 0; i < string.length; i++){
//
// const char = string[i];
//
// if(char !== char_prev){
//
// if(i && (char === "h")){
//
// if((chars[char_prev] && chars[char_next]) || (char_prev === " ")){
//
// collapsed_string += char;
// }
// }
// else{
//
// collapsed_string += char;
// }
// }
//
// char_next = (
//
// (i === (string.length - 1)) ?
//
// ""
// :
// string[i + 1]
// );
//
// char_prev = char;
// }
//
// return collapsed_string;
// }

View File

@@ -0,0 +1,27 @@
import { IndexInterface } from "../../type.js";
import { pipeline } from "../../lang.js";
export const rtl = /* append: */ /* skip update: */ /* skip_update: */!0;
export const tokenize = "";
export default {
encode: encode,
rtl: !0
};
const regex = /[\x00-\x7F]+/g,
split = /\s+/;
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
return pipeline.call(this,
/* string: */("" + str).replace(regex, " "),
/* normalize: */
/* collapse: */!1,
/* split: */split, !1);
}

View File

@@ -0,0 +1,41 @@
/**
* http://www.ranks.nl/stopwords
* @type {Array<string>}
*/
export const filter = ["aber", "als", "am", "an", "auch", "auf", "aus", "bei", "bin", "bis", "bist", "da", "dadurch", "daher", "darum", "das", "daß", "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", "für", "hatte", "hatten", "hattest", "hattet", "hier", "hinter", "ich", "ihr", "ihre", "im", "in", "ist", "ja", "jede", "jedem", "jeden", "jeder", "jedes", "jener", "jenes", "jetzt", "kann", "kannst", "können", "könnt", "machen", "mein", "meine", "mit", "muß", "mußt", "musst", "müssen", "müßt", "nach", "nachdem", "nein", "nicht", "nun", "oder", "seid", "sein", "seine", "sich", "sie", "sind", "soll", "sollen", "sollst", "sollt", "sonst", "soweit", "sowie", "und", "unser", "unsere", "unter", "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", "über"];
/**
* @type {Object<string, string>}
*/
export const stemmer = {
niss: "",
isch: "",
lich: "",
heit: "",
keit: "",
end: "",
ung: "",
est: "",
ern: "",
em: "",
er: "",
en: "",
es: "",
st: "",
ig: "",
ik: "",
e: "",
s: ""
};
export const matcher = {};
export default {
filter: filter,
stemmer: stemmer,
matcher: matcher
};

View File

@@ -0,0 +1,26 @@
import { IndexInterface } from "../../type.js";
import { pipeline } from "../../lang.js";
export const rtl = /* normalize: */ /* collapse: */
/* normalize: */
/* collapse: */!1;
export const tokenize = "strict";
export default {
encode: encode,
rtl: !1,
tokenize: "strict"
};
const regex = /[\x00-\x7F]+/g;
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
return pipeline.call(this,
/* string: */("" + str).replace(regex, ""), !1,
/* split: */"", !1);
}

View File

@@ -0,0 +1,27 @@
import { IndexInterface } from "../../type.js";
import { pipeline } from "../../lang.js";
export const rtl = /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */
/* normalize: */
/* collapse: */!1;
export const tokenize = "";
export default {
encode: encode,
rtl: !1
};
const regex = /[\x00-\x7F]+/g,
split = /\s+/;
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
return pipeline.call(this,
/* string: */("" + str).replace(regex, " "), !1,
/* split: */split, !1);
}

View File

@@ -0,0 +1,54 @@
/**
* Filter are also known as "stopwords", they completely filter out words from being indexed.
* Source: http://www.ranks.nl/stopwords
* Object Definition: Just provide an array of words.
* @type {Array<string>}
*/
export const filter = ["aber", "als", "am", "an", "auch", "auf", "aus", "bei", "bin", "bis", "bist", "da", "dadurch", "daher", "darum", "das", "daß", "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", "für", "hatte", "hatten", "hattest", "hattet", "hier", "hinter", "ich", "ihr", "ihre", "im", "in", "ist", "ja", "jede", "jedem", "jeden", "jeder", "jedes", "jener", "jenes", "jetzt", "kann", "kannst", "können", "könnt", "machen", "mein", "meine", "mit", "muß", "mußt", "musst", "müssen", "müßt", "nach", "nachdem", "nein", "nicht", "nun", "oder", "seid", "sein", "seine", "sich", "sie", "sind", "soll", "sollen", "sollst", "sollt", "sonst", "soweit", "sowie", "und", "unser", "unsere", "unter", "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", "über"];
/**
* Stemmer removes word endings and is a kind of "partial normalization". A word ending just matched when the word length is bigger than the matched partial.
* Example: The word "correct" and "correctness" could be the same word, so you can define {"ness": ""} to normalize the ending.
* Object Definition: the key represents the word ending, the value contains the replacement (or empty string for removal).
* @type {Object<string, string>}
*/
export const stemmer = {
niss: "",
isch: "",
lich: "",
heit: "",
keit: "",
ell: "",
bar: "",
end: "",
ung: "",
est: "",
ern: "",
em: "",
er: "",
en: "",
es: "",
st: "",
ig: "",
ik: "",
e: "",
s: ""
};
/**
* Matcher replaces all occurrences of a given string regardless of its position and is also a kind of "partial normalization".
* Object Definition: the key represents the target term, the value contains the search string which should be replaced (could also be an array of multiple terms).
* @type {Object<string, Array<string>|string>}
*/
export const matcher = {};
export default {
filter: filter,
stemmer: stemmer,
matcher: matcher
};

View File

@@ -0,0 +1,100 @@
/**
* http://www.ranks.nl/stopwords
* @type {Array<string>}
*/
export const filter = ["a", "about", "above", "after", "again", "against", "all", "also", "am", "an", "and", "any", "are", "aren't", "as", "at",
//"back",
"be", "because", "been", "before", "being", "below",
//"between",
"both", "but", "by", "can", "cannot", "can't", "come", "could", "couldn't",
//"day",
"did", "didn't", "do", "does", "doesn't", "doing", "dont", "down", "during", "each", "even", "few", "first", "for", "from", "further", "get",
//"give",
"go",
//"good",
"had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "hed",
//"hell",
"her", "here", "here's", "hers", "herself", "hes", "him", "himself", "his", "how", "how's", "i", "id", "if", "ill", "im", "in", "into", "is", "isn't", "it", "it's", "itself", "i've", "just", "know", "let's", "like",
//"look",
"make", "me", "more", "most", "mustn't", "my", "myself", "new", "no", "nor", "not", "now", "of", "off", "on", "once",
//"one",
"only", "or", "other", "ought", "our", "our's", "ourselves", "out", "over", "own",
//"people",
"same", "say", "see", "shan't", "she", "she'd", "shell", "shes", "should", "shouldn't", "so", "some", "such",
//"take",
"than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've",
//"think",
"this", "those", "through", "time", "to", "too",
//"two",
//"under",
"until", "up", "us",
//"use",
"very", "want", "was", "wasn't", "way", "we", "wed", "well", "were", "weren't", "we've", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "whom", "who's", "why", "why's", "will", "with", "won't",
//"work",
"would", "wouldn't",
//"year",
"you", "you'd", "you'll", "your", "you're", "your's", "yourself", "yourselves", "you've"];
/**
* @type {Object<string, string>}
*/
export const stemmer = {
ational: "ate",
iveness: "ive",
fulness: "ful",
ousness: "ous",
ization: "ize",
tional: "tion",
biliti: "ble",
icate: "ic",
ative: "",
alize: "al",
iciti: "ic",
entli: "ent",
ousli: "ous",
alism: "al",
ation: "ate",
aliti: "al",
iviti: "ive",
ement: "",
enci: "ence",
anci: "ance",
izer: "ize",
alli: "al",
ator: "ate",
logi: "log",
ical: "ic",
ance: "",
ence: "",
ness: "",
able: "",
ible: "",
ment: "",
eli: "e",
bli: "ble",
ful: "",
ant: "",
ent: "",
ism: "",
ate: "",
iti: "",
ous: "",
ive: "",
ize: "",
al: "",
ou: "",
er: "",
ic: ""
};
export const matcher = {};
export default {
filter: filter,
stemmer: stemmer,
matcher: matcher
};

View File

@@ -0,0 +1,89 @@
import { IndexInterface } from "../../type.js";
import { regex, replace, collapse } from "../../lang.js";
import { encode as encode_balance } from "./balance.js";
export const rtl = /* normalize: */
/* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */!1;
export const tokenize = "";
export default {
encode: encode,
rtl: !1,
tokenize: ""
// Phonetic Normalization
};const regex_ae = regex("ae"),
//regex_ai = regex("ai"),
//regex_ay = regex("ay"),
//regex_ey = regex("ey"),
regex_oe = regex("oe"),
//regex_ue = regex("ue"),
//regex_ie = regex("ie"),
//regex_sz = regex("sz"),
//regex_zs = regex("zs"),
//regex_ck = regex("ck"),
//regex_cc = regex("cc"),
regex_sh = regex("sh"),
regex_th = regex("th"),
//regex_dt = regex("dt"),
regex_ph = regex("ph"),
regex_pf = regex("pf"),
pairs = [regex_ae, "a",
// regex_ai, "ei",
// regex_ay, "ei",
// regex_ey, "ei",
regex_oe, "o",
// regex_ue, "u",
// regex_ie, "i",
// regex_sz, "s",
// regex_zs, "s",
regex_sh, "s",
// regex_ck, "k",
// regex_cc, "k",
regex_th, "t",
// regex_dt, "t",
regex_ph, "f", regex_pf, "f",
// regex_ou, "o",
// regex_uo, "u"
// regex("(?![aeiouy])h(?![aeiouy])"), "",
// regex("(?!^[aeiouy])h(?!^[aeiouy])"), ""
regex("(?![aeo])h(?![aeo])"), "", regex("(?!^[aeo])h(?!^[aeo])"), ""];
//regex_ou = regex("ou"),
//regex_uo = regex("uo");
/**
* @param {string|number} str
* @param {boolean=} _skip_postprocessing
* @this IndexInterface
*/
export function encode(str, _skip_postprocessing) {
if (str) {
str = encode_balance.call(this, str).join(" ");
if (2 < str.length) {
str = replace(str, pairs);
}
if (!_skip_postprocessing) {
if (1 < str.length) {
str = collapse(str);
}
if (str) {
str = str.split(" ");
}
}
}
return str || [];
}

View File

@@ -0,0 +1,119 @@
import { IndexInterface } from "../../type.js";
import { encode as encode_simple } from "./simple.js";
// custom soundex implementation
export const rtl = /* normalize: */ /* collapse: */
/* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */!1;
export const tokenize = "strict";
export default {
encode: encode,
rtl: !1,
tokenize: "strict"
//const regex_whitespace = /[\W_]+/g;
};const regex_strip = /[^a-z0-9]+/,
soundex = {
b: "p",
//"p": "p",
//"f": "f",
v: "f", w: "f",
//"s": "s",
z: "s",
x: "s",
ß: "s",
d: "t",
//"t": "t",
//"l": "l",
//"m": "m",
n: "m",
c: "k",
g: "k",
j: "k",
//"k": "k",
q: "k",
//"r": "r",
//"h": "h",
//"a": "a",
//"e": "e",
i: "e",
y: "e",
//"o": "o",
u: "o"
};
// const pairs = [
// regex_whitespace, " ",
// regex_strip, ""
// ];
// modified
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
str = encode_simple.call(this, str).join(" ");
// str = this.pipeline(
//
// /* string: */ normalize("" + str).toLowerCase(),
// /* normalize: */ false,
// /* split: */ false,
// /* collapse: */ false
// );
const result = [];
if (str) {
const words = str.split(regex_strip),
length = words.length;
for (let x = 0, tmp, count = 0; x < length; x++) {
if ((str = words[x]) && ( /*&& (str.length > 2)*/!this.filter || !this.filter[str])) {
tmp = str[0];
let code = soundex[tmp] || tmp,
previous = code; //str[0];
//soundex[code] || code;
for (let i = 1; i < str.length; i++) {
tmp = str[i];
const current = soundex[tmp] || tmp;
if (current && current !== previous) {
code += current;
previous = current;
// if(code.length === 7){
//
// break;
// }
}
}
result[count++] = code; //(code + "0000").substring(0, 4);
}
}
}
return result;
}

View File

@@ -0,0 +1,23 @@
import { IndexInterface } from "../../type.js";
import { pipeline, normalize, regex_whitespace } from "../../lang.js";
export const rtl = /* normalize: */
/* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */
/* normalize: */
/* collapse: */!1;
export const tokenize = "";
export default {
encode: encode,
rtl: !1,
tokenize: ""
/**
* @param {string|number} str
* @this IndexInterface
*/
};export function encode(str) {
return pipeline.call(this,
/* string: */("" + str).toLowerCase(), !1, /* split: */regex_whitespace, !1);
}

View File

@@ -0,0 +1,65 @@
import { IndexInterface } from "../../type.js";
import { regex, replace, collapse } from "../../lang.js";
import { encode as encode_advanced } from "./advanced.js";
export const rtl = /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */!1;
export const tokenize = "";
export default {
encode: encode,
rtl: !1,
tokenize: ""
// Soundex Normalization
};const prefix = "(?!\\b)",
//soundex_b = regex(prefix + "p"),
// soundex_s = regex(prefix + "z"),
// soundex_k = regex(prefix + "[cgq]"),
// soundex_m = regex(prefix + "n"),
// soundex_t = regex(prefix + "d"),
// soundex_f = regex(prefix + "[vw]"),
//regex_vowel = regex(prefix + "[aeiouy]");
regex_vowel = regex("(?!\\b)[aeo]"),
pairs = [
// soundex_b, "b",
// soundex_s, "s",
// soundex_k, "k",
// soundex_m, "m",
// soundex_t, "t",
// soundex_f, "f",
// regex("(?![aeiouy])h(?![aeiouy])"), "",
// regex("(?!^[aeiouy])h(?!^[aeiouy])"), "",
regex_vowel, ""];
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
if (str) {
str = encode_advanced.call(this, str, /* append: */ /* skip update: */ /* skip_update: */ /* skip post-processing: */!0);
if (1 < str.length) {
//str = replace(str, pairs);
str = str.replace(regex_vowel, "");
}
if (1 < str.length) {
str = collapse(str);
}
if (str) {
str = str.split(" ");
}
}
return str || [];
}

View File

@@ -0,0 +1,45 @@
import { IndexInterface } from "../../type.js";
import { pipeline, normalize, regex_whitespace, regex } from "../../lang.js";
export const rtl = /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */
/* collapse: */!1;
export const tokenize = "";
export default {
encode: encode,
rtl: !1,
tokenize: ""
// Charset Normalization
};const //regex_whitespace = /\W+/,
//regex_strip = regex("[^a-z0-9 ]"),
regex_a = regex("[àáâãäå]"),
regex_e = regex("[èéêë]"),
regex_i = regex("[ìíîï]"),
regex_o = regex("[òóôõöő]"),
regex_u = regex("[ùúûüű]"),
regex_y = regex("[ýŷÿ]"),
regex_n = regex("ñ"),
regex_c = regex("[çc]"),
regex_s = regex("ß"),
regex_and = regex(" & "),
pairs = [regex_a, "a", regex_e, "e", regex_i, "i", regex_o, "o", regex_u, "u", regex_y, "y", regex_n, "n", regex_c, "k", regex_s, "s", regex_and, " and "
//regex_whitespace, " "
//regex_strip, ""
];
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
str = "" + str;
return pipeline.call(this,
/* string: */normalize(str).toLowerCase(),
/* normalize: */!str.normalize && pairs,
/* split: */regex_whitespace, !1);
}

View File

@@ -0,0 +1,100 @@
/**
* http://www.ranks.nl/stopwords
* @type {Array<string>}
*/
export const filter = ["a", "about", "above", "after", "again", "against", "all", "also", "am", "an", "and", "any", "are", "aren't", "as", "at",
//"back",
"be", "because", "been", "before", "being", "below",
//"between",
"both", "but", "by", "can", "cannot", "can't", "come", "could", "couldn't",
//"day",
"did", "didn't", "do", "does", "doesn't", "doing", "dont", "down", "during", "each", "even", "few", "first", "for", "from", "further", "get",
//"give",
"go",
//"good",
"had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "hed",
//"hell",
"her", "here", "here's", "hers", "herself", "hes", "him", "himself", "his", "how", "how's", "i", "id", "if", "ill", "im", "in", "into", "is", "isn't", "it", "it's", "itself", "i've", "just", "know", "let's", "like",
//"look",
"make", "me", "more", "most", "mustn't", "my", "myself", "new", "no", "nor", "not", "now", "of", "off", "on", "once",
//"one",
"only", "or", "other", "ought", "our", "our's", "ourselves", "out", "over", "own",
//"people",
"same", "say", "see", "shan't", "she", "she'd", "shell", "shes", "should", "shouldn't", "so", "some", "such",
//"take",
"than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've",
//"think",
"this", "those", "through", "time", "to", "too",
//"two",
//"under",
"until", "up", "us",
//"use",
"very", "want", "was", "wasn't", "way", "we", "wed", "well", "were", "weren't", "we've", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "whom", "who's", "why", "why's", "will", "with", "won't",
//"work",
"would", "wouldn't",
//"year",
"you", "you'd", "you'll", "your", "you're", "your's", "yourself", "yourselves", "you've"];
/**
* @type {Object<string, string>}
*/
export const stemmer = {
ational: "ate",
iveness: "ive",
fulness: "ful",
ousness: "ous",
ization: "ize",
tional: "tion",
biliti: "ble",
icate: "ic",
ative: "",
alize: "al",
iciti: "ic",
entli: "ent",
ousli: "ous",
alism: "al",
ation: "ate",
aliti: "al",
iviti: "ive",
ement: "",
enci: "ence",
anci: "ance",
izer: "ize",
alli: "al",
ator: "ate",
logi: "log",
ical: "ic",
ance: "",
ence: "",
ness: "",
able: "",
ible: "",
ment: "",
eli: "e",
bli: "ble",
ful: "",
ant: "",
ent: "",
ism: "",
ate: "",
iti: "",
ous: "",
ive: "",
ize: "",
al: "",
ou: "",
er: "",
ic: ""
};
export const matcher = {};
export default {
filter: filter,
stemmer: stemmer,
matcher: matcher
};

View File

@@ -0,0 +1,74 @@
export let promise = Promise;
Object.assign || (Object.assign = function () {
const args = arguments,
size = args.length,
obj = args[0];
for (let x = 1, current, keys, length; x < size; x++) {
current = args[x];
keys = Object.keys(current);
length = keys.length;
for (let i = 0, key; i < length; i++) {
key = keys[i];
obj[key] = current[key];
}
}
return obj;
});
// Object.values || (Object.values = function(obj){
//
// const keys = Object.keys(obj);
// const length = keys.length;
// const values = new Array(length);
//
// for(let x = 0; x < length; x++){
//
// values[x] = obj[keys[x]];
// }
//
// return values;
// });
if (!promise) {
/**
* @param {Function} fn
* @constructor
*/
function SimplePromise(fn) {
this.callback = null;
const self = this;
fn(function (val) {
if (self.callback) {
self.callback(val);
// self.callback = null;
// self = null;
}
});
}
/**
* @param {Function} callback
*/
SimplePromise.prototype.then = function (callback) {
this.callback = callback;
};
promise = SimplePromise;
}

View File

@@ -0,0 +1,97 @@
import { is_string } from "./common.js";
/**
* @enum {Object}
* @const
*/
const preset = {
memory: {
charset: "latin:extra",
//tokenize: "strict",
resolution: 3,
//threshold: 0,
minlength: 4,
fastupdate: /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */
/* collapse: */
/* collapse: */!1
},
performance: {
//charset: "latin",
//tokenize: "strict",
resolution: 3,
minlength: 3,
//fastupdate: true,
optimize: !1, //fastupdate: true,
context: {
depth: 2, resolution: 1
//bidirectional: false
}
},
match: {
charset: "latin:extra",
tokenize: "reverse"
//resolution: 9,
//threshold: 0
},
score: {
charset: "latin:advanced",
//tokenize: "strict",
resolution: 20,
minlength: 3,
context: {
depth: 3,
resolution: 9
//bidirectional: true
}
},
default: {
// charset: "latin:default",
// tokenize: "strict",
// resolution: 3,
// threshold: 0,
// depth: 3
}
// "fast": {
// //charset: "latin",
// //tokenize: "strict",
// threshold: 8,
// resolution: 9,
// depth: 1
// }
};
export default function apply_preset(options) {
if (is_string(options)) {
if (!preset[options]) {
console.warn("Preset not found: " + options);
}
options = preset[options];
} else {
const preset = options.preset;
if (preset) {
if (!preset[preset]) {
console.warn("Preset not found: " + preset);
}
options = Object.assign({}, preset[preset], /** @type {Object} */options);
}
}
return options;
}

View File

@@ -0,0 +1,271 @@
// TODO return promises instead of inner await
import { IndexInterface, DocumentInterface } from "./type.js";
import { create_object, is_string } from "./common.js";
function async(callback, self, field, key, index_doc, index, data, on_done) {
setTimeout(function () {
const res = callback(field ? field + "." + key : key, JSON.stringify(data));
// await isn't supported by ES5
if (res && res.then) {
res.then(function () {
self.export(callback, self, field, index_doc, index + 1, on_done);
});
} else {
self.export(callback, self, field, index_doc, index + 1, on_done);
}
});
}
/**
* @this IndexInterface
*/
export function exportIndex(callback, self, field, index_doc, index, on_done) {
let return_value = /* append: */ /* skip update: */ /* skip_update: */ /* skip post-processing: */!0;
if ('undefined' == typeof on_done) {
return_value = new Promise(resolve => {
on_done = resolve;
});
}
let key, data;
switch (index || (index = 0)) {
case 0:
key = "reg";
// fastupdate isn't supported by export
if (this.fastupdate) {
data = create_object();
for (let key in this.register) {
data[key] = 1;
}
} else {
data = this.register;
}
break;
case 1:
key = "cfg";
data = {
doc: 0,
opt: this.optimize ? 1 : 0
};
break;
case 2:
key = "map";
data = this.map;
break;
case 3:
key = "ctx";
data = this.ctx;
break;
default:
if ('undefined' == typeof field && on_done) {
on_done();
}
return;
}
async(callback, self || this, field, key, index_doc, index, data, on_done);
return return_value;
}
/**
* @this IndexInterface
*/
export function importIndex(key, data) {
if (!data) {
return;
}
if (is_string(data)) {
data = JSON.parse(data);
}
switch (key) {
case "cfg":
this.optimize = !!data.opt;
break;
case "reg":
// fastupdate isn't supported by import
this.fastupdate = /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* collapse: */!1;
this.register = data;
break;
case "map":
this.map = data;
break;
case "ctx":
this.ctx = data;
break;
}
}
/**
* @this DocumentInterface
*/
export function exportDocument(callback, self, field, index_doc, index, on_done) {
let return_value;
if ('undefined' == typeof on_done) {
return_value = new Promise(resolve => {
on_done = resolve;
});
}
index || (index = 0);
index_doc || (index_doc = 0);
if (index_doc < this.field.length) {
const field = this.field[index_doc],
idx = this.index[field];
self = this;
setTimeout(function () {
if (!idx.export(callback, self, index ? field /*.replace(":", "-")*/ : "", index_doc, index++, on_done)) {
index_doc++;
index = 1;
self.export(callback, self, field, index_doc, index, on_done);
}
});
} else {
let key, data;
switch (index) {
case 1:
key = "tag";
data = this.tagindex;
field = null;
break;
case 2:
key = "store";
data = this.store;
field = null;
break;
// case 3:
//
// key = "reg";
// data = this.register;
// break;
default:
on_done();
return;
}
async(callback, this, field, key, index_doc, index, data, on_done);
}
return return_value;
}
/**
* @this DocumentInterface
*/
export function importDocument(key, data) {
if (!data) {
return;
}
if (is_string(data)) {
data = JSON.parse(data);
}
switch (key) {
case "tag":
this.tagindex = data;
break;
case "reg":
// fastupdate isn't supported by import
this.fastupdate = !1;
this.register = data;
for (let i = 0, index; i < this.field.length; i++) {
index = this.index[this.field[i]];
index.register = data;
index.fastupdate = !1;
}
break;
case "store":
this.store = data;
break;
default:
key = key.split(".");
const field = key[0];
key = key[1];
if (field && key) {
this.index[field].import(key, data);
}
}
}

View File

@@ -0,0 +1,69 @@
/**
* @interface
*/
export function IndexInterface() {
this.cache = null;
this.matcher = null;
this.stemmer = null;
this.filter = null;
}
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} collapse
* @returns {string|Array<string>}
*/
//IndexInterface.prototype.pipeline;
/**
* @param {!number|string} id
* @param {!string} content
*/
IndexInterface.prototype.add;
/**
* @param {!number|string} id
* @param {!string} content
*/
IndexInterface.prototype.append;
/**
* @param {!string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @returns {Array<number|string>}
*/
IndexInterface.prototype.search;
/**
* @param {!number|string} id
* @param {!string} content
*/
IndexInterface.prototype.update;
/**
* @param {!number|string} id
*/
IndexInterface.prototype.remove;
/**
* @interface
*/
export function DocumentInterface() {
this.field = null;
/** @type IndexInterface */
this.index = null;
}

View File

@@ -0,0 +1,52 @@
import Index from "../index.js";
export default function (data) {
data = data.data;
/** @type Index */
const index = self._index,
args = data.args,
task = data.task;
switch (task) {
case "init":
const options = data.options || {},
factory = data.factory,
encode = options.encode;
options.cache = /* normalize: */ /* collapse: */ /* normalize: */
/* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* collapse: */!1;
if (encode && 0 === encode.indexOf("function")) {
options.encode = Function("return " + encode)();
}
if (factory) {
// export the FlexSearch global payload to "self"
Function("return " + factory)()(self);
/** @type Index */
self._index = new self.FlexSearch.Index(options);
// destroy the exported payload
delete self.FlexSearch;
} else {
self._index = new Index(options);
}
break;
default:
const id = data.id,
message = index[task].apply(index, args);
postMessage("search" === task ? { id: id, msg: message } : { id: id });
}
}

View File

@@ -0,0 +1,136 @@
//import { promise as Promise } from "../polyfill.js";
import { create_object, is_function, is_object, is_string } from "../common.js";
import handler from "./handler.js";
let pid = 0;
/**
* @param {Object=} options
* @constructor
*/
function WorkerIndex(options) {
if (!(this instanceof WorkerIndex)) {
return new WorkerIndex(options);
}
let opt;
if (options) {
if (is_function(opt = options.encode)) {
options.encode = opt.toString();
}
} else {
options = {};
}
// the factory is the outer wrapper from the build
// we use "self" as a trap for node.js
let factory = (self || window)._factory;
if (factory) {
factory = factory.toString();
}
const is_node_js = "undefined" == typeof window && self.exports,
_self = this;
this.worker = create(factory, is_node_js, options.worker);
this.resolver = create_object();
if (!this.worker) {
return;
}
if (is_node_js) {
this.worker.on("message", function (msg) {
_self.resolver[msg.id](msg.msg);
delete _self.resolver[msg.id];
});
} else {
this.worker.onmessage = function (msg) {
msg = msg.data;
_self.resolver[msg.id](msg.msg);
delete _self.resolver[msg.id];
};
}
this.worker.postMessage({
task: "init",
factory: factory,
options: options
});
}
export default WorkerIndex;
register("add");
register("append");
register("search");
register("update");
register("remove");
function register(key) {
WorkerIndex.prototype[key] = WorkerIndex.prototype[key + "Async"] = function () {
const self = this,
args = [].slice.call(arguments),
arg = args[args.length - 1];
let callback;
if (is_function(arg)) {
callback = arg;
args.splice(args.length - 1, 1);
}
const promise = new Promise(function (resolve) {
setTimeout(function () {
self.resolver[++pid] = resolve;
self.worker.postMessage({
task: key,
id: pid,
args: args
});
});
});
if (callback) {
promise.then(callback);
return this;
} else {
return promise;
}
};
}
function create(factory, is_node_js, worker_path) {
let worker;
try {
worker = is_node_js ? eval('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")') : factory ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + handler.toString()], { type: "text/javascript" }))) : new Worker(is_string(worker_path) ? worker_path : "worker/worker.js", { type: "module" });
} catch (e) {}
return worker;
}

View File

@@ -0,0 +1,36 @@
const { parentPort } = require("worker_threads"),
{ Index } = require("../flexsearch.bundle.min.js");
let index;
parentPort.on("message", function (data) {
/** @type Index */
const args = data.args,
task = data.task,
id = data.id;
switch (task) {
case "init":
const options = data.options || {},
encode = options.encode;
options.cache = /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */ /* collapse: */!1;
if (encode && 0 === encode.indexOf("function")) {
options.encode = new Function("return " + encode)();
}
index = new Index(options);
break;
default:
const message = index[task].apply(index, args);
parentPort.postMessage("search" === task ? { id: id, msg: message } : { id: id });
}
});

View File

@@ -0,0 +1,2 @@
import handler from "./handler.js";
onmessage = handler;

View File

@@ -0,0 +1 @@
import{IndexInterface,DocumentInterface}from"./type.js";import{is_function,is_object,is_string}from"./common.js";export default function(a){register(a,"add"),register(a,"append"),register(a,"search"),register(a,"update"),register(a,"remove")}function register(a,b){a[b+"Async"]=function(){const a=this,c=arguments,d=c[c.length-1];let e;is_function(d)&&(e=d,delete c[c.length-1]);const f=new Promise(function(d){setTimeout(function(){a.async=!0;const e=a[b].apply(a,c);a.async=!1,d(e)})});return e?(f.then(e),this):f}}

View File

@@ -0,0 +1 @@
import{IndexInterface,DocumentInterface}from"./type.js";import{create_object,is_object}from"./common.js";function CacheClass(a){this.limit=!0!==a&&a,this.cache=create_object(),this.queue=[]}export default CacheClass;export function searchCache(a,b,c){is_object(a)&&(a=a.query);let d=this.cache.get(a);return d||(d=this.search(a,b,c),this.cache.set(a,d)),d}CacheClass.prototype.set=function(a,b){if(!this.cache[a]){let b=this.queue.length;b===this.limit?delete this.cache[this.queue[b-1]]:b++;for(let a=b-1;0<a;a--)this.queue[a]=this.queue[a-1];this.queue[0]=a}this.cache[a]=b},CacheClass.prototype.get=function(a){const b=this.cache[a];if(this.limit&&b){const b=this.queue.indexOf(a);if(b){const a=this.queue[b-1];this.queue[b-1]=this.queue[b],this.queue[b]=a}}return b},CacheClass.prototype.del=function(a){for(let b,c,d=0;d<this.queue.length;d++)c=this.queue[d],b=this.cache[c],b.includes(a)&&(this.queue.splice(d--,1),delete this.cache[c])};

View File

@@ -0,0 +1 @@
export function parse_option(a,b){return"undefined"==typeof a?b:a}export function create_object_array(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=create_object();return b}export function create_arrays(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=[];return b}export function get_keys(a){return Object.keys(a)}export function create_object(){return Object.create(null)}export function concat(a){return[].concat.apply([],a)}export function sort_by_length_down(c,a){return a.length-c.length}export function is_array(a){return a.constructor===Array}export function is_string(a){return"string"==typeof a}export function is_object(a){return"object"==typeof a}export function is_function(a){return"function"==typeof a}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import{searchCache}from"./cache";function Engine(a){a.prototype.searchCache=searchCache,a.prototype.addAsync=addAsync,a.prototype.appendAsync=appendAsync,a.prototype.searchAsync=searchAsync,a.prototype.updateAsync=updateAsync,a.prototype.removeAsync=removeAsync}Engine.prototype.searchCache=searchCache,Engine.prototype.addAsync=addAsync,Engine.prototype.appendAsync=appendAsync,Engine.prototype.searchAsync=searchAsync,Engine.prototype.updateAsync=updateAsync,Engine.prototype.removeAsync=removeAsync;

View File

@@ -0,0 +1 @@
export const global_lang={};export const global_charset={};export function registerCharset(a,b){global_charset[a]=b}export function registerLanguage(a,b){global_lang[a]=b}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import{create_object,concat}from"./common.js";export function intersect(a,b,c,d){const e=a.length;let f,g,h=[],i=0;d&&(d=[]);for(let j=e-1;0<=j;j--){const k=a[j],l=k.length,m=create_object();let n=!f;for(let a=0;a<l;a++){const l=k[a],o=l.length;if(o)for(let a,k,p=0;p<o;p++)if(k=l[p],f){if(f[k]){if(!j)if(c)c--;else if(h[i++]=k,i===b)return h;(j||d)&&(m[k]=1),n=!0}if(d&&(a=(g[k]||0)+1,g[k]=a,a<e)){const b=d[a-2]||(d[a-2]=[]);b[b.length]=k}}else m[k]=1}if(d)f||(g=m);else if(!n)return[];f=m}if(d)for(let a,e,g=d.length-1;0<=g;g--){a=d[g],e=a.length;for(let d,g=0;g<e;g++)if(d=a[g],!f[d]){if(c)c--;else if(h[i++]=d,i===b)return h;f[d]=1}}return h}export function intersect_union(a,b){const c=create_object(),d=create_object(),e=[];for(let d=0;d<a.length;d++)c[a[d]]=1;for(let f,g=0;g<b.length;g++){f=b[g];for(let a,b=0;b<f.length;b++)a=f[b],c[a]&&!d[a]&&(d[a]=1,e[e.length]=a)}return e}

View File

@@ -0,0 +1 @@
import{IndexInterface}from"./type.js";import{create_object,get_keys}from"./common.js";export function pipeline(a,b,c,d){if(a&&(b&&(a=replace(a,b)),this.matcher&&(a=replace(a,this.matcher)),this.stemmer&&1<a.length&&(a=replace(a,this.stemmer)),d&&1<a.length&&(a=collapse(a)),c||""===c)){const b=a.split(c);return this.filter?filter(b,this.filter):b}return a}export const regex_whitespace=/[\p{Z}\p{S}\p{P}\p{C}]+/u;const regex_normalize=/[\u0300-\u036f]/g;export function normalize(a){return a.normalize&&(a=a.normalize("NFD").replace(regex_normalize,"")),a}export function init_filter(a){const b=create_object();for(let c=0,d=a.length;c<d;c++)b[a[c]]=1;return b}export function init_stemmer_or_matcher(a,b){const c=get_keys(a),d=c.length,e=[];let f="",g=0;for(let h,j,k=0;k<d;k++)h=c[k],j=a[h],j?(e[g++]=regex(b?"(?!\\b)"+h+"(\\b|_)":h),e[g++]=j):f+=(f?"|":"")+h;return f&&(e[g++]=regex(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]=""),e}export function replace(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),!!a);c+=2);return a}export function regex(a){return new RegExp(a,"g")}export function collapse(a){let b="",c="";for(let d,e=0,f=a.length;e<f;e++)(d=a[e])!==c&&(b+=c=d);return b}export function filter(a,b){const c=a.length,d=[];for(let e=0,f=0;e<c;e++){const c=a[e];c&&!b[c]&&(d[f++]=c)}return d}

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{pipeline}from"../../lang.js";export const rtl=!0;export const tokenize="";export default{encode:encode,rtl:!0};const regex=/[\x00-\x7F]+/g,split=/\s+/;export function encode(a){return pipeline.call(this,(""+a).replace(regex," "),!1,split,!1)}

View File

@@ -0,0 +1 @@
export const filter=["aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","da\xDF","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","f\xFCr","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","k\xF6nnen","k\xF6nnt","machen","mein","meine","mit","mu\xDF","mu\xDFt","musst","m\xFCssen","m\xFC\xDFt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser","unsere","unter","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","\xFCber"];export const stemmer={niss:"",isch:"",lich:"",heit:"",keit:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{pipeline}from"../../lang.js";export const rtl=!1;export const tokenize="strict";export default{encode:encode,rtl:!1,tokenize:"strict"};const regex=/[\x00-\x7F]+/g;export function encode(a){return pipeline.call(this,(""+a).replace(regex,""),!1,"",!1)}

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{pipeline}from"../../lang.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const regex=/[\x00-\x7F]+/g,split=/\s+/;export function encode(a){return pipeline.call(this,(""+a).replace(regex," "),!1,split,!1)}

View File

@@ -0,0 +1 @@
export const filter=["aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","da\xDF","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","f\xFCr","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","k\xF6nnen","k\xF6nnt","machen","mein","meine","mit","mu\xDF","mu\xDFt","musst","m\xFCssen","m\xFC\xDFt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser","unsere","unter","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","\xFCber"];export const stemmer={niss:"",isch:"",lich:"",heit:"",keit:"",ell:"",bar:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -0,0 +1 @@
export const filter=["a","about","above","after","again","against","all","also","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","both","but","by","can","cannot","can't","come","could","couldn't","did","didn't","do","does","doesn't","doing","dont","down","during","each","even","few","first","for","from","further","get","go","had","hadn't","has","hasn't","have","haven't","having","he","hed","her","here","here's","hers","herself","hes","him","himself","his","how","how's","i","id","if","ill","im","in","into","is","isn't","it","it's","itself","i've","just","know","let's","like","make","me","more","most","mustn't","my","myself","new","no","nor","not","now","of","off","on","once","only","or","other","ought","our","our's","ourselves","out","over","own","same","say","see","shan't","she","she'd","shell","shes","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","time","to","too","until","up","us","very","want","was","wasn't","way","we","wed","well","were","weren't","we've","what","what's","when","when's","where","where's","which","while","who","whom","who's","why","why's","will","with","won't","would","wouldn't","you","you'd","you'll","your","you're","your's","yourself","yourselves","you've"];export const stemmer={ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{regex,replace,collapse}from"../../lang.js";import{encode as encode_balance}from"./balance.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};const regex_ae=regex("ae"),regex_oe=regex("oe"),regex_sh=regex("sh"),regex_th=regex("th"),regex_ph=regex("ph"),regex_pf=regex("pf"),pairs=[regex_ae,"a",regex_oe,"o",regex_sh,"s",regex_th,"t",regex_ph,"f",regex_pf,"f",regex("(?![aeo])h(?![aeo])"),"",regex("(?!^[aeo])h(?!^[aeo])"),""];export function encode(a,b){return a&&(a=encode_balance.call(this,a).join(" "),2<a.length&&(a=replace(a,pairs)),!b&&(1<a.length&&(a=collapse(a)),a&&(a=a.split(" ")))),a||[]}

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{encode as encode_simple}from"./simple.js";export const rtl=!1;export const tokenize="strict";export default{encode:encode,rtl:!1,tokenize:"strict"};const regex_strip=/[^a-z0-9]+/,soundex={b:"p",v:"f",w:"f",z:"s",x:"s",ß:"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};export function encode(a){a=encode_simple.call(this,a).join(" ");const b=[];if(a){const c=a.split(regex_strip),d=c.length;for(let e,f=0,g=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){e=a[0];let c=soundex[e]||e,d=c;for(let b=1;b<a.length;b++){e=a[b];const f=soundex[e]||e;f&&f!==d&&(c+=f,d=f)}b[g++]=c}}return b}

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{pipeline,normalize,regex_whitespace}from"../../lang.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};export function encode(a){return pipeline.call(this,(""+a).toLowerCase(),!1,regex_whitespace,!1)}

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{regex,replace,collapse}from"../../lang.js";import{encode as encode_advanced}from"./advanced.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};const prefix="(?!\\b)",regex_vowel=regex("(?!\\b)[aeo]"),pairs=[regex_vowel,""];export function encode(a){return a&&(a=encode_advanced.call(this,a,!0),1<a.length&&(a=a.replace(regex_vowel,"")),1<a.length&&(a=collapse(a)),a&&(a=a.split(" "))),a||[]}

View File

@@ -0,0 +1 @@
import{IndexInterface}from"../../type.js";import{pipeline,normalize,regex_whitespace,regex}from"../../lang.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};const regex_a=regex("[\xE0\xE1\xE2\xE3\xE4\xE5]"),regex_e=regex("[\xE8\xE9\xEA\xEB]"),regex_i=regex("[\xEC\xED\xEE\xEF]"),regex_o=regex("[\xF2\xF3\xF4\xF5\xF6\u0151]"),regex_u=regex("[\xF9\xFA\xFB\xFC\u0171]"),regex_y=regex("[\xFD\u0177\xFF]"),regex_n=regex("\xF1"),regex_c=regex("[\xE7c]"),regex_s=regex("\xDF"),regex_and=regex(" & "),pairs=[regex_a,"a",regex_e,"e",regex_i,"i",regex_o,"o",regex_u,"u",regex_y,"y",regex_n,"n",regex_c,"k",regex_s,"s",regex_and," and "];export function encode(a){return a=""+a,pipeline.call(this,normalize(a).toLowerCase(),!a.normalize&&pairs,regex_whitespace,!1)}

View File

@@ -0,0 +1 @@
export const filter=["a","about","above","after","again","against","all","also","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","both","but","by","can","cannot","can't","come","could","couldn't","did","didn't","do","does","doesn't","doing","dont","down","during","each","even","few","first","for","from","further","get","go","had","hadn't","has","hasn't","have","haven't","having","he","hed","her","here","here's","hers","herself","hes","him","himself","his","how","how's","i","id","if","ill","im","in","into","is","isn't","it","it's","itself","i've","just","know","let's","like","make","me","more","most","mustn't","my","myself","new","no","nor","not","now","of","off","on","once","only","or","other","ought","our","our's","ourselves","out","over","own","same","say","see","shan't","she","she'd","shell","shes","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","time","to","too","until","up","us","very","want","was","wasn't","way","we","wed","well","were","weren't","we've","what","what's","when","when's","where","where's","which","while","who","whom","who's","why","why's","will","with","won't","would","wouldn't","you","you'd","you'll","your","you're","your's","yourself","yourselves","you've"];export const stemmer={ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -0,0 +1 @@
export let promise=Promise;if(Object.assign||(Object.assign=function(){const a=arguments,b=a.length,c=a[0];for(let d,e,f,g=1;g<b;g++){d=a[g],e=Object.keys(d),f=e.length;for(let a,b=0;b<f;b++)a=e[b],c[a]=d[a]}return c}),!promise){function a(a){this.callback=null;const b=this;a(function(a){b.callback&&b.callback(a)})}a.prototype.then=function(a){this.callback=a},promise=a}

View File

@@ -0,0 +1 @@
import{is_string}from"./common.js";const preset={memory:{charset:"latin:extra",resolution:3,minlength:4,fastupdate:!1},performance:{resolution:3,minlength:3,optimize:!1,context:{depth:2,resolution:1}},match:{charset:"latin:extra",tokenize:"reverse"},score:{charset:"latin:advanced",resolution:20,minlength:3,context:{depth:3,resolution:9}},default:{}};export default function apply_preset(a){if(is_string(a))!1,a=preset[a];else{const b=a.preset;b&&(!1,a=Object.assign({},b[b],a))}return a}

View File

@@ -0,0 +1 @@
import{IndexInterface,DocumentInterface}from"./type.js";import{create_object,is_string}from"./common.js";function async(a,b,c,d,e,f,g,h){setTimeout(function(){const i=a(c?c+"."+d:d,JSON.stringify(g));i&&i.then?i.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)})}export function exportIndex(a,b,c,d,e,f){let g=!0;"undefined"==typeof f&&(g=new Promise(a=>{f=a}));let h,i;switch(e||(e=0)){case 0:if(h="reg",this.fastupdate)for(let a in i=create_object(),this.register)i[a]=1;else i=this.register;break;case 1:h="cfg",i={doc:0,opt:this.optimize?1:0};break;case 2:h="map",i=this.map;break;case 3:h="ctx",i=this.ctx;break;default:return void("undefined"==typeof c&&f&&f());}return async(a,b||this,c,h,d,e,i,f),g}export function importIndex(a,b){b&&(is_string(b)&&(b=JSON.parse(b)),"cfg"===a?this.optimize=!!b.opt:"reg"===a?(this.fastupdate=!1,this.register=b):"map"===a?this.map=b:"ctx"===a?this.ctx=b:void 0)}export function exportDocument(a,b,c,d,e,f){let g;if("undefined"==typeof f&&(g=new Promise(a=>{f=a})),e||(e=0),d||(d=0),d<this.field.length){const c=this.field[d],g=this.index[c];b=this,setTimeout(function(){g.export(a,b,e?c:"",d,e++,f)||(d++,e=1,b.export(a,b,c,d,e,f))})}else{let b,g;switch(e){case 1:b="tag",g=this.tagindex,c=null;break;case 2:b="store",g=this.store,c=null;break;default:return void f();}async(a,this,c,b,d,e,g,f)}return g}export function importDocument(a,b){if(b)switch(is_string(b)&&(b=JSON.parse(b)),a){case"tag":this.tagindex=b;break;case"reg":this.fastupdate=!1,this.register=b;for(let a,c=0;c<this.field.length;c++)a=this.index[this.field[c]],a.register=b,a.fastupdate=!1;break;case"store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1],c&&a&&this.index[c].import(a,b);}}

View File

@@ -0,0 +1 @@
export function IndexInterface(){this.cache=null,this.matcher=null,this.stemmer=null,this.filter=null}IndexInterface.prototype.add,IndexInterface.prototype.append,IndexInterface.prototype.search,IndexInterface.prototype.update,IndexInterface.prototype.remove;export function DocumentInterface(){this.field=null,this.index=null}

View File

@@ -0,0 +1 @@
import Index from"../index.js";export default function(a){a=a.data;const b=self._index,c=a.args,d=a.task;switch(d){case"init":const e=a.options||{},f=a.factory,g=e.encode;e.cache=!1,g&&0===g.indexOf("function")&&(e.encode=Function("return "+g)()),f?(Function("return "+f)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new Index(e);break;default:const h=a.id,i=b[d].apply(b,c);postMessage("search"===d?{id:h,msg:i}:{id:h});}}

View File

@@ -0,0 +1 @@
import{create_object,is_function,is_object,is_string}from"../common.js";import handler from"./handler.js";let pid=0;function WorkerIndex(a){if(!(this instanceof WorkerIndex))return new WorkerIndex(a);let b;a?is_function(b=a.encode)&&(a.encode=b.toString()):a={};let c=(self||window)._factory;c&&(c=c.toString());const d="undefined"==typeof window&&self.exports,e=this;this.worker=create(c,d,a.worker),this.resolver=create_object();this.worker&&(d?this.worker.on("message",function(a){e.resolver[a.id](a.msg),delete e.resolver[a.id]}):this.worker.onmessage=function(a){a=a.data,e.resolver[a.id](a.msg),delete e.resolver[a.id]},this.worker.postMessage({task:"init",factory:c,options:a}))}export default WorkerIndex;register("add"),register("append"),register("search"),register("update"),register("remove");function register(a){WorkerIndex.prototype[a]=WorkerIndex.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments),d=c[c.length-1];let e;is_function(d)&&(e=d,c.splice(c.length-1,1));const f=new Promise(function(d){setTimeout(function(){b.resolver[++pid]=d,b.worker.postMessage({task:a,id:pid,args:c})})});return e?(f.then(e),this):f}}function create(factory,is_node_js,worker_path){let worker;try{worker=is_node_js?eval("new (require(\"worker_threads\")[\"Worker\"])(__dirname + \"/node/node.js\")"):factory?new Worker(URL.createObjectURL(new Blob(["onmessage="+handler.toString()],{type:"text/javascript"}))):new Worker(is_string(worker_path)?worker_path:"worker/worker.js",{type:"module"})}catch(a){}return worker}

View File

@@ -0,0 +1 @@
const{parentPort}=require("worker_threads"),{Index}=require("../flexsearch.bundle.min.js");let index;parentPort.on("message",function(a){const b=a.args,c=a.task,d=a.id;switch(c){case"init":const e=a.options||{},f=e.encode;e.cache=!1,f&&0===f.indexOf("function")&&(e.encode=new Function("return "+f)()),index=new Index(e);break;default:const g=index[c].apply(index,b);parentPort.postMessage("search"===c?{id:d,msg:g}:{id:d});}});

View File

@@ -0,0 +1 @@
import handler from"./handler.js";onmessage=handler;

View File

@@ -0,0 +1,51 @@
import { IndexInterface, DocumentInterface } from "./type.js";
//import { promise as Promise } from "./polyfill.js";
import { is_function, is_object, is_string } from "./common.js";
export default function (prototype) {
register(prototype, "add");
register(prototype, "append");
register(prototype, "search");
register(prototype, "update");
register(prototype, "remove");
}
function register(prototype, key) {
prototype[key + "Async"] = function () {
/** @type {IndexInterface|DocumentInterface} */
const self = this,
args = /*[].slice.call*/arguments,
arg = args[args.length - 1];
let callback;
if (is_function(arg)) {
callback = arg;
delete args[args.length - 1];
}
const promise = new Promise(function (resolve) {
setTimeout(function () {
self.async = !0;
const res = self[key].apply(self, args);
self.async = !1;
resolve(res);
});
});
if (callback) {
promise.then(callback);
return this;
} else {
return promise;
}
};
}

View File

@@ -0,0 +1,168 @@
import { IndexInterface, DocumentInterface } from "./type.js";
import { create_object, is_object } from "./common.js";
/**
* @param {boolean|number=} limit
* @constructor
*/
function CacheClass(limit) {
/** @private */
this.limit = !0 !== limit && limit;
/** @private */
this.cache = create_object();
/** @private */
this.queue = [];
//this.clear();
}
export default CacheClass;
/**
* @param {string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @this {IndexInterface}
* @returns {Array<number|string>}
*/
export function searchCache(query, limit, options) {
if (is_object(query)) {
query = query.query;
}
let cache = this.cache.get(query);
if (!cache) {
cache = this.search(query, limit, options);
this.cache.set(query, cache);
}
return cache;
}
// CacheClass.prototype.clear = function(){
//
// /** @private */
// this.cache = create_object();
//
// /** @private */
// this.queue = [];
// };
CacheClass.prototype.set = function (key, value) {
if (!this.cache[key]) {
// it is just a shame that native function array.shift() performs so bad
// const length = this.queue.length;
//
// this.queue[length] = key;
//
// if(length === this.limit){
//
// delete this.cache[this.queue.shift()];
// }
// the same bad performance
// this.queue.unshift(key);
//
// if(this.queue.length === this.limit){
//
// this.queue.pop();
// }
// fast implementation variant
// let length = this.queue.length;
//
// if(length === this.limit){
//
// length--;
//
// delete this.cache[this.queue[0]];
//
// for(let x = 0; x < length; x++){
//
// this.queue[x] = this.queue[x + 1];
// }
// }
//
// this.queue[length] = key;
// current fastest implementation variant
// theoretically that should not perform better compared to the example above
let length = this.queue.length;
if (length === this.limit) {
delete this.cache[this.queue[length - 1]];
} else {
length++;
}
for (let x = length - 1; 0 < x; x--) {
this.queue[x] = this.queue[x - 1];
}
this.queue[0] = key;
}
this.cache[key] = value;
};
CacheClass.prototype.get = function (key) {
const cache = this.cache[key];
if (this.limit && cache) {
// probably the indexOf() method performs faster when matched content is on front (left-to-right)
// using lastIndexOf() does not help, it performs almost slower
const pos = this.queue.indexOf(key);
// if(pos < this.queue.length - 1){
//
// const tmp = this.queue[pos];
// this.queue[pos] = this.queue[pos + 1];
// this.queue[pos + 1] = tmp;
// }
if (pos) {
const tmp = this.queue[pos - 1];
this.queue[pos - 1] = this.queue[pos];
this.queue[pos] = tmp;
}
}
return cache;
};
CacheClass.prototype.del = function (id) {
for (let i = 0, item, key; i < this.queue.length; i++) {
key = this.queue[i];
item = this.cache[key];
if (item.includes(id)) {
this.queue.splice(i--, 1);
delete this.cache[key];
}
}
};

View File

@@ -0,0 +1,78 @@
export function parse_option(value, default_value) {
return "undefined" != typeof value ? value : default_value;
}
/**
* @param {!number} count
* @returns {Array<Object>}
*/
export function create_object_array(count) {
const array = Array(count);
for (let i = 0; i < count; i++) {
array[i] = create_object();
}
return array;
}
export function create_arrays(count) {
const array = Array(count);
for (let i = 0; i < count; i++) {
array[i] = [];
}
return array;
}
/**
* @param {!Object} obj
* @returns {Array<string>}
*/
export function get_keys(obj) {
return Object.keys(obj);
}
export function create_object() {
return Object.create(null);
}
export function concat(arrays) {
return [].concat.apply([], arrays);
}
export function sort_by_length_down(a, b) {
return b.length - a.length;
}
export function is_array(val) {
return val.constructor === Array;
}
export function is_string(val) {
return "string" == typeof val;
}
export function is_object(val) {
return "object" == typeof val;
}
export function is_function(val) {
return "function" == typeof val;
}

View File

@@ -0,0 +1,731 @@
/**!
* FlexSearch.js
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
import Index from "./index.js";
import { DocumentInterface } from "./type.js";
import Cache, { searchCache } from "./cache.js";
import { create_object, is_array, is_string, is_object, parse_option, get_keys } from "./common.js";
import apply_async from "./async.js";
import { intersect, intersect_union } from "./intersect.js";
import { exportDocument, importDocument } from "./serialize.js";
import WorkerIndex from "./worker/index.js";
/**
* @constructor
* @implements {DocumentInterface}
* @param {Object=} options
* @return {Document}
*/
function Document(options) {
if (!(this instanceof Document)) {
return new Document(options);
}
const document = options.document || options.doc || options;
let opt;
this.tree = [];
this.field = [];
this.marker = [];
this.register = create_object();
this.key = (opt = document.key || document.id) && parse_tree(opt, this.marker) || "id";
this.fastupdate = parse_option(options.fastupdate, /* append: */ /* skip update: */ /* skip_update: */!0);
this.storetree = (opt = document.store) && !0 !== opt && [];
this.store = opt && create_object();
// TODO case-insensitive tags
this.tag = (opt = document.tag) && parse_tree(opt, this.marker);
this.tagindex = opt && create_object();
this.cache = (opt = options.cache) && new Cache(opt);
// do not apply cache again for the indexes
options.cache = !1;
this.worker = options.worker;
// this switch is used by recall of promise callbacks
this.async = !1;
/** @export */
this.index = parse_descriptor.call(this, options, document);
}
export default Document;
/**
* @this Document
*/
function parse_descriptor(options, document) {
const index = create_object();
let field = document.index || document.field || document;
if (is_string(field)) {
field = [field];
}
for (let i = 0, key, opt; i < field.length; i++) {
key = field[i];
if (!is_string(key)) {
opt = key;
key = key.field;
}
opt = is_object(opt) ? Object.assign({}, options, opt) : options;
if (this.worker) {
index[key] = new WorkerIndex(opt);
if (!index[key].worker) {
this.worker = !1;
}
}
if (!this.worker) {
index[key] = new Index(opt, this.register);
}
this.tree[i] = parse_tree(key, this.marker);
this.field[i] = key;
}
if (this.storetree) {
let store = document.store;
if (is_string(store)) {
store = [store];
}
for (let i = 0; i < store.length; i++) {
this.storetree[i] = parse_tree(store[i], this.marker);
}
}
return index;
}
function parse_tree(key, marker) {
const tree = key.split(":");
let count = 0;
for (let i = 0; i < tree.length; i++) {
key = tree[i];
if (0 <= key.indexOf("[]")) {
key = key.substring(0, key.length - 2);
if (key) {
marker[count] = !0;
}
}
if (key) {
tree[count++] = key;
}
}
if (count < tree.length) {
tree.length = count;
}
return 1 < count ? tree : tree[0];
}
// TODO support generic function created from string when tree depth > 1
function parse_simple(obj, tree) {
if (is_string(tree)) {
obj = obj[tree];
} else {
for (let i = 0; obj && i < tree.length; i++) {
obj = obj[tree[i]];
}
}
return obj;
}
// TODO support generic function created from string when tree depth > 1
function store_value(obj, store, tree, pos, key) {
obj = obj[key];
// reached target field
if (pos === tree.length - 1) {
// store target value
store[key] = obj;
} else if (obj) {
if (is_array(obj)) {
store = store[key] = Array(obj.length);
for (let i = 0; i < obj.length; i++) {
// do not increase pos (an array is not a field)
store_value(obj, store, tree, pos, i);
}
} else {
store = store[key] || (store[key] = create_object());
key = tree[++pos];
store_value(obj, store, tree, pos, key);
}
}
}
function add_index(obj, tree, marker, pos, index, id, key, _append) {
obj = obj[key];
if (obj) {
// reached target field
if (pos === tree.length - 1) {
// handle target value
if (is_array(obj)) {
// append array contents so each entry gets a new scoring context
if (marker[pos]) {
for (let i = 0; i < obj.length; i++) {
index.add(id, obj[i], !0, !0);
}
return;
}
// or join array contents and use one scoring context
obj = obj.join(" ");
}
index.add(id, obj, _append, !0);
} else {
if (is_array(obj)) {
for (let i = 0; i < obj.length; i++) {
// do not increase index, an array is not a field
add_index(obj, tree, marker, pos, index, id, i, _append);
}
} else {
key = tree[++pos];
add_index(obj, tree, marker, pos, index, id, key, _append);
}
}
}
}
/**
*
* @param id
* @param content
* @param {boolean=} _append
* @returns {Document|Promise}
*/
Document.prototype.add = function (id, content, _append) {
if (is_object(id)) {
content = id;
id = parse_simple(content, this.key);
}
if (content && (id || 0 === id)) {
if (!_append && this.register[id]) {
return this.update(id, content);
}
for (let i = 0, tree, field; i < this.field.length; i++) {
field = this.field[i];
tree = this.tree[i];
if (is_string(tree)) {
tree = [tree];
}
add_index(content, tree, this.marker, 0, this.index[field], id, tree[0], _append);
}
if (this.tag) {
let tag = parse_simple(content, this.tag),
dupes = create_object();
if (is_string(tag)) {
tag = [tag];
}
for (let i = 0, key, arr; i < tag.length; i++) {
key = tag[i];
if (!dupes[key]) {
dupes[key] = 1;
arr = this.tagindex[key] || (this.tagindex[key] = []);
if (!_append || !arr.includes(id)) {
arr[arr.length] = id;
// add a reference to the register for fast updates
if (this.fastupdate) {
const tmp = this.register[id] || (this.register[id] = []);
tmp[tmp.length] = arr;
}
}
}
}
}
// TODO: how to handle store when appending contents?
if (this.store && (!_append || !this.store[id])) {
let store;
if (this.storetree) {
store = create_object();
for (let i = 0, tree; i < this.storetree.length; i++) {
tree = this.storetree[i];
if (is_string(tree)) {
store[tree] = content[tree];
} else {
store_value(content, store, tree, 0, tree[0]);
}
}
}
this.store[id] = store || content;
}
}
return this;
};
Document.prototype.append = function (id, content) {
return this.add(id, content, !0);
};
Document.prototype.update = function (id, content) {
return this.remove(id).add(id, content);
};
Document.prototype.remove = function (id) {
if (is_object(id)) {
id = parse_simple(id, this.key);
}
if (this.register[id]) {
for (let i = 0; i < this.field.length; i++) {
// workers does not share the register
this.index[this.field[i]].remove(id, !this.worker);
if (this.fastupdate) {
// when fastupdate was enabled all ids are removed
break;
}
}
if (this.tag) {
// when fastupdate was enabled all ids are already removed
if (!this.fastupdate) {
for (let key in this.tagindex) {
const tag = this.tagindex[key],
pos = tag.indexOf(id);
if (-1 !== pos) {
if (1 < tag.length) {
tag.splice(pos, 1);
} else {
delete this.tagindex[key];
}
}
}
}
}
if (this.store) {
delete this.store[id];
}
delete this.register[id];
}
return this;
};
/**
* @param {!string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @param {Array<Array>=} _resolve For internal use only.
* @returns {Promise|Array}
*/
Document.prototype.search = function (query, limit, options, _resolve) {
if (!options) {
if (!limit && is_object(query)) {
options = /** @type {Object} */query;
query = "";
} else if (is_object(limit)) {
options = /** @type {Object} */limit;
limit = 0;
}
}
let result = [],
result_field = [],
pluck,
enrich,
field,
tag,
bool,
offset,
count = 0;
if (options) {
if (is_array(options)) {
field = options;
options = null;
} else {
query = options.query || query;
pluck = options.pluck;
field = pluck || options.index || options.field /*|| (is_string(options) && [options])*/;
tag = options.tag;
enrich = this.store && options.enrich;
bool = "and" === options.bool;
limit = options.limit || limit || 100;
offset = options.offset || 0;
if (tag) {
if (is_string(tag)) {
tag = [tag];
}
// when tags is used and no query was set,
// then just return the tag indexes
if (!query) {
for (let i = 0, res; i < tag.length; i++) {
res = get_tag.call(this, tag[i], limit, offset, enrich);
if (res) {
result[result.length] = res;
count++;
}
}
return count ? result : [];
}
}
if (is_string(field)) {
field = [field];
}
}
}
field || (field = this.field);
bool = bool && (1 < field.length || tag && 1 < tag.length);
const promises = !_resolve && (this.worker || this.async) && [];
// TODO solve this in one loop below
for (let i = 0, res, key, len; i < field.length; i++) {
let field_options;
key = field[i];
if (!is_string(key)) {
field_options = key;
key = field_options.field;
query = field_options.query || query;
limit = field_options.limit || limit;
enrich = field_options.enrich || enrich;
}
if (promises) {
promises[i] = this.index[key].searchAsync(query, limit, field_options || options);
// just collect and continue
continue;
} else if (_resolve) {
res = _resolve[i];
} else {
// inherit options also when search? it is just for laziness, Object.assign() has a cost
res = this.index[key].search(query, limit, field_options || options);
}
len = res && res.length;
if (tag && len) {
const arr = [];
let count = 0;
if (bool) {
// prepare for intersection
arr[0] = [res];
}
for (let y = 0, key, res; y < tag.length; y++) {
key = tag[y];
res = this.tagindex[key];
len = res && res.length;
if (len) {
count++;
arr[arr.length] = bool ? [res] : res;
}
}
if (count) {
if (bool) {
res = intersect(arr, limit || 100, offset || 0);
} else {
res = intersect_union(res, arr);
}
len = res.length;
}
}
if (len) {
result_field[count] = key;
result[count++] = res;
} else if (bool) {
return [];
}
}
if (promises) {
const self = this;
// anyone knows a better workaround of optionally having async promises?
// the promise.all() needs to be wrapped into additional promise,
// otherwise the recursive callback wouldn't run before return
return new Promise(function (resolve) {
Promise.all(promises).then(function (result) {
resolve(self.search(query, limit, options, result));
});
});
}
if (!count) {
// fast path "not found"
return [];
}
if (pluck && (!enrich || !this.store)) {
// fast path optimization
return result[0];
}
for (let i = 0, res; i < result_field.length; i++) {
res = result[i];
if (res.length) {
if (enrich) {
res = apply_enrich.call(this, res);
}
}
if (pluck) {
return res;
}
result[i] = {
field: result_field[i],
result: res
};
}
return result;
};
/**
* @this Document
*/
function get_tag(key, limit, offset) {
let res = this.tagindex[key],
len = res && res.length - offset;
}
/**
* @this Document
*/
function apply_enrich(res) {
const arr = Array(res.length);
for (let x = 0, id; x < res.length; x++) {
id = res[x];
arr[x] = {
id: id,
doc: this.store[id]
};
}
return arr;
}
Document.prototype.contain = function (id) {
return !!this.register[id];
};
Document.prototype.get = function (id) {
return this.store[id];
};
Document.prototype.set = function (id, data) {
this.store[id] = data;
return this;
};
Document.prototype.searchCache = searchCache;
Document.prototype.export = exportDocument;
Document.prototype.import = importDocument;
apply_async(Document.prototype);

View File

@@ -0,0 +1,28 @@
import { searchCache } from "./cache";
/**
* @constructor
* @abstract
*/
function Engine(index) {
index.prototype.searchCache = searchCache;
index.prototype.addAsync = addAsync;
index.prototype.appendAsync = appendAsync;
index.prototype.searchAsync = searchAsync;
index.prototype.updateAsync = updateAsync;
index.prototype.removeAsync = removeAsync;
}
Engine.prototype.searchCache = searchCache;
Engine.prototype.addAsync = addAsync;
Engine.prototype.appendAsync = appendAsync;
Engine.prototype.searchAsync = searchAsync;
Engine.prototype.updateAsync = updateAsync;
Engine.prototype.removeAsync = removeAsync;

View File

@@ -0,0 +1,22 @@
export const global_lang = {};
export const global_charset = {};
/**
* @param {!string} name
* @param {Object} charset
*/
export function registerCharset(name, charset) {
global_charset[name] = charset;
}
/**
* @param {!string} name
* @param {Object} lang
*/
export function registerLanguage(name, lang) {
global_lang[name] = lang;
}

View File

@@ -0,0 +1,784 @@
/**!
* FlexSearch.js
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
import { IndexInterface } from "./type.js";
import { encode as default_encoder } from "./lang/latin/default.js";
import { create_object, create_object_array, concat, sort_by_length_down, is_array, is_string, is_object, parse_option } from "./common.js";
import { pipeline, init_stemmer_or_matcher, init_filter } from "./lang.js";
import { global_lang, global_charset } from "./global.js";
import apply_async from "./async.js";
import { intersect } from "./intersect.js";
import Cache, { searchCache } from "./cache.js";
import apply_preset from "./preset.js";
import { exportIndex, importIndex } from "./serialize.js";
/**
* @constructor
* @implements IndexInterface
* @param {Object=} options
* @param {Object=} _register
* @return {Index}
*/
function Index(options, _register) {
if (!(this instanceof Index)) {
return new Index(options);
}
let charset, lang, tmp;
if (options) {
options = apply_preset(options);
charset = options.charset;
lang = options.lang;
if (is_string(charset)) {
if (-1 === charset.indexOf(":")) {
charset += ":default";
}
charset = global_charset[charset];
}
if (is_string(lang)) {
lang = global_lang[lang];
}
} else {
options = {};
}
let resolution,
optimize,
context = options.context || {};
this.encode = options.encode || charset && charset.encode || default_encoder;
this.register = _register || create_object();
this.resolution = resolution = options.resolution || 9;
this.tokenize = tmp = charset && charset.tokenize || options.tokenize || "strict";
this.depth = "strict" === tmp && context.depth;
this.bidirectional = parse_option(context.bidirectional, /* append: */ /* skip update: */ /* skip_update: */!0);
this.optimize = optimize = parse_option(options.optimize, !0);
this.fastupdate = parse_option(options.fastupdate, !0);
this.minlength = options.minlength || 1;
this.boost = options.boost;
// when not using the memory strategy the score array should not pre-allocated to its full length
this.map = optimize ? create_object_array(resolution) : create_object();
this.resolution_ctx = resolution = context.resolution || 1;
this.ctx = optimize ? create_object_array(resolution) : create_object();
this.rtl = charset && charset.rtl || options.rtl;
this.matcher = (tmp = options.matcher || lang && lang.matcher) && init_stemmer_or_matcher(tmp, !1);
this.stemmer = (tmp = options.stemmer || lang && lang.stemmer) && init_stemmer_or_matcher(tmp, !0);
this.filter = (tmp = options.filter || lang && lang.filter) && init_filter(tmp);
this.cache = (tmp = options.cache) && new Cache(tmp);
}
export default Index;
//Index.prototype.pipeline = pipeline;
/**
* @param {!number|string} id
* @param {!string} content
*/
Index.prototype.append = function (id, content) {
return this.add(id, content, !0);
};
// TODO:
// string + number as text
// boolean, null, undefined as ?
/**
* @param {!number|string} id
* @param {!string} content
* @param {boolean=} _append
* @param {boolean=} _skip_update
*/
Index.prototype.add = function (id, content, _append, _skip_update) {
if (content && (id || 0 === id)) {
if (!_skip_update && !_append && this.register[id]) {
return this.update(id, content);
}
content = this.encode("" + content);
const length = content.length;
if (length) {
// check context dupes to skip all contextual redundancy along a document
const dupes_ctx = create_object(),
dupes = create_object(),
depth = this.depth,
resolution = this.resolution;
for (let i = 0; i < length; i++) {
let term = content[this.rtl ? length - 1 - i : i],
term_length = term.length;
// skip dupes will break the context chain
if (term && term_length >= this.minlength && (depth || !dupes[term])) {
let score = get_score(resolution, length, i),
token = "";
switch (this.tokenize) {
case "full":
if (2 < term_length) {
for (let x = 0; x < term_length; x++) {
for (let y = term_length; y > x; y--) {
if (y - x >= this.minlength) {
const partial_score = get_score(resolution, length, i, term_length, x);
token = term.substring(x, y);
this.push_index(dupes, token, partial_score, id, _append);
}
}
}
break;
}
// fallthrough to next case when term length < 3
case "reverse":
// skip last round (this token exist already in "forward")
if (1 < term_length) {
for (let x = term_length - 1; 0 < x; x--) {
token = term[x] + token;
if (token.length >= this.minlength) {
const partial_score = get_score(resolution, length, i, term_length, x);
this.push_index(dupes, token, partial_score, id, _append);
}
}
token = "";
}
// fallthrough to next case to apply forward also
case "forward":
if (1 < term_length) {
for (let x = 0; x < term_length; x++) {
token += term[x];
if (token.length >= this.minlength) {
this.push_index(dupes, token, score, id, _append);
}
}
break;
}
// fallthrough to next case when token has a length of 1
default:
// case "strict":
if (this.boost) {
score = Math.min(0 | score / this.boost(content, term, i), resolution - 1);
}
this.push_index(dupes, term, score, id, _append);
// context is just supported by tokenizer "strict"
if (depth) {
if (1 < length && i < length - 1) {
// check inner dupes to skip repeating words in the current context
const dupes_inner = create_object(),
resolution = this.resolution_ctx,
keyword = term,
size = Math.min(depth + 1, length - i);
dupes_inner[keyword] = 1;
for (let x = 1; x < size; x++) {
term = content[this.rtl ? length - 1 - i - x : i + x];
if (term && term.length >= this.minlength && !dupes_inner[term]) {
dupes_inner[term] = 1;
const context_score = get_score(resolution + (length / 2 > resolution ? 0 : 1), length, i, size - 1, x - 1),
swap = this.bidirectional && term > keyword;
this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword);
}
}
}
}
}
}
}
this.fastupdate || (this.register[id] = 1);
}
}
return this;
};
/**
* @param {number} resolution
* @param {number} length
* @param {number} i
* @param {number=} term_length
* @param {number=} x
* @returns {number}
*/
function get_score(resolution, length, i, term_length, x) {
// console.log("resolution", resolution);
// console.log("length", length);
// console.log("term_length", term_length);
// console.log("i", i);
// console.log("x", x);
// console.log((resolution - 1) / (length + (term_length || 0)) * (i + (x || 0)) + 1);
// the first resolution slot is reserved for the best match,
// when a query matches the first word(s).
// also to stretch score to the whole range of resolution, the
// calculation is shift by one and cut the floating point.
// this needs the resolution "1" to be handled additionally.
// do not stretch the resolution more than the term length will
// improve performance and memory, also it improves scoring in
// most cases between a short document and a long document
return i && 1 < resolution ? length + (term_length || 0) <= resolution ? i + (x || 0) : 0 | (resolution - 1) / (length + (term_length || 0)) * (i + (x || 0)) + 1 : 0;
}
/**
* @private
* @param dupes
* @param value
* @param score
* @param id
* @param {boolean=} append
* @param {string=} keyword
*/
Index.prototype.push_index = function (dupes, value, score, id, append, keyword) {
let arr = keyword ? this.ctx : this.map;
if (!dupes[value] || keyword && !dupes[value][keyword]) {
if (this.optimize) {
arr = arr[score];
}
if (keyword) {
dupes = dupes[value] || (dupes[value] = create_object());
dupes[keyword] = 1;
arr = arr[keyword] || (arr[keyword] = create_object());
} else {
dupes[value] = 1;
}
arr = arr[value] || (arr[value] = []);
if (!this.optimize) {
arr = arr[score] || (arr[score] = []);
}
if (!append || !arr.includes(id)) {
arr[arr.length] = id;
// add a reference to the register for fast updates
if (this.fastupdate) {
const tmp = this.register[id] || (this.register[id] = []);
tmp[tmp.length] = arr;
}
}
}
};
/**
* @param {string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @returns {Array<number|string>}
*/
Index.prototype.search = function (query, limit, options) {
if (!options) {
if (!limit && is_object(query)) {
options = /** @type {Object} */query;
query = options.query;
} else if (is_object(limit)) {
options = /** @type {Object} */limit;
}
}
let result = [],
length,
context,
suggest,
offset = 0;
if (options) {
query = options.query || query;
limit = options.limit;
offset = options.offset || 0;
context = options.context;
suggest = options.suggest;
}
if (query) {
query = /** @type {Array} */this.encode("" + query);
length = query.length;
// TODO: solve this in one single loop below
if (1 < length) {
const dupes = create_object(),
query_new = [];
for (let i = 0, count = 0, term; i < length; i++) {
term = query[i];
if (term && term.length >= this.minlength && !dupes[term]) {
// this fast path can just apply when not in memory-optimized mode
if (!this.optimize && !suggest && !this.map[term]) {
// fast path "not found"
return result;
} else {
query_new[count++] = term;
dupes[term] = 1;
}
}
}
query = query_new;
length = query.length;
}
}
if (!length) {
return result;
}
limit || (limit = 100);
let depth = this.depth && 1 < length && !1 !== context,
index = 0,
keyword;
if (depth) {
keyword = query[0];
index = 1;
} else {
if (1 < length) {
query.sort(sort_by_length_down);
}
}
for (let arr, term; index < length; index++) {
term = query[index];
// console.log(keyword);
// console.log(term);
// console.log("");
if (depth) {
arr = this.add_result(result, suggest, limit, offset, 2 === length, term, keyword);
// console.log(arr);
// console.log(result);
// when suggestion enabled just forward keyword if term was found
// as long as the result is empty forward the pointer also
if (!suggest || !1 !== arr || !result.length) {
keyword = term;
}
} else {
arr = this.add_result(result, suggest, limit, offset, 1 === length, term);
}
if (arr) {
return (/** @type {Array<number|string>} */arr
);
}
// apply suggestions on last loop or fallback
if (suggest && index == length - 1) {
let length = result.length;
if (!length) {
if (depth) {
// fallback to non-contextual search when no result was found
depth = 0;
index = -1;
continue;
}
return result;
} else if (1 === length) {
// fast path optimization
return single_result(result[0], limit, offset);
}
}
}
return intersect(result, limit, offset, suggest);
};
/**
* Returns an array when the result is done (to stop the process immediately),
* returns false when suggestions is enabled and no result was found,
* or returns nothing when a set was pushed successfully to the results
*
* @private
* @param {Array} result
* @param {Array} suggest
* @param {number} limit
* @param {number} offset
* @param {boolean} single_term
* @param {string} term
* @param {string=} keyword
* @return {Array<Array<string|number>>|boolean|undefined}
*/
Index.prototype.add_result = function (result, suggest, limit, offset, single_term, term, keyword) {
let word_arr = [],
arr = keyword ? this.ctx : this.map;
if (!this.optimize) {
arr = get_array(arr, term, keyword, this.bidirectional);
}
if (arr) {
let count = 0;
const arr_len = Math.min(arr.length, keyword ? this.resolution_ctx : this.resolution);
// relevance:
for (let x = 0, size = 0, tmp, len; x < arr_len; x++) {
tmp = arr[x];
if (tmp) {
if (this.optimize) {
tmp = get_array(tmp, term, keyword, this.bidirectional);
}
if (offset) {
if (tmp && single_term) {
len = tmp.length;
if (len <= offset) {
offset -= len;
tmp = null;
} else {
tmp = tmp.slice(offset);
offset = 0;
}
}
}
if (tmp) {
// keep score (sparse array):
//word_arr[x] = tmp;
// simplified score order:
word_arr[count++] = tmp;
if (single_term) {
size += tmp.length;
if (size >= limit) {
// fast path optimization
break;
}
}
}
}
}
if (count) {
if (single_term) {
// fast path optimization
// offset was already applied at this point
return single_result(word_arr, limit, 0);
}
result[result.length] = word_arr;
return;
}
}
// return an empty array will stop the loop,
// to prevent stop when using suggestions return a false value
return !suggest && word_arr;
};
function single_result(result, limit, offset) {
if (1 === result.length) {
result = result[0];
} else {
result = concat(result);
}
return offset || result.length > limit ? result.slice(offset, offset + limit) : result;
}
function get_array(arr, term, keyword, bidirectional) {
if (keyword) {
// the frequency of the starting letter is slightly less
// on the last half of the alphabet (m-z) in almost every latin language,
// so we sort downwards (https://en.wikipedia.org/wiki/Letter_frequency)
const swap = bidirectional && term > keyword;
arr = arr[swap ? term : keyword];
arr = arr && arr[swap ? keyword : term];
} else {
arr = arr[term];
}
return arr;
}
Index.prototype.contain = function (id) {
return !!this.register[id];
};
Index.prototype.update = function (id, content) {
return this.remove(id).add(id, content);
};
/**
* @param {boolean=} _skip_deletion
*/
Index.prototype.remove = function (id, _skip_deletion) {
const refs = this.register[id];
if (refs) {
if (this.fastupdate) {
// fast updates performs really fast but did not fully cleanup the key entries
for (let i = 0, tmp; i < refs.length; i++) {
tmp = refs[i];
tmp.splice(tmp.indexOf(id), 1);
}
} else {
remove_index(this.map, id, this.resolution, this.optimize);
if (this.depth) {
remove_index(this.ctx, id, this.resolution_ctx, this.optimize);
}
}
_skip_deletion || delete this.register[id];
if (this.cache) {
this.cache.del(id);
}
}
return this;
};
/**
* @param map
* @param id
* @param res
* @param optimize
* @param {number=} resolution
* @return {number}
*/
function remove_index(map, id, res, optimize, resolution) {
let count = 0;
if (is_array(map)) {
// the first array is the score array in both strategies
if (!resolution) {
resolution = Math.min(map.length, res);
for (let x = 0, arr; x < resolution; x++) {
arr = map[x];
if (arr) {
count = remove_index(arr, id, res, optimize, resolution);
if (!optimize && !count) {
// when not memory optimized the score index should removed
delete map[x];
}
}
}
} else {
const pos = map.indexOf(id);
if (-1 !== pos) {
// fast path, when length is 1 or lower then the whole field gets deleted
if (1 < map.length) {
map.splice(pos, 1);
count++;
}
} else {
count++;
}
}
} else {
for (let key in map) {
count = remove_index(map[key], id, res, optimize, resolution);
if (!count) {
delete map[key];
}
}
}
return count;
}
Index.prototype.searchCache = searchCache;
Index.prototype.export = exportIndex;
Index.prototype.import = importIndex;
apply_async(Index.prototype);

View File

@@ -0,0 +1,394 @@
import { create_object, concat } from "./common.js";
/**
* Implementation based on Array.includes() provides better performance,
* but it needs at least one word in the query which is less frequent.
* Also on large indexes it does not scale well performance-wise.
* This strategy also lacks of suggestion capabilities (matching & sorting).
*
* @param arrays
* @param limit
* @param offset
* @param {boolean|Array=} suggest
* @returns {Array}
*/
// export function intersect(arrays, limit, offset, suggest) {
//
// const length = arrays.length;
// let result = [];
// let check;
//
// // determine shortest array and collect results
// // from the sparse relevance arrays
//
// let smallest_size;
// let smallest_arr;
// let smallest_index;
//
// for(let x = 0; x < length; x++){
//
// const arr = arrays[x];
// const len = arr.length;
//
// let size = 0;
//
// for(let y = 0, tmp; y < len; y++){
//
// tmp = arr[y];
//
// if(tmp){
//
// size += tmp.length;
// }
// }
//
// if(!smallest_size || (size < smallest_size)){
//
// smallest_size = size;
// smallest_arr = arr;
// smallest_index = x;
// }
// }
//
// smallest_arr = smallest_arr.length === 1 ?
//
// smallest_arr[0]
// :
// concat(smallest_arr);
//
// if(suggest){
//
// suggest = [smallest_arr];
// check = create_object();
// }
//
// let size = 0;
// let steps = 0;
//
// // process terms in reversed order often results in better performance.
// // the outer loop must be the words array, using the
// // smallest array here disables the "fast fail" optimization.
//
// for(let x = length - 1; x >= 0; x--){
//
// if(x !== smallest_index){
//
// steps++;
//
// const word_arr = arrays[x];
// const word_arr_len = word_arr.length;
// const new_arr = [];
//
// let count = 0;
//
// for(let z = 0, id; z < smallest_arr.length; z++){
//
// id = smallest_arr[z];
//
// let found;
//
// // process relevance in forward order (direction is
// // important for adding IDs during the last round)
//
// for(let y = 0; y < word_arr_len; y++){
//
// const arr = word_arr[y];
//
// if(arr.length){
//
// found = arr.includes(id);
//
// if(found){
//
// // check if in last round
//
// if(steps === length - 1){
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[size++] = id;
//
// if(size === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
//
// if(suggest){
//
// check[id] = 1;
// }
// }
//
// break;
// }
// }
// }
//
// if(found){
//
// new_arr[count++] = id;
// }
// }
//
// if(suggest){
//
// suggest[steps] = new_arr;
// }
// else if(!count){
//
// return [];
// }
//
// smallest_arr = new_arr;
// }
// }
//
// if(suggest){
//
// // needs to iterate in reverse direction
//
// for(let x = suggest.length - 1, arr, len; x >= 0; x--){
//
// arr = suggest[x];
// len = arr && arr.length;
//
// if(len){
//
// for(let y = 0, id; y < len; y++){
//
// id = arr[y];
//
// if(!check[id]){
//
// check[id] = 1;
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[size++] = id;
//
// if(size === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
// }
// }
// }
// }
// }
//
// return result;
// }
/**
* Implementation based on Object[key] provides better suggestions
* capabilities and has less performance scaling issues on large indexes.
*
* @param arrays
* @param limit
* @param offset
* @param {boolean|Array=} suggest
* @returns {Array}
*/
export function intersect(arrays, limit, offset, suggest) {
const length = arrays.length;
let result = [],
check,
check_suggest,
size = 0;
if (suggest) {
suggest = [];
}
// process terms in reversed order often has advantage for the fast path "end reached".
// also a reversed order prioritize the order of words from a query.
for (let x = length - 1; 0 <= x; x--) {
const word_arr = arrays[x],
word_arr_len = word_arr.length,
check_new = create_object();
let found = !check;
// process relevance in forward order (direction is
// important for adding IDs during the last round)
for (let y = 0; y < word_arr_len; y++) {
const arr = word_arr[y],
arr_len = arr.length;
if (arr_len) {
// loop through IDs
for (let z = 0, check_idx, id; z < arr_len; z++) {
id = arr[z];
if (check) {
if (check[id]) {
// check if in last round
if (!x) {
if (offset) {
offset--;
} else {
result[size++] = id;
if (size === limit) {
// fast path "end reached"
return result;
}
}
}
if (x || suggest) {
check_new[id] = 1;
}
found = /* append: */ /* skip update: */ /* skip_update: */!0;
}
if (suggest) {
check_idx = (check_suggest[id] || 0) + 1;
check_suggest[id] = check_idx;
// do not adding IDs which are already included in the result (saves one loop)
// the first intersection match has the check index 2, so shift by -2
if (check_idx < length) {
const tmp = suggest[check_idx - 2] || (suggest[check_idx - 2] = []);
tmp[tmp.length] = id;
}
}
} else {
// pre-fill in first round
check_new[id] = 1;
}
}
}
}
if (suggest) {
// re-use the first pre-filled check for suggestions
check || (check_suggest = check_new);
} else if (!found) {
return [];
}
check = check_new;
}
if (suggest) {
// needs to iterate in reverse direction
for (let x = suggest.length - 1, arr, len; 0 <= x; x--) {
arr = suggest[x];
len = arr.length;
for (let y = 0, id; y < len; y++) {
id = arr[y];
if (!check[id]) {
if (offset) {
offset--;
} else {
result[size++] = id;
if (size === limit) {
// fast path "end reached"
return result;
}
}
check[id] = 1;
}
}
}
}
return result;
}
/**
* @param mandatory
* @param arrays
* @returns {Array}
*/
export function intersect_union(mandatory, arrays) {
const check = create_object(),
union = create_object(),
result = [];
for (let x = 0; x < mandatory.length; x++) {
check[mandatory[x]] = 1;
}
for (let x = 0, arr; x < arrays.length; x++) {
arr = arrays[x];
for (let y = 0, id; y < arr.length; y++) {
id = arr[y];
if (check[id]) {
if (!union[id]) {
union[id] = 1;
result[result.length] = id;
}
}
}
}
return result;
}

View File

@@ -0,0 +1,321 @@
import { IndexInterface } from "./type.js";
import { create_object, get_keys } from "./common.js";
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} _collapse
* @returns {string|Array<string>}
* @this IndexInterface
*/
export function pipeline(str, normalize, split, _collapse) {
if (str) {
if (normalize) {
str = replace(str, /** @type {Array<string|RegExp>} */normalize);
}
if (this.matcher) {
str = replace(str, this.matcher);
}
if (this.stemmer && 1 < str.length) {
str = replace(str, this.stemmer);
}
if (_collapse && 1 < str.length) {
str = collapse(str);
}
if (split || "" === split) {
const words = str.split( /** @type {string|RegExp} */split);
return this.filter ? filter(words, this.filter) : words;
}
}
return str;
}
// TODO improve normalize + remove non-delimited chars like in "I'm" + split on whitespace+
export const regex_whitespace = /[\p{Z}\p{S}\p{P}\p{C}]+/u;
// https://github.com/nextapps-de/flexsearch/pull/414
//export const regex_whitespace = /[\s\xA0\u2000-\u200B\u2028\u2029\u3000\ufeff!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/
const regex_normalize = /[\u0300-\u036f]/g;
export function normalize(str) {
if (str.normalize) {
str = str.normalize("NFD").replace(regex_normalize, "");
}
return str;
}
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} _collapse
* @returns {string|Array<string>}
*/
// FlexSearch.prototype.pipeline = function(str, normalize, split, _collapse){
//
// if(str){
//
// if(normalize && str){
//
// str = replace(str, /** @type {Array<string|RegExp>} */ (normalize));
// }
//
// if(str && this.matcher){
//
// str = replace(str, this.matcher);
// }
//
// if(this.stemmer && str.length > 1){
//
// str = replace(str, this.stemmer);
// }
//
// if(_collapse && str.length > 1){
//
// str = collapse(str);
// }
//
// if(str){
//
// if(split || (split === "")){
//
// const words = str.split(/** @type {string|RegExp} */ (split));
//
// return this.filter ? filter(words, this.filter) : words;
// }
// }
// }
//
// return str;
// };
// export function pipeline(str, normalize, matcher, stemmer, split, _filter, _collapse){
//
// if(str){
//
// if(normalize && str){
//
// str = replace(str, normalize);
// }
//
// if(matcher && str){
//
// str = replace(str, matcher);
// }
//
// if(stemmer && str.length > 1){
//
// str = replace(str, stemmer);
// }
//
// if(_collapse && str.length > 1){
//
// str = collapse(str);
// }
//
// if(str){
//
// if(split !== false){
//
// str = str.split(split);
//
// if(_filter){
//
// str = filter(str, _filter);
// }
// }
// }
// }
//
// return str;
// }
/**
* @param {Array<string>} words
* @returns {Object<string, string>}
*/
export function init_filter(words) {
const filter = create_object();
for (let i = 0, length = words.length; i < length; i++) {
filter[words[i]] = 1;
}
return filter;
}
/**
* @param {!Object<string, string>} obj
* @param {boolean} is_stemmer
* @returns {Array}
*/
export function init_stemmer_or_matcher(obj, is_stemmer) {
const keys = get_keys(obj),
length = keys.length,
final = [];
let removal = "",
count = 0;
for (let i = 0, key, tmp; i < length; i++) {
key = keys[i];
tmp = obj[key];
if (tmp) {
final[count++] = regex(is_stemmer ? "(?!\\b)" + key + "(\\b|_)" : key);
final[count++] = tmp;
} else {
removal += (removal ? "|" : "") + key;
}
}
if (removal) {
final[count++] = regex(is_stemmer ? "(?!\\b)(" + removal + ")(\\b|_)" : "(" + removal + ")");
final[count] = "";
}
return final;
}
/**
* @param {!string} str
* @param {Array} regexp
* @returns {string}
*/
export function replace(str, regexp) {
for (let i = 0, len = regexp.length; i < len; i += 2) {
str = str.replace(regexp[i], regexp[i + 1]);
if (!str) {
break;
}
}
return str;
}
/**
* @param {!string} str
* @returns {RegExp}
*/
export function regex(str) {
return new RegExp(str, "g");
}
/**
* Regex: replace(/(?:(\w)(?:\1)*)/g, "$1")
* @param {!string} string
* @returns {string}
*/
export function collapse(string) {
let final = "",
prev = "";
for (let i = 0, len = string.length, char; i < len; i++) {
if ((char = string[i]) !== prev) {
final += prev = char;
}
}
return final;
}
// TODO using fast-swap
export function filter(words, map) {
const length = words.length,
filtered = [];
for (let i = 0, count = 0; i < length; i++) {
const word = words[i];
if (word && !map[word]) {
filtered[count++] = word;
}
}
return filtered;
}
// const chars = {a:1, e:1, i:1, o:1, u:1, y:1};
//
// function collapse_repeating_chars(string){
//
// let collapsed_string = "",
// char_prev = "",
// char_next = "";
//
// for(let i = 0; i < string.length; i++){
//
// const char = string[i];
//
// if(char !== char_prev){
//
// if(i && (char === "h")){
//
// if((chars[char_prev] && chars[char_next]) || (char_prev === " ")){
//
// collapsed_string += char;
// }
// }
// else{
//
// collapsed_string += char;
// }
// }
//
// char_next = (
//
// (i === (string.length - 1)) ?
//
// ""
// :
// string[i + 1]
// );
//
// char_prev = char;
// }
//
// return collapsed_string;
// }

View File

@@ -0,0 +1,27 @@
import { IndexInterface } from "../../type.js";
import { pipeline } from "../../lang.js";
export const rtl = /* append: */ /* skip update: */ /* skip_update: */!0;
export const tokenize = "";
export default {
encode: encode,
rtl: !0
};
const regex = /[\x00-\x7F]+/g,
split = /\s+/;
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
return pipeline.call(this,
/* string: */("" + str).replace(regex, " "),
/* normalize: */
/* collapse: */!1,
/* split: */split, !1);
}

View File

@@ -0,0 +1,41 @@
/**
* http://www.ranks.nl/stopwords
* @type {Array<string>}
*/
export const filter = ["aber", "als", "am", "an", "auch", "auf", "aus", "bei", "bin", "bis", "bist", "da", "dadurch", "daher", "darum", "das", "daß", "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", "für", "hatte", "hatten", "hattest", "hattet", "hier", "hinter", "ich", "ihr", "ihre", "im", "in", "ist", "ja", "jede", "jedem", "jeden", "jeder", "jedes", "jener", "jenes", "jetzt", "kann", "kannst", "können", "könnt", "machen", "mein", "meine", "mit", "muß", "mußt", "musst", "müssen", "müßt", "nach", "nachdem", "nein", "nicht", "nun", "oder", "seid", "sein", "seine", "sich", "sie", "sind", "soll", "sollen", "sollst", "sollt", "sonst", "soweit", "sowie", "und", "unser", "unsere", "unter", "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", "über"];
/**
* @type {Object<string, string>}
*/
export const stemmer = {
niss: "",
isch: "",
lich: "",
heit: "",
keit: "",
end: "",
ung: "",
est: "",
ern: "",
em: "",
er: "",
en: "",
es: "",
st: "",
ig: "",
ik: "",
e: "",
s: ""
};
export const matcher = {};
export default {
filter: filter,
stemmer: stemmer,
matcher: matcher
};

View File

@@ -0,0 +1,26 @@
import { IndexInterface } from "../../type.js";
import { pipeline } from "../../lang.js";
export const rtl = /* normalize: */ /* collapse: */
/* normalize: */
/* collapse: */!1;
export const tokenize = "strict";
export default {
encode: encode,
rtl: !1,
tokenize: "strict"
};
const regex = /[\x00-\x7F]+/g;
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
return pipeline.call(this,
/* string: */("" + str).replace(regex, ""), !1,
/* split: */"", !1);
}

View File

@@ -0,0 +1,27 @@
import { IndexInterface } from "../../type.js";
import { pipeline } from "../../lang.js";
export const rtl = /* normalize: */ /* collapse: */ /* normalize: */ /* collapse: */
/* normalize: */
/* collapse: */!1;
export const tokenize = "";
export default {
encode: encode,
rtl: !1
};
const regex = /[\x00-\x7F]+/g,
split = /\s+/;
/**
* @param {string|number} str
* @this IndexInterface
*/
export function encode(str) {
return pipeline.call(this,
/* string: */("" + str).replace(regex, " "), !1,
/* split: */split, !1);
}

Some files were not shown because too many files have changed in this diff Show More