@eox/itemfilter 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eox-itemfilter.js +1079 -1107
- package/dist/eox-itemfilter.umd.cjs +159 -1221
- package/package.json +1 -1
- package/test/general.cy.ts +11 -1
- package/test/general.html +8 -2
- package/test/reducedWidth.cy.ts +32 -0
|
@@ -1,1233 +1,171 @@
|
|
|
1
|
-
(function (E, m) {
|
|
2
|
-
typeof exports == "object" && typeof module < "u"
|
|
3
|
-
? m(exports)
|
|
4
|
-
: typeof define == "function" && define.amd
|
|
5
|
-
? define(["exports"], m)
|
|
6
|
-
: ((E = typeof globalThis < "u" ? globalThis : E || self),
|
|
7
|
-
m((E["eox-itemfilter"] = {})));
|
|
8
|
-
})(this, function (E) {
|
|
9
|
-
"use strict";
|
|
10
|
-
var Ze = Object.defineProperty;
|
|
11
|
-
var et = (E, m, R) =>
|
|
12
|
-
m in E
|
|
13
|
-
? Ze(E, m, { enumerable: !0, configurable: !0, writable: !0, value: R })
|
|
14
|
-
: (E[m] = R);
|
|
15
|
-
var _ = (E, m, R) => (et(E, typeof m != "symbol" ? m + "" : m, R), R);
|
|
16
|
-
function m(s) {
|
|
17
|
-
return Array.isArray ? Array.isArray(s) : J(s) === "[object Array]";
|
|
18
|
-
}
|
|
19
|
-
const R = 1 / 0;
|
|
20
|
-
function de(s) {
|
|
21
|
-
if (typeof s == "string") return s;
|
|
22
|
-
let e = s + "";
|
|
23
|
-
return e == "0" && 1 / s == -R ? "-0" : e;
|
|
24
|
-
}
|
|
25
|
-
function ge(s) {
|
|
26
|
-
return s == null ? "" : de(s);
|
|
27
|
-
}
|
|
28
|
-
function A(s) {
|
|
29
|
-
return typeof s == "string";
|
|
30
|
-
}
|
|
31
|
-
function Q(s) {
|
|
32
|
-
return typeof s == "number";
|
|
33
|
-
}
|
|
34
|
-
function pe(s) {
|
|
35
|
-
return s === !0 || s === !1 || (me(s) && J(s) == "[object Boolean]");
|
|
36
|
-
}
|
|
37
|
-
function X(s) {
|
|
38
|
-
return typeof s == "object";
|
|
39
|
-
}
|
|
40
|
-
function me(s) {
|
|
41
|
-
return X(s) && s !== null;
|
|
42
|
-
}
|
|
43
|
-
function M(s) {
|
|
44
|
-
return s != null;
|
|
45
|
-
}
|
|
46
|
-
function H(s) {
|
|
47
|
-
return !s.trim().length;
|
|
48
|
-
}
|
|
49
|
-
function J(s) {
|
|
50
|
-
return s == null
|
|
51
|
-
? s === void 0
|
|
52
|
-
? "[object Undefined]"
|
|
53
|
-
: "[object Null]"
|
|
54
|
-
: Object.prototype.toString.call(s);
|
|
55
|
-
}
|
|
56
|
-
const tt = "Extended search is not available",
|
|
57
|
-
ye = "Incorrect 'index' type",
|
|
58
|
-
Me = (s) => `Invalid value for key ${s}`,
|
|
59
|
-
Ee = (s) => `Pattern length exceeds max of ${s}.`,
|
|
60
|
-
xe = (s) => `Missing ${s} property in key`,
|
|
61
|
-
Se = (s) => `Property 'weight' in key '${s}' must be a positive integer`,
|
|
62
|
-
q = Object.prototype.hasOwnProperty;
|
|
63
|
-
class Ae {
|
|
64
|
-
constructor(e) {
|
|
65
|
-
(this._keys = []), (this._keyMap = {});
|
|
66
|
-
let t = 0;
|
|
67
|
-
e.forEach((r) => {
|
|
68
|
-
let n = Z(r);
|
|
69
|
-
(t += n.weight),
|
|
70
|
-
this._keys.push(n),
|
|
71
|
-
(this._keyMap[n.id] = n),
|
|
72
|
-
(t += n.weight);
|
|
73
|
-
}),
|
|
74
|
-
this._keys.forEach((r) => {
|
|
75
|
-
r.weight /= t;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
get(e) {
|
|
79
|
-
return this._keyMap[e];
|
|
80
|
-
}
|
|
81
|
-
keys() {
|
|
82
|
-
return this._keys;
|
|
83
|
-
}
|
|
84
|
-
toJSON() {
|
|
85
|
-
return JSON.stringify(this._keys);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function Z(s) {
|
|
89
|
-
let e = null,
|
|
90
|
-
t = null,
|
|
91
|
-
r = null,
|
|
92
|
-
n = 1,
|
|
93
|
-
i = null;
|
|
94
|
-
if (A(s) || m(s)) (r = s), (e = ee(s)), (t = B(s));
|
|
95
|
-
else {
|
|
96
|
-
if (!q.call(s, "name")) throw new Error(xe("name"));
|
|
97
|
-
const c = s.name;
|
|
98
|
-
if (((r = c), q.call(s, "weight") && ((n = s.weight), n <= 0)))
|
|
99
|
-
throw new Error(Se(c));
|
|
100
|
-
(e = ee(c)), (t = B(c)), (i = s.getFn);
|
|
101
|
-
}
|
|
102
|
-
return { path: e, id: t, weight: n, src: r, getFn: i };
|
|
103
|
-
}
|
|
104
|
-
function ee(s) {
|
|
105
|
-
return m(s) ? s : s.split(".");
|
|
106
|
-
}
|
|
107
|
-
function B(s) {
|
|
108
|
-
return m(s) ? s.join(".") : s;
|
|
109
|
-
}
|
|
110
|
-
function Ie(s, e) {
|
|
111
|
-
let t = [],
|
|
112
|
-
r = !1;
|
|
113
|
-
const n = (i, c, o) => {
|
|
114
|
-
if (M(i))
|
|
115
|
-
if (!c[o]) t.push(i);
|
|
116
|
-
else {
|
|
117
|
-
let a = c[o];
|
|
118
|
-
const h = i[a];
|
|
119
|
-
if (!M(h)) return;
|
|
120
|
-
if (o === c.length - 1 && (A(h) || Q(h) || pe(h))) t.push(ge(h));
|
|
121
|
-
else if (m(h)) {
|
|
122
|
-
r = !0;
|
|
123
|
-
for (let l = 0, u = h.length; l < u; l += 1) n(h[l], c, o + 1);
|
|
124
|
-
} else c.length && n(h, c, o + 1);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
return n(s, A(e) ? e.split(".") : e, 0), r ? t : t[0];
|
|
128
|
-
}
|
|
129
|
-
var f = {
|
|
130
|
-
...{
|
|
131
|
-
isCaseSensitive: !1,
|
|
132
|
-
includeScore: !1,
|
|
133
|
-
keys: [],
|
|
134
|
-
shouldSort: !0,
|
|
135
|
-
sortFn: (s, e) =>
|
|
136
|
-
s.score === e.score
|
|
137
|
-
? s.idx < e.idx
|
|
138
|
-
? -1
|
|
139
|
-
: 1
|
|
140
|
-
: s.score < e.score
|
|
141
|
-
? -1
|
|
142
|
-
: 1,
|
|
143
|
-
},
|
|
144
|
-
...{ includeMatches: !1, findAllMatches: !1, minMatchCharLength: 1 },
|
|
145
|
-
...{ location: 0, threshold: 0.6, distance: 100 },
|
|
146
|
-
...{
|
|
147
|
-
useExtendedSearch: !1,
|
|
148
|
-
getFn: Ie,
|
|
149
|
-
ignoreLocation: !1,
|
|
150
|
-
ignoreFieldNorm: !1,
|
|
151
|
-
fieldNormWeight: 1,
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
const _e = /[^ ]+/g;
|
|
155
|
-
function we(s = 1, e = 3) {
|
|
156
|
-
const t = new Map(),
|
|
157
|
-
r = Math.pow(10, e);
|
|
158
|
-
return {
|
|
159
|
-
get(n) {
|
|
160
|
-
const i = n.match(_e).length;
|
|
161
|
-
if (t.has(i)) return t.get(i);
|
|
162
|
-
const c = 1 / Math.pow(i, 0.5 * s),
|
|
163
|
-
o = parseFloat(Math.round(c * r) / r);
|
|
164
|
-
return t.set(i, o), o;
|
|
165
|
-
},
|
|
166
|
-
clear() {
|
|
167
|
-
t.clear();
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
class K {
|
|
172
|
-
constructor({
|
|
173
|
-
getFn: e = f.getFn,
|
|
174
|
-
fieldNormWeight: t = f.fieldNormWeight,
|
|
175
|
-
} = {}) {
|
|
176
|
-
(this.norm = we(t, 3)),
|
|
177
|
-
(this.getFn = e),
|
|
178
|
-
(this.isCreated = !1),
|
|
179
|
-
this.setIndexRecords();
|
|
180
|
-
}
|
|
181
|
-
setSources(e = []) {
|
|
182
|
-
this.docs = e;
|
|
183
|
-
}
|
|
184
|
-
setIndexRecords(e = []) {
|
|
185
|
-
this.records = e;
|
|
186
|
-
}
|
|
187
|
-
setKeys(e = []) {
|
|
188
|
-
(this.keys = e),
|
|
189
|
-
(this._keysMap = {}),
|
|
190
|
-
e.forEach((t, r) => {
|
|
191
|
-
this._keysMap[t.id] = r;
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
create() {
|
|
195
|
-
this.isCreated ||
|
|
196
|
-
!this.docs.length ||
|
|
197
|
-
((this.isCreated = !0),
|
|
198
|
-
A(this.docs[0])
|
|
199
|
-
? this.docs.forEach((e, t) => {
|
|
200
|
-
this._addString(e, t);
|
|
201
|
-
})
|
|
202
|
-
: this.docs.forEach((e, t) => {
|
|
203
|
-
this._addObject(e, t);
|
|
204
|
-
}),
|
|
205
|
-
this.norm.clear());
|
|
206
|
-
}
|
|
207
|
-
add(e) {
|
|
208
|
-
const t = this.size();
|
|
209
|
-
A(e) ? this._addString(e, t) : this._addObject(e, t);
|
|
210
|
-
}
|
|
211
|
-
removeAt(e) {
|
|
212
|
-
this.records.splice(e, 1);
|
|
213
|
-
for (let t = e, r = this.size(); t < r; t += 1) this.records[t].i -= 1;
|
|
214
|
-
}
|
|
215
|
-
getValueForItemAtKeyId(e, t) {
|
|
216
|
-
return e[this._keysMap[t]];
|
|
217
|
-
}
|
|
218
|
-
size() {
|
|
219
|
-
return this.records.length;
|
|
220
|
-
}
|
|
221
|
-
_addString(e, t) {
|
|
222
|
-
if (!M(e) || H(e)) return;
|
|
223
|
-
let r = { v: e, i: t, n: this.norm.get(e) };
|
|
224
|
-
this.records.push(r);
|
|
225
|
-
}
|
|
226
|
-
_addObject(e, t) {
|
|
227
|
-
let r = { i: t, $: {} };
|
|
228
|
-
this.keys.forEach((n, i) => {
|
|
229
|
-
let c = n.getFn ? n.getFn(e) : this.getFn(e, n.path);
|
|
230
|
-
if (M(c)) {
|
|
231
|
-
if (m(c)) {
|
|
232
|
-
let o = [];
|
|
233
|
-
const a = [{ nestedArrIndex: -1, value: c }];
|
|
234
|
-
for (; a.length; ) {
|
|
235
|
-
const { nestedArrIndex: h, value: l } = a.pop();
|
|
236
|
-
if (M(l))
|
|
237
|
-
if (A(l) && !H(l)) {
|
|
238
|
-
let u = { v: l, i: h, n: this.norm.get(l) };
|
|
239
|
-
o.push(u);
|
|
240
|
-
} else
|
|
241
|
-
m(l) &&
|
|
242
|
-
l.forEach((u, d) => {
|
|
243
|
-
a.push({ nestedArrIndex: d, value: u });
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
r.$[i] = o;
|
|
247
|
-
} else if (A(c) && !H(c)) {
|
|
248
|
-
let o = { v: c, n: this.norm.get(c) };
|
|
249
|
-
r.$[i] = o;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}),
|
|
253
|
-
this.records.push(r);
|
|
254
|
-
}
|
|
255
|
-
toJSON() {
|
|
256
|
-
return { keys: this.keys, records: this.records };
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function te(
|
|
260
|
-
s,
|
|
261
|
-
e,
|
|
262
|
-
{ getFn: t = f.getFn, fieldNormWeight: r = f.fieldNormWeight } = {}
|
|
263
|
-
) {
|
|
264
|
-
const n = new K({ getFn: t, fieldNormWeight: r });
|
|
265
|
-
return n.setKeys(s.map(Z)), n.setSources(e), n.create(), n;
|
|
266
|
-
}
|
|
267
|
-
function Le(
|
|
268
|
-
s,
|
|
269
|
-
{ getFn: e = f.getFn, fieldNormWeight: t = f.fieldNormWeight } = {}
|
|
270
|
-
) {
|
|
271
|
-
const { keys: r, records: n } = s,
|
|
272
|
-
i = new K({ getFn: e, fieldNormWeight: t });
|
|
273
|
-
return i.setKeys(r), i.setIndexRecords(n), i;
|
|
274
|
-
}
|
|
275
|
-
function v(
|
|
276
|
-
s,
|
|
277
|
-
{
|
|
278
|
-
errors: e = 0,
|
|
279
|
-
currentLocation: t = 0,
|
|
280
|
-
expectedLocation: r = 0,
|
|
281
|
-
distance: n = f.distance,
|
|
282
|
-
ignoreLocation: i = f.ignoreLocation,
|
|
283
|
-
} = {}
|
|
284
|
-
) {
|
|
285
|
-
const c = e / s.length;
|
|
286
|
-
if (i) return c;
|
|
287
|
-
const o = Math.abs(r - t);
|
|
288
|
-
return n ? c + o / n : o ? 1 : c;
|
|
289
|
-
}
|
|
290
|
-
function be(s = [], e = f.minMatchCharLength) {
|
|
291
|
-
let t = [],
|
|
292
|
-
r = -1,
|
|
293
|
-
n = -1,
|
|
294
|
-
i = 0;
|
|
295
|
-
for (let c = s.length; i < c; i += 1) {
|
|
296
|
-
let o = s[i];
|
|
297
|
-
o && r === -1
|
|
298
|
-
? (r = i)
|
|
299
|
-
: !o &&
|
|
300
|
-
r !== -1 &&
|
|
301
|
-
((n = i - 1), n - r + 1 >= e && t.push([r, n]), (r = -1));
|
|
302
|
-
}
|
|
303
|
-
return s[i - 1] && i - r >= e && t.push([r, i - 1]), t;
|
|
304
|
-
}
|
|
305
|
-
const k = 32;
|
|
306
|
-
function Re(
|
|
307
|
-
s,
|
|
308
|
-
e,
|
|
309
|
-
t,
|
|
310
|
-
{
|
|
311
|
-
location: r = f.location,
|
|
312
|
-
distance: n = f.distance,
|
|
313
|
-
threshold: i = f.threshold,
|
|
314
|
-
findAllMatches: c = f.findAllMatches,
|
|
315
|
-
minMatchCharLength: o = f.minMatchCharLength,
|
|
316
|
-
includeMatches: a = f.includeMatches,
|
|
317
|
-
ignoreLocation: h = f.ignoreLocation,
|
|
318
|
-
} = {}
|
|
319
|
-
) {
|
|
320
|
-
if (e.length > k) throw new Error(Ee(k));
|
|
321
|
-
const l = e.length,
|
|
322
|
-
u = s.length,
|
|
323
|
-
d = Math.max(0, Math.min(r, u));
|
|
324
|
-
let g = i,
|
|
325
|
-
p = d;
|
|
326
|
-
const y = o > 1 || a,
|
|
327
|
-
T = y ? Array(u) : [];
|
|
328
|
-
let I;
|
|
329
|
-
for (; (I = s.indexOf(e, p)) > -1; ) {
|
|
330
|
-
let x = v(e, {
|
|
331
|
-
currentLocation: I,
|
|
332
|
-
expectedLocation: d,
|
|
333
|
-
distance: n,
|
|
334
|
-
ignoreLocation: h,
|
|
335
|
-
});
|
|
336
|
-
if (((g = Math.min(x, g)), (p = I + l), y)) {
|
|
337
|
-
let L = 0;
|
|
338
|
-
for (; L < l; ) (T[I + L] = 1), (L += 1);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
p = -1;
|
|
342
|
-
let N = [],
|
|
343
|
-
O = 1,
|
|
344
|
-
P = l + u;
|
|
345
|
-
const qe = 1 << (l - 1);
|
|
346
|
-
for (let x = 0; x < l; x += 1) {
|
|
347
|
-
let L = 0,
|
|
348
|
-
b = P;
|
|
349
|
-
for (; L < b; )
|
|
350
|
-
v(e, {
|
|
351
|
-
errors: x,
|
|
352
|
-
currentLocation: d + b,
|
|
353
|
-
expectedLocation: d,
|
|
354
|
-
distance: n,
|
|
355
|
-
ignoreLocation: h,
|
|
356
|
-
}) <= g
|
|
357
|
-
? (L = b)
|
|
358
|
-
: (P = b),
|
|
359
|
-
(b = Math.floor((P - L) / 2 + L));
|
|
360
|
-
P = b;
|
|
361
|
-
let ue = Math.max(1, d - b + 1),
|
|
362
|
-
U = c ? u : Math.min(d + b, u) + l,
|
|
363
|
-
C = Array(U + 2);
|
|
364
|
-
C[U + 1] = (1 << x) - 1;
|
|
365
|
-
for (let S = U; S >= ue; S -= 1) {
|
|
366
|
-
let j = S - 1,
|
|
367
|
-
fe = t[s.charAt(j)];
|
|
368
|
-
if (
|
|
369
|
-
(y && (T[j] = +!!fe),
|
|
370
|
-
(C[S] = ((C[S + 1] << 1) | 1) & fe),
|
|
371
|
-
x && (C[S] |= ((N[S + 1] | N[S]) << 1) | 1 | N[S + 1]),
|
|
372
|
-
C[S] & qe &&
|
|
373
|
-
((O = v(e, {
|
|
374
|
-
errors: x,
|
|
375
|
-
currentLocation: j,
|
|
376
|
-
expectedLocation: d,
|
|
377
|
-
distance: n,
|
|
378
|
-
ignoreLocation: h,
|
|
379
|
-
})),
|
|
380
|
-
O <= g))
|
|
381
|
-
) {
|
|
382
|
-
if (((g = O), (p = j), p <= d)) break;
|
|
383
|
-
ue = Math.max(1, 2 * d - p);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (
|
|
387
|
-
v(e, {
|
|
388
|
-
errors: x + 1,
|
|
389
|
-
currentLocation: d,
|
|
390
|
-
expectedLocation: d,
|
|
391
|
-
distance: n,
|
|
392
|
-
ignoreLocation: h,
|
|
393
|
-
}) > g
|
|
394
|
-
)
|
|
395
|
-
break;
|
|
396
|
-
N = C;
|
|
397
|
-
}
|
|
398
|
-
const G = { isMatch: p >= 0, score: Math.max(0.001, O) };
|
|
399
|
-
if (y) {
|
|
400
|
-
const x = be(T, o);
|
|
401
|
-
x.length ? a && (G.indices = x) : (G.isMatch = !1);
|
|
402
|
-
}
|
|
403
|
-
return G;
|
|
404
|
-
}
|
|
405
|
-
function ke(s) {
|
|
406
|
-
let e = {};
|
|
407
|
-
for (let t = 0, r = s.length; t < r; t += 1) {
|
|
408
|
-
const n = s.charAt(t);
|
|
409
|
-
e[n] = (e[n] || 0) | (1 << (r - t - 1));
|
|
410
|
-
}
|
|
411
|
-
return e;
|
|
412
|
-
}
|
|
413
|
-
class se {
|
|
414
|
-
constructor(
|
|
415
|
-
e,
|
|
416
|
-
{
|
|
417
|
-
location: t = f.location,
|
|
418
|
-
threshold: r = f.threshold,
|
|
419
|
-
distance: n = f.distance,
|
|
420
|
-
includeMatches: i = f.includeMatches,
|
|
421
|
-
findAllMatches: c = f.findAllMatches,
|
|
422
|
-
minMatchCharLength: o = f.minMatchCharLength,
|
|
423
|
-
isCaseSensitive: a = f.isCaseSensitive,
|
|
424
|
-
ignoreLocation: h = f.ignoreLocation,
|
|
425
|
-
} = {}
|
|
426
|
-
) {
|
|
427
|
-
if (
|
|
428
|
-
((this.options = {
|
|
429
|
-
location: t,
|
|
430
|
-
threshold: r,
|
|
431
|
-
distance: n,
|
|
432
|
-
includeMatches: i,
|
|
433
|
-
findAllMatches: c,
|
|
434
|
-
minMatchCharLength: o,
|
|
435
|
-
isCaseSensitive: a,
|
|
436
|
-
ignoreLocation: h,
|
|
437
|
-
}),
|
|
438
|
-
(this.pattern = a ? e : e.toLowerCase()),
|
|
439
|
-
(this.chunks = []),
|
|
440
|
-
!this.pattern.length)
|
|
441
|
-
)
|
|
442
|
-
return;
|
|
443
|
-
const l = (d, g) => {
|
|
444
|
-
this.chunks.push({ pattern: d, alphabet: ke(d), startIndex: g });
|
|
445
|
-
},
|
|
446
|
-
u = this.pattern.length;
|
|
447
|
-
if (u > k) {
|
|
448
|
-
let d = 0;
|
|
449
|
-
const g = u % k,
|
|
450
|
-
p = u - g;
|
|
451
|
-
for (; d < p; ) l(this.pattern.substr(d, k), d), (d += k);
|
|
452
|
-
if (g) {
|
|
453
|
-
const y = u - k;
|
|
454
|
-
l(this.pattern.substr(y), y);
|
|
455
|
-
}
|
|
456
|
-
} else l(this.pattern, 0);
|
|
457
|
-
}
|
|
458
|
-
searchIn(e) {
|
|
459
|
-
const { isCaseSensitive: t, includeMatches: r } = this.options;
|
|
460
|
-
if ((t || (e = e.toLowerCase()), this.pattern === e)) {
|
|
461
|
-
let p = { isMatch: !0, score: 0 };
|
|
462
|
-
return r && (p.indices = [[0, e.length - 1]]), p;
|
|
463
|
-
}
|
|
464
|
-
const {
|
|
465
|
-
location: n,
|
|
466
|
-
distance: i,
|
|
467
|
-
threshold: c,
|
|
468
|
-
findAllMatches: o,
|
|
469
|
-
minMatchCharLength: a,
|
|
470
|
-
ignoreLocation: h,
|
|
471
|
-
} = this.options;
|
|
472
|
-
let l = [],
|
|
473
|
-
u = 0,
|
|
474
|
-
d = !1;
|
|
475
|
-
this.chunks.forEach(({ pattern: p, alphabet: y, startIndex: T }) => {
|
|
476
|
-
const {
|
|
477
|
-
isMatch: I,
|
|
478
|
-
score: N,
|
|
479
|
-
indices: O,
|
|
480
|
-
} = Re(e, p, y, {
|
|
481
|
-
location: n + T,
|
|
482
|
-
distance: i,
|
|
483
|
-
threshold: c,
|
|
484
|
-
findAllMatches: o,
|
|
485
|
-
minMatchCharLength: a,
|
|
486
|
-
includeMatches: r,
|
|
487
|
-
ignoreLocation: h,
|
|
488
|
-
});
|
|
489
|
-
I && (d = !0), (u += N), I && O && (l = [...l, ...O]);
|
|
490
|
-
});
|
|
491
|
-
let g = { isMatch: d, score: d ? u / this.chunks.length : 1 };
|
|
492
|
-
return d && r && (g.indices = l), g;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
class w {
|
|
496
|
-
constructor(e) {
|
|
497
|
-
this.pattern = e;
|
|
498
|
-
}
|
|
499
|
-
static isMultiMatch(e) {
|
|
500
|
-
return ne(e, this.multiRegex);
|
|
501
|
-
}
|
|
502
|
-
static isSingleMatch(e) {
|
|
503
|
-
return ne(e, this.singleRegex);
|
|
504
|
-
}
|
|
505
|
-
search() {}
|
|
506
|
-
}
|
|
507
|
-
function ne(s, e) {
|
|
508
|
-
const t = s.match(e);
|
|
509
|
-
return t ? t[1] : null;
|
|
510
|
-
}
|
|
511
|
-
class Te extends w {
|
|
512
|
-
constructor(e) {
|
|
513
|
-
super(e);
|
|
514
|
-
}
|
|
515
|
-
static get type() {
|
|
516
|
-
return "exact";
|
|
517
|
-
}
|
|
518
|
-
static get multiRegex() {
|
|
519
|
-
return /^="(.*)"$/;
|
|
520
|
-
}
|
|
521
|
-
static get singleRegex() {
|
|
522
|
-
return /^=(.*)$/;
|
|
523
|
-
}
|
|
524
|
-
search(e) {
|
|
525
|
-
const t = e === this.pattern;
|
|
526
|
-
return {
|
|
527
|
-
isMatch: t,
|
|
528
|
-
score: t ? 0 : 1,
|
|
529
|
-
indices: [0, this.pattern.length - 1],
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
class Oe extends w {
|
|
534
|
-
constructor(e) {
|
|
535
|
-
super(e);
|
|
536
|
-
}
|
|
537
|
-
static get type() {
|
|
538
|
-
return "inverse-exact";
|
|
539
|
-
}
|
|
540
|
-
static get multiRegex() {
|
|
541
|
-
return /^!"(.*)"$/;
|
|
542
|
-
}
|
|
543
|
-
static get singleRegex() {
|
|
544
|
-
return /^!(.*)$/;
|
|
545
|
-
}
|
|
546
|
-
search(e) {
|
|
547
|
-
const r = e.indexOf(this.pattern) === -1;
|
|
548
|
-
return { isMatch: r, score: r ? 0 : 1, indices: [0, e.length - 1] };
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
class $e extends w {
|
|
552
|
-
constructor(e) {
|
|
553
|
-
super(e);
|
|
554
|
-
}
|
|
555
|
-
static get type() {
|
|
556
|
-
return "prefix-exact";
|
|
557
|
-
}
|
|
558
|
-
static get multiRegex() {
|
|
559
|
-
return /^\^"(.*)"$/;
|
|
560
|
-
}
|
|
561
|
-
static get singleRegex() {
|
|
562
|
-
return /^\^(.*)$/;
|
|
563
|
-
}
|
|
564
|
-
search(e) {
|
|
565
|
-
const t = e.startsWith(this.pattern);
|
|
566
|
-
return {
|
|
567
|
-
isMatch: t,
|
|
568
|
-
score: t ? 0 : 1,
|
|
569
|
-
indices: [0, this.pattern.length - 1],
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
class Ne extends w {
|
|
574
|
-
constructor(e) {
|
|
575
|
-
super(e);
|
|
576
|
-
}
|
|
577
|
-
static get type() {
|
|
578
|
-
return "inverse-prefix-exact";
|
|
579
|
-
}
|
|
580
|
-
static get multiRegex() {
|
|
581
|
-
return /^!\^"(.*)"$/;
|
|
582
|
-
}
|
|
583
|
-
static get singleRegex() {
|
|
584
|
-
return /^!\^(.*)$/;
|
|
585
|
-
}
|
|
586
|
-
search(e) {
|
|
587
|
-
const t = !e.startsWith(this.pattern);
|
|
588
|
-
return { isMatch: t, score: t ? 0 : 1, indices: [0, e.length - 1] };
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
class Ce extends w {
|
|
592
|
-
constructor(e) {
|
|
593
|
-
super(e);
|
|
594
|
-
}
|
|
595
|
-
static get type() {
|
|
596
|
-
return "suffix-exact";
|
|
597
|
-
}
|
|
598
|
-
static get multiRegex() {
|
|
599
|
-
return /^"(.*)"\$$/;
|
|
600
|
-
}
|
|
601
|
-
static get singleRegex() {
|
|
602
|
-
return /^(.*)\$$/;
|
|
603
|
-
}
|
|
604
|
-
search(e) {
|
|
605
|
-
const t = e.endsWith(this.pattern);
|
|
606
|
-
return {
|
|
607
|
-
isMatch: t,
|
|
608
|
-
score: t ? 0 : 1,
|
|
609
|
-
indices: [e.length - this.pattern.length, e.length - 1],
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
class ve extends w {
|
|
614
|
-
constructor(e) {
|
|
615
|
-
super(e);
|
|
616
|
-
}
|
|
617
|
-
static get type() {
|
|
618
|
-
return "inverse-suffix-exact";
|
|
619
|
-
}
|
|
620
|
-
static get multiRegex() {
|
|
621
|
-
return /^!"(.*)"\$$/;
|
|
622
|
-
}
|
|
623
|
-
static get singleRegex() {
|
|
624
|
-
return /^!(.*)\$$/;
|
|
625
|
-
}
|
|
626
|
-
search(e) {
|
|
627
|
-
const t = !e.endsWith(this.pattern);
|
|
628
|
-
return { isMatch: t, score: t ? 0 : 1, indices: [0, e.length - 1] };
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
class re extends w {
|
|
632
|
-
constructor(
|
|
633
|
-
e,
|
|
634
|
-
{
|
|
635
|
-
location: t = f.location,
|
|
636
|
-
threshold: r = f.threshold,
|
|
637
|
-
distance: n = f.distance,
|
|
638
|
-
includeMatches: i = f.includeMatches,
|
|
639
|
-
findAllMatches: c = f.findAllMatches,
|
|
640
|
-
minMatchCharLength: o = f.minMatchCharLength,
|
|
641
|
-
isCaseSensitive: a = f.isCaseSensitive,
|
|
642
|
-
ignoreLocation: h = f.ignoreLocation,
|
|
643
|
-
} = {}
|
|
644
|
-
) {
|
|
645
|
-
super(e),
|
|
646
|
-
(this._bitapSearch = new se(e, {
|
|
647
|
-
location: t,
|
|
648
|
-
threshold: r,
|
|
649
|
-
distance: n,
|
|
650
|
-
includeMatches: i,
|
|
651
|
-
findAllMatches: c,
|
|
652
|
-
minMatchCharLength: o,
|
|
653
|
-
isCaseSensitive: a,
|
|
654
|
-
ignoreLocation: h,
|
|
655
|
-
}));
|
|
656
|
-
}
|
|
657
|
-
static get type() {
|
|
658
|
-
return "fuzzy";
|
|
659
|
-
}
|
|
660
|
-
static get multiRegex() {
|
|
661
|
-
return /^"(.*)"$/;
|
|
662
|
-
}
|
|
663
|
-
static get singleRegex() {
|
|
664
|
-
return /^(.*)$/;
|
|
665
|
-
}
|
|
666
|
-
search(e) {
|
|
667
|
-
return this._bitapSearch.searchIn(e);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
class ie extends w {
|
|
671
|
-
constructor(e) {
|
|
672
|
-
super(e);
|
|
673
|
-
}
|
|
674
|
-
static get type() {
|
|
675
|
-
return "include";
|
|
676
|
-
}
|
|
677
|
-
static get multiRegex() {
|
|
678
|
-
return /^'"(.*)"$/;
|
|
679
|
-
}
|
|
680
|
-
static get singleRegex() {
|
|
681
|
-
return /^'(.*)$/;
|
|
682
|
-
}
|
|
683
|
-
search(e) {
|
|
684
|
-
let t = 0,
|
|
685
|
-
r;
|
|
686
|
-
const n = [],
|
|
687
|
-
i = this.pattern.length;
|
|
688
|
-
for (; (r = e.indexOf(this.pattern, t)) > -1; )
|
|
689
|
-
(t = r + i), n.push([r, t - 1]);
|
|
690
|
-
const c = !!n.length;
|
|
691
|
-
return { isMatch: c, score: c ? 0 : 1, indices: n };
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
const D = [Te, ie, $e, Ne, ve, Ce, Oe, re],
|
|
695
|
-
ce = D.length,
|
|
696
|
-
Fe = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,
|
|
697
|
-
Pe = "|";
|
|
698
|
-
function je(s, e = {}) {
|
|
699
|
-
return s.split(Pe).map((t) => {
|
|
700
|
-
let r = t
|
|
701
|
-
.trim()
|
|
702
|
-
.split(Fe)
|
|
703
|
-
.filter((i) => i && !!i.trim()),
|
|
704
|
-
n = [];
|
|
705
|
-
for (let i = 0, c = r.length; i < c; i += 1) {
|
|
706
|
-
const o = r[i];
|
|
707
|
-
let a = !1,
|
|
708
|
-
h = -1;
|
|
709
|
-
for (; !a && ++h < ce; ) {
|
|
710
|
-
const l = D[h];
|
|
711
|
-
let u = l.isMultiMatch(o);
|
|
712
|
-
u && (n.push(new l(u, e)), (a = !0));
|
|
713
|
-
}
|
|
714
|
-
if (!a)
|
|
715
|
-
for (h = -1; ++h < ce; ) {
|
|
716
|
-
const l = D[h];
|
|
717
|
-
let u = l.isSingleMatch(o);
|
|
718
|
-
if (u) {
|
|
719
|
-
n.push(new l(u, e));
|
|
720
|
-
break;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
return n;
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
const He = new Set([re.type, ie.type]);
|
|
728
|
-
class Be {
|
|
729
|
-
constructor(
|
|
730
|
-
e,
|
|
731
|
-
{
|
|
732
|
-
isCaseSensitive: t = f.isCaseSensitive,
|
|
733
|
-
includeMatches: r = f.includeMatches,
|
|
734
|
-
minMatchCharLength: n = f.minMatchCharLength,
|
|
735
|
-
ignoreLocation: i = f.ignoreLocation,
|
|
736
|
-
findAllMatches: c = f.findAllMatches,
|
|
737
|
-
location: o = f.location,
|
|
738
|
-
threshold: a = f.threshold,
|
|
739
|
-
distance: h = f.distance,
|
|
740
|
-
} = {}
|
|
741
|
-
) {
|
|
742
|
-
(this.query = null),
|
|
743
|
-
(this.options = {
|
|
744
|
-
isCaseSensitive: t,
|
|
745
|
-
includeMatches: r,
|
|
746
|
-
minMatchCharLength: n,
|
|
747
|
-
findAllMatches: c,
|
|
748
|
-
ignoreLocation: i,
|
|
749
|
-
location: o,
|
|
750
|
-
threshold: a,
|
|
751
|
-
distance: h,
|
|
752
|
-
}),
|
|
753
|
-
(this.pattern = t ? e : e.toLowerCase()),
|
|
754
|
-
(this.query = je(this.pattern, this.options));
|
|
755
|
-
}
|
|
756
|
-
static condition(e, t) {
|
|
757
|
-
return t.useExtendedSearch;
|
|
758
|
-
}
|
|
759
|
-
searchIn(e) {
|
|
760
|
-
const t = this.query;
|
|
761
|
-
if (!t) return { isMatch: !1, score: 1 };
|
|
762
|
-
const { includeMatches: r, isCaseSensitive: n } = this.options;
|
|
763
|
-
e = n ? e : e.toLowerCase();
|
|
764
|
-
let i = 0,
|
|
765
|
-
c = [],
|
|
766
|
-
o = 0;
|
|
767
|
-
for (let a = 0, h = t.length; a < h; a += 1) {
|
|
768
|
-
const l = t[a];
|
|
769
|
-
(c.length = 0), (i = 0);
|
|
770
|
-
for (let u = 0, d = l.length; u < d; u += 1) {
|
|
771
|
-
const g = l[u],
|
|
772
|
-
{ isMatch: p, indices: y, score: T } = g.search(e);
|
|
773
|
-
if (p) {
|
|
774
|
-
if (((i += 1), (o += T), r)) {
|
|
775
|
-
const I = g.constructor.type;
|
|
776
|
-
He.has(I) ? (c = [...c, ...y]) : c.push(y);
|
|
777
|
-
}
|
|
778
|
-
} else {
|
|
779
|
-
(o = 0), (i = 0), (c.length = 0);
|
|
780
|
-
break;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
if (i) {
|
|
784
|
-
let u = { isMatch: !0, score: o / i };
|
|
785
|
-
return r && (u.indices = c), u;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
return { isMatch: !1, score: 1 };
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
const W = [];
|
|
792
|
-
function Ke(...s) {
|
|
793
|
-
W.push(...s);
|
|
794
|
-
}
|
|
795
|
-
function z(s, e) {
|
|
796
|
-
for (let t = 0, r = W.length; t < r; t += 1) {
|
|
797
|
-
let n = W[t];
|
|
798
|
-
if (n.condition(s, e)) return new n(s, e);
|
|
799
|
-
}
|
|
800
|
-
return new se(s, e);
|
|
801
|
-
}
|
|
802
|
-
const F = { AND: "$and", OR: "$or" },
|
|
803
|
-
V = { PATH: "$path", PATTERN: "$val" },
|
|
804
|
-
Y = (s) => !!(s[F.AND] || s[F.OR]),
|
|
805
|
-
De = (s) => !!s[V.PATH],
|
|
806
|
-
We = (s) => !m(s) && X(s) && !Y(s),
|
|
807
|
-
oe = (s) => ({ [F.AND]: Object.keys(s).map((e) => ({ [e]: s[e] })) });
|
|
808
|
-
function ae(s, e, { auto: t = !0 } = {}) {
|
|
809
|
-
const r = (n) => {
|
|
810
|
-
let i = Object.keys(n);
|
|
811
|
-
const c = De(n);
|
|
812
|
-
if (!c && i.length > 1 && !Y(n)) return r(oe(n));
|
|
813
|
-
if (We(n)) {
|
|
814
|
-
const a = c ? n[V.PATH] : i[0],
|
|
815
|
-
h = c ? n[V.PATTERN] : n[a];
|
|
816
|
-
if (!A(h)) throw new Error(Me(a));
|
|
817
|
-
const l = { keyId: B(a), pattern: h };
|
|
818
|
-
return t && (l.searcher = z(h, e)), l;
|
|
819
|
-
}
|
|
820
|
-
let o = { children: [], operator: i[0] };
|
|
821
|
-
return (
|
|
822
|
-
i.forEach((a) => {
|
|
823
|
-
const h = n[a];
|
|
824
|
-
m(h) &&
|
|
825
|
-
h.forEach((l) => {
|
|
826
|
-
o.children.push(r(l));
|
|
827
|
-
});
|
|
828
|
-
}),
|
|
829
|
-
o
|
|
830
|
-
);
|
|
831
|
-
};
|
|
832
|
-
return Y(s) || (s = oe(s)), r(s);
|
|
833
|
-
}
|
|
834
|
-
function ze(s, { ignoreFieldNorm: e = f.ignoreFieldNorm }) {
|
|
835
|
-
s.forEach((t) => {
|
|
836
|
-
let r = 1;
|
|
837
|
-
t.matches.forEach(({ key: n, norm: i, score: c }) => {
|
|
838
|
-
const o = n ? n.weight : null;
|
|
839
|
-
r *= Math.pow(
|
|
840
|
-
c === 0 && o ? Number.EPSILON : c,
|
|
841
|
-
(o || 1) * (e ? 1 : i)
|
|
842
|
-
);
|
|
843
|
-
}),
|
|
844
|
-
(t.score = r);
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
function Ve(s, e) {
|
|
848
|
-
const t = s.matches;
|
|
849
|
-
(e.matches = []),
|
|
850
|
-
M(t) &&
|
|
851
|
-
t.forEach((r) => {
|
|
852
|
-
if (!M(r.indices) || !r.indices.length) return;
|
|
853
|
-
const { indices: n, value: i } = r;
|
|
854
|
-
let c = { indices: n, value: i };
|
|
855
|
-
r.key && (c.key = r.key.src),
|
|
856
|
-
r.idx > -1 && (c.refIndex = r.idx),
|
|
857
|
-
e.matches.push(c);
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
function Ye(s, e) {
|
|
861
|
-
e.score = s.score;
|
|
862
|
-
}
|
|
863
|
-
function Ge(
|
|
864
|
-
s,
|
|
865
|
-
e,
|
|
866
|
-
{
|
|
867
|
-
includeMatches: t = f.includeMatches,
|
|
868
|
-
includeScore: r = f.includeScore,
|
|
869
|
-
} = {}
|
|
870
|
-
) {
|
|
871
|
-
const n = [];
|
|
872
|
-
return (
|
|
873
|
-
t && n.push(Ve),
|
|
874
|
-
r && n.push(Ye),
|
|
875
|
-
s.map((i) => {
|
|
876
|
-
const { idx: c } = i,
|
|
877
|
-
o = { item: e[c], refIndex: c };
|
|
878
|
-
return (
|
|
879
|
-
n.length &&
|
|
880
|
-
n.forEach((a) => {
|
|
881
|
-
a(i, o);
|
|
882
|
-
}),
|
|
883
|
-
o
|
|
884
|
-
);
|
|
885
|
-
})
|
|
886
|
-
);
|
|
887
|
-
}
|
|
888
|
-
class $ {
|
|
889
|
-
constructor(e, t = {}, r) {
|
|
890
|
-
(this.options = { ...f, ...t }),
|
|
891
|
-
this.options.useExtendedSearch,
|
|
892
|
-
(this._keyStore = new Ae(this.options.keys)),
|
|
893
|
-
this.setCollection(e, r);
|
|
894
|
-
}
|
|
895
|
-
setCollection(e, t) {
|
|
896
|
-
if (((this._docs = e), t && !(t instanceof K))) throw new Error(ye);
|
|
897
|
-
this._myIndex =
|
|
898
|
-
t ||
|
|
899
|
-
te(this.options.keys, this._docs, {
|
|
900
|
-
getFn: this.options.getFn,
|
|
901
|
-
fieldNormWeight: this.options.fieldNormWeight,
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
|
-
add(e) {
|
|
905
|
-
M(e) && (this._docs.push(e), this._myIndex.add(e));
|
|
906
|
-
}
|
|
907
|
-
remove(e = () => !1) {
|
|
908
|
-
const t = [];
|
|
909
|
-
for (let r = 0, n = this._docs.length; r < n; r += 1) {
|
|
910
|
-
const i = this._docs[r];
|
|
911
|
-
e(i, r) && (this.removeAt(r), (r -= 1), (n -= 1), t.push(i));
|
|
912
|
-
}
|
|
913
|
-
return t;
|
|
914
|
-
}
|
|
915
|
-
removeAt(e) {
|
|
916
|
-
this._docs.splice(e, 1), this._myIndex.removeAt(e);
|
|
917
|
-
}
|
|
918
|
-
getIndex() {
|
|
919
|
-
return this._myIndex;
|
|
920
|
-
}
|
|
921
|
-
search(e, { limit: t = -1 } = {}) {
|
|
922
|
-
const {
|
|
923
|
-
includeMatches: r,
|
|
924
|
-
includeScore: n,
|
|
925
|
-
shouldSort: i,
|
|
926
|
-
sortFn: c,
|
|
927
|
-
ignoreFieldNorm: o,
|
|
928
|
-
} = this.options;
|
|
929
|
-
let a = A(e)
|
|
930
|
-
? A(this._docs[0])
|
|
931
|
-
? this._searchStringList(e)
|
|
932
|
-
: this._searchObjectList(e)
|
|
933
|
-
: this._searchLogical(e);
|
|
934
|
-
return (
|
|
935
|
-
ze(a, { ignoreFieldNorm: o }),
|
|
936
|
-
i && a.sort(c),
|
|
937
|
-
Q(t) && t > -1 && (a = a.slice(0, t)),
|
|
938
|
-
Ge(a, this._docs, { includeMatches: r, includeScore: n })
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
_searchStringList(e) {
|
|
942
|
-
const t = z(e, this.options),
|
|
943
|
-
{ records: r } = this._myIndex,
|
|
944
|
-
n = [];
|
|
945
|
-
return (
|
|
946
|
-
r.forEach(({ v: i, i: c, n: o }) => {
|
|
947
|
-
if (!M(i)) return;
|
|
948
|
-
const { isMatch: a, score: h, indices: l } = t.searchIn(i);
|
|
949
|
-
a &&
|
|
950
|
-
n.push({
|
|
951
|
-
item: i,
|
|
952
|
-
idx: c,
|
|
953
|
-
matches: [{ score: h, value: i, norm: o, indices: l }],
|
|
954
|
-
});
|
|
955
|
-
}),
|
|
956
|
-
n
|
|
957
|
-
);
|
|
958
|
-
}
|
|
959
|
-
_searchLogical(e) {
|
|
960
|
-
const t = ae(e, this.options),
|
|
961
|
-
r = (o, a, h) => {
|
|
962
|
-
if (!o.children) {
|
|
963
|
-
const { keyId: u, searcher: d } = o,
|
|
964
|
-
g = this._findMatches({
|
|
965
|
-
key: this._keyStore.get(u),
|
|
966
|
-
value: this._myIndex.getValueForItemAtKeyId(a, u),
|
|
967
|
-
searcher: d,
|
|
968
|
-
});
|
|
969
|
-
return g && g.length ? [{ idx: h, item: a, matches: g }] : [];
|
|
970
|
-
}
|
|
971
|
-
const l = [];
|
|
972
|
-
for (let u = 0, d = o.children.length; u < d; u += 1) {
|
|
973
|
-
const g = o.children[u],
|
|
974
|
-
p = r(g, a, h);
|
|
975
|
-
if (p.length) l.push(...p);
|
|
976
|
-
else if (o.operator === F.AND) return [];
|
|
977
|
-
}
|
|
978
|
-
return l;
|
|
979
|
-
},
|
|
980
|
-
n = this._myIndex.records,
|
|
981
|
-
i = {},
|
|
982
|
-
c = [];
|
|
983
|
-
return (
|
|
984
|
-
n.forEach(({ $: o, i: a }) => {
|
|
985
|
-
if (M(o)) {
|
|
986
|
-
let h = r(t, o, a);
|
|
987
|
-
h.length &&
|
|
988
|
-
(i[a] ||
|
|
989
|
-
((i[a] = { idx: a, item: o, matches: [] }), c.push(i[a])),
|
|
990
|
-
h.forEach(({ matches: l }) => {
|
|
991
|
-
i[a].matches.push(...l);
|
|
992
|
-
}));
|
|
993
|
-
}
|
|
994
|
-
}),
|
|
995
|
-
c
|
|
996
|
-
);
|
|
997
|
-
}
|
|
998
|
-
_searchObjectList(e) {
|
|
999
|
-
const t = z(e, this.options),
|
|
1000
|
-
{ keys: r, records: n } = this._myIndex,
|
|
1001
|
-
i = [];
|
|
1002
|
-
return (
|
|
1003
|
-
n.forEach(({ $: c, i: o }) => {
|
|
1004
|
-
if (!M(c)) return;
|
|
1005
|
-
let a = [];
|
|
1006
|
-
r.forEach((h, l) => {
|
|
1007
|
-
a.push(...this._findMatches({ key: h, value: c[l], searcher: t }));
|
|
1008
|
-
}),
|
|
1009
|
-
a.length && i.push({ idx: o, item: c, matches: a });
|
|
1010
|
-
}),
|
|
1011
|
-
i
|
|
1012
|
-
);
|
|
1013
|
-
}
|
|
1014
|
-
_findMatches({ key: e, value: t, searcher: r }) {
|
|
1015
|
-
if (!M(t)) return [];
|
|
1016
|
-
let n = [];
|
|
1017
|
-
if (m(t))
|
|
1018
|
-
t.forEach(({ v: i, i: c, n: o }) => {
|
|
1019
|
-
if (!M(i)) return;
|
|
1020
|
-
const { isMatch: a, score: h, indices: l } = r.searchIn(i);
|
|
1021
|
-
a &&
|
|
1022
|
-
n.push({ score: h, key: e, value: i, idx: c, norm: o, indices: l });
|
|
1023
|
-
});
|
|
1024
|
-
else {
|
|
1025
|
-
const { v: i, n: c } = t,
|
|
1026
|
-
{ isMatch: o, score: a, indices: h } = r.searchIn(i);
|
|
1027
|
-
o && n.push({ score: a, key: e, value: i, norm: c, indices: h });
|
|
1028
|
-
}
|
|
1029
|
-
return n;
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
($.version = "6.6.2"),
|
|
1033
|
-
($.createIndex = te),
|
|
1034
|
-
($.parseIndex = Le),
|
|
1035
|
-
($.config = f),
|
|
1036
|
-
($.parseQuery = ae),
|
|
1037
|
-
Ke(Be);
|
|
1038
|
-
const Ue = `
|
|
1
|
+
(function(M,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(M=typeof globalThis<"u"?globalThis:M||self,m(M["eox-itemfilter"]={}))})(this,function(M){"use strict";var et=Object.defineProperty;var tt=(M,m,v)=>m in M?et(M,m,{enumerable:!0,configurable:!0,writable:!0,value:v}):M[m]=v;var R=(M,m,v)=>(tt(M,typeof m!="symbol"?m+"":m,v),v);function m(s){return Array.isArray?Array.isArray(s):X(s)==="[object Array]"}const v=1/0;function fe(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-v?"-0":e}function de(s){return s==null?"":fe(s)}function S(s){return typeof s=="string"}function G(s){return typeof s=="number"}function ge(s){return s===!0||s===!1||pe(s)&&X(s)=="[object Boolean]"}function Q(s){return typeof s=="object"}function pe(s){return Q(s)&&s!==null}function x(s){return s!=null}function P(s){return!s.trim().length}function X(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const st="Extended search is not available",me="Incorrect 'index' type",ye=s=>`Invalid value for key ${s}`,xe=s=>`Pattern length exceeds max of ${s}.`,Me=s=>`Missing ${s} property in key`,Ee=s=>`Property 'weight' in key '${s}' must be a positive integer`,J=Object.prototype.hasOwnProperty;class we{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(n=>{let i=Z(n);t+=i.weight,this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight}),this._keys.forEach(n=>{n.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Z(s){let e=null,t=null,n=null,i=1,c=null;if(S(s)||m(s))n=s,e=ee(s),t=B(s);else{if(!J.call(s,"name"))throw new Error(Me("name"));const r=s.name;if(n=r,J.call(s,"weight")&&(i=s.weight,i<=0))throw new Error(Ee(r));e=ee(r),t=B(r),c=s.getFn}return{path:e,id:t,weight:i,src:n,getFn:c}}function ee(s){return m(s)?s:s.split(".")}function B(s){return m(s)?s.join("."):s}function Se(s,e){let t=[],n=!1;const i=(c,r,o)=>{if(x(c))if(!r[o])t.push(c);else{let l=r[o];const a=c[l];if(!x(a))return;if(o===r.length-1&&(S(a)||G(a)||ge(a)))t.push(de(a));else if(m(a)){n=!0;for(let h=0,u=a.length;h<u;h+=1)i(a[h],r,o+1)}else r.length&&i(a,r,o+1)}};return i(s,S(e)?e.split("."):e,0),n?t:t[0]}var d={...{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:Se,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const Le=/[^ ]+/g;function Ae(s=1,e=3){const t=new Map,n=Math.pow(10,e);return{get(i){const c=i.match(Le).length;if(t.has(c))return t.get(c);const r=1/Math.pow(c,.5*s),o=parseFloat(Math.round(r*n)/n);return t.set(c,o),o},clear(){t.clear()}}}class z{constructor({getFn:e=d.getFn,fieldNormWeight:t=d.fieldNormWeight}={}){this.norm=Ae(t,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,n)=>{this._keysMap[t.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,S(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){const t=this.size();S(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!x(e)||P(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((i,c)=>{let r=i.getFn?i.getFn(e):this.getFn(e,i.path);if(x(r)){if(m(r)){let o=[];const l=[{nestedArrIndex:-1,value:r}];for(;l.length;){const{nestedArrIndex:a,value:h}=l.pop();if(x(h))if(S(h)&&!P(h)){let u={v:h,i:a,n:this.norm.get(h)};o.push(u)}else m(h)&&h.forEach((u,f)=>{l.push({nestedArrIndex:f,value:u})})}n.$[c]=o}else if(S(r)&&!P(r)){let o={v:r,n:this.norm.get(r)};n.$[c]=o}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function te(s,e,{getFn:t=d.getFn,fieldNormWeight:n=d.fieldNormWeight}={}){const i=new z({getFn:t,fieldNormWeight:n});return i.setKeys(s.map(Z)),i.setSources(e),i.create(),i}function Ie(s,{getFn:e=d.getFn,fieldNormWeight:t=d.fieldNormWeight}={}){const{keys:n,records:i}=s,c=new z({getFn:e,fieldNormWeight:t});return c.setKeys(n),c.setIndexRecords(i),c}function F(s,{errors:e=0,currentLocation:t=0,expectedLocation:n=0,distance:i=d.distance,ignoreLocation:c=d.ignoreLocation}={}){const r=e/s.length;if(c)return r;const o=Math.abs(n-t);return i?r+o/i:o?1:r}function be(s=[],e=d.minMatchCharLength){let t=[],n=-1,i=-1,c=0;for(let r=s.length;c<r;c+=1){let o=s[c];o&&n===-1?n=c:!o&&n!==-1&&(i=c-1,i-n+1>=e&&t.push([n,i]),n=-1)}return s[c-1]&&c-n>=e&&t.push([n,c-1]),t}const T=32;function _e(s,e,t,{location:n=d.location,distance:i=d.distance,threshold:c=d.threshold,findAllMatches:r=d.findAllMatches,minMatchCharLength:o=d.minMatchCharLength,includeMatches:l=d.includeMatches,ignoreLocation:a=d.ignoreLocation}={}){if(e.length>T)throw new Error(xe(T));const h=e.length,u=s.length,f=Math.max(0,Math.min(n,u));let g=c,p=f;const y=o>1||l,L=y?Array(u):[];let A;for(;(A=s.indexOf(e,p))>-1;){let E=F(e,{currentLocation:A,expectedLocation:f,distance:i,ignoreLocation:a});if(g=Math.min(E,g),p=A+h,y){let b=0;for(;b<h;)L[A+b]=1,b+=1}}p=-1;let $=[],k=1,j=h+u;const Ze=1<<h-1;for(let E=0;E<h;E+=1){let b=0,_=j;for(;b<_;)F(e,{errors:E,currentLocation:f+_,expectedLocation:f,distance:i,ignoreLocation:a})<=g?b=_:j=_,_=Math.floor((j-b)/2+b);j=_;let he=Math.max(1,f-_+1),Y=r?u:Math.min(f+_,u)+h,N=Array(Y+2);N[Y+1]=(1<<E)-1;for(let w=Y;w>=he;w-=1){let H=w-1,ue=t[s.charAt(H)];if(y&&(L[H]=+!!ue),N[w]=(N[w+1]<<1|1)&ue,E&&(N[w]|=($[w+1]|$[w])<<1|1|$[w+1]),N[w]&Ze&&(k=F(e,{errors:E,currentLocation:H,expectedLocation:f,distance:i,ignoreLocation:a}),k<=g)){if(g=k,p=H,p<=f)break;he=Math.max(1,2*f-p)}}if(F(e,{errors:E+1,currentLocation:f,expectedLocation:f,distance:i,ignoreLocation:a})>g)break;$=N}const U={isMatch:p>=0,score:Math.max(.001,k)};if(y){const E=be(L,o);E.length?l&&(U.indices=E):U.isMatch=!1}return U}function Re(s){let e={};for(let t=0,n=s.length;t<n;t+=1){const i=s.charAt(t);e[i]=(e[i]||0)|1<<n-t-1}return e}class se{constructor(e,{location:t=d.location,threshold:n=d.threshold,distance:i=d.distance,includeMatches:c=d.includeMatches,findAllMatches:r=d.findAllMatches,minMatchCharLength:o=d.minMatchCharLength,isCaseSensitive:l=d.isCaseSensitive,ignoreLocation:a=d.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:i,includeMatches:c,findAllMatches:r,minMatchCharLength:o,isCaseSensitive:l,ignoreLocation:a},this.pattern=l?e:e.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(f,g)=>{this.chunks.push({pattern:f,alphabet:Re(f),startIndex:g})},u=this.pattern.length;if(u>T){let f=0;const g=u%T,p=u-g;for(;f<p;)h(this.pattern.substr(f,T),f),f+=T;if(g){const y=u-T;h(this.pattern.substr(y),y)}}else h(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,includeMatches:n}=this.options;if(t||(e=e.toLowerCase()),this.pattern===e){let p={isMatch:!0,score:0};return n&&(p.indices=[[0,e.length-1]]),p}const{location:i,distance:c,threshold:r,findAllMatches:o,minMatchCharLength:l,ignoreLocation:a}=this.options;let h=[],u=0,f=!1;this.chunks.forEach(({pattern:p,alphabet:y,startIndex:L})=>{const{isMatch:A,score:$,indices:k}=_e(e,p,y,{location:i+L,distance:c,threshold:r,findAllMatches:o,minMatchCharLength:l,includeMatches:n,ignoreLocation:a});A&&(f=!0),u+=$,A&&k&&(h=[...h,...k])});let g={isMatch:f,score:f?u/this.chunks.length:1};return f&&n&&(g.indices=h),g}}class I{constructor(e){this.pattern=e}static isMultiMatch(e){return ie(e,this.multiRegex)}static isSingleMatch(e){return ie(e,this.singleRegex)}search(){}}function ie(s,e){const t=s.match(e);return t?t[1]:null}class ve extends I{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class Te extends I{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class ke extends I{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class Oe extends I{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class $e extends I{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Ne extends I{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class ne extends I{constructor(e,{location:t=d.location,threshold:n=d.threshold,distance:i=d.distance,includeMatches:c=d.includeMatches,findAllMatches:r=d.findAllMatches,minMatchCharLength:o=d.minMatchCharLength,isCaseSensitive:l=d.isCaseSensitive,ignoreLocation:a=d.ignoreLocation}={}){super(e),this._bitapSearch=new se(e,{location:t,threshold:n,distance:i,includeMatches:c,findAllMatches:r,minMatchCharLength:o,isCaseSensitive:l,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class re extends I{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,n;const i=[],c=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+c,i.push([n,t-1]);const r=!!i.length;return{isMatch:r,score:r?0:1,indices:i}}}const K=[ve,re,ke,Oe,Ne,$e,Te,ne],ce=K.length,Fe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ce="|";function je(s,e={}){return s.split(Ce).map(t=>{let n=t.trim().split(Fe).filter(c=>c&&!!c.trim()),i=[];for(let c=0,r=n.length;c<r;c+=1){const o=n[c];let l=!1,a=-1;for(;!l&&++a<ce;){const h=K[a];let u=h.isMultiMatch(o);u&&(i.push(new h(u,e)),l=!0)}if(!l)for(a=-1;++a<ce;){const h=K[a];let u=h.isSingleMatch(o);if(u){i.push(new h(u,e));break}}}return i})}const He=new Set([ne.type,re.type]);class Pe{constructor(e,{isCaseSensitive:t=d.isCaseSensitive,includeMatches:n=d.includeMatches,minMatchCharLength:i=d.minMatchCharLength,ignoreLocation:c=d.ignoreLocation,findAllMatches:r=d.findAllMatches,location:o=d.location,threshold:l=d.threshold,distance:a=d.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:n,minMatchCharLength:i,findAllMatches:r,ignoreLocation:c,location:o,threshold:l,distance:a},this.pattern=t?e:e.toLowerCase(),this.query=je(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i}=this.options;e=i?e:e.toLowerCase();let c=0,r=[],o=0;for(let l=0,a=t.length;l<a;l+=1){const h=t[l];r.length=0,c=0;for(let u=0,f=h.length;u<f;u+=1){const g=h[u],{isMatch:p,indices:y,score:L}=g.search(e);if(p){if(c+=1,o+=L,n){const A=g.constructor.type;He.has(A)?r=[...r,...y]:r.push(y)}}else{o=0,c=0,r.length=0;break}}if(c){let u={isMatch:!0,score:o/c};return n&&(u.indices=r),u}}return{isMatch:!1,score:1}}}const W=[];function Be(...s){W.push(...s)}function D(s,e){for(let t=0,n=W.length;t<n;t+=1){let i=W[t];if(i.condition(s,e))return new i(s,e)}return new se(s,e)}const C={AND:"$and",OR:"$or"},q={PATH:"$path",PATTERN:"$val"},V=s=>!!(s[C.AND]||s[C.OR]),ze=s=>!!s[q.PATH],Ke=s=>!m(s)&&Q(s)&&!V(s),oe=s=>({[C.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function le(s,e,{auto:t=!0}={}){const n=i=>{let c=Object.keys(i);const r=ze(i);if(!r&&c.length>1&&!V(i))return n(oe(i));if(Ke(i)){const l=r?i[q.PATH]:c[0],a=r?i[q.PATTERN]:i[l];if(!S(a))throw new Error(ye(l));const h={keyId:B(l),pattern:a};return t&&(h.searcher=D(a,e)),h}let o={children:[],operator:c[0]};return c.forEach(l=>{const a=i[l];m(a)&&a.forEach(h=>{o.children.push(n(h))})}),o};return V(s)||(s=oe(s)),n(s)}function We(s,{ignoreFieldNorm:e=d.ignoreFieldNorm}){s.forEach(t=>{let n=1;t.matches.forEach(({key:i,norm:c,score:r})=>{const o=i?i.weight:null;n*=Math.pow(r===0&&o?Number.EPSILON:r,(o||1)*(e?1:c))}),t.score=n})}function De(s,e){const t=s.matches;e.matches=[],x(t)&&t.forEach(n=>{if(!x(n.indices)||!n.indices.length)return;const{indices:i,value:c}=n;let r={indices:i,value:c};n.key&&(r.key=n.key.src),n.idx>-1&&(r.refIndex=n.idx),e.matches.push(r)})}function qe(s,e){e.score=s.score}function Ve(s,e,{includeMatches:t=d.includeMatches,includeScore:n=d.includeScore}={}){const i=[];return t&&i.push(De),n&&i.push(qe),s.map(c=>{const{idx:r}=c,o={item:e[r],refIndex:r};return i.length&&i.forEach(l=>{l(c,o)}),o})}class O{constructor(e,t={},n){this.options={...d,...t},this.options.useExtendedSearch,this._keyStore=new we(this.options.keys),this.setCollection(e,n)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof z))throw new Error(me);this._myIndex=t||te(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){x(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[];for(let n=0,i=this._docs.length;n<i;n+=1){const c=this._docs[n];e(c,n)&&(this.removeAt(n),n-=1,i-=1,t.push(c))}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:c,sortFn:r,ignoreFieldNorm:o}=this.options;let l=S(e)?S(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return We(l,{ignoreFieldNorm:o}),c&&l.sort(r),G(t)&&t>-1&&(l=l.slice(0,t)),Ve(l,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(e){const t=D(e,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:c,i:r,n:o})=>{if(!x(c))return;const{isMatch:l,score:a,indices:h}=t.searchIn(c);l&&i.push({item:c,idx:r,matches:[{score:a,value:c,norm:o,indices:h}]})}),i}_searchLogical(e){const t=le(e,this.options),n=(o,l,a)=>{if(!o.children){const{keyId:u,searcher:f}=o,g=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:f});return g&&g.length?[{idx:a,item:l,matches:g}]:[]}const h=[];for(let u=0,f=o.children.length;u<f;u+=1){const g=o.children[u],p=n(g,l,a);if(p.length)h.push(...p);else if(o.operator===C.AND)return[]}return h},i=this._myIndex.records,c={},r=[];return i.forEach(({$:o,i:l})=>{if(x(o)){let a=n(t,o,l);a.length&&(c[l]||(c[l]={idx:l,item:o,matches:[]},r.push(c[l])),a.forEach(({matches:h})=>{c[l].matches.push(...h)}))}}),r}_searchObjectList(e){const t=D(e,this.options),{keys:n,records:i}=this._myIndex,c=[];return i.forEach(({$:r,i:o})=>{if(!x(r))return;let l=[];n.forEach((a,h)=>{l.push(...this._findMatches({key:a,value:r[h],searcher:t}))}),l.length&&c.push({idx:o,item:r,matches:l})}),c}_findMatches({key:e,value:t,searcher:n}){if(!x(t))return[];let i=[];if(m(t))t.forEach(({v:c,i:r,n:o})=>{if(!x(c))return;const{isMatch:l,score:a,indices:h}=n.searchIn(c);l&&i.push({score:a,key:e,value:c,idx:r,norm:o,indices:h})});else{const{v:c,n:r}=t,{isMatch:o,score:l,indices:a}=n.searchIn(c);o&&i.push({score:l,key:e,value:c,norm:r,indices:a})}return i}}O.version="6.6.2",O.createIndex=te,O.parseIndex=Ie,O.config=d,O.parseQuery=le,Be(Pe);const Ue=`
|
|
1039
2
|
<style>
|
|
1040
3
|
:host {
|
|
1041
|
-
display:
|
|
4
|
+
display: flex;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
height: 100%;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
*, *:before, *:after {
|
|
10
|
+
box-sizing: inherit;
|
|
11
|
+
}
|
|
12
|
+
form {
|
|
13
|
+
height: 100%;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
}
|
|
18
|
+
ul {
|
|
19
|
+
padding-left: 0;
|
|
20
|
+
margin-top: 0;
|
|
21
|
+
}
|
|
22
|
+
li {
|
|
23
|
+
list-style: none;
|
|
24
|
+
}
|
|
25
|
+
li span {
|
|
26
|
+
font-size: small;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
text-overflow: ellipsis;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
}
|
|
31
|
+
label {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
}
|
|
35
|
+
details {
|
|
36
|
+
margin-bottom: 0.5rem;
|
|
37
|
+
}
|
|
38
|
+
details summary > * {
|
|
39
|
+
display: inline;
|
|
40
|
+
}
|
|
41
|
+
details summary {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
}
|
|
45
|
+
#details-filter summary {
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
}
|
|
48
|
+
#details-results summary {
|
|
49
|
+
list-style: none;
|
|
50
|
+
}
|
|
51
|
+
#details-filter summary svg,
|
|
52
|
+
#details-results summary svg {
|
|
53
|
+
width: 24px;
|
|
54
|
+
height: 24px;
|
|
55
|
+
transition: all ease-in-out 0.3s;
|
|
56
|
+
}
|
|
57
|
+
#details-results summary svg {
|
|
58
|
+
transform: rotate(-90deg);
|
|
59
|
+
}
|
|
60
|
+
#details-filter[open] summary svg {
|
|
61
|
+
transform: rotate(180deg);
|
|
62
|
+
}
|
|
63
|
+
#details-results[open] summary svg {
|
|
64
|
+
transform: rotate(0deg);
|
|
65
|
+
}
|
|
66
|
+
li span,
|
|
67
|
+
details summary {
|
|
68
|
+
text-transform: capitalize;
|
|
69
|
+
}
|
|
70
|
+
li,
|
|
71
|
+
label,
|
|
72
|
+
details,
|
|
73
|
+
input[type=checkbox],
|
|
74
|
+
input[type=radio] {
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
}
|
|
77
|
+
input[type=checkbox],
|
|
78
|
+
input[type=radio] {
|
|
79
|
+
margin: 0;
|
|
80
|
+
margin-right: 0.5rem;
|
|
81
|
+
}
|
|
82
|
+
input[type=text] {
|
|
83
|
+
display: none;
|
|
84
|
+
width: 100%;
|
|
85
|
+
margin-bottom: 0.5rem;
|
|
86
|
+
}
|
|
87
|
+
section {
|
|
88
|
+
padding-left: 1rem;
|
|
89
|
+
padding-right: 1rem;
|
|
90
|
+
}
|
|
91
|
+
section:first-of-type {
|
|
92
|
+
padding-top: 1rem;
|
|
93
|
+
}
|
|
94
|
+
#section-results {
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
flex: 1;
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
}
|
|
100
|
+
#container-results {
|
|
101
|
+
margin-right: -1rem;
|
|
102
|
+
}
|
|
103
|
+
ul#results {
|
|
104
|
+
padding-right: 1rem;
|
|
105
|
+
}
|
|
106
|
+
ul#results li {
|
|
107
|
+
padding-left: 0.5rem;
|
|
108
|
+
}
|
|
109
|
+
.scroll {
|
|
110
|
+
height: 100%;
|
|
111
|
+
overflow-x: hidden;
|
|
112
|
+
overflow-y: auto;
|
|
1042
113
|
}
|
|
1043
114
|
</style>
|
|
1044
|
-
<
|
|
1045
|
-
<
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
<
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
115
|
+
<form>
|
|
116
|
+
<section>
|
|
117
|
+
<input type="text" placeholder="Search" />
|
|
118
|
+
</section>
|
|
119
|
+
<section>
|
|
120
|
+
<slot name="filterstitle"></slot>
|
|
121
|
+
<ul id="filters"></ul>
|
|
122
|
+
</section>
|
|
123
|
+
<section id="section-results">
|
|
124
|
+
<div>
|
|
125
|
+
<slot name="resultstitle"></slot>
|
|
126
|
+
</div>
|
|
127
|
+
<div id="container-results" class="scroll">
|
|
128
|
+
<ul id="results"></ul>
|
|
129
|
+
</div>
|
|
130
|
+
</section>
|
|
131
|
+
</form>
|
|
132
|
+
`,Ye=`
|
|
1052
133
|
<li>
|
|
1053
134
|
<label>
|
|
1054
135
|
<input type="checkbox" />
|
|
1055
136
|
<span class="title">FILTERITEMTITLE</span>
|
|
1056
137
|
</label>
|
|
1057
138
|
</li>
|
|
1058
|
-
`,
|
|
1059
|
-
|
|
1060
|
-
<
|
|
1061
|
-
|
|
139
|
+
`,Ge=`
|
|
140
|
+
<details id="details-filter">
|
|
141
|
+
<summary>
|
|
142
|
+
<small>
|
|
143
|
+
<strong class="title">
|
|
144
|
+
FILTERTITLE
|
|
145
|
+
</strong>
|
|
146
|
+
</small>
|
|
147
|
+
<div>
|
|
148
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>chevron-down</title><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" /></svg>
|
|
149
|
+
</div>
|
|
150
|
+
</summary>
|
|
151
|
+
<ul></ul>
|
|
152
|
+
</details>
|
|
153
|
+
`,Qe=`
|
|
154
|
+
<li>
|
|
155
|
+
<label>
|
|
156
|
+
<input type="radio" name="result" />
|
|
157
|
+
<span class="title">RESULTTITLE</span>
|
|
158
|
+
</label>
|
|
159
|
+
</li>
|
|
160
|
+
`,Xe=`
|
|
161
|
+
<details id="details-results" open>
|
|
162
|
+
<summary>
|
|
163
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>chevron-down</title><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" /></svg>
|
|
164
|
+
<strong class="title">
|
|
165
|
+
SUMMARYTITLE
|
|
166
|
+
</strong>
|
|
167
|
+
<span style="margin-left: 0.25rem">(<span class="count"></span>)</span>
|
|
168
|
+
</summary>
|
|
1062
169
|
<ul></ul>
|
|
1063
170
|
</details>
|
|
1064
|
-
`,
|
|
1065
|
-
Je = (s, e = "highlight") => {
|
|
1066
|
-
const t = (n, i, c) => {
|
|
1067
|
-
const o = i.split(".");
|
|
1068
|
-
let a;
|
|
1069
|
-
for (a = 0; a < o.length - 1; a++) n = n[o[a]];
|
|
1070
|
-
n[o[a]] = c;
|
|
1071
|
-
},
|
|
1072
|
-
r = (n, i = []) => {
|
|
1073
|
-
let c = "",
|
|
1074
|
-
o = 0;
|
|
1075
|
-
return (
|
|
1076
|
-
i.forEach((a) => {
|
|
1077
|
-
const h = a[1] + 1;
|
|
1078
|
-
(c += [
|
|
1079
|
-
n.substring(o, a[0]),
|
|
1080
|
-
`<mark class="${e}">`,
|
|
1081
|
-
n.substring(a[0], h),
|
|
1082
|
-
"</mark>",
|
|
1083
|
-
].join("")),
|
|
1084
|
-
(o = h);
|
|
1085
|
-
}),
|
|
1086
|
-
(c += n.substring(o)),
|
|
1087
|
-
c
|
|
1088
|
-
);
|
|
1089
|
-
};
|
|
1090
|
-
return s
|
|
1091
|
-
.filter(({ matches: n }) => n && n.length)
|
|
1092
|
-
.map(({ item: n, matches: i }) => {
|
|
1093
|
-
const c = { ...n };
|
|
1094
|
-
return (
|
|
1095
|
-
i.forEach((o) => {
|
|
1096
|
-
o.key === "name" && t(c, o.key, r(o.value, o.indices));
|
|
1097
|
-
}),
|
|
1098
|
-
c
|
|
1099
|
-
);
|
|
1100
|
-
});
|
|
1101
|
-
},
|
|
1102
|
-
he = document.createElement("template");
|
|
1103
|
-
he.innerHTML = Ue;
|
|
1104
|
-
class le extends HTMLElement {
|
|
1105
|
-
constructor() {
|
|
1106
|
-
super();
|
|
1107
|
-
_(this, "shadowRoot");
|
|
1108
|
-
_(this, "apply");
|
|
1109
|
-
_(this, "filterProperties");
|
|
1110
|
-
_(this, "items");
|
|
1111
|
-
_(this, "fuse");
|
|
1112
|
-
_(this, "filters");
|
|
1113
|
-
_(this, "aggregateBy");
|
|
1114
|
-
_(this, "fuseConfig");
|
|
1115
|
-
this.filters = {};
|
|
1116
|
-
const t = this.getAttribute("aggregateResults") || !1;
|
|
1117
|
-
(this.shadowRoot = this.attachShadow({ mode: "open" })),
|
|
1118
|
-
this.shadowRoot.appendChild(he.content.cloneNode(!0)),
|
|
1119
|
-
(this.apply = (i) => {
|
|
1120
|
-
(this.items = i),
|
|
1121
|
-
(this.fuse = new $(this.items, {
|
|
1122
|
-
minMatchCharLength: 1,
|
|
1123
|
-
includeMatches: !0,
|
|
1124
|
-
keys: ["name", ...this.filterProperties],
|
|
1125
|
-
useExtendedSearch: !0,
|
|
1126
|
-
...this.fuseConfig,
|
|
1127
|
-
})),
|
|
1128
|
-
this.filterProperties.forEach((c) => {
|
|
1129
|
-
const o = [
|
|
1130
|
-
...new Set(this.items.reduce((h, l) => h.concat(l[c]), [])),
|
|
1131
|
-
].sort(),
|
|
1132
|
-
a = this.shadowRoot.querySelector("ul#filters");
|
|
1133
|
-
o.forEach((h) => {
|
|
1134
|
-
const l = document.createElement("template");
|
|
1135
|
-
l.innerHTML = Qe;
|
|
1136
|
-
const u = l.content.cloneNode(!0);
|
|
1137
|
-
u
|
|
1138
|
-
.querySelector("input[type='checkbox']")
|
|
1139
|
-
.setAttribute("data-filter-key", c),
|
|
1140
|
-
u
|
|
1141
|
-
.querySelector("input[type='checkbox']")
|
|
1142
|
-
.setAttribute("data-filter-value", h),
|
|
1143
|
-
(u.querySelector("span.title").innerHTML = h),
|
|
1144
|
-
a.appendChild(u);
|
|
1145
|
-
}),
|
|
1146
|
-
t === c && (this.aggregateBy = o);
|
|
1147
|
-
}),
|
|
1148
|
-
r();
|
|
1149
|
-
});
|
|
1150
|
-
const r = () => {
|
|
1151
|
-
this.shadowRoot
|
|
1152
|
-
.querySelectorAll("input[type='checkbox']")
|
|
1153
|
-
.forEach((i) => {
|
|
1154
|
-
i.addEventListener("click", (c) => {
|
|
1155
|
-
const o = c.target,
|
|
1156
|
-
a = o.getAttribute("data-filter-key"),
|
|
1157
|
-
h = o.getAttribute("data-filter-value");
|
|
1158
|
-
o.checked
|
|
1159
|
-
? (this.filters[a] || (this.filters[a] = []),
|
|
1160
|
-
this.filters[a].push(h))
|
|
1161
|
-
: (this.filters[a].splice(this.filters[a].indexOf(h), 1),
|
|
1162
|
-
this.filters[a].length === 0 && delete this.filters[a]),
|
|
1163
|
-
n(this.shadowRoot.querySelector("input[type='text']").value);
|
|
1164
|
-
});
|
|
1165
|
-
});
|
|
1166
|
-
},
|
|
1167
|
-
n = (i, c = this.filters) => {
|
|
1168
|
-
const o = Object.entries(c).reduce((l, [u, d]) => {
|
|
1169
|
-
const g = (p) => {
|
|
1170
|
-
const y = {};
|
|
1171
|
-
(y[u] = `=${p}`), l.push(y);
|
|
1172
|
-
};
|
|
1173
|
-
return Array.isArray(d) ? d.forEach((p) => g(p)) : g(d), l;
|
|
1174
|
-
}, []),
|
|
1175
|
-
a = Je(
|
|
1176
|
-
this.fuse.search({
|
|
1177
|
-
...(i.length && Object.keys(o).length
|
|
1178
|
-
? { $and: [{ name: i }, { $or: o }] }
|
|
1179
|
-
: { $or: [{ name: i }, { $or: o }] }),
|
|
1180
|
-
})
|
|
1181
|
-
),
|
|
1182
|
-
h = this.shadowRoot.querySelector("ul#results");
|
|
1183
|
-
if (((h.innerHTML = ""), t)) {
|
|
1184
|
-
const l = document.createElement("template");
|
|
1185
|
-
(l.innerHTML = Xe),
|
|
1186
|
-
this.aggregateBy.forEach((u) => {
|
|
1187
|
-
if (
|
|
1188
|
-
!a.find((g) =>
|
|
1189
|
-
Array.isArray(g[t]) ? g[t].includes(u) : g[t] === u
|
|
1190
|
-
)
|
|
1191
|
-
)
|
|
1192
|
-
return;
|
|
1193
|
-
const d = l.content.cloneNode(!0);
|
|
1194
|
-
(d.querySelector("summary").innerHTML = u),
|
|
1195
|
-
d.querySelector("details").setAttribute("data-aggregate", u),
|
|
1196
|
-
h.appendChild(d);
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
a.forEach((l) => {
|
|
1200
|
-
if (this.aggregateBy) {
|
|
1201
|
-
const u = l[t];
|
|
1202
|
-
if (Array.isArray(u))
|
|
1203
|
-
u.forEach((d) => {
|
|
1204
|
-
const g = document.createElement("li");
|
|
1205
|
-
(g.innerHTML = l.name),
|
|
1206
|
-
this.shadowRoot
|
|
1207
|
-
.querySelector(`details[data-aggregate=${d}]`)
|
|
1208
|
-
.appendChild(g);
|
|
1209
|
-
});
|
|
1210
|
-
else {
|
|
1211
|
-
const d = document.createElement("li");
|
|
1212
|
-
(d.innerHTML = l.name),
|
|
1213
|
-
this.shadowRoot
|
|
1214
|
-
.querySelector(`details[data-aggregate=${u}]`)
|
|
1215
|
-
.appendChild(d);
|
|
1216
|
-
}
|
|
1217
|
-
} else {
|
|
1218
|
-
const u = document.createElement("li");
|
|
1219
|
-
(u.innerHTML = l.name), h.appendChild(u);
|
|
1220
|
-
}
|
|
1221
|
-
});
|
|
1222
|
-
};
|
|
1223
|
-
this.shadowRoot
|
|
1224
|
-
.querySelector("input[type='text']")
|
|
1225
|
-
.addEventListener("input", (i) => {
|
|
1226
|
-
n(i.target.value);
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
customElements.define("eox-itemfilter", le),
|
|
1231
|
-
(E.EOxItemFilter = le),
|
|
1232
|
-
Object.defineProperty(E, Symbol.toStringTag, { value: "Module" });
|
|
1233
|
-
});
|
|
171
|
+
`,Je=(s,e="highlight")=>{const t=(i,c,r)=>{const o=c.split(".");let l;for(l=0;l<o.length-1;l++)i=i[o[l]];i[o[l]]=r},n=(i,c=[])=>{let r="",o=0;return c.forEach(l=>{const a=l[1]+1;r+=[i.substring(o,l[0]),`<mark class="${e}">`,i.substring(l[0],a),"</mark>"].join(""),o=a}),r+=i.substring(o),r};return s.filter(({matches:i})=>i&&i.length).map(({item:i,matches:c})=>{const r={...i};return c.forEach(o=>{o.key==="name"&&t(r,o.key,n(o.value,o.indices))}),r})};class ae extends HTMLElement{constructor(){super();R(this,"shadowRoot");R(this,"apply");R(this,"items");R(this,"fuse");R(this,"filters");R(this,"aggregateBy");R(this,"config");this.filters={},this.shadowRoot=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=Ue,this.shadowRoot.appendChild(t.content.cloneNode(!0)),this.apply=r=>{this.config.enableSearch&&(this.shadowRoot.querySelector("input[type=text").style.display="block"),this.items=r,this.fuse=new O(this.items,{minMatchCharLength:1,includeMatches:!0,keys:["name",...this.config.filterProperties],useExtendedSearch:!0,...this.config.fuseConfig}),this.config.filterProperties.forEach(o=>{const l=[...new Set(this.items.reduce((f,g)=>f.concat(g[o]),[]))].sort(),a=this.shadowRoot.querySelector("ul#filters"),h=document.createElement("template");h.innerHTML=Ge;const u=h.content.cloneNode(!0);u.querySelector(".title").innerHTML=o,u.querySelector("details").setAttribute("data-filter",o),a.appendChild(u),l.forEach(f=>{const g=document.createElement("template");g.innerHTML=Ye;const p=g.content.cloneNode(!0),y=p.querySelector("input[type='checkbox']");y.setAttribute("data-filter-key",o),y.setAttribute("name","filter"),this.config.exclusiveFilters===!0&&(y.type="radio"),y.setAttribute("data-filter-value",f),p.querySelector("span.title").innerHTML=f,this.shadowRoot.querySelector(`details[data-filter='${o}']`).appendChild(p)}),this.config.aggregateResults===o&&(this.aggregateBy=l)}),n(),this.config.matchAllWhenEmpty!==!1&&i(this.items)};const n=()=>{const r=this.shadowRoot.querySelectorAll(`input[type="${this.config.exclusiveFilters===!0?"radio":"checkbox"}"]`),o=l=>{r.forEach(a=>{var f,g;const h=a.getAttribute("data-filter-key"),u=a.getAttribute("data-filter-value");if(a.checked)this.filters[h]||(this.filters[h]=[]),this.filters[h].includes(u)||this.filters[h].push(u);else{if(l===a){if(!this.filters[h])return;this.filters[h].splice(this.filters[h].indexOf(u),1)}else this.config.exclusiveFilters===!0&&this.filters[h]&&this.filters[h].includes(u)&&((f=this.filters[h])==null||f.splice(this.filters[h].indexOf(u),1));((g=this.filters[h])==null?void 0:g.length)===0&&delete this.filters[h]}})};r.forEach(l=>{l.addEventListener("click",a=>{o(a.target),this.config.matchAllWhenEmpty!==!1&&Object.keys(this.filters).length===0?i(this.items):c(this.shadowRoot.querySelector("input[type='text']").value)})})},i=r=>{const o=this.shadowRoot.querySelector("ul#results");if(o.innerHTML="",this.config.aggregateResults){const l=document.createElement("template");l.innerHTML=Xe,this.aggregateBy.forEach(a=>{if(!r.find(u=>Array.isArray(u[this.config.aggregateResults])?u[this.config.aggregateResults].includes(a):u[this.config.aggregateResults]===a))return;const h=l.content.cloneNode(!0);h.querySelector("summary .title").innerHTML=a,h.querySelector("details").setAttribute("data-aggregate",a),o.appendChild(h)})}r.forEach(l=>{const a=document.createElement("template");a.innerHTML=Qe;const h=a.content.cloneNode(!0);h.querySelector(".title").innerHTML=l.name;let u;if(this.aggregateBy){const f=l[this.config.aggregateResults];Array.isArray(f)?f.forEach(g=>{u=this.shadowRoot.querySelector(`details[data-aggregate=${g}]`)}):u=this.shadowRoot.querySelector(`details[data-aggregate=${f}]`)}else u=o;h.querySelector("input").addEventListener("click",()=>{this.config.onSelect&&this.config.onSelect(l)}),u.appendChild(h)}),this.config.aggregateResults&&this.shadowRoot.querySelectorAll("#results details").forEach(a=>{a.querySelector("summary .count").innerHTML=a.querySelectorAll("li").length})},c=(r,o=this.filters)=>{const l=Object.entries(o).reduce((u,[f,g])=>{const p=y=>{const L={};L[f]=`=${y}`,u.push(L)};return Array.isArray(g)?g.forEach(y=>p(y)):p(g),u},[]),a=this.fuse.search({...r.length&&Object.keys(l).length?{$and:[{name:r},{$or:l}]}:{$or:[{name:r},{$or:l}]}}),h=this.config.enableHighlighting?Je(a):a.map(u=>u.item);i(h)};this.shadowRoot.querySelector("input[type='text']").addEventListener("input",r=>{const o=r.target.value;!o&&this.config.matchAllWhenEmpty!==!1?i(this.items):c(o)})}}customElements.define("eox-itemfilter",ae),M.EOxItemFilter=ae,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|