@untemps/react-vocal 2.0.0-beta.4 → 2.0.0-beta.5

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/index.es.js CHANGED
@@ -672,7 +672,7 @@ x(N, "defaultOptions", {
672
672
  });
673
673
  //#endregion
674
674
  //#region node_modules/@untemps/utils/dist/function/isFunction.js
675
- var ee = (e) => typeof e == "function", P = (e = "en-US", t = null, i = 1, o = null) => {
675
+ var P = (e) => typeof e == "function", F = (e = "en-US", t = null, i = 1, o = null) => {
676
676
  let s = a(null);
677
677
  return r(() => {
678
678
  if (N.isSupported) return s.current = o || new N({
@@ -707,7 +707,7 @@ var ee = (e) => typeof e == "function", P = (e = "en-US", t = null, i = 1, o = n
707
707
  s.current && s.current.cleanup();
708
708
  }, [])
709
709
  }];
710
- }, te = (e, t = 0) => {
710
+ }, I = (e, t = 0) => {
711
711
  let i = a(-1), o = n(() => {
712
712
  clearTimeout(i.current), i.current = -1;
713
713
  }, []), s = n(() => {
@@ -718,1180 +718,27 @@ var ee = (e) => typeof e == "function", P = (e = "en-US", t = null, i = 1, o = n
718
718
  o
719
719
  ]);
720
720
  return r(() => o, [o]), [s, o];
721
- };
722
- //#endregion
723
- //#region node_modules/fuse.js/dist/fuse.mjs
724
- function F(e) {
725
- return Array.isArray ? Array.isArray(e) : W(e) === "[object Array]";
726
- }
727
- function I(e) {
728
- if (typeof e == "string") return e;
729
- if (typeof e == "bigint") return e.toString();
730
- let t = e + "";
731
- return t == "0" && 1 / e == -Infinity ? "-0" : t;
732
- }
733
- function L(e) {
734
- return e == null ? "" : I(e);
735
- }
736
- function R(e) {
737
- return typeof e == "string";
738
- }
739
- function z(e) {
740
- return typeof e == "number";
741
- }
742
- function B(e) {
743
- return e === !0 || e === !1 || ne(e) && W(e) == "[object Boolean]";
744
- }
745
- function V(e) {
746
- return typeof e == "object";
747
- }
748
- function ne(e) {
749
- return V(e) && e !== null;
750
- }
751
- function H(e) {
752
- return e != null;
753
- }
754
- function U(e) {
755
- return !e.trim().length;
756
- }
757
- function W(e) {
758
- return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
759
- }
760
- var G = "Incorrect 'index' type", re = (e) => `Invalid value for key ${e}`, K = (e) => `Pattern length exceeds max of ${e}.`, q = (e) => `Missing ${e} property in key`, ie = (e) => `Property 'weight' in key '${e}' must be a positive integer`, ae = Object.prototype.hasOwnProperty, oe = class {
761
- constructor(e) {
762
- this._keys = [], this._keyMap = {};
763
- let t = 0;
764
- e.forEach((e) => {
765
- let n = se(e);
766
- this._keys.push(n), this._keyMap[n.id] = n, t += n.weight;
767
- }), this._keys.forEach((e) => {
768
- e.weight /= t;
769
- });
770
- }
771
- get(e) {
772
- return this._keyMap[e];
773
- }
774
- keys() {
775
- return this._keys;
776
- }
777
- toJSON() {
778
- return JSON.stringify(this._keys);
779
- }
780
- };
781
- function se(e) {
782
- let t = null, n = null, r = null, i = 1, a = null;
783
- if (R(e) || F(e)) r = e, t = ce(e), n = le(e);
784
- else {
785
- if (!ae.call(e, "name")) throw Error(q("name"));
786
- let o = e.name;
787
- if (r = o, ae.call(e, "weight") && (i = e.weight, i <= 0)) throw Error(ie(o));
788
- t = ce(o), n = le(o), a = e.getFn;
789
- }
790
- return {
791
- path: t,
792
- id: n,
793
- weight: i,
794
- src: r,
795
- getFn: a
796
- };
797
- }
798
- function ce(e) {
799
- return F(e) ? e : e.split(".");
800
- }
801
- function le(e) {
802
- return F(e) ? e.join(".") : e;
803
- }
804
- function ue(e, t) {
805
- let n = [], r = !1, i = (e, t, a, o) => {
806
- if (H(e)) if (!t[a]) n.push(o === void 0 ? e : {
807
- v: e,
808
- i: o
809
- });
810
- else {
811
- let s = e[t[a]];
812
- if (!H(s)) return;
813
- if (a === t.length - 1 && (R(s) || z(s) || B(s) || typeof s == "bigint")) n.push(o === void 0 ? L(s) : {
814
- v: L(s),
815
- i: o
816
- });
817
- else if (F(s)) {
818
- r = !0;
819
- for (let e = 0, n = s.length; e < n; e += 1) i(s[e], t, a + 1, e);
820
- } else t.length && i(s, t, a + 1, o);
821
- }
822
- };
823
- return i(e, R(t) ? t.split(".") : t, 0), r ? n : n[0];
824
- }
825
- var de = {
826
- includeMatches: !1,
827
- findAllMatches: !1,
828
- minMatchCharLength: 1
829
- }, fe = {
830
- isCaseSensitive: !1,
831
- ignoreDiacritics: !1,
832
- includeScore: !1,
833
- keys: [],
834
- shouldSort: !0,
835
- sortFn: (e, t) => e.score === t.score ? e.idx < t.idx ? -1 : 1 : e.score < t.score ? -1 : 1
836
- }, pe = {
837
- location: 0,
838
- threshold: .6,
839
- distance: 100
840
- }, me = {
841
- useExtendedSearch: !1,
842
- useTokenSearch: !1,
843
- getFn: ue,
844
- ignoreLocation: !1,
845
- ignoreFieldNorm: !1,
846
- fieldNormWeight: 1
847
- }, J = Object.freeze({
848
- ...fe,
849
- ...de,
850
- ...pe,
851
- ...me
852
- }), he = /[^ ]+/g;
853
- function ge(e = 1, t = 3) {
854
- let n = /* @__PURE__ */ new Map(), r = 10 ** t;
855
- return {
856
- get(t) {
857
- let i = t.match(he).length;
858
- if (n.has(i)) return n.get(i);
859
- let a = 1 / i ** (.5 * e), o = parseFloat(Math.round(a * r) / r);
860
- return n.set(i, o), o;
861
- },
862
- clear() {
863
- n.clear();
864
- }
865
- };
866
- }
867
- var _e = class {
868
- constructor({ getFn: e = J.getFn, fieldNormWeight: t = J.fieldNormWeight } = {}) {
869
- this.norm = ge(t, 3), this.getFn = e, this.isCreated = !1, this.docs = [], this.keys = [], this._keysMap = {}, this.setIndexRecords();
870
- }
871
- setSources(e = []) {
872
- this.docs = e;
873
- }
874
- setIndexRecords(e = []) {
875
- this.records = e;
876
- }
877
- setKeys(e = []) {
878
- this.keys = e, this._keysMap = {}, e.forEach((e, t) => {
879
- this._keysMap[e.id] = t;
880
- });
881
- }
882
- create() {
883
- this.isCreated || !this.docs.length || (this.isCreated = !0, R(this.docs[0]) ? this.docs.forEach((e, t) => {
884
- this._addString(e, t);
885
- }) : this.docs.forEach((e, t) => {
886
- this._addObject(e, t);
887
- }), this.norm.clear());
888
- }
889
- add(e) {
890
- let t = this.size();
891
- R(e) ? this._addString(e, t) : this._addObject(e, t);
892
- }
893
- removeAt(e) {
894
- this.records.splice(e, 1);
895
- for (let t = e, n = this.size(); t < n; t += 1) --this.records[t].i;
896
- }
897
- removeAll(e) {
898
- for (let t = e.length - 1; t >= 0; --t) this.records.splice(e[t], 1);
899
- for (let e = 0, t = this.records.length; e < t; e += 1) this.records[e].i = e;
900
- }
901
- getValueForItemAtKeyId(e, t) {
902
- return e[this._keysMap[t]];
903
- }
904
- size() {
905
- return this.records.length;
906
- }
907
- _addString(e, t) {
908
- if (!H(e) || U(e)) return;
909
- let n = {
910
- v: e,
911
- i: t,
912
- n: this.norm.get(e)
913
- };
914
- this.records.push(n);
915
- }
916
- _addObject(e, t) {
917
- let n = {
918
- i: t,
919
- $: {}
920
- };
921
- this.keys.forEach((t, r) => {
922
- let i = t.getFn ? t.getFn(e) : this.getFn(e, t.path);
923
- if (H(i)) {
924
- if (F(i)) {
925
- let e = [];
926
- for (let t = 0, n = i.length; t < n; t += 1) {
927
- let n = i[t];
928
- if (H(n)) {
929
- if (R(n)) {
930
- if (!U(n)) {
931
- let r = {
932
- v: n,
933
- i: t,
934
- n: this.norm.get(n)
935
- };
936
- e.push(r);
937
- }
938
- } else if (H(n.v)) {
939
- let t = R(n.v) ? n.v : L(n.v);
940
- if (!U(t)) {
941
- let r = {
942
- v: t,
943
- i: n.i,
944
- n: this.norm.get(t)
945
- };
946
- e.push(r);
947
- }
948
- }
949
- }
950
- }
951
- n.$[r] = e;
952
- } else if (R(i) && !U(i)) {
953
- let e = {
954
- v: i,
955
- n: this.norm.get(i)
956
- };
957
- n.$[r] = e;
958
- }
959
- }
960
- }), this.records.push(n);
961
- }
962
- toJSON() {
963
- return {
964
- keys: this.keys.map(({ getFn: e, ...t }) => t),
965
- records: this.records
966
- };
967
- }
968
- };
969
- function ve(e, t, { getFn: n = J.getFn, fieldNormWeight: r = J.fieldNormWeight } = {}) {
970
- let i = new _e({
971
- getFn: n,
972
- fieldNormWeight: r
973
- });
974
- return i.setKeys(e.map(se)), i.setSources(t), i.create(), i;
975
- }
976
- function ye(e, { getFn: t = J.getFn, fieldNormWeight: n = J.fieldNormWeight } = {}) {
977
- let { keys: r, records: i } = e, a = new _e({
978
- getFn: t,
979
- fieldNormWeight: n
980
- });
981
- return a.setKeys(r), a.setIndexRecords(i), a;
982
- }
983
- function be(e = [], t = J.minMatchCharLength) {
984
- let n = [], r = -1, i = -1, a = 0;
985
- for (let o = e.length; a < o; a += 1) {
986
- let o = e[a];
987
- o && r === -1 ? r = a : !o && r !== -1 && (i = a - 1, i - r + 1 >= t && n.push([r, i]), r = -1);
988
- }
989
- return e[a - 1] && a - r >= t && n.push([r, a - 1]), n;
990
- }
991
- var Y = 32;
992
- function xe(e, t, n, { location: r = J.location, distance: i = J.distance, threshold: a = J.threshold, findAllMatches: o = J.findAllMatches, minMatchCharLength: s = J.minMatchCharLength, includeMatches: c = J.includeMatches, ignoreLocation: l = J.ignoreLocation } = {}) {
993
- if (t.length > Y) throw Error(K(Y));
994
- let u = t.length, d = e.length, f = Math.max(0, Math.min(r, d)), p = a, m = f, h = (e, t) => {
995
- let n = e / u;
996
- if (l) return n;
997
- let r = Math.abs(f - t);
998
- return i ? n + r / i : r ? 1 : n;
999
- }, g = s > 1 || c, _ = g ? Array(d) : [], v;
1000
- for (; (v = e.indexOf(t, m)) > -1;) {
1001
- let e = h(0, v);
1002
- if (p = Math.min(e, p), m = v + u, g) {
1003
- let e = 0;
1004
- for (; e < u;) _[v + e] = 1, e += 1;
1005
- }
1006
- }
1007
- m = -1;
1008
- let y = [], b = 1, x = u + d, S = 1 << u - 1;
1009
- for (let t = 0; t < u; t += 1) {
1010
- let r = 0, i = x;
1011
- for (; r < i;) h(t, f + i) <= p ? r = i : x = i, i = Math.floor((x - r) / 2 + r);
1012
- x = i;
1013
- let a = Math.max(1, f - i + 1), s = o ? d : Math.min(f + i, d) + u, c = Array(s + 2);
1014
- c[s + 1] = (1 << t) - 1;
1015
- for (let r = s; r >= a; --r) {
1016
- let i = r - 1, o = n[e[i]];
1017
- if (g && (_[i] = +!!o), c[r] = (c[r + 1] << 1 | 1) & o, t && (c[r] |= (y[r + 1] | y[r]) << 1 | 1 | y[r + 1]), c[r] & S && (b = h(t, i), b <= p)) {
1018
- if (p = b, m = i, m <= f) break;
1019
- a = Math.max(1, 2 * f - m);
1020
- }
1021
- }
1022
- if (h(t + 1, f) > p) break;
1023
- y = c;
1024
- }
1025
- let C = {
1026
- isMatch: m >= 0,
1027
- score: Math.max(.001, b)
1028
- };
1029
- if (g) {
1030
- let e = be(_, s);
1031
- e.length ? c && (C.indices = e) : C.isMatch = !1;
1032
- }
1033
- return C;
1034
- }
1035
- function Se(e) {
1036
- let t = {};
1037
- for (let n = 0, r = e.length; n < r; n += 1) {
1038
- let i = e.charAt(n);
1039
- t[i] = (t[i] || 0) | 1 << r - n - 1;
1040
- }
1041
- return t;
1042
- }
1043
- function Ce(e) {
1044
- if (e.length <= 1) return e;
1045
- e.sort((e, t) => e[0] - t[0] || e[1] - t[1]);
1046
- let t = [e[0]];
1047
- for (let n = 1, r = e.length; n < r; n += 1) {
1048
- let r = t[t.length - 1], i = e[n];
1049
- i[0] <= r[1] + 1 ? r[1] = Math.max(r[1], i[1]) : t.push(i);
1050
- }
1051
- return t;
1052
- }
1053
- var we = {
1054
- ł: "l",
1055
- Ł: "L",
1056
- đ: "d",
1057
- Đ: "D",
1058
- ø: "o",
1059
- Ø: "O",
1060
- ħ: "h",
1061
- Ħ: "H",
1062
- ŧ: "t",
1063
- Ŧ: "T",
1064
- ı: "i",
1065
- ß: "ss"
1066
- }, Te = RegExp("[" + Object.keys(we).join("") + "]", "g"), X = 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(Te, (e) => we[e]) : (e) => e, Ee = class {
1067
- constructor(e, { location: t = J.location, threshold: n = J.threshold, distance: r = J.distance, includeMatches: i = J.includeMatches, findAllMatches: a = J.findAllMatches, minMatchCharLength: o = J.minMatchCharLength, isCaseSensitive: s = J.isCaseSensitive, ignoreDiacritics: c = J.ignoreDiacritics, ignoreLocation: l = J.ignoreLocation } = {}) {
1068
- if (this.options = {
1069
- location: t,
1070
- threshold: n,
1071
- distance: r,
1072
- includeMatches: i,
1073
- findAllMatches: a,
1074
- minMatchCharLength: o,
1075
- isCaseSensitive: s,
1076
- ignoreDiacritics: c,
1077
- ignoreLocation: l
1078
- }, e = s ? e : e.toLowerCase(), e = c ? X(e) : e, this.pattern = e, this.chunks = [], !this.pattern.length) return;
1079
- let u = (e, t) => {
1080
- this.chunks.push({
1081
- pattern: e,
1082
- alphabet: Se(e),
1083
- startIndex: t
1084
- });
1085
- }, d = this.pattern.length;
1086
- if (d > Y) {
1087
- let e = 0, t = d % Y, n = d - t;
1088
- for (; e < n;) u(this.pattern.substr(e, Y), e), e += Y;
1089
- if (t) {
1090
- let e = d - Y;
1091
- u(this.pattern.substr(e), e);
1092
- }
1093
- } else u(this.pattern, 0);
1094
- }
1095
- searchIn(e) {
1096
- let { isCaseSensitive: t, ignoreDiacritics: n, includeMatches: r } = this.options;
1097
- if (e = t ? e : e.toLowerCase(), e = n ? X(e) : e, this.pattern === e) {
1098
- let t = {
1099
- isMatch: !0,
1100
- score: 0
1101
- };
1102
- return r && (t.indices = [[0, e.length - 1]]), t;
1103
- }
1104
- let { location: i, distance: a, threshold: o, findAllMatches: s, minMatchCharLength: c, ignoreLocation: l } = this.options, u = [], d = 0, f = !1;
1105
- this.chunks.forEach(({ pattern: t, alphabet: n, startIndex: p }) => {
1106
- let { isMatch: m, score: h, indices: g } = xe(e, t, n, {
1107
- location: i + p,
1108
- distance: a,
1109
- threshold: o,
1110
- findAllMatches: s,
1111
- minMatchCharLength: c,
1112
- includeMatches: r,
1113
- ignoreLocation: l
1114
- });
1115
- m && (f = !0), d += h, m && g && u.push(...g);
1116
- });
1117
- let p = {
1118
- isMatch: f,
1119
- score: f ? d / this.chunks.length : 1
1120
- };
1121
- return f && r && (p.indices = Ce(u)), p;
1122
- }
1123
- }, Z = class {
1124
- constructor(e) {
1125
- this.pattern = e;
1126
- }
1127
- static isMultiMatch(e) {
1128
- return De(e, this.multiRegex);
1129
- }
1130
- static isSingleMatch(e) {
1131
- return De(e, this.singleRegex);
1132
- }
1133
- search(e) {
1134
- return {
1135
- isMatch: !1,
1136
- score: 1
1137
- };
1138
- }
1139
- };
1140
- function De(e, t) {
1141
- let n = e.match(t);
1142
- return n ? n[1] : null;
1143
- }
1144
- var Oe = class extends Z {
1145
- constructor(e) {
1146
- super(e);
1147
- }
1148
- static get type() {
1149
- return "exact";
1150
- }
1151
- static get multiRegex() {
1152
- return /^="(.*)"$/;
1153
- }
1154
- static get singleRegex() {
1155
- return /^=(.*)$/;
1156
- }
1157
- search(e) {
1158
- let t = e === this.pattern;
1159
- return {
1160
- isMatch: t,
1161
- score: +!t,
1162
- indices: [0, this.pattern.length - 1]
1163
- };
1164
- }
1165
- }, ke = class extends Z {
1166
- constructor(e) {
1167
- super(e);
1168
- }
1169
- static get type() {
1170
- return "inverse-exact";
1171
- }
1172
- static get multiRegex() {
1173
- return /^!"(.*)"$/;
1174
- }
1175
- static get singleRegex() {
1176
- return /^!(.*)$/;
1177
- }
1178
- search(e) {
1179
- let t = e.indexOf(this.pattern) === -1;
1180
- return {
1181
- isMatch: t,
1182
- score: +!t,
1183
- indices: [0, e.length - 1]
1184
- };
1185
- }
1186
- }, Ae = class extends Z {
1187
- constructor(e) {
1188
- super(e);
1189
- }
1190
- static get type() {
1191
- return "prefix-exact";
1192
- }
1193
- static get multiRegex() {
1194
- return /^\^"(.*)"$/;
1195
- }
1196
- static get singleRegex() {
1197
- return /^\^(.*)$/;
1198
- }
1199
- search(e) {
1200
- let t = e.startsWith(this.pattern);
1201
- return {
1202
- isMatch: t,
1203
- score: +!t,
1204
- indices: [0, this.pattern.length - 1]
1205
- };
1206
- }
1207
- }, je = class extends Z {
1208
- constructor(e) {
1209
- super(e);
1210
- }
1211
- static get type() {
1212
- return "inverse-prefix-exact";
1213
- }
1214
- static get multiRegex() {
1215
- return /^!\^"(.*)"$/;
1216
- }
1217
- static get singleRegex() {
1218
- return /^!\^(.*)$/;
1219
- }
1220
- search(e) {
1221
- let t = !e.startsWith(this.pattern);
1222
- return {
1223
- isMatch: t,
1224
- score: +!t,
1225
- indices: [0, e.length - 1]
1226
- };
1227
- }
1228
- }, Me = class extends Z {
1229
- constructor(e) {
1230
- super(e);
1231
- }
1232
- static get type() {
1233
- return "suffix-exact";
1234
- }
1235
- static get multiRegex() {
1236
- return /^"(.*)"\$$/;
1237
- }
1238
- static get singleRegex() {
1239
- return /^(.*)\$$/;
1240
- }
1241
- search(e) {
1242
- let t = e.endsWith(this.pattern);
1243
- return {
1244
- isMatch: t,
1245
- score: +!t,
1246
- indices: [e.length - this.pattern.length, e.length - 1]
1247
- };
1248
- }
1249
- }, Ne = class extends Z {
1250
- constructor(e) {
1251
- super(e);
1252
- }
1253
- static get type() {
1254
- return "inverse-suffix-exact";
1255
- }
1256
- static get multiRegex() {
1257
- return /^!"(.*)"\$$/;
1258
- }
1259
- static get singleRegex() {
1260
- return /^!(.*)\$$/;
1261
- }
1262
- search(e) {
1263
- let t = !e.endsWith(this.pattern);
1264
- return {
1265
- isMatch: t,
1266
- score: +!t,
1267
- indices: [0, e.length - 1]
1268
- };
1269
- }
1270
- }, Pe = class extends Z {
1271
- constructor(e, { location: t = J.location, threshold: n = J.threshold, distance: r = J.distance, includeMatches: i = J.includeMatches, findAllMatches: a = J.findAllMatches, minMatchCharLength: o = J.minMatchCharLength, isCaseSensitive: s = J.isCaseSensitive, ignoreDiacritics: c = J.ignoreDiacritics, ignoreLocation: l = J.ignoreLocation } = {}) {
1272
- super(e), this._bitapSearch = new Ee(e, {
1273
- location: t,
1274
- threshold: n,
1275
- distance: r,
1276
- includeMatches: i,
1277
- findAllMatches: a,
1278
- minMatchCharLength: o,
1279
- isCaseSensitive: s,
1280
- ignoreDiacritics: c,
1281
- ignoreLocation: l
1282
- });
1283
- }
1284
- static get type() {
1285
- return "fuzzy";
1286
- }
1287
- static get multiRegex() {
1288
- return /^"(.*)"$/;
1289
- }
1290
- static get singleRegex() {
1291
- return /^(.*)$/;
1292
- }
1293
- search(e) {
1294
- return this._bitapSearch.searchIn(e);
1295
- }
1296
- }, Fe = class extends Z {
1297
- constructor(e) {
1298
- super(e);
1299
- }
1300
- static get type() {
1301
- return "include";
1302
- }
1303
- static get multiRegex() {
1304
- return /^'"(.*)"$/;
1305
- }
1306
- static get singleRegex() {
1307
- return /^'(.*)$/;
1308
- }
1309
- search(e) {
1310
- let t = 0, n, r = [], i = this.pattern.length;
1311
- for (; (n = e.indexOf(this.pattern, t)) > -1;) t = n + i, r.push([n, t - 1]);
1312
- let a = !!r.length;
1313
- return {
1314
- isMatch: a,
1315
- score: +!a,
1316
- indices: r
1317
- };
1318
- }
1319
- }, Ie = [
1320
- Oe,
1321
- Fe,
1322
- Ae,
1323
- je,
1324
- Ne,
1325
- Me,
1326
- ke,
1327
- Pe
1328
- ], Le = Ie.length, Re = "\0", ze = "|";
1329
- function Be(e) {
1330
- let t = [], n = e.length, r = 0;
1331
- for (; r < n;) {
1332
- for (; r < n && e[r] === " ";) r++;
1333
- if (r >= n) break;
1334
- let i = r;
1335
- for (; i < n && e[i] !== " " && e[i] !== "\"";) i++;
1336
- if (i < n && e[i] === "\"") {
1337
- for (i++; i < n;) {
1338
- if (e[i] === "\"") {
1339
- let t = i + 1;
1340
- if (t >= n || e[t] === " ") {
1341
- i++;
1342
- break;
1343
- }
1344
- if (e[t] === "$" && (t + 1 >= n || e[t + 1] === " ")) {
1345
- i += 2;
1346
- break;
1347
- }
1348
- }
1349
- i++;
1350
- }
1351
- t.push(e.substring(r, i)), r = i;
1352
- } else {
1353
- for (; i < n && e[i] !== " ";) i++;
1354
- t.push(e.substring(r, i)), r = i;
1355
- }
1356
- }
1357
- return t;
1358
- }
1359
- function Ve(e, t = {}) {
1360
- return e.replace(/\\\|/g, Re).split(ze).map((e) => {
1361
- let n = Be(e.replace(/\u0000/g, "|").trim()).filter((e) => e && !!e.trim()), r = [];
1362
- for (let e = 0, i = n.length; e < i; e += 1) {
1363
- let i = n[e], a = !1, o = -1;
1364
- for (; !a && ++o < Le;) {
1365
- let e = Ie[o], n = e.isMultiMatch(i);
1366
- n && (r.push(new e(n, t)), a = !0);
1367
- }
1368
- if (!a) for (o = -1; ++o < Le;) {
1369
- let e = Ie[o], n = e.isSingleMatch(i);
1370
- if (n) {
1371
- r.push(new e(n, t));
1372
- break;
1373
- }
1374
- }
1375
- }
1376
- return r;
1377
- });
1378
- }
1379
- var He = new Set([Pe.type, Fe.type]), Ue = class {
1380
- constructor(e, { isCaseSensitive: t = J.isCaseSensitive, ignoreDiacritics: n = J.ignoreDiacritics, includeMatches: r = J.includeMatches, minMatchCharLength: i = J.minMatchCharLength, ignoreLocation: a = J.ignoreLocation, findAllMatches: o = J.findAllMatches, location: s = J.location, threshold: c = J.threshold, distance: l = J.distance } = {}) {
1381
- this.query = null, this.options = {
1382
- isCaseSensitive: t,
1383
- ignoreDiacritics: n,
1384
- includeMatches: r,
1385
- minMatchCharLength: i,
1386
- findAllMatches: o,
1387
- ignoreLocation: a,
1388
- location: s,
1389
- threshold: c,
1390
- distance: l
1391
- }, e = t ? e : e.toLowerCase(), e = n ? X(e) : e, this.pattern = e, this.query = Ve(this.pattern, this.options);
1392
- }
1393
- static condition(e, t) {
1394
- return t.useExtendedSearch;
1395
- }
1396
- searchIn(e) {
1397
- let t = this.query;
1398
- if (!t) return {
1399
- isMatch: !1,
1400
- score: 1
1401
- };
1402
- let { includeMatches: n, isCaseSensitive: r, ignoreDiacritics: i } = this.options;
1403
- e = r ? e : e.toLowerCase(), e = i ? X(e) : e;
1404
- let a = 0, o = [], s = 0, c = !1;
1405
- for (let r = 0, i = t.length; r < i; r += 1) {
1406
- let i = t[r];
1407
- o.length = 0, a = 0, c = !1;
1408
- for (let t = 0, r = i.length; t < r; t += 1) {
1409
- let r = i[t], { isMatch: l, indices: u, score: d } = r.search(e);
1410
- if (l) {
1411
- a += 1, s += d;
1412
- let e = r.constructor.type;
1413
- e.startsWith("inverse") && (c = !0), n && (He.has(e) ? o.push(...u) : o.push(u));
1414
- } else {
1415
- s = 0, a = 0, o.length = 0, c = !1;
1416
- break;
1417
- }
1418
- }
1419
- if (a) {
1420
- let e = {
1421
- isMatch: !0,
1422
- score: s / a
1423
- };
1424
- return c && (e.hasInverse = !0), n && (e.indices = Ce(o)), e;
1425
- }
1426
- }
1427
- return {
1428
- isMatch: !1,
1429
- score: 1
1430
- };
1431
- }
1432
- }, We = [];
1433
- function Ge(...e) {
1434
- We.push(...e);
1435
- }
1436
- function Ke(e, t) {
1437
- for (let n = 0, r = We.length; n < r; n += 1) {
1438
- let r = We[n];
1439
- if (r.condition(e, t)) return new r(e, t);
1440
- }
1441
- return new Ee(e, t);
1442
- }
1443
- var qe = {
1444
- AND: "$and",
1445
- OR: "$or"
1446
- }, Je = {
1447
- PATH: "$path",
1448
- PATTERN: "$val"
1449
- }, Ye = (e) => !!(e[qe.AND] || e[qe.OR]), Xe = (e) => !!e[Je.PATH], Ze = (e) => !F(e) && V(e) && !Ye(e), Qe = (e) => ({ [qe.AND]: Object.keys(e).map((t) => ({ [t]: e[t] })) });
1450
- function $e(e, t, { auto: n = !0 } = {}) {
1451
- let r = (e) => {
1452
- if (R(e)) {
1453
- let r = {
1454
- keyId: null,
1455
- pattern: e
1456
- };
1457
- return n && (r.searcher = Ke(e, t)), r;
1458
- }
1459
- let i = Object.keys(e), a = Xe(e);
1460
- if (!a && i.length > 1 && !Ye(e)) return r(Qe(e));
1461
- if (Ze(e)) {
1462
- let r = a ? e[Je.PATH] : i[0], o = a ? e[Je.PATTERN] : e[r];
1463
- if (!R(o)) throw Error(re(r));
1464
- let s = {
1465
- keyId: le(r),
1466
- pattern: o
1467
- };
1468
- return n && (s.searcher = Ke(o, t)), s;
1469
- }
1470
- let o = {
1471
- children: [],
1472
- operator: i[0]
1473
- };
1474
- return i.forEach((t) => {
1475
- let n = e[t];
1476
- F(n) && n.forEach((e) => {
1477
- o.children.push(r(e));
1478
- });
1479
- }), o;
1480
- };
1481
- return Ye(e) || (e = Qe(e)), r(e);
1482
- }
1483
- function et(e, { ignoreFieldNorm: t = J.ignoreFieldNorm }) {
1484
- let n = 1;
1485
- return e.forEach(({ key: e, norm: r, score: i }) => {
1486
- let a = e ? e.weight : null;
1487
- n *= (i === 0 && a ? 2 ** -52 : i) ** +((a || 1) * (t ? 1 : r));
1488
- }), n;
1489
- }
1490
- function tt(e, { ignoreFieldNorm: t = J.ignoreFieldNorm }) {
1491
- e.forEach((e) => {
1492
- e.score = et(e.matches, { ignoreFieldNorm: t });
1493
- });
1494
- }
1495
- var nt = class {
1496
- constructor(e) {
1497
- this.limit = e, this.heap = [];
1498
- }
1499
- get size() {
1500
- return this.heap.length;
1501
- }
1502
- shouldInsert(e) {
1503
- return this.size < this.limit || e < this.heap[0].score;
1504
- }
1505
- insert(e) {
1506
- 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));
1507
- }
1508
- extractSorted(e) {
1509
- return this.heap.sort(e);
1510
- }
1511
- _bubbleUp(e) {
1512
- let t = this.heap;
1513
- for (; e > 0;) {
1514
- let n = e - 1 >> 1;
1515
- if (t[e].score <= t[n].score) break;
1516
- let r = t[e];
1517
- t[e] = t[n], t[n] = r, e = n;
1518
- }
1519
- }
1520
- _sinkDown(e) {
1521
- let t = this.heap, n = t.length, r = e;
1522
- do {
1523
- e = r;
1524
- let i = 2 * e + 1, a = 2 * e + 2;
1525
- if (i < n && t[i].score > t[r].score && (r = i), a < n && t[a].score > t[r].score && (r = a), r !== e) {
1526
- let n = t[e];
1527
- t[e] = t[r], t[r] = n;
1528
- }
1529
- } while (r !== e);
1530
- }
1531
- };
1532
- function rt(e, t) {
1533
- let n = e.matches;
1534
- t.matches = [], H(n) && n.forEach((e) => {
1535
- if (!H(e.indices) || !e.indices.length) return;
1536
- let { indices: n, value: r } = e, i = {
1537
- indices: n,
1538
- value: r
1539
- };
1540
- e.key && (i.key = e.key.src), e.idx > -1 && (i.refIndex = e.idx), t.matches.push(i);
1541
- });
1542
- }
1543
- function it(e, t) {
1544
- t.score = e.score;
1545
- }
1546
- function at(e, t, { includeMatches: n = J.includeMatches, includeScore: r = J.includeScore } = {}) {
1547
- let i = [];
1548
- return n && i.push(rt), r && i.push(it), e.map((e) => {
1549
- let { idx: n } = e, r = {
1550
- item: t[n],
1551
- refIndex: n
1552
- };
1553
- return i.length && i.forEach((t) => {
1554
- t(e, r);
1555
- }), r;
1556
- });
1557
- }
1558
- var ot = /\b\w+\b/g;
1559
- function st({ isCaseSensitive: e = !1, ignoreDiacritics: t = !1 } = {}) {
1560
- return { tokenize(n) {
1561
- return e || (n = n.toLowerCase()), t && (n = X(n)), n.match(ot) || [];
1562
- } };
1563
- }
1564
- function ct(e, t, n) {
1565
- let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0;
1566
- function o(e, t, o, s) {
1567
- let c = n.tokenize(e);
1568
- if (!c.length) return;
1569
- a++;
1570
- let l = /* @__PURE__ */ new Map();
1571
- for (let e of c) l.set(e, (l.get(e) || 0) + 1);
1572
- for (let [e, n] of l) {
1573
- let a = {
1574
- docIdx: t,
1575
- keyIdx: o,
1576
- subIdx: s,
1577
- tf: n
1578
- }, c = r.get(e);
1579
- c || (c = [], r.set(e, c)), c.push(a), i.set(e, (i.get(e) || 0) + 1);
1580
- }
1581
- }
1582
- for (let n of e) {
1583
- let { i: e, v: r, $: i } = n;
1584
- if (r !== void 0) {
1585
- o(r, e, -1, -1);
1586
- continue;
1587
- }
1588
- if (i) for (let n = 0; n < t; n++) {
1589
- let t = i[n];
1590
- if (t) if (Array.isArray(t)) for (let r of t) o(r.v, e, n, r.i ?? -1);
1591
- else o(t.v, e, n, -1);
1592
- }
1593
- }
1594
- return {
1595
- terms: r,
1596
- fieldCount: a,
1597
- df: i
1598
- };
1599
- }
1600
- function lt(e, t, n, r) {
1601
- let { i, v: a, $: o } = t;
1602
- function s(t, n, a) {
1603
- let o = r.tokenize(t);
1604
- if (!o.length) return;
1605
- e.fieldCount++;
1606
- let s = /* @__PURE__ */ new Map();
1607
- for (let e of o) s.set(e, (s.get(e) || 0) + 1);
1608
- for (let [t, r] of s) {
1609
- let o = {
1610
- docIdx: i,
1611
- keyIdx: n,
1612
- subIdx: a,
1613
- tf: r
1614
- }, s = e.terms.get(t);
1615
- s || (s = [], e.terms.set(t, s)), s.push(o), e.df.set(t, (e.df.get(t) || 0) + 1);
1616
- }
1617
- }
1618
- if (a !== void 0) {
1619
- s(a, -1, -1);
1620
- return;
1621
- }
1622
- if (o) for (let e = 0; e < n; e++) {
1623
- let t = o[e];
1624
- if (t) if (Array.isArray(t)) for (let n of t) s(n.v, e, n.i ?? -1);
1625
- else s(t.v, e, -1);
1626
- }
1627
- }
1628
- function ut(e, t) {
1629
- for (let [n, r] of e.terms) {
1630
- let i = r.filter((e) => e.docIdx !== t), a = r.length - i.length;
1631
- 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));
1632
- }
1633
- }
1634
- var Q = class {
1635
- constructor(e, t, n) {
1636
- this.options = {
1637
- ...J,
1638
- ...t
1639
- }, this.options.useExtendedSearch, this.options.useTokenSearch, this._keyStore = new oe(this.options.keys), this._docs = e, this._myIndex = null, this._invertedIndex = null, this.setCollection(e, n), this._lastQuery = null, this._lastSearcher = null;
1640
- }
1641
- _getSearcher(e) {
1642
- if (this._lastQuery === e) return this._lastSearcher;
1643
- let t = Ke(e, this._invertedIndex ? {
1644
- ...this.options,
1645
- _invertedIndex: this._invertedIndex
1646
- } : this.options);
1647
- return this._lastQuery = e, this._lastSearcher = t, t;
1648
- }
1649
- setCollection(e, t) {
1650
- if (this._docs = e, t && !(t instanceof _e)) throw Error(G);
1651
- if (this._myIndex = t || ve(this.options.keys, this._docs, {
1652
- getFn: this.options.getFn,
1653
- fieldNormWeight: this.options.fieldNormWeight
1654
- }), this.options.useTokenSearch) {
1655
- let e = st({
1656
- isCaseSensitive: this.options.isCaseSensitive,
1657
- ignoreDiacritics: this.options.ignoreDiacritics
1658
- });
1659
- this._invertedIndex = ct(this._myIndex.records, this._myIndex.keys.length, e);
1660
- }
1661
- }
1662
- add(e) {
1663
- if (H(e) && (this._docs.push(e), this._myIndex.add(e), this._invertedIndex)) {
1664
- let e = this._myIndex.records[this._myIndex.records.length - 1], t = st({
1665
- isCaseSensitive: this.options.isCaseSensitive,
1666
- ignoreDiacritics: this.options.ignoreDiacritics
1667
- });
1668
- lt(this._invertedIndex, e, this._myIndex.keys.length, t);
1669
- }
1670
- }
1671
- remove(e = () => !1) {
1672
- let t = [], n = [];
1673
- 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));
1674
- if (n.length) {
1675
- if (this._invertedIndex) for (let e of n) ut(this._invertedIndex, e);
1676
- for (let e = n.length - 1; e >= 0; --e) this._docs.splice(n[e], 1);
1677
- this._myIndex.removeAll(n);
1678
- }
1679
- return t;
1680
- }
1681
- removeAt(e) {
1682
- this._invertedIndex && ut(this._invertedIndex, e);
1683
- let t = this._docs.splice(e, 1)[0];
1684
- return this._myIndex.removeAt(e), t;
1685
- }
1686
- getIndex() {
1687
- return this._myIndex;
1688
- }
1689
- search(e, t) {
1690
- let { limit: n = -1 } = t || {}, { includeMatches: r, includeScore: i, shouldSort: a, sortFn: o, ignoreFieldNorm: s } = this.options;
1691
- if (R(e) && !e.trim()) {
1692
- let e = this._docs.map((e, t) => ({
1693
- item: e,
1694
- refIndex: t
1695
- }));
1696
- return z(n) && n > -1 && (e = e.slice(0, n)), e;
1697
- }
1698
- let c = z(n) && n > 0 && R(e), l;
1699
- if (c) {
1700
- let t = new nt(n);
1701
- R(this._docs[0]) ? this._searchStringList(e, {
1702
- heap: t,
1703
- ignoreFieldNorm: s
1704
- }) : this._searchObjectList(e, {
1705
- heap: t,
1706
- ignoreFieldNorm: s
1707
- }), l = t.extractSorted(o);
1708
- } else l = R(e) ? R(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e), tt(l, { ignoreFieldNorm: s }), a && l.sort(o), z(n) && n > -1 && (l = l.slice(0, n));
1709
- return at(l, this._docs, {
1710
- includeMatches: r,
1711
- includeScore: i
1712
- });
1713
- }
1714
- _searchStringList(e, { heap: t, ignoreFieldNorm: n } = {}) {
1715
- let r = this._getSearcher(e), { records: i } = this._myIndex, a = t ? null : [];
1716
- return i.forEach(({ v: e, i, n: o }) => {
1717
- if (!H(e)) return;
1718
- let { isMatch: s, score: c, indices: l } = r.searchIn(e);
1719
- if (s) {
1720
- let r = {
1721
- item: e,
1722
- idx: i,
1723
- matches: [{
1724
- score: c,
1725
- value: e,
1726
- norm: o,
1727
- indices: l
1728
- }]
1729
- };
1730
- t ? (r.score = et(r.matches, { ignoreFieldNorm: n }), t.shouldInsert(r.score) && t.insert(r)) : a.push(r);
1731
- }
1732
- }), a;
1733
- }
1734
- _searchLogical(e) {
1735
- let t = $e(e, this.options), n = (e, t, r) => {
1736
- if (!("children" in e)) {
1737
- let { keyId: n, searcher: i } = e, a;
1738
- return n === null ? (a = [], this._myIndex.keys.forEach((e, n) => {
1739
- a.push(...this._findMatches({
1740
- key: e,
1741
- value: t[n],
1742
- searcher: i
1743
- }));
1744
- })) : a = this._findMatches({
1745
- key: this._keyStore.get(n),
1746
- value: this._myIndex.getValueForItemAtKeyId(t, n),
1747
- searcher: i
1748
- }), a && a.length ? [{
1749
- idx: r,
1750
- item: t,
1751
- matches: a
1752
- }] : [];
1753
- }
1754
- let { children: i, operator: a } = e, o = [];
1755
- for (let e = 0, s = i.length; e < s; e += 1) {
1756
- let s = i[e], c = n(s, t, r);
1757
- if (c.length) o.push(...c);
1758
- else if (a === qe.AND) return [];
1759
- }
1760
- return o;
1761
- }, r = this._myIndex.records, i = /* @__PURE__ */ new Map(), a = [];
1762
- return r.forEach(({ $: e, i: r }) => {
1763
- if (H(e)) {
1764
- let o = n(t, e, r);
1765
- o.length && (i.has(r) || (i.set(r, {
1766
- idx: r,
1767
- item: e,
1768
- matches: []
1769
- }), a.push(i.get(r))), o.forEach(({ matches: e }) => {
1770
- i.get(r).matches.push(...e);
1771
- }));
1772
- }
1773
- }), a;
1774
- }
1775
- _searchObjectList(e, { heap: t, ignoreFieldNorm: n } = {}) {
1776
- let r = this._getSearcher(e), { keys: i, records: a } = this._myIndex, o = t ? null : [];
1777
- return a.forEach(({ $: e, i: a }) => {
1778
- if (!H(e)) return;
1779
- let s = [], c = !1, l = !1;
1780
- if (i.forEach((t, n) => {
1781
- let i = this._findMatches({
1782
- key: t,
1783
- value: e[n],
1784
- searcher: r
1785
- });
1786
- i.length ? (s.push(...i), i[0].hasInverse && (l = !0)) : c = !0;
1787
- }), !(l && c) && s.length) {
1788
- let r = {
1789
- idx: a,
1790
- item: e,
1791
- matches: s
1792
- };
1793
- t ? (r.score = et(r.matches, { ignoreFieldNorm: n }), t.shouldInsert(r.score) && t.insert(r)) : o.push(r);
1794
- }
1795
- }), o;
1796
- }
1797
- _findMatches({ key: e, value: t, searcher: n }) {
1798
- if (!H(t)) return [];
1799
- let r = [];
1800
- if (F(t)) t.forEach(({ v: t, i, n: a }) => {
1801
- if (!H(t)) return;
1802
- let { isMatch: o, score: s, indices: c, hasInverse: l } = n.searchIn(t);
1803
- o && r.push({
1804
- score: s,
1805
- key: e,
1806
- value: t,
1807
- idx: i,
1808
- norm: a,
1809
- indices: c,
1810
- hasInverse: l
1811
- });
1812
- });
1813
- else {
1814
- let { v: i, n: a } = t, { isMatch: o, score: s, indices: c, hasInverse: l } = n.searchIn(i);
1815
- o && r.push({
1816
- score: s,
1817
- key: e,
1818
- value: i,
1819
- norm: a,
1820
- indices: c,
1821
- hasInverse: l
1822
- });
1823
- }
1824
- return r;
1825
- }
1826
- }, dt = class {
1827
- static condition(e, t) {
1828
- return t.useTokenSearch;
1829
- }
1830
- constructor(e, t) {
1831
- this.options = t, this.analyzer = st({
1832
- isCaseSensitive: t.isCaseSensitive,
1833
- ignoreDiacritics: t.ignoreDiacritics
1834
- });
1835
- let n = this.analyzer.tokenize(e), { df: r, fieldCount: i } = t._invertedIndex;
1836
- this.termSearchers = [], this.idfWeights = [];
1837
- for (let e of n) {
1838
- this.termSearchers.push(new Ee(e, {
1839
- location: t.location,
1840
- threshold: t.threshold,
1841
- distance: t.distance,
1842
- includeMatches: t.includeMatches,
1843
- findAllMatches: t.findAllMatches,
1844
- minMatchCharLength: t.minMatchCharLength,
1845
- isCaseSensitive: t.isCaseSensitive,
1846
- ignoreDiacritics: t.ignoreDiacritics,
1847
- ignoreLocation: !0
1848
- }));
1849
- let n = r.get(e) || 0, a = Math.log(1 + (i - n + .5) / (n + .5));
1850
- this.idfWeights.push(a);
1851
- }
1852
- }
1853
- searchIn(e) {
1854
- if (!this.termSearchers.length) return {
1855
- isMatch: !1,
1856
- score: 1
1857
- };
1858
- let t = [], n = 0, r = 0, i = 0;
1859
- for (let a = 0; a < this.termSearchers.length; a++) {
1860
- let o = this.termSearchers[a].searchIn(e), s = this.idfWeights[a];
1861
- r += s, o.isMatch && (i++, n += s * (1 - o.score), o.indices && t.push(...o.indices));
1862
- }
1863
- if (i === 0) return {
1864
- isMatch: !1,
1865
- score: 1
1866
- };
1867
- let a = r > 0 ? 1 - n / r : 0, o = {
1868
- isMatch: !0,
1869
- score: Math.max(.001, a)
1870
- };
1871
- return this.options.includeMatches && t.length && (o.indices = Ce(t)), o;
1872
- }
1873
- };
1874
- Q.version = "7.3.0", Q.createIndex = ve, Q.parseIndex = ye, Q.config = J, Q.match = function(e, t, n) {
1875
- return Ke(e, {
1876
- ...J,
1877
- ...n
1878
- }).searchIn(t);
1879
- }, Q.parseQuery = $e, Ge(Ue), Ge(dt), Q.use = function(...e) {
1880
- e.forEach((e) => Ge(e));
1881
- };
1882
- //#endregion
1883
- //#region src/hooks/useCommands.js
1884
- var ft = (e, t = .4) => {
721
+ }, L = (e, t = .4) => {
1885
722
  let n = i(() => e ? Object.entries(e).reduce((e, [t, n]) => ({
1886
723
  ...e,
1887
724
  [t.toLowerCase()]: n
1888
- }), {}) : {}, [e]), r = i(() => Object.keys(n), [n]), a = i(() => r.some((e) => e.includes(" ")), [r]), o = i(() => a ? new Q(r, {
1889
- includeScore: !0,
1890
- ignoreLocation: !0
1891
- }) : null, [a, r]);
1892
- return (e) => {
1893
- if (!r.length) return null;
1894
- if (!a) {
725
+ }), {}) : {}, [e]), o = i(() => Object.keys(n), [n]), s = i(() => o.some((e) => e.includes(" ")), [o]), c = a(null);
726
+ return r(() => {
727
+ if (!s) {
728
+ c.current = null;
729
+ return;
730
+ }
731
+ import("fuse.js").then((e) => {
732
+ c.current = new (e.default ?? e)(o, {
733
+ includeScore: !0,
734
+ ignoreLocation: !0
735
+ });
736
+ }).catch(() => {
737
+ process.env.NODE_ENV !== "production" && console.warn("[react-vocal] fuse.js is not installed. Phrase command keys will fall back to exact matching. Install fuse.js to enable fuzzy matching: npm install fuse.js");
738
+ });
739
+ }, [s, o]), (e) => {
740
+ if (!o.length) return null;
741
+ if (!s) {
1895
742
  let t = e.trim().split(/\s+/), r = t.length > 1 ? t : [e.trim()];
1896
743
  for (let e of r) {
1897
744
  let t = e.toLowerCase();
@@ -1899,10 +746,17 @@ var ft = (e, t = .4) => {
1899
746
  }
1900
747
  return null;
1901
748
  }
1902
- let i = o.search(e).filter((e) => e.score < t);
1903
- return i?.length ? n[i[0].item.toLowerCase()]?.(e) : null;
749
+ let r = c.current;
750
+ if (r) {
751
+ let i = r.search(e).filter((e) => e.score < t);
752
+ if (i?.length) return n[i[0].item.toLowerCase()]?.(e);
753
+ } else {
754
+ let t = e.toLowerCase(), r = o.find((e) => t.includes(e) || e.includes(t));
755
+ if (r) return n[r]?.(e);
756
+ }
757
+ return null;
1904
758
  };
1905
- }, pt = /* @__PURE__ */ s(((e) => {
759
+ }, R = /* @__PURE__ */ s(((e) => {
1906
760
  var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
1907
761
  function r(e, n, r) {
1908
762
  var i = null;
@@ -1917,7 +771,7 @@ var ft = (e, t = .4) => {
1917
771
  };
1918
772
  }
1919
773
  e.Fragment = n, e.jsx = r, e.jsxs = r;
1920
- })), mt = /* @__PURE__ */ s(((e) => {
774
+ })), z = /* @__PURE__ */ s(((e) => {
1921
775
  process.env.NODE_ENV !== "production" && (function() {
1922
776
  function t(e) {
1923
777
  if (e == null) return null;
@@ -1989,7 +843,7 @@ var ft = (e, t = .4) => {
1989
843
  }
1990
844
  function l(e, t) {
1991
845
  function n() {
1992
- ee || (ee = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
846
+ P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
1993
847
  }
1994
848
  n.isReactWarning = !0, Object.defineProperty(e, "key", {
1995
849
  get: n,
@@ -1998,7 +852,7 @@ var ft = (e, t = .4) => {
1998
852
  }
1999
853
  function u() {
2000
854
  var e = t(this.type);
2001
- return P[e] || (P[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
855
+ return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
2002
856
  }
2003
857
  function d(e, t, n, r, i, a) {
2004
858
  var o = n.ref;
@@ -2048,7 +902,7 @@ var ft = (e, t = .4) => {
2048
902
  var m = Object.keys(n).filter(function(e) {
2049
903
  return e !== "key";
2050
904
  });
2051
- o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", I[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), I[f + o] = !0);
905
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), R[f + o] = !0);
2052
906
  }
2053
907
  if (f = null, i !== void 0 && (r(i), f = "" + i), s(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
2054
908
  else i = n;
@@ -2066,39 +920,39 @@ var ft = (e, t = .4) => {
2066
920
  h = { react_stack_bottom_frame: function(e) {
2067
921
  return e();
2068
922
  } };
2069
- var ee, P = {}, te = h.react_stack_bottom_frame.bind(h, o)(), F = N(i(o)), I = {};
923
+ var P, F = {}, I = h.react_stack_bottom_frame.bind(h, o)(), L = N(i(o)), R = {};
2070
924
  e.Fragment = v, e.jsx = function(e, t, n) {
2071
925
  var r = 1e4 > A.recentlyCreatedOwnerStacks++;
2072
- return f(e, t, n, !1, r ? Error("react-stack-top-frame") : te, r ? N(i(e)) : F);
926
+ return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
2073
927
  }, e.jsxs = function(e, t, n) {
2074
928
  var r = 1e4 > A.recentlyCreatedOwnerStacks++;
2075
- return f(e, t, n, !0, r ? Error("react-stack-top-frame") : te, r ? N(i(e)) : F);
929
+ return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
2076
930
  };
2077
931
  })();
2078
- })), $ = (/* @__PURE__ */ s(((e, t) => {
2079
- process.env.NODE_ENV === "production" ? t.exports = pt() : t.exports = mt();
2080
- })))(), ht = ({ color: e = "black", activeColor: t = "red", isActive: n = !1 }) => /* @__PURE__ */ (0, $.jsx)("svg", {
932
+ })), B = (/* @__PURE__ */ s(((e, t) => {
933
+ process.env.NODE_ENV === "production" ? t.exports = R() : t.exports = z();
934
+ })))(), ee = ({ color: e = "black", activeColor: t = "red", isActive: n = !1 }) => /* @__PURE__ */ (0, B.jsx)("svg", {
2081
935
  "data-testid": "__icon-root__",
2082
936
  xmlns: "http://www.w3.org/2000/svg",
2083
937
  width: "100%",
2084
938
  height: "100%",
2085
939
  viewBox: "0 0 24 24",
2086
- children: /* @__PURE__ */ (0, $.jsxs)("g", { children: [/* @__PURE__ */ (0, $.jsx)("path", {
940
+ children: /* @__PURE__ */ (0, B.jsxs)("g", { children: [/* @__PURE__ */ (0, B.jsx)("path", {
2087
941
  "data-testid": "__icon-path__",
2088
942
  fill: e,
2089
943
  d: "M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"
2090
- }), n && /* @__PURE__ */ (0, $.jsx)("circle", {
944
+ }), n && /* @__PURE__ */ (0, B.jsx)("circle", {
2091
945
  "data-testid": "__icon-active__",
2092
946
  fill: t,
2093
947
  cx: "16",
2094
948
  cy: "4",
2095
949
  r: "4"
2096
950
  })] })
2097
- }), gt = (e, t) => {
951
+ }), te = (e, t) => {
2098
952
  for (let { alternatives: n } of e) for (let e of n) if (t(e) !== null) return;
2099
- }, _t = ({ children: r, commands: s = null, lang: c = "en-US", grammars: l = null, timeout: u = 3e3, precision: d = .4, maxAlternatives: f = 1, ariaLabel: p = "start recognition", style: m = null, className: h = null, outlineStyle: g = "2px solid", onStart: _ = null, onEnd: v = null, onSpeechStart: y = null, onSpeechEnd: b = null, onResult: x = null, onError: S = null, onNoMatch: C = null, __rsInstance: w }) => {
2100
- let T = a(null), [E, D] = o(!1), [, { start: O, stop: k, subscribe: A, unsubscribe: j }] = P(c, l, f, w), M = ft(s, d), F = a({});
2101
- F.current = {
953
+ }, V = ({ children: r, commands: s = null, lang: c = "en-US", grammars: l = null, timeout: u = 3e3, precision: d = .4, maxAlternatives: f = 1, ariaLabel: p = "start recognition", style: m = null, className: h = null, outlineStyle: g = "2px solid", onStart: _ = null, onEnd: v = null, onSpeechStart: y = null, onSpeechEnd: b = null, onResult: x = null, onError: S = null, onNoMatch: C = null, __rsInstance: w }) => {
954
+ let T = a(null), [E, D] = o(!1), [, { start: O, stop: k, subscribe: A, unsubscribe: j }] = F(c, l, f, w), M = L(s, d), R = a({});
955
+ R.current = {
2102
956
  onStart: _,
2103
957
  onEnd: v,
2104
958
  onSpeechStart: y,
@@ -2107,21 +961,21 @@ var ft = (e, t = .4) => {
2107
961
  onError: S,
2108
962
  onNoMatch: C
2109
963
  };
2110
- let I = a(M);
2111
- I.current = M;
2112
- let L = a(null), R = a(null), [z, B] = te(n(() => R.current?.(), []), u), V = n(() => {
964
+ let z = a(M);
965
+ z.current = M;
966
+ let V = a(null), H = a(null), [U, W] = I(n(() => H.current?.(), []), u), G = n(() => {
2113
967
  try {
2114
968
  D(!1), k();
2115
969
  } catch (e) {
2116
- F.current.onError?.(e), L.current?.();
970
+ R.current.onError?.(e), V.current?.();
2117
971
  }
2118
- }, [k]), ne = n((e) => {
2119
- z(), F.current.onStart?.(e);
2120
- }, [z]), H = n((e) => {
2121
- B(), F.current.onSpeechStart?.(e);
2122
- }, [B]), U = n((e) => {
2123
- z(), F.current.onSpeechEnd?.(e);
2124
- }, [z]), W = n((e) => {
972
+ }, [k]), K = n((e) => {
973
+ U(), R.current.onStart?.(e);
974
+ }, [U]), q = n((e) => {
975
+ W(), R.current.onSpeechStart?.(e);
976
+ }, [W]), J = n((e) => {
977
+ U(), R.current.onSpeechEnd?.(e);
978
+ }, [U]), Y = n((e) => {
2125
979
  let t = Array.from(e?.results ?? [], (e) => {
2126
980
  let t = {
2127
981
  confidence: -Infinity,
@@ -2136,55 +990,55 @@ var ft = (e, t = .4) => {
2136
990
  alternatives: n
2137
991
  };
2138
992
  }), n = t.map((e) => e.best).join("");
2139
- B(), V(), gt(t, I.current), F.current.onResult?.(n, e);
2140
- }, [B, V]), G = n((e) => {
2141
- V(), F.current.onError?.(e);
2142
- }, [V]), re = n((e) => {
2143
- B(), V(), F.current.onNoMatch?.(e);
2144
- }, [B, V]), K = n((e) => {
2145
- B();
993
+ W(), G(), te(t, z.current), R.current.onResult?.(n, e);
994
+ }, [W, G]), X = n((e) => {
995
+ G(), R.current.onError?.(e);
996
+ }, [G]), ne = n((e) => {
997
+ W(), G(), R.current.onNoMatch?.(e);
998
+ }, [W, G]), Z = n((e) => {
999
+ W();
2146
1000
  try {
2147
- V(), L.current?.();
1001
+ G(), V.current?.();
2148
1002
  } finally {
2149
- F.current.onEnd?.(e);
1003
+ R.current.onEnd?.(e);
2150
1004
  }
2151
- }, [B, V]);
2152
- R.current = K;
2153
- let q = i(() => ({
2154
- start: ne,
2155
- end: K,
2156
- speechstart: H,
2157
- speechend: U,
2158
- result: W,
2159
- error: G,
2160
- nomatch: re
1005
+ }, [W, G]);
1006
+ H.current = Z;
1007
+ let Q = i(() => ({
1008
+ start: K,
1009
+ end: Z,
1010
+ speechstart: q,
1011
+ speechend: J,
1012
+ result: Y,
1013
+ error: X,
1014
+ nomatch: ne
2161
1015
  }), [
2162
- ne,
2163
1016
  K,
2164
- H,
2165
- U,
2166
- W,
2167
- G,
2168
- re
1017
+ Z,
1018
+ q,
1019
+ J,
1020
+ Y,
1021
+ X,
1022
+ ne
2169
1023
  ]);
2170
- L.current = () => Object.entries(q).forEach(([e, t]) => j?.(e, t));
2171
- let ie = n(() => {
1024
+ V.current = () => Object.entries(Q).forEach(([e, t]) => j?.(e, t));
1025
+ let $ = n(() => {
2172
1026
  try {
2173
- D(!0), Object.entries(q).forEach(([e, t]) => A(e, t)), O();
1027
+ D(!0), Object.entries(Q).forEach(([e, t]) => A(e, t)), O();
2174
1028
  } catch (e) {
2175
- G(e);
1029
+ X(e);
2176
1030
  }
2177
1031
  }, [
2178
- q,
1032
+ Q,
2179
1033
  A,
2180
1034
  O,
2181
- G
2182
- ]), ae = () => {
1035
+ X
1036
+ ]), re = () => {
2183
1037
  !h && g && (T.current.style.outline = g);
2184
- }, oe = () => {
1038
+ }, ie = () => {
2185
1039
  !h && g && (T.current.style.outline = "none");
2186
1040
  };
2187
- return N.isSupported ? ee(r) ? r(ie, V, E) : t(r) ? e(r, { ...!E && { onClick: ie } }) : /* @__PURE__ */ (0, $.jsx)("button", {
1041
+ return N.isSupported ? P(r) ? r($, G, E) : t(r) ? e(r, { ...!E && { onClick: $ } }) : /* @__PURE__ */ (0, B.jsx)("button", {
2188
1042
  "data-testid": "__vocal-root__",
2189
1043
  ref: T,
2190
1044
  role: "button",
@@ -2199,16 +1053,16 @@ var ft = (e, t = .4) => {
2199
1053
  ...m
2200
1054
  },
2201
1055
  className: h,
2202
- onFocus: ae,
2203
- onBlur: oe,
2204
- onClick: ie,
2205
- children: /* @__PURE__ */ (0, $.jsx)(ht, {
1056
+ onFocus: re,
1057
+ onBlur: ie,
1058
+ onClick: $,
1059
+ children: /* @__PURE__ */ (0, B.jsx)(ee, {
2206
1060
  isActive: E,
2207
1061
  color: "#aaa"
2208
1062
  })
2209
1063
  }) : null;
2210
- }, vt = N.isSupported, yt = _t;
1064
+ }, H = N.isSupported, U = V;
2211
1065
  //#endregion
2212
- export { yt as default, vt as isSupported, P as useVocal };
1066
+ export { U as default, H as isSupported, F as useVocal };
2213
1067
 
2214
1068
  //# sourceMappingURL=index.es.js.map