import { g as ye } from "./_commonjsHelpers-DaMA6jEr.js";
import { isPlainObject as me } from "es-toolkit";
import "vue";
import { normalizeText as Ie } from "./utils/helpers.js";
function ze(A) {
  return Array.isArray(A) && typeof A[0] == "string";
}
function Be(A) {
  return Array.isArray(A) && me(A[0]);
}
var j = { exports: {} }, Ce = j.exports, he;
function ke() {
  return he || (he = 1, (function(A) {
    ((E, k) => {
      A.exports ? A.exports = k() : E.fuzzysort = k();
    })(Ce, (E) => {
      var k = (r, e) => {
        if (!r || !e) return b;
        var a = _e(r);
        V(e) || (e = q(e));
        var i = a.bitflags;
        return (i & e._bitflags) !== i ? b : $(a, e);
      }, ve = (r, e, a) => {
        if (!r) return a != null && a.all ? de(e, a) : fe;
        var i = _e(r), v = i.bitflags, f = i.containsSpace, n = Q((a == null ? void 0 : a.threshold) || 0), s = (a == null ? void 0 : a.limit) || ne, t = 0, _ = 0, u = e.length;
        function I(Y) {
          t < s ? (U.add(Y), ++t) : (++_, Y._score > U.peek()._score && U.replaceTop(Y));
        }
        if (a != null && a.key)
          for (var L = a.key, g = 0; g < u; ++g) {
            var m = e[g], h = Z(m, L);
            if (h && (V(h) || (h = q(h)), (v & h._bitflags) === v)) {
              var d = $(i, h);
              d !== b && (d._score < n || (d.obj = m, I(d)));
            }
          }
        else if (a != null && a.keys) {
          var O = a.keys, C = O.length;
          e: for (var g = 0; g < u; ++g) {
            var m = e[g];
            {
              for (var y = 0, c = 0; c < C; ++c) {
                var L = O[c], h = Z(m, L);
                if (!h) {
                  ae[c] = H;
                  continue;
                }
                V(h) || (h = q(h)), ae[c] = h, y |= h._bitflags;
              }
              if ((v & y) !== v) continue;
            }
            if (f) for (let o = 0; o < i.spaceSearches.length; o++) T[o] = z;
            for (var c = 0; c < C; ++c) {
              if (h = ae[c], h === H) {
                D[c] = H;
                continue;
              }
              if (D[c] = $(
                i,
                h,
                /*allowSpaces=*/
                !1,
                /*allowPartialMatch=*/
                f
              ), D[c] === b) {
                D[c] = H;
                continue;
              }
              if (f) for (let x = 0; x < i.spaceSearches.length; x++) {
                if (G[x] > -1e3 && T[x] > z) {
                  var S = (T[x] + G[x]) / 4;
                  S > T[x] && (T[x] = S);
                }
                G[x] > T[x] && (T[x] = G[x]);
              }
            }
            if (f) {
              for (let o = 0; o < i.spaceSearches.length; o++)
                if (T[o] === z) continue e;
            } else {
              var l = !1;
              for (let o = 0; o < C; o++)
                if (D[o]._score !== z) {
                  l = !0;
                  break;
                }
              if (!l) continue;
            }
            var B = new se(C);
            for (let o = 0; o < C; o++)
              B[o] = D[o];
            if (f) {
              var w = 0;
              for (let o = 0; o < i.spaceSearches.length; o++) w += T[o];
            } else {
              var w = z;
              for (let x = 0; x < C; x++) {
                var d = B[x];
                if (d._score > -1e3 && w > z) {
                  var S = (w + d._score) / 4;
                  S > w && (w = S);
                }
                d._score > w && (w = d._score);
              }
            }
            if (B.obj = m, B._score = w, a != null && a.scoreFn) {
              if (w = a.scoreFn(B), !w) continue;
              w = Q(w), B._score = w;
            }
            w < n || I(B);
          }
        } else
          for (var g = 0; g < u; ++g) {
            var h = e[g];
            if (h && (V(h) || (h = q(h)), (v & h._bitflags) === v)) {
              var d = $(i, h);
              d !== b && (d._score < n || I(d));
            }
          }
        if (t === 0) return fe;
        for (var M = new Array(t), g = t - 1; g >= 0; --g) M[g] = U.poll();
        return M.total = t + _, M;
      }, J = (r, e = "<b>", a = "</b>") => {
        for (var i = typeof e == "function" ? e : void 0, v = r.target, f = v.length, n = r.indexes, s = "", t = 0, _ = 0, u = !1, I = [], L = 0; L < f; ++L) {
          var g = v[L];
          if (n[_] === L) {
            if (++_, u || (u = !0, i ? (I.push(s), s = "") : s += e), _ === n.length) {
              i ? (s += g, I.push(i(s, t++)), s = "", I.push(v.substr(L + 1))) : s += g + a + v.substr(L + 1);
              break;
            }
          } else
            u && (u = !1, i ? (I.push(i(s, t++)), s = "") : s += a);
          s += g;
        }
        return i ? I : s;
      }, P = (r) => {
        typeof r == "number" ? r = "" + r : typeof r != "string" && (r = "");
        var e = p(r);
        return le(r, { _targetLower: e._lower, _targetLowerCodes: e.lowerCodes, _bitflags: e.bitflags });
      }, K = () => {
        ee.clear(), re.clear();
      };
      class te {
        get indexes() {
          return this._indexes.slice(0, this._indexes.len).sort((e, a) => e - a);
        }
        set indexes(e) {
          return this._indexes = e;
        }
        highlight(e, a) {
          return J(this, e, a);
        }
        get score() {
          return ue(this._score);
        }
        set score(e) {
          this._score = Q(e);
        }
      }
      class se extends Array {
        get score() {
          return ue(this._score);
        }
        set score(e) {
          this._score = Q(e);
        }
      }
      var le = (r, e) => {
        const a = new te();
        return a.target = r, a.obj = e.obj ?? b, a._score = e._score ?? z, a._indexes = e._indexes ?? [], a._targetLower = e._targetLower ?? "", a._targetLowerCodes = e._targetLowerCodes ?? b, a._nextBeginningIndexes = e._nextBeginningIndexes ?? b, a._bitflags = e._bitflags ?? 0, a;
      }, ue = (r) => r === z ? 0 : r > 1 ? r : Math.E ** (((-r + 1) ** 0.04307 - 1) * -2), Q = (r) => r === 0 ? z : r > 1 ? r : 1 - Math.pow(Math.log(r) / -2 + 1, 1 / 0.04307), ce = (r) => {
        typeof r == "number" ? r = "" + r : typeof r != "string" && (r = ""), r = r.trim();
        var e = p(r), a = [];
        if (e.containsSpace) {
          var i = r.split(/\s+/);
          i = [...new Set(i)];
          for (var v = 0; v < i.length; v++)
            if (i[v] !== "") {
              var f = p(i[v]);
              a.push({ lowerCodes: f.lowerCodes, _lower: i[v].toLowerCase(), containsSpace: !1 });
            }
        }
        return { lowerCodes: e.lowerCodes, _lower: e._lower, containsSpace: e.containsSpace, bitflags: e.bitflags, spaceSearches: a };
      }, q = (r) => {
        if (r.length > 999) return P(r);
        var e = ee.get(r);
        return e !== void 0 || (e = P(r), ee.set(r, e)), e;
      }, _e = (r) => {
        if (r.length > 999) return ce(r);
        var e = re.get(r);
        return e !== void 0 || (e = ce(r), re.set(r, e)), e;
      }, de = (r, e) => {
        var a = [];
        a.total = r.length;
        var i = (e == null ? void 0 : e.limit) || ne;
        if (e != null && e.key)
          for (var v = 0; v < r.length; v++) {
            var f = r[v], n = Z(f, e.key);
            if (n != b) {
              V(n) || (n = q(n));
              var s = le(n.target, { _score: n._score, obj: f });
              if (a.push(s), a.length >= i) return a;
            }
          }
        else if (e != null && e.keys)
          for (var v = 0; v < r.length; v++) {
            for (var f = r[v], t = new se(e.keys.length), _ = e.keys.length - 1; _ >= 0; --_) {
              var n = Z(f, e.keys[_]);
              if (!n) {
                t[_] = H;
                continue;
              }
              V(n) || (n = q(n)), n._score = z, n._indexes.len = 0, t[_] = n;
            }
            if (t.obj = f, t._score = z, a.push(t), a.length >= i) return a;
          }
        else
          for (var v = 0; v < r.length; v++) {
            var n = r[v];
            if (n != b && (V(n) || (n = q(n)), n._score = z, n._indexes.len = 0, a.push(n), a.length >= i))
              return a;
          }
        return a;
      }, $ = (r, e, a = !1, i = !1) => {
        if (a === !1 && r.containsSpace) return xe(r, e, i);
        for (var v = r._lower, f = r.lowerCodes, n = f[0], s = e._targetLowerCodes, t = f.length, _ = s.length, g = 0, u = 0, I = 0; ; ) {
          var L = n === s[u];
          if (L) {
            if (N[I++] = u, ++g, g === t) break;
            n = f[g];
          }
          if (++u, u >= _) return b;
        }
        var g = 0, m = !1, h = 0, d = e._nextBeginningIndexes;
        d === b && (d = e._nextBeginningIndexes = be(e.target)), u = N[0] === 0 ? 0 : d[N[0] - 1];
        var O = 0;
        if (u !== _) for (; ; )
          if (u >= _) {
            if (g <= 0 || (++O, O > 200)) break;
            --g;
            var C = W[--h];
            u = d[C];
          } else {
            var L = f[g] === s[u];
            if (L) {
              if (W[h++] = u, ++g, g === t) {
                m = !0;
                break;
              }
              ++u;
            } else
              u = d[u];
          }
        var y = t <= 1 ? -1 : e._targetLower.indexOf(v, N[0]), c = !!~y, S = c ? y === 0 || e._nextBeginningIndexes[y - 1] === y : !1;
        if (c && !S) {
          for (var l = 0; l < d.length; l = d[l])
            if (!(l <= y)) {
              for (var B = 0; B < t && f[B] === e._targetLowerCodes[l + B]; B++) ;
              if (B === t) {
                y = l, S = !0;
                break;
              }
            }
        }
        var w = (o) => {
          for (var x = 0, ge = 0, F = 1; F < t; ++F)
            o[F] - o[F - 1] !== 1 && (x -= o[F], ++ge);
          var Le = o[t - 1] - o[0] - (t - 1);
          if (x -= (12 + Le) * ge, o[0] !== 0 && (x -= o[0] * o[0] * 0.2), !m)
            x *= 1e3;
          else {
            for (var ie = 1, F = d[0]; F < _; F = d[F]) ++ie;
            ie > 24 && (x *= (ie - 24) * 10);
          }
          return x -= (_ - t) / 2, c && (x /= 1 + t * t * 1), S && (x /= 1 + t * t * 1), x -= (_ - t) / 2, x;
        };
        if (m)
          if (S) {
            for (var l = 0; l < t; ++l) N[l] = y + l;
            var M = N, Y = w(N);
          } else
            var M = W, Y = w(W);
        else {
          if (c) for (var l = 0; l < t; ++l) N[l] = y + l;
          var M = N, Y = w(M);
        }
        e._score = Y;
        for (var l = 0; l < t; ++l) e._indexes[l] = M[l];
        e._indexes.len = t;
        const R = new te();
        return R.target = e.target, R._score = e._score, R._indexes = e._indexes, R;
      }, xe = (r, e, a) => {
        for (var i = /* @__PURE__ */ new Set(), v = 0, f = b, n = 0, s = r.spaceSearches, t = s.length, _ = 0, u = () => {
          for (let S = _ - 1; S >= 0; S--) e._nextBeginningIndexes[X[S * 2 + 0]] = X[S * 2 + 1];
        }, I = !1, c = 0; c < t; ++c) {
          G[c] = z;
          var L = s[c];
          if (f = $(L, e), a) {
            if (f === b) continue;
            I = !0;
          } else if (f === b)
            return u(), b;
          var g = c === t - 1;
          if (!g) {
            var m = f._indexes, h = !0;
            for (let l = 0; l < m.len - 1; l++)
              if (m[l + 1] - m[l] !== 1) {
                h = !1;
                break;
              }
            if (h) {
              var d = m[m.len - 1] + 1, O = e._nextBeginningIndexes[d - 1];
              for (let l = d - 1; l >= 0 && O === e._nextBeginningIndexes[l]; l--)
                e._nextBeginningIndexes[l] = d, X[_ * 2 + 0] = l, X[_ * 2 + 1] = O, _++;
            }
          }
          v += f._score / t, G[c] = f._score / t, f._indexes[0] < n && (v -= (n - f._indexes[0]) * 2), n = f._indexes[0];
          for (var C = 0; C < f._indexes.len; ++C) i.add(f._indexes[C]);
        }
        if (a && !I) return b;
        u();
        var y = $(
          r,
          e,
          /*allowSpaces=*/
          !0
        );
        if (y !== b && y._score > v) {
          if (a)
            for (var c = 0; c < t; ++c)
              G[c] = y._score / t;
          return y;
        }
        a && (f = e), f._score = v;
        var c = 0;
        for (let S of i) f._indexes[c++] = S;
        return f._indexes.len = c, f;
      }, p = (r) => {
        for (var e = r.length, a = r.toLowerCase(), i = [], v = 0, f = !1, n = 0; n < e; ++n) {
          var s = i[n] = a.charCodeAt(n);
          if (s === 32) {
            f = !0;
            continue;
          }
          var t = s >= 97 && s <= 122 ? s - 97 : s >= 48 && s <= 57 ? 26 : s <= 127 ? 30 : 31;
          v |= 1 << t;
        }
        return { lowerCodes: i, bitflags: v, containsSpace: f, _lower: a };
      }, we = (r) => {
        for (var e = r.length, a = [], i = 0, v = !1, f = !1, n = 0; n < e; ++n) {
          var s = r.charCodeAt(n), t = s >= 65 && s <= 90, _ = t || s >= 97 && s <= 122 || s >= 48 && s <= 57, u = t && !v || !f || !_;
          v = t, f = _, u && (a[i++] = n);
        }
        return a;
      }, be = (r) => {
        for (var e = r.length, a = we(r), i = [], v = a[0], f = 0, n = 0; n < e; ++n)
          v > n ? i[n] = v : (v = a[++f], i[n] = v === void 0 ? e : v);
        return i;
      }, ee = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map(), N = [], W = [], X = [], T = [], G = [], ae = [], D = [], Z = (r, e) => {
        var a = r[e];
        if (a !== void 0) return a;
        if (typeof e == "function") return e(r);
        var i = e;
        Array.isArray(e) || (i = e.split("."));
        for (var v = i.length, f = -1; r && ++f < v; ) r = r[i[f]];
        return r;
      }, V = (r) => typeof r == "object" && typeof r._bitflags == "number", ne = 1 / 0, z = -ne, fe = [];
      fe.total = 0;
      var b = null, H = P(""), Se = (r) => {
        var e = [], a = 0, i = {}, v = (f) => {
          for (var n = 0, s = e[n], t = 1; t < a; ) {
            var _ = t + 1;
            n = t, _ < a && e[_]._score < e[t]._score && (n = _), e[n - 1 >> 1] = e[n], t = 1 + (n << 1);
          }
          for (var u = n - 1 >> 1; n > 0 && s._score < e[u]._score; u = (n = u) - 1 >> 1) e[n] = e[u];
          e[n] = s;
        };
        return i.add = ((f) => {
          var n = a;
          e[a++] = f;
          for (var s = n - 1 >> 1; n > 0 && f._score < e[s]._score; s = (n = s) - 1 >> 1) e[n] = e[s];
          e[n] = f;
        }), i.poll = ((f) => {
          if (a !== 0) {
            var n = e[0];
            return e[0] = e[--a], v(), n;
          }
        }), i.peek = ((f) => {
          if (a !== 0) return e[0];
        }), i.replaceTop = ((f) => {
          e[0] = f, v();
        }), i;
      }, U = Se();
      return { single: k, go: ve, prepare: P, cleanup: K };
    });
  })(j)), j.exports;
}
var Ae = ke();
const oe = /* @__PURE__ */ ye(Ae);
function Oe(A, E, k) {
  var P;
  const J = Ie(A).replace(/[^\w\s]/gi, "").toLowerCase();
  return ze(E) ? oe.go(J, E, { all: !0, threshold: -1e5 }).map((K) => K.target) : Be(E) && ((P = k == null ? void 0 : k.fieldNames) != null && P.length) ? oe.go(J, E, { all: !0, threshold: -1e5, keys: k == null ? void 0 : k.fieldNames }).map((K) => K.obj) : E;
}
export {
  Be as i,
  Oe as s
};
//# sourceMappingURL=searchFuzzy-DVCFTy5v.js.map
