dictate-button 2.0.0 → 2.1.0

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 (2) hide show
  1. package/dist/dictate-button.js +373 -365
  2. package/package.json +2 -2
@@ -1,67 +1,67 @@
1
- const Pt = (t, e) => t === e, q = {
2
- equals: Pt
1
+ const Mt = (t, n) => t === n, q = {
2
+ equals: Mt
3
3
  };
4
- let gt = vt;
5
- const T = 1, H = 2, bt = {
4
+ let yt = Ct;
5
+ const T = 1, H = 2, _t = {
6
6
  owned: null,
7
7
  cleanups: null,
8
8
  context: null,
9
9
  owner: null
10
10
  };
11
11
  var y = null;
12
- let et = null, Mt = null, b = null, w = null, S = null, Q = 0;
13
- function Lt(t, e) {
14
- const n = b, s = y, r = t.length === 0, o = e === void 0 ? s : e, l = r ? bt : {
12
+ let nt = null, Ot = null, b = null, w = null, E = null, Q = 0;
13
+ function $t(t, n) {
14
+ const e = b, i = y, r = t.length === 0, o = n === void 0 ? i : n, l = r ? _t : {
15
15
  owned: null,
16
16
  cleanups: null,
17
17
  context: o ? o.context : null,
18
18
  owner: o
19
- }, i = r ? t : () => t(() => Y(() => j(l)));
19
+ }, s = r ? t : () => t(() => Y(() => j(l)));
20
20
  y = l, b = null;
21
21
  try {
22
- return B(i, !0);
22
+ return B(s, !0);
23
23
  } finally {
24
- b = n, y = s;
24
+ b = e, y = i;
25
25
  }
26
26
  }
27
- function yt(t, e) {
28
- e = e ? Object.assign({}, q, e) : q;
29
- const n = {
27
+ function wt(t, n) {
28
+ n = n ? Object.assign({}, q, n) : q;
29
+ const e = {
30
30
  value: t,
31
31
  observers: null,
32
32
  observerSlots: null,
33
- comparator: e.equals || void 0
34
- }, s = (r) => (typeof r == "function" && (r = r(n.value)), wt(n, r));
35
- return [_t.bind(n), s];
33
+ comparator: n.equals || void 0
34
+ }, i = (r) => (typeof r == "function" && (r = r(e.value)), mt(e, r));
35
+ return [vt.bind(e), i];
36
36
  }
37
- function J(t, e, n) {
38
- const s = it(t, e, !1, T);
39
- I(s);
37
+ function J(t, n, e) {
38
+ const i = ot(t, n, !1, T);
39
+ I(i);
40
40
  }
41
- function Ot(t, e, n) {
42
- gt = It;
43
- const s = it(t, e, !1, T);
44
- s.user = !0, S ? S.push(s) : I(s);
41
+ function Rt(t, n, e) {
42
+ yt = Bt;
43
+ const i = ot(t, n, !1, T);
44
+ i.user = !0, E ? E.push(i) : I(i);
45
45
  }
46
- function $t(t, e, n) {
47
- n = n ? Object.assign({}, q, n) : q;
48
- const s = it(t, e, !0, 0);
49
- return s.observers = null, s.observerSlots = null, s.comparator = n.equals || void 0, I(s), _t.bind(s);
46
+ function Nt(t, n, e) {
47
+ e = e ? Object.assign({}, q, e) : q;
48
+ const i = ot(t, n, !0, 0);
49
+ return i.observers = null, i.observerSlots = null, i.comparator = e.equals || void 0, I(i), vt.bind(i);
50
50
  }
51
51
  function Y(t) {
52
52
  if (b === null) return t();
53
- const e = b;
53
+ const n = b;
54
54
  b = null;
55
55
  try {
56
56
  return t();
57
57
  } finally {
58
- b = e;
58
+ b = n;
59
59
  }
60
60
  }
61
- function Rt(t) {
61
+ function ft(t) {
62
62
  return y === null || (y.cleanups === null ? y.cleanups = [t] : y.cleanups.push(t)), t;
63
63
  }
64
- function _t() {
64
+ function vt() {
65
65
  if (this.sources && this.state)
66
66
  if (this.state === T) I(this);
67
67
  else {
@@ -74,330 +74,330 @@ function _t() {
74
74
  }
75
75
  return this.value;
76
76
  }
77
- function wt(t, e, n) {
78
- let s = t.value;
79
- return (!t.comparator || !t.comparator(s, e)) && (t.value = e, t.observers && t.observers.length && B(() => {
77
+ function mt(t, n, e) {
78
+ let i = t.value;
79
+ return (!t.comparator || !t.comparator(i, n)) && (t.value = n, t.observers && t.observers.length && B(() => {
80
80
  for (let r = 0; r < t.observers.length; r += 1) {
81
- const o = t.observers[r], l = et && et.running;
82
- l && et.disposed.has(o), (l ? !o.tState : !o.state) && (o.pure ? w.push(o) : S.push(o), o.observers && mt(o)), l || (o.state = T);
81
+ const o = t.observers[r], l = nt && nt.running;
82
+ l && nt.disposed.has(o), (l ? !o.tState : !o.state) && (o.pure ? w.push(o) : E.push(o), o.observers && xt(o)), l || (o.state = T);
83
83
  }
84
84
  if (w.length > 1e6)
85
85
  throw w = [], new Error();
86
- }, !1)), e;
86
+ }, !1)), n;
87
87
  }
88
88
  function I(t) {
89
89
  if (!t.fn) return;
90
90
  j(t);
91
- const e = Q;
92
- Nt(t, t.value, e);
91
+ const n = Q;
92
+ jt(t, t.value, n);
93
93
  }
94
- function Nt(t, e, n) {
95
- let s;
94
+ function jt(t, n, e) {
95
+ let i;
96
96
  const r = y, o = b;
97
97
  b = y = t;
98
98
  try {
99
- s = t.fn(e);
99
+ i = t.fn(n);
100
100
  } catch (l) {
101
- return t.pure && (t.state = T, t.owned && t.owned.forEach(j), t.owned = null), t.updatedAt = n + 1, Ct(l);
101
+ return t.pure && (t.state = T, t.owned && t.owned.forEach(j), t.owned = null), t.updatedAt = e + 1, Et(l);
102
102
  } finally {
103
103
  b = o, y = r;
104
104
  }
105
- (!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? wt(t, s) : t.value = s, t.updatedAt = n);
105
+ (!t.updatedAt || t.updatedAt <= e) && (t.updatedAt != null && "observers" in t ? mt(t, i) : t.value = i, t.updatedAt = e);
106
106
  }
107
- function it(t, e, n, s = T, r) {
107
+ function ot(t, n, e, i = T, r) {
108
108
  const o = {
109
109
  fn: t,
110
- state: s,
110
+ state: i,
111
111
  updatedAt: null,
112
112
  owned: null,
113
113
  sources: null,
114
114
  sourceSlots: null,
115
115
  cleanups: null,
116
- value: e,
116
+ value: n,
117
117
  owner: y,
118
118
  context: y ? y.context : null,
119
- pure: n
119
+ pure: e
120
120
  };
121
- return y === null || y !== bt && (y.owned ? y.owned.push(o) : y.owned = [o]), o;
121
+ return y === null || y !== _t && (y.owned ? y.owned.push(o) : y.owned = [o]), o;
122
122
  }
123
123
  function G(t) {
124
124
  if (t.state === 0) return;
125
125
  if (t.state === H) return X(t);
126
126
  if (t.suspense && Y(t.suspense.inFallback)) return t.suspense.effects.push(t);
127
- const e = [t];
127
+ const n = [t];
128
128
  for (; (t = t.owner) && (!t.updatedAt || t.updatedAt < Q); )
129
- t.state && e.push(t);
130
- for (let n = e.length - 1; n >= 0; n--)
131
- if (t = e[n], t.state === T)
129
+ t.state && n.push(t);
130
+ for (let e = n.length - 1; e >= 0; e--)
131
+ if (t = n[e], t.state === T)
132
132
  I(t);
133
133
  else if (t.state === H) {
134
- const s = w;
135
- w = null, B(() => X(t, e[0]), !1), w = s;
134
+ const i = w;
135
+ w = null, B(() => X(t, n[0]), !1), w = i;
136
136
  }
137
137
  }
138
- function B(t, e) {
138
+ function B(t, n) {
139
139
  if (w) return t();
140
- let n = !1;
141
- e || (w = []), S ? n = !0 : S = [], Q++;
140
+ let e = !1;
141
+ n || (w = []), E ? e = !0 : E = [], Q++;
142
142
  try {
143
- const s = t();
144
- return jt(n), s;
145
- } catch (s) {
146
- n || (S = null), w = null, Ct(s);
143
+ const i = t();
144
+ return It(e), i;
145
+ } catch (i) {
146
+ e || (E = null), w = null, Et(i);
147
147
  }
148
148
  }
149
- function jt(t) {
150
- if (w && (vt(w), w = null), t) return;
151
- const e = S;
152
- S = null, e.length && B(() => gt(e), !1);
149
+ function It(t) {
150
+ if (w && (Ct(w), w = null), t) return;
151
+ const n = E;
152
+ E = null, n.length && B(() => yt(n), !1);
153
153
  }
154
- function vt(t) {
155
- for (let e = 0; e < t.length; e++) G(t[e]);
154
+ function Ct(t) {
155
+ for (let n = 0; n < t.length; n++) G(t[n]);
156
156
  }
157
- function It(t) {
158
- let e, n = 0;
159
- for (e = 0; e < t.length; e++) {
160
- const s = t[e];
161
- s.user ? t[n++] = s : G(s);
157
+ function Bt(t) {
158
+ let n, e = 0;
159
+ for (n = 0; n < t.length; n++) {
160
+ const i = t[n];
161
+ i.user ? t[e++] = i : G(i);
162
162
  }
163
- for (e = 0; e < n; e++) G(t[e]);
163
+ for (n = 0; n < e; n++) G(t[n]);
164
164
  }
165
- function X(t, e) {
165
+ function X(t, n) {
166
166
  t.state = 0;
167
- for (let n = 0; n < t.sources.length; n += 1) {
168
- const s = t.sources[n];
169
- if (s.sources) {
170
- const r = s.state;
171
- r === T ? s !== e && (!s.updatedAt || s.updatedAt < Q) && G(s) : r === H && X(s, e);
167
+ for (let e = 0; e < t.sources.length; e += 1) {
168
+ const i = t.sources[e];
169
+ if (i.sources) {
170
+ const r = i.state;
171
+ r === T ? i !== n && (!i.updatedAt || i.updatedAt < Q) && G(i) : r === H && X(i, n);
172
172
  }
173
173
  }
174
174
  }
175
- function mt(t) {
176
- for (let e = 0; e < t.observers.length; e += 1) {
177
- const n = t.observers[e];
178
- n.state || (n.state = H, n.pure ? w.push(n) : S.push(n), n.observers && mt(n));
175
+ function xt(t) {
176
+ for (let n = 0; n < t.observers.length; n += 1) {
177
+ const e = t.observers[n];
178
+ e.state || (e.state = H, e.pure ? w.push(e) : E.push(e), e.observers && xt(e));
179
179
  }
180
180
  }
181
181
  function j(t) {
182
- let e;
182
+ let n;
183
183
  if (t.sources)
184
184
  for (; t.sources.length; ) {
185
- const n = t.sources.pop(), s = t.sourceSlots.pop(), r = n.observers;
185
+ const e = t.sources.pop(), i = t.sourceSlots.pop(), r = e.observers;
186
186
  if (r && r.length) {
187
- const o = r.pop(), l = n.observerSlots.pop();
188
- s < r.length && (o.sourceSlots[l] = s, r[s] = o, n.observerSlots[s] = l);
187
+ const o = r.pop(), l = e.observerSlots.pop();
188
+ i < r.length && (o.sourceSlots[l] = i, r[i] = o, e.observerSlots[i] = l);
189
189
  }
190
190
  }
191
191
  if (t.tOwned) {
192
- for (e = t.tOwned.length - 1; e >= 0; e--) j(t.tOwned[e]);
192
+ for (n = t.tOwned.length - 1; n >= 0; n--) j(t.tOwned[n]);
193
193
  delete t.tOwned;
194
194
  }
195
195
  if (t.owned) {
196
- for (e = t.owned.length - 1; e >= 0; e--) j(t.owned[e]);
196
+ for (n = t.owned.length - 1; n >= 0; n--) j(t.owned[n]);
197
197
  t.owned = null;
198
198
  }
199
199
  if (t.cleanups) {
200
- for (e = t.cleanups.length - 1; e >= 0; e--) t.cleanups[e]();
200
+ for (n = t.cleanups.length - 1; n >= 0; n--) t.cleanups[n]();
201
201
  t.cleanups = null;
202
202
  }
203
203
  t.state = 0;
204
204
  }
205
- function Bt(t) {
205
+ function Dt(t) {
206
206
  return t instanceof Error ? t : new Error(typeof t == "string" ? t : "Unknown error", {
207
207
  cause: t
208
208
  });
209
209
  }
210
- function Ct(t, e = y) {
211
- throw Bt(t);
210
+ function Et(t, n = y) {
211
+ throw Dt(t);
212
212
  }
213
- function K(t, e) {
214
- return Y(() => t(e || {}));
213
+ function K(t, n) {
214
+ return Y(() => t(n || {}));
215
215
  }
216
- const V = (t) => $t(() => t());
217
- function Dt(t, e, n) {
218
- let s = n.length, r = e.length, o = s, l = 0, i = 0, a = e[r - 1].nextSibling, g = null;
219
- for (; l < r || i < o; ) {
220
- if (e[l] === n[i]) {
221
- l++, i++;
216
+ const V = (t) => Nt(() => t());
217
+ function Ut(t, n, e) {
218
+ let i = e.length, r = n.length, o = i, l = 0, s = 0, a = n[r - 1].nextSibling, g = null;
219
+ for (; l < r || s < o; ) {
220
+ if (n[l] === e[s]) {
221
+ l++, s++;
222
222
  continue;
223
223
  }
224
- for (; e[r - 1] === n[o - 1]; )
224
+ for (; n[r - 1] === e[o - 1]; )
225
225
  r--, o--;
226
226
  if (r === l) {
227
- const f = o < s ? i ? n[i - 1].nextSibling : n[o - i] : a;
228
- for (; i < o; ) t.insertBefore(n[i++], f);
229
- } else if (o === i)
227
+ const f = o < i ? s ? e[s - 1].nextSibling : e[o - s] : a;
228
+ for (; s < o; ) t.insertBefore(e[s++], f);
229
+ } else if (o === s)
230
230
  for (; l < r; )
231
- (!g || !g.has(e[l])) && e[l].remove(), l++;
232
- else if (e[l] === n[o - 1] && n[i] === e[r - 1]) {
233
- const f = e[--r].nextSibling;
234
- t.insertBefore(n[i++], e[l++].nextSibling), t.insertBefore(n[--o], f), e[r] = n[o];
231
+ (!g || !g.has(n[l])) && n[l].remove(), l++;
232
+ else if (n[l] === e[o - 1] && e[s] === n[r - 1]) {
233
+ const f = n[--r].nextSibling;
234
+ t.insertBefore(e[s++], n[l++].nextSibling), t.insertBefore(e[--o], f), n[r] = e[o];
235
235
  } else {
236
236
  if (!g) {
237
237
  g = /* @__PURE__ */ new Map();
238
- let d = i;
239
- for (; d < o; ) g.set(n[d], d++);
238
+ let d = s;
239
+ for (; d < o; ) g.set(e[d], d++);
240
240
  }
241
- const f = g.get(e[l]);
241
+ const f = g.get(n[l]);
242
242
  if (f != null)
243
- if (i < f && f < o) {
244
- let d = l, m = 1, u;
245
- for (; ++d < r && d < o && !((u = g.get(e[d])) == null || u !== f + m); )
243
+ if (s < f && f < o) {
244
+ let d = l, m = 1, c;
245
+ for (; ++d < r && d < o && !((c = g.get(n[d])) == null || c !== f + m); )
246
246
  m++;
247
- if (m > f - i) {
248
- const P = e[l];
249
- for (; i < f; ) t.insertBefore(n[i++], P);
250
- } else t.replaceChild(n[i++], e[l++]);
247
+ if (m > f - s) {
248
+ const P = n[l];
249
+ for (; s < f; ) t.insertBefore(e[s++], P);
250
+ } else t.replaceChild(e[s++], n[l++]);
251
251
  } else l++;
252
- else e[l++].remove();
252
+ else n[l++].remove();
253
253
  }
254
254
  }
255
255
  }
256
- function D(t, e, n, s) {
256
+ function D(t, n, e, i) {
257
257
  let r;
258
258
  const o = () => {
259
- const i = document.createElement("template");
260
- return i.innerHTML = t, i.content.firstChild;
259
+ const s = document.createElement("template");
260
+ return s.innerHTML = t, s.content.firstChild;
261
261
  }, l = () => (r || (r = o())).cloneNode(!0);
262
262
  return l.cloneNode = l, l;
263
263
  }
264
- function N(t, e, n) {
265
- n == null ? t.removeAttribute(e) : t.setAttribute(e, n);
264
+ function N(t, n, e) {
265
+ e == null ? t.removeAttribute(n) : t.setAttribute(n, e);
266
266
  }
267
- function Ut(t, e, n) {
268
- if (!e) return n ? N(t, "style") : e;
269
- const s = t.style;
270
- if (typeof e == "string") return s.cssText = e;
271
- typeof n == "string" && (s.cssText = n = void 0), n || (n = {}), e || (e = {});
267
+ function zt(t, n, e) {
268
+ if (!n) return e ? N(t, "style") : n;
269
+ const i = t.style;
270
+ if (typeof n == "string") return i.cssText = n;
271
+ typeof e == "string" && (i.cssText = e = void 0), e || (e = {}), n || (n = {});
272
272
  let r, o;
273
- for (o in n)
274
- e[o] == null && s.removeProperty(o), delete n[o];
275
273
  for (o in e)
276
- r = e[o], r !== n[o] && (s.setProperty(o, r), n[o] = r);
277
- return n;
278
- }
279
- function zt(t, e, n) {
280
- return Y(() => t(e, n));
281
- }
282
- function L(t, e, n, s) {
283
- if (n !== void 0 && !s && (s = []), typeof e != "function") return Z(t, e, s, n);
284
- J((r) => Z(t, e(), r, n), s);
285
- }
286
- function Z(t, e, n, s, r) {
287
- for (; typeof n == "function"; ) n = n();
288
- if (e === n) return n;
289
- const o = typeof e, l = s !== void 0;
290
- if (t = l && n[0] && n[0].parentNode || t, o === "string" || o === "number") {
291
- if (o === "number" && (e = e.toString(), e === n))
292
- return n;
274
+ n[o] == null && i.removeProperty(o), delete e[o];
275
+ for (o in n)
276
+ r = n[o], r !== e[o] && (i.setProperty(o, r), e[o] = r);
277
+ return e;
278
+ }
279
+ function Ft(t, n, e) {
280
+ return Y(() => t(n, e));
281
+ }
282
+ function M(t, n, e, i) {
283
+ if (e !== void 0 && !i && (i = []), typeof n != "function") return Z(t, n, i, e);
284
+ J((r) => Z(t, n(), r, e), i);
285
+ }
286
+ function Z(t, n, e, i, r) {
287
+ for (; typeof e == "function"; ) e = e();
288
+ if (n === e) return e;
289
+ const o = typeof n, l = i !== void 0;
290
+ if (t = l && e[0] && e[0].parentNode || t, o === "string" || o === "number") {
291
+ if (o === "number" && (n = n.toString(), n === e))
292
+ return e;
293
293
  if (l) {
294
- let i = n[0];
295
- i && i.nodeType === 3 ? i.data !== e && (i.data = e) : i = document.createTextNode(e), n = $(t, n, s, i);
294
+ let s = e[0];
295
+ s && s.nodeType === 3 ? s.data !== n && (s.data = n) : s = document.createTextNode(n), e = $(t, e, i, s);
296
296
  } else
297
- n !== "" && typeof n == "string" ? n = t.firstChild.data = e : n = t.textContent = e;
298
- } else if (e == null || o === "boolean")
299
- n = $(t, n, s);
297
+ e !== "" && typeof e == "string" ? e = t.firstChild.data = n : e = t.textContent = n;
298
+ } else if (n == null || o === "boolean")
299
+ e = $(t, e, i);
300
300
  else {
301
301
  if (o === "function")
302
302
  return J(() => {
303
- let i = e();
304
- for (; typeof i == "function"; ) i = i();
305
- n = Z(t, i, n, s);
306
- }), () => n;
307
- if (Array.isArray(e)) {
308
- const i = [], a = n && Array.isArray(n);
309
- if (st(i, e, n, r))
310
- return J(() => n = Z(t, i, n, s, !0)), () => n;
311
- if (i.length === 0) {
312
- if (n = $(t, n, s), l) return n;
313
- } else a ? n.length === 0 ? ut(t, i, s) : Dt(t, n, i) : (n && $(t), ut(t, i));
314
- n = i;
315
- } else if (e.nodeType) {
316
- if (Array.isArray(n)) {
317
- if (l) return n = $(t, n, s, e);
318
- $(t, n, null, e);
319
- } else n == null || n === "" || !t.firstChild ? t.appendChild(e) : t.replaceChild(e, t.firstChild);
320
- n = e;
303
+ let s = n();
304
+ for (; typeof s == "function"; ) s = s();
305
+ e = Z(t, s, e, i);
306
+ }), () => e;
307
+ if (Array.isArray(n)) {
308
+ const s = [], a = e && Array.isArray(e);
309
+ if (st(s, n, e, r))
310
+ return J(() => e = Z(t, s, e, i, !0)), () => e;
311
+ if (s.length === 0) {
312
+ if (e = $(t, e, i), l) return e;
313
+ } else a ? e.length === 0 ? dt(t, s, i) : Ut(t, e, s) : (e && $(t), dt(t, s));
314
+ e = s;
315
+ } else if (n.nodeType) {
316
+ if (Array.isArray(e)) {
317
+ if (l) return e = $(t, e, i, n);
318
+ $(t, e, null, n);
319
+ } else e == null || e === "" || !t.firstChild ? t.appendChild(n) : t.replaceChild(n, t.firstChild);
320
+ e = n;
321
321
  }
322
322
  }
323
- return n;
323
+ return e;
324
324
  }
325
- function st(t, e, n, s) {
325
+ function st(t, n, e, i) {
326
326
  let r = !1;
327
- for (let o = 0, l = e.length; o < l; o++) {
328
- let i = e[o], a = n && n[t.length], g;
329
- if (!(i == null || i === !0 || i === !1)) if ((g = typeof i) == "object" && i.nodeType)
330
- t.push(i);
331
- else if (Array.isArray(i))
332
- r = st(t, i, a) || r;
327
+ for (let o = 0, l = n.length; o < l; o++) {
328
+ let s = n[o], a = e && e[t.length], g;
329
+ if (!(s == null || s === !0 || s === !1)) if ((g = typeof s) == "object" && s.nodeType)
330
+ t.push(s);
331
+ else if (Array.isArray(s))
332
+ r = st(t, s, a) || r;
333
333
  else if (g === "function")
334
- if (s) {
335
- for (; typeof i == "function"; ) i = i();
336
- r = st(t, Array.isArray(i) ? i : [i], Array.isArray(a) ? a : [a]) || r;
334
+ if (i) {
335
+ for (; typeof s == "function"; ) s = s();
336
+ r = st(t, Array.isArray(s) ? s : [s], Array.isArray(a) ? a : [a]) || r;
337
337
  } else
338
- t.push(i), r = !0;
338
+ t.push(s), r = !0;
339
339
  else {
340
- const f = String(i);
340
+ const f = String(s);
341
341
  a && a.nodeType === 3 && a.data === f ? t.push(a) : t.push(document.createTextNode(f));
342
342
  }
343
343
  }
344
344
  return r;
345
345
  }
346
- function ut(t, e, n = null) {
347
- for (let s = 0, r = e.length; s < r; s++) t.insertBefore(e[s], n);
346
+ function dt(t, n, e = null) {
347
+ for (let i = 0, r = n.length; i < r; i++) t.insertBefore(n[i], e);
348
348
  }
349
- function $(t, e, n, s) {
350
- if (n === void 0) return t.textContent = "";
351
- const r = s || document.createTextNode("");
352
- if (e.length) {
349
+ function $(t, n, e, i) {
350
+ if (e === void 0) return t.textContent = "";
351
+ const r = i || document.createTextNode("");
352
+ if (n.length) {
353
353
  let o = !1;
354
- for (let l = e.length - 1; l >= 0; l--) {
355
- const i = e[l];
356
- if (r !== i) {
357
- const a = i.parentNode === t;
358
- !o && !l ? a ? t.replaceChild(r, i) : t.insertBefore(r, n) : a && i.remove();
354
+ for (let l = n.length - 1; l >= 0; l--) {
355
+ const s = n[l];
356
+ if (r !== s) {
357
+ const a = s.parentNode === t;
358
+ !o && !l ? a ? t.replaceChild(r, s) : t.insertBefore(r, e) : a && s.remove();
359
359
  } else o = !0;
360
360
  }
361
- } else t.insertBefore(r, n);
361
+ } else t.insertBefore(r, e);
362
362
  return [r];
363
363
  }
364
- function Ft(t) {
365
- return Object.keys(t).reduce((n, s) => {
366
- const r = t[s];
367
- return n[s] = Object.assign({}, r), St(r.value) && !Ht(r.value) && !Array.isArray(r.value) && (n[s].value = Object.assign({}, r.value)), Array.isArray(r.value) && (n[s].value = r.value.slice(0)), n;
364
+ function Wt(t) {
365
+ return Object.keys(t).reduce((e, i) => {
366
+ const r = t[i];
367
+ return e[i] = Object.assign({}, r), At(r.value) && !Jt(r.value) && !Array.isArray(r.value) && (e[i].value = Object.assign({}, r.value)), Array.isArray(r.value) && (e[i].value = r.value.slice(0)), e;
368
368
  }, {});
369
369
  }
370
- function Wt(t) {
371
- return t ? Object.keys(t).reduce((n, s) => {
372
- const r = t[s];
373
- return n[s] = St(r) && "value" in r ? r : {
370
+ function Kt(t) {
371
+ return t ? Object.keys(t).reduce((e, i) => {
372
+ const r = t[i];
373
+ return e[i] = At(r) && "value" in r ? r : {
374
374
  value: r
375
- }, n[s].attribute || (n[s].attribute = qt(s)), n[s].parse = "parse" in n[s] ? n[s].parse : typeof n[s].value != "string", n;
375
+ }, e[i].attribute || (e[i].attribute = Ht(i)), e[i].parse = "parse" in e[i] ? e[i].parse : typeof e[i].value != "string", e;
376
376
  }, {}) : {};
377
377
  }
378
- function Kt(t) {
379
- return Object.keys(t).reduce((n, s) => (n[s] = t[s].value, n), {});
378
+ function Vt(t) {
379
+ return Object.keys(t).reduce((e, i) => (e[i] = t[i].value, e), {});
380
380
  }
381
- function Vt(t, e) {
382
- const n = Ft(e);
383
- return Object.keys(e).forEach((r) => {
384
- const o = n[r], l = t.getAttribute(o.attribute), i = t[r];
385
- l != null && (o.value = o.parse ? xt(l) : l), i != null && (o.value = Array.isArray(i) ? i.slice(0) : i), o.reflect && ft(t, o.attribute, o.value, !!o.parse), Object.defineProperty(t, r, {
381
+ function qt(t, n) {
382
+ const e = Wt(n);
383
+ return Object.keys(n).forEach((r) => {
384
+ const o = e[r], l = t.getAttribute(o.attribute), s = t[r];
385
+ l != null && (o.value = o.parse ? St(l) : l), s != null && (o.value = Array.isArray(s) ? s.slice(0) : s), o.reflect && pt(t, o.attribute, o.value, !!o.parse), Object.defineProperty(t, r, {
386
386
  get() {
387
387
  return o.value;
388
388
  },
389
389
  set(a) {
390
390
  const g = o.value;
391
- o.value = a, o.reflect && ft(this, o.attribute, o.value, !!o.parse);
391
+ o.value = a, o.reflect && pt(this, o.attribute, o.value, !!o.parse);
392
392
  for (let f = 0, d = this.__propertyChangedCallbacks.length; f < d; f++)
393
393
  this.__propertyChangedCallbacks[f](r, a, g);
394
394
  },
395
395
  enumerable: !0,
396
396
  configurable: !0
397
397
  });
398
- }), n;
398
+ }), e;
399
399
  }
400
- function xt(t) {
400
+ function St(t) {
401
401
  if (t)
402
402
  try {
403
403
  return JSON.parse(t);
@@ -405,47 +405,47 @@ function xt(t) {
405
405
  return t;
406
406
  }
407
407
  }
408
- function ft(t, e, n, s) {
409
- if (n == null || n === !1) return t.removeAttribute(e);
410
- let r = s ? JSON.stringify(n) : n;
411
- t.__updating[e] = !0, r === "true" && (r = ""), t.setAttribute(e, r), Promise.resolve().then(() => delete t.__updating[e]);
408
+ function pt(t, n, e, i) {
409
+ if (e == null || e === !1) return t.removeAttribute(n);
410
+ let r = i ? JSON.stringify(e) : e;
411
+ t.__updating[n] = !0, r === "true" && (r = ""), t.setAttribute(n, r), Promise.resolve().then(() => delete t.__updating[n]);
412
412
  }
413
- function qt(t) {
414
- return t.replace(/\.?([A-Z]+)/g, (e, n) => "-" + n.toLowerCase()).replace("_", "-").replace(/^-/, "");
413
+ function Ht(t) {
414
+ return t.replace(/\.?([A-Z]+)/g, (n, e) => "-" + e.toLowerCase()).replace("_", "-").replace(/^-/, "");
415
415
  }
416
- function St(t) {
416
+ function At(t) {
417
417
  return t != null && (typeof t == "object" || typeof t == "function");
418
418
  }
419
- function Ht(t) {
419
+ function Jt(t) {
420
420
  return Object.prototype.toString.call(t) === "[object Function]";
421
421
  }
422
- function Jt(t) {
422
+ function Gt(t) {
423
423
  return typeof t == "function" && t.toString().indexOf("class") === 0;
424
424
  }
425
- let nt;
426
- function Gt(t, e) {
427
- const n = Object.keys(e);
425
+ let rt;
426
+ function Xt(t, n) {
427
+ const e = Object.keys(n);
428
428
  return class extends t {
429
429
  static get observedAttributes() {
430
- return n.map((r) => e[r].attribute);
430
+ return e.map((r) => n[r].attribute);
431
431
  }
432
432
  constructor() {
433
433
  super(), this.__initialized = !1, this.__released = !1, this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props = {};
434
- for (let r of n)
434
+ for (let r of e)
435
435
  this[r] = void 0;
436
436
  }
437
437
  connectedCallback() {
438
438
  if (this.__initialized) return;
439
- this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props = Vt(this, e);
440
- const r = Kt(this.props), o = this.Component, l = nt;
439
+ this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props = qt(this, n);
440
+ const r = Vt(this.props), o = this.Component, l = rt;
441
441
  try {
442
- nt = this, this.__initialized = !0, Jt(o) ? new o(r, {
442
+ rt = this, this.__initialized = !0, Gt(o) ? new o(r, {
443
443
  element: this
444
444
  }) : o(r, {
445
445
  element: this
446
446
  });
447
447
  } finally {
448
- nt = l;
448
+ rt = l;
449
449
  }
450
450
  }
451
451
  async disconnectedCallback() {
@@ -456,14 +456,14 @@ function Gt(t, e) {
456
456
  delete this.__initialized, this.__released = !0;
457
457
  }
458
458
  attributeChangedCallback(r, o, l) {
459
- if (this.__initialized && !this.__updating[r] && (r = this.lookupProp(r), r in e)) {
459
+ if (this.__initialized && !this.__updating[r] && (r = this.lookupProp(r), r in n)) {
460
460
  if (l == null && !this[r]) return;
461
- this[r] = e[r].parse ? xt(l) : l;
461
+ this[r] = n[r].parse ? St(l) : l;
462
462
  }
463
463
  }
464
464
  lookupProp(r) {
465
- if (e)
466
- return n.find((o) => r === o || r === e[o].attribute);
465
+ if (n)
466
+ return e.find((o) => r === o || r === n[o].attribute);
467
467
  }
468
468
  get renderRoot() {
469
469
  return this.shadowRoot || this.attachShadow({
@@ -478,54 +478,54 @@ function Gt(t, e) {
478
478
  }
479
479
  };
480
480
  }
481
- function Xt(t, e = {}, n = {}) {
481
+ function Zt(t, n = {}, e = {}) {
482
482
  const {
483
- BaseElement: s = HTMLElement,
483
+ BaseElement: i = HTMLElement,
484
484
  extension: r,
485
485
  customElements: o = window.customElements
486
- } = n;
486
+ } = e;
487
487
  return (l) => {
488
- let i = o.get(t);
489
- return i ? (i.prototype.Component = l, i) : (i = Gt(s, Wt(e)), i.prototype.Component = l, i.prototype.registeredTag = t, o.define(t, i, r), i);
488
+ let s = o.get(t);
489
+ return s ? (s.prototype.Component = l, s) : (s = Xt(i, Kt(n)), s.prototype.Component = l, s.prototype.registeredTag = t, o.define(t, s, r), s);
490
490
  };
491
491
  }
492
- function Zt(t) {
493
- const e = Object.keys(t), n = {};
494
- for (let s = 0; s < e.length; s++) {
495
- const [r, o] = yt(t[e[s]]);
496
- Object.defineProperty(n, e[s], {
492
+ function Qt(t) {
493
+ const n = Object.keys(t), e = {};
494
+ for (let i = 0; i < n.length; i++) {
495
+ const [r, o] = wt(t[n[i]]);
496
+ Object.defineProperty(e, n[i], {
497
497
  get: r,
498
498
  set(l) {
499
499
  o(() => l);
500
500
  }
501
501
  });
502
502
  }
503
- return n;
504
- }
505
- function Qt(t) {
506
- if (t.assignedSlot && t.assignedSlot._$owner) return t.assignedSlot._$owner;
507
- let e = t.parentNode;
508
- for (; e && !e._$owner && !(e.assignedSlot && e.assignedSlot._$owner); )
509
- e = e.parentNode;
510
- return e && e.assignedSlot ? e.assignedSlot._$owner : t._$owner;
503
+ return e;
511
504
  }
512
505
  function Yt(t) {
513
- return (e, n) => {
514
- const { element: s } = n;
515
- return Lt((r) => {
516
- const o = Zt(e);
517
- s.addPropertyChangedCallback((i, a) => o[i] = a), s.addReleaseCallback(() => {
518
- s.renderRoot.textContent = "", r();
506
+ if (t.assignedSlot && t.assignedSlot._$owner) return t.assignedSlot._$owner;
507
+ let n = t.parentNode;
508
+ for (; n && !n._$owner && !(n.assignedSlot && n.assignedSlot._$owner); )
509
+ n = n.parentNode;
510
+ return n && n.assignedSlot ? n.assignedSlot._$owner : t._$owner;
511
+ }
512
+ function te(t) {
513
+ return (n, e) => {
514
+ const { element: i } = e;
515
+ return $t((r) => {
516
+ const o = Qt(n);
517
+ i.addPropertyChangedCallback((s, a) => o[s] = a), i.addReleaseCallback(() => {
518
+ i.renderRoot.textContent = "", r();
519
519
  });
520
- const l = t(o, n);
521
- return L(s.renderRoot, l);
522
- }, Qt(s));
520
+ const l = t(o, e);
521
+ return M(i.renderRoot, l);
522
+ }, Yt(i));
523
523
  };
524
524
  }
525
- function te(t, e, n) {
526
- return arguments.length === 2 && (n = e, e = {}), Xt(t, e)(Yt(n));
525
+ function ee(t, n, e) {
526
+ return arguments.length === 2 && (e = n, n = {}), Zt(t, n)(te(e));
527
527
  }
528
- const ee = `
528
+ const ne = `
529
529
  :host([theme="dark"]) {
530
530
  color-scheme: only dark;
531
531
  }
@@ -583,44 +583,50 @@ const ee = `
583
583
  }
584
584
  }
585
585
  `;
586
- var ne = /* @__PURE__ */ D('<div part=container class=dictate-button__container><style></style><div aria-live=polite class=dictate-button__status-announcer style="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"></div><button part=button class=dictate-button__button>'), re = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--idle"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor role=img aria-hidden=true><path stroke-linecap=round stroke-linejoin=round d="M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1 6 0v8.25a3 3 0 0 1-3 3Z">'), se = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--recording"viewBox="0 0 24 24"fill=currentColor role=img aria-hidden=true><circle cx=12 cy=12 r=10>'), ie = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--error"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=4 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><line x1=12 x2=12 y1=4 y2=14></line><line x1=12 x2=12.01 y1=20 y2=20>'), oe = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--processing"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><path d="M12 2v4"></path><path d="M12 18v4"></path><path d="M4.93 4.93l2.83 2.83"></path><path d="M16.24 16.24l2.83 2.83"></path><path d="M2 12h4"></path><path d="M18 12h4"></path><path d="M4.93 19.07l2.83-2.83"></path><path d="M16.24 7.76l2.83-2.83">');
587
- console.debug("[dictate-button] version:", "2.0.0");
588
- const le = "wss://api.dictate-button.io/v2/transcribe", k = "dictate-button.io", rt = -70, dt = -10, pt = 0, ae = 4, ce = 0.25, ue = 0.05;
589
- customElements.get("dictate-button") ? console.debug("[dictate-button] We don't require importing the dictate-button component separately anymore, so you may remove the script tag which imports https://cdn.dictate-button.io/dictate-button.js from the HTML head.") : te("dictate-button", {
586
+ var re = /* @__PURE__ */ D('<div part=container class=dictate-button__container><style></style><div aria-live=polite class=dictate-button__status-announcer style="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"></div><button part=button class=dictate-button__button>'), ie = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--idle"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor role=img aria-hidden=true><path stroke-linecap=round stroke-linejoin=round d="M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1 6 0v8.25a3 3 0 0 1-3 3Z">'), se = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--recording"viewBox="0 0 24 24"fill=currentColor role=img aria-hidden=true><circle cx=12 cy=12 r=10>'), oe = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--error"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=4 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><line x1=12 x2=12 y1=4 y2=14></line><line x1=12 x2=12.01 y1=20 y2=20>'), le = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--processing"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><path d="M12 2v4"></path><path d="M12 18v4"></path><path d="M4.93 4.93l2.83 2.83"></path><path d="M16.24 16.24l2.83 2.83"></path><path d="M2 12h4"></path><path d="M18 12h4"></path><path d="M4.93 19.07l2.83-2.83"></path><path d="M16.24 7.76l2.83-2.83">');
587
+ console.debug("[dictate-button] version:", "2.1.0");
588
+ const ae = "wss://api.dictate-button.io/v2/transcribe", k = "dictate-button.io", it = -70, ht = -10, gt = 0, ce = 4, ue = 0.25, fe = 0.05;
589
+ customElements.get("dictate-button") ? console.debug("[dictate-button] We don't require importing the dictate-button component separately anymore, so you may remove the script tag which imports https://cdn.dictate-button.io/dictate-button.js from the HTML head.") : ee("dictate-button", {
590
590
  size: 30,
591
- apiEndpoint: le,
591
+ apiEndpoint: ae,
592
592
  language: "en"
593
593
  }, (t, {
594
- element: e
594
+ element: n
595
595
  }) => {
596
596
  console.debug("[dictate-button] api:", t.apiEndpoint);
597
- const [n, s] = yt("idle");
598
- let r = null, o = null, l = null, i = "", a = "", g = -1, f = "", d = null, m = null, u = null, P = null, U = !1, R = 0;
599
- const Et = (c) => c <= rt ? 0 : c >= dt ? 1 : (c - rt) / (dt - rt), At = (c) => {
597
+ const [e, i] = wt("idle");
598
+ let r = null, o = null, l = null, s = "", a = "", g = -1, f = "", d = null, m = null, c = null, P = null, U = !1, R = 0;
599
+ const kt = (u) => u <= it ? 0 : u >= ht ? 1 : (u - it) / (ht - it), Tt = (u) => {
600
600
  let _ = 0;
601
- for (let C = 0; C < c.length; C++) {
602
- const p = (c[C] - 128) / 128;
601
+ for (let C = 0; C < u.length; C++) {
602
+ const p = (u[C] - 128) / 128;
603
603
  _ += p * p;
604
604
  }
605
- return Math.sqrt(_ / c.length);
606
- }, kt = (c) => 20 * Math.log10(Math.max(c, 1e-8)), ot = (c) => {
607
- const _ = e.shadowRoot.querySelector(".dictate-button__button");
605
+ return Math.sqrt(_ / u.length);
606
+ }, Pt = (u) => 20 * Math.log10(Math.max(u, 1e-8)), lt = (u) => {
607
+ const _ = n.shadowRoot.querySelector(".dictate-button__button");
608
608
  if (!_)
609
609
  return;
610
- const C = pt + c * (ae - pt), p = 0 + c * 0.4;
610
+ const C = gt + u * (ce - gt), p = 0 + u * 0.4;
611
611
  _.style.boxShadow = `0 0 0 ${C}px light-dark(rgba(0, 0, 0, ${p}), rgba(255, 255, 255, ${p}))`;
612
- }, lt = () => {
612
+ }, at = () => {
613
613
  if (!U || !m || !P) return;
614
614
  m.getByteTimeDomainData(P);
615
- const c = At(P), _ = kt(c), C = Et(_), p = C > R ? ce : ue;
616
- R = p * C + (1 - p) * R, ot(R), requestAnimationFrame(lt);
615
+ const u = Tt(P), _ = Pt(u), C = kt(_), p = C > R ? ue : fe;
616
+ R = p * C + (1 - p) * R, lt(R), requestAnimationFrame(at);
617
617
  }, O = () => {
618
- r && (r.close(), r = null), u && (u.disconnect(), u = null), o && (o.getTracks().forEach((c) => c.stop()), o = null), l = null, i = "", a = "", g = -1, f = "", U = !1, d && d.state !== "closed" && d.close(), d = null, m = null, P = null, R = 0, ot(0);
618
+ r && (r.close(), r = null), c && (c.disconnect(), c = null), o && (o.getTracks().forEach((u) => u.stop()), o = null), l = null, s = "", a = "", g = -1, f = "", U = !1, d && d.state !== "closed" && d.close(), d = null, m = null, P = null, R = 0, lt(0);
619
619
  };
620
- e.addEventListener("disconnected", O);
621
- const at = async (c) => {
622
- if (n() === "idle") {
623
- l = c, i = "", a = "", g = -1, f = "";
620
+ n.addEventListener("disconnected", O);
621
+ const ct = () => {
622
+ document.visibilityState === "hidden" && e() === "transcribing" && tt();
623
+ };
624
+ document.addEventListener("visibilitychange", ct), ft(() => {
625
+ document.removeEventListener("visibilitychange", ct);
626
+ });
627
+ const ut = async (u) => {
628
+ if (e() === "idle") {
629
+ l = u, s = "", a = "", g = -1, f = "";
624
630
  try {
625
631
  const _ = await navigator.mediaDevices.getUserMedia({
626
632
  audio: {
@@ -655,94 +661,94 @@ customElements.get("dictate-button") ? console.debug("[dictate-button] We don't
655
661
  `, F = new Blob([p], {
656
662
  type: "application/javascript"
657
663
  }), h = URL.createObjectURL(F);
658
- await d.audioWorklet.addModule(h), URL.revokeObjectURL(h), u = new AudioWorkletNode(d, "pcm-processor"), C.connect(u);
664
+ await d.audioWorklet.addModule(h), URL.revokeObjectURL(h), c = new AudioWorkletNode(d, "pcm-processor"), C.connect(c);
659
665
  const W = new URL(t.apiEndpoint);
660
- t.language && W.searchParams.set("language", t.language), r = new WebSocket(W.toString()), r.onmessage = (E) => {
666
+ t.language && W.searchParams.set("language", t.language), r = new WebSocket(W.toString()), r.onmessage = (S) => {
661
667
  try {
662
- const v = JSON.parse(E.data);
668
+ const v = JSON.parse(S.data);
663
669
  if (v.type === "interim_transcript" && v.text) {
664
670
  f = v.text;
665
- const M = [a, i, f].filter(Boolean).join(" ");
666
- A(e, "dictate-text", M);
671
+ const L = [a, s, f].filter(Boolean).join(" ");
672
+ A(n, "dictate-text", L);
667
673
  } else if (v.type === "transcript" && v.text) {
668
- const M = v.turn_order ?? 0, x = v.text;
669
- f = "", M > g ? (i && (a = a ? a + " " + i : i), g = M, i = x) : x.length > i.length && x.startsWith(i.substring(0, Math.min(10, i.length))) ? i = x : i = i ? i + " " + x : x;
670
- const Tt = a ? a + " " + i : i;
671
- A(e, "dictate-text", Tt);
672
- } else v.type === "error" && (console.error("[dictate-button] Server error:", v.error), A(e, "dictate-error", v.error), tt(), O());
674
+ const L = v.turn_order ?? 0, x = v.text;
675
+ f = "", L > g ? (s && (a = a ? a + " " + s : s), g = L, s = x) : x.length > s.length && x.startsWith(s.substring(0, Math.min(10, s.length))) ? s = x : s = s ? s + " " + x : x;
676
+ const Lt = a ? a + " " + s : s;
677
+ A(n, "dictate-text", Lt);
678
+ } else v.type === "error" && (console.error("[dictate-button] Server error:", v.error), A(n, "dictate-error", v.error), et(), O());
673
679
  } catch (v) {
674
680
  console.error("[dictate-button] Error parsing message:", v);
675
681
  }
676
- }, r.onerror = (E) => {
677
- console.error("[dictate-button] WebSocket error:", E), A(e, "dictate-error", "Connection error"), tt(), O();
682
+ }, r.onerror = (S) => {
683
+ console.error("[dictate-button] WebSocket error:", S), A(n, "dictate-error", "Connection error"), et(), O();
678
684
  }, r.onclose = () => {
679
- }, u.port.onmessage = (E) => {
680
- r && r.readyState === WebSocket.OPEN && r.send(E.data);
681
- }, A(e, "dictate-start", "Started transcribing"), U = !0, lt(), s("transcribing");
685
+ }, c.port.onmessage = (S) => {
686
+ r && r.readyState === WebSocket.OPEN && r.send(S.data);
687
+ }, A(n, "dictate-start", "Started transcribing"), U = !0, at(), i("transcribing");
682
688
  } catch (_) {
683
- console.error("[dictate-button] Failed to start:", _), A(e, "dictate-error", "Failed to start transcription"), tt(), O();
689
+ console.error("[dictate-button] Failed to start:", _), A(n, "dictate-error", "Failed to start transcription"), et(), O();
684
690
  }
685
691
  }
686
- }, ct = () => {
687
- if (n() === "transcribing")
688
- if (U = !1, s("finalizing"), r && r.readyState === WebSocket.OPEN)
692
+ }, tt = () => {
693
+ if (e() === "transcribing")
694
+ if (U = !1, i("finalizing"), r && r.readyState === WebSocket.OPEN)
689
695
  r.send(JSON.stringify({
690
696
  type: "close"
691
697
  })), setTimeout(() => {
692
- const c = a ? a + (i ? " " + i : "") : i;
693
- c && A(e, "dictate-end", c), O(), s("idle");
698
+ const u = a ? a + (s ? " " + s : "") : s;
699
+ u && A(n, "dictate-end", u), O(), i("idle");
694
700
  }, 500);
695
701
  else {
696
- const c = a ? a + (i ? " " + i : "") : i;
697
- c && A(e, "dictate-end", c), O(), s("idle");
702
+ const u = a ? a + (s ? " " + s : "") : s;
703
+ u && A(n, "dictate-end", u), O(), i("idle");
698
704
  }
699
- }, tt = () => {
700
- s("error"), setTimeout(() => s("idle"), 2e3);
705
+ }, et = () => {
706
+ i("error"), setTimeout(() => i("idle"), 2e3);
701
707
  };
702
708
  let z;
703
- return Ot(() => {
709
+ return Rt(() => {
704
710
  if (!z) return;
705
- const c = be(z, {
711
+ const u = ye(z, {
706
712
  onShortTap: () => {
707
- n() === "idle" ? at("short-tap") : n() === "transcribing" && l === "short-tap" && ct();
713
+ e() === "idle" ? ut("short-tap") : e() === "transcribing" && l === "short-tap" && tt();
708
714
  },
709
715
  onLongPressStart: () => {
710
- n() === "idle" && at("long-press");
716
+ e() === "idle" && ut("long-press");
711
717
  },
712
718
  onLongPressEnd: () => {
713
- n() === "transcribing" && l === "long-press" && ct();
719
+ e() === "transcribing" && l === "long-press" && tt();
714
720
  }
715
721
  });
716
- Rt(c);
722
+ ft(u);
717
723
  }), (() => {
718
- var c = ne(), _ = c.firstChild, C = _.nextSibling, p = C.nextSibling;
719
- L(_, ee), L(C, () => ht(n()));
724
+ var u = re(), _ = u.firstChild, C = _.nextSibling, p = C.nextSibling;
725
+ M(_, ne), M(C, () => bt(e()));
720
726
  var F = z;
721
- return typeof F == "function" ? zt(F, p) : z = p, L(p, (() => {
722
- var h = V(() => n() === "idle");
723
- return () => h() && K(de, {});
724
- })(), null), L(p, (() => {
725
- var h = V(() => n() === "transcribing");
727
+ return typeof F == "function" ? Ft(F, p) : z = p, M(p, (() => {
728
+ var h = V(() => e() === "idle");
726
729
  return () => h() && K(pe, {});
727
- })(), null), L(p, (() => {
728
- var h = V(() => n() === "finalizing");
729
- return () => h() && K(ge, {});
730
- })(), null), L(p, (() => {
731
- var h = V(() => n() === "error");
730
+ })(), null), M(p, (() => {
731
+ var h = V(() => e() === "transcribing");
732
732
  return () => h() && K(he, {});
733
+ })(), null), M(p, (() => {
734
+ var h = V(() => e() === "finalizing");
735
+ return () => h() && K(be, {});
736
+ })(), null), M(p, (() => {
737
+ var h = V(() => e() === "error");
738
+ return () => h() && K(ge, {});
733
739
  })(), null), J((h) => {
734
- var W = `width:${t.size}px;height:${t.size}px"`, E = fe(n()), v = ht(n()), M = n() === "transcribing", x = n() === "transcribing" || n() === "finalizing";
735
- return h.e = Ut(p, W, h.e), E !== h.t && N(p, "title", h.t = E), v !== h.a && N(p, "aria-label", h.a = v), M !== h.o && N(p, "aria-pressed", h.o = M), x !== h.i && N(p, "aria-busy", h.i = x), h;
740
+ var W = `width:${t.size}px;height:${t.size}px"`, S = de(e()), v = bt(e()), L = e() === "transcribing", x = e() === "transcribing" || e() === "finalizing";
741
+ return h.e = zt(p, W, h.e), S !== h.t && N(p, "title", h.t = S), v !== h.a && N(p, "aria-label", h.a = v), L !== h.o && N(p, "aria-pressed", h.o = L), x !== h.i && N(p, "aria-busy", h.i = x), h;
736
742
  }, {
737
743
  e: void 0,
738
744
  t: void 0,
739
745
  a: void 0,
740
746
  o: void 0,
741
747
  i: void 0
742
- }), c;
748
+ }), u;
743
749
  })();
744
750
  });
745
- const fe = (t) => {
751
+ const de = (t) => {
746
752
  switch (t) {
747
753
  case "idle":
748
754
  return `Start dictation (${k})`;
@@ -753,7 +759,7 @@ const fe = (t) => {
753
759
  case "error":
754
760
  return `Click to reset (${k})`;
755
761
  }
756
- }, ht = (t) => {
762
+ }, bt = (t) => {
757
763
  switch (t) {
758
764
  case "idle":
759
765
  return `Start dictation (${k})`;
@@ -764,39 +770,41 @@ const fe = (t) => {
764
770
  case "error":
765
771
  return `Dictation error. Click to reset (${k})`;
766
772
  }
767
- }, A = (t, e, n) => {
768
- t.dispatchEvent(new CustomEvent(e, {
769
- detail: n,
773
+ }, A = (t, n, e) => {
774
+ t.dispatchEvent(new CustomEvent(n, {
775
+ detail: e,
770
776
  bubbles: !0,
771
777
  composed: !0
772
778
  }));
773
- }, de = () => re(), pe = () => se(), he = () => ie(), ge = () => oe();
774
- function be(t, {
775
- threshold: e = 500,
776
- preventScroll: n = !0,
777
- onShortTap: s,
779
+ }, pe = () => ie(), he = () => se(), ge = () => oe(), be = () => le();
780
+ function ye(t, {
781
+ threshold: n = 500,
782
+ preventScroll: e = !0,
783
+ onShortTap: i,
778
784
  onLongPressStart: r,
779
785
  onLongPressEnd: o
780
786
  } = {}) {
781
- let l, i = !1;
782
- const a = (u) => u.preventDefault(), g = (u) => {
783
- l && clearTimeout(l), i = !1, u.preventDefault(), t.setPointerCapture(u.pointerId), l = window.setTimeout(() => {
784
- i = !0, r?.(u), t.dispatchEvent(new CustomEvent("longpress", {
785
- detail: u
787
+ let l, s = !1;
788
+ const a = (c) => c.preventDefault(), g = (c) => {
789
+ l && clearTimeout(l), s = !1, c.preventDefault(), t.setPointerCapture(c.pointerId), l = window.setTimeout(() => {
790
+ s = !0, r?.(c), t.dispatchEvent(new CustomEvent("longpress", {
791
+ detail: c
786
792
  }));
787
- }, e);
788
- }, f = (u) => {
789
- l && clearTimeout(l), t.releasePointerCapture(u.pointerId), i ? (o?.(u), t.dispatchEvent(new CustomEvent("longpressend", {
790
- detail: u
791
- }))) : (s?.(u), t.dispatchEvent(new CustomEvent("shorttap", {
792
- detail: u
793
+ }, n);
794
+ }, f = (c) => {
795
+ l && clearTimeout(l), t.releasePointerCapture(c.pointerId), s ? (o?.(c), t.dispatchEvent(new CustomEvent("longpressend", {
796
+ detail: c
797
+ }))) : (i?.(c), t.dispatchEvent(new CustomEvent("shorttap", {
798
+ detail: c
793
799
  })));
794
- }, d = (u) => {
795
- l && clearTimeout(l), t.releasePointerCapture(u.pointerId), i = !1;
796
- }, m = (u) => {
797
- u.preventDefault(), u.stopPropagation();
800
+ }, d = (c) => {
801
+ l && clearTimeout(l), t.releasePointerCapture(c.pointerId), s && (o?.(c), t.dispatchEvent(new CustomEvent("longpressend", {
802
+ detail: c
803
+ }))), s = !1;
804
+ }, m = (c) => {
805
+ c.preventDefault(), c.stopPropagation();
798
806
  };
799
- return n && (t.style.touchAction = "none", t.addEventListener("contextmenu", a)), t.addEventListener("pointerdown", g), t.addEventListener("pointerup", f), t.addEventListener("pointercancel", d), t.addEventListener("click", m), () => {
800
- n && t.removeEventListener("contextmenu", a), t.removeEventListener("pointerdown", g), t.removeEventListener("pointerup", f), t.removeEventListener("pointercancel", d), t.removeEventListener("click", m);
807
+ return e && (t.style.touchAction = "none", t.addEventListener("contextmenu", a)), t.addEventListener("pointerdown", g), t.addEventListener("pointerup", f), t.addEventListener("pointercancel", d), t.addEventListener("click", m), () => {
808
+ e && t.removeEventListener("contextmenu", a), t.removeEventListener("pointerdown", g), t.removeEventListener("pointerup", f), t.removeEventListener("pointercancel", d), t.removeEventListener("click", m);
801
809
  };
802
810
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dictate-button",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Customizable Web Component that adds speech-to-text dictation capabilities to text fields",
5
5
  "keywords": [
6
6
  "custom-element",
@@ -72,7 +72,7 @@
72
72
  "vite": "^7.3.1",
73
73
  "vite-plugin-dts": "^4.5.4",
74
74
  "vite-plugin-solid": "^2.11.10",
75
- "vite-plugin-static-copy": "^3.1.4",
75
+ "vite-plugin-static-copy": "^3.1.5",
76
76
  "vitest": "^4.0.17"
77
77
  },
78
78
  "homepage": "https://github.com/dictate-button/dictate-button",