@burdenoff/fe-libs 2026.1117.6 → 2026.1117.8
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/shared/assistant/avatar/live/createLiveAvatarSeam.js +8 -0
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +132 -98
- package/dist/shared/assistant/speech/routingSpeechEngine.js +6 -0
- package/dist/shared/assistant/speech/speechFeed.d.ts +14 -0
- package/dist/shared/assistant/speech/speechFeed.js +7 -0
- package/dist/shared/assistant/speech/types.d.ts +10 -0
- package/dist/shared/assistant/turnState.d.ts +36 -0
- package/dist/shared/assistant/turnState.js +18 -1
- package/dist/shared/assistant/turnTimeline.d.ts +8 -88
- package/dist/shared/assistant/ui/AssistantChatArea.js +1212 -1201
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +281 -245
- package/dist/shared/assistant/voice/firstClipPrefetchConfig.d.ts +4 -0
- package/dist/shared/assistant/voice/firstClipPrefetchConfig.js +9 -0
- package/dist/shared/assistant/voice/speakableText.d.ts +18 -0
- package/dist/shared/assistant/voice/speakableText.js +113 -107
- package/dist/shared-assistant.js +381 -380
- package/package.json +1 -1
|
@@ -157,4 +157,22 @@ export declare function containsCjk(text: string): boolean;
|
|
|
157
157
|
export declare function chunkForSpeech(text: string, maxChars?: number, cjkMaxChars?: number, options?: {
|
|
158
158
|
firstChunkMaxChars?: number;
|
|
159
159
|
packFirstChunk?: boolean;
|
|
160
|
+
/** P1: lead with a first sentence this long even when the reply fits one chunk. */
|
|
161
|
+
leadSentenceMinChars?: number;
|
|
160
162
|
}): string[];
|
|
163
|
+
/**
|
|
164
|
+
* ★ P1 (BOFF-12936): the first sentence long enough to lead a reply on its own
|
|
165
|
+
* when its clip is fetched early (see `chunkForSpeech`). About 2.5 s of speech:
|
|
166
|
+
* the clip after it (~1.1 s to synthesise) is ready before it ends.
|
|
167
|
+
*/
|
|
168
|
+
export declare const FIRST_CLIP_LEAD_MIN_CHARS = 40;
|
|
169
|
+
/**
|
|
170
|
+
* ★ P1 (BOFF-12936): the first chunk of an answer still being written, once it
|
|
171
|
+
* can no longer change: the answer's first sentence is complete (more text
|
|
172
|
+
* follows it), and the first chunk lies within that sentence. Null until then.
|
|
173
|
+
* `options` must be the ones the finished answer will be chunked with.
|
|
174
|
+
*/
|
|
175
|
+
export declare function settledFirstChunk(partial: string, options: {
|
|
176
|
+
firstChunkMaxChars?: number;
|
|
177
|
+
leadSentenceMinChars?: number;
|
|
178
|
+
}): string | null;
|
|
@@ -31,15 +31,15 @@ function l(e, t) {
|
|
|
31
31
|
}
|
|
32
32
|
return n ? v(t.linkTo, { site: n }) : t.link;
|
|
33
33
|
}
|
|
34
|
-
var u = /^\s{0,3}(?:`{3,}|~{3,})/,
|
|
34
|
+
var u = /^\s{0,3}(?:`{3,}|~{3,})/, ee = /^\s{0,3}#{1,6}\s+(.*)$/, d = /^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/, f = /^\s{0,3}(?:>\s?)+/, p = /^(\s*)(?:[-*+]|(\d{1,9})[.)])\s+/, m = /^\[[ xX]\]\s*/, h = /[.!?…⋯:;。!?;.।॥۔؟؛]$/, g = /^\s{0,3}=+\s*$/, _ = /^(?: {4}|\t)/;
|
|
35
35
|
function v(e, t) {
|
|
36
36
|
return Object.entries(t).reduce((e, [t, n]) => e.replace(RegExp(`\\{\\{${t}\\}\\}`, "g"), String(n)), e);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function te(e) {
|
|
39
39
|
let t = e.trim();
|
|
40
40
|
return t.includes("|") && t.includes("-") && /^[\s:|-]+$/.test(t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function y(e) {
|
|
43
43
|
let t = e.trim().replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
|
|
44
44
|
for (let e = 0; e < t.length; e += 1) {
|
|
45
45
|
let i = t[e];
|
|
@@ -47,7 +47,7 @@ function b(e) {
|
|
|
47
47
|
}
|
|
48
48
|
return n.push(r), n.map((e) => e.trim());
|
|
49
49
|
}
|
|
50
|
-
var
|
|
50
|
+
var b = {
|
|
51
51
|
"&": " and ",
|
|
52
52
|
"<": " less than ",
|
|
53
53
|
">": " greater than ",
|
|
@@ -55,86 +55,86 @@ var x = {
|
|
|
55
55
|
"'": "'",
|
|
56
56
|
"'": "'",
|
|
57
57
|
" ": " "
|
|
58
|
-
},
|
|
59
|
-
function
|
|
58
|
+
}, x = "[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\\.[A-Za-z0-9-]+)+", S = RegExp(`<(?:mailto:)?(${x})>`, "g"), C = RegExp(`\\bmailto:(${x})`, "g"), w = new RegExp(x, "g");
|
|
59
|
+
function T(e, t = "at", n = "dot") {
|
|
60
60
|
return e.replace(/@/g, ` ${t} `).replace(/\./g, ` ${n} `).replace(/\s+/g, " ").trim();
|
|
61
61
|
}
|
|
62
|
-
var
|
|
63
|
-
function
|
|
64
|
-
let n = e.replace(
|
|
62
|
+
var E = 57600, D = /[\ue121-\ue17e]/g, O = "", k = /\ue180/g, A = /[\ue100-\ue1ff]/g;
|
|
63
|
+
function j(e, t) {
|
|
64
|
+
let n = e.replace(A, "").replace(/\\[!-/:-@[-`{-~]|(`+)[^`]*?\1(?!`)/g, (e, t) => t ? e.replace(/\\/g, O) : e).replace(/\\([!-/:-@[-`{-~])/g, (e, t) => String.fromCharCode(E + t.charCodeAt(0)));
|
|
65
65
|
n = n.replace(/!\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.image} `), n = n.replace(/\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/\[([^\]]*)\]\[[^\]]*\]/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/<(https?:\/\/[^>\s]+)>/g, (e, n) => ` ${l(n, t)} `), n = n.replace(/\bhttps?:\/\/\S+/g, (e) => {
|
|
66
66
|
let n = e.replace(/[.,;:!?)\]]+$/, ""), r = e.slice(n.length).replace(/[)\]]/g, "");
|
|
67
67
|
return ` ${l(n, t)}${r} `;
|
|
68
|
-
}), n = n.replace(
|
|
69
|
-
for (let [e, t] of Object.entries(
|
|
70
|
-
return n = n.replace(/(\*\*\*|___)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/(\*\*|__)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/~~(\S(?:[\s\S]*?\S)?)~~/g, "$1"), n = n.replace(/(^|[\s([{"'])\*(\S(?:[\s\S]*?\S)?)\*(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/(^|[\s([{"'])_(\S(?:[\s\S]*?\S)?)_(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/[\p{Extended_Pictographic}\uFE0F\u200D]/gu, " "), n = n.replace(/[•·▪▫◦‣⁃∙●○■□▶▸►➤➜→←↑↓⇒⇔★☆⭐✦✧✓✔✗✘✕✖]/gu, " "), n = n.replace(/(\d)?\s*[—–―]\s*(\d)?/g, (e, t, n) => t !== void 0 && n !== void 0 ? e : `${t ?? ""}, ${n ?? ""}`), n = n.replace(/\*{2,}/g, ""), n.replace(/\s+/g, " ").replace(/\s+([.,!?;:)\]}])/g, "$1").replace(/([([{])\s+/g, "$1").trim().replace(
|
|
68
|
+
}), n = n.replace(S, (e, n) => ` ${T(n, t.emailAt, t.emailDot)} `), n = n.replace(C, (e, n) => ` ${T(n, t.emailAt, t.emailDot)} `), n = n.replace(w, (e) => ` ${T(e, t.emailAt, t.emailDot)} `), n = n.replace(/`+([^`]*)`+/g, (e, t) => t), n = n.replace(/<\/?[a-zA-Z][^>]*>/g, " ");
|
|
69
|
+
for (let [e, t] of Object.entries(b)) n = n.split(e).join(t);
|
|
70
|
+
return n = n.replace(/(\*\*\*|___)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/(\*\*|__)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/~~(\S(?:[\s\S]*?\S)?)~~/g, "$1"), n = n.replace(/(^|[\s([{"'])\*(\S(?:[\s\S]*?\S)?)\*(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/(^|[\s([{"'])_(\S(?:[\s\S]*?\S)?)_(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/[\p{Extended_Pictographic}\uFE0F\u200D]/gu, " "), n = n.replace(/[•·▪▫◦‣⁃∙●○■□▶▸►➤➜→←↑↓⇒⇔★☆⭐✦✧✓✔✗✘✕✖]/gu, " "), n = n.replace(/(\d)?\s*[—–―]\s*(\d)?/g, (e, t, n) => t !== void 0 && n !== void 0 ? e : `${t ?? ""}, ${n ?? ""}`), n = n.replace(/\*{2,}/g, ""), n.replace(/\s+/g, " ").replace(/\s+([.,!?;:)\]}])/g, "$1").replace(/([([{])\s+/g, "$1").trim().replace(D, (e) => String.fromCharCode(e.charCodeAt(0) - E)).replace(k, "\\");
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function M(e) {
|
|
73
73
|
let t = e.trim();
|
|
74
74
|
return t ? h.test(t) ? t : `${t}.` : "";
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function N(e, t, n) {
|
|
77
77
|
if (e.length <= t) return e;
|
|
78
78
|
let r = e.slice(0, t), i = Math.max(r.lastIndexOf(". "), r.lastIndexOf("\n")), a = r.lastIndexOf(" "), o = i > t * .5 ? i + 1 : a > 0 ? a : t;
|
|
79
79
|
return `${r.slice(0, o).trim()}\n${n}`;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function P(e) {
|
|
82
82
|
let t = 0;
|
|
83
83
|
for (let n of e) t += n === " " ? 4 : 1;
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function F(e, t) {
|
|
87
87
|
let n = e[e.length - 1];
|
|
88
88
|
if (!n?.ordinal) return "";
|
|
89
89
|
if (e.length === 1) return `${n.ordinal}. `;
|
|
90
90
|
let r = e.map((e) => e.ordinal);
|
|
91
91
|
return r.every((e) => !!e) ? `${r.join(".")}. ` : `${v(t.nestedItem, { ordinal: n.ordinal })}. `;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function I(t, n = {}) {
|
|
94
94
|
let r = {
|
|
95
95
|
...e,
|
|
96
96
|
...n.labels
|
|
97
97
|
}, i = n.maxChars ?? 8e3, a = n.maxSpokenTableRows ?? 3, o = n.locale ?? "en", s = 0;
|
|
98
98
|
if (!t) return "";
|
|
99
|
-
let l = t.replace(/\r\n?/g, "\n").split("\n"), h = [],
|
|
100
|
-
for (;
|
|
101
|
-
let e = l[
|
|
99
|
+
let l = t.replace(/\r\n?/g, "\n").split("\n"), h = [], b = [], x = 0;
|
|
100
|
+
for (; x < l.length;) {
|
|
101
|
+
let e = l[x].replace(f, ""), t = x === 0 || !l[x - 1].replace(f, "").trim();
|
|
102
102
|
if (u.test(e)) {
|
|
103
|
-
for (
|
|
104
|
-
|
|
103
|
+
for (x += 1; x < l.length && !u.test(l[x].replace(f, ""));) x += 1;
|
|
104
|
+
x += 1, h.push(M(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
|
-
if (t &&
|
|
108
|
-
for (
|
|
109
|
-
let e = l[
|
|
107
|
+
if (t && b.length === 0 && e.trim() && _.test(e)) {
|
|
108
|
+
for (x += 1; x < l.length;) {
|
|
109
|
+
let e = l[x].replace(f, "");
|
|
110
110
|
if (e.trim() && _.test(e)) {
|
|
111
|
-
|
|
111
|
+
x += 1;
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
114
|
if (e.trim()) break;
|
|
115
|
-
let t =
|
|
115
|
+
let t = x;
|
|
116
116
|
for (; t < l.length && !l[t].replace(f, "").trim();) t += 1;
|
|
117
117
|
let n = t < l.length ? l[t].replace(f, "") : "";
|
|
118
118
|
if (!n.trim() || !_.test(n)) break;
|
|
119
|
-
|
|
119
|
+
x = t;
|
|
120
120
|
}
|
|
121
|
-
h.push(
|
|
121
|
+
h.push(M(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
|
|
122
122
|
continue;
|
|
123
123
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
124
|
+
if (d.test(e) || g.test(e)) {
|
|
125
|
+
x += 1;
|
|
126
126
|
continue;
|
|
127
127
|
}
|
|
128
|
-
let n =
|
|
129
|
-
if (e.includes("|") &&
|
|
130
|
-
|
|
131
|
-
let t =
|
|
132
|
-
|
|
128
|
+
let n = x + 1 < l.length ? l[x + 1].replace(f, "") : "";
|
|
129
|
+
if (e.includes("|") && te(n)) {
|
|
130
|
+
b.length = 0;
|
|
131
|
+
let t = y(e).map((e) => j(e, r));
|
|
132
|
+
x += 2;
|
|
133
133
|
let n = [];
|
|
134
|
-
for (;
|
|
135
|
-
let e = l[
|
|
134
|
+
for (; x < l.length;) {
|
|
135
|
+
let e = l[x].replace(f, "");
|
|
136
136
|
if (!e.includes("|") || !e.trim()) break;
|
|
137
|
-
n.push(
|
|
137
|
+
n.push(y(e).map((e) => j(e, r))), x += 1;
|
|
138
138
|
}
|
|
139
139
|
if (n.length > a) {
|
|
140
140
|
let e = c(t.slice(0, 5), o), i = v(r.largeTable, {
|
|
@@ -142,51 +142,51 @@ function L(t, n = {}) {
|
|
|
142
142
|
columns: t.length,
|
|
143
143
|
headers: e
|
|
144
144
|
});
|
|
145
|
-
h.push(
|
|
145
|
+
h.push(M(e ? i : i.replace(/[\s::،,]+$/u, "")));
|
|
146
146
|
} else for (let e of n) {
|
|
147
147
|
let n = e.map((e, n) => {
|
|
148
148
|
if (!e) return "";
|
|
149
149
|
let r = t[n];
|
|
150
150
|
return r ? `${r}: ${e}` : e;
|
|
151
151
|
}).filter(Boolean);
|
|
152
|
-
n.length && h.push(
|
|
152
|
+
n.length && h.push(M(n.join(", ")));
|
|
153
153
|
}
|
|
154
154
|
continue;
|
|
155
155
|
}
|
|
156
|
-
if (
|
|
157
|
-
let i =
|
|
156
|
+
if (x += 1, !e.trim()) continue;
|
|
157
|
+
let i = ee.exec(e);
|
|
158
158
|
if (i) {
|
|
159
|
-
|
|
160
|
-
let e =
|
|
161
|
-
e && h.push(
|
|
159
|
+
b.length = 0;
|
|
160
|
+
let e = j(i[1].replace(/\s+#+\s*$/, ""), r);
|
|
161
|
+
e && h.push(M(e));
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
let t =
|
|
168
|
-
for (;
|
|
169
|
-
|
|
164
|
+
let S = p.exec(e), C = e, w = "";
|
|
165
|
+
if (S) {
|
|
166
|
+
C = e.slice(S[0].length).replace(m, "");
|
|
167
|
+
let t = P(S[1]);
|
|
168
|
+
for (; b.length > 0 && b[b.length - 1].indent >= t;) b.pop();
|
|
169
|
+
b.push({
|
|
170
170
|
indent: t,
|
|
171
|
-
ordinal:
|
|
172
|
-
}),
|
|
173
|
-
} else /^\s/.test(e) || (
|
|
174
|
-
if (!
|
|
175
|
-
|
|
176
|
-
let t =
|
|
177
|
-
t && h.push(
|
|
171
|
+
ordinal: S[2] ?? null
|
|
172
|
+
}), w = F(b, r);
|
|
173
|
+
} else /^\s/.test(e) || (b.length = 0);
|
|
174
|
+
if (!S && g.test(n)) {
|
|
175
|
+
b.length = 0, x += 1;
|
|
176
|
+
let t = j(e, r);
|
|
177
|
+
t && h.push(M(t));
|
|
178
178
|
continue;
|
|
179
179
|
}
|
|
180
|
-
let
|
|
181
|
-
|
|
180
|
+
let T = j(C, r);
|
|
181
|
+
T && h.push(M(`${w}${T}`));
|
|
182
182
|
}
|
|
183
|
-
return
|
|
183
|
+
return N(h.join("\n").replace(/\n{2,}/g, "\n").trim(), i, M(r.truncated));
|
|
184
184
|
}
|
|
185
|
-
var
|
|
185
|
+
var L = /* @__PURE__ */ new Set([
|
|
186
186
|
".",
|
|
187
187
|
"!",
|
|
188
188
|
"?"
|
|
189
|
-
]),
|
|
189
|
+
]), R = /* @__PURE__ */ new Set([
|
|
190
190
|
"。",
|
|
191
191
|
"!",
|
|
192
192
|
"?",
|
|
@@ -200,7 +200,7 @@ var R = /* @__PURE__ */ new Set([
|
|
|
200
200
|
"۔",
|
|
201
201
|
"؟",
|
|
202
202
|
"؛"
|
|
203
|
-
]),
|
|
203
|
+
]), z = /* @__PURE__ */ new Set([
|
|
204
204
|
"\"",
|
|
205
205
|
"'",
|
|
206
206
|
")",
|
|
@@ -215,25 +215,25 @@ var R = /* @__PURE__ */ new Set([
|
|
|
215
215
|
"』",
|
|
216
216
|
"】",
|
|
217
217
|
")"
|
|
218
|
-
]),
|
|
218
|
+
]), B = /* @__PURE__ */ new Set(/* @__PURE__ */ "i.e,e.g,etc,approx,vs,cf,viz,al,est,dept,fig,figs,ref,min,max,avg,qty,temp,mr,mrs,ms,dr,prof,sr,jr,st,inc,ltd,co,corp,univ,ca,kg,mg,gm,ha,cm,mm,km,ml,lb,oz,sq,hrs,wk,yr,mo,vol,pp".split(",")), V = /* @__PURE__ */ new Set([
|
|
219
219
|
"no",
|
|
220
220
|
"nos",
|
|
221
221
|
"p",
|
|
222
222
|
"ch",
|
|
223
223
|
"sec",
|
|
224
224
|
"art"
|
|
225
|
-
]),
|
|
226
|
-
function
|
|
227
|
-
for (let r = t; r < n; r += 1) if (
|
|
225
|
+
]), H = /^\d+(?:\.\d+)*$/, U = /^[A-Za-z]$/;
|
|
226
|
+
function W(e, t, n) {
|
|
227
|
+
for (let r = t; r < n; r += 1) if (R.has(e[r])) return !0;
|
|
228
228
|
if (n < e.length && !/\s/.test(e[n])) return !1;
|
|
229
229
|
if (e[t] !== ".") return !0;
|
|
230
230
|
let r = e.slice(0, t), i = /(\S+)$/.exec(r)?.[1] ?? "";
|
|
231
231
|
if (!i) return !0;
|
|
232
|
-
if (
|
|
232
|
+
if (H.test(i) && !r.slice(0, r.length - i.length).trim()) return !1;
|
|
233
233
|
let a = i.toLowerCase();
|
|
234
|
-
return
|
|
234
|
+
return U.test(i) || B.has(a) ? !1 : !V.has(a) || !/^\s*\d/.test(e.slice(n));
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function G(e) {
|
|
237
237
|
let t = [];
|
|
238
238
|
for (let n of e.split("\n")) {
|
|
239
239
|
let e = n.trim();
|
|
@@ -241,14 +241,14 @@ function K(e) {
|
|
|
241
241
|
let r = 0, i = 0;
|
|
242
242
|
for (; i < e.length;) {
|
|
243
243
|
let n = e[i];
|
|
244
|
-
if (!
|
|
244
|
+
if (!L.has(n) && !R.has(n)) {
|
|
245
245
|
i += 1;
|
|
246
246
|
continue;
|
|
247
247
|
}
|
|
248
248
|
let a = i;
|
|
249
|
-
for (; a < e.length && (
|
|
250
|
-
for (; a < e.length &&
|
|
251
|
-
if (
|
|
249
|
+
for (; a < e.length && (L.has(e[a]) || R.has(e[a]));) a += 1;
|
|
250
|
+
for (; a < e.length && z.has(e[a]);) a += 1;
|
|
251
|
+
if (W(e, i, a)) {
|
|
252
252
|
let n = e.slice(r, a).trim();
|
|
253
253
|
n && t.push(n), r = a;
|
|
254
254
|
}
|
|
@@ -259,38 +259,38 @@ function K(e) {
|
|
|
259
259
|
}
|
|
260
260
|
return t;
|
|
261
261
|
}
|
|
262
|
-
var
|
|
263
|
-
function
|
|
264
|
-
return
|
|
262
|
+
var K = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/, q = /[\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff01-\uff9f]/, J = /[、,,;;::。!?!?]/, Y = /[A-Za-z0-9][A-Za-z0-9._,:%/+-]*[A-Za-z0-9%]|[\s\S]/gu;
|
|
263
|
+
function X(e) {
|
|
264
|
+
return K.test(e);
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function Z(e, t) {
|
|
267
267
|
let n = `${e.slice(-1)}${t.slice(0, 1)}`;
|
|
268
|
-
return
|
|
268
|
+
return q.test(n) ? `${e}${t}` : `${e} ${t}`;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function Q(e, t) {
|
|
271
271
|
let n = t.trim();
|
|
272
272
|
n && e.push(n);
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function ne(e, t) {
|
|
275
275
|
let n = [], r = "", i = -1;
|
|
276
|
-
for (let a of e.match(
|
|
276
|
+
for (let a of e.match(Y) ?? []) {
|
|
277
277
|
if (r.length + a.length > t && r.trim()) {
|
|
278
278
|
if (i > 0 && i < r.length && i >= t * .4) {
|
|
279
|
-
|
|
279
|
+
Q(n, r.slice(0, i));
|
|
280
280
|
let e = r.slice(i);
|
|
281
|
-
e.trim().length + a.length > t ? (
|
|
282
|
-
} else
|
|
281
|
+
e.trim().length + a.length > t ? (Q(n, e), r = "") : r = e;
|
|
282
|
+
} else Q(n, r), r = "";
|
|
283
283
|
i = -1;
|
|
284
284
|
}
|
|
285
285
|
if (a.length > t) {
|
|
286
|
-
|
|
286
|
+
Q(n, r), r = "", i = -1;
|
|
287
287
|
for (let e = 0; e < a.length; e += t) n.push(a.slice(e, e + t));
|
|
288
|
-
} else r += a,
|
|
288
|
+
} else r += a, J.test(a) && (i = r.length);
|
|
289
289
|
}
|
|
290
|
-
return
|
|
290
|
+
return Q(n, r), n;
|
|
291
291
|
}
|
|
292
|
-
function
|
|
293
|
-
if (
|
|
292
|
+
function re(e, t) {
|
|
293
|
+
if (X(e)) return ne(e, t);
|
|
294
294
|
let n = [], r = "";
|
|
295
295
|
for (let i of e.split(/\s+/)) if (i.length > t) {
|
|
296
296
|
r &&= (n.push(r), "");
|
|
@@ -298,36 +298,42 @@ function ne(e, t) {
|
|
|
298
298
|
} else r ? r.length + 1 + i.length <= t ? r = `${r} ${i}` : (n.push(r), r = i) : r = i;
|
|
299
299
|
return r && n.push(r), n;
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function $(e, t = 180, n = 40, r = {}) {
|
|
302
302
|
let i = Math.max(1, t), a = Math.max(1, Math.min(n, i)), o = [], s = "", c = i;
|
|
303
|
-
for (let t of
|
|
304
|
-
let e =
|
|
303
|
+
for (let t of G(e)) {
|
|
304
|
+
let e = X(t) ? a : i;
|
|
305
305
|
if (t.length > e) {
|
|
306
|
-
s &&= (o.push(s), ""), o.push(...
|
|
306
|
+
s &&= (o.push(s), ""), o.push(...re(t, e)), c = i;
|
|
307
307
|
continue;
|
|
308
308
|
}
|
|
309
309
|
if (!s) {
|
|
310
310
|
s = t, c = e;
|
|
311
311
|
continue;
|
|
312
312
|
}
|
|
313
|
-
let n =
|
|
313
|
+
let n = Z(s, t), r = Math.min(c, e);
|
|
314
314
|
n.length <= r ? (s = n, c = r) : (o.push(s), s = t, c = e);
|
|
315
315
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
316
|
+
s && o.push(s);
|
|
317
|
+
let l = o.length > 0 ? G(o[0]) : [];
|
|
318
|
+
if ((o.length > 1 || r.leadSentenceMinChars !== void 0 && (l[0] ?? "").length >= r.leadSentenceMinChars) && !r.packFirstChunk && l.length > 1) {
|
|
319
|
+
let [e, ...t] = l;
|
|
320
|
+
o.splice(0, 1, e, t.reduce((e, t) => Z(e, t)));
|
|
322
321
|
}
|
|
323
322
|
if (r.firstChunkMaxChars !== void 0 && o.length > 0) {
|
|
324
|
-
let [e, t] =
|
|
323
|
+
let [e, t] = oe(o[0], r.firstChunkMaxChars);
|
|
325
324
|
t && o.splice(0, 1, e, t);
|
|
326
325
|
}
|
|
327
326
|
return o;
|
|
328
327
|
}
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
var ie = 40;
|
|
329
|
+
function ae(e, t) {
|
|
330
|
+
let n = G(e), r = n[0];
|
|
331
|
+
if (n.length < 2 || r === void 0) return null;
|
|
332
|
+
let i = $(e, 180, 40, t)[0];
|
|
333
|
+
return i !== void 0 && i !== "" && r.startsWith(i) ? i : null;
|
|
334
|
+
}
|
|
335
|
+
function oe(e, t) {
|
|
336
|
+
if (e.length <= t || X(e)) return [e, null];
|
|
331
337
|
for (let n = Math.min(t, e.length - 1); n >= o; --n) {
|
|
332
338
|
let t = e[n - 1], r = e[n];
|
|
333
339
|
if (!("—–".includes(t) || ",;:".includes(t) && /\s/.test(r))) continue;
|
|
@@ -336,4 +342,4 @@ function ie(e, t) {
|
|
|
336
342
|
}
|
|
337
343
|
return [e, null];
|
|
338
344
|
}
|
|
339
|
-
export { e as DEFAULT_SPEAKABLE_LABELS, n as MAX_SPEAKABLE_CHARS, s as MAX_SPOKEN_TABLE_HEADERS, t as MAX_SPOKEN_TABLE_ROWS, r as SPEECH_CHUNK_CHARS, i as SPEECH_CHUNK_CJK_CHARS, a as SPEECH_FIRST_CHUNK_MAX_CHARS,
|
|
345
|
+
export { e as DEFAULT_SPEAKABLE_LABELS, ie as FIRST_CLIP_LEAD_MIN_CHARS, n as MAX_SPEAKABLE_CHARS, s as MAX_SPOKEN_TABLE_HEADERS, t as MAX_SPOKEN_TABLE_ROWS, r as SPEECH_CHUNK_CHARS, i as SPEECH_CHUNK_CJK_CHARS, a as SPEECH_FIRST_CHUNK_MAX_CHARS, $ as chunkForSpeech, X as containsCjk, c as joinSpokenList, ae as settledFirstChunk, T as speakableEmail, l as speakableLink, y as splitTableRow, I as toSpeakableText };
|