@readium/speech 0.12.0 → 0.14.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.
package/build/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { DecorationController as vn, DirectCommsChannel as yn, Decorator as Sn } from "@readium/decorator";
1
+ import { DecorationController as yn, DirectCommsChannel as Sn, Decorator as bn } from "@readium/decorator";
2
2
  export * from "@readium/decorator";
3
- import { LocatorText as bn, LocatorLocations as wn, Locator as kn } from "@readium/shared";
4
- import { Locator as da, LocatorLocations as ga, LocatorText as fa } from "@readium/shared";
5
- import { startsWithBindingPunct as ee, ssmlTextEscape as B, BINDING_PUNCT_CLASS as K } from "@readium/helpers";
6
- import Cn from "i18next";
7
- import { decodeTextref as Xe, combineDomRangeTextrefs as En, substitutedOwnSelector as Rn, isAriaSubstituted as te } from "@readium/guided-navigation";
8
- import { DomRange as In, DomRangePoint as et } from "@readium/shared/html";
9
- const E = (n) => {
3
+ import { LocatorText as wn, LocatorLocations as kn, Locator as Cn } from "@readium/shared";
4
+ import { Locator as ma, LocatorLocations as va, LocatorText as ya } from "@readium/shared";
5
+ import { startsWithBindingPunct as te, ssmlTextEscape as B, BINDING_PUNCT_CLASS as K } from "@readium/helpers";
6
+ import En from "i18next";
7
+ import { decodeTextref as et, combineDomRangeTextrefs as Rn, substitutedOwnSelector as In, isAriaSubstituted as ne } from "@readium/guided-navigation";
8
+ import { DomRange as Pn, DomRangePoint as tt } from "@readium/shared/html";
9
+ const k = (n) => {
10
10
  if (!n) return ["", void 0];
11
11
  const e = n.replace(/_/g, "-");
12
12
  try {
@@ -22,7 +22,14 @@ const E = (n) => {
22
22
  t[1]?.toUpperCase()
23
23
  ];
24
24
  }
25
- }, T = {
25
+ }, ve = (n, e) => {
26
+ const t = e.toLowerCase().replace(/_/g, "-"), [s] = k(e);
27
+ let i;
28
+ for (const a of [s, t])
29
+ for (const [r, o] of Object.entries(n))
30
+ r.toLowerCase().replace(/_/g, "-") === a && (i ??= /* @__PURE__ */ new Set(), o.forEach((l) => i.add(l)));
31
+ return i && [...i];
32
+ }, V = {
26
33
  ar: {
27
34
  defaultRegion: "SA",
28
35
  availableRegions: [
@@ -409,16 +416,16 @@ const E = (n) => {
409
416
  ],
410
417
  testUtterance: "你好,我叫 {name},係越中文聲。"
411
418
  }
412
- }, Ee = /* @__PURE__ */ new Map(), Pn = /* @__PURE__ */ Object.assign({ "../../json/ar.json": () => import("./ar-BGKtJRyt.js"), "../../json/bg.json": () => import("./bg-D9Q1JriY.js"), "../../json/bho.json": () => import("./bho-CpuLBMN3.js"), "../../json/bn.json": () => import("./bn-Bpn_lzoe.js"), "../../json/ca.json": () => import("./ca-5hzouNcE.js"), "../../json/cmn.json": () => import("./cmn-DlnYMCd8.js"), "../../json/cs.json": () => import("./cs-CDpMkMNO.js"), "../../json/da.json": () => import("./da-XWCfWAwB.js"), "../../json/de.json": () => import("./de-DU0USiOh.js"), "../../json/el.json": () => import("./el-ClBwbIAW.js"), "../../json/en.json": () => import("./en-l3wcpTw3.js"), "../../json/es.json": () => import("./es-DwOFJY07.js"), "../../json/eu.json": () => import("./eu-DxWirHU-.js"), "../../json/fa.json": () => import("./fa-Ml9KtIw1.js"), "../../json/fi.json": () => import("./fi-Dk-5Fhhl.js"), "../../json/fr.json": () => import("./fr-MfhjukJ4.js"), "../../json/gl.json": () => import("./gl-DwtzWds9.js"), "../../json/he.json": () => import("./he-CfajFNE_.js"), "../../json/hi.json": () => import("./hi-pv2ttBoh.js"), "../../json/hr.json": () => import("./hr-MRApcEKR.js"), "../../json/hu.json": () => import("./hu-DGRDZdHH.js"), "../../json/id.json": () => import("./id-DZUuUiTG.js"), "../../json/it.json": () => import("./it-DJUYnjyj.js"), "../../json/ja.json": () => import("./ja-BpFcZRMu.js"), "../../json/kk.json": () => import("./kk-C480t1iH.js"), "../../json/kn.json": () => import("./kn-BVqs26qv.js"), "../../json/ko.json": () => import("./ko-TNoPZd6N.js"), "../../json/mr.json": () => import("./mr-DstAHTvT.js"), "../../json/ms.json": () => import("./ms-BceBSD-j.js"), "../../json/nb.json": () => import("./nb-CwPbwG-i.js"), "../../json/nl.json": () => import("./nl-BmW-Dmw5.js"), "../../json/pl.json": () => import("./pl-CH8qoDu8.js"), "../../json/pt.json": () => import("./pt-CjCENn24.js"), "../../json/ro.json": () => import("./ro-BlJN7qkA.js"), "../../json/ru.json": () => import("./ru-udzq1D5e.js"), "../../json/sk.json": () => import("./sk-VAEHsTWJ.js"), "../../json/sl.json": () => import("./sl-DaZQ1gp0.js"), "../../json/sv.json": () => import("./sv-CicHwXe4.js"), "../../json/ta.json": () => import("./ta-CvpRY89g.js"), "../../json/te.json": () => import("./te-D5TcdW9V.js"), "../../json/th.json": () => import("./th-CYakoFVa.js"), "../../json/tr.json": () => import("./tr-BfYrcAz7.js"), "../../json/uk.json": () => import("./uk-BVs6lQbX.js"), "../../json/vi.json": () => import("./vi-DP1xN9KL.js"), "../../json/wuu.json": () => import("./wuu-C6uQvT6g.js"), "../../json/yue.json": () => import("./yue-C8kEWdfv.js") });
419
+ }, Re = /* @__PURE__ */ new Map(), An = /* @__PURE__ */ Object.assign({ "../../json/ar.json": () => import("./ar-BGKtJRyt.js"), "../../json/bg.json": () => import("./bg-D9Q1JriY.js"), "../../json/bho.json": () => import("./bho-CpuLBMN3.js"), "../../json/bn.json": () => import("./bn-Bpn_lzoe.js"), "../../json/ca.json": () => import("./ca-5hzouNcE.js"), "../../json/cmn.json": () => import("./cmn-DlnYMCd8.js"), "../../json/cs.json": () => import("./cs-CDpMkMNO.js"), "../../json/da.json": () => import("./da-XWCfWAwB.js"), "../../json/de.json": () => import("./de-DU0USiOh.js"), "../../json/el.json": () => import("./el-ClBwbIAW.js"), "../../json/en.json": () => import("./en-l3wcpTw3.js"), "../../json/es.json": () => import("./es-DwOFJY07.js"), "../../json/eu.json": () => import("./eu-DxWirHU-.js"), "../../json/fa.json": () => import("./fa-Ml9KtIw1.js"), "../../json/fi.json": () => import("./fi-Dk-5Fhhl.js"), "../../json/fr.json": () => import("./fr-MfhjukJ4.js"), "../../json/gl.json": () => import("./gl-DwtzWds9.js"), "../../json/he.json": () => import("./he-CfajFNE_.js"), "../../json/hi.json": () => import("./hi-pv2ttBoh.js"), "../../json/hr.json": () => import("./hr-MRApcEKR.js"), "../../json/hu.json": () => import("./hu-DGRDZdHH.js"), "../../json/id.json": () => import("./id-DZUuUiTG.js"), "../../json/it.json": () => import("./it-DJUYnjyj.js"), "../../json/ja.json": () => import("./ja-BpFcZRMu.js"), "../../json/kk.json": () => import("./kk-C480t1iH.js"), "../../json/kn.json": () => import("./kn-BVqs26qv.js"), "../../json/ko.json": () => import("./ko-TNoPZd6N.js"), "../../json/mr.json": () => import("./mr-DstAHTvT.js"), "../../json/ms.json": () => import("./ms-BceBSD-j.js"), "../../json/nb.json": () => import("./nb-CwPbwG-i.js"), "../../json/nl.json": () => import("./nl-BmW-Dmw5.js"), "../../json/pl.json": () => import("./pl-CH8qoDu8.js"), "../../json/pt.json": () => import("./pt-CjCENn24.js"), "../../json/ro.json": () => import("./ro-BlJN7qkA.js"), "../../json/ru.json": () => import("./ru-udzq1D5e.js"), "../../json/sk.json": () => import("./sk-VAEHsTWJ.js"), "../../json/sl.json": () => import("./sl-DaZQ1gp0.js"), "../../json/sv.json": () => import("./sv-CicHwXe4.js"), "../../json/ta.json": () => import("./ta-CvpRY89g.js"), "../../json/te.json": () => import("./te-D5TcdW9V.js"), "../../json/th.json": () => import("./th-CYakoFVa.js"), "../../json/tr.json": () => import("./tr-BfYrcAz7.js"), "../../json/uk.json": () => import("./uk-BVs6lQbX.js"), "../../json/vi.json": () => import("./vi-DP1xN9KL.js"), "../../json/wuu.json": () => import("./wuu-C6uQvT6g.js"), "../../json/yue.json": () => import("./yue-C8kEWdfv.js") });
413
420
  async function xn(n) {
414
421
  try {
415
- const e = n.split("-")[0], t = Pn[`../../json/${e}.json`];
422
+ const e = n.split("-")[0], t = An[`../../json/${e}.json`];
416
423
  if (!t)
417
424
  throw new Error(`No voice data found for language: ${n}`);
418
425
  const i = (await t()).default;
419
426
  return {
420
427
  ...i,
421
- voices: i.voices.map(On)
428
+ voices: i.voices.map(Un)
422
429
  };
423
430
  } catch (e) {
424
431
  return console.warn(`Failed to load voice data for ${n}:`, e), {
@@ -429,13 +436,13 @@ async function xn(n) {
429
436
  };
430
437
  }
431
438
  }
432
- function tt(n) {
433
- return Ee.has(n) || Ee.set(n, xn(n)), Ee.get(n);
439
+ function nt(n) {
440
+ return Re.has(n) || Re.set(n, xn(n)), Re.get(n);
434
441
  }
435
- const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "apple"], On = (n) => ({
442
+ const Ln = ["veryLow", "low", "normal", "high", "veryHigh"], On = ["android", "apple"], Un = (n) => ({
436
443
  ...n,
437
- quality: n.quality?.filter((e) => An.includes(e)),
438
- localizedName: n.localizedName && Ln.includes(n.localizedName) ? n.localizedName : void 0
444
+ quality: n.quality?.filter((e) => Ln.includes(e)),
445
+ localizedName: n.localizedName && On.includes(n.localizedName) ? n.localizedName : void 0
439
446
  }), Q = {
440
447
  cmn: "cmn",
441
448
  "cmn-CN": "cmn-CN",
@@ -456,21 +463,21 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
456
463
  e = `${t.toLowerCase()}-${s.toUpperCase()}`;
457
464
  }
458
465
  return Q[e] || e;
459
- }, Pe = async (n) => {
466
+ }, Ae = async (n) => {
460
467
  if (!n) return [];
461
468
  try {
462
469
  const e = L(n);
463
470
  try {
464
- const s = await tt(e);
471
+ const s = await nt(e);
465
472
  if (s?.voices?.length)
466
473
  return s.voices;
467
474
  } catch (s) {
468
475
  console.warn(`Failed to load voices for ${e}:`, s);
469
476
  }
470
- const [t] = E(e);
477
+ const [t] = k(e);
471
478
  if (t !== e)
472
479
  try {
473
- const s = await tt(t);
480
+ const s = await nt(t);
474
481
  if (s?.voices?.length)
475
482
  return s.voices;
476
483
  } catch (s) {
@@ -489,39 +496,39 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
489
496
  } catch {
490
497
  return n.toUpperCase();
491
498
  }
492
- }, nt = (n) => {
499
+ }, st = (n) => {
493
500
  if (!n) return "";
494
501
  try {
495
- const e = L(n), t = T[e];
502
+ const e = L(n), t = V[e];
496
503
  if (t?.testUtterance)
497
504
  return t.testUtterance;
498
505
  if (e in Q) {
499
506
  const i = Q[e];
500
- if (i && T[i]?.testUtterance)
501
- return T[i].testUtterance;
507
+ if (i && V[i]?.testUtterance)
508
+ return V[i].testUtterance;
502
509
  }
503
- const [s] = E(e);
504
- return s !== e && T[s]?.testUtterance ? T[s].testUtterance : "";
510
+ const [s] = k(e);
511
+ return s !== e && V[s]?.testUtterance ? V[s].testUtterance : "";
505
512
  } catch (e) {
506
513
  return console.error(`Error in getTestUtterance for ${n}:`, e), "";
507
514
  }
508
- }, ve = (n) => {
515
+ }, ye = (n) => {
509
516
  if (!n) return "";
510
517
  try {
511
- const e = L(n), t = T[e];
518
+ const e = L(n), t = V[e];
512
519
  if (t?.defaultRegion)
513
520
  return `${e}-${t.defaultRegion}`;
514
521
  if (e in Q) {
515
522
  const i = Q[e];
516
523
  if (i) {
517
- const a = T[i];
524
+ const a = V[i];
518
525
  if (a?.defaultRegion)
519
526
  return `${i}-${a.defaultRegion}`;
520
527
  }
521
528
  }
522
- const [s] = E(e);
529
+ const [s] = k(e);
523
530
  if (s !== e) {
524
- const i = T[s];
531
+ const i = V[s];
525
532
  if (i?.defaultRegion)
526
533
  return `${s}-${i.defaultRegion}`;
527
534
  }
@@ -529,26 +536,26 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
529
536
  } catch (e) {
530
537
  return console.error(`Failed to get default region for ${n}:`, e), "";
531
538
  }
532
- }, ye = (n) => {
539
+ }, Se = (n) => {
533
540
  if (!n?.length) return [];
534
541
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
535
542
  for (const [i, a] of n.entries()) {
536
543
  if (!a) continue;
537
- const r = L(a), [o, l] = E(r);
544
+ const r = L(a), [o, l] = k(r);
538
545
  l && (e.add(l), s.has(l) || s.set(l, i)), t.has(o) || t.set(o, /* @__PURE__ */ new Set()), l && t.get(o).add(l);
539
546
  }
540
547
  return Array.from(t.entries()).map(([i, a]) => {
541
548
  const r = new Set(
542
- T[i]?.availableRegions || []
549
+ V[i]?.availableRegions || []
543
550
  ), o = Array.from(a), l = Array.from(e).filter(
544
551
  (u) => r.has(u) && !o.includes(u)
545
- ), c = Array.from(/* @__PURE__ */ new Set([...o, ...l])).sort((u, d) => {
546
- const h = s.get(u) ?? Number.MAX_SAFE_INTEGER, g = s.get(d) ?? Number.MAX_SAFE_INTEGER;
547
- return h - g;
552
+ ), c = Array.from(/* @__PURE__ */ new Set([...o, ...l])).sort((u, g) => {
553
+ const h = s.get(u) ?? Number.MAX_SAFE_INTEGER, d = s.get(g) ?? Number.MAX_SAFE_INTEGER;
554
+ return h - d;
548
555
  });
549
556
  if (c.length === 0) {
550
- const u = ve(i), [, d] = E(u);
551
- d && c.push(d);
557
+ const u = ye(i), [, g] = k(u);
558
+ g && c.push(g);
552
559
  }
553
560
  return {
554
561
  baseLang: i,
@@ -559,12 +566,12 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
559
566
  const e = /* @__PURE__ */ new Map();
560
567
  for (const s of n) {
561
568
  if (s.source !== "json") continue;
562
- const [i] = E(s.language);
569
+ const [i] = k(s.language);
563
570
  e.has(i) || e.set(i, []), e.get(i).push(s);
564
571
  }
565
572
  const t = /* @__PURE__ */ new Map();
566
573
  for (const [s, i] of e.entries()) {
567
- const a = /* @__PURE__ */ new Map(), r = await Pe(s), o = /* @__PURE__ */ new Map();
574
+ const a = /* @__PURE__ */ new Map(), r = await Ae(s), o = /* @__PURE__ */ new Map();
568
575
  r.forEach((l, c) => {
569
576
  o.set(l.name.toLowerCase(), c), l.altNames?.forEach((u) => {
570
577
  o.set(u.toLowerCase(), c);
@@ -577,14 +584,14 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
577
584
  a.size > 0 && t.set(s, a);
578
585
  }
579
586
  return t;
580
- }, Un = {
587
+ }, Vn = {
581
588
  veryLow: 1,
582
589
  low: 2,
583
590
  normal: 3,
584
591
  high: 4,
585
592
  veryHigh: 5
586
- }, le = (n) => n ? Un[n] ?? 0 : 0, j = (n, e, t, s) => {
587
- const i = le(n.quality), a = le(e.quality);
593
+ }, ce = (n) => n ? Vn[n] ?? 0 : 0, j = (n, e, t, s) => {
594
+ const i = ce(n.quality), a = ce(e.quality);
588
595
  if (t && s && n.source === "json" && e.source === "json") {
589
596
  const r = t.get(s);
590
597
  if (r) {
@@ -594,24 +601,24 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
594
601
  }
595
602
  }
596
603
  return a !== i ? a - i : n.name.localeCompare(e.name);
597
- }, Se = (n, e) => {
604
+ }, be = (n, e) => {
598
605
  const t = new Map(e.map((a) => [a.baseLang, a])), s = /* @__PURE__ */ new Map(), i = [];
599
606
  for (const a of n) {
600
- const [r] = E(a.language);
607
+ const [r] = k(a.language);
601
608
  t.get(r) ? (s.has(r) || s.set(r, []), s.get(r).push(a)) : i.push(a);
602
609
  }
603
610
  return { voicesByLang: s, otherLangVoices: i };
604
- }, zt = (n, e, t, s) => {
605
- const [, i] = E(n.language), [, a] = E(e.language), r = i && t.regions.includes(i), o = a && t.regions.includes(a);
611
+ }, Nt = (n, e, t, s) => {
612
+ const [, i] = k(n.language), [, a] = k(e.language), r = i && t.regions.includes(i), o = a && t.regions.includes(a);
606
613
  if (r && o) {
607
- const h = t.regions.indexOf(i), g = t.regions.indexOf(a);
608
- return h === g ? j(n, e, s, t.baseLang) : h - g;
614
+ const h = t.regions.indexOf(i), d = t.regions.indexOf(a);
615
+ return h === d ? j(n, e, s, t.baseLang) : h - d;
609
616
  }
610
617
  if (r) return -1;
611
618
  if (o) return 1;
612
- const l = ve(t.baseLang), [, c] = E(l), u = !!c && i === c, d = !!c && a === c;
613
- if (u && !d) return -1;
614
- if (!u && d) return 1;
619
+ const l = ye(t.baseLang), [, c] = k(l), u = !!c && i === c, g = !!c && a === c;
620
+ if (u && !g) return -1;
621
+ if (!u && g) return 1;
615
622
  if (i && a) {
616
623
  const h = i.localeCompare(a);
617
624
  return h !== 0 ? h : j(n, e, s, t.baseLang);
@@ -619,60 +626,69 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
619
626
  return i ? -1 : a ? 1 : j(n, e, s, t.baseLang);
620
627
  }, Tn = async (n, e, t) => {
621
628
  const s = t ?? await _(n);
622
- n.sort((i, a) => zt(i, a, e, s));
623
- }, Nt = (n, e, t) => {
624
- const [s] = E(n.language), [i] = E(e.language), a = xe(s).toLowerCase(), r = xe(i).toLowerCase(), o = a.localeCompare(r);
629
+ n.sort((i, a) => Nt(i, a, e, s));
630
+ }, Bt = (n, e, t) => {
631
+ const [s] = k(n.language), [i] = k(e.language), a = xe(s).toLowerCase(), r = xe(i).toLowerCase(), o = a.localeCompare(r);
625
632
  if (o !== 0)
626
633
  return o;
627
634
  if (s === i) {
628
- const l = ve(s), [, c] = E(n.language), [, u] = E(e.language), d = l && c === l.split("-")[1], h = l && u === l.split("-")[1];
629
- if (d && !h) return -1;
630
- if (!d && h) return 1;
635
+ const l = ye(s), [, c] = k(n.language), [, u] = k(e.language), g = l && c === l.split("-")[1], h = l && u === l.split("-")[1];
636
+ if (g && !h) return -1;
637
+ if (!g && h) return 1;
631
638
  if (c && u) {
632
- const g = c.localeCompare(u);
633
- if (g !== 0)
634
- return g;
639
+ const d = c.localeCompare(u);
640
+ if (d !== 0)
641
+ return d;
635
642
  }
636
643
  return c && !u ? -1 : !c && u ? 1 : j(n, e, t, s);
637
644
  }
638
645
  return j(n, e, t, s);
639
- }, Ae = async (n, e) => {
646
+ }, Le = async (n, e) => {
640
647
  const t = e ?? await _(n);
641
- n.sort((s, i) => Nt(s, i, t));
642
- }, Vn = async (n, e) => {
648
+ n.sort((s, i) => Bt(s, i, t));
649
+ }, zn = async (n, e) => {
643
650
  if (!e?.length) return [];
644
- const t = ye(n || []), { voicesByLang: s, otherLangVoices: i } = Se(e, t), a = await _(e), r = [];
651
+ const t = Se(n || []), { voicesByLang: s, otherLangVoices: i } = be(e, t), a = await _(e), r = [];
645
652
  for (const o of t) {
646
653
  const l = s.get(o.baseLang);
647
654
  l && (await Tn(l, o, a), r.push(...l));
648
655
  }
649
- return await Ae(i, a), r.push(...i), r;
650
- }, zn = async (n, e) => {
656
+ return await Le(i, a), r.push(...i), r;
657
+ }, Nn = async (n, e) => {
651
658
  if (!e.length) return null;
652
- const [t] = ye([n]), { voicesByLang: s, otherLangVoices: i } = Se(e, [t]), a = s.get(t.baseLang), r = a?.length ? a : i, o = await _(e), l = a?.length ? (c, u) => zt(c, u, t, o) : (c, u) => Nt(c, u, o);
659
+ const [t] = Se([n]), { voicesByLang: s, otherLangVoices: i } = be(e, [t]), a = s.get(t.baseLang), r = a?.length ? a : i, o = await _(e), l = a?.length ? (c, u) => Nt(c, u, t, o) : (c, u) => Bt(c, u, o);
653
660
  return r.reduce((c, u) => l(u, c) < 0 ? u : c);
654
- }, Bt = (n, e) => {
661
+ }, Mt = (n, e) => {
655
662
  const t = n.filter((s) => s.controls?.boundary !== !1 === e);
656
663
  return t.length > 0 ? t : n;
657
- }, Nn = [{ name: "Albert", nativeID: ["com.apple.speech.synthesis.voice.Albert"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bad News", nativeID: ["com.apple.speech.synthesis.voice.BadNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Mauvaises nouvelles", "Malas noticias", "Brutte notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bahh", nativeID: ["com.apple.speech.synthesis.voice.Bahh"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bells", nativeID: ["com.apple.speech.synthesis.voice.Bells"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Cloches", "Campanas", "Campane"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Boing", nativeID: ["com.apple.speech.synthesis.voice.Boing"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bubbles", nativeID: ["com.apple.speech.synthesis.voice.Bubbles"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bulles", "Burbujas", "Bollicine"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Cellos", nativeID: ["com.apple.speech.synthesis.voice.Cellos"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Violoncelles", "Violonchelos", "Violoncelli"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Good News", nativeID: ["com.apple.speech.synthesis.voice.GoodNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bonnes nouvelles", "Buenas noticias", "Buone notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jester", nativeID: ["com.apple.speech.synthesis.voice.Hysterical"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bouffon", "Bufón", "Giullare"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Organ", nativeID: ["com.apple.speech.synthesis.voice.Organ"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Orgue", "Órgano", "Organo"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Superstar", nativeID: ["com.apple.speech.synthesis.voice.Princess"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Superestrella"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Trinoids", nativeID: ["com.apple.speech.synthesis.voice.Trinoids"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Trinoïdes"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Whisper", nativeID: ["com.apple.speech.synthesis.voice.Whisper"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Murmure", "Susurro", "Sussurro"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Wobble", nativeID: ["com.apple.speech.synthesis.voice.Deranged"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Zarvox", nativeID: ["com.apple.speech.synthesis.voice.Zarvox"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }], Bn = {
658
- voices: Nn
659
- }, Mn = [{ name: "Eddy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Flo", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandma", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandpa", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jacques", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Reed", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Rocko", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Sandy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Shelley", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Fred", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Junior", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Kathy", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Ralph", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "eSpeak Arabic", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ar", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bulgarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bg", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bengali", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Catalan", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ca", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Chinese (Mandarin, latin as English)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cmn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Czech", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cs", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Danish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "da", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak German", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "de", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Greek", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "el", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Spanish (Spain)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "es", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Estonian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "et", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Finnish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "fi", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Gujarati", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "gu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Croatian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Hungarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Indonesian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "id", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Italian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "it", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Kannada", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "kn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Korean", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ko", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Lithuanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lt", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Latvian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malayalm", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ml", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Marathi", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "mr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malay", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ms", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Norwegian Bokmål", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "nb", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Polish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Portuguese (Brazil)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pt-br", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Romanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ro", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Russian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ru", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovak", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sk", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovenian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Serbian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swedish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swahili", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sw", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Tamil", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ta", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Telugu", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "te", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Turkish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "tr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Vietnamese (Northern)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "vi", os: ["ChromeOS"], preloaded: !0 }], Dn = {
660
- voices: Mn
661
- }, jn = Bn, Fn = Dn, Le = (n, e) => jn.voices.some(
664
+ }, Bn = [{ name: "Albert", nativeID: ["com.apple.speech.synthesis.voice.Albert"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bad News", nativeID: ["com.apple.speech.synthesis.voice.BadNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Mauvaises nouvelles", "Malas noticias", "Brutte notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bahh", nativeID: ["com.apple.speech.synthesis.voice.Bahh"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bells", nativeID: ["com.apple.speech.synthesis.voice.Bells"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Cloches", "Campanas", "Campane"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Boing", nativeID: ["com.apple.speech.synthesis.voice.Boing"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bubbles", nativeID: ["com.apple.speech.synthesis.voice.Bubbles"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bulles", "Burbujas", "Bollicine"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Cellos", nativeID: ["com.apple.speech.synthesis.voice.Cellos"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Violoncelles", "Violonchelos", "Violoncelli"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Good News", nativeID: ["com.apple.speech.synthesis.voice.GoodNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bonnes nouvelles", "Buenas noticias", "Buone notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jester", nativeID: ["com.apple.speech.synthesis.voice.Hysterical"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bouffon", "Bufón", "Giullare"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Organ", nativeID: ["com.apple.speech.synthesis.voice.Organ"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Orgue", "Órgano", "Organo"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Superstar", nativeID: ["com.apple.speech.synthesis.voice.Princess"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Superestrella"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Trinoids", nativeID: ["com.apple.speech.synthesis.voice.Trinoids"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Trinoïdes"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Whisper", nativeID: ["com.apple.speech.synthesis.voice.Whisper"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Murmure", "Susurro", "Sussurro"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Wobble", nativeID: ["com.apple.speech.synthesis.voice.Deranged"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Zarvox", nativeID: ["com.apple.speech.synthesis.voice.Zarvox"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }], Mn = {
665
+ voices: Bn
666
+ }, Dn = [{ name: "Eddy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Flo", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandma", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandpa", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jacques", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Reed", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Rocko", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Sandy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Shelley", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Fred", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Junior", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Kathy", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Ralph", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "eSpeak Arabic", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ar", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bulgarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bg", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bengali", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Catalan", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ca", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Chinese (Mandarin, latin as English)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cmn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Czech", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cs", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Danish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "da", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak German", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "de", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Greek", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "el", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Spanish (Spain)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "es", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Estonian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "et", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Finnish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "fi", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Gujarati", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "gu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Croatian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Hungarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Indonesian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "id", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Italian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "it", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Kannada", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "kn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Korean", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ko", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Lithuanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lt", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Latvian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malayalm", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ml", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Marathi", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "mr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malay", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ms", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Norwegian Bokmål", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "nb", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Polish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Portuguese (Brazil)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pt-br", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Romanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ro", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Russian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ru", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovak", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sk", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovenian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Serbian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swedish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swahili", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sw", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Tamil", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ta", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Telugu", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "te", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Turkish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "tr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Vietnamese (Northern)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "vi", os: ["ChromeOS"], preloaded: !0 }], jn = {
667
+ voices: Dn
668
+ }, Fn = Mn, _n = jn, Oe = (n, e) => Fn.voices.some(
662
669
  (t) => n.includes(t.name) || e && t.nativeID?.some((s) => e.includes(s)) || t.altNames?.some((s) => n.includes(s))
663
- ), Oe = (n, e) => Fn.voices.some(
670
+ ), Ue = (n, e) => _n.voices.some(
664
671
  (t) => n.includes(t.name)
665
- ) || e === "veryLow", st = (n) => n?.length ? n.filter((e) => !(e.isNovelty || Le(e.name, e.voiceURI))) : [], it = (n) => n?.length ? n.filter((e) => !Oe(e.name, e.quality)) : [], _n = { ar: { normal: "محسن", high: "استثنائي" }, ca: { normal: "millorada", high: "prèmium" }, "cmn-CN": { normal: "优化音质", high: "高音质" }, "cmn-TW": { normal: "增強音質", high: "高音質" }, cs: { normal: "vylepšená verze", high: "prémiový" }, da: { normal: "forbedret", high: "høj kvalitet" }, de: { normal: "erweitert", high: "premium" }, el: { normal: "βελτιωμένη", high: "υψηλής ποιότητας" }, en: { normal: "Enhanced", high: "Premium" }, es: { normal: "mejorada", high: "premium" }, fi: { normal: "parannettu", high: "korkealaatuinen" }, fr: { normal: "premium", high: "de qualité" }, he: { normal: "משופר", high: "פרימיום" }, hi: { normal: "बेहतर", high: "प्रीमियम" }, hr: { normal: "poboljšani", high: "vrhunski" }, hu: { normal: "továbbfejlesztett", high: "prémium" }, id: { normal: "Ditingkatkan", high: "Premium" }, it: { normal: "ottimizzata", high: "premium" }, ja: { normal: "拡張", high: "プレミアム" }, ko: { normal: "고품질", high: "프리미엄" }, ms: { normal: "Dipertingkat", high: "Premium" }, nb: { normal: "forbedret", high: "premium" }, nl: { normal: "verbeterd", high: "premium" }, pl: { normal: "rozszerzony", high: "premium" }, pt: { normal: "melhorada", high: "premium" }, ro: { normal: "îmbunătățită", high: "premium" }, ru: { normal: "улучшенный", high: "высшее качество" }, sk: { normal: "vylepšený", high: "prémiový" }, sl: { normal: "izboljšano", high: "prvovrsten" }, sv: { normal: "förbättrad", high: "premium" }, th: { normal: "คุณภาพสูง", high: "คุณภาพสูง" }, tr: { normal: "Geliştirilmiş", high: "Yüksek Kaliteli" }, uk: { normal: "вдосконалений", high: "високої якості" }, vi: { normal: "Nâng cao", high: "Cao cấp" } }, Hn = {
666
- quality: _n
667
- }, Ue = {
668
- apple: Hn.quality
672
+ ) || e === "veryLow", it = (n) => n?.length ? n.filter((e) => !(e.isNovelty || Oe(e.name, e.voiceURI))) : [], at = (n) => n?.length ? n.filter((e) => !Ue(e.name, e.quality)) : [], Hn = (n, e) => {
673
+ const t = Array.isArray(e) ? e : [e];
674
+ return n.filter((s) => t.some((i) => {
675
+ const a = i.toLowerCase(), r = s.language?.toLowerCase(), o = s.altLanguage?.toLowerCase();
676
+ if (r === a || o === a)
677
+ return !0;
678
+ const [l] = a.split("-");
679
+ return r && r.startsWith(l) || o && o.startsWith(l);
680
+ }));
681
+ }, qn = { ar: { normal: "محسن", high: "استثنائي" }, ca: { normal: "millorada", high: "prèmium" }, "cmn-CN": { normal: "优化音质", high: "高音质" }, "cmn-TW": { normal: "增強音質", high: "高音質" }, cs: { normal: "vylepšená verze", high: "prémiový" }, da: { normal: "forbedret", high: "høj kvalitet" }, de: { normal: "erweitert", high: "premium" }, el: { normal: "βελτιωμένη", high: "υψηλής ποιότητας" }, en: { normal: "Enhanced", high: "Premium" }, es: { normal: "mejorada", high: "premium" }, fi: { normal: "parannettu", high: "korkealaatuinen" }, fr: { normal: "premium", high: "de qualité" }, he: { normal: "משופר", high: "פרימיום" }, hi: { normal: "बेहतर", high: "प्रीमियम" }, hr: { normal: "poboljšani", high: "vrhunski" }, hu: { normal: "továbbfejlesztett", high: "prémium" }, id: { normal: "Ditingkatkan", high: "Premium" }, it: { normal: "ottimizzata", high: "premium" }, ja: { normal: "拡張", high: "プレミアム" }, ko: { normal: "고품질", high: "프리미엄" }, ms: { normal: "Dipertingkat", high: "Premium" }, nb: { normal: "forbedret", high: "premium" }, nl: { normal: "verbeterd", high: "premium" }, pl: { normal: "rozszerzony", high: "premium" }, pt: { normal: "melhorada", high: "premium" }, ro: { normal: "îmbunătățită", high: "premium" }, ru: { normal: "улучшенный", high: "высшее качество" }, sk: { normal: "vylepšený", high: "prémiový" }, sl: { normal: "izboljšano", high: "prvovrsten" }, sv: { normal: "förbättrad", high: "premium" }, th: { normal: "คุณภาพสูง", high: "คุณภาพสูง" }, tr: { normal: "Geliştirilmiş", high: "Yüksek Kaliteli" }, uk: { normal: "вдосконалений", high: "високої якості" }, vi: { normal: "Nâng cao", high: "Cao cấp" } }, Gn = {
682
+ quality: qn
683
+ }, Ve = {
684
+ apple: Gn.quality
669
685
  // android: androidQualities.quality
670
- }, qn = (n, e, t) => {
686
+ }, $n = (n, e, t) => {
671
687
  if (!n) return;
672
688
  const s = Array.isArray(t) ? t : t ? [t] : [];
673
689
  for (const i of s)
674
- if (i && Ue[i]) {
675
- const a = Ue[i], r = E(e)[0], o = a[e] || a[r];
690
+ if (i && Ve[i]) {
691
+ const a = Ve[i], r = k(e)[0], o = a[e] || a[r];
676
692
  if (o) {
677
693
  const l = n.toLowerCase(), { normal: c, high: u } = o;
678
694
  if (u && l.includes(u.toLowerCase()))
@@ -681,15 +697,15 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
681
697
  return "normal";
682
698
  }
683
699
  }
684
- }, $n = (n, e) => {
685
- const t = Ue[e];
700
+ }, Kn = (n, e) => {
701
+ const t = Ve[e];
686
702
  if (t)
687
703
  for (const [s, { high: i, normal: a }] of Object.entries(t)) {
688
704
  const r = i && n.some((l) => l.includes(i)), o = a && n.some((l) => l.includes(a));
689
705
  if (r && o)
690
706
  return s;
691
707
  }
692
- }, Gn = {
708
+ }, Wn = {
693
709
  low: {
694
710
  values: ["super-compact", "compact"],
695
711
  quality: "low"
@@ -702,20 +718,20 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
702
718
  values: ["premium"],
703
719
  quality: "high"
704
720
  }
705
- }, at = (n) => {
721
+ }, rt = (n) => {
706
722
  if (!n) return;
707
723
  const t = n.toLowerCase().split(/[._-]/);
708
- for (const s of Object.values(Gn))
724
+ for (const s of Object.values(Wn))
709
725
  if (s.values.some((i) => t.includes(i)))
710
726
  return s.quality;
711
727
  };
712
- function Kn(n, e) {
728
+ function Qn(n, e) {
713
729
  if (n.name === n.originalName) return n;
714
730
  if (e.name === e.originalName) return e;
715
731
  const t = [n.originalName, ...n.altNames || []], s = [e.originalName, ...e.altNames || []], i = t.findIndex((r) => s.includes(r)), a = s.findIndex((r) => t.includes(r));
716
732
  return i === -1 && a === -1 || i !== -1 && (a === -1 || i <= a) ? n : e;
717
733
  }
718
- function Wn(n, e) {
734
+ function Jn(n, e) {
719
735
  if (!n.altNames && !e.altNames)
720
736
  return !1;
721
737
  const t = n.originalName, s = e.originalName, i = n.altNames || [], a = e.altNames || [];
@@ -815,7 +831,7 @@ class b {
815
831
  * @returns A tuple of [language, region] where language is lowercase and region is UPPERCASE
816
832
  */
817
833
  static extractLangRegionFromBCP47(e) {
818
- return E(e);
834
+ return k(e);
819
835
  }
820
836
  /**
821
837
  * Clean voice name by removing specific formatting
@@ -854,7 +870,7 @@ class b {
854
870
  */
855
871
  updateSystemLocale(e) {
856
872
  if (!e?.length) return;
857
- const t = e.map((i) => i.name), s = $n(t, "apple");
873
+ const t = e.map((i) => i.name), s = Kn(t, "apple");
858
874
  s && (this.systemLocale = s);
859
875
  }
860
876
  /**
@@ -863,15 +879,15 @@ class b {
863
879
  * @private
864
880
  */
865
881
  inferVoiceQuality(e, t, s) {
866
- const i = e.voiceURI ? at(e.voiceURI) : void 0;
882
+ const i = e.voiceURI ? rt(e.voiceURI) : void 0;
867
883
  if (i) return i;
868
884
  if (t?.nativeID && Array.isArray(t.nativeID))
869
885
  for (const a of t.nativeID) {
870
- const r = at(a);
886
+ const r = rt(a);
871
887
  if (r) return r;
872
888
  }
873
889
  if (t?.localizedName && e.voiceURI && e.lang) {
874
- const a = qn(
890
+ const a = $n(
875
891
  e.voiceURI,
876
892
  this.systemLocale,
877
893
  t.localizedName
@@ -905,12 +921,12 @@ class b {
905
921
  const i = `${s.language.toLowerCase()}_${this.normalizeVoiceName(s.name)}`, a = t.get(i);
906
922
  if (!a)
907
923
  t.set(i, s);
908
- else if (Wn(s, a)) {
909
- const r = Kn(s, a);
924
+ else if (Jn(s, a)) {
925
+ const r = Qn(s, a);
910
926
  t.set(i, r);
911
927
  } else {
912
- const r = le(a.quality);
913
- le(s.quality) >= r && t.set(i, s);
928
+ const r = ce(a.quality);
929
+ ce(s.quality) >= r && t.set(i, s);
914
930
  }
915
931
  }
916
932
  return Array.from(t.values());
@@ -922,11 +938,11 @@ class b {
922
938
  */
923
939
  getTestUtterance(e) {
924
940
  if (!e) return "";
925
- const t = nt(e);
941
+ const t = st(e);
926
942
  if (t) return t;
927
943
  const [s] = b.extractLangRegionFromBCP47(e);
928
944
  if (s && s !== e) {
929
- const i = nt(s);
945
+ const i = st(s);
930
946
  if (i) return i;
931
947
  }
932
948
  return "";
@@ -953,10 +969,10 @@ class b {
953
969
  for (const l of a) {
954
970
  const u = L(l.language).split("-")[0];
955
971
  if (!o.has(u)) {
956
- const d = xe(u, e), h = a.filter(
957
- (g) => L(g.language).split("-")[0] === u
972
+ const g = xe(u, e), h = a.filter(
973
+ (d) => L(d.language).split("-")[0] === u
958
974
  ).length;
959
- r.push({ code: u, label: d, count: h }), o.add(u);
975
+ r.push({ code: u, label: g, count: h }), o.add(u);
960
976
  }
961
977
  }
962
978
  return s ? r : r.sort((l, c) => l.label.localeCompare(c.label));
@@ -978,16 +994,16 @@ class b {
978
994
  for (const c of a) {
979
995
  const [, u] = b.extractLangRegionFromBCP47(c.language);
980
996
  if (u && !o.has(u)) {
981
- let d = c.language;
997
+ let g = c.language;
982
998
  try {
983
999
  const h = e || navigator.language;
984
- d = new Intl.DisplayNames([h], { type: "region" }).of(u) || c.language;
1000
+ g = new Intl.DisplayNames([h], { type: "region" }).of(u) || c.language;
985
1001
  } catch (h) {
986
1002
  console.warn(`Failed to get display name for region ${u}`, h);
987
1003
  }
988
1004
  r.push({
989
1005
  code: u,
990
- label: d,
1006
+ label: g,
991
1007
  count: l.get(u) || 0
992
1008
  }), o.add(u);
993
1009
  }
@@ -1019,8 +1035,8 @@ class b {
1019
1035
  const u = () => {
1020
1036
  if (o < 1) return a([]);
1021
1037
  --o;
1022
- const d = s();
1023
- if (Array.isArray(d) && d.length) return a(d);
1038
+ const g = s();
1039
+ if (Array.isArray(g) && g.length) return a(g);
1024
1040
  setTimeout(u, t);
1025
1041
  };
1026
1042
  setTimeout(u, t);
@@ -1040,21 +1056,21 @@ class b {
1040
1056
  return await Promise.all(
1041
1057
  e.filter((i) => i?.name && i?.lang).map(async (i) => {
1042
1058
  const a = L(i.lang), [r] = b.extractLangRegionFromBCP47(a), o = this.normalizeVoiceName(i.name), l = `${i.lang.toLowerCase()}_${o}`, c = t.get(l) || 1;
1043
- let u = await Pe(a);
1044
- (!u || u.length === 0) && (u = await Pe(r));
1045
- const d = this.findMatchingJsonVoice(u, o), h = this.inferVoiceQuality(i, d, c);
1046
- return d ? {
1047
- ...d,
1048
- label: d.label ?? this.cleanVoiceName(i.name),
1059
+ let u = await Ae(a);
1060
+ (!u || u.length === 0) && (u = await Ae(r));
1061
+ const g = this.findMatchingJsonVoice(u, o), h = this.inferVoiceQuality(i, g, c);
1062
+ return g ? {
1063
+ ...g,
1064
+ label: g.label ?? this.cleanVoiceName(i.name),
1049
1065
  source: "json",
1050
1066
  originalName: i.name,
1051
- language: d.language ?? a,
1067
+ language: g.language ?? a,
1052
1068
  voiceURI: i.voiceURI,
1053
1069
  quality: h,
1054
1070
  isDefault: i.default || !1,
1055
1071
  offlineAvailability: i.localService || !1,
1056
- isNovelty: Le(i.name, i.voiceURI),
1057
- isLowQuality: Oe(i.name, h)
1072
+ isNovelty: Oe(i.name, i.voiceURI),
1073
+ isLowQuality: Ue(i.name, h)
1058
1074
  } : {
1059
1075
  source: "browser",
1060
1076
  label: this.cleanVoiceName(i.name),
@@ -1065,8 +1081,8 @@ class b {
1065
1081
  quality: h,
1066
1082
  isDefault: i.default || !1,
1067
1083
  offlineAvailability: i.localService || !1,
1068
- isNovelty: Le(i.name, i.voiceURI),
1069
- isLowQuality: Oe(i.name, h)
1084
+ isNovelty: Oe(i.name, i.voiceURI),
1085
+ isLowQuality: Ue(i.name, h)
1070
1086
  };
1071
1087
  })
1072
1088
  );
@@ -1095,23 +1111,13 @@ class b {
1095
1111
  ...e
1096
1112
  // Let explicit options override the defaults
1097
1113
  };
1098
- if (i.languages) {
1099
- const a = Array.isArray(i.languages) ? i.languages : [i.languages];
1100
- s = s.filter((r) => a.some((o) => {
1101
- const l = o.toLowerCase(), c = r.language?.toLowerCase(), u = r.altLanguage?.toLowerCase();
1102
- if (c === l || u === l)
1103
- return !0;
1104
- const [d] = l.split("-");
1105
- return c && c.startsWith(d) || u && u.startsWith(d);
1106
- }));
1107
- }
1108
- if (i.source && (s = s.filter((a) => a.source === i.source)), i.gender && (s = s.filter((a) => a.gender === i.gender)), i.quality) {
1114
+ if (i.languages && (s = Hn(s, i.languages)), i.source && (s = s.filter((a) => a.source === i.source)), i.gender && (s = s.filter((a) => a.gender === i.gender)), i.quality) {
1109
1115
  const a = Array.isArray(i.quality) ? i.quality : [i.quality];
1110
1116
  s = s.filter((r) => r.quality && a.includes(r.quality));
1111
1117
  }
1112
1118
  return i.offlineOnly && (s = s.filter((a) => a.offlineAvailability === !0)), i.provider && (s = s.filter(
1113
1119
  (a) => a.provider?.toLowerCase() === i.provider?.toLowerCase()
1114
- )), i.excludeNovelty && (s = st(s)), i.excludeVeryLowQuality && (s = it(s)), i.removeDuplicates && (s = this.removeDuplicates(s)), s;
1120
+ )), i.excludeNovelty && (s = it(s)), i.excludeVeryLowQuality && (s = at(s)), i.removeDuplicates && (s = this.removeDuplicates(s)), s;
1115
1121
  }
1116
1122
  /**
1117
1123
  * Filter out novelty voices
@@ -1120,7 +1126,7 @@ class b {
1120
1126
  */
1121
1127
  filterOutNoveltyVoices(e) {
1122
1128
  const t = e ?? this.voices;
1123
- return st(t);
1129
+ return it(t);
1124
1130
  }
1125
1131
  /**
1126
1132
  * Filter out very low quality voices
@@ -1129,7 +1135,7 @@ class b {
1129
1135
  */
1130
1136
  filterOutVeryLowQualityVoices(e) {
1131
1137
  const t = e ?? this.voices;
1132
- return it(t);
1138
+ return at(t);
1133
1139
  }
1134
1140
  /**
1135
1141
  * Sort voices by quality, respecting JSON name order, then alphabetically for undefined/null quality
@@ -1146,7 +1152,7 @@ class b {
1146
1152
  * Sort regions by default then alphabetically, sort voices by quality
1147
1153
  */
1148
1154
  static async sortByDefaultRegion(e, t) {
1149
- const s = await _(e), i = ve(t);
1155
+ const s = await _(e), i = ye(t);
1150
1156
  e.sort((a, r) => {
1151
1157
  const [, o] = b.extractLangRegionFromBCP47(a.language), [, l] = b.extractLangRegionFromBCP47(r.language), c = i && o === i.split("-")[1], u = i && l === i.split("-")[1];
1152
1158
  return c && !u ? -1 : !c && u ? 1 : j(a, r, s, t);
@@ -1163,14 +1169,14 @@ class b {
1163
1169
  if (!s?.length) return [];
1164
1170
  if (!e?.length) {
1165
1171
  const l = [...s];
1166
- return await Ae(l), l;
1172
+ return await Le(l), l;
1167
1173
  }
1168
- const i = ye(e), { voicesByLang: a, otherLangVoices: r } = Se(s, i), o = [];
1174
+ const i = Se(e), { voicesByLang: a, otherLangVoices: r } = be(s, i), o = [];
1169
1175
  for (const l of i) {
1170
1176
  const c = a.get(l.baseLang);
1171
1177
  c && (await b.sortByDefaultRegion(c, l.baseLang), o.push(...c));
1172
1178
  }
1173
- return await Ae(r), o.push(...r), o;
1179
+ return await Le(r), o.push(...r), o;
1174
1180
  }
1175
1181
  /**
1176
1182
  * Sort voices by region preference, then alphabetically
@@ -1179,7 +1185,7 @@ class b {
1179
1185
  * @returns Sorted array of voices
1180
1186
  */
1181
1187
  async sortVoicesByRegions(e, t) {
1182
- return Vn(e, t || this.voices);
1188
+ return zn(e, t || this.voices);
1183
1189
  }
1184
1190
  /**
1185
1191
  * Group voices by the specified criteria
@@ -1211,7 +1217,7 @@ class b {
1211
1217
  return s;
1212
1218
  }
1213
1219
  }
1214
- const Qn = ["webKit", "moz", "ms", "o"], Jn = [
1220
+ const Zn = ["webKit", "moz", "ms", "o"], Yn = [
1215
1221
  "boundary",
1216
1222
  "end",
1217
1223
  "error",
@@ -1219,10 +1225,10 @@ const Qn = ["webKit", "moz", "ms", "o"], Jn = [
1219
1225
  "pause",
1220
1226
  "resume",
1221
1227
  "start"
1222
- ], Zn = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, $ = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], Yn = (n) => typeof window < "u" && n in window, Xn = (n) => {
1223
- const e = Zn(n), t = Qn.map((i) => `${i}${e}`), s = [n, e].concat(t).find(Yn);
1228
+ ], Xn = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, G = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], es = (n) => typeof window < "u" && n in window, ts = (n) => {
1229
+ const e = Xn(n), t = Zn.map((i) => `${i}${e}`), s = [n, e].concat(t).find(es);
1224
1230
  return s && typeof window < "u" ? window[s] : void 0;
1225
- }, es = () => {
1231
+ }, ns = () => {
1226
1232
  const n = {};
1227
1233
  [
1228
1234
  "speechSynthesis",
@@ -1231,14 +1237,14 @@ const Qn = ["webKit", "moz", "ms", "o"], Jn = [
1231
1237
  "speechSynthesisEvent",
1232
1238
  "speechSynthesisErrorEvent"
1233
1239
  ].forEach((t) => {
1234
- n[t] = Xn(t);
1235
- }), n.onvoiceschanged = $(n.speechSynthesis, "onvoiceschanged"), n.speechSynthesisSpeaking = $(n.speechSynthesis, "speaking"), n.speechSynthesisPaused = $(n.speechSynthesis, "paused");
1236
- const e = n.speechSynthesisUtterance ? $(n.speechSynthesisUtterance, "prototype") : !1;
1237
- return Jn.forEach((t) => {
1240
+ n[t] = ts(t);
1241
+ }), n.onvoiceschanged = G(n.speechSynthesis, "onvoiceschanged"), n.speechSynthesisSpeaking = G(n.speechSynthesis, "speaking"), n.speechSynthesisPaused = G(n.speechSynthesis, "paused");
1242
+ const e = n.speechSynthesisUtterance ? G(n.speechSynthesisUtterance, "prototype") : !1;
1243
+ return Yn.forEach((t) => {
1238
1244
  const s = `on${t}`;
1239
- n[s] = e && n.speechSynthesisUtterance ? $(n.speechSynthesisUtterance.prototype, s) : !1;
1245
+ n[s] = e && n.speechSynthesisUtterance ? G(n.speechSynthesisUtterance.prototype, s) : !1;
1240
1246
  }), n;
1241
- }, ts = () => {
1247
+ }, ss = () => {
1242
1248
  const e = typeof window < "u" && (window.navigator || {}).userAgent || "", t = () => /android/i.test(e), s = () => /kaios/i.test(e), i = () => typeof window.InstallTrigger < "u" ? !0 : /firefox/i.test(e), a = () => typeof window.GestureEvent < "u" || /safari/i.test(e);
1243
1249
  return {
1244
1250
  isAndroid: t(),
@@ -1247,7 +1253,7 @@ const Qn = ["webKit", "moz", "ms", "o"], Jn = [
1247
1253
  isKaiOS: s()
1248
1254
  };
1249
1255
  };
1250
- class be {
1256
+ class we {
1251
1257
  listeners = /* @__PURE__ */ new Map();
1252
1258
  on(e, t) {
1253
1259
  return this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t), () => {
@@ -1272,46 +1278,46 @@ class be {
1272
1278
  this.listeners.clear();
1273
1279
  }
1274
1280
  }
1275
- const oe = (n, e) => Math.min(Math.max(n, 0), Math.max(e - 1, 0));
1281
+ const le = (n, e) => Math.min(Math.max(n, 0), Math.max(e - 1, 0));
1276
1282
  function F(n, e, t, s) {
1277
1283
  return Number.isFinite(n) ? Math.max(e, Math.min(t, n)) : s;
1278
1284
  }
1279
- const Te = "\\p{Ps}\\p{Pi}¿¡", ns = new RegExp(`^[${Te}]`, "u"), ss = new RegExp("^\\p{P}$", "u");
1280
- function is(n) {
1281
- return ns.test(n);
1285
+ const Te = "\\p{Ps}\\p{Pi}¿¡", is = new RegExp(`^[${Te}]`, "u"), as = new RegExp("^\\p{P}$", "u");
1286
+ function rs(n) {
1287
+ return is.test(n);
1282
1288
  }
1283
- function as(n) {
1284
- return ss.test(n);
1289
+ function os(n) {
1290
+ return as.test(n);
1285
1291
  }
1286
- function Mt(n) {
1292
+ function Dt(n) {
1287
1293
  return n.replace(/[<>]/g, "​");
1288
1294
  }
1289
- function rs(n) {
1295
+ function ls(n) {
1290
1296
  return n.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&nbsp;/g, " ").replace(/&#(\d+);/g, (e, t) => String.fromCodePoint(Number(t))).replace(/&#x([0-9a-fA-F]+);/g, (e, t) => String.fromCodePoint(parseInt(t, 16)));
1291
1297
  }
1292
- const os = /\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;
1293
- function ls(n) {
1294
- return n.replace(os, (t, s, i) => {
1298
+ const cs = /\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;
1299
+ function us(n) {
1300
+ return n.replace(cs, (t, s, i) => {
1295
1301
  const a = i.slice(s + t.length);
1296
- return a.length === 0 || ee(a) ? "" : " ";
1302
+ return a.length === 0 || te(a) ? "" : " ";
1297
1303
  }).replace(/ {2,}/g, " ").trim();
1298
1304
  }
1299
- function cs(n) {
1305
+ function hs(n) {
1300
1306
  return n.includes("<");
1301
1307
  }
1302
- function Ne(n) {
1308
+ function Be(n) {
1303
1309
  if (n === void 0) return;
1304
1310
  const e = {};
1305
1311
  if (n.language !== void 0 && (e.language = n.language), n.ssml) {
1306
- const t = ls(n.ssml);
1307
- cs(t) && (e.ssml = t);
1312
+ const t = us(n.ssml);
1313
+ hs(t) && (e.ssml = t);
1308
1314
  }
1309
1315
  return n.plain && (e.plain = n.plain), e.plain || e.ssml ? e : void 0;
1310
1316
  }
1311
1317
  function z(n) {
1312
- return Dt(n).plain;
1318
+ return jt(n).plain;
1313
1319
  }
1314
- function Dt(n) {
1320
+ function jt(n) {
1315
1321
  let e = "";
1316
1322
  const t = [];
1317
1323
  let s = !1, i = 0;
@@ -1319,7 +1325,7 @@ function Dt(n) {
1319
1325
  const o = n[i];
1320
1326
  if (o === "<") {
1321
1327
  const c = n.indexOf(">", i), u = c === -1 ? "" : n.slice(c + 1);
1322
- i = c === -1 ? n.length : c + 1, !s && e.length > 0 && u.length > 0 && !ee(u) && (e += " ", t.push(i), s = !0);
1328
+ i = c === -1 ? n.length : c + 1, !s && e.length > 0 && u.length > 0 && !te(u) && (e += " ", t.push(i), s = !0);
1323
1329
  continue;
1324
1330
  }
1325
1331
  const l = n.startsWith("&lt;", i) ? "<" : n.startsWith("&gt;", i) ? ">" : n.startsWith("&amp;", i) ? "&" : void 0;
@@ -1339,7 +1345,7 @@ function Dt(n) {
1339
1345
  for (; r > a && /\s/.test(e[r - 1]); ) r--;
1340
1346
  return { plain: e.slice(a, r), map: t.slice(a, r) };
1341
1347
  }
1342
- function rt(n, e) {
1348
+ function ot(n, e) {
1343
1349
  let t = 0, s = n.length;
1344
1350
  for (; t < s; ) {
1345
1351
  const i = t + s >> 1;
@@ -1347,27 +1353,27 @@ function rt(n, e) {
1347
1353
  }
1348
1354
  return t;
1349
1355
  }
1350
- const ot = /* @__PURE__ */ new WeakMap();
1351
- function us(n) {
1356
+ const lt = /* @__PURE__ */ new WeakMap();
1357
+ function ds(n) {
1352
1358
  return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1353
1359
  }
1354
- function hs(n) {
1355
- const e = us(n), t = /\w/.test(n[0]) ? "(?<!\\w)" : "", s = /\w/.test(n[n.length - 1]) ? "(?!\\w)" : "";
1360
+ function gs(n) {
1361
+ const e = ds(n), t = /\w/.test(n[0]) ? "(?<!\\w)" : "", s = /\w/.test(n[n.length - 1]) ? "(?!\\w)" : "";
1356
1362
  return `${t}${e}${s}`;
1357
1363
  }
1358
- function ds(n, e) {
1364
+ function fs(n, e) {
1359
1365
  if (typeof e == "string")
1360
- return { regex: new RegExp(hs(n), "g"), replace: e };
1366
+ return { regex: new RegExp(gs(n), "g"), replace: e };
1361
1367
  const t = e.pattern.flags.includes("g") ? e.pattern.flags : `${e.pattern.flags}g`;
1362
1368
  return { regex: new RegExp(e.pattern.source, t), replace: e.replace };
1363
1369
  }
1364
- function gs(n) {
1365
- let e = ot.get(n);
1366
- return e || (e = Object.entries(n).map(([t, s]) => ds(t, s)), ot.set(n, e)), e;
1370
+ function ps(n) {
1371
+ let e = lt.get(n);
1372
+ return e || (e = Object.entries(n).map(([t, s]) => fs(t, s)), lt.set(n, e)), e;
1367
1373
  }
1368
- function jt(n, e) {
1374
+ function Ft(n, e) {
1369
1375
  const t = [];
1370
- for (const a of gs(e))
1376
+ for (const a of ps(e))
1371
1377
  for (const r of n.matchAll(a.regex)) {
1372
1378
  const o = r.index, l = typeof a.replace == "string" ? a.replace : a.replace(...r);
1373
1379
  t.push({ start: o, end: o + r[0].length, replacement: l });
@@ -1379,11 +1385,11 @@ function jt(n, e) {
1379
1385
  a.start < i || (s.push(a), i = a.end);
1380
1386
  return s;
1381
1387
  }
1382
- function fs(n, e) {
1388
+ function ms(n, e) {
1383
1389
  let t = "";
1384
1390
  const s = [];
1385
1391
  let i = 0;
1386
- for (const a of jt(n, e)) {
1392
+ for (const a of Ft(n, e)) {
1387
1393
  for (; i < a.start; )
1388
1394
  t += n[i], s.push(i), i++;
1389
1395
  for (let r = 0; r < a.replacement.length; r++)
@@ -1394,69 +1400,69 @@ function fs(n, e) {
1394
1400
  t += n[i], s.push(i), i++;
1395
1401
  return { text: t, map: s };
1396
1402
  }
1397
- function lt(n, e) {
1403
+ function ct(n, e) {
1398
1404
  return n.length ? e <= 0 ? n[0] : e >= n.length ? n[n.length - 1] + 1 : n[e] : e;
1399
1405
  }
1400
- const ps = /<([a-zA-Z][\w-]*)([^>]*)>([\s\S]*?)<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1401
- function ct(n) {
1406
+ const vs = /<([a-zA-Z][\w-]*)([^>]*)>([\s\S]*?)<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1407
+ function ut(n) {
1402
1408
  return n.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
1403
1409
  }
1404
- function Ft(n) {
1410
+ function _t(n) {
1405
1411
  const e = [];
1406
- for (const t of n.matchAll(ps))
1407
- t[1] !== void 0 ? e.push({ kind: "paired", raw: t[0], tag: t[1], attrs: t[2], innerText: ct(t[3]) }) : t[0][0] === "<" ? e.push({ kind: "selfClosing", raw: t[0] }) : e.push({ kind: "text", raw: t[0], text: ct(t[0]) });
1412
+ for (const t of n.matchAll(vs))
1413
+ t[1] !== void 0 ? e.push({ kind: "paired", raw: t[0], tag: t[1], attrs: t[2], innerText: ut(t[3]) }) : t[0][0] === "<" ? e.push({ kind: "selfClosing", raw: t[0] }) : e.push({ kind: "text", raw: t[0], text: ut(t[0]) });
1408
1414
  return e;
1409
1415
  }
1410
- function ms(n, e) {
1411
- const t = Ft(n);
1416
+ function ys(n, e) {
1417
+ const t = _t(n);
1412
1418
  let s = "", i = !1;
1413
1419
  const a = [], r = t.map(() => []);
1414
- t.forEach((y, k) => {
1420
+ t.forEach((y, C) => {
1415
1421
  if (y.kind === "selfClosing") return;
1416
1422
  const R = y.kind === "paired" ? y.innerText : y.text;
1417
- if (!i && s.length > 0 && R.length > 0 && !ee(R) && !/^\s/.test(R)) {
1418
- const C = s.length;
1419
- s += " ", r[k].push(a.length), a.push({ start: C, end: C + 1, atomIndex: -1 }), i = !0;
1423
+ if (!i && s.length > 0 && R.length > 0 && !te(R) && !/^\s/.test(R)) {
1424
+ const E = s.length;
1425
+ s += " ", r[C].push(a.length), a.push({ start: E, end: E + 1, atomIndex: -1 }), i = !0;
1420
1426
  }
1421
1427
  const w = s.length;
1422
- s += R, r[k].push(a.length), a.push({ start: w, end: s.length, atomIndex: k }), R.length > 0 && (i = /\s$/.test(R));
1428
+ s += R, r[C].push(a.length), a.push({ start: w, end: s.length, atomIndex: C }), R.length > 0 && (i = /\s$/.test(R));
1423
1429
  });
1424
- const o = jt(s, e);
1430
+ const o = Ft(s, e);
1425
1431
  let l = "", c = "";
1426
1432
  const u = [];
1427
- let d = -2, h = "", g = 0;
1433
+ let g = -2, h = "", d = 0;
1428
1434
  const f = () => {
1429
- if (d >= 0) {
1430
- const y = t[d];
1435
+ if (g >= 0) {
1436
+ const y = t[g];
1431
1437
  l += y.kind === "paired" ? `<${y.tag}${y.attrs}>${h}</${y.tag}>` : h;
1432
1438
  }
1433
- h = "", d = -2;
1439
+ h = "", g = -2;
1434
1440
  };
1435
1441
  for (let y = 0; y < t.length; y++) {
1436
- const k = t[y];
1437
- if (k.kind === "selfClosing") {
1438
- f(), l += k.raw;
1442
+ const C = t[y];
1443
+ if (C.kind === "selfClosing") {
1444
+ f(), l += C.raw;
1439
1445
  continue;
1440
1446
  }
1441
1447
  for (const R of r[y]) {
1442
1448
  const w = a[R];
1443
- let C = w.start;
1444
- for (; C < w.end; ) {
1445
- const x = g < o.length ? o[g] : void 0;
1446
- if (x && x.start <= C && x.end > C) {
1447
- const q = x.start === C, mn = x.end > w.end;
1449
+ let E = w.start;
1450
+ for (; E < w.end; ) {
1451
+ const A = d < o.length ? o[d] : void 0;
1452
+ if (A && A.start <= E && A.end > E) {
1453
+ const q = A.start === E, vn = A.end > w.end;
1448
1454
  if (q) {
1449
- c += x.replacement;
1450
- for (let Ye = 0; Ye < x.replacement.length; Ye++) u.push(x.start);
1451
- w.atomIndex === -1 || mn ? (f(), l += B(x.replacement)) : (d !== w.atomIndex && (f(), d = w.atomIndex), h += B(x.replacement));
1455
+ c += A.replacement;
1456
+ for (let Xe = 0; Xe < A.replacement.length; Xe++) u.push(A.start);
1457
+ w.atomIndex === -1 || vn ? (f(), l += B(A.replacement)) : (g !== w.atomIndex && (f(), g = w.atomIndex), h += B(A.replacement));
1452
1458
  }
1453
- C = Math.min(x.end, w.end), x.end <= w.end && g++;
1459
+ E = Math.min(A.end, w.end), A.end <= w.end && d++;
1454
1460
  continue;
1455
1461
  }
1456
- const Ze = x ? Math.min(x.start, w.end) : w.end, se = s.slice(C, Ze);
1457
- c += se;
1458
- for (let q = 0; q < se.length; q++) u.push(C + q);
1459
- w.atomIndex === -1 ? (f(), l += B(se)) : (d !== w.atomIndex && (f(), d = w.atomIndex), h += B(se)), C = Ze;
1462
+ const Ye = A ? Math.min(A.start, w.end) : w.end, ie = s.slice(E, Ye);
1463
+ c += ie;
1464
+ for (let q = 0; q < ie.length; q++) u.push(E + q);
1465
+ w.atomIndex === -1 ? (f(), l += B(ie)) : (g !== w.atomIndex && (f(), g = w.atomIndex), h += B(ie)), E = Ye;
1460
1466
  }
1461
1467
  }
1462
1468
  }
@@ -1472,24 +1478,24 @@ function ms(n, e) {
1472
1478
  const I = s.slice(p, m), P = u.slice(S, v).map((y) => Math.min(Math.max(y - p, 0), Math.max(I.length - 1, 0)));
1473
1479
  return { ssml: l, plain: I, map: P };
1474
1480
  }
1475
- const _t = /<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;
1476
- function Ht(n) {
1477
- return new RegExp(_t).test(n);
1481
+ const Ht = /<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;
1482
+ function qt(n) {
1483
+ return new RegExp(Ht).test(n);
1478
1484
  }
1479
- function ut(n) {
1485
+ function ht(n) {
1480
1486
  return n.replace(/<[^>]+>/g, "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/ {2,}/g, " ");
1481
1487
  }
1482
- const vs = new RegExp(
1488
+ const Ss = new RegExp(
1483
1489
  `\\s+|[${Te}]+|[${K}]+|[^\\s${Te}${K}]+`,
1484
1490
  "gu"
1485
1491
  );
1486
- function Re(n) {
1492
+ function Ie(n) {
1487
1493
  const e = [];
1488
- for (const [t] of n.matchAll(vs))
1489
- /^\s/.test(t) ? e.push({ kind: "space" }) : is(t) ? e.push({ kind: "open", text: t }) : ee(t) ? e.push({ kind: "close", text: t }) : e.push({ kind: "word", text: t });
1494
+ for (const [t] of n.matchAll(Ss))
1495
+ /^\s/.test(t) ? e.push({ kind: "space" }) : rs(t) ? e.push({ kind: "open", text: t }) : te(t) ? e.push({ kind: "close", text: t }) : e.push({ kind: "word", text: t });
1490
1496
  return e;
1491
1497
  }
1492
- function ys(n) {
1498
+ function bs(n) {
1493
1499
  let e = "", t = !1;
1494
1500
  for (const s of n) {
1495
1501
  if (s.kind === "space") {
@@ -1500,45 +1506,45 @@ function ys(n) {
1500
1506
  }
1501
1507
  return e;
1502
1508
  }
1503
- function Ss(n) {
1509
+ function ws(n) {
1504
1510
  let e = n.length;
1505
1511
  for (; e > 0 && (n[e - 1].kind === "space" || n[e - 1].kind === "open"); ) e--;
1506
1512
  return n.slice(e).some((t) => t.kind === "open") ? n.splice(e) : [];
1507
1513
  }
1508
- function bs(n) {
1514
+ function ks(n) {
1509
1515
  let e = 0;
1510
1516
  for (; e < n.length && (n[e].kind === "space" || n[e].kind === "close"); ) e++;
1511
1517
  return n.slice(0, e).some((t) => t.kind === "close") ? n.splice(0, e) : [];
1512
1518
  }
1513
- function qt(n, e) {
1519
+ function Gt(n, e) {
1514
1520
  const t = [];
1515
1521
  let s = 0;
1516
- for (const r of n.matchAll(_t))
1522
+ for (const r of n.matchAll(Ht))
1517
1523
  t.push({
1518
- tokens: Re(ut(n.slice(s, r.index))),
1524
+ tokens: Ie(ht(n.slice(s, r.index))),
1519
1525
  language: e,
1520
1526
  tagged: !1
1521
- }), t.push({ tokens: Re(z(r[2])), language: r[1], tagged: !0 }), s = r.index + r[0].length;
1527
+ }), t.push({ tokens: Ie(z(r[2])), language: r[1], tagged: !0 }), s = r.index + r[0].length;
1522
1528
  t.push({
1523
- tokens: Re(ut(n.slice(s))),
1529
+ tokens: Ie(ht(n.slice(s))),
1524
1530
  language: e,
1525
1531
  tagged: !1
1526
1532
  });
1527
1533
  for (let r = 0; r < t.length - 1; r++)
1528
- !t[r].tagged && t[r + 1].tagged ? t[r + 1].tokens.unshift(...Ss(t[r].tokens)) : t[r].tagged && !t[r + 1].tagged && t[r].tokens.push(...bs(t[r + 1].tokens));
1534
+ !t[r].tagged && t[r + 1].tagged ? t[r + 1].tokens.unshift(...ws(t[r].tokens)) : t[r].tagged && !t[r + 1].tagged && t[r].tokens.push(...ks(t[r + 1].tokens));
1529
1535
  const i = [];
1530
1536
  let a = 0;
1531
1537
  for (const r of t) {
1532
- const o = ys(r.tokens);
1538
+ const o = bs(r.tokens);
1533
1539
  o && (i.push({ plain: o, language: r.language, start: a, end: a + o.length }), a += o.length);
1534
1540
  }
1535
1541
  return i;
1536
1542
  }
1537
1543
  const $t = /<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;
1538
- function ws(n) {
1544
+ function Cs(n) {
1539
1545
  return new RegExp($t).test(n);
1540
1546
  }
1541
- function ks(n) {
1547
+ function Es(n) {
1542
1548
  const e = [];
1543
1549
  let t = 0;
1544
1550
  for (const i of n.matchAll($t)) {
@@ -1548,14 +1554,14 @@ function ks(n) {
1548
1554
  const s = n.slice(t).trim();
1549
1555
  return s && e.push({ ssml: s }), e;
1550
1556
  }
1551
- class ht {
1557
+ class dt {
1552
1558
  speechSynthesis;
1553
1559
  speechSynthesisUtterance;
1554
1560
  currentVoice = null;
1555
1561
  currentUtterances = [];
1556
1562
  currentUtteranceIndex = 0;
1557
1563
  playbackState = "idle";
1558
- events = new be();
1564
+ events = new we();
1559
1565
  voiceManager = null;
1560
1566
  voices = [];
1561
1567
  defaultVoice = null;
@@ -1578,6 +1584,8 @@ class ht {
1578
1584
  maxLengthExceeded = "warn";
1579
1585
  utterancesBeingCancelled = !1;
1580
1586
  // Flag to track if utterances are being cancelled
1587
+ lacksNativePauseEvents = !1;
1588
+ // Google online voices in desktop Chrome never fire onpause/onresume
1581
1589
  // Playback parameters
1582
1590
  rate = 1;
1583
1591
  pitch = 1;
@@ -1585,7 +1593,7 @@ class ht {
1585
1593
  features;
1586
1594
  patches;
1587
1595
  constructor() {
1588
- if (this.features = es(), this.patches = ts(), !this.features.speechSynthesis || !this.features.speechSynthesisUtterance)
1596
+ if (this.features = ns(), this.patches = ss(), !this.features.speechSynthesis || !this.features.speechSynthesisUtterance)
1589
1597
  throw new Error("Web Speech API is not available in this environment");
1590
1598
  this.speechSynthesis = this.features.speechSynthesis, this.speechSynthesisUtterance = this.features.speechSynthesisUtterance;
1591
1599
  }
@@ -1636,7 +1644,7 @@ class ht {
1636
1644
  }
1637
1645
  // No cross-region fallback: fr-FR content must not match an fr-CA voice.
1638
1646
  voiceMatchesLanguage(e, t) {
1639
- const [s, i] = E(t), [a, r] = E(e.language);
1647
+ const [s, i] = k(t), [a, r] = k(e.language);
1640
1648
  return a === s && (!i || r === i);
1641
1649
  }
1642
1650
  languageCacheKey(e, t) {
@@ -1671,8 +1679,8 @@ class ht {
1671
1679
  ), i = [...s].filter((o) => this.warmingLanguages.has(this.languageCacheKey(o, t))), r = [...s].filter((o) => !this.warmingLanguages.has(this.languageCacheKey(o, t))).map((o) => {
1672
1680
  const l = this.languageCacheKey(o, t), c = (async () => {
1673
1681
  await b.initialize({ languages: [o] }), this.voices = this.voiceManager.getVoices();
1674
- const u = this.voices.filter((f) => this.voiceMatchesLanguage(f, o)), d = Bt(u, t), g = (await this.voiceManager.sortVoicesByQuality(d))[0] ?? null;
1675
- this.languageVoiceCache.set(l, g), g || this.emitEvent({ type: "languagefallback", detail: { language: o, reason: "no-matching-voice" } });
1682
+ const u = this.voices.filter((f) => this.voiceMatchesLanguage(f, o)), g = Mt(u, t), d = (await this.voiceManager.sortVoicesByQuality(g))[0] ?? null;
1683
+ this.languageVoiceCache.set(l, d), d || this.emitEvent({ type: "languagefallback", detail: { language: o, reason: "no-matching-voice" } });
1676
1684
  })();
1677
1685
  return this.warmingLanguages.set(l, c.finally(() => this.warmingLanguages.delete(l))), this.warmingLanguages.get(l);
1678
1686
  });
@@ -1685,7 +1693,7 @@ class ht {
1685
1693
  return this.currentVoice;
1686
1694
  }
1687
1695
  setSpeakInContentLanguage(e) {
1688
- this.speakInContentLanguage = e, e && this.warmLanguageVoiceCache(this.currentUtterances);
1696
+ e !== this.speakInContentLanguage && (this.speakInContentLanguage = e, e && this.warmLanguageVoiceCache(this.currentUtterances), this.scheduleRestartIfSpeaking());
1689
1697
  }
1690
1698
  getSpeakInContentLanguage() {
1691
1699
  return this.speakInContentLanguage;
@@ -1696,22 +1704,22 @@ class ht {
1696
1704
  toPlainText(e) {
1697
1705
  return e.map((t) => ({
1698
1706
  ...t,
1699
- plain: t.plain ?? (t.ssml ? z(rs(t.ssml)) : "")
1707
+ plain: t.plain ?? (t.ssml ? z(ls(t.ssml)) : "")
1700
1708
  }));
1701
1709
  }
1702
1710
  // Queue Management
1703
1711
  loadUtterances(e, t) {
1704
- this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex = oe(t ?? 0, e.length), this.warmLanguageVoiceCache(this.currentUtterances), this.playbackState = "ready", this.emitEvent({ type: "ready" });
1712
+ this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex = le(t ?? 0, e.length), this.warmLanguageVoiceCache(this.currentUtterances), this.playbackState = "ready", this.emitEvent({ type: "ready" });
1705
1713
  }
1706
1714
  // Voice Configuration
1707
1715
  async setVoice(e) {
1708
1716
  const t = this.currentVoice;
1709
1717
  if (typeof e == "string") {
1710
1718
  const s = this.voices.find((i) => i.name === e || i.language === e);
1711
- s ? (this.currentVoice = s, t && t.name !== s.name && (this.currentUtteranceIndex = 0)) : console.warn(`Voice "${e}" not found`);
1719
+ s ? this.currentVoice = s : console.warn(`Voice "${e}" not found`);
1712
1720
  } else
1713
- this.currentVoice = e, t && t.name !== e.name && (this.currentUtteranceIndex = 0);
1714
- this.voiceManager && this.defaultVoice && this.currentVoice && this.currentVoice.language !== this.defaultVoice.language && (this.defaultVoice = await this.voiceManager.getDefaultVoice([this.currentVoice.language], this.voices));
1721
+ this.currentVoice = e;
1722
+ this.currentVoice?.name !== t?.name && this.scheduleRestartIfSpeaking(), this.voiceManager && this.defaultVoice && this.currentVoice && this.currentVoice.language !== this.defaultVoice.language && (this.defaultVoice = await this.voiceManager.getDefaultVoice([this.currentVoice.language], this.voices));
1715
1723
  }
1716
1724
  async getAvailableVoices() {
1717
1725
  if (this.voices.length > 0)
@@ -1749,22 +1757,23 @@ class ht {
1749
1757
  }
1750
1758
  const t = this.currentUtterances[this.currentUtteranceIndex], s = t.plain ?? "";
1751
1759
  this.validateText(s);
1752
- const i = this.createUtterance(Mt(s)), a = await this.voiceForUtterance(t);
1760
+ const i = this.createUtterance(Dt(s)), a = await this.voiceForUtterance(t);
1753
1761
  if (e === this.speakGeneration) {
1754
- if (a && this.voiceManager) {
1762
+ if (this.lacksNativePauseEvents = !1, a && this.voiceManager) {
1755
1763
  const r = this.voiceManager.convertToSpeechSynthesisVoice(a);
1756
- r && (i.voice = r, i.lang = r.lang);
1764
+ r && (i.voice = r, i.lang = r.lang, this.lacksNativePauseEvents = !r.localService && r.name.startsWith("Google"));
1757
1765
  }
1758
1766
  t.language && (i.lang = t.language), i.rate = this.rate, i.pitch = this.pitch, i.volume = this.volume, i.onstart = () => {
1767
+ if (e !== this.speakGeneration) return;
1759
1768
  this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.emitEvent({ type: "start" }), this.patches.isAndroid && this.isAndroidPaused && (this.isAndroidPaused = !1), this.shouldUseResumeInfinity() && this.startResumeInfinity(i);
1760
1769
  }, i.onend = () => {
1761
1770
  if (this.utterancesBeingCancelled) {
1762
1771
  this.utterancesBeingCancelled = !1;
1763
1772
  return;
1764
1773
  }
1765
- this.playbackState !== "idle" && (this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length - 1 && this.setState("idle"), this.emitEvent({ type: "end" }));
1774
+ e === this.speakGeneration && this.playbackState !== "idle" && (this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length - 1 && this.setState("idle"), this.emitEvent({ type: "end" }));
1766
1775
  }, i.onerror = (r) => {
1767
- if (r.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
1776
+ if (e !== this.speakGeneration || r.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
1768
1777
  return;
1769
1778
  this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.setState("idle"), ["synthesis-unavailable", "audio-hardware", "voice-unavailable"].includes(r.error) && (console.log("[ENGINE] fatal error detected, resetting index to 0"), this.currentUtteranceIndex = 0), r.error === "interrupted" || r.error === "canceled" ? this.emitEvent({ type: "stop" }) : this.emitEvent({
1770
1779
  type: "error",
@@ -1775,9 +1784,9 @@ class ht {
1775
1784
  }
1776
1785
  });
1777
1786
  }, i.onpause = () => {
1778
- this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" });
1787
+ e === this.speakGeneration && (this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" }));
1779
1788
  }, i.onresume = () => {
1780
- this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" });
1789
+ e === this.speakGeneration && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" }));
1781
1790
  }, i.onboundary = (r) => {
1782
1791
  e === this.speakGeneration && this.emitEvent({
1783
1792
  type: "boundary",
@@ -1789,7 +1798,7 @@ class ht {
1789
1798
  }
1790
1799
  });
1791
1800
  }, i.onmark = (r) => {
1792
- this.emitEvent({
1801
+ e === this.speakGeneration && this.emitEvent({
1793
1802
  type: "mark",
1794
1803
  detail: {
1795
1804
  name: r.name
@@ -1811,10 +1820,10 @@ class ht {
1811
1820
  this.resumeInfinityTimer && (clearTimeout(this.resumeInfinityTimer), this.resumeInfinityTimer = void 0);
1812
1821
  }
1813
1822
  pause() {
1814
- this.playbackState === "playing" && (this.pausedAtUtteranceIndex = this.currentUtteranceIndex, this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.setState("paused"), this.patches.isAndroid ? (this.isAndroidPaused = !0, this.speechSynthesis.cancel(), this.emitEvent({ type: "pause" })) : this.speechSynthesis.pause());
1823
+ this.playbackState === "playing" && (this.pausedAtUtteranceIndex = this.currentUtteranceIndex, this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.setState("paused"), this.patches.isAndroid ? (this.isAndroidPaused = !0, this.speechSynthesis.cancel(), this.emitEvent({ type: "pause" })) : (this.speechSynthesis.pause(), this.lacksNativePauseEvents && this.emitEvent({ type: "pause" })));
1815
1824
  }
1816
1825
  resume() {
1817
- this.playbackState === "paused" && this.currentUtteranceIndex < this.currentUtterances.length && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.setState("playing"), this.patches.isAndroid || this.pausedAtUtteranceIndex !== this.currentUtteranceIndex ? (this.emitEvent({ type: "resume" }), this.speak(this.currentUtteranceIndex)) : this.speechSynthesis.resume(), this.pausedAtUtteranceIndex = null);
1826
+ this.playbackState === "paused" && this.currentUtteranceIndex < this.currentUtterances.length && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.setState("playing"), this.patches.isAndroid || this.pausedAtUtteranceIndex !== this.currentUtteranceIndex ? (this.emitEvent({ type: "resume" }), this.speak(this.currentUtteranceIndex)) : (this.speechSynthesis.resume(), this.lacksNativePauseEvents && this.emitEvent({ type: "resume" })), this.pausedAtUtteranceIndex = null);
1818
1827
  }
1819
1828
  stop() {
1820
1829
  this.cancelCurrentSpeech(), this.speakGeneration++, this.currentUtteranceIndex = 0, this.patches.isAndroid && (this.isAndroidPaused = !1), this.setState("idle"), this.emitEvent({ type: "stop" });
@@ -1841,12 +1850,15 @@ class ht {
1841
1850
  getVolume() {
1842
1851
  return this.volume;
1843
1852
  }
1844
- // rate/pitch/volume are baked into the SpeechSynthesisUtterance object once, at speak()-time —
1845
- // restart the in-flight one so a change applies now instead of waiting for the next utterance.
1846
- // Coalesces multiple same-tick changes (e.g. rate+pitch together) into a single restart.
1853
+ // Voice, language, rate, pitch and volume are baked into the SpeechSynthesisUtterance at speak()-time:
1854
+ // restart it so a change applies now (or on resume when paused). Same-tick changes coalesce.
1847
1855
  scheduleRestartIfSpeaking() {
1856
+ if (this.playbackState === "paused") {
1857
+ this.pausedAtUtteranceIndex = null;
1858
+ return;
1859
+ }
1848
1860
  !this.isSpeakingInternal || this.restartPending || (this.restartPending = !0, queueMicrotask(() => {
1849
- this.restartPending && (this.restartPending = !1, this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
1861
+ this.restartPending && (this.restartPending = !1, this.playbackState === "paused" ? this.pausedAtUtteranceIndex = null : this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
1850
1862
  }));
1851
1863
  }
1852
1864
  // State
@@ -1861,7 +1873,11 @@ class ht {
1861
1873
  t?.(!1);
1862
1874
  return;
1863
1875
  }
1864
- e !== this.currentUtteranceIndex && (!this.isPausedInternal && this.isSpeakingInternal && this.cancelCurrentSpeech(), this.currentUtteranceIndex = e, t?.(!0));
1876
+ if (e === this.currentUtteranceIndex) {
1877
+ t?.(!0);
1878
+ return;
1879
+ }
1880
+ !this.isPausedInternal && this.isSpeakingInternal && this.cancelCurrentSpeech(), this.currentUtteranceIndex = e, t?.(!0);
1865
1881
  }
1866
1882
  getUtteranceCount() {
1867
1883
  return this.currentUtterances.length;
@@ -1893,27 +1909,27 @@ class ht {
1893
1909
  this.stop(), this.stopResumeInfinity(), this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.voices = [], this.defaultVoice = null, this.languageVoiceCache.clear(), this.warmingLanguages.clear(), this.initialized = !1;
1894
1910
  }
1895
1911
  }
1896
- class ea {
1912
+ class ia {
1897
1913
  id = "webspeech";
1898
1914
  name = "Web Speech API";
1899
1915
  voiceEngine = null;
1900
1916
  // No cache to bypass here — local API, no network cost to re-checking.
1901
1917
  async getVoices() {
1902
- return this.voiceEngine || (this.voiceEngine = new ht(), await this.voiceEngine.initialize()), this.voiceEngine.getAvailableVoices();
1918
+ return this.voiceEngine || (this.voiceEngine = new dt(), await this.voiceEngine.initialize()), this.voiceEngine.getAvailableVoices();
1903
1919
  }
1904
1920
  async createEngine(e) {
1905
- const t = new ht();
1921
+ const t = new dt();
1906
1922
  return await t.initialize(), e && await t.setVoice(e), t;
1907
1923
  }
1908
1924
  async destroy() {
1909
1925
  this.voiceEngine && (await this.voiceEngine.destroy(), this.voiceEngine = null);
1910
1926
  }
1911
1927
  }
1912
- function Gt(n, e) {
1928
+ function Kt(n, e) {
1913
1929
  const t = [];
1914
1930
  let s = -1, i = -1;
1915
1931
  const a = () => {
1916
- s !== -1 && (t.push({ text: Cs(n, s, i), offset: n[s].offset }), s = -1, i = -1);
1932
+ s !== -1 && (t.push({ text: Rs(n, s, i), offset: n[s].offset }), s = -1, i = -1);
1917
1933
  };
1918
1934
  for (let r = 0; r < n.length; r++) {
1919
1935
  const o = n[r];
@@ -1926,49 +1942,49 @@ function Gt(n, e) {
1926
1942
  }
1927
1943
  return a(), t;
1928
1944
  }
1929
- function Cs(n, e, t) {
1945
+ function Rs(n, e, t) {
1930
1946
  const s = n[e], i = n[t];
1931
1947
  return s === i ? s.text : n.slice(e, t + 1).map((a) => a.text).join("");
1932
1948
  }
1933
- const Kt = new RegExp(
1949
+ const Wt = new RegExp(
1934
1950
  `[^${K}]*[${K}]+\\s*|[^${K}]+$`,
1935
1951
  "gu"
1936
- ), Es = /\S+\s*|\s+/g;
1937
- function Be(n, e, t) {
1952
+ ), Is = /\S+\s*|\s+/g;
1953
+ function Me(n, e, t) {
1938
1954
  const s = [];
1939
1955
  for (const i of n.matchAll(t))
1940
1956
  i[0].length !== 0 && s.push({ text: i[0], offset: e + i.index, atomic: !1 });
1941
1957
  return s;
1942
1958
  }
1943
- function Me(n, e) {
1959
+ function De(n, e) {
1944
1960
  if (n.text.length <= e || n.atomic)
1945
1961
  return [n];
1946
- const t = Be(n.text, n.offset, Es);
1962
+ const t = Me(n.text, n.offset, Is);
1947
1963
  if (t.length > 1)
1948
- return t.flatMap((r) => Me(r, e));
1964
+ return t.flatMap((r) => De(r, e));
1949
1965
  const s = [];
1950
1966
  let i = n.offset, a = "";
1951
1967
  for (const r of n.text)
1952
1968
  a.length > 0 && a.length + r.length > e && (s.push({ text: a, offset: i, atomic: !1 }), i += a.length, a = ""), a += r;
1953
1969
  return a.length > 0 && s.push({ text: a, offset: i, atomic: !1 }), s;
1954
1970
  }
1955
- function Rs(n, e) {
1971
+ function Ps(n, e) {
1956
1972
  if (n.length <= e)
1957
1973
  return [{ text: n, offset: 0 }];
1958
- const s = Be(n, 0, Kt).flatMap((i) => Me(i, e));
1959
- return Gt(s, e);
1974
+ const s = Me(n, 0, Wt).flatMap((i) => De(i, e));
1975
+ return Kt(s, e);
1960
1976
  }
1961
- const Is = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1962
- function Ps(n, e) {
1977
+ const As = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1978
+ function xs(n, e) {
1963
1979
  if (n.length <= e)
1964
1980
  return [{ text: n, offset: 0 }];
1965
1981
  const t = [];
1966
- for (const i of n.matchAll(Is))
1967
- i[0][0] === "<" ? t.push({ text: i[0], offset: i.index, atomic: !0 }) : t.push(...Be(i[0], i.index, Kt));
1968
- const s = t.flatMap((i) => Me(i, e));
1969
- return Gt(s, e);
1982
+ for (const i of n.matchAll(As))
1983
+ i[0][0] === "<" ? t.push({ text: i[0], offset: i.index, atomic: !0 }) : t.push(...Me(i[0], i.index, Wt));
1984
+ const s = t.flatMap((i) => De(i, e));
1985
+ return Kt(s, e);
1970
1986
  }
1971
- const xs = {
1987
+ const Ls = {
1972
1988
  wav: "audio/wav",
1973
1989
  mp3: "audio/mpeg",
1974
1990
  opus: "audio/ogg",
@@ -1978,31 +1994,31 @@ const xs = {
1978
1994
  webm: "audio/webm",
1979
1995
  m4a: "audio/mp4"
1980
1996
  };
1981
- function As(n) {
1982
- return xs[n] ?? `audio/${n}`;
1997
+ function Os(n) {
1998
+ return Ls[n] ?? `audio/${n}`;
1983
1999
  }
1984
- const Ls = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], Os = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
1985
- function Us(n, e, t) {
1986
- const s = (o) => t(As(o)) !== "", i = n.formats.filter(s);
2000
+ const Us = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], Vs = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
2001
+ function Ts(n, e, t) {
2002
+ const s = (o) => t(Os(o)) !== "", i = n.formats.filter(s);
1987
2003
  if (e.preferredFormat && i.includes(e.preferredFormat))
1988
2004
  return e.preferredFormat;
1989
- const a = e.strategy === "bandwidth" ? Os : Ls, r = [...a, ...i.filter((o) => !a.includes(o))];
2005
+ const a = e.strategy === "bandwidth" ? Vs : Us, r = [...a, ...i.filter((o) => !a.includes(o))];
1990
2006
  for (const o of r)
1991
2007
  if (i.includes(o))
1992
2008
  return o;
1993
2009
  return n.default;
1994
2010
  }
1995
- const Ts = /* @__PURE__ */ new Set(["wav", "flac"]), Vs = {
2011
+ const zs = /* @__PURE__ */ new Set(["wav", "flac"]), Ns = {
1996
2012
  mp3: 48e3,
1997
2013
  opus: 24e3,
1998
2014
  aac: 48e3,
1999
2015
  ogg: 48e3,
2000
2016
  webm: 32e3
2001
2017
  };
2002
- function zs(n, e, t) {
2003
- return Ts.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Vs[n] : void 0;
2018
+ function Bs(n, e, t) {
2019
+ return zs.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Ns[n] : void 0;
2004
2020
  }
2005
- function Wt(n, e) {
2021
+ function Qt(n, e) {
2006
2022
  return {
2007
2023
  source: "server",
2008
2024
  label: n.name,
@@ -2026,17 +2042,17 @@ class J extends Error {
2026
2042
  super(e), this.name = "SpeechServerError", this.status = t.status, this.type = t.type, this.title = t.title, this.instance = t.instance;
2027
2043
  }
2028
2044
  }
2029
- class Qt extends J {
2045
+ class Jt extends J {
2030
2046
  constructor(e) {
2031
2047
  super(e, { status: 408, type: "https://readium.org/speech-server/error#stall", title: "Synthesis Stalled" }), this.name = "SpeechServerStallError";
2032
2048
  }
2033
2049
  }
2034
- class Jt extends Error {
2050
+ class Zt extends Error {
2035
2051
  constructor(e) {
2036
2052
  super(e), this.name = "SpeechServerAudioDecodeError";
2037
2053
  }
2038
2054
  }
2039
- class Zt extends Error {
2055
+ class Yt extends Error {
2040
2056
  constructor(e) {
2041
2057
  super(e), this.name = "SpeechServerNetworkError";
2042
2058
  }
@@ -2055,23 +2071,23 @@ async function W(n) {
2055
2071
  }
2056
2072
  return new J(`Request failed with status ${n.status}`, { status: n.status });
2057
2073
  }
2058
- const Ns = 3, Bs = 400;
2059
- function Ms(n) {
2074
+ const Ms = 3, Ds = 400;
2075
+ function js(n) {
2060
2076
  const e = atob(n), t = new Uint8Array(e.length);
2061
2077
  for (let s = 0; s < e.length; s++)
2062
2078
  t[s] = e.charCodeAt(s);
2063
2079
  return t.buffer;
2064
2080
  }
2065
- function Ds(n) {
2081
+ function Fs(n) {
2066
2082
  return F(n, 0.25, 4, 1);
2067
2083
  }
2068
- function ie(n) {
2084
+ function ae(n) {
2069
2085
  return n?.plain ?? n?.ssml ?? void 0;
2070
2086
  }
2071
- function dt(n) {
2072
- return n instanceof Qt ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof J ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Jt ? { message: n.message, recoverable: !1 } : n instanceof Zt ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
2087
+ function gt(n) {
2088
+ return n instanceof Jt ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof J ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Zt ? { message: n.message, recoverable: !1 } : n instanceof Yt ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
2073
2089
  }
2074
- class js {
2090
+ class _s {
2075
2091
  endpoints;
2076
2092
  fetchImpl;
2077
2093
  currentVoice = null;
@@ -2081,7 +2097,7 @@ class js {
2081
2097
  currentUtterances = [];
2082
2098
  currentUtteranceIndex = 0;
2083
2099
  playbackState = "idle";
2084
- events = new be();
2100
+ events = new we();
2085
2101
  speakInContentLanguage = !1;
2086
2102
  speakGeneration = 0;
2087
2103
  loadGeneration = 0;
@@ -2102,6 +2118,7 @@ class js {
2102
2118
  liveControllers = /* @__PURE__ */ new Set();
2103
2119
  isSpeakingInternal = !1;
2104
2120
  restartPending = !1;
2121
+ restartOnResume = !1;
2105
2122
  audioContext = null;
2106
2123
  masterGain = null;
2107
2124
  scheduledChunks = [];
@@ -2110,7 +2127,7 @@ class js {
2110
2127
  pitch = 1;
2111
2128
  volume = 1;
2112
2129
  constructor(e) {
2113
- this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? Ns, this.readyBufferChars = e.readyBufferChars ?? Bs, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
2130
+ this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? Ms, this.readyBufferChars = e.readyBufferChars ?? Ds, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
2114
2131
  }
2115
2132
  // Lets a provider that already fetched /voices seed this engine without a second request.
2116
2133
  setAvailableVoices(e) {
@@ -2122,17 +2139,17 @@ class js {
2122
2139
  try {
2123
2140
  return await this.fetchImpl(e, t);
2124
2141
  } catch (s) {
2125
- throw s instanceof TypeError ? new Zt(s.message) : s;
2142
+ throw s instanceof TypeError ? new Yt(s.message) : s;
2126
2143
  }
2127
2144
  }
2128
2145
  loadUtterances(e, t) {
2129
- this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex = oe(t ?? 0, e.length), this.setState("loading"), this.bufferUntilReady(++this.loadGeneration);
2146
+ this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex = le(t ?? 0, e.length), this.setState("loading"), this.bufferUntilReady(++this.loadGeneration);
2130
2147
  }
2131
2148
  // Buffers enough utterances ahead of currentUtteranceIndex to cover readyBufferChars before
2132
2149
  // declaring "ready", so playback doesn't catch up to an empty prefetch cache right away —
2133
2150
  // starting from wherever playback will actually resume, not always utterance 0.
2134
2151
  async bufferUntilReady(e) {
2135
- const t = oe(this.currentUtteranceIndex, this.currentUtterances.length), s = Math.min(this.indexCoveringChars(this.readyBufferChars, t), t + this.prefetchWindow), i = [];
2152
+ const t = le(this.currentUtteranceIndex, this.currentUtterances.length), s = Math.min(this.indexCoveringChars(this.readyBufferChars, t), t + this.prefetchWindow), i = [];
2136
2153
  for (let a = t; a <= s; a++) {
2137
2154
  this.queuePrefetch(a);
2138
2155
  const r = this.prefetchCache.get(a);
@@ -2147,33 +2164,34 @@ class js {
2147
2164
  indexCoveringChars(e, t) {
2148
2165
  if (this.currentUtterances.length === 0)
2149
2166
  return -1;
2150
- const s = oe(t, this.currentUtterances.length);
2167
+ const s = le(t, this.currentUtterances.length);
2151
2168
  let i = 0;
2152
2169
  for (let a = s; a < this.currentUtterances.length; a++)
2153
- if (i += (ie(this.currentUtterances[a]) ?? "").length, i >= e)
2170
+ if (i += (ae(this.currentUtterances[a]) ?? "").length, i >= e)
2154
2171
  return a;
2155
2172
  return this.currentUtterances.length - 1;
2156
2173
  }
2157
2174
  setVoice(e) {
2175
+ const t = this.currentVoice?.identifier ?? this.currentVoice?.name;
2158
2176
  if (typeof e == "string") {
2159
- const t = this.voices.find((s) => s.identifier === e || s.name === e);
2160
- t ? this.currentVoice = t : (this.currentVoice = {
2177
+ const s = this.voices.find((i) => i.identifier === e || i.name === e);
2178
+ s ? this.currentVoice = s : (this.currentVoice = {
2161
2179
  source: "server",
2162
2180
  label: e,
2163
2181
  name: e,
2164
2182
  originalName: e,
2165
2183
  language: "",
2166
2184
  identifier: e
2167
- }, this.getAvailableVoices().then((s) => {
2185
+ }, this.getAvailableVoices().then((i) => {
2168
2186
  if (this.currentVoice?.identifier !== e)
2169
2187
  return;
2170
- const i = s.find((a) => a.identifier === e || a.name === e);
2171
- i && (this.currentVoice = i);
2188
+ const a = i.find((r) => r.identifier === e || r.name === e);
2189
+ a && (this.currentVoice = a, (a.identifier !== e || a.controls?.speed === !0) && (this.clearPrefetchCache(), this.scheduleRestartIfSpeaking()));
2172
2190
  }).catch(() => {
2173
2191
  }));
2174
2192
  } else
2175
2193
  this.currentVoice = e;
2176
- this.abortLiveControllers(), this.clearPrefetchCache();
2194
+ (this.currentVoice?.identifier ?? this.currentVoice?.name) !== t && (this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
2177
2195
  }
2178
2196
  getCurrentVoice() {
2179
2197
  return this.currentVoice;
@@ -2185,7 +2203,7 @@ class js {
2185
2203
  if (!e.ok)
2186
2204
  throw await W(e);
2187
2205
  const s = await e.json(), i = new Map(t.providers.map((a) => [a.id, a.controls]));
2188
- return this.voices = s.map((a) => Wt(a, i.get(a.provider))), this.voices;
2206
+ return this.voices = s.map((a) => Qt(a, i.get(a.provider))), this.voices;
2189
2207
  }
2190
2208
  // Cached after the first successful fetch; a failed fetch isn't cached, so the next
2191
2209
  // synthesize() call retries rather than being stuck on a transient network error.
@@ -2201,7 +2219,7 @@ class js {
2201
2219
  return e.json();
2202
2220
  }
2203
2221
  setSpeakInContentLanguage(e) {
2204
- this.speakInContentLanguage = e, this.abortLiveControllers(), this.clearPrefetchCache();
2222
+ e !== this.speakInContentLanguage && (this.speakInContentLanguage = e, this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
2205
2223
  }
2206
2224
  getSpeakInContentLanguage() {
2207
2225
  return this.speakInContentLanguage;
@@ -2212,7 +2230,7 @@ class js {
2212
2230
  throw new Error("Invalid utterance index");
2213
2231
  this.currentUtteranceIndex = e;
2214
2232
  }
2215
- if (this.restartPending = !1, this.currentUtterances.length === 0) {
2233
+ if (this.restartPending = !1, this.restartOnResume = !1, this.currentUtterances.length === 0) {
2216
2234
  console.warn("No utterances loaded");
2217
2235
  return;
2218
2236
  }
@@ -2232,7 +2250,7 @@ class js {
2232
2250
  return;
2233
2251
  this.isSpeakingInternal = !1, this.setState("idle"), this.emitEvent({
2234
2252
  type: "error",
2235
- detail: dt(s)
2253
+ detail: gt(s)
2236
2254
  });
2237
2255
  }
2238
2256
  }
@@ -2279,11 +2297,11 @@ class js {
2279
2297
  this.liveControllers.forEach((e) => e.abort()), this.liveControllers.clear();
2280
2298
  }
2281
2299
  async synthesizeStream(e, t) {
2282
- const s = this.currentUtterances[e], i = !s.plain && !!s.ssml, a = this.speakInContentLanguage ? s.language : void 0, r = ie(s) ?? "", o = i ? Dt(r).map : void 0, l = ie(this.currentUtterances[e - 1]), c = ie(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), d = Us(u.output, this.formatOptions, this.canPlayType), h = navigator.connection, g = zs(d, this.formatOptions.adaptBitrateToNetwork ?? !1, h);
2300
+ const s = this.currentUtterances[e], i = !s.plain && !!s.ssml, a = this.speakInContentLanguage ? s.language : void 0, r = ae(s) ?? "", o = i ? jt(r).map : void 0, l = ae(this.currentUtterances[e - 1]), c = ae(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g = Ts(u.output, this.formatOptions, this.canPlayType), h = navigator.connection, d = Bs(g, this.formatOptions.adaptBitrateToNetwork ?? !1, h);
2283
2301
  if (r.length <= u.limits.maxTextLength) {
2284
2302
  const v = new AbortController();
2285
2303
  return (t ? this.activeControllers : this.liveControllers).add(v), [{
2286
- promise: this.synthesizeChunk({ content: s, text: r, textOffset: 0, useSSML: i, ssmlMap: o, language: a, prevText: l, nextText: c, format: d, bitrate: g, controller: v }),
2304
+ promise: this.synthesizeChunk({ content: s, text: r, textOffset: 0, useSSML: i, ssmlMap: o, language: a, prevText: l, nextText: c, format: g, bitrate: d, controller: v }),
2287
2305
  controller: v
2288
2306
  }];
2289
2307
  }
@@ -2296,45 +2314,45 @@ class js {
2296
2314
  title: "Payload Too Large"
2297
2315
  }
2298
2316
  );
2299
- const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = i ? Ps(r, f) : Rs(r, f), m = [];
2317
+ const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = i ? xs(r, f) : Ps(r, f), m = [];
2300
2318
  let S = Promise.resolve();
2301
2319
  for (let v = 0; v < p.length; v++) {
2302
- const I = v === 0 ? l : p[v - 1].text, P = v === p.length - 1 ? c : p[v + 1].text, y = p[v], k = new AbortController();
2303
- (t ? this.activeControllers : this.liveControllers).add(k);
2320
+ const I = v === 0 ? l : p[v - 1].text, P = v === p.length - 1 ? c : p[v + 1].text, y = p[v], C = new AbortController();
2321
+ (t ? this.activeControllers : this.liveControllers).add(C);
2304
2322
  const R = S.then(
2305
- () => this.synthesizeChunk({ content: s, text: y.text, textOffset: y.offset, useSSML: i, ssmlMap: o, language: a, prevText: I, nextText: P, format: d, bitrate: g, controller: k })
2323
+ () => this.synthesizeChunk({ content: s, text: y.text, textOffset: y.offset, useSSML: i, ssmlMap: o, language: a, prevText: I, nextText: P, format: g, bitrate: d, controller: C })
2306
2324
  );
2307
- m.push({ promise: R, controller: k }), S = R;
2325
+ m.push({ promise: R, controller: C }), S = R;
2308
2326
  }
2309
2327
  return m;
2310
2328
  }
2311
2329
  async synthesizeChunk(e) {
2312
- const { content: t, text: s, textOffset: i, useSSML: a, ssmlMap: r, language: o, prevText: l, nextText: c, format: u, bitrate: d, controller: h } = e;
2330
+ const { content: t, text: s, textOffset: i, useSSML: a, ssmlMap: r, language: o, prevText: l, nextText: c, format: u, bitrate: g, controller: h } = e;
2313
2331
  try {
2314
- const g = await this.fetchNetwork(this.endpoints.synthesize, {
2332
+ const d = await this.fetchNetwork(this.endpoints.synthesize, {
2315
2333
  method: "POST",
2316
2334
  headers: { "Content-Type": "application/json" },
2317
2335
  body: JSON.stringify({
2318
2336
  id: t.id,
2319
- text: a ? s : Mt(s),
2337
+ text: a ? s : Dt(s),
2320
2338
  ssml: a,
2321
2339
  language: o,
2322
2340
  voice: this.currentVoice?.identifier ?? this.currentVoice?.name,
2323
2341
  prev_utterance: l,
2324
2342
  next_utterance: c,
2325
2343
  boundary: !0,
2326
- output: { format: u, bitrate: d, speed: this.rate, pitch: this.pitch }
2344
+ output: { format: u, bitrate: g, speed: this.rate, pitch: this.pitch }
2327
2345
  }),
2328
2346
  signal: h.signal
2329
2347
  });
2330
- if (!g.ok)
2331
- throw await W(g);
2332
- const f = await g.json(), p = Ms(f.audio);
2348
+ if (!d.ok)
2349
+ throw await W(d);
2350
+ const f = await d.json(), p = js(f.audio);
2333
2351
  let m;
2334
2352
  try {
2335
2353
  m = await this.ensureAudioContext().decodeAudioData(p);
2336
2354
  } catch {
2337
- throw new Jt("Audio playback failed");
2355
+ throw new Zt("Audio playback failed");
2338
2356
  }
2339
2357
  return { audioBuffer: m, format: f.format, boundaries: f.boundaries, textOffset: i, ssmlMap: r };
2340
2358
  } finally {
@@ -2355,7 +2373,7 @@ class js {
2355
2373
  const i = s + this.timeoutMs;
2356
2374
  return new Promise((a, r) => {
2357
2375
  const o = setTimeout(() => {
2358
- t.abort(), r(new Qt(`No audio chunk arrived within ${i.toFixed(0)}ms of the playback buffer running dry`));
2376
+ t.abort(), r(new Jt(`No audio chunk arrived within ${i.toFixed(0)}ms of the playback buffer running dry`));
2359
2377
  }, i);
2360
2378
  e.then(
2361
2379
  (l) => {
@@ -2372,21 +2390,21 @@ class js {
2372
2390
  const s = await this.awaitWithStallDeadline(e[0].promise, e[0].controller, 0);
2373
2391
  if (t !== this.speakGeneration)
2374
2392
  return;
2375
- const i = this.ensureAudioContext(), a = this.masterGain, o = this.currentVoice?.controls?.speed === !0 ? 1 : Ds(this.rate);
2393
+ const i = this.ensureAudioContext(), a = this.masterGain, o = this.currentVoice?.controls?.speed === !0 ? 1 : Fs(this.rate);
2376
2394
  this.scheduledChunks = [], this.setState("playing"), this.emitEvent({ type: "start" });
2377
2395
  let l = i.currentTime, c = null;
2378
- const u = (d) => {
2396
+ const u = (g) => {
2379
2397
  const h = i.createBufferSource();
2380
- h.buffer = d.audioBuffer, h.playbackRate.value = o, h.connect(a), h.start(l), c && (c.onended = null), h.onended = () => this.handleUtteranceEnded(t), c = h, this.scheduledChunks.push({ chunk: d, startTime: l, node: h, nextBoundaryIndex: 0, rate: o }), l += d.audioBuffer.duration / o;
2398
+ h.buffer = g.audioBuffer, h.playbackRate.value = o, h.connect(a), h.start(l), c && (c.onended = null), h.onended = () => this.handleUtteranceEnded(t), c = h, this.scheduledChunks.push({ chunk: g, startTime: l, node: h, nextBoundaryIndex: 0, rate: o }), l += g.audioBuffer.duration / o;
2381
2399
  };
2382
2400
  u(s), this.startBoundaryPolling(t);
2383
- for (let d = 1; d < e.length; d++) {
2401
+ for (let g = 1; g < e.length; g++) {
2384
2402
  let h;
2385
2403
  try {
2386
- const g = Math.max(0, (l - i.currentTime) * 1e3);
2387
- h = await this.awaitWithStallDeadline(e[d].promise, e[d].controller, g);
2388
- } catch (g) {
2389
- t === this.speakGeneration && this.emitEvent({ type: "error", detail: dt(g) });
2404
+ const d = Math.max(0, (l - i.currentTime) * 1e3);
2405
+ h = await this.awaitWithStallDeadline(e[g].promise, e[g].controller, d);
2406
+ } catch (d) {
2407
+ t === this.speakGeneration && this.emitEvent({ type: "error", detail: gt(d) });
2390
2408
  return;
2391
2409
  }
2392
2410
  if (t !== this.speakGeneration)
@@ -2417,7 +2435,7 @@ class js {
2417
2435
  let r = a, o = i.charLength;
2418
2436
  if (t.chunk.ssmlMap) {
2419
2437
  const l = t.chunk.ssmlMap;
2420
- r = rt(l, a), o = Math.max(0, rt(l, a + i.charLength) - r);
2438
+ r = ot(l, a), o = Math.max(0, ot(l, a + i.charLength) - r);
2421
2439
  }
2422
2440
  this.emitEvent({
2423
2441
  type: "boundary",
@@ -2448,11 +2466,17 @@ class js {
2448
2466
  }), this.stopBoundaryPolling(), this.isSpeakingInternal = !1, this.setState("paused"), this.emitEvent({ type: "pause" }));
2449
2467
  }
2450
2468
  resume() {
2451
- this.playbackState === "paused" && this.audioContext && (this.audioContext.resume().catch(() => {
2452
- }), this.startBoundaryPolling(this.speakGeneration), this.isSpeakingInternal = !0, this.setState("playing"), this.emitEvent({ type: "resume" }));
2469
+ if (this.playbackState === "paused" && this.audioContext) {
2470
+ if (this.restartOnResume) {
2471
+ this.emitEvent({ type: "resume" }), this.speak(this.currentUtteranceIndex);
2472
+ return;
2473
+ }
2474
+ this.audioContext.resume().catch(() => {
2475
+ }), this.startBoundaryPolling(this.speakGeneration), this.isSpeakingInternal = !0, this.setState("playing"), this.emitEvent({ type: "resume" });
2476
+ }
2453
2477
  }
2454
2478
  stop() {
2455
- this.speakGeneration++, this.loadGeneration++, this.stopAudio(), this.abortLiveControllers(), this.clearPrefetchCache(), this.isSpeakingInternal = !1, this.currentUtteranceIndex = 0, this.setState("idle"), this.emitEvent({ type: "stop" });
2479
+ this.speakGeneration++, this.loadGeneration++, this.stopAudio(), this.abortLiveControllers(), this.clearPrefetchCache(), this.isSpeakingInternal = !1, this.restartOnResume = !1, this.currentUtteranceIndex = 0, this.setState("idle"), this.emitEvent({ type: "stop" });
2456
2480
  }
2457
2481
  setRate(e) {
2458
2482
  const t = F(e, 0.1, 10, this.rate);
@@ -2475,11 +2499,15 @@ class js {
2475
2499
  getVolume() {
2476
2500
  return this.volume;
2477
2501
  }
2478
- // rate/pitch are baked into each chunk's synthesis request at fetch-time — restart the
2479
- // in-flight utterance so a change applies now. Coalesces same-tick changes into one restart.
2502
+ // Voice, language, rate and pitch are baked into each chunk's synthesis request at fetch-time:
2503
+ // restart the utterance so a change applies now (or on resume when paused). Same-tick changes coalesce.
2480
2504
  scheduleRestartIfSpeaking() {
2505
+ if (this.playbackState === "paused") {
2506
+ this.restartOnResume = !0;
2507
+ return;
2508
+ }
2481
2509
  !this.isSpeakingInternal || this.restartPending || (this.restartPending = !0, queueMicrotask(() => {
2482
- this.restartPending && (this.restartPending = !1, this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
2510
+ this.restartPending && (this.restartPending = !1, this.playbackState === "paused" ? this.restartOnResume = !0 : this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
2483
2511
  }));
2484
2512
  }
2485
2513
  getState() {
@@ -2527,7 +2555,7 @@ class js {
2527
2555
  this.stop(), await this.audioContext?.close(), this.audioContext = null, this.masterGain = null, this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.voices = [];
2528
2556
  }
2529
2557
  }
2530
- class ta {
2558
+ class aa {
2531
2559
  id = "speech-server";
2532
2560
  name = "Readium Speech Server";
2533
2561
  options;
@@ -2548,20 +2576,20 @@ class ta {
2548
2576
  if (!s.ok)
2549
2577
  throw await W(s);
2550
2578
  const i = await t.json(), a = await s.json(), r = new Map(a.providers.map((o) => [o.id, o.controls]));
2551
- return this.voices = i.map((o) => Wt(o, r.get(o.provider))), this.voices;
2579
+ return this.voices = i.map((o) => Qt(o, r.get(o.provider))), this.voices;
2552
2580
  }
2553
2581
  async createEngine(e) {
2554
- const t = new js(this.options);
2582
+ const t = new _s(this.options);
2555
2583
  return this.voices.length > 0 && t.setAvailableVoices(this.voices), e && t.setVoice(e), t;
2556
2584
  }
2557
2585
  async destroy() {
2558
2586
  this.voices = [];
2559
2587
  }
2560
2588
  }
2561
- function Fs(n) {
2589
+ function Hs(n) {
2562
2590
  return n.detail?.recoverable === !0;
2563
2591
  }
2564
- const _s = 3e4, Hs = [
2592
+ const qs = 3e4, Gs = [
2565
2593
  "start",
2566
2594
  "pause",
2567
2595
  "resume",
@@ -2576,7 +2604,7 @@ const _s = 3e4, Hs = [
2576
2604
  "voiceschanged",
2577
2605
  "languagefallback"
2578
2606
  ];
2579
- class qs {
2607
+ class $s {
2580
2608
  activeEngine;
2581
2609
  primaryProvider;
2582
2610
  fallbackProvider;
@@ -2608,10 +2636,10 @@ class qs {
2608
2636
  teardownEpoch = 0;
2609
2637
  // Bumped by every loadUtterances() call, so startEngineWhenReady() can tell its queue is stale.
2610
2638
  loadToken = 0;
2611
- events = new be();
2639
+ events = new we();
2612
2640
  unbindActiveEngine = null;
2613
2641
  constructor(e) {
2614
- this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? _s, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
2642
+ this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? qs, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
2615
2643
  }
2616
2644
  async initialize() {
2617
2645
  return this.activeEngine.initialize?.();
@@ -2711,13 +2739,13 @@ class qs {
2711
2739
  this.events.emit(e.type, e);
2712
2740
  }
2713
2741
  bindActiveEngine() {
2714
- const e = this.activeEngine, t = Hs.map((s) => e.on(s, (i) => {
2742
+ const e = this.activeEngine, t = Gs.map((s) => e.on(s, (i) => {
2715
2743
  this.emitEvent(i), this.maybeRecoverNow();
2716
2744
  }));
2717
2745
  t.push(e.on("error", (s) => this.handleError(s))), this.unbindActiveEngine = () => t.forEach((s) => s());
2718
2746
  }
2719
2747
  handleError(e) {
2720
- if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !Fs(e)) {
2748
+ if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !Hs(e)) {
2721
2749
  this.emitEvent(e);
2722
2750
  return;
2723
2751
  }
@@ -2809,14 +2837,14 @@ class qs {
2809
2837
  async pickBestFallbackVoice(e, t, s) {
2810
2838
  const i = await this.fallbackProvider.getVoices(), r = typeof navigator < "u" && navigator.onLine === !0 ? i : i.filter((f) => f.offlineAvailability === !0);
2811
2839
  if (r.length === 0) return null;
2812
- const [o] = ye([e]), { voicesByLang: l } = Se(r, [o]), c = l.get(o.baseLang) ?? [], u = c.length > 0 ? c : r, d = t ? u.filter((f) => f.gender === t) : [], h = d.length > 0 ? d : u, g = Bt(h, s);
2813
- return zn(e, g);
2840
+ const [o] = Se([e]), { voicesByLang: l } = be(r, [o]), c = l.get(o.baseLang) ?? [], u = c.length > 0 ? c : r, g = t ? u.filter((f) => f.gender === t) : [], h = g.length > 0 ? g : u, d = Mt(h, s);
2841
+ return Nn(e, d);
2814
2842
  }
2815
2843
  async destroy() {
2816
2844
  this.teardownEpoch++, this.healthCheckTimer !== null && (clearTimeout(this.healthCheckTimer), this.healthCheckTimer = null), this.unbindActiveEngine?.(), this.events.clear(), await this.activeEngine.destroy();
2817
2845
  }
2818
2846
  }
2819
- class na {
2847
+ class ra {
2820
2848
  id = "fallback";
2821
2849
  name = "Fallback";
2822
2850
  primary;
@@ -2844,7 +2872,7 @@ class na {
2844
2872
  throw s;
2845
2873
  return this.fallback.createEngine(e);
2846
2874
  }
2847
- return new qs({
2875
+ return new $s({
2848
2876
  primaryEngine: t,
2849
2877
  primaryProvider: this.primary,
2850
2878
  fallbackProvider: this.fallback,
@@ -2856,27 +2884,27 @@ class na {
2856
2884
  await Promise.all([this.primary.destroy(), this.fallback.destroy()]);
2857
2885
  }
2858
2886
  }
2859
- function $s(n) {
2860
- return new In({
2861
- start: new et(n.start),
2862
- end: n.end ? new et(n.end) : void 0
2887
+ function Ks(n) {
2888
+ return new Pn({
2889
+ start: new tt(n.start),
2890
+ end: n.end ? new tt(n.end) : void 0
2863
2891
  });
2864
2892
  }
2865
- function Gs(n, e = window) {
2866
- const { text: t, cssSelector: s, domRange: i, fragment: a } = n, r = t ? new bn(t) : void 0, o = s || i ? /* @__PURE__ */ new Map() : void 0;
2867
- o && (s && o.set("cssSelector", s), i && o.set("domRange", $s(i).serialize()));
2868
- const c = o !== void 0 || a !== void 0 ? new wn({
2869
- fragments: a ? [a] : void 0,
2870
- otherLocations: o
2893
+ function Ws(n, e = window) {
2894
+ const { href: t, text: s, cssSelector: i, domRange: a, fragment: r } = n, o = s ? new wn(s) : void 0, l = i || a ? /* @__PURE__ */ new Map() : void 0;
2895
+ l && (i && l.set("cssSelector", i), a && l.set("domRange", Ks(a).serialize()));
2896
+ const u = l !== void 0 || r !== void 0 ? new kn({
2897
+ fragments: r ? [r] : void 0,
2898
+ otherLocations: l
2871
2899
  }) : void 0;
2872
- return new kn({
2873
- href: e.location.href,
2900
+ return new Cn({
2901
+ href: t ?? e.location.href,
2874
2902
  type: "text/html",
2875
- text: r,
2876
- locations: c
2903
+ text: o,
2904
+ locations: u
2877
2905
  });
2878
2906
  }
2879
- class Ks extends vn {
2907
+ class Qs extends yn {
2880
2908
  constructor(e, t, s, i = {}) {
2881
2909
  super(e.host, i), this.channel = e, this.wnd = t, this.decorator = s;
2882
2910
  }
@@ -2892,7 +2920,7 @@ class Ks extends vn {
2892
2920
  e.map(({ id: s, style: i, ...a }) => ({
2893
2921
  id: s,
2894
2922
  style: i,
2895
- locator: Gs(a, this.wnd)
2923
+ locator: Ws(a, this.wnd)
2896
2924
  })),
2897
2925
  t
2898
2926
  );
@@ -2901,11 +2929,11 @@ class Ks extends vn {
2901
2929
  super.destroy(), this.decorator.unmount(this.wnd, this.channel.frame), this.channel.frame.destroy();
2902
2930
  }
2903
2931
  }
2904
- function sa(n = window, e = {}) {
2905
- const t = new yn(), s = new Sn();
2906
- return s.mount(n, t.frame), new Ks(t, n, s, e);
2932
+ function oa(n = window, e = {}) {
2933
+ const t = new Sn(), s = new bn();
2934
+ return s.mount(n, t.frame), new Qs(t, n, s, e);
2907
2935
  }
2908
- class ia {
2936
+ class la {
2909
2937
  providers = /* @__PURE__ */ new Map();
2910
2938
  register(e) {
2911
2939
  if (this.providers.has(e.id))
@@ -2945,7 +2973,7 @@ class ia {
2945
2973
  return t;
2946
2974
  }
2947
2975
  }
2948
- const we = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t }), ce = we(0, 5e3, 100), ue = we(0.1, 10, 0.1), he = we(0, 2, 0.1), de = we(0, 1, 0.05), De = Object.freeze(["none", "few", "some", "most", "custom"]), je = Object.freeze(["none", "block-level", "always"]), Fe = Object.freeze(["plain", "ssml"]), _e = Object.freeze(["none", "utterance", "block"]), He = Object.freeze(["structure", "sentence"]), gt = Object.freeze([
2976
+ const ke = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t }), ue = ke(0, 5e3, 100), he = ke(0.1, 10, 0.1), de = ke(0, 2, 0.1), ge = ke(0, 1, 0.05), je = Object.freeze(["none", "few", "some", "most", "custom"]), Fe = Object.freeze(["none", "block-level", "always"]), _e = Object.freeze(["plain", "ssml"]), He = Object.freeze(["none", "utterance", "block"]), qe = Object.freeze(["structure", "sentence"]), ft = Object.freeze([
2949
2977
  "format",
2950
2978
  "inlineContextualization",
2951
2979
  "verbosity",
@@ -2954,13 +2982,13 @@ const we = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t })
2954
2982
  "language",
2955
2983
  "segmentation"
2956
2984
  ]);
2957
- function qe(n) {
2985
+ function Ge(n) {
2958
2986
  return n == null || typeof n == "boolean" ? n : void 0;
2959
2987
  }
2960
2988
  function O(n, e) {
2961
2989
  return n == null || e.includes(n) ? n : void 0;
2962
2990
  }
2963
- function V(n, e) {
2991
+ function T(n, e) {
2964
2992
  if (n == null) return n;
2965
2993
  if (typeof n != "number" || Number.isNaN(n)) return;
2966
2994
  const t = Math.min(...e), s = Math.max(...e);
@@ -2969,7 +2997,7 @@ function V(n, e) {
2969
2997
  function Z(n) {
2970
2998
  return n == null || Array.isArray(n) && n.every((e) => typeof e == "string") ? n : void 0;
2971
2999
  }
2972
- class Ws {
3000
+ class Js {
2973
3001
  format;
2974
3002
  inlineContextualization;
2975
3003
  verbosity;
@@ -2983,7 +3011,7 @@ class Ws {
2983
3011
  pitch;
2984
3012
  volume;
2985
3013
  constructor(e = {}) {
2986
- this.format = O(e.format, Fe) ?? "plain", this.inlineContextualization = qe(e.inlineContextualization) ?? !1, this.verbosity = O(e.verbosity, De) ?? "few", this.skip = Z(e.skip) ?? [], this.contextualize = Z(e.contextualize) ?? [], this.language = O(e.language, je) ?? "block-level", this.segmentation = O(e.segmentation, He) ?? "structure", this.pauseDuration = V(e.pauseDuration, ce.range) ?? 300, this.autoPause = O(e.autoPause, _e) ?? "none", this.rate = V(e.rate, ue.range) ?? 1, this.pitch = V(e.pitch, he.range) ?? 1, this.volume = V(e.volume, de.range) ?? 1;
3014
+ this.format = O(e.format, _e) ?? "plain", this.inlineContextualization = Ge(e.inlineContextualization) ?? !1, this.verbosity = O(e.verbosity, je) ?? "few", this.skip = Z(e.skip) ?? [], this.contextualize = Z(e.contextualize) ?? [], this.language = O(e.language, Fe) ?? "block-level", this.segmentation = O(e.segmentation, qe) ?? "structure", this.pauseDuration = T(e.pauseDuration, ue.range) ?? 300, this.autoPause = O(e.autoPause, He) ?? "none", this.rate = T(e.rate, he.range) ?? 1, this.pitch = T(e.pitch, de.range) ?? 1, this.volume = T(e.volume, ge.range) ?? 1;
2987
3015
  }
2988
3016
  }
2989
3017
  class Y {
@@ -3000,7 +3028,7 @@ class Y {
3000
3028
  pitch;
3001
3029
  volume;
3002
3030
  constructor(e = {}) {
3003
- this.format = O(e.format, Fe), this.inlineContextualization = qe(e.inlineContextualization), this.verbosity = O(e.verbosity, De), this.skip = Z(e.skip), this.contextualize = Z(e.contextualize), this.language = O(e.language, je), this.segmentation = O(e.segmentation, He), this.pauseDuration = V(e.pauseDuration, ce.range), this.autoPause = O(e.autoPause, _e), this.rate = V(e.rate, ue.range), this.pitch = V(e.pitch, he.range), this.volume = V(e.volume, de.range);
3031
+ this.format = O(e.format, _e), this.inlineContextualization = Ge(e.inlineContextualization), this.verbosity = O(e.verbosity, je), this.skip = Z(e.skip), this.contextualize = Z(e.contextualize), this.language = O(e.language, Fe), this.segmentation = O(e.segmentation, qe), this.pauseDuration = T(e.pauseDuration, ue.range), this.autoPause = O(e.autoPause, He), this.rate = T(e.rate, he.range), this.pitch = T(e.pitch, de.range), this.volume = T(e.volume, ge.range);
3004
3032
  }
3005
3033
  merging(e) {
3006
3034
  const t = { ...this };
@@ -3009,7 +3037,7 @@ class Y {
3009
3037
  return new Y(t);
3010
3038
  }
3011
3039
  }
3012
- class ke {
3040
+ class Ce {
3013
3041
  _value;
3014
3042
  _effectiveValue;
3015
3043
  _isEffective;
@@ -3038,7 +3066,7 @@ class ke {
3038
3066
  this._value = null, this._onChange(this._value);
3039
3067
  }
3040
3068
  }
3041
- class G extends ke {
3069
+ class $ extends Ce {
3042
3070
  _supportedValues;
3043
3071
  constructor({
3044
3072
  initialValue: e = null,
@@ -3061,9 +3089,9 @@ class G extends ke {
3061
3089
  return this._supportedValues;
3062
3090
  }
3063
3091
  }
3064
- class Qs extends ke {
3092
+ class Zs extends Ce {
3065
3093
  set value(e) {
3066
- if (e != null && qe(e) === void 0)
3094
+ if (e != null && Ge(e) === void 0)
3067
3095
  throw new Error(`Value '${String(e)}' is not a boolean.`);
3068
3096
  this._value = e, this._onChange(this._value);
3069
3097
  }
@@ -3071,7 +3099,7 @@ class Qs extends ke {
3071
3099
  return this._value;
3072
3100
  }
3073
3101
  }
3074
- class ft extends ke {
3102
+ class pt extends Ce {
3075
3103
  set value(e) {
3076
3104
  if (e != null && Z(e) === void 0)
3077
3105
  throw new Error(`Value '${String(e)}' is not an array of strings.`);
@@ -3081,7 +3109,7 @@ class ft extends ke {
3081
3109
  return this._value;
3082
3110
  }
3083
3111
  }
3084
- class ae extends ke {
3112
+ class re extends Ce {
3085
3113
  _supportedRange;
3086
3114
  _step;
3087
3115
  _decimals;
@@ -3096,7 +3124,7 @@ class ae extends ke {
3096
3124
  super({ initialValue: e, effectiveValue: t, isEffective: s, onChange: i }), this._supportedRange = a, this._step = r, this._decimals = this._step.toString().includes(".") ? this._step.toString().split(".")[1].length : 0;
3097
3125
  }
3098
3126
  set value(e) {
3099
- if (e != null && V(e, this._supportedRange) === void 0)
3127
+ if (e != null && T(e, this._supportedRange) === void 0)
3100
3128
  throw new Error(`Value '${String(e)}' is out of the supported range for this preference.`);
3101
3129
  this._value = e, this._onChange(this._value);
3102
3130
  }
@@ -3125,7 +3153,7 @@ class ae extends ke {
3125
3153
  return e.toString();
3126
3154
  }
3127
3155
  }
3128
- class pt {
3156
+ class mt {
3129
3157
  preferences;
3130
3158
  settings;
3131
3159
  // Cloned rather than aliased: edits made through this editor's setters
@@ -3157,16 +3185,16 @@ class pt {
3157
3185
  this.preferences[e] = t;
3158
3186
  }
3159
3187
  get format() {
3160
- return new G({
3188
+ return new $({
3161
3189
  initialValue: this.preferences.format,
3162
3190
  effectiveValue: this.settings.format,
3163
3191
  isEffective: this.preferences.format != null,
3164
3192
  onChange: (e) => this.updatePreference("format", e ?? null),
3165
- supportedValues: Fe
3193
+ supportedValues: _e
3166
3194
  });
3167
3195
  }
3168
3196
  get inlineContextualization() {
3169
- return new Qs({
3197
+ return new Zs({
3170
3198
  initialValue: this.preferences.inlineContextualization,
3171
3199
  effectiveValue: this.settings.inlineContextualization,
3172
3200
  isEffective: this.preferences.inlineContextualization != null,
@@ -3174,16 +3202,16 @@ class pt {
3174
3202
  });
3175
3203
  }
3176
3204
  get verbosity() {
3177
- return new G({
3205
+ return new $({
3178
3206
  initialValue: this.preferences.verbosity,
3179
3207
  effectiveValue: this.settings.verbosity,
3180
3208
  isEffective: this.preferences.verbosity != null,
3181
3209
  onChange: (e) => this.updatePreference("verbosity", e ?? null),
3182
- supportedValues: De
3210
+ supportedValues: je
3183
3211
  });
3184
3212
  }
3185
3213
  get skip() {
3186
- return new ft({
3214
+ return new pt({
3187
3215
  initialValue: this.preferences.skip,
3188
3216
  effectiveValue: this.settings.skip,
3189
3217
  isEffective: this.preferences.skip != null,
@@ -3191,7 +3219,7 @@ class pt {
3191
3219
  });
3192
3220
  }
3193
3221
  get contextualize() {
3194
- return new ft({
3222
+ return new pt({
3195
3223
  initialValue: this.preferences.contextualize,
3196
3224
  effectiveValue: this.settings.contextualize,
3197
3225
  isEffective: this.preferences.contextualize != null,
@@ -3199,75 +3227,75 @@ class pt {
3199
3227
  });
3200
3228
  }
3201
3229
  get language() {
3202
- return new G({
3230
+ return new $({
3203
3231
  initialValue: this.preferences.language,
3204
3232
  effectiveValue: this.settings.language,
3205
3233
  isEffective: this.preferences.language != null,
3206
3234
  onChange: (e) => this.updatePreference("language", e ?? null),
3207
- supportedValues: je
3235
+ supportedValues: Fe
3208
3236
  });
3209
3237
  }
3210
3238
  get segmentation() {
3211
- return new G({
3239
+ return new $({
3212
3240
  initialValue: this.preferences.segmentation,
3213
3241
  effectiveValue: this.settings.segmentation,
3214
3242
  isEffective: this.preferences.segmentation != null,
3215
3243
  onChange: (e) => this.updatePreference("segmentation", e ?? null),
3216
- supportedValues: He
3244
+ supportedValues: qe
3217
3245
  });
3218
3246
  }
3219
3247
  get pauseDuration() {
3220
- return new ae({
3248
+ return new re({
3221
3249
  initialValue: this.preferences.pauseDuration,
3222
3250
  effectiveValue: this.settings.pauseDuration,
3223
3251
  isEffective: this.preferences.pauseDuration != null,
3224
3252
  onChange: (e) => this.updatePreference("pauseDuration", e ?? null),
3225
- supportedRange: ce.range,
3226
- step: ce.step
3253
+ supportedRange: ue.range,
3254
+ step: ue.step
3227
3255
  });
3228
3256
  }
3229
3257
  get autoPause() {
3230
- return new G({
3258
+ return new $({
3231
3259
  initialValue: this.preferences.autoPause,
3232
3260
  effectiveValue: this.settings.autoPause,
3233
3261
  isEffective: this.preferences.autoPause != null,
3234
3262
  onChange: (e) => this.updatePreference("autoPause", e ?? null),
3235
- supportedValues: _e
3263
+ supportedValues: He
3236
3264
  });
3237
3265
  }
3238
3266
  get rate() {
3239
- return new ae({
3267
+ return new re({
3240
3268
  initialValue: this.preferences.rate,
3241
3269
  effectiveValue: this.settings.rate,
3242
3270
  isEffective: this.preferences.rate != null,
3243
3271
  onChange: (e) => this.updatePreference("rate", e ?? null),
3244
- supportedRange: ue.range,
3245
- step: ue.step
3272
+ supportedRange: he.range,
3273
+ step: he.step
3246
3274
  });
3247
3275
  }
3248
3276
  get pitch() {
3249
- return new ae({
3277
+ return new re({
3250
3278
  initialValue: this.preferences.pitch,
3251
3279
  effectiveValue: this.settings.pitch,
3252
3280
  isEffective: this.preferences.pitch != null,
3253
3281
  onChange: (e) => this.updatePreference("pitch", e ?? null),
3254
- supportedRange: he.range,
3255
- step: he.step
3282
+ supportedRange: de.range,
3283
+ step: de.step
3256
3284
  });
3257
3285
  }
3258
3286
  get volume() {
3259
- return new ae({
3287
+ return new re({
3260
3288
  initialValue: this.preferences.volume,
3261
3289
  effectiveValue: this.settings.volume,
3262
3290
  isEffective: this.preferences.volume != null,
3263
3291
  onChange: (e) => this.updatePreference("volume", e ?? null),
3264
- supportedRange: de.range,
3265
- step: de.step
3292
+ supportedRange: ge.range,
3293
+ step: ge.step
3266
3294
  });
3267
3295
  }
3268
3296
  }
3269
- const Yt = ["audio", "figure", "image", "math", "table", "video"], Xt = [
3270
- ...Yt,
3297
+ const Xt = ["audio", "figure", "image", "math", "table", "video"], en = [
3298
+ ...Xt,
3271
3299
  "blockquote",
3272
3300
  "chapter",
3273
3301
  "cover",
@@ -3280,8 +3308,8 @@ const Yt = ["audio", "figure", "image", "math", "table", "video"], Xt = [
3280
3308
  "rowheader",
3281
3309
  "subtitle",
3282
3310
  "tip"
3283
- ], Js = [
3284
- ...Xt,
3311
+ ], Ys = [
3312
+ ...en,
3285
3313
  "abstract",
3286
3314
  "acknowledgments",
3287
3315
  "afterword",
@@ -3325,7 +3353,7 @@ const Yt = ["audio", "figure", "image", "math", "table", "video"], Xt = [
3325
3353
  "separator",
3326
3354
  "summary",
3327
3355
  "term"
3328
- ], Zs = {
3356
+ ], Xs = {
3329
3357
  none: /* @__PURE__ */ new Set([
3330
3358
  "aside",
3331
3359
  "audio",
@@ -3393,28 +3421,28 @@ const Yt = ["audio", "figure", "image", "math", "table", "video"], Xt = [
3393
3421
  "toc"
3394
3422
  ]),
3395
3423
  most: /* @__PURE__ */ new Set(["landmarks", "loa", "loi", "lot", "lov", "toc"])
3396
- }, Ys = {
3424
+ }, ei = {
3397
3425
  none: /* @__PURE__ */ new Set(),
3398
- few: new Set(Yt),
3399
- some: new Set(Xt),
3400
- most: new Set(Js)
3401
- }, Ve = {
3426
+ few: new Set(Xt),
3427
+ some: new Set(en),
3428
+ most: new Set(Ys)
3429
+ }, ze = {
3402
3430
  table: { few: "inline", some: "block", most: "block" }
3403
3431
  };
3404
- function re(n) {
3432
+ function oe(n) {
3405
3433
  const e = {};
3406
- for (const t of Object.keys(Ve))
3407
- e[t] = Ve[t]?.[n] ?? "inline";
3434
+ for (const t of Object.keys(ze))
3435
+ e[t] = ze[t]?.[n] ?? "inline";
3408
3436
  return e;
3409
3437
  }
3410
- const Xs = {
3411
- none: re("none"),
3412
- few: re("few"),
3413
- some: re("some"),
3414
- most: re("most")
3415
- }, aa = Object.keys(Ve);
3416
- function ei(n, e) {
3417
- const t = n === "custom" ? {} : Xs[n];
3438
+ const ti = {
3439
+ none: oe("none"),
3440
+ few: oe("few"),
3441
+ some: oe("some"),
3442
+ most: oe("most")
3443
+ }, ca = Object.keys(ze);
3444
+ function ni(n, e) {
3445
+ const t = n === "custom" ? {} : ti[n];
3418
3446
  if (!e) return t;
3419
3447
  const s = { ...t };
3420
3448
  for (const i of Object.keys(e)) {
@@ -3423,7 +3451,7 @@ function ei(n, e) {
3423
3451
  }
3424
3452
  return s;
3425
3453
  }
3426
- class mt {
3454
+ class vt {
3427
3455
  format;
3428
3456
  inlineContextualization;
3429
3457
  verbosity;
@@ -3437,57 +3465,57 @@ class mt {
3437
3465
  pitch;
3438
3466
  volume;
3439
3467
  constructor(e, t) {
3440
- this.format = e.format ?? t.format, this.inlineContextualization = e.inlineContextualization ?? t.inlineContextualization, this.verbosity = e.verbosity ?? t.verbosity, this.verbosity === "custom" ? (this.skip = e.skip ?? t.skip, this.contextualize = e.contextualize ?? t.contextualize) : (this.skip = [...Zs[this.verbosity]], this.contextualize = [...Ys[this.verbosity]]), this.language = e.language ?? t.language, this.segmentation = e.segmentation ?? t.segmentation, this.pauseDuration = e.pauseDuration ?? t.pauseDuration, this.autoPause = e.autoPause ?? t.autoPause, this.rate = e.rate ?? t.rate, this.pitch = e.pitch ?? t.pitch, this.volume = e.volume ?? t.volume;
3468
+ this.format = e.format ?? t.format, this.inlineContextualization = e.inlineContextualization ?? t.inlineContextualization, this.verbosity = e.verbosity ?? t.verbosity, this.verbosity === "custom" ? (this.skip = e.skip ?? t.skip, this.contextualize = e.contextualize ?? t.contextualize) : (this.skip = [...Xs[this.verbosity]], this.contextualize = [...ei[this.verbosity]]), this.language = e.language ?? t.language, this.segmentation = e.segmentation ?? t.segmentation, this.pauseDuration = e.pauseDuration ?? t.pauseDuration, this.autoPause = e.autoPause ?? t.autoPause, this.rate = e.rate ?? t.rate, this.pitch = e.pitch ?? t.pitch, this.volume = e.volume ?? t.volume;
3441
3469
  }
3442
3470
  }
3443
- const vt = /* @__PURE__ */ new WeakMap(), en = /* @__PURE__ */ new WeakMap();
3444
- function yt(n, e) {
3445
- en.set(n, e);
3471
+ const yt = /* @__PURE__ */ new WeakMap(), tn = /* @__PURE__ */ new WeakMap();
3472
+ function St(n, e) {
3473
+ tn.set(n, e);
3446
3474
  }
3447
- const tn = /* @__PURE__ */ new WeakSet();
3448
- function St(n) {
3449
- return tn.add(n), n;
3475
+ const nn = /* @__PURE__ */ new WeakSet();
3476
+ function bt(n) {
3477
+ return nn.add(n), n;
3450
3478
  }
3451
- function ti(n, e, t) {
3452
- const s = en.get(n);
3479
+ function si(n, e, t) {
3480
+ const s = tn.get(n);
3453
3481
  if (s) {
3454
- const u = lt(s.map, e), d = lt(s.map, e + t);
3455
- e = u, t = Math.max(0, d - u);
3482
+ const u = ct(s.map, e), g = ct(s.map, e + t);
3483
+ e = u, t = Math.max(0, g - u);
3456
3484
  }
3457
3485
  const i = n.offsets, a = !n.plain && !!n.ssml, r = s?.plain ?? n.plain ?? (n.ssml ? z(n.ssml) : "");
3458
3486
  if (!i?.length || !r) return;
3459
- const o = vt.get(n), l = o !== void 0 && e >= o.cursor;
3487
+ const o = yt.get(n), l = o !== void 0 && e >= o.cursor;
3460
3488
  let c = l ? o.cursor : 0;
3461
3489
  for (let u = l ? o.pieceIndex : 0; u < i.length; u++) {
3462
- const d = i[u], h = d.locate.text?.highlight, g = h ? a ? z(h) : h : r.slice(c);
3463
- if (!g) continue;
3464
- const f = r.indexOf(g, c);
3490
+ const g = i[u], h = g.locate.text?.highlight, d = h ? a ? z(h) : h : r.slice(c);
3491
+ if (!d) continue;
3492
+ const f = r.indexOf(d, c);
3465
3493
  if (f === -1) continue;
3466
- const p = f + g.length;
3494
+ const p = f + d.length;
3467
3495
  if (e >= f && e < p) {
3468
- if (tn.has(d.locate)) return;
3469
- vt.set(n, { pieceIndex: u, cursor: c });
3470
- const m = e - f, S = g.substring(m, Math.min(m + t, g.length));
3496
+ if (nn.has(g.locate)) return;
3497
+ yt.set(n, { pieceIndex: u, cursor: c });
3498
+ const m = e - f, S = d.substring(m, Math.min(m + t, d.length));
3471
3499
  return { locate: {
3472
- ...d.locate,
3500
+ ...g.locate,
3473
3501
  domRange: void 0,
3474
3502
  text: {
3475
3503
  highlight: S,
3476
- before: g.substring(0, m),
3477
- after: g.substring(m + S.length)
3504
+ before: d.substring(0, m),
3505
+ after: d.substring(m + S.length)
3478
3506
  }
3479
3507
  }, word: S };
3480
3508
  }
3481
3509
  c = p;
3482
3510
  }
3483
3511
  }
3484
- function ni(n, e) {
3512
+ function ii(n, e) {
3485
3513
  return e === "sentence" && n.offsets?.length ? n.offsets.map((t) => t.locate) : n.locate ? [n.locate] : [];
3486
3514
  }
3487
3515
  function U(n) {
3488
3516
  return { pattern: new RegExp(`(\\d+)\\s?u${n}\\b`, "g"), replace: (e, t) => `${t}µ${n}` };
3489
3517
  }
3490
- const si = {
3518
+ const ai = {
3491
3519
  "1/4": "¼",
3492
3520
  "1/2": "½",
3493
3521
  "3/4": "¾",
@@ -3507,8 +3535,8 @@ const si = {
3507
3535
  "5/8": "⅝",
3508
3536
  "7/8": "⅞",
3509
3537
  "0/3": "↉"
3510
- }, ii = {
3511
- ...si,
3538
+ }, ri = {
3539
+ ...ai,
3512
3540
  // Rejects "(c)" directly preceded by "(a)"/"(b)" (a lettered list, not a copyright notice).
3513
3541
  "(c)": { pattern: new RegExp("(?<!\\([ab]\\)\\s{0,3})\\(c\\)", "g"), replace: "©" },
3514
3542
  "(C)": { pattern: new RegExp("(?<!\\([AB]\\)\\s{0,3})\\(C\\)", "g"), replace: "©" },
@@ -3534,18 +3562,18 @@ const si = {
3534
3562
  // convention for pronunciation, but drop the real prime marks silently.
3535
3563
  "′": "'",
3536
3564
  "″": '"'
3537
- }, ai = { contextualizations: { abstract: { block: { start: "Start of the abstract.", end: "End of the abstract." } }, acknowledgments: { block: { start: "Start of the acknowledgments.", end: "End of the acknowledgments." } }, afterword: { block: { start: "Start of the afterword.", end: "End of the afterword." } }, appendix: { block: { start: "Start of the appendix.", end: "End of the appendix." } }, aside: { block: { start: "Start of the aside.", end: "End of the aside." } }, audio: { inline: { labelled: "Audio with a label: {{ description }}", unlabelled: "Audio with no label." } }, bibliography: { block: { start: "Start of the bibliography.", end: "End of the bibliography." } }, blockquote: { inline: "Blockquote." }, cell: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, chapter: { block: { start: "Start of the chapter.", end: "End of the chapter." } }, colophon: { inline: "Colophon." }, complementary: { block: { start: "Start of the complementary content.", end: "End of the complementary content." } }, conclusion: { block: { start: "Start of the conclusion.", end: "End of the conclusion." } }, cover: { inline: { labelled: "Cover with a label: {{ description }}", unlabelled: "Cover with no label." } }, credit: { inline: "Credit." }, credits: { block: { start: "Start of the credits.", end: "End of the credits." } }, dedication: { inline: "Dedication." }, definition: { inline: "Definition." }, details: { block: { start: "Start of the disclosure.", end: "End of the disclosure." } }, endnotes: { block: { start: "Start of the endnotes.", end: "End of the endnotes." } }, epigraph: { inline: "Epigraph." }, epilogue: { block: { start: "Start of the epilogue.", end: "End of the epilogue." } }, errata: { block: { start: "Start of the errata.", end: "End of the errata." } }, example: { block: { start: "Start of the example.", end: "End of the example." } }, figure: { inline: "Figure: {{ description }}" }, footnote: { block: { start: "Start of the footnote.", end: "End of the footnote." } }, foreword: { block: { start: "Start of the foreword.", end: "End of the foreword." } }, glossary: { block: { start: "Start of the glossary.", end: "End of the glossary." } }, heading1: { inline: "Heading level 1." }, heading2: { inline: "Heading level 2." }, heading3: { inline: "Heading level 3." }, heading4: { inline: "Heading level 4." }, heading5: { inline: "Heading level 5." }, heading6: { inline: "Heading level 6." }, image: { inline: { labelled: "Image with a label: {{ description }}", unlabelled: "Image with no label." } }, index: { block: { start: "Start of the index.", end: "End of the index." } }, introduction: { block: { start: "Start of the introduction.", end: "End of the introduction." } }, list: { block: { start: "Start of the list.", end: "End of the list." } }, listItem: { inline: "List item." }, math: { inline: { labelled: "{{ description }}", unlabelled: "Math formula with no label." } }, notice: { inline: "Notice." }, pagebreak: { inline: "Pagebreak." }, pagelist: { block: { start: "Start of the page list.", end: "End of the page list." } }, part: { inline: "Part." }, preface: { block: { start: "Start of the preface.", end: "End of the preface." } }, prologue: { block: { start: "Start of the prologue.", end: "End of the prologue." } }, pullquote: { inline: "Pullquote." }, qna: { block: { start: "Start of the questions and answers.", end: "End of the questions and answers." } }, row: { inline: "Row: {{ count }}" }, rowheader: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, separator: { inline: "Separator." }, subtitle: { inline: "Subtitle." }, summary: { inline: "Summary." }, table: { block: { end: "End of the table.", start: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." } }, inline: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." }, parts: { columns_one: "1 column", columns_other: "{{ count }} columns", lines_one: "1 line", lines_other: "{{ count }} lines" } }, term: { inline: "Term." }, tip: { inline: "Tip." }, video: { inline: { labelled: "Video with a label: {{ description }}", unlabelled: "Video with no label." } } } }, ri = {
3538
- speech: ai
3539
- }, nn = ri.speech.contextualizations, bt = { en: nn }, oi = {};
3540
- async function li(n) {
3541
- const e = bt[n];
3565
+ }, oi = { contextualizations: { abstract: { block: { start: "Start of the abstract.", end: "End of the abstract." } }, acknowledgments: { block: { start: "Start of the acknowledgments.", end: "End of the acknowledgments." } }, afterword: { block: { start: "Start of the afterword.", end: "End of the afterword." } }, appendix: { block: { start: "Start of the appendix.", end: "End of the appendix." } }, aside: { block: { start: "Start of the aside.", end: "End of the aside." } }, audio: { inline: { labelled: "Audio with a label: {{ description }}", unlabelled: "Audio with no label." } }, bibliography: { block: { start: "Start of the bibliography.", end: "End of the bibliography." } }, blockquote: { inline: "Blockquote." }, cell: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, chapter: { block: { start: "Start of the chapter.", end: "End of the chapter." } }, colophon: { inline: "Colophon." }, complementary: { block: { start: "Start of the complementary content.", end: "End of the complementary content." } }, conclusion: { block: { start: "Start of the conclusion.", end: "End of the conclusion." } }, cover: { inline: { labelled: "Cover with a label: {{ description }}", unlabelled: "Cover with no label." } }, credit: { inline: "Credit." }, credits: { block: { start: "Start of the credits.", end: "End of the credits." } }, dedication: { inline: "Dedication." }, definition: { inline: "Definition." }, details: { block: { start: "Start of the disclosure.", end: "End of the disclosure." } }, endnotes: { block: { start: "Start of the endnotes.", end: "End of the endnotes." } }, epigraph: { inline: "Epigraph." }, epilogue: { block: { start: "Start of the epilogue.", end: "End of the epilogue." } }, errata: { block: { start: "Start of the errata.", end: "End of the errata." } }, example: { block: { start: "Start of the example.", end: "End of the example." } }, figure: { inline: "Figure: {{ description }}" }, footnote: { block: { start: "Start of the footnote.", end: "End of the footnote." } }, foreword: { block: { start: "Start of the foreword.", end: "End of the foreword." } }, glossary: { block: { start: "Start of the glossary.", end: "End of the glossary." } }, heading1: { inline: "Heading level 1." }, heading2: { inline: "Heading level 2." }, heading3: { inline: "Heading level 3." }, heading4: { inline: "Heading level 4." }, heading5: { inline: "Heading level 5." }, heading6: { inline: "Heading level 6." }, image: { inline: { labelled: "Image with a label: {{ description }}", unlabelled: "Image with no label." } }, index: { block: { start: "Start of the index.", end: "End of the index." } }, introduction: { block: { start: "Start of the introduction.", end: "End of the introduction." } }, list: { block: { start: "Start of the list.", end: "End of the list." } }, listItem: { inline: "List item." }, math: { inline: { labelled: "{{ description }}", unlabelled: "Math formula with no label." } }, notice: { inline: "Notice." }, pagebreak: { inline: "Pagebreak." }, pagelist: { block: { start: "Start of the page list.", end: "End of the page list." } }, part: { inline: "Part." }, preface: { block: { start: "Start of the preface.", end: "End of the preface." } }, prologue: { block: { start: "Start of the prologue.", end: "End of the prologue." } }, pullquote: { inline: "Pullquote." }, qna: { block: { start: "Start of the questions and answers.", end: "End of the questions and answers." } }, row: { inline: "Row: {{ count }}" }, rowheader: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, separator: { inline: "Separator." }, subtitle: { inline: "Subtitle." }, summary: { inline: "Summary." }, table: { block: { end: "End of the table.", start: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." } }, inline: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." }, parts: { columns_one: "1 column", columns_other: "{{ count }} columns", lines_one: "1 line", lines_other: "{{ count }} lines" } }, term: { inline: "Term." }, tip: { inline: "Tip." }, video: { inline: { labelled: "Video with a label: {{ description }}", unlabelled: "Video with no label." } } } }, li = {
3566
+ speech: oi
3567
+ }, sn = li.speech.contextualizations, wt = { en: sn }, ci = {};
3568
+ async function ui(n) {
3569
+ const e = wt[n];
3542
3570
  if (e) return e;
3543
- const t = oi[n];
3544
- if (!t) return nn;
3571
+ const t = ci[n];
3572
+ if (!t) return sn;
3545
3573
  const s = (await t()).speech.contextualizations;
3546
- return bt[n] = s, s;
3574
+ return wt[n] = s, s;
3547
3575
  }
3548
- const wt = {
3576
+ const hi = {
3549
3577
  de: ["A.", "A.M.", "Abs.", "Abt.", "Abw.", "Adj.", "Adr.", "Akt.", "Allg.", "Alt.", "App.", "Apr.", "Art.", "Aug.", "Ausg.", "Ausschl.", "B.", "Bed.", "Ben.", "Ber.", "Best.", "Bibl.", "C.", "Ca.", "Chin.", "Chr.", "Co.", "D.", "D. h.", "Dat.", "Dez.", "Di.", "Dim.", "Dipl.-Ing.", "Dipl.-Kfm.", "Dir.", "Do.", "Dr.", "Dtzd.", "Einh.", "Erf.", "Evtl.", "F.", "F.f.", "Fa.", "Fam.", "Feb.", "Fn.", "Folg.", "Forts. f.", "Fr.", "Frl.", "G.", "Gebr.", "Gem.", "Geograph.", "Ges.", "Gesch.", "Ggf.", "Hbf.", "Hptst.", "Hr.", "Hrn.", "Hrsg.", "I.", "Inc.", "Ing.", "Inh.", "Int.", "J.", "J.D.", "Jahrh.", "Jan.", "Jr.", "Kap.", "Kfm.", "Kl.", "Konv.", "Kop.", "L.", "Ltd.", "M.", "Max.", "Mi.", "Min.", "Mind.", "Mio.", "Mo.", "Mod.", "Mrd.", "Msp.", "N.", "Nov.", "Nr.", "O.", "Obj.", "Okt.", "Op.", "P.", "P.M.", "PIN.", "Pfd.", "Phys.", "Port.", "Prot.", "Proz.", "Qu.", "R.", "Rd.", "Reg.", "Reg.-Bez.", "Rel.", "Rep.", "S.A.", "Sa.", "Schr.", "Sek.", "Sep.", "Sept.", "So.", "Spezif.", "St.", "StR.", "Std.", "Str.", "T.", "Tel.", "Temp.", "Test.", "Trans.", "Tägl.", "U.", "U. U.", "U.S.", "U.S.A.", "U.U.", "Urspr.", "Ursprüngl.", "Verf.", "Vgl.", "W.", "Wg.", "Y.", "Z.", "Z. B.", "Z. Zt.", "Ztr.", "a.D.", "a.M.", "a.Rh.", "a.a.O.", "a.a.S.", "am.", "amtl.", "b.", "beil.", "d.J.", "d.Ä.", "e.V.", "e.Wz.", "e.h.", "ehem.", "eigtl.", "einschl.", "entspr.", "erw.", "ev.", "evtl.", "exkl.", "frz.", "geb.", "gedr.", "gek.", "gesch.", "gest.", "ggf.", "ggfs.", "hpts.", "i.A.", "i.B.", "i.H.", "i.J.", "i.R.", "i.V.", "inkl.", "jew.", "jhrl.", "k. u. k.", "k.u.k.", "kath.", "kfm.", "kgl.", "led.", "m.E.", "m.W.", "mtl.", "möbl.", "n. Chr.", "n.u.Z.", "näml.", "o.A.", "o.B.", "o.g.", "od.", "p.Adr.", "r.", "röm.", "röm.-kath.", "s.", "s.a.", "schles.", "schweiz.", "schwäb.", "sog.", "südd.", "tägl.", "u.", "u. Z.", "u.A.w.g.", "u.U.", "u.a.", "u.v.a.", "u.Ä.", "u.ä.", "v. Chr.", "v. H.", "v. u. Z.", "v.Chr.", "v.H.", "v.R.w.", "v.T.", "v.u.Z.", "verh.", "verw.", "vgl.", "z.", "z.B.", "z.Hd.", "z.Z.", "zzgl.", "österr."],
3550
3578
  en: ["A.D.", "A.I.", "A.M.", "A.S.", "AA.", "AB.", "Abs.", "Adj.", "Adv.", "Alt.", "Approx.", "Aug.", "B.V.", "C.F.", "C.O.D.", "Capt.", "Col.", "Comm.", "Conn.", "Cont.", "D.A.", "D.C.", "DC.", "DR.", "Dec.", "Def.", "Dept.", "Diff.", "Dr.", "E.G.", "E.g.", "Ed.", "Est.", "Etc.", "Ex.", "Exec.", "Feb.", "Fn.", "Fri.", "Hon.B.A.", "I.", "I.D.", "I.T.", "I.e.", "J.B.", "J.D.", "J.K.", "Jan.", "Jun.", "K.R.", "L.A.", "L.P.", "Lev.", "Lib.", "Lt.", "Lt.Cdr.", "M.", "M.I.T.", "M.R.", "M.T.", "MR.", "Maj.", "Mar.", "Mart.", "Mb.", "Md.", "Mgr.", "Min.", "Misc.", "Mr.", "Mrs.", "Ms.", "Mt.", "N.V.", "N.Y.", "Nov.", "Nr.", "Num.", "Op.", "Org.", "P.M.", "P.O.", "P.V.", "PP.", "Ph.D.", "Phys.", "Prof.", "Pvt.", "R.L.", "R.T.", "Rep.", "Rev.", "S.A.", "S.A.R.", "S.E.", "S.p.A.", "Sep.", "Sept.", "Sgt.", "Sq.", "St.", "U.S.", "U.S.A.", "U.S.C.", "VS.", "Yr.", "a.m.", "d.", "dr.", "exec.", "pp.", "vs."],
3551
3579
  es: ["A.C.", "AA.", "All.", "Ant.", "Av.", "Avda.", "Bien.", "C.", "C.P.", "C.S.", "C.V.", "CA.", "Col.", "Comm.", "Corp.", "Cía.", "D.", "DC.", "Da.", "Desc.", "Desv.", "Dr.", "Dra.", "Drs.", "Dto.", "Dª.", "Dña.", "Em.", "Emm.", "Exc.", "Excma.", "Excmas.", "Excmo.", "Excmos.", "Exma.", "Exmas.", "Exmo.", "Exmos.", "FF.CC.", "Fabric.", "Fr.", "H.P.", "Id.", "Ilma.", "Ilmas.", "Ilmo.", "Ilmos.", "Inc.", "JJ.OO.", "K.", "Kit.", "Korn.", "L.", "Lcda.", "Lcdo.", "Lda.", "Ldo.", "Lic.", "Ltd.", "Ltda.", "Ltdo.", "M.", "MM.", "Mons.", "Mr.", "Mrs.", "O.M.", "PP.", "R.D.", "R.U.", "RAM.", "RR.HH.", "Rdo.", "Rdos.", "Reg.", "Rev.", "Rol.", "Rvdmo.", "Rvdmos.", "Rvdo.", "Rvdos.", "SA.", "SS.AA.", "SS.MM.", "Sdad.", "Seg.", "Sol.", "Sr.", "Sra.", "Sras.", "Sres.", "Srta.", "Srtas.", "Sta.", "Sto.", "Trab.", "U.S.", "U.S.A.", "Var.", "Vda.", "a. C.", "a. e. c.", "abr.", "afma.", "afmas.", "afmo.", "afmos.", "ago.", "bco.", "bol.", "c/c.", "cap.", "cf.", "cfr.", "col.", "d. C.", "depto.", "deptos.", "dic.", "doc.", "dom.", "dpto.", "dptos.", "dtor.", "e. c.", "e.g.", "ed.", "ej.", "ene.", "feb.", "fig.", "figs.", "fund.", "hnos.", "jue.", "jul.", "jun.", "licda.", "licdo.", "lun.", "mar.", "may.", "mié.", "ms.", "mss.", "mtro.", "nov.", "ntra.", "ntro.", "oct.", "p.ej.", "prof.", "prov.", "sept.", "sras.", "sres.", "srs.", "ss.", "sáb.", "trad.", "v.gr.", "vid.", "vie.", "vs."],
@@ -3555,39 +3583,39 @@ const wt = {
3555
3583
  ru: ["авг.", "апр.", "дек.", "до н. э.", "кв.", "н. э.", "н.э.", "нояб.", "окт.", "отд.", "проф.", "руб.", "сент.", "тел.", "тыс.", "ул.", "февр.", "янв."],
3556
3584
  th: ["ค.ศ."]
3557
3585
  };
3558
- function Ie(n, e, t) {
3586
+ function Pe(n, e, t) {
3559
3587
  let s = t;
3560
3588
  for (; s > e && /\s/.test(n[s - 1]); ) s--;
3561
3589
  return s;
3562
3590
  }
3563
- const ci = /[\s([{"'“‘]/;
3564
- function ui(n, e) {
3591
+ const di = /[\s([{"'“‘]/;
3592
+ function gi(n, e) {
3565
3593
  for (const t of e) {
3566
3594
  if (n.length < t.length || !n.endsWith(t)) continue;
3567
3595
  const s = n.length - t.length - 1;
3568
- if (s < 0 || ci.test(n[s])) return !0;
3596
+ if (s < 0 || di.test(n[s])) return !0;
3569
3597
  }
3570
3598
  return !1;
3571
3599
  }
3572
- function hi(n) {
3600
+ function fi(n) {
3573
3601
  let e = 0;
3574
3602
  for (const t of n)
3575
3603
  if (new RegExp("\\p{L}", "u").test(t) && e++, e >= 2) return !0;
3576
3604
  return !1;
3577
3605
  }
3578
- function di(n) {
3606
+ function pi(n) {
3579
3607
  return /\.{3,}$/.test(n);
3580
3608
  }
3581
- function gi(n, e, t, s) {
3609
+ function mi(n, e, t, s) {
3582
3610
  if (s === "“") return !0;
3583
3611
  if (s !== '"') return !1;
3584
3612
  let i = 0;
3585
3613
  for (let a = e; a < t; a++) n[a] === '"' && i++;
3586
3614
  return i % 2 === 1;
3587
3615
  }
3588
- const fi = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
3589
- function pi(n, e) {
3590
- const t = [...n.matchAll(fi)].map((i) => i.index + i[0].length);
3616
+ const vi = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
3617
+ function yi(n, e) {
3618
+ const t = [...n.matchAll(vi)].map((i) => i.index + i[0].length);
3591
3619
  if (t.length === 0) return e;
3592
3620
  const s = [];
3593
3621
  for (const i of e) {
@@ -3598,40 +3626,40 @@ function pi(n, e) {
3598
3626
  }
3599
3627
  return s;
3600
3628
  }
3601
- function mi(n, e, t) {
3602
- const s = pi(n, e).map((a) => ({ ...a }));
3629
+ function Si(n, e, t) {
3630
+ const s = yi(n, e).map((a) => ({ ...a }));
3603
3631
  for (let a = 0; a < s.length - 1; a++) {
3604
- const r = Ie(n, s[a].start, s[a].end);
3632
+ const r = Pe(n, s[a].start, s[a].end);
3605
3633
  if (r !== s[a].end || r <= s[a].start) continue;
3606
3634
  const o = n[r - 1];
3607
- gi(n, s[a].start, r, o) && (s[a].end -= 1, s[a + 1].start -= 1);
3635
+ mi(n, s[a].start, r, o) && (s[a].end -= 1, s[a + 1].start -= 1);
3608
3636
  }
3609
3637
  const i = [];
3610
3638
  for (const a of s) {
3611
3639
  let r = a;
3612
3640
  for (; i.length > 0; ) {
3613
- const o = i[i.length - 1], l = Ie(n, o.start, o.end), c = n.slice(o.start, l);
3614
- if (!ui(c, t) && hi(c) && !di(c)) break;
3641
+ const o = i[i.length - 1], l = Pe(n, o.start, o.end), c = n.slice(o.start, l);
3642
+ if (!gi(c, t) && fi(c) && !pi(c)) break;
3615
3643
  i.pop(), r = { start: o.start, end: r.end };
3616
3644
  }
3617
3645
  i.push(r);
3618
3646
  }
3619
3647
  return i.map((a) => {
3620
- const r = Ie(n, a.start, a.end);
3648
+ const r = Pe(n, a.start, a.end);
3621
3649
  return { text: n.slice(a.start, r), start: a.start, end: a.end, contentEnd: r };
3622
3650
  });
3623
3651
  }
3624
3652
  const kt = /* @__PURE__ */ new Map();
3625
- function vi(n) {
3653
+ function bi(n) {
3626
3654
  let e = kt.get(n);
3627
3655
  return e || (e = new Intl.Segmenter(n, { granularity: "sentence" }), kt.set(n, e)), e;
3628
3656
  }
3629
- async function yi(n, e, t) {
3657
+ async function wi(n, e, t) {
3630
3658
  if (e === "") return [];
3631
- const i = [...vi(n).segment(e)].map((r) => ({ start: r.index, end: r.index + r.segment.length })), a = t ? [...wt[n] ?? [], ...t] : wt[n] ?? [];
3632
- return mi(e, i, a);
3659
+ const i = [...bi(n).segment(e)].map((o) => ({ start: o.index, end: o.index + o.segment.length })), a = ve(hi, n) ?? [], r = t ? [...a, ...t] : a;
3660
+ return Si(e, i, r);
3633
3661
  }
3634
- const ra = [
3662
+ const ua = [
3635
3663
  "aside",
3636
3664
  "audio",
3637
3665
  "bibliography",
@@ -3657,7 +3685,7 @@ const ra = [
3657
3685
  "table",
3658
3686
  "toc",
3659
3687
  "video"
3660
- ], Si = [
3688
+ ], ki = [
3661
3689
  // Headings
3662
3690
  "heading1",
3663
3691
  "heading2",
@@ -3715,49 +3743,49 @@ const ra = [
3715
3743
  "section",
3716
3744
  "summary",
3717
3745
  "tip"
3718
- ], bi = {
3746
+ ], Ci = {
3719
3747
  footnote: { drops: ["aside"], unconditional: !0 },
3720
3748
  cover: { drops: ["image"] },
3721
3749
  pullquote: { drops: ["blockquote", "aside"] },
3722
3750
  epigraph: { drops: ["blockquote"] }
3723
- }, wi = ["noteref", "pagebreak"], ki = ["audio", "video", "image", "figure", "math", "table", "cover"], Ci = ["cell", "rowheader"], Ei = ["separator"], Ct = new Set(Si), Ri = new Set(wi), Ii = new Set(ki), sn = new Set(Ci), Pi = new Set(Ei);
3724
- function xi(n, e) {
3725
- const t = Cn.createInstance();
3751
+ }, Ei = ["noteref", "pagebreak"], Ri = ["audio", "video", "image", "figure", "math", "table", "cover"], Ii = ["cell", "rowheader"], Pi = ["separator"], Ct = new Set(ki), Ai = new Set(Ei), xi = new Set(Ri), an = new Set(Ii), Li = new Set(Pi);
3752
+ function Oi(n, e) {
3753
+ const t = En.createInstance();
3726
3754
  return t.init({
3727
3755
  lng: n,
3728
3756
  resources: { [n]: { translation: e } },
3729
3757
  interpolation: { escapeValue: !1 }
3730
3758
  }), t;
3731
3759
  }
3732
- function Ai(n, e, t) {
3760
+ function Ui(n, e, t) {
3733
3761
  if (!e) return n;
3734
3762
  const s = { ...n };
3735
3763
  for (const i of Object.keys(e))
3736
3764
  s[i] = t(n[i], e[i]);
3737
3765
  return s;
3738
3766
  }
3739
- function an(n, e) {
3767
+ function rn(n, e) {
3740
3768
  if (typeof e == "string" || typeof n != "object") return e;
3741
3769
  const t = { ...n };
3742
3770
  for (const s of Object.keys(e))
3743
- t[s] = an(n[s], e[s]);
3771
+ t[s] = rn(n[s], e[s]);
3744
3772
  return t;
3745
3773
  }
3746
- function Li(n, e) {
3747
- return Ai(n, e, an);
3774
+ function Vi(n, e) {
3775
+ return Ui(n, e, rn);
3748
3776
  }
3749
- function rn(n, e = [], t = /* @__PURE__ */ new Map()) {
3777
+ function on(n, e = [], t = /* @__PURE__ */ new Map()) {
3750
3778
  for (const s of n)
3751
- t.set(s, e), s.children && rn(s.children, [s, ...e], t);
3779
+ t.set(s, e), s.children && on(s.children, [s, ...e], t);
3752
3780
  return t;
3753
3781
  }
3754
- async function on(n, e) {
3755
- const t = e.contextualizationLocale ?? "en", s = Li(
3756
- await li(t),
3782
+ async function ln(n, e) {
3783
+ const t = e.contextualizationLocale ?? "en", s = Vi(
3784
+ await ui(t),
3757
3785
  e.contextualization?.contextualizations
3758
3786
  );
3759
3787
  return {
3760
- i18n: xi(t, s),
3788
+ i18n: Oi(t, s),
3761
3789
  skip: new Set(e.skip ?? []),
3762
3790
  contextualize: new Set(e.contextualize ?? []),
3763
3791
  contextualizationShapes: e.contextualization?.shapes ?? {},
@@ -3770,26 +3798,26 @@ async function on(n, e) {
3770
3798
  // (Intl.Segmenter has no built-in equivalent of its own) — this is only
3771
3799
  // the caller's own additive extras, per `SegmentationOptions.suppressions`.
3772
3800
  segmentationSuppressions: e.segmentation?.suppressions ?? {},
3773
- segmenter: e.segmentation?.segmenter ?? yi,
3801
+ segmenter: e.segmentation?.segmenter ?? wi,
3774
3802
  // Per-key override, not an additive union — each key holds one whole rule.
3775
- substitutions: { ...ii, ...e.substitutions },
3803
+ substitutions: { ...ri, ...e.substitutions },
3776
3804
  blockStarts: /* @__PURE__ */ new Set(),
3777
3805
  tableRowNumbers: /* @__PURE__ */ new Map(),
3778
3806
  tableCellHeaders: /* @__PURE__ */ new Map(),
3779
3807
  synthetic: /* @__PURE__ */ new Set(),
3780
- ancestorChains: rn(n),
3808
+ ancestorChains: on(n),
3781
3809
  pendingRange: /* @__PURE__ */ new Map(),
3782
3810
  edgeSubstitutedLocate: /* @__PURE__ */ new WeakMap()
3783
3811
  };
3784
3812
  }
3785
- const Oi = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
3786
- function ln(n) {
3787
- return n.replace(Oi, "$1");
3813
+ const Ti = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
3814
+ function cn(n) {
3815
+ return n.replace(Ti, "$1");
3788
3816
  }
3789
- function ge(n) {
3817
+ function X(n) {
3790
3818
  return n.role ? [...n.role] : [];
3791
3819
  }
3792
- function ze(n) {
3820
+ function Ne(n) {
3793
3821
  return n.role?.has("math") ? void 0 : n.text;
3794
3822
  }
3795
3823
  function $e(n) {
@@ -3799,24 +3827,26 @@ function $e(n) {
3799
3827
  }
3800
3828
  function H(n, e) {
3801
3829
  const t = n.cssSelector ?? n.domRange?.start.cssSelector;
3802
- return t ? { cssSelector: t, text: { highlight: e } } : { ...n, text: { highlight: e } };
3830
+ if (!t) return { ...n, text: { highlight: e } };
3831
+ const s = { cssSelector: t, text: { highlight: e } };
3832
+ return n.href !== void 0 && (s.href = n.href), s;
3803
3833
  }
3804
- function A(n, e) {
3805
- const t = Xe(n);
3834
+ function x(n, e) {
3835
+ const t = et(n);
3806
3836
  if (t) return { own: !0, ref: t };
3807
3837
  for (const s of e.get(n) ?? []) {
3808
- const i = Xe(s);
3838
+ const i = et(s);
3809
3839
  if (i) return { own: !1, ref: i };
3810
3840
  }
3811
3841
  }
3812
- function Ge(n, e) {
3842
+ function Ke(n, e) {
3813
3843
  if (n)
3814
3844
  return n.own ? n.ref : H(n.ref, e);
3815
3845
  }
3816
- function Ke(n, e, t) {
3817
- return (n && e ? En(n.ref, e.ref) : void 0) ?? t;
3846
+ function We(n, e, t) {
3847
+ return (n && e ? Rn(n.ref, e.ref) : void 0) ?? t;
3818
3848
  }
3819
- function cn(n, e, t) {
3849
+ function un(n, e, t) {
3820
3850
  const { ancestorChains: s } = t, i = /* @__PURE__ */ new Map();
3821
3851
  for (const a of e)
3822
3852
  a && !Array.isArray(a) && i.set(a, (i.get(a) ?? 0) + 1);
@@ -3824,31 +3854,31 @@ function cn(n, e, t) {
3824
3854
  if (a.offsets) return a;
3825
3855
  const o = e[r], l = a.plain ?? a.ssml ?? "";
3826
3856
  if (Array.isArray(o)) {
3827
- const [h, g] = o, f = A(h, s), p = A(g, s), m = Ke(f, p, Ge(f, l));
3857
+ const [h, d] = o, f = x(h, s), p = x(d, s), m = We(f, p, Ke(f, l));
3828
3858
  return m ? { ...a, locate: m } : a;
3829
3859
  }
3830
- const c = o, u = c ? A(c, s) : void 0;
3860
+ const c = o, u = c ? x(c, s) : void 0;
3831
3861
  if (!u) return a;
3832
- const d = { ...a, locate: u.ref };
3862
+ const g = { ...a, locate: u.ref };
3833
3863
  if (!t.synthetic.has(a)) {
3834
- const h = t.pendingRange.get(a), g = h !== void 0 || c && (i.get(c) ?? 0) > 1;
3835
- d.locate = u.own && !g ? u.ref : H(u.ref, l), d.offsets = [{ start: h?.start ?? 0, end: h?.end ?? l.length, locate: d.locate }];
3864
+ const h = t.pendingRange.get(a), d = h !== void 0 || c && (i.get(c) ?? 0) > 1;
3865
+ g.locate = u.own && !d ? u.ref : H(u.ref, l), g.offsets = [{ start: h?.start ?? 0, end: h?.end ?? l.length, locate: g.locate }];
3836
3866
  }
3837
- return d;
3867
+ return g;
3838
3868
  });
3839
3869
  }
3840
- function We(n) {
3841
- const e = Ne(ze(n));
3870
+ function Qe(n) {
3871
+ const e = Be(Ne(n));
3842
3872
  return e ? e.plain ?? (e.ssml ? z(e.ssml) : "") : "";
3843
3873
  }
3844
- function Ui(n) {
3874
+ function zi(n) {
3845
3875
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
3846
3876
  let s = 0, i;
3847
3877
  return n.forEach((a, r) => {
3848
3878
  e.set(a, r + 1);
3849
3879
  const o = a.children ?? [];
3850
3880
  if (s = Math.max(s, o.length), o.some((l) => l.role?.has("columnheader"))) {
3851
- i = o.map(We);
3881
+ i = o.map(Qe);
3852
3882
  return;
3853
3883
  }
3854
3884
  i && o.forEach((l, c) => {
@@ -3866,34 +3896,34 @@ function D(n, e, t, s) {
3866
3896
  n.push(...s);
3867
3897
  for (let i = 0; i < s.length; i++) e.push(t);
3868
3898
  }
3869
- function un(n, e, t, s, i, a, r) {
3899
+ function hn(n, e, t, s, i, a, r) {
3870
3900
  r ? (i.some((o) => t.blockStarts.has(o)) && t.blockStarts.add(r), D(n, e, a[0] ?? s, [r])) : (n.push(...i), e.push(...a));
3871
3901
  }
3872
- function X(n, e, t, s) {
3902
+ function ee(n, e, t, s) {
3873
3903
  const i = t ? `${e}.${t}` : void 0;
3874
3904
  if (i && n.i18n.exists(i)) return n.i18n.t(i, s);
3875
3905
  if (n.i18n.exists(e)) return n.i18n.t(e, s);
3876
3906
  }
3877
- function Qe(n, e) {
3878
- return sn.has(n) ? !0 : e.contextualize.has(n);
3907
+ function Je(n, e) {
3908
+ return an.has(n) ? !0 : e.contextualize.has(n);
3879
3909
  }
3880
- function Ti(n, e, t) {
3910
+ function Ni(n, e, t) {
3881
3911
  return e.some((s) => {
3882
- const i = bi[s];
3883
- return i?.drops.includes(n) ? i.unconditional || Qe(s, t) : !1;
3912
+ const i = Ci[s];
3913
+ return i?.drops.includes(n) ? i.unconditional || Je(s, t) : !1;
3884
3914
  });
3885
3915
  }
3886
3916
  function fe(n, e, t, s, i) {
3887
3917
  const a = e.lastIndexOf(t);
3888
3918
  if (a === -1) return;
3889
- const r = A(s, i.ancestorChains);
3919
+ const r = x(s, i.ancestorChains);
3890
3920
  if (!r) return;
3891
3921
  const o = H(r.ref, t);
3892
3922
  n.offsets = [{ start: a, end: a + t.length, locate: o }], n.locate = r.own ? r.ref : o;
3893
3923
  }
3894
3924
  function Et(n, e, t, s, i, a) {
3895
3925
  const r = a?.value;
3896
- if (r !== void 0 && r === We(t)) {
3926
+ if (r !== void 0 && r === Qe(t)) {
3897
3927
  if (s.language !== "none") {
3898
3928
  const l = t.text?.language;
3899
3929
  l && (n.language = l);
@@ -3905,17 +3935,17 @@ function Et(n, e, t, s, i, a) {
3905
3935
  o !== void 0 && o === $e(t) && (i === "figure" || i === "table") && fe(n, e, o, t, s);
3906
3936
  }
3907
3937
  function Rt(n, e, t, s, i, a, r, o) {
3908
- if (!Qe(i, s)) return;
3938
+ if (!Je(i, s)) return;
3909
3939
  if ((s.i18n.exists(`${i}.block.start`) || s.i18n.exists(`${i}.block.end`)) && s.contextualizationShapes[i] !== "inline") {
3910
- const c = a === "before" ? `${i}.block.start` : `${i}.block.end`, u = X(s, c, r, o);
3940
+ const c = a === "before" ? `${i}.block.start` : `${i}.block.end`, u = ee(s, c, r, o);
3911
3941
  if (u) {
3912
- const d = M(u, s);
3913
- Et(d, u, t, s, i, o), D(n, e, t, [d]);
3942
+ const g = M(u, s);
3943
+ Et(g, u, t, s, i, o), D(n, e, t, [g]);
3914
3944
  }
3915
3945
  return;
3916
3946
  }
3917
3947
  if (a === "before") {
3918
- const c = X(s, `${i}.inline`, r, o);
3948
+ const c = ee(s, `${i}.inline`, r, o);
3919
3949
  if (c) {
3920
3950
  const u = M(c, s);
3921
3951
  Et(u, c, t, s, i, o), D(n, e, t, [u]);
@@ -3926,7 +3956,7 @@ function It(n, e, t, s) {
3926
3956
  const i = `${e}.parts.${t}`;
3927
3957
  return n.i18n.exists(i, { count: s }) ? n.i18n.t(i, { count: s }) : String(s);
3928
3958
  }
3929
- function Vi(n) {
3959
+ function Bi(n) {
3930
3960
  const e = $e(n);
3931
3961
  return e === void 0 ? { variantKey: "unlabelled" } : { variantKey: "labelled", params: { description: e } };
3932
3962
  }
@@ -3934,12 +3964,12 @@ function Pt(n, e) {
3934
3964
  const t = e.tableCellHeaders.get(n);
3935
3965
  return {
3936
3966
  variantKey: t !== void 0 ? "withHeader" : "withoutHeader",
3937
- params: { header: t ?? "", value: We(n) }
3967
+ params: { header: t ?? "", value: Qe(n) }
3938
3968
  };
3939
3969
  }
3940
- const zi = {
3970
+ const Mi = {
3941
3971
  table: (n, e) => {
3942
- const t = (n.children ?? []).filter((i) => i.role?.has("row")), s = Ui(t);
3972
+ const t = (n.children ?? []).filter((i) => i.role?.has("row")), s = zi(t);
3943
3973
  for (const [i, a] of s.rowNumbers) e.tableRowNumbers.set(i, a);
3944
3974
  for (const [i, a] of s.cellHeaders) e.tableCellHeaders.set(i, a);
3945
3975
  return {
@@ -3953,10 +3983,10 @@ const zi = {
3953
3983
  cell: Pt,
3954
3984
  rowheader: Pt
3955
3985
  };
3956
- function xt(n, e, t) {
3957
- const s = Vi(e);
3986
+ function At(n, e, t) {
3987
+ const s = Bi(e);
3958
3988
  let i = s.variantKey, a = s.params;
3959
- const r = zi[n]?.(e, t);
3989
+ const r = Mi[n]?.(e, t);
3960
3990
  r && (r.variantKey && (i = r.variantKey), a = { ...a, ...r.params });
3961
3991
  const o = t.contextualizationParams?.(n, e);
3962
3992
  return o && (a = { ...a, ...o }), { variantKey: i, params: a };
@@ -3965,23 +3995,25 @@ function pe(n) {
3965
3995
  let e = "";
3966
3996
  const t = [];
3967
3997
  for (const s of n) {
3968
- if (s.length === 1 && as(s) && e.endsWith(s)) {
3998
+ if (s.length === 1 && os(s) && e.endsWith(s)) {
3969
3999
  t.push({ start: e.length, end: e.length });
3970
4000
  continue;
3971
4001
  }
3972
- e && !ee(s) && !/\s$/.test(e) && !/^\s/.test(s) && (e += " ");
4002
+ e && !te(s) && !/\s$/.test(e) && !/^\s/.test(s) && (e += " ");
3973
4003
  const i = e.length;
3974
4004
  e += s, t.push({ start: i, end: e.length });
3975
4005
  }
3976
4006
  return { joined: e, ranges: t };
3977
4007
  }
3978
- function Ce(n, e) {
3979
- const t = Rn(n);
3980
- if (t) return St({ cssSelector: t });
3981
- const s = A(n, e.ancestorChains)?.ref;
3982
- return s && St(s);
4008
+ function Ee(n, e) {
4009
+ const t = In(n), s = x(n, e.ancestorChains)?.ref;
4010
+ if (t) {
4011
+ const i = { cssSelector: t };
4012
+ return s?.href !== void 0 && (i.href = s.href), bt(i);
4013
+ }
4014
+ return s && bt(s);
3983
4015
  }
3984
- function Ni(n, e, t) {
4016
+ function Di(n, e, t) {
3985
4017
  const s = [];
3986
4018
  return n.forEach((i, a) => {
3987
4019
  if (i.offsets) {
@@ -3991,29 +4023,29 @@ function Ni(n, e, t) {
3991
4023
  if (t.synthetic.has(i)) return;
3992
4024
  const r = e[a];
3993
4025
  if (!r || Array.isArray(r)) return;
3994
- const o = A(r, t.ancestorChains);
4026
+ const o = x(r, t.ancestorChains);
3995
4027
  if (!o) return;
3996
4028
  const l = t.format === "ssml" ? i.ssml : i.plain;
3997
4029
  if (!l) return;
3998
- const c = t.pendingRange.get(i), u = te(r) ? Ce(r, t) ?? o.ref : H(o.ref, l);
4030
+ const c = t.pendingRange.get(i), u = ne(r) ? Ee(r, t) ?? o.ref : H(o.ref, l);
3999
4031
  s.push({ start: c?.start ?? 0, end: c?.end ?? l.length, locate: u });
4000
4032
  }), s;
4001
4033
  }
4002
- function At(n, e, t, s) {
4034
+ function xt(n, e, t, s) {
4003
4035
  const i = s.edgeSubstitutedLocate.get(n);
4004
4036
  if (i) return i[t];
4005
- if (!(!e || Array.isArray(e) || !te(e)))
4006
- return Ce(e, s);
4037
+ if (!(!e || Array.isArray(e) || !ne(e)))
4038
+ return Ee(e, s);
4007
4039
  }
4008
- function Bi(n, e, t) {
4040
+ function ji(n, e, t) {
4009
4041
  const s = n.map((l, c) => {
4010
4042
  if (l.locate) return l.locate;
4011
4043
  if (t.synthetic.has(l)) return;
4012
4044
  const u = e[c];
4013
4045
  if (!u || Array.isArray(u)) return;
4014
- const d = t.format === "ssml" ? l.ssml : l.plain;
4015
- if (d)
4016
- return te(u) ? A(u, t.ancestorChains) && Ce(u, t) : Ge(A(u, t.ancestorChains), d);
4046
+ const g = t.format === "ssml" ? l.ssml : l.plain;
4047
+ if (g)
4048
+ return ne(u) ? x(u, t.ancestorChains) && Ee(u, t) : Ke(x(u, t.ancestorChains), g);
4017
4049
  }), i = s.findIndex((l) => l !== void 0);
4018
4050
  if (i === -1) return;
4019
4051
  let a = s.length - 1;
@@ -4021,12 +4053,12 @@ function Bi(n, e, t) {
4021
4053
  if (i === a) return s[i];
4022
4054
  const r = e[i], o = e[a];
4023
4055
  if (r && o && !Array.isArray(r) && !Array.isArray(o)) {
4024
- const l = A(r, t.ancestorChains), c = A(o, t.ancestorChains);
4025
- return Ke(l, c, s[i]);
4056
+ const l = x(r, t.ancestorChains), c = x(o, t.ancestorChains);
4057
+ return We(l, c, s[i]);
4026
4058
  }
4027
4059
  return s[i];
4028
4060
  }
4029
- function Je(n, e, t) {
4061
+ function Ze(n, e, t) {
4030
4062
  let s, i = !1;
4031
4063
  const a = [], r = [], o = [];
4032
4064
  for (let f = 0; f < n.length; f++) {
@@ -4039,133 +4071,133 @@ function Je(n, e, t) {
4039
4071
  if (a.length === 0) return;
4040
4072
  const { joined: l } = pe(a), c = t.format === "ssml" ? { ssml: l } : { plain: l };
4041
4073
  s && (c.language = s), n.some((f) => t.synthetic.has(f)) && t.synthetic.add(c);
4042
- const u = Ni(r, o, t);
4074
+ const u = Di(r, o, t);
4043
4075
  u.length > 0 && (c.offsets = u);
4044
- const d = Bi(r, o, t);
4045
- d && (c.locate = d);
4046
- const h = At(r[0], o[0], "leading", t), g = At(r[r.length - 1], o[r.length - 1], "trailing", t);
4047
- return (h || g) && t.edgeSubstitutedLocate.set(c, { leading: h, trailing: g }), c;
4048
- }
4049
- function hn(n, e, t, s) {
4050
- if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml && Ht(n.ssml))
4051
- return qt(n.ssml, n.language).map((a) => {
4076
+ const g = ji(r, o, t);
4077
+ g && (c.locate = g);
4078
+ const h = xt(r[0], o[0], "leading", t), d = xt(r[r.length - 1], o[r.length - 1], "trailing", t);
4079
+ return (h || d) && t.edgeSubstitutedLocate.set(c, { leading: h, trailing: d }), c;
4080
+ }
4081
+ function dn(n, e, t, s) {
4082
+ if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml && qt(n.ssml))
4083
+ return Gt(n.ssml, n.language).map((a) => {
4052
4084
  const r = { plain: a.plain };
4053
4085
  return a.language && (r.language = a.language), s.pendingRange.set(r, { start: a.start, end: a.end }), r;
4054
4086
  });
4055
4087
  const i = {};
4056
- return n.language && (i.language = n.language), e === "ssml" ? i.ssml = n.ssml ?? B(n.plain ?? "") : i.plain = n.plain ?? z(n.ssml ?? ""), (t === "block-level" || t === "none") && (i.ssml && (i.ssml = ln(i.ssml)), t === "none" && delete i.language), [i];
4088
+ return n.language && (i.language = n.language), e === "ssml" ? i.ssml = n.ssml ?? B(n.plain ?? "") : i.plain = n.plain ?? z(n.ssml ?? ""), (t === "block-level" || t === "none") && (i.ssml && (i.ssml = cn(i.ssml)), t === "none" && delete i.language), [i];
4057
4089
  }
4058
- function ne(n, e) {
4090
+ function se(n, e) {
4059
4091
  return e !== "ssml" ? n : n.replace(/<[^>]+>/g, "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
4060
4092
  }
4061
4093
  function Lt(n, e) {
4062
4094
  return e.size > 0 && n.some((t) => e.has(t));
4063
4095
  }
4064
- function Mi(n, e) {
4065
- const t = Ne(n.text), s = t ? hn(t, e.format, e.language, e) : [];
4096
+ function Fi(n, e) {
4097
+ const t = Be(n.text), s = t ? dn(t, e.format, e.language, e) : [];
4066
4098
  if (!e.contextualize.has("pagebreak")) return s;
4067
- const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", a = X(e, i);
4099
+ const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", a = ee(e, i);
4068
4100
  if (a === void 0) return s;
4069
4101
  const r = M(a, e);
4070
4102
  if (s.length === 0) return [r];
4071
- const o = Je([r, ...s], [void 0, ...s.map(() => n)], e);
4103
+ const o = Ze([r, ...s], [void 0, ...s.map(() => n)], e);
4072
4104
  return o ? (o.plain !== void 0 && (o.plain += "."), o.ssml !== void 0 && (o.ssml += "."), [o]) : [r, ...s];
4073
4105
  }
4074
- function Di(n) {
4075
- return ge(n).some((e) => Ri.has(e));
4106
+ function _i(n) {
4107
+ return X(n).some((e) => Ai.has(e));
4076
4108
  }
4077
- function ji(n, e, t, s, i, a) {
4109
+ function Hi(n, e, t, s, i, a) {
4078
4110
  const r = n.text?.language, o = new Map((n.children ?? []).map((h) => [h.id, h])), l = [], c = [], u = [];
4079
- for (const h of ks(e)) {
4111
+ for (const h of Es(e)) {
4080
4112
  if (h.placeholderId !== void 0) {
4081
4113
  const f = o.get(h.placeholderId);
4082
4114
  if (!f) continue;
4083
- i.inlineContextualization || !Di(f) ? dn(f, l, c, i, a) : u.push(f);
4115
+ i.inlineContextualization || !_i(f) ? gn(f, l, c, i, a) : u.push(f);
4084
4116
  continue;
4085
4117
  }
4086
4118
  if (!h.ssml) continue;
4087
- if (i.format === "plain" && i.language !== "block-level" && i.language !== "none" && Ht(h.ssml)) {
4088
- for (const f of qt(h.ssml, r)) {
4119
+ if (i.format === "plain" && i.language !== "block-level" && i.language !== "none" && qt(h.ssml)) {
4120
+ for (const f of Gt(h.ssml, r)) {
4089
4121
  const p = { plain: f.plain };
4090
4122
  f.language && (p.language = f.language), l.push(p), c.push(n);
4091
4123
  }
4092
4124
  continue;
4093
4125
  }
4094
- const g = {};
4095
- r && (g.language = r), i.format === "ssml" ? g.ssml = h.ssml : g.plain = z(h.ssml), (i.language === "block-level" || i.language === "none") && (g.ssml && (g.ssml = ln(g.ssml)), i.language === "none" && delete g.language), l.push(g), c.push(n);
4126
+ const d = {};
4127
+ r && (d.language = r), i.format === "ssml" ? d.ssml = h.ssml : d.plain = z(h.ssml), (i.language === "block-level" || i.language === "none") && (d.ssml && (d.ssml = cn(d.ssml)), i.language === "none" && delete d.language), l.push(d), c.push(n);
4096
4128
  }
4097
- const d = l.length > 1 ? Je(l, c, i) : void 0;
4098
- return un(t, s, i, n, l, c, d), u;
4129
+ const g = l.length > 1 ? Ze(l, c, i) : void 0;
4130
+ return hn(t, s, i, n, l, c, g), u;
4099
4131
  }
4100
- function dn(n, e, t, s, i) {
4101
- const a = ge(n), r = $e(n);
4132
+ function gn(n, e, t, s, i) {
4133
+ const a = X(n), r = $e(n);
4102
4134
  if (Lt(a, s.skip)) return;
4103
- const o = a.some((g) => Ct.has(g)), l = o && !i, c = e.length, u = a.filter(
4104
- (g) => g !== "footnote" && g !== "pagebreak" && !Ti(g, a, s)
4105
- ), d = a.some((g) => Ii.has(g) && s.contextualize.has(g)), h = a.includes("table") && r !== void 0 && !d;
4135
+ const o = a.some((d) => Ct.has(d)), l = o && !i, c = e.length, u = a.filter(
4136
+ (d) => d !== "footnote" && d !== "pagebreak" && !Ni(d, a, s)
4137
+ ), g = a.some((d) => xi.has(d) && s.contextualize.has(d)), h = a.includes("table") && r !== void 0 && !g;
4106
4138
  if (h) {
4107
- const g = M(r, s);
4108
- fe(g, r, r, n, s), D(e, t, n, [g]);
4139
+ const d = M(r, s);
4140
+ fe(d, r, r, n, s), D(e, t, n, [d]);
4109
4141
  }
4110
- for (const g of u) {
4111
- if (g === "figure" && r === void 0) continue;
4112
- const { variantKey: f, params: p } = xt(g, n, s);
4113
- Rt(e, t, n, s, g, "before", f, p);
4142
+ for (const d of u) {
4143
+ if (d === "figure" && r === void 0) continue;
4144
+ const { variantKey: f, params: p } = At(d, n, s);
4145
+ Rt(e, t, n, s, d, "before", f, p);
4114
4146
  }
4115
4147
  if (a.includes("noteref"))
4116
- for (const g of n.children ?? []) {
4117
- const f = ge(g);
4148
+ for (const d of n.children ?? []) {
4149
+ const f = X(d);
4118
4150
  if (!Lt(f, s.skip))
4119
4151
  if (f.includes("footnote")) {
4120
- const p = s.contextualize.has("footnote"), m = s.i18n.exists("footnote.block.start") || s.i18n.exists("footnote.block.end"), S = f.some((C) => Ct.has(C)) && !i && !s.inlineContextualization, v = p ? X(s, m ? "footnote.block.start" : "footnote.inline") : void 0, I = p && (v !== void 0 || m), P = [], y = [];
4121
- v !== void 0 && (P.push(M(v, s)), y.push(g));
4122
- const k = [], R = [];
4123
- if (N([g], k, R, s, i || S), S && k.length > 0 && s.blockStarts.add(k[0]), P.push(...k), y.push(...R), I && m) {
4124
- const C = X(s, "footnote.block.end");
4125
- C !== void 0 && (P.push(M(C, s)), y.push(g));
4152
+ const p = s.contextualize.has("footnote"), m = s.i18n.exists("footnote.block.start") || s.i18n.exists("footnote.block.end"), S = f.some((E) => Ct.has(E)) && !i && !s.inlineContextualization, v = p ? ee(s, m ? "footnote.block.start" : "footnote.inline") : void 0, I = p && (v !== void 0 || m), P = [], y = [];
4153
+ v !== void 0 && (P.push(M(v, s)), y.push(d));
4154
+ const C = [], R = [];
4155
+ if (N([d], C, R, s, i || S), S && C.length > 0 && s.blockStarts.add(C[0]), P.push(...C), y.push(...R), I && m) {
4156
+ const E = ee(s, "footnote.block.end");
4157
+ E !== void 0 && (P.push(M(E, s)), y.push(d));
4126
4158
  }
4127
- const w = I && P.length > 1 ? Je(P, y, s) : void 0;
4128
- un(e, t, s, g, P, y, w);
4159
+ const w = I && P.length > 1 ? Ze(P, y, s) : void 0;
4160
+ hn(e, t, s, d, P, y, w);
4129
4161
  } else
4130
- N([g], e, t, s, i);
4162
+ N([d], e, t, s, i);
4131
4163
  }
4132
- else if (!a.some((g) => Pi.has(g))) {
4133
- const g = ze(n)?.ssml;
4134
- if (g && ws(g)) {
4135
- const f = ji(n, g, e, t, s, i);
4164
+ else if (!a.some((d) => Li.has(d))) {
4165
+ const d = Ne(n)?.ssml;
4166
+ if (d && Cs(d)) {
4167
+ const f = Hi(n, d, e, t, s, i);
4136
4168
  if (f.length > 0) {
4137
4169
  const p = i || o && e.length > c;
4138
4170
  N(f, e, t, s, p);
4139
4171
  }
4140
4172
  } else if (a.includes("pagebreak")) {
4141
- if (D(e, t, n, Mi(n, s)), n.children) {
4173
+ if (D(e, t, n, Fi(n, s)), n.children) {
4142
4174
  const f = i || o && e.length > c;
4143
4175
  N(n.children, e, t, s, f);
4144
4176
  }
4145
4177
  } else {
4146
- const p = a.some((m) => sn.has(m) && Qe(m, s)) ? void 0 : Ne(ze(n));
4147
- if (p && D(e, t, n, hn(p, s.format, s.language, s)), n.children) {
4178
+ const p = a.some((m) => an.has(m) && Je(m, s)) ? void 0 : Be(Ne(n));
4179
+ if (p && D(e, t, n, dn(p, s.format, s.language, s)), n.children) {
4148
4180
  const m = i || o && e.length > c;
4149
4181
  N(n.children, e, t, s, m);
4150
4182
  }
4151
4183
  }
4152
4184
  }
4153
- if (l && e.length > c && s.blockStarts.add(e[c]), r !== void 0 && !d && !h) {
4154
- const g = M(r, s);
4155
- a.includes("figure") && fe(g, r, r, n, s), D(e, t, n, [g]);
4185
+ if (l && e.length > c && s.blockStarts.add(e[c]), r !== void 0 && !g && !h) {
4186
+ const d = M(r, s);
4187
+ a.includes("figure") && fe(d, r, r, n, s), D(e, t, n, [d]);
4156
4188
  }
4157
- for (const g of u) {
4158
- if (g === "figure" && r === void 0) continue;
4159
- const { variantKey: f, params: p } = xt(g, n, s);
4160
- Rt(e, t, n, s, g, "after", f, p);
4189
+ for (const d of u) {
4190
+ if (d === "figure" && r === void 0) continue;
4191
+ const { variantKey: f, params: p } = At(d, n, s);
4192
+ Rt(e, t, n, s, d, "after", f, p);
4161
4193
  }
4162
4194
  }
4163
4195
  function N(n, e, t, s, i) {
4164
- n.forEach((a, r) => dn(a, e, t, s, r === 0 ? i : !1));
4196
+ n.forEach((a, r) => gn(a, e, t, s, r === 0 ? i : !1));
4165
4197
  }
4166
- const Fi = Ft;
4167
- async function gn(n, e, t, s) {
4168
- const i = Fi(n);
4198
+ const qi = _t;
4199
+ async function fn(n, e, t, s) {
4200
+ const i = qi(n);
4169
4201
  let a = "";
4170
4202
  const r = [];
4171
4203
  for (const h of i)
@@ -4175,35 +4207,35 @@ async function gn(n, e, t, s) {
4175
4207
  if (o.length <= 1) return;
4176
4208
  const l = [];
4177
4209
  let c = "", u = 0;
4178
- function d(h, g, f) {
4179
- let p = g;
4180
- const m = g + h.length;
4210
+ function g(h, d, f) {
4211
+ let p = d;
4212
+ const m = d + h.length;
4181
4213
  for (; p < m; ) {
4182
4214
  const S = o[u], v = Math.min(m, S.end), I = v >= S.end && u < o.length - 1;
4183
- let P = h.slice(p - g, v - g);
4215
+ let P = h.slice(p - d, v - d);
4184
4216
  I && (P = P.replace(/[ \t\r\n]+$/, ""));
4185
4217
  const y = B(P);
4186
4218
  c += f ? f(y) : y, p = v, I && (l.push(c), c = "", u++);
4187
4219
  }
4188
4220
  }
4189
- return i.forEach((h, g) => {
4221
+ return i.forEach((h, d) => {
4190
4222
  if (h.kind === "selfClosing")
4191
4223
  c += h.raw;
4192
4224
  else if (h.kind === "text")
4193
- d(h.text, r[g]);
4225
+ g(h.text, r[d]);
4194
4226
  else {
4195
4227
  const f = `<${h.tag}${h.attrs}>`, p = `</${h.tag}>`;
4196
- h.innerText ? d(h.innerText, r[g], (m) => `${f}${m}${p}`) : c += f + p;
4228
+ h.innerText ? g(h.innerText, r[d], (m) => `${f}${m}${p}`) : c += f + p;
4197
4229
  }
4198
4230
  }), c && l.push(c.replace(/[ \t\r\n]+$/, "")), l;
4199
4231
  }
4200
- async function _i(n, e) {
4201
- const t = n.language ?? "en", s = e.segmentationSuppressions[t], i = e.format === "ssml" ? n.ssml : n.plain;
4232
+ async function Gi(n, e) {
4233
+ const t = n.language ?? "en", s = ve(e.segmentationSuppressions, t), i = e.format === "ssml" ? n.ssml : n.plain;
4202
4234
  if (!i) return;
4203
- const a = await e.segmenter(t, ne(i, e.format), s);
4235
+ const a = await e.segmenter(t, se(i, e.format), s);
4204
4236
  if (a.length <= 1) return;
4205
4237
  if (e.format !== "ssml") return a.map((o) => ({ text: o.text, start: o.start, end: o.contentEnd }));
4206
- const r = await gn(i, t, e.segmenter, s);
4238
+ const r = await fn(i, t, e.segmenter, s);
4207
4239
  if (r)
4208
4240
  return a.map((o, l) => ({ text: r[l], start: o.start, end: o.contentEnd }));
4209
4241
  }
@@ -4223,32 +4255,39 @@ const Ot = /* @__PURE__ */ new Set([
4223
4255
  "heading6"
4224
4256
  ]);
4225
4257
  function Ut(n) {
4226
- return n ? ge(Array.isArray(n) ? n[1] : n) : [];
4258
+ return n ? X(Array.isArray(n) ? n[1] : n) : [];
4259
+ }
4260
+ function Vt(n, e, t) {
4261
+ const s = Array.isArray(n) ? n[e === "leading" ? 0 : 1] : n;
4262
+ return (t.ancestorChains.get(s) ?? []).filter((i) => X(i).some((a) => a !== "presentation"));
4263
+ }
4264
+ function $i(n, e) {
4265
+ return n.length === e.length && n.every((t, s) => t === e[s]);
4227
4266
  }
4228
4267
  function Tt(n, e, t, s) {
4229
- return s.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) && te(n);
4268
+ return s.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) && ne(n);
4230
4269
  }
4231
- function Hi(n, e, t, s, i) {
4270
+ function Ki(n, e, t, s, i) {
4232
4271
  if (i.synthetic.has(n) || i.synthetic.has(t) || !e || !s) return !1;
4233
4272
  const a = i.format === "ssml" ? n.ssml : n.plain, r = i.format === "ssml" ? t.ssml : t.plain;
4234
- return !(!a || !r || (n.language ?? "en") !== (t.language ?? "en") || Ut(e).some((o) => Ot.has(o)) || Ut(s).some((o) => Ot.has(o)) || Tt(e, n, "trailing", i) || Tt(s, t, "leading", i));
4273
+ return !(!a || !r || (n.language ?? "en") !== (t.language ?? "en") || Ut(e).some((o) => Ot.has(o)) || Ut(s).some((o) => Ot.has(o)) || !$i(Vt(e, "trailing", i), Vt(s, "leading", i)) || Tt(e, n, "trailing", i) || Tt(s, t, "leading", i));
4235
4274
  }
4236
- async function Vt(n, e, t, s, i) {
4237
- const a = t.synthetic.has(n) ? void 0 : await _i(n, t);
4275
+ async function zt(n, e, t, s, i) {
4276
+ const a = t.synthetic.has(n) ? void 0 : await Gi(n, t);
4238
4277
  if (!a) {
4239
4278
  s.push(n), i.push(e);
4240
4279
  return;
4241
4280
  }
4242
4281
  const r = t.blockStarts.has(n);
4243
4282
  r && t.blockStarts.delete(n);
4244
- const o = Array.isArray(e) ? void 0 : e, l = o ? A(o, t.ancestorChains) : void 0, c = o && te(o) ? Ce(o, t) : void 0, u = t.edgeSubstitutedLocate.get(n);
4245
- a.forEach(({ text: d, start: h, end: g }, f) => {
4246
- const p = { ...n, [t.format]: d }, m = (f === 0 ? u?.leading : void 0) ?? (f === a.length - 1 ? u?.trailing : void 0) ?? c;
4283
+ const o = Array.isArray(e) ? void 0 : e, l = o ? x(o, t.ancestorChains) : void 0, c = o && ne(o) ? Ee(o, t) : void 0, u = t.edgeSubstitutedLocate.get(n);
4284
+ a.forEach(({ text: g, start: h, end: d }, f) => {
4285
+ const p = { ...n, [t.format]: g }, m = (f === 0 ? u?.leading : void 0) ?? (f === a.length - 1 ? u?.trailing : void 0) ?? c;
4247
4286
  if (m && l)
4248
- p.locate = m, p.offsets = [{ start: h, end: g, locate: m }];
4287
+ p.locate = m, p.offsets = [{ start: h, end: d, locate: m }];
4249
4288
  else if (l) {
4250
- const S = t.format === "ssml" ? ne(d, t.format) : d, v = H(l.ref, S);
4251
- p.locate = v, p.offsets = [{ start: h, end: g, locate: v }];
4289
+ const S = t.format === "ssml" ? se(g, t.format) : g, v = H(l.ref, S);
4290
+ p.locate = v, p.offsets = [{ start: h, end: d, locate: v }];
4252
4291
  }
4253
4292
  r && f === 0 && t.blockStarts.add(p), s.push(p), i.push(e);
4254
4293
  });
@@ -4258,89 +4297,89 @@ function me(n, e) {
4258
4297
  for (; t < n.length - 1 && n[t + 1].start <= e; ) t++;
4259
4298
  return t;
4260
4299
  }
4261
- async function qi(n, e, t, s) {
4262
- const i = n.map((c) => ne(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = pe(i), o = await e.segmenter(t, a, s), l = new Array(n.length - 1).fill(!1);
4300
+ async function Wi(n, e, t, s) {
4301
+ const i = n.map((c) => se(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = pe(i), o = await e.segmenter(t, a, s), l = new Array(n.length - 1).fill(!1);
4263
4302
  for (const c of o) {
4264
- const u = me(r, c.start), d = c.end > c.start ? me(r, c.end - 1) : u;
4265
- for (let h = u; h < d; h++) l[h] = !0;
4303
+ const u = me(r, c.start), g = c.end > c.start ? me(r, c.end - 1) : u;
4304
+ for (let h = u; h < g; h++) l[h] = !0;
4266
4305
  }
4267
4306
  return l;
4268
4307
  }
4269
- function $i(n, e, t, s, i, a, r) {
4308
+ function Qi(n, e, t, s, i, a, r) {
4270
4309
  const o = [];
4271
4310
  for (let l = i; l <= a; l++) {
4272
- const c = A(e[l], r.ancestorChains);
4311
+ const c = x(e[l], r.ancestorChains);
4273
4312
  if (!c) continue;
4274
- const u = t[l], d = Math.max(u.start, s.start), h = Math.min(u.end, l === a ? s.contentEnd : s.end);
4275
- if (h <= d) continue;
4276
- const g = d - u.start, f = h - u.start, p = ne(r.format === "ssml" ? n[l].ssml : n[l].plain, r.format), m = H(c.ref, p.slice(g, f));
4277
- o.push({ start: g, end: f, locate: m });
4313
+ const u = t[l], g = Math.max(u.start, s.start), h = Math.min(u.end, l === a ? s.contentEnd : s.end);
4314
+ if (h <= g) continue;
4315
+ const d = g - u.start, f = h - u.start, p = se(r.format === "ssml" ? n[l].ssml : n[l].plain, r.format), m = H(c.ref, p.slice(d, f));
4316
+ o.push({ start: d, end: f, locate: m });
4278
4317
  }
4279
4318
  return o;
4280
4319
  }
4281
- async function Gi(n, e, t, s, i) {
4282
- const a = n[0].language ?? "en", r = t.segmentationSuppressions[a], o = n.map((f) => ne(t.format === "ssml" ? f.ssml : f.plain, t.format)), { joined: l, ranges: c } = pe(o), u = await t.segmenter(a, l, r);
4283
- let d, h;
4284
- t.format === "ssml" && (h = pe(n.map((f) => f.ssml)).joined, d = u.length > 1 ? await gn(h, a, t.segmenter, r) : void 0), (u.length > 0 ? u : [{ text: l, start: 0, end: l.length, contentEnd: l.length }]).forEach((f, p) => {
4285
- const m = me(c, f.start), S = f.end > f.start ? me(c, f.end - 1) : m, v = t.format === "ssml" ? d ? d[p] : h : f.text, I = { [t.format]: v };
4286
- a && (I.language = a), n.slice(m, S + 1).some((C) => t.blockStarts.has(C)) && t.blockStarts.add(I);
4287
- const y = $i(n, e, c, f, m, S, t);
4320
+ async function Ji(n, e, t, s, i) {
4321
+ const a = n[0].language ?? "en", r = ve(t.segmentationSuppressions, a), o = n.map((f) => se(t.format === "ssml" ? f.ssml : f.plain, t.format)), { joined: l, ranges: c } = pe(o), u = await t.segmenter(a, l, r);
4322
+ let g, h;
4323
+ t.format === "ssml" && (h = pe(n.map((f) => f.ssml)).joined, g = u.length > 1 ? await fn(h, a, t.segmenter, r) : void 0), (u.length > 0 ? u : [{ text: l, start: 0, end: l.length, contentEnd: l.length }]).forEach((f, p) => {
4324
+ const m = me(c, f.start), S = f.end > f.start ? me(c, f.end - 1) : m, v = t.format === "ssml" ? g ? g[p] : h : f.text, I = { [t.format]: v };
4325
+ a && (I.language = a), n.slice(m, S + 1).some((E) => t.blockStarts.has(E)) && t.blockStarts.add(I);
4326
+ const y = Qi(n, e, c, f, m, S, t);
4288
4327
  y.length > 0 && (I.offsets = y);
4289
- const k = A(e[m], t.ancestorChains), R = Ge(k, v), w = m !== S ? Ke(k, A(e[S], t.ancestorChains), R) : R;
4328
+ const C = x(e[m], t.ancestorChains), R = Ke(C, v), w = m !== S ? We(C, x(e[S], t.ancestorChains), R) : R;
4290
4329
  w && (I.locate = w), s.push(I), i.push(m === S ? e[m] : [e[m], e[S]]);
4291
4330
  });
4292
4331
  }
4293
- async function fn(n, e, t) {
4332
+ async function pn(n, e, t) {
4294
4333
  if (t.segmentation !== "sentence") return { out: n, sources: e };
4295
4334
  const s = [], i = [];
4296
4335
  let a = 0;
4297
4336
  for (; a < n.length; ) {
4298
4337
  let r = a;
4299
- for (; r + 1 < n.length && Hi(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
4338
+ for (; r + 1 < n.length && Ki(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
4300
4339
  if (r === a) {
4301
- await Vt(n[a], e[a], t, s, i), a = r + 1;
4340
+ await zt(n[a], e[a], t, s, i), a = r + 1;
4302
4341
  continue;
4303
4342
  }
4304
- const o = n.slice(a, r + 1), l = e.slice(a, r + 1), c = o[0].language ?? "en", u = await qi(o, t, c, t.segmentationSuppressions[c]);
4305
- let d = 0;
4343
+ const o = n.slice(a, r + 1), l = e.slice(a, r + 1), c = o[0].language ?? "en", u = await Wi(o, t, c, ve(t.segmentationSuppressions, c));
4344
+ let g = 0;
4306
4345
  for (let h = 0; h < o.length; h++)
4307
- h < o.length - 1 && u[h] || (d === h ? await Vt(o[d], l[d], t, s, i) : await Gi(o.slice(d, h + 1), l.slice(d, h + 1), t, s, i), d = h + 1);
4346
+ h < o.length - 1 && u[h] || (g === h ? await zt(o[g], l[g], t, s, i) : await Ji(o.slice(g, h + 1), l.slice(g, h + 1), t, s, i), g = h + 1);
4308
4347
  a = r + 1;
4309
4348
  }
4310
4349
  return { out: s, sources: i };
4311
4350
  }
4312
- function pn(n, e) {
4351
+ function mn(n, e) {
4313
4352
  return Object.keys(e.substitutions).length === 0 ? n : n.map((t) => {
4314
4353
  if (t.ssml) {
4315
- const { ssml: o, plain: l, map: c } = ms(t.ssml, e.substitutions);
4354
+ const { ssml: o, plain: l, map: c } = ys(t.ssml, e.substitutions);
4316
4355
  if (o === t.ssml) return t;
4317
4356
  const u = { ...t, ssml: o };
4318
- return yt(u, { plain: l, map: c }), u;
4357
+ return St(u, { plain: l, map: c }), u;
4319
4358
  }
4320
4359
  const s = t.plain;
4321
4360
  if (!s) return t;
4322
- const { text: i, map: a } = fs(s, e.substitutions);
4361
+ const { text: i, map: a } = ms(s, e.substitutions);
4323
4362
  if (i === s) return t;
4324
4363
  const r = { ...t, plain: i };
4325
- return yt(r, { plain: s, map: a }), r;
4364
+ return St(r, { plain: s, map: a }), r;
4326
4365
  });
4327
4366
  }
4328
- async function oa(n, e = {}) {
4329
- const t = [], s = [], i = await on(n, e);
4367
+ async function ha(n, e = {}) {
4368
+ const t = [], s = [], i = await ln(n, e);
4330
4369
  N(n, t, s, i, !1);
4331
- const a = await fn(t, s, i);
4332
- return pn(cn(a.out, a.sources, i), i);
4370
+ const a = await pn(t, s, i);
4371
+ return mn(un(a.out, a.sources, i), i);
4333
4372
  }
4334
- async function Ki(n, e = {}) {
4335
- const t = [], s = [], i = await on(n, e);
4373
+ async function Zi(n, e = {}) {
4374
+ const t = [], s = [], i = await ln(n, e);
4336
4375
  N(n, t, s, i, !1);
4337
- const a = await fn(t, s, i), r = a.out.map((l) => i.blockStarts.has(l)), o = cn(a.out, a.sources, i);
4338
- return { utterances: pn(o, i), sources: a.sources, blockStarts: r };
4376
+ const a = await pn(t, s, i), r = a.out.map((l) => i.blockStarts.has(l)), o = un(a.out, a.sources, i);
4377
+ return { utterances: mn(o, i), sources: a.sources, blockStarts: r };
4339
4378
  }
4340
- class la {
4379
+ class da {
4341
4380
  engine;
4342
4381
  contentQueue = [];
4343
- events = new be();
4382
+ events = new we();
4344
4383
  // Navigator owns the state, not the engine
4345
4384
  navigatorState = "idle";
4346
4385
  // Scheduled by the "end" handler's pauseDuration delay — cleared on
@@ -4373,7 +4412,7 @@ class la {
4373
4412
  // Index to speak() on the next play() when autoPause has stopped playback between utterances.
4374
4413
  pendingAutoPauseIndex = null;
4375
4414
  constructor(e, t = {}) {
4376
- this.engine = e, this._defaults = new Ws(t.defaults), this._preferences = new Y(t.preferences), this._settings = new mt(this._preferences, this._defaults), this.contextualizationOverrides = t.contextualizationOverrides, this.segmentationOverrides = t.segmentationOverrides, this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
4415
+ this.engine = e, this._defaults = new Js(t.defaults), this._preferences = new Y(t.preferences), this._settings = new vt(this._preferences, this._defaults), this.contextualizationOverrides = t.contextualizationOverrides, this.segmentationOverrides = t.segmentationOverrides, this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
4377
4416
  }
4378
4417
  // Unlike pauseDuration/autoPause (read live off settings), the engine owns rate/pitch/volume and must be pushed.
4379
4418
  applyEngineParameters() {
@@ -4419,13 +4458,13 @@ class la {
4419
4458
  }
4420
4459
  if (t === "paused") {
4421
4460
  const s = e ?? 0;
4422
- s > 0 ? this.engine.setCurrentUtteranceIndex(s, () => this.setNavigatorState("paused")) : this.setNavigatorState("paused");
4461
+ this.pendingAutoPauseIndex = s, s > 0 ? this.engine.setCurrentUtteranceIndex(s, () => this.setNavigatorState("paused")) : this.setNavigatorState("paused");
4423
4462
  return;
4424
4463
  }
4425
4464
  this.setNavigatorState("ready"), this.emitEvent({ type: "ready" });
4426
4465
  }
4427
4466
  }), this.engine.on("boundary", (e) => {
4428
- const { charIndex: t, charLength: s } = e.detail ?? {}, i = this.getCurrentContent(), a = i && typeof t == "number" && typeof s == "number" ? ti(i, t, s) : void 0;
4467
+ const { charIndex: t, charLength: s } = e.detail ?? {}, i = this.getCurrentContent(), a = i && typeof t == "number" && typeof s == "number" ? si(i, t, s) : void 0;
4429
4468
  this.emitEvent(a ? { ...e, detail: { ...e.detail, ...a } } : e);
4430
4469
  }), this.engine.on("mark", (e) => {
4431
4470
  this.emitEvent(e);
@@ -4475,14 +4514,14 @@ class la {
4475
4514
  // Re-runs extraction from `this.source`, resuming near the old position if playback was underway.
4476
4515
  async reextract() {
4477
4516
  if (!this.source) return;
4478
- const e = this.navigatorState === "playing" || this.navigatorState === "paused" ? this.navigatorState : null, t = this.contentSources, s = this.getCurrentUtteranceIndex(), { utterances: i, sources: a, blockStarts: r } = await Ki(this.source, {
4517
+ const e = this.navigatorState === "playing" || this.navigatorState === "paused" ? this.navigatorState : null, t = this.contentSources, s = this.getCurrentUtteranceIndex(), { utterances: i, sources: a, blockStarts: r } = await Zi(this.source, {
4479
4518
  format: this._settings.format,
4480
4519
  inlineContextualization: this._settings.inlineContextualization,
4481
4520
  skip: this._settings.skip,
4482
4521
  contextualize: this._settings.contextualize,
4483
4522
  contextualization: {
4484
4523
  contextualizations: this.contextualizationOverrides?.contextualizations,
4485
- shapes: ei(this._settings.verbosity, this.contextualizationOverrides?.shapes),
4524
+ shapes: ni(this._settings.verbosity, this.contextualizationOverrides?.shapes),
4486
4525
  params: this.contextualizationOverrides?.params
4487
4526
  },
4488
4527
  language: this._settings.language,
@@ -4533,7 +4572,13 @@ class la {
4533
4572
  return;
4534
4573
  }
4535
4574
  pause() {
4536
- this.navigatorState === "playing" && (this.clearPendingAdvance(), this.pendingAutoPauseIndex = null, this.setNavigatorState("paused"), this.engine.pause());
4575
+ if (this.navigatorState === "playing") {
4576
+ if (this.pendingAdvanceTimeout !== null) {
4577
+ this.clearPendingAdvance(), this.pendingAutoPauseIndex = this.getCurrentUtteranceIndex() + 1, this.setNavigatorState("paused"), this.emitEvent({ type: "pause" });
4578
+ return;
4579
+ }
4580
+ this.pendingAutoPauseIndex = null, this.setNavigatorState("paused"), this.engine.pause();
4581
+ }
4537
4582
  }
4538
4583
  stop() {
4539
4584
  this.clearPendingAdvance(), this.pendingAutoPauseIndex = null, this.setNavigatorState("idle"), this.engine.stop(), this.emitEvent({ type: "stop" });
@@ -4584,7 +4629,7 @@ class la {
4584
4629
  // LocatorOptions there — and the same "resolve, then skip if there's nothing
4585
4630
  // to show" shape, since there's no raw engine event to fall back to unenriched.
4586
4631
  emitUtteranceBoundary(e) {
4587
- const t = this._settings.segmentation, s = ni(e, t);
4632
+ const t = this._settings.segmentation, s = ii(e, t);
4588
4633
  if (!s.length) return;
4589
4634
  const i = t === "sentence" ? "sentence" : "structure";
4590
4635
  this.emitEvent({
@@ -4600,16 +4645,16 @@ class la {
4600
4645
  return this._settings;
4601
4646
  }
4602
4647
  get preferencesEditor() {
4603
- return this._preferencesEditor === null && (this._preferencesEditor = new pt(this._preferences, this.settings)), this._preferencesEditor;
4648
+ return this._preferencesEditor === null && (this._preferencesEditor = new mt(this._preferences, this.settings)), this._preferencesEditor;
4604
4649
  }
4605
4650
  async submitPreferences(e) {
4606
- !this.source && gt.some((t) => e[t] !== void 0) && console.warn(
4651
+ !this.source && this.contentQueue.length > 0 && ft.some((t) => e[t] !== void 0) && console.warn(
4607
4652
  "submitPreferences(): extraction-affecting preferences (format, inlineContextualization, verbosity, skip, contextualize, language, segmentation) have no effect on content loaded via loadContent() — use loadGndContent() to re-extract on submission."
4608
4653
  ), this._preferences = this._preferences.merging(e), await this.applyPreferences();
4609
4654
  }
4610
4655
  async applyPreferences() {
4611
4656
  const e = this._settings;
4612
- this._settings = new mt(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new pt(this._preferences, this._settings)), gt.some((t) => !this.sameSettingValue(e[t], this._settings[t])) && await this.reextract();
4657
+ this._settings = new vt(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new mt(this._preferences, this._settings)), ft.some((t) => !this.sameSettingValue(e[t], this._settings[t])) && await this.reextract();
4613
4658
  }
4614
4659
  // Arrays (skip/contextualize) compare as sets, not by reference.
4615
4660
  sameSettingValue(e, t) {
@@ -4620,61 +4665,77 @@ class la {
4620
4665
  }
4621
4666
  }
4622
4667
  export {
4623
- Qs as BooleanPreference,
4624
- G as EnumPreference,
4625
- na as FallbackEngineProvider,
4626
- qs as FallbackSpeechEngine,
4627
- da as Locator,
4628
- ga as LocatorLocations,
4629
- fa as LocatorText,
4630
- ke as Preference,
4631
- ae as RangePreference,
4632
- Ks as ReadiumSpeechDecorationController,
4633
- la as ReadiumSpeechNavigator,
4634
- ia as ReadiumSpeechProviderRegistry,
4635
- Ws as SpeechDefaults,
4668
+ Zs as BooleanPreference,
4669
+ $ as EnumPreference,
4670
+ ra as FallbackEngineProvider,
4671
+ $s as FallbackSpeechEngine,
4672
+ ma as Locator,
4673
+ va as LocatorLocations,
4674
+ ya as LocatorText,
4675
+ Ce as Preference,
4676
+ re as RangePreference,
4677
+ Qs as ReadiumSpeechDecorationController,
4678
+ da as ReadiumSpeechNavigator,
4679
+ la as ReadiumSpeechProviderRegistry,
4680
+ Js as SpeechDefaults,
4636
4681
  Y as SpeechPreferences,
4637
- pt as SpeechPreferencesEditor,
4638
- Jt as SpeechServerAudioDecodeError,
4639
- js as SpeechServerEngine,
4640
- ta as SpeechServerEngineProvider,
4682
+ mt as SpeechPreferencesEditor,
4683
+ Zt as SpeechServerAudioDecodeError,
4684
+ _s as SpeechServerEngine,
4685
+ aa as SpeechServerEngineProvider,
4641
4686
  J as SpeechServerError,
4642
- Zt as SpeechServerNetworkError,
4643
- Qt as SpeechServerStallError,
4644
- mt as SpeechSettings,
4645
- ft as StringArrayPreference,
4646
- ht as WebSpeechEngine,
4647
- ea as WebSpeechEngineProvider,
4687
+ Yt as SpeechServerNetworkError,
4688
+ Jt as SpeechServerStallError,
4689
+ vt as SpeechSettings,
4690
+ pt as StringArrayPreference,
4691
+ dt as WebSpeechEngine,
4692
+ ia as WebSpeechEngineProvider,
4648
4693
  b as WebSpeechVoiceManager,
4649
- _e as autoPauseScopes,
4650
- Si as blockLevelRoles,
4694
+ He as autoPauseScopes,
4695
+ ki as blockLevelRoles,
4651
4696
  Q as chineseVariantMap,
4652
- Rs as chunkPlainText,
4653
- Ps as chunkSsmlText,
4654
- Xs as contextualizationShapesAtVerbosity,
4655
- Ys as contextualizedAtVerbosity,
4656
- Gs as createLocator,
4657
- nn as defaultContextualizations,
4658
- oa as extractUtterances,
4659
- Fe as extractionFormats,
4660
- gt as extractionPreferenceKeys,
4661
- Fs as isRecoverableFailure,
4662
- je as languageModes,
4663
- Wt as mapServerVoice,
4664
- As as mimeTypeForFormat,
4665
- ce as pauseDurationRangeConfig,
4666
- he as pitchRangeConfig,
4667
- ue as rateRangeConfig,
4668
- ti as resolveBoundaryLocate,
4669
- ni as resolveUtteranceLocate,
4670
- He as segmentationModes,
4671
- zs as selectBitrate,
4672
- Us as selectFormat,
4673
- sa as setupDecorations,
4674
- aa as shapeableRoles,
4675
- ra as skippableRoles,
4676
- Zs as skippedAtVerbosity,
4697
+ Ps as chunkPlainText,
4698
+ xs as chunkSsmlText,
4699
+ Bt as compareAlphabetically,
4700
+ Nt as compareByPreferredRegion,
4701
+ ti as contextualizationShapesAtVerbosity,
4702
+ ei as contextualizedAtVerbosity,
4703
+ _ as createJsonOrderMap,
4704
+ Ws as createLocator,
4705
+ sn as defaultContextualizations,
4706
+ ha as extractUtterances,
4707
+ _e as extractionFormats,
4708
+ ft as extractionPreferenceKeys,
4709
+ Mt as filterByBoundarySupport,
4710
+ Hn as filterByLanguages,
4711
+ it as filterOutNoveltyVoices,
4712
+ at as filterOutVeryLowQualityVoices,
4713
+ ce as getQualityValue,
4714
+ be as groupVoicesByLanguage,
4715
+ Oe as isNoveltyVoice,
4716
+ Hs as isRecoverableFailure,
4717
+ Ue as isVeryLowQualityVoice,
4718
+ Fe as languageModes,
4719
+ Qt as mapServerVoice,
4720
+ Os as mimeTypeForFormat,
4721
+ ue as pauseDurationRangeConfig,
4722
+ Nn as pickBestVoiceByRegion,
4723
+ de as pitchRangeConfig,
4724
+ he as rateRangeConfig,
4725
+ si as resolveBoundaryLocate,
4726
+ ii as resolveUtteranceLocate,
4727
+ qe as segmentationModes,
4728
+ Bs as selectBitrate,
4729
+ Ts as selectFormat,
4730
+ oa as setupDecorations,
4731
+ ca as shapeableRoles,
4732
+ ua as skippableRoles,
4733
+ Xs as skippedAtVerbosity,
4734
+ Le as sortAlphabetically,
4735
+ Tn as sortByPreferredRegion,
4736
+ j as sortByQuality,
4737
+ zn as sortVoicesByRegions,
4677
4738
  W as toSpeechServerError,
4678
- De as verbosityPresets,
4679
- de as volumeRangeConfig
4739
+ je as verbosityPresets,
4740
+ ge as volumeRangeConfig
4680
4741
  };