@pie-qti/player-elements 0.1.24 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ItemToolBar-d36g3aw4-B6TGPyKt.js +3079 -0
- package/dist/ItemToolBar-d36g3aw4-B6TGPyKt.js.map +1 -0
- package/dist/{define-D7_K0JFy.js → define-D80uAEx4.js} +1902 -4395
- package/dist/define-D80uAEx4.js.map +1 -0
- package/dist/dist-BSG0NOza.js +229 -0
- package/dist/dist-BSG0NOza.js.map +1 -0
- package/dist/{dist-ffJZTPTU.js → dist-C8BDh5vZ.js} +987 -707
- package/dist/dist-C8BDh5vZ.js.map +1 -0
- package/dist/dist-CQel8-vi.js +2507 -0
- package/dist/dist-CQel8-vi.js.map +1 -0
- package/dist/{dist-BaQdJU08.js → dist-L-bDDBry.js} +116 -103
- package/dist/dist-L-bDDBry.js.map +1 -0
- package/dist/{element-DSCNeDLu.js → element-C5rTAwch.js} +2 -2
- package/dist/{element-DSCNeDLu.js.map → element-C5rTAwch.js.map} +1 -1
- package/dist/{element-class-DQy2cIPM-CldZrSRR.js → element-class-B_qAd8ET-DGj15cBY.js} +5124 -4448
- package/dist/element-class-B_qAd8ET-DGj15cBY.js.map +1 -0
- package/dist/elements.js +3 -3
- package/dist/index.js +2 -2
- package/dist/item-toolbar-element-BgqPFwsS.js +1990 -0
- package/dist/item-toolbar-element-BgqPFwsS.js.map +1 -0
- package/dist/{language-tags-DVlRltrl.js → language-tags-BwFWXo71.js} +3 -3
- package/dist/{language-tags-DVlRltrl.js.map → language-tags-BwFWXo71.js.map} +1 -1
- package/dist/{nl-NL-BeQBX6yq.js → nl-NL-BRA_1Wcl.js} +5 -3
- package/dist/nl-NL-BRA_1Wcl.js.map +1 -0
- package/dist/pie-DwmznDHb.js +363 -0
- package/dist/pie-DwmznDHb.js.map +1 -0
- package/dist/pie-assessment-toolkit-Cruxm385.js +5 -0
- package/dist/pie-assessment-toolkit-Cruxm385.js.map +1 -0
- package/dist/pie-assessment-toolkit-DJfg6laX.js +5 -0
- package/dist/pie-assessment-toolkit-DJfg6laX.js.map +1 -0
- package/dist/{pie-assessment-toolkit-element-CpiB3twr.js → pie-assessment-toolkit-element-CT5UuvVY.js} +1364 -1203
- package/dist/pie-assessment-toolkit-element-CT5UuvVY.js.map +1 -0
- package/dist/pie-tool-calculator-Crfk-IZe.js +378 -0
- package/dist/pie-tool-calculator-Crfk-IZe.js.map +1 -0
- package/dist/{provider-Y5PhmTAu.js → provider-gBXlGb0d.js} +3 -3
- package/dist/{provider-Y5PhmTAu.js.map → provider-gBXlGb0d.js.map} +1 -1
- package/dist/register-players.js +1 -1
- package/dist/register.js +10246 -9664
- package/dist/register.js.map +1 -1
- package/dist/{resolveItems-D8DJkv-4.js → resolveItems-CNMvD8LP.js} +2 -2
- package/dist/{resolveItems-D8DJkv-4.js.map → resolveItems-CNMvD8LP.js.map} +1 -1
- package/dist/{root-DSkIM1v3.js → root-dCY6j_Hh.js} +3 -3
- package/dist/{root-DSkIM1v3.js.map → root-dCY6j_Hh.js.map} +1 -1
- package/dist/tag-names-DZGvnAgd.js +2495 -0
- package/dist/tag-names-DZGvnAgd.js.map +1 -0
- package/dist/{tool-tts-inline-B71NTBbb.js → tool-tts-inline-k3hLJUfp.js} +1315 -1303
- package/dist/tool-tts-inline-k3hLJUfp.js.map +1 -0
- package/package.json +8 -8
- package/dist/define-D7_K0JFy.js.map +0 -1
- package/dist/dist-BRTWr852.js +0 -5809
- package/dist/dist-BRTWr852.js.map +0 -1
- package/dist/dist-BaQdJU08.js.map +0 -1
- package/dist/dist-DwvskOs6.js +0 -220
- package/dist/dist-DwvskOs6.js.map +0 -1
- package/dist/dist-ffJZTPTU.js.map +0 -1
- package/dist/element-class-DQy2cIPM-CldZrSRR.js.map +0 -1
- package/dist/item-toolbar-element-BW9Y_n5x.js +0 -1990
- package/dist/item-toolbar-element-BW9Y_n5x.js.map +0 -1
- package/dist/nl-NL-BeQBX6yq.js.map +0 -1
- package/dist/pie-assessment-toolkit-element-CpiB3twr.js.map +0 -1
- package/dist/pie-tool-calculator-BiWMTJe7.js +0 -2992
- package/dist/pie-tool-calculator-BiWMTJe7.js.map +0 -1
- package/dist/tool-tts-inline-B71NTBbb.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { o as e } from "./rolldown-runtime-CEFd7nDs.js";
|
|
2
|
-
import { a as t, i as n, n as r, r as i } from "./language-tags-
|
|
3
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
2
|
+
import { a as t, i as n, n as r, r as i } from "./language-tags-BwFWXo71.js";
|
|
3
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/context/assessment-toolkit-context.js
|
|
4
4
|
var a = n(Symbol.for("pie.assessmentToolkit.runtimeContext"));
|
|
5
5
|
n(Symbol.for("pie.assessmentToolkit.hostRuntimeContext"));
|
|
6
6
|
var o = n(Symbol.for("pie.assessmentToolkit.shellContext")), s = n(Symbol.for("pie.assessmentToolkit.regionScopeContext"));
|
|
7
7
|
//#endregion
|
|
8
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
8
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/context/runtime-context-consumer.js
|
|
9
9
|
function c(e, n, r) {
|
|
10
10
|
let i = !1, a = new t(e, {
|
|
11
11
|
context: n,
|
|
@@ -40,7 +40,7 @@ function d(e, t) {
|
|
|
40
40
|
return c(e, s, t);
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
43
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/catalog-owner.js
|
|
44
44
|
var f = (e) => Array.isArray(e) && e.length > 0;
|
|
45
45
|
function p(e) {
|
|
46
46
|
return e.kind === "passage" ? {
|
|
@@ -76,7 +76,7 @@ function m(e, t) {
|
|
|
76
76
|
return r;
|
|
77
77
|
}
|
|
78
78
|
//#endregion
|
|
79
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
79
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/runtime/tool-host-contract.js
|
|
80
80
|
function h(e, t) {
|
|
81
81
|
return l(e, t);
|
|
82
82
|
}
|
|
@@ -87,7 +87,7 @@ function te(e, t) {
|
|
|
87
87
|
return d(e, t);
|
|
88
88
|
}
|
|
89
89
|
//#endregion
|
|
90
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
90
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/SSMLExtractor.js
|
|
91
91
|
var g = /* @__PURE__ */ new Set([
|
|
92
92
|
"speak",
|
|
93
93
|
"break",
|
|
@@ -193,43 +193,43 @@ function se(e) {
|
|
|
193
193
|
t !== null && !oe(t) && e.removeAttribute("src");
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
let t = e.tagName.toLowerCase(), n = Array.from(e.attributes).filter((e) => ne.has(e.name.toLowerCase())).map((e) => ` ${e.name}="${
|
|
196
|
+
function ce(e) {
|
|
197
|
+
let t = e.tagName.toLowerCase(), n = Array.from(e.attributes).filter((e) => ne.has(e.name.toLowerCase())).map((e) => ` ${e.name}="${ue(e.value)}"`).join("");
|
|
198
198
|
if (re.has(t)) return `<${t}${n}/>`;
|
|
199
199
|
let r = [];
|
|
200
|
-
for (let t of Array.from(e.childNodes)) if (t.nodeType === 3) r.push(
|
|
200
|
+
for (let t of Array.from(e.childNodes)) if (t.nodeType === 3) r.push(v(t.nodeValue ?? ""));
|
|
201
201
|
else if (t.nodeType === 1) {
|
|
202
202
|
let e = t, n = e.tagName.toLowerCase();
|
|
203
203
|
if (_.has(n)) continue;
|
|
204
|
-
g.has(n) ? r.push(
|
|
204
|
+
g.has(n) ? r.push(ce(e)) : r.push(v(e.textContent ?? ""));
|
|
205
205
|
}
|
|
206
206
|
return `<${t}${n}>${r.join("")}</${t}>`;
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function le(e) {
|
|
209
209
|
let t = String(e || "").trim();
|
|
210
210
|
if (!t || !t.includes("<") || typeof DOMParser > "u") return e;
|
|
211
211
|
let n = new DOMParser().parseFromString(ie(t), "text/html"), r = n.querySelector("speak");
|
|
212
|
-
if (r) return se(r),
|
|
212
|
+
if (r) return se(r), ce(r);
|
|
213
213
|
let i = n.createElement("speak");
|
|
214
214
|
for (let e of Array.from(n.body.childNodes)) i.appendChild(e);
|
|
215
215
|
return se(i), Array.from(i.childNodes).map((e) => {
|
|
216
|
-
if (e.nodeType === 3) return
|
|
216
|
+
if (e.nodeType === 3) return v(e.nodeValue ?? "");
|
|
217
217
|
if (e.nodeType === 1) {
|
|
218
218
|
let t = e;
|
|
219
|
-
return g.has(t.tagName.toLowerCase()) ?
|
|
219
|
+
return g.has(t.tagName.toLowerCase()) ? ce(t) : v(t.textContent ?? "");
|
|
220
220
|
}
|
|
221
221
|
return "";
|
|
222
222
|
}).join("");
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function v(e) {
|
|
225
225
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function ue(e) {
|
|
228
228
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
229
229
|
}
|
|
230
230
|
//#endregion
|
|
231
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
232
|
-
var
|
|
231
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/AccessibilityCatalogResolver.js
|
|
232
|
+
var de = /* @__PURE__ */ new Set([
|
|
233
233
|
"spoken",
|
|
234
234
|
"sign-language",
|
|
235
235
|
"transcript",
|
|
@@ -238,22 +238,22 @@ var ue = /* @__PURE__ */ new Set([
|
|
|
238
238
|
"simplified-language",
|
|
239
239
|
"audio-description",
|
|
240
240
|
"extended-description"
|
|
241
|
-
]),
|
|
242
|
-
function
|
|
243
|
-
return
|
|
241
|
+
]), fe = "ext:";
|
|
242
|
+
function pe(e) {
|
|
243
|
+
return de.has(e) ? !0 : e.startsWith(fe) && e.length > 4;
|
|
244
244
|
}
|
|
245
|
-
var
|
|
246
|
-
function
|
|
245
|
+
var me = /* @__PURE__ */ new Set();
|
|
246
|
+
function y(e, t = /* @__PURE__ */ new Set()) {
|
|
247
247
|
if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === void 0) return e;
|
|
248
248
|
if (typeof e != "object") throw TypeError("catalog cards must contain JSON-compatible values");
|
|
249
249
|
if (t.has(e)) throw TypeError("catalog cards must not contain cycles");
|
|
250
250
|
t.add(e);
|
|
251
251
|
try {
|
|
252
|
-
if (Array.isArray(e)) return Object.freeze(e.map((e) =>
|
|
252
|
+
if (Array.isArray(e)) return Object.freeze(e.map((e) => y(e, t)));
|
|
253
253
|
let n = Object.getPrototypeOf(e);
|
|
254
254
|
if (n !== Object.prototype && n !== null) throw TypeError("catalog cards must contain only plain objects and arrays");
|
|
255
255
|
let r = {};
|
|
256
|
-
for (let [n, i] of Object.entries(e)) r[n] =
|
|
256
|
+
for (let [n, i] of Object.entries(e)) r[n] = y(i, t);
|
|
257
257
|
return Object.freeze(r);
|
|
258
258
|
} finally {
|
|
259
259
|
t.delete(e);
|
|
@@ -261,9 +261,9 @@ function me(e, t = /* @__PURE__ */ new Set()) {
|
|
|
261
261
|
}
|
|
262
262
|
function he(e, t, n) {
|
|
263
263
|
let r = `${t}|${e}`;
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
let i = `${Array.from(
|
|
264
|
+
if (me.has(r)) return;
|
|
265
|
+
me.add(r);
|
|
266
|
+
let i = `${Array.from(de).join(", ")}, or an "${fe}" prefixed vendor extension`;
|
|
267
267
|
if (t === "card") {
|
|
268
268
|
console.warn(`[AccessibilityCatalogResolver] catalog "${n}" has a card of unknown type "${e}"; it is stored but no reader asks for that type, so the alternate will never be shown. Expected one of: ${i}.`);
|
|
269
269
|
return;
|
|
@@ -396,7 +396,7 @@ var ge = (e) => e.payload === void 0 ? "content" : "payload", _e = class {
|
|
|
396
396
|
return this.itemCatalogs.has(e) || this.assessmentCatalogs.has(e) || Array.from(this.scopedCatalogs.values()).some((t) => t.catalogs.has(e));
|
|
397
397
|
}
|
|
398
398
|
getAlternative(e, t) {
|
|
399
|
-
|
|
399
|
+
pe(t.type) || he(t.type, "lookup", e);
|
|
400
400
|
let n = t.context ? this.scopedCatalogs.get(this.getOwnerKey(t.context))?.catalogs.get(e) : null;
|
|
401
401
|
if (n) {
|
|
402
402
|
let r = this.findMatchingCard(n, t);
|
|
@@ -434,7 +434,7 @@ var ge = (e) => e.payload === void 0 ? "content" : "payload", _e = class {
|
|
|
434
434
|
ensureSpokenSanitized(e) {
|
|
435
435
|
let t = this.sanitizedSpokenCache.get(e);
|
|
436
436
|
if (t !== void 0) return t;
|
|
437
|
-
let n =
|
|
437
|
+
let n = le(e);
|
|
438
438
|
return this.sanitizedSpokenCache.set(e, n), n;
|
|
439
439
|
}
|
|
440
440
|
getOwnerKey(e) {
|
|
@@ -471,7 +471,7 @@ var ge = (e) => e.payload === void 0 ? "content" : "payload", _e = class {
|
|
|
471
471
|
for (let [r, i] of n) for (let n of i.cards) try {
|
|
472
472
|
t.push(Object.freeze({
|
|
473
473
|
catalogId: r,
|
|
474
|
-
card:
|
|
474
|
+
card: y(n)
|
|
475
475
|
}));
|
|
476
476
|
} catch (t) {
|
|
477
477
|
let n = `${this.getOwnerKey(e)}\u0000${r}`;
|
|
@@ -488,9 +488,9 @@ var ge = (e) => e.payload === void 0 ? "content" : "payload", _e = class {
|
|
|
488
488
|
sanitizeCatalogs(e) {
|
|
489
489
|
return e.map((e) => ({
|
|
490
490
|
...e,
|
|
491
|
-
cards: e.cards.map((t) => (
|
|
491
|
+
cards: e.cards.map((t) => (pe(t.catalog) || he(t.catalog, "card", e.identifier), {
|
|
492
492
|
...t,
|
|
493
|
-
content: t.catalog === "spoken" && t.content !== void 0 ?
|
|
493
|
+
content: t.catalog === "spoken" && t.content !== void 0 ? le(t.content) : t.content
|
|
494
494
|
}))
|
|
495
495
|
}));
|
|
496
496
|
}
|
|
@@ -1040,24 +1040,18 @@ var be = class e {
|
|
|
1040
1040
|
}, this.applyAdaptiveTTSStyle());
|
|
1041
1041
|
}
|
|
1042
1042
|
destroy() {
|
|
1043
|
-
|
|
1044
|
-
if (this.clearTTS(), this.clearAnnotations(), typeof document < "u") {
|
|
1045
|
-
let e = document.getElementById("pie-highlight-styles");
|
|
1046
|
-
e && e.remove();
|
|
1047
|
-
}
|
|
1048
|
-
this.themeObserver?.disconnect(), this.themeObserver = null;
|
|
1049
|
-
}
|
|
1043
|
+
this.supported && (this.clearTTS(), this.clearAnnotations(), this.themeObserver?.disconnect(), this.themeObserver = null);
|
|
1050
1044
|
}
|
|
1051
1045
|
};
|
|
1052
1046
|
//#endregion
|
|
1053
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1047
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/utils/logger.js
|
|
1054
1048
|
function xe(e) {
|
|
1055
1049
|
return (...t) => {
|
|
1056
1050
|
console.debug(`[${e}]`, ...t);
|
|
1057
1051
|
};
|
|
1058
1052
|
}
|
|
1059
1053
|
//#endregion
|
|
1060
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1054
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/tool-config-defaults.js
|
|
1061
1055
|
var Se = {
|
|
1062
1056
|
assessment: [],
|
|
1063
1057
|
section: [],
|
|
@@ -1143,7 +1137,7 @@ function Ae(e) {
|
|
|
1143
1137
|
return i && (a.pnpEnforcement = i), a;
|
|
1144
1138
|
}
|
|
1145
1139
|
//#endregion
|
|
1146
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1140
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/ToolRegistry.js
|
|
1147
1141
|
var je = [
|
|
1148
1142
|
"assessment",
|
|
1149
1143
|
"section",
|
|
@@ -1200,6 +1194,7 @@ function Pe(e) {
|
|
|
1200
1194
|
if (e.pnpSupportIds !== void 0 && (!Array.isArray(e.pnpSupportIds) || e.pnpSupportIds.some((e) => typeof e != "string" || e.trim().length === 0))) throw Error(`Invalid tool registration "${e.toolId}": "pnpSupportIds" must be an array of non-empty strings.`);
|
|
1201
1195
|
if (e.activation !== "region" && typeof e.isVisibleInContext != "function") throw Error(`Invalid tool registration "${e.toolId}": "isVisibleInContext" must be a function.`);
|
|
1202
1196
|
if (e.isVisibleInContext !== void 0 && typeof e.isVisibleInContext != "function") throw Error(`Invalid tool registration "${e.toolId}": "isVisibleInContext" must be a function when present.`);
|
|
1197
|
+
if (e.isApplicableToContent !== void 0 && typeof e.isApplicableToContent != "function") throw Error(`Invalid tool registration "${e.toolId}": "isApplicableToContent" must be a function when present.`);
|
|
1203
1198
|
if (e.requiresAuthoredContent !== void 0) {
|
|
1204
1199
|
if (typeof e.requiresAuthoredContent != "object" || e.requiresAuthoredContent === null || typeof e.requiresAuthoredContent.resolve != "function") throw Error(`Invalid tool registration "${e.toolId}": "requiresAuthoredContent" must be an object with a "resolve" function.`);
|
|
1205
1200
|
if (!e.pnpSupportIds?.length) throw Error(`Invalid tool registration "${e.toolId}": "requiresAuthoredContent" requires at least one entry in "pnpSupportIds", which is what a host filters a default grant list on.`);
|
|
@@ -1208,7 +1203,7 @@ function Pe(e) {
|
|
|
1208
1203
|
if (typeof e.renderToolbar != "function") throw Error(`Invalid tool registration "${e.toolId}": "renderToolbar" must be a function.`);
|
|
1209
1204
|
} else if (!t) throw Error(`Invalid tool registration "${e.toolId}": "renderToolbar" must be a function.`);
|
|
1210
1205
|
}
|
|
1211
|
-
var
|
|
1206
|
+
var Fe = class {
|
|
1212
1207
|
tools = /* @__PURE__ */ new Map();
|
|
1213
1208
|
pnpIndex = /* @__PURE__ */ new Map();
|
|
1214
1209
|
componentOverrides = {};
|
|
@@ -1315,6 +1310,16 @@ var E = class {
|
|
|
1315
1310
|
}
|
|
1316
1311
|
return n;
|
|
1317
1312
|
}
|
|
1313
|
+
isApplicableToAnyContext(e, t) {
|
|
1314
|
+
let n = this.get(e);
|
|
1315
|
+
return !n?.isApplicableToContent || t.length === 0 || t.some((t) => {
|
|
1316
|
+
try {
|
|
1317
|
+
return n.isApplicableToContent?.(t) ?? !0;
|
|
1318
|
+
} catch (t) {
|
|
1319
|
+
return console.error(`Error evaluating applicability for tool '${e}':`, t), !0;
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1318
1323
|
getToolMetadata() {
|
|
1319
1324
|
return this.getAllTools().map((e) => ({
|
|
1320
1325
|
toolId: e.toolId,
|
|
@@ -1410,7 +1415,7 @@ var E = class {
|
|
|
1410
1415
|
}
|
|
1411
1416
|
});
|
|
1412
1417
|
}
|
|
1413
|
-
},
|
|
1418
|
+
}, Ie = class {
|
|
1414
1419
|
targets = /* @__PURE__ */ new Set();
|
|
1415
1420
|
changeListeners = /* @__PURE__ */ new Set();
|
|
1416
1421
|
registerTarget(e) {
|
|
@@ -1460,10 +1465,13 @@ var E = class {
|
|
|
1460
1465
|
console.warn("[ToolRequestRegistry] Target change listener threw:", e);
|
|
1461
1466
|
}
|
|
1462
1467
|
}
|
|
1468
|
+
dispose() {
|
|
1469
|
+
this.targets.clear(), this.changeListeners.clear();
|
|
1470
|
+
}
|
|
1463
1471
|
};
|
|
1464
1472
|
//#endregion
|
|
1465
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1466
|
-
function
|
|
1473
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/framework-error.js
|
|
1474
|
+
function Le(e) {
|
|
1467
1475
|
return {
|
|
1468
1476
|
kind: e.kind,
|
|
1469
1477
|
severity: e.severity ?? "error",
|
|
@@ -1474,9 +1482,9 @@ function Ie(e) {
|
|
|
1474
1482
|
cause: e.cause
|
|
1475
1483
|
};
|
|
1476
1484
|
}
|
|
1477
|
-
function
|
|
1485
|
+
function Re(e) {
|
|
1478
1486
|
let t = e.error instanceof Error && e.error.message.trim().length > 0 ? e.error.message : String(e.error || "Unknown framework error");
|
|
1479
|
-
return
|
|
1487
|
+
return Le({
|
|
1480
1488
|
kind: e.kind,
|
|
1481
1489
|
source: e.source,
|
|
1482
1490
|
message: t,
|
|
@@ -1484,7 +1492,7 @@ function Le(e) {
|
|
|
1484
1492
|
cause: e.error
|
|
1485
1493
|
});
|
|
1486
1494
|
}
|
|
1487
|
-
var
|
|
1495
|
+
var ze = {
|
|
1488
1496
|
"coordinator-ready": "coordinator-init",
|
|
1489
1497
|
"state-load": "tool-state-load",
|
|
1490
1498
|
"state-save": "tool-state-save",
|
|
@@ -1494,9 +1502,9 @@ var Re = {
|
|
|
1494
1502
|
"section-controller-init": "section-controller-init",
|
|
1495
1503
|
"section-controller-dispose": "section-controller-dispose"
|
|
1496
1504
|
};
|
|
1497
|
-
function
|
|
1498
|
-
let t =
|
|
1499
|
-
return
|
|
1505
|
+
function Be(e) {
|
|
1506
|
+
let t = ze[e.context.phase];
|
|
1507
|
+
return Re({
|
|
1500
1508
|
kind: t,
|
|
1501
1509
|
source: e.context.providerId ? `pie-toolkit-coordinator/${e.context.providerId}` : `pie-toolkit-coordinator:${e.context.phase}`,
|
|
1502
1510
|
error: e.error,
|
|
@@ -1504,22 +1512,22 @@ function ze(e) {
|
|
|
1504
1512
|
});
|
|
1505
1513
|
}
|
|
1506
1514
|
//#endregion
|
|
1507
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1508
|
-
var
|
|
1509
|
-
function
|
|
1510
|
-
return e === "off" || e === "warn" || e === "error" ? e :
|
|
1515
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/tool-config-validation.js
|
|
1516
|
+
var Ve = "error";
|
|
1517
|
+
function He(e) {
|
|
1518
|
+
return e === "off" || e === "warn" || e === "error" ? e : Ve;
|
|
1511
1519
|
}
|
|
1512
|
-
function
|
|
1520
|
+
function E(e) {
|
|
1513
1521
|
return e;
|
|
1514
1522
|
}
|
|
1515
|
-
function
|
|
1523
|
+
function Ue(e) {
|
|
1516
1524
|
return e ? new Map(e.getAllTools().slice().sort((e, t) => e.toolId.localeCompare(t.toolId)).map((e) => [e.toolId, e])) : /* @__PURE__ */ new Map();
|
|
1517
1525
|
}
|
|
1518
|
-
function
|
|
1526
|
+
function We(e, t, n, r) {
|
|
1519
1527
|
if (!t || !n?.provider?.sanitizeConfig) return t;
|
|
1520
1528
|
try {
|
|
1521
1529
|
let i = n.provider.sanitizeConfig(t);
|
|
1522
|
-
return !i || typeof i != "object" || Array.isArray(i) ? (r.push(
|
|
1530
|
+
return !i || typeof i != "object" || Array.isArray(i) ? (r.push(E({
|
|
1523
1531
|
code: "tools.providerSanitizeFailed",
|
|
1524
1532
|
severity: "error",
|
|
1525
1533
|
path: `providers.${e}`,
|
|
@@ -1528,7 +1536,7 @@ function Ue(e, t, n, r) {
|
|
|
1528
1536
|
toolId: e
|
|
1529
1537
|
})), t) : i;
|
|
1530
1538
|
} catch (n) {
|
|
1531
|
-
return r.push(
|
|
1539
|
+
return r.push(E({
|
|
1532
1540
|
code: "tools.providerSanitizeFailed",
|
|
1533
1541
|
severity: "error",
|
|
1534
1542
|
path: `providers.${e}`,
|
|
@@ -1538,11 +1546,11 @@ function Ue(e, t, n, r) {
|
|
|
1538
1546
|
})), t;
|
|
1539
1547
|
}
|
|
1540
1548
|
}
|
|
1541
|
-
function
|
|
1549
|
+
function Ge(e, t, n, r) {
|
|
1542
1550
|
if (!(!t || !n?.provider?.validateConfig)) try {
|
|
1543
1551
|
let i = n.provider.validateConfig(t);
|
|
1544
1552
|
if (!Array.isArray(i)) {
|
|
1545
|
-
r.push(
|
|
1553
|
+
r.push(E({
|
|
1546
1554
|
code: "tools.invalidProviderValidation",
|
|
1547
1555
|
severity: "error",
|
|
1548
1556
|
path: `providers.${e}`,
|
|
@@ -1559,7 +1567,7 @@ function We(e, t, n, r) {
|
|
|
1559
1567
|
toolId: t.toolId || e
|
|
1560
1568
|
});
|
|
1561
1569
|
} catch (t) {
|
|
1562
|
-
r.push(
|
|
1570
|
+
r.push(E({
|
|
1563
1571
|
code: "tools.providerValidateFailed",
|
|
1564
1572
|
severity: "error",
|
|
1565
1573
|
path: `providers.${e}`,
|
|
@@ -1569,7 +1577,7 @@ function We(e, t, n, r) {
|
|
|
1569
1577
|
}));
|
|
1570
1578
|
}
|
|
1571
1579
|
}
|
|
1572
|
-
function
|
|
1580
|
+
function Ke(e, t, n) {
|
|
1573
1581
|
if (t.size !== 0) for (let r of [
|
|
1574
1582
|
"section",
|
|
1575
1583
|
"item",
|
|
@@ -1577,7 +1585,7 @@ function Ge(e, t, n) {
|
|
|
1577
1585
|
]) for (let i of e.placement[r]) {
|
|
1578
1586
|
let e = t.get(i);
|
|
1579
1587
|
if (!e) {
|
|
1580
|
-
n.push(
|
|
1588
|
+
n.push(E({
|
|
1581
1589
|
code: "tools.unknownToolId",
|
|
1582
1590
|
severity: "error",
|
|
1583
1591
|
path: `placement.${r}`,
|
|
@@ -1587,7 +1595,7 @@ function Ge(e, t, n) {
|
|
|
1587
1595
|
continue;
|
|
1588
1596
|
}
|
|
1589
1597
|
if (e.activation === "region") {
|
|
1590
|
-
n.push(
|
|
1598
|
+
n.push(E({
|
|
1591
1599
|
code: "tools.unplaceableActivation",
|
|
1592
1600
|
severity: "error",
|
|
1593
1601
|
path: `placement.${r}`,
|
|
@@ -1597,7 +1605,7 @@ function Ge(e, t, n) {
|
|
|
1597
1605
|
continue;
|
|
1598
1606
|
}
|
|
1599
1607
|
let a = e.supportedLevels.includes(r), o = r === "item" && e.supportedLevels.includes("section");
|
|
1600
|
-
!a && !o && n.push(
|
|
1608
|
+
!a && !o && n.push(E({
|
|
1601
1609
|
code: "tools.unsupportedLevel",
|
|
1602
1610
|
severity: "error",
|
|
1603
1611
|
path: `placement.${r}`,
|
|
@@ -1606,16 +1614,16 @@ function Ge(e, t, n) {
|
|
|
1606
1614
|
}));
|
|
1607
1615
|
}
|
|
1608
1616
|
}
|
|
1609
|
-
function
|
|
1617
|
+
function qe(e, t, n) {
|
|
1610
1618
|
if (t.size !== 0) {
|
|
1611
|
-
for (let r of e.policy.allowed || []) t.has(r) || n.push(
|
|
1619
|
+
for (let r of e.policy.allowed || []) t.has(r) || n.push(E({
|
|
1612
1620
|
code: "tools.unknownToolId",
|
|
1613
1621
|
severity: "error",
|
|
1614
1622
|
path: "policy.allowed",
|
|
1615
1623
|
message: `Unknown tool id "${r}" in policy.allowed.`,
|
|
1616
1624
|
toolId: r
|
|
1617
1625
|
}));
|
|
1618
|
-
for (let r of e.policy.blocked || []) t.has(r) || n.push(
|
|
1626
|
+
for (let r of e.policy.blocked || []) t.has(r) || n.push(E({
|
|
1619
1627
|
code: "tools.unknownToolId",
|
|
1620
1628
|
severity: "error",
|
|
1621
1629
|
path: "policy.blocked",
|
|
@@ -1624,8 +1632,8 @@ function Ke(e, t, n) {
|
|
|
1624
1632
|
}));
|
|
1625
1633
|
}
|
|
1626
1634
|
}
|
|
1627
|
-
function
|
|
1628
|
-
n && r.push(
|
|
1635
|
+
function Je(e, t, n, r) {
|
|
1636
|
+
n && r.push(E({
|
|
1629
1637
|
code: "tools.removedProviderKey",
|
|
1630
1638
|
severity: "error",
|
|
1631
1639
|
path: "providers.tts",
|
|
@@ -1633,7 +1641,7 @@ function qe(e, t, n, r) {
|
|
|
1633
1641
|
providerId: "tts",
|
|
1634
1642
|
toolId: "textToSpeech"
|
|
1635
1643
|
}));
|
|
1636
|
-
for (let n of Object.keys(e.providers).sort()) t.size === 0 || t.has(n) || r.push(
|
|
1644
|
+
for (let n of Object.keys(e.providers).sort()) t.size === 0 || t.has(n) || r.push(E({
|
|
1637
1645
|
code: "tools.unknownProviderKey",
|
|
1638
1646
|
severity: "error",
|
|
1639
1647
|
path: `providers.${n}`,
|
|
@@ -1642,19 +1650,19 @@ function qe(e, t, n, r) {
|
|
|
1642
1650
|
toolId: n
|
|
1643
1651
|
}));
|
|
1644
1652
|
}
|
|
1645
|
-
function
|
|
1653
|
+
function Ye(e, t) {
|
|
1646
1654
|
if (e.length !== 0) for (let n of e) {
|
|
1647
1655
|
let e = `[tool-config-validation:${t}]`;
|
|
1648
1656
|
console.warn(`${e} ${n.path} - ${n.message}`);
|
|
1649
1657
|
}
|
|
1650
1658
|
}
|
|
1651
|
-
function
|
|
1659
|
+
function Xe(e, t) {
|
|
1652
1660
|
let n = e.map((e) => `- ${e.path}: ${e.message}`).join("\n");
|
|
1653
1661
|
throw Error(`[tool-config-validation:${t}] Invalid tools config:\n${n}`);
|
|
1654
1662
|
}
|
|
1655
|
-
function
|
|
1656
|
-
let n =
|
|
1657
|
-
i.size === 0 && s && o.push(
|
|
1663
|
+
function D(e, t = {}) {
|
|
1664
|
+
let n = He(t.strictness), r = t.source ?? "tools", i = Ue(t.toolRegistry), a = Ae(e), o = [], s = Object.values(a.placement).some((e) => e.length > 0) || Object.keys(a.providers).length > 0 || (a.policy.allowed?.length ?? 0) > 0 || (a.policy.blocked?.length ?? 0) > 0;
|
|
1665
|
+
i.size === 0 && s && o.push(E({
|
|
1658
1666
|
code: "tools.registryUnavailable",
|
|
1659
1667
|
severity: "warning",
|
|
1660
1668
|
path: "tools",
|
|
@@ -1667,15 +1675,15 @@ function O(e, t = {}) {
|
|
|
1667
1675
|
continue;
|
|
1668
1676
|
}
|
|
1669
1677
|
let t = i.get(e);
|
|
1670
|
-
l[e] =
|
|
1678
|
+
l[e] = We(e, l[e], t, o), Ge(e, l[e], t, o);
|
|
1671
1679
|
}
|
|
1672
1680
|
let u = {
|
|
1673
1681
|
...a,
|
|
1674
1682
|
providers: l
|
|
1675
1683
|
};
|
|
1676
|
-
|
|
1684
|
+
Ke(u, i, o), qe(u, i, o), Je(u, i, c, o), c && Xe(o.filter((e) => e.code === "tools.removedProviderKey"), r), n === "warn" && Ye(o, r);
|
|
1677
1685
|
let d = o.filter((e) => e.severity === "error");
|
|
1678
|
-
return n === "error" && d.length > 0 &&
|
|
1686
|
+
return n === "error" && d.length > 0 && Xe(d, r), n === "error" && d.length === 0 && Ye(o, r), {
|
|
1679
1687
|
config: u,
|
|
1680
1688
|
diagnostics: o
|
|
1681
1689
|
};
|
|
@@ -1795,37 +1803,37 @@ Object.values({
|
|
|
1795
1803
|
}
|
|
1796
1804
|
}).flatMap((e) => Object.values(e));
|
|
1797
1805
|
//#endregion
|
|
1798
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1799
|
-
var
|
|
1806
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/catalog-media.js
|
|
1807
|
+
var Ze = /^[a-z][a-z0-9+.-]*:/i, Qe = /* @__PURE__ */ new Set([
|
|
1800
1808
|
"http:",
|
|
1801
1809
|
"https:",
|
|
1802
1810
|
"data:",
|
|
1803
1811
|
"blob:"
|
|
1804
1812
|
]);
|
|
1805
|
-
function
|
|
1813
|
+
function $e(e) {
|
|
1806
1814
|
return e !== void 0 && e !== 1;
|
|
1807
1815
|
}
|
|
1808
|
-
function
|
|
1816
|
+
function et(e) {
|
|
1809
1817
|
if (typeof e != "string") return !1;
|
|
1810
1818
|
let t = e.trim();
|
|
1811
1819
|
if (!t) return !1;
|
|
1812
|
-
if (t.startsWith("//") || !
|
|
1820
|
+
if (t.startsWith("//") || !Ze.test(t)) return !0;
|
|
1813
1821
|
let n = t.slice(0, t.indexOf(":") + 1).toLowerCase();
|
|
1814
|
-
return
|
|
1822
|
+
return Qe.has(n);
|
|
1815
1823
|
}
|
|
1816
|
-
function
|
|
1824
|
+
function tt(e) {
|
|
1817
1825
|
if (!Array.isArray(e)) return [];
|
|
1818
1826
|
let t = [];
|
|
1819
1827
|
for (let n of e) {
|
|
1820
1828
|
if (!n || typeof n != "object") continue;
|
|
1821
1829
|
let e = n;
|
|
1822
|
-
if (
|
|
1830
|
+
if (!et(e.src)) continue;
|
|
1823
1831
|
let r = { src: e.src.trim() };
|
|
1824
1832
|
typeof e.type == "string" && e.type.trim() && (r.type = e.type.trim()), Number.isFinite(e.width) && (r.width = e.width), Number.isFinite(e.height) && (r.height = e.height), !t.some((e) => e.src === r.src) && t.push(r);
|
|
1825
1833
|
}
|
|
1826
1834
|
return t;
|
|
1827
1835
|
}
|
|
1828
|
-
function
|
|
1836
|
+
function nt(e) {
|
|
1829
1837
|
if (!e || typeof e != "object") return;
|
|
1830
1838
|
let t = e, n = Number(t.startSeconds);
|
|
1831
1839
|
if (!Number.isFinite(n) || n < 0) return;
|
|
@@ -1835,61 +1843,61 @@ function tt(e) {
|
|
|
1835
1843
|
endSeconds: r
|
|
1836
1844
|
};
|
|
1837
1845
|
}
|
|
1838
|
-
function
|
|
1846
|
+
function rt(e) {
|
|
1839
1847
|
if (typeof e == "string") return e.trim() || void 0;
|
|
1840
1848
|
}
|
|
1841
|
-
var
|
|
1842
|
-
function
|
|
1849
|
+
var it = 100, at = 1;
|
|
1850
|
+
function ot(e, t, n) {
|
|
1843
1851
|
if (!t) return () => {};
|
|
1844
1852
|
let { startSeconds: r, endSeconds: i } = t, a;
|
|
1845
1853
|
r > 0 && (a = () => {
|
|
1846
1854
|
e.currentTime < r && (e.currentTime = r);
|
|
1847
|
-
}, e.readyState >=
|
|
1855
|
+
}, e.readyState >= at ? a() : e.addEventListener("loadedmetadata", a));
|
|
1848
1856
|
let o, s;
|
|
1849
1857
|
return i !== void 0 && (o = () => {
|
|
1850
1858
|
e.currentTime >= i && n();
|
|
1851
1859
|
}, e.addEventListener("timeupdate", o), s = setInterval(() => {
|
|
1852
1860
|
e.paused || o?.();
|
|
1853
|
-
},
|
|
1861
|
+
}, it)), () => {
|
|
1854
1862
|
a && e.removeEventListener("loadedmetadata", a), o && e.removeEventListener("timeupdate", o), s !== void 0 && clearInterval(s);
|
|
1855
1863
|
};
|
|
1856
1864
|
}
|
|
1857
|
-
function
|
|
1865
|
+
function st(e, t) {
|
|
1858
1866
|
if (!t || e.includes("#")) return e;
|
|
1859
1867
|
let n = t.endSeconds === void 0 ? "" : `,${t.endSeconds}`;
|
|
1860
1868
|
return `${e}#t=${t.startSeconds}${n}`;
|
|
1861
1869
|
}
|
|
1862
1870
|
//#endregion
|
|
1863
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1864
|
-
function
|
|
1871
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/spoken-audio-cards.js
|
|
1872
|
+
function ct(e) {
|
|
1865
1873
|
if (!e) return null;
|
|
1866
1874
|
let t = e.payload;
|
|
1867
1875
|
if (!t || typeof t != "object") return null;
|
|
1868
1876
|
let n = t.media;
|
|
1869
1877
|
if (!n || typeof n != "object") return console.warn("[spoken-audio] card carries a `payload` with no `media`; recorded speech needs `media.sources`, so this card is ignored and read-aloud falls back to the script or generated speech"), null;
|
|
1870
|
-
if (
|
|
1878
|
+
if ($e(n.version)) return console.warn(`[spoken-audio] card's media declares version ${String(n.version)}, which this build does not render; the card is ignored and read-aloud falls back to the script or generated speech`), null;
|
|
1871
1879
|
if (n.kind !== void 0 && n.kind !== "audio") return console.warn(`[spoken-audio] card's media is kind "${n.kind}", not "audio"; a spoken card carries recorded speech, so this card is ignored`), null;
|
|
1872
|
-
let r =
|
|
1880
|
+
let r = tt(n.sources);
|
|
1873
1881
|
return r.length === 0 ? (console.warn("[spoken-audio] card's `media.sources` yielded no usable URL; read-aloud falls back to the script or generated speech"), null) : {
|
|
1874
1882
|
sources: r,
|
|
1875
|
-
fragment:
|
|
1876
|
-
label:
|
|
1883
|
+
fragment: nt(t.fragment),
|
|
1884
|
+
label: rt(n.label)
|
|
1877
1885
|
};
|
|
1878
1886
|
}
|
|
1879
1887
|
//#endregion
|
|
1880
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1881
|
-
var
|
|
1888
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/ToolCoordinator.js
|
|
1889
|
+
var O = xe("ToolCoordinator"), k;
|
|
1882
1890
|
(function(e) {
|
|
1883
1891
|
e[e.BASE = 0] = "BASE", e[e.TOOL = 1e3] = "TOOL", e[e.MODAL = 2e3] = "MODAL", e[e.CONTROL = 3e3] = "CONTROL", e[e.HIGHLIGHT = 4e3] = "HIGHLIGHT";
|
|
1884
|
-
})(
|
|
1885
|
-
var
|
|
1892
|
+
})(k ||= {});
|
|
1893
|
+
var lt = class {
|
|
1886
1894
|
config;
|
|
1887
1895
|
tools = /* @__PURE__ */ new Map();
|
|
1888
1896
|
layerCounters = /* @__PURE__ */ new Map();
|
|
1889
1897
|
listeners = /* @__PURE__ */ new Set();
|
|
1890
1898
|
visibilityState = /* @__PURE__ */ new Map();
|
|
1891
1899
|
constructor(e = {}) {
|
|
1892
|
-
this.config = e, this.layerCounters.set(
|
|
1900
|
+
this.config = e, this.layerCounters.set(k.BASE, 0), this.layerCounters.set(k.TOOL, 0), this.layerCounters.set(k.MODAL, 0), this.layerCounters.set(k.CONTROL, 0), this.layerCounters.set(k.HIGHLIGHT, 0);
|
|
1893
1901
|
}
|
|
1894
1902
|
subscribe(e) {
|
|
1895
1903
|
return this.listeners.add(e), () => {
|
|
@@ -1899,14 +1907,14 @@ var ct = class {
|
|
|
1899
1907
|
notifyListeners() {
|
|
1900
1908
|
this.listeners.forEach((e) => e());
|
|
1901
1909
|
}
|
|
1902
|
-
registerTool(e, t, n, r =
|
|
1903
|
-
if (
|
|
1910
|
+
registerTool(e, t, n, r = k.MODAL) {
|
|
1911
|
+
if (O("registerTool called:", {
|
|
1904
1912
|
id: e,
|
|
1905
1913
|
name: t,
|
|
1906
1914
|
hasElement: !!n,
|
|
1907
1915
|
layer: r
|
|
1908
1916
|
}), this.tools.has(e)) {
|
|
1909
|
-
|
|
1917
|
+
O(`Tool ${e} is already registered`);
|
|
1910
1918
|
return;
|
|
1911
1919
|
}
|
|
1912
1920
|
let i = this.visibilityState.get(e) ?? !1;
|
|
@@ -1918,7 +1926,7 @@ var ct = class {
|
|
|
1918
1926
|
layer: r,
|
|
1919
1927
|
isVisible: i,
|
|
1920
1928
|
baseZIndex: r
|
|
1921
|
-
}),
|
|
1929
|
+
}), O("Tool registered without element:", e);
|
|
1922
1930
|
return;
|
|
1923
1931
|
}
|
|
1924
1932
|
let a = r + this.getNextLayerOffset(r);
|
|
@@ -1932,7 +1940,7 @@ var ct = class {
|
|
|
1932
1940
|
isVisible: i,
|
|
1933
1941
|
baseZIndex: a,
|
|
1934
1942
|
mouseDownHandler: o
|
|
1935
|
-
}), i && this.bringToFront(n),
|
|
1943
|
+
}), i && this.bringToFront(n), O("Tool registered with element:", e);
|
|
1936
1944
|
}
|
|
1937
1945
|
unregisterTool(e) {
|
|
1938
1946
|
let t = this.tools.get(e);
|
|
@@ -1944,7 +1952,7 @@ var ct = class {
|
|
|
1944
1952
|
showTool(e) {
|
|
1945
1953
|
let t = this.tools.get(e);
|
|
1946
1954
|
if (!t) {
|
|
1947
|
-
|
|
1955
|
+
O(`Tool ${e} not found`);
|
|
1948
1956
|
return;
|
|
1949
1957
|
}
|
|
1950
1958
|
t.element && (t.element.style.display = "", this.bringToFront(t.element)), t.isVisible = !0, this.visibilityState.set(e, !0), this.notifyListeners();
|
|
@@ -1952,19 +1960,19 @@ var ct = class {
|
|
|
1952
1960
|
hideTool(e) {
|
|
1953
1961
|
let t = this.tools.get(e);
|
|
1954
1962
|
if (!t) {
|
|
1955
|
-
|
|
1963
|
+
O(`Tool ${e} not found`);
|
|
1956
1964
|
return;
|
|
1957
1965
|
}
|
|
1958
1966
|
t.element && (t.element.style.display = "none"), t.isVisible = !1, this.visibilityState.set(e, !1), this.notifyListeners();
|
|
1959
1967
|
}
|
|
1960
1968
|
toggleTool(e) {
|
|
1961
|
-
|
|
1969
|
+
O("toggleTool called for:", e);
|
|
1962
1970
|
let t = this.tools.get(e);
|
|
1963
1971
|
if (!t) {
|
|
1964
|
-
|
|
1972
|
+
O(`Tool ${e} not found. Registered tools:`, Array.from(this.tools.keys()));
|
|
1965
1973
|
return;
|
|
1966
1974
|
}
|
|
1967
|
-
|
|
1975
|
+
O("Tool found, current visibility:", t.isVisible), t.isVisible ? this.hideTool(e) : this.showTool(e);
|
|
1968
1976
|
}
|
|
1969
1977
|
isToolVisible(e) {
|
|
1970
1978
|
let t = this.tools.get(e);
|
|
@@ -1997,7 +2005,7 @@ var ct = class {
|
|
|
1997
2005
|
updateToolElement(e, t) {
|
|
1998
2006
|
let n = this.tools.get(e);
|
|
1999
2007
|
if (!n) {
|
|
2000
|
-
|
|
2008
|
+
O(`Tool ${e} not found`);
|
|
2001
2009
|
return;
|
|
2002
2010
|
}
|
|
2003
2011
|
n.element && n.mouseDownHandler && n.element.removeEventListener("mousedown", n.mouseDownHandler);
|
|
@@ -2027,7 +2035,7 @@ var ct = class {
|
|
|
2027
2035
|
layer: e.layer
|
|
2028
2036
|
}));
|
|
2029
2037
|
}
|
|
2030
|
-
},
|
|
2038
|
+
}, ut = class {
|
|
2031
2039
|
listeners = /* @__PURE__ */ new Set();
|
|
2032
2040
|
subscribeFrameworkErrors(e) {
|
|
2033
2041
|
this.listeners.add(e);
|
|
@@ -2050,7 +2058,7 @@ var ct = class {
|
|
|
2050
2058
|
getListenerCount() {
|
|
2051
2059
|
return this.listeners.size;
|
|
2052
2060
|
}
|
|
2053
|
-
},
|
|
2061
|
+
}, A = (e, t) => {
|
|
2054
2062
|
let n = t?.useSentenceSegmenter !== !1;
|
|
2055
2063
|
try {
|
|
2056
2064
|
if (!n) throw Error("Segmenter disabled by policy");
|
|
@@ -2092,14 +2100,14 @@ var ct = class {
|
|
|
2092
2100
|
if (n) return n;
|
|
2093
2101
|
}
|
|
2094
2102
|
return e[0] || null;
|
|
2095
|
-
}, gt = (e) => !e.default,
|
|
2103
|
+
}, gt = (e) => !e.default, j = class {
|
|
2096
2104
|
providerId = "browser";
|
|
2097
2105
|
providerName = "Browser Speech Synthesis";
|
|
2098
2106
|
version = "1.0.0";
|
|
2099
2107
|
async initialize(e) {
|
|
2100
2108
|
if (typeof window > "u") throw Error("BrowserTTSProvider requires browser environment");
|
|
2101
2109
|
if (!("speechSynthesis" in window)) throw Error("Browser does not support Speech Synthesis API");
|
|
2102
|
-
return new
|
|
2110
|
+
return new _t(e);
|
|
2103
2111
|
}
|
|
2104
2112
|
supportsFeature(e) {
|
|
2105
2113
|
return !0;
|
|
@@ -2116,7 +2124,7 @@ var ct = class {
|
|
|
2116
2124
|
};
|
|
2117
2125
|
}
|
|
2118
2126
|
destroy() {}
|
|
2119
|
-
},
|
|
2127
|
+
}, _t = class {
|
|
2120
2128
|
utterance = null;
|
|
2121
2129
|
config = null;
|
|
2122
2130
|
_isPlaying = !1;
|
|
@@ -2234,7 +2242,7 @@ var ct = class {
|
|
|
2234
2242
|
}
|
|
2235
2243
|
segmentSentences(e) {
|
|
2236
2244
|
let t = this.getSegmentationPolicy();
|
|
2237
|
-
return
|
|
2245
|
+
return A(e, {
|
|
2238
2246
|
locale: t.locale,
|
|
2239
2247
|
useSentenceSegmenter: t.useSentenceSegmenter
|
|
2240
2248
|
});
|
|
@@ -2332,7 +2340,7 @@ var ct = class {
|
|
|
2332
2340
|
});
|
|
2333
2341
|
}
|
|
2334
2342
|
onWordBoundary;
|
|
2335
|
-
},
|
|
2343
|
+
}, M = (e) => e.trim().replace(/\s+/g, " "), vt = () => /[\p{L}]+|\d+(?:\.\d+)?|[±√=+\-*/()²³^×÷≤≥≠≈<>|%°'′\u2062]/gu, yt = (e) => {
|
|
2336
2344
|
if (e.hidden || e.tagName?.toLowerCase() === "mjx-assistive-mml" || e.getAttribute("aria-hidden") === "true" || e.hasAttribute("inert")) return !0;
|
|
2337
2345
|
let t = e.classList;
|
|
2338
2346
|
if (t?.contains("sr-only") || t?.contains("pie-sr-only") || t?.contains("visually-hidden")) return !0;
|
|
@@ -2343,28 +2351,28 @@ var ct = class {
|
|
|
2343
2351
|
if ((t.position === "absolute" || t.position === "fixed") && i && (t.overflow === "hidden" || a) || t.opacity === "0" && i) return !0;
|
|
2344
2352
|
}
|
|
2345
2353
|
return !1;
|
|
2346
|
-
},
|
|
2354
|
+
}, bt = (e, t) => {
|
|
2347
2355
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
2348
2356
|
for (; n;) {
|
|
2349
|
-
if (
|
|
2357
|
+
if (yt(n)) return !0;
|
|
2350
2358
|
if (t && n === t) break;
|
|
2351
2359
|
n = n.parentElement;
|
|
2352
2360
|
}
|
|
2353
2361
|
return !1;
|
|
2354
|
-
},
|
|
2355
|
-
let t = e.getAttribute?.(
|
|
2362
|
+
}, xt = "data-tts-suppress", St = /* @__PURE__ */ new Set(["computer-read-aloud", "all"]), Ct = /* @__PURE__ */ new Set([...St, "screen-reader"]), wt = /* @__PURE__ */ new Set(), Tt = (e) => {
|
|
2363
|
+
let t = e.getAttribute?.(xt);
|
|
2356
2364
|
if (t == null) return !1;
|
|
2357
2365
|
let n = t.trim().toLowerCase();
|
|
2358
|
-
return
|
|
2359
|
-
},
|
|
2366
|
+
return St.has(n) ? !0 : !Ct.has(n) && (wt.has(n) || (wt.add(n), console.warn(`[tts] ${xt}="${t}" is not one of ${Array.from(Ct).join(", ")}; suppressing read-aloud for this content anyway, because a suppression attribute that fails open would leak the answer to items where reading is the construct. Correct the value to silence this.`)), !0);
|
|
2367
|
+
}, Et = (e, t) => {
|
|
2360
2368
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
2361
2369
|
for (; n;) {
|
|
2362
|
-
if (
|
|
2370
|
+
if (Tt(n)) return !0;
|
|
2363
2371
|
if (t && n === t) break;
|
|
2364
2372
|
n = n.parentElement;
|
|
2365
2373
|
}
|
|
2366
2374
|
return !1;
|
|
2367
|
-
},
|
|
2375
|
+
}, N = (e, t) => bt(e, t) || Et(e), Dt = (e, t) => {
|
|
2368
2376
|
if (typeof document > "u" || typeof document.createTreeWalker != "function" || typeof NodeFilter > "u" || typeof e.intersectsNode != "function") return {
|
|
2369
2377
|
text: e.toString(),
|
|
2370
2378
|
filtered: !1
|
|
@@ -2373,7 +2381,7 @@ var ct = class {
|
|
|
2373
2381
|
for (; a;) {
|
|
2374
2382
|
let o = a;
|
|
2375
2383
|
if (e.intersectsNode(o)) {
|
|
2376
|
-
if (
|
|
2384
|
+
if (N(o, t)) r = !0;
|
|
2377
2385
|
else {
|
|
2378
2386
|
let t = o.textContent || "", r = o === e.startContainer ? e.startOffset : 0, i = o === e.endContainer ? e.endOffset : t.length;
|
|
2379
2387
|
n.push(t.slice(r, i));
|
|
@@ -2385,7 +2393,7 @@ var ct = class {
|
|
|
2385
2393
|
text: n.join(""),
|
|
2386
2394
|
filtered: r
|
|
2387
2395
|
};
|
|
2388
|
-
},
|
|
2396
|
+
}, Ot = (e, t, n) => {
|
|
2389
2397
|
if (!e || !t || /\s/.test(e) || /\s/.test(t)) return !1;
|
|
2390
2398
|
let r = n?.boundarySpacingMode ?? "segmenterPreferred";
|
|
2391
2399
|
if (r === "none") return !1;
|
|
@@ -2398,7 +2406,7 @@ var ct = class {
|
|
|
2398
2406
|
} catch {}
|
|
2399
2407
|
let i = /[A-Za-z0-9]/.test(e), a = /[A-Za-z0-9]/.test(t);
|
|
2400
2408
|
return i && a;
|
|
2401
|
-
},
|
|
2409
|
+
}, P = (e, t) => {
|
|
2402
2410
|
let n = /* @__PURE__ */ new Map();
|
|
2403
2411
|
if (typeof document > "u" || typeof document.createTreeWalker != "function" || typeof NodeFilter > "u") return {
|
|
2404
2412
|
text: "",
|
|
@@ -2407,9 +2415,9 @@ var ct = class {
|
|
|
2407
2415
|
let r = [], i = 0, a = !0, o = !1, s = null, c = null, l = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), u = l.nextNode();
|
|
2408
2416
|
for (; u;) {
|
|
2409
2417
|
let d = u;
|
|
2410
|
-
if (d.parentElement && !
|
|
2418
|
+
if (d.parentElement && !N(d, e)) {
|
|
2411
2419
|
let e = d.textContent || "", l = e.match(/\S/), u = l ? l[0] : null;
|
|
2412
|
-
!a && !o &&
|
|
2420
|
+
!a && !o && Ot(c, u, t) && (r.push(" "), s && n.set(i, s), i++, o = !0);
|
|
2413
2421
|
for (let t = 0; t < e.length; t++) {
|
|
2414
2422
|
let l = e[t], u = /\s/.test(l);
|
|
2415
2423
|
a ? u || (a = !1, r.push(l), n.set(i, {
|
|
@@ -2441,7 +2449,7 @@ var ct = class {
|
|
|
2441
2449
|
text: d,
|
|
2442
2450
|
map: n
|
|
2443
2451
|
};
|
|
2444
|
-
},
|
|
2452
|
+
}, kt = /* @__PURE__ */ new Set([
|
|
2445
2453
|
"speak",
|
|
2446
2454
|
"p",
|
|
2447
2455
|
"s",
|
|
@@ -2450,20 +2458,20 @@ var ct = class {
|
|
|
2450
2458
|
"say-as",
|
|
2451
2459
|
"voice",
|
|
2452
2460
|
"lang"
|
|
2453
|
-
]),
|
|
2461
|
+
]), At = /* @__PURE__ */ new Set(["audio", "phoneme"]), jt = (e) => e.replace(/"/g, "\"").replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/ /g, "\xA0").replace(/ /g, "\xA0").replace(/&/g, "&"), F = (e, t, n) => {
|
|
2454
2462
|
for (let r = 0; r < t.length; r++) e.push({
|
|
2455
2463
|
char: t[r],
|
|
2456
2464
|
rawOffset: n === null ? null : n + r
|
|
2457
2465
|
});
|
|
2458
|
-
},
|
|
2466
|
+
}, Mt = (e, t, n) => {
|
|
2459
2467
|
let r = t.slice(n).match(/^&(quot|apos|lt|gt|nbsp|amp|#160);/i);
|
|
2460
|
-
return r ? (
|
|
2461
|
-
},
|
|
2468
|
+
return r ? (F(e, jt(r[0]), n), r[0].length) : 0;
|
|
2469
|
+
}, Nt = (e) => {
|
|
2462
2470
|
e.push({
|
|
2463
2471
|
char: " ",
|
|
2464
2472
|
rawOffset: null
|
|
2465
2473
|
});
|
|
2466
|
-
},
|
|
2474
|
+
}, Pt = (e) => {
|
|
2467
2475
|
let t = /* @__PURE__ */ new Map(), n = [], r = !0;
|
|
2468
2476
|
for (let i of e) {
|
|
2469
2477
|
if (/\s/.test(i.char)) {
|
|
@@ -2478,60 +2486,60 @@ var ct = class {
|
|
|
2478
2486
|
text: n.join(""),
|
|
2479
2487
|
rawToSpokenOffsetMap: t
|
|
2480
2488
|
};
|
|
2481
|
-
},
|
|
2489
|
+
}, Ft = (e) => e.match(/^<\/?\s*([A-Za-z0-9:-]+)/)?.[1]?.toLowerCase() || "", It = (e, t) => {
|
|
2482
2490
|
let n = RegExp(`${t}\\s*=\\s*("([^"]*)"|'([^']*)')`, "i"), r = e.match(n);
|
|
2483
|
-
return
|
|
2484
|
-
},
|
|
2491
|
+
return jt(r?.[2] ?? r?.[3] ?? "") || null;
|
|
2492
|
+
}, Lt = (e) => {
|
|
2485
2493
|
let t = [], n = !1, r = !1, i = 0;
|
|
2486
2494
|
for (; i < e.length;) {
|
|
2487
2495
|
let a = e[i];
|
|
2488
2496
|
if (a !== "<") {
|
|
2489
2497
|
if (a === "&") {
|
|
2490
|
-
let n =
|
|
2498
|
+
let n = Mt(t, e, i);
|
|
2491
2499
|
if (n > 0) {
|
|
2492
2500
|
i += n;
|
|
2493
2501
|
continue;
|
|
2494
2502
|
}
|
|
2495
2503
|
}
|
|
2496
|
-
|
|
2504
|
+
F(t, a, i), i++;
|
|
2497
2505
|
continue;
|
|
2498
2506
|
}
|
|
2499
2507
|
let o = e.indexOf(">", i + 1);
|
|
2500
2508
|
if (o < 0) {
|
|
2501
|
-
|
|
2509
|
+
F(t, a, i), i++;
|
|
2502
2510
|
continue;
|
|
2503
2511
|
}
|
|
2504
2512
|
r = !0;
|
|
2505
|
-
let s = e.slice(i, o + 1), c =
|
|
2513
|
+
let s = e.slice(i, o + 1), c = Ft(s), l = /^<\s*\//.test(s), u = /\/\s*>$/.test(s);
|
|
2506
2514
|
if (!l && c === "sub") {
|
|
2507
|
-
let r =
|
|
2515
|
+
let r = It(s, "alias");
|
|
2508
2516
|
if (!r) {
|
|
2509
2517
|
n = !0, i = o + 1;
|
|
2510
2518
|
continue;
|
|
2511
2519
|
}
|
|
2512
|
-
|
|
2520
|
+
F(t, r, null);
|
|
2513
2521
|
let a = e.toLowerCase().indexOf("</sub>", o + 1);
|
|
2514
2522
|
i = a >= 0 ? a + 6 : o + 1;
|
|
2515
2523
|
continue;
|
|
2516
2524
|
}
|
|
2517
2525
|
if (!l && c === "break") {
|
|
2518
|
-
|
|
2526
|
+
Nt(t), i = o + 1;
|
|
2519
2527
|
continue;
|
|
2520
2528
|
}
|
|
2521
|
-
if (!l &&
|
|
2529
|
+
if (!l && At.has(c) && (n = !0, u)) {
|
|
2522
2530
|
i = o + 1;
|
|
2523
2531
|
continue;
|
|
2524
2532
|
}
|
|
2525
|
-
c && !
|
|
2533
|
+
c && !kt.has(c) && !At.has(c) && c !== "break" && c !== "sub" && (n = !0), !l && (c === "p" || c === "s") && Nt(t), i = o + 1;
|
|
2526
2534
|
}
|
|
2527
|
-
let a =
|
|
2535
|
+
let a = Pt(t);
|
|
2528
2536
|
return {
|
|
2529
|
-
spokenText:
|
|
2537
|
+
spokenText: M(a.text),
|
|
2530
2538
|
rawToSpokenOffsetMap: a.rawToSpokenOffsetMap,
|
|
2531
2539
|
unsupportedSemantic: n,
|
|
2532
2540
|
hasMarkup: r
|
|
2533
2541
|
};
|
|
2534
|
-
},
|
|
2542
|
+
}, Rt = vt(), zt = /* @__PURE__ */ new Map([
|
|
2535
2543
|
["zero", "0"],
|
|
2536
2544
|
["one", "1"],
|
|
2537
2545
|
["two", "2"],
|
|
@@ -2543,7 +2551,7 @@ var ct = class {
|
|
|
2543
2551
|
["eight", "8"],
|
|
2544
2552
|
["nine", "9"],
|
|
2545
2553
|
["ten", "10"]
|
|
2546
|
-
]),
|
|
2554
|
+
]), Bt = [
|
|
2547
2555
|
{
|
|
2548
2556
|
phrase: [
|
|
2549
2557
|
"plus",
|
|
@@ -2618,9 +2626,9 @@ var ct = class {
|
|
|
2618
2626
|
visible: "+",
|
|
2619
2627
|
score: 5
|
|
2620
2628
|
}
|
|
2621
|
-
],
|
|
2629
|
+
], Vt = (e) => {
|
|
2622
2630
|
let t = [];
|
|
2623
|
-
for (let n of e.matchAll(
|
|
2631
|
+
for (let n of e.matchAll(Rt)) {
|
|
2624
2632
|
let e = n[0], r = n.index ?? 0;
|
|
2625
2633
|
t.push({
|
|
2626
2634
|
text: e,
|
|
@@ -2630,16 +2638,16 @@ var ct = class {
|
|
|
2630
2638
|
});
|
|
2631
2639
|
}
|
|
2632
2640
|
return t;
|
|
2633
|
-
},
|
|
2641
|
+
}, Ht = (e) => zt.get(e.normalized) || e.normalized, Ut = (e, t) => {
|
|
2634
2642
|
let n = [];
|
|
2635
2643
|
for (let r = 0; r < e.length; r++) {
|
|
2636
|
-
for (let i = 0; i < t.length; i++)
|
|
2644
|
+
for (let i = 0; i < t.length; i++) Ht(e[r]) === Ht(t[i]) && n.push({
|
|
2637
2645
|
spokenStartToken: r,
|
|
2638
2646
|
spokenEndToken: r + 1,
|
|
2639
2647
|
visibleToken: i,
|
|
2640
2648
|
score: 10
|
|
2641
2649
|
});
|
|
2642
|
-
for (let i of
|
|
2650
|
+
for (let i of Bt) {
|
|
2643
2651
|
let a = e.slice(r, r + i.phrase.length);
|
|
2644
2652
|
if (a.length === i.phrase.length && a.every((e, t) => e.normalized === i.phrase[t])) for (let e = 0; e < t.length; e++) t[e].normalized === i.visible && n.push({
|
|
2645
2653
|
spokenStartToken: r,
|
|
@@ -2650,8 +2658,8 @@ var ct = class {
|
|
|
2650
2658
|
}
|
|
2651
2659
|
}
|
|
2652
2660
|
return n;
|
|
2653
|
-
},
|
|
2654
|
-
let n =
|
|
2661
|
+
}, Wt = (e, t) => {
|
|
2662
|
+
let n = Ut(e, t).sort((n, r) => e[n.spokenStartToken].start - e[r.spokenStartToken].start || t[n.visibleToken].start - t[r.visibleToken].start), r = Array(n.length).fill(0), i = Array(n.length).fill(-1);
|
|
2655
2663
|
for (let e = 0; e < n.length; e++) {
|
|
2656
2664
|
let t = n[e];
|
|
2657
2665
|
r[e] = t.score;
|
|
@@ -2678,12 +2686,12 @@ var ct = class {
|
|
|
2678
2686
|
score: n.score
|
|
2679
2687
|
};
|
|
2680
2688
|
});
|
|
2681
|
-
},
|
|
2689
|
+
}, Gt = (e, t, n) => {
|
|
2682
2690
|
if (e.length === 0) return 0;
|
|
2683
2691
|
let r = e.length / Math.max(1, Math.min(t.length, n.length)), i = e.reduce((e, t) => e + t.score, 0) / e.length / 10;
|
|
2684
2692
|
return Math.min(1, r * i);
|
|
2685
|
-
},
|
|
2686
|
-
let t =
|
|
2693
|
+
}, Kt = (e) => {
|
|
2694
|
+
let t = Lt(e.speechText), n = M(e.visibleText), r = t.spokenText, i = Vt(r), a = Vt(n), o = t.unsupportedSemantic ? [] : Wt(i, a), s = Gt(o, i, a), c = r === n && r.length > 0, l = o.length === 1 && o[0].score === 10 && i.length <= 2 && a.length <= 2, u = t.unsupportedSemantic ? "region-fallback" : c ? "exact-word" : (o.length >= 2 || l) && s >= .12 ? "anchor-span" : "region-fallback", d = t.unsupportedSemantic ? "unsupported" : t.hasMarkup ? "raw-ssml" : "plain-spoken-text";
|
|
2687
2695
|
return {
|
|
2688
2696
|
speechText: e.speechText,
|
|
2689
2697
|
spokenText: r,
|
|
@@ -2696,16 +2704,16 @@ var ct = class {
|
|
|
2696
2704
|
visibleTokens: a,
|
|
2697
2705
|
rawToSpokenOffsetMap: t.rawToSpokenOffsetMap
|
|
2698
2706
|
};
|
|
2699
|
-
},
|
|
2707
|
+
}, qt = (e, t) => e.find((e) => e.start <= t && t < e.end) || null, Jt = (e) => {
|
|
2700
2708
|
if (!e || /^<[^>]+>$/.test(e.trim())) return null;
|
|
2701
|
-
let t =
|
|
2702
|
-
return t ?
|
|
2703
|
-
},
|
|
2704
|
-
let r =
|
|
2709
|
+
let t = Vt(e)[0];
|
|
2710
|
+
return t ? zt.get(t.normalized) || t.normalized : null;
|
|
2711
|
+
}, Yt = (e, t, n) => {
|
|
2712
|
+
let r = Jt(n);
|
|
2705
2713
|
if (!t || !r) return !1;
|
|
2706
|
-
let i =
|
|
2707
|
-
return i ?
|
|
2708
|
-
},
|
|
2714
|
+
let i = qt(e.spokenTokens, t.start);
|
|
2715
|
+
return i ? Ht(i) === r : !1;
|
|
2716
|
+
}, Xt = (e, t) => {
|
|
2709
2717
|
let n = e.rawToSpokenOffsetMap.get(t);
|
|
2710
2718
|
if (n !== void 0) return n;
|
|
2711
2719
|
for (let n = t; n < e.speechText.length; n++) {
|
|
@@ -2714,36 +2722,36 @@ var ct = class {
|
|
|
2714
2722
|
if (e.speechText[n] === ">") break;
|
|
2715
2723
|
}
|
|
2716
2724
|
return null;
|
|
2717
|
-
},
|
|
2718
|
-
let r =
|
|
2725
|
+
}, Zt = (e, t, n) => {
|
|
2726
|
+
let r = Xt(e, t);
|
|
2719
2727
|
if (r === null) return null;
|
|
2720
|
-
let i =
|
|
2728
|
+
let i = Xt(e, Math.max(t, t + n - 1)), a = qt(e.spokenTokens, r), o = i !== null && i >= r ? i - r + 1 : a ? a.end - r : n;
|
|
2721
2729
|
return {
|
|
2722
2730
|
start: r,
|
|
2723
2731
|
length: Math.max(1, o)
|
|
2724
2732
|
};
|
|
2725
|
-
},
|
|
2733
|
+
}, Qt = (e, t, n) => {
|
|
2726
2734
|
if (t < 0 || t >= e.spokenText.length) return null;
|
|
2727
|
-
let r =
|
|
2735
|
+
let r = qt(e.spokenTokens, t);
|
|
2728
2736
|
return r ? {
|
|
2729
2737
|
start: t,
|
|
2730
2738
|
length: Math.min(n, r.end - t)
|
|
2731
2739
|
} : null;
|
|
2732
|
-
},
|
|
2740
|
+
}, $t = (e, t, n = 1, r) => {
|
|
2733
2741
|
if (e.boundaryOffsetMode === "unsupported" || !Number.isFinite(t)) return null;
|
|
2734
2742
|
let i = Math.max(1, Number.isFinite(n) ? n : 1);
|
|
2735
2743
|
if (r && /^<[^>]+>$/.test(r.trim())) return null;
|
|
2736
2744
|
if (e.boundaryOffsetMode === "raw-ssml") {
|
|
2737
|
-
let n =
|
|
2745
|
+
let n = Zt(e, t, i), a = Qt(e, t, i);
|
|
2738
2746
|
if (r) {
|
|
2739
|
-
if (
|
|
2740
|
-
if (
|
|
2741
|
-
if (
|
|
2747
|
+
if (Yt(e, n, r)) return n;
|
|
2748
|
+
if (Yt(e, a, r)) return a;
|
|
2749
|
+
if (Jt(r)) return null;
|
|
2742
2750
|
}
|
|
2743
2751
|
return n || a;
|
|
2744
2752
|
}
|
|
2745
|
-
return
|
|
2746
|
-
},
|
|
2753
|
+
return Qt(e, t, i) || Zt(e, t, i);
|
|
2754
|
+
}, en = (e, t) => {
|
|
2747
2755
|
if (e.playbackMode === "region-fallback") return null;
|
|
2748
2756
|
let n = e.anchors.find((e) => e.spokenStart <= t && t < e.spokenEnd);
|
|
2749
2757
|
if (n) return {
|
|
@@ -2765,7 +2773,7 @@ var ct = class {
|
|
|
2765
2773
|
start: Math.min(r.visibleStart, i.visibleStart),
|
|
2766
2774
|
end: Math.max(r.visibleEnd, i.visibleEnd)
|
|
2767
2775
|
} : null;
|
|
2768
|
-
},
|
|
2776
|
+
}, tn = /* @__PURE__ */ new Map([
|
|
2769
2777
|
["+", ["plus"]],
|
|
2770
2778
|
["-", ["minus", "negative"]],
|
|
2771
2779
|
["−", ["minus", "negative"]],
|
|
@@ -2789,12 +2797,12 @@ var ct = class {
|
|
|
2789
2797
|
["•", ["times"]],
|
|
2790
2798
|
["·", ["times"]],
|
|
2791
2799
|
["", ["times", "multiplied by"]]
|
|
2792
|
-
]),
|
|
2800
|
+
]), nn = /* @__PURE__ */ new Map([
|
|
2793
2801
|
["", "function-application"],
|
|
2794
2802
|
["", "implicit-multiply"],
|
|
2795
2803
|
["", "invisible-separator"],
|
|
2796
2804
|
["", "invisible-plus"]
|
|
2797
|
-
]),
|
|
2805
|
+
]), rn = /* @__PURE__ */ new Map([["2", ["squared"]], ["3", ["cubed"]]]), an = /* @__PURE__ */ new Map([
|
|
2798
2806
|
["msqrt", "radical"],
|
|
2799
2807
|
["mroot", "radical"],
|
|
2800
2808
|
["msub", "subscript"],
|
|
@@ -2804,11 +2812,11 @@ var ct = class {
|
|
|
2804
2812
|
["munderover", "underoverscript"],
|
|
2805
2813
|
["mmultiscripts", "multiscript"],
|
|
2806
2814
|
["menclose", "enclosure"]
|
|
2807
|
-
]),
|
|
2815
|
+
]), on = (e) => e.replace(/\s+/g, " ").trim(), I = (e) => (e.localName || e.tagName || "").toLowerCase(), sn = (e) => e.nodeType === Node.ELEMENT_NODE, L = (e) => Array.from(e.childNodes).filter(sn), cn = (e) => on(e.textContent || ""), R = (e, t) => ({
|
|
2808
2816
|
type: "element-range",
|
|
2809
2817
|
quality: t,
|
|
2810
2818
|
element: e
|
|
2811
|
-
}),
|
|
2819
|
+
}), ln = (e) => {
|
|
2812
2820
|
switch (e) {
|
|
2813
2821
|
case "mi": return "identifier";
|
|
2814
2822
|
case "mn": return "number";
|
|
@@ -2818,62 +2826,62 @@ var ct = class {
|
|
|
2818
2826
|
case "mspace": return "space";
|
|
2819
2827
|
default: return "unknown";
|
|
2820
2828
|
}
|
|
2821
|
-
},
|
|
2822
|
-
let t = e.normalized ??
|
|
2829
|
+
}, un = (e, t) => t === "operator" ? e === "−" ? "-" : e : e.toLowerCase(), dn = (e, t, n) => n === "fraction" ? ["over", "divided by"] : n === "superscript" ? rn.get(e) ?? [] : e === "|" ? ["absolute value"] : t === "operator" && tn.get(e) || [], z = (e) => {
|
|
2830
|
+
let t = e.normalized ?? un(e.text, e.kind || "unknown");
|
|
2823
2831
|
return {
|
|
2824
2832
|
id: `math-token-${e.state.nextId++}`,
|
|
2825
2833
|
kind: e.kind,
|
|
2826
2834
|
role: e.role,
|
|
2827
2835
|
text: e.text,
|
|
2828
2836
|
normalized: t,
|
|
2829
|
-
spokenAliases:
|
|
2837
|
+
spokenAliases: dn(e.text, e.kind, e.role),
|
|
2830
2838
|
sourceElement: e.sourceElement,
|
|
2831
2839
|
path: e.path,
|
|
2832
|
-
target: e.target ||
|
|
2840
|
+
target: e.target || R(e.sourceElement, "element-range"),
|
|
2833
2841
|
optional: e.optional
|
|
2834
2842
|
};
|
|
2835
|
-
},
|
|
2843
|
+
}, B = (e, t, n = "tokens") => {
|
|
2836
2844
|
e[n].push(t);
|
|
2837
|
-
}, dn = (e, t, n) => {
|
|
2838
|
-
R(e).forEach((e, r) => H(e, t, `${n}/${L(e)}[${r}]`));
|
|
2839
2845
|
}, fn = (e, t, n) => {
|
|
2840
|
-
|
|
2841
|
-
|
|
2846
|
+
L(e).forEach((e, r) => V(e, t, `${n}/${I(e)}[${r}]`));
|
|
2847
|
+
}, pn = (e, t, n) => {
|
|
2848
|
+
let r = L(e);
|
|
2849
|
+
r[0] && V(r[0], t, `${n}/numerator`), B(t, z({
|
|
2842
2850
|
state: t,
|
|
2843
2851
|
kind: "structure",
|
|
2844
2852
|
role: "fraction",
|
|
2845
2853
|
text: "/",
|
|
2846
2854
|
sourceElement: e,
|
|
2847
2855
|
path: n,
|
|
2848
|
-
target:
|
|
2849
|
-
})), r[1] &&
|
|
2850
|
-
},
|
|
2856
|
+
target: R(e, "element-range")
|
|
2857
|
+
})), r[1] && V(r[1], t, `${n}/denominator`);
|
|
2858
|
+
}, mn = (e, t, n) => {
|
|
2851
2859
|
let r = e.getAttribute("open") || "(", i = e.getAttribute("close") || ")";
|
|
2852
|
-
|
|
2860
|
+
B(t, z({
|
|
2853
2861
|
state: t,
|
|
2854
2862
|
kind: "operator",
|
|
2855
2863
|
role: r === "|" ? "absolute-value-fence" : "open-fence",
|
|
2856
2864
|
text: r,
|
|
2857
2865
|
sourceElement: e,
|
|
2858
2866
|
path: `${n}/open`,
|
|
2859
|
-
target:
|
|
2860
|
-
})),
|
|
2867
|
+
target: R(e, "element-range")
|
|
2868
|
+
})), fn(e, t, n), B(t, z({
|
|
2861
2869
|
state: t,
|
|
2862
2870
|
kind: "operator",
|
|
2863
2871
|
role: i === "|" ? "absolute-value-fence" : "close-fence",
|
|
2864
2872
|
text: i,
|
|
2865
2873
|
sourceElement: e,
|
|
2866
2874
|
path: `${n}/close`,
|
|
2867
|
-
target:
|
|
2875
|
+
target: R(e, "element-range")
|
|
2868
2876
|
}));
|
|
2869
|
-
},
|
|
2870
|
-
let r =
|
|
2871
|
-
r[0] &&
|
|
2877
|
+
}, hn = (e, t, n) => {
|
|
2878
|
+
let r = L(e);
|
|
2879
|
+
r[0] && V(r[0], t, `${n}/base`);
|
|
2872
2880
|
let i = r[1];
|
|
2873
2881
|
if (!i) return;
|
|
2874
|
-
let a =
|
|
2875
|
-
if (
|
|
2876
|
-
|
|
2882
|
+
let a = cn(i);
|
|
2883
|
+
if (rn.has(a)) {
|
|
2884
|
+
B(t, z({
|
|
2877
2885
|
state: t,
|
|
2878
2886
|
kind: "structure",
|
|
2879
2887
|
role: "superscript",
|
|
@@ -2881,25 +2889,25 @@ var ct = class {
|
|
|
2881
2889
|
normalized: a,
|
|
2882
2890
|
sourceElement: i,
|
|
2883
2891
|
path: `${n}/exponent`,
|
|
2884
|
-
target:
|
|
2892
|
+
target: R(e, "element-range")
|
|
2885
2893
|
}));
|
|
2886
2894
|
return;
|
|
2887
2895
|
}
|
|
2888
|
-
|
|
2889
|
-
},
|
|
2890
|
-
|
|
2896
|
+
V(i, t, `${n}/exponent`);
|
|
2897
|
+
}, gn = (e, t, n, r) => {
|
|
2898
|
+
B(t, z({
|
|
2891
2899
|
state: t,
|
|
2892
2900
|
kind: "structure",
|
|
2893
2901
|
role: r,
|
|
2894
|
-
text:
|
|
2902
|
+
text: cn(e) || r,
|
|
2895
2903
|
normalized: `\u0000${r}`,
|
|
2896
2904
|
sourceElement: e,
|
|
2897
2905
|
path: n,
|
|
2898
|
-
target:
|
|
2906
|
+
target: R(e, "element-range")
|
|
2899
2907
|
}));
|
|
2900
|
-
},
|
|
2908
|
+
}, _n = (e, t, n) => {
|
|
2901
2909
|
let r = 0;
|
|
2902
|
-
for (let i of
|
|
2910
|
+
for (let i of L(e)) (I(i) === "mtr" || I(i) === "mlabeledtr") && (r++, B(t, z({
|
|
2903
2911
|
state: t,
|
|
2904
2912
|
kind: "layout",
|
|
2905
2913
|
role: "table-row",
|
|
@@ -2907,33 +2915,33 @@ var ct = class {
|
|
|
2907
2915
|
normalized: `row-${r}`,
|
|
2908
2916
|
sourceElement: i,
|
|
2909
2917
|
path: `${n}/row[${r}]`,
|
|
2910
|
-
target:
|
|
2911
|
-
}), "layoutTargets")),
|
|
2912
|
-
},
|
|
2913
|
-
let r =
|
|
2918
|
+
target: R(i, "region-fallback")
|
|
2919
|
+
}), "layoutTargets")), V(i, t, `${n}/${I(i)}[${r}]`);
|
|
2920
|
+
}, vn = (e, t, n) => {
|
|
2921
|
+
let r = cn(e);
|
|
2914
2922
|
if (!r) return;
|
|
2915
|
-
let i =
|
|
2916
|
-
|
|
2923
|
+
let i = ln(I(e)), a = i === "operator" ? nn.get(r) : void 0, o = a ?? (i === "operator" && (r === "(" || r === ")") ? "grouping-fence" : i);
|
|
2924
|
+
B(t, z({
|
|
2917
2925
|
state: t,
|
|
2918
2926
|
kind: i,
|
|
2919
2927
|
role: o,
|
|
2920
2928
|
text: r,
|
|
2921
2929
|
sourceElement: e,
|
|
2922
2930
|
path: n,
|
|
2923
|
-
target: a && e.parentElement ?
|
|
2931
|
+
target: a && e.parentElement ? R(e.parentElement, "region-fallback") : void 0,
|
|
2924
2932
|
optional: !!a || o === "grouping-fence"
|
|
2925
2933
|
}));
|
|
2926
|
-
},
|
|
2927
|
-
let r =
|
|
2934
|
+
}, V = (e, t, n) => {
|
|
2935
|
+
let r = I(e);
|
|
2928
2936
|
switch (r) {
|
|
2929
2937
|
case "annotation":
|
|
2930
2938
|
case "annotation-xml": return;
|
|
2931
2939
|
case "semantics": {
|
|
2932
|
-
let r =
|
|
2933
|
-
let t =
|
|
2940
|
+
let r = L(e).find((e) => {
|
|
2941
|
+
let t = I(e);
|
|
2934
2942
|
return t !== "annotation" && t !== "annotation-xml";
|
|
2935
2943
|
});
|
|
2936
|
-
r &&
|
|
2944
|
+
r && V(r, t, `${n}/presentation`);
|
|
2937
2945
|
return;
|
|
2938
2946
|
}
|
|
2939
2947
|
case "mi":
|
|
@@ -2942,47 +2950,47 @@ var ct = class {
|
|
|
2942
2950
|
case "mtext":
|
|
2943
2951
|
case "ms":
|
|
2944
2952
|
case "mspace":
|
|
2945
|
-
|
|
2953
|
+
vn(e, t, n);
|
|
2946
2954
|
return;
|
|
2947
2955
|
case "mfrac":
|
|
2948
|
-
|
|
2956
|
+
pn(e, t, n);
|
|
2949
2957
|
return;
|
|
2950
2958
|
case "msup":
|
|
2951
|
-
|
|
2959
|
+
hn(e, t, n);
|
|
2952
2960
|
return;
|
|
2953
2961
|
case "mfenced":
|
|
2954
|
-
|
|
2962
|
+
mn(e, t, n);
|
|
2955
2963
|
return;
|
|
2956
2964
|
case "mtable":
|
|
2957
|
-
|
|
2965
|
+
_n(e, t, n);
|
|
2958
2966
|
return;
|
|
2959
2967
|
case "mphantom": return;
|
|
2960
2968
|
case "maction": {
|
|
2961
|
-
let r =
|
|
2962
|
-
r &&
|
|
2969
|
+
let r = L(e)[0];
|
|
2970
|
+
r && V(r, t, `${n}/action`);
|
|
2963
2971
|
return;
|
|
2964
2972
|
}
|
|
2965
2973
|
default: {
|
|
2966
|
-
let i =
|
|
2974
|
+
let i = an.get(r);
|
|
2967
2975
|
if (i) {
|
|
2968
|
-
|
|
2976
|
+
gn(e, t, n, i);
|
|
2969
2977
|
return;
|
|
2970
2978
|
}
|
|
2971
|
-
|
|
2979
|
+
fn(e, t, n);
|
|
2972
2980
|
}
|
|
2973
2981
|
}
|
|
2974
|
-
},
|
|
2982
|
+
}, yn = (e) => {
|
|
2975
2983
|
let t = {
|
|
2976
2984
|
tokens: [],
|
|
2977
2985
|
layoutTargets: [],
|
|
2978
2986
|
nextId: 0
|
|
2979
2987
|
};
|
|
2980
|
-
return
|
|
2988
|
+
return V(e, t, "/math"), {
|
|
2981
2989
|
tokens: t.tokens,
|
|
2982
2990
|
layoutTargets: t.layoutTargets,
|
|
2983
|
-
expressionTarget:
|
|
2991
|
+
expressionTarget: R(e, "region-fallback")
|
|
2984
2992
|
};
|
|
2985
|
-
},
|
|
2993
|
+
}, bn = (e) => e.boundary && e.alignment.segments.find((t) => t.speechTokenIds.includes(e.boundary.token.id))?.target || null, xn = .95, Sn = (e) => {
|
|
2986
2994
|
let t = [], n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
2987
2995
|
let r = e.toLowerCase().trim().split(/\s+/).filter(Boolean);
|
|
2988
2996
|
if (r.length === 0) return;
|
|
@@ -2992,7 +3000,7 @@ var ct = class {
|
|
|
2992
3000
|
r(e.normalized);
|
|
2993
3001
|
for (let t of e.spokenAliases) r(t);
|
|
2994
3002
|
return t;
|
|
2995
|
-
},
|
|
3003
|
+
}, Cn = (e, t, n) => {
|
|
2996
3004
|
let r = 0;
|
|
2997
3005
|
for (let i of n) {
|
|
2998
3006
|
if (i.length <= r) continue;
|
|
@@ -3007,12 +3015,12 @@ var ct = class {
|
|
|
3007
3015
|
n && (r = i.length);
|
|
3008
3016
|
}
|
|
3009
3017
|
return r;
|
|
3010
|
-
},
|
|
3018
|
+
}, wn = (e, t) => {
|
|
3011
3019
|
let n = [], r = 0;
|
|
3012
3020
|
for (let i of t) {
|
|
3013
|
-
let t =
|
|
3021
|
+
let t = Sn(i);
|
|
3014
3022
|
if (i.optional) {
|
|
3015
|
-
let a =
|
|
3023
|
+
let a = Cn(e, r, t);
|
|
3016
3024
|
a > 0 && (n.push({
|
|
3017
3025
|
speechTokens: e.slice(r, r + a),
|
|
3018
3026
|
math: i
|
|
@@ -3020,7 +3028,7 @@ var ct = class {
|
|
|
3020
3028
|
continue;
|
|
3021
3029
|
}
|
|
3022
3030
|
for (; r < e.length;) {
|
|
3023
|
-
let a =
|
|
3031
|
+
let a = Cn(e, r, t);
|
|
3024
3032
|
if (a > 0) {
|
|
3025
3033
|
n.push({
|
|
3026
3034
|
speechTokens: e.slice(r, r + a),
|
|
@@ -3032,23 +3040,23 @@ var ct = class {
|
|
|
3032
3040
|
}
|
|
3033
3041
|
}
|
|
3034
3042
|
return n;
|
|
3035
|
-
},
|
|
3043
|
+
}, Tn = (e, t, n) => {
|
|
3036
3044
|
let r = n.filter((e) => !e.optional).length, i = e.filter((e) => !e.math.optional).length, a = e.reduce((e, t) => e + t.speechTokens.length, 0);
|
|
3037
3045
|
return r > 0 && i === r && a === t.length;
|
|
3038
|
-
},
|
|
3046
|
+
}, En = (e) => e.map(({ speechTokens: e, math: t }) => ({
|
|
3039
3047
|
speechTokenIds: e.map((e) => e.id),
|
|
3040
3048
|
mathTokenIds: [t.id],
|
|
3041
3049
|
score: 1,
|
|
3042
3050
|
confidence: 1,
|
|
3043
3051
|
target: t.target
|
|
3044
|
-
})),
|
|
3045
|
-
let t = e.minExactWordConfidence ??
|
|
3052
|
+
})), Dn = (e) => {
|
|
3053
|
+
let t = e.minExactWordConfidence ?? xn, n = wn(e.speech.tokens, e.math.tokens), r = +!!Tn(n, e.speech.tokens, e.math.tokens);
|
|
3046
3054
|
return {
|
|
3047
|
-
segments: r >= t ?
|
|
3055
|
+
segments: r >= t ? En(n) : [],
|
|
3048
3056
|
confidence: r,
|
|
3049
3057
|
fallbackTarget: e.math.expressionTarget
|
|
3050
3058
|
};
|
|
3051
|
-
},
|
|
3059
|
+
}, On = vt(), kn = /* @__PURE__ */ new Map([
|
|
3052
3060
|
["zero", "0"],
|
|
3053
3061
|
["one", "1"],
|
|
3054
3062
|
["two", "2"],
|
|
@@ -3060,17 +3068,17 @@ var ct = class {
|
|
|
3060
3068
|
["eight", "8"],
|
|
3061
3069
|
["nine", "9"],
|
|
3062
3070
|
["ten", "10"]
|
|
3063
|
-
]),
|
|
3071
|
+
]), An = (e) => {
|
|
3064
3072
|
let t = e.toLowerCase();
|
|
3065
|
-
return
|
|
3066
|
-
},
|
|
3073
|
+
return kn.get(t) || t;
|
|
3074
|
+
}, jn = (e) => {
|
|
3067
3075
|
let t = [];
|
|
3068
|
-
for (let n of e.matchAll(
|
|
3076
|
+
for (let n of e.matchAll(On)) {
|
|
3069
3077
|
let e = n[0], r = n.index ?? 0;
|
|
3070
3078
|
t.push({
|
|
3071
3079
|
id: `speech-token-${t.length}`,
|
|
3072
3080
|
text: e,
|
|
3073
|
-
normalized:
|
|
3081
|
+
normalized: An(e),
|
|
3074
3082
|
start: r,
|
|
3075
3083
|
end: r + e.length,
|
|
3076
3084
|
sourceStart: r,
|
|
@@ -3079,22 +3087,22 @@ var ct = class {
|
|
|
3079
3087
|
});
|
|
3080
3088
|
}
|
|
3081
3089
|
return t;
|
|
3082
|
-
},
|
|
3083
|
-
let t =
|
|
3090
|
+
}, H = (e) => {
|
|
3091
|
+
let t = Lt(e.speechText);
|
|
3084
3092
|
return {
|
|
3085
3093
|
speechText: e.speechText,
|
|
3086
3094
|
spokenText: t.spokenText,
|
|
3087
|
-
tokens:
|
|
3095
|
+
tokens: jn(t.spokenText),
|
|
3088
3096
|
rawToSpokenOffsetMap: t.rawToSpokenOffsetMap,
|
|
3089
3097
|
boundaryOffsetSpace: t.unsupportedSemantic ? "unsupported" : t.hasMarkup ? "raw-ssml" : "plain-spoken-text",
|
|
3090
3098
|
unsupportedSemantic: t.unsupportedSemantic,
|
|
3091
3099
|
hasMarkup: t.hasMarkup
|
|
3092
3100
|
};
|
|
3093
|
-
},
|
|
3101
|
+
}, Mn = (e) => {
|
|
3094
3102
|
if (!e || /^<[^>]+>$/.test(e.trim())) return null;
|
|
3095
|
-
let t = e.match(
|
|
3096
|
-
return t?.[0] ?
|
|
3097
|
-
},
|
|
3103
|
+
let t = e.match(On);
|
|
3104
|
+
return t?.[0] ? An(t[0]) : null;
|
|
3105
|
+
}, Nn = (e, t) => e.find((e) => e.start <= t && t < e.end) || null, Pn = (e, t) => {
|
|
3098
3106
|
let n = e.rawToSpokenOffsetMap.get(t);
|
|
3099
3107
|
if (n !== void 0) return n;
|
|
3100
3108
|
for (let n = t; n < e.speechText.length; n++) {
|
|
@@ -3103,103 +3111,103 @@ var ct = class {
|
|
|
3103
3111
|
if (e.speechText[n] === ">") break;
|
|
3104
3112
|
}
|
|
3105
3113
|
return null;
|
|
3106
|
-
},
|
|
3114
|
+
}, Fn = (e, t, n) => {
|
|
3107
3115
|
if (t === null) return null;
|
|
3108
|
-
let r =
|
|
3116
|
+
let r = Nn(e.tokens, t);
|
|
3109
3117
|
return r ? {
|
|
3110
3118
|
token: r,
|
|
3111
3119
|
start: t,
|
|
3112
3120
|
length: Math.max(1, Math.min(n, r.end - t)),
|
|
3113
3121
|
confidence: .75
|
|
3114
3122
|
} : null;
|
|
3115
|
-
},
|
|
3116
|
-
let n =
|
|
3123
|
+
}, In = (e, t) => {
|
|
3124
|
+
let n = Mn(t);
|
|
3117
3125
|
return !!(e && n && e.token.normalized === n);
|
|
3118
|
-
},
|
|
3126
|
+
}, Ln = (e) => {
|
|
3119
3127
|
if (e.tokenization.boundaryOffsetSpace === "unsupported" || !Number.isFinite(e.position) || e.boundaryWord && /^<[^>]+>$/.test(e.boundaryWord.trim())) return null;
|
|
3120
|
-
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n =
|
|
3121
|
-
return
|
|
3128
|
+
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n = Fn(e.tokenization, Pn(e.tokenization, e.position), t), r = Fn(e.tokenization, e.position >= 0 && e.position < e.tokenization.spokenText.length ? e.position : null, t);
|
|
3129
|
+
return In(n, e.boundaryWord) ? {
|
|
3122
3130
|
...n,
|
|
3123
3131
|
confidence: 1
|
|
3124
|
-
} :
|
|
3132
|
+
} : In(r, e.boundaryWord) ? {
|
|
3125
3133
|
...r,
|
|
3126
3134
|
confidence: 1
|
|
3127
|
-
} : e.boundaryWord &&
|
|
3128
|
-
},
|
|
3135
|
+
} : e.boundaryWord && Mn(e.boundaryWord) ? null : e.tokenization.boundaryOffsetSpace === "raw-ssml" ? n || r : r || n;
|
|
3136
|
+
}, Rn = (e) => {
|
|
3129
3137
|
if (e.tokenization.boundaryOffsetSpace === "unsupported" || !Number.isFinite(e.position) || e.boundaryWord && /^<[^>]+>$/.test(e.boundaryWord.trim())) return null;
|
|
3130
|
-
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n =
|
|
3131
|
-
return
|
|
3138
|
+
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n = Fn(e.tokenization, e.position >= 0 && e.position < e.tokenization.spokenText.length ? e.position : null, t);
|
|
3139
|
+
return In(n, e.boundaryWord) ? {
|
|
3132
3140
|
...n,
|
|
3133
3141
|
confidence: 1
|
|
3134
|
-
} : e.boundaryWord &&
|
|
3135
|
-
},
|
|
3136
|
-
let t =
|
|
3142
|
+
} : e.boundaryWord && Mn(e.boundaryWord) ? null : n;
|
|
3143
|
+
}, U = (e) => {
|
|
3144
|
+
let t = H({ speechText: e.speechText }), n = yn(e.mathElement);
|
|
3137
3145
|
return {
|
|
3138
3146
|
speech: t,
|
|
3139
3147
|
math: n,
|
|
3140
|
-
result:
|
|
3148
|
+
result: Dn({
|
|
3141
3149
|
speech: t,
|
|
3142
3150
|
math: n
|
|
3143
3151
|
})
|
|
3144
3152
|
};
|
|
3145
|
-
},
|
|
3146
|
-
let n =
|
|
3153
|
+
}, zn = (e, t) => {
|
|
3154
|
+
let n = Rn({
|
|
3147
3155
|
tokenization: e.speech,
|
|
3148
3156
|
position: t.position,
|
|
3149
3157
|
length: t.length,
|
|
3150
3158
|
boundaryWord: t.boundaryWord
|
|
3151
3159
|
});
|
|
3152
|
-
return
|
|
3160
|
+
return bn({
|
|
3153
3161
|
alignment: e.result,
|
|
3154
3162
|
boundary: n
|
|
3155
3163
|
});
|
|
3156
|
-
},
|
|
3164
|
+
}, Bn = (e, t) => {
|
|
3157
3165
|
if (!t.boundaryWord || /^<[^>]+>$/.test(t.boundaryWord.trim())) return null;
|
|
3158
|
-
let n =
|
|
3166
|
+
let n = H({ speechText: t.boundaryWord }).tokens[0];
|
|
3159
3167
|
if (!n) return null;
|
|
3160
3168
|
let r = e.math.tokens.filter((e) => {
|
|
3161
3169
|
let t = n.normalized.toLowerCase();
|
|
3162
3170
|
return e.normalized.toLowerCase() === t || e.spokenAliases.some((e) => e.toLowerCase() === t);
|
|
3163
3171
|
});
|
|
3164
3172
|
return r.length === 1 ? r[0].target : null;
|
|
3165
|
-
},
|
|
3173
|
+
}, Vn = "http://www.w3.org/1998/Math/MathML", Hn = /* @__PURE__ */ new Set(/* @__PURE__ */ "math.maction.menclose.merror.mfenced.mfrac.mi.mmultiscripts.mn.mo.mover.mpadded.mphantom.mprescripts.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msubsup.msup.mtable.mtd.mtext.mtr.munder.munderover.none.semantics.annotation.annotation-xml".split(".")), Un = /* @__PURE__ */ new Set(/* @__PURE__ */ "accent.accentunder.align.bevelled.class.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.encoding.fence.height.href.id.largeop.length.linethickness.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.width.xmlns.xml:lang".split(".")), Wn = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), Gn = (e) => Wn(e).replace(/"/g, """), Kn = (e, t) => {
|
|
3166
3174
|
let n = e.toLowerCase(), r = t.trim().toLowerCase();
|
|
3167
|
-
return !!(n.startsWith("on") || !
|
|
3168
|
-
},
|
|
3175
|
+
return !!(n.startsWith("on") || !Un.has(n) || r.includes("javascript:") || r.includes("data:text/html"));
|
|
3176
|
+
}, qn = (e) => {
|
|
3169
3177
|
let t = e.localName.toLowerCase();
|
|
3170
|
-
if (!
|
|
3178
|
+
if (!Hn.has(t)) return !1;
|
|
3171
3179
|
let n = e.namespaceURI;
|
|
3172
|
-
return !n || n ===
|
|
3173
|
-
},
|
|
3174
|
-
if (e.nodeType === Node.TEXT_NODE) return
|
|
3180
|
+
return !n || n === Vn || n === "http://www.w3.org/1999/xhtml";
|
|
3181
|
+
}, Jn = (e) => {
|
|
3182
|
+
if (e.nodeType === Node.TEXT_NODE) return Wn(e.textContent || "");
|
|
3175
3183
|
if (e.nodeType === Node.COMMENT_NODE) return "";
|
|
3176
3184
|
if (e.nodeType !== Node.ELEMENT_NODE) return null;
|
|
3177
3185
|
let t = e;
|
|
3178
|
-
if (!
|
|
3186
|
+
if (!qn(t)) return null;
|
|
3179
3187
|
let n = t.localName.toLowerCase(), r = [];
|
|
3180
3188
|
for (let e of Array.from(t.attributes)) {
|
|
3181
3189
|
let t = e.name.toLowerCase();
|
|
3182
|
-
if (!
|
|
3183
|
-
if (t === "xmlns" && e.value !==
|
|
3184
|
-
r.push(`${t}="${
|
|
3190
|
+
if (!Kn(t, e.value)) {
|
|
3191
|
+
if (t === "xmlns" && e.value !== Vn) return null;
|
|
3192
|
+
r.push(`${t}="${Gn(e.value)}"`);
|
|
3185
3193
|
}
|
|
3186
3194
|
}
|
|
3187
|
-
n === "math" && !r.some((e) => e.startsWith("xmlns=")) && r.unshift(`xmlns="${
|
|
3195
|
+
n === "math" && !r.some((e) => e.startsWith("xmlns=")) && r.unshift(`xmlns="${Vn}"`);
|
|
3188
3196
|
let i = [];
|
|
3189
3197
|
for (let e of Array.from(t.childNodes)) {
|
|
3190
|
-
let t =
|
|
3198
|
+
let t = Jn(e);
|
|
3191
3199
|
if (t === null) return null;
|
|
3192
3200
|
i.push(t);
|
|
3193
3201
|
}
|
|
3194
3202
|
return `<${n}${r.length > 0 ? ` ${r.join(" ")}` : ""}>${i.join("")}</${n}>`;
|
|
3195
|
-
},
|
|
3203
|
+
}, Yn = (e) => typeof DOMParser < "u" ? new DOMParser().parseFromString(e, "application/xml") : null, Xn = (e) => {
|
|
3196
3204
|
let t = String(e || "").trim();
|
|
3197
3205
|
if (!t) return null;
|
|
3198
|
-
let n =
|
|
3206
|
+
let n = Yn(t);
|
|
3199
3207
|
if (!n || n.getElementsByTagName("parsererror").length > 0) return null;
|
|
3200
3208
|
let r = n.documentElement;
|
|
3201
|
-
return !r || r.localName.toLowerCase() !== "math" ? null :
|
|
3202
|
-
},
|
|
3209
|
+
return !r || r.localName.toLowerCase() !== "math" ? null : Jn(r);
|
|
3210
|
+
}, Zn = (e) => ({
|
|
3203
3211
|
chars: [],
|
|
3204
3212
|
map: /* @__PURE__ */ new Map(),
|
|
3205
3213
|
position: 0,
|
|
@@ -3207,28 +3215,28 @@ var ct = class {
|
|
|
3207
3215
|
lastCharWasWhitespace: !1,
|
|
3208
3216
|
lastMapped: null,
|
|
3209
3217
|
options: e
|
|
3210
|
-
}),
|
|
3218
|
+
}), Qn = (e) => e.classList?.contains("MathJax") || e.tagName?.toLowerCase() === "mjx-container", $n = (e) => e.tagName?.toLowerCase() === "mjx-assistive-mml", er = (e) => {
|
|
3211
3219
|
let t = e.tagName?.toLowerCase();
|
|
3212
3220
|
return t === "annotation" || t === "annotation-xml";
|
|
3213
|
-
},
|
|
3221
|
+
}, tr = (e) => {
|
|
3214
3222
|
let t = e.getAttribute("data-mathml");
|
|
3215
3223
|
return t && t.trim() ? t : null;
|
|
3216
|
-
},
|
|
3217
|
-
if (e.tagName.toLowerCase() === "math") return
|
|
3218
|
-
let t =
|
|
3224
|
+
}, nr = (e) => e.querySelector("mjx-assistive-mml math")?.outerHTML || null, rr = (e) => {
|
|
3225
|
+
if (e.tagName.toLowerCase() === "math") return Xn(e.outerHTML);
|
|
3226
|
+
let t = tr(e);
|
|
3219
3227
|
if (t) {
|
|
3220
|
-
let e =
|
|
3228
|
+
let e = Xn(t);
|
|
3221
3229
|
if (e) return e;
|
|
3222
3230
|
}
|
|
3223
|
-
if (
|
|
3224
|
-
let t =
|
|
3231
|
+
if (Qn(e)) {
|
|
3232
|
+
let t = nr(e);
|
|
3225
3233
|
if (t) {
|
|
3226
|
-
let e =
|
|
3234
|
+
let e = Xn(t);
|
|
3227
3235
|
if (e) return e;
|
|
3228
3236
|
}
|
|
3229
3237
|
}
|
|
3230
3238
|
return null;
|
|
3231
|
-
},
|
|
3239
|
+
}, ir = /* @__PURE__ */ new Set([
|
|
3232
3240
|
"P",
|
|
3233
3241
|
"H1",
|
|
3234
3242
|
"H2",
|
|
@@ -3244,7 +3252,7 @@ var ct = class {
|
|
|
3244
3252
|
"FIGCAPTION",
|
|
3245
3253
|
"LABEL",
|
|
3246
3254
|
"BUTTON"
|
|
3247
|
-
]),
|
|
3255
|
+
]), ar = /* @__PURE__ */ new Set([
|
|
3248
3256
|
"heading",
|
|
3249
3257
|
"listitem",
|
|
3250
3258
|
"option",
|
|
@@ -3253,50 +3261,50 @@ var ct = class {
|
|
|
3253
3261
|
"cell",
|
|
3254
3262
|
"columnheader",
|
|
3255
3263
|
"rowheader"
|
|
3256
|
-
]),
|
|
3264
|
+
]), or = (e, t) => {
|
|
3257
3265
|
let n = e.parentElement, r = null;
|
|
3258
3266
|
for (; n && n !== t;) {
|
|
3259
3267
|
let e = (n.getAttribute("role") || "").toLowerCase(), t = n.tagName.toUpperCase();
|
|
3260
|
-
if (
|
|
3268
|
+
if (ir.has(t) || ar.has(e)) {
|
|
3261
3269
|
r = n;
|
|
3262
3270
|
break;
|
|
3263
3271
|
}
|
|
3264
3272
|
n = n.parentElement;
|
|
3265
3273
|
}
|
|
3266
3274
|
return r || t;
|
|
3267
|
-
},
|
|
3275
|
+
}, sr = (e) => !!(typeof e.querySelector == "function" && e.querySelector("math, [data-mathml], .MathJax, mjx-container, mjx-assistive-mml")) || e.tagName?.toLowerCase() === "math" || e.hasAttribute?.("data-mathml") || Qn(e), W = (e, t, n) => {
|
|
3268
3276
|
/[.,;:!?]/.test(t) && e.chars.length > 0 && e.chars[e.chars.length - 1] === " " && (e.chars.pop(), e.position--, e.map.delete(e.position)), e.chars.push(t), n ? (e.map.set(e.position, n), e.lastMapped = n) : e.lastMapped && e.map.set(e.position, e.lastMapped), e.position++;
|
|
3269
|
-
},
|
|
3277
|
+
}, cr = (e, t) => {
|
|
3270
3278
|
if (e.inLeadingWhitespace || e.lastCharWasWhitespace || e.chars.length === 0) return !1;
|
|
3271
3279
|
let n = e.chars[e.chars.length - 1];
|
|
3272
|
-
return
|
|
3273
|
-
},
|
|
3280
|
+
return Ot(n, t, e.options);
|
|
3281
|
+
}, lr = (e, t) => {
|
|
3274
3282
|
let n = t.textContent || "", r = !1;
|
|
3275
3283
|
for (let i = 0; i < n.length; i++) {
|
|
3276
3284
|
let a = n[i], o = /\s/.test(a);
|
|
3277
3285
|
if (e.inLeadingWhitespace) {
|
|
3278
|
-
o || (e.inLeadingWhitespace = !1,
|
|
3286
|
+
o || (e.inLeadingWhitespace = !1, W(e, a, {
|
|
3279
3287
|
node: t,
|
|
3280
3288
|
offset: i
|
|
3281
3289
|
}), r = !0, e.lastCharWasWhitespace = !1);
|
|
3282
3290
|
continue;
|
|
3283
3291
|
}
|
|
3284
3292
|
if (o) {
|
|
3285
|
-
e.lastCharWasWhitespace ||
|
|
3293
|
+
e.lastCharWasWhitespace || W(e, " ", {
|
|
3286
3294
|
node: t,
|
|
3287
3295
|
offset: i
|
|
3288
3296
|
}), e.lastCharWasWhitespace = !0;
|
|
3289
3297
|
continue;
|
|
3290
3298
|
}
|
|
3291
|
-
!r &&
|
|
3299
|
+
!r && cr(e, a) && W(e, " ", {
|
|
3292
3300
|
node: t,
|
|
3293
3301
|
offset: i
|
|
3294
|
-
}),
|
|
3302
|
+
}), W(e, a, {
|
|
3295
3303
|
node: t,
|
|
3296
3304
|
offset: i
|
|
3297
3305
|
}), r = !0, e.lastCharWasWhitespace = !1;
|
|
3298
3306
|
}
|
|
3299
|
-
},
|
|
3307
|
+
}, ur = (e, t) => {
|
|
3300
3308
|
for (let n = 0; n < t.text.length; n++) {
|
|
3301
3309
|
let r = t.text[n], i = /\s/.test(r), a = t.map.get(n) || null, o = a?.node || e.lastMapped?.node || null, s = a?.offset ?? e.lastMapped?.offset ?? 0, c = a ? {
|
|
3302
3310
|
node: a.node,
|
|
@@ -3310,10 +3318,10 @@ var ct = class {
|
|
|
3310
3318
|
e.inLeadingWhitespace = !1;
|
|
3311
3319
|
}
|
|
3312
3320
|
if (i) {
|
|
3313
|
-
e.lastCharWasWhitespace ||
|
|
3321
|
+
e.lastCharWasWhitespace || W(e, " ", c), e.lastCharWasWhitespace = !0;
|
|
3314
3322
|
continue;
|
|
3315
3323
|
}
|
|
3316
|
-
n === 0 &&
|
|
3324
|
+
n === 0 && cr(e, r) && W(e, " ", c), W(e, r, c), e.lastCharWasWhitespace = !1, a ? (e.map.set(e.position - 1, {
|
|
3317
3325
|
node: a.node,
|
|
3318
3326
|
offset: a.offset
|
|
3319
3327
|
}), e.lastMapped = {
|
|
@@ -3324,7 +3332,7 @@ var ct = class {
|
|
|
3324
3332
|
offset: s
|
|
3325
3333
|
});
|
|
3326
3334
|
}
|
|
3327
|
-
},
|
|
3335
|
+
}, dr = (e) => {
|
|
3328
3336
|
if (typeof DOMParser > "u") return "";
|
|
3329
3337
|
let t = new DOMParser().parseFromString(e, "application/xml");
|
|
3330
3338
|
if (t.getElementsByTagName("parsererror").length > 0) return "";
|
|
@@ -3336,57 +3344,57 @@ var ct = class {
|
|
|
3336
3344
|
}
|
|
3337
3345
|
if (e.nodeType !== 1) return;
|
|
3338
3346
|
let t = e;
|
|
3339
|
-
if (!
|
|
3347
|
+
if (!er(t)) for (let e of Array.from(t.childNodes)) r(e);
|
|
3340
3348
|
};
|
|
3341
|
-
return r(t.documentElement),
|
|
3342
|
-
},
|
|
3343
|
-
let r =
|
|
3344
|
-
if (
|
|
3349
|
+
return r(t.documentElement), M(n.join(" "));
|
|
3350
|
+
}, fr = (e, t, n) => {
|
|
3351
|
+
let r = Zn(n), i = (t) => {
|
|
3352
|
+
if (N(t, e)) return;
|
|
3345
3353
|
if (t.nodeType === 3) {
|
|
3346
|
-
|
|
3354
|
+
lr(r, t);
|
|
3347
3355
|
return;
|
|
3348
3356
|
}
|
|
3349
3357
|
if (t.nodeType !== 1) return;
|
|
3350
3358
|
let n = t;
|
|
3351
|
-
if (!(
|
|
3359
|
+
if (!($n(n) || er(n))) for (let e of Array.from(n.childNodes)) i(e);
|
|
3352
3360
|
};
|
|
3353
|
-
i(e),
|
|
3354
|
-
let a =
|
|
3361
|
+
i(e), pr(r);
|
|
3362
|
+
let a = M(r.chars.join(""));
|
|
3355
3363
|
if (a) return {
|
|
3356
3364
|
text: a,
|
|
3357
3365
|
map: r.map
|
|
3358
3366
|
};
|
|
3359
|
-
let o =
|
|
3367
|
+
let o = dr(t);
|
|
3360
3368
|
return o ? {
|
|
3361
3369
|
text: o,
|
|
3362
3370
|
map: /* @__PURE__ */ new Map()
|
|
3363
|
-
} :
|
|
3364
|
-
},
|
|
3371
|
+
} : P(e, n);
|
|
3372
|
+
}, pr = (e) => {
|
|
3365
3373
|
for (; e.chars.length > 0 && /\s/.test(e.chars[e.chars.length - 1]);) e.chars.pop(), e.position--, e.map.delete(e.position);
|
|
3366
|
-
},
|
|
3367
|
-
let n =
|
|
3368
|
-
let e =
|
|
3374
|
+
}, mr = (e, t) => {
|
|
3375
|
+
let n = Zn(t), r = [], i = 0, a, o = !1, s = () => {
|
|
3376
|
+
let e = M(n.chars.slice(i, n.chars.length).join(""));
|
|
3369
3377
|
e && r.push({
|
|
3370
3378
|
type: "text",
|
|
3371
3379
|
text: e,
|
|
3372
3380
|
sourceElement: a
|
|
3373
3381
|
}), i = n.chars.length, a = void 0;
|
|
3374
3382
|
}, c = (l) => {
|
|
3375
|
-
if (
|
|
3383
|
+
if (N(l, e)) return;
|
|
3376
3384
|
if (l.nodeType === Node.TEXT_NODE) {
|
|
3377
|
-
let t =
|
|
3378
|
-
a && t !== a && s(), a = t,
|
|
3385
|
+
let t = or(l, e);
|
|
3386
|
+
a && t !== a && s(), a = t, lr(n, l);
|
|
3379
3387
|
return;
|
|
3380
3388
|
}
|
|
3381
3389
|
if (l.nodeType !== Node.ELEMENT_NODE) return;
|
|
3382
3390
|
let u = l;
|
|
3383
|
-
if (
|
|
3384
|
-
let d =
|
|
3391
|
+
if ($n(u)) return;
|
|
3392
|
+
let d = rr(u);
|
|
3385
3393
|
if (d) {
|
|
3386
3394
|
s();
|
|
3387
|
-
let e =
|
|
3388
|
-
|
|
3389
|
-
let a =
|
|
3395
|
+
let e = fr(u, d, t);
|
|
3396
|
+
ur(n, e);
|
|
3397
|
+
let a = M(e.text);
|
|
3390
3398
|
r.push({
|
|
3391
3399
|
type: "math",
|
|
3392
3400
|
mathml: d,
|
|
@@ -3398,7 +3406,7 @@ var ct = class {
|
|
|
3398
3406
|
for (let e of Array.from(u.childNodes)) c(e);
|
|
3399
3407
|
};
|
|
3400
3408
|
for (let t of Array.from(e.childNodes)) c(t);
|
|
3401
|
-
|
|
3409
|
+
pr(n), s();
|
|
3402
3410
|
let l = n.chars.join("");
|
|
3403
3411
|
for (; n.map.has(l.length);) n.map.delete(l.length);
|
|
3404
3412
|
return {
|
|
@@ -3407,9 +3415,9 @@ var ct = class {
|
|
|
3407
3415
|
chunks: r,
|
|
3408
3416
|
containsMathMarkup: o
|
|
3409
3417
|
};
|
|
3410
|
-
},
|
|
3411
|
-
if (!
|
|
3412
|
-
let { text: n, map: r } =
|
|
3418
|
+
}, G = (e, t) => {
|
|
3419
|
+
if (!sr(e)) {
|
|
3420
|
+
let { text: n, map: r } = P(e, t);
|
|
3413
3421
|
return {
|
|
3414
3422
|
visibleText: n,
|
|
3415
3423
|
map: r,
|
|
@@ -3420,46 +3428,46 @@ var ct = class {
|
|
|
3420
3428
|
containsMathMarkup: !1
|
|
3421
3429
|
};
|
|
3422
3430
|
}
|
|
3423
|
-
return
|
|
3424
|
-
},
|
|
3431
|
+
return mr(e, t);
|
|
3432
|
+
}, hr = null, gr = Promise.resolve(), _r = (e) => (e || "en").split("-")[0].toLowerCase() || "en", vr = async () => (hr ||= import("./sre-BD1SyGce.js").then((t) => /* @__PURE__ */ e(t.default, 1)).then((e) => {
|
|
3425
3433
|
let t = e.default || e;
|
|
3426
3434
|
if (!t || typeof t.toSpeech != "function") throw Error("speech-rule-engine did not expose toSpeech");
|
|
3427
3435
|
return t;
|
|
3428
|
-
}),
|
|
3429
|
-
if (!
|
|
3430
|
-
let t =
|
|
3436
|
+
}), hr), yr = (e) => e === "en" ? "clearspeak" : "mathspeak", br = (e) => !!e && typeof e == "object" && !Array.isArray(e), xr = (e) => typeof e == "string" && e.trim() ? e.trim() : void 0, K = (e) => {
|
|
3437
|
+
if (!br(e)) return;
|
|
3438
|
+
let t = xr(e.domain), n = xr(e.style), r = br(e.engineOptions) ? e.engineOptions : void 0;
|
|
3431
3439
|
if (!(!t && !n && !r)) return {
|
|
3432
3440
|
...t ? { domain: t } : {},
|
|
3433
3441
|
...n ? { style: n } : {},
|
|
3434
3442
|
...r ? { engineOptions: r } : {}
|
|
3435
3443
|
};
|
|
3436
|
-
},
|
|
3437
|
-
let i =
|
|
3444
|
+
}, Sr = async (e, t, n, r) => {
|
|
3445
|
+
let i = _r(t), a = K(r);
|
|
3438
3446
|
await e.setupEngine?.({
|
|
3439
3447
|
...a?.engineOptions || {},
|
|
3440
3448
|
locale: i,
|
|
3441
|
-
domain: a?.domain ||
|
|
3449
|
+
domain: a?.domain || yr(i),
|
|
3442
3450
|
...a?.style ? { style: a.style } : {},
|
|
3443
3451
|
modality: "speech",
|
|
3444
3452
|
markup: n
|
|
3445
3453
|
}), await e.engineReady?.();
|
|
3446
|
-
},
|
|
3447
|
-
let t =
|
|
3448
|
-
return
|
|
3449
|
-
},
|
|
3454
|
+
}, Cr = async (e) => {
|
|
3455
|
+
let t = gr.then(e, e);
|
|
3456
|
+
return gr = t.then(() => void 0, () => void 0), t;
|
|
3457
|
+
}, wr = async (e, t, n, r, i) => Cr(async () => (await Sr(e, n, r, i), e.toSpeech(t))), Tr = (e) => e.replace(/^\s*<\?xml[^>]*\?>\s*/i, ""), Er = async (e, t, n, r) => {
|
|
3450
3458
|
try {
|
|
3451
|
-
let i =
|
|
3459
|
+
let i = Tr(await wr(e, t, n, "ssml", r));
|
|
3452
3460
|
return i.includes("<speak") ? i : null;
|
|
3453
3461
|
} catch (e) {
|
|
3454
3462
|
return console.debug("[TTSService] Math SSML generation failed; using plain", { message: e instanceof Error ? e.message : String(e) }), null;
|
|
3455
3463
|
}
|
|
3456
|
-
},
|
|
3464
|
+
}, Dr = async (e, t = {}) => {
|
|
3457
3465
|
if (!e.some((e) => e.type === "math")) return {
|
|
3458
|
-
speechText:
|
|
3466
|
+
speechText: M(e.map((e) => e.type === "text" ? e.text : e.fallbackText).join(" ")),
|
|
3459
3467
|
usedMathSpeech: !1,
|
|
3460
3468
|
usedFallback: !1
|
|
3461
3469
|
};
|
|
3462
|
-
let n = null, r = !1, i = !1, a = t.loadSre ||
|
|
3470
|
+
let n = null, r = !1, i = !1, a = t.loadSre || vr, o = [];
|
|
3463
3471
|
for (let s of e) {
|
|
3464
3472
|
if (s.type === "text") {
|
|
3465
3473
|
o.push(s.text);
|
|
@@ -3467,7 +3475,7 @@ var ct = class {
|
|
|
3467
3475
|
}
|
|
3468
3476
|
try {
|
|
3469
3477
|
n ||= await a();
|
|
3470
|
-
let e =
|
|
3478
|
+
let e = M(await wr(n, s.mathml, t.language, "none", t.mathSpeech));
|
|
3471
3479
|
if (e) {
|
|
3472
3480
|
o.push(e), r = !0;
|
|
3473
3481
|
continue;
|
|
@@ -3477,14 +3485,14 @@ var ct = class {
|
|
|
3477
3485
|
i = !0, console.debug("[TTSService] Math speech generation failed; using visible fallback", { message: e instanceof Error ? e.message : String(e) }), o.push(s.fallbackText);
|
|
3478
3486
|
}
|
|
3479
3487
|
}
|
|
3480
|
-
let s =
|
|
3481
|
-
return t.produceSsml && n && r && e.length === 1 && e[0].type === "math" && (c = await
|
|
3488
|
+
let s = M(o.join(" ")), c;
|
|
3489
|
+
return t.produceSsml && n && r && e.length === 1 && e[0].type === "math" && (c = await Er(n, e[0].mathml, t.language, t.mathSpeech) ?? void 0), {
|
|
3482
3490
|
speechText: s,
|
|
3483
3491
|
usedMathSpeech: r,
|
|
3484
3492
|
usedFallback: i,
|
|
3485
3493
|
ssml: c
|
|
3486
3494
|
};
|
|
3487
|
-
},
|
|
3495
|
+
}, Or = (e, t) => Dr([e], t), kr = (e) => (e || "en").split("-")[0].toLowerCase() || "en", Ar = /* @__PURE__ */ new Set([
|
|
3488
3496
|
"H1",
|
|
3489
3497
|
"H2",
|
|
3490
3498
|
"H3",
|
|
@@ -3494,18 +3502,18 @@ var ct = class {
|
|
|
3494
3502
|
"LI",
|
|
3495
3503
|
"LABEL",
|
|
3496
3504
|
"BUTTON"
|
|
3497
|
-
]),
|
|
3505
|
+
]), jr = /* @__PURE__ */ new Set([
|
|
3498
3506
|
"heading",
|
|
3499
3507
|
"listitem",
|
|
3500
3508
|
"option",
|
|
3501
3509
|
"radio"
|
|
3502
|
-
]),
|
|
3510
|
+
]), Mr = (e) => {
|
|
3503
3511
|
if (e.type !== "text" || !e.sourceElement) return !1;
|
|
3504
3512
|
let t = e.sourceElement.tagName.toUpperCase(), n = (e.sourceElement.getAttribute("role") || "").toLowerCase();
|
|
3505
|
-
return
|
|
3506
|
-
},
|
|
3507
|
-
let t = e.resolveMathSpeech ??
|
|
3508
|
-
let t =
|
|
3513
|
+
return Ar.has(t) || jr.has(n);
|
|
3514
|
+
}, Nr = async (e) => {
|
|
3515
|
+
let t = e.resolveMathSpeech ?? Or, { visibleText: n } = e, r = [], i = 0, a = (e) => {
|
|
3516
|
+
let t = M(e), r = n.indexOf(t, i), a = r >= 0 ? r : i, o = a + t.length;
|
|
3509
3517
|
return i = o, {
|
|
3510
3518
|
start: a,
|
|
3511
3519
|
end: o
|
|
@@ -3514,12 +3522,12 @@ var ct = class {
|
|
|
3514
3522
|
for (let n = 0; n < e.chunks.length; n++) {
|
|
3515
3523
|
let i = e.chunks[n];
|
|
3516
3524
|
if (i.type === "text") {
|
|
3517
|
-
let t =
|
|
3525
|
+
let t = Mr(i) ? [{
|
|
3518
3526
|
text: i.text,
|
|
3519
3527
|
offset: 0
|
|
3520
|
-
}] :
|
|
3528
|
+
}] : A(i.text, { locale: e.language });
|
|
3521
3529
|
for (let e of t) {
|
|
3522
|
-
let t =
|
|
3530
|
+
let t = M(e.text);
|
|
3523
3531
|
if (!t) continue;
|
|
3524
3532
|
let i = a(t);
|
|
3525
3533
|
r.push({
|
|
@@ -3554,37 +3562,37 @@ var ct = class {
|
|
|
3554
3562
|
}
|
|
3555
3563
|
return {
|
|
3556
3564
|
segments: r,
|
|
3557
|
-
locale:
|
|
3565
|
+
locale: kr(e.language),
|
|
3558
3566
|
visibleText: n,
|
|
3559
|
-
plainSpeechText:
|
|
3567
|
+
plainSpeechText: M(o.join(" "))
|
|
3560
3568
|
};
|
|
3561
|
-
},
|
|
3562
|
-
let t = Math.max(1, e.maxEntries ??
|
|
3569
|
+
}, Pr = (e) => (e || "en").split("-")[0].toLowerCase() || "en", Fr = "sre-v1", Ir = 256, Lr = (e) => Array.isArray(e) ? `array:[${e.map(Lr).join(",")}]` : e && typeof e == "object" ? `object:{${Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${JSON.stringify(e)}:${Lr(t)}`).join(",")}}` : e === null ? "null:null" : e === void 0 ? "undefined:" : typeof e == "function" ? `function:${e.name || "anonymous"}` : typeof e == "symbol" ? `symbol:${String(e)}` : typeof e == "bigint" ? `bigint:${e.toString()}` : typeof e == "number" ? Number.isFinite(e) ? `number:${e}` : `number:${String(e)}` : `${typeof e}:${JSON.stringify(e)}`, Rr = (e, t, n, r) => `${Fr}\u0000${Pr(e)}\u0000${t ? "ssml" : "plain"}\u0000${Lr(n ?? null)}\u0000${r}`, zr = (e = {}) => {
|
|
3570
|
+
let t = Math.max(1, e.maxEntries ?? Ir), n = e.resolve ?? ((e, t) => Dr([e], t)), r = /* @__PURE__ */ new Map(), i = (e, n) => {
|
|
3563
3571
|
for (r.delete(e), r.set(e, n); r.size > t;) {
|
|
3564
3572
|
let e = r.keys().next().value;
|
|
3565
3573
|
e !== void 0 && r.delete(e);
|
|
3566
3574
|
}
|
|
3567
3575
|
};
|
|
3568
3576
|
return async (e, a) => {
|
|
3569
|
-
let o =
|
|
3577
|
+
let o = K(a.mathSpeech), s = a.produceSsml === !0, c = Rr(a.language, s, o, e.mathml), l = r.get(c);
|
|
3570
3578
|
if (l) return r.delete(c), r.set(c, l), l;
|
|
3571
3579
|
let u = await n(e, {
|
|
3572
3580
|
...a,
|
|
3573
3581
|
mathSpeech: o
|
|
3574
3582
|
});
|
|
3575
|
-
return s && u.ssml && t > 1 && i(
|
|
3583
|
+
return s && u.ssml && t > 1 && i(Rr(a.language, !1, o, e.mathml), {
|
|
3576
3584
|
speechText: u.speechText,
|
|
3577
3585
|
usedMathSpeech: u.usedMathSpeech,
|
|
3578
3586
|
usedFallback: u.usedFallback
|
|
3579
3587
|
}), i(c, u), u;
|
|
3580
3588
|
};
|
|
3581
|
-
},
|
|
3582
|
-
let n =
|
|
3589
|
+
}, Br = (e) => !e || /^<[^>]+>$/.test(e.trim()) ? null : H({ speechText: e }).tokens[0]?.normalized || null, Vr = (e, t) => {
|
|
3590
|
+
let n = H({ speechText: e.speechText });
|
|
3583
3591
|
if (!Number.isFinite(t.position)) return {
|
|
3584
3592
|
boundary: null,
|
|
3585
3593
|
spokenText: n.spokenText
|
|
3586
3594
|
};
|
|
3587
|
-
let r =
|
|
3595
|
+
let r = Ln({
|
|
3588
3596
|
tokenization: n,
|
|
3589
3597
|
position: t.position,
|
|
3590
3598
|
length: t.length,
|
|
@@ -3597,8 +3605,8 @@ var ct = class {
|
|
|
3597
3605
|
} : null,
|
|
3598
3606
|
spokenText: n.spokenText
|
|
3599
3607
|
};
|
|
3600
|
-
},
|
|
3601
|
-
let n =
|
|
3608
|
+
}, Hr = (e, t, n) => !n || H({ speechText: e }).tokens.find((e) => e.start <= t && t < e.end)?.normalized === n, Ur = (e, t) => {
|
|
3609
|
+
let n = Br(t.word);
|
|
3602
3610
|
if (e.id !== t.chunkId) return {
|
|
3603
3611
|
chunkId: t.chunkId,
|
|
3604
3612
|
normalizedWord: n,
|
|
@@ -3616,12 +3624,12 @@ var ct = class {
|
|
|
3616
3624
|
reason: "boundary offset space is unsupported"
|
|
3617
3625
|
};
|
|
3618
3626
|
let r, i;
|
|
3619
|
-
if (e.catalogAlignment) r =
|
|
3627
|
+
if (e.catalogAlignment) r = $t(e.catalogAlignment, t.position, t.length, t.word), i = e.catalogAlignment.spokenText;
|
|
3620
3628
|
else {
|
|
3621
|
-
let n =
|
|
3629
|
+
let n = Vr(e, t);
|
|
3622
3630
|
r = n.boundary, i = n.spokenText;
|
|
3623
3631
|
}
|
|
3624
|
-
return r ?
|
|
3632
|
+
return r ? Hr(i, r.start, n) ? {
|
|
3625
3633
|
chunkId: e.id,
|
|
3626
3634
|
normalizedWord: n,
|
|
3627
3635
|
chunkSpokenStart: r.start,
|
|
@@ -3643,7 +3651,7 @@ var ct = class {
|
|
|
3643
3651
|
confidence: 0,
|
|
3644
3652
|
reason: "could not resolve provider boundary to chunk speech"
|
|
3645
3653
|
};
|
|
3646
|
-
},
|
|
3654
|
+
}, q = (e) => e.semanticTarget ? {
|
|
3647
3655
|
activeTarget: e.semanticTarget,
|
|
3648
3656
|
regionTarget: e.regionTarget,
|
|
3649
3657
|
quality: e.semanticTarget.quality === "exact-word" ? "exact-word" : e.semanticTarget.quality === "expression" ? "expression" : "semantic-token",
|
|
@@ -3661,12 +3669,12 @@ var ct = class {
|
|
|
3661
3669
|
quality: "region",
|
|
3662
3670
|
confidence: e.confidence,
|
|
3663
3671
|
reason: e.reason
|
|
3664
|
-
},
|
|
3672
|
+
}, Wr = /* @__PURE__ */ new Map([
|
|
3665
3673
|
["mi", "mjx-mi"],
|
|
3666
3674
|
["mn", "mjx-mn"],
|
|
3667
3675
|
["mo", "mjx-mo"],
|
|
3668
3676
|
["mtext", "mjx-mtext"]
|
|
3669
|
-
]),
|
|
3677
|
+
]), Gr = "mi,mn,mo,mtext", Kr = "mjx-mi,mjx-mn,mjx-mo,mjx-mtext", qr = [
|
|
3670
3678
|
"mjx-mfrac",
|
|
3671
3679
|
"mjx-msqrt",
|
|
3672
3680
|
"mjx-mroot",
|
|
@@ -3674,55 +3682,55 @@ var ct = class {
|
|
|
3674
3682
|
"mjx-munder",
|
|
3675
3683
|
"mjx-mover",
|
|
3676
3684
|
"mjx-munderover"
|
|
3677
|
-
].join(","),
|
|
3685
|
+
].join(","), Jr = (e) => e.type === "text-range" ? e.node.parentElement : e.element, J = (e) => {
|
|
3678
3686
|
let t = e;
|
|
3679
3687
|
for (; t;) {
|
|
3680
3688
|
if (t.localName?.toLowerCase() === "mjx-container") return t;
|
|
3681
3689
|
t = t.parentElement;
|
|
3682
3690
|
}
|
|
3683
3691
|
return null;
|
|
3684
|
-
},
|
|
3692
|
+
}, Yr = (e) => !e || J(e) ? !1 : !bt(e), Xr = (e) => {
|
|
3685
3693
|
let t = e.getBoundingClientRect?.();
|
|
3686
3694
|
return !!(t && t.width > 0 && t.height > 0);
|
|
3687
|
-
},
|
|
3695
|
+
}, Zr = (e) => {
|
|
3688
3696
|
let t = e;
|
|
3689
3697
|
for (; t;) {
|
|
3690
3698
|
if (t.localName?.toLowerCase() === "math") return t;
|
|
3691
3699
|
t = t.parentElement;
|
|
3692
3700
|
}
|
|
3693
3701
|
return null;
|
|
3694
|
-
},
|
|
3702
|
+
}, Qr = (e, t) => {
|
|
3695
3703
|
if (e.length === 0 || e.length !== t.length) return !1;
|
|
3696
3704
|
for (let n = 0; n < e.length; n += 1) {
|
|
3697
|
-
let r =
|
|
3705
|
+
let r = Wr.get(e[n].localName.toLowerCase());
|
|
3698
3706
|
if (!r || t[n].localName.toLowerCase() !== r) return !1;
|
|
3699
3707
|
}
|
|
3700
3708
|
return !0;
|
|
3701
|
-
},
|
|
3702
|
-
if (!e || !
|
|
3703
|
-
let n =
|
|
3709
|
+
}, $r = (e, t) => {
|
|
3710
|
+
if (!e || !Wr.has(e.localName.toLowerCase()) || t.querySelector(qr)) return null;
|
|
3711
|
+
let n = Zr(e), r = t.querySelector("mjx-math");
|
|
3704
3712
|
if (!n || !r) return null;
|
|
3705
|
-
let i = Array.from(n.querySelectorAll(
|
|
3713
|
+
let i = Array.from(n.querySelectorAll(Gr)), a = i.indexOf(e);
|
|
3706
3714
|
if (a < 0) return null;
|
|
3707
|
-
let o = Array.from(r.querySelectorAll(
|
|
3708
|
-
if (!
|
|
3715
|
+
let o = Array.from(r.querySelectorAll(Kr));
|
|
3716
|
+
if (!Qr(i, o)) return null;
|
|
3709
3717
|
let s = o[a];
|
|
3710
|
-
return !s || !
|
|
3711
|
-
},
|
|
3712
|
-
let t =
|
|
3718
|
+
return !s || !Xr(s) ? null : s;
|
|
3719
|
+
}, ei = (e) => {
|
|
3720
|
+
let t = J(e);
|
|
3713
3721
|
if (t) {
|
|
3714
|
-
if (t.querySelector(
|
|
3715
|
-
let n =
|
|
3722
|
+
if (t.querySelector(qr)) return "expression";
|
|
3723
|
+
let n = Zr(e) ?? e, r = t.querySelector("mjx-math");
|
|
3716
3724
|
if (!r) return "expression";
|
|
3717
|
-
let i = Array.from(n.querySelectorAll(
|
|
3718
|
-
return
|
|
3725
|
+
let i = Array.from(n.querySelectorAll(Gr)), a = Array.from(r.querySelectorAll(Kr));
|
|
3726
|
+
return Qr(i, a) && a.some((e) => Xr(e)) ? "token" : "expression";
|
|
3719
3727
|
}
|
|
3720
|
-
let n =
|
|
3721
|
-
return Array.from(n.querySelectorAll(
|
|
3722
|
-
},
|
|
3723
|
-
let t =
|
|
3728
|
+
let n = Zr(e) ?? e;
|
|
3729
|
+
return Array.from(n.querySelectorAll(Gr)).some((e) => !bt(e)) ? "token" : "expression";
|
|
3730
|
+
}, Y = (e) => {
|
|
3731
|
+
let t = Jr(e), n = J(t);
|
|
3724
3732
|
if (n) {
|
|
3725
|
-
let e =
|
|
3733
|
+
let e = $r(t, n);
|
|
3726
3734
|
return e ? {
|
|
3727
3735
|
type: "element",
|
|
3728
3736
|
quality: "semantic-token",
|
|
@@ -3733,35 +3741,35 @@ var ct = class {
|
|
|
3733
3741
|
element: n
|
|
3734
3742
|
};
|
|
3735
3743
|
}
|
|
3736
|
-
return e.type === "text-range" ?
|
|
3744
|
+
return e.type === "text-range" ? Yr(e.node.parentElement) ? {
|
|
3737
3745
|
type: "text-range",
|
|
3738
3746
|
quality: "semantic-token",
|
|
3739
3747
|
node: e.node,
|
|
3740
3748
|
startOffset: e.startOffset,
|
|
3741
3749
|
endOffset: e.endOffset
|
|
3742
|
-
} : null :
|
|
3750
|
+
} : null : Yr(e.element) ? {
|
|
3743
3751
|
type: "element",
|
|
3744
3752
|
quality: e.quality === "region-fallback" ? "expression" : "semantic-token",
|
|
3745
3753
|
element: e.element
|
|
3746
3754
|
} : null;
|
|
3747
|
-
},
|
|
3755
|
+
}, ti = Y, ni = () => {
|
|
3748
3756
|
let e = /* @__PURE__ */ new WeakMap();
|
|
3749
3757
|
return (t) => {
|
|
3750
|
-
let n =
|
|
3751
|
-
if (!n || !r) return
|
|
3758
|
+
let n = Jr(t), r = J(n);
|
|
3759
|
+
if (!n || !r) return Y(t);
|
|
3752
3760
|
if (e.has(n)) return e.get(n) ?? null;
|
|
3753
|
-
let i =
|
|
3761
|
+
let i = Y(t);
|
|
3754
3762
|
return e.set(n, i), i;
|
|
3755
3763
|
};
|
|
3756
|
-
},
|
|
3764
|
+
}, ri = (e, t, n, r = e.mathAlignments, i = ti) => {
|
|
3757
3765
|
if (t.chunkSpokenStart === null || t.chunkSpokenEnd === null) return null;
|
|
3758
3766
|
let a = null;
|
|
3759
3767
|
for (let e of r) {
|
|
3760
|
-
let r =
|
|
3768
|
+
let r = zn(e.alignment, {
|
|
3761
3769
|
position: t.chunkSpokenStart,
|
|
3762
3770
|
length: Math.max(1, t.chunkSpokenEnd - t.chunkSpokenStart),
|
|
3763
3771
|
boundaryWord: n.word
|
|
3764
|
-
}) ||
|
|
3772
|
+
}) || Bn(e.alignment, { boundaryWord: n.word });
|
|
3765
3773
|
if (!r) continue;
|
|
3766
3774
|
let o = i(r);
|
|
3767
3775
|
if (o) {
|
|
@@ -3770,7 +3778,7 @@ var ct = class {
|
|
|
3770
3778
|
}
|
|
3771
3779
|
}
|
|
3772
3780
|
return a;
|
|
3773
|
-
},
|
|
3781
|
+
}, ii = (e, t, n) => {
|
|
3774
3782
|
if (!e || typeof document > "u" || n <= t) return null;
|
|
3775
3783
|
let r = e.get(t), i = e.get(Math.max(t, n - 1));
|
|
3776
3784
|
if (!r) return null;
|
|
@@ -3781,17 +3789,17 @@ var ct = class {
|
|
|
3781
3789
|
} catch {
|
|
3782
3790
|
return null;
|
|
3783
3791
|
}
|
|
3784
|
-
},
|
|
3792
|
+
}, ai = (e, t) => {
|
|
3785
3793
|
if (!e.catalogAlignment || t.chunkSpokenStart === null) return null;
|
|
3786
|
-
let n =
|
|
3794
|
+
let n = en(e.catalogAlignment, t.chunkSpokenStart);
|
|
3787
3795
|
if (!n) return null;
|
|
3788
|
-
let r =
|
|
3796
|
+
let r = ii(e.visibleMap, n.start, n.end);
|
|
3789
3797
|
return r ? {
|
|
3790
3798
|
type: "range",
|
|
3791
3799
|
quality: e.catalogAlignment.playbackMode === "exact-word" ? "exact-word" : "semantic-token",
|
|
3792
3800
|
range: r
|
|
3793
3801
|
} : null;
|
|
3794
|
-
},
|
|
3802
|
+
}, oi = (e) => e.regionRange ? {
|
|
3795
3803
|
type: "range",
|
|
3796
3804
|
quality: "region",
|
|
3797
3805
|
range: e.regionRange
|
|
@@ -3799,43 +3807,43 @@ var ct = class {
|
|
|
3799
3807
|
type: "element",
|
|
3800
3808
|
quality: "region",
|
|
3801
3809
|
element: e.regionElement
|
|
3802
|
-
} : null,
|
|
3810
|
+
} : null, si = (e, t = e.chunk.mathAlignments) => {
|
|
3803
3811
|
if (t.length !== 1) return null;
|
|
3804
3812
|
let n = t[0]?.alignment.result.fallbackTarget;
|
|
3805
3813
|
return n ? e.renderedMathTargetResolver(n) : null;
|
|
3806
|
-
},
|
|
3814
|
+
}, ci = (e, t) => e ? t.mathAlignments.filter(({ element: t }) => {
|
|
3807
3815
|
try {
|
|
3808
3816
|
return e.type === "range" ? e.range.intersectsNode(t) : e.type === "element" ? e.element === t || e.element.contains(t) : e.node.parentElement?.contains(t) || !1;
|
|
3809
3817
|
} catch {
|
|
3810
3818
|
return !1;
|
|
3811
3819
|
}
|
|
3812
|
-
}) : t.mathAlignments,
|
|
3820
|
+
}) : t.mathAlignments, li = () => ({
|
|
3813
3821
|
activeTarget: null,
|
|
3814
3822
|
regionTarget: null,
|
|
3815
3823
|
quality: "region",
|
|
3816
3824
|
confidence: 0,
|
|
3817
3825
|
reason: "boundary chunk id was not found"
|
|
3818
|
-
}),
|
|
3826
|
+
}), ui = (e) => e.length === 1 ? e[0].element : null, di = (e, t) => t.length > 0 && t.every(({ element: t }) => e.mathCapabilityByElement.get(t) === "token"), fi = 3, pi = (e, t, n) => {
|
|
3819
3827
|
if (!t || t.type !== "range") return !1;
|
|
3820
3828
|
let { startContainer: r, endContainer: i } = t.range;
|
|
3821
|
-
return r === i && r.nodeType ===
|
|
3822
|
-
},
|
|
3829
|
+
return r === i && r.nodeType === fi ? !1 : n.some(({ element: t }) => e.mathCapabilityByElement.get(t) === "token" && t.contains(r) && t.contains(i));
|
|
3830
|
+
}, mi = (e, t) => ({
|
|
3823
3831
|
chunk: e,
|
|
3824
|
-
regionTarget:
|
|
3825
|
-
renderedMathTargetResolver:
|
|
3826
|
-
mathCapabilityByElement: new Map(e.mathAlignments.map(({ element: e }) => [e, t ?
|
|
3832
|
+
regionTarget: oi(e),
|
|
3833
|
+
renderedMathTargetResolver: ni(),
|
|
3834
|
+
mathCapabilityByElement: new Map(e.mathAlignments.map(({ element: e }) => [e, t ? ei(e) : "expression"])),
|
|
3827
3835
|
heldTokenByElement: /* @__PURE__ */ new Map()
|
|
3828
|
-
}),
|
|
3829
|
-
let t = e.mathTokenHighlighting !== !1, n = new Map(e.chunks.map((e) => [e.id,
|
|
3836
|
+
}), hi = (e) => {
|
|
3837
|
+
let t = e.mathTokenHighlighting !== !1, n = new Map(e.chunks.map((e) => [e.id, mi(e, t)]));
|
|
3830
3838
|
return {
|
|
3831
3839
|
chunks: e.chunks,
|
|
3832
3840
|
resolveInitial(e) {
|
|
3833
3841
|
let t = n.get(e);
|
|
3834
|
-
if (!t) return
|
|
3842
|
+
if (!t) return li();
|
|
3835
3843
|
let r = t.chunk.mathAlignments, i = r.length === 1 ? r[0].element : null, a = i ? t.mathCapabilityByElement.get(i) : null;
|
|
3836
|
-
return
|
|
3844
|
+
return q(a === "expression" ? {
|
|
3837
3845
|
semanticTarget: null,
|
|
3838
|
-
expressionTarget:
|
|
3846
|
+
expressionTarget: si(t),
|
|
3839
3847
|
regionTarget: t.regionTarget,
|
|
3840
3848
|
confidence: .5,
|
|
3841
3849
|
reason: "initial expression (sticky expression mode)"
|
|
@@ -3849,11 +3857,11 @@ var ct = class {
|
|
|
3849
3857
|
},
|
|
3850
3858
|
resolveBoundary(e) {
|
|
3851
3859
|
let r = n.get(e.chunkId);
|
|
3852
|
-
if (!r) return
|
|
3853
|
-
let { chunk: i } = r, a =
|
|
3860
|
+
if (!r) return li();
|
|
3861
|
+
let { chunk: i } = r, a = Ur(i, e), o = ai(i, a), s = ci(o, i), c = (!o || s.length > 0 ? ri(i, a, e, s, r.renderedMathTargetResolver) : null) || null, l = t && c && c.quality !== "expression" ? c : null, u = c && c.quality === "expression" ? c : null;
|
|
3854
3862
|
if (l) {
|
|
3855
|
-
let e =
|
|
3856
|
-
return e && r.heldTokenByElement.set(e, l),
|
|
3863
|
+
let e = ui(s);
|
|
3864
|
+
return e && r.heldTokenByElement.set(e, l), q({
|
|
3857
3865
|
semanticTarget: l,
|
|
3858
3866
|
expressionTarget: null,
|
|
3859
3867
|
regionTarget: r.regionTarget,
|
|
@@ -3861,16 +3869,16 @@ var ct = class {
|
|
|
3861
3869
|
reason: a.reason
|
|
3862
3870
|
});
|
|
3863
3871
|
}
|
|
3864
|
-
if (o && (t ? !
|
|
3872
|
+
if (o && (t ? !pi(r, o, s) : s.length === 0)) return q({
|
|
3865
3873
|
semanticTarget: o,
|
|
3866
3874
|
expressionTarget: null,
|
|
3867
3875
|
regionTarget: r.regionTarget,
|
|
3868
3876
|
confidence: a.confidence,
|
|
3869
3877
|
reason: a.reason
|
|
3870
3878
|
});
|
|
3871
|
-
if (
|
|
3872
|
-
let e =
|
|
3873
|
-
return
|
|
3879
|
+
if (di(r, s)) {
|
|
3880
|
+
let e = ui(s), t = e ? r.heldTokenByElement.get(e) ?? null : null;
|
|
3881
|
+
return q({
|
|
3874
3882
|
semanticTarget: t,
|
|
3875
3883
|
expressionTarget: null,
|
|
3876
3884
|
regionTarget: r.regionTarget,
|
|
@@ -3878,19 +3886,19 @@ var ct = class {
|
|
|
3878
3886
|
reason: t ? "hold last token (sticky token mode)" : "region (sticky token mode, awaiting first token)"
|
|
3879
3887
|
});
|
|
3880
3888
|
}
|
|
3881
|
-
return
|
|
3889
|
+
return q({
|
|
3882
3890
|
semanticTarget: null,
|
|
3883
|
-
expressionTarget: u ??
|
|
3891
|
+
expressionTarget: u ?? si(r, s),
|
|
3884
3892
|
regionTarget: r.regionTarget,
|
|
3885
3893
|
confidence: a.confidence,
|
|
3886
3894
|
reason: a.reason
|
|
3887
3895
|
});
|
|
3888
3896
|
}
|
|
3889
3897
|
};
|
|
3890
|
-
},
|
|
3898
|
+
}, gi = (e) => e.alignment?.boundaryOffsetMode ? e.alignment.boundaryOffsetMode : e.mathAlignment?.speech.boundaryOffsetSpace || "plain-spoken-text", _i = (e) => e.mathAlignments?.length ? e.mathAlignments : e.mathAlignment && e.sourceElement ? [{
|
|
3891
3899
|
element: e.sourceElement,
|
|
3892
3900
|
alignment: e.mathAlignment
|
|
3893
|
-
}] : [],
|
|
3901
|
+
}] : [], vi = (e) => (e.chunks && e.chunks.length ? e.chunks : [{
|
|
3894
3902
|
speechText: e.speechText || "",
|
|
3895
3903
|
visibleText: e.visibleText || e.speechText || "",
|
|
3896
3904
|
sourceElement: e.sourceElement || e.contentRoot,
|
|
@@ -3907,9 +3915,9 @@ var ct = class {
|
|
|
3907
3915
|
regionRange: t.regionRange,
|
|
3908
3916
|
visibleMap: t.visibleMap,
|
|
3909
3917
|
catalogAlignment: t.alignment,
|
|
3910
|
-
mathAlignments:
|
|
3911
|
-
offsetSpace:
|
|
3912
|
-
})),
|
|
3918
|
+
mathAlignments: _i(t),
|
|
3919
|
+
offsetSpace: gi(t)
|
|
3920
|
+
})), yi = [
|
|
3913
3921
|
"[data-pie-tts-region]",
|
|
3914
3922
|
"[data-catalog-region]",
|
|
3915
3923
|
"li",
|
|
@@ -3919,18 +3927,18 @@ var ct = class {
|
|
|
3919
3927
|
"[role='group']",
|
|
3920
3928
|
"[role='region']",
|
|
3921
3929
|
"div"
|
|
3922
|
-
].join(","),
|
|
3923
|
-
let n = e.closest(
|
|
3930
|
+
].join(","), bi = (e, t) => {
|
|
3931
|
+
let n = e.closest(yi);
|
|
3924
3932
|
return n && t.contains(n) ? n : e;
|
|
3925
|
-
},
|
|
3933
|
+
}, xi = (e, t, n) => {
|
|
3926
3934
|
let r = /* @__PURE__ */ new Map();
|
|
3927
3935
|
for (let i = t; i < n; i++) {
|
|
3928
3936
|
let n = e.get(i);
|
|
3929
3937
|
n && r.set(i - t, n);
|
|
3930
3938
|
}
|
|
3931
3939
|
return r;
|
|
3932
|
-
},
|
|
3933
|
-
let t =
|
|
3940
|
+
}, Si = async (e) => {
|
|
3941
|
+
let t = G(e.contentRoot, e.textProcessingOptions), n = await Nr({
|
|
3934
3942
|
chunks: t.chunks,
|
|
3935
3943
|
visibleText: t.visibleText,
|
|
3936
3944
|
language: e.language,
|
|
@@ -3948,8 +3956,8 @@ var ct = class {
|
|
|
3948
3956
|
segment: n,
|
|
3949
3957
|
anchor: {
|
|
3950
3958
|
sourceElement: r,
|
|
3951
|
-
regionElement:
|
|
3952
|
-
visibleMap:
|
|
3959
|
+
regionElement: bi(r, e.contentRoot),
|
|
3960
|
+
visibleMap: xi(t.map, n.visibleSpan.start, n.visibleSpan.end)
|
|
3953
3961
|
}
|
|
3954
3962
|
};
|
|
3955
3963
|
}
|
|
@@ -3969,8 +3977,8 @@ var ct = class {
|
|
|
3969
3977
|
containsMathMarkup: t.containsMathMarkup,
|
|
3970
3978
|
visibleText: t.visibleText
|
|
3971
3979
|
};
|
|
3972
|
-
},
|
|
3973
|
-
let n =
|
|
3980
|
+
}, Ci = (e, t) => {
|
|
3981
|
+
let n = Kt({
|
|
3974
3982
|
speechText: e.spokenText,
|
|
3975
3983
|
visibleText: e.spokenText
|
|
3976
3984
|
});
|
|
@@ -3979,13 +3987,13 @@ var ct = class {
|
|
|
3979
3987
|
visibleText: e.visibleText,
|
|
3980
3988
|
sourceElement: t.sourceElement,
|
|
3981
3989
|
regionElement: t.regionElement,
|
|
3982
|
-
regionRange:
|
|
3990
|
+
regionRange: ii(t.visibleMap, 0, e.visibleText.length) ?? void 0,
|
|
3983
3991
|
speechMatchesVisibleText: !0,
|
|
3984
3992
|
playbackMode: n.playbackMode,
|
|
3985
3993
|
alignment: n,
|
|
3986
3994
|
visibleMap: t.visibleMap
|
|
3987
3995
|
};
|
|
3988
|
-
},
|
|
3996
|
+
}, wi = (e, t) => {
|
|
3989
3997
|
let n = t.sourceElement;
|
|
3990
3998
|
return {
|
|
3991
3999
|
speechText: e.spokenText,
|
|
@@ -3993,12 +4001,12 @@ var ct = class {
|
|
|
3993
4001
|
sourceElement: n,
|
|
3994
4002
|
regionElement: t.regionElement,
|
|
3995
4003
|
speechMatchesVisibleText: e.spokenText === e.fallbackText,
|
|
3996
|
-
mathAlignment: n ?
|
|
4004
|
+
mathAlignment: n ? U({
|
|
3997
4005
|
mathElement: n,
|
|
3998
4006
|
speechText: e.spokenText
|
|
3999
4007
|
}) : void 0
|
|
4000
4008
|
};
|
|
4001
|
-
},
|
|
4009
|
+
}, Ti = (e, t, n) => {
|
|
4002
4010
|
let r = t.sourceElement;
|
|
4003
4011
|
return {
|
|
4004
4012
|
speechText: n,
|
|
@@ -4006,23 +4014,23 @@ var ct = class {
|
|
|
4006
4014
|
sourceElement: r,
|
|
4007
4015
|
regionElement: t.regionElement,
|
|
4008
4016
|
speechMatchesVisibleText: !1,
|
|
4009
|
-
mathAlignment: r ?
|
|
4017
|
+
mathAlignment: r ? U({
|
|
4010
4018
|
mathElement: r,
|
|
4011
4019
|
speechText: n
|
|
4012
4020
|
}) : void 0,
|
|
4013
|
-
plainFallback:
|
|
4021
|
+
plainFallback: wi(e, t)
|
|
4014
4022
|
};
|
|
4015
|
-
},
|
|
4023
|
+
}, Ei = (e, t = {}) => e.items.map(({ segment: e, anchor: n }) => e.kind === "prose" ? Ci(e, n) : t.format === "ssml" && e.ssml ? Ti(e, n, e.ssml) : wi(e, n)), Di = "pie-tts-control-handoff", X;
|
|
4016
4024
|
(function(e) {
|
|
4017
4025
|
e.IDLE = "idle", e.LOADING = "loading", e.PLAYING = "playing", e.PAUSED = "paused", e.ERROR = "error";
|
|
4018
|
-
})(
|
|
4019
|
-
var
|
|
4026
|
+
})(X ||= {});
|
|
4027
|
+
var Oi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOffset === t.startOffset && e.endContainer === t.endContainer && e.endOffset === t.endOffset, ki = (e, t) => e === t ? !0 : !e || !t || e.type !== t.type || e.quality !== t.quality ? !1 : e.type === "range" && t.type === "range" ? Oi(e.range, t.range) : e.type === "element" && t.type === "element" ? e.element === t.element : e.type === "text-range" && t.type === "text-range" && e.node === t.node && e.startOffset === t.startOffset && e.endOffset === t.endOffset, Ai = class e {
|
|
4020
4028
|
currentProvider = null;
|
|
4021
4029
|
provider = null;
|
|
4022
4030
|
highlightCoordinator = null;
|
|
4023
4031
|
highlightTargetResolverProvider = null;
|
|
4024
4032
|
catalogResolver = null;
|
|
4025
|
-
state =
|
|
4033
|
+
state = X.IDLE;
|
|
4026
4034
|
ttsConfig = {};
|
|
4027
4035
|
currentText = null;
|
|
4028
4036
|
currentContentElement = null;
|
|
@@ -4048,7 +4056,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4048
4056
|
activeHighlightMode = "word";
|
|
4049
4057
|
lastRenderedRegionTarget = null;
|
|
4050
4058
|
telemetryReporter = null;
|
|
4051
|
-
generatedMathSpeechResolver =
|
|
4059
|
+
generatedMathSpeechResolver = zr();
|
|
4052
4060
|
static debugEnabled = (() => {
|
|
4053
4061
|
try {
|
|
4054
4062
|
if (typeof process < "u" && process.env?.PIE_TTS_DEBUG === "1") return !0;
|
|
@@ -4064,7 +4072,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4064
4072
|
}
|
|
4065
4073
|
notifyPlaybackStarted(e) {
|
|
4066
4074
|
if (this.playbackStartDeferredRunId !== e || e !== this.speakRunId) return;
|
|
4067
|
-
this.setState(
|
|
4075
|
+
this.setState(X.PLAYING);
|
|
4068
4076
|
let t = this.pendingPlaybackStartHighlights.splice(0);
|
|
4069
4077
|
for (let e of t) e();
|
|
4070
4078
|
}
|
|
@@ -4177,7 +4185,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4177
4185
|
let i = n?.resolveWordRange?.(e, t);
|
|
4178
4186
|
if (i && this.isRangeWithinScope(i, r)) return {
|
|
4179
4187
|
range: i,
|
|
4180
|
-
remapped: !
|
|
4188
|
+
remapped: !Oi(e, i)
|
|
4181
4189
|
};
|
|
4182
4190
|
} catch {}
|
|
4183
4191
|
return {
|
|
@@ -4273,11 +4281,11 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4273
4281
|
}
|
|
4274
4282
|
getMathSpeechOptions() {
|
|
4275
4283
|
let e = (this.ttsConfig.providerOptions || {}).mathSpeech;
|
|
4276
|
-
return
|
|
4284
|
+
return K(e);
|
|
4277
4285
|
}
|
|
4278
4286
|
buildPositionMap(t, n, r) {
|
|
4279
4287
|
this.normalizedToDOM.clear();
|
|
4280
|
-
let { text: i, map: a } =
|
|
4288
|
+
let { text: i, map: a } = P(t, this.getTextProcessingOptions(r));
|
|
4281
4289
|
this.normalizedToDOM = a, e.debugEnabled && (this.debugLog("[TTSService] Text comparison:", {
|
|
4282
4290
|
spokenLength: n.length,
|
|
4283
4291
|
normalizedDomLength: i.length,
|
|
@@ -4339,7 +4347,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4339
4347
|
return e.includes("<") ? /<\s*break\b|<\s*speak\b|<\s*prosody\b|<\s*p\b|<\s*s\b/i.test(e) : !1;
|
|
4340
4348
|
}
|
|
4341
4349
|
isElementHidden(e) {
|
|
4342
|
-
return
|
|
4350
|
+
return yt(e);
|
|
4343
4351
|
}
|
|
4344
4352
|
getBoundaryStrength(e) {
|
|
4345
4353
|
let t = Number(e.getAttribute("data-tts-break-ms"));
|
|
@@ -4387,10 +4395,10 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4387
4395
|
return this.createSpeechPlanSegments(t, n);
|
|
4388
4396
|
}
|
|
4389
4397
|
collectSpeechPlanBoundaries(e, t) {
|
|
4390
|
-
let n = /* @__PURE__ */ new Map(), { map: r } =
|
|
4398
|
+
let n = /* @__PURE__ */ new Map(), { map: r } = P(e, this.getTextProcessingOptions()), i = this.createNodeStartOffsets(r), a = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), o = a.nextNode(), s = null;
|
|
4391
4399
|
for (; o;) {
|
|
4392
4400
|
let t = o, r = t.parentElement;
|
|
4393
|
-
if (r && !this.isElementHidden(r) && !
|
|
4401
|
+
if (r && !this.isElementHidden(r) && !Et(t)) {
|
|
4394
4402
|
let r = this.getBoundaryAnchor(t, e), a = i.get(t);
|
|
4395
4403
|
r && a !== void 0 && r.anchor !== s && a > 0 && (n.set(a, Math.max(n.get(a) || 0, r.units)), s = r.anchor);
|
|
4396
4404
|
}
|
|
@@ -4425,7 +4433,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4425
4433
|
}), r.filter((e) => e.text.trim().length > 0);
|
|
4426
4434
|
}
|
|
4427
4435
|
segmentSentences(e) {
|
|
4428
|
-
return
|
|
4436
|
+
return A(e, { locale: this.ttsConfig.providerOptions?.locale || void 0 });
|
|
4429
4437
|
}
|
|
4430
4438
|
createSeekSegmentsFromText(e) {
|
|
4431
4439
|
return this.segmentSentences(e).map((e) => {
|
|
@@ -4469,7 +4477,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4469
4477
|
createSeekSegmentsFromSpeechChunks(e) {
|
|
4470
4478
|
let t = 0;
|
|
4471
4479
|
return e.map((e) => {
|
|
4472
|
-
let n =
|
|
4480
|
+
let n = M(e.plainFallback?.speechText || (this.hasExplicitBreakSemantics(e.speechText) ? e.visibleText : e.speechText) || e.visibleText) || e.visibleText || "", r = {
|
|
4473
4481
|
text: n,
|
|
4474
4482
|
startOffset: t,
|
|
4475
4483
|
pauseMsAfter: 0
|
|
@@ -4583,7 +4591,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4583
4591
|
contentToSpeak: s,
|
|
4584
4592
|
shouldUsePlan: h,
|
|
4585
4593
|
playbackSegments: this.seekSegments
|
|
4586
|
-
}), this.setState(
|
|
4594
|
+
}), this.setState(X.LOADING), r = this.installPlaybackStartBarrier(n, !!this.playbackChunks[0]?.audio), this.prepareHighlightsForSpeak({
|
|
4587
4595
|
contentToSpeak: s,
|
|
4588
4596
|
options: t,
|
|
4589
4597
|
highlightMode: p,
|
|
@@ -4592,25 +4600,25 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4592
4600
|
}), d ? this.configureWordBoundaryHighlighting({
|
|
4593
4601
|
highlightMode: p,
|
|
4594
4602
|
wordBoundaryOffset: t?.wordBoundaryOffset || 0
|
|
4595
|
-
}) : this.clearWordBoundaryHighlighting(), r || this.setState(
|
|
4603
|
+
}) : this.clearWordBoundaryHighlighting(), r || this.setState(X.PLAYING), this.activePlaybackRate = this.normalizePlaybackRate(Number(this.ttsConfig.rate ?? 1)), await this.executeSpeakPlayback({
|
|
4596
4604
|
shouldUsePlan: h,
|
|
4597
4605
|
runId: n,
|
|
4598
4606
|
highlightMode: p,
|
|
4599
4607
|
contentToSpeak: o,
|
|
4600
4608
|
speechChunks: f
|
|
4601
4609
|
}), n !== this.speakRunId) return;
|
|
4602
|
-
this.setState(
|
|
4610
|
+
this.setState(X.IDLE), this.clearHighlightsAndTracking();
|
|
4603
4611
|
} catch (e) {
|
|
4604
4612
|
let t = e;
|
|
4605
4613
|
if (console.error("TTS error:", t), this.lastError = t instanceof Error ? t.message : String(t), n !== this.speakRunId) return;
|
|
4606
|
-
throw this.setState(
|
|
4614
|
+
throw this.setState(X.ERROR), this.clearHighlightsAndTracking(), t;
|
|
4607
4615
|
} finally {
|
|
4608
4616
|
this.clearPlaybackStartBarrier(r);
|
|
4609
4617
|
}
|
|
4610
4618
|
}
|
|
4611
4619
|
async switchProviderToBrowser(e, t) {
|
|
4612
4620
|
if (!this.currentProvider) return !1;
|
|
4613
|
-
let n = new
|
|
4621
|
+
let n = new j(), r = this.currentProvider.providerId, i = {};
|
|
4614
4622
|
this.ttsConfig.rate !== void 0 && (i.rate = this.ttsConfig.rate), this.ttsConfig.pitch !== void 0 && (i.pitch = this.ttsConfig.pitch), this.ttsConfig.mathTokenHighlighting !== void 0 && (i.mathTokenHighlighting = this.ttsConfig.mathTokenHighlighting);
|
|
4615
4623
|
let a = t?.operation || "tts-initialize", o = t?.contentToSpeak ?? "", s = o.replace(/\s+/g, " ").trim().slice(0, 120), c = o.length > 0 ? {
|
|
4616
4624
|
textLength: o.length,
|
|
@@ -4663,7 +4671,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4663
4671
|
}, "updateSettings" in this.provider && typeof this.provider.updateSettings == "function" && await this.provider.updateSettings({ providerOptions: i });
|
|
4664
4672
|
}
|
|
4665
4673
|
async resolveSpeechContent(e, t) {
|
|
4666
|
-
let n =
|
|
4674
|
+
let n = M(e);
|
|
4667
4675
|
if (t?.ignoreCatalogs) return {
|
|
4668
4676
|
contentToSpeak: n,
|
|
4669
4677
|
speechText: n,
|
|
@@ -4684,7 +4692,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4684
4692
|
form: "content"
|
|
4685
4693
|
}), r = e?.content;
|
|
4686
4694
|
if (e && r !== void 0) {
|
|
4687
|
-
let i = t?.contentElement &&
|
|
4695
|
+
let i = t?.contentElement && G(t.contentElement, this.getTextProcessingOptions(t.language)).visibleText || n, a = M(r);
|
|
4688
4696
|
return this.debugLog(`[TTSService] Using catalog content for "${t.catalogId}" (${e.language})`), {
|
|
4689
4697
|
contentToSpeak: r,
|
|
4690
4698
|
speechText: r,
|
|
@@ -4717,7 +4725,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4717
4725
|
if (!this.catalogResolver) return null;
|
|
4718
4726
|
let r = this.collectCatalogSpeechChunks(e, n);
|
|
4719
4727
|
if (!r.some((e) => e.sourceElement)) return null;
|
|
4720
|
-
let i =
|
|
4728
|
+
let i = M(r.map((e) => e.speechText).join(" ")), a = G(e, this.getTextProcessingOptions(n.language)).visibleText || t;
|
|
4721
4729
|
return {
|
|
4722
4730
|
contentToSpeak: i,
|
|
4723
4731
|
speechText: i,
|
|
@@ -4733,7 +4741,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4733
4741
|
}
|
|
4734
4742
|
collectCatalogSpeechChunks(e, t) {
|
|
4735
4743
|
let n = [], r = "", i = () => {
|
|
4736
|
-
let e =
|
|
4744
|
+
let e = M(r);
|
|
4737
4745
|
r = "", e && n.push({
|
|
4738
4746
|
speechText: e,
|
|
4739
4747
|
visibleText: e,
|
|
@@ -4751,7 +4759,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4751
4759
|
}, i = this.catalogResolver.getAlternative(n, {
|
|
4752
4760
|
...r,
|
|
4753
4761
|
form: "payload"
|
|
4754
|
-
}), a = i?.payload ?
|
|
4762
|
+
}), a = i?.payload ? ct({ payload: i.payload }) ?? void 0 : void 0, o = this.catalogResolver.getAlternative(n, {
|
|
4755
4763
|
...r,
|
|
4756
4764
|
form: "content"
|
|
4757
4765
|
})?.content;
|
|
@@ -4762,13 +4770,13 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4762
4770
|
}, o = (e, n) => {
|
|
4763
4771
|
let r = s(e);
|
|
4764
4772
|
if (r.length !== 1) return null;
|
|
4765
|
-
let i = r[0], a =
|
|
4773
|
+
let i = r[0], a = G(i, this.getTextProcessingOptions(t.language)).visibleText || M(i.textContent || ""), o = (e) => M(e).replace(/\s+/g, "");
|
|
4766
4774
|
return o(a) === o(n) ? i : null;
|
|
4767
4775
|
}, s = (e) => {
|
|
4768
4776
|
let t = Array.from(e.querySelectorAll("math"));
|
|
4769
4777
|
return e.localName?.toLowerCase() === "math" ? [e, ...t] : t;
|
|
4770
4778
|
}, c = (l) => {
|
|
4771
|
-
if (
|
|
4779
|
+
if (N(l, e)) return;
|
|
4772
4780
|
if (l.nodeType === Node.TEXT_NODE) {
|
|
4773
4781
|
r += ` ${l.textContent || ""}`;
|
|
4774
4782
|
return;
|
|
@@ -4777,16 +4785,16 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4777
4785
|
let u = l, d = a(u);
|
|
4778
4786
|
if (d) {
|
|
4779
4787
|
i();
|
|
4780
|
-
let r =
|
|
4781
|
-
let e = d.script, t =
|
|
4788
|
+
let r = G(u, this.getTextProcessingOptions(t.language)), a = r.visibleText || M(u.textContent || ""), c = bi(u, e), l = d.script === void 0 ? null : (() => {
|
|
4789
|
+
let e = d.script, t = Kt({
|
|
4782
4790
|
speechText: e,
|
|
4783
4791
|
visibleText: a
|
|
4784
|
-
}), n = o(u, a), i = n ?
|
|
4792
|
+
}), n = o(u, a), i = n ? U({
|
|
4785
4793
|
mathElement: n,
|
|
4786
4794
|
speechText: e
|
|
4787
4795
|
}) : void 0, l = i ? void 0 : s(u).map((t) => ({
|
|
4788
4796
|
element: t,
|
|
4789
|
-
alignment:
|
|
4797
|
+
alignment: U({
|
|
4790
4798
|
mathElement: t,
|
|
4791
4799
|
speechText: e
|
|
4792
4800
|
})
|
|
@@ -4796,7 +4804,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4796
4804
|
visibleText: a,
|
|
4797
4805
|
sourceElement: u,
|
|
4798
4806
|
regionElement: c,
|
|
4799
|
-
speechMatchesVisibleText:
|
|
4807
|
+
speechMatchesVisibleText: M(e) === a,
|
|
4800
4808
|
playbackMode: t.playbackMode,
|
|
4801
4809
|
alignment: t,
|
|
4802
4810
|
mathAlignment: i,
|
|
@@ -4832,7 +4840,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4832
4840
|
return !e || e.providerId?.toLowerCase() === "browser" ? "plain" : e.getCapabilities?.().supportsSSML ? "ssml" : "plain";
|
|
4833
4841
|
}
|
|
4834
4842
|
async resolveGeneratedSpeechContent(e, t, n) {
|
|
4835
|
-
let r = this.resolveGeneratedPlaybackFormat(), { plan: i, containsMathMarkup: a, visibleText: o } = await
|
|
4843
|
+
let r = this.resolveGeneratedPlaybackFormat(), { plan: i, containsMathMarkup: a, visibleText: o } = await Si({
|
|
4836
4844
|
contentRoot: e,
|
|
4837
4845
|
language: n,
|
|
4838
4846
|
mathSpeech: this.getMathSpeechOptions(),
|
|
@@ -4849,7 +4857,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4849
4857
|
containsMathMarkup: !1,
|
|
4850
4858
|
speechMatchesVisibleText: !0
|
|
4851
4859
|
};
|
|
4852
|
-
let c =
|
|
4860
|
+
let c = Ei(i, { format: r }), l = i.plainSpeechText;
|
|
4853
4861
|
return {
|
|
4854
4862
|
contentToSpeak: l,
|
|
4855
4863
|
speechText: l,
|
|
@@ -4916,7 +4924,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4916
4924
|
this.highlightCoordinator && this.paintTTSWordRange(this.resolveWordHighlightRange(e).range);
|
|
4917
4925
|
}
|
|
4918
4926
|
highlightRenderableRegionTarget(e) {
|
|
4919
|
-
if (!(!this.highlightCoordinator || !e || typeof document > "u") && !(!this.highlightTargetResolverProvider &&
|
|
4927
|
+
if (!(!this.highlightCoordinator || !e || typeof document > "u") && !(!this.highlightTargetResolverProvider && ki(this.lastRenderedRegionTarget, e))) try {
|
|
4920
4928
|
let t = document.createRange();
|
|
4921
4929
|
if (e.type === "element") t.selectNodeContents(e.element);
|
|
4922
4930
|
else if (e.type === "range") {
|
|
@@ -4963,7 +4971,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4963
4971
|
await this.speakCatalogChunkOnce(e, t);
|
|
4964
4972
|
} catch (n) {
|
|
4965
4973
|
if (e.plainFallback && t === this.speakRunId) {
|
|
4966
|
-
this.debugLog("[TTSService] SSML chunk speak failed; retrying plain text", { message: n instanceof Error ? n.message : String(n) }), this.playbackStartDeferredRunId === t && this.provider && !("onPlaybackStart" in this.provider) && (this.pendingPlaybackStartHighlights = [], this.clearPlaybackStartBarrier(), this.setState(
|
|
4974
|
+
this.debugLog("[TTSService] SSML chunk speak failed; retrying plain text", { message: n instanceof Error ? n.message : String(n) }), this.playbackStartDeferredRunId === t && this.provider && !("onPlaybackStart" in this.provider) && (this.pendingPlaybackStartHighlights = [], this.clearPlaybackStartBarrier(), this.setState(X.PLAYING)), await this.speakCatalogChunkOnce(e.plainFallback, t);
|
|
4967
4975
|
return;
|
|
4968
4976
|
}
|
|
4969
4977
|
throw n;
|
|
@@ -4972,7 +4980,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4972
4980
|
async playRecordedAudio(e, t) {
|
|
4973
4981
|
if (typeof document > "u") throw Error("[tts] no document available to play recorded audio");
|
|
4974
4982
|
let n = e.sources[0], r = document.createElement("audio");
|
|
4975
|
-
r.preload = "auto", r.src =
|
|
4983
|
+
r.preload = "auto", r.src = st(n.src, e.fragment), r.playbackRate = this.normalizePlaybackRate(Number(this.ttsConfig.rate || 1)), await new Promise((i, a) => {
|
|
4976
4984
|
let o, s = !1, c = !1, l = () => {
|
|
4977
4985
|
c || s || (s = !0, t?.());
|
|
4978
4986
|
}, u = () => {
|
|
@@ -4987,7 +4995,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4987
4995
|
cancel: () => {
|
|
4988
4996
|
c || (c = !0, u(), r.pause(), i());
|
|
4989
4997
|
}
|
|
4990
|
-
}, r.addEventListener("ended", d), r.addEventListener("error", f), r.addEventListener("playing", l), o =
|
|
4998
|
+
}, r.addEventListener("ended", d), r.addEventListener("error", f), r.addEventListener("playing", l), o = ot(r, e.fragment, d), Promise.resolve(r.play()).then(l).catch(f);
|
|
4991
4999
|
}).finally(() => {
|
|
4992
5000
|
this.activeRecordedAudio?.element === r && (this.activeRecordedAudio = null), r.pause(), r.removeAttribute("src");
|
|
4993
5001
|
});
|
|
@@ -5006,10 +5014,10 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5006
5014
|
});
|
|
5007
5015
|
return;
|
|
5008
5016
|
}
|
|
5009
|
-
let n = e.regionElement || e.sourceElement || this.currentContentElement, r = n ?
|
|
5017
|
+
let n = e.regionElement || e.sourceElement || this.currentContentElement, r = n ? vi({
|
|
5010
5018
|
contentRoot: n,
|
|
5011
5019
|
chunks: [e]
|
|
5012
|
-
})[0] : null, i = this.ttsConfig.mathTokenHighlighting !== !1, a = r ?
|
|
5020
|
+
})[0] : null, i = this.ttsConfig.mathTokenHighlighting !== !1, a = r ? hi({
|
|
5013
5021
|
chunks: [r],
|
|
5014
5022
|
mathTokenHighlighting: i
|
|
5015
5023
|
}) : null;
|
|
@@ -5069,7 +5077,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5069
5077
|
}
|
|
5070
5078
|
async speakRange(e, t) {
|
|
5071
5079
|
if (!this.provider) throw Error("TTS service not initialized");
|
|
5072
|
-
if (
|
|
5080
|
+
if (Et(e.commonAncestorContainer)) {
|
|
5073
5081
|
console.warn("[tts] selection lies inside content marked not-to-be-spoken; nothing was spoken. Selecting a node and pressing read-aloud must not become a way around suppression.");
|
|
5074
5082
|
return;
|
|
5075
5083
|
}
|
|
@@ -5079,14 +5087,14 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5079
5087
|
n = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
5080
5088
|
}
|
|
5081
5089
|
if (!n) return;
|
|
5082
|
-
let r =
|
|
5090
|
+
let r = Dt(e, n), i = r.text.trim();
|
|
5083
5091
|
if (!i) {
|
|
5084
5092
|
r.filtered && console.warn("[tts] every part of the selection is either hidden or marked not-to-be-spoken; nothing was spoken.");
|
|
5085
5093
|
return;
|
|
5086
5094
|
}
|
|
5087
5095
|
let a = document.createRange();
|
|
5088
5096
|
a.selectNodeContents(n), a.setEnd(e.startContainer, e.startOffset);
|
|
5089
|
-
let o =
|
|
5097
|
+
let o = Dt(a, n).text, s = M(o), c = s.length + (/\s$/.test(o) && s ? 1 : 0);
|
|
5090
5098
|
this.debugLog("[TTSService] speakRange offset calculation:", {
|
|
5091
5099
|
selectedText: i,
|
|
5092
5100
|
textBeforeRange: o.substring(0, 100),
|
|
@@ -5099,12 +5107,12 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5099
5107
|
});
|
|
5100
5108
|
}
|
|
5101
5109
|
pause() {
|
|
5102
|
-
this.provider && this.state ===
|
|
5110
|
+
this.provider && this.state === X.PLAYING && (this.activeRecordedAudio?.element.pause(), this.provider.pause(), this.setState(X.PAUSED));
|
|
5103
5111
|
}
|
|
5104
5112
|
resume() {
|
|
5105
|
-
if (this.provider && this.state ===
|
|
5113
|
+
if (this.provider && this.state === X.PAUSED) {
|
|
5106
5114
|
let e = this.activeRecordedAudio?.element;
|
|
5107
|
-
e && Promise.resolve(e.play()).catch(() => {}), this.provider.resume(), this.setState(
|
|
5115
|
+
e && Promise.resolve(e.play()).catch(() => {}), this.provider.resume(), this.setState(X.PLAYING);
|
|
5108
5116
|
}
|
|
5109
5117
|
}
|
|
5110
5118
|
normalizePlaybackRate(e) {
|
|
@@ -5115,9 +5123,9 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5115
5123
|
let t = Math.max(0, Math.min(this.seekSegments.length - 1, e)), n = this.playbackChunks.length ? this.playbackChunks.slice(t) : null;
|
|
5116
5124
|
this.speakRunId += 1, this.clearPlaybackStartBarrier(), this.cancelRecordedAudio(), this.provider.onWordBoundary = void 0, this.provider.stop(), this.currentSeekSegmentIndex = t;
|
|
5117
5125
|
let r = ++this.speakRunId, i = this.seekSegments.slice(t);
|
|
5118
|
-
this.highlightCoordinator?.clearTTS(), this.activeSentenceStartOffset = null, this.setState(
|
|
5126
|
+
this.highlightCoordinator?.clearTTS(), this.activeSentenceStartOffset = null, this.setState(X.LOADING);
|
|
5119
5127
|
let a = this.installPlaybackStartBarrier(r, !!n?.[0]?.audio);
|
|
5120
|
-
a || this.setState(
|
|
5128
|
+
a || this.setState(X.PLAYING), this.activePlaybackRate = this.normalizePlaybackRate(Number(this.ttsConfig.rate ?? 1));
|
|
5121
5129
|
try {
|
|
5122
5130
|
if (this.configureWordBoundaryHighlighting({
|
|
5123
5131
|
highlightMode: this.activeHighlightMode,
|
|
@@ -5131,10 +5139,10 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5131
5139
|
}
|
|
5132
5140
|
else await this.speakWithPlan(i, r, { highlightMode: this.activeHighlightMode });
|
|
5133
5141
|
if (r !== this.speakRunId) return;
|
|
5134
|
-
this.setState(
|
|
5142
|
+
this.setState(X.IDLE), this.clearHighlightsAndTracking();
|
|
5135
5143
|
} catch (e) {
|
|
5136
5144
|
if (r !== this.speakRunId) return;
|
|
5137
|
-
throw this.lastError = e instanceof Error ? e.message : String(e), this.setState(
|
|
5145
|
+
throw this.lastError = e instanceof Error ? e.message : String(e), this.setState(X.ERROR), this.clearHighlightsAndTracking(), e;
|
|
5138
5146
|
} finally {
|
|
5139
5147
|
this.clearPlaybackStartBarrier(a);
|
|
5140
5148
|
}
|
|
@@ -5165,7 +5173,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5165
5173
|
let a = i.then(async (e) => {
|
|
5166
5174
|
if (r !== this.playbackRateRequestId || e.playbackRunId !== this.speakRunId) return;
|
|
5167
5175
|
let n = this.activePlaybackRate !== null && this.activePlaybackRate !== t;
|
|
5168
|
-
!e.didUpdate && !n || this.state !==
|
|
5176
|
+
!e.didUpdate && !n || this.state !== X.PLAYING && this.state !== X.LOADING || !this.currentText || this.seekSegments.length === 0 || this.hasExplicitBreakSemantics(this.currentText) || await this.restartFromSeekIndex(this.getCurrentSeekSegmentIndex());
|
|
5169
5177
|
}), o;
|
|
5170
5178
|
o = a.finally(() => {
|
|
5171
5179
|
this.pendingPlaybackRateRequest?.promise === o && (this.pendingPlaybackRateRequest = null);
|
|
@@ -5175,7 +5183,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5175
5183
|
}, await o;
|
|
5176
5184
|
}
|
|
5177
5185
|
async seekBy(e) {
|
|
5178
|
-
if (!this.provider || !this.currentText || this.state !==
|
|
5186
|
+
if (!this.provider || !this.currentText || this.state !== X.PLAYING && this.state !== X.PAUSED || this.hasExplicitBreakSemantics(this.currentText) || this.seekSegments.length === 0) return;
|
|
5179
5187
|
let t = Number.isFinite(e) ? Math.trunc(e) : 0;
|
|
5180
5188
|
if (t === 0) return;
|
|
5181
5189
|
let n = this.getCurrentSeekSegmentIndex(), r = Math.max(0, Math.min(this.seekSegments.length - 1, n + t));
|
|
@@ -5190,16 +5198,16 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5190
5198
|
await this.seekBy(-t);
|
|
5191
5199
|
}
|
|
5192
5200
|
stop() {
|
|
5193
|
-
this.provider && (this.speakRunId += 1, this.clearPlaybackStartBarrier(), this.cancelRecordedAudio(), this.provider.onWordBoundary = void 0, this.provider.stop(), this.setState(
|
|
5201
|
+
this.provider && (this.speakRunId += 1, this.clearPlaybackStartBarrier(), this.cancelRecordedAudio(), this.provider.onWordBoundary = void 0, this.provider.stop(), this.setState(X.IDLE), this.currentText = null, this.highlightCoordinator && this.highlightCoordinator.clearTTS(), this.lastRenderedRegionTarget = null, this.currentContentElement = null, this.normalizedToDOM.clear(), this.currentBoundaryOffset = 0, this.activeWordBoundaryOffset = 0, this.seekSegments = [], this.playbackChunks = [], this.sentenceHighlightSegments = [], this.currentSeekSegmentIndex = 0, this.activeSentenceStartOffset = null, this.activePlaybackRate = null);
|
|
5194
5202
|
}
|
|
5195
5203
|
requestControlHandoff() {
|
|
5196
|
-
typeof window > "u" || window.dispatchEvent(new CustomEvent(
|
|
5204
|
+
typeof window > "u" || window.dispatchEvent(new CustomEvent(Di, { detail: { source: "host" } }));
|
|
5197
5205
|
}
|
|
5198
5206
|
isPlaying() {
|
|
5199
|
-
return this.state ===
|
|
5207
|
+
return this.state === X.PLAYING;
|
|
5200
5208
|
}
|
|
5201
5209
|
isPaused() {
|
|
5202
|
-
return this.state ===
|
|
5210
|
+
return this.state === X.PAUSED;
|
|
5203
5211
|
}
|
|
5204
5212
|
getState() {
|
|
5205
5213
|
return this.state;
|
|
@@ -5227,8 +5235,8 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5227
5235
|
providerId: "tts",
|
|
5228
5236
|
previousState: t,
|
|
5229
5237
|
state: e
|
|
5230
|
-
}), e ===
|
|
5231
|
-
let n = t ===
|
|
5238
|
+
}), e === X.PLAYING) {
|
|
5239
|
+
let n = t === X.PAUSED ? "pie-tool-playback-resume" : "pie-tool-playback-start";
|
|
5232
5240
|
this.emitTelemetry(n, {
|
|
5233
5241
|
toolId: "textToSpeech",
|
|
5234
5242
|
providerId: "tts",
|
|
@@ -5237,7 +5245,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5237
5245
|
});
|
|
5238
5246
|
return;
|
|
5239
5247
|
}
|
|
5240
|
-
if (e ===
|
|
5248
|
+
if (e === X.PAUSED) {
|
|
5241
5249
|
this.emitTelemetry("pie-tool-playback-pause", {
|
|
5242
5250
|
toolId: "textToSpeech",
|
|
5243
5251
|
providerId: "tts",
|
|
@@ -5246,7 +5254,7 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5246
5254
|
});
|
|
5247
5255
|
return;
|
|
5248
5256
|
}
|
|
5249
|
-
if (e ===
|
|
5257
|
+
if (e === X.ERROR) {
|
|
5250
5258
|
this.emitTelemetry("pie-tool-playback-error", {
|
|
5251
5259
|
toolId: "textToSpeech",
|
|
5252
5260
|
providerId: "tts",
|
|
@@ -5256,21 +5264,21 @@ var Di = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5256
5264
|
});
|
|
5257
5265
|
return;
|
|
5258
5266
|
}
|
|
5259
|
-
e ===
|
|
5267
|
+
e === X.IDLE && (t === X.PLAYING || t === X.PAUSED || t === X.LOADING) && this.emitTelemetry("pie-tool-playback-stop", {
|
|
5260
5268
|
toolId: "textToSpeech",
|
|
5261
5269
|
providerId: "tts",
|
|
5262
5270
|
previousState: t,
|
|
5263
5271
|
state: e
|
|
5264
5272
|
});
|
|
5265
5273
|
}
|
|
5266
|
-
},
|
|
5274
|
+
}, ji = /* @__PURE__ */ new Set([
|
|
5267
5275
|
"reserved-row",
|
|
5268
5276
|
"expanding-row",
|
|
5269
5277
|
"floating-overlay",
|
|
5270
5278
|
"left-aligned"
|
|
5271
|
-
]),
|
|
5279
|
+
]), Mi = (e) => e && typeof e == "object" ? e : {}, Ni = (e) => e === "polly" || e === "google" || e === "server", Z = (e, t) => e === void 0 ? t : e, Pi = (e, t = "left-aligned") => typeof e == "string" && ji.has(e) ? e : t;
|
|
5272
5280
|
Object.freeze([.8, 1.25]);
|
|
5273
|
-
var
|
|
5281
|
+
var Fi = Object.freeze([
|
|
5274
5282
|
{
|
|
5275
5283
|
rate: .8,
|
|
5276
5284
|
label: "Slow",
|
|
@@ -5287,21 +5295,21 @@ var Pi = Object.freeze([
|
|
|
5287
5295
|
label: "Fast",
|
|
5288
5296
|
ariaLabel: "Fast speed"
|
|
5289
5297
|
}
|
|
5290
|
-
]),
|
|
5298
|
+
]), Ii = (e) => {
|
|
5291
5299
|
if (!(typeof e != "number" || !Number.isFinite(e) || e <= 0)) return Math.round(e * 100) / 100;
|
|
5292
|
-
},
|
|
5300
|
+
}, Li = (e) => {
|
|
5293
5301
|
if (typeof e != "string") return;
|
|
5294
5302
|
let t = e.trim();
|
|
5295
5303
|
return t.length ? t : void 0;
|
|
5296
|
-
},
|
|
5297
|
-
let t = Array.isArray(e) ? e : [...
|
|
5304
|
+
}, Ri = (e) => `${e}x`, zi = (e, t) => e.toLowerCase() === "normal" ? "Normal speed" : t ? `Speed ${e}` : `${e} speed`, Bi = (e, t, n) => t ? t.toLowerCase().includes(e.toLowerCase()) ? t : `${e} ${t}` : zi(e, n), Vi = (e) => {
|
|
5305
|
+
let t = Array.isArray(e) ? e : [...Fi];
|
|
5298
5306
|
if (t.length === 0) return [];
|
|
5299
5307
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5300
5308
|
for (let e of t) {
|
|
5301
|
-
let t =
|
|
5309
|
+
let t = Mi(e), i = Ii(typeof e == "number" ? e : t.rate);
|
|
5302
5310
|
if (i === void 0 || n.has(i)) continue;
|
|
5303
5311
|
n.add(i);
|
|
5304
|
-
let a = i === 1 ? "Normal" :
|
|
5312
|
+
let a = i === 1 ? "Normal" : Ri(i), o = typeof e == "number" ? a : Li(t.label) || a, s = typeof e == "number" ? i === 1 ? "Normal speed" : zi(o, !0) : Bi(o, Li(t.ariaLabel), o === a);
|
|
5305
5313
|
r.push({
|
|
5306
5314
|
rate: i,
|
|
5307
5315
|
label: o,
|
|
@@ -5310,7 +5318,7 @@ var Pi = Object.freeze([
|
|
|
5310
5318
|
requestedDefault: t.default === !0 || t.isDefault === !0
|
|
5311
5319
|
});
|
|
5312
5320
|
}
|
|
5313
|
-
if (!r.length) return
|
|
5321
|
+
if (!r.length) return Vi(Fi);
|
|
5314
5322
|
if (!n.has(1)) {
|
|
5315
5323
|
let e = {
|
|
5316
5324
|
rate: 1,
|
|
@@ -5332,40 +5340,40 @@ Object.freeze([
|
|
|
5332
5340
|
1,
|
|
5333
5341
|
1.25
|
|
5334
5342
|
]);
|
|
5335
|
-
var
|
|
5343
|
+
var Hi = (e) => {
|
|
5336
5344
|
let t = {
|
|
5337
5345
|
...e,
|
|
5338
|
-
layoutMode:
|
|
5346
|
+
layoutMode: Pi(e.layoutMode)
|
|
5339
5347
|
}, n = e.backend || "browser";
|
|
5340
|
-
if (!
|
|
5348
|
+
if (!Ni(n)) return t;
|
|
5341
5349
|
let r = {
|
|
5342
5350
|
...t,
|
|
5343
|
-
apiEndpoint:
|
|
5344
|
-
transportMode:
|
|
5345
|
-
endpointValidationMode:
|
|
5346
|
-
validateEndpoint:
|
|
5347
|
-
includeAuthOnAssetFetch:
|
|
5348
|
-
rate:
|
|
5349
|
-
language:
|
|
5351
|
+
apiEndpoint: Z(t.apiEndpoint, "/api/tts"),
|
|
5352
|
+
transportMode: Z(t.transportMode, "pie"),
|
|
5353
|
+
endpointValidationMode: Z(t.endpointValidationMode, "voices"),
|
|
5354
|
+
validateEndpoint: Z(t.validateEndpoint, !0),
|
|
5355
|
+
includeAuthOnAssetFetch: Z(t.includeAuthOnAssetFetch, !1),
|
|
5356
|
+
rate: Z(t.rate, 1),
|
|
5357
|
+
language: Z(t.language, "en-US")
|
|
5350
5358
|
};
|
|
5351
5359
|
return n === "polly" ? {
|
|
5352
5360
|
...r,
|
|
5353
|
-
defaultVoice:
|
|
5354
|
-
engine:
|
|
5355
|
-
format:
|
|
5356
|
-
speechMarksMode:
|
|
5361
|
+
defaultVoice: Z(r.defaultVoice, "Joanna"),
|
|
5362
|
+
engine: Z(r.engine, "neural"),
|
|
5363
|
+
format: Z(r.format, "mp3"),
|
|
5364
|
+
speechMarksMode: Z(r.speechMarksMode, "word+sentence")
|
|
5357
5365
|
} : n === "google" ? {
|
|
5358
5366
|
...r,
|
|
5359
|
-
defaultVoice:
|
|
5367
|
+
defaultVoice: Z(r.defaultVoice, "en-US-Wavenet-A")
|
|
5360
5368
|
} : r;
|
|
5361
|
-
},
|
|
5362
|
-
let t =
|
|
5363
|
-
return
|
|
5369
|
+
}, Ui = (e) => {
|
|
5370
|
+
let t = Mi(e), n = Mi(t.settings);
|
|
5371
|
+
return Hi({
|
|
5364
5372
|
...t,
|
|
5365
5373
|
...n
|
|
5366
5374
|
});
|
|
5367
|
-
},
|
|
5368
|
-
let t =
|
|
5375
|
+
}, Wi = (e) => e.backend || "browser", Gi = (e, t) => t === "polly" || t === "google" ? t : e.serverProvider || e.provider, Ki = (e, t) => e.transportMode || (t === "custom" ? "custom" : "pie"), qi = (e) => {
|
|
5376
|
+
let t = Wi(e), n = Gi(e, t), r = Ki(e, n), i = K(e.mathSpeech);
|
|
5369
5377
|
return {
|
|
5370
5378
|
voice: e.defaultVoice,
|
|
5371
5379
|
rate: e.rate,
|
|
@@ -5391,8 +5399,8 @@ var Vi = (e) => {
|
|
|
5391
5399
|
validateEndpoint: e.validateEndpoint,
|
|
5392
5400
|
...typeof e.mathTokenHighlighting == "boolean" ? { mathTokenHighlighting: e.mathTokenHighlighting } : {}
|
|
5393
5401
|
};
|
|
5394
|
-
},
|
|
5395
|
-
switch (
|
|
5402
|
+
}, Ji = (e) => Pi(e.layoutMode), Yi = (e) => {
|
|
5403
|
+
switch (Ji(e)) {
|
|
5396
5404
|
case "reserved-row": return {
|
|
5397
5405
|
mount: "before-buttons",
|
|
5398
5406
|
controlsRow: {
|
|
@@ -5426,7 +5434,7 @@ var Vi = (e) => {
|
|
|
5426
5434
|
headerOverlay: { expandWhenToolActive: !0 }
|
|
5427
5435
|
};
|
|
5428
5436
|
}
|
|
5429
|
-
},
|
|
5437
|
+
}, Xi = class {
|
|
5430
5438
|
providers = /* @__PURE__ */ new Map();
|
|
5431
5439
|
configs = /* @__PURE__ */ new Map();
|
|
5432
5440
|
initialized = /* @__PURE__ */ new Map();
|
|
@@ -5572,8 +5580,127 @@ var Vi = (e) => {
|
|
|
5572
5580
|
let e = Array.from(this.providers.keys());
|
|
5573
5581
|
await Promise.all(e.map((e) => this.unregister(e))), console.log("[ToolProviderRegistry] Registry destroyed");
|
|
5574
5582
|
}
|
|
5575
|
-
},
|
|
5576
|
-
|
|
5583
|
+
}, Zi = class {
|
|
5584
|
+
category = "calculator";
|
|
5585
|
+
calculatorProvider = null;
|
|
5586
|
+
initializationPromise = null;
|
|
5587
|
+
lifecycleGeneration = 0;
|
|
5588
|
+
async emitTelemetry(e, t, n) {
|
|
5589
|
+
try {
|
|
5590
|
+
await e.onTelemetry?.(t, n);
|
|
5591
|
+
} catch (e) {
|
|
5592
|
+
console.warn(`[${this.providerName}] telemetry callback failed:`, e);
|
|
5593
|
+
}
|
|
5594
|
+
}
|
|
5595
|
+
async initialize(e = {}) {
|
|
5596
|
+
if (this.calculatorProvider) return;
|
|
5597
|
+
if (this.initializationPromise) return this.initializationPromise;
|
|
5598
|
+
let t = ++this.lifecycleGeneration, n = this.initializeProvider(e, t);
|
|
5599
|
+
this.initializationPromise = n;
|
|
5600
|
+
try {
|
|
5601
|
+
await n;
|
|
5602
|
+
} finally {
|
|
5603
|
+
this.initializationPromise === n && (this.initializationPromise = null);
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
async initializeProvider(e, t) {
|
|
5607
|
+
let n = this.getDefinition(), r = Date.now();
|
|
5608
|
+
await this.emitTelemetry(e, "pie-tool-library-load-start", {
|
|
5609
|
+
toolId: "calculator",
|
|
5610
|
+
operation: n.moduleImportOperation,
|
|
5611
|
+
backend: n.backend
|
|
5612
|
+
});
|
|
5613
|
+
let i;
|
|
5614
|
+
try {
|
|
5615
|
+
i = await n.loadProvider(), await this.emitTelemetry(e, "pie-tool-library-load-success", {
|
|
5616
|
+
toolId: "calculator",
|
|
5617
|
+
operation: n.moduleImportOperation,
|
|
5618
|
+
backend: n.backend,
|
|
5619
|
+
duration: Date.now() - r
|
|
5620
|
+
});
|
|
5621
|
+
} catch (t) {
|
|
5622
|
+
throw await this.emitTelemetry(e, "pie-tool-library-load-error", {
|
|
5623
|
+
toolId: "calculator",
|
|
5624
|
+
operation: n.moduleImportOperation,
|
|
5625
|
+
backend: n.backend,
|
|
5626
|
+
duration: Date.now() - r,
|
|
5627
|
+
errorType: "ToolLibraryLoadError",
|
|
5628
|
+
message: t instanceof Error ? t.message : String(t)
|
|
5629
|
+
}), Error(n.initializationErrorMessage, { cause: t });
|
|
5630
|
+
}
|
|
5631
|
+
if (t !== this.lifecycleGeneration) throw Error(`${this.providerName} initialization was cancelled`);
|
|
5632
|
+
let a = new i();
|
|
5633
|
+
try {
|
|
5634
|
+
if (await a.initialize(e), t !== this.lifecycleGeneration) throw Error(`${this.providerName} initialization was cancelled`);
|
|
5635
|
+
this.calculatorProvider = a;
|
|
5636
|
+
} catch (e) {
|
|
5637
|
+
throw a.destroy(), Error(n.initializationErrorMessage, { cause: e });
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5640
|
+
async createInstance() {
|
|
5641
|
+
if (!this.calculatorProvider) throw Error(`[${this.providerName}] Provider not initialized. Call initialize() first.`);
|
|
5642
|
+
return this.calculatorProvider;
|
|
5643
|
+
}
|
|
5644
|
+
isReady() {
|
|
5645
|
+
return this.calculatorProvider !== null;
|
|
5646
|
+
}
|
|
5647
|
+
destroy() {
|
|
5648
|
+
this.lifecycleGeneration += 1, this.initializationPromise = null, this.calculatorProvider?.destroy(), this.calculatorProvider = null;
|
|
5649
|
+
}
|
|
5650
|
+
}, Qi = class extends Zi {
|
|
5651
|
+
providerId = "cortex-calculator";
|
|
5652
|
+
providerName = "PIE Open-Source Calculator";
|
|
5653
|
+
version = "1";
|
|
5654
|
+
requiresAuth = !1;
|
|
5655
|
+
getDefinition() {
|
|
5656
|
+
return {
|
|
5657
|
+
backend: "cortex",
|
|
5658
|
+
moduleImportOperation: "cortex-provider-module-import",
|
|
5659
|
+
loadProvider: async () => (await import("./pie-assessment-toolkit-DJfg6laX.js")).CortexCalculatorProvider,
|
|
5660
|
+
initializationErrorMessage: "Failed to initialize the PIE open-source calculator provider. Confirm that this browser supports module workers and that the bundled worker assets are available."
|
|
5661
|
+
};
|
|
5662
|
+
}
|
|
5663
|
+
getCapabilities() {
|
|
5664
|
+
return {
|
|
5665
|
+
supportsOffline: !0,
|
|
5666
|
+
requiresAuth: !1,
|
|
5667
|
+
maxInstances: null,
|
|
5668
|
+
features: {
|
|
5669
|
+
basic: !0,
|
|
5670
|
+
scientific: !0,
|
|
5671
|
+
graphing: !0,
|
|
5672
|
+
fourFunction: !0
|
|
5673
|
+
}
|
|
5674
|
+
};
|
|
5675
|
+
}
|
|
5676
|
+
}, $i = class extends Zi {
|
|
5677
|
+
providerId = "geogebra-calculator";
|
|
5678
|
+
providerName = "GeoGebra Calculator";
|
|
5679
|
+
version = "6";
|
|
5680
|
+
requiresAuth = !1;
|
|
5681
|
+
getDefinition() {
|
|
5682
|
+
return {
|
|
5683
|
+
backend: "geogebra",
|
|
5684
|
+
moduleImportOperation: "geogebra-provider-module-import",
|
|
5685
|
+
loadProvider: async () => (await import("./pie-assessment-toolkit-Cruxm385.js")).GeoGebraCalculatorProvider,
|
|
5686
|
+
initializationErrorMessage: "Failed to initialize GeoGebra calculator provider. Confirm that the deployment may load GeoGebra and that its script URL is reachable."
|
|
5687
|
+
};
|
|
5688
|
+
}
|
|
5689
|
+
getCapabilities() {
|
|
5690
|
+
return {
|
|
5691
|
+
supportsOffline: !1,
|
|
5692
|
+
requiresAuth: !1,
|
|
5693
|
+
maxInstances: null,
|
|
5694
|
+
features: {
|
|
5695
|
+
basic: !0,
|
|
5696
|
+
scientific: !0,
|
|
5697
|
+
graphing: !0,
|
|
5698
|
+
fourFunction: !1
|
|
5699
|
+
}
|
|
5700
|
+
};
|
|
5701
|
+
}
|
|
5702
|
+
}, ea = (e) => `No assessment is bound, so no policy source could grant "${e}"`;
|
|
5703
|
+
function ta(e, t, n, r) {
|
|
5577
5704
|
return {
|
|
5578
5705
|
featureId: e,
|
|
5579
5706
|
granted: !1,
|
|
@@ -5586,7 +5713,7 @@ function Zi(e, t, n, r) {
|
|
|
5586
5713
|
assessmentBound: r.assessmentBound
|
|
5587
5714
|
};
|
|
5588
5715
|
}
|
|
5589
|
-
function
|
|
5716
|
+
function na(e, t, n) {
|
|
5590
5717
|
let r = t.decisions[0], i = Array.from(t.perToolFlags.values())[0], a = r?.action === "enable", o = r?.reason ?? `Feature "${e}" not configured`;
|
|
5591
5718
|
return {
|
|
5592
5719
|
featureId: e,
|
|
@@ -5595,15 +5722,15 @@ function Qi(e, t, n) {
|
|
|
5595
5722
|
rule: r?.rule ?? "pnp-support",
|
|
5596
5723
|
precedence: r?.precedence ?? 6,
|
|
5597
5724
|
sourceType: r?.sourceType ?? "system",
|
|
5598
|
-
reason: n.assessmentBound || a ? o :
|
|
5725
|
+
reason: n.assessmentBound || a ? o : ea(e),
|
|
5599
5726
|
required: !!i?.required,
|
|
5600
5727
|
parameters: i?.settings,
|
|
5601
5728
|
assessmentBound: n.assessmentBound
|
|
5602
5729
|
};
|
|
5603
5730
|
}
|
|
5604
5731
|
//#endregion
|
|
5605
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5606
|
-
var
|
|
5732
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/core/provenance.js
|
|
5733
|
+
var ra = class {
|
|
5607
5734
|
provenance;
|
|
5608
5735
|
stepCounter = 0;
|
|
5609
5736
|
constructor(e) {
|
|
@@ -5713,12 +5840,12 @@ var $i = class {
|
|
|
5713
5840
|
return this;
|
|
5714
5841
|
}
|
|
5715
5842
|
build() {
|
|
5716
|
-
for (let e of this.provenance.features.values()) e.explanation =
|
|
5843
|
+
for (let e of this.provenance.features.values()) e.explanation = ia(e);
|
|
5717
5844
|
for (let e of this.provenance.features.values()) this.provenance.summary.totalFeatures++, e.finalState === "enabled" ? this.provenance.summary.enabled++ : e.finalState === "blocked" ? this.provenance.summary.blocked++ : this.provenance.summary.notConfigured++;
|
|
5718
5845
|
return this.provenance;
|
|
5719
5846
|
}
|
|
5720
5847
|
};
|
|
5721
|
-
function
|
|
5848
|
+
function ia(e) {
|
|
5722
5849
|
if (!e.winningDecision) {
|
|
5723
5850
|
if (e.finalState === "advisory-only") {
|
|
5724
5851
|
let t = e.allDecisions.find((e) => e.action === "advisory");
|
|
@@ -5736,9 +5863,9 @@ function ea(e) {
|
|
|
5736
5863
|
return r;
|
|
5737
5864
|
}
|
|
5738
5865
|
//#endregion
|
|
5739
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5740
|
-
function
|
|
5741
|
-
let { request: t, tools: n, pnpPolicy: r, customSources: i, contextId: a } = e, o = new
|
|
5866
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/core/compose-decision.js
|
|
5867
|
+
function aa(e) {
|
|
5868
|
+
let { request: t, tools: n, pnpPolicy: r, customSources: i, contextId: a } = e, o = new ra(a);
|
|
5742
5869
|
o.addSource("host", {
|
|
5743
5870
|
id: t.scope.scopeId,
|
|
5744
5871
|
name: `${t.level}:${t.scope.scopeId}`,
|
|
@@ -5802,11 +5929,18 @@ function ta(e) {
|
|
|
5802
5929
|
reason: e.reason,
|
|
5803
5930
|
value: e.value
|
|
5804
5931
|
});
|
|
5932
|
+
for (let e of m.unmappedSupportIds) d.push({
|
|
5933
|
+
code: "tool-policy.unknownSupportId",
|
|
5934
|
+
level: t.level,
|
|
5935
|
+
toolId: e,
|
|
5936
|
+
message: `No registered tool claims PNP support id "${e}"; it was carried through as a feature id and matched nothing. Expected an AfA 3.0 / QTI 3.0 access feature id.`,
|
|
5937
|
+
source: "pnp.pnp-support"
|
|
5938
|
+
});
|
|
5805
5939
|
u = u.filter((e) => !m.blockedToolIds.has(e));
|
|
5806
5940
|
for (let e of Array.from(f.keys())) m.blockedToolIds.has(e) && f.delete(e);
|
|
5807
5941
|
for (let e of m.mandatedToolIds) {
|
|
5808
5942
|
if (p.has(e)) continue;
|
|
5809
|
-
let r = m.perToolFlags.get(e)?.rule ?? "required-tool", i =
|
|
5943
|
+
let r = m.perToolFlags.get(e)?.rule ?? "required-tool", i = oa(e, {
|
|
5810
5944
|
placement: s,
|
|
5811
5945
|
allowed: c,
|
|
5812
5946
|
blocked: l,
|
|
@@ -5894,7 +6028,7 @@ function ta(e) {
|
|
|
5894
6028
|
provenance: o.build()
|
|
5895
6029
|
};
|
|
5896
6030
|
}
|
|
5897
|
-
function
|
|
6031
|
+
function oa(e, t) {
|
|
5898
6032
|
return t.placement.includes(e) ? t.providers?.[e]?.enabled === !1 ? {
|
|
5899
6033
|
hostRule: "provider-disabled",
|
|
5900
6034
|
hostValue: !1
|
|
@@ -5913,8 +6047,8 @@ function na(e, t) {
|
|
|
5913
6047
|
};
|
|
5914
6048
|
}
|
|
5915
6049
|
//#endregion
|
|
5916
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5917
|
-
function
|
|
6050
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/core/pnp-policy-inputs.js
|
|
6051
|
+
function sa(e) {
|
|
5918
6052
|
if (!e) return !1;
|
|
5919
6053
|
let t = e.personalNeedsProfile;
|
|
5920
6054
|
if (t && (Array.isArray(t.supports) && t.supports.length > 0 || Array.isArray(t.prohibitedSupports) && t.prohibitedSupports.length > 0 || Array.isArray(t.activateAtInit) && t.activateAtInit.length > 0)) return !0;
|
|
@@ -5930,16 +6064,16 @@ function ra(e) {
|
|
|
5930
6064
|
}
|
|
5931
6065
|
return !1;
|
|
5932
6066
|
}
|
|
5933
|
-
function
|
|
6067
|
+
function ca(e) {
|
|
5934
6068
|
let t = e?.settings;
|
|
5935
6069
|
return t ? !!(Array.isArray(t.requiredTools) && t.requiredTools.length > 0 || Array.isArray(t.restrictedTools) && t.restrictedTools.length > 0 || t.toolParameters && typeof t.toolParameters == "object" && Object.keys(t.toolParameters).length > 0) : !1;
|
|
5936
6070
|
}
|
|
5937
|
-
function
|
|
5938
|
-
return
|
|
6071
|
+
function la(e) {
|
|
6072
|
+
return sa(e.assessment) || ca(e.currentItemRef) ? "on" : "off";
|
|
5939
6073
|
}
|
|
5940
6074
|
//#endregion
|
|
5941
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5942
|
-
var
|
|
6075
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/sources/PnpPolicySource.js
|
|
6076
|
+
var ua = class {
|
|
5943
6077
|
id = "pnp";
|
|
5944
6078
|
toolRegistry;
|
|
5945
6079
|
constructor(e) {
|
|
@@ -5961,6 +6095,7 @@ var oa = class {
|
|
|
5961
6095
|
mandatedToolIds: /* @__PURE__ */ new Set(),
|
|
5962
6096
|
perToolFlags: /* @__PURE__ */ new Map(),
|
|
5963
6097
|
decisions: [],
|
|
6098
|
+
unmappedSupportIds: /* @__PURE__ */ new Set(),
|
|
5964
6099
|
sources: {}
|
|
5965
6100
|
};
|
|
5966
6101
|
return (i?.districtPolicy || i?.testAdministration) && (o.sources.assessment = {
|
|
@@ -5988,7 +6123,7 @@ var oa = class {
|
|
|
5988
6123
|
}
|
|
5989
6124
|
resolveSupport(e, t, n) {
|
|
5990
6125
|
if (t.districtPolicy?.blockedTools?.includes(e)) {
|
|
5991
|
-
let r = this.mapSupportToToolId(e);
|
|
6126
|
+
let r = this.mapSupportToToolId(e, n);
|
|
5992
6127
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
5993
6128
|
precedence: 1,
|
|
5994
6129
|
rule: "district-block",
|
|
@@ -6001,7 +6136,7 @@ var oa = class {
|
|
|
6001
6136
|
return;
|
|
6002
6137
|
}
|
|
6003
6138
|
if (t.testAdmin?.toolOverrides?.[e] === !1) {
|
|
6004
|
-
let r = this.mapSupportToToolId(e);
|
|
6139
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6005
6140
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
6006
6141
|
precedence: 2,
|
|
6007
6142
|
rule: "test-admin-override",
|
|
@@ -6014,7 +6149,7 @@ var oa = class {
|
|
|
6014
6149
|
return;
|
|
6015
6150
|
}
|
|
6016
6151
|
if (t.itemSettings?.restrictedTools?.includes(e)) {
|
|
6017
|
-
let r = this.mapSupportToToolId(e);
|
|
6152
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6018
6153
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
6019
6154
|
precedence: 3,
|
|
6020
6155
|
rule: "item-restriction",
|
|
@@ -6027,7 +6162,7 @@ var oa = class {
|
|
|
6027
6162
|
return;
|
|
6028
6163
|
}
|
|
6029
6164
|
if (t.itemSettings?.requiredTools?.includes(e)) {
|
|
6030
|
-
let r = this.mapSupportToToolId(e);
|
|
6165
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6031
6166
|
n.mandatedToolIds.add(r), n.perToolFlags.set(r, {
|
|
6032
6167
|
required: !0,
|
|
6033
6168
|
alwaysAvailable: !1,
|
|
@@ -6046,7 +6181,7 @@ var oa = class {
|
|
|
6046
6181
|
return;
|
|
6047
6182
|
}
|
|
6048
6183
|
if (t.districtPolicy?.requiredTools?.includes(e)) {
|
|
6049
|
-
let r = this.mapSupportToToolId(e);
|
|
6184
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6050
6185
|
n.mandatedToolIds.add(r), n.perToolFlags.set(r, {
|
|
6051
6186
|
required: !0,
|
|
6052
6187
|
alwaysAvailable: !1,
|
|
@@ -6065,7 +6200,7 @@ var oa = class {
|
|
|
6065
6200
|
return;
|
|
6066
6201
|
}
|
|
6067
6202
|
if (t.pnp?.prohibitedSupports?.includes(e)) {
|
|
6068
|
-
let r = this.mapSupportToToolId(e);
|
|
6203
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6069
6204
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
6070
6205
|
precedence: 6,
|
|
6071
6206
|
rule: "pnp-prohibited",
|
|
@@ -6078,7 +6213,7 @@ var oa = class {
|
|
|
6078
6213
|
return;
|
|
6079
6214
|
}
|
|
6080
6215
|
if (t.pnp?.supports?.includes(e)) {
|
|
6081
|
-
let r = this.mapSupportToToolId(e);
|
|
6216
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6082
6217
|
n.perToolFlags.set(r, {
|
|
6083
6218
|
required: !1,
|
|
6084
6219
|
alwaysAvailable: !0,
|
|
@@ -6096,7 +6231,7 @@ var oa = class {
|
|
|
6096
6231
|
});
|
|
6097
6232
|
return;
|
|
6098
6233
|
}
|
|
6099
|
-
let r = this.mapSupportToToolId(e);
|
|
6234
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6100
6235
|
n.decisions.push({
|
|
6101
6236
|
precedence: 6,
|
|
6102
6237
|
rule: "pnp-support",
|
|
@@ -6107,14 +6242,14 @@ var oa = class {
|
|
|
6107
6242
|
value: { supportId: e }
|
|
6108
6243
|
});
|
|
6109
6244
|
}
|
|
6110
|
-
mapSupportToToolId(e) {
|
|
6111
|
-
let
|
|
6112
|
-
return
|
|
6245
|
+
mapSupportToToolId(e, t) {
|
|
6246
|
+
let n = this.toolRegistry.getToolsByPNPSupport(e);
|
|
6247
|
+
return n.size === 0 ? (this.toolRegistry.getAllTools().length > 0 && t.unmappedSupportIds.add(e), e) : Array.from(n)[0];
|
|
6113
6248
|
}
|
|
6114
6249
|
resolveToolSettings(e, t) {
|
|
6115
6250
|
return t.itemSettings?.toolParameters?.[e] ?? t.toolConfigs?.[e];
|
|
6116
6251
|
}
|
|
6117
|
-
},
|
|
6252
|
+
}, da = Ae({
|
|
6118
6253
|
policy: {
|
|
6119
6254
|
allowed: [],
|
|
6120
6255
|
blocked: []
|
|
@@ -6125,7 +6260,7 @@ var oa = class {
|
|
|
6125
6260
|
passage: []
|
|
6126
6261
|
},
|
|
6127
6262
|
providers: {}
|
|
6128
|
-
}),
|
|
6263
|
+
}), fa = class {
|
|
6129
6264
|
toolRegistry;
|
|
6130
6265
|
contextId;
|
|
6131
6266
|
pnpPolicySource;
|
|
@@ -6137,9 +6272,9 @@ var oa = class {
|
|
|
6137
6272
|
pnpEnforcement;
|
|
6138
6273
|
disposed = !1;
|
|
6139
6274
|
constructor(e) {
|
|
6140
|
-
this.toolRegistry = e.toolRegistry, this.contextId = e.contextId ?? "tool-policy", this.pnpPolicySource = new
|
|
6275
|
+
this.toolRegistry = e.toolRegistry, this.contextId = e.contextId ?? "tool-policy", this.pnpPolicySource = new ua(this.toolRegistry), this.customSources = e.customSources ? [...e.customSources] : [];
|
|
6141
6276
|
let t = e.inputs ?? {};
|
|
6142
|
-
this.tools = t.tools ??
|
|
6277
|
+
this.tools = t.tools ?? da, this.assessment = t.assessment ?? null, this.currentItemRef = t.currentItemRef ?? null, this.pnpEnforcement = t.pnpEnforcement ?? la({
|
|
6143
6278
|
assessment: this.assessment,
|
|
6144
6279
|
currentItemRef: this.currentItemRef
|
|
6145
6280
|
});
|
|
@@ -6147,7 +6282,7 @@ var oa = class {
|
|
|
6147
6282
|
decide(e) {
|
|
6148
6283
|
this.assertNotDisposed();
|
|
6149
6284
|
let t = e.scope.scopeId ? `${this.contextId}:${e.level}:${e.scope.scopeId}` : `${this.contextId}:${e.level}`;
|
|
6150
|
-
return
|
|
6285
|
+
return aa({
|
|
6151
6286
|
request: e,
|
|
6152
6287
|
tools: this.tools,
|
|
6153
6288
|
pnpPolicy: {
|
|
@@ -6161,16 +6296,16 @@ var oa = class {
|
|
|
6161
6296
|
});
|
|
6162
6297
|
}
|
|
6163
6298
|
decideFeature(e) {
|
|
6164
|
-
return this.assertNotDisposed(), this.hostFeatureGate(e) ||
|
|
6299
|
+
return this.assertNotDisposed(), this.hostFeatureGate(e) || na(e, this.pnpPolicySource.resolveFeature(e, {
|
|
6165
6300
|
assessment: this.assessment ?? void 0,
|
|
6166
6301
|
currentItemRef: this.currentItemRef ?? void 0
|
|
6167
6302
|
}), { assessmentBound: this.assessment !== null });
|
|
6168
6303
|
}
|
|
6169
6304
|
hostFeatureGate(e) {
|
|
6170
6305
|
let t = { assessmentBound: this.assessment !== null }, n = w(this.tools.policy.blocked);
|
|
6171
|
-
if (n.includes(e)) return
|
|
6306
|
+
if (n.includes(e)) return ta(e, "host-blocked", n, t);
|
|
6172
6307
|
let r = w(this.tools.policy.allowed);
|
|
6173
|
-
return r.length > 0 && !r.includes(e) ?
|
|
6308
|
+
return r.length > 0 && !r.includes(e) ? ta(e, "host-allowlist", r, t) : null;
|
|
6174
6309
|
}
|
|
6175
6310
|
getVisibleToolIds(e, t) {
|
|
6176
6311
|
return this.decide({
|
|
@@ -6185,7 +6320,7 @@ var oa = class {
|
|
|
6185
6320
|
this.assertNotDisposed();
|
|
6186
6321
|
let t = !1, n = !1;
|
|
6187
6322
|
if ("tools" in e) {
|
|
6188
|
-
let n = e.tools ??
|
|
6323
|
+
let n = e.tools ?? da;
|
|
6189
6324
|
Object.is(this.tools, n) || (this.tools = n, t = !0);
|
|
6190
6325
|
}
|
|
6191
6326
|
if ("assessment" in e) {
|
|
@@ -6243,7 +6378,15 @@ var oa = class {
|
|
|
6243
6378
|
assertNotDisposed() {
|
|
6244
6379
|
if (this.disposed) throw Error("ToolPolicyEngine has been disposed.");
|
|
6245
6380
|
}
|
|
6246
|
-
},
|
|
6381
|
+
}, Q = class extends Error {
|
|
6382
|
+
constructor() {
|
|
6383
|
+
super("ToolkitCoordinator has been disposed."), this.name = "ToolkitCoordinatorDisposedError";
|
|
6384
|
+
}
|
|
6385
|
+
}, pa = class extends Error {
|
|
6386
|
+
constructor() {
|
|
6387
|
+
super("Section controller acquisition was retired during initialization."), this.name = "SectionControllerRetiredError";
|
|
6388
|
+
}
|
|
6389
|
+
}, $ = (e) => !!e && typeof e == "object" && !Array.isArray(e), ma = (e, t, n) => {
|
|
6247
6390
|
let r = {
|
|
6248
6391
|
...t,
|
|
6249
6392
|
...n
|
|
@@ -6255,14 +6398,14 @@ var oa = class {
|
|
|
6255
6398
|
...t.settings.mathSpeech,
|
|
6256
6399
|
...n.settings.mathSpeech
|
|
6257
6400
|
})), r;
|
|
6258
|
-
},
|
|
6401
|
+
}, ha = [
|
|
6259
6402
|
"item-selected",
|
|
6260
6403
|
"item-session-data-changed",
|
|
6261
6404
|
"item-session-meta-changed",
|
|
6262
6405
|
"item-complete-changed",
|
|
6263
6406
|
"content-loaded",
|
|
6264
6407
|
"item-player-error"
|
|
6265
|
-
],
|
|
6408
|
+
], ga = [
|
|
6266
6409
|
"section-navigation-change",
|
|
6267
6410
|
"section-session-applied",
|
|
6268
6411
|
"section-loading-complete",
|
|
@@ -6271,7 +6414,7 @@ var oa = class {
|
|
|
6271
6414
|
"timed-media-cue-changed",
|
|
6272
6415
|
"timed-media-policy-degraded",
|
|
6273
6416
|
"timed-media-invalid"
|
|
6274
|
-
],
|
|
6417
|
+
], _a = class e {
|
|
6275
6418
|
assessmentId;
|
|
6276
6419
|
config;
|
|
6277
6420
|
ttsService;
|
|
@@ -6293,10 +6436,11 @@ var oa = class {
|
|
|
6293
6436
|
toolRegistry;
|
|
6294
6437
|
toolContextResolvers = /* @__PURE__ */ new Map();
|
|
6295
6438
|
toolContextResolverChangeListeners = /* @__PURE__ */ new Set();
|
|
6296
|
-
toolRequests = new
|
|
6439
|
+
toolRequests = new Ie();
|
|
6297
6440
|
sectionControllers = /* @__PURE__ */ new Map();
|
|
6298
6441
|
sectionControllerKeys = /* @__PURE__ */ new Map();
|
|
6299
|
-
|
|
6442
|
+
sectionControllerInitEntries = /* @__PURE__ */ new Map();
|
|
6443
|
+
sectionControllerDisposePromises = /* @__PURE__ */ new Map();
|
|
6300
6444
|
sectionPersistenceStrategies = /* @__PURE__ */ new Map();
|
|
6301
6445
|
sectionControllerLifecycleListeners = /* @__PURE__ */ new Set();
|
|
6302
6446
|
activeSubscriptions = /* @__PURE__ */ new Map();
|
|
@@ -6305,13 +6449,15 @@ var oa = class {
|
|
|
6305
6449
|
telemetryListeners = /* @__PURE__ */ new Set();
|
|
6306
6450
|
frameworkErrorBus;
|
|
6307
6451
|
ownsFrameworkErrorBus;
|
|
6452
|
+
frameworkErrorHookUnsubscribe = null;
|
|
6453
|
+
disposePromise = null;
|
|
6308
6454
|
policyEngine;
|
|
6309
6455
|
pnpEnforcementOverride = null;
|
|
6310
6456
|
boundAssessment = null;
|
|
6311
6457
|
boundCurrentItemRef = null;
|
|
6312
6458
|
reportedUnboundFeaturePolicy = !1;
|
|
6313
6459
|
static resolveConfig(e) {
|
|
6314
|
-
let t =
|
|
6460
|
+
let t = He(e.toolConfigStrictness), n = e.toolRegistry ?? new Fe(), r = e.deferToolConfigValidation === !0 ? Ae(e.tools) : D(e.tools, {
|
|
6315
6461
|
strictness: t,
|
|
6316
6462
|
source: "ToolkitCoordinator.init",
|
|
6317
6463
|
toolRegistry: n
|
|
@@ -6343,7 +6489,7 @@ var oa = class {
|
|
|
6343
6489
|
constructor(t) {
|
|
6344
6490
|
if (!t.assessmentId) throw Error("ToolkitCoordinator requires assessmentId in config");
|
|
6345
6491
|
let n = e.resolveConfig(t);
|
|
6346
|
-
this.assessmentId = n.assessmentId, this.config = n, this.toolRegistry = n.toolRegistry ?? new
|
|
6492
|
+
this.assessmentId = n.assessmentId, this.config = n, this.toolRegistry = n.toolRegistry ?? new Fe(), this.installToolContextResolvers(n.toolContextResolvers), this.hooks = n.hooks ?? {}, this.lazyInit = t.lazyInit === !0, this.pnpEnforcementOverride = this.resolveConfiguredPnpEnforcement(), this.frameworkErrorBus = t.frameworkErrorBus ?? new ut(), this.ownsFrameworkErrorBus = !t.frameworkErrorBus, this.subscribeFrameworkErrorHookAdapters(), this.toolCoordinator = new lt(), this.highlightCoordinator = new be(), this.elementToolStateStore = new ve(), this.catalogResolver = new _e(n.accessibility?.catalogs || [], n.accessibility?.language || "en-US"), this.toolProviderRegistry = new Xi(), this._registerToolProviders(), this.ttsService = new Ai(), this.setupStatePersistenceHooks(), this.policyEngine = new fa({
|
|
6347
6493
|
toolRegistry: this.toolRegistry,
|
|
6348
6494
|
contextId: `toolkit-coordinator:${this.assessmentId}`,
|
|
6349
6495
|
inputs: {
|
|
@@ -6353,11 +6499,14 @@ var oa = class {
|
|
|
6353
6499
|
pnpEnforcement: this.resolveEffectivePnpEnforcement()
|
|
6354
6500
|
}
|
|
6355
6501
|
}), this.lazyInit || this.waitUntilReady().catch((e) => {
|
|
6356
|
-
console.error("[ToolkitCoordinator] Failed eager initialization:", e), this.handleError(e, { phase: "coordinator-ready" });
|
|
6502
|
+
e instanceof Q || (console.error("[ToolkitCoordinator] Failed eager initialization:", e), this.handleError(e, { phase: "coordinator-ready" }));
|
|
6357
6503
|
});
|
|
6358
6504
|
}
|
|
6505
|
+
assertNotDisposed() {
|
|
6506
|
+
if (this.disposePromise !== null) throw new Q();
|
|
6507
|
+
}
|
|
6359
6508
|
subscribeFrameworkErrorHookAdapters() {
|
|
6360
|
-
this.frameworkErrorBus.subscribeFrameworkErrors((e) => {
|
|
6509
|
+
this.frameworkErrorHookUnsubscribe = this.frameworkErrorBus.subscribeFrameworkErrors((e) => {
|
|
6361
6510
|
let t = this.hooks.onFrameworkError;
|
|
6362
6511
|
if (t) try {
|
|
6363
6512
|
t(e);
|
|
@@ -6390,7 +6539,7 @@ var oa = class {
|
|
|
6390
6539
|
}
|
|
6391
6540
|
}
|
|
6392
6541
|
handleError(e, t) {
|
|
6393
|
-
let n =
|
|
6542
|
+
let n = Be({
|
|
6394
6543
|
error: e,
|
|
6395
6544
|
context: t
|
|
6396
6545
|
});
|
|
@@ -6453,8 +6602,9 @@ var oa = class {
|
|
|
6453
6602
|
let e = this.hooks.loadToolState;
|
|
6454
6603
|
if (e) try {
|
|
6455
6604
|
let t = await e();
|
|
6456
|
-
t && typeof t == "object" && this.elementToolStateStore.loadState(t), this.stateLoaded = !0, await this.emitTelemetry("pie-toolkit-tool-state-loaded", { hasState: !!t });
|
|
6605
|
+
this.assertNotDisposed(), t && typeof t == "object" && this.elementToolStateStore.loadState(t), this.stateLoaded = !0, await this.emitTelemetry("pie-toolkit-tool-state-loaded", { hasState: !!t });
|
|
6457
6606
|
} catch (e) {
|
|
6607
|
+
if (e instanceof Q) throw e;
|
|
6458
6608
|
this.handleError(e, { phase: "state-load" });
|
|
6459
6609
|
}
|
|
6460
6610
|
})().finally(() => {
|
|
@@ -6528,16 +6678,20 @@ var oa = class {
|
|
|
6528
6678
|
}
|
|
6529
6679
|
}
|
|
6530
6680
|
async ensureProviderReady(e) {
|
|
6681
|
+
this.assertNotDisposed();
|
|
6531
6682
|
let t = this.providerInitPromises.get(e);
|
|
6532
6683
|
if (t) return t;
|
|
6533
6684
|
let n = (async () => {
|
|
6534
|
-
let t = await this.toolProviderRegistry.getProvider(e, !1)
|
|
6685
|
+
let t = await this.toolProviderRegistry.getProvider(e, !1);
|
|
6686
|
+
this.assertNotDisposed();
|
|
6687
|
+
let n = {
|
|
6535
6688
|
providerId: e,
|
|
6536
6689
|
providerName: t.providerName
|
|
6537
6690
|
};
|
|
6538
6691
|
try {
|
|
6539
|
-
return await this.hooks.onProviderInitStart?.(e, n), await this.toolProviderRegistry.initialize(e), await this.hooks.onProviderReady?.(e, n), await this.emitTelemetry("pie-toolkit-provider-ready", { providerId: e }), t;
|
|
6692
|
+
return await this.hooks.onProviderInitStart?.(e, n), this.assertNotDisposed(), await this.toolProviderRegistry.initialize(e), this.assertNotDisposed(), await this.hooks.onProviderReady?.(e, n), this.assertNotDisposed(), await this.emitTelemetry("pie-toolkit-provider-ready", { providerId: e }), this.assertNotDisposed(), t;
|
|
6540
6693
|
} catch (t) {
|
|
6694
|
+
if (t instanceof Q) throw t;
|
|
6541
6695
|
let n = t instanceof Error ? t : Error(String(t));
|
|
6542
6696
|
throw this.handleError(n, {
|
|
6543
6697
|
phase: "provider-init",
|
|
@@ -6550,7 +6704,7 @@ var oa = class {
|
|
|
6550
6704
|
return this.providerInitPromises.set(e, n), n;
|
|
6551
6705
|
}
|
|
6552
6706
|
setHooks(e) {
|
|
6553
|
-
Object.assign(this.hooks, e), this.setupStatePersistenceHooks(), e.onCoordinatorReady && this.isReady() && Promise.resolve(e.onCoordinatorReady(this)).catch((e) => {
|
|
6707
|
+
Object.assign(this.hooks, e), this.setupStatePersistenceHooks(), this.disposePromise === null && e.onCoordinatorReady && this.isReady() && Promise.resolve(e.onCoordinatorReady(this)).catch((e) => {
|
|
6554
6708
|
this.handleError(e, { phase: "coordinator-ready" });
|
|
6555
6709
|
});
|
|
6556
6710
|
}
|
|
@@ -6672,14 +6826,14 @@ var oa = class {
|
|
|
6672
6826
|
}
|
|
6673
6827
|
subscribeItemEvents(e) {
|
|
6674
6828
|
return this.subscribeSectionEvents({
|
|
6675
|
-
eventTypes: e.eventTypes ||
|
|
6829
|
+
eventTypes: e.eventTypes || ha,
|
|
6676
6830
|
itemIds: e.itemIds,
|
|
6677
6831
|
listener: e.listener
|
|
6678
6832
|
});
|
|
6679
6833
|
}
|
|
6680
6834
|
subscribeSectionLifecycleEvents(e) {
|
|
6681
6835
|
return this.subscribeSectionEvents({
|
|
6682
|
-
eventTypes: e.eventTypes ||
|
|
6836
|
+
eventTypes: e.eventTypes || ga,
|
|
6683
6837
|
listener: e.listener
|
|
6684
6838
|
});
|
|
6685
6839
|
}
|
|
@@ -6689,6 +6843,7 @@ var oa = class {
|
|
|
6689
6843
|
};
|
|
6690
6844
|
}
|
|
6691
6845
|
async getOrCreateSectionController(e) {
|
|
6846
|
+
if (this.disposePromise !== null) throw new Q();
|
|
6692
6847
|
let t = {
|
|
6693
6848
|
assessmentId: this.assessmentId,
|
|
6694
6849
|
sectionId: e.sectionId,
|
|
@@ -6701,23 +6856,36 @@ var oa = class {
|
|
|
6701
6856
|
input: e.input,
|
|
6702
6857
|
updateExisting: e.updateExisting
|
|
6703
6858
|
});
|
|
6704
|
-
if (r)
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6859
|
+
if (r) {
|
|
6860
|
+
if (this.disposePromise !== null) throw new Q();
|
|
6861
|
+
return r;
|
|
6862
|
+
}
|
|
6863
|
+
let i = this.sectionControllerDisposePromises.get(n);
|
|
6864
|
+
if (i && await Promise.allSettled([i]), this.disposePromise !== null) throw new Q();
|
|
6865
|
+
let a = this.sectionControllerInitEntries.get(n);
|
|
6866
|
+
if (a) return a.promise;
|
|
6867
|
+
let o = {
|
|
6868
|
+
retired: !1,
|
|
6869
|
+
candidateClaimed: !1
|
|
6870
|
+
}, s = this.initializeNewSectionController({
|
|
6708
6871
|
args: e,
|
|
6709
6872
|
key: t,
|
|
6710
|
-
mapKey: n
|
|
6873
|
+
mapKey: n,
|
|
6874
|
+
token: o
|
|
6711
6875
|
}).catch((t) => {
|
|
6712
6876
|
throw this.handleSectionControllerInitError(t, e), t;
|
|
6713
6877
|
}).finally(() => {
|
|
6714
|
-
this.
|
|
6878
|
+
this.sectionControllerInitEntries.get(n)?.token === o && this.sectionControllerInitEntries.delete(n);
|
|
6715
6879
|
});
|
|
6716
|
-
return this.
|
|
6880
|
+
return this.sectionControllerInitEntries.set(n, {
|
|
6881
|
+
key: t,
|
|
6882
|
+
token: o,
|
|
6883
|
+
promise: s
|
|
6884
|
+
}), s;
|
|
6717
6885
|
}
|
|
6718
6886
|
async resolveExistingSectionController(e) {
|
|
6719
6887
|
let t = this.sectionControllers.get(e.mapKey);
|
|
6720
|
-
if (t
|
|
6888
|
+
if (t && (this.sectionControllerKeys.set(e.mapKey, e.key), e.updateExisting !== !1 && await t.updateInput?.(e.input), this.sectionControllers.get(e.mapKey) === t)) return this.setActiveCohortIfLatestRequest(e.mapKey), t;
|
|
6721
6889
|
}
|
|
6722
6890
|
createSectionControllerContext(e) {
|
|
6723
6891
|
return {
|
|
@@ -6730,30 +6898,70 @@ var oa = class {
|
|
|
6730
6898
|
let t = this.createSectionControllerContext({
|
|
6731
6899
|
key: e.key,
|
|
6732
6900
|
input: e.args.input
|
|
6733
|
-
}), n = await this.resolveSectionPersistence(t)
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
context: t
|
|
6737
|
-
}), await i.initialize?.(e.args.input), await i.hydrate?.(), await this.finalizeSectionControllerReady({
|
|
6901
|
+
}), n = await this.resolveSectionPersistence(t);
|
|
6902
|
+
if (this.disposePromise !== null || e.token.retired) throw this.sectionPersistenceStrategies.get(e.mapKey) === n && this.sectionPersistenceStrategies.delete(e.mapKey), this.createSectionControllerRetirementError();
|
|
6903
|
+
let r = { createDefaultController: e.args.createDefaultController }, i = await this.hooks.createSectionController?.(t, r) ?? await r.createDefaultController(), a = {
|
|
6738
6904
|
mapKey: e.mapKey,
|
|
6739
6905
|
key: e.key,
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6906
|
+
controller: i,
|
|
6907
|
+
persistence: n,
|
|
6908
|
+
token: e.token
|
|
6909
|
+
};
|
|
6910
|
+
try {
|
|
6911
|
+
return await this.retireUnpublishedSectionControllerIfNeeded(a), await i.configureSessionPersistence?.({
|
|
6912
|
+
strategy: n,
|
|
6913
|
+
context: t
|
|
6914
|
+
}), await this.retireUnpublishedSectionControllerIfNeeded(a), await i.initialize?.(e.args.input), await this.retireUnpublishedSectionControllerIfNeeded(a), await i.hydrate?.(), await this.finalizeSectionControllerReady({
|
|
6915
|
+
...a,
|
|
6916
|
+
context: t
|
|
6917
|
+
}), i;
|
|
6918
|
+
} catch (e) {
|
|
6919
|
+
throw await this.cleanupUnpublishedSectionController(a), e;
|
|
6920
|
+
}
|
|
6921
|
+
}
|
|
6922
|
+
createSectionControllerRetirementError() {
|
|
6923
|
+
return this.disposePromise === null ? new pa() : new Q();
|
|
6924
|
+
}
|
|
6925
|
+
async retireUnpublishedSectionControllerIfNeeded(e) {
|
|
6926
|
+
if (!(this.disposePromise === null && !e.token.retired)) throw await this.cleanupUnpublishedSectionController(e), this.createSectionControllerRetirementError();
|
|
6927
|
+
}
|
|
6928
|
+
async cleanupUnpublishedSectionController(e) {
|
|
6929
|
+
if (!e.token.candidateClaimed) {
|
|
6930
|
+
e.token.candidateClaimed = !0;
|
|
6931
|
+
try {
|
|
6932
|
+
await e.controller.dispose?.();
|
|
6933
|
+
} catch (t) {
|
|
6934
|
+
this.handleError(t, {
|
|
6935
|
+
phase: "section-controller-dispose",
|
|
6936
|
+
details: {
|
|
6937
|
+
sectionId: e.key.sectionId,
|
|
6938
|
+
attemptId: e.key.attemptId
|
|
6939
|
+
}
|
|
6940
|
+
});
|
|
6941
|
+
} finally {
|
|
6942
|
+
this.sectionPersistenceStrategies.get(e.mapKey) === e.persistence && this.sectionPersistenceStrategies.delete(e.mapKey);
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6945
|
+
}
|
|
6946
|
+
retirePublishedSectionControllerIfNeeded(e) {
|
|
6947
|
+
if (this.disposePromise !== null && !e.token.retired && this.disposeSectionController({
|
|
6948
|
+
sectionId: e.key.sectionId,
|
|
6949
|
+
attemptId: e.key.attemptId
|
|
6950
|
+
}), e.token.retired) throw this.createSectionControllerRetirementError();
|
|
6743
6951
|
}
|
|
6744
6952
|
async finalizeSectionControllerReady(e) {
|
|
6745
|
-
this.sectionControllers.set(e.mapKey, e.controller), this.sectionControllerKeys.set(e.mapKey, e.key), this.setActiveCohortIfLatestRequest(e.mapKey), this.emitSectionControllerLifecycle({
|
|
6953
|
+
await this.retireUnpublishedSectionControllerIfNeeded(e), this.sectionControllers.set(e.mapKey, e.controller), this.sectionControllerKeys.set(e.mapKey, e.key), e.token.candidateClaimed = !0, this.setActiveCohortIfLatestRequest(e.mapKey), this.emitSectionControllerLifecycle({
|
|
6746
6954
|
type: "ready",
|
|
6747
6955
|
key: e.key,
|
|
6748
6956
|
controller: e.controller
|
|
6749
|
-
}), await this.hooks.onSectionControllerReady?.(e.context, e.controller), await this.emitTelemetry("pie-toolkit-section-controller-ready", {
|
|
6957
|
+
}), await this.hooks.onSectionControllerReady?.(e.context, e.controller), this.retirePublishedSectionControllerIfNeeded(e), await this.emitTelemetry("pie-toolkit-section-controller-ready", {
|
|
6750
6958
|
assessmentId: e.key.assessmentId,
|
|
6751
6959
|
sectionId: e.key.sectionId,
|
|
6752
6960
|
attemptId: e.key.attemptId
|
|
6753
|
-
});
|
|
6961
|
+
}), this.retirePublishedSectionControllerIfNeeded(e);
|
|
6754
6962
|
}
|
|
6755
6963
|
handleSectionControllerInitError(e, t) {
|
|
6756
|
-
this.handleError(e, {
|
|
6964
|
+
e instanceof Q || e instanceof pa || this.handleError(e, {
|
|
6757
6965
|
phase: "section-controller-init",
|
|
6758
6966
|
details: {
|
|
6759
6967
|
sectionId: t.sectionId,
|
|
@@ -6761,57 +6969,126 @@ var oa = class {
|
|
|
6761
6969
|
}
|
|
6762
6970
|
});
|
|
6763
6971
|
}
|
|
6764
|
-
|
|
6972
|
+
disposeSectionController(e) {
|
|
6765
6973
|
let t = {
|
|
6766
6974
|
assessmentId: this.assessmentId,
|
|
6767
6975
|
sectionId: e.sectionId,
|
|
6768
6976
|
attemptId: e.attemptId
|
|
6769
|
-
}, n = this.getSectionControllerMapKey(t), r = this.
|
|
6770
|
-
|
|
6771
|
-
this.
|
|
6772
|
-
|
|
6977
|
+
}, n = this.getSectionControllerMapKey(t), r = this.sectionControllerInitEntries.get(n);
|
|
6978
|
+
r && (r.token.retired = !0);
|
|
6979
|
+
let i = this.sectionControllers.get(n);
|
|
6980
|
+
if (!i) {
|
|
6981
|
+
let e = this.sectionControllerDisposePromises.get(n);
|
|
6982
|
+
if (e) return e;
|
|
6983
|
+
if (!r) return Promise.resolve();
|
|
6984
|
+
let t = Promise.allSettled([r.promise]).then(() => void 0);
|
|
6985
|
+
return this.trackSectionControllerDisposal(n, t);
|
|
6986
|
+
}
|
|
6987
|
+
let a = this.sectionPersistenceStrategies.get(n);
|
|
6988
|
+
this.clearActiveCohortIfMatches(n), this.sectionControllers.get(n) === i && (this.sectionControllers.delete(n), this.sectionControllerKeys.delete(n), this.sectionPersistenceStrategies.delete(n), this.emitSectionControllerLifecycle({
|
|
6989
|
+
type: "disposed",
|
|
6990
|
+
key: t
|
|
6991
|
+
}));
|
|
6992
|
+
let o = this.createSectionControllerContext({
|
|
6773
6993
|
key: t,
|
|
6774
6994
|
input: void 0
|
|
6775
|
-
})
|
|
6995
|
+
}), s = this.disposeSectionControllerEntry({
|
|
6996
|
+
args: e,
|
|
6997
|
+
key: t,
|
|
6998
|
+
context: o,
|
|
6999
|
+
controller: i,
|
|
7000
|
+
persistenceStrategy: a
|
|
7001
|
+
}), c = r ? Promise.allSettled([r.promise]).then(() => s) : s;
|
|
7002
|
+
return this.trackSectionControllerDisposal(n, c);
|
|
7003
|
+
}
|
|
7004
|
+
trackSectionControllerDisposal(e, t) {
|
|
7005
|
+
this.sectionControllerDisposePromises.set(e, t);
|
|
7006
|
+
let n = () => {
|
|
7007
|
+
this.sectionControllerDisposePromises.get(e) === t && this.sectionControllerDisposePromises.delete(e);
|
|
7008
|
+
};
|
|
7009
|
+
return t.then(n, n), t;
|
|
7010
|
+
}
|
|
7011
|
+
async disposeSectionControllerEntry(e) {
|
|
6776
7012
|
try {
|
|
6777
7013
|
await this.runSectionControllerDisposePipeline({
|
|
6778
|
-
key:
|
|
6779
|
-
context:
|
|
6780
|
-
controller:
|
|
6781
|
-
persistBeforeDispose: e.persistBeforeDispose
|
|
7014
|
+
key: e.key,
|
|
7015
|
+
context: e.context,
|
|
7016
|
+
controller: e.controller,
|
|
7017
|
+
persistBeforeDispose: e.args.persistBeforeDispose
|
|
6782
7018
|
});
|
|
6783
7019
|
} catch (t) {
|
|
6784
7020
|
this.handleError(t, {
|
|
6785
7021
|
phase: "section-controller-dispose",
|
|
6786
7022
|
details: {
|
|
6787
|
-
sectionId: e.sectionId,
|
|
6788
|
-
attemptId: e.attemptId
|
|
7023
|
+
sectionId: e.args.sectionId,
|
|
7024
|
+
attemptId: e.args.attemptId
|
|
6789
7025
|
}
|
|
6790
7026
|
});
|
|
6791
7027
|
} finally {
|
|
6792
7028
|
await this.finalizeSectionControllerDispose({
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
clearPersistence: e.clearPersistence
|
|
7029
|
+
context: e.context,
|
|
7030
|
+
persistenceStrategy: e.persistenceStrategy,
|
|
7031
|
+
clearPersistence: e.args.clearPersistence
|
|
6797
7032
|
});
|
|
6798
7033
|
}
|
|
6799
7034
|
}
|
|
6800
7035
|
async runSectionControllerDisposePipeline(e) {
|
|
6801
|
-
|
|
7036
|
+
let t = [];
|
|
7037
|
+
if (e.persistBeforeDispose !== !1) try {
|
|
7038
|
+
await e.controller.persist?.();
|
|
7039
|
+
} catch (e) {
|
|
7040
|
+
t.push(e);
|
|
7041
|
+
}
|
|
7042
|
+
try {
|
|
7043
|
+
await e.controller.dispose?.();
|
|
7044
|
+
} catch (e) {
|
|
7045
|
+
t.push(e);
|
|
7046
|
+
}
|
|
7047
|
+
if (t.length === 1) throw t[0];
|
|
7048
|
+
if (t.length > 1) throw AggregateError(t, "Section controller persistence and disposal both failed.");
|
|
7049
|
+
await this.hooks.onSectionControllerDispose?.(e.context, e.controller), await this.emitTelemetry("pie-toolkit-section-controller-disposed", {
|
|
6802
7050
|
assessmentId: e.key.assessmentId,
|
|
6803
7051
|
sectionId: e.key.sectionId,
|
|
6804
7052
|
attemptId: e.key.attemptId
|
|
6805
7053
|
});
|
|
6806
7054
|
}
|
|
6807
7055
|
async finalizeSectionControllerDispose(e) {
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
7056
|
+
e.clearPersistence && await e.persistenceStrategy?.clearSession?.(e.context);
|
|
7057
|
+
}
|
|
7058
|
+
dispose() {
|
|
7059
|
+
return this.disposePromise ||= Promise.resolve().then(() => this.disposeOwnedResources()), this.disposePromise;
|
|
7060
|
+
}
|
|
7061
|
+
async disposeOwnedResources() {
|
|
7062
|
+
let e = [], t = async (t) => {
|
|
7063
|
+
try {
|
|
7064
|
+
await t();
|
|
7065
|
+
} catch (t) {
|
|
7066
|
+
e.push(t);
|
|
7067
|
+
}
|
|
7068
|
+
};
|
|
7069
|
+
await this.waitForAdmittedInitialization();
|
|
7070
|
+
let n = /* @__PURE__ */ new Map();
|
|
7071
|
+
for (let [e, t] of this.sectionControllerInitEntries) n.set(e, t.key);
|
|
7072
|
+
for (let [e, t] of this.sectionControllerKeys) n.set(e, t);
|
|
7073
|
+
for (let e of n.values()) this.disposeSectionController({
|
|
7074
|
+
sectionId: e.sectionId,
|
|
7075
|
+
attemptId: e.attemptId
|
|
7076
|
+
});
|
|
7077
|
+
await Promise.allSettled(Array.from(this.sectionControllerDisposePromises.values())), this.sectionControllers.clear(), this.sectionControllerKeys.clear(), this.sectionControllerInitEntries.clear(), this.sectionPersistenceStrategies.clear();
|
|
7078
|
+
for (let e of this.activeSubscriptions.values()) await t(() => e.unsubscribeCurrent?.()), e.unsubscribeCurrent = null;
|
|
7079
|
+
this.activeSubscriptions.clear(), this.activeCohortMapKey = null, this.latestRequestedActiveCohortMapKey = null, await t(() => this.ttsService.stop()), await t(() => this.toolProviderRegistry.destroy()), await t(() => this.highlightCoordinator.destroy());
|
|
7080
|
+
for (let e of this.toolCoordinator.getRegisteredTools()) await t(() => this.toolCoordinator.releaseTool(e));
|
|
7081
|
+
if (await t(() => this.catalogResolver.destroy()), await t(() => this.toolRequests.dispose()), await t(() => this.policyEngine.dispose()), this.toolContextResolvers.clear(), this.toolContextResolverChangeListeners.clear(), this.sectionControllerLifecycleListeners.clear(), this.telemetryListeners.clear(), this.frameworkErrorHookUnsubscribe?.(), this.frameworkErrorHookUnsubscribe = null, this.ownsFrameworkErrorBus && this.frameworkErrorBus.dispose(), e.length === 1) throw e[0];
|
|
7082
|
+
if (e.length > 1) throw AggregateError(e, "ToolkitCoordinator cleanup failed for multiple owned resources.");
|
|
7083
|
+
}
|
|
7084
|
+
async waitForAdmittedInitialization() {
|
|
7085
|
+
let e = /* @__PURE__ */ new Set();
|
|
7086
|
+
this.coordinatorReadyPromise && e.add(this.coordinatorReadyPromise), this.ttsInitPromise && e.add(this.ttsInitPromise), this.ttsReconfigurePromise && e.add(this.ttsReconfigurePromise);
|
|
7087
|
+
for (let t of this.providerInitPromises.values()) e.add(t);
|
|
7088
|
+
await Promise.allSettled(e);
|
|
6812
7089
|
}
|
|
6813
7090
|
async ensureTTSReady(e) {
|
|
6814
|
-
if (await this.waitForPendingTTSReconfigure(), !this.ttsInitialized) return this.ttsInitPromise ||= this._initializeTTS(e).finally(() => {
|
|
7091
|
+
if (this.assertNotDisposed(), await this.waitForPendingTTSReconfigure(), this.assertNotDisposed(), !this.ttsInitialized) return this.ttsInitPromise ||= this._initializeTTS(e).then(() => this.assertNotDisposed()).finally(() => {
|
|
6815
7092
|
this.ttsInitPromise = void 0;
|
|
6816
7093
|
}), this.ttsInitPromise;
|
|
6817
7094
|
}
|
|
@@ -6821,11 +7098,11 @@ var oa = class {
|
|
|
6821
7098
|
}
|
|
6822
7099
|
async _initializeTTS(e) {
|
|
6823
7100
|
if (this.ttsInitialized) return;
|
|
6824
|
-
let t =
|
|
7101
|
+
let t = Ui(this.resolveTTSToolConfig(e)), n = Wi(t), r = qi(t);
|
|
6825
7102
|
if (await this.hooks.onBeforeTTSInit?.({
|
|
6826
7103
|
phase: "tts-init",
|
|
6827
7104
|
details: { backend: n }
|
|
6828
|
-
}), await this.emitTelemetry("pie-toolkit-tts-init-start", { backend: n }), await this.emitTelemetry("pie-tool-init-start", {
|
|
7105
|
+
}), this.assertNotDisposed(), await this.emitTelemetry("pie-toolkit-tts-init-start", { backend: n }), await this.emitTelemetry("pie-tool-init-start", {
|
|
6829
7106
|
toolId: "textToSpeech",
|
|
6830
7107
|
operation: "tts-init",
|
|
6831
7108
|
backend: n
|
|
@@ -6839,6 +7116,7 @@ var oa = class {
|
|
|
6839
7116
|
}), console.log("[ToolkitCoordinator] TTS initialized via ToolProviderRegistry");
|
|
6840
7117
|
return;
|
|
6841
7118
|
} catch (e) {
|
|
7119
|
+
if (e instanceof Q) throw e;
|
|
6842
7120
|
let t = e instanceof Error ? e : Error(String(e));
|
|
6843
7121
|
await this.emitTelemetry("pie-tool-init-error", {
|
|
6844
7122
|
toolId: "textToSpeech",
|
|
@@ -6858,7 +7136,7 @@ var oa = class {
|
|
|
6858
7136
|
reason: t.message
|
|
6859
7137
|
}), console.warn("[ToolkitCoordinator] Failed to initialize TTS via registry, falling back to browser provider:", t);
|
|
6860
7138
|
}
|
|
6861
|
-
let i = new
|
|
7139
|
+
let i = new j();
|
|
6862
7140
|
try {
|
|
6863
7141
|
await this.initializeTTSService(i, r), await this.emitTelemetry("pie-toolkit-tts-init-success", { provider: "browser-fallback" }), await this.emitTelemetry("pie-tool-init-success", {
|
|
6864
7142
|
toolId: "textToSpeech",
|
|
@@ -6867,6 +7145,7 @@ var oa = class {
|
|
|
6867
7145
|
provider: "browser-fallback"
|
|
6868
7146
|
});
|
|
6869
7147
|
} catch (e) {
|
|
7148
|
+
if (e instanceof Q) throw e;
|
|
6870
7149
|
let t = e instanceof Error ? e : Error(String(e));
|
|
6871
7150
|
throw this.handleError(t, { phase: "tts-init" }), await this.emitTelemetry("pie-toolkit-tts-init-error", { message: t.message }), await this.emitTelemetry("pie-tool-init-error", {
|
|
6872
7151
|
toolId: "textToSpeech",
|
|
@@ -6893,7 +7172,7 @@ var oa = class {
|
|
|
6893
7172
|
...t,
|
|
6894
7173
|
providerOptions: n
|
|
6895
7174
|
};
|
|
6896
|
-
await this.ttsService.initialize(e, r), await this.ensureBrowserVoicesReady(e), this.ttsService.setCatalogResolver(this.catalogResolver), this.ttsInitialized = !0, await this.hooks.onTTSReady?.();
|
|
7175
|
+
await this.ttsService.initialize(e, r), await this.ensureBrowserVoicesReady(e), this.assertNotDisposed(), this.ttsService.setCatalogResolver(this.catalogResolver), this.ttsInitialized = !0, await this.hooks.onTTSReady?.(), this.assertNotDisposed();
|
|
6897
7176
|
}
|
|
6898
7177
|
async ensureBrowserVoicesReady(e, t = 1200) {
|
|
6899
7178
|
if (e.providerId !== "browser" || typeof window > "u" || !("speechSynthesis" in window)) return;
|
|
@@ -6927,10 +7206,10 @@ var oa = class {
|
|
|
6927
7206
|
return this.ensureProviderReady(e);
|
|
6928
7207
|
}
|
|
6929
7208
|
async waitUntilReady() {
|
|
6930
|
-
if (!this.isReady()) return this.coordinatorReadyPromise ||= (async () => {
|
|
6931
|
-
await this.ensureStateLoaded();
|
|
7209
|
+
if (this.assertNotDisposed(), !this.isReady()) return this.coordinatorReadyPromise ||= (async () => {
|
|
7210
|
+
await this.ensureStateLoaded(), this.assertNotDisposed();
|
|
6932
7211
|
let e = this.getTTSConfigFromProviders();
|
|
6933
|
-
e?.enabled !== !1 && await this.ensureTTSReady(e), this.coordinatorReadyNotified || (this.coordinatorReadyNotified = !0, await this.hooks.onCoordinatorReady?.(this), await this.emitTelemetry("pie-toolkit-coordinator-ready", { assessmentId: this.assessmentId }));
|
|
7212
|
+
e?.enabled !== !1 && await this.ensureTTSReady(e), this.assertNotDisposed(), this.coordinatorReadyNotified || (this.coordinatorReadyNotified = !0, await this.hooks.onCoordinatorReady?.(this), this.assertNotDisposed(), await this.emitTelemetry("pie-toolkit-coordinator-ready", { assessmentId: this.assessmentId }));
|
|
6934
7213
|
})().finally(() => {
|
|
6935
7214
|
this.coordinatorReadyPromise = void 0;
|
|
6936
7215
|
}), this.coordinatorReadyPromise;
|
|
@@ -6984,15 +7263,15 @@ var oa = class {
|
|
|
6984
7263
|
updateToolConfig(e, t) {
|
|
6985
7264
|
this.assertCanonicalToolId(e);
|
|
6986
7265
|
let n = this.getToolConfig(e) || {};
|
|
6987
|
-
this.config.tools || (this.config.tools =
|
|
7266
|
+
this.config.tools || (this.config.tools = D(void 0, {
|
|
6988
7267
|
strictness: this.config.toolConfigStrictness ?? "error",
|
|
6989
7268
|
source: "ToolkitCoordinator.updateToolConfig",
|
|
6990
7269
|
toolRegistry: this.toolRegistry
|
|
6991
7270
|
}).config), this.config.tools.providers || (this.config.tools.providers = {});
|
|
6992
7271
|
let r = {
|
|
6993
7272
|
...this.config.tools.providers || {},
|
|
6994
|
-
[e]:
|
|
6995
|
-
}, i =
|
|
7273
|
+
[e]: ma(e, n, t)
|
|
7274
|
+
}, i = D({
|
|
6996
7275
|
...this.config.tools,
|
|
6997
7276
|
providers: r
|
|
6998
7277
|
}, {
|
|
@@ -7006,7 +7285,7 @@ var oa = class {
|
|
|
7006
7285
|
this.updateToolsPlacement({ [e]: [...t] });
|
|
7007
7286
|
}
|
|
7008
7287
|
updateToolsPlacement(e) {
|
|
7009
|
-
this.config.tools || (this.config.tools =
|
|
7288
|
+
this.config.tools || (this.config.tools = D(void 0, {
|
|
7010
7289
|
strictness: this.config.toolConfigStrictness ?? "error",
|
|
7011
7290
|
source: "ToolkitCoordinator.updateToolsPlacement",
|
|
7012
7291
|
toolRegistry: this.toolRegistry
|
|
@@ -7019,7 +7298,7 @@ var oa = class {
|
|
|
7019
7298
|
section: [...e.section ?? t.section ?? []],
|
|
7020
7299
|
item: [...e.item ?? t.item ?? []],
|
|
7021
7300
|
passage: [...e.passage ?? t.passage ?? []]
|
|
7022
|
-
}, r =
|
|
7301
|
+
}, r = D({
|
|
7023
7302
|
...this.config.tools,
|
|
7024
7303
|
placement: n
|
|
7025
7304
|
}, {
|
|
@@ -7123,7 +7402,7 @@ var oa = class {
|
|
|
7123
7402
|
return this.toolRequests.onTargetsChange(e);
|
|
7124
7403
|
}
|
|
7125
7404
|
resolveEffectivePnpEnforcement() {
|
|
7126
|
-
return this.pnpEnforcementOverride === null ?
|
|
7405
|
+
return this.pnpEnforcementOverride === null ? la({
|
|
7127
7406
|
assessment: this.boundAssessment,
|
|
7128
7407
|
currentItemRef: this.boundCurrentItemRef
|
|
7129
7408
|
}) : this.pnpEnforcementOverride;
|
|
@@ -7132,12 +7411,13 @@ var oa = class {
|
|
|
7132
7411
|
return this.config.tools?.pnpEnforcement ?? null;
|
|
7133
7412
|
}
|
|
7134
7413
|
_applyToolConfigChange(e, t) {
|
|
7135
|
-
switch (e) {
|
|
7414
|
+
if (this.disposePromise === null) switch (e) {
|
|
7136
7415
|
case "textToSpeech": {
|
|
7137
7416
|
let e = this._reconfigureTTSProvider();
|
|
7138
7417
|
this.ttsReconfigurePromise = e, e.finally(() => {
|
|
7139
7418
|
this.ttsReconfigurePromise === e && (this.ttsReconfigurePromise = void 0);
|
|
7140
7419
|
}), e.then(async () => {
|
|
7420
|
+
if (this.disposePromise !== null) return;
|
|
7141
7421
|
let e = this.getTTSConfigFromProviders();
|
|
7142
7422
|
!this.lazyInit && e?.enabled !== !1 && await this.ensureTTSReady(e);
|
|
7143
7423
|
});
|
|
@@ -7150,27 +7430,27 @@ var oa = class {
|
|
|
7150
7430
|
try {
|
|
7151
7431
|
this.ttsService.stop();
|
|
7152
7432
|
} catch {}
|
|
7153
|
-
this.toolProviderRegistry.has("tts") && await this.toolProviderRegistry.unregister("tts");
|
|
7433
|
+
if (this.toolProviderRegistry.has("tts") && await this.toolProviderRegistry.unregister("tts"), this.disposePromise !== null) return;
|
|
7154
7434
|
let e = this.getProviderDescriptorTools().find((e) => e.toolId === "textToSpeech");
|
|
7155
7435
|
e && await this.registerProviderFromTool(e);
|
|
7156
7436
|
}
|
|
7157
|
-
},
|
|
7437
|
+
}, va = /* @__PURE__ */ new Set([
|
|
7158
7438
|
"assessment",
|
|
7159
7439
|
"section",
|
|
7160
7440
|
"item",
|
|
7161
7441
|
"passage",
|
|
7162
7442
|
"rubric"
|
|
7163
7443
|
]);
|
|
7164
|
-
function
|
|
7165
|
-
return
|
|
7444
|
+
function ya(e) {
|
|
7445
|
+
return va.has(e);
|
|
7166
7446
|
}
|
|
7167
|
-
function
|
|
7447
|
+
function ba(e, t, n) {
|
|
7168
7448
|
let r = e.trim(), i = n.trim();
|
|
7169
7449
|
if (!r || !i) throw Error("Tool instance ids require non-empty tool and scope ids");
|
|
7170
|
-
if (!
|
|
7450
|
+
if (!ya(t)) throw Error(`Unknown tool scope level '${t}'. Register custom levels with registerToolScopeLevel().`);
|
|
7171
7451
|
return `${r}:${t}:${i}`;
|
|
7172
7452
|
}
|
|
7173
7453
|
//#endregion
|
|
7174
|
-
export {
|
|
7454
|
+
export { o as C, s as S, Fe as _, Zi as a, ee as b, Vi as c, Yi as d, Ji as f, j as g, Di as h, Qi as i, Gi as l, Ki as m, _a as n, qi as o, Ui as p, $i as r, Pi as s, ba as t, Wi as u, te as v, p as x, h as y };
|
|
7175
7455
|
|
|
7176
|
-
//# sourceMappingURL=dist-
|
|
7456
|
+
//# sourceMappingURL=dist-C8BDh5vZ.js.map
|