muddle/modules/amezing/scripts/fuse.js
2026-10-23 09:12:49 -04:00

1935 lines
46 KiB
JavaScript

/**
* Fuse.js v7.2.0 - Lightweight fuzzy-search (http://fusejs.io)
*
* Copyright (c) 2026 Kiro Risk (http://kiro.me)
* All Rights Reserved. Apache Software License 2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
var e, t;
(e = this),
(t = function () {
"use strict";
function e(e, t) {
var n = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var r = Object.getOwnPropertySymbols(e);
t &&
(r = r.filter(function (t) {
return Object.getOwnPropertyDescriptor(e, t).enumerable;
})),
n.push.apply(n, r);
}
return n;
}
function t(t) {
for (var n = 1; n < arguments.length; n++) {
var r = null != arguments[n] ? arguments[n] : {};
n % 2
? e(Object(r), !0).forEach(function (e) {
o(t, e, r[e]);
})
: Object.getOwnPropertyDescriptors
? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r))
: e(Object(r)).forEach(function (e) {
Object.defineProperty(
t,
e,
Object.getOwnPropertyDescriptor(r, e),
);
});
}
return t;
}
function n(e) {
return (
(n =
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator
? function (e) {
return typeof e;
}
: function (e) {
return e &&
"function" == typeof Symbol &&
e.constructor === Symbol &&
e !== Symbol.prototype
? "symbol"
: typeof e;
}),
n(e)
);
}
function r(e, t) {
if (!(e instanceof t))
throw new TypeError("Cannot call a class as a function");
}
function i(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
(r.enumerable = r.enumerable || !1),
(r.configurable = !0),
"value" in r && (r.writable = !0),
Object.defineProperty(e, v(r.key), r);
}
}
function u(e, t, n) {
return (
t && i(e.prototype, t),
n && i(e, n),
Object.defineProperty(e, "prototype", { writable: !1 }),
e
);
}
function o(e, t, n) {
return (
(t = v(t)) in e
? Object.defineProperty(e, t, {
value: n,
enumerable: !0,
configurable: !0,
writable: !0,
})
: (e[t] = n),
e
);
}
function c(e, t) {
if ("function" != typeof t && null !== t)
throw new TypeError(
"Super expression must either be null or a function",
);
(e.prototype = Object.create(t && t.prototype, {
constructor: { value: e, writable: !0, configurable: !0 },
})),
Object.defineProperty(e, "prototype", { writable: !1 }),
t && a(e, t);
}
function s(e) {
return (
(s = Object.setPrototypeOf
? Object.getPrototypeOf.bind()
: function (e) {
return e.__proto__ || Object.getPrototypeOf(e);
}),
s(e)
);
}
function a(e, t) {
return (
(a = Object.setPrototypeOf
? Object.setPrototypeOf.bind()
: function (e, t) {
return ((e.__proto__ = t), e);
}),
a(e, t)
);
}
function h(e, t) {
if (t && ("object" == typeof t || "function" == typeof t)) return t;
if (void 0 !== t)
throw new TypeError(
"Derived constructors may only return object or undefined",
);
return (function (e) {
if (void 0 === e)
throw new ReferenceError(
"this hasn't been initialised - super() hasn't been called",
);
return e;
})(e);
}
function l(e) {
var t = (function () {
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
if (Reflect.construct.sham) return !1;
if ("function" == typeof Proxy) return !0;
try {
return (
Boolean.prototype.valueOf.call(
Reflect.construct(Boolean, [], function () {}),
),
!0
);
} catch (e) {
return !1;
}
})();
return function () {
var n,
r = s(e);
if (t) {
var i = s(this).constructor;
n = Reflect.construct(r, arguments, i);
} else n = r.apply(this, arguments);
return h(this, n);
};
}
function f(e) {
return (
(function (e) {
if (Array.isArray(e)) return d(e);
})(e) ||
(function (e) {
if (
("undefined" != typeof Symbol && null != e[Symbol.iterator]) ||
null != e["@@iterator"]
)
return Array.from(e);
})(e) ||
(function (e, t) {
if (e) {
if ("string" == typeof e) return d(e, t);
var n = Object.prototype.toString.call(e).slice(8, -1);
return (
"Object" === n && e.constructor && (n = e.constructor.name),
"Map" === n || "Set" === n
? Array.from(e)
: "Arguments" === n ||
/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)
? d(e, t)
: void 0
);
}
})(e) ||
(function () {
throw new TypeError(
"Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.",
);
})()
);
}
function d(e, t) {
(null == t || t > e.length) && (t = e.length);
for (var n = 0, r = new Array(t); n < t; n++) r[n] = e[n];
return r;
}
function v(e) {
var t = (function (e, t) {
if ("object" != typeof e || null === e) return e;
var n = e[Symbol.toPrimitive];
if (void 0 !== n) {
var r = n.call(e, t || "default");
if ("object" != typeof r) return r;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === t ? String : Number)(e);
})(e, "string");
return "symbol" == typeof t ? t : String(t);
}
function g(e) {
return Array.isArray ? Array.isArray(e) : "[object Array]" === M(e);
}
var y = 1 / 0;
function p(e) {
return null == e
? ""
: (function (e) {
if ("string" == typeof e) return e;
var t = e + "";
return "0" == t && 1 / e == -y ? "-0" : t;
})(e);
}
function A(e) {
return "string" == typeof e;
}
function m(e) {
return "number" == typeof e;
}
function C(e) {
return (
!0 === e ||
!1 === e ||
((function (e) {
return k(e) && null !== e;
})(e) &&
"[object Boolean]" == M(e))
);
}
function k(e) {
return "object" === n(e);
}
function F(e) {
return null != e;
}
function b(e) {
return !e.trim().length;
}
function M(e) {
return null == e
? void 0 === e
? "[object Undefined]"
: "[object Null]"
: Object.prototype.toString.call(e);
}
var E = function (e) {
return "Missing ".concat(e, " property in key");
},
D = function (e) {
return "Property 'weight' in key '".concat(
e,
"' must be a positive integer",
);
},
B = Object.prototype.hasOwnProperty,
x = (function () {
function e(t) {
var n = this;
r(this, e), (this._keys = []), (this._keyMap = {});
var i = 0;
t.forEach(function (e) {
var t = _(e);
n._keys.push(t), (n._keyMap[t.id] = t), (i += t.weight);
}),
this._keys.forEach(function (e) {
e.weight /= i;
});
}
return (
u(e, [
{
key: "get",
value: function (e) {
return this._keyMap[e];
},
},
{
key: "keys",
value: function () {
return this._keys;
},
},
{
key: "toJSON",
value: function () {
return JSON.stringify(this._keys);
},
},
]),
e
);
})();
function _(e) {
var t = null,
n = null,
r = null,
i = 1,
u = null;
if (A(e) || g(e)) (r = e), (t = S(e)), (n = w(e));
else {
if (!B.call(e, "name")) throw new Error(E("name"));
var o = e.name;
if (((r = o), B.call(e, "weight") && (i = e.weight) <= 0))
throw new Error(D(o));
(t = S(o)), (n = w(o)), (u = e.getFn);
}
return { path: t, id: n, weight: i, src: r, getFn: u };
}
function S(e) {
return g(e) ? e : e.split(".");
}
function w(e) {
return g(e) ? e.join(".") : e;
}
var O = {
useExtendedSearch: !1,
getFn: function (e, t) {
var n = [],
r = !1;
return (
(function e(t, i, u, o) {
if (F(t))
if (i[u]) {
var c = t[i[u]];
if (!F(c)) return;
if (u === i.length - 1 && (A(c) || m(c) || C(c)))
n.push(void 0 !== o ? { v: p(c), i: o } : p(c));
else if (g(c)) {
r = !0;
for (var s = 0, a = c.length; s < a; s += 1)
e(c[s], i, u + 1, s);
} else i.length && e(c, i, u + 1, o);
} else n.push(void 0 !== o ? { v: t, i: o } : t);
})(e, A(t) ? t.split(".") : t, 0),
r ? n : n[0]
);
},
ignoreLocation: !1,
ignoreFieldNorm: !1,
fieldNormWeight: 1,
},
j = t(
t(
t(
t(
{},
{
isCaseSensitive: !1,
ignoreDiacritics: !1,
includeScore: !1,
keys: [],
shouldSort: !0,
sortFn: function (e, t) {
return e.score === t.score
? e.idx < t.idx
? -1
: 1
: e.score < t.score
? -1
: 1;
},
},
),
{ includeMatches: !1, findAllMatches: !1, minMatchCharLength: 1 },
),
{ location: 0, threshold: 0.6, distance: 100 },
),
O,
),
L = /[^ ]+/g,
I = (function () {
function e() {
var t =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: {},
n = t.getFn,
i = void 0 === n ? j.getFn : n,
u = t.fieldNormWeight,
o = void 0 === u ? j.fieldNormWeight : u;
r(this, e),
(this.norm = (function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 1,
t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: 3,
n = new Map(),
r = Math.pow(10, t);
return {
get: function (t) {
var i = t.match(L).length;
if (n.has(i)) return n.get(i);
var u = 1 / Math.pow(i, 0.5 * e),
o = parseFloat(Math.round(u * r) / r);
return (n.set(i, o), o);
},
clear: function () {
n.clear();
},
};
})(o, 3)),
(this.getFn = i),
(this.isCreated = !1),
this.setIndexRecords();
}
return (
u(e, [
{
key: "setSources",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: [];
this.docs = e;
},
},
{
key: "setIndexRecords",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: [];
this.records = e;
},
},
{
key: "setKeys",
value: function () {
var e = this,
t =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: [];
(this.keys = t),
(this._keysMap = {}),
t.forEach(function (t, n) {
e._keysMap[t.id] = n;
});
},
},
{
key: "create",
value: function () {
var e = this;
!this.isCreated &&
this.docs.length &&
((this.isCreated = !0),
A(this.docs[0])
? this.docs.forEach(function (t, n) {
e._addString(t, n);
})
: this.docs.forEach(function (t, n) {
e._addObject(t, n);
}),
this.norm.clear());
},
},
{
key: "add",
value: function (e) {
var t = this.size();
A(e) ? this._addString(e, t) : this._addObject(e, t);
},
},
{
key: "removeAt",
value: function (e) {
this.records.splice(e, 1);
for (var t = e, n = this.size(); t < n; t += 1)
this.records[t].i -= 1;
},
},
{
key: "removeAll",
value: function (e) {
for (var t = e.length - 1; t >= 0; t -= 1)
this.records.splice(e[t], 1);
for (var n = 0, r = this.records.length; n < r; n += 1)
this.records[n].i = n;
},
},
{
key: "getValueForItemAtKeyId",
value: function (e, t) {
return e[this._keysMap[t]];
},
},
{
key: "size",
value: function () {
return this.records.length;
},
},
{
key: "_addString",
value: function (e, t) {
if (F(e) && !b(e)) {
var n = { v: e, i: t, n: this.norm.get(e) };
this.records.push(n);
}
},
},
{
key: "_addObject",
value: function (e, t) {
var n = this,
r = { i: t, $: {} };
this.keys.forEach(function (t, i) {
var u = t.getFn ? t.getFn(e) : n.getFn(e, t.path);
if (F(u))
if (g(u)) {
for (var o = [], c = 0, s = u.length; c < s; c += 1) {
var a = u[c];
if (F(a))
if (A(a)) {
if (!b(a)) {
var h = { v: a, i: c, n: n.norm.get(a) };
o.push(h);
}
} else if (A(a.v) && !b(a.v)) {
var l = { v: a.v, i: a.i, n: n.norm.get(a.v) };
o.push(l);
}
}
r.$[i] = o;
} else if (A(u) && !b(u)) {
var f = { v: u, n: n.norm.get(u) };
r.$[i] = f;
}
}),
this.records.push(r);
},
},
{
key: "toJSON",
value: function () {
return { keys: this.keys, records: this.records };
},
},
]),
e
);
})();
function N(e, t) {
var n =
arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {},
r = n.getFn,
i = void 0 === r ? j.getFn : r,
u = n.fieldNormWeight,
o = void 0 === u ? j.fieldNormWeight : u,
c = new I({ getFn: i, fieldNormWeight: o });
return (c.setKeys(e.map(_)), c.setSources(t), c.create(), c);
}
var $ = 32;
function R(e, t, n) {
var r =
arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {},
i = r.location,
u = void 0 === i ? j.location : i,
o = r.distance,
c = void 0 === o ? j.distance : o,
s = r.threshold,
a = void 0 === s ? j.threshold : s,
h = r.findAllMatches,
l = void 0 === h ? j.findAllMatches : h,
f = r.minMatchCharLength,
d = void 0 === f ? j.minMatchCharLength : f,
v = r.includeMatches,
g = void 0 === v ? j.includeMatches : v,
y = r.ignoreLocation,
p = void 0 === y ? j.ignoreLocation : y;
if (t.length > $)
throw new Error("Pattern length exceeds max of ".concat($, "."));
for (
var A,
m = t.length,
C = e.length,
k = Math.max(0, Math.min(u, C)),
F = a,
b = k,
M = function (e, t) {
var n = e / m;
if (p) return n;
var r = Math.abs(k - t);
return c ? n + r / c : r ? 1 : n;
},
E = d > 1 || g,
D = E ? Array(C) : [];
(A = e.indexOf(t, b)) > -1;
) {
var B = M(0, A);
if (((F = Math.min(B, F)), (b = A + m), E))
for (var x = 0; x < m; ) (D[A + x] = 1), (x += 1);
}
b = -1;
for (
var _ = [], S = 1, w = m + C, O = 1 << (m - 1), L = 0;
L < m;
L += 1
) {
for (var I = 0, N = w; I < N; )
M(L, k + N) <= F ? (I = N) : (w = N),
(N = Math.floor((w - I) / 2 + I));
w = N;
var R = Math.max(1, k - N + 1),
P = l ? C : Math.min(k + N, C) + m,
W = Array(P + 2);
W[P + 1] = (1 << L) - 1;
for (var z = P; z >= R; z -= 1) {
var T = z - 1,
K = n[e[T]];
if (
(E && (D[T] = +!!K),
(W[z] = ((W[z + 1] << 1) | 1) & K),
L && (W[z] |= ((_[z + 1] | _[z]) << 1) | 1 | _[z + 1]),
W[z] & O && (S = M(L, T)) <= F)
) {
if (((F = S), (b = T) <= k)) break;
R = Math.max(1, 2 * k - b);
}
}
if (M(L + 1, k) > F) break;
_ = W;
}
var U = { isMatch: b >= 0, score: Math.max(0.001, S) };
if (E) {
var q = (function () {
for (
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: [],
t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: j.minMatchCharLength,
n = [],
r = -1,
i = -1,
u = 0,
o = e.length;
u < o;
u += 1
) {
var c = e[u];
c && -1 === r
? (r = u)
: c ||
-1 === r ||
((i = u - 1) - r + 1 >= t && n.push([r, i]), (r = -1));
}
return (e[u - 1] && u - r >= t && n.push([r, u - 1]), n);
})(D, d);
q.length ? g && (U.indices = q) : (U.isMatch = !1);
}
return U;
}
function P(e) {
for (var t = {}, n = 0, r = e.length; n < r; n += 1) {
var i = e.charAt(n);
t[i] = (t[i] || 0) | (1 << (r - n - 1));
}
return t;
}
var W = String.prototype.normalize
? function (e) {
return e
.normalize("NFD")
.replace(
/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,
"",
);
}
: function (e) {
return e;
},
z = (function () {
function e(t) {
var n = this,
i =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: {},
u = i.location,
o = void 0 === u ? j.location : u,
c = i.threshold,
s = void 0 === c ? j.threshold : c,
a = i.distance,
h = void 0 === a ? j.distance : a,
l = i.includeMatches,
f = void 0 === l ? j.includeMatches : l,
d = i.findAllMatches,
v = void 0 === d ? j.findAllMatches : d,
g = i.minMatchCharLength,
y = void 0 === g ? j.minMatchCharLength : g,
p = i.isCaseSensitive,
A = void 0 === p ? j.isCaseSensitive : p,
m = i.ignoreDiacritics,
C = void 0 === m ? j.ignoreDiacritics : m,
k = i.ignoreLocation,
F = void 0 === k ? j.ignoreLocation : k;
if (
(r(this, e),
(this.options = {
location: o,
threshold: s,
distance: h,
includeMatches: f,
findAllMatches: v,
minMatchCharLength: y,
isCaseSensitive: A,
ignoreDiacritics: C,
ignoreLocation: F,
}),
(t = A ? t : t.toLowerCase()),
(t = C ? W(t) : t),
(this.pattern = t),
(this.chunks = []),
this.pattern.length)
) {
var b = function (e, t) {
n.chunks.push({ pattern: e, alphabet: P(e), startIndex: t });
},
M = this.pattern.length;
if (M > $) {
for (var E = 0, D = M % $, B = M - D; E < B; )
b(this.pattern.substr(E, $), E), (E += $);
if (D) {
var x = M - $;
b(this.pattern.substr(x), x);
}
} else b(this.pattern, 0);
}
}
return (
u(e, [
{
key: "searchIn",
value: function (e) {
var t = this.options,
n = t.isCaseSensitive,
r = t.ignoreDiacritics,
i = t.includeMatches;
if (
((e = n ? e : e.toLowerCase()),
(e = r ? W(e) : e),
this.pattern === e)
) {
var u = { isMatch: !0, score: 0 };
return (i && (u.indices = [[0, e.length - 1]]), u);
}
var o = this.options,
c = o.location,
s = o.distance,
a = o.threshold,
h = o.findAllMatches,
l = o.minMatchCharLength,
d = o.ignoreLocation,
v = [],
g = 0,
y = !1;
this.chunks.forEach(function (t) {
var n = t.pattern,
r = t.alphabet,
u = t.startIndex,
o = R(e, n, r, {
location: c + u,
distance: s,
threshold: a,
findAllMatches: h,
minMatchCharLength: l,
includeMatches: i,
ignoreLocation: d,
}),
p = o.isMatch,
A = o.score,
m = o.indices;
p && (y = !0), (g += A), p && m && v.push.apply(v, f(m));
});
var p = { isMatch: y, score: y ? g / this.chunks.length : 1 };
return (
y &&
i &&
(p.indices = (function (e) {
if (e.length <= 1) return e;
e.sort(function (e, t) {
return e[0] - t[0] || e[1] - t[1];
});
for (var t = [e[0]], n = 1, r = e.length; n < r; n += 1) {
var i = t[t.length - 1],
u = e[n];
u[0] <= i[1] + 1
? (i[1] = Math.max(i[1], u[1]))
: t.push(u);
}
return t;
})(v)),
p
);
},
},
]),
e
);
})(),
T = (function () {
function e(t) {
r(this, e), (this.pattern = t);
}
return (
u(
e,
[{ key: "search", value: function () {} }],
[
{
key: "isMultiMatch",
value: function (e) {
return K(e, this.multiRegex);
},
},
{
key: "isSingleMatch",
value: function (e) {
return K(e, this.singleRegex);
},
},
],
),
e
);
})();
function K(e, t) {
var n = e.match(t);
return n ? n[1] : null;
}
var U = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
return (r(this, n), t.call(this, e));
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
var t = e === this.pattern;
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, this.pattern.length - 1],
};
},
},
],
[
{
key: "type",
get: function () {
return "exact";
},
},
{
key: "multiRegex",
get: function () {
return /^="(.*)"$/;
},
},
{
key: "singleRegex",
get: function () {
return /^=(.*)$/;
},
},
],
),
n
);
})(T),
q = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
return (r(this, n), t.call(this, e));
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
var t = -1 === e.indexOf(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, e.length - 1],
};
},
},
],
[
{
key: "type",
get: function () {
return "inverse-exact";
},
},
{
key: "multiRegex",
get: function () {
return /^!"(.*)"$/;
},
},
{
key: "singleRegex",
get: function () {
return /^!(.*)$/;
},
},
],
),
n
);
})(T),
J = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
return (r(this, n), t.call(this, e));
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
var t = e.startsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, this.pattern.length - 1],
};
},
},
],
[
{
key: "type",
get: function () {
return "prefix-exact";
},
},
{
key: "multiRegex",
get: function () {
return /^\^"(.*)"$/;
},
},
{
key: "singleRegex",
get: function () {
return /^\^(.*)$/;
},
},
],
),
n
);
})(T),
Q = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
return (r(this, n), t.call(this, e));
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
var t = !e.startsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, e.length - 1],
};
},
},
],
[
{
key: "type",
get: function () {
return "inverse-prefix-exact";
},
},
{
key: "multiRegex",
get: function () {
return /^!\^"(.*)"$/;
},
},
{
key: "singleRegex",
get: function () {
return /^!\^(.*)$/;
},
},
],
),
n
);
})(T),
V = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
return (r(this, n), t.call(this, e));
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
var t = e.endsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [e.length - this.pattern.length, e.length - 1],
};
},
},
],
[
{
key: "type",
get: function () {
return "suffix-exact";
},
},
{
key: "multiRegex",
get: function () {
return /^"(.*)"\$$/;
},
},
{
key: "singleRegex",
get: function () {
return /^(.*)\$$/;
},
},
],
),
n
);
})(T),
G = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
return (r(this, n), t.call(this, e));
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
var t = !e.endsWith(this.pattern);
return {
isMatch: t,
score: t ? 0 : 1,
indices: [0, e.length - 1],
};
},
},
],
[
{
key: "type",
get: function () {
return "inverse-suffix-exact";
},
},
{
key: "multiRegex",
get: function () {
return /^!"(.*)"\$$/;
},
},
{
key: "singleRegex",
get: function () {
return /^!(.*)\$$/;
},
},
],
),
n
);
})(T),
H = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
var i,
u =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: {},
o = u.location,
c = void 0 === o ? j.location : o,
s = u.threshold,
a = void 0 === s ? j.threshold : s,
h = u.distance,
l = void 0 === h ? j.distance : h,
f = u.includeMatches,
d = void 0 === f ? j.includeMatches : f,
v = u.findAllMatches,
g = void 0 === v ? j.findAllMatches : v,
y = u.minMatchCharLength,
p = void 0 === y ? j.minMatchCharLength : y,
A = u.isCaseSensitive,
m = void 0 === A ? j.isCaseSensitive : A,
C = u.ignoreDiacritics,
k = void 0 === C ? j.ignoreDiacritics : C,
F = u.ignoreLocation,
b = void 0 === F ? j.ignoreLocation : F;
return (
r(this, n),
((i = t.call(this, e))._bitapSearch = new z(e, {
location: c,
threshold: a,
distance: l,
includeMatches: d,
findAllMatches: g,
minMatchCharLength: p,
isCaseSensitive: m,
ignoreDiacritics: k,
ignoreLocation: b,
})),
i
);
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
return this._bitapSearch.searchIn(e);
},
},
],
[
{
key: "type",
get: function () {
return "fuzzy";
},
},
{
key: "multiRegex",
get: function () {
return /^"(.*)"$/;
},
},
{
key: "singleRegex",
get: function () {
return /^(.*)$/;
},
},
],
),
n
);
})(T),
X = (function (e) {
c(n, e);
var t = l(n);
function n(e) {
return (r(this, n), t.call(this, e));
}
return (
u(
n,
[
{
key: "search",
value: function (e) {
for (
var t, n = 0, r = [], i = this.pattern.length;
(t = e.indexOf(this.pattern, n)) > -1;
)
(n = t + i), r.push([t, n - 1]);
var u = !!r.length;
return { isMatch: u, score: u ? 0 : 1, indices: r };
},
},
],
[
{
key: "type",
get: function () {
return "include";
},
},
{
key: "multiRegex",
get: function () {
return /^'"(.*)"$/;
},
},
{
key: "singleRegex",
get: function () {
return /^'(.*)$/;
},
},
],
),
n
);
})(T),
Y = [U, X, J, Q, G, V, q, H],
Z = Y.length,
ee = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,
te = new Set([H.type, X.type]),
ne = (function () {
function e(t) {
var n =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: {},
i = n.isCaseSensitive,
u = void 0 === i ? j.isCaseSensitive : i,
o = n.ignoreDiacritics,
c = void 0 === o ? j.ignoreDiacritics : o,
s = n.includeMatches,
a = void 0 === s ? j.includeMatches : s,
h = n.minMatchCharLength,
l = void 0 === h ? j.minMatchCharLength : h,
f = n.ignoreLocation,
d = void 0 === f ? j.ignoreLocation : f,
v = n.findAllMatches,
g = void 0 === v ? j.findAllMatches : v,
y = n.location,
p = void 0 === y ? j.location : y,
A = n.threshold,
m = void 0 === A ? j.threshold : A,
C = n.distance,
k = void 0 === C ? j.distance : C;
r(this, e),
(this.query = null),
(this.options = {
isCaseSensitive: u,
ignoreDiacritics: c,
includeMatches: a,
minMatchCharLength: l,
findAllMatches: g,
ignoreLocation: d,
location: p,
threshold: m,
distance: k,
}),
(t = u ? t : t.toLowerCase()),
(t = c ? W(t) : t),
(this.pattern = t),
(this.query = (function (e) {
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: {};
return e.split("|").map(function (e) {
for (
var n = e
.trim()
.split(ee)
.filter(function (e) {
return e && !!e.trim();
}),
r = [],
i = 0,
u = n.length;
i < u;
i += 1
) {
for (var o = n[i], c = !1, s = -1; !c && ++s < Z; ) {
var a = Y[s],
h = a.isMultiMatch(o);
h && (r.push(new a(h, t)), (c = !0));
}
if (!c)
for (s = -1; ++s < Z; ) {
var l = Y[s],
f = l.isSingleMatch(o);
if (f) {
r.push(new l(f, t));
break;
}
}
}
return r;
});
})(this.pattern, this.options));
}
return (
u(
e,
[
{
key: "searchIn",
value: function (e) {
var t = this.query;
if (!t) return { isMatch: !1, score: 1 };
var n = this.options,
r = n.includeMatches,
i = n.isCaseSensitive,
u = n.ignoreDiacritics;
(e = i ? e : e.toLowerCase()), (e = u ? W(e) : e);
for (
var o = 0, c = [], s = 0, a = 0, h = t.length;
a < h;
a += 1
) {
var l = t[a];
(c.length = 0), (o = 0);
for (var d = 0, v = l.length; d < v; d += 1) {
var g = l[d],
y = g.search(e),
p = y.isMatch,
A = y.indices,
m = y.score;
if (!p) {
(s = 0), (o = 0), (c.length = 0);
break;
}
if (((o += 1), (s += m), r)) {
var C = g.constructor.type;
te.has(C) ? c.push.apply(c, f(A)) : c.push(A);
}
}
if (o) {
var k = { isMatch: !0, score: s / o };
return (r && (k.indices = c), k);
}
}
return { isMatch: !1, score: 1 };
},
},
],
[
{
key: "condition",
value: function (e, t) {
return t.useExtendedSearch;
},
},
],
),
e
);
})(),
re = [];
function ie() {
re.push.apply(re, arguments);
}
function ue(e, t) {
for (var n = 0, r = re.length; n < r; n += 1) {
var i = re[n];
if (i.condition(e, t)) return new i(e, t);
}
return new z(e, t);
}
var oe = "$and",
ce = "$or",
se = "$path",
ae = "$val",
he = function (e) {
return !(!e[oe] && !e[ce]);
},
le = function (e) {
return o(
{},
oe,
Object.keys(e).map(function (t) {
return o({}, t, e[t]);
}),
);
};
function fe(e, t) {
var n = (
arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}
).auto,
r = void 0 === n || n;
return (
he(e) || (e = le(e)),
(function e(n) {
var i = Object.keys(n),
u = (function (e) {
return !!e[se];
})(n);
if (!u && i.length > 1 && !he(n)) return e(le(n));
if (
(function (e) {
return !g(e) && k(e) && !he(e);
})(n)
) {
var o = u ? n[se] : i[0],
c = u ? n[ae] : n[o];
if (!A(c))
throw new Error(
(function (e) {
return "Invalid value for key ".concat(e);
})(o),
);
var s = { keyId: w(o), pattern: c };
return (r && (s.searcher = ue(c, t)), s);
}
var a = { children: [], operator: i[0] };
return (
i.forEach(function (t) {
var r = n[t];
g(r) &&
r.forEach(function (t) {
a.children.push(e(t));
});
}),
a
);
})(e)
);
}
function de(e, t) {
var n = t.ignoreFieldNorm,
r = void 0 === n ? j.ignoreFieldNorm : n,
i = 1;
e.matches.forEach(function (e) {
var t = e.key,
n = e.norm,
u = e.score,
o = t ? t.weight : null;
i *= Math.pow(
0 === u && o ? Number.EPSILON : u,
(o || 1) * (r ? 1 : n),
);
}),
(e.score = i);
}
var ve = (function () {
function e(t) {
r(this, e), (this.limit = t), (this.heap = []);
}
return (
u(e, [
{
key: "size",
get: function () {
return this.heap.length;
},
},
{
key: "shouldInsert",
value: function (e) {
return this.size < this.limit || e < this.heap[0].score;
},
},
{
key: "insert",
value: function (e) {
this.size < this.limit
? (this.heap.push(e), this._bubbleUp(this.size - 1))
: e.score < this.heap[0].score &&
((this.heap[0] = e), this._sinkDown(0));
},
},
{
key: "extractSorted",
value: function (e) {
return this.heap.sort(e);
},
},
{
key: "_bubbleUp",
value: function (e) {
for (var t = this.heap; e > 0; ) {
var n = (e - 1) >> 1;
if (t[e].score <= t[n].score) break;
var r = t[e];
(t[e] = t[n]), (t[n] = r), (e = n);
}
},
},
{
key: "_sinkDown",
value: function (e) {
var t = this.heap,
n = t.length,
r = e;
do {
var i = 2 * (e = r) + 1,
u = 2 * e + 2;
if (
(i < n && t[i].score > t[r].score && (r = i),
u < n && t[u].score > t[r].score && (r = u),
r !== e)
) {
var o = t[e];
(t[e] = t[r]), (t[r] = o);
}
} while (r !== e);
},
},
]),
e
);
})();
function ge(e, t) {
var n = e.matches;
(t.matches = []),
F(n) &&
n.forEach(function (e) {
if (F(e.indices) && e.indices.length) {
var n = { indices: e.indices, value: e.value };
e.key && (n.key = e.key.src),
e.idx > -1 && (n.refIndex = e.idx),
t.matches.push(n);
}
});
}
function ye(e, t) {
t.score = e.score;
}
var pe = (function () {
function e(n) {
var i =
arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {},
u = arguments.length > 2 ? arguments[2] : void 0;
r(this, e),
(this.options = t(t({}, j), i)),
this.options.useExtendedSearch,
(this._keyStore = new x(this.options.keys)),
this.setCollection(n, u),
(this._lastQuery = null),
(this._lastSearcher = null);
}
return (
u(e, [
{
key: "_getSearcher",
value: function (e) {
if (this._lastQuery === e) return this._lastSearcher;
var t = ue(e, this.options);
return ((this._lastQuery = e), (this._lastSearcher = t), t);
},
},
{
key: "setCollection",
value: function (e, t) {
if (((this._docs = e), t && !(t instanceof I)))
throw new Error("Incorrect 'index' type");
this._myIndex =
t ||
N(this.options.keys, this._docs, {
getFn: this.options.getFn,
fieldNormWeight: this.options.fieldNormWeight,
});
},
},
{
key: "add",
value: function (e) {
F(e) && (this._docs.push(e), this._myIndex.add(e));
},
},
{
key: "remove",
value: function () {
for (
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: function () {
return !1;
},
t = [],
n = [],
r = 0,
i = this._docs.length;
r < i;
r += 1
)
e(this._docs[r], r) && (t.push(this._docs[r]), n.push(r));
if (n.length) {
for (var u = n.length - 1; u >= 0; u -= 1)
this._docs.splice(n[u], 1);
this._myIndex.removeAll(n);
}
return t;
},
},
{
key: "removeAt",
value: function (e) {
this._docs.splice(e, 1), this._myIndex.removeAt(e);
},
},
{
key: "getIndex",
value: function () {
return this._myIndex;
},
},
{
key: "search",
value: function (e) {
var t,
n = (
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: {}
).limit,
r = void 0 === n ? -1 : n,
i = this.options,
u = i.includeMatches,
o = i.includeScore,
c = i.shouldSort,
s = i.sortFn,
a = i.ignoreFieldNorm;
if (m(r) && r > 0 && A(e)) {
var h = new ve(r);
A(this._docs[0])
? this._searchStringList(e, { heap: h, ignoreFieldNorm: a })
: this._searchObjectList(e, { heap: h, ignoreFieldNorm: a }),
(t = h.extractSorted(s));
} else
(function (e, t) {
var n = t.ignoreFieldNorm,
r = void 0 === n ? j.ignoreFieldNorm : n;
e.forEach(function (e) {
de(e, { ignoreFieldNorm: r });
});
})(
(t = A(e)
? A(this._docs[0])
? this._searchStringList(e)
: this._searchObjectList(e)
: this._searchLogical(e)),
{ ignoreFieldNorm: a },
),
c && t.sort(s),
m(r) && r > -1 && (t = t.slice(0, r));
return (function (e, t) {
var n =
arguments.length > 2 && void 0 !== arguments[2]
? arguments[2]
: {},
r = n.includeMatches,
i = void 0 === r ? j.includeMatches : r,
u = n.includeScore,
o = void 0 === u ? j.includeScore : u,
c = [];
return (
i && c.push(ge),
o && c.push(ye),
e.map(function (e) {
var n = e.idx,
r = { item: t[n], refIndex: n };
return (
c.length &&
c.forEach(function (t) {
t(e, r);
}),
r
);
})
);
})(t, this._docs, { includeMatches: u, includeScore: o });
},
},
{
key: "_searchStringList",
value: function (e) {
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: {},
n = t.heap,
r = t.ignoreFieldNorm,
i = this._getSearcher(e),
u = this._myIndex.records,
o = n ? null : [];
return (
u.forEach(function (e) {
var t = e.v,
u = e.i,
c = e.n;
if (F(t)) {
var s = i.searchIn(t),
a = s.isMatch,
h = s.score,
l = s.indices;
if (a) {
var f = {
item: t,
idx: u,
matches: [{ score: h, value: t, norm: c, indices: l }],
};
n
? (de(f, { ignoreFieldNorm: r }),
n.shouldInsert(f.score) && n.insert(f))
: o.push(f);
}
}
}),
o
);
},
},
{
key: "_searchLogical",
value: function (e) {
var t = this,
n = fe(e, this.options),
r = function e(n, r, i) {
if (!n.children) {
var u = n.keyId,
o = n.searcher,
c = t._findMatches({
key: t._keyStore.get(u),
value: t._myIndex.getValueForItemAtKeyId(r, u),
searcher: o,
});
return c && c.length
? [{ idx: i, item: r, matches: c }]
: [];
}
for (
var s = [], a = 0, h = n.children.length;
a < h;
a += 1
) {
var l = e(n.children[a], r, i);
if (l.length) s.push.apply(s, f(l));
else if (n.operator === oe) return [];
}
return s;
},
i = this._myIndex.records,
u = new Map(),
o = [];
return (
i.forEach(function (e) {
var t = e.$,
i = e.i;
if (F(t)) {
var c = r(n, t, i);
c.length &&
(u.has(i) ||
(u.set(i, { idx: i, item: t, matches: [] }),
o.push(u.get(i))),
c.forEach(function (e) {
var t,
n = e.matches;
(t = u.get(i).matches).push.apply(t, f(n));
}));
}
}),
o
);
},
},
{
key: "_searchObjectList",
value: function (e) {
var t = this,
n =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: {},
r = n.heap,
i = n.ignoreFieldNorm,
u = this._getSearcher(e),
o = this._myIndex,
c = o.keys,
s = o.records,
a = r ? null : [];
return (
s.forEach(function (e) {
var n = e.$,
o = e.i;
if (F(n)) {
var s = [];
if (
(c.forEach(function (e, r) {
s.push.apply(
s,
f(
t._findMatches({
key: e,
value: n[r],
searcher: u,
}),
),
);
}),
s.length)
) {
var h = { idx: o, item: n, matches: s };
r
? (de(h, { ignoreFieldNorm: i }),
r.shouldInsert(h.score) && r.insert(h))
: a.push(h);
}
}
}),
a
);
},
},
{
key: "_findMatches",
value: function (e) {
var t = e.key,
n = e.value,
r = e.searcher;
if (!F(n)) return [];
var i = [];
if (g(n))
n.forEach(function (e) {
var n = e.v,
u = e.i,
o = e.n;
if (F(n)) {
var c = r.searchIn(n),
s = c.isMatch,
a = c.score,
h = c.indices;
s &&
i.push({
score: a,
key: t,
value: n,
idx: u,
norm: o,
indices: h,
});
}
});
else {
var u = n.v,
o = n.n,
c = r.searchIn(u),
s = c.isMatch,
a = c.score,
h = c.indices;
s &&
i.push({ score: a, key: t, value: u, norm: o, indices: h });
}
return i;
},
},
]),
e
);
})();
return (
(pe.version = "7.2.0"),
(pe.createIndex = N),
(pe.parseIndex = function (e) {
var t =
arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {},
n = t.getFn,
r = void 0 === n ? j.getFn : n,
i = t.fieldNormWeight,
u = void 0 === i ? j.fieldNormWeight : i,
o = e.keys,
c = e.records,
s = new I({ getFn: r, fieldNormWeight: u });
return (s.setKeys(o), s.setIndexRecords(c), s);
}),
(pe.config = j),
ie(ne),
(pe.use = function () {
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
t[n] = arguments[n];
t.forEach(function (e) {
return ie(e);
});
}),
pe
);
}),
"object" == typeof exports && "undefined" != typeof module
? (module.exports = t())
: "function" == typeof define && define.amd
? define(t)
: ((e = "undefined" != typeof globalThis ? globalThis : e || self).Fuse =
t());