@readium/speech 0.15.0 → 0.16.1

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 si, DirectCommsChannel as ai, Decorator as ri } from "@readium/decorator";
1
+ import { DecorationController as ci, DirectCommsChannel as ui, Decorator as hi } from "@readium/decorator";
2
2
  export * from "@readium/decorator";
3
- import { LocatorText as oi, LocatorLocations as li, Locator as ci } from "@readium/shared";
4
- import { Locator as or, LocatorLocations as lr, LocatorText as cr } from "@readium/shared";
5
- import { startsWithBindingPunct as ue, ssmlTextEscape as z, BINDING_PUNCT_CLASS as ie, ssmlAttrEscape as on } from "@readium/helpers";
6
- import ui from "i18next";
7
- import { decodeTextref as Ct, combineDomRangeTextrefs as hi, substitutedOwnSelector as di, isAriaSubstituted as he } from "@readium/guided-navigation";
8
- import { DomRange as gi, DomRangePoint as Et } from "@readium/shared/html";
9
- const C = (n) => {
3
+ import { LocatorText as di, LocatorLocations as gi, Locator as fi } from "@readium/shared";
4
+ import { Locator as fr, LocatorLocations as pr, LocatorText as mr } from "@readium/shared";
5
+ import { startsWithBindingPunct as he, ssmlTextEscape as T, BINDING_PUNCT_CLASS as se, ssmlAttrEscape as ln } from "@readium/helpers";
6
+ import pi from "i18next";
7
+ import { decodeTextref as Et, combineDomRangeTextrefs as mi, substitutedOwnSelector as vi, isAriaSubstituted as de } from "@readium/guided-navigation";
8
+ import { DomRange as yi, DomRangePoint as Rt } 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 {
@@ -23,19 +23,19 @@ const C = (n) => {
23
23
  ];
24
24
  }
25
25
  }, nt = (n, e) => {
26
- const t = e.toLowerCase().replace(/_/g, "-"), [i] = C(e), s = Object.entries(n);
26
+ const t = e.toLowerCase().replace(/_/g, "-"), [i] = k(e), s = Object.entries(n);
27
27
  for (const a of [t, i]) {
28
28
  const r = s.find(([o]) => o.toLowerCase().replace(/_/g, "-") === a);
29
29
  if (r) return r[1];
30
30
  }
31
- }, Ce = (n, e) => {
32
- const t = e.toLowerCase().replace(/_/g, "-"), [i] = C(e);
31
+ }, cn = (n, e) => {
32
+ const t = e.toLowerCase().replace(/_/g, "-"), [i] = k(e);
33
33
  let s;
34
34
  for (const a of [i, t])
35
35
  for (const [r, o] of Object.entries(n))
36
36
  r.toLowerCase().replace(/_/g, "-") === a && (s ??= /* @__PURE__ */ new Set(), o.forEach((l) => s.add(l)));
37
37
  return s && [...s];
38
- }, T = {
38
+ }, U = {
39
39
  ar: {
40
40
  defaultRegion: "SA",
41
41
  availableRegions: [
@@ -422,16 +422,16 @@ const C = (n) => {
422
422
  ],
423
423
  testUtterance: "你好,我叫 {name},係越中文聲。"
424
424
  }
425
- }, Ve = /* @__PURE__ */ new Map(), fi = /* @__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") });
426
- async function pi(n) {
425
+ }, xe = /* @__PURE__ */ new Map(), Si = /* @__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") });
426
+ async function bi(n) {
427
427
  try {
428
- const e = n.split("-")[0], t = fi[`../../json/${e}.json`];
428
+ const e = n.split("-")[0], t = Si[`../../json/${e}.json`];
429
429
  if (!t)
430
430
  throw new Error(`No voice data found for language: ${n}`);
431
431
  const s = (await t()).default;
432
432
  return {
433
433
  ...s,
434
- voices: s.voices.map(yi)
434
+ voices: s.voices.map(Ci)
435
435
  };
436
436
  } catch (e) {
437
437
  return console.warn(`Failed to load voice data for ${n}:`, e), {
@@ -442,14 +442,14 @@ async function pi(n) {
442
442
  };
443
443
  }
444
444
  }
445
- function Rt(n) {
446
- return Ve.has(n) || Ve.set(n, pi(n)), Ve.get(n);
445
+ function It(n) {
446
+ return xe.has(n) || xe.set(n, bi(n)), xe.get(n);
447
447
  }
448
- const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "apple"], yi = (n) => ({
448
+ const wi = ["veryLow", "low", "normal", "high", "veryHigh"], ki = ["android", "apple"], Ci = (n) => ({
449
449
  ...n,
450
- quality: n.quality?.filter((e) => mi.includes(e)),
451
- localizedName: n.localizedName && vi.includes(n.localizedName) ? n.localizedName : void 0
452
- }), ae = {
450
+ quality: n.quality?.filter((e) => wi.includes(e)),
451
+ localizedName: n.localizedName && ki.includes(n.localizedName) ? n.localizedName : void 0
452
+ }), re = {
453
453
  cmn: "cmn",
454
454
  "cmn-CN": "cmn-CN",
455
455
  "cmn-TW": "cmn-TW",
@@ -461,29 +461,29 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
461
461
  "zh-HK": "yue-HK",
462
462
  wuu: "wuu",
463
463
  "wuu-CN": "wuu-CN"
464
- }, x = (n) => {
464
+ }, V = (n) => {
465
465
  if (!n) return "";
466
466
  let e = n.toLowerCase().replace(/_/g, "-");
467
467
  if (/\w{2,3}-\w{2,3}/.test(e)) {
468
468
  const [t, i] = e.split("-");
469
469
  e = `${t.toLowerCase()}-${i.toUpperCase()}`;
470
470
  }
471
- return ae[e] || e;
472
- }, je = async (n) => {
471
+ return re[e] || e;
472
+ }, De = async (n) => {
473
473
  if (!n) return [];
474
474
  try {
475
- const e = x(n);
475
+ const e = V(n);
476
476
  try {
477
- const i = await Rt(e);
477
+ const i = await It(e);
478
478
  if (i?.voices?.length)
479
479
  return i.voices;
480
480
  } catch (i) {
481
481
  console.warn(`Failed to load voices for ${e}:`, i);
482
482
  }
483
- const [t] = C(e);
483
+ const [t] = k(e);
484
484
  if (t !== e)
485
485
  try {
486
- const i = await Rt(t);
486
+ const i = await It(t);
487
487
  if (i?.voices?.length)
488
488
  return i.voices;
489
489
  } catch (i) {
@@ -493,7 +493,7 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
493
493
  } catch (e) {
494
494
  return console.error(`Error in getVoices for ${n}:`, e), [];
495
495
  }
496
- }, De = (n, e) => {
496
+ }, je = (n, e) => {
497
497
  try {
498
498
  return new Intl.DisplayNames(
499
499
  e ? [e] : [],
@@ -502,39 +502,39 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
502
502
  } catch {
503
503
  return n.toUpperCase();
504
504
  }
505
- }, It = (n) => {
505
+ }, Pt = (n) => {
506
506
  if (!n) return "";
507
507
  try {
508
- const e = x(n), t = T[e];
508
+ const e = V(n), t = U[e];
509
509
  if (t?.testUtterance)
510
510
  return t.testUtterance;
511
- if (e in ae) {
512
- const s = ae[e];
513
- if (s && T[s]?.testUtterance)
514
- return T[s].testUtterance;
511
+ if (e in re) {
512
+ const s = re[e];
513
+ if (s && U[s]?.testUtterance)
514
+ return U[s].testUtterance;
515
515
  }
516
- const [i] = C(e);
517
- return i !== e && T[i]?.testUtterance ? T[i].testUtterance : "";
516
+ const [i] = k(e);
517
+ return i !== e && U[i]?.testUtterance ? U[i].testUtterance : "";
518
518
  } catch (e) {
519
519
  return console.error(`Error in getTestUtterance for ${n}:`, e), "";
520
520
  }
521
- }, Ee = (n) => {
521
+ }, Re = (n) => {
522
522
  if (!n) return "";
523
523
  try {
524
- const e = x(n), t = T[e];
524
+ const e = V(n), t = U[e];
525
525
  if (t?.defaultRegion)
526
526
  return `${e}-${t.defaultRegion}`;
527
- if (e in ae) {
528
- const s = ae[e];
527
+ if (e in re) {
528
+ const s = re[e];
529
529
  if (s) {
530
- const a = T[s];
530
+ const a = U[s];
531
531
  if (a?.defaultRegion)
532
532
  return `${s}-${a.defaultRegion}`;
533
533
  }
534
534
  }
535
- const [i] = C(e);
535
+ const [i] = k(e);
536
536
  if (i !== e) {
537
- const s = T[i];
537
+ const s = U[i];
538
538
  if (s?.defaultRegion)
539
539
  return `${i}-${s.defaultRegion}`;
540
540
  }
@@ -542,17 +542,17 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
542
542
  } catch (e) {
543
543
  return console.error(`Failed to get default region for ${n}:`, e), "";
544
544
  }
545
- }, Re = (n) => {
545
+ }, Ie = (n) => {
546
546
  if (!n?.length) return [];
547
547
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
548
548
  for (const [s, a] of n.entries()) {
549
549
  if (!a) continue;
550
- const r = x(a), [o, l] = C(r);
550
+ const r = V(a), [o, l] = k(r);
551
551
  l && (e.add(l), i.has(l) || i.set(l, s)), t.has(o) || t.set(o, /* @__PURE__ */ new Set()), l && t.get(o).add(l);
552
552
  }
553
553
  return Array.from(t.entries()).map(([s, a]) => {
554
554
  const r = new Set(
555
- T[s]?.availableRegions || []
555
+ U[s]?.availableRegions || []
556
556
  ), o = Array.from(a), l = Array.from(e).filter(
557
557
  (u) => r.has(u) && !o.includes(u)
558
558
  ), c = Array.from(/* @__PURE__ */ new Set([...o, ...l])).sort((u, g) => {
@@ -560,7 +560,7 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
560
560
  return d - h;
561
561
  });
562
562
  if (c.length === 0) {
563
- const u = Ee(s), [, g] = C(u);
563
+ const u = Re(s), [, g] = k(u);
564
564
  g && c.push(g);
565
565
  }
566
566
  return {
@@ -568,16 +568,16 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
568
568
  regions: c
569
569
  };
570
570
  });
571
- }, W = async (n) => {
571
+ }, H = async (n) => {
572
572
  const e = /* @__PURE__ */ new Map();
573
573
  for (const i of n) {
574
574
  if (i.source !== "json") continue;
575
- const [s] = C(i.language);
575
+ const [s] = k(i.language);
576
576
  e.has(s) || e.set(s, []), e.get(s).push(i);
577
577
  }
578
578
  const t = /* @__PURE__ */ new Map();
579
579
  for (const [i, s] of e.entries()) {
580
- const a = /* @__PURE__ */ new Map(), r = await je(i), o = /* @__PURE__ */ new Map();
580
+ const a = /* @__PURE__ */ new Map(), r = await De(i), o = /* @__PURE__ */ new Map();
581
581
  r.forEach((l, c) => {
582
582
  o.set(l.name.toLowerCase(), c), l.altNames?.forEach((u) => {
583
583
  o.set(u.toLowerCase(), c);
@@ -590,14 +590,14 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
590
590
  a.size > 0 && t.set(i, a);
591
591
  }
592
592
  return t;
593
- }, Si = {
593
+ }, Ei = {
594
594
  veryLow: 1,
595
595
  low: 2,
596
596
  normal: 3,
597
597
  high: 4,
598
598
  veryHigh: 5
599
- }, ve = (n) => n ? Si[n] ?? 0 : 0, G = (n, e, t, i) => {
600
- const s = ve(n.quality), a = ve(e.quality);
599
+ }, Se = (n) => n ? Ei[n] ?? 0 : 0, $ = (n, e, t, i) => {
600
+ const s = Se(n.quality), a = Se(e.quality);
601
601
  if (t && i && n.source === "json" && e.source === "json") {
602
602
  const r = t.get(i);
603
603
  if (r) {
@@ -607,38 +607,38 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
607
607
  }
608
608
  }
609
609
  return a !== s ? a - s : n.name.localeCompare(e.name);
610
- }, Ie = (n, e) => {
610
+ }, Pe = (n, e) => {
611
611
  const t = new Map(e.map((a) => [a.baseLang, a])), i = /* @__PURE__ */ new Map(), s = [];
612
612
  for (const a of n) {
613
- const [r] = C(a.language);
613
+ const [r] = k(a.language);
614
614
  t.get(r) ? (i.has(r) || i.set(r, []), i.get(r).push(a)) : s.push(a);
615
615
  }
616
616
  return { voicesByLang: i, otherLangVoices: s };
617
- }, ln = (n, e, t, i) => {
618
- const [, s] = C(n.language), [, a] = C(e.language), r = s && t.regions.includes(s), o = a && t.regions.includes(a);
617
+ }, un = (n, e, t, i) => {
618
+ const [, s] = k(n.language), [, a] = k(e.language), r = s && t.regions.includes(s), o = a && t.regions.includes(a);
619
619
  if (r && o) {
620
620
  const d = t.regions.indexOf(s), h = t.regions.indexOf(a);
621
- return d === h ? G(n, e, i, t.baseLang) : d - h;
621
+ return d === h ? $(n, e, i, t.baseLang) : d - h;
622
622
  }
623
623
  if (r) return -1;
624
624
  if (o) return 1;
625
- const l = Ee(t.baseLang), [, c] = C(l), u = !!c && s === c, g = !!c && a === c;
625
+ const l = Re(t.baseLang), [, c] = k(l), u = !!c && s === c, g = !!c && a === c;
626
626
  if (u && !g) return -1;
627
627
  if (!u && g) return 1;
628
628
  if (s && a) {
629
629
  const d = s.localeCompare(a);
630
- return d !== 0 ? d : G(n, e, i, t.baseLang);
631
- }
632
- return s ? -1 : a ? 1 : G(n, e, i, t.baseLang);
633
- }, bi = async (n, e, t) => {
634
- const i = t ?? await W(n);
635
- n.sort((s, a) => ln(s, a, e, i));
636
- }, cn = (n, e, t) => {
637
- const [i] = C(n.language), [s] = C(e.language), a = De(i).toLowerCase(), r = De(s).toLowerCase(), o = a.localeCompare(r);
630
+ return d !== 0 ? d : $(n, e, i, t.baseLang);
631
+ }
632
+ return s ? -1 : a ? 1 : $(n, e, i, t.baseLang);
633
+ }, Ri = async (n, e, t) => {
634
+ const i = t ?? await H(n);
635
+ n.sort((s, a) => un(s, a, e, i));
636
+ }, hn = (n, e, t) => {
637
+ const [i] = k(n.language), [s] = k(e.language), a = je(i).toLowerCase(), r = je(s).toLowerCase(), o = a.localeCompare(r);
638
638
  if (o !== 0)
639
639
  return o;
640
640
  if (i === s) {
641
- const l = Ee(i), [, c] = C(n.language), [, u] = C(e.language), g = l && c === l.split("-")[1], d = l && u === l.split("-")[1];
641
+ const l = Re(i), [, c] = k(n.language), [, u] = k(e.language), g = l && c === l.split("-")[1], d = l && u === l.split("-")[1];
642
642
  if (g && !d) return -1;
643
643
  if (!g && d) return 1;
644
644
  if (c && u) {
@@ -646,36 +646,36 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
646
646
  if (h !== 0)
647
647
  return h;
648
648
  }
649
- return c && !u ? -1 : !c && u ? 1 : G(n, e, t, i);
649
+ return c && !u ? -1 : !c && u ? 1 : $(n, e, t, i);
650
650
  }
651
- return G(n, e, t, i);
651
+ return $(n, e, t, i);
652
652
  }, Fe = async (n, e) => {
653
- const t = e ?? await W(n);
654
- n.sort((i, s) => cn(i, s, t));
655
- }, un = async (n, e) => {
653
+ const t = e ?? await H(n);
654
+ n.sort((i, s) => hn(i, s, t));
655
+ }, dn = async (n, e) => {
656
656
  if (!e?.length) return [];
657
- const t = Re(n || []), { voicesByLang: i, otherLangVoices: s } = Ie(e, t), a = await W(e), r = [];
657
+ const t = Ie(n || []), { voicesByLang: i, otherLangVoices: s } = Pe(e, t), a = await H(e), r = [];
658
658
  for (const o of t) {
659
659
  const l = i.get(o.baseLang);
660
- l && (await bi(l, o, a), r.push(...l));
660
+ l && (await Ri(l, o, a), r.push(...l));
661
661
  }
662
662
  return await Fe(s, a), r.push(...s), r;
663
- }, hn = async (n, e) => {
663
+ }, gn = async (n, e) => {
664
664
  if (!e.length) return null;
665
- const [t] = Re([n]), { voicesByLang: i, otherLangVoices: s } = Ie(e, [t]), a = i.get(t.baseLang), r = a?.length ? a : s, o = await W(e), l = a?.length ? (c, u) => ln(c, u, t, o) : (c, u) => cn(c, u, o);
665
+ const [t] = Ie([n]), { voicesByLang: i, otherLangVoices: s } = Pe(e, [t]), a = i.get(t.baseLang), r = a?.length ? a : s, o = await H(e), l = a?.length ? (c, u) => un(c, u, t, o) : (c, u) => hn(c, u, o);
666
666
  return r.reduce((c, u) => l(u, c) < 0 ? u : c);
667
667
  }, it = (n, e) => {
668
668
  const t = n.filter((i) => i.controls?.boundary !== !1 === e);
669
669
  return t.length > 0 ? t : n;
670
- }, wi = [{ 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 }], ki = {
671
- voices: wi
672
- }, Ci = [{ 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 }], Ei = {
673
- voices: Ci
674
- }, Ri = ki, Ii = Ei, _e = (n, e) => Ri.voices.some(
670
+ }, Ii = [{ 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 }], Pi = {
671
+ voices: Ii
672
+ }, Ai = [{ 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 }], Li = {
673
+ voices: Ai
674
+ }, Oi = Pi, Vi = Li, _e = (n, e) => Oi.voices.some(
675
675
  (t) => n.includes(t.name) || e && t.nativeID?.some((i) => e.includes(i)) || t.altNames?.some((i) => n.includes(i))
676
- ), $e = (n, e) => Ii.voices.some(
676
+ ), $e = (n, e) => Vi.voices.some(
677
677
  (t) => n.includes(t.name)
678
- ) || e === "veryLow", Pt = (n) => n?.length ? n.filter((e) => !(e.isNovelty || _e(e.name, e.voiceURI))) : [], At = (n) => n?.length ? n.filter((e) => !$e(e.name, e.quality)) : [], Pi = (n, e) => {
678
+ ) || e === "veryLow", At = (n) => n?.length ? n.filter((e) => !(e.isNovelty || _e(e.name, e.voiceURI))) : [], Lt = (n) => n?.length ? n.filter((e) => !$e(e.name, e.quality)) : [], xi = (n, e) => {
679
679
  const t = Array.isArray(e) ? e : [e];
680
680
  return n.filter((i) => t.some((s) => {
681
681
  const a = s.toLowerCase(), r = i.language?.toLowerCase(), o = i.altLanguage?.toLowerCase();
@@ -684,17 +684,17 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
684
684
  const [l] = a.split("-");
685
685
  return r && r.startsWith(l) || o && o.startsWith(l);
686
686
  }));
687
- }, Ai = { 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" } }, Li = {
688
- quality: Ai
687
+ }, Ui = { 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" } }, Ti = {
688
+ quality: Ui
689
689
  }, qe = {
690
- apple: Li.quality
690
+ apple: Ti.quality
691
691
  // android: androidQualities.quality
692
- }, Oi = (n, e, t) => {
692
+ }, zi = (n, e, t) => {
693
693
  if (!n) return;
694
694
  const i = Array.isArray(t) ? t : t ? [t] : [];
695
695
  for (const s of i)
696
696
  if (s && qe[s]) {
697
- const a = qe[s], r = C(e)[0], o = a[e] || a[r];
697
+ const a = qe[s], r = k(e)[0], o = a[e] || a[r];
698
698
  if (o) {
699
699
  const l = n.toLowerCase(), { normal: c, high: u } = o;
700
700
  if (u && l.includes(u.toLowerCase()))
@@ -703,7 +703,7 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
703
703
  return "normal";
704
704
  }
705
705
  }
706
- }, xi = (n, e) => {
706
+ }, Ni = (n, e) => {
707
707
  const t = qe[e];
708
708
  if (t)
709
709
  for (const [i, { high: s, normal: a }] of Object.entries(t)) {
@@ -711,7 +711,7 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
711
711
  if (r && o)
712
712
  return i;
713
713
  }
714
- }, Vi = {
714
+ }, Mi = {
715
715
  low: {
716
716
  values: ["super-compact", "compact"],
717
717
  quality: "low"
@@ -724,27 +724,27 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
724
724
  values: ["premium"],
725
725
  quality: "high"
726
726
  }
727
- }, Lt = (n) => {
727
+ }, Ot = (n) => {
728
728
  if (!n) return;
729
729
  const t = n.toLowerCase().split(/[._-]/);
730
- for (const i of Object.values(Vi))
730
+ for (const i of Object.values(Mi))
731
731
  if (i.values.some((s) => t.includes(s)))
732
732
  return i.quality;
733
733
  };
734
- function Ui(n, e) {
734
+ function Bi(n, e) {
735
735
  if (n.name === n.originalName) return n;
736
736
  if (e.name === e.originalName) return e;
737
737
  const t = [n.originalName, ...n.altNames || []], i = [e.originalName, ...e.altNames || []], s = t.findIndex((r) => i.includes(r)), a = i.findIndex((r) => t.includes(r));
738
738
  return s === -1 && a === -1 || s !== -1 && (a === -1 || s <= a) ? n : e;
739
739
  }
740
- function Ti(n, e) {
740
+ function Di(n, e) {
741
741
  if (!n.altNames && !e.altNames)
742
742
  return !1;
743
743
  const t = n.originalName, i = e.originalName, s = n.altNames || [], a = e.altNames || [];
744
744
  return a.includes(t) || s.includes(i) ? !0 : s.filter((o) => a.includes(o)).length > 0;
745
745
  }
746
- const dn = () => {
747
- const e = typeof window < "u" && (window.navigator || {}).userAgent || "", t = () => /android/i.test(e), i = () => /kaios/i.test(e), s = () => typeof window.InstallTrigger < "u" ? !0 : /firefox/i.test(e), a = () => typeof window.GestureEvent < "u" || /safari/i.test(e);
746
+ const fn = () => {
747
+ const e = typeof window < "u" && (window.navigator || {}).userAgent || "", t = () => /android/i.test(e), i = () => /kaios/i.test(e), s = () => typeof window.InstallTrigger < "u" ? !0 : /firefox/i.test(e), a = () => /AppleWebKit/i.test(e) && !/Chrome|Chromium|Edg\/|OPR|Android/i.test(e);
748
748
  return {
749
749
  isAndroid: t(),
750
750
  isFirefox: s() || i(),
@@ -752,7 +752,7 @@ const dn = () => {
752
752
  isKaiOS: i()
753
753
  };
754
754
  };
755
- class k {
755
+ class C {
756
756
  static instance;
757
757
  static initializationPromise = null;
758
758
  systemLocale;
@@ -766,7 +766,7 @@ class k {
766
766
  constructor() {
767
767
  if (typeof window > "u" || !window.speechSynthesis)
768
768
  throw new Error("Web Speech API is not available in this environment");
769
- this.systemLocale = navigator.languages?.[0]?.split("-")[0] || "en", this.isAndroid = dn().isAndroid;
769
+ this.systemLocale = navigator.languages?.[0]?.split("-")[0] || "en", this.isAndroid = fn().isAndroid;
770
770
  }
771
771
  /**
772
772
  * Initialize voice manager, or broaden an already-initialized singleton to
@@ -781,20 +781,20 @@ class k {
781
781
  * @returns Promise that resolves with the WebSpeechVoiceManager instance
782
782
  */
783
783
  static async initialize(e) {
784
- if (k.instance?.isInitialized) {
785
- const t = k.instance;
784
+ if (C.instance?.isInitialized) {
785
+ const t = C.instance;
786
786
  return e?.languages && e.languages.length > 0 && await t.broadenLanguages(e.languages), t;
787
787
  }
788
- return k.initializationPromise || (k.initializationPromise = (async () => {
788
+ return C.initializationPromise || (C.initializationPromise = (async () => {
789
789
  try {
790
- const t = new k();
791
- k.instance = t, t.browserVoices = await t.getBrowserVoices(e?.maxTimeout, e?.interval), t.updateSystemLocale(t.browserVoices);
790
+ const t = new C();
791
+ C.instance = t, t.browserVoices = await t.getBrowserVoices(e?.maxTimeout, e?.interval), t.updateSystemLocale(t.browserVoices);
792
792
  let i = t.browserVoices;
793
- return e?.languages && e.languages.length > 0 ? (i = t.filterBrowserVoicesByLanguages(t.browserVoices, e.languages), t.scopedLanguages = k.toBaseLangSet(e.languages)) : t.scopedLanguages = null, t.voices = await t.parseToReadiumSpeechVoices(i), t.isInitialized = !0, t;
793
+ return e?.languages && e.languages.length > 0 ? (i = t.filterBrowserVoicesByLanguages(t.browserVoices, e.languages), t.scopedLanguages = C.toBaseLangSet(e.languages)) : t.scopedLanguages = null, t.voices = await t.parseToReadiumSpeechVoices(i), t.isInitialized = !0, t;
794
794
  } catch (t) {
795
- throw k.initializationPromise = null, console.error("Failed to initialize WebSpeechVoiceManager:", t), t;
795
+ throw C.initializationPromise = null, console.error("Failed to initialize WebSpeechVoiceManager:", t), t;
796
796
  }
797
- })()), k.initializationPromise;
797
+ })()), C.initializationPromise;
798
798
  }
799
799
  /**
800
800
  * Filter browser voices based on preferred languages
@@ -802,10 +802,10 @@ class k {
802
802
  */
803
803
  filterBrowserVoicesByLanguages(e, t) {
804
804
  if (!t?.length) return e;
805
- const i = k.toBaseLangSet(t);
805
+ const i = C.toBaseLangSet(t);
806
806
  return e.filter((s) => {
807
807
  if (!s?.lang) return !1;
808
- const a = x(s.lang), [r] = k.extractLangRegionFromBCP47(a);
808
+ const a = V(s.lang), [r] = C.extractLangRegionFromBCP47(a);
809
809
  return i.has(r);
810
810
  });
811
811
  }
@@ -816,7 +816,7 @@ class k {
816
816
  static toBaseLangSet(e) {
817
817
  return new Set(
818
818
  e.map((t) => {
819
- const i = x(t), [s] = k.extractLangRegionFromBCP47(i);
819
+ const i = V(t), [s] = C.extractLangRegionFromBCP47(i);
820
820
  return s;
821
821
  })
822
822
  );
@@ -829,7 +829,7 @@ class k {
829
829
  */
830
830
  async broadenLanguages(e) {
831
831
  if (this.scopedLanguages === null) return;
832
- const i = [...k.toBaseLangSet(e)].filter((o) => !this.scopedLanguages.has(o));
832
+ const i = [...C.toBaseLangSet(e)].filter((o) => !this.scopedLanguages.has(o));
833
833
  if (i.length === 0) return;
834
834
  const s = i.filter((o) => this.broadenPromises.has(o)), a = i.filter((o) => !this.broadenPromises.has(o));
835
835
  let r;
@@ -847,7 +847,7 @@ class k {
847
847
  * @returns A tuple of [language, region] where language is lowercase and region is UPPERCASE
848
848
  */
849
849
  static extractLangRegionFromBCP47(e) {
850
- return C(e);
850
+ return k(e);
851
851
  }
852
852
  /**
853
853
  * Clean voice name by removing specific formatting
@@ -886,7 +886,7 @@ class k {
886
886
  */
887
887
  updateSystemLocale(e) {
888
888
  if (!e?.length) return;
889
- const t = e.map((s) => s.name), i = xi(t, "apple");
889
+ const t = e.map((s) => s.name), i = Ni(t, "apple");
890
890
  i && (this.systemLocale = i);
891
891
  }
892
892
  /**
@@ -895,15 +895,15 @@ class k {
895
895
  * @private
896
896
  */
897
897
  inferVoiceQuality(e, t, i) {
898
- const s = e.voiceURI ? Lt(e.voiceURI) : void 0;
898
+ const s = e.voiceURI ? Ot(e.voiceURI) : void 0;
899
899
  if (s) return s;
900
900
  if (t?.nativeID && Array.isArray(t.nativeID))
901
901
  for (const a of t.nativeID) {
902
- const r = Lt(a);
902
+ const r = Ot(a);
903
903
  if (r) return r;
904
904
  }
905
905
  if (t?.localizedName && e.voiceURI && e.lang) {
906
- const a = Oi(
906
+ const a = zi(
907
907
  e.voiceURI,
908
908
  this.systemLocale,
909
909
  t.localizedName
@@ -937,12 +937,12 @@ class k {
937
937
  const s = `${i.language.toLowerCase()}_${this.normalizeVoiceName(i.name)}`, a = t.get(s);
938
938
  if (!a)
939
939
  t.set(s, i);
940
- else if (Ti(i, a)) {
941
- const r = Ui(i, a);
940
+ else if (Di(i, a)) {
941
+ const r = Bi(i, a);
942
942
  t.set(s, r);
943
943
  } else {
944
- const r = ve(a.quality);
945
- ve(i.quality) >= r && t.set(s, i);
944
+ const r = Se(a.quality);
945
+ Se(i.quality) >= r && t.set(s, i);
946
946
  }
947
947
  }
948
948
  return Array.from(t.values());
@@ -954,11 +954,11 @@ class k {
954
954
  */
955
955
  getTestUtterance(e) {
956
956
  if (!e) return "";
957
- const t = It(e);
957
+ const t = Pt(e);
958
958
  if (t) return t;
959
- const [i] = k.extractLangRegionFromBCP47(e);
959
+ const [i] = C.extractLangRegionFromBCP47(e);
960
960
  if (i && i !== e) {
961
- const s = It(i);
961
+ const s = Pt(i);
962
962
  if (s) return s;
963
963
  }
964
964
  return "";
@@ -999,10 +999,10 @@ class k {
999
999
  countLanguages(e, t) {
1000
1000
  const i = /* @__PURE__ */ new Map();
1001
1001
  for (const s of e) {
1002
- const a = x(s).split("-")[0];
1002
+ const a = V(s).split("-")[0];
1003
1003
  i.set(a, (i.get(a) ?? 0) + 1);
1004
1004
  }
1005
- return [...i].map(([s, a]) => ({ code: s, label: De(s, t), count: a }));
1005
+ return [...i].map(([s, a]) => ({ code: s, label: je(s, t), count: a }));
1006
1006
  }
1007
1007
  /**
1008
1008
  * Get available regions with voice counts
@@ -1015,11 +1015,11 @@ class k {
1015
1015
  throw new Error("WebSpeechVoiceManager not initialized. Call initialize() first.");
1016
1016
  const s = i ?? this.voices, a = t ? this.filterVoices(t, s) : s, r = [], o = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
1017
1017
  for (const c of a) {
1018
- const [, u] = k.extractLangRegionFromBCP47(c.language);
1018
+ const [, u] = C.extractLangRegionFromBCP47(c.language);
1019
1019
  u && l.set(u, (l.get(u) || 0) + 1);
1020
1020
  }
1021
1021
  for (const c of a) {
1022
- const [, u] = k.extractLangRegionFromBCP47(c.language);
1022
+ const [, u] = C.extractLangRegionFromBCP47(c.language);
1023
1023
  if (u && !o.has(u)) {
1024
1024
  let g = c.language;
1025
1025
  try {
@@ -1082,9 +1082,9 @@ class k {
1082
1082
  const t = this.countVoiceDuplicates(e);
1083
1083
  return await Promise.all(
1084
1084
  e.filter((s) => s?.name && s?.lang).map(async (s) => {
1085
- const a = x(s.lang), [r] = k.extractLangRegionFromBCP47(a), o = this.normalizeVoiceName(s.name), l = `${s.lang.toLowerCase()}_${o}`, c = t.get(l) || 1;
1086
- let u = await je(a);
1087
- (!u || u.length === 0) && (u = await je(r));
1085
+ const a = V(s.lang), [r] = C.extractLangRegionFromBCP47(a), o = this.normalizeVoiceName(s.name), l = `${s.lang.toLowerCase()}_${o}`, c = t.get(l) || 1;
1086
+ let u = await De(a);
1087
+ (!u || u.length === 0) && (u = await De(r));
1088
1088
  const g = this.findMatchingJsonVoice(u, o), d = this.inferVoiceQuality(s, g, c), h = this.isAndroid ? { ...g?.controls, boundary: !1 } : g?.controls;
1089
1089
  return g ? {
1090
1090
  ...g,
@@ -1138,13 +1138,13 @@ class k {
1138
1138
  ...e
1139
1139
  // Let explicit options override the defaults
1140
1140
  };
1141
- if (s.languages && (i = Pi(i, s.languages)), s.source && (i = i.filter((a) => a.source === s.source)), s.gender && (i = i.filter((a) => a.gender === s.gender)), s.quality) {
1141
+ if (s.languages && (i = xi(i, s.languages)), s.source && (i = i.filter((a) => a.source === s.source)), s.gender && (i = i.filter((a) => a.gender === s.gender)), s.quality) {
1142
1142
  const a = Array.isArray(s.quality) ? s.quality : [s.quality];
1143
1143
  i = i.filter((r) => r.quality && a.includes(r.quality));
1144
1144
  }
1145
1145
  return s.offlineOnly && (i = i.filter((a) => a.offlineAvailability === !0)), s.provider && (i = i.filter(
1146
1146
  (a) => a.provider?.toLowerCase() === s.provider?.toLowerCase()
1147
- )), s.excludeNovelty && (i = Pt(i)), s.excludeVeryLowQuality && (i = At(i)), s.removeDuplicates && (i = this.removeDuplicates(i)), i;
1147
+ )), s.excludeNovelty && (i = At(i)), s.excludeVeryLowQuality && (i = Lt(i)), s.removeDuplicates && (i = this.removeDuplicates(i)), i;
1148
1148
  }
1149
1149
  /**
1150
1150
  * Filter out novelty voices
@@ -1153,7 +1153,7 @@ class k {
1153
1153
  */
1154
1154
  filterOutNoveltyVoices(e) {
1155
1155
  const t = e ?? this.voices;
1156
- return Pt(t);
1156
+ return At(t);
1157
1157
  }
1158
1158
  /**
1159
1159
  * Filter out very low quality voices
@@ -1162,7 +1162,7 @@ class k {
1162
1162
  */
1163
1163
  filterOutVeryLowQualityVoices(e) {
1164
1164
  const t = e ?? this.voices;
1165
- return At(t);
1165
+ return Lt(t);
1166
1166
  }
1167
1167
  /**
1168
1168
  * Sort voices by quality, respecting JSON name order, then alphabetically for undefined/null quality
@@ -1172,17 +1172,17 @@ class k {
1172
1172
  async sortVoicesByQuality(e) {
1173
1173
  const t = e || this.voices;
1174
1174
  if (!t?.length) return [];
1175
- const i = await W(t);
1176
- return [...t].sort((s, a) => G(s, a, i));
1175
+ const i = await H(t);
1176
+ return [...t].sort((s, a) => $(s, a, i));
1177
1177
  }
1178
1178
  /**
1179
1179
  * Sort regions by default then alphabetically, sort voices by quality
1180
1180
  */
1181
1181
  static async sortByDefaultRegion(e, t) {
1182
- const i = await W(e), s = Ee(t);
1182
+ const i = await H(e), s = Re(t);
1183
1183
  e.sort((a, r) => {
1184
- const [, o] = k.extractLangRegionFromBCP47(a.language), [, l] = k.extractLangRegionFromBCP47(r.language), c = s && o === s.split("-")[1], u = s && l === s.split("-")[1];
1185
- return c && !u ? -1 : !c && u ? 1 : G(a, r, i, t);
1184
+ const [, o] = C.extractLangRegionFromBCP47(a.language), [, l] = C.extractLangRegionFromBCP47(r.language), c = s && o === s.split("-")[1], u = s && l === s.split("-")[1];
1185
+ return c && !u ? -1 : !c && u ? 1 : $(a, r, i, t);
1186
1186
  });
1187
1187
  }
1188
1188
  /**
@@ -1198,10 +1198,10 @@ class k {
1198
1198
  const l = [...i];
1199
1199
  return await Fe(l), l;
1200
1200
  }
1201
- const s = Re(e), { voicesByLang: a, otherLangVoices: r } = Ie(i, s), o = [];
1201
+ const s = Ie(e), { voicesByLang: a, otherLangVoices: r } = Pe(i, s), o = [];
1202
1202
  for (const l of s) {
1203
1203
  const c = a.get(l.baseLang);
1204
- c && (await k.sortByDefaultRegion(c, l.baseLang), o.push(...c));
1204
+ c && (await C.sortByDefaultRegion(c, l.baseLang), o.push(...c));
1205
1205
  }
1206
1206
  return await Fe(r), o.push(...r), o;
1207
1207
  }
@@ -1212,7 +1212,7 @@ class k {
1212
1212
  * @returns Sorted array of voices
1213
1213
  */
1214
1214
  async sortVoicesByRegions(e, t) {
1215
- return un(e, t || this.voices);
1215
+ return dn(e, t || this.voices);
1216
1216
  }
1217
1217
  /**
1218
1218
  * Group voices by the specified criteria
@@ -1226,7 +1226,7 @@ class k {
1226
1226
  let r = "Unknown";
1227
1227
  switch (e) {
1228
1228
  case "languages":
1229
- r = k.extractLangRegionFromBCP47(a.language)[0];
1229
+ r = C.extractLangRegionFromBCP47(a.language)[0];
1230
1230
  break;
1231
1231
  case "gender":
1232
1232
  r = a.gender || "unknown";
@@ -1235,7 +1235,7 @@ class k {
1235
1235
  r = a.quality || "unknown";
1236
1236
  break;
1237
1237
  case "region":
1238
- const [, o] = k.extractLangRegionFromBCP47(a.language);
1238
+ const [, o] = C.extractLangRegionFromBCP47(a.language);
1239
1239
  r = o || "unknown";
1240
1240
  break;
1241
1241
  }
@@ -1244,10 +1244,10 @@ class k {
1244
1244
  return i;
1245
1245
  }
1246
1246
  }
1247
- const gn = (n, e) => {
1248
- const [t, i] = C(e), [s, a] = C(n.language);
1247
+ const pn = (n, e) => {
1248
+ const [t, i] = k(e), [s, a] = k(n.language);
1249
1249
  return s === t && (!i || a === i);
1250
- }, Ge = (n, e) => !!n && C(n.language)[0] === C(e)[0], zi = ["webKit", "moz", "ms", "o"], Ni = [
1250
+ }, Ge = (n, e) => !!n && k(n.language)[0] === k(e)[0], ji = ["webKit", "moz", "ms", "o"], Fi = [
1251
1251
  "boundary",
1252
1252
  "end",
1253
1253
  "error",
@@ -1255,10 +1255,10 @@ const gn = (n, e) => {
1255
1255
  "pause",
1256
1256
  "resume",
1257
1257
  "start"
1258
- ], Mi = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, te = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], Bi = (n) => typeof window < "u" && n in window, ji = (n) => {
1259
- const e = Mi(n), t = zi.map((s) => `${s}${e}`), i = [n, e].concat(t).find(Bi);
1258
+ ], _i = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, ne = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], $i = (n) => typeof window < "u" && n in window, qi = (n) => {
1259
+ const e = _i(n), t = ji.map((s) => `${s}${e}`), i = [n, e].concat(t).find($i);
1260
1260
  return i && typeof window < "u" ? window[i] : void 0;
1261
- }, Di = () => {
1261
+ }, Gi = () => {
1262
1262
  const n = {};
1263
1263
  [
1264
1264
  "speechSynthesis",
@@ -1267,15 +1267,15 @@ const gn = (n, e) => {
1267
1267
  "speechSynthesisEvent",
1268
1268
  "speechSynthesisErrorEvent"
1269
1269
  ].forEach((t) => {
1270
- n[t] = ji(t);
1271
- }), n.onvoiceschanged = te(n.speechSynthesis, "onvoiceschanged"), n.speechSynthesisSpeaking = te(n.speechSynthesis, "speaking"), n.speechSynthesisPaused = te(n.speechSynthesis, "paused");
1272
- const e = n.speechSynthesisUtterance ? te(n.speechSynthesisUtterance, "prototype") : !1;
1273
- return Ni.forEach((t) => {
1270
+ n[t] = qi(t);
1271
+ }), n.onvoiceschanged = ne(n.speechSynthesis, "onvoiceschanged"), n.speechSynthesisSpeaking = ne(n.speechSynthesis, "speaking"), n.speechSynthesisPaused = ne(n.speechSynthesis, "paused");
1272
+ const e = n.speechSynthesisUtterance ? ne(n.speechSynthesisUtterance, "prototype") : !1;
1273
+ return Fi.forEach((t) => {
1274
1274
  const i = `on${t}`;
1275
- n[i] = e && n.speechSynthesisUtterance ? te(n.speechSynthesisUtterance.prototype, i) : !1;
1275
+ n[i] = e && n.speechSynthesisUtterance ? ne(n.speechSynthesisUtterance.prototype, i) : !1;
1276
1276
  }), n;
1277
1277
  };
1278
- class Pe {
1278
+ class Ae {
1279
1279
  listeners = /* @__PURE__ */ new Map();
1280
1280
  on(e, t) {
1281
1281
  return this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t), () => {
@@ -1300,46 +1300,46 @@ class Pe {
1300
1300
  this.listeners.clear();
1301
1301
  }
1302
1302
  }
1303
- const me = (n, e) => Math.min(Math.max(n, 0), Math.max(e - 1, 0));
1304
- function H(n, e, t, i) {
1303
+ const ye = (n, e) => Math.min(Math.max(n, 0), Math.max(e - 1, 0));
1304
+ function q(n, e, t, i) {
1305
1305
  return Number.isFinite(n) ? Math.max(e, Math.min(t, n)) : i;
1306
1306
  }
1307
- const He = "\\p{Ps}\\p{Pi}¿¡", Fi = new RegExp(`^[${He}]`, "u"), _i = new RegExp("^\\p{P}$", "u");
1308
- function $i(n) {
1309
- return Fi.test(n);
1307
+ const He = "\\p{Ps}\\p{Pi}¿¡", Hi = new RegExp(`^[${He}]`, "u"), Ki = new RegExp("^\\p{P}$", "u");
1308
+ function Wi(n) {
1309
+ return Hi.test(n);
1310
1310
  }
1311
- function qi(n) {
1312
- return _i.test(n);
1311
+ function Qi(n) {
1312
+ return Ki.test(n);
1313
1313
  }
1314
- function fn(n) {
1314
+ function mn(n) {
1315
1315
  return n.replace(/[<>]/g, "​");
1316
1316
  }
1317
- function Gi(n) {
1317
+ function Ji(n) {
1318
1318
  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)));
1319
1319
  }
1320
- const Hi = /\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;
1321
- function Ki(n) {
1322
- return n.replace(Hi, (t, i, s) => {
1320
+ const Zi = /\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;
1321
+ function Xi(n) {
1322
+ return n.replace(Zi, (t, i, s) => {
1323
1323
  const a = s.slice(i + t.length);
1324
- return a.length === 0 || ue(a) ? "" : " ";
1324
+ return a.length === 0 || he(a) ? "" : " ";
1325
1325
  }).replace(/ {2,}/g, " ").trim();
1326
1326
  }
1327
- function Wi(n) {
1327
+ function Yi(n) {
1328
1328
  return n.includes("<");
1329
1329
  }
1330
1330
  function st(n) {
1331
1331
  if (n === void 0) return;
1332
1332
  const e = {};
1333
1333
  if (n.language !== void 0 && (e.language = n.language), n.ssml) {
1334
- const t = Ki(n.ssml);
1335
- Wi(t) && (e.ssml = t);
1334
+ const t = Xi(n.ssml);
1335
+ Yi(t) && (e.ssml = t);
1336
1336
  }
1337
1337
  return n.plain && (e.plain = n.plain), e.plain || e.ssml ? e : void 0;
1338
1338
  }
1339
- function M(n) {
1340
- return pn(n).plain;
1339
+ function N(n) {
1340
+ return vn(n).plain;
1341
1341
  }
1342
- function pn(n) {
1342
+ function vn(n) {
1343
1343
  let e = "";
1344
1344
  const t = [];
1345
1345
  let i = !1, s = 0;
@@ -1347,7 +1347,7 @@ function pn(n) {
1347
1347
  const o = n[s];
1348
1348
  if (o === "<") {
1349
1349
  const c = n.indexOf(">", s), u = c === -1 ? "" : n.slice(c + 1);
1350
- s = c === -1 ? n.length : c + 1, !i && e.length > 0 && u.length > 0 && !ue(u) && (e += " ", t.push(s), i = !0);
1350
+ s = c === -1 ? n.length : c + 1, !i && e.length > 0 && u.length > 0 && !he(u) && (e += " ", t.push(s), i = !0);
1351
1351
  continue;
1352
1352
  }
1353
1353
  const l = n.startsWith("&lt;", s) ? "<" : n.startsWith("&gt;", s) ? ">" : n.startsWith("&amp;", s) ? "&" : void 0;
@@ -1367,7 +1367,7 @@ function pn(n) {
1367
1367
  for (; r > a && /\s/.test(e[r - 1]); ) r--;
1368
1368
  return { plain: e.slice(a, r), map: t.slice(a, r) };
1369
1369
  }
1370
- function Ot(n, e) {
1370
+ function Vt(n, e) {
1371
1371
  let t = 0, i = n.length;
1372
1372
  for (; t < i; ) {
1373
1373
  const s = t + i >> 1;
@@ -1376,26 +1376,26 @@ function Ot(n, e) {
1376
1376
  return t;
1377
1377
  }
1378
1378
  const xt = /* @__PURE__ */ new WeakMap();
1379
- function Qi(n) {
1379
+ function es(n) {
1380
1380
  return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1381
1381
  }
1382
- function Ji(n) {
1383
- const e = Qi(n), t = /\w/.test(n[0]) ? "(?<!\\w)" : "", i = /\w/.test(n[n.length - 1]) ? "(?!\\w)" : "";
1382
+ function ts(n) {
1383
+ const e = es(n), t = /\w/.test(n[0]) ? "(?<!\\w)" : "", i = /\w/.test(n[n.length - 1]) ? "(?!\\w)" : "";
1384
1384
  return `${t}${e}${i}`;
1385
1385
  }
1386
- function Zi(n, e) {
1386
+ function ns(n, e) {
1387
1387
  if (typeof e == "string")
1388
- return { regex: new RegExp(Ji(n), "g"), replace: e };
1388
+ return { regex: new RegExp(ts(n), "g"), replace: e };
1389
1389
  const t = e.pattern.flags.includes("g") ? e.pattern.flags : `${e.pattern.flags}g`;
1390
1390
  return { regex: new RegExp(e.pattern.source, t), replace: e.replace };
1391
1391
  }
1392
- function Xi(n) {
1392
+ function is(n) {
1393
1393
  let e = xt.get(n);
1394
- return e || (e = Object.entries(n).map(([t, i]) => Zi(t, i)), xt.set(n, e)), e;
1394
+ return e || (e = Object.entries(n).map(([t, i]) => ns(t, i)), xt.set(n, e)), e;
1395
1395
  }
1396
- function mn(n, e) {
1396
+ function yn(n, e) {
1397
1397
  const t = [];
1398
- for (const a of Xi(e))
1398
+ for (const a of is(e))
1399
1399
  for (const r of n.matchAll(a.regex)) {
1400
1400
  const o = r.index, l = typeof a.replace == "string" ? a.replace : a.replace(...r);
1401
1401
  t.push({ start: o, end: o + r[0].length, replacement: l });
@@ -1407,11 +1407,11 @@ function mn(n, e) {
1407
1407
  a.start < s || (i.push(a), s = a.end);
1408
1408
  return i;
1409
1409
  }
1410
- function Yi(n, e) {
1410
+ function ss(n, e) {
1411
1411
  let t = "";
1412
1412
  const i = [];
1413
1413
  let s = 0;
1414
- for (const a of mn(n, e)) {
1414
+ for (const a of yn(n, e)) {
1415
1415
  for (; s < a.start; )
1416
1416
  t += n[s], i.push(s), s++;
1417
1417
  for (let r = 0; r < a.replacement.length; r++)
@@ -1422,34 +1422,34 @@ function Yi(n, e) {
1422
1422
  t += n[s], i.push(s), s++;
1423
1423
  return { text: t, map: i };
1424
1424
  }
1425
- function Vt(n, e) {
1425
+ function Ut(n, e) {
1426
1426
  return n.length ? e <= 0 ? n[0] : e >= n.length ? n[n.length - 1] + 1 : n[e] : e;
1427
1427
  }
1428
- const es = /<([a-zA-Z][\w-]*)([^>]*)>([\s\S]*?)<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1429
- function Ut(n) {
1428
+ const as = /<([a-zA-Z][\w-]*)([^>]*)>([\s\S]*?)<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1429
+ function Tt(n) {
1430
1430
  return n.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
1431
1431
  }
1432
- function vn(n) {
1432
+ function Sn(n) {
1433
1433
  const e = [];
1434
- for (const t of n.matchAll(es))
1435
- 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]) });
1434
+ for (const t of n.matchAll(as))
1435
+ t[1] !== void 0 ? e.push({ kind: "paired", raw: t[0], tag: t[1], attrs: t[2], innerText: Tt(t[3]) }) : t[0][0] === "<" ? e.push({ kind: "selfClosing", raw: t[0] }) : e.push({ kind: "text", raw: t[0], text: Tt(t[0]) });
1436
1436
  return e;
1437
1437
  }
1438
- function ts(n, e) {
1439
- const t = vn(n);
1438
+ function rs(n, e) {
1439
+ const t = Sn(n);
1440
1440
  let i = "", s = !1;
1441
1441
  const a = [], r = t.map(() => []);
1442
1442
  t.forEach((b, P) => {
1443
1443
  if (b.kind === "selfClosing") return;
1444
1444
  const A = b.kind === "paired" ? b.innerText : b.text;
1445
- if (!s && i.length > 0 && A.length > 0 && !ue(A) && !/^\s/.test(A)) {
1445
+ if (!s && i.length > 0 && A.length > 0 && !he(A) && !/^\s/.test(A)) {
1446
1446
  const I = i.length;
1447
1447
  i += " ", r[P].push(a.length), a.push({ start: I, end: I + 1, atomIndex: -1 }), s = !0;
1448
1448
  }
1449
1449
  const E = i.length;
1450
1450
  i += A, r[P].push(a.length), a.push({ start: E, end: i.length, atomIndex: P }), A.length > 0 && (s = /\s$/.test(A));
1451
1451
  });
1452
- const o = mn(i, e);
1452
+ const o = yn(i, e);
1453
1453
  let l = "", c = "";
1454
1454
  const u = [];
1455
1455
  let g = -2, d = "", h = 0;
@@ -1472,19 +1472,19 @@ function ts(n, e) {
1472
1472
  for (; I < E.end; ) {
1473
1473
  const R = h < o.length ? o[h] : void 0;
1474
1474
  if (R && R.start <= I && R.end > I) {
1475
- const U = R.start === I, F = R.end > E.end;
1476
- if (U) {
1475
+ const B = R.start === I, ee = R.end > E.end;
1476
+ if (B) {
1477
1477
  c += R.replacement;
1478
- for (let _ = 0; _ < R.replacement.length; _++) u.push(R.start);
1479
- E.atomIndex === -1 || F ? (f(), l += z(R.replacement)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += z(R.replacement));
1478
+ for (let D = 0; D < R.replacement.length; D++) u.push(R.start);
1479
+ E.atomIndex === -1 || ee ? (f(), l += T(R.replacement)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += T(R.replacement));
1480
1480
  }
1481
1481
  I = Math.min(R.end, E.end), R.end <= E.end && h++;
1482
1482
  continue;
1483
1483
  }
1484
- const xe = R ? Math.min(R.start, E.end) : E.end, D = i.slice(I, xe);
1485
- c += D;
1486
- for (let U = 0; U < D.length; U++) u.push(I + U);
1487
- E.atomIndex === -1 ? (f(), l += z(D)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += z(D)), I = xe;
1484
+ const X = R ? Math.min(R.start, E.end) : E.end, Y = i.slice(I, X);
1485
+ c += Y;
1486
+ for (let B = 0; B < Y.length; B++) u.push(I + B);
1487
+ E.atomIndex === -1 ? (f(), l += T(Y)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += T(Y)), I = X;
1488
1488
  }
1489
1489
  }
1490
1490
  }
@@ -1500,24 +1500,24 @@ function ts(n, e) {
1500
1500
  const w = i.slice(p, m), y = u.slice(S, v).map((b) => Math.min(Math.max(b - p, 0), Math.max(w.length - 1, 0)));
1501
1501
  return { ssml: l, plain: w, map: y };
1502
1502
  }
1503
- const yn = /<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;
1504
- function Sn(n) {
1505
- return new RegExp(yn).test(n);
1503
+ const bn = /<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;
1504
+ function wn(n) {
1505
+ return new RegExp(bn).test(n);
1506
1506
  }
1507
- function Tt(n) {
1507
+ function zt(n) {
1508
1508
  return n.replace(/<[^>]+>/g, "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/ {2,}/g, " ");
1509
1509
  }
1510
- const ns = new RegExp(
1511
- `\\s+|[${He}]+|[${ie}]+|[^\\s${He}${ie}]+`,
1510
+ const os = new RegExp(
1511
+ `\\s+|[${He}]+|[${se}]+|[^\\s${He}${se}]+`,
1512
1512
  "gu"
1513
1513
  );
1514
1514
  function Ue(n) {
1515
1515
  const e = [];
1516
- for (const [t] of n.matchAll(ns))
1517
- /^\s/.test(t) ? e.push({ kind: "space" }) : $i(t) ? e.push({ kind: "open", text: t }) : ue(t) ? e.push({ kind: "close", text: t }) : e.push({ kind: "word", text: t });
1516
+ for (const [t] of n.matchAll(os))
1517
+ /^\s/.test(t) ? e.push({ kind: "space" }) : Wi(t) ? e.push({ kind: "open", text: t }) : he(t) ? e.push({ kind: "close", text: t }) : e.push({ kind: "word", text: t });
1518
1518
  return e;
1519
1519
  }
1520
- function is(n) {
1520
+ function ls(n) {
1521
1521
  let e = "", t = !1;
1522
1522
  for (const i of n) {
1523
1523
  if (i.kind === "space") {
@@ -1528,12 +1528,12 @@ function is(n) {
1528
1528
  }
1529
1529
  return e;
1530
1530
  }
1531
- function ss(n) {
1531
+ function cs(n) {
1532
1532
  let e = n.length;
1533
1533
  for (; e > 0 && (n[e - 1].kind === "space" || n[e - 1].kind === "open"); ) e--;
1534
1534
  return n.slice(e).some((t) => t.kind === "open") ? n.splice(e) : [];
1535
1535
  }
1536
- function as(n) {
1536
+ function us(n) {
1537
1537
  let e = 0;
1538
1538
  for (; e < n.length && (n[e].kind === "space" || n[e].kind === "close"); ) e++;
1539
1539
  return n.slice(0, e).some((t) => t.kind === "close") ? n.splice(0, e) : [];
@@ -1541,42 +1541,43 @@ function as(n) {
1541
1541
  function at(n, e) {
1542
1542
  const t = [];
1543
1543
  let i = 0;
1544
- for (const r of n.matchAll(yn))
1544
+ for (const r of n.matchAll(bn))
1545
1545
  t.push({
1546
- tokens: Ue(Tt(n.slice(i, r.index))),
1546
+ tokens: Ue(zt(n.slice(i, r.index))),
1547
1547
  language: e,
1548
1548
  tagged: !1
1549
- }), t.push({ tokens: Ue(M(r[2])), language: r[1], tagged: !0 }), i = r.index + r[0].length;
1549
+ }), t.push({ tokens: Ue(N(r[2])), language: r[1], tagged: !0 }), i = r.index + r[0].length;
1550
1550
  t.push({
1551
- tokens: Ue(Tt(n.slice(i))),
1551
+ tokens: Ue(zt(n.slice(i))),
1552
1552
  language: e,
1553
1553
  tagged: !1
1554
1554
  });
1555
1555
  for (let r = 0; r < t.length - 1; r++)
1556
- !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(...as(t[r + 1].tokens));
1556
+ !t[r].tagged && t[r + 1].tagged ? t[r + 1].tokens.unshift(...cs(t[r].tokens)) : t[r].tagged && !t[r + 1].tagged && t[r].tokens.push(...us(t[r + 1].tokens));
1557
1557
  const s = [];
1558
1558
  let a = 0;
1559
1559
  for (const r of t) {
1560
- const o = is(r.tokens);
1560
+ const o = ls(r.tokens);
1561
1561
  o && (s.push({ plain: o, language: r.language, start: a, end: a + o.length }), a += o.length);
1562
1562
  }
1563
1563
  return s;
1564
1564
  }
1565
- const bn = /<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;
1566
- function rs(n) {
1567
- return new RegExp(bn).test(n);
1565
+ const kn = /<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;
1566
+ function hs(n) {
1567
+ return new RegExp(kn).test(n);
1568
1568
  }
1569
- function os(n) {
1569
+ function ds(n) {
1570
1570
  const e = [];
1571
1571
  let t = 0;
1572
- for (const s of n.matchAll(bn)) {
1572
+ for (const s of n.matchAll(kn)) {
1573
1573
  const a = n.slice(t, s.index).trim();
1574
1574
  a && e.push({ ssml: a }), e.push({ placeholderId: s[1] }), t = s.index + s[0].length;
1575
1575
  }
1576
1576
  const i = n.slice(t).trim();
1577
1577
  return i && e.push({ ssml: i }), e;
1578
1578
  }
1579
- class zt {
1579
+ const gs = 250;
1580
+ class Nt {
1580
1581
  speechSynthesis;
1581
1582
  speechSynthesisUtterance;
1582
1583
  currentVoice = null;
@@ -1585,7 +1586,7 @@ class zt {
1585
1586
  currentUtterances = [];
1586
1587
  currentUtteranceIndex = 0;
1587
1588
  playbackState = "idle";
1588
- events = new Pe();
1589
+ events = new Ae();
1589
1590
  voiceManager = null;
1590
1591
  defaultVoice = null;
1591
1592
  // Keyed by `${language}:${needsBoundary}` — the boundary requirement rides in the key
@@ -1608,6 +1609,8 @@ class zt {
1608
1609
  maxLengthExceeded = "warn";
1609
1610
  utterancesBeingCancelled = !1;
1610
1611
  // Flag to track if utterances are being cancelled
1612
+ lastCancelAt = -1 / 0;
1613
+ // Safari: when cancel() last stopped speech
1611
1614
  lacksNativePauseEvents = !1;
1612
1615
  // Google and Chrome OS voices never fire onpause/onresume
1613
1616
  // Playback parameters
@@ -1617,16 +1620,17 @@ class zt {
1617
1620
  features;
1618
1621
  patches;
1619
1622
  constructor() {
1620
- if (this.features = Di(), this.patches = dn(), !this.features.speechSynthesis || !this.features.speechSynthesisUtterance)
1623
+ if (this.features = Gi(), this.patches = fn(), !this.features.speechSynthesis || !this.features.speechSynthesisUtterance)
1621
1624
  throw new Error("Web Speech API is not available in this environment");
1622
1625
  this.speechSynthesis = this.features.speechSynthesis, this.speechSynthesisUtterance = this.features.speechSynthesisUtterance;
1623
1626
  }
1624
1627
  // From Easy Speech,
1625
1628
  // Check infinity pattern for long texts (except on problematic platforms)
1626
1629
  // Skip resume infinity for Microsoft Natural voices as they have different behavior
1630
+ // Only for voices without pause events (Chrome's Google voices, which cut off long texts): others would report each pause/resume
1627
1631
  shouldUseResumeInfinity() {
1628
1632
  const e = this.speakingVoice ?? this.currentVoice, t = !!(e?.name && typeof e.name == "string" && e.name.toLocaleLowerCase().includes("(natural)"));
1629
- return this.patches.isAndroid !== !0 && !this.patches.isFirefox && !this.patches.isSafari && !t;
1633
+ return this.patches.isAndroid !== !0 && !this.patches.isFirefox && !this.patches.isSafari && !t && this.lacksNativePauseEvents;
1630
1634
  }
1631
1635
  // Creates a new SpeechSynthesisUtterance using detected constructor
1632
1636
  createUtterance(e) {
@@ -1638,7 +1642,7 @@ class zt {
1638
1642
  return !1;
1639
1643
  this.maxLengthExceeded = a;
1640
1644
  try {
1641
- this.voiceManager = await k.initialize({
1645
+ this.voiceManager = await C.initialize({
1642
1646
  languages: t,
1643
1647
  maxTimeout: i,
1644
1648
  interval: s
@@ -1692,7 +1696,7 @@ class zt {
1692
1696
  const i = this.getCurrentVoiceForUtterance(this.currentVoice);
1693
1697
  if (!e.language)
1694
1698
  return i;
1695
- const s = x(e.language);
1699
+ const s = V(e.language);
1696
1700
  if (Ge(i, s))
1697
1701
  return i;
1698
1702
  const a = i?.controls?.boundary !== !1, r = this.languageCacheKey(s, a);
@@ -1707,7 +1711,7 @@ class zt {
1707
1711
  return t;
1708
1712
  const i = this.unloadedOwnVoiceLanguage(e);
1709
1713
  if (i) {
1710
- await k.initialize({ languages: [i] }), this.loadedOwnVoiceLanguages.add(i);
1714
+ await C.initialize({ languages: [i] }), this.loadedOwnVoiceLanguages.add(i);
1711
1715
  const s = this.voiceForUtteranceSync(e);
1712
1716
  if (s !== void 0) return s;
1713
1717
  }
@@ -1719,11 +1723,11 @@ class zt {
1719
1723
  if (!this.voiceManager)
1720
1724
  return;
1721
1725
  const t = this.getCurrentVoiceForUtterance(this.currentVoice), i = t?.controls?.boundary !== !1, s = new Set(
1722
- e.filter((l) => !this.ownVoice(l)).map((l) => l.language).filter((l) => !!l).map((l) => x(l)).filter((l) => !Ge(t, l)).filter((l) => !this.languageVoiceCache.has(this.languageCacheKey(l, i)))
1726
+ e.filter((l) => !this.ownVoice(l)).map((l) => l.language).filter((l) => !!l).map((l) => V(l)).filter((l) => !Ge(t, l)).filter((l) => !this.languageVoiceCache.has(this.languageCacheKey(l, i)))
1723
1727
  ), a = [...s].filter((l) => this.warmingLanguages.has(this.languageCacheKey(l, i))), o = [...s].filter((l) => !this.warmingLanguages.has(this.languageCacheKey(l, i))).map((l) => {
1724
1728
  const c = this.languageCacheKey(l, i), u = (async () => {
1725
- await k.initialize({ languages: [l] });
1726
- const g = this.voices.filter((p) => gn(p, l)), d = it(g, i), f = (await this.voiceManager.sortVoicesByQuality(d))[0] ?? null;
1729
+ await C.initialize({ languages: [l] });
1730
+ const g = this.voices.filter((p) => pn(p, l)), d = it(g, i), f = (await this.voiceManager.sortVoicesByQuality(d))[0] ?? null;
1727
1731
  this.languageVoiceCache.set(c, f), f || this.emitEvent({ type: "languagefallback", detail: { language: l, reason: "no-matching-voice" } });
1728
1732
  })();
1729
1733
  return this.warmingLanguages.set(c, u.finally(() => this.warmingLanguages.delete(c))), this.warmingLanguages.get(c);
@@ -1743,12 +1747,12 @@ class zt {
1743
1747
  toPlainText(e) {
1744
1748
  return e.map((t) => ({
1745
1749
  ...t,
1746
- plain: t.plain ?? (t.ssml ? M(Gi(t.ssml)) : "")
1750
+ plain: t.plain ?? (t.ssml ? N(Ji(t.ssml)) : "")
1747
1751
  }));
1748
1752
  }
1749
1753
  // Queue Management
1750
1754
  loadUtterances(e, t) {
1751
- this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex = me(t ?? 0, e.length), this.warmLanguageVoiceCache(this.currentUtterances), this.playbackState = "ready", this.emitEvent({ type: "ready" });
1755
+ this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex = ye(t ?? 0, e.length), this.warmLanguageVoiceCache(this.currentUtterances), this.playbackState = "ready", this.emitEvent({ type: "ready" });
1752
1756
  }
1753
1757
  // Voice Configuration
1754
1758
  async setVoice(e) {
@@ -1784,71 +1788,103 @@ class zt {
1784
1788
  console.warn("No utterances loaded");
1785
1789
  return;
1786
1790
  }
1787
- this.cancelCurrentSpeech();
1791
+ this.patches.isSafari && this.speakGeneration++, this.cancelCurrentSpeech();
1788
1792
  const t = ++this.speakGeneration;
1789
- this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length && (this.currentUtteranceIndex = 0), this.speakCurrentUtterance(t);
1793
+ this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length && (this.currentUtteranceIndex = 0);
1794
+ const i = this.lastCancelAt + gs - Date.now();
1795
+ if (this.patches.isSafari && i > 0) {
1796
+ this.speakNextTask(t, 1, i);
1797
+ return;
1798
+ }
1799
+ this.speakCurrentUtterance(t);
1790
1800
  }
1791
1801
  cancelCurrentSpeech() {
1792
1802
  this.patches.isFirefox && this.speechSynthesis.speaking && (this.utterancesBeingCancelled = !0, setTimeout(() => {
1793
1803
  this.utterancesBeingCancelled = !1;
1794
- }, 100)), this.speechSynthesis.cancel();
1804
+ }, 100)), this.patches.isSafari && this.speechSynthesis.speaking && (this.lastCancelAt = Date.now()), this.speechSynthesis.cancel();
1805
+ }
1806
+ // Safari: `unstartedRetries` is how many more times to speak it if Safari ends it without starting it, as it can right after cancel()
1807
+ speakNextTask(e, t, i = 0) {
1808
+ setTimeout(() => {
1809
+ if (e === this.speakGeneration) {
1810
+ if (this.playbackState === "paused") {
1811
+ this.pausedAtUtteranceIndex = null;
1812
+ return;
1813
+ }
1814
+ this.playbackState === "playing" && this.speakCurrentUtterance(e, t);
1815
+ }
1816
+ }, i);
1795
1817
  }
1796
- async speakCurrentUtterance(e) {
1818
+ async speakCurrentUtterance(e, t) {
1797
1819
  if (this.currentUtteranceIndex >= this.currentUtterances.length) {
1798
1820
  this.setState("idle"), this.emitEvent({ type: "end" });
1799
1821
  return;
1800
1822
  }
1801
- const t = this.currentUtterances[this.currentUtteranceIndex], i = t.plain ?? "";
1802
- this.validateText(i);
1803
- const s = this.createUtterance(fn(i)), a = await this.voiceForUtterance(t);
1804
- if (e === this.speakGeneration) {
1805
- if (this.lacksNativePauseEvents = !1, this.speakingVoice = a, a && this.voiceManager) {
1806
- const r = this.voiceManager.convertToSpeechSynthesisVoice(a);
1807
- r && (s.voice = r, s.lang = r.lang, this.lacksNativePauseEvents = r.name.startsWith("Google") || r.name.startsWith("Chrome OS"));
1823
+ const i = this.currentUtterances[this.currentUtteranceIndex], s = i.plain ?? "";
1824
+ this.validateText(s);
1825
+ const a = this.createUtterance(mn(s)), r = await this.voiceForUtterance(i);
1826
+ if (e !== this.speakGeneration)
1827
+ return;
1828
+ if (this.lacksNativePauseEvents = !1, this.speakingVoice = r, r && this.voiceManager) {
1829
+ const l = this.voiceManager.convertToSpeechSynthesisVoice(r);
1830
+ l && (a.voice = l, a.lang = l.lang, this.lacksNativePauseEvents = l.name.startsWith("Google") || l.name.startsWith("Chrome OS"));
1831
+ }
1832
+ i.language && (a.lang = i.language), a.rate = this.rate, a.pitch = this.pitch, a.volume = this.volume;
1833
+ let o = !1;
1834
+ a.onstart = () => {
1835
+ if (o = !0, e !== this.speakGeneration) return;
1836
+ this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.emitEvent({ type: "start", detail: { voice: r } }), this.patches.isAndroid && this.isAndroidPaused && (this.isAndroidPaused = !1), this.shouldUseResumeInfinity() && this.startResumeInfinity(a);
1837
+ }, a.onend = () => {
1838
+ if (this.utterancesBeingCancelled) {
1839
+ this.utterancesBeingCancelled = !1;
1840
+ return;
1808
1841
  }
1809
- t.language && (s.lang = t.language), s.rate = this.rate, s.pitch = this.pitch, s.volume = this.volume, s.onstart = () => {
1810
- if (e !== this.speakGeneration) return;
1811
- this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.emitEvent({ type: "start", detail: { voice: a } }), this.patches.isAndroid && this.isAndroidPaused && (this.isAndroidPaused = !1), this.shouldUseResumeInfinity() && this.startResumeInfinity(s);
1812
- }, s.onend = () => {
1813
- if (this.utterancesBeingCancelled) {
1814
- this.utterancesBeingCancelled = !1;
1815
- return;
1816
- }
1817
- 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" }));
1818
- }, s.onerror = (r) => {
1819
- if (e !== this.speakGeneration || r.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
1820
- return;
1821
- 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({
1822
- type: "error",
1823
- detail: {
1824
- error: r.error,
1825
- // Preserve original error type
1826
- message: `Speech synthesis error: ${r.error}`
1827
- }
1828
- });
1829
- }, s.onpause = () => {
1830
- e === this.speakGeneration && (this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" }));
1831
- }, s.onresume = () => {
1832
- e === this.speakGeneration && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" }));
1833
- }, s.onboundary = (r) => {
1834
- e === this.speakGeneration && this.emitEvent({
1835
- type: "boundary",
1836
- detail: {
1837
- charIndex: r.charIndex,
1838
- charLength: r.charLength,
1839
- elapsedTime: r.elapsedTime,
1840
- name: r.name
1842
+ if (e === this.speakGeneration && this.playbackState !== "idle") {
1843
+ if (t !== void 0 && !o) {
1844
+ if (this.playbackState === "paused") {
1845
+ this.pausedAtUtteranceIndex = null;
1846
+ return;
1841
1847
  }
1842
- });
1843
- }, s.onmark = (r) => {
1844
- e === this.speakGeneration && this.emitEvent({
1845
- type: "mark",
1846
- detail: {
1847
- name: r.name
1848
+ if (this.playbackState === "playing" && t > 0) {
1849
+ this.speakNextTask(e, t - 1);
1850
+ return;
1848
1851
  }
1849
- });
1850
- }, this.speechSynthesis.speak(s);
1851
- }
1852
+ }
1853
+ this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length - 1 && this.setState("idle"), this.emitEvent({ type: "end" });
1854
+ }
1855
+ }, a.onerror = (l) => {
1856
+ if (e !== this.speakGeneration || l.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
1857
+ return;
1858
+ this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.setState("idle"), ["synthesis-unavailable", "audio-hardware", "voice-unavailable"].includes(l.error) && (console.log("[ENGINE] fatal error detected, resetting index to 0"), this.currentUtteranceIndex = 0), l.error === "interrupted" || l.error === "canceled" ? this.emitEvent({ type: "stop" }) : this.emitEvent({
1859
+ type: "error",
1860
+ detail: {
1861
+ error: l.error,
1862
+ // Preserve original error type
1863
+ message: `Speech synthesis error: ${l.error}`
1864
+ }
1865
+ });
1866
+ }, a.onpause = () => {
1867
+ e === this.speakGeneration && (this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" }));
1868
+ }, a.onresume = () => {
1869
+ e === this.speakGeneration && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" }));
1870
+ }, a.onboundary = (l) => {
1871
+ e === this.speakGeneration && this.emitEvent({
1872
+ type: "boundary",
1873
+ detail: {
1874
+ charIndex: l.charIndex,
1875
+ charLength: l.charLength,
1876
+ elapsedTime: l.elapsedTime,
1877
+ name: l.name
1878
+ }
1879
+ });
1880
+ }, a.onmark = (l) => {
1881
+ e === this.speakGeneration && this.emitEvent({
1882
+ type: "mark",
1883
+ detail: {
1884
+ name: l.name
1885
+ }
1886
+ });
1887
+ }, this.speechSynthesis.speak(a);
1852
1888
  }
1853
1889
  startResumeInfinity(e) {
1854
1890
  this.shouldUseResumeInfinity() && (this.resumeInfinityTimer = window.setTimeout(() => {
@@ -1873,21 +1909,21 @@ class zt {
1873
1909
  }
1874
1910
  // Playback Parameters
1875
1911
  setRate(e) {
1876
- const t = H(e, 0.1, 10, this.rate);
1912
+ const t = q(e, 0.1, 10, this.rate);
1877
1913
  t !== this.rate && (this.rate = t, this.scheduleRestartIfSpeaking());
1878
1914
  }
1879
1915
  getRate() {
1880
1916
  return this.rate;
1881
1917
  }
1882
1918
  setPitch(e) {
1883
- const t = H(e, 0, 2, this.pitch);
1919
+ const t = q(e, 0, 2, this.pitch);
1884
1920
  t !== this.pitch && (this.pitch = t, this.scheduleRestartIfSpeaking());
1885
1921
  }
1886
1922
  getPitch() {
1887
1923
  return this.pitch;
1888
1924
  }
1889
1925
  setVolume(e) {
1890
- const t = H(e, 0, 1, this.volume);
1926
+ const t = q(e, 0, 1, this.volume);
1891
1927
  t !== this.volume && (this.volume = t, this.scheduleRestartIfSpeaking());
1892
1928
  }
1893
1929
  getVolume() {
@@ -1952,27 +1988,27 @@ class zt {
1952
1988
  this.stop(), this.stopResumeInfinity(), this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.speakingVoice = null, this.voiceManager = null, this.defaultVoice = null, this.languageVoiceCache.clear(), this.warmingLanguages.clear(), this.initialized = !1;
1953
1989
  }
1954
1990
  }
1955
- class Wa {
1991
+ class tr {
1956
1992
  id = "webspeech";
1957
1993
  name = "Web Speech API";
1958
1994
  voiceEngine = null;
1959
1995
  // No cache to bypass here — local API, no network cost to re-checking.
1960
1996
  async getVoices() {
1961
- return this.voiceEngine || (this.voiceEngine = new zt(), await this.voiceEngine.initialize()), this.voiceEngine.getAvailableVoices();
1997
+ return this.voiceEngine || (this.voiceEngine = new Nt(), await this.voiceEngine.initialize()), this.voiceEngine.getAvailableVoices();
1962
1998
  }
1963
1999
  async createEngine(e) {
1964
- const t = new zt();
2000
+ const t = new Nt();
1965
2001
  return await t.initialize(), e && await t.setVoice(e), t;
1966
2002
  }
1967
2003
  async destroy() {
1968
2004
  this.voiceEngine && (await this.voiceEngine.destroy(), this.voiceEngine = null);
1969
2005
  }
1970
2006
  }
1971
- function wn(n, e) {
2007
+ function Cn(n, e) {
1972
2008
  const t = [];
1973
2009
  let i = -1, s = -1;
1974
2010
  const a = () => {
1975
- i !== -1 && (t.push({ text: ls(n, i, s), offset: n[i].offset }), i = -1, s = -1);
2011
+ i !== -1 && (t.push({ text: fs(n, i, s), offset: n[i].offset }), i = -1, s = -1);
1976
2012
  };
1977
2013
  for (let r = 0; r < n.length; r++) {
1978
2014
  const o = n[r];
@@ -1985,14 +2021,14 @@ function wn(n, e) {
1985
2021
  }
1986
2022
  return a(), t;
1987
2023
  }
1988
- function ls(n, e, t) {
2024
+ function fs(n, e, t) {
1989
2025
  const i = n[e], s = n[t];
1990
2026
  return i === s ? i.text : n.slice(e, t + 1).map((a) => a.text).join("");
1991
2027
  }
1992
- const kn = new RegExp(
1993
- `[^${ie}]*[${ie}]+\\s*|[^${ie}]+$`,
2028
+ const En = new RegExp(
2029
+ `[^${se}]*[${se}]+\\s*|[^${se}]+$`,
1994
2030
  "gu"
1995
- ), cs = /\S+\s*|\s+/g;
2031
+ ), ps = /\S+\s*|\s+/g;
1996
2032
  function rt(n, e, t) {
1997
2033
  const i = [];
1998
2034
  for (const s of n.matchAll(t))
@@ -2002,7 +2038,7 @@ function rt(n, e, t) {
2002
2038
  function ot(n, e) {
2003
2039
  if (n.text.length <= e || n.atomic)
2004
2040
  return [n];
2005
- const t = rt(n.text, n.offset, cs);
2041
+ const t = rt(n.text, n.offset, ps);
2006
2042
  if (t.length > 1)
2007
2043
  return t.flatMap((r) => ot(r, e));
2008
2044
  const i = [];
@@ -2011,23 +2047,23 @@ function ot(n, e) {
2011
2047
  a.length > 0 && a.length + r.length > e && (i.push({ text: a, offset: s, atomic: !1 }), s += a.length, a = ""), a += r;
2012
2048
  return a.length > 0 && i.push({ text: a, offset: s, atomic: !1 }), i;
2013
2049
  }
2014
- function us(n, e) {
2050
+ function ms(n, e) {
2015
2051
  if (n.length <= e)
2016
2052
  return [{ text: n, offset: 0 }];
2017
- const i = rt(n, 0, kn).flatMap((s) => ot(s, e));
2018
- return wn(i, e);
2053
+ const i = rt(n, 0, En).flatMap((s) => ot(s, e));
2054
+ return Cn(i, e);
2019
2055
  }
2020
- const hs = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
2021
- function ds(n, e) {
2056
+ const vs = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
2057
+ function ys(n, e) {
2022
2058
  if (n.length <= e)
2023
2059
  return [{ text: n, offset: 0 }];
2024
2060
  const t = [];
2025
- for (const s of n.matchAll(hs))
2026
- s[0][0] === "<" ? t.push({ text: s[0], offset: s.index, atomic: !0 }) : t.push(...rt(s[0], s.index, kn));
2061
+ for (const s of n.matchAll(vs))
2062
+ s[0][0] === "<" ? t.push({ text: s[0], offset: s.index, atomic: !0 }) : t.push(...rt(s[0], s.index, En));
2027
2063
  const i = t.flatMap((s) => ot(s, e));
2028
- return wn(i, e);
2064
+ return Cn(i, e);
2029
2065
  }
2030
- const gs = {
2066
+ const Ss = {
2031
2067
  wav: "audio/wav",
2032
2068
  mp3: "audio/mpeg",
2033
2069
  opus: "audio/ogg",
@@ -2037,31 +2073,31 @@ const gs = {
2037
2073
  webm: "audio/webm",
2038
2074
  m4a: "audio/mp4"
2039
2075
  };
2040
- function fs(n) {
2041
- return gs[n] ?? `audio/${n}`;
2076
+ function bs(n) {
2077
+ return Ss[n] ?? `audio/${n}`;
2042
2078
  }
2043
- const ps = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], ms = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
2044
- function vs(n, e, t) {
2045
- const i = (o) => t(fs(o)) !== "", s = n.formats.filter(i);
2079
+ const ws = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], ks = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
2080
+ function Cs(n, e, t) {
2081
+ const i = (o) => t(bs(o)) !== "", s = n.formats.filter(i);
2046
2082
  if (e.preferredFormat && s.includes(e.preferredFormat))
2047
2083
  return e.preferredFormat;
2048
- const a = e.strategy === "bandwidth" ? ms : ps, r = [...a, ...s.filter((o) => !a.includes(o))];
2084
+ const a = e.strategy === "bandwidth" ? ks : ws, r = [...a, ...s.filter((o) => !a.includes(o))];
2049
2085
  for (const o of r)
2050
2086
  if (s.includes(o))
2051
2087
  return o;
2052
2088
  return n.default;
2053
2089
  }
2054
- const ys = /* @__PURE__ */ new Set(["wav", "flac"]), Ss = {
2090
+ const Es = /* @__PURE__ */ new Set(["wav", "flac"]), Rs = {
2055
2091
  mp3: 48e3,
2056
2092
  opus: 24e3,
2057
2093
  aac: 48e3,
2058
2094
  ogg: 48e3,
2059
2095
  webm: 32e3
2060
2096
  };
2061
- function bs(n, e, t) {
2062
- return ys.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Ss[n] : void 0;
2097
+ function Is(n, e, t) {
2098
+ return Es.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Rs[n] : void 0;
2063
2099
  }
2064
- function Cn(n, e) {
2100
+ function Rn(n, e) {
2065
2101
  return {
2066
2102
  source: "server",
2067
2103
  label: n.name,
@@ -2076,7 +2112,7 @@ function Cn(n, e) {
2076
2112
  controls: e
2077
2113
  };
2078
2114
  }
2079
- class re extends Error {
2115
+ class oe extends Error {
2080
2116
  status;
2081
2117
  type;
2082
2118
  title;
@@ -2085,26 +2121,26 @@ class re extends Error {
2085
2121
  super(e), this.name = "SpeechServerError", this.status = t.status, this.type = t.type, this.title = t.title, this.instance = t.instance;
2086
2122
  }
2087
2123
  }
2088
- class En extends re {
2124
+ class In extends oe {
2089
2125
  constructor(e) {
2090
2126
  super(e, { status: 408, type: "https://readium.org/speech-server/error#stall", title: "Synthesis Stalled" }), this.name = "SpeechServerStallError";
2091
2127
  }
2092
2128
  }
2093
- class Rn extends Error {
2129
+ class Pn extends Error {
2094
2130
  constructor(e) {
2095
2131
  super(e), this.name = "SpeechServerAudioDecodeError";
2096
2132
  }
2097
2133
  }
2098
- class In extends Error {
2134
+ class An extends Error {
2099
2135
  constructor(e) {
2100
2136
  super(e), this.name = "SpeechServerNetworkError";
2101
2137
  }
2102
2138
  }
2103
- async function se(n) {
2139
+ async function ae(n) {
2104
2140
  if ((n.headers.get("content-type") ?? "").includes("application/problem+json"))
2105
2141
  try {
2106
2142
  const t = await n.json();
2107
- return new re(t.detail || t.title || `Request failed with status ${n.status}`, {
2143
+ return new oe(t.detail || t.title || `Request failed with status ${n.status}`, {
2108
2144
  status: t.status ?? n.status,
2109
2145
  type: t.type,
2110
2146
  title: t.title,
@@ -2112,25 +2148,25 @@ async function se(n) {
2112
2148
  });
2113
2149
  } catch {
2114
2150
  }
2115
- return new re(`Request failed with status ${n.status}`, { status: n.status });
2151
+ return new oe(`Request failed with status ${n.status}`, { status: n.status });
2116
2152
  }
2117
- const ws = 3, ks = 400;
2118
- function Cs(n) {
2153
+ const Ps = 3, As = 400;
2154
+ function Ls(n) {
2119
2155
  const e = atob(n), t = new Uint8Array(e.length);
2120
2156
  for (let i = 0; i < e.length; i++)
2121
2157
  t[i] = e.charCodeAt(i);
2122
2158
  return t.buffer;
2123
2159
  }
2124
- function Es(n) {
2125
- return H(n, 0.25, 4, 1);
2160
+ function Os(n) {
2161
+ return q(n, 0.25, 4, 1);
2126
2162
  }
2127
- function ge(n) {
2163
+ function pe(n) {
2128
2164
  return n?.plain ?? n?.ssml ?? void 0;
2129
2165
  }
2130
- function Nt(n) {
2131
- return n instanceof En ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof re ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Rn ? { message: n.message, recoverable: !1 } : n instanceof In ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
2166
+ function Mt(n) {
2167
+ return n instanceof In ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof oe ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Pn ? { message: n.message, recoverable: !1 } : n instanceof An ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
2132
2168
  }
2133
- class Rs {
2169
+ class Vs {
2134
2170
  endpoints;
2135
2171
  fetchImpl;
2136
2172
  currentVoice = null;
@@ -2145,7 +2181,7 @@ class Rs {
2145
2181
  currentUtterances = [];
2146
2182
  currentUtteranceIndex = 0;
2147
2183
  playbackState = "idle";
2148
- events = new Pe();
2184
+ events = new Ae();
2149
2185
  speakGeneration = 0;
2150
2186
  loadGeneration = 0;
2151
2187
  // Rolling buffer of upcoming utterances' audio, fetched one at a time via prefetchChainTail.
@@ -2174,7 +2210,7 @@ class Rs {
2174
2210
  pitch = 1;
2175
2211
  volume = 1;
2176
2212
  constructor(e) {
2177
- this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? ws, this.readyBufferChars = e.readyBufferChars ?? ks, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
2213
+ this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? Ps, this.readyBufferChars = e.readyBufferChars ?? As, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
2178
2214
  }
2179
2215
  // Lets a provider that already fetched /voices seed this engine without a second request.
2180
2216
  setAvailableVoices(e) {
@@ -2184,7 +2220,7 @@ class Rs {
2184
2220
  async initialize() {
2185
2221
  this.initializing = (async () => {
2186
2222
  const e = await this.getAvailableVoices(), t = typeof navigator < "u" && navigator.languages?.length ? [...navigator.languages] : ["en"];
2187
- return this.defaultVoice = (await un(t, e))[0] ?? null, !0;
2223
+ return this.defaultVoice = (await dn(t, e))[0] ?? null, !0;
2188
2224
  })();
2189
2225
  try {
2190
2226
  return await this.initializing;
@@ -2198,17 +2234,17 @@ class Rs {
2198
2234
  try {
2199
2235
  return await this.fetchImpl(e, t);
2200
2236
  } catch (i) {
2201
- throw i instanceof TypeError ? new In(i.message) : i;
2237
+ throw i instanceof TypeError ? new An(i.message) : i;
2202
2238
  }
2203
2239
  }
2204
2240
  loadUtterances(e, t) {
2205
- this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex = me(t ?? 0, e.length), this.setState("loading"), this.bufferUntilReady(++this.loadGeneration);
2241
+ this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex = ye(t ?? 0, e.length), this.setState("loading"), this.bufferUntilReady(++this.loadGeneration);
2206
2242
  }
2207
2243
  // Buffers enough utterances ahead of currentUtteranceIndex to cover readyBufferChars before
2208
2244
  // declaring "ready", so playback doesn't catch up to an empty prefetch cache right away —
2209
2245
  // starting from wherever playback will actually resume, not always utterance 0.
2210
2246
  async bufferUntilReady(e) {
2211
- const t = me(this.currentUtteranceIndex, this.currentUtterances.length), i = Math.min(this.indexCoveringChars(this.readyBufferChars, t), t + this.prefetchWindow), s = [];
2247
+ const t = ye(this.currentUtteranceIndex, this.currentUtterances.length), i = Math.min(this.indexCoveringChars(this.readyBufferChars, t), t + this.prefetchWindow), s = [];
2212
2248
  for (let a = t; a <= i; a++) {
2213
2249
  this.queuePrefetch(a);
2214
2250
  const r = this.prefetchCache.get(a);
@@ -2223,10 +2259,10 @@ class Rs {
2223
2259
  indexCoveringChars(e, t) {
2224
2260
  if (this.currentUtterances.length === 0)
2225
2261
  return -1;
2226
- const i = me(t, this.currentUtterances.length);
2262
+ const i = ye(t, this.currentUtterances.length);
2227
2263
  let s = 0;
2228
2264
  for (let a = i; a < this.currentUtterances.length; a++)
2229
- if (s += (ge(this.currentUtterances[a]) ?? "").length, s >= e)
2265
+ if (s += (pe(this.currentUtterances[a]) ?? "").length, s >= e)
2230
2266
  return a;
2231
2267
  return this.currentUtterances.length - 1;
2232
2268
  }
@@ -2240,12 +2276,12 @@ class Rs {
2240
2276
  const i = this.currentVoice ?? this.defaultVoice;
2241
2277
  if (!e?.language || this.voices.length === 0 || Ge(i, e.language))
2242
2278
  return i;
2243
- const s = x(e.language), a = i?.controls?.boundary !== !1, r = `${s}:${a}`;
2279
+ const s = V(e.language), a = i?.controls?.boundary !== !1, r = `${s}:${a}`;
2244
2280
  let o = this.languageVoiceCache.get(r);
2245
2281
  return o || (o = this.pickLanguageVoice(s, a), this.languageVoiceCache.set(r, o)), await o ?? i;
2246
2282
  }
2247
2283
  async pickLanguageVoice(e, t) {
2248
- const i = this.voices.filter((a) => gn(a, e)), s = i.length > 0 ? await hn(e, it(i, t)) : null;
2284
+ const i = this.voices.filter((a) => pn(a, e)), s = i.length > 0 ? await gn(e, it(i, t)) : null;
2249
2285
  return s || this.emitEvent({ type: "languagefallback", detail: { language: e, reason: "no-matching-voice" } }), s;
2250
2286
  }
2251
2287
  setVoice(e) {
@@ -2282,9 +2318,9 @@ class Rs {
2282
2318
  async fetchVoices() {
2283
2319
  const [e, t] = await Promise.all([this.fetchNetwork(this.endpoints.voices), this.getServiceInfo()]);
2284
2320
  if (!e.ok)
2285
- throw await se(e);
2321
+ throw await ae(e);
2286
2322
  const i = await e.json(), s = new Map(t.providers.map((a) => [a.id, a.controls]));
2287
- return this.voices = i.map((a) => Cn(a, s.get(a.provider))), this.voices;
2323
+ return this.voices = i.map((a) => Rn(a, s.get(a.provider))), this.voices;
2288
2324
  }
2289
2325
  // Cached after the first successful fetch; a failed fetch isn't cached, so the next
2290
2326
  // synthesize() call retries rather than being stuck on a transient network error.
@@ -2296,7 +2332,7 @@ class Rs {
2296
2332
  async fetchServiceInfo() {
2297
2333
  const e = await this.fetchNetwork(this.endpoints.service);
2298
2334
  if (!e.ok)
2299
- throw await se(e);
2335
+ throw await ae(e);
2300
2336
  return e.json();
2301
2337
  }
2302
2338
  speak(e) {
@@ -2328,7 +2364,7 @@ class Rs {
2328
2364
  return;
2329
2365
  this.isSpeakingInternal = !1, this.setState("idle"), this.emitEvent({
2330
2366
  type: "error",
2331
- detail: Nt(i)
2367
+ detail: Mt(i)
2332
2368
  });
2333
2369
  }
2334
2370
  }
@@ -2375,7 +2411,7 @@ class Rs {
2375
2411
  this.liveControllers.forEach((e) => e.abort()), this.liveControllers.clear();
2376
2412
  }
2377
2413
  async synthesizeStream(e, t) {
2378
- const i = this.currentUtterances[e], s = !i.plain && !!i.ssml, a = i.language, r = ge(i) ?? "", o = s ? pn(r).map : void 0, l = ge(this.currentUtterances[e - 1]), c = ge(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g = vs(u.output, this.formatOptions, this.canPlayType), d = navigator.connection, h = bs(g, this.formatOptions.adaptBitrateToNetwork ?? !1, d);
2414
+ const i = this.currentUtterances[e], s = !i.plain && !!i.ssml, a = i.language, r = pe(i) ?? "", o = s ? vn(r).map : void 0, l = pe(this.currentUtterances[e - 1]), c = pe(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g = Cs(u.output, this.formatOptions, this.canPlayType), d = navigator.connection, h = Is(g, this.formatOptions.adaptBitrateToNetwork ?? !1, d);
2379
2415
  if (r.length <= u.limits.maxTextLength) {
2380
2416
  const v = new AbortController();
2381
2417
  return (t ? this.activeControllers : this.liveControllers).add(v), [{
@@ -2384,7 +2420,7 @@ class Rs {
2384
2420
  }];
2385
2421
  }
2386
2422
  if (this.overLengthText === "error")
2387
- throw new re(
2423
+ throw new oe(
2388
2424
  `Text exceeds this server's maximum length of ${u.limits.maxTextLength} characters`,
2389
2425
  {
2390
2426
  status: 413,
@@ -2392,7 +2428,7 @@ class Rs {
2392
2428
  title: "Payload Too Large"
2393
2429
  }
2394
2430
  );
2395
- const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = s ? ds(r, f) : us(r, f), m = [];
2431
+ const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = s ? ys(r, f) : ms(r, f), m = [];
2396
2432
  let S = Promise.resolve();
2397
2433
  for (let v = 0; v < p.length; v++) {
2398
2434
  const w = v === 0 ? l : p[v - 1].text, y = v === p.length - 1 ? c : p[v + 1].text, b = p[v], P = new AbortController();
@@ -2412,7 +2448,7 @@ class Rs {
2412
2448
  headers: { "Content-Type": "application/json" },
2413
2449
  body: JSON.stringify({
2414
2450
  id: t.id,
2415
- text: a ? i : fn(i),
2451
+ text: a ? i : mn(i),
2416
2452
  ssml: a,
2417
2453
  language: o,
2418
2454
  voice: h?.identifier ?? h?.name,
@@ -2424,13 +2460,13 @@ class Rs {
2424
2460
  signal: d.signal
2425
2461
  });
2426
2462
  if (!f.ok)
2427
- throw await se(f);
2428
- const p = await f.json(), m = Cs(p.audio);
2463
+ throw await ae(f);
2464
+ const p = await f.json(), m = Ls(p.audio);
2429
2465
  let S;
2430
2466
  try {
2431
2467
  S = await this.ensureAudioContext().decodeAudioData(m);
2432
2468
  } catch {
2433
- throw new Rn("Audio playback failed");
2469
+ throw new Pn("Audio playback failed");
2434
2470
  }
2435
2471
  return { audioBuffer: S, format: p.format, boundaries: p.boundaries, textOffset: s, ssmlMap: r };
2436
2472
  } finally {
@@ -2451,7 +2487,7 @@ class Rs {
2451
2487
  const s = i + this.timeoutMs;
2452
2488
  return new Promise((a, r) => {
2453
2489
  const o = setTimeout(() => {
2454
- t.abort(), r(new En(`No audio chunk arrived within ${s.toFixed(0)}ms of the playback buffer running dry`));
2490
+ t.abort(), r(new In(`No audio chunk arrived within ${s.toFixed(0)}ms of the playback buffer running dry`));
2455
2491
  }, s);
2456
2492
  e.then(
2457
2493
  (l) => {
@@ -2468,7 +2504,7 @@ class Rs {
2468
2504
  const s = await this.awaitWithStallDeadline(e[0].promise, e[0].controller, 0);
2469
2505
  if (t !== this.speakGeneration)
2470
2506
  return;
2471
- const a = this.ensureAudioContext(), r = this.masterGain, l = i?.controls?.speed === !0 ? 1 : Es(this.rate);
2507
+ const a = this.ensureAudioContext(), r = this.masterGain, l = i?.controls?.speed === !0 ? 1 : Os(this.rate);
2472
2508
  this.scheduledChunks = [], this.setState("playing"), this.emitEvent({ type: "start", detail: { voice: i } });
2473
2509
  let c = a.currentTime, u = null;
2474
2510
  const g = (d) => {
@@ -2482,7 +2518,7 @@ class Rs {
2482
2518
  const f = Math.max(0, (c - a.currentTime) * 1e3);
2483
2519
  h = await this.awaitWithStallDeadline(e[d].promise, e[d].controller, f);
2484
2520
  } catch (f) {
2485
- t === this.speakGeneration && this.emitEvent({ type: "error", detail: Nt(f) });
2521
+ t === this.speakGeneration && this.emitEvent({ type: "error", detail: Mt(f) });
2486
2522
  return;
2487
2523
  }
2488
2524
  if (t !== this.speakGeneration)
@@ -2513,7 +2549,7 @@ class Rs {
2513
2549
  let r = a, o = s.charLength;
2514
2550
  if (t.chunk.ssmlMap) {
2515
2551
  const l = t.chunk.ssmlMap;
2516
- r = Ot(l, a), o = Math.max(0, Ot(l, a + s.charLength) - r);
2552
+ r = Vt(l, a), o = Math.max(0, Vt(l, a + s.charLength) - r);
2517
2553
  }
2518
2554
  this.emitEvent({
2519
2555
  type: "boundary",
@@ -2557,21 +2593,21 @@ class Rs {
2557
2593
  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" });
2558
2594
  }
2559
2595
  setRate(e) {
2560
- const t = H(e, 0.1, 10, this.rate);
2596
+ const t = q(e, 0.1, 10, this.rate);
2561
2597
  t !== this.rate && (this.rate = t, this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
2562
2598
  }
2563
2599
  getRate() {
2564
2600
  return this.rate;
2565
2601
  }
2566
2602
  setPitch(e) {
2567
- const t = H(e, 0, 2, this.pitch);
2603
+ const t = q(e, 0, 2, this.pitch);
2568
2604
  t !== this.pitch && (this.pitch = t, this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
2569
2605
  }
2570
2606
  getPitch() {
2571
2607
  return this.pitch;
2572
2608
  }
2573
2609
  setVolume(e) {
2574
- const t = H(e, 0, 1, this.volume);
2610
+ const t = q(e, 0, 1, this.volume);
2575
2611
  t !== this.volume && (this.volume = t, this.masterGain && (this.masterGain.gain.value = this.volume));
2576
2612
  }
2577
2613
  getVolume() {
@@ -2633,7 +2669,7 @@ class Rs {
2633
2669
  this.stop(), await this.audioContext?.close(), this.audioContext = null, this.masterGain = null, this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.defaultVoice = null, this.voices = [], this.voicesRequest = null, this.languageVoiceCache.clear();
2634
2670
  }
2635
2671
  }
2636
- class Qa {
2672
+ class nr {
2637
2673
  id = "speech-server";
2638
2674
  name = "Readium Speech Server";
2639
2675
  options;
@@ -2650,24 +2686,24 @@ class Qa {
2650
2686
  this.fetchImpl(this.options.endpoints.service)
2651
2687
  ]);
2652
2688
  if (!t.ok)
2653
- throw await se(t);
2689
+ throw await ae(t);
2654
2690
  if (!i.ok)
2655
- throw await se(i);
2691
+ throw await ae(i);
2656
2692
  const s = await t.json(), a = await i.json(), r = new Map(a.providers.map((o) => [o.id, o.controls]));
2657
- return this.voices = s.map((o) => Cn(o, r.get(o.provider))), this.voices;
2693
+ return this.voices = s.map((o) => Rn(o, r.get(o.provider))), this.voices;
2658
2694
  }
2659
2695
  async createEngine(e) {
2660
- const t = new Rs(this.options);
2696
+ const t = new Vs(this.options);
2661
2697
  return this.voices.length > 0 && t.setAvailableVoices(this.voices), e && t.setVoice(e), t;
2662
2698
  }
2663
2699
  async destroy() {
2664
2700
  this.voices = [];
2665
2701
  }
2666
2702
  }
2667
- function Is(n) {
2703
+ function xs(n) {
2668
2704
  return n.detail?.recoverable === !0;
2669
2705
  }
2670
- const Ps = 3e4, As = [
2706
+ const Us = 3e4, Ts = [
2671
2707
  "start",
2672
2708
  "pause",
2673
2709
  "resume",
@@ -2682,7 +2718,7 @@ const Ps = 3e4, As = [
2682
2718
  "voiceschanged",
2683
2719
  "languagefallback"
2684
2720
  ];
2685
- class Ls {
2721
+ class zs {
2686
2722
  activeEngine;
2687
2723
  primaryProvider;
2688
2724
  fallbackProvider;
@@ -2714,10 +2750,10 @@ class Ls {
2714
2750
  teardownEpoch = 0;
2715
2751
  // Bumped by every loadUtterances() call, so startEngineWhenReady() can tell its queue is stale.
2716
2752
  loadToken = 0;
2717
- events = new Pe();
2753
+ events = new Ae();
2718
2754
  unbindActiveEngine = null;
2719
2755
  constructor(e) {
2720
- this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? Ps, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
2756
+ this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? Us, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
2721
2757
  }
2722
2758
  async initialize() {
2723
2759
  return this.activeEngine.initialize?.();
@@ -2811,13 +2847,13 @@ class Ls {
2811
2847
  this.events.emit(e.type, e);
2812
2848
  }
2813
2849
  bindActiveEngine() {
2814
- const e = this.activeEngine, t = As.map((i) => e.on(i, (s) => {
2850
+ const e = this.activeEngine, t = Ts.map((i) => e.on(i, (s) => {
2815
2851
  this.emitEvent(s), this.maybeRecoverNow();
2816
2852
  }));
2817
2853
  t.push(e.on("error", (i) => this.handleError(i))), this.unbindActiveEngine = () => t.forEach((i) => i());
2818
2854
  }
2819
2855
  handleError(e) {
2820
- if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !Is(e)) {
2856
+ if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !xs(e)) {
2821
2857
  this.emitEvent(e);
2822
2858
  return;
2823
2859
  }
@@ -2909,14 +2945,14 @@ class Ls {
2909
2945
  async pickBestFallbackVoice(e, t, i) {
2910
2946
  const s = await this.fallbackProvider.getVoices(), r = typeof navigator < "u" && navigator.onLine === !0 ? s : s.filter((f) => f.offlineAvailability === !0);
2911
2947
  if (r.length === 0) return null;
2912
- const [o] = Re([e]), { voicesByLang: l } = Ie(r, [o]), c = l.get(o.baseLang) ?? [], u = c.length > 0 ? c : r, g = t ? u.filter((f) => f.gender === t) : [], d = g.length > 0 ? g : u, h = it(d, i);
2913
- return hn(e, h);
2948
+ const [o] = Ie([e]), { voicesByLang: l } = Pe(r, [o]), c = l.get(o.baseLang) ?? [], u = c.length > 0 ? c : r, g = t ? u.filter((f) => f.gender === t) : [], d = g.length > 0 ? g : u, h = it(d, i);
2949
+ return gn(e, h);
2914
2950
  }
2915
2951
  async destroy() {
2916
2952
  this.teardownEpoch++, this.healthCheckTimer !== null && (clearTimeout(this.healthCheckTimer), this.healthCheckTimer = null), this.unbindActiveEngine?.(), this.events.clear(), await this.activeEngine.destroy();
2917
2953
  }
2918
2954
  }
2919
- class Ja {
2955
+ class ir {
2920
2956
  id = "fallback";
2921
2957
  name = "Fallback";
2922
2958
  primary;
@@ -2944,7 +2980,7 @@ class Ja {
2944
2980
  throw i;
2945
2981
  return this.fallback.createEngine(e);
2946
2982
  }
2947
- return new Ls({
2983
+ return new zs({
2948
2984
  primaryEngine: t,
2949
2985
  primaryProvider: this.primary,
2950
2986
  fallbackProvider: this.fallback,
@@ -2956,27 +2992,27 @@ class Ja {
2956
2992
  await Promise.all([this.primary.destroy(), this.fallback.destroy()]);
2957
2993
  }
2958
2994
  }
2959
- function Os(n) {
2960
- return new gi({
2961
- start: new Et(n.start),
2962
- end: n.end ? new Et(n.end) : void 0
2995
+ function Ns(n) {
2996
+ return new yi({
2997
+ start: new Rt(n.start),
2998
+ end: n.end ? new Rt(n.end) : void 0
2963
2999
  });
2964
3000
  }
2965
- function xs(n, e = window) {
2966
- const { href: t, text: i, cssSelector: s, domRange: a, fragment: r } = n, o = i ? new oi(i) : void 0, l = s || a ? /* @__PURE__ */ new Map() : void 0;
2967
- l && (s && l.set("cssSelector", s), a && l.set("domRange", Os(a).serialize()));
2968
- const u = l !== void 0 || r !== void 0 ? new li({
3001
+ function Ms(n, e = window) {
3002
+ const { href: t, text: i, cssSelector: s, domRange: a, fragment: r } = n, o = i ? new di(i) : void 0, l = s || a ? /* @__PURE__ */ new Map() : void 0;
3003
+ l && (s && l.set("cssSelector", s), a && l.set("domRange", Ns(a).serialize()));
3004
+ const u = l !== void 0 || r !== void 0 ? new gi({
2969
3005
  fragments: r ? [r] : void 0,
2970
3006
  otherLocations: l
2971
3007
  }) : void 0;
2972
- return new ci({
3008
+ return new fi({
2973
3009
  href: t ?? e.location.href,
2974
3010
  type: "text/html",
2975
3011
  text: o,
2976
3012
  locations: u
2977
3013
  });
2978
3014
  }
2979
- class Vs extends si {
3015
+ class Bs extends ci {
2980
3016
  constructor(e, t, i, s = {}) {
2981
3017
  super(e.host, s), this.channel = e, this.wnd = t, this.decorator = i;
2982
3018
  }
@@ -2992,7 +3028,7 @@ class Vs extends si {
2992
3028
  e.map(({ id: i, style: s, ...a }) => ({
2993
3029
  id: i,
2994
3030
  style: s,
2995
- locator: xs(a, this.wnd)
3031
+ locator: Ms(a, this.wnd)
2996
3032
  })),
2997
3033
  t
2998
3034
  );
@@ -3001,12 +3037,12 @@ class Vs extends si {
3001
3037
  super.destroy(), this.decorator.unmount(this.wnd, this.channel.frame), this.channel.frame.destroy();
3002
3038
  }
3003
3039
  }
3004
- function Za(n = window, e = {}) {
3005
- const t = new ai(), i = new ri();
3006
- return i.mount(n, t.frame), new Vs(t, n, i, e);
3040
+ function sr(n = window, e = {}) {
3041
+ const t = new ui(), i = new hi();
3042
+ return i.mount(n, t.frame), new Bs(t, n, i, e);
3007
3043
  }
3008
- const Pn = (n) => n.voiceURI ?? n.identifier ?? n.name;
3009
- class Xa {
3044
+ const Ln = (n) => n.voiceURI ?? n.identifier ?? n.name;
3045
+ class ar {
3010
3046
  providers = /* @__PURE__ */ new Map();
3011
3047
  register(e) {
3012
3048
  if (this.providers.has(e.id))
@@ -3046,7 +3082,7 @@ class Xa {
3046
3082
  return t;
3047
3083
  }
3048
3084
  }
3049
- const Ae = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t }), ye = Ae(0, 5e3, 100), Se = Ae(0.1, 10, 0.1), be = Ae(0, 2, 0.1), we = Ae(0, 1, 0.05), lt = Object.freeze(["none", "few", "some", "most", "custom"]), ct = Object.freeze(["none", "block-level", "always"]), ut = Object.freeze(["plain", "ssml"]), ht = Object.freeze(["none", "utterance", "block"]), dt = Object.freeze(["structure", "sentence"]), Mt = Object.freeze([
3085
+ const Le = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t }), be = Le(0, 5e3, 100), we = Le(0.1, 10, 0.1), ke = Le(0, 2, 0.1), Ce = Le(0, 1, 0.05), lt = Object.freeze(["none", "few", "some", "most", "custom"]), ct = Object.freeze(["none", "block-level", "always"]), ut = Object.freeze(["plain", "ssml"]), ht = Object.freeze(["none", "utterance", "block"]), dt = Object.freeze(["structure", "sentence"]), Bt = Object.freeze([
3050
3086
  "format",
3051
3087
  "inlineContextualization",
3052
3088
  "verbosity",
@@ -3056,13 +3092,13 @@ const Ae = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t })
3056
3092
  "languageOverrides",
3057
3093
  "segmentation"
3058
3094
  ]);
3059
- function Us(n) {
3095
+ function Ds(n) {
3060
3096
  return n == null || typeof n == "boolean" ? n : void 0;
3061
3097
  }
3062
3098
  function O(n, e) {
3063
3099
  return n == null || e.includes(n) ? n : void 0;
3064
3100
  }
3065
- function N(n, e) {
3101
+ function z(n, e) {
3066
3102
  if (n == null) return n;
3067
3103
  if (typeof n != "number" || Number.isNaN(n)) return;
3068
3104
  const t = Math.min(...e), i = Math.max(...e);
@@ -3073,13 +3109,13 @@ function gt(n) {
3073
3109
  if (!(typeof n != "object" || Array.isArray(n)))
3074
3110
  return Object.values(n).every((e) => typeof e == "string") ? { ...n } : void 0;
3075
3111
  }
3076
- function An(n) {
3112
+ function On(n) {
3077
3113
  return typeof n == "string" ? n : gt(n);
3078
3114
  }
3079
- function K(n) {
3115
+ function G(n) {
3080
3116
  return n == null ? n : Array.isArray(n) && n.every((e) => typeof e == "string") ? [...n] : void 0;
3081
3117
  }
3082
- class Ts {
3118
+ class js {
3083
3119
  format;
3084
3120
  inlineContextualization;
3085
3121
  verbosity;
@@ -3095,10 +3131,10 @@ class Ts {
3095
3131
  pitch;
3096
3132
  volume;
3097
3133
  constructor(e = {}) {
3098
- this.format = O(e.format, ut) ?? "plain", this.inlineContextualization = K(e.inlineContextualization) ?? [], this.verbosity = O(e.verbosity, lt) ?? "few", this.skip = K(e.skip) ?? [], this.contextualize = K(e.contextualize) ?? [], this.language = O(e.language, ct) ?? "block-level", this.languageOverrides = gt(e.languageOverrides) ?? {}, this.segmentation = O(e.segmentation, dt) ?? "structure", this.voice = An(e.voice) ?? null, this.pauseDuration = N(e.pauseDuration, ye.range) ?? 300, this.autoPause = O(e.autoPause, ht) ?? "none", this.rate = N(e.rate, Se.range) ?? 1, this.pitch = N(e.pitch, be.range) ?? 1, this.volume = N(e.volume, we.range) ?? 1;
3134
+ this.format = O(e.format, ut) ?? "plain", this.inlineContextualization = G(e.inlineContextualization) ?? [], this.verbosity = O(e.verbosity, lt) ?? "few", this.skip = G(e.skip) ?? [], this.contextualize = G(e.contextualize) ?? [], this.language = O(e.language, ct) ?? "block-level", this.languageOverrides = gt(e.languageOverrides) ?? {}, this.segmentation = O(e.segmentation, dt) ?? "structure", this.voice = On(e.voice) ?? null, this.pauseDuration = z(e.pauseDuration, be.range) ?? 300, this.autoPause = O(e.autoPause, ht) ?? "none", this.rate = z(e.rate, we.range) ?? 1, this.pitch = z(e.pitch, ke.range) ?? 1, this.volume = z(e.volume, Ce.range) ?? 1;
3099
3135
  }
3100
3136
  }
3101
- class oe {
3137
+ class le {
3102
3138
  format;
3103
3139
  inlineContextualization;
3104
3140
  verbosity;
@@ -3114,16 +3150,16 @@ class oe {
3114
3150
  pitch;
3115
3151
  volume;
3116
3152
  constructor(e = {}) {
3117
- this.format = O(e.format, ut), this.inlineContextualization = K(e.inlineContextualization), this.verbosity = O(e.verbosity, lt), this.skip = K(e.skip), this.contextualize = K(e.contextualize), this.language = O(e.language, ct), this.languageOverrides = gt(e.languageOverrides), this.segmentation = O(e.segmentation, dt), this.voice = An(e.voice), this.pauseDuration = N(e.pauseDuration, ye.range), this.autoPause = O(e.autoPause, ht), this.rate = N(e.rate, Se.range), this.pitch = N(e.pitch, be.range), this.volume = N(e.volume, we.range);
3153
+ this.format = O(e.format, ut), this.inlineContextualization = G(e.inlineContextualization), this.verbosity = O(e.verbosity, lt), this.skip = G(e.skip), this.contextualize = G(e.contextualize), this.language = O(e.language, ct), this.languageOverrides = gt(e.languageOverrides), this.segmentation = O(e.segmentation, dt), this.voice = On(e.voice), this.pauseDuration = z(e.pauseDuration, be.range), this.autoPause = O(e.autoPause, ht), this.rate = z(e.rate, we.range), this.pitch = z(e.pitch, ke.range), this.volume = z(e.volume, Ce.range);
3118
3154
  }
3119
3155
  merging(e) {
3120
3156
  const t = { ...this };
3121
3157
  for (const i of Object.keys(e))
3122
3158
  e[i] !== void 0 && (t[i] = e[i]);
3123
- return new oe(t);
3159
+ return new le(t);
3124
3160
  }
3125
3161
  }
3126
- class Q {
3162
+ class K {
3127
3163
  _value;
3128
3164
  _effectiveValue;
3129
3165
  _isEffective;
@@ -3152,7 +3188,7 @@ class Q {
3152
3188
  this._value = null, this._onChange(this._value);
3153
3189
  }
3154
3190
  }
3155
- class ne extends Q {
3191
+ class ie extends K {
3156
3192
  _supportedValues;
3157
3193
  constructor({
3158
3194
  initialValue: e = null,
@@ -3175,9 +3211,9 @@ class ne extends Q {
3175
3211
  return this._supportedValues;
3176
3212
  }
3177
3213
  }
3178
- class Ya extends Q {
3214
+ class rr extends K {
3179
3215
  set value(e) {
3180
- if (e != null && Us(e) === void 0)
3216
+ if (e != null && Ds(e) === void 0)
3181
3217
  throw new Error(`Value '${String(e)}' is not a boolean.`);
3182
3218
  this._value = e, this._onChange(this._value);
3183
3219
  }
@@ -3185,9 +3221,9 @@ class Ya extends Q {
3185
3221
  return this._value;
3186
3222
  }
3187
3223
  }
3188
- class Te extends Q {
3224
+ class Te extends K {
3189
3225
  set value(e) {
3190
- if (e != null && K(e) === void 0)
3226
+ if (e != null && G(e) === void 0)
3191
3227
  throw new Error(`Value '${String(e)}' is not an array of strings.`);
3192
3228
  this._value = e, this._onChange(this._value);
3193
3229
  }
@@ -3195,7 +3231,7 @@ class Te extends Q {
3195
3231
  return this._value;
3196
3232
  }
3197
3233
  }
3198
- class fe extends Q {
3234
+ class me extends K {
3199
3235
  _supportedRange;
3200
3236
  _step;
3201
3237
  _decimals;
@@ -3210,7 +3246,7 @@ class fe extends Q {
3210
3246
  super({ initialValue: e, effectiveValue: t, isEffective: i, onChange: s }), this._supportedRange = a, this._step = r, this._decimals = this._step.toString().includes(".") ? this._step.toString().split(".")[1].length : 0;
3211
3247
  }
3212
3248
  set value(e) {
3213
- if (e != null && N(e, this._supportedRange) === void 0)
3249
+ if (e != null && z(e, this._supportedRange) === void 0)
3214
3250
  throw new Error(`Value '${String(e)}' is out of the supported range for this preference.`);
3215
3251
  this._value = e, this._onChange(this._value);
3216
3252
  }
@@ -3239,7 +3275,7 @@ class fe extends Q {
3239
3275
  return e.toString();
3240
3276
  }
3241
3277
  }
3242
- class Bt {
3278
+ class Dt {
3243
3279
  preferences;
3244
3280
  settings;
3245
3281
  // Cloned rather than aliased: edits made through this editor's setters
@@ -3247,12 +3283,12 @@ class Bt {
3247
3283
  // once explicitly passed to submitPreferences() — discarding the editor
3248
3284
  // without submitting must leave the navigator untouched.
3249
3285
  constructor(e, t) {
3250
- this.preferences = new oe({ ...e }), this.settings = t;
3286
+ this.preferences = new le({ ...e }), this.settings = t;
3251
3287
  }
3252
3288
  // Explicit `null`s, not `undefined` — merging() skips `undefined` fields,
3253
3289
  // so only `null` actually clears them once submitted.
3254
3290
  clear() {
3255
- this.preferences = new oe({
3291
+ this.preferences = new le({
3256
3292
  format: null,
3257
3293
  inlineContextualization: null,
3258
3294
  verbosity: null,
@@ -3273,7 +3309,7 @@ class Bt {
3273
3309
  this.preferences[e] = t;
3274
3310
  }
3275
3311
  get format() {
3276
- return new ne({
3312
+ return new ie({
3277
3313
  initialValue: this.preferences.format,
3278
3314
  effectiveValue: this.settings.format,
3279
3315
  isEffective: this.preferences.format != null,
@@ -3290,7 +3326,7 @@ class Bt {
3290
3326
  });
3291
3327
  }
3292
3328
  get verbosity() {
3293
- return new ne({
3329
+ return new ie({
3294
3330
  initialValue: this.preferences.verbosity,
3295
3331
  effectiveValue: this.settings.verbosity,
3296
3332
  isEffective: this.preferences.verbosity != null,
@@ -3315,7 +3351,7 @@ class Bt {
3315
3351
  });
3316
3352
  }
3317
3353
  get language() {
3318
- return new ne({
3354
+ return new ie({
3319
3355
  initialValue: this.preferences.language,
3320
3356
  effectiveValue: this.settings.language,
3321
3357
  isEffective: this.preferences.language != null,
@@ -3324,7 +3360,7 @@ class Bt {
3324
3360
  });
3325
3361
  }
3326
3362
  get languageOverrides() {
3327
- return new Q({
3363
+ return new K({
3328
3364
  initialValue: this.preferences.languageOverrides,
3329
3365
  effectiveValue: this.settings.languageOverrides,
3330
3366
  isEffective: this.preferences.languageOverrides != null,
@@ -3332,7 +3368,7 @@ class Bt {
3332
3368
  });
3333
3369
  }
3334
3370
  get segmentation() {
3335
- return new ne({
3371
+ return new ie({
3336
3372
  initialValue: this.preferences.segmentation,
3337
3373
  effectiveValue: this.settings.segmentation,
3338
3374
  isEffective: this.preferences.segmentation != null,
@@ -3341,7 +3377,7 @@ class Bt {
3341
3377
  });
3342
3378
  }
3343
3379
  get voice() {
3344
- return new Q({
3380
+ return new K({
3345
3381
  initialValue: this.preferences.voice,
3346
3382
  effectiveValue: this.settings.voice,
3347
3383
  isEffective: this.preferences.voice != null,
@@ -3349,17 +3385,17 @@ class Bt {
3349
3385
  });
3350
3386
  }
3351
3387
  get pauseDuration() {
3352
- return new fe({
3388
+ return new me({
3353
3389
  initialValue: this.preferences.pauseDuration,
3354
3390
  effectiveValue: this.settings.pauseDuration,
3355
3391
  isEffective: this.preferences.pauseDuration != null,
3356
3392
  onChange: (e) => this.updatePreference("pauseDuration", e ?? null),
3357
- supportedRange: ye.range,
3358
- step: ye.step
3393
+ supportedRange: be.range,
3394
+ step: be.step
3359
3395
  });
3360
3396
  }
3361
3397
  get autoPause() {
3362
- return new ne({
3398
+ return new ie({
3363
3399
  initialValue: this.preferences.autoPause,
3364
3400
  effectiveValue: this.settings.autoPause,
3365
3401
  isEffective: this.preferences.autoPause != null,
@@ -3368,38 +3404,38 @@ class Bt {
3368
3404
  });
3369
3405
  }
3370
3406
  get rate() {
3371
- return new fe({
3407
+ return new me({
3372
3408
  initialValue: this.preferences.rate,
3373
3409
  effectiveValue: this.settings.rate,
3374
3410
  isEffective: this.preferences.rate != null,
3375
3411
  onChange: (e) => this.updatePreference("rate", e ?? null),
3376
- supportedRange: Se.range,
3377
- step: Se.step
3412
+ supportedRange: we.range,
3413
+ step: we.step
3378
3414
  });
3379
3415
  }
3380
3416
  get pitch() {
3381
- return new fe({
3417
+ return new me({
3382
3418
  initialValue: this.preferences.pitch,
3383
3419
  effectiveValue: this.settings.pitch,
3384
3420
  isEffective: this.preferences.pitch != null,
3385
3421
  onChange: (e) => this.updatePreference("pitch", e ?? null),
3386
- supportedRange: be.range,
3387
- step: be.step
3422
+ supportedRange: ke.range,
3423
+ step: ke.step
3388
3424
  });
3389
3425
  }
3390
3426
  get volume() {
3391
- return new fe({
3427
+ return new me({
3392
3428
  initialValue: this.preferences.volume,
3393
3429
  effectiveValue: this.settings.volume,
3394
3430
  isEffective: this.preferences.volume != null,
3395
3431
  onChange: (e) => this.updatePreference("volume", e ?? null),
3396
- supportedRange: we.range,
3397
- step: we.step
3432
+ supportedRange: Ce.range,
3433
+ step: Ce.step
3398
3434
  });
3399
3435
  }
3400
3436
  }
3401
- const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3402
- ...Ln,
3437
+ const Vn = ["audio", "figure", "image", "math", "table", "video"], xn = [
3438
+ ...Vn,
3403
3439
  "blockquote",
3404
3440
  "chapter",
3405
3441
  "cover",
@@ -3412,8 +3448,8 @@ const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3412
3448
  "rowheader",
3413
3449
  "subtitle",
3414
3450
  "tip"
3415
- ], zs = [
3416
- ...On,
3451
+ ], Fs = [
3452
+ ...xn,
3417
3453
  "abstract",
3418
3454
  "acknowledgments",
3419
3455
  "afterword",
@@ -3457,7 +3493,7 @@ const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3457
3493
  "separator",
3458
3494
  "summary",
3459
3495
  "term"
3460
- ], Ns = {
3496
+ ], _s = {
3461
3497
  none: /* @__PURE__ */ new Set([
3462
3498
  "aside",
3463
3499
  "audio",
@@ -3525,28 +3561,28 @@ const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3525
3561
  "toc"
3526
3562
  ]),
3527
3563
  most: /* @__PURE__ */ new Set(["landmarks", "loa", "loi", "lot", "lov", "toc"])
3528
- }, Ms = {
3564
+ }, $s = {
3529
3565
  none: /* @__PURE__ */ new Set(),
3530
- few: new Set(Ln),
3531
- some: new Set(On),
3532
- most: new Set(zs)
3566
+ few: new Set(Vn),
3567
+ some: new Set(xn),
3568
+ most: new Set(Fs)
3533
3569
  }, Ke = {
3534
3570
  table: { few: "inline", some: "block", most: "block" }
3535
3571
  };
3536
- function pe(n) {
3572
+ function ve(n) {
3537
3573
  const e = {};
3538
3574
  for (const t of Object.keys(Ke))
3539
3575
  e[t] = Ke[t]?.[n] ?? "inline";
3540
3576
  return e;
3541
3577
  }
3542
- const Bs = {
3543
- none: pe("none"),
3544
- few: pe("few"),
3545
- some: pe("some"),
3546
- most: pe("most")
3547
- }, er = Object.keys(Ke);
3548
- function js(n, e) {
3549
- const t = n === "custom" ? {} : Bs[n];
3578
+ const qs = {
3579
+ none: ve("none"),
3580
+ few: ve("few"),
3581
+ some: ve("some"),
3582
+ most: ve("most")
3583
+ }, or = Object.keys(Ke);
3584
+ function Gs(n, e) {
3585
+ const t = n === "custom" ? {} : qs[n];
3550
3586
  if (!e) return t;
3551
3587
  const i = { ...t };
3552
3588
  for (const s of Object.keys(e)) {
@@ -3555,10 +3591,10 @@ function js(n, e) {
3555
3591
  }
3556
3592
  return i;
3557
3593
  }
3558
- const Ds = (n, e) => {
3594
+ const Hs = (n, e) => {
3559
3595
  if (!e || typeof n == "string") return n;
3560
- const [t] = C(e.language);
3561
- return !t || n && nt(n, t) !== void 0 ? n : { ...n, [t]: Pn(e) };
3596
+ const [t] = k(e.language);
3597
+ return !t || n && nt(n, t) !== void 0 ? n : { ...n, [t]: Ln(e) };
3562
3598
  };
3563
3599
  class ze {
3564
3600
  format;
@@ -3579,35 +3615,35 @@ class ze {
3579
3615
  * @param engineVoice The engine's voice, which `voice` falls back to: when unset, or for its language in a record without it.
3580
3616
  */
3581
3617
  constructor(e, t, i) {
3582
- 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 = [...Ns[this.verbosity]], this.contextualize = [...Ms[this.verbosity]]), this.language = e.language ?? t.language, this.languageOverrides = e.languageOverrides ?? t.languageOverrides, this.segmentation = e.segmentation ?? t.segmentation, this.voice = Ds(e.voice ?? t.voice, i), 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;
3618
+ 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 = [..._s[this.verbosity]], this.contextualize = [...$s[this.verbosity]]), this.language = e.language ?? t.language, this.languageOverrides = e.languageOverrides ?? t.languageOverrides, this.segmentation = e.segmentation ?? t.segmentation, this.voice = Hs(e.voice ?? t.voice, i), 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;
3583
3619
  }
3584
3620
  }
3585
- const jt = /* @__PURE__ */ new WeakMap(), xn = /* @__PURE__ */ new WeakMap();
3586
- function Dt(n, e) {
3587
- xn.set(n, e);
3621
+ const jt = /* @__PURE__ */ new WeakMap(), Un = /* @__PURE__ */ new WeakMap();
3622
+ function Ft(n, e) {
3623
+ Un.set(n, e);
3588
3624
  }
3589
- const Vn = /* @__PURE__ */ new WeakSet();
3590
- function Ft(n) {
3591
- return Vn.add(n), n;
3625
+ const Tn = /* @__PURE__ */ new WeakSet();
3626
+ function _t(n) {
3627
+ return Tn.add(n), n;
3592
3628
  }
3593
- function Fs(n, e, t) {
3594
- const i = xn.get(n);
3629
+ function Ks(n, e, t) {
3630
+ const i = Un.get(n);
3595
3631
  if (i) {
3596
- const u = Vt(i.map, e), g = Vt(i.map, e + t);
3632
+ const u = Ut(i.map, e), g = Ut(i.map, e + t);
3597
3633
  e = u, t = Math.max(0, g - u);
3598
3634
  }
3599
- const s = n.offsets, a = !n.plain && !!n.ssml, r = i?.plain ?? n.plain ?? (n.ssml ? M(n.ssml) : "");
3635
+ const s = n.offsets, a = !n.plain && !!n.ssml, r = i?.plain ?? n.plain ?? (n.ssml ? N(n.ssml) : "");
3600
3636
  if (!s?.length || !r) return;
3601
3637
  const o = jt.get(n), l = o !== void 0 && e >= o.cursor;
3602
3638
  let c = l ? o.cursor : 0;
3603
3639
  for (let u = l ? o.pieceIndex : 0; u < s.length; u++) {
3604
- const g = s[u], d = g.locate.text?.highlight, h = d ? a ? M(d) : d : r.slice(c);
3640
+ const g = s[u], d = g.locate.text?.highlight, h = d ? a ? N(d) : d : r.slice(c);
3605
3641
  if (!h) continue;
3606
3642
  const f = r.indexOf(h, c);
3607
3643
  if (f === -1) continue;
3608
3644
  const p = f + h.length;
3609
3645
  if (e >= f && e < p) {
3610
- if (Vn.has(g.locate)) return;
3646
+ if (Tn.has(g.locate)) return;
3611
3647
  jt.set(n, { pieceIndex: u, cursor: c });
3612
3648
  const m = e - f, S = h.substring(m, Math.min(m + t, h.length));
3613
3649
  return { locate: {
@@ -3623,13 +3659,13 @@ function Fs(n, e, t) {
3623
3659
  c = p;
3624
3660
  }
3625
3661
  }
3626
- function _s(n, e) {
3662
+ function Ws(n, e) {
3627
3663
  return e === "sentence" && n.offsets?.length ? n.offsets.map((t) => t.locate) : n.locate ? [n.locate] : [];
3628
3664
  }
3629
- function V(n) {
3665
+ function x(n) {
3630
3666
  return { pattern: new RegExp(`(\\d+)\\s?u${n}\\b`, "g"), replace: (e, t) => `${t}µ${n}` };
3631
3667
  }
3632
- const $s = {
3668
+ const Qs = {
3633
3669
  "1/4": "¼",
3634
3670
  "1/2": "½",
3635
3671
  "3/4": "¾",
@@ -3649,8 +3685,8 @@ const $s = {
3649
3685
  "5/8": "⅝",
3650
3686
  "7/8": "⅞",
3651
3687
  "0/3": "↉"
3652
- }, qs = {
3653
- ...$s,
3688
+ }, Js = {
3689
+ ...Qs,
3654
3690
  // Rejects "(c)" directly preceded by "(a)"/"(b)" (a lettered list, not a copyright notice).
3655
3691
  "(c)": { pattern: new RegExp("(?<!\\([ab]\\)\\s{0,3})\\(c\\)", "g"), replace: "©" },
3656
3692
  "(C)": { pattern: new RegExp("(?<!\\([AB]\\)\\s{0,3})\\(C\\)", "g"), replace: "©" },
@@ -3660,37 +3696,37 @@ const $s = {
3660
3696
  "(TM)": "™",
3661
3697
  deg: { pattern: /(\d+)\s?deg\b/g, replace: (n, e) => `${e}°` },
3662
3698
  x: { pattern: /(\d+)\s?[xX]\s?(?=\d)/g, replace: (n, e) => `${e}×` },
3663
- ug: V("g"),
3664
- um: V("m"),
3665
- us: V("s"),
3666
- uL: V("L"),
3667
- uF: V("F"),
3668
- uA: V("A"),
3669
- uV: V("V"),
3670
- uW: V("W"),
3671
- uN: V("N"),
3672
- umol: V("mol"),
3699
+ ug: x("g"),
3700
+ um: x("m"),
3701
+ us: x("s"),
3702
+ uL: x("L"),
3703
+ uF: x("F"),
3704
+ uA: x("A"),
3705
+ uV: x("V"),
3706
+ uW: x("W"),
3707
+ uN: x("N"),
3708
+ umol: x("mol"),
3673
3709
  "->": "→",
3674
3710
  "<-": "←",
3675
3711
  // Reversed from every other entry: engines pattern-match the ASCII foot/inch
3676
3712
  // convention for pronunciation, but drop the real prime marks silently.
3677
3713
  "′": "'",
3678
3714
  "″": '"'
3679
- }, Gs = { 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.", number: "Page {{ number }}" }, 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." } } } }, Hs = {
3680
- speech: Gs
3681
- }, Un = Hs.speech.contextualizations, We = { en: Un }, Tn = {};
3682
- function Ks(n) {
3683
- return We[n] || Tn[n] ? n : "en";
3715
+ }, Zs = { 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.", number: "Page {{ number }}" }, 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." } } } }, Xs = {
3716
+ speech: Zs
3717
+ }, zn = Xs.speech.contextualizations, We = { en: zn }, Nn = {};
3718
+ function Ys(n) {
3719
+ return We[n] || Nn[n] ? n : "en";
3684
3720
  }
3685
- async function Ws(n) {
3721
+ async function ea(n) {
3686
3722
  const e = We[n];
3687
3723
  if (e) return e;
3688
- const t = Tn[n];
3689
- if (!t) return Un;
3724
+ const t = Nn[n];
3725
+ if (!t) return zn;
3690
3726
  const i = (await t()).speech.contextualizations;
3691
3727
  return We[n] = i, i;
3692
3728
  }
3693
- const Qs = {
3729
+ const ta = {
3694
3730
  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."],
3695
3731
  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."],
3696
3732
  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."],
@@ -3705,34 +3741,34 @@ function Ne(n, e, t) {
3705
3741
  for (; i > e && /\s/.test(n[i - 1]); ) i--;
3706
3742
  return i;
3707
3743
  }
3708
- const Js = /[\s([{"'“‘]/;
3709
- function Zs(n, e) {
3744
+ const na = /[\s([{"'“‘]/;
3745
+ function ia(n, e) {
3710
3746
  for (const t of e) {
3711
3747
  if (n.length < t.length || !n.endsWith(t)) continue;
3712
3748
  const i = n.length - t.length - 1;
3713
- if (i < 0 || Js.test(n[i])) return !0;
3749
+ if (i < 0 || na.test(n[i])) return !0;
3714
3750
  }
3715
3751
  return !1;
3716
3752
  }
3717
- function Xs(n) {
3753
+ function sa(n) {
3718
3754
  let e = 0;
3719
3755
  for (const t of n)
3720
3756
  if (new RegExp("\\p{L}", "u").test(t) && e++, e >= 2) return !0;
3721
3757
  return !1;
3722
3758
  }
3723
- function Ys(n) {
3759
+ function aa(n) {
3724
3760
  return /\.{3,}$/.test(n);
3725
3761
  }
3726
- function ea(n, e, t, i) {
3762
+ function ra(n, e, t, i) {
3727
3763
  if (i === "“") return !0;
3728
3764
  if (i !== '"') return !1;
3729
3765
  let s = 0;
3730
3766
  for (let a = e; a < t; a++) n[a] === '"' && s++;
3731
3767
  return s % 2 === 1;
3732
3768
  }
3733
- const ta = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
3734
- function na(n, e) {
3735
- const t = [...n.matchAll(ta)].map((s) => s.index + s[0].length);
3769
+ const oa = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
3770
+ function la(n, e) {
3771
+ const t = [...n.matchAll(oa)].map((s) => s.index + s[0].length);
3736
3772
  if (t.length === 0) return e;
3737
3773
  const i = [];
3738
3774
  for (const s of e) {
@@ -3743,20 +3779,42 @@ function na(n, e) {
3743
3779
  }
3744
3780
  return i;
3745
3781
  }
3746
- function ia(n, e, t) {
3747
- const i = na(n, e).map((a) => ({ ...a }));
3782
+ const ca = { "»": "«", "«": "»", "›": "‹", "‹": "›" };
3783
+ function ua(n, e) {
3784
+ const t = [], i = /* @__PURE__ */ new Map();
3785
+ let s = 0;
3786
+ const a = (r, o) => {
3787
+ for (; s < r; s++) i.set(n[s], (i.get(n[s]) ?? 0) + 1);
3788
+ return i.get(o) ?? 0;
3789
+ };
3790
+ for (const r of e) {
3791
+ const o = { ...r }, l = t[t.length - 1];
3792
+ let c = o.start;
3793
+ for (; l && c < o.end; ) {
3794
+ for (; c < o.end && /\s/.test(n[c]); ) c++;
3795
+ const u = ca[n[c]];
3796
+ if (u === void 0 || a(l.end, u) <= a(l.end, n[c])) break;
3797
+ for (c++; c < o.end && /\s/.test(n[c]); ) c++;
3798
+ l.end = o.start = c;
3799
+ }
3800
+ o.start < o.end ? t.push(o) : l && (l.end = o.end);
3801
+ }
3802
+ return t;
3803
+ }
3804
+ function ha(n, e, t) {
3805
+ const i = ua(n, la(n, e));
3748
3806
  for (let a = 0; a < i.length - 1; a++) {
3749
3807
  const r = Ne(n, i[a].start, i[a].end);
3750
3808
  if (r !== i[a].end || r <= i[a].start) continue;
3751
3809
  const o = n[r - 1];
3752
- ea(n, i[a].start, r, o) && (i[a].end -= 1, i[a + 1].start -= 1);
3810
+ ra(n, i[a].start, r, o) && (i[a].end -= 1, i[a + 1].start -= 1);
3753
3811
  }
3754
3812
  const s = [];
3755
3813
  for (const a of i) {
3756
3814
  let r = a;
3757
3815
  for (; s.length > 0; ) {
3758
3816
  const o = s[s.length - 1], l = Ne(n, o.start, o.end), c = n.slice(o.start, l);
3759
- if (!Zs(c, t) && Xs(c) && !Ys(c)) break;
3817
+ if (!ia(c, t) && sa(c) && !aa(c)) break;
3760
3818
  s.pop(), r = { start: o.start, end: r.end };
3761
3819
  }
3762
3820
  s.push(r);
@@ -3766,17 +3824,29 @@ function ia(n, e, t) {
3766
3824
  return { text: n.slice(a.start, r), start: a.start, end: a.end, contentEnd: r };
3767
3825
  });
3768
3826
  }
3769
- const _t = /* @__PURE__ */ new Map();
3770
- function sa(n) {
3771
- let e = _t.get(n);
3772
- return e || (e = new Intl.Segmenter(n, { granularity: "sentence" }), _t.set(n, e)), e;
3827
+ const $t = /* @__PURE__ */ new Map();
3828
+ function Mn(n) {
3829
+ let e = $t.get(n);
3830
+ if (!e) {
3831
+ try {
3832
+ const [t, i] = k(n), s = i ? `${t}-${i}` : t;
3833
+ e = { segmenter: new Intl.Segmenter(s, { granularity: "sentence" }), language: n };
3834
+ } catch {
3835
+ e = { segmenter: new Intl.Segmenter("en", { granularity: "sentence" }), language: "en" };
3836
+ }
3837
+ $t.set(n, e);
3838
+ }
3839
+ return e;
3840
+ }
3841
+ function da(n) {
3842
+ return Mn(n).language;
3773
3843
  }
3774
- async function aa(n, e, t) {
3844
+ async function Bn(n, e, t) {
3775
3845
  if (e === "") return [];
3776
- const s = [...sa(n).segment(e)].map((o) => ({ start: o.index, end: o.index + o.segment.length })), a = Ce(Qs, n) ?? [], r = t ? [...a, ...t] : a;
3777
- return ia(e, s, r);
3846
+ const { segmenter: i, language: s } = Mn(n), r = [...i.segment(e)].map((c) => ({ start: c.index, end: c.index + c.segment.length })), o = cn(ta, s) ?? [], l = t ? [...o, ...t] : o;
3847
+ return ha(e, r, l);
3778
3848
  }
3779
- const tr = [
3849
+ const lr = [
3780
3850
  "aside",
3781
3851
  "audio",
3782
3852
  "bibliography",
@@ -3802,7 +3872,7 @@ const tr = [
3802
3872
  "table",
3803
3873
  "toc",
3804
3874
  "video"
3805
- ], ra = [
3875
+ ], ga = [
3806
3876
  // Headings
3807
3877
  "heading1",
3808
3878
  "heading2",
@@ -3860,50 +3930,50 @@ const tr = [
3860
3930
  "section",
3861
3931
  "summary",
3862
3932
  "tip"
3863
- ], oa = {
3933
+ ], fa = {
3864
3934
  footnote: { drops: ["aside"], unconditional: !0 },
3865
3935
  cover: { drops: ["image"] },
3866
3936
  pullquote: { drops: ["blockquote", "aside"] },
3867
3937
  epigraph: { drops: ["blockquote"] }
3868
- }, la = ["noteref", "pagebreak"], ca = ["audio", "video", "image", "figure", "math", "table", "cover"], ua = ["cell", "rowheader"], ha = ["separator"], $t = new Set(ra), zn = new Set(la), da = new Set(ca), Nn = new Set(ua), ga = new Set(ha);
3869
- function fa(n, e) {
3870
- const t = ui.createInstance();
3938
+ }, pa = ["noteref", "pagebreak"], ma = ["audio", "video", "image", "figure", "math", "table", "cover"], va = ["cell", "rowheader"], ya = ["separator"], qt = new Set(ga), Dn = new Set(pa), Sa = new Set(ma), jn = new Set(va), ba = new Set(ya);
3939
+ function wa(n, e) {
3940
+ const t = pi.createInstance();
3871
3941
  return t.init({
3872
3942
  lng: n,
3873
3943
  resources: { [n]: { translation: e } },
3874
3944
  interpolation: { escapeValue: !1 }
3875
3945
  }), t;
3876
3946
  }
3877
- function pa(n, e, t) {
3947
+ function ka(n, e, t) {
3878
3948
  if (!e) return n;
3879
3949
  const i = { ...n };
3880
3950
  for (const s of Object.keys(e))
3881
3951
  i[s] = t(n[s], e[s]);
3882
3952
  return i;
3883
3953
  }
3884
- function Mn(n, e) {
3954
+ function Fn(n, e) {
3885
3955
  if (typeof e == "string" || typeof n != "object") return e;
3886
3956
  const t = { ...n };
3887
3957
  for (const i of Object.keys(e))
3888
- t[i] = Mn(n[i], e[i]);
3958
+ t[i] = Fn(n[i], e[i]);
3889
3959
  return t;
3890
3960
  }
3891
- function ma(n, e) {
3892
- return pa(n, e, Mn);
3961
+ function Ca(n, e) {
3962
+ return ka(n, e, Fn);
3893
3963
  }
3894
- function Bn(n, e = [], t = /* @__PURE__ */ new Map()) {
3964
+ function _n(n, e = [], t = /* @__PURE__ */ new Map()) {
3895
3965
  for (const i of n)
3896
- t.set(i, e), i.children && Bn(i.children, [i, ...e], t);
3966
+ t.set(i, e), i.children && _n(i.children, [i, ...e], t);
3897
3967
  return t;
3898
3968
  }
3899
- async function jn(n, e) {
3900
- const t = e.contextualizationLocale ?? "en", i = ma(
3901
- await Ws(t),
3969
+ async function $n(n, e) {
3970
+ const t = e.contextualizationLocale ?? "en", i = Ca(
3971
+ await ea(t),
3902
3972
  e.contextualization?.contextualizations
3903
3973
  );
3904
3974
  return {
3905
- i18n: fa(t, i),
3906
- contextualizationLanguage: Ks(t),
3975
+ i18n: wa(t, i),
3976
+ contextualizationLanguage: Ys(t),
3907
3977
  skip: new Set(e.skip ?? []),
3908
3978
  contextualize: new Set(e.contextualize ?? []),
3909
3979
  contextualizationShapes: e.contextualization?.shapes ?? {},
@@ -3912,109 +3982,113 @@ async function jn(n, e) {
3912
3982
  inlineContextualization: new Set(e.inlineContextualization ?? []),
3913
3983
  language: e.language ?? "block-level",
3914
3984
  languageOverrides: e.languageOverrides ?? {},
3985
+ contentLanguage: e.contentLanguage,
3915
3986
  segmentation: e.segmentation?.mode ?? "structure",
3916
3987
  // segmentSentences() already applies builtInSuppressions internally
3917
3988
  // (Intl.Segmenter has no built-in equivalent of its own) — this is only
3918
3989
  // the caller's own additive extras, per `SegmentationOptions.suppressions`.
3919
3990
  segmentationSuppressions: e.segmentation?.suppressions ?? {},
3920
- segmenter: e.segmentation?.segmenter ?? aa,
3991
+ segmenter: e.segmentation?.segmenter ?? Bn,
3921
3992
  // Per-key override, not an additive union — each key holds one whole rule.
3922
- substitutions: { ...qs, ...e.substitutions },
3993
+ substitutions: { ...Js, ...e.substitutions },
3923
3994
  blockStarts: /* @__PURE__ */ new Set(),
3924
3995
  tableRowNumbers: /* @__PURE__ */ new Map(),
3925
3996
  tableCellHeaders: /* @__PURE__ */ new Map(),
3926
3997
  synthetic: /* @__PURE__ */ new Set(),
3927
- ancestorChains: Bn(n),
3998
+ ancestorChains: _n(n),
3928
3999
  pendingRange: /* @__PURE__ */ new Map(),
3929
4000
  edgeSubstitutedLocate: /* @__PURE__ */ new WeakMap(),
3930
4001
  placeholderPieces: /* @__PURE__ */ new Map()
3931
4002
  };
3932
4003
  }
3933
- const va = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
3934
- function Dn(n) {
3935
- return n.replace(va, "$1");
4004
+ const Ea = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
4005
+ function qn(n) {
4006
+ return n.replace(Ea, "$1");
3936
4007
  }
3937
- function j(n, e) {
4008
+ function Gn(n, e) {
3938
4009
  return n === void 0 ? void 0 : nt(e, n) ?? n;
3939
4010
  }
4011
+ function M(n, e) {
4012
+ return Gn(e.language === "none" ? e.contentLanguage : n ?? e.contentLanguage, e.languageOverrides);
4013
+ }
3940
4014
  function ft(n, e) {
3941
4015
  return n === e || n !== void 0 && e !== void 0 && n.toLowerCase() === e.toLowerCase();
3942
4016
  }
3943
4017
  function Qe(n, e) {
3944
- return C(n)[0] === C(e)[0];
4018
+ return k(n)[0] === k(e)[0];
3945
4019
  }
3946
4020
  function Je(n, e, t, i) {
3947
4021
  const { language: s } = e;
3948
- return s === void 0 ? !0 : _n(e, t) ? !i && n.content !== void 0 && !Qe(n.content, s) ? !1 : (n.entry = s, !0) : n.content !== void 0 && !ft(n.content, s) || !i && n.entry !== void 0 && !Qe(s, n.entry) ? !1 : (n.content = s, !0);
4022
+ return s === void 0 ? !0 : Kn(e, t) ? !i && n.content !== void 0 && !Qe(n.content, s) ? !1 : (n.entry = s, !0) : n.content !== void 0 && !ft(n.content, s) || !i && n.entry !== void 0 && !Qe(s, n.entry) ? !1 : (n.content = s, !0);
3949
4023
  }
3950
- function Fn(n, e, t) {
4024
+ function Hn(n, e, t) {
3951
4025
  const i = {};
3952
4026
  for (const s of n)
3953
4027
  if (!Je(i, s, e, t)) return null;
3954
4028
  return i.content ?? i.entry;
3955
4029
  }
3956
- function ya(n, e) {
3957
- return Fn(n, e, !1);
4030
+ function Ra(n, e) {
4031
+ return Hn(n, e, !1);
3958
4032
  }
3959
- function _n(n, e) {
4033
+ function Kn(n, e) {
3960
4034
  return e.synthetic.has(n) && ft(n.language, e.contextualizationLanguage);
3961
4035
  }
3962
- function $n(n, e) {
3963
- return Fn(n, e, e.format === "ssml");
4036
+ function Wn(n, e) {
4037
+ return Hn(n, e, e.format === "ssml");
3964
4038
  }
3965
- function qn(n, e, t) {
4039
+ function Qn(n, e, t) {
3966
4040
  const i = n.ssml ?? "";
3967
- return !e || !n.language || !_n(n, t) || Qe(n.language, e) ? i : `<lang xml:lang="${on(n.language)}">${i}</lang>`;
4041
+ return !e || !n.language || !Kn(n, t) || Qe(n.language, e) ? i : `<lang xml:lang="${ln(n.language)}">${i}</lang>`;
3968
4042
  }
3969
- function Gn(n, e) {
4043
+ function Jn(n, e) {
3970
4044
  const t = e.format === "ssml", i = [];
3971
4045
  let s = 0, a = {};
3972
4046
  return n.forEach((r, o) => {
3973
4047
  Je(a, r, e, t) || (i.push([s, o]), s = o, a = {}, Je(a, r, e, t));
3974
4048
  }), n.length > 0 && i.push([s, n.length]), i;
3975
4049
  }
3976
- function Hn(n, e) {
4050
+ function Zn(n, e) {
3977
4051
  return n.replace(/<lang xml:lang="([^"]*)">/g, (t, i) => {
3978
- const s = j(i, e);
4052
+ const s = Gn(i, e);
3979
4053
  return s === i ? t : `<lang xml:lang="${s}">`;
3980
4054
  });
3981
4055
  }
3982
- function J(n) {
4056
+ function W(n) {
3983
4057
  return n.role ? [...n.role] : [];
3984
4058
  }
3985
4059
  function Ze(n) {
3986
4060
  return n.role?.has("math") ? void 0 : n.text;
3987
4061
  }
3988
- function Le(n) {
4062
+ function Oe(n) {
3989
4063
  const e = n.description?.text;
3990
4064
  if (e)
3991
- return e.plain ?? (e.ssml !== void 0 ? M(e.ssml) : void 0);
4065
+ return e.plain ?? (e.ssml !== void 0 ? N(e.ssml) : void 0);
3992
4066
  }
3993
- function Kn(n) {
4067
+ function Xn(n) {
3994
4068
  return n.description?.text?.language;
3995
4069
  }
3996
- function X(n, e) {
4070
+ function J(n, e) {
3997
4071
  const t = n.cssSelector ?? n.domRange?.start.cssSelector;
3998
4072
  if (!t) return { ...n, text: { highlight: e } };
3999
4073
  const i = { cssSelector: t, text: { highlight: e } };
4000
4074
  return n.href !== void 0 && (i.href = n.href), i;
4001
4075
  }
4002
4076
  function L(n, e) {
4003
- const t = Ct(n);
4077
+ const t = Et(n);
4004
4078
  if (t) return { own: !0, ref: t };
4005
4079
  for (const i of e.get(n) ?? []) {
4006
- const s = Ct(i);
4080
+ const s = Et(i);
4007
4081
  if (s) return { own: !1, ref: s };
4008
4082
  }
4009
4083
  }
4010
4084
  function pt(n, e) {
4011
4085
  if (n)
4012
- return n.own ? n.ref : X(n.ref, e);
4086
+ return n.own ? n.ref : J(n.ref, e);
4013
4087
  }
4014
4088
  function mt(n, e, t) {
4015
- return (n && e ? hi(n.ref, e.ref) : void 0) ?? t;
4089
+ return (n && e ? mi(n.ref, e.ref) : void 0) ?? t;
4016
4090
  }
4017
- function Wn(n, e, t) {
4091
+ function Yn(n, e, t) {
4018
4092
  const { ancestorChains: i } = t, s = /* @__PURE__ */ new Map();
4019
4093
  for (const a of e)
4020
4094
  a && !Array.isArray(a) && s.set(a, (s.get(a) ?? 0) + 1);
@@ -4030,16 +4104,16 @@ function Wn(n, e, t) {
4030
4104
  const g = { ...a, locate: u.ref };
4031
4105
  if (!t.synthetic.has(a)) {
4032
4106
  const d = t.pendingRange.get(a), h = d !== void 0 || c && (s.get(c) ?? 0) > 1;
4033
- g.locate = u.own && !h ? u.ref : X(u.ref, l), g.offsets = [{ start: d?.start ?? 0, end: d?.end ?? l.length, locate: g.locate }];
4107
+ g.locate = u.own && !h ? u.ref : J(u.ref, l), g.offsets = [{ start: d?.start ?? 0, end: d?.end ?? l.length, locate: g.locate }];
4034
4108
  }
4035
4109
  return g;
4036
4110
  });
4037
4111
  }
4038
4112
  function vt(n) {
4039
4113
  const e = st(Ze(n));
4040
- return e ? e.plain ?? (e.ssml ? M(e.ssml) : "") : "";
4114
+ return e ? e.plain ?? (e.ssml ? N(e.ssml) : "") : "";
4041
4115
  }
4042
- function Sa(n) {
4116
+ function Ia(n) {
4043
4117
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
4044
4118
  let i = 0, s;
4045
4119
  return n.forEach((a, r) => {
@@ -4056,159 +4130,152 @@ function Sa(n) {
4056
4130
  });
4057
4131
  }), { lines: n.length, columns: i, rowNumbers: e, cellHeaders: t };
4058
4132
  }
4059
- function Qn(n, e) {
4060
- const t = e.format === "ssml" ? { ssml: z(n) } : { plain: n };
4133
+ function ei(n, e) {
4134
+ const t = e.format === "ssml" ? { ssml: T(n) } : { plain: n };
4061
4135
  return e.synthetic.add(t), t;
4062
4136
  }
4063
- function B(n, e) {
4064
- const t = Qn(n, e);
4065
- return e.language !== "none" && (t.language = e.contextualizationLanguage), t;
4137
+ function j(n, e) {
4138
+ const t = ei(n, e), i = e.language === "none" ? M(void 0, e) : e.contextualizationLanguage;
4139
+ return i && (t.language = i), t;
4066
4140
  }
4067
4141
  function Xe(n, e, t) {
4068
- const i = Qn(n, t);
4069
- if (t.language !== "none") {
4070
- const s = j(Kn(e), t.languageOverrides);
4071
- s && (i.language = s);
4072
- }
4073
- return i;
4142
+ const i = ei(n, t), s = M(Xn(e), t);
4143
+ return s && (i.language = s), i;
4074
4144
  }
4075
- function q(n, e, t, i) {
4145
+ function _(n, e, t, i) {
4076
4146
  n.push(...i);
4077
4147
  for (let s = 0; s < i.length; s++) e.push(t);
4078
4148
  }
4079
4149
  function Ye(n, e, t, i, s, a, r) {
4080
- r ? (s.some((o) => t.blockStarts.has(o)) && t.blockStarts.add(r), q(n, e, a[0] ?? i, [r])) : (n.push(...s), e.push(...a));
4150
+ r ? (s.some((o) => t.blockStarts.has(o)) && t.blockStarts.add(r), _(n, e, a[0] ?? i, [r])) : (n.push(...s), e.push(...a));
4081
4151
  }
4082
- function Z(n, e, t, i) {
4152
+ function Q(n, e, t, i) {
4083
4153
  const s = t ? `${e}.${t}` : void 0;
4084
4154
  if (s && n.i18n.exists(s)) return n.i18n.t(s, i);
4085
4155
  if (n.i18n.exists(e)) return n.i18n.t(e, i);
4086
4156
  }
4087
4157
  function yt(n, e) {
4088
- return Nn.has(n) ? !0 : e.contextualize.has(n);
4158
+ return jn.has(n) ? !0 : e.contextualize.has(n);
4089
4159
  }
4090
- function Jn(n, e, t) {
4160
+ function ti(n, e, t) {
4091
4161
  return e.some((i) => {
4092
- const s = oa[i];
4162
+ const s = fa[i];
4093
4163
  return s?.drops.includes(n) ? s.unconditional || yt(i, t) : !1;
4094
4164
  });
4095
4165
  }
4096
- function le(n, e, t, i, s) {
4166
+ function ce(n, e, t, i, s) {
4097
4167
  const a = e.lastIndexOf(t);
4098
4168
  if (a === -1) return;
4099
4169
  const r = L(i, s.ancestorChains);
4100
4170
  if (!r) return;
4101
- const o = X(r.ref, t);
4171
+ const o = J(r.ref, t);
4102
4172
  n.offsets = [{ start: a, end: a + t.length, locate: o }], n.locate = r.own ? r.ref : o;
4103
4173
  }
4104
4174
  function Me(n, e, t, i, s, a) {
4105
4175
  const r = a?.value;
4106
4176
  if (r !== void 0 && r === vt(t)) {
4107
- if (i.language !== "none") {
4108
- const l = j(t.text?.language, i.languageOverrides);
4109
- l && (n.language = l);
4110
- }
4111
- i.synthetic.delete(n), le(n, e, r, t, i);
4177
+ const l = M(t.text?.language, i);
4178
+ l && (n.language = l), i.synthetic.delete(n), ce(n, e, r, t, i);
4112
4179
  return;
4113
4180
  }
4114
4181
  const o = a?.description;
4115
- o !== void 0 && o === Le(t) && (s === "figure" || s === "table") && le(n, e, o, t, i);
4182
+ o !== void 0 && o === Oe(t) && (s === "figure" || s === "table") && ce(n, e, o, t, i);
4116
4183
  }
4117
- function qt(n, e, t, i, s, a, r, o) {
4184
+ function Gt(n, e, t, i, s, a, r, o) {
4118
4185
  if (!yt(s, i)) return;
4119
4186
  if ((i.i18n.exists(`${s}.block.start`) || i.i18n.exists(`${s}.block.end`)) && i.contextualizationShapes[s] !== "inline") {
4120
4187
  const c = a === "before" ? `${s}.block.start` : `${s}.block.end`;
4121
- q(n, e, t, Ht(c, r, o, t, s, i));
4188
+ _(n, e, t, Kt(c, r, o, t, s, i));
4122
4189
  return;
4123
4190
  }
4124
- a === "before" && q(n, e, t, Ht(`${s}.inline`, r, o, t, s, i));
4191
+ a === "before" && _(n, e, t, Kt(`${s}.inline`, r, o, t, s, i));
4125
4192
  }
4126
- const Gt = "\0";
4127
- function Ht(n, e, t, i, s, a) {
4128
- const r = Z(a, n, e, t);
4193
+ const Ht = "\0";
4194
+ function Kt(n, e, t, i, s, a) {
4195
+ const r = Q(a, n, e, t);
4129
4196
  if (!r) return [];
4130
- const o = t?.description, l = a.language !== "none" && o !== void 0 && o === Le(i) ? j(Kn(i), a.languageOverrides) : void 0, c = l ? Z(a, n, e, { ...t, description: Gt })?.split(Gt) : void 0;
4197
+ const o = t?.description, l = a.language !== "none" && o !== void 0 && o === Oe(i) ? M(Xn(i), a) : void 0, c = l ? Q(a, n, e, { ...t, description: Ht })?.split(Ht) : void 0;
4131
4198
  if (!l || !c || c.length < 2) {
4132
- const d = B(r, a);
4199
+ const d = j(r, a);
4133
4200
  return Me(d, r, i, a, s, t), [d];
4134
4201
  }
4135
- if (C(l)[0] === C(a.contextualizationLanguage)[0]) {
4136
- const d = B(r, a);
4202
+ if (k(l)[0] === k(a.contextualizationLanguage)[0]) {
4203
+ const d = j(r, a);
4137
4204
  return d.language = l, Me(d, r, i, a, s, t), [d];
4138
4205
  }
4139
- const u = `<lang xml:lang="${on(l)}">${z(o)}</lang>`, g = c.map((d) => z(d)).join(u);
4206
+ const u = `<lang xml:lang="${ln(l)}">${T(o)}</lang>`, g = c.map((d) => T(d)).join(u);
4140
4207
  if (a.format === "ssml") {
4141
- const d = B(r, a);
4208
+ const d = j(r, a);
4142
4209
  return d.ssml = g, Me(d, r, i, a, s, t), [d];
4143
4210
  }
4144
4211
  return at(g, a.contextualizationLanguage).map((d) => {
4145
- if (d.language !== l) return B(d.plain, a);
4212
+ if (d.language !== l) return j(d.plain, a);
4146
4213
  const h = Xe(d.plain, i, a);
4147
- return (s === "figure" || s === "table") && le(h, d.plain, o, i, a), h;
4214
+ return (s === "figure" || s === "table") && ce(h, d.plain, o, i, a), h;
4148
4215
  });
4149
4216
  }
4150
- function Kt(n, e, t, i) {
4217
+ function Wt(n, e, t, i) {
4151
4218
  const s = `${e}.parts.${t}`;
4152
4219
  return n.i18n.exists(s, { count: i }) ? n.i18n.t(s, { count: i }) : String(i);
4153
4220
  }
4154
- function ba(n) {
4155
- const e = Le(n);
4221
+ function Pa(n) {
4222
+ const e = Oe(n);
4156
4223
  return e === void 0 ? { variantKey: "unlabelled" } : { variantKey: "labelled", params: { description: e } };
4157
4224
  }
4158
- function Wt(n, e) {
4225
+ function Qt(n, e) {
4159
4226
  const t = e.tableCellHeaders.get(n);
4160
4227
  return {
4161
4228
  variantKey: t !== void 0 ? "withHeader" : "withoutHeader",
4162
4229
  params: { header: t ?? "", value: vt(n) }
4163
4230
  };
4164
4231
  }
4165
- const wa = {
4232
+ const Aa = {
4166
4233
  table: (n, e) => {
4167
- const t = (n.children ?? []).filter((s) => s.role?.has("row")), i = Sa(t);
4234
+ const t = (n.children ?? []).filter((s) => s.role?.has("row")), i = Ia(t);
4168
4235
  for (const [s, a] of i.rowNumbers) e.tableRowNumbers.set(s, a);
4169
4236
  for (const [s, a] of i.cellHeaders) e.tableCellHeaders.set(s, a);
4170
4237
  return {
4171
4238
  params: {
4172
- lines: Kt(e, "table", "lines", i.lines),
4173
- columns: Kt(e, "table", "columns", i.columns)
4239
+ lines: Wt(e, "table", "lines", i.lines),
4240
+ columns: Wt(e, "table", "columns", i.columns)
4174
4241
  }
4175
4242
  };
4176
4243
  },
4177
4244
  row: (n, e) => ({ params: { count: String(e.tableRowNumbers.get(n) ?? "") } }),
4178
- cell: Wt,
4179
- rowheader: Wt
4245
+ cell: Qt,
4246
+ rowheader: Qt
4180
4247
  };
4181
- function Qt(n, e, t) {
4182
- const i = ba(e);
4248
+ function Jt(n, e, t) {
4249
+ const i = Pa(e);
4183
4250
  let s = i.variantKey, a = i.params;
4184
- const r = wa[n]?.(e, t);
4251
+ const r = Aa[n]?.(e, t);
4185
4252
  r && (r.variantKey && (s = r.variantKey), a = { ...a, ...r.params });
4186
4253
  const o = t.contextualizationParams?.(n, e);
4187
4254
  return o && (a = { ...a, ...o }), { variantKey: s, params: a };
4188
4255
  }
4189
- function ke(n, e = n) {
4256
+ function Ee(n, e = n) {
4190
4257
  let t = "", i = "";
4191
4258
  const s = [];
4192
4259
  return n.forEach((a, r) => {
4193
4260
  const o = e[r];
4194
- if (o.length === 1 && qi(o) && i.endsWith(o)) {
4261
+ if (o.length === 1 && Qi(o) && i.endsWith(o)) {
4195
4262
  s.push({ start: t.length, end: t.length });
4196
4263
  return;
4197
4264
  }
4198
- i && !ue(o) && !/\s$/.test(i) && !/^\s/.test(o) && (t += " ", i += " ");
4265
+ i && !he(o) && !/\s$/.test(i) && !/^\s/.test(o) && (t += " ", i += " ");
4199
4266
  const l = t.length;
4200
4267
  t += a, i += o, s.push({ start: l, end: t.length });
4201
4268
  }), { joined: t, ranges: s };
4202
4269
  }
4203
- function Oe(n, e) {
4204
- const t = di(n), i = L(n, e.ancestorChains)?.ref;
4270
+ function Ve(n, e) {
4271
+ const t = vi(n), i = L(n, e.ancestorChains)?.ref;
4205
4272
  if (t) {
4206
4273
  const s = { cssSelector: t };
4207
- return i?.href !== void 0 && (s.href = i.href), Ft(s);
4274
+ return i?.href !== void 0 && (s.href = i.href), _t(s);
4208
4275
  }
4209
- return i && Ft(i);
4276
+ return i && _t(i);
4210
4277
  }
4211
- function Zn(n, e, t) {
4278
+ function ni(n, e, t) {
4212
4279
  const i = [];
4213
4280
  return n.forEach((s, a) => {
4214
4281
  if (s.offsets) {
@@ -4222,17 +4289,17 @@ function Zn(n, e, t) {
4222
4289
  if (!o) return;
4223
4290
  const l = t.format === "ssml" ? s.ssml : s.plain;
4224
4291
  if (!l) return;
4225
- const c = t.pendingRange.get(s), u = he(r) ? Oe(r, t) ?? o.ref : X(o.ref, l);
4292
+ const c = t.pendingRange.get(s), u = de(r) ? Ve(r, t) ?? o.ref : J(o.ref, l);
4226
4293
  i.push({ start: c?.start ?? 0, end: c?.end ?? l.length, locate: u });
4227
4294
  }), i;
4228
4295
  }
4229
- function Jt(n, e, t, i) {
4296
+ function Zt(n, e, t, i) {
4230
4297
  const s = i.edgeSubstitutedLocate.get(n);
4231
4298
  if (s) return s[t];
4232
- if (!(!e || Array.isArray(e) || !he(e)))
4233
- return Oe(e, i);
4299
+ if (!(!e || Array.isArray(e) || !de(e)))
4300
+ return Ve(e, i);
4234
4301
  }
4235
- function ka(n, e, t) {
4302
+ function La(n, e, t) {
4236
4303
  const i = n.map((l, c) => {
4237
4304
  if (l.locate) return l.locate;
4238
4305
  if (t.synthetic.has(l)) return;
@@ -4240,7 +4307,7 @@ function ka(n, e, t) {
4240
4307
  if (!u || Array.isArray(u)) return;
4241
4308
  const g = t.format === "ssml" ? l.ssml : l.plain;
4242
4309
  if (g)
4243
- return he(u) ? L(u, t.ancestorChains) && Oe(u, t) : pt(L(u, t.ancestorChains), g);
4310
+ return de(u) ? L(u, t.ancestorChains) && Ve(u, t) : pt(L(u, t.ancestorChains), g);
4244
4311
  }), s = i.findIndex((l) => l !== void 0);
4245
4312
  if (s === -1) return;
4246
4313
  let a = i.length - 1;
@@ -4260,30 +4327,30 @@ function St(n, e, t) {
4260
4327
  p && (i.push(p), s.push(f), a.push(e[h]));
4261
4328
  }
4262
4329
  if (i.length === 0) return;
4263
- const r = $n(s, t);
4330
+ const r = Wn(s, t);
4264
4331
  if (r === null) return;
4265
- const { joined: o } = ke(t.format === "ssml" ? s.map((h) => qn(h, r, t)) : i), l = t.format === "ssml" ? { ssml: o } : { plain: o };
4332
+ const { joined: o } = Ee(t.format === "ssml" ? s.map((h) => Qn(h, r, t)) : i), l = t.format === "ssml" ? { ssml: o } : { plain: o };
4266
4333
  r && (l.language = r), n.some((h) => t.synthetic.has(h)) && t.synthetic.add(l);
4267
- const c = Zn(s, a, t);
4334
+ const c = ni(s, a, t);
4268
4335
  c.length > 0 && (l.offsets = c);
4269
- const u = ka(s, a, t);
4336
+ const u = La(s, a, t);
4270
4337
  u && (l.locate = u);
4271
- const g = Jt(s[0], a[0], "leading", t), d = Jt(s[s.length - 1], a[s.length - 1], "trailing", t);
4338
+ const g = Zt(s[0], a[0], "leading", t), d = Zt(s[s.length - 1], a[s.length - 1], "trailing", t);
4272
4339
  return (g || d) && t.edgeSubstitutedLocate.set(l, { leading: g, trailing: d }), l;
4273
4340
  }
4274
- function Xn(n, e, t, i) {
4275
- if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml && Sn(n.ssml))
4341
+ function ii(n, e, t, i) {
4342
+ if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml && wn(n.ssml))
4276
4343
  return at(n.ssml, n.language).map((r) => {
4277
- const o = { plain: r.plain }, l = j(r.language, i.languageOverrides);
4344
+ const o = { plain: r.plain }, l = M(r.language, i);
4278
4345
  return l && (o.language = l), i.pendingRange.set(o, { start: r.start, end: r.end }), o;
4279
4346
  });
4280
- const s = {}, a = j(n.language, i.languageOverrides);
4281
- return a && (s.language = a), e === "ssml" ? s.ssml = n.ssml ? Hn(n.ssml, i.languageOverrides) : z(n.plain ?? "") : s.plain = n.plain ?? M(n.ssml ?? ""), (t === "block-level" || t === "none") && (s.ssml && (s.ssml = Dn(s.ssml)), t === "none" && delete s.language), [s];
4347
+ const s = {}, a = M(n.language, i);
4348
+ return a && (s.language = a), e === "ssml" ? s.ssml = n.ssml ? Zn(n.ssml, i.languageOverrides) : T(n.plain ?? "") : s.plain = n.plain ?? N(n.ssml ?? ""), (t === "block-level" || t === "none") && s.ssml && (s.ssml = qn(s.ssml)), [s];
4282
4349
  }
4283
- function de(n, e) {
4350
+ function ge(n, e) {
4284
4351
  return e !== "ssml" ? n : n.replace(/<[^>]+>/g, "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
4285
4352
  }
4286
- const Zt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", Ca = "[\\u0374\\u02B9\\u0384']", Be = "[\\u05D0-\\u05EA]", Xt = "[\\u0400-\\u0481\\u048A-\\u04FF]", Ea = [
4353
+ const Xt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", Oa = "[\\u0374\\u02B9\\u0384']", Be = "[\\u05D0-\\u05EA]", Yt = "[\\u0400-\\u0481\\u048A-\\u04FF]", Va = [
4287
4354
  new RegExp("^\\p{Nd}+$", "u"),
4288
4355
  new RegExp("^\\p{Nl}+$", "u"),
4289
4356
  /^(?=[MDCLXVI])M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i,
@@ -4291,151 +4358,151 @@ const Zt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", Ca = "[\\u0374\\u0
4291
4358
  /^[፩-፼]+$/u,
4292
4359
  new RegExp(`^${Be}[\\u05F3']$`, "u"),
4293
4360
  new RegExp(`^${Be}+[\\u05F4"]${Be}$`, "u"),
4294
- new RegExp(`^(?:\\u0375${Zt})*${Zt}+${Ca}$`, "u"),
4361
+ new RegExp(`^(?:\\u0375${Xt})*${Xt}+${Oa}$`, "u"),
4295
4362
  /^(?:[Ա-Ֆա-և]̅)+$/u,
4296
- new RegExp(`^\\u0482?${Xt}+\\u0483${Xt}*$`, "u")
4363
+ new RegExp(`^\\u0482?${Yt}+\\u0483${Yt}*$`, "u")
4297
4364
  ];
4298
- function Ra(n) {
4365
+ function xa(n) {
4299
4366
  const e = n.trim();
4300
- return e.length > 0 && Ea.some((t) => t.test(e));
4367
+ return e.length > 0 && Va.some((t) => t.test(e));
4301
4368
  }
4302
- function Yt(n, e) {
4303
- return e.skip.size > 0 && n.some((t) => e.skip.has(t) && !Jn(t, n, e));
4369
+ function en(n, e) {
4370
+ return e.skip.size > 0 && n.some((t) => e.skip.has(t) && !ti(t, n, e));
4304
4371
  }
4305
- function Ia(n, e) {
4372
+ function Ua(n, e) {
4306
4373
  const t = st(n.text);
4307
4374
  if (!t) return [];
4308
- const i = t.plain ?? M(t.ssml ?? "");
4309
- if (Ra(i)) {
4310
- const s = Z(e, "pagebreak.number", void 0, { number: i.trim() });
4311
- if (s !== void 0) return [B(s, e)];
4375
+ const i = t.plain ?? N(t.ssml ?? "");
4376
+ if (xa(i)) {
4377
+ const s = Q(e, "pagebreak.number", void 0, { number: i.trim() });
4378
+ if (s !== void 0) return [j(s, e)];
4312
4379
  }
4313
- return Xn(t, e.format, e.language, e);
4380
+ return ii(t, e.format, e.language, e);
4314
4381
  }
4315
- function en(n) {
4382
+ function tn(n) {
4316
4383
  n.plain !== void 0 && (n.plain += "."), n.ssml !== void 0 && (n.ssml += ".");
4317
4384
  }
4318
- function Pa(n, e) {
4319
- const t = Ia(n, e);
4385
+ function Ta(n, e) {
4386
+ const t = Ua(n, e);
4320
4387
  if (!e.contextualize.has("pagebreak")) return t;
4321
- const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", s = Z(e, i);
4388
+ const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", s = Q(e, i);
4322
4389
  if (s === void 0) return t;
4323
- const a = B(s, e);
4390
+ const a = j(s, e);
4324
4391
  if (t.length === 0) return [a];
4325
4392
  const r = St([a, ...t], [void 0, ...t.map(() => n)], e);
4326
- return r ? (en(r), [r]) : (en(t[t.length - 1]), [a, ...t]);
4393
+ return r ? (tn(r), [r]) : (tn(t[t.length - 1]), [a, ...t]);
4327
4394
  }
4328
- function Aa(n, e) {
4329
- return J(n).some((t) => zn.has(t) && !e.inlineContextualization.has(t));
4395
+ function za(n, e) {
4396
+ return W(n).some((t) => Dn.has(t) && !e.inlineContextualization.has(t));
4330
4397
  }
4331
- function La(n, e, t, i, s, a, r) {
4332
- const o = n.text?.language, l = j(o, s.languageOverrides), c = new Map((n.children ?? []).map((m) => [m.id, m])), u = [], g = [], d = [], h = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), p = s.segmentation === "sentence";
4333
- for (const m of os(e)) {
4398
+ function Na(n, e, t, i, s, a, r) {
4399
+ const o = n.text?.language, l = M(o, s), c = new Map((n.children ?? []).map((m) => [m.id, m])), u = [], g = [], d = [], h = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), p = s.segmentation === "sentence";
4400
+ for (const m of ds(e)) {
4334
4401
  if (m.placeholderId !== void 0) {
4335
4402
  const v = c.get(m.placeholderId);
4336
4403
  if (!v) continue;
4337
- if (Aa(v, s)) {
4404
+ if (za(v, s)) {
4338
4405
  if (d.push(v), p) {
4339
4406
  const w = u.length;
4340
4407
  et(v, u, g, s, d.length === 1 && (a || r)), u.slice(w).forEach((y) => f.add(y));
4341
4408
  }
4342
4409
  } else {
4343
4410
  const w = u.length;
4344
- et(v, u, g, s, a), J(v).some((y) => zn.has(y)) && u.slice(w).forEach((y) => h.add(y));
4411
+ et(v, u, g, s, a), W(v).some((y) => Dn.has(y)) && u.slice(w).forEach((y) => h.add(y));
4345
4412
  }
4346
4413
  continue;
4347
4414
  }
4348
4415
  if (!m.ssml) continue;
4349
- if (s.format === "plain" && s.language !== "block-level" && s.language !== "none" && Sn(m.ssml)) {
4416
+ if (s.format === "plain" && s.language !== "block-level" && s.language !== "none" && wn(m.ssml)) {
4350
4417
  for (const v of at(m.ssml, o)) {
4351
- const w = { plain: v.plain }, y = j(v.language, s.languageOverrides);
4418
+ const w = { plain: v.plain }, y = M(v.language, s);
4352
4419
  y && (w.language = y), u.push(w), g.push(n);
4353
4420
  }
4354
4421
  continue;
4355
4422
  }
4356
4423
  const S = {};
4357
- l && (S.language = l), s.format === "ssml" ? S.ssml = Hn(m.ssml, s.languageOverrides) : S.plain = M(m.ssml), (s.language === "block-level" || s.language === "none") && (S.ssml && (S.ssml = Dn(S.ssml)), s.language === "none" && delete S.language), u.push(S), g.push(n);
4424
+ l && (S.language = l), s.format === "ssml" ? S.ssml = Zn(m.ssml, s.languageOverrides) : S.plain = N(m.ssml), (s.language === "block-level" || s.language === "none") && S.ssml && (S.ssml = qn(S.ssml)), u.push(S), g.push(n);
4358
4425
  }
4359
4426
  if (p && d.length + h.size > 0)
4360
4427
  return u.forEach((m) => {
4361
4428
  const S = h.has(m) ? "inline" : f.has(m) ? "after" : void 0;
4362
4429
  s.placeholderPieces.set(m, { node: n, placement: S });
4363
4430
  }), Ye(t, i, s, n, u, g, void 0), [];
4364
- for (const [m, S] of Gn(u, s)) {
4431
+ for (const [m, S] of Jn(u, s)) {
4365
4432
  const v = u.slice(m, S), w = g.slice(m, S), y = v.length > 1 ? St(v, w, s) : void 0;
4366
4433
  Ye(t, i, s, n, v, w, y);
4367
4434
  }
4368
4435
  return d;
4369
4436
  }
4370
4437
  function et(n, e, t, i, s) {
4371
- const a = J(n), r = Le(n);
4372
- if (Yt(a, i)) return;
4373
- const o = a.some((h) => $t.has(h)), l = o && !s, c = e.length, u = a.filter(
4374
- (h) => h !== "footnote" && h !== "pagebreak" && !Jn(h, a, i)
4375
- ), g = a.some((h) => da.has(h) && i.contextualize.has(h)), d = a.includes("table") && r !== void 0 && !g;
4438
+ const a = W(n), r = Oe(n);
4439
+ if (en(a, i)) return;
4440
+ const o = a.some((h) => qt.has(h)), l = o && !s, c = e.length, u = a.filter(
4441
+ (h) => h !== "footnote" && h !== "pagebreak" && !ti(h, a, i)
4442
+ ), g = a.some((h) => Sa.has(h) && i.contextualize.has(h)), d = a.includes("table") && r !== void 0 && !g;
4376
4443
  if (d) {
4377
4444
  const h = Xe(r, n, i);
4378
- le(h, r, r, n, i), q(e, t, n, [h]);
4445
+ ce(h, r, r, n, i), _(e, t, n, [h]);
4379
4446
  }
4380
4447
  for (const h of u) {
4381
4448
  if (h === "figure" && r === void 0) continue;
4382
- const { variantKey: f, params: p } = Qt(h, n, i);
4383
- qt(e, t, n, i, h, "before", f, p);
4449
+ const { variantKey: f, params: p } = Jt(h, n, i);
4450
+ Gt(e, t, n, i, h, "before", f, p);
4384
4451
  }
4385
4452
  if (a.includes("noteref"))
4386
4453
  for (const h of n.children ?? []) {
4387
- const f = J(h);
4388
- if (!Yt(f, i))
4454
+ const f = W(h);
4455
+ if (!en(f, i))
4389
4456
  if (f.includes("footnote")) {
4390
- const p = i.contextualize.has("footnote"), m = i.i18n.exists("footnote.block.start") || i.i18n.exists("footnote.block.end"), S = f.some((I) => $t.has(I)) && !s && !i.inlineContextualization.has("noteref"), v = p ? Z(i, m ? "footnote.block.start" : "footnote.inline") : void 0, w = p && (v !== void 0 || m), y = [], b = [];
4391
- v !== void 0 && (y.push(B(v, i)), b.push(h));
4457
+ const p = i.contextualize.has("footnote"), m = i.i18n.exists("footnote.block.start") || i.i18n.exists("footnote.block.end"), S = f.some((I) => qt.has(I)) && !s && !i.inlineContextualization.has("noteref"), v = p ? Q(i, m ? "footnote.block.start" : "footnote.inline") : void 0, w = p && (v !== void 0 || m), y = [], b = [];
4458
+ v !== void 0 && (y.push(j(v, i)), b.push(h));
4392
4459
  const P = [], A = [];
4393
- if ($([h], P, A, i, s || S), S && P.length > 0 && i.blockStarts.add(P[0]), y.push(...P), b.push(...A), w && m) {
4394
- const I = Z(i, "footnote.block.end");
4395
- I !== void 0 && (y.push(B(I, i)), b.push(h));
4460
+ if (F([h], P, A, i, s || S), S && P.length > 0 && i.blockStarts.add(P[0]), y.push(...P), b.push(...A), w && m) {
4461
+ const I = Q(i, "footnote.block.end");
4462
+ I !== void 0 && (y.push(j(I, i)), b.push(h));
4396
4463
  }
4397
4464
  const E = w && y.length > 1 ? St(y, b, i) : void 0;
4398
4465
  Ye(e, t, i, h, y, b, E);
4399
4466
  } else
4400
- $([h], e, t, i, s);
4467
+ F([h], e, t, i, s);
4401
4468
  }
4402
- else if (!a.some((h) => ga.has(h))) {
4469
+ else if (!a.some((h) => ba.has(h))) {
4403
4470
  const h = Ze(n)?.ssml;
4404
- if (h && rs(h)) {
4405
- const f = La(n, h, e, t, i, s, o);
4471
+ if (h && hs(h)) {
4472
+ const f = Na(n, h, e, t, i, s, o);
4406
4473
  if (f.length > 0) {
4407
4474
  const p = s || o && e.length > c;
4408
- $(f, e, t, i, p);
4475
+ F(f, e, t, i, p);
4409
4476
  }
4410
4477
  } else if (a.includes("pagebreak")) {
4411
- if (q(e, t, n, Pa(n, i)), n.children) {
4478
+ if (_(e, t, n, Ta(n, i)), n.children) {
4412
4479
  const f = s || o && e.length > c;
4413
- $(n.children, e, t, i, f);
4480
+ F(n.children, e, t, i, f);
4414
4481
  }
4415
4482
  } else {
4416
- const p = a.some((m) => Nn.has(m) && yt(m, i)) ? void 0 : st(Ze(n));
4417
- if (p && q(e, t, n, Xn(p, i.format, i.language, i)), n.children) {
4483
+ const p = a.some((m) => jn.has(m) && yt(m, i)) ? void 0 : st(Ze(n));
4484
+ if (p && _(e, t, n, ii(p, i.format, i.language, i)), n.children) {
4418
4485
  const m = s || o && e.length > c;
4419
- $(n.children, e, t, i, m);
4486
+ F(n.children, e, t, i, m);
4420
4487
  }
4421
4488
  }
4422
4489
  }
4423
4490
  if (l && e.length > c && i.blockStarts.add(e[c]), r !== void 0 && !g && !d) {
4424
4491
  const h = Xe(r, n, i);
4425
- a.includes("figure") && le(h, r, r, n, i), q(e, t, n, [h]);
4492
+ a.includes("figure") && ce(h, r, r, n, i), _(e, t, n, [h]);
4426
4493
  }
4427
4494
  for (const h of u) {
4428
4495
  if (h === "figure" && r === void 0) continue;
4429
- const { variantKey: f, params: p } = Qt(h, n, i);
4430
- qt(e, t, n, i, h, "after", f, p);
4496
+ const { variantKey: f, params: p } = Jt(h, n, i);
4497
+ Gt(e, t, n, i, h, "after", f, p);
4431
4498
  }
4432
4499
  }
4433
- function $(n, e, t, i, s) {
4500
+ function F(n, e, t, i, s) {
4434
4501
  n.forEach((a, r) => et(a, e, t, i, r === 0 ? s : !1));
4435
4502
  }
4436
- const Oa = vn;
4437
- async function Yn(n, e, t, i) {
4438
- const s = Oa(n);
4503
+ const Ma = Sn;
4504
+ async function si(n, e, t, i) {
4505
+ const s = Ma(n);
4439
4506
  let a = "";
4440
4507
  const r = [];
4441
4508
  for (const d of s)
@@ -4452,7 +4519,7 @@ async function Yn(n, e, t, i) {
4452
4519
  const S = o[u], v = Math.min(m, S.end), w = v >= S.end && u < o.length - 1;
4453
4520
  let y = d.slice(p - h, v - h);
4454
4521
  w && (y = y.replace(/[ \t\r\n]+$/, ""));
4455
- const b = z(y);
4522
+ const b = T(y);
4456
4523
  c += f ? f(b) : b, p = v, w && (l.push(c), c = "", u++);
4457
4524
  }
4458
4525
  }
@@ -4467,17 +4534,21 @@ async function Yn(n, e, t, i) {
4467
4534
  }
4468
4535
  }), c && l.push(c.replace(/[ \t\r\n]+$/, "")), l;
4469
4536
  }
4470
- async function xa(n, e) {
4471
- const t = n.language ?? "en", i = Ce(e.segmentationSuppressions, t), s = e.format === "ssml" ? n.ssml : n.plain;
4537
+ function bt(n, e) {
4538
+ const t = e.segmenter === Bn ? da(n) : n;
4539
+ return cn(e.segmentationSuppressions, t);
4540
+ }
4541
+ async function Ba(n, e) {
4542
+ const t = n.language ?? "en", i = bt(t, e), s = e.format === "ssml" ? n.ssml : n.plain;
4472
4543
  if (!s) return;
4473
- const a = await e.segmenter(t, de(s, e.format), i);
4544
+ const a = await e.segmenter(t, ge(s, e.format), i);
4474
4545
  if (a.length <= 1) return;
4475
4546
  if (e.format !== "ssml") return a.map((o) => ({ text: o.text, start: o.start, end: o.contentEnd }));
4476
- const r = await Yn(s, t, e.segmenter, i);
4547
+ const r = await si(s, t, e.segmenter, i);
4477
4548
  if (r)
4478
4549
  return a.map((o, l) => ({ text: r[l], start: o.start, end: o.contentEnd }));
4479
4550
  }
4480
- const tn = /* @__PURE__ */ new Set([
4551
+ const nn = /* @__PURE__ */ new Set([
4481
4552
  "cell",
4482
4553
  "rowheader",
4483
4554
  "columnheader",
@@ -4492,26 +4563,26 @@ const tn = /* @__PURE__ */ new Set([
4492
4563
  "heading5",
4493
4564
  "heading6"
4494
4565
  ]);
4495
- function nn(n) {
4496
- return n ? J(Array.isArray(n) ? n[1] : n) : [];
4566
+ function sn(n) {
4567
+ return n ? W(Array.isArray(n) ? n[1] : n) : [];
4497
4568
  }
4498
- function sn(n, e, t) {
4569
+ function an(n, e, t) {
4499
4570
  const i = Array.isArray(n) ? n[e === "leading" ? 0 : 1] : n;
4500
- return (t.ancestorChains.get(i) ?? []).filter((s) => J(s).some((a) => a !== "presentation"));
4571
+ return (t.ancestorChains.get(i) ?? []).filter((s) => W(s).some((a) => a !== "presentation"));
4501
4572
  }
4502
- function Va(n, e) {
4573
+ function Da(n, e) {
4503
4574
  return n.length === e.length && n.every((t, i) => t === e[i]);
4504
4575
  }
4505
- function an(n, e, t, i) {
4506
- return i.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) && he(n);
4576
+ function rn(n, e, t, i) {
4577
+ return i.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) && de(n);
4507
4578
  }
4508
- function Y(n, e) {
4579
+ function Z(n, e) {
4509
4580
  return e.placeholderPieces.get(n)?.placement === "inline";
4510
4581
  }
4511
- function Ua(n, e) {
4582
+ function ja(n, e) {
4512
4583
  return e.placeholderPieces.get(n)?.placement === "after";
4513
4584
  }
4514
- function ei(n, e, t, i) {
4585
+ function ai(n, e, t, i) {
4515
4586
  for (const { piece: s, source: a } of n.get(e) ?? [])
4516
4587
  t.push(s), i.push(a);
4517
4588
  n.delete(e);
@@ -4520,53 +4591,53 @@ function tt(n, e, t) {
4520
4591
  const i = t.placeholderPieces.get(n)?.node;
4521
4592
  return i !== void 0 && i === t.placeholderPieces.get(e)?.node;
4522
4593
  }
4523
- function Ta(n, e, t, i, s) {
4594
+ function Fa(n, e, t, i, s) {
4524
4595
  const a = s.format === "ssml" ? n.ssml : n.plain, r = s.format === "ssml" ? t.ssml : t.plain;
4525
- return !a || !r ? !1 : tt(n, t, s) ? !0 : !(!ft(n.language ?? "en", t.language ?? "en") || s.synthetic.has(n) || s.synthetic.has(t) || !e || !i || nn(e).some((o) => tn.has(o)) || nn(i).some((o) => tn.has(o)) || !Va(sn(e, "trailing", s), sn(i, "leading", s)) || an(e, n, "trailing", s) || an(i, t, "leading", s));
4596
+ return !a || !r ? !1 : tt(n, t, s) ? !0 : !(!ft(n.language ?? "en", t.language ?? "en") || s.synthetic.has(n) || s.synthetic.has(t) || !e || !i || sn(e).some((o) => nn.has(o)) || sn(i).some((o) => nn.has(o)) || !Da(an(e, "trailing", s), an(i, "leading", s)) || rn(e, n, "trailing", s) || rn(i, t, "leading", s));
4526
4597
  }
4527
- async function rn(n, e, t, i, s) {
4528
- const a = t.synthetic.has(n) ? void 0 : await xa(n, t);
4598
+ async function on(n, e, t, i, s) {
4599
+ const a = t.synthetic.has(n) ? void 0 : await Ba(n, t);
4529
4600
  if (!a) {
4530
4601
  i.push(n), s.push(e);
4531
4602
  return;
4532
4603
  }
4533
4604
  const r = t.blockStarts.has(n);
4534
4605
  r && t.blockStarts.delete(n);
4535
- const o = Array.isArray(e) ? void 0 : e, l = o ? L(o, t.ancestorChains) : void 0, c = o && he(o) ? Oe(o, t) : void 0, u = t.edgeSubstitutedLocate.get(n);
4606
+ const o = Array.isArray(e) ? void 0 : e, l = o ? L(o, t.ancestorChains) : void 0, c = o && de(o) ? Ve(o, t) : void 0, u = t.edgeSubstitutedLocate.get(n);
4536
4607
  a.forEach(({ text: g, start: d, end: h }, f) => {
4537
4608
  const p = { ...n, [t.format]: g }, m = (f === 0 ? u?.leading : void 0) ?? (f === a.length - 1 ? u?.trailing : void 0) ?? c;
4538
4609
  if (m && l)
4539
4610
  p.locate = m, p.offsets = [{ start: d, end: h, locate: m }];
4540
4611
  else if (l) {
4541
- const S = t.format === "ssml" ? de(g, t.format) : g, v = X(l.ref, S);
4612
+ const S = t.format === "ssml" ? ge(g, t.format) : g, v = J(l.ref, S);
4542
4613
  p.locate = v, p.offsets = [{ start: d, end: h, locate: v }];
4543
4614
  }
4544
4615
  r && f === 0 && t.blockStarts.add(p), i.push(p), s.push(e);
4545
4616
  });
4546
4617
  }
4547
- function ce(n, e) {
4618
+ function ue(n, e) {
4548
4619
  let t = 0;
4549
4620
  for (; t < n.length - 1 && n[t + 1].start <= e; ) t++;
4550
4621
  return t;
4551
4622
  }
4552
- async function za(n, e, t, i) {
4553
- const s = n.map((c) => de(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = ke(s), o = await e.segmenter(t, a, i), l = new Array(n.length - 1).fill(!1);
4623
+ async function _a(n, e, t, i) {
4624
+ const s = n.map((c) => ge(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = Ee(s), o = await e.segmenter(t, a, i), l = new Array(n.length - 1).fill(!1);
4554
4625
  for (const c of o) {
4555
- const u = ce(r, c.start), g = c.end > c.start ? ce(r, c.end - 1) : u;
4626
+ const u = ue(r, c.start), g = c.end > c.start ? ue(r, c.end - 1) : u;
4556
4627
  for (let d = u; d < g; d++) l[d] = !0;
4557
4628
  }
4558
4629
  return l;
4559
4630
  }
4560
- function Na(n, e, t) {
4631
+ function $a(n, e, t) {
4561
4632
  const i = [...e];
4562
4633
  return n.forEach((s, a) => {
4563
- if (!Y(s, t)) return;
4634
+ if (!Z(s, t)) return;
4564
4635
  const r = a > 0 && tt(n[a - 1], s, t), o = a < n.length - 1 && tt(s, n[a + 1], t);
4565
4636
  r && !i[a - 1] ? i[a - 1] = !0 : o && (i[a] = !0);
4566
4637
  }), i;
4567
4638
  }
4568
- function Ma(n, e, t, i, s) {
4569
- const a = (l) => Y(t[ce(i, l)], s), r = [];
4639
+ function qa(n, e, t, i, s) {
4640
+ const a = (l) => Z(t[ue(i, l)], s), r = [];
4570
4641
  let o;
4571
4642
  return e.forEach((l, c) => {
4572
4643
  o ??= l;
@@ -4574,75 +4645,75 @@ function Ma(n, e, t, i, s) {
4574
4645
  u && (a(l.contentEnd - 1) || a(u.start)) || (r.push({ text: n.slice(o.start, l.contentEnd), start: o.start, end: l.end, contentEnd: l.contentEnd }), o = void 0);
4575
4646
  }), r;
4576
4647
  }
4577
- function Ba(n, e, t, i, s, a, r) {
4648
+ function Ga(n, e, t, i, s, a, r) {
4578
4649
  const o = [];
4579
4650
  for (let l = s; l <= a; l++) {
4580
- if (Y(n[l], r)) {
4581
- o.push(...Zn([n[l]], [e[l]], r));
4651
+ if (Z(n[l], r)) {
4652
+ o.push(...ni([n[l]], [e[l]], r));
4582
4653
  continue;
4583
4654
  }
4584
4655
  const c = L(e[l], r.ancestorChains);
4585
4656
  if (!c) continue;
4586
4657
  const u = t[l], g = Math.max(u.start, i.start), d = Math.min(u.end, l === a ? i.contentEnd : i.end);
4587
4658
  if (d <= g) continue;
4588
- const h = g - u.start, f = d - u.start, p = de(r.format === "ssml" ? n[l].ssml : n[l].plain, r.format), m = X(c.ref, p.slice(h, f));
4659
+ const h = g - u.start, f = d - u.start, p = ge(r.format === "ssml" ? n[l].ssml : n[l].plain, r.format), m = J(c.ref, p.slice(h, f));
4589
4660
  o.push({ start: h, end: f, locate: m });
4590
4661
  }
4591
4662
  return o;
4592
4663
  }
4593
- function ti(n, e) {
4594
- const t = ya(n, e);
4595
- return t !== null ? t ?? "en" : n.find((i) => !Y(i, e))?.language ?? n[0].language ?? "en";
4664
+ function ri(n, e) {
4665
+ const t = Ra(n, e);
4666
+ return t !== null ? t ?? "en" : n.find((i) => !Z(i, e))?.language ?? n[0].language ?? "en";
4596
4667
  }
4597
- function ja(n, e, t, i, s) {
4598
- const a = ce(t, n.start), r = n.end > n.start ? ce(t, n.end - 1) : a, o = Gn(e.slice(a, r + 1), s);
4668
+ function Ha(n, e, t, i, s) {
4669
+ const a = ue(t, n.start), r = n.end > n.start ? ue(t, n.end - 1) : a, o = Jn(e.slice(a, r + 1), s);
4599
4670
  return o.map(([l, c], u) => {
4600
- const g = a + l, d = a + c - 1, h = u === o.length - 1, f = u === 0 ? n.start : t[g].start, p = h ? n.contentEnd : t[d].end, m = h ? n.end : t[d + 1].start, S = $n(e.slice(g, d + 1), s) ?? void 0, v = { text: i.slice(f, p), start: f, end: m, contentEnd: p }, w = o.length > 1 && g === d && Y(e[g], s);
4671
+ const g = a + l, d = a + c - 1, h = u === o.length - 1, f = u === 0 ? n.start : t[g].start, p = h ? n.contentEnd : t[d].end, m = h ? n.end : t[d + 1].start, S = Wn(e.slice(g, d + 1), s) ?? void 0, v = { text: i.slice(f, p), start: f, end: m, contentEnd: p }, w = o.length > 1 && g === d && Z(e[g], s);
4601
4672
  return { boundary: v, startIdx: g, endIdx: d, language: S, sentenceEnd: h ? n.end : void 0, isolated: w };
4602
4673
  });
4603
4674
  }
4604
- async function Da(n, e, t, i, s, a) {
4605
- const r = ti(n, t), o = Ce(t.segmentationSuppressions, r), l = n.map((v) => de(t.format === "ssml" ? v.ssml : v.plain, t.format)), { joined: c, ranges: u } = ke(l), g = Ma(c, await t.segmenter(r, c, o), n, u, t), h = (g.length > 0 ? g : [{ text: c, start: 0, end: c.length, contentEnd: c.length }]).flatMap((v) => ja(v, n, u, c, t));
4675
+ async function Ka(n, e, t, i, s, a) {
4676
+ const r = ri(n, t), o = bt(r, t), l = n.map((v) => ge(t.format === "ssml" ? v.ssml : v.plain, t.format)), { joined: c, ranges: u } = Ee(l), g = qa(c, await t.segmenter(r, c, o), n, u, t), h = (g.length > 0 ? g : [{ text: c, start: 0, end: c.length, contentEnd: c.length }]).flatMap((v) => Ha(v, n, u, c, t));
4606
4677
  let f, p;
4607
4678
  if (t.format === "ssml") {
4608
4679
  const v = /* @__PURE__ */ new Map();
4609
4680
  for (const y of h) for (let b = y.startIdx; b <= y.endIdx; b++) v.set(b, y.language);
4610
- p = ke(n.map((y, b) => qn(y, v.get(b), t)), l).joined;
4681
+ p = Ee(n.map((y, b) => Qn(y, v.get(b), t)), l).joined;
4611
4682
  const w = h.map((y) => y.boundary);
4612
- f = h.length > 1 ? await Yn(p, r, async () => w, o) : void 0;
4683
+ f = h.length > 1 ? await si(p, r, async () => w, o) : void 0;
4613
4684
  }
4614
4685
  const m = new Set(n.filter((v) => t.blockStarts.has(v))), S = (v, w) => {
4615
4686
  if (v !== void 0)
4616
4687
  for (let y = 0; y < n.length; y++)
4617
- (u[y].end <= v || w === h.length - 1) && ei(a, y, i, s);
4688
+ (u[y].end <= v || w === h.length - 1) && ai(a, y, i, s);
4618
4689
  };
4619
4690
  h.forEach(({ boundary: v, startIdx: w, endIdx: y, language: b, sentenceEnd: P, isolated: A }, E) => {
4620
4691
  if (A) {
4621
4692
  i.push(n[w]), s.push(e[w]), S(P, E);
4622
4693
  return;
4623
4694
  }
4624
- const I = t.format === "ssml" ? f ? f[E] : p : v.text, R = { [t.format]: I };
4625
- t.language !== "none" && (R.language = b ?? "en"), n.slice(w, y + 1).filter((ee) => m.delete(ee)).length > 0 && t.blockStarts.add(R);
4626
- const D = Ba(n, e, u, v, w, y, t);
4627
- D.length > 0 && (R.offsets = D);
4628
- const U = [...Array(y - w + 1).keys()].map((ee) => w + ee).filter((ee) => !Y(n[ee], t)), F = U[0] ?? w, _ = U[U.length - 1] ?? y, bt = L(e[F], t.ancestorChains), wt = pt(bt, I), kt = F !== _ ? mt(bt, L(e[_], t.ancestorChains), wt) : wt;
4629
- kt && (R.locate = kt), i.push(R), s.push(F === _ ? e[F] : [e[F], e[_]]), S(P, E);
4695
+ const I = t.format === "ssml" ? f ? f[E] : p : v.text, R = { [t.format]: I }, X = t.language === "none" ? M(void 0, t) : b ?? "en";
4696
+ X && (R.language = X), n.slice(w, y + 1).filter((te) => m.delete(te)).length > 0 && t.blockStarts.add(R);
4697
+ const B = Ga(n, e, u, v, w, y, t);
4698
+ B.length > 0 && (R.offsets = B);
4699
+ const ee = [...Array(y - w + 1).keys()].map((te) => w + te).filter((te) => !Z(n[te], t)), D = ee[0] ?? w, fe = ee[ee.length - 1] ?? y, wt = L(e[D], t.ancestorChains), kt = pt(wt, I), Ct = D !== fe ? mt(wt, L(e[fe], t.ancestorChains), kt) : kt;
4700
+ Ct && (R.locate = Ct), i.push(R), s.push(D === fe ? e[D] : [e[D], e[fe]]), S(P, E);
4630
4701
  });
4631
4702
  }
4632
- async function ni(n, e, t) {
4703
+ async function oi(n, e, t) {
4633
4704
  if (t.segmentation !== "sentence") return { out: n, sources: e };
4634
4705
  const i = [], s = [];
4635
4706
  let a = 0;
4636
4707
  for (; a < n.length; ) {
4637
4708
  let r = a;
4638
- for (; r + 1 < n.length && Ta(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
4709
+ for (; r + 1 < n.length && Fa(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
4639
4710
  if (r === a) {
4640
- await rn(n[a], e[a], t, i, s), a = r + 1;
4711
+ await on(n[a], e[a], t, i, s), a = r + 1;
4641
4712
  continue;
4642
4713
  }
4643
4714
  const o = [], l = [], c = /* @__PURE__ */ new Map();
4644
4715
  for (let f = a; f <= r; f++)
4645
- if (!Ua(n[f], t))
4716
+ if (!ja(n[f], t))
4646
4717
  o.push(n[f]), l.push(e[f]);
4647
4718
  else if (o.length === 0)
4648
4719
  i.push(n[f]), s.push(e[f]);
@@ -4654,16 +4725,16 @@ async function ni(n, e, t) {
4654
4725
  a = r + 1;
4655
4726
  continue;
4656
4727
  }
4657
- const u = ti(o, t), g = await za(o, t, u, Ce(t.segmentationSuppressions, u)), d = Na(o, g, t);
4728
+ const u = ri(o, t), g = await _a(o, t, u, bt(u, t)), d = $a(o, g, t);
4658
4729
  let h = 0;
4659
4730
  for (let f = 0; f < o.length; f++)
4660
4731
  if (!(f < o.length - 1 && d[f])) {
4661
4732
  if (h === f)
4662
- await rn(o[h], l[h], t, i, s), ei(c, h, i, s);
4733
+ await on(o[h], l[h], t, i, s), ai(c, h, i, s);
4663
4734
  else {
4664
4735
  const p = /* @__PURE__ */ new Map();
4665
4736
  for (let m = h; m <= f; m++) c.has(m) && p.set(m - h, c.get(m));
4666
- await Da(o.slice(h, f + 1), l.slice(h, f + 1), t, i, s, p);
4737
+ await Ka(o.slice(h, f + 1), l.slice(h, f + 1), t, i, s, p);
4667
4738
  }
4668
4739
  h = f + 1;
4669
4740
  }
@@ -4671,40 +4742,40 @@ async function ni(n, e, t) {
4671
4742
  }
4672
4743
  return { out: i, sources: s };
4673
4744
  }
4674
- function ii(n, e) {
4745
+ function li(n, e) {
4675
4746
  return Object.keys(e.substitutions).length === 0 ? n : n.map((t) => {
4676
4747
  if (t.ssml) {
4677
- const { ssml: o, plain: l, map: c } = ts(t.ssml, e.substitutions);
4748
+ const { ssml: o, plain: l, map: c } = rs(t.ssml, e.substitutions);
4678
4749
  if (o === t.ssml) return t;
4679
4750
  const u = { ...t, ssml: o };
4680
- return Dt(u, { plain: l, map: c }), u;
4751
+ return Ft(u, { plain: l, map: c }), u;
4681
4752
  }
4682
4753
  const i = t.plain;
4683
4754
  if (!i) return t;
4684
- const { text: s, map: a } = Yi(i, e.substitutions);
4755
+ const { text: s, map: a } = ss(i, e.substitutions);
4685
4756
  if (s === i) return t;
4686
4757
  const r = { ...t, plain: s };
4687
- return Dt(r, { plain: i, map: a }), r;
4758
+ return Ft(r, { plain: i, map: a }), r;
4688
4759
  });
4689
4760
  }
4690
- async function nr(n, e = {}) {
4691
- const t = [], i = [], s = await jn(n, e);
4692
- $(n, t, i, s, !1);
4693
- const a = await ni(t, i, s);
4694
- return ii(Wn(a.out, a.sources, s), s);
4761
+ async function cr(n, e = {}) {
4762
+ const t = [], i = [], s = await $n(n, e);
4763
+ F(n, t, i, s, !1);
4764
+ const a = await oi(t, i, s);
4765
+ return li(Yn(a.out, a.sources, s), s);
4695
4766
  }
4696
- async function Fa(n, e = {}) {
4697
- const t = [], i = [], s = await jn(n, e);
4698
- $(n, t, i, s, !1);
4699
- const a = await ni(t, i, s), r = a.out.map((l) => s.blockStarts.has(l)), o = Wn(a.out, a.sources, s);
4700
- return { utterances: ii(o, s), sources: a.sources, blockStarts: r };
4767
+ async function Wa(n, e = {}) {
4768
+ const t = [], i = [], s = await $n(n, e);
4769
+ F(n, t, i, s, !1);
4770
+ const a = await oi(t, i, s), r = a.out.map((l) => s.blockStarts.has(l)), o = Yn(a.out, a.sources, s);
4771
+ return { utterances: li(o, s), sources: a.sources, blockStarts: r };
4701
4772
  }
4702
- class ir {
4773
+ class ur {
4703
4774
  engine;
4704
4775
  contentQueue = [];
4705
4776
  // `contentQueue` as loaded, before `voice` stamped it — re-stamped when that changes.
4706
4777
  loadedQueue = [];
4707
- events = new Pe();
4778
+ events = new Ae();
4708
4779
  // Navigator owns the state, not the engine
4709
4780
  navigatorState = "idle";
4710
4781
  // Scheduled by the "end" handler's pauseDuration delay — cleared on
@@ -4725,6 +4796,8 @@ class ir {
4725
4796
  // language, segmentation) a no-op on content loaded via loadContent() — prosody
4726
4797
  // fields (rate/pitch/volume/pauseDuration/autoPause) still apply.
4727
4798
  source;
4799
+ // The language of the loaded content as a whole, given with it.
4800
+ contentLanguage;
4728
4801
  // Parallel to `contentQueue`, from the extraction that produced it — lets
4729
4802
  // reextract() find where to resume after a reload (see resolveResumeIndex).
4730
4803
  contentSources = [];
@@ -4738,7 +4811,7 @@ class ir {
4738
4811
  // Index to speak() on the next play() when autoPause has stopped playback between utterances.
4739
4812
  pendingAutoPauseIndex = null;
4740
4813
  constructor(e, t = {}) {
4741
- this.engine = e, this._defaults = new Ts(t.defaults), this._preferences = new oe(t.preferences), this._settings = new ze(this._preferences, this._defaults), this.contextualizationOverrides = t.contextualizationOverrides, this.segmentationOverrides = t.segmentationOverrides, this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
4814
+ this.engine = e, this._defaults = new js(t.defaults), this._preferences = new le(t.preferences), this._settings = new ze(this._preferences, this._defaults), this.contextualizationOverrides = t.contextualizationOverrides, this.segmentationOverrides = t.segmentationOverrides, this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
4742
4815
  }
4743
4816
  // Unlike pauseDuration/autoPause (read live off settings), the engine owns rate/pitch/volume and must be pushed.
4744
4817
  applyEngineParameters() {
@@ -4790,7 +4863,7 @@ class ir {
4790
4863
  this.setNavigatorState("ready"), this.emitEvent({ type: "ready" });
4791
4864
  }
4792
4865
  }), this.engine.on("boundary", (e) => {
4793
- const { charIndex: t, charLength: i } = e.detail ?? {}, s = this.getCurrentContent(), a = s && typeof t == "number" && typeof i == "number" ? Fs(s, t, i) : void 0;
4866
+ const { charIndex: t, charLength: i } = e.detail ?? {}, s = this.loadedQueue[this.getCurrentUtteranceIndex()], a = s && typeof t == "number" && typeof i == "number" ? Ks(s, t, i) : void 0;
4794
4867
  this.emitEvent(a ? { ...e, detail: { ...e.detail, ...a } } : e);
4795
4868
  }), this.engine.on("mark", (e) => {
4796
4869
  this.emitEvent(e);
@@ -4812,19 +4885,23 @@ class ir {
4812
4885
  return this.engine.getAvailableVoices();
4813
4886
  }
4814
4887
  // Content Management
4815
- loadContent(e) {
4888
+ loadContent(e, t = {}) {
4816
4889
  if (this.source)
4817
4890
  throw new Error("loadContent() cannot be used after loadGndContent() — the two are exclusive. Create a new navigator instance to switch content sources.");
4818
- this.setContentQueue(e);
4891
+ this.contentLanguage = t.language, this.setContentQueue(e);
4819
4892
  }
4820
- async loadGndContent(e) {
4821
- this.source = e, await this.reextract();
4893
+ async loadGndContent(e, t = {}) {
4894
+ this.source = e, this.contentLanguage = t.language, await this.reextract();
4822
4895
  }
4823
4896
  setContentQueue(e, t = null, i = null) {
4824
4897
  this.clearPendingAdvance(), this.pendingAutoPauseIndex = null, (this.navigatorState === "playing" || this.navigatorState === "paused") && this.engine.stop(), this.loadedQueue = Array.isArray(e) ? [...e] : [e];
4825
- const s = this.loadedQueue.map((a) => this.withVoice(a));
4898
+ const s = this.loadedQueue.map((a) => this.withVoice(this.withLanguage(a)));
4826
4899
  this.contentQueue = s, this.pendingResumeIndex = t, this.pendingResumeState = i, this.setNavigatorState("loading"), this.emitEvent({ type: "loading" }), this.engine.loadUtterances(s, t ?? void 0), this.emitContentChangeEvent({ content: s });
4827
4900
  }
4901
+ // The content's language when a loadContent() utterance has none; extraction applies it to loadGndContent()'s.
4902
+ withLanguage(e) {
4903
+ return this.source !== void 0 || this.contentLanguage === void 0 || e.language ? e : { ...e, language: this.contentLanguage };
4904
+ }
4828
4905
  // The utterance's own voice, else `voice`'s for its language.
4829
4906
  withVoice(e) {
4830
4907
  const t = this._settings.voice;
@@ -4835,17 +4912,18 @@ class ir {
4835
4912
  // Re-runs extraction from `this.source`, resuming near the old position if playback was underway.
4836
4913
  async reextract() {
4837
4914
  if (!this.source) return;
4838
- const { index: e, state: t } = this.resumeTarget(), i = this.contentSources, { utterances: s, sources: a, blockStarts: r } = await Fa(this.source, {
4915
+ const { index: e, state: t } = this.resumeTarget(), i = this.contentSources, { utterances: s, sources: a, blockStarts: r } = await Wa(this.source, {
4839
4916
  format: this._settings.format,
4840
4917
  inlineContextualization: this._settings.inlineContextualization,
4841
4918
  skip: this._settings.skip,
4842
4919
  contextualize: this._settings.contextualize,
4843
4920
  contextualization: {
4844
4921
  contextualizations: this.contextualizationOverrides?.contextualizations,
4845
- shapes: js(this._settings.verbosity, this.contextualizationOverrides?.shapes),
4922
+ shapes: Gs(this._settings.verbosity, this.contextualizationOverrides?.shapes),
4846
4923
  params: this.contextualizationOverrides?.params
4847
4924
  },
4848
4925
  language: this._settings.language,
4926
+ contentLanguage: this.contentLanguage,
4849
4927
  languageOverrides: this._settings.languageOverrides,
4850
4928
  segmentation: {
4851
4929
  mode: this._settings.segmentation,
@@ -4961,7 +5039,7 @@ class ir {
4961
5039
  // LocatorOptions there — and the same "resolve, then skip if there's nothing
4962
5040
  // to show" shape, since there's no raw engine event to fall back to unenriched.
4963
5041
  emitUtteranceBoundary(e) {
4964
- const t = this._settings.segmentation, i = _s(e, t);
5042
+ const t = this._settings.segmentation, i = Ws(e, t);
4965
5043
  if (!i.length) return;
4966
5044
  const s = t === "sentence" ? "sentence" : "structure";
4967
5045
  this.emitEvent({
@@ -4979,17 +5057,17 @@ class ir {
4979
5057
  }
4980
5058
  // Rebuilt, staged edits kept, once the engine's voice changes, e.g. when it picks its default after being read.
4981
5059
  get preferencesEditor() {
4982
- const e = this.engine.getCurrentVoice(), t = e ? Pn(e) : null;
4983
- return (this._preferencesEditor === null || t !== this.preferencesEditorEngineVoice) && (this._preferencesEditor = new Bt(this._preferencesEditor?.preferences ?? this._preferences, this.settings), this.preferencesEditorEngineVoice = t), this._preferencesEditor;
5060
+ const e = this.engine.getCurrentVoice(), t = e ? Ln(e) : null;
5061
+ return (this._preferencesEditor === null || t !== this.preferencesEditorEngineVoice) && (this._preferencesEditor = new Dt(this._preferencesEditor?.preferences ?? this._preferences, this.settings), this.preferencesEditorEngineVoice = t), this._preferencesEditor;
4984
5062
  }
4985
5063
  async submitPreferences(e) {
4986
- !this.source && this.contentQueue.length > 0 && Mt.some((t) => e[t] !== void 0) && console.warn(
5064
+ !this.source && this.contentQueue.length > 0 && Bt.some((t) => e[t] !== void 0) && console.warn(
4987
5065
  "submitPreferences(): extraction-affecting preferences (format, inlineContextualization, verbosity, skip, contextualize, language, languageOverrides, segmentation) have no effect on content loaded via loadContent() — use loadGndContent() to re-extract on submission."
4988
5066
  ), this._preferences = this._preferences.merging(e), await this.applyPreferences();
4989
5067
  }
4990
5068
  async applyPreferences() {
4991
5069
  const e = this._settings;
4992
- if (this._settings = new ze(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new Bt(this._preferences, this.settings)), Mt.some((t) => !this.sameSettingValue(e[t], this._settings[t])))
5070
+ if (this._settings = new ze(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new Dt(this._preferences, this.settings)), Bt.some((t) => !this.sameSettingValue(e[t], this._settings[t])))
4993
5071
  await this.reextract();
4994
5072
  else if (this.loadedQueue.length > 0 && !this.sameSettingValue(e.voice, this._settings.voice)) {
4995
5073
  const { index: t, state: i } = this.resumeTarget();
@@ -5011,82 +5089,82 @@ class ir {
5011
5089
  }
5012
5090
  }
5013
5091
  export {
5014
- Ya as BooleanPreference,
5015
- ne as EnumPreference,
5016
- Ja as FallbackEngineProvider,
5017
- Ls as FallbackSpeechEngine,
5018
- or as Locator,
5019
- lr as LocatorLocations,
5020
- cr as LocatorText,
5021
- Q as Preference,
5022
- fe as RangePreference,
5023
- Vs as ReadiumSpeechDecorationController,
5024
- ir as ReadiumSpeechNavigator,
5025
- Xa as ReadiumSpeechProviderRegistry,
5026
- Ts as SpeechDefaults,
5027
- oe as SpeechPreferences,
5028
- Bt as SpeechPreferencesEditor,
5029
- Rn as SpeechServerAudioDecodeError,
5030
- Rs as SpeechServerEngine,
5031
- Qa as SpeechServerEngineProvider,
5032
- re as SpeechServerError,
5033
- In as SpeechServerNetworkError,
5034
- En as SpeechServerStallError,
5092
+ rr as BooleanPreference,
5093
+ ie as EnumPreference,
5094
+ ir as FallbackEngineProvider,
5095
+ zs as FallbackSpeechEngine,
5096
+ fr as Locator,
5097
+ pr as LocatorLocations,
5098
+ mr as LocatorText,
5099
+ K as Preference,
5100
+ me as RangePreference,
5101
+ Bs as ReadiumSpeechDecorationController,
5102
+ ur as ReadiumSpeechNavigator,
5103
+ ar as ReadiumSpeechProviderRegistry,
5104
+ js as SpeechDefaults,
5105
+ le as SpeechPreferences,
5106
+ Dt as SpeechPreferencesEditor,
5107
+ Pn as SpeechServerAudioDecodeError,
5108
+ Vs as SpeechServerEngine,
5109
+ nr as SpeechServerEngineProvider,
5110
+ oe as SpeechServerError,
5111
+ An as SpeechServerNetworkError,
5112
+ In as SpeechServerStallError,
5035
5113
  ze as SpeechSettings,
5036
5114
  Te as StringArrayPreference,
5037
- zt as WebSpeechEngine,
5038
- Wa as WebSpeechEngineProvider,
5039
- k as WebSpeechVoiceManager,
5115
+ Nt as WebSpeechEngine,
5116
+ tr as WebSpeechEngineProvider,
5117
+ C as WebSpeechVoiceManager,
5040
5118
  ht as autoPauseScopes,
5041
- ra as blockLevelRoles,
5042
- ae as chineseVariantMap,
5043
- us as chunkPlainText,
5044
- ds as chunkSsmlText,
5045
- cn as compareAlphabetically,
5046
- ln as compareByPreferredRegion,
5047
- Bs as contextualizationShapesAtVerbosity,
5048
- Ms as contextualizedAtVerbosity,
5049
- W as createJsonOrderMap,
5050
- xs as createLocator,
5051
- Un as defaultContextualizations,
5052
- C as extractLangRegionFromBCP47,
5053
- nr as extractUtterances,
5119
+ ga as blockLevelRoles,
5120
+ re as chineseVariantMap,
5121
+ ms as chunkPlainText,
5122
+ ys as chunkSsmlText,
5123
+ hn as compareAlphabetically,
5124
+ un as compareByPreferredRegion,
5125
+ qs as contextualizationShapesAtVerbosity,
5126
+ $s as contextualizedAtVerbosity,
5127
+ H as createJsonOrderMap,
5128
+ Ms as createLocator,
5129
+ zn as defaultContextualizations,
5130
+ k as extractLangRegionFromBCP47,
5131
+ cr as extractUtterances,
5054
5132
  ut as extractionFormats,
5055
- Mt as extractionPreferenceKeys,
5133
+ Bt as extractionPreferenceKeys,
5056
5134
  it as filterByBoundarySupport,
5057
- Pi as filterByLanguages,
5058
- Pt as filterOutNoveltyVoices,
5059
- At as filterOutVeryLowQualityVoices,
5060
- De as getLanguageDisplayName,
5061
- ve as getQualityValue,
5062
- Pn as getVoiceId,
5063
- Ie as groupVoicesByLanguage,
5064
- la as inlineContextualizationRoles,
5135
+ xi as filterByLanguages,
5136
+ At as filterOutNoveltyVoices,
5137
+ Lt as filterOutVeryLowQualityVoices,
5138
+ je as getLanguageDisplayName,
5139
+ Se as getQualityValue,
5140
+ Ln as getVoiceId,
5141
+ Pe as groupVoicesByLanguage,
5142
+ pa as inlineContextualizationRoles,
5065
5143
  _e as isNoveltyVoice,
5066
- Is as isRecoverableFailure,
5144
+ xs as isRecoverableFailure,
5067
5145
  $e as isVeryLowQualityVoice,
5068
5146
  ct as languageModes,
5069
- Cn as mapServerVoice,
5070
- fs as mimeTypeForFormat,
5071
- ye as pauseDurationRangeConfig,
5072
- hn as pickBestVoiceByRegion,
5073
- be as pitchRangeConfig,
5074
- Se as rateRangeConfig,
5075
- Fs as resolveBoundaryLocate,
5076
- _s as resolveUtteranceLocate,
5147
+ Rn as mapServerVoice,
5148
+ bs as mimeTypeForFormat,
5149
+ be as pauseDurationRangeConfig,
5150
+ gn as pickBestVoiceByRegion,
5151
+ ke as pitchRangeConfig,
5152
+ we as rateRangeConfig,
5153
+ Ks as resolveBoundaryLocate,
5154
+ Ws as resolveUtteranceLocate,
5077
5155
  dt as segmentationModes,
5078
- bs as selectBitrate,
5079
- vs as selectFormat,
5080
- Za as setupDecorations,
5081
- er as shapeableRoles,
5082
- tr as skippableRoles,
5083
- Ns as skippedAtVerbosity,
5156
+ Is as selectBitrate,
5157
+ Cs as selectFormat,
5158
+ sr as setupDecorations,
5159
+ or as shapeableRoles,
5160
+ lr as skippableRoles,
5161
+ _s as skippedAtVerbosity,
5084
5162
  Fe as sortAlphabetically,
5085
- bi as sortByPreferredRegion,
5086
- G as sortByQuality,
5087
- un as sortVoicesByRegions,
5088
- se as toSpeechServerError,
5163
+ Ri as sortByPreferredRegion,
5164
+ $ as sortByQuality,
5165
+ dn as sortVoicesByRegions,
5166
+ ae as toSpeechServerError,
5089
5167
  nt as valueForLanguage,
5090
5168
  lt as verbosityPresets,
5091
- we as volumeRangeConfig
5169
+ Ce as volumeRangeConfig
5092
5170
  };