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

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -1
  3. package/dist/index.es.js +99 -78
  4. package/dist/index.js +2 -2
  5. package/dist/index.umd.js +2 -2
  6. package/package.json +7 -1
  7. package/.github/workflows/publish.yml +0 -32
  8. package/.husky/commit-msg +0 -1
  9. package/.husky/pre-commit +0 -1
  10. package/.prettierignore +0 -3
  11. package/.prettierrc +0 -29
  12. package/CLAUDE.md +0 -59
  13. package/assets/icon-idle.png +0 -0
  14. package/assets/icon-listening.png +0 -0
  15. package/assets/microphone.png +0 -0
  16. package/assets/react-vocal.png +0 -0
  17. package/commitlint.config.js +0 -7
  18. package/dev/index.html +0 -24
  19. package/dev/package.json +0 -18
  20. package/dev/public/index.html +0 -24
  21. package/dev/src/index.jsx +0 -58
  22. package/dev/vite.config.js +0 -10
  23. package/dev/yarn.lock +0 -325
  24. package/dist/index.es.js.map +0 -1
  25. package/dist/index.js.map +0 -1
  26. package/dist/index.umd.js.map +0 -1
  27. package/src/components/Icon.jsx +0 -24
  28. package/src/components/Vocal.jsx +0 -233
  29. package/src/components/__tests__/Icon.test.jsx +0 -38
  30. package/src/components/__tests__/Vocal.test.jsx +0 -611
  31. package/src/components/__tests__/VocalWithMockedUseVocal.test.jsx +0 -38
  32. package/src/components/__tests__/__snapshots__/Icon.test.jsx.snap +0 -21
  33. package/src/components/__tests__/__snapshots__/Vocal.test.jsx.snap +0 -28
  34. package/src/hooks/__tests__/useCommands.test.js +0 -115
  35. package/src/hooks/__tests__/useTimeout.test.js +0 -69
  36. package/src/hooks/__tests__/useVocal.test.js +0 -202
  37. package/src/hooks/useCommands.js +0 -75
  38. package/src/hooks/useTimeout.js +0 -21
  39. package/src/hooks/useVocal.js +0 -56
  40. package/src/index.js +0 -7
  41. package/vite.config.js +0 -36
  42. package/vitest.setup.js +0 -77
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [2.0.0-beta.7](https://github.com/untemps/react-vocal/compare/v2.0.0-beta.6...v2.0.0-beta.7) (2026-05-13)
2
+
3
+ # [2.0.0-beta.6](https://github.com/untemps/react-vocal/compare/v2.0.0-beta.5...v2.0.0-beta.6) (2026-05-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * Add continuous session support ([#118](https://github.com/untemps/react-vocal/issues/118)) ([690ba61](https://github.com/untemps/react-vocal/commit/690ba617746aa28499d7ea2d48751453a652ff5e))
9
+
1
10
  # [2.0.0-beta.5](https://github.com/untemps/react-vocal/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2026-05-11)
2
11
 
3
12
 
package/README.md CHANGED
@@ -224,6 +224,8 @@ fuse.js is an optional peer dependency — install it separately to enable fuzzy
224
224
  | timeout | number | 3000 | Time in ms to wait before discarding the recognition |
225
225
  | precision | number | 0.4 | Fuse.js score threshold for **phrase** command keys only (lower = stricter). Single-word commands always use exact lookup. |
226
226
  | maxAlternatives | number | 1 | Maximum number of recognition alternatives per segment. Setting this to 3–5 lets the engine surface the correct word as a secondary transcript, which is useful for handling homophones (e.g. _vert_ / _verre_ in French). |
227
+ | continuous | boolean | false | Keep the recognition session open after each result. The session accumulates transcript across segments and stops when the button is clicked again or `silenceTimeout` expires. Commands are not evaluated in continuous mode. |
228
+ | silenceTimeout | number | null | When `continuous` is true, automatically stop the session after this many ms of inactivity following the last recognized result. `null` or `0` disables auto-stop (button click required). |
227
229
  | style | object | null | Styles of the root element if className is not specified |
228
230
  | className | string | null | Class of the root element |
229
231
  | ariaLabel | string | 'start recognition' | Accessible label for the default button |
@@ -298,7 +300,7 @@ const App = () => {
298
300
  #### Signature
299
301
 
300
302
  ```
301
- useVocal(lang, grammars, maxAlternatives)
303
+ useVocal(lang, grammars, maxAlternatives, continuous)
302
304
  ```
303
305
 
304
306
  | Args | Type | Default | Description |
@@ -306,6 +308,7 @@ useVocal(lang, grammars, maxAlternatives)
306
308
  | lang | string | 'en-US' | Language understood by the recognition [BCP 47 language tag](https://tools.ietf.org/html/bcp47) |
307
309
  | grammars | SpeechGrammarList | null | Grammars understood by the recognition [JSpeech Grammar Format](https://www.w3.org/TR/jsgf/) |
308
310
  | maxAlternatives | number | 1 | Maximum number of recognition alternatives per segment |
311
+ | continuous | boolean | false | Keep the recognition session open after each result |
309
312
 
310
313
  ---
311
314
 
package/dist/index.es.js CHANGED
@@ -672,39 +672,41 @@ x(N, "defaultOptions", {
672
672
  });
673
673
  //#endregion
674
674
  //#region node_modules/@untemps/utils/dist/function/isFunction.js
675
- var P = (e) => typeof e == "function", F = (e = "en-US", t = null, i = 1, o = null) => {
676
- let s = a(null);
675
+ var P = (e) => typeof e == "function", F = (e = "en-US", t = null, i = 1, o = !1, s = null) => {
676
+ let c = a(null);
677
677
  return r(() => {
678
- if (N.isSupported) return s.current = o || new N({
678
+ if (N.isSupported) return c.current = s || new N({
679
679
  lang: e,
680
680
  grammars: t,
681
- maxAlternatives: i
681
+ maxAlternatives: i,
682
+ continuous: o
682
683
  }), () => {
683
- s.current.abort(), s.current.cleanup();
684
+ c.current.abort(), c.current.cleanup();
684
685
  };
685
686
  }, [
686
687
  e,
687
688
  t,
688
689
  i,
689
- o
690
- ]), [s, {
690
+ o,
691
+ s
692
+ ]), [c, {
691
693
  start: n(() => {
692
- s.current && s.current.start();
694
+ c.current && c.current.start();
693
695
  }, []),
694
696
  stop: n(() => {
695
- s.current && s.current.stop();
697
+ c.current && c.current.stop();
696
698
  }, []),
697
699
  abort: n(() => {
698
- s.current && s.current.abort();
700
+ c.current && c.current.abort();
699
701
  }, []),
700
702
  subscribe: n((e, t) => {
701
- s.current && s.current.addEventListener(e, t);
703
+ c.current && c.current.addEventListener(e, t);
702
704
  }, []),
703
705
  unsubscribe: n((e, t) => {
704
- s.current && s.current.removeEventListener(e, t);
706
+ c.current && c.current.removeEventListener(e, t);
705
707
  }, []),
706
708
  clean: n(() => {
707
- s.current && s.current.cleanup();
709
+ c.current && c.current.cleanup();
708
710
  }, [])
709
711
  }];
710
712
  }, I = (e, t = 0) => {
@@ -742,17 +744,20 @@ var P = (e) => typeof e == "function", F = (e = "en-US", t = null, i = 1, o = nu
742
744
  let t = e.trim().split(/\s+/), r = t.length > 1 ? t : [e.trim()];
743
745
  for (let e of r) {
744
746
  let t = e.toLowerCase();
745
- if (t in n) return n[t]?.(e);
747
+ if (t in n) return n[t]?.(e, t);
746
748
  }
747
749
  return null;
748
750
  }
749
751
  let r = c.current;
750
752
  if (r) {
751
753
  let i = r.search(e).filter((e) => e.score < t);
752
- if (i?.length) return n[i[0].item.toLowerCase()]?.(e);
754
+ if (i?.length) {
755
+ let t = i[0].item.toLowerCase();
756
+ return n[t]?.(e, t);
757
+ }
753
758
  } else {
754
759
  let t = e.toLowerCase(), r = o.find((e) => t.includes(e) || e.includes(t));
755
- if (r) return n[r]?.(e);
760
+ if (r) return n[r]?.(e, r);
756
761
  }
757
762
  return null;
758
763
  };
@@ -950,32 +955,39 @@ var P = (e) => typeof e == "function", F = (e = "en-US", t = null, i = 1, o = nu
950
955
  })] })
951
956
  }), te = (e, t) => {
952
957
  for (let { alternatives: n } of e) for (let e of n) if (t(e) !== null) return;
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 = {
956
- onStart: _,
957
- onEnd: v,
958
- onSpeechStart: y,
959
- onSpeechEnd: b,
960
- onResult: x,
961
- onError: S,
962
- onNoMatch: C
958
+ }, V = ({ children: r, commands: s = null, lang: c = "en-US", grammars: l = null, timeout: u = 3e3, silenceTimeout: d = null, precision: f = .4, maxAlternatives: p = 1, continuous: m = !1, ariaLabel: h = "start recognition", style: g = null, className: _ = null, outlineStyle: v = "2px solid", onStart: y = null, onEnd: b = null, onSpeechStart: x = null, onSpeechEnd: S = null, onResult: C = null, onError: w = null, onNoMatch: T = null, __rsInstance: E }) => {
959
+ let D = a(null), [O, k] = o(!1), [, { start: A, stop: j, subscribe: M, unsubscribe: R }] = F(c, l, p, m, E), z = L(s, f), V = a({});
960
+ V.current = {
961
+ onStart: y,
962
+ onEnd: b,
963
+ onSpeechStart: x,
964
+ onSpeechEnd: S,
965
+ onResult: C,
966
+ onError: w,
967
+ onNoMatch: T
963
968
  };
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(() => {
969
+ let H = a(m);
970
+ H.current = m;
971
+ let U = a({
972
+ transcript: "",
973
+ event: null
974
+ }), W = a(z);
975
+ W.current = z;
976
+ let G = a(null), ne = a(null), re = a(d);
977
+ re.current = d;
978
+ let ie = n(() => ne.current?.(), []), [K, q] = I(ie, u), [ae, J] = I(ie, d ?? 0), Y = n(() => {
967
979
  try {
968
- D(!1), k();
980
+ k(!1), j();
969
981
  } catch (e) {
970
- R.current.onError?.(e), V.current?.();
982
+ V.current.onError?.(e), G.current?.();
971
983
  }
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) => {
984
+ }, [j]), oe = n((e) => {
985
+ K(), V.current.onStart?.(e);
986
+ }, [K]), se = n((e) => {
987
+ q(), V.current.onSpeechStart?.(e);
988
+ }, [q]), ce = n((e) => {
989
+ K(), V.current.onSpeechEnd?.(e);
990
+ }, [K]), le = n((e) => {
979
991
  let t = Array.from(e?.results ?? [], (e) => {
980
992
  let t = {
981
993
  confidence: -Infinity,
@@ -990,74 +1002,83 @@ var P = (e) => typeof e == "function", F = (e = "en-US", t = null, i = 1, o = nu
990
1002
  alternatives: n
991
1003
  };
992
1004
  }), n = t.map((e) => e.best).join("");
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();
1005
+ q(), H.current ? (U.current.transcript = n, U.current.event = e, re.current > 0 && ae()) : (te(t, W.current), Y(), V.current.onResult?.(n, e));
1006
+ }, [
1007
+ q,
1008
+ ae,
1009
+ Y
1010
+ ]), X = n((e) => {
1011
+ Y(), V.current.onError?.(e);
1012
+ }, [Y]), ue = n((e) => {
1013
+ q(), Y(), V.current.onNoMatch?.(e);
1014
+ }, [q, Y]), Z = n((e) => {
1015
+ q(), J();
1000
1016
  try {
1001
- G(), V.current?.();
1017
+ Y(), G.current?.(), H.current && U.current.transcript && (V.current.onResult?.(U.current.transcript, U.current.event), U.current.transcript = "", U.current.event = null);
1002
1018
  } finally {
1003
- R.current.onEnd?.(e);
1019
+ V.current.onEnd?.(e);
1004
1020
  }
1005
- }, [W, G]);
1006
- H.current = Z;
1021
+ }, [
1022
+ q,
1023
+ J,
1024
+ Y
1025
+ ]);
1026
+ ne.current = Z;
1007
1027
  let Q = i(() => ({
1008
- start: K,
1028
+ start: oe,
1009
1029
  end: Z,
1010
- speechstart: q,
1011
- speechend: J,
1012
- result: Y,
1030
+ speechstart: se,
1031
+ speechend: ce,
1032
+ result: le,
1013
1033
  error: X,
1014
- nomatch: ne
1034
+ nomatch: ue
1015
1035
  }), [
1016
- K,
1036
+ oe,
1017
1037
  Z,
1018
- q,
1019
- J,
1020
- Y,
1038
+ se,
1039
+ ce,
1040
+ le,
1021
1041
  X,
1022
- ne
1042
+ ue
1023
1043
  ]);
1024
- V.current = () => Object.entries(Q).forEach(([e, t]) => j?.(e, t));
1044
+ G.current = () => Object.entries(Q).forEach(([e, t]) => R?.(e, t));
1025
1045
  let $ = n(() => {
1026
1046
  try {
1027
- D(!0), Object.entries(Q).forEach(([e, t]) => A(e, t)), O();
1047
+ U.current.transcript = "", U.current.event = null, J(), k(!0), Object.entries(Q).forEach(([e, t]) => M(e, t)), A();
1028
1048
  } catch (e) {
1029
1049
  X(e);
1030
1050
  }
1031
1051
  }, [
1032
1052
  Q,
1053
+ M,
1033
1054
  A,
1034
- O,
1055
+ J,
1035
1056
  X
1036
- ]), re = () => {
1037
- !h && g && (T.current.style.outline = g);
1038
- }, ie = () => {
1039
- !h && g && (T.current.style.outline = "none");
1057
+ ]), de = () => {
1058
+ !_ && v && (D.current.style.outline = v);
1059
+ }, fe = () => {
1060
+ !_ && v && (D.current.style.outline = "none");
1040
1061
  };
1041
- return N.isSupported ? P(r) ? r($, G, E) : t(r) ? e(r, { ...!E && { onClick: $ } }) : /* @__PURE__ */ (0, B.jsx)("button", {
1062
+ return N.isSupported ? P(r) ? r($, Y, O) : t(r) ? e(r, { ...!O && { onClick: $ } }) : /* @__PURE__ */ (0, B.jsx)("button", {
1042
1063
  "data-testid": "__vocal-root__",
1043
- ref: T,
1044
- role: "button",
1045
- "aria-label": p,
1046
- style: h ? null : {
1064
+ ref: D,
1065
+ "aria-label": h,
1066
+ "aria-pressed": O,
1067
+ style: _ ? null : {
1047
1068
  width: 24,
1048
1069
  height: 24,
1049
1070
  backgroundColor: "transparent",
1050
1071
  border: "none",
1051
1072
  padding: 0,
1052
- cursor: E ? "default" : "pointer",
1053
- ...m
1073
+ cursor: !m && O ? "default" : "pointer",
1074
+ ...g
1054
1075
  },
1055
- className: h,
1056
- onFocus: re,
1057
- onBlur: ie,
1058
- onClick: $,
1076
+ className: _,
1077
+ onFocus: de,
1078
+ onBlur: fe,
1079
+ onClick: O ? Y : $,
1059
1080
  children: /* @__PURE__ */ (0, B.jsx)(ee, {
1060
- isActive: E,
1081
+ isActive: O,
1061
1082
  color: "#aaa"
1062
1083
  })
1063
1084
  }) : null;
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`react`);l=c(l);var u=function(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw Error(`Dynamic requires are not currently supported by @rollup/plugin-commonjs`)}(t==null&&n.path)}},n.exports),n.exports}((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r=typeof Symbol==`function`?Symbol:{},i=r.iterator||`@@iterator`,a=r.asyncIterator||`@@asyncIterator`,o=r.toStringTag||`@@toStringTag`;function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},``)}catch{s=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype);return a._invoke=function(e,t,n){var r=`suspendedStart`;return function(i,a){if(r===`executing`)throw Error(`Generator is already running`);if(r===`completed`){if(i===`throw`)throw a;return T()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=b(o,n);if(s){if(s===u)continue;return s}}if(n.method===`next`)n.sent=n._sent=n.arg;else if(n.method===`throw`){if(r===`suspendedStart`)throw r=`completed`,n.arg;n.dispatchException(n.arg)}else n.method===`return`&&n.abrupt(`return`,n.arg);r=`executing`;var c=l(e,t,n);if(c.type===`normal`){if(r=n.done?`completed`:`suspendedYield`,c.arg===u)continue;return{value:c.arg,done:n.done}}c.type===`throw`&&(r=`completed`,n.method=`throw`,n.arg=c.arg)}}}(e,n,new C(r||[])),a}function l(e,t,n){try{return{type:`normal`,arg:e.call(t,n)}}catch(e){return{type:`throw`,arg:e}}}e.wrap=c;var u={};function d(){}function f(){}function p(){}var m={};m[i]=function(){return this};var h=Object.getPrototypeOf,g=h&&h(h(w([])));g&&g!==t&&n.call(g,i)&&(m=g);var _=p.prototype=d.prototype=Object.create(m);function v(e){[`next`,`throw`,`return`].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var r;this._invoke=function(i,a){function o(){return new t((function(r,o){(function r(i,a,o,s){var c=l(e[i],e,a);if(c.type!==`throw`){var u=c.arg,d=u.value;return d&&typeof d==`object`&&n.call(d,`__await`)?t.resolve(d.__await).then((function(e){r(`next`,e,o,s)}),(function(e){r(`throw`,e,o,s)})):t.resolve(d).then((function(e){u.value=e,o(u)}),(function(e){return r(`throw`,e,o,s)}))}s(c.arg)})(i,a,r,o)}))}return r=r?r.then(o,o):o()}}function b(e,t){var n=e.iterator[t.method];if(n===void 0){if(t.delegate=null,t.method===`throw`){if(e.iterator.return&&(t.method=`return`,t.arg=void 0,b(e,t),t.method===`throw`))return u;t.method=`throw`,t.arg=TypeError(`The iterator does not provide a 'throw' method`)}return u}var r=l(n,e.iterator,t.arg);if(r.type===`throw`)return t.method=`throw`,t.arg=r.arg,t.delegate=null,u;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,t.method!==`return`&&(t.method=`next`,t.arg=void 0),t.delegate=null,u):i:(t.method=`throw`,t.arg=TypeError(`iterator result is not an object`),t.delegate=null,u)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type=`normal`,delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:`root`}],e.forEach(x,this),this.reset(!0)}function w(e){if(e){var t=e[i];if(t)return t.call(e);if(typeof e.next==`function`)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:T}}function T(){return{value:void 0,done:!0}}return f.prototype=_.constructor=p,p.constructor=f,f.displayName=s(p,o,`GeneratorFunction`),e.isGeneratorFunction=function(e){var t=typeof e==`function`&&e.constructor;return!!t&&(t===f||(t.displayName||t.name)===`GeneratorFunction`)},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,o,`GeneratorFunction`)),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},v(y.prototype),y.prototype[a]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,r,i,a){a===void 0&&(a=Promise);var o=new y(c(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},v(_),s(_,o,`Generator`),_[i]=function(){return this},_.toString=function(){return`[object Generator]`},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=w,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method=`next`,this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)t.charAt(0)===`t`&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if(e.type===`throw`)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type=`throw`,o.arg=e,t.next=n,r&&(t.method=`next`,t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if(a.tryLoc===`root`)return r(`end`);if(a.tryLoc<=this.prev){var s=n.call(a,`catchLoc`),c=n.call(a,`finallyLoc`);if(s&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw Error(`try statement without catch or finally`);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,`finallyLoc`)&&this.prev<i.finallyLoc){var a=i;break}}a&&(e===`break`||e===`continue`)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method=`next`,this.next=a.finallyLoc,u):this.complete(o)},complete:function(e,t){if(e.type===`throw`)throw e.arg;return e.type===`break`||e.type===`continue`?this.next=e.arg:e.type===`return`?(this.rval=this.arg=e.arg,this.method=`return`,this.next=`end`):e.type===`normal`&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if(r.type===`throw`){var i=r.arg;S(n)}return i}}throw Error(`illegal catch attempt`)},delegateYield:function(e,t,n){return this.delegate={iterator:w(e),resultName:t,nextLoc:n},this.method===`next`&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch{Function(`r`,`regeneratorRuntime = r`)(t)}}));function d(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}var f=function(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){d(a,r,i,o,s,`next`,e)}function s(e){d(a,r,i,o,s,`throw`,e)}o(void 0)}))}},p=function(e){if(Array.isArray(e))return e},m=function(e,t){if(typeof Symbol<`u`&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||s.return==null||s.return()}finally{if(i)throw a}}return n}},h=function(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},g=function(e,t){if(e){if(typeof e==`string`)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(e,t):void 0}},_=function(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)},v=function(e,t){return p(e)||m(e,t)||g(e,t)||_()},y=function(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)};function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var x=function(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),e},S=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},C=function(){return!!navigator.permissions},w=function(){return!!navigator.mediaDevices};function T(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function E(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){T(a,r,i,o,s,`next`,e)}function s(e){T(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function D(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(typeof Symbol<`u`&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||s.return==null||s.return()}finally{if(i)throw a}}return n}}(e,t)||function(e,t){if(e){if(typeof e==`string`)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}(e,t)||function(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function O(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var k=function(){var e=E(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(n,r){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()||r(new DOMException(`Navigator API: permissions not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.next=4,navigator.permissions.query({name:t});case 4:i=e.sent,a=function e(t){i.removeEventListener(`change`,e),A(t.target.state,n,r)},i.addEventListener(`change`,a),A(i.state,n,r),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),r(e.t0);case 13:case`end`:return e.stop()}}),e,null,[[1,10]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),A=function(e,t,n){switch(e){case`denied`:n(new DOMException(`Permission denied`,`NOT_ALLOWED_ERR`));break;default:t(e)}},j=function(){var e=E(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(r,i){var a,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()&&w()||i(new DOMException(`Navigator API: permissions or Navigator API: mediaDevices not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.t0=Promise,e.next=5,k(t);case 5:return e.t1=e.sent,e.next=8,navigator.mediaDevices.getUserMedia(n);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:a=e.sent,o=D(a,2),s=o[1],r(s),e.next=21;break;case 18:e.prev=18,e.t4=e.catch(1),i(e.t4);case 21:case`end`:return e.stop()}}),e,null,[[1,18]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?M(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var P=function(){function e(t){var n=this;y(this,e),S(this,`_instance`,null),S(this,`_listeners`,null);var r=e._resolveSpeechRecognition();if(!r)throw new DOMException(`SpeechRecognition not supported`,`NOT_SUPPORTED_ERR`);this._instance=new r,this._listeners={},Object.entries(N(N({},e.defaultOptions),t||{})).forEach((function(t){var r=v(t,2),i=r[0],a=r[1];if(i===`grammars`&&!a){var o=e._resolveSpeechGrammarList();o&&(a=new o)}n._instance[i]=a}))}var t;return x(e,null,[{key:`isSupported`,get:function(){return!!e._resolveSpeechRecognition()&&!!C()&&!!w()},set:function(e){throw Error(`You cannot set isSupported directly.`)}}]),x(e,[{key:`start`,value:(t=f(u.mark((function e(){var t;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._instance){e.next=14;break}return e.prev=1,e.next=4,j(`microphone`,{audio:!0});case 4:if(e.sent){e.next=7;break}throw Error(`Unable to retrieve the stream from media device`);case 7:this._instance.start(),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),(t=this._listeners.error)&&t(e.t0);case 14:return e.abrupt(`return`,this);case 15:case`end`:return e.stop()}}),e,this,[[1,10]])}))),function(){return t.apply(this,arguments)})},{key:`stop`,value:function(){return this._instance&&this._instance.stop(),this}},{key:`abort`,value:function(){return this._instance&&this._instance.abort(),this}},{key:`addEventListener`,value:function(t,n){var r=this;if(this._instance&&this._includesEventType(t)){this._listeners[t]&&this.removeEventListener(t);var i=function(i){var a=[];t===e.eventTypes.RESULT&&i.results&&i.results.length>0&&a.push(i.results[0][0].transcript),n&&n.apply(r,[i].concat(a))};this._instance.addEventListener(t,i),this._listeners[t]=i}return this}},{key:`removeEventListener`,value:function(e){var t=this._listeners[e];return this._instance.removeEventListener(e,t),delete this._listeners[e],this}},{key:`cleanup`,value:function(){var e=this;return this.stop(),Object.keys(this._listeners).forEach((function(t){return e.removeEventListener(t)})),this._instance=null,this}},{key:`_includesEventType`,value:function(t){return!!Object.values(e.eventTypes).find((function(e){return e===t}))}},{key:`instance`,get:function(){return this._instance},set:function(e){throw Error(`You cannot set instance directly.`)}}],[{key:`_resolveSpeechRecognition`,value:function(){return window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition}},{key:`_resolveSpeechGrammarList`,value:function(){return window.SpeechGrammarList||window.webkitSpeechGrammarList||window.mozSpeechGrammarList||window.msSpeechGrammarList}}]),e}();S(P,`defaultOptions`,{grammars:null,lang:`en-US`,continuous:!1,interimResults:!1,maxAlternatives:1,serviceURI:null}),S(P,`eventTypes`,{AUDIO_END:`audioend`,AUDIO_START:`audiostart`,END:`end`,ERROR:`error`,NO_MATCH:`nomatch`,RESULT:`result`,SOUND_END:`soundend`,SOUND_START:`soundstart`,SPEECH_END:`speechend`,SPEECH_START:`speechstart`,START:`start`});var F=e=>typeof e==`function`,I=(e=`en-US`,t=null,n=1,r=null)=>{let i=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(P.isSupported)return i.current=r||new P({lang:e,grammars:t,maxAlternatives:n}),()=>{i.current.abort(),i.current.cleanup()}},[e,t,n,r]),[i,{start:(0,l.useCallback)(()=>{i.current&&i.current.start()},[]),stop:(0,l.useCallback)(()=>{i.current&&i.current.stop()},[]),abort:(0,l.useCallback)(()=>{i.current&&i.current.abort()},[]),subscribe:(0,l.useCallback)((e,t)=>{i.current&&i.current.addEventListener(e,t)},[]),unsubscribe:(0,l.useCallback)((e,t)=>{i.current&&i.current.removeEventListener(e,t)},[]),clean:(0,l.useCallback)(()=>{i.current&&i.current.cleanup()},[])}]},L=(e,t=0)=>{let n=(0,l.useRef)(-1),r=(0,l.useCallback)(()=>{clearTimeout(n.current),n.current=-1},[]),i=(0,l.useCallback)(()=>{r(),n.current=setTimeout(e,t)},[e,t,r]);return(0,l.useEffect)(()=>r,[r]),[i,r]},R=(e,t=.4)=>{let n=(0,l.useMemo)(()=>e?Object.entries(e).reduce((e,[t,n])=>({...e,[t.toLowerCase()]:n}),{}):{},[e]),r=(0,l.useMemo)(()=>Object.keys(n),[n]),i=(0,l.useMemo)(()=>r.some(e=>e.includes(` `)),[r]),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!i){a.current=null;return}import(`fuse.js`).then(e=>{a.current=new(e.default??e)(r,{includeScore:!0,ignoreLocation:!0})}).catch(()=>{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`)})},[i,r]),e=>{if(!r.length)return null;if(!i){let t=e.trim().split(/\s+/),r=t.length>1?t:[e.trim()];for(let e of r){let t=e.toLowerCase();if(t in n)return n[t]?.(e)}return null}let o=a.current;if(o){let r=o.search(e).filter(e=>e.score<t);if(r?.length)return n[r[0].item.toLowerCase()]?.(e)}else{let t=e.toLowerCase(),i=r.find(e=>t.includes(e)||e.includes(t));if(i)return n[i]?.(e)}return null}},z=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),B=o((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!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))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);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}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function O(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var k=function(){var e=E(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(n,r){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()||r(new DOMException(`Navigator API: permissions not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.next=4,navigator.permissions.query({name:t});case 4:i=e.sent,a=function e(t){i.removeEventListener(`change`,e),A(t.target.state,n,r)},i.addEventListener(`change`,a),A(i.state,n,r),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),r(e.t0);case 13:case`end`:return e.stop()}}),e,null,[[1,10]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),A=function(e,t,n){switch(e){case`denied`:n(new DOMException(`Permission denied`,`NOT_ALLOWED_ERR`));break;default:t(e)}},j=function(){var e=E(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(r,i){var a,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()&&w()||i(new DOMException(`Navigator API: permissions or Navigator API: mediaDevices not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.t0=Promise,e.next=5,k(t);case 5:return e.t1=e.sent,e.next=8,navigator.mediaDevices.getUserMedia(n);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:a=e.sent,o=D(a,2),s=o[1],r(s),e.next=21;break;case 18:e.prev=18,e.t4=e.catch(1),i(e.t4);case 21:case`end`:return e.stop()}}),e,null,[[1,18]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?M(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var P=function(){function e(t){var n=this;y(this,e),S(this,`_instance`,null),S(this,`_listeners`,null);var r=e._resolveSpeechRecognition();if(!r)throw new DOMException(`SpeechRecognition not supported`,`NOT_SUPPORTED_ERR`);this._instance=new r,this._listeners={},Object.entries(N(N({},e.defaultOptions),t||{})).forEach((function(t){var r=v(t,2),i=r[0],a=r[1];if(i===`grammars`&&!a){var o=e._resolveSpeechGrammarList();o&&(a=new o)}n._instance[i]=a}))}var t;return x(e,null,[{key:`isSupported`,get:function(){return!!e._resolveSpeechRecognition()&&!!C()&&!!w()},set:function(e){throw Error(`You cannot set isSupported directly.`)}}]),x(e,[{key:`start`,value:(t=f(u.mark((function e(){var t;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._instance){e.next=14;break}return e.prev=1,e.next=4,j(`microphone`,{audio:!0});case 4:if(e.sent){e.next=7;break}throw Error(`Unable to retrieve the stream from media device`);case 7:this._instance.start(),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),(t=this._listeners.error)&&t(e.t0);case 14:return e.abrupt(`return`,this);case 15:case`end`:return e.stop()}}),e,this,[[1,10]])}))),function(){return t.apply(this,arguments)})},{key:`stop`,value:function(){return this._instance&&this._instance.stop(),this}},{key:`abort`,value:function(){return this._instance&&this._instance.abort(),this}},{key:`addEventListener`,value:function(t,n){var r=this;if(this._instance&&this._includesEventType(t)){this._listeners[t]&&this.removeEventListener(t);var i=function(i){var a=[];t===e.eventTypes.RESULT&&i.results&&i.results.length>0&&a.push(i.results[0][0].transcript),n&&n.apply(r,[i].concat(a))};this._instance.addEventListener(t,i),this._listeners[t]=i}return this}},{key:`removeEventListener`,value:function(e){var t=this._listeners[e];return this._instance.removeEventListener(e,t),delete this._listeners[e],this}},{key:`cleanup`,value:function(){var e=this;return this.stop(),Object.keys(this._listeners).forEach((function(t){return e.removeEventListener(t)})),this._instance=null,this}},{key:`_includesEventType`,value:function(t){return!!Object.values(e.eventTypes).find((function(e){return e===t}))}},{key:`instance`,get:function(){return this._instance},set:function(e){throw Error(`You cannot set instance directly.`)}}],[{key:`_resolveSpeechRecognition`,value:function(){return window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition}},{key:`_resolveSpeechGrammarList`,value:function(){return window.SpeechGrammarList||window.webkitSpeechGrammarList||window.mozSpeechGrammarList||window.msSpeechGrammarList}}]),e}();S(P,`defaultOptions`,{grammars:null,lang:`en-US`,continuous:!1,interimResults:!1,maxAlternatives:1,serviceURI:null}),S(P,`eventTypes`,{AUDIO_END:`audioend`,AUDIO_START:`audiostart`,END:`end`,ERROR:`error`,NO_MATCH:`nomatch`,RESULT:`result`,SOUND_END:`soundend`,SOUND_START:`soundstart`,SPEECH_END:`speechend`,SPEECH_START:`speechstart`,START:`start`});var F=e=>typeof e==`function`,I=(e=`en-US`,t=null,n=1,r=!1,i=null)=>{let a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(P.isSupported)return a.current=i||new P({lang:e,grammars:t,maxAlternatives:n,continuous:r}),()=>{a.current.abort(),a.current.cleanup()}},[e,t,n,r,i]),[a,{start:(0,l.useCallback)(()=>{a.current&&a.current.start()},[]),stop:(0,l.useCallback)(()=>{a.current&&a.current.stop()},[]),abort:(0,l.useCallback)(()=>{a.current&&a.current.abort()},[]),subscribe:(0,l.useCallback)((e,t)=>{a.current&&a.current.addEventListener(e,t)},[]),unsubscribe:(0,l.useCallback)((e,t)=>{a.current&&a.current.removeEventListener(e,t)},[]),clean:(0,l.useCallback)(()=>{a.current&&a.current.cleanup()},[])}]},L=(e,t=0)=>{let n=(0,l.useRef)(-1),r=(0,l.useCallback)(()=>{clearTimeout(n.current),n.current=-1},[]),i=(0,l.useCallback)(()=>{r(),n.current=setTimeout(e,t)},[e,t,r]);return(0,l.useEffect)(()=>r,[r]),[i,r]},ee=(e,t=.4)=>{let n=(0,l.useMemo)(()=>e?Object.entries(e).reduce((e,[t,n])=>({...e,[t.toLowerCase()]:n}),{}):{},[e]),r=(0,l.useMemo)(()=>Object.keys(n),[n]),i=(0,l.useMemo)(()=>r.some(e=>e.includes(` `)),[r]),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!i){a.current=null;return}import(`fuse.js`).then(e=>{a.current=new(e.default??e)(r,{includeScore:!0,ignoreLocation:!0})}).catch(()=>{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`)})},[i,r]),e=>{if(!r.length)return null;if(!i){let t=e.trim().split(/\s+/),r=t.length>1?t:[e.trim()];for(let e of r){let t=e.toLowerCase();if(t in n)return n[t]?.(e,t)}return null}let o=a.current;if(o){let r=o.search(e).filter(e=>e.score<t);if(r?.length){let t=r[0].item.toLowerCase();return n[t]?.(e,t)}}else{let t=e.toLowerCase(),i=r.find(e=>t.includes(e)||e.includes(t));if(i)return n[i]?.(e,i)}return null}},R=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),z=o((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!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))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);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}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
4
4
  let props = %s;
5
5
  <%s {...props} />
6
6
  React keys must be passed directly to JSX without using spread:
7
7
  let props = %s;
8
- <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),V=o(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=z():t.exports=B()}))(),H=({color:e=`black`,activeColor:t=`red`,isActive:n=!1})=>(0,V.jsx)(`svg`,{"data-testid":`__icon-root__`,xmlns:`http://www.w3.org/2000/svg`,width:`100%`,height:`100%`,viewBox:`0 0 24 24`,children:(0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{"data-testid":`__icon-path__`,fill:e,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`}),n&&(0,V.jsx)(`circle`,{"data-testid":`__icon-active__`,fill:t,cx:`16`,cy:`4`,r:`4`})]})}),U=(e,t)=>{for(let{alternatives:n}of e)for(let e of n)if(t(e)!==null)return},W=({children:e,commands:t=null,lang:n=`en-US`,grammars:r=null,timeout:i=3e3,precision:a=.4,maxAlternatives:o=1,ariaLabel:s=`start recognition`,style:c=null,className:u=null,outlineStyle:d=`2px solid`,onStart:f=null,onEnd:p=null,onSpeechStart:m=null,onSpeechEnd:h=null,onResult:g=null,onError:_=null,onNoMatch:v=null,__rsInstance:y})=>{let b=(0,l.useRef)(null),[x,S]=(0,l.useState)(!1),[,{start:C,stop:w,subscribe:T,unsubscribe:E}]=I(n,r,o,y),D=R(t,a),O=(0,l.useRef)({});O.current={onStart:f,onEnd:p,onSpeechStart:m,onSpeechEnd:h,onResult:g,onError:_,onNoMatch:v};let k=(0,l.useRef)(D);k.current=D;let A=(0,l.useRef)(null),j=(0,l.useRef)(null),[M,N]=L((0,l.useCallback)(()=>j.current?.(),[]),i),z=(0,l.useCallback)(()=>{try{S(!1),w()}catch(e){O.current.onError?.(e),A.current?.()}},[w]),B=(0,l.useCallback)(e=>{M(),O.current.onStart?.(e)},[M]),W=(0,l.useCallback)(e=>{N(),O.current.onSpeechStart?.(e)},[N]),G=(0,l.useCallback)(e=>{M(),O.current.onSpeechEnd?.(e)},[M]),K=(0,l.useCallback)(e=>{let t=Array.from(e?.results??[],e=>{let t={confidence:-1/0,transcript:``},n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(i.transcript??``),(i.confidence===void 0||i.confidence>t.confidence)&&(t=i)}return{best:t.transcript??``,alternatives:n}}),n=t.map(e=>e.best).join(``);N(),z(),U(t,k.current),O.current.onResult?.(n,e)},[N,z]),q=(0,l.useCallback)(e=>{z(),O.current.onError?.(e)},[z]),J=(0,l.useCallback)(e=>{N(),z(),O.current.onNoMatch?.(e)},[N,z]),Y=(0,l.useCallback)(e=>{N();try{z(),A.current?.()}finally{O.current.onEnd?.(e)}},[N,z]);j.current=Y;let X=(0,l.useMemo)(()=>({start:B,end:Y,speechstart:W,speechend:G,result:K,error:q,nomatch:J}),[B,Y,W,G,K,q,J]);A.current=()=>Object.entries(X).forEach(([e,t])=>E?.(e,t));let Z=(0,l.useCallback)(()=>{try{S(!0),Object.entries(X).forEach(([e,t])=>T(e,t)),C()}catch(e){q(e)}},[X,T,C,q]),Q=()=>{!u&&d&&(b.current.style.outline=d)},$=()=>{!u&&d&&(b.current.style.outline=`none`)};return P.isSupported?F(e)?e(Z,z,x):(0,l.isValidElement)(e)?(0,l.cloneElement)(e,{...!x&&{onClick:Z}}):(0,V.jsx)(`button`,{"data-testid":`__vocal-root__`,ref:b,role:`button`,"aria-label":s,style:u?null:{width:24,height:24,backgroundColor:`transparent`,border:`none`,padding:0,cursor:x?`default`:`pointer`,...c},className:u,onFocus:Q,onBlur:$,onClick:Z,children:(0,V.jsx)(H,{isActive:x,color:`#aaa`})}):null},G=P.isSupported,K=W;exports.default=K,exports.isSupported=G,exports.useVocal=I;
8
+ <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),B=o(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=R():t.exports=z()}))(),te=({color:e=`black`,activeColor:t=`red`,isActive:n=!1})=>(0,B.jsx)(`svg`,{"data-testid":`__icon-root__`,xmlns:`http://www.w3.org/2000/svg`,width:`100%`,height:`100%`,viewBox:`0 0 24 24`,children:(0,B.jsxs)(`g`,{children:[(0,B.jsx)(`path`,{"data-testid":`__icon-path__`,fill:e,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`}),n&&(0,B.jsx)(`circle`,{"data-testid":`__icon-active__`,fill:t,cx:`16`,cy:`4`,r:`4`})]})}),ne=(e,t)=>{for(let{alternatives:n}of e)for(let e of n)if(t(e)!==null)return},V=({children:e,commands:t=null,lang:n=`en-US`,grammars:r=null,timeout:i=3e3,silenceTimeout:a=null,precision:o=.4,maxAlternatives:s=1,continuous:c=!1,ariaLabel:u=`start recognition`,style:d=null,className:f=null,outlineStyle:p=`2px solid`,onStart:m=null,onEnd:h=null,onSpeechStart:g=null,onSpeechEnd:_=null,onResult:v=null,onError:y=null,onNoMatch:b=null,__rsInstance:x})=>{let S=(0,l.useRef)(null),[C,w]=(0,l.useState)(!1),[,{start:T,stop:E,subscribe:D,unsubscribe:O}]=I(n,r,s,c,x),k=ee(t,o),A=(0,l.useRef)({});A.current={onStart:m,onEnd:h,onSpeechStart:g,onSpeechEnd:_,onResult:v,onError:y,onNoMatch:b};let j=(0,l.useRef)(c);j.current=c;let M=(0,l.useRef)({transcript:``,event:null}),N=(0,l.useRef)(k);N.current=k;let R=(0,l.useRef)(null),z=(0,l.useRef)(null),V=(0,l.useRef)(a);V.current=a;let H=(0,l.useCallback)(()=>z.current?.(),[]),[U,W]=L(H,i),[G,K]=L(H,a??0),q=(0,l.useCallback)(()=>{try{w(!1),E()}catch(e){A.current.onError?.(e),R.current?.()}},[E]),J=(0,l.useCallback)(e=>{U(),A.current.onStart?.(e)},[U]),Y=(0,l.useCallback)(e=>{W(),A.current.onSpeechStart?.(e)},[W]),re=(0,l.useCallback)(e=>{U(),A.current.onSpeechEnd?.(e)},[U]),ie=(0,l.useCallback)(e=>{let t=Array.from(e?.results??[],e=>{let t={confidence:-1/0,transcript:``},n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(i.transcript??``),(i.confidence===void 0||i.confidence>t.confidence)&&(t=i)}return{best:t.transcript??``,alternatives:n}}),n=t.map(e=>e.best).join(``);W(),j.current?(M.current.transcript=n,M.current.event=e,V.current>0&&G()):(ne(t,N.current),q(),A.current.onResult?.(n,e))},[W,G,q]),X=(0,l.useCallback)(e=>{q(),A.current.onError?.(e)},[q]),ae=(0,l.useCallback)(e=>{W(),q(),A.current.onNoMatch?.(e)},[W,q]),Z=(0,l.useCallback)(e=>{W(),K();try{q(),R.current?.(),j.current&&M.current.transcript&&(A.current.onResult?.(M.current.transcript,M.current.event),M.current.transcript=``,M.current.event=null)}finally{A.current.onEnd?.(e)}},[W,K,q]);z.current=Z;let Q=(0,l.useMemo)(()=>({start:J,end:Z,speechstart:Y,speechend:re,result:ie,error:X,nomatch:ae}),[J,Z,Y,re,ie,X,ae]);R.current=()=>Object.entries(Q).forEach(([e,t])=>O?.(e,t));let $=(0,l.useCallback)(()=>{try{M.current.transcript=``,M.current.event=null,K(),w(!0),Object.entries(Q).forEach(([e,t])=>D(e,t)),T()}catch(e){X(e)}},[Q,D,T,K,X]),oe=()=>{!f&&p&&(S.current.style.outline=p)},se=()=>{!f&&p&&(S.current.style.outline=`none`)};return P.isSupported?F(e)?e($,q,C):(0,l.isValidElement)(e)?(0,l.cloneElement)(e,{...!C&&{onClick:$}}):(0,B.jsx)(`button`,{"data-testid":`__vocal-root__`,ref:S,"aria-label":u,"aria-pressed":C,style:f?null:{width:24,height:24,backgroundColor:`transparent`,border:`none`,padding:0,cursor:!c&&C?`default`:`pointer`,...d},className:f,onFocus:oe,onBlur:se,onClick:C?q:$,children:(0,B.jsx)(te,{isActive:C,color:`#aaa`})}):null},H=P.isSupported,U=V;exports.default=U,exports.isSupported=H,exports.useVocal=I;
9
9
  //# sourceMappingURL=index.js.map
package/dist/index.umd.js CHANGED
@@ -1,9 +1,9 @@
1
1
  (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`)):typeof define==`function`&&define.amd?define([`exports`,`react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ReactVocal={},e.React))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t);var u=function(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw Error(`Dynamic requires are not currently supported by @rollup/plugin-commonjs`)}(t==null&&n.path)}},n.exports),n.exports}((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r=typeof Symbol==`function`?Symbol:{},i=r.iterator||`@@iterator`,a=r.asyncIterator||`@@asyncIterator`,o=r.toStringTag||`@@toStringTag`;function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},``)}catch{s=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype);return a._invoke=function(e,t,n){var r=`suspendedStart`;return function(i,a){if(r===`executing`)throw Error(`Generator is already running`);if(r===`completed`){if(i===`throw`)throw a;return T()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=b(o,n);if(s){if(s===u)continue;return s}}if(n.method===`next`)n.sent=n._sent=n.arg;else if(n.method===`throw`){if(r===`suspendedStart`)throw r=`completed`,n.arg;n.dispatchException(n.arg)}else n.method===`return`&&n.abrupt(`return`,n.arg);r=`executing`;var c=l(e,t,n);if(c.type===`normal`){if(r=n.done?`completed`:`suspendedYield`,c.arg===u)continue;return{value:c.arg,done:n.done}}c.type===`throw`&&(r=`completed`,n.method=`throw`,n.arg=c.arg)}}}(e,n,new C(r||[])),a}function l(e,t,n){try{return{type:`normal`,arg:e.call(t,n)}}catch(e){return{type:`throw`,arg:e}}}e.wrap=c;var u={};function d(){}function f(){}function p(){}var m={};m[i]=function(){return this};var h=Object.getPrototypeOf,g=h&&h(h(w([])));g&&g!==t&&n.call(g,i)&&(m=g);var _=p.prototype=d.prototype=Object.create(m);function v(e){[`next`,`throw`,`return`].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var r;this._invoke=function(i,a){function o(){return new t((function(r,o){(function r(i,a,o,s){var c=l(e[i],e,a);if(c.type!==`throw`){var u=c.arg,d=u.value;return d&&typeof d==`object`&&n.call(d,`__await`)?t.resolve(d.__await).then((function(e){r(`next`,e,o,s)}),(function(e){r(`throw`,e,o,s)})):t.resolve(d).then((function(e){u.value=e,o(u)}),(function(e){return r(`throw`,e,o,s)}))}s(c.arg)})(i,a,r,o)}))}return r=r?r.then(o,o):o()}}function b(e,t){var n=e.iterator[t.method];if(n===void 0){if(t.delegate=null,t.method===`throw`){if(e.iterator.return&&(t.method=`return`,t.arg=void 0,b(e,t),t.method===`throw`))return u;t.method=`throw`,t.arg=TypeError(`The iterator does not provide a 'throw' method`)}return u}var r=l(n,e.iterator,t.arg);if(r.type===`throw`)return t.method=`throw`,t.arg=r.arg,t.delegate=null,u;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,t.method!==`return`&&(t.method=`next`,t.arg=void 0),t.delegate=null,u):i:(t.method=`throw`,t.arg=TypeError(`iterator result is not an object`),t.delegate=null,u)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type=`normal`,delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:`root`}],e.forEach(x,this),this.reset(!0)}function w(e){if(e){var t=e[i];if(t)return t.call(e);if(typeof e.next==`function`)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:T}}function T(){return{value:void 0,done:!0}}return f.prototype=_.constructor=p,p.constructor=f,f.displayName=s(p,o,`GeneratorFunction`),e.isGeneratorFunction=function(e){var t=typeof e==`function`&&e.constructor;return!!t&&(t===f||(t.displayName||t.name)===`GeneratorFunction`)},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,o,`GeneratorFunction`)),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},v(y.prototype),y.prototype[a]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,r,i,a){a===void 0&&(a=Promise);var o=new y(c(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},v(_),s(_,o,`Generator`),_[i]=function(){return this},_.toString=function(){return`[object Generator]`},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=w,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method=`next`,this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)t.charAt(0)===`t`&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if(e.type===`throw`)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type=`throw`,o.arg=e,t.next=n,r&&(t.method=`next`,t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if(a.tryLoc===`root`)return r(`end`);if(a.tryLoc<=this.prev){var s=n.call(a,`catchLoc`),c=n.call(a,`finallyLoc`);if(s&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw Error(`try statement without catch or finally`);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,`finallyLoc`)&&this.prev<i.finallyLoc){var a=i;break}}a&&(e===`break`||e===`continue`)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method=`next`,this.next=a.finallyLoc,u):this.complete(o)},complete:function(e,t){if(e.type===`throw`)throw e.arg;return e.type===`break`||e.type===`continue`?this.next=e.arg:e.type===`return`?(this.rval=this.arg=e.arg,this.method=`return`,this.next=`end`):e.type===`normal`&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if(r.type===`throw`){var i=r.arg;S(n)}return i}}throw Error(`illegal catch attempt`)},delegateYield:function(e,t,n){return this.delegate={iterator:w(e),resultName:t,nextLoc:n},this.method===`next`&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch{Function(`r`,`regeneratorRuntime = r`)(t)}}));function d(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}var f=function(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){d(a,r,i,o,s,`next`,e)}function s(e){d(a,r,i,o,s,`throw`,e)}o(void 0)}))}},p=function(e){if(Array.isArray(e))return e},m=function(e,t){if(typeof Symbol<`u`&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||s.return==null||s.return()}finally{if(i)throw a}}return n}},h=function(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},g=function(e,t){if(e){if(typeof e==`string`)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(e,t):void 0}},_=function(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)},v=function(e,t){return p(e)||m(e,t)||g(e,t)||_()},y=function(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)};function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var x=function(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),e},S=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},C=function(){return!!navigator.permissions},w=function(){return!!navigator.mediaDevices};function T(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function E(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){T(a,r,i,o,s,`next`,e)}function s(e){T(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function D(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(typeof Symbol<`u`&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||s.return==null||s.return()}finally{if(i)throw a}}return n}}(e,t)||function(e,t){if(e){if(typeof e==`string`)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}(e,t)||function(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function O(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var k=function(){var e=E(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(n,r){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()||r(new DOMException(`Navigator API: permissions not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.next=4,navigator.permissions.query({name:t});case 4:i=e.sent,a=function e(t){i.removeEventListener(`change`,e),A(t.target.state,n,r)},i.addEventListener(`change`,a),A(i.state,n,r),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),r(e.t0);case 13:case`end`:return e.stop()}}),e,null,[[1,10]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),A=function(e,t,n){switch(e){case`denied`:n(new DOMException(`Permission denied`,`NOT_ALLOWED_ERR`));break;default:t(e)}},j=function(){var e=E(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(r,i){var a,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()&&w()||i(new DOMException(`Navigator API: permissions or Navigator API: mediaDevices not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.t0=Promise,e.next=5,k(t);case 5:return e.t1=e.sent,e.next=8,navigator.mediaDevices.getUserMedia(n);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:a=e.sent,o=D(a,2),s=o[1],r(s),e.next=21;break;case 18:e.prev=18,e.t4=e.catch(1),i(e.t4);case 21:case`end`:return e.stop()}}),e,null,[[1,18]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?M(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var P=function(){function e(t){var n=this;y(this,e),S(this,`_instance`,null),S(this,`_listeners`,null);var r=e._resolveSpeechRecognition();if(!r)throw new DOMException(`SpeechRecognition not supported`,`NOT_SUPPORTED_ERR`);this._instance=new r,this._listeners={},Object.entries(N(N({},e.defaultOptions),t||{})).forEach((function(t){var r=v(t,2),i=r[0],a=r[1];if(i===`grammars`&&!a){var o=e._resolveSpeechGrammarList();o&&(a=new o)}n._instance[i]=a}))}var t;return x(e,null,[{key:`isSupported`,get:function(){return!!e._resolveSpeechRecognition()&&!!C()&&!!w()},set:function(e){throw Error(`You cannot set isSupported directly.`)}}]),x(e,[{key:`start`,value:(t=f(u.mark((function e(){var t;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._instance){e.next=14;break}return e.prev=1,e.next=4,j(`microphone`,{audio:!0});case 4:if(e.sent){e.next=7;break}throw Error(`Unable to retrieve the stream from media device`);case 7:this._instance.start(),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),(t=this._listeners.error)&&t(e.t0);case 14:return e.abrupt(`return`,this);case 15:case`end`:return e.stop()}}),e,this,[[1,10]])}))),function(){return t.apply(this,arguments)})},{key:`stop`,value:function(){return this._instance&&this._instance.stop(),this}},{key:`abort`,value:function(){return this._instance&&this._instance.abort(),this}},{key:`addEventListener`,value:function(t,n){var r=this;if(this._instance&&this._includesEventType(t)){this._listeners[t]&&this.removeEventListener(t);var i=function(i){var a=[];t===e.eventTypes.RESULT&&i.results&&i.results.length>0&&a.push(i.results[0][0].transcript),n&&n.apply(r,[i].concat(a))};this._instance.addEventListener(t,i),this._listeners[t]=i}return this}},{key:`removeEventListener`,value:function(e){var t=this._listeners[e];return this._instance.removeEventListener(e,t),delete this._listeners[e],this}},{key:`cleanup`,value:function(){var e=this;return this.stop(),Object.keys(this._listeners).forEach((function(t){return e.removeEventListener(t)})),this._instance=null,this}},{key:`_includesEventType`,value:function(t){return!!Object.values(e.eventTypes).find((function(e){return e===t}))}},{key:`instance`,get:function(){return this._instance},set:function(e){throw Error(`You cannot set instance directly.`)}}],[{key:`_resolveSpeechRecognition`,value:function(){return window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition}},{key:`_resolveSpeechGrammarList`,value:function(){return window.SpeechGrammarList||window.webkitSpeechGrammarList||window.mozSpeechGrammarList||window.msSpeechGrammarList}}]),e}();S(P,`defaultOptions`,{grammars:null,lang:`en-US`,continuous:!1,interimResults:!1,maxAlternatives:1,serviceURI:null}),S(P,`eventTypes`,{AUDIO_END:`audioend`,AUDIO_START:`audiostart`,END:`end`,ERROR:`error`,NO_MATCH:`nomatch`,RESULT:`result`,SOUND_END:`soundend`,SOUND_START:`soundstart`,SPEECH_END:`speechend`,SPEECH_START:`speechstart`,START:`start`});var F=e=>typeof e==`function`,I=(e=`en-US`,n=null,r=1,i=null)=>{let a=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(P.isSupported)return a.current=i||new P({lang:e,grammars:n,maxAlternatives:r}),()=>{a.current.abort(),a.current.cleanup()}},[e,n,r,i]),[a,{start:(0,t.useCallback)(()=>{a.current&&a.current.start()},[]),stop:(0,t.useCallback)(()=>{a.current&&a.current.stop()},[]),abort:(0,t.useCallback)(()=>{a.current&&a.current.abort()},[]),subscribe:(0,t.useCallback)((e,t)=>{a.current&&a.current.addEventListener(e,t)},[]),unsubscribe:(0,t.useCallback)((e,t)=>{a.current&&a.current.removeEventListener(e,t)},[]),clean:(0,t.useCallback)(()=>{a.current&&a.current.cleanup()},[])}]},L=(e,n=0)=>{let r=(0,t.useRef)(-1),i=(0,t.useCallback)(()=>{clearTimeout(r.current),r.current=-1},[]),a=(0,t.useCallback)(()=>{i(),r.current=setTimeout(e,n)},[e,n,i]);return(0,t.useEffect)(()=>i,[i]),[a,i]},R=(e,n=.4)=>{let r=(0,t.useMemo)(()=>e?Object.entries(e).reduce((e,[t,n])=>({...e,[t.toLowerCase()]:n}),{}):{},[e]),i=(0,t.useMemo)(()=>Object.keys(r),[r]),a=(0,t.useMemo)(()=>i.some(e=>e.includes(` `)),[i]),o=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!a){o.current=null;return}import(`fuse.js`).then(e=>{o.current=new(e.default??e)(i,{includeScore:!0,ignoreLocation:!0})}).catch(()=>{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`)})},[a,i]),e=>{if(!i.length)return null;if(!a){let t=e.trim().split(/\s+/),n=t.length>1?t:[e.trim()];for(let e of n){let t=e.toLowerCase();if(t in r)return r[t]?.(e)}return null}let t=o.current;if(t){let i=t.search(e).filter(e=>e.score<n);if(i?.length)return r[i[0].item.toLowerCase()]?.(e)}else{let t=e.toLowerCase(),n=i.find(e=>t.includes(e)||e.includes(t));if(n)return r[n]?.(e)}return null}},z=c((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),B=c((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!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))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);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}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function O(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var k=function(){var e=E(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(n,r){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()||r(new DOMException(`Navigator API: permissions not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.next=4,navigator.permissions.query({name:t});case 4:i=e.sent,a=function e(t){i.removeEventListener(`change`,e),A(t.target.state,n,r)},i.addEventListener(`change`,a),A(i.state,n,r),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),r(e.t0);case 13:case`end`:return e.stop()}}),e,null,[[1,10]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),A=function(e,t,n){switch(e){case`denied`:n(new DOMException(`Permission denied`,`NOT_ALLOWED_ERR`));break;default:t(e)}},j=function(){var e=E(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt(`return`,new Promise(function(){var e=E(regeneratorRuntime.mark((function e(r,i){var a,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return C()&&w()||i(new DOMException(`Navigator API: permissions or Navigator API: mediaDevices not supported`,`NOT_SUPPORTED_ERR`)),e.prev=1,e.t0=Promise,e.next=5,k(t);case 5:return e.t1=e.sent,e.next=8,navigator.mediaDevices.getUserMedia(n);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:a=e.sent,o=D(a,2),s=o[1],r(s),e.next=21;break;case 18:e.prev=18,e.t4=e.catch(1),i(e.t4);case 21:case`end`:return e.stop()}}),e,null,[[1,18]])})));return function(t,n){return e.apply(this,arguments)}}()));case 1:case`end`:return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?M(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var P=function(){function e(t){var n=this;y(this,e),S(this,`_instance`,null),S(this,`_listeners`,null);var r=e._resolveSpeechRecognition();if(!r)throw new DOMException(`SpeechRecognition not supported`,`NOT_SUPPORTED_ERR`);this._instance=new r,this._listeners={},Object.entries(N(N({},e.defaultOptions),t||{})).forEach((function(t){var r=v(t,2),i=r[0],a=r[1];if(i===`grammars`&&!a){var o=e._resolveSpeechGrammarList();o&&(a=new o)}n._instance[i]=a}))}var t;return x(e,null,[{key:`isSupported`,get:function(){return!!e._resolveSpeechRecognition()&&!!C()&&!!w()},set:function(e){throw Error(`You cannot set isSupported directly.`)}}]),x(e,[{key:`start`,value:(t=f(u.mark((function e(){var t;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._instance){e.next=14;break}return e.prev=1,e.next=4,j(`microphone`,{audio:!0});case 4:if(e.sent){e.next=7;break}throw Error(`Unable to retrieve the stream from media device`);case 7:this._instance.start(),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),(t=this._listeners.error)&&t(e.t0);case 14:return e.abrupt(`return`,this);case 15:case`end`:return e.stop()}}),e,this,[[1,10]])}))),function(){return t.apply(this,arguments)})},{key:`stop`,value:function(){return this._instance&&this._instance.stop(),this}},{key:`abort`,value:function(){return this._instance&&this._instance.abort(),this}},{key:`addEventListener`,value:function(t,n){var r=this;if(this._instance&&this._includesEventType(t)){this._listeners[t]&&this.removeEventListener(t);var i=function(i){var a=[];t===e.eventTypes.RESULT&&i.results&&i.results.length>0&&a.push(i.results[0][0].transcript),n&&n.apply(r,[i].concat(a))};this._instance.addEventListener(t,i),this._listeners[t]=i}return this}},{key:`removeEventListener`,value:function(e){var t=this._listeners[e];return this._instance.removeEventListener(e,t),delete this._listeners[e],this}},{key:`cleanup`,value:function(){var e=this;return this.stop(),Object.keys(this._listeners).forEach((function(t){return e.removeEventListener(t)})),this._instance=null,this}},{key:`_includesEventType`,value:function(t){return!!Object.values(e.eventTypes).find((function(e){return e===t}))}},{key:`instance`,get:function(){return this._instance},set:function(e){throw Error(`You cannot set instance directly.`)}}],[{key:`_resolveSpeechRecognition`,value:function(){return window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition}},{key:`_resolveSpeechGrammarList`,value:function(){return window.SpeechGrammarList||window.webkitSpeechGrammarList||window.mozSpeechGrammarList||window.msSpeechGrammarList}}]),e}();S(P,`defaultOptions`,{grammars:null,lang:`en-US`,continuous:!1,interimResults:!1,maxAlternatives:1,serviceURI:null}),S(P,`eventTypes`,{AUDIO_END:`audioend`,AUDIO_START:`audiostart`,END:`end`,ERROR:`error`,NO_MATCH:`nomatch`,RESULT:`result`,SOUND_END:`soundend`,SOUND_START:`soundstart`,SPEECH_END:`speechend`,SPEECH_START:`speechstart`,START:`start`});var F=e=>typeof e==`function`,I=(e=`en-US`,n=null,r=1,i=!1,a=null)=>{let o=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(P.isSupported)return o.current=a||new P({lang:e,grammars:n,maxAlternatives:r,continuous:i}),()=>{o.current.abort(),o.current.cleanup()}},[e,n,r,i,a]),[o,{start:(0,t.useCallback)(()=>{o.current&&o.current.start()},[]),stop:(0,t.useCallback)(()=>{o.current&&o.current.stop()},[]),abort:(0,t.useCallback)(()=>{o.current&&o.current.abort()},[]),subscribe:(0,t.useCallback)((e,t)=>{o.current&&o.current.addEventListener(e,t)},[]),unsubscribe:(0,t.useCallback)((e,t)=>{o.current&&o.current.removeEventListener(e,t)},[]),clean:(0,t.useCallback)(()=>{o.current&&o.current.cleanup()},[])}]},L=(e,n=0)=>{let r=(0,t.useRef)(-1),i=(0,t.useCallback)(()=>{clearTimeout(r.current),r.current=-1},[]),a=(0,t.useCallback)(()=>{i(),r.current=setTimeout(e,n)},[e,n,i]);return(0,t.useEffect)(()=>i,[i]),[a,i]},ee=(e,n=.4)=>{let r=(0,t.useMemo)(()=>e?Object.entries(e).reduce((e,[t,n])=>({...e,[t.toLowerCase()]:n}),{}):{},[e]),i=(0,t.useMemo)(()=>Object.keys(r),[r]),a=(0,t.useMemo)(()=>i.some(e=>e.includes(` `)),[i]),o=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!a){o.current=null;return}import(`fuse.js`).then(e=>{o.current=new(e.default??e)(i,{includeScore:!0,ignoreLocation:!0})}).catch(()=>{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`)})},[a,i]),e=>{if(!i.length)return null;if(!a){let t=e.trim().split(/\s+/),n=t.length>1?t:[e.trim()];for(let e of n){let t=e.toLowerCase();if(t in r)return r[t]?.(e,t)}return null}let t=o.current;if(t){let i=t.search(e).filter(e=>e.score<n);if(i?.length){let t=i[0].item.toLowerCase();return r[t]?.(e,t)}}else{let t=e.toLowerCase(),n=i.find(e=>t.includes(e)||e.includes(t));if(n)return r[n]?.(e,n)}return null}},R=c((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),z=c((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!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))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);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}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
4
4
  let props = %s;
5
5
  <%s {...props} />
6
6
  React keys must be passed directly to JSX without using spread:
7
7
  let props = %s;
8
- <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),V=c(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=z():t.exports=B()}))(),H=({color:e=`black`,activeColor:t=`red`,isActive:n=!1})=>(0,V.jsx)(`svg`,{"data-testid":`__icon-root__`,xmlns:`http://www.w3.org/2000/svg`,width:`100%`,height:`100%`,viewBox:`0 0 24 24`,children:(0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{"data-testid":`__icon-path__`,fill:e,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`}),n&&(0,V.jsx)(`circle`,{"data-testid":`__icon-active__`,fill:t,cx:`16`,cy:`4`,r:`4`})]})}),U=(e,t)=>{for(let{alternatives:n}of e)for(let e of n)if(t(e)!==null)return},W=({children:e,commands:n=null,lang:r=`en-US`,grammars:i=null,timeout:a=3e3,precision:o=.4,maxAlternatives:s=1,ariaLabel:c=`start recognition`,style:l=null,className:u=null,outlineStyle:d=`2px solid`,onStart:f=null,onEnd:p=null,onSpeechStart:m=null,onSpeechEnd:h=null,onResult:g=null,onError:_=null,onNoMatch:v=null,__rsInstance:y})=>{let b=(0,t.useRef)(null),[x,S]=(0,t.useState)(!1),[,{start:C,stop:w,subscribe:T,unsubscribe:E}]=I(r,i,s,y),D=R(n,o),O=(0,t.useRef)({});O.current={onStart:f,onEnd:p,onSpeechStart:m,onSpeechEnd:h,onResult:g,onError:_,onNoMatch:v};let k=(0,t.useRef)(D);k.current=D;let A=(0,t.useRef)(null),j=(0,t.useRef)(null),[M,N]=L((0,t.useCallback)(()=>j.current?.(),[]),a),z=(0,t.useCallback)(()=>{try{S(!1),w()}catch(e){O.current.onError?.(e),A.current?.()}},[w]),B=(0,t.useCallback)(e=>{M(),O.current.onStart?.(e)},[M]),W=(0,t.useCallback)(e=>{N(),O.current.onSpeechStart?.(e)},[N]),G=(0,t.useCallback)(e=>{M(),O.current.onSpeechEnd?.(e)},[M]),K=(0,t.useCallback)(e=>{let t=Array.from(e?.results??[],e=>{let t={confidence:-1/0,transcript:``},n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(i.transcript??``),(i.confidence===void 0||i.confidence>t.confidence)&&(t=i)}return{best:t.transcript??``,alternatives:n}}),n=t.map(e=>e.best).join(``);N(),z(),U(t,k.current),O.current.onResult?.(n,e)},[N,z]),q=(0,t.useCallback)(e=>{z(),O.current.onError?.(e)},[z]),J=(0,t.useCallback)(e=>{N(),z(),O.current.onNoMatch?.(e)},[N,z]),Y=(0,t.useCallback)(e=>{N();try{z(),A.current?.()}finally{O.current.onEnd?.(e)}},[N,z]);j.current=Y;let X=(0,t.useMemo)(()=>({start:B,end:Y,speechstart:W,speechend:G,result:K,error:q,nomatch:J}),[B,Y,W,G,K,q,J]);A.current=()=>Object.entries(X).forEach(([e,t])=>E?.(e,t));let Z=(0,t.useCallback)(()=>{try{S(!0),Object.entries(X).forEach(([e,t])=>T(e,t)),C()}catch(e){q(e)}},[X,T,C,q]),Q=()=>{!u&&d&&(b.current.style.outline=d)},$=()=>{!u&&d&&(b.current.style.outline=`none`)};return P.isSupported?F(e)?e(Z,z,x):(0,t.isValidElement)(e)?(0,t.cloneElement)(e,{...!x&&{onClick:Z}}):(0,V.jsx)(`button`,{"data-testid":`__vocal-root__`,ref:b,role:`button`,"aria-label":c,style:u?null:{width:24,height:24,backgroundColor:`transparent`,border:`none`,padding:0,cursor:x?`default`:`pointer`,...l},className:u,onFocus:Q,onBlur:$,onClick:Z,children:(0,V.jsx)(H,{isActive:x,color:`#aaa`})}):null},G=P.isSupported;e.default=W,e.isSupported=G,e.useVocal=I});
8
+ <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),B=c(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=R():t.exports=z()}))(),te=({color:e=`black`,activeColor:t=`red`,isActive:n=!1})=>(0,B.jsx)(`svg`,{"data-testid":`__icon-root__`,xmlns:`http://www.w3.org/2000/svg`,width:`100%`,height:`100%`,viewBox:`0 0 24 24`,children:(0,B.jsxs)(`g`,{children:[(0,B.jsx)(`path`,{"data-testid":`__icon-path__`,fill:e,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`}),n&&(0,B.jsx)(`circle`,{"data-testid":`__icon-active__`,fill:t,cx:`16`,cy:`4`,r:`4`})]})}),ne=(e,t)=>{for(let{alternatives:n}of e)for(let e of n)if(t(e)!==null)return},V=({children:e,commands:n=null,lang:r=`en-US`,grammars:i=null,timeout:a=3e3,silenceTimeout:o=null,precision:s=.4,maxAlternatives:c=1,continuous:l=!1,ariaLabel:u=`start recognition`,style:d=null,className:f=null,outlineStyle:p=`2px solid`,onStart:m=null,onEnd:h=null,onSpeechStart:g=null,onSpeechEnd:_=null,onResult:v=null,onError:y=null,onNoMatch:b=null,__rsInstance:x})=>{let S=(0,t.useRef)(null),[C,w]=(0,t.useState)(!1),[,{start:T,stop:E,subscribe:D,unsubscribe:O}]=I(r,i,c,l,x),k=ee(n,s),A=(0,t.useRef)({});A.current={onStart:m,onEnd:h,onSpeechStart:g,onSpeechEnd:_,onResult:v,onError:y,onNoMatch:b};let j=(0,t.useRef)(l);j.current=l;let M=(0,t.useRef)({transcript:``,event:null}),N=(0,t.useRef)(k);N.current=k;let R=(0,t.useRef)(null),z=(0,t.useRef)(null),V=(0,t.useRef)(o);V.current=o;let H=(0,t.useCallback)(()=>z.current?.(),[]),[U,W]=L(H,a),[G,K]=L(H,o??0),q=(0,t.useCallback)(()=>{try{w(!1),E()}catch(e){A.current.onError?.(e),R.current?.()}},[E]),J=(0,t.useCallback)(e=>{U(),A.current.onStart?.(e)},[U]),Y=(0,t.useCallback)(e=>{W(),A.current.onSpeechStart?.(e)},[W]),re=(0,t.useCallback)(e=>{U(),A.current.onSpeechEnd?.(e)},[U]),ie=(0,t.useCallback)(e=>{let t=Array.from(e?.results??[],e=>{let t={confidence:-1/0,transcript:``},n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(i.transcript??``),(i.confidence===void 0||i.confidence>t.confidence)&&(t=i)}return{best:t.transcript??``,alternatives:n}}),n=t.map(e=>e.best).join(``);W(),j.current?(M.current.transcript=n,M.current.event=e,V.current>0&&G()):(ne(t,N.current),q(),A.current.onResult?.(n,e))},[W,G,q]),X=(0,t.useCallback)(e=>{q(),A.current.onError?.(e)},[q]),ae=(0,t.useCallback)(e=>{W(),q(),A.current.onNoMatch?.(e)},[W,q]),Z=(0,t.useCallback)(e=>{W(),K();try{q(),R.current?.(),j.current&&M.current.transcript&&(A.current.onResult?.(M.current.transcript,M.current.event),M.current.transcript=``,M.current.event=null)}finally{A.current.onEnd?.(e)}},[W,K,q]);z.current=Z;let Q=(0,t.useMemo)(()=>({start:J,end:Z,speechstart:Y,speechend:re,result:ie,error:X,nomatch:ae}),[J,Z,Y,re,ie,X,ae]);R.current=()=>Object.entries(Q).forEach(([e,t])=>O?.(e,t));let $=(0,t.useCallback)(()=>{try{M.current.transcript=``,M.current.event=null,K(),w(!0),Object.entries(Q).forEach(([e,t])=>D(e,t)),T()}catch(e){X(e)}},[Q,D,T,K,X]),oe=()=>{!f&&p&&(S.current.style.outline=p)},se=()=>{!f&&p&&(S.current.style.outline=`none`)};return P.isSupported?F(e)?e($,q,C):(0,t.isValidElement)(e)?(0,t.cloneElement)(e,{...!C&&{onClick:$}}):(0,B.jsx)(`button`,{"data-testid":`__vocal-root__`,ref:S,"aria-label":u,"aria-pressed":C,style:f?null:{width:24,height:24,backgroundColor:`transparent`,border:`none`,padding:0,cursor:!l&&C?`default`:`pointer`,...d},className:f,onFocus:oe,onBlur:se,onClick:C?q:$,children:(0,B.jsx)(te,{isActive:C,color:`#aaa`})}):null},H=P.isSupported;e.default=V,e.isSupported=H,e.useVocal=I});
9
9
  //# sourceMappingURL=index.umd.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@untemps/react-vocal",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.0-beta.7",
4
4
  "author": "Vincent Le Badezet <v.lebadezet@untemps.net>",
5
5
  "repository": "git@github.com:untemps/react-vocal.git",
6
6
  "license": "MIT",
@@ -20,6 +20,12 @@
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
+ "files": [
24
+ "dist/index.js",
25
+ "dist/index.es.js",
26
+ "dist/index.umd.js",
27
+ "CHANGELOG.md"
28
+ ],
23
29
  "main": "dist/index.js",
24
30
  "module": "dist/index.es.js",
25
31
  "engines": {
@@ -1,32 +0,0 @@
1
- name: "Publish package"
2
- on:
3
- push:
4
- branches:
5
- - main
6
- - beta
7
- permissions:
8
- contents: write
9
- id-token: write
10
- pull-requests: write
11
- issues: write
12
- jobs:
13
- release:
14
- runs-on: ubuntu-latest
15
- env:
16
- HUSKY: '0'
17
- steps:
18
- - uses: actions/checkout@v6
19
- with:
20
- fetch-depth: 0
21
- - uses: actions/setup-node@v6
22
- with:
23
- node-version: '24'
24
- - run: yarn install --frozen-lockfile
25
- - run: yarn test:ci
26
- - run: yarn build
27
- - run: npx semantic-release
28
- env:
29
- GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
30
- - uses: codecov/codecov-action@v5
31
- with:
32
- files: coverage/lcov.info
package/.husky/commit-msg DELETED
@@ -1 +0,0 @@
1
- npx --no -- commitlint --edit "$1"
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- yarn test:ci && yarn prettier
package/.prettierignore DELETED
@@ -1,3 +0,0 @@
1
- dist/
2
- node_modules/
3
- coverage/