@naersen/tts-rich-text 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,42 +1,42 @@
1
- const f = {
1
+ const h = {
2
2
  DELETE_NODE: "deleteNode",
3
3
  CONVERT_TO_TEXT: "convertToText"
4
- }, h = {
4
+ }, f = {
5
5
  stop: {
6
6
  label: "停顿",
7
7
  icon: "editor-stop",
8
8
  type: "stop",
9
- deleteMode: f.DELETE_NODE
9
+ deleteMode: h.DELETE_NODE
10
10
  },
11
11
  customStop: {
12
12
  label: "长停顿",
13
13
  icon: "editor-stop-long",
14
14
  type: "customStop",
15
- deleteMode: f.DELETE_NODE
15
+ deleteMode: h.DELETE_NODE
16
16
  },
17
17
  continue: {
18
18
  label: "连续",
19
19
  icon: "editor-continue",
20
20
  type: "continue",
21
- deleteMode: f.CONVERT_TO_TEXT
21
+ deleteMode: h.CONVERT_TO_TEXT
22
22
  },
23
23
  pinyin: {
24
24
  label: "拼音标注",
25
25
  icon: "editor-pinyin",
26
26
  type: "pinyin",
27
- deleteMode: f.CONVERT_TO_TEXT
27
+ deleteMode: h.CONVERT_TO_TEXT
28
28
  },
29
29
  replace: {
30
30
  label: "替换",
31
31
  icon: "editor-replace",
32
32
  type: "replace",
33
- deleteMode: f.CONVERT_TO_TEXT
33
+ deleteMode: h.CONVERT_TO_TEXT
34
34
  },
35
35
  language: {
36
36
  label: "语种标记",
37
37
  icon: "editor-language",
38
38
  type: "language",
39
- deleteMode: f.CONVERT_TO_TEXT
39
+ deleteMode: h.CONVERT_TO_TEXT
40
40
  },
41
41
  number: {
42
42
  label: "数字读法",
@@ -62,9 +62,9 @@ const f = {
62
62
  label: "忽略读音",
63
63
  icon: "editor-ingore",
64
64
  type: "ignore",
65
- deleteMode: f.CONVERT_TO_TEXT
65
+ deleteMode: h.CONVERT_TO_TEXT
66
66
  }
67
- }, _ = [
67
+ }, x = [
68
68
  { value: "zh", label: "中文" },
69
69
  { value: "en", label: "英语" },
70
70
  { value: "jp", label: "日语" },
@@ -75,12 +75,12 @@ const f = {
75
75
  { value: "it", label: "意大利语" },
76
76
  { value: "pt", label: "葡萄牙语" },
77
77
  { value: "ru", label: "俄语" }
78
- ], le = [
78
+ ], pe = [
79
79
  { label: "停顿 0.5 秒", value: 0.5 },
80
80
  { label: "停顿 1 秒", value: 1 }
81
- ], v = Object.keys(h), d = {
81
+ ], v = Object.keys(f), d = {
82
82
  tools: v,
83
- languages: _,
83
+ languages: x,
84
84
  maxPinyinLength: 4,
85
85
  maxNumberLength: 16,
86
86
  enablePreview: !0
@@ -97,21 +97,21 @@ const f = {
97
97
  "upload",
98
98
  "ignore"
99
99
  ],
100
- languages: _.filter(
100
+ languages: x.filter(
101
101
  (e) => ["zh", "en"].includes(e.value)
102
102
  )
103
103
  },
104
104
  2: d
105
- }, ae = (e, n = {}) => {
106
- const t = D[e] ?? d;
105
+ }, ge = (e, t = {}) => {
106
+ const n = D[e] ?? d;
107
107
  return {
108
108
  ...d,
109
- ...t,
110
109
  ...n,
111
- tools: n.tools ?? t.tools ?? d.tools,
112
- languages: n.languages ?? t.languages ?? d.languages
110
+ ...t,
111
+ tools: t.tools ?? n.tools ?? d.tools,
112
+ languages: t.languages ?? n.languages ?? d.languages
113
113
  };
114
- }, ce = () => ({
114
+ }, fe = () => ({
115
115
  type: "doc",
116
116
  content: [
117
117
  {
@@ -119,7 +119,13 @@ const f = {
119
119
  content: []
120
120
  }
121
121
  ]
122
- }), y = {
122
+ }), w = /[\u4e00-\u9fff]/, H = /\s/g, V = 0.28, $ = 0.14, he = (e, t = 1) => {
123
+ const n = Number.isFinite(t) && t > 0 ? t : 1;
124
+ return Array.from(e.replace(H, "")).reduce(
125
+ (s, a) => s + (w.test(a) ? V : $),
126
+ 0
127
+ ) / n;
128
+ }, R = {
123
129
  0: "零",
124
130
  1: "一",
125
131
  2: "二",
@@ -130,7 +136,7 @@ const f = {
130
136
  7: "七",
131
137
  8: "八",
132
138
  9: "九"
133
- }, w = {
139
+ }, U = {
134
140
  0: "洞",
135
141
  1: "幺",
136
142
  2: "二",
@@ -141,49 +147,49 @@ const f = {
141
147
  7: "七",
142
148
  8: "八",
143
149
  9: "九"
144
- }, V = ["", "十", "百", "千"], $ = ["", "万", "亿", "万亿"];
145
- function B(e) {
146
- return e ? e.split("").map((n) => y[n] || n).join("") : "";
150
+ }, B = ["", "十", "百", "千"], k = ["", "万", "亿", "万亿"];
151
+ function j(e) {
152
+ return e ? e.split("").map((t) => R[t] || t).join("") : "";
147
153
  }
148
- function ue(e) {
149
- return e ? e.split("").map((n) => w[n] || n).join("") : "";
154
+ function de(e) {
155
+ return e ? e.split("").map((t) => U[t] || t).join("") : "";
150
156
  }
151
- function U(e) {
152
- const n = e.length;
153
- let t = "", o = !1;
154
- for (let s = 0; s < n; s++) {
155
- const l = e[s], r = n - 1 - s;
156
- l === "0" ? !o && t !== "" && (o = !0) : (o && (t += "零", o = !1), t += y[l] + V[r]);
157
+ function X(e) {
158
+ const t = e.length;
159
+ let n = "", o = !1;
160
+ for (let s = 0; s < t; s++) {
161
+ const a = e[s], r = t - 1 - s;
162
+ a === "0" ? !o && n !== "" && (o = !0) : (o && (n += "零", o = !1), n += R[a] + B[r]);
157
163
  }
158
- return t.startsWith("一十") && t.length === 2 && (t = t.substring(1)), t;
164
+ return n.startsWith("一十") && n.length === 2 && (n = n.substring(1)), n;
159
165
  }
160
- function F(e) {
166
+ function y(e) {
161
167
  if (!e) return "";
162
168
  if (e === "0" || (e = e.replace(/^0+/, "") || "0", e === "0")) return "零";
163
- let n = "";
164
- const t = e.length, o = [];
165
- for (let s = t; s > 0; s -= 4) {
166
- const l = Math.max(0, s - 4);
167
- o.unshift(e.substring(l, s));
169
+ let t = "";
170
+ const n = e.length, o = [];
171
+ for (let s = n; s > 0; s -= 4) {
172
+ const a = Math.max(0, s - 4);
173
+ o.unshift(e.substring(a, s));
168
174
  }
169
175
  for (let s = 0; s < o.length; s++) {
170
- const l = o[s], r = U(l);
176
+ const a = o[s], r = X(a);
171
177
  if (r !== "") {
172
178
  const i = o.length - 1 - s;
173
- n += r + $[i];
179
+ t += r + k[i];
174
180
  }
175
181
  }
176
- return n;
182
+ return t;
177
183
  }
178
- function j(e) {
179
- return F(e);
184
+ function z(e) {
185
+ return y(e);
180
186
  }
181
- const pe = [
182
- { label: "基数读法", func: B },
187
+ const Te = [
188
+ { label: "基数读法", func: j },
183
189
  // { label: '位数读法', func: toPhoneReading },
184
- { label: "位数读法", func: F },
185
- { label: "口语读法", func: j }
186
- ], k = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFFD\uE000-\uF8FF]/g, z = /[\t\f\v\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g, O = {
190
+ { label: "位数读法", func: y },
191
+ { label: "口语读法", func: z }
192
+ ], G = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFFD\uE000-\uF8FF]/g, W = /[\t\f\v\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g, I = {
187
193
  "‘": "'",
188
194
  "’": "'",
189
195
  "‚": "'",
@@ -215,161 +221,161 @@ const pe = [
215
221
  "︔": ";",
216
222
  "︕": "!",
217
223
  "︖": "?"
218
- }, H = new RegExp(
219
- `[${Object.keys(O).join("")}]`,
224
+ }, Y = new RegExp(
225
+ `[${Object.keys(I).join("")}]`,
220
226
  "g"
221
- ), X = (e) => e.replace(/[\uFF21-\uFF3A\uFF41-\uFF5A\uFF10-\uFF19]/g, (n) => String.fromCharCode(n.charCodeAt(0) - 65248)), G = (e) => X(e).replace(/\r\n?/g, `
227
+ ), K = (e) => e.replace(/[\uFF21-\uFF3A\uFF41-\uFF5A\uFF10-\uFF19]/g, (t) => String.fromCharCode(t.charCodeAt(0) - 65248)), q = (e) => K(e).replace(/\r\n?/g, `
222
228
  `).replace(/[\u2028\u2029]/g, `
223
- `).replace(k, "").replace(z, " ").replace(H, (n) => O[n] || "").replace(/ *\n */g, `
229
+ `).replace(G, "").replace(W, " ").replace(Y, (t) => I[t] || "").replace(/ *\n */g, `
224
230
  `).replace(/\n{3,}/g, `
225
231
 
226
- `), ge = (e) => {
232
+ `), Ee = (e) => {
227
233
  if (typeof window > "u" || !e)
228
234
  return e;
229
- const t = new DOMParser().parseFromString(e, "text/html"), o = t.createTreeWalker(t.body, NodeFilter.SHOW_TEXT);
235
+ const n = new DOMParser().parseFromString(e, "text/html"), o = n.createTreeWalker(n.body, NodeFilter.SHOW_TEXT);
230
236
  let s = o.nextNode();
231
237
  for (; s; )
232
- s.textContent = G(s.textContent || ""), s = o.nextNode();
233
- return t.body.innerHTML;
234
- }, W = {
238
+ s.textContent = q(s.textContent || ""), s = o.nextNode();
239
+ return n.body.innerHTML;
240
+ }, J = {
235
241
  minSegmentLength: 32,
236
242
  maxSegmentLength: 64,
237
243
  rebalanceRatio: 0.4
238
- }, L = /[一-鿿㐀-䶿豈-﫿 -〿＀-￯]/, I = /[。!?!?\.]/, P = /[;;]/, M = /[,,::]/, Y = /[、]/, R = "", S = "", p = (e) => {
239
- let n = 0;
240
- for (const t of e)
241
- n += L.test(t) ? 2 : 1;
242
- return n;
243
- }, K = (e) => e.replace(/\r/g, "").split(`
244
- `).map((n) => n.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), q = (e) => {
245
- let n = e, t = "";
246
- for (; t !== n; )
247
- t = n, n = n.replace(/(\d),(\d)/g, `$1${R}$2`);
248
- for (t = ""; t !== n; )
249
- t = n, n = n.replace(/(\d)\.(\d)/g, `$1${S}$2`);
250
- return n;
251
- }, b = (e) => e.split(R).join(",").split(S).join("."), E = (e, n) => {
244
+ }, O = /[一-鿿㐀-䶿豈-﫿 -〿＀-￯]/, F = /[。!?!?\.]/, P = /[;;]/, C = /[,,::]/, Z = /[、]/, L = "", A = "", p = (e) => {
252
245
  let t = 0;
246
+ for (const n of e)
247
+ t += O.test(n) ? 2 : 1;
248
+ return t;
249
+ }, Q = (e) => e.replace(/\r/g, "").split(`
250
+ `).map((t) => t.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), ee = (e) => {
251
+ let t = e, n = "";
252
+ for (; n !== t; )
253
+ n = t, t = t.replace(/(\d),(\d)/g, `$1${L}$2`);
254
+ for (n = ""; n !== t; )
255
+ n = t, t = t.replace(/(\d)\.(\d)/g, `$1${A}$2`);
256
+ return t;
257
+ }, b = (e) => e.split(L).join(",").split(A).join("."), m = (e, t) => {
258
+ let n = 0;
253
259
  for (let o = 0; o < e.length; o += 1)
254
- if (t += L.test(e[o]) ? 2 : 1, t >= n)
260
+ if (n += O.test(e[o]) ? 2 : 1, n >= t)
255
261
  return o + 1;
256
262
  return e.length;
257
- }, x = (e, n, t, o, s) => {
258
- let l = -1, r = Number.POSITIVE_INFINITY;
259
- const i = Math.max(1, t), c = Math.min(e.length - 1, o);
260
- for (let a = i; a <= c; a += 1) {
261
- if (!s.test(e[a - 1]))
263
+ }, _ = (e, t, n, o, s) => {
264
+ let a = -1, r = Number.POSITIVE_INFINITY;
265
+ const i = Math.max(1, n), c = Math.min(e.length - 1, o);
266
+ for (let l = i; l <= c; l += 1) {
267
+ if (!s.test(e[l - 1]))
262
268
  continue;
263
- const u = Math.abs(a - n);
264
- if (u < r && (r = u, l = a), a > n && l >= 0)
269
+ const u = Math.abs(l - t);
270
+ if (u < r && (r = u, a = l), l > t && a >= 0)
265
271
  break;
266
272
  }
267
- return l;
268
- }, J = (e, n, t, o) => {
269
- let s = -1, l = Number.POSITIVE_INFINITY;
270
- const r = Math.max(1, t), i = Math.min(e.length - 1, o);
273
+ return a;
274
+ }, te = (e, t, n, o) => {
275
+ let s = -1, a = Number.POSITIVE_INFINITY;
276
+ const r = Math.max(1, n), i = Math.min(e.length - 1, o);
271
277
  for (let c = r; c <= i; c += 1) {
272
278
  if (e[c - 1] !== " ")
273
279
  continue;
274
- const a = Math.abs(c - n);
275
- if (a < l && (l = a, s = c), c > n && s >= 0)
280
+ const l = Math.abs(c - t);
281
+ if (l < a && (a = l, s = c), c > t && s >= 0)
276
282
  break;
277
283
  }
278
284
  return s;
279
- }, C = (e, n, t, o, s) => {
285
+ }, S = (e, t, n, o, s) => {
280
286
  for (const r of s) {
281
- const i = x(
287
+ const i = _(
282
288
  e,
283
- n,
284
289
  t,
290
+ n,
285
291
  o,
286
292
  r
287
293
  );
288
294
  if (i >= 0)
289
295
  return i;
290
296
  }
291
- const l = J(
297
+ const a = te(
292
298
  e,
293
- n,
294
299
  t,
300
+ n,
295
301
  o
296
302
  );
297
- return l >= 0 ? l : x(
303
+ return a >= 0 ? a : _(
298
304
  e,
299
- n,
300
305
  t,
306
+ n,
301
307
  o,
302
- Y
308
+ Z
303
309
  );
304
- }, Z = (e, n) => {
305
- const t = [];
310
+ }, ne = (e, t) => {
311
+ const n = [];
306
312
  let o = e.trim();
307
- for (; o && p(o) > n; ) {
308
- const s = p(o), l = Math.min(
313
+ for (; o && p(o) > t; ) {
314
+ const s = p(o), a = Math.min(
309
315
  Math.floor(s / 2),
310
- n
311
- ), r = E(o, l), i = Math.max(1, Math.floor(r / 3)), c = Math.max(
316
+ t
317
+ ), r = m(o, a), i = Math.max(1, Math.floor(r / 3)), c = Math.max(
312
318
  r + 1,
313
- E(o, n)
319
+ m(o, t)
314
320
  );
315
- let a = C(
321
+ let l = S(
316
322
  o,
317
323
  r,
318
324
  i,
319
325
  c,
320
- [P, M]
326
+ [P, C]
321
327
  );
322
- (a < 0 || a >= o.length) && (a = r), t.push(o.slice(0, a).trim()), o = o.slice(a).trim();
328
+ (l < 0 || l >= o.length) && (l = r), n.push(o.slice(0, l).trim()), o = o.slice(l).trim();
323
329
  }
324
- return o && t.push(o), t;
325
- }, Q = (e, n) => {
330
+ return o && n.push(o), n;
331
+ }, oe = (e, t) => {
326
332
  if (e.length <= 1)
327
333
  return e;
328
- const t = e[e.length - 1], o = e.reduce((T, m) => T + p(m), 0) / e.length, s = Math.floor(o * n);
329
- if (p(t) >= s)
334
+ const n = e[e.length - 1], o = e.reduce((T, E) => T + p(E), 0) / e.length, s = Math.floor(o * t);
335
+ if (p(n) >= s)
330
336
  return e;
331
- const r = `${e[e.length - 2]}${t}`, i = Math.floor(p(r) / 2), c = E(r, i), a = Math.max(1, Math.floor(c / 3));
332
- let u = C(
337
+ const r = `${e[e.length - 2]}${n}`, i = Math.floor(p(r) / 2), c = m(r, i), l = Math.max(1, Math.floor(c / 3));
338
+ let u = S(
333
339
  r,
334
340
  c,
335
- a,
341
+ l,
336
342
  r.length,
337
- [I, P, M]
343
+ [F, P, C]
338
344
  );
339
345
  if (u <= 0 || u >= r.length)
340
346
  return e;
341
347
  const g = [...e];
342
348
  return g[g.length - 2] = r.slice(0, u).trim(), g[g.length - 1] = r.slice(u).trim(), g.filter(Boolean);
343
- }, ee = (e, n = {}) => {
344
- const t = {
345
- ...W,
346
- ...n
347
- }, o = K(e);
349
+ }, re = (e, t = {}) => {
350
+ const n = {
351
+ ...J,
352
+ ...t
353
+ }, o = Q(e);
348
354
  if (!o)
349
355
  return [];
350
- const s = q(o);
351
- if (p(s) <= t.minSegmentLength)
356
+ const s = ee(o);
357
+ if (p(s) <= n.minSegmentLength)
352
358
  return [b(s)];
353
- const l = [], r = s.split(new RegExp("(?<=[。!?!?\\.])"));
359
+ const a = [], r = s.split(new RegExp("(?<=[。!?!?\\.])"));
354
360
  let i = "";
355
- for (const a of r) {
356
- if (!a)
361
+ for (const l of r) {
362
+ if (!l)
357
363
  continue;
358
- i += a;
364
+ i += l;
359
365
  const u = i[i.length - 1] ?? "";
360
- p(i) >= t.minSegmentLength && I.test(u) && (l.push(i.trim()), i = "");
366
+ p(i) >= n.minSegmentLength && F.test(u) && (a.push(i.trim()), i = "");
361
367
  }
362
- i && (l.length > 0 && p(i) < t.minSegmentLength ? l[l.length - 1] += i : l.push(i.trim()));
363
- const c = l.flatMap((a) => p(a) <= t.maxSegmentLength ? [a] : Z(a, t.maxSegmentLength));
364
- return Q(
368
+ i && (a.length > 0 && p(i) < n.minSegmentLength ? a[a.length - 1] += i : a.push(i.trim()));
369
+ const c = a.flatMap((l) => p(l) <= n.maxSegmentLength ? [l] : ne(l, n.maxSegmentLength));
370
+ return oe(
365
371
  c,
366
- t.rebalanceRatio
372
+ n.rebalanceRatio
367
373
  ).map(b);
368
- }, A = (e) => e.type === "text" ? e.text || "" : (e.content || []).map(A).join(""), te = (e) => {
369
- const n = e.content || [];
370
- let t = "";
371
- const o = [], s = [], l = {
372
- [h.stop.type]: ({ position: r, actionCode: i }) => {
374
+ }, M = (e) => e.type === "text" ? e.text || "" : (e.content || []).map(M).join(""), se = (e) => {
375
+ const t = e.content || [];
376
+ let n = "";
377
+ const o = [], s = [], a = {
378
+ [f.stop.type]: ({ position: r, actionCode: i }) => {
373
379
  o.push({
374
380
  action: "insert",
375
381
  model: "control",
@@ -379,7 +385,7 @@ const pe = [
379
385
  actionCode: i
380
386
  });
381
387
  },
382
- [h.customStop.type]: ({ payload: r, position: i, actionCode: c }) => {
388
+ [f.customStop.type]: ({ payload: r, position: i, actionCode: c }) => {
383
389
  o.push({
384
390
  action: "insert",
385
391
  model: "control",
@@ -389,7 +395,7 @@ const pe = [
389
395
  actionCode: c
390
396
  });
391
397
  },
392
- [h.continue.type]: ({ position: r, text: i, actionCode: c }) => {
398
+ [f.continue.type]: ({ position: r, text: i, actionCode: c }) => {
393
399
  o.push({
394
400
  action: "replace",
395
401
  model: "replace",
@@ -399,11 +405,11 @@ const pe = [
399
405
  actionCode: c
400
406
  });
401
407
  },
402
- [h.replace.type]: ({
408
+ [f.replace.type]: ({
403
409
  payload: r,
404
410
  position: i,
405
411
  text: c,
406
- actionCode: a
412
+ actionCode: l
407
413
  }) => {
408
414
  o.push({
409
415
  action: "replace",
@@ -411,24 +417,24 @@ const pe = [
411
417
  payload: `${r == null ? void 0 : r.text}`,
412
418
  position: i,
413
419
  text: c,
414
- actionCode: a
420
+ actionCode: l
415
421
  });
416
422
  },
417
- [h.pinyin.type]: ({ payload: r, position: i, text: c, actionCode: a }) => {
423
+ [f.pinyin.type]: ({ payload: r, position: i, text: c, actionCode: l }) => {
418
424
  o.push({
419
425
  action: "replace",
420
426
  model: "pinyin",
421
427
  payload: `${r == null ? void 0 : r.text}`,
422
428
  position: i,
423
429
  text: c,
424
- actionCode: a
430
+ actionCode: l
425
431
  });
426
432
  },
427
- [h.language.type]: ({
433
+ [f.language.type]: ({
428
434
  payload: r,
429
435
  position: i,
430
436
  text: c,
431
- actionCode: a
437
+ actionCode: l
432
438
  }) => {
433
439
  o.push({
434
440
  action: "language",
@@ -436,10 +442,10 @@ const pe = [
436
442
  payload: `${r == null ? void 0 : r.code}`,
437
443
  position: i,
438
444
  text: c,
439
- actionCode: a
445
+ actionCode: l
440
446
  });
441
447
  },
442
- [h.ignore.type]: ({
448
+ [f.ignore.type]: ({
443
449
  position: r,
444
450
  text: i,
445
451
  actionCode: c
@@ -454,74 +460,74 @@ const pe = [
454
460
  });
455
461
  }
456
462
  };
457
- return n.forEach((r) => {
458
- var T, m;
463
+ return t.forEach((r) => {
464
+ var T, E;
459
465
  if (r.type === "text") {
460
- t += r.text || "";
466
+ n += r.text || "";
461
467
  return;
462
468
  }
463
469
  if (r.type !== "customTag") return;
464
- const i = (T = r.attrs) == null ? void 0 : T.categ, c = (m = r.attrs) == null ? void 0 : m.payload, a = t.length, u = A(r), g = l[i];
470
+ const i = (T = r.attrs) == null ? void 0 : T.categ, c = (E = r.attrs) == null ? void 0 : E.payload, l = n.length, u = M(r), g = a[i];
465
471
  u && s.push({
466
- start: a,
467
- end: a + u.length
472
+ start: l,
473
+ end: l + u.length
468
474
  }), g && g({
469
475
  payload: c,
470
- position: a,
476
+ position: l,
471
477
  text: u,
472
478
  actionCode: i
473
- }), t += u;
479
+ }), n += u;
474
480
  }), {
475
- text: t,
481
+ text: n,
476
482
  protectedRanges: s,
477
483
  playments: o
478
484
  };
479
- }, N = (e) => e.type === "text" || e.type === "customTag", ne = (e) => {
480
- const n = e.content || [];
485
+ }, N = (e) => e.type === "text" || e.type === "customTag", ie = (e) => {
486
+ const t = e.content || [];
481
487
  if (e.type === "paragraph") return [e];
482
488
  if (e.type === "doc")
483
- return n.filter((o) => o.type === "paragraph");
484
- const t = n.filter(
489
+ return t.filter((o) => o.type === "paragraph");
490
+ const n = t.filter(
485
491
  (o) => o.type === "paragraph"
486
492
  );
487
- return t.length ? t : n.some(N) ? [
493
+ return n.length ? n : t.some(N) ? [
488
494
  {
489
495
  type: "paragraph",
490
- content: n.filter(N)
496
+ content: t.filter(N)
491
497
  }
492
498
  ] : [];
493
- }, oe = (e, n) => {
494
- let t = 0;
495
- return n.map((o) => {
496
- const s = e.indexOf(o, t), l = s >= 0 ? s : t, r = l + o.length;
497
- return t = r, {
499
+ }, ae = (e, t) => {
500
+ let n = 0;
501
+ return t.map((o) => {
502
+ const s = e.indexOf(o, n), a = s >= 0 ? s : n, r = a + o.length;
503
+ return n = r, {
498
504
  text: o,
499
- start: l,
505
+ start: a,
500
506
  end: r
501
507
  };
502
508
  });
503
- }, re = (e, n) => e.reduce((t, o) => {
504
- if (n.some(
505
- (l) => o.start > l.start && o.start < l.end
506
- ) && t.length) {
507
- const l = t[t.length - 1];
508
- return l.text += o.text, l.end = o.end, t;
509
+ }, le = (e, t) => e.reduce((n, o) => {
510
+ if (t.some(
511
+ (a) => o.start > a.start && o.start < a.end
512
+ ) && n.length) {
513
+ const a = n[n.length - 1];
514
+ return a.text += o.text, a.end = o.end, n;
509
515
  }
510
- return t.push({ ...o }), t;
511
- }, []), se = (e, n, t, o) => e.position >= n && e.position < t ? !0 : !e.text && o && e.position === t, ie = (e) => {
512
- const n = ee(e.text);
513
- if (n.length <= 1) return [e];
514
- const t = re(
515
- oe(e.text, n),
516
+ return n.push({ ...o }), n;
517
+ }, []), ce = (e, t, n, o) => e.position >= t && e.position < n ? !0 : !e.text && o && e.position === n, ue = (e) => {
518
+ const t = re(e.text);
519
+ if (t.length <= 1) return [e];
520
+ const n = le(
521
+ ae(e.text, t),
516
522
  e.protectedRanges || []
517
523
  );
518
- return t.map((o, s) => {
519
- const l = s === t.length - 1, r = e.playments.filter(
520
- (i) => se(
524
+ return n.map((o, s) => {
525
+ const a = s === n.length - 1, r = e.playments.filter(
526
+ (i) => ce(
521
527
  i,
522
528
  o.start,
523
529
  o.end,
524
- l
530
+ a
525
531
  )
526
532
  ).map((i) => ({
527
533
  ...i,
@@ -532,35 +538,36 @@ const pe = [
532
538
  playments: r
533
539
  };
534
540
  });
535
- }, he = (e) => {
536
- const n = {
541
+ }, me = (e) => {
542
+ const t = {
537
543
  playments: [],
538
544
  sentences: []
539
545
  };
540
- return ne(e).forEach((o) => {
541
- const s = te(o);
542
- !s.text && !s.playments.length || ie(s).forEach(({ text: l, playments: r }) => {
543
- n.sentences.push(l), n.playments.push(r);
546
+ return ie(e).forEach((o) => {
547
+ const s = se(o);
548
+ !s.text && !s.playments.length || ue(s).forEach(({ text: a, playments: r }) => {
549
+ t.sentences.push(a), t.playments.push(r);
544
550
  });
545
- }), n;
551
+ }), t;
546
552
  };
547
553
  export {
548
- f as DeleteMode,
549
- _ as LanguageOptions,
550
- pe as NumberToTextTools,
551
- le as StopOptions,
552
- h as ToolConfig,
554
+ h as DeleteMode,
555
+ x as LanguageOptions,
556
+ Te as NumberToTextTools,
557
+ pe as StopOptions,
558
+ f as ToolConfig,
553
559
  v as allToolTypes,
554
- he as convertToTtsFormat,
555
- ce as getInitContent,
560
+ me as convertToTtsFormat,
561
+ he as estimateTtsDuration,
562
+ fe as getInitContent,
556
563
  p as getVisualLength,
557
- ae as resolveTtsEditorFeatures,
558
- ge as sanitizePastedHtml,
559
- G as sanitizePastedText,
560
- ee as splitTextToSentences,
561
- B as toCardinal,
562
- j as toColloquial,
563
- ue as toPhoneReading,
564
- F as toPositional,
565
- te as transformParagraph
564
+ ge as resolveTtsEditorFeatures,
565
+ Ee as sanitizePastedHtml,
566
+ q as sanitizePastedText,
567
+ re as splitTextToSentences,
568
+ j as toCardinal,
569
+ z as toColloquial,
570
+ de as toPhoneReading,
571
+ y as toPositional,
572
+ se as transformParagraph
566
573
  };