UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

1,178 lines (1,177 loc) 32.2 kB
(function() { try { var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}; e.SENTRY_RELEASE = { id: "3.7.8" }; var t = new e.Error().stack; t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "ab62e059-9e69-487d-8f65-2bdb01a0d05f", e._sentryDebugIdIdentifier = "sentry-dbid-ab62e059-9e69-487d-8f65-2bdb01a0d05f"); } catch {} })(); import { n as e } from "./rolldown-runtime-YBAZwyzS.js"; //#region ../../node_modules/.pnpm/fuse.js@7.3.0/node_modules/fuse.js/dist/fuse.mjs var t = /* @__PURE__ */ e({ default: () => $ }); function n(e) { return Array.isArray ? Array.isArray(e) : f(e) === "[object Array]"; } function r(e) { if (typeof e == "string") return e; if (typeof e == "bigint") return e.toString(); let t = e + ""; return t == "0" && 1 / e == -Infinity ? "-0" : t; } function i(e) { return e == null ? "" : r(e); } function a(e) { return typeof e == "string"; } function o(e) { return typeof e == "number"; } function s(e) { return e === !0 || e === !1 || l(e) && f(e) == "[object Boolean]"; } function c(e) { return typeof e == "object"; } function l(e) { return c(e) && e !== null; } function u(e) { return e != null; } function d(e) { return !e.trim().length; } function f(e) { return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e); } var p = "Incorrect 'index' type", m = (e) => `Invalid value for key ${e}`, h = (e) => `Pattern length exceeds max of ${e}.`, g = (e) => `Missing ${e} property in key`, _ = (e) => `Property 'weight' in key '${e}' must be a positive integer`, v = Object.prototype.hasOwnProperty, y = class { constructor(e) { this._keys = [], this._keyMap = {}; let t = 0; e.forEach((e) => { let n = b(e); this._keys.push(n), this._keyMap[n.id] = n, t += n.weight; }), this._keys.forEach((e) => { e.weight /= t; }); } get(e) { return this._keyMap[e]; } keys() { return this._keys; } toJSON() { return JSON.stringify(this._keys); } }; function b(e) { let t = null, r = null, i = null, o = 1, s = null; if (a(e) || n(e)) i = e, t = x(e), r = S(e); else { if (!v.call(e, "name")) throw Error(g("name")); let n = e.name; if (i = n, v.call(e, "weight") && (o = e.weight, o <= 0)) throw Error(_(n)); t = x(n), r = S(n), s = e.getFn; } return { path: t, id: r, weight: o, src: i, getFn: s }; } function x(e) { return n(e) ? e : e.split("."); } function S(e) { return n(e) ? e.join(".") : e; } function C(e, t) { let r = [], c = !1, l = (e, t, d, f) => { if (u(e)) if (!t[d]) r.push(f === void 0 ? e : { v: e, i: f }); else { let p = e[t[d]]; if (!u(p)) return; if (d === t.length - 1 && (a(p) || o(p) || s(p) || typeof p == "bigint")) r.push(f === void 0 ? i(p) : { v: i(p), i: f }); else if (n(p)) { c = !0; for (let e = 0, n = p.length; e < n; e += 1) l(p[e], t, d + 1, e); } else t.length && l(p, t, d + 1, f); } }; return l(e, a(t) ? t.split(".") : t, 0), c ? r : r[0]; } var w = { includeMatches: !1, findAllMatches: !1, minMatchCharLength: 1 }, ee = { isCaseSensitive: !1, ignoreDiacritics: !1, includeScore: !1, keys: [], shouldSort: !0, sortFn: (e, t) => e.score === t.score ? e.idx < t.idx ? -1 : 1 : e.score < t.score ? -1 : 1 }, te = { location: 0, threshold: .6, distance: 100 }, ne = { useExtendedSearch: !1, useTokenSearch: !1, getFn: C, ignoreLocation: !1, ignoreFieldNorm: !1, fieldNormWeight: 1 }, T = Object.freeze({ ...ee, ...w, ...te, ...ne }), re = /[^ ]+/g; function ie(e = 1, t = 3) { let n = /* @__PURE__ */ new Map(), r = 10 ** t; return { get(t) { let i = t.match(re).length; if (n.has(i)) return n.get(i); let a = 1 / i ** (.5 * e), o = parseFloat(Math.round(a * r) / r); return n.set(i, o), o; }, clear() { n.clear(); } }; } var E = class { constructor({ getFn: e = T.getFn, fieldNormWeight: t = T.fieldNormWeight } = {}) { this.norm = ie(t, 3), this.getFn = e, this.isCreated = !1, this.docs = [], this.keys = [], this._keysMap = {}, this.setIndexRecords(); } setSources(e = []) { this.docs = e; } setIndexRecords(e = []) { this.records = e; } setKeys(e = []) { this.keys = e, this._keysMap = {}, e.forEach((e, t) => { this._keysMap[e.id] = t; }); } create() { this.isCreated || !this.docs.length || (this.isCreated = !0, a(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) { let t = this.size(); a(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; } removeAll(e) { for (let t = e.length - 1; t >= 0; --t) this.records.splice(e[t], 1); for (let e = 0, t = this.records.length; e < t; e += 1) this.records[e].i = e; } getValueForItemAtKeyId(e, t) { return e[this._keysMap[t]]; } size() { return this.records.length; } _addString(e, t) { if (!u(e) || d(e)) return; let n = { v: e, i: t, n: this.norm.get(e) }; this.records.push(n); } _addObject(e, t) { let r = { i: t, $: {} }; this.keys.forEach((t, o) => { let s = t.getFn ? t.getFn(e) : this.getFn(e, t.path); if (u(s)) { if (n(s)) { let e = []; for (let t = 0, n = s.length; t < n; t += 1) { let n = s[t]; if (u(n)) { if (a(n)) { if (!d(n)) { let r = { v: n, i: t, n: this.norm.get(n) }; e.push(r); } } else if (u(n.v)) { let t = a(n.v) ? n.v : i(n.v); if (!d(t)) { let r = { v: t, i: n.i, n: this.norm.get(t) }; e.push(r); } } } } r.$[o] = e; } else if (a(s) && !d(s)) { let e = { v: s, n: this.norm.get(s) }; r.$[o] = e; } } }), this.records.push(r); } toJSON() { return { keys: this.keys.map(({ getFn: e, ...t }) => t), records: this.records }; } }; function D(e, t, { getFn: n = T.getFn, fieldNormWeight: r = T.fieldNormWeight } = {}) { let i = new E({ getFn: n, fieldNormWeight: r }); return i.setKeys(e.map(b)), i.setSources(t), i.create(), i; } function ae(e, { getFn: t = T.getFn, fieldNormWeight: n = T.fieldNormWeight } = {}) { let { keys: r, records: i } = e, a = new E({ getFn: t, fieldNormWeight: n }); return a.setKeys(r), a.setIndexRecords(i), a; } function oe(e = [], t = T.minMatchCharLength) { let n = [], r = -1, i = -1, a = 0; for (let o = e.length; a < o; a += 1) { let o = e[a]; o && r === -1 ? r = a : !o && r !== -1 && (i = a - 1, i - r + 1 >= t && n.push([r, i]), r = -1); } return e[a - 1] && a - r >= t && n.push([r, a - 1]), n; } var O = 32; function k(e, t, n, { location: r = T.location, distance: i = T.distance, threshold: a = T.threshold, findAllMatches: o = T.findAllMatches, minMatchCharLength: s = T.minMatchCharLength, includeMatches: c = T.includeMatches, ignoreLocation: l = T.ignoreLocation } = {}) { if (t.length > O) throw Error(h(O)); let u = t.length, d = e.length, f = Math.max(0, Math.min(r, d)), p = a, m = f, g = (e, t) => { let n = e / u; if (l) return n; let r = Math.abs(f - t); return i ? n + r / i : r ? 1 : n; }, _ = s > 1 || c, v = _ ? Array(d) : [], y; for (; (y = e.indexOf(t, m)) > -1;) { let e = g(0, y); if (p = Math.min(e, p), m = y + u, _) { let e = 0; for (; e < u;) v[y + e] = 1, e += 1; } } m = -1; let b = [], x = 1, S = u + d, C = 1 << u - 1; for (let t = 0; t < u; t += 1) { let r = 0, i = S; for (; r < i;) g(t, f + i) <= p ? r = i : S = i, i = Math.floor((S - r) / 2 + r); S = i; let a = Math.max(1, f - i + 1), s = o ? d : Math.min(f + i, d) + u, c = Array(s + 2); c[s + 1] = (1 << t) - 1; for (let r = s; r >= a; --r) { let i = r - 1, o = n[e[i]]; if (_ && (v[i] = +!!o), c[r] = (c[r + 1] << 1 | 1) & o, t && (c[r] |= (b[r + 1] | b[r]) << 1 | 1 | b[r + 1]), c[r] & C && (x = g(t, i), x <= p)) { if (p = x, m = i, m <= f) break; a = Math.max(1, 2 * f - m); } } if (g(t + 1, f) > p) break; b = c; } let w = { isMatch: m >= 0, score: Math.max(.001, x) }; if (_) { let e = oe(v, s); e.length ? c && (w.indices = e) : w.isMatch = !1; } return w; } function A(e) { let t = {}; for (let n = 0, r = e.length; n < r; n += 1) { let i = e.charAt(n); t[i] = (t[i] || 0) | 1 << r - n - 1; } return t; } function j(e) { if (e.length <= 1) return e; e.sort((e, t) => e[0] - t[0] || e[1] - t[1]); let t = [e[0]]; for (let n = 1, r = e.length; n < r; n += 1) { let r = t[t.length - 1], i = e[n]; i[0] <= r[1] + 1 ? r[1] = Math.max(r[1], i[1]) : t.push(i); } return t; } var M = { ł: "l", Ł: "L", đ: "d", Đ: "D", ø: "o", Ø: "O", ħ: "h", Ħ: "H", ŧ: "t", Ŧ: "T", ı: "i", ß: "ss" }, se = RegExp("[" + Object.keys(M).join("") + "]", "g"), N = String.prototype.normalize ? (e) => 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, "").replace(se, (e) => M[e]) : (e) => e, P = class { constructor(e, { location: t = T.location, threshold: n = T.threshold, distance: r = T.distance, includeMatches: i = T.includeMatches, findAllMatches: a = T.findAllMatches, minMatchCharLength: o = T.minMatchCharLength, isCaseSensitive: s = T.isCaseSensitive, ignoreDiacritics: c = T.ignoreDiacritics, ignoreLocation: l = T.ignoreLocation } = {}) { if (this.options = { location: t, threshold: n, distance: r, includeMatches: i, findAllMatches: a, minMatchCharLength: o, isCaseSensitive: s, ignoreDiacritics: c, ignoreLocation: l }, e = s ? e : e.toLowerCase(), e = c ? N(e) : e, this.pattern = e, this.chunks = [], !this.pattern.length) return; let u = (e, t) => { this.chunks.push({ pattern: e, alphabet: A(e), startIndex: t }); }, d = this.pattern.length; if (d > O) { let e = 0, t = d % O, n = d - t; for (; e < n;) u(this.pattern.substr(e, O), e), e += O; if (t) { let e = d - O; u(this.pattern.substr(e), e); } } else u(this.pattern, 0); } searchIn(e) { let { isCaseSensitive: t, ignoreDiacritics: n, includeMatches: r } = this.options; if (e = t ? e : e.toLowerCase(), e = n ? N(e) : e, this.pattern === e) { let t = { isMatch: !0, score: 0 }; return r && (t.indices = [[0, e.length - 1]]), t; } let { location: i, distance: a, threshold: o, findAllMatches: s, minMatchCharLength: c, ignoreLocation: l } = this.options, u = [], d = 0, f = !1; this.chunks.forEach(({ pattern: t, alphabet: n, startIndex: p }) => { let { isMatch: m, score: h, indices: g } = k(e, t, n, { location: i + p, distance: a, threshold: o, findAllMatches: s, minMatchCharLength: c, includeMatches: r, ignoreLocation: l }); m && (f = !0), d += h, m && g && u.push(...g); }); let p = { isMatch: f, score: f ? d / this.chunks.length : 1 }; return f && r && (p.indices = j(u)), p; } }, F = class { constructor(e) { this.pattern = e; } static isMultiMatch(e) { return I(e, this.multiRegex); } static isSingleMatch(e) { return I(e, this.singleRegex); } search(e) { return { isMatch: !1, score: 1 }; } }; function I(e, t) { let n = e.match(t); return n ? n[1] : null; } var ce = class extends F { constructor(e) { super(e); } static get type() { return "exact"; } static get multiRegex() { return /^="(.*)"$/; } static get singleRegex() { return /^=(.*)$/; } search(e) { let t = e === this.pattern; return { isMatch: t, score: +!t, indices: [0, this.pattern.length - 1] }; } }, le = class extends F { constructor(e) { super(e); } static get type() { return "inverse-exact"; } static get multiRegex() { return /^!"(.*)"$/; } static get singleRegex() { return /^!(.*)$/; } search(e) { let t = e.indexOf(this.pattern) === -1; return { isMatch: t, score: +!t, indices: [0, e.length - 1] }; } }, ue = class extends F { constructor(e) { super(e); } static get type() { return "prefix-exact"; } static get multiRegex() { return /^\^"(.*)"$/; } static get singleRegex() { return /^\^(.*)$/; } search(e) { let t = e.startsWith(this.pattern); return { isMatch: t, score: +!t, indices: [0, this.pattern.length - 1] }; } }, de = class extends F { constructor(e) { super(e); } static get type() { return "inverse-prefix-exact"; } static get multiRegex() { return /^!\^"(.*)"$/; } static get singleRegex() { return /^!\^(.*)$/; } search(e) { let t = !e.startsWith(this.pattern); return { isMatch: t, score: +!t, indices: [0, e.length - 1] }; } }, fe = class extends F { constructor(e) { super(e); } static get type() { return "suffix-exact"; } static get multiRegex() { return /^"(.*)"\$$/; } static get singleRegex() { return /^(.*)\$$/; } search(e) { let t = e.endsWith(this.pattern); return { isMatch: t, score: +!t, indices: [e.length - this.pattern.length, e.length - 1] }; } }, pe = class extends F { constructor(e) { super(e); } static get type() { return "inverse-suffix-exact"; } static get multiRegex() { return /^!"(.*)"\$$/; } static get singleRegex() { return /^!(.*)\$$/; } search(e) { let t = !e.endsWith(this.pattern); return { isMatch: t, score: +!t, indices: [0, e.length - 1] }; } }, L = class extends F { constructor(e, { location: t = T.location, threshold: n = T.threshold, distance: r = T.distance, includeMatches: i = T.includeMatches, findAllMatches: a = T.findAllMatches, minMatchCharLength: o = T.minMatchCharLength, isCaseSensitive: s = T.isCaseSensitive, ignoreDiacritics: c = T.ignoreDiacritics, ignoreLocation: l = T.ignoreLocation } = {}) { super(e), this._bitapSearch = new P(e, { location: t, threshold: n, distance: r, includeMatches: i, findAllMatches: a, minMatchCharLength: o, isCaseSensitive: s, ignoreDiacritics: c, ignoreLocation: l }); } static get type() { return "fuzzy"; } static get multiRegex() { return /^"(.*)"$/; } static get singleRegex() { return /^(.*)$/; } search(e) { return this._bitapSearch.searchIn(e); } }, R = class extends F { constructor(e) { super(e); } static get type() { return "include"; } static get multiRegex() { return /^'"(.*)"$/; } static get singleRegex() { return /^'(.*)$/; } search(e) { let t = 0, n, r = [], i = this.pattern.length; for (; (n = e.indexOf(this.pattern, t)) > -1;) t = n + i, r.push([n, t - 1]); let a = !!r.length; return { isMatch: a, score: +!a, indices: r }; } }, z = [ ce, R, ue, de, pe, fe, le, L ], B = z.length, me = "\0", he = "|"; function ge(e) { let t = [], n = e.length, r = 0; for (; r < n;) { for (; r < n && e[r] === " ";) r++; if (r >= n) break; let i = r; for (; i < n && e[i] !== " " && e[i] !== "\"";) i++; if (i < n && e[i] === "\"") { for (i++; i < n;) { if (e[i] === "\"") { let t = i + 1; if (t >= n || e[t] === " ") { i++; break; } if (e[t] === "$" && (t + 1 >= n || e[t + 1] === " ")) { i += 2; break; } } i++; } t.push(e.substring(r, i)), r = i; } else { for (; i < n && e[i] !== " ";) i++; t.push(e.substring(r, i)), r = i; } } return t; } function _e(e, t = {}) { return e.replace(/\\\|/g, me).split(he).map((e) => { let n = ge(e.replace(/\u0000/g, "|").trim()).filter((e) => e && !!e.trim()), r = []; for (let e = 0, i = n.length; e < i; e += 1) { let i = n[e], a = !1, o = -1; for (; !a && ++o < B;) { let e = z[o], n = e.isMultiMatch(i); n && (r.push(new e(n, t)), a = !0); } if (!a) for (o = -1; ++o < B;) { let e = z[o], n = e.isSingleMatch(i); if (n) { r.push(new e(n, t)); break; } } } return r; }); } var ve = new Set([L.type, R.type]), ye = class { constructor(e, { isCaseSensitive: t = T.isCaseSensitive, ignoreDiacritics: n = T.ignoreDiacritics, includeMatches: r = T.includeMatches, minMatchCharLength: i = T.minMatchCharLength, ignoreLocation: a = T.ignoreLocation, findAllMatches: o = T.findAllMatches, location: s = T.location, threshold: c = T.threshold, distance: l = T.distance } = {}) { this.query = null, this.options = { isCaseSensitive: t, ignoreDiacritics: n, includeMatches: r, minMatchCharLength: i, findAllMatches: o, ignoreLocation: a, location: s, threshold: c, distance: l }, e = t ? e : e.toLowerCase(), e = n ? N(e) : e, this.pattern = e, this.query = _e(this.pattern, this.options); } static condition(e, t) { return t.useExtendedSearch; } searchIn(e) { let t = this.query; if (!t) return { isMatch: !1, score: 1 }; let { includeMatches: n, isCaseSensitive: r, ignoreDiacritics: i } = this.options; e = r ? e : e.toLowerCase(), e = i ? N(e) : e; let a = 0, o = [], s = 0, c = !1; for (let r = 0, i = t.length; r < i; r += 1) { let i = t[r]; o.length = 0, a = 0, c = !1; for (let t = 0, r = i.length; t < r; t += 1) { let r = i[t], { isMatch: l, indices: u, score: d } = r.search(e); if (l) { a += 1, s += d; let e = r.constructor.type; e.startsWith("inverse") && (c = !0), n && (ve.has(e) ? o.push(...u) : o.push(u)); } else { s = 0, a = 0, o.length = 0, c = !1; break; } } if (a) { let e = { isMatch: !0, score: s / a }; return c && (e.hasInverse = !0), n && (e.indices = j(o)), e; } } return { isMatch: !1, score: 1 }; } }, V = []; function H(...e) { V.push(...e); } function U(e, t) { for (let n = 0, r = V.length; n < r; n += 1) { let r = V[n]; if (r.condition(e, t)) return new r(e, t); } return new P(e, t); } var W = { AND: "$and", OR: "$or" }, G = { PATH: "$path", PATTERN: "$val" }, K = (e) => !!(e[W.AND] || e[W.OR]), be = (e) => !!e[G.PATH], xe = (e) => !n(e) && c(e) && !K(e), q = (e) => ({ [W.AND]: Object.keys(e).map((t) => ({ [t]: e[t] })) }); function J(e, t, { auto: r = !0 } = {}) { let i = (e) => { if (a(e)) { let n = { keyId: null, pattern: e }; return r && (n.searcher = U(e, t)), n; } let o = Object.keys(e), s = be(e); if (!s && o.length > 1 && !K(e)) return i(q(e)); if (xe(e)) { let n = s ? e[G.PATH] : o[0], i = s ? e[G.PATTERN] : e[n]; if (!a(i)) throw Error(m(n)); let c = { keyId: S(n), pattern: i }; return r && (c.searcher = U(i, t)), c; } let c = { children: [], operator: o[0] }; return o.forEach((t) => { let r = e[t]; n(r) && r.forEach((e) => { c.children.push(i(e)); }); }), c; }; return K(e) || (e = q(e)), i(e); } function Y(e, { ignoreFieldNorm: t = T.ignoreFieldNorm }) { let n = 1; return e.forEach(({ key: e, norm: r, score: i }) => { let a = e ? e.weight : null; n *= (i === 0 && a ? 2 ** -52 : i) ** +((a || 1) * (t ? 1 : r)); }), n; } function Se(e, { ignoreFieldNorm: t = T.ignoreFieldNorm }) { e.forEach((e) => { e.score = Y(e.matches, { ignoreFieldNorm: t }); }); } var Ce = class { constructor(e) { this.limit = e, this.heap = []; } get size() { return this.heap.length; } shouldInsert(e) { return this.size < this.limit || e < this.heap[0].score; } insert(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)); } extractSorted(e) { return this.heap.sort(e); } _bubbleUp(e) { let t = this.heap; for (; e > 0;) { let n = e - 1 >> 1; if (t[e].score <= t[n].score) break; let r = t[e]; t[e] = t[n], t[n] = r, e = n; } } _sinkDown(e) { let t = this.heap, n = t.length, r = e; do { e = r; let i = 2 * e + 1, a = 2 * e + 2; if (i < n && t[i].score > t[r].score && (r = i), a < n && t[a].score > t[r].score && (r = a), r !== e) { let n = t[e]; t[e] = t[r], t[r] = n; } } while (r !== e); } }; function we(e, t) { let n = e.matches; t.matches = [], u(n) && n.forEach((e) => { if (!u(e.indices) || !e.indices.length) return; let { indices: n, value: r } = e, i = { indices: n, value: r }; e.key && (i.key = e.key.src), e.idx > -1 && (i.refIndex = e.idx), t.matches.push(i); }); } function Te(e, t) { t.score = e.score; } function Ee(e, t, { includeMatches: n = T.includeMatches, includeScore: r = T.includeScore } = {}) { let i = []; return n && i.push(we), r && i.push(Te), e.map((e) => { let { idx: n } = e, r = { item: t[n], refIndex: n }; return i.length && i.forEach((t) => { t(e, r); }), r; }); } var X = /\b\w+\b/g; function Z({ isCaseSensitive: e = !1, ignoreDiacritics: t = !1 } = {}) { return { tokenize(n) { return e || (n = n.toLowerCase()), t && (n = N(n)), n.match(X) || []; } }; } function De(e, t, n) { let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0; function o(e, t, o, s) { let c = n.tokenize(e); if (!c.length) return; a++; let l = /* @__PURE__ */ new Map(); for (let e of c) l.set(e, (l.get(e) || 0) + 1); for (let [e, n] of l) { let a = { docIdx: t, keyIdx: o, subIdx: s, tf: n }, c = r.get(e); c || (c = [], r.set(e, c)), c.push(a), i.set(e, (i.get(e) || 0) + 1); } } for (let n of e) { let { i: e, v: r, $: i } = n; if (r !== void 0) { o(r, e, -1, -1); continue; } if (i) for (let n = 0; n < t; n++) { let t = i[n]; if (t) if (Array.isArray(t)) for (let r of t) { var s; o(r.v, e, n, (s = r.i) == null ? -1 : s); } else o(t.v, e, n, -1); } } return { terms: r, fieldCount: a, df: i }; } function Oe(e, t, n, r) { let { i, v: a, $: o } = t; function s(t, n, a) { let o = r.tokenize(t); if (!o.length) return; e.fieldCount++; let s = /* @__PURE__ */ new Map(); for (let e of o) s.set(e, (s.get(e) || 0) + 1); for (let [t, r] of s) { let o = { docIdx: i, keyIdx: n, subIdx: a, tf: r }, s = e.terms.get(t); s || (s = [], e.terms.set(t, s)), s.push(o), e.df.set(t, (e.df.get(t) || 0) + 1); } } if (a !== void 0) { s(a, -1, -1); return; } if (o) for (let e = 0; e < n; e++) { let t = o[e]; if (t) if (Array.isArray(t)) for (let n of t) { var c; s(n.v, e, (c = n.i) == null ? -1 : c); } else s(t.v, e, -1); } } function Q(e, t) { for (let [n, r] of e.terms) { let i = r.filter((e) => e.docIdx !== t), a = r.length - i.length; a > 0 && (e.fieldCount -= a, e.df.set(n, (e.df.get(n) || 0) - a), i.length === 0 ? (e.terms.delete(n), e.df.delete(n)) : e.terms.set(n, i)); } } var $ = class { constructor(e, t, n) { this.options = { ...T, ...t }, this.options.useExtendedSearch, this.options.useTokenSearch, this._keyStore = new y(this.options.keys), this._docs = e, this._myIndex = null, this._invertedIndex = null, this.setCollection(e, n), this._lastQuery = null, this._lastSearcher = null; } _getSearcher(e) { if (this._lastQuery === e) return this._lastSearcher; let t = U(e, this._invertedIndex ? { ...this.options, _invertedIndex: this._invertedIndex } : this.options); return this._lastQuery = e, this._lastSearcher = t, t; } setCollection(e, t) { if (this._docs = e, t && !(t instanceof E)) throw Error(p); if (this._myIndex = t || D(this.options.keys, this._docs, { getFn: this.options.getFn, fieldNormWeight: this.options.fieldNormWeight }), this.options.useTokenSearch) { let e = Z({ isCaseSensitive: this.options.isCaseSensitive, ignoreDiacritics: this.options.ignoreDiacritics }); this._invertedIndex = De(this._myIndex.records, this._myIndex.keys.length, e); } } add(e) { if (u(e) && (this._docs.push(e), this._myIndex.add(e), this._invertedIndex)) { let e = this._myIndex.records[this._myIndex.records.length - 1], t = Z({ isCaseSensitive: this.options.isCaseSensitive, ignoreDiacritics: this.options.ignoreDiacritics }); Oe(this._invertedIndex, e, this._myIndex.keys.length, t); } } remove(e = () => !1) { let t = [], n = []; for (let 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) { if (this._invertedIndex) for (let e of n) Q(this._invertedIndex, e); for (let e = n.length - 1; e >= 0; --e) this._docs.splice(n[e], 1); this._myIndex.removeAll(n); } return t; } removeAt(e) { this._invertedIndex && Q(this._invertedIndex, e); let t = this._docs.splice(e, 1)[0]; return this._myIndex.removeAt(e), t; } getIndex() { return this._myIndex; } search(e, t) { let { limit: n = -1 } = t || {}, { includeMatches: r, includeScore: i, shouldSort: s, sortFn: c, ignoreFieldNorm: l } = this.options; if (a(e) && !e.trim()) { let e = this._docs.map((e, t) => ({ item: e, refIndex: t })); return o(n) && n > -1 && (e = e.slice(0, n)), e; } let u = o(n) && n > 0 && a(e), d; if (u) { let t = new Ce(n); a(this._docs[0]) ? this._searchStringList(e, { heap: t, ignoreFieldNorm: l }) : this._searchObjectList(e, { heap: t, ignoreFieldNorm: l }), d = t.extractSorted(c); } else d = a(e) ? a(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e), Se(d, { ignoreFieldNorm: l }), s && d.sort(c), o(n) && n > -1 && (d = d.slice(0, n)); return Ee(d, this._docs, { includeMatches: r, includeScore: i }); } _searchStringList(e, { heap: t, ignoreFieldNorm: n } = {}) { let r = this._getSearcher(e), { records: i } = this._myIndex, a = t ? null : []; return i.forEach(({ v: e, i, n: o }) => { if (!u(e)) return; let { isMatch: s, score: c, indices: l } = r.searchIn(e); if (s) { let r = { item: e, idx: i, matches: [{ score: c, value: e, norm: o, indices: l }] }; t ? (r.score = Y(r.matches, { ignoreFieldNorm: n }), t.shouldInsert(r.score) && t.insert(r)) : a.push(r); } }), a; } _searchLogical(e) { let t = J(e, this.options), n = (e, t, r) => { if (!("children" in e)) { let { keyId: n, searcher: i } = e, a; return n === null ? (a = [], this._myIndex.keys.forEach((e, n) => { a.push(...this._findMatches({ key: e, value: t[n], searcher: i })); })) : a = this._findMatches({ key: this._keyStore.get(n), value: this._myIndex.getValueForItemAtKeyId(t, n), searcher: i }), a && a.length ? [{ idx: r, item: t, matches: a }] : []; } let { children: i, operator: a } = e, o = []; for (let e = 0, s = i.length; e < s; e += 1) { let s = i[e], c = n(s, t, r); if (c.length) o.push(...c); else if (a === W.AND) return []; } return o; }, r = this._myIndex.records, i = /* @__PURE__ */ new Map(), a = []; return r.forEach(({ $: e, i: r }) => { if (u(e)) { let o = n(t, e, r); o.length && (i.has(r) || (i.set(r, { idx: r, item: e, matches: [] }), a.push(i.get(r))), o.forEach(({ matches: e }) => { i.get(r).matches.push(...e); })); } }), a; } _searchObjectList(e, { heap: t, ignoreFieldNorm: n } = {}) { let r = this._getSearcher(e), { keys: i, records: a } = this._myIndex, o = t ? null : []; return a.forEach(({ $: e, i: a }) => { if (!u(e)) return; let s = [], c = !1, l = !1; if (i.forEach((t, n) => { let i = this._findMatches({ key: t, value: e[n], searcher: r }); i.length ? (s.push(...i), i[0].hasInverse && (l = !0)) : c = !0; }), !(l && c) && s.length) { let r = { idx: a, item: e, matches: s }; t ? (r.score = Y(r.matches, { ignoreFieldNorm: n }), t.shouldInsert(r.score) && t.insert(r)) : o.push(r); } }), o; } _findMatches({ key: e, value: t, searcher: r }) { if (!u(t)) return []; let i = []; if (n(t)) t.forEach(({ v: t, i: n, n: a }) => { if (!u(t)) return; let { isMatch: o, score: s, indices: c, hasInverse: l } = r.searchIn(t); o && i.push({ score: s, key: e, value: t, idx: n, norm: a, indices: c, hasInverse: l }); }); else { let { v: n, n: a } = t, { isMatch: o, score: s, indices: c, hasInverse: l } = r.searchIn(n); o && i.push({ score: s, key: e, value: n, norm: a, indices: c, hasInverse: l }); } return i; } }, ke = class { static condition(e, t) { return t.useTokenSearch; } constructor(e, t) { this.options = t, this.analyzer = Z({ isCaseSensitive: t.isCaseSensitive, ignoreDiacritics: t.ignoreDiacritics }); let n = this.analyzer.tokenize(e), { df: r, fieldCount: i } = t._invertedIndex; this.termSearchers = [], this.idfWeights = []; for (let e of n) { this.termSearchers.push(new P(e, { location: t.location, threshold: t.threshold, distance: t.distance, includeMatches: t.includeMatches, findAllMatches: t.findAllMatches, minMatchCharLength: t.minMatchCharLength, isCaseSensitive: t.isCaseSensitive, ignoreDiacritics: t.ignoreDiacritics, ignoreLocation: !0 })); let n = r.get(e) || 0, a = Math.log(1 + (i - n + .5) / (n + .5)); this.idfWeights.push(a); } } searchIn(e) { if (!this.termSearchers.length) return { isMatch: !1, score: 1 }; let t = [], n = 0, r = 0, i = 0; for (let a = 0; a < this.termSearchers.length; a++) { let o = this.termSearchers[a].searchIn(e), s = this.idfWeights[a]; r += s, o.isMatch && (i++, n += s * (1 - o.score), o.indices && t.push(...o.indices)); } if (i === 0) return { isMatch: !1, score: 1 }; let a = r > 0 ? 1 - n / r : 0, o = { isMatch: !0, score: Math.max(.001, a) }; return this.options.includeMatches && t.length && (o.indices = j(t)), o; } }; $.version = "7.3.0", $.createIndex = D, $.parseIndex = ae, $.config = T, $.match = function(e, t, n) { return U(e, { ...T, ...n }).searchIn(t); }, $.parseQuery = J, H(ye), H(ke), $.use = function(...e) { e.forEach((e) => H(e)); }; //#endregion export { t as n, $ as t };