@naersen/tts-rich-text 0.5.0 → 0.7.0

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