@forevka/wordcanvas 0.7.0 → 0.7.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.
Files changed (47) hide show
  1. package/README.md +48 -1
  2. package/dist-lib/assets/{worker-BsOsK39A.js → worker-D8rUOKfg.js} +9603 -9451
  3. package/dist-lib/assets/worker-wXuuyshQ.js +2258 -0
  4. package/dist-lib/{blockFactory-Bcy0U40y.js → blockFactory-CUI4Rqiq.js} +50 -42
  5. package/dist-lib/{browser-5Sv4CuNy.js → browser-DkKxreJM.js} +404 -383
  6. package/dist-lib/builder.js +364 -109
  7. package/dist-lib/editorApp-DLXMmtu5.js +8023 -0
  8. package/dist-lib/export.js +3820 -3768
  9. package/dist-lib/generate-toc.js +4 -4
  10. package/dist-lib/import.js +4 -1538
  11. package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
  12. package/dist-lib/pipeline-CbxmCE84.js +1705 -0
  13. package/dist-lib/recalc-docx.js +2 -2
  14. package/dist-lib/recalcToc-g1hFKSNs.js +3935 -0
  15. package/dist-lib/toc-B6VpkJge.js +213 -0
  16. package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-6WxRNKCc.js} +2 -2
  17. package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-CFqpDK0k.js} +1 -1
  18. package/dist-lib/wordcanvas.js +1 -1
  19. package/dist-node/{chunk-GXFDF7UY.js → chunk-22JHAERT.js} +95 -23
  20. package/dist-node/chunk-22JHAERT.js.map +7 -0
  21. package/dist-node/{chunk-2RCPB7UZ.js → chunk-6AJJMHKY.js} +1 -1
  22. package/dist-node/chunk-6AJJMHKY.js.map +7 -0
  23. package/dist-node/{chunk-XDUDPPJW.js → chunk-CDN6WU2P.js} +89 -26
  24. package/dist-node/chunk-CDN6WU2P.js.map +7 -0
  25. package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
  26. package/dist-node/chunk-EGSAVPCC.js.map +7 -0
  27. package/dist-node/{chunk-IJLL6IFJ.js → chunk-RNB336F3.js} +116 -5
  28. package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-RNB336F3.js.map} +2 -2
  29. package/dist-node/{engine-FRCX7PXF.js → engine-5FGDJD2H.js} +3 -3
  30. package/dist-node/export.js +92 -31
  31. package/dist-node/export.js.map +2 -2
  32. package/dist-node/generate-toc.js +5 -5
  33. package/dist-node/import.js +3 -3
  34. package/dist-node/recalc-docx.js +4 -4
  35. package/dist-node/recalc-docx.js.map +1 -1
  36. package/package.json +1 -1
  37. package/types/model.d.ts +231 -225
  38. package/types/recalc-docx.d.ts +27 -27
  39. package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
  40. package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
  41. package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
  42. package/dist-lib/toc-CZel_Kk3.js +0 -127
  43. package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
  44. package/dist-node/chunk-GXFDF7UY.js.map +0 -7
  45. package/dist-node/chunk-TBSXA2I4.js.map +0 -7
  46. package/dist-node/chunk-XDUDPPJW.js.map +0 -7
  47. /package/dist-node/{engine-FRCX7PXF.js.map → engine-5FGDJD2H.js.map} +0 -0
@@ -1,3835 +0,0 @@
1
- import { q as mn, F as En, t as Bn, f as Mn } from "./browser-5Sv4CuNy.js";
2
- import { e as Cn, f as Oe } from "./lists-BegzmTmD.js";
3
- import { m as fe, q as tt, t as Ie } from "./metrics-CkAo4zh8.js";
4
- const kn = [
5
- "BN",
6
- "BN",
7
- "BN",
8
- "BN",
9
- "BN",
10
- "BN",
11
- "BN",
12
- "BN",
13
- "BN",
14
- "S",
15
- "B",
16
- "S",
17
- "WS",
18
- "B",
19
- "BN",
20
- "BN",
21
- "BN",
22
- "BN",
23
- "BN",
24
- "BN",
25
- "BN",
26
- "BN",
27
- "BN",
28
- "BN",
29
- "BN",
30
- "BN",
31
- "BN",
32
- "BN",
33
- "B",
34
- "B",
35
- "B",
36
- "S",
37
- "WS",
38
- "ON",
39
- "ON",
40
- "ET",
41
- "ET",
42
- "ET",
43
- "ON",
44
- "ON",
45
- "ON",
46
- "ON",
47
- "ON",
48
- "ES",
49
- "CS",
50
- "ES",
51
- "CS",
52
- "CS",
53
- "EN",
54
- "EN",
55
- "EN",
56
- "EN",
57
- "EN",
58
- "EN",
59
- "EN",
60
- "EN",
61
- "EN",
62
- "EN",
63
- "CS",
64
- "ON",
65
- "ON",
66
- "ON",
67
- "ON",
68
- "ON",
69
- "ON",
70
- "L",
71
- "L",
72
- "L",
73
- "L",
74
- "L",
75
- "L",
76
- "L",
77
- "L",
78
- "L",
79
- "L",
80
- "L",
81
- "L",
82
- "L",
83
- "L",
84
- "L",
85
- "L",
86
- "L",
87
- "L",
88
- "L",
89
- "L",
90
- "L",
91
- "L",
92
- "L",
93
- "L",
94
- "L",
95
- "L",
96
- "ON",
97
- "ON",
98
- "ON",
99
- "ON",
100
- "ON",
101
- "ON",
102
- "L",
103
- "L",
104
- "L",
105
- "L",
106
- "L",
107
- "L",
108
- "L",
109
- "L",
110
- "L",
111
- "L",
112
- "L",
113
- "L",
114
- "L",
115
- "L",
116
- "L",
117
- "L",
118
- "L",
119
- "L",
120
- "L",
121
- "L",
122
- "L",
123
- "L",
124
- "L",
125
- "L",
126
- "L",
127
- "L",
128
- "ON",
129
- "ON",
130
- "ON",
131
- "ON",
132
- "BN",
133
- "BN",
134
- "BN",
135
- "BN",
136
- "BN",
137
- "BN",
138
- "B",
139
- "BN",
140
- "BN",
141
- "BN",
142
- "BN",
143
- "BN",
144
- "BN",
145
- "BN",
146
- "BN",
147
- "BN",
148
- "BN",
149
- "BN",
150
- "BN",
151
- "BN",
152
- "BN",
153
- "BN",
154
- "BN",
155
- "BN",
156
- "BN",
157
- "BN",
158
- "BN",
159
- "BN",
160
- "BN",
161
- "BN",
162
- "BN",
163
- "BN",
164
- "BN",
165
- "CS",
166
- "ON",
167
- "ET",
168
- "ET",
169
- "ET",
170
- "ET",
171
- "ON",
172
- "ON",
173
- "ON",
174
- "ON",
175
- "L",
176
- "ON",
177
- "ON",
178
- "BN",
179
- "ON",
180
- "ON",
181
- "ET",
182
- "ET",
183
- "EN",
184
- "EN",
185
- "ON",
186
- "L",
187
- "ON",
188
- "ON",
189
- "ON",
190
- "EN",
191
- "L",
192
- "ON",
193
- "ON",
194
- "ON",
195
- "ON",
196
- "ON",
197
- "L",
198
- "L",
199
- "L",
200
- "L",
201
- "L",
202
- "L",
203
- "L",
204
- "L",
205
- "L",
206
- "L",
207
- "L",
208
- "L",
209
- "L",
210
- "L",
211
- "L",
212
- "L",
213
- "L",
214
- "L",
215
- "L",
216
- "L",
217
- "L",
218
- "L",
219
- "L",
220
- "ON",
221
- "L",
222
- "L",
223
- "L",
224
- "L",
225
- "L",
226
- "L",
227
- "L",
228
- "L",
229
- "L",
230
- "L",
231
- "L",
232
- "L",
233
- "L",
234
- "L",
235
- "L",
236
- "L",
237
- "L",
238
- "L",
239
- "L",
240
- "L",
241
- "L",
242
- "L",
243
- "L",
244
- "L",
245
- "L",
246
- "L",
247
- "L",
248
- "L",
249
- "L",
250
- "L",
251
- "L",
252
- "ON",
253
- "L",
254
- "L",
255
- "L",
256
- "L",
257
- "L",
258
- "L",
259
- "L",
260
- "L"
261
- ], At = [
262
- [697, 698, "ON"],
263
- [706, 719, "ON"],
264
- [722, 735, "ON"],
265
- [741, 749, "ON"],
266
- [751, 767, "ON"],
267
- [768, 879, "NSM"],
268
- [884, 885, "ON"],
269
- [894, 894, "ON"],
270
- [900, 901, "ON"],
271
- [903, 903, "ON"],
272
- [1014, 1014, "ON"],
273
- [1155, 1161, "NSM"],
274
- [1418, 1418, "ON"],
275
- [1421, 1422, "ON"],
276
- [1423, 1423, "ET"],
277
- [1424, 1424, "R"],
278
- [1425, 1469, "NSM"],
279
- [1470, 1470, "R"],
280
- [1471, 1471, "NSM"],
281
- [1472, 1472, "R"],
282
- [1473, 1474, "NSM"],
283
- [1475, 1475, "R"],
284
- [1476, 1477, "NSM"],
285
- [1478, 1478, "R"],
286
- [1479, 1479, "NSM"],
287
- [1480, 1535, "R"],
288
- [1536, 1541, "AN"],
289
- [1542, 1543, "ON"],
290
- [1544, 1544, "AL"],
291
- [1545, 1546, "ET"],
292
- [1547, 1547, "AL"],
293
- [1548, 1548, "CS"],
294
- [1549, 1549, "AL"],
295
- [1550, 1551, "ON"],
296
- [1552, 1562, "NSM"],
297
- [1563, 1610, "AL"],
298
- [1611, 1631, "NSM"],
299
- [1632, 1641, "AN"],
300
- [1642, 1642, "ET"],
301
- [1643, 1644, "AN"],
302
- [1645, 1647, "AL"],
303
- [1648, 1648, "NSM"],
304
- [1649, 1749, "AL"],
305
- [1750, 1756, "NSM"],
306
- [1757, 1757, "AN"],
307
- [1758, 1758, "ON"],
308
- [1759, 1764, "NSM"],
309
- [1765, 1766, "AL"],
310
- [1767, 1768, "NSM"],
311
- [1769, 1769, "ON"],
312
- [1770, 1773, "NSM"],
313
- [1774, 1775, "AL"],
314
- [1776, 1785, "EN"],
315
- [1786, 1808, "AL"],
316
- [1809, 1809, "NSM"],
317
- [1810, 1839, "AL"],
318
- [1840, 1866, "NSM"],
319
- [1867, 1957, "AL"],
320
- [1958, 1968, "NSM"],
321
- [1969, 1983, "AL"],
322
- [1984, 2026, "R"],
323
- [2027, 2035, "NSM"],
324
- [2036, 2037, "R"],
325
- [2038, 2041, "ON"],
326
- [2042, 2044, "R"],
327
- [2045, 2045, "NSM"],
328
- [2046, 2069, "R"],
329
- [2070, 2073, "NSM"],
330
- [2074, 2074, "R"],
331
- [2075, 2083, "NSM"],
332
- [2084, 2084, "R"],
333
- [2085, 2087, "NSM"],
334
- [2088, 2088, "R"],
335
- [2089, 2093, "NSM"],
336
- [2094, 2136, "R"],
337
- [2137, 2139, "NSM"],
338
- [2140, 2143, "R"],
339
- [2144, 2191, "AL"],
340
- [2192, 2193, "AN"],
341
- [2194, 2198, "AL"],
342
- [2199, 2207, "NSM"],
343
- [2208, 2249, "AL"],
344
- [2250, 2273, "NSM"],
345
- [2274, 2274, "AN"],
346
- [2275, 2306, "NSM"],
347
- [2362, 2362, "NSM"],
348
- [2364, 2364, "NSM"],
349
- [2369, 2376, "NSM"],
350
- [2381, 2381, "NSM"],
351
- [2385, 2391, "NSM"],
352
- [2402, 2403, "NSM"],
353
- [2433, 2433, "NSM"],
354
- [2492, 2492, "NSM"],
355
- [2497, 2500, "NSM"],
356
- [2509, 2509, "NSM"],
357
- [2530, 2531, "NSM"],
358
- [2546, 2547, "ET"],
359
- [2555, 2555, "ET"],
360
- [2558, 2558, "NSM"],
361
- [2561, 2562, "NSM"],
362
- [2620, 2620, "NSM"],
363
- [2625, 2626, "NSM"],
364
- [2631, 2632, "NSM"],
365
- [2635, 2637, "NSM"],
366
- [2641, 2641, "NSM"],
367
- [2672, 2673, "NSM"],
368
- [2677, 2677, "NSM"],
369
- [2689, 2690, "NSM"],
370
- [2748, 2748, "NSM"],
371
- [2753, 2757, "NSM"],
372
- [2759, 2760, "NSM"],
373
- [2765, 2765, "NSM"],
374
- [2786, 2787, "NSM"],
375
- [2801, 2801, "ET"],
376
- [2810, 2815, "NSM"],
377
- [2817, 2817, "NSM"],
378
- [2876, 2876, "NSM"],
379
- [2879, 2879, "NSM"],
380
- [2881, 2884, "NSM"],
381
- [2893, 2893, "NSM"],
382
- [2901, 2902, "NSM"],
383
- [2914, 2915, "NSM"],
384
- [2946, 2946, "NSM"],
385
- [3008, 3008, "NSM"],
386
- [3021, 3021, "NSM"],
387
- [3059, 3064, "ON"],
388
- [3065, 3065, "ET"],
389
- [3066, 3066, "ON"],
390
- [3072, 3072, "NSM"],
391
- [3076, 3076, "NSM"],
392
- [3132, 3132, "NSM"],
393
- [3134, 3136, "NSM"],
394
- [3142, 3144, "NSM"],
395
- [3146, 3149, "NSM"],
396
- [3157, 3158, "NSM"],
397
- [3170, 3171, "NSM"],
398
- [3192, 3198, "ON"],
399
- [3201, 3201, "NSM"],
400
- [3260, 3260, "NSM"],
401
- [3276, 3277, "NSM"],
402
- [3298, 3299, "NSM"],
403
- [3328, 3329, "NSM"],
404
- [3387, 3388, "NSM"],
405
- [3393, 3396, "NSM"],
406
- [3405, 3405, "NSM"],
407
- [3426, 3427, "NSM"],
408
- [3457, 3457, "NSM"],
409
- [3530, 3530, "NSM"],
410
- [3538, 3540, "NSM"],
411
- [3542, 3542, "NSM"],
412
- [3633, 3633, "NSM"],
413
- [3636, 3642, "NSM"],
414
- [3647, 3647, "ET"],
415
- [3655, 3662, "NSM"],
416
- [3761, 3761, "NSM"],
417
- [3764, 3772, "NSM"],
418
- [3784, 3790, "NSM"],
419
- [3864, 3865, "NSM"],
420
- [3893, 3893, "NSM"],
421
- [3895, 3895, "NSM"],
422
- [3897, 3897, "NSM"],
423
- [3898, 3901, "ON"],
424
- [3953, 3966, "NSM"],
425
- [3968, 3972, "NSM"],
426
- [3974, 3975, "NSM"],
427
- [3981, 3991, "NSM"],
428
- [3993, 4028, "NSM"],
429
- [4038, 4038, "NSM"],
430
- [4141, 4144, "NSM"],
431
- [4146, 4151, "NSM"],
432
- [4153, 4154, "NSM"],
433
- [4157, 4158, "NSM"],
434
- [4184, 4185, "NSM"],
435
- [4190, 4192, "NSM"],
436
- [4209, 4212, "NSM"],
437
- [4226, 4226, "NSM"],
438
- [4229, 4230, "NSM"],
439
- [4237, 4237, "NSM"],
440
- [4253, 4253, "NSM"],
441
- [4957, 4959, "NSM"],
442
- [5008, 5017, "ON"],
443
- [5120, 5120, "ON"],
444
- [5760, 5760, "WS"],
445
- [5787, 5788, "ON"],
446
- [5906, 5908, "NSM"],
447
- [5938, 5939, "NSM"],
448
- [5970, 5971, "NSM"],
449
- [6002, 6003, "NSM"],
450
- [6068, 6069, "NSM"],
451
- [6071, 6077, "NSM"],
452
- [6086, 6086, "NSM"],
453
- [6089, 6099, "NSM"],
454
- [6107, 6107, "ET"],
455
- [6109, 6109, "NSM"],
456
- [6128, 6137, "ON"],
457
- [6144, 6154, "ON"],
458
- [6155, 6157, "NSM"],
459
- [6158, 6158, "BN"],
460
- [6159, 6159, "NSM"],
461
- [6277, 6278, "NSM"],
462
- [6313, 6313, "NSM"],
463
- [6432, 6434, "NSM"],
464
- [6439, 6440, "NSM"],
465
- [6450, 6450, "NSM"],
466
- [6457, 6459, "NSM"],
467
- [6464, 6464, "ON"],
468
- [6468, 6469, "ON"],
469
- [6622, 6655, "ON"],
470
- [6679, 6680, "NSM"],
471
- [6683, 6683, "NSM"],
472
- [6742, 6742, "NSM"],
473
- [6744, 6750, "NSM"],
474
- [6752, 6752, "NSM"],
475
- [6754, 6754, "NSM"],
476
- [6757, 6764, "NSM"],
477
- [6771, 6780, "NSM"],
478
- [6783, 6783, "NSM"],
479
- [6832, 6877, "NSM"],
480
- [6880, 6891, "NSM"],
481
- [6912, 6915, "NSM"],
482
- [6964, 6964, "NSM"],
483
- [6966, 6970, "NSM"],
484
- [6972, 6972, "NSM"],
485
- [6978, 6978, "NSM"],
486
- [7019, 7027, "NSM"],
487
- [7040, 7041, "NSM"],
488
- [7074, 7077, "NSM"],
489
- [7080, 7081, "NSM"],
490
- [7083, 7085, "NSM"],
491
- [7142, 7142, "NSM"],
492
- [7144, 7145, "NSM"],
493
- [7149, 7149, "NSM"],
494
- [7151, 7153, "NSM"],
495
- [7212, 7219, "NSM"],
496
- [7222, 7223, "NSM"],
497
- [7376, 7378, "NSM"],
498
- [7380, 7392, "NSM"],
499
- [7394, 7400, "NSM"],
500
- [7405, 7405, "NSM"],
501
- [7412, 7412, "NSM"],
502
- [7416, 7417, "NSM"],
503
- [7616, 7679, "NSM"],
504
- [8125, 8125, "ON"],
505
- [8127, 8129, "ON"],
506
- [8141, 8143, "ON"],
507
- [8157, 8159, "ON"],
508
- [8173, 8175, "ON"],
509
- [8189, 8190, "ON"],
510
- [8192, 8202, "WS"],
511
- [8203, 8205, "BN"],
512
- [8207, 8207, "R"],
513
- [8208, 8231, "ON"],
514
- [8232, 8232, "WS"],
515
- [8233, 8233, "B"],
516
- [8234, 8238, "BN"],
517
- [8239, 8239, "CS"],
518
- [8240, 8244, "ET"],
519
- [8245, 8259, "ON"],
520
- [8260, 8260, "CS"],
521
- [8261, 8286, "ON"],
522
- [8287, 8287, "WS"],
523
- [8288, 8303, "BN"],
524
- [8304, 8304, "EN"],
525
- [8308, 8313, "EN"],
526
- [8314, 8315, "ES"],
527
- [8316, 8318, "ON"],
528
- [8320, 8329, "EN"],
529
- [8330, 8331, "ES"],
530
- [8332, 8334, "ON"],
531
- [8352, 8399, "ET"],
532
- [8400, 8432, "NSM"],
533
- [8448, 8449, "ON"],
534
- [8451, 8454, "ON"],
535
- [8456, 8457, "ON"],
536
- [8468, 8468, "ON"],
537
- [8470, 8472, "ON"],
538
- [8478, 8483, "ON"],
539
- [8485, 8485, "ON"],
540
- [8487, 8487, "ON"],
541
- [8489, 8489, "ON"],
542
- [8494, 8494, "ET"],
543
- [8506, 8507, "ON"],
544
- [8512, 8516, "ON"],
545
- [8522, 8525, "ON"],
546
- [8528, 8543, "ON"],
547
- [8585, 8587, "ON"],
548
- [8592, 8721, "ON"],
549
- [8722, 8722, "ES"],
550
- [8723, 8723, "ET"],
551
- [8724, 9013, "ON"],
552
- [9083, 9108, "ON"],
553
- [9110, 9257, "ON"],
554
- [9280, 9290, "ON"],
555
- [9312, 9351, "ON"],
556
- [9352, 9371, "EN"],
557
- [9450, 9899, "ON"],
558
- [9901, 10239, "ON"],
559
- [10496, 11123, "ON"],
560
- [11126, 11263, "ON"],
561
- [11493, 11498, "ON"],
562
- [11503, 11505, "NSM"],
563
- [11513, 11519, "ON"],
564
- [11647, 11647, "NSM"],
565
- [11744, 11775, "NSM"],
566
- [11776, 11869, "ON"],
567
- [11904, 11929, "ON"],
568
- [11931, 12019, "ON"],
569
- [12032, 12245, "ON"],
570
- [12272, 12287, "ON"],
571
- [12288, 12288, "WS"],
572
- [12289, 12292, "ON"],
573
- [12296, 12320, "ON"],
574
- [12330, 12333, "NSM"],
575
- [12336, 12336, "ON"],
576
- [12342, 12343, "ON"],
577
- [12349, 12351, "ON"],
578
- [12441, 12442, "NSM"],
579
- [12443, 12444, "ON"],
580
- [12448, 12448, "ON"],
581
- [12539, 12539, "ON"],
582
- [12736, 12773, "ON"],
583
- [12783, 12783, "ON"],
584
- [12829, 12830, "ON"],
585
- [12880, 12895, "ON"],
586
- [12924, 12926, "ON"],
587
- [12977, 12991, "ON"],
588
- [13004, 13007, "ON"],
589
- [13175, 13178, "ON"],
590
- [13278, 13279, "ON"],
591
- [13311, 13311, "ON"],
592
- [19904, 19967, "ON"],
593
- [42128, 42182, "ON"],
594
- [42509, 42511, "ON"],
595
- [42607, 42610, "NSM"],
596
- [42611, 42611, "ON"],
597
- [42612, 42621, "NSM"],
598
- [42622, 42623, "ON"],
599
- [42654, 42655, "NSM"],
600
- [42736, 42737, "NSM"],
601
- [42752, 42785, "ON"],
602
- [42888, 42888, "ON"],
603
- [43010, 43010, "NSM"],
604
- [43014, 43014, "NSM"],
605
- [43019, 43019, "NSM"],
606
- [43045, 43046, "NSM"],
607
- [43048, 43051, "ON"],
608
- [43052, 43052, "NSM"],
609
- [43064, 43065, "ET"],
610
- [43124, 43127, "ON"],
611
- [43204, 43205, "NSM"],
612
- [43232, 43249, "NSM"],
613
- [43263, 43263, "NSM"],
614
- [43302, 43309, "NSM"],
615
- [43335, 43345, "NSM"],
616
- [43392, 43394, "NSM"],
617
- [43443, 43443, "NSM"],
618
- [43446, 43449, "NSM"],
619
- [43452, 43453, "NSM"],
620
- [43493, 43493, "NSM"],
621
- [43561, 43566, "NSM"],
622
- [43569, 43570, "NSM"],
623
- [43573, 43574, "NSM"],
624
- [43587, 43587, "NSM"],
625
- [43596, 43596, "NSM"],
626
- [43644, 43644, "NSM"],
627
- [43696, 43696, "NSM"],
628
- [43698, 43700, "NSM"],
629
- [43703, 43704, "NSM"],
630
- [43710, 43711, "NSM"],
631
- [43713, 43713, "NSM"],
632
- [43756, 43757, "NSM"],
633
- [43766, 43766, "NSM"],
634
- [43882, 43883, "ON"],
635
- [44005, 44005, "NSM"],
636
- [44008, 44008, "NSM"],
637
- [44013, 44013, "NSM"],
638
- [64285, 64285, "R"],
639
- [64286, 64286, "NSM"],
640
- [64287, 64296, "R"],
641
- [64297, 64297, "ES"],
642
- [64298, 64335, "R"],
643
- [64336, 64450, "AL"],
644
- [64451, 64466, "ON"],
645
- [64467, 64829, "AL"],
646
- [64830, 64847, "ON"],
647
- [64848, 64911, "AL"],
648
- [64912, 64913, "ON"],
649
- [64914, 64967, "AL"],
650
- [64968, 64975, "ON"],
651
- [64976, 65007, "BN"],
652
- [65008, 65020, "AL"],
653
- [65021, 65023, "ON"],
654
- [65024, 65039, "NSM"],
655
- [65040, 65049, "ON"],
656
- [65056, 65071, "NSM"],
657
- [65072, 65103, "ON"],
658
- [65104, 65104, "CS"],
659
- [65105, 65105, "ON"],
660
- [65106, 65106, "CS"],
661
- [65108, 65108, "ON"],
662
- [65109, 65109, "CS"],
663
- [65110, 65118, "ON"],
664
- [65119, 65119, "ET"],
665
- [65120, 65121, "ON"],
666
- [65122, 65123, "ES"],
667
- [65124, 65126, "ON"],
668
- [65128, 65128, "ON"],
669
- [65129, 65130, "ET"],
670
- [65131, 65131, "ON"],
671
- [65136, 65278, "AL"],
672
- [65279, 65279, "BN"],
673
- [65281, 65282, "ON"],
674
- [65283, 65285, "ET"],
675
- [65286, 65290, "ON"],
676
- [65291, 65291, "ES"],
677
- [65292, 65292, "CS"],
678
- [65293, 65293, "ES"],
679
- [65294, 65295, "CS"],
680
- [65296, 65305, "EN"],
681
- [65306, 65306, "CS"],
682
- [65307, 65312, "ON"],
683
- [65339, 65344, "ON"],
684
- [65371, 65381, "ON"],
685
- [65504, 65505, "ET"],
686
- [65506, 65508, "ON"],
687
- [65509, 65510, "ET"],
688
- [65512, 65518, "ON"],
689
- [65520, 65528, "BN"],
690
- [65529, 65533, "ON"],
691
- [65534, 65535, "BN"],
692
- [65793, 65793, "ON"],
693
- [65856, 65932, "ON"],
694
- [65936, 65948, "ON"],
695
- [65952, 65952, "ON"],
696
- [66045, 66045, "NSM"],
697
- [66272, 66272, "NSM"],
698
- [66273, 66299, "EN"],
699
- [66422, 66426, "NSM"],
700
- [67584, 67870, "R"],
701
- [67871, 67871, "ON"],
702
- [67872, 68096, "R"],
703
- [68097, 68099, "NSM"],
704
- [68100, 68100, "R"],
705
- [68101, 68102, "NSM"],
706
- [68103, 68107, "R"],
707
- [68108, 68111, "NSM"],
708
- [68112, 68151, "R"],
709
- [68152, 68154, "NSM"],
710
- [68155, 68158, "R"],
711
- [68159, 68159, "NSM"],
712
- [68160, 68324, "R"],
713
- [68325, 68326, "NSM"],
714
- [68327, 68408, "R"],
715
- [68409, 68415, "ON"],
716
- [68416, 68863, "R"],
717
- [68864, 68899, "AL"],
718
- [68900, 68903, "NSM"],
719
- [68904, 68911, "AL"],
720
- [68912, 68921, "AN"],
721
- [68922, 68927, "AL"],
722
- [68928, 68937, "AN"],
723
- [68938, 68968, "R"],
724
- [68969, 68973, "NSM"],
725
- [68974, 68974, "ON"],
726
- [68975, 69215, "R"],
727
- [69216, 69246, "AN"],
728
- [69247, 69290, "R"],
729
- [69291, 69292, "NSM"],
730
- [69293, 69311, "R"],
731
- [69312, 69327, "AL"],
732
- [69328, 69336, "ON"],
733
- [69337, 69369, "AL"],
734
- [69370, 69375, "NSM"],
735
- [69376, 69423, "R"],
736
- [69424, 69445, "AL"],
737
- [69446, 69456, "NSM"],
738
- [69457, 69487, "AL"],
739
- [69488, 69505, "R"],
740
- [69506, 69509, "NSM"],
741
- [69510, 69631, "R"],
742
- [69633, 69633, "NSM"],
743
- [69688, 69702, "NSM"],
744
- [69714, 69733, "ON"],
745
- [69744, 69744, "NSM"],
746
- [69747, 69748, "NSM"],
747
- [69759, 69761, "NSM"],
748
- [69811, 69814, "NSM"],
749
- [69817, 69818, "NSM"],
750
- [69826, 69826, "NSM"],
751
- [69888, 69890, "NSM"],
752
- [69927, 69931, "NSM"],
753
- [69933, 69940, "NSM"],
754
- [70003, 70003, "NSM"],
755
- [70016, 70017, "NSM"],
756
- [70070, 70078, "NSM"],
757
- [70089, 70092, "NSM"],
758
- [70095, 70095, "NSM"],
759
- [70191, 70193, "NSM"],
760
- [70196, 70196, "NSM"],
761
- [70198, 70199, "NSM"],
762
- [70206, 70206, "NSM"],
763
- [70209, 70209, "NSM"],
764
- [70367, 70367, "NSM"],
765
- [70371, 70378, "NSM"],
766
- [70400, 70401, "NSM"],
767
- [70459, 70460, "NSM"],
768
- [70464, 70464, "NSM"],
769
- [70502, 70508, "NSM"],
770
- [70512, 70516, "NSM"],
771
- [70587, 70592, "NSM"],
772
- [70606, 70606, "NSM"],
773
- [70608, 70608, "NSM"],
774
- [70610, 70610, "NSM"],
775
- [70625, 70626, "NSM"],
776
- [70712, 70719, "NSM"],
777
- [70722, 70724, "NSM"],
778
- [70726, 70726, "NSM"],
779
- [70750, 70750, "NSM"],
780
- [70835, 70840, "NSM"],
781
- [70842, 70842, "NSM"],
782
- [70847, 70848, "NSM"],
783
- [70850, 70851, "NSM"],
784
- [71090, 71093, "NSM"],
785
- [71100, 71101, "NSM"],
786
- [71103, 71104, "NSM"],
787
- [71132, 71133, "NSM"],
788
- [71219, 71226, "NSM"],
789
- [71229, 71229, "NSM"],
790
- [71231, 71232, "NSM"],
791
- [71264, 71276, "ON"],
792
- [71339, 71339, "NSM"],
793
- [71341, 71341, "NSM"],
794
- [71344, 71349, "NSM"],
795
- [71351, 71351, "NSM"],
796
- [71453, 71453, "NSM"],
797
- [71455, 71455, "NSM"],
798
- [71458, 71461, "NSM"],
799
- [71463, 71467, "NSM"],
800
- [71727, 71735, "NSM"],
801
- [71737, 71738, "NSM"],
802
- [71995, 71996, "NSM"],
803
- [71998, 71998, "NSM"],
804
- [72003, 72003, "NSM"],
805
- [72148, 72151, "NSM"],
806
- [72154, 72155, "NSM"],
807
- [72160, 72160, "NSM"],
808
- [72193, 72198, "NSM"],
809
- [72201, 72202, "NSM"],
810
- [72243, 72248, "NSM"],
811
- [72251, 72254, "NSM"],
812
- [72263, 72263, "NSM"],
813
- [72273, 72278, "NSM"],
814
- [72281, 72283, "NSM"],
815
- [72330, 72342, "NSM"],
816
- [72344, 72345, "NSM"],
817
- [72544, 72544, "NSM"],
818
- [72546, 72548, "NSM"],
819
- [72550, 72550, "NSM"],
820
- [72752, 72758, "NSM"],
821
- [72760, 72765, "NSM"],
822
- [72850, 72871, "NSM"],
823
- [72874, 72880, "NSM"],
824
- [72882, 72883, "NSM"],
825
- [72885, 72886, "NSM"],
826
- [73009, 73014, "NSM"],
827
- [73018, 73018, "NSM"],
828
- [73020, 73021, "NSM"],
829
- [73023, 73029, "NSM"],
830
- [73031, 73031, "NSM"],
831
- [73104, 73105, "NSM"],
832
- [73109, 73109, "NSM"],
833
- [73111, 73111, "NSM"],
834
- [73459, 73460, "NSM"],
835
- [73472, 73473, "NSM"],
836
- [73526, 73530, "NSM"],
837
- [73536, 73536, "NSM"],
838
- [73538, 73538, "NSM"],
839
- [73562, 73562, "NSM"],
840
- [73685, 73692, "ON"],
841
- [73693, 73696, "ET"],
842
- [73697, 73713, "ON"],
843
- [78912, 78912, "NSM"],
844
- [78919, 78933, "NSM"],
845
- [90398, 90409, "NSM"],
846
- [90413, 90415, "NSM"],
847
- [92912, 92916, "NSM"],
848
- [92976, 92982, "NSM"],
849
- [94031, 94031, "NSM"],
850
- [94095, 94098, "NSM"],
851
- [94178, 94178, "ON"],
852
- [94180, 94180, "NSM"],
853
- [113821, 113822, "NSM"],
854
- [113824, 113827, "BN"],
855
- [117760, 117973, "ON"],
856
- [118e3, 118009, "EN"],
857
- [118010, 118012, "ON"],
858
- [118016, 118451, "ON"],
859
- [118458, 118480, "ON"],
860
- [118496, 118512, "ON"],
861
- [118528, 118573, "NSM"],
862
- [118576, 118598, "NSM"],
863
- [119143, 119145, "NSM"],
864
- [119155, 119162, "BN"],
865
- [119163, 119170, "NSM"],
866
- [119173, 119179, "NSM"],
867
- [119210, 119213, "NSM"],
868
- [119273, 119274, "ON"],
869
- [119296, 119361, "ON"],
870
- [119362, 119364, "NSM"],
871
- [119365, 119365, "ON"],
872
- [119552, 119638, "ON"],
873
- [120513, 120513, "ON"],
874
- [120539, 120539, "ON"],
875
- [120571, 120571, "ON"],
876
- [120597, 120597, "ON"],
877
- [120629, 120629, "ON"],
878
- [120655, 120655, "ON"],
879
- [120687, 120687, "ON"],
880
- [120713, 120713, "ON"],
881
- [120745, 120745, "ON"],
882
- [120771, 120771, "ON"],
883
- [120782, 120831, "EN"],
884
- [121344, 121398, "NSM"],
885
- [121403, 121452, "NSM"],
886
- [121461, 121461, "NSM"],
887
- [121476, 121476, "NSM"],
888
- [121499, 121503, "NSM"],
889
- [121505, 121519, "NSM"],
890
- [122880, 122886, "NSM"],
891
- [122888, 122904, "NSM"],
892
- [122907, 122913, "NSM"],
893
- [122915, 122916, "NSM"],
894
- [122918, 122922, "NSM"],
895
- [123023, 123023, "NSM"],
896
- [123184, 123190, "NSM"],
897
- [123566, 123566, "NSM"],
898
- [123628, 123631, "NSM"],
899
- [123647, 123647, "ET"],
900
- [124140, 124143, "NSM"],
901
- [124398, 124399, "NSM"],
902
- [124643, 124643, "NSM"],
903
- [124646, 124646, "NSM"],
904
- [124654, 124655, "NSM"],
905
- [124661, 124661, "NSM"],
906
- [124928, 125135, "R"],
907
- [125136, 125142, "NSM"],
908
- [125143, 125251, "R"],
909
- [125252, 125258, "NSM"],
910
- [125259, 126063, "R"],
911
- [126064, 126143, "AL"],
912
- [126144, 126207, "R"],
913
- [126208, 126287, "AL"],
914
- [126288, 126463, "R"],
915
- [126464, 126703, "AL"],
916
- [126704, 126705, "ON"],
917
- [126706, 126719, "AL"],
918
- [126720, 126975, "R"],
919
- [126976, 127019, "ON"],
920
- [127024, 127123, "ON"],
921
- [127136, 127150, "ON"],
922
- [127153, 127167, "ON"],
923
- [127169, 127183, "ON"],
924
- [127185, 127221, "ON"],
925
- [127232, 127242, "EN"],
926
- [127243, 127247, "ON"],
927
- [127279, 127279, "ON"],
928
- [127338, 127343, "ON"],
929
- [127405, 127405, "ON"],
930
- [127584, 127589, "ON"],
931
- [127744, 128728, "ON"],
932
- [128732, 128748, "ON"],
933
- [128752, 128764, "ON"],
934
- [128768, 128985, "ON"],
935
- [128992, 129003, "ON"],
936
- [129008, 129008, "ON"],
937
- [129024, 129035, "ON"],
938
- [129040, 129095, "ON"],
939
- [129104, 129113, "ON"],
940
- [129120, 129159, "ON"],
941
- [129168, 129197, "ON"],
942
- [129200, 129211, "ON"],
943
- [129216, 129217, "ON"],
944
- [129232, 129240, "ON"],
945
- [129280, 129623, "ON"],
946
- [129632, 129645, "ON"],
947
- [129648, 129660, "ON"],
948
- [129664, 129674, "ON"],
949
- [129678, 129734, "ON"],
950
- [129736, 129736, "ON"],
951
- [129741, 129756, "ON"],
952
- [129759, 129770, "ON"],
953
- [129775, 129784, "ON"],
954
- [129792, 129938, "ON"],
955
- [129940, 130031, "ON"],
956
- [130032, 130041, "EN"],
957
- [130042, 130042, "ON"],
958
- [131070, 131071, "BN"],
959
- [196606, 196607, "BN"],
960
- [262142, 262143, "BN"],
961
- [327678, 327679, "BN"],
962
- [393214, 393215, "BN"],
963
- [458750, 458751, "BN"],
964
- [524286, 524287, "BN"],
965
- [589822, 589823, "BN"],
966
- [655358, 655359, "BN"],
967
- [720894, 720895, "BN"],
968
- [786430, 786431, "BN"],
969
- [851966, 851967, "BN"],
970
- [917502, 917759, "BN"],
971
- [917760, 917999, "NSM"],
972
- [918e3, 921599, "BN"],
973
- [983038, 983039, "BN"],
974
- [1048574, 1048575, "BN"],
975
- [1114110, 1114111, "BN"]
976
- ];
977
- function Dn(e) {
978
- if (e <= 255)
979
- return kn[e];
980
- let t = 0, n = At.length - 1;
981
- for (; t <= n; ) {
982
- const x = t + n >> 1, i = At[x];
983
- if (e < i[0]) {
984
- n = x - 1;
985
- continue;
986
- }
987
- if (e > i[1]) {
988
- t = x + 1;
989
- continue;
990
- }
991
- return i[2];
992
- }
993
- return "L";
994
- }
995
- function Ln(e) {
996
- const t = e.length;
997
- if (t === 0)
998
- return null;
999
- const n = new Array(t);
1000
- let x = !1;
1001
- for (let r = 0; r < t; ) {
1002
- const c = e.charCodeAt(r);
1003
- let u = c, f = 1;
1004
- if (c >= 55296 && c <= 56319 && r + 1 < t) {
1005
- const S = e.charCodeAt(r + 1);
1006
- S >= 56320 && S <= 57343 && (u = (c - 55296 << 10) + (S - 56320) + 65536, f = 2);
1007
- }
1008
- const d = Dn(u);
1009
- (d === "R" || d === "AL" || d === "AN") && (x = !0);
1010
- for (let S = 0; S < f; S++)
1011
- n[r + S] = d;
1012
- r += f;
1013
- }
1014
- if (!x)
1015
- return null;
1016
- let i = 0;
1017
- for (let r = 0; r < t; r++) {
1018
- const c = n[r];
1019
- if (c === "L") {
1020
- i = 0;
1021
- break;
1022
- }
1023
- if (c === "R" || c === "AL") {
1024
- i = 1;
1025
- break;
1026
- }
1027
- }
1028
- const s = new Int8Array(t);
1029
- for (let r = 0; r < t; r++)
1030
- s[r] = i;
1031
- const o = i & 1 ? "R" : "L", a = o;
1032
- let l = a;
1033
- for (let r = 0; r < t; r++)
1034
- n[r] === "NSM" ? n[r] = l : l = n[r];
1035
- l = a;
1036
- for (let r = 0; r < t; r++) {
1037
- const c = n[r];
1038
- c === "EN" ? n[r] = l === "AL" ? "AN" : "EN" : (c === "R" || c === "L" || c === "AL") && (l = c);
1039
- }
1040
- for (let r = 0; r < t; r++)
1041
- n[r] === "AL" && (n[r] = "R");
1042
- for (let r = 1; r < t - 1; r++)
1043
- n[r] === "ES" && n[r - 1] === "EN" && n[r + 1] === "EN" && (n[r] = "EN"), n[r] === "CS" && (n[r - 1] === "EN" || n[r - 1] === "AN") && n[r + 1] === n[r - 1] && (n[r] = n[r - 1]);
1044
- for (let r = 0; r < t; r++) {
1045
- if (n[r] !== "EN")
1046
- continue;
1047
- let c;
1048
- for (c = r - 1; c >= 0 && n[c] === "ET"; c--)
1049
- n[c] = "EN";
1050
- for (c = r + 1; c < t && n[c] === "ET"; c++)
1051
- n[c] = "EN";
1052
- }
1053
- for (let r = 0; r < t; r++) {
1054
- const c = n[r];
1055
- (c === "WS" || c === "ES" || c === "ET" || c === "CS") && (n[r] = "ON");
1056
- }
1057
- l = a;
1058
- for (let r = 0; r < t; r++) {
1059
- const c = n[r];
1060
- c === "EN" ? n[r] = l === "L" ? "L" : "EN" : (c === "R" || c === "L") && (l = c);
1061
- }
1062
- for (let r = 0; r < t; r++) {
1063
- if (n[r] !== "ON")
1064
- continue;
1065
- let c = r + 1;
1066
- for (; c < t && n[c] === "ON"; )
1067
- c++;
1068
- const u = r > 0 ? n[r - 1] : a, f = c < t ? n[c] : a, d = u !== "L" ? "R" : "L";
1069
- if (d === (f !== "L" ? "R" : "L"))
1070
- for (let m = r; m < c; m++)
1071
- n[m] = d;
1072
- r = c - 1;
1073
- }
1074
- for (let r = 0; r < t; r++)
1075
- n[r] === "ON" && (n[r] = o);
1076
- for (let r = 0; r < t; r++) {
1077
- const c = n[r];
1078
- (s[r] & 1) === 0 ? c === "R" ? s[r]++ : (c === "AN" || c === "EN") && (s[r] += 2) : (c === "L" || c === "AN" || c === "EN") && s[r]++;
1079
- }
1080
- return s;
1081
- }
1082
- function On(e, t) {
1083
- const n = Ln(e);
1084
- if (n === null)
1085
- return null;
1086
- const x = new Int8Array(t.length);
1087
- for (let i = 0; i < t.length; i++)
1088
- x[i] = n[t[i]];
1089
- return x;
1090
- }
1091
- const bn = /[ \t\n\r\f]+/g, yn = /[\t\n\r\f]| {2,}|^ | $/;
1092
- function In(e) {
1093
- const t = e ?? "normal";
1094
- return t === "pre-wrap" ? { mode: t, preserveOrdinarySpaces: !0, preserveHardBreaks: !0 } : { mode: t, preserveOrdinarySpaces: !1, preserveHardBreaks: !1 };
1095
- }
1096
- function wn(e) {
1097
- if (!yn.test(e))
1098
- return e;
1099
- let t = e.replace(bn, " ");
1100
- return t.charCodeAt(0) === 32 && (t = t.slice(1)), t.length > 0 && t.charCodeAt(t.length - 1) === 32 && (t = t.slice(0, -1)), t;
1101
- }
1102
- function Pn(e) {
1103
- return /[\r\f]/.test(e) ? e.replace(/\r\n/g, `
1104
- `).replace(/[\r\f]/g, `
1105
- `) : e;
1106
- }
1107
- let je = null, Wn;
1108
- function vn() {
1109
- return je === null && (je = new Intl.Segmenter(Wn, { granularity: "word" })), je;
1110
- }
1111
- const Rn = /\p{Script=Arabic}/u, Ne = /\p{M}/u, nt = /\p{Nd}/u;
1112
- function mt(e) {
1113
- return Rn.test(e);
1114
- }
1115
- function Et(e) {
1116
- return e >= 19968 && e <= 40959 || e >= 13312 && e <= 19903 || e >= 131072 && e <= 173791 || e >= 173824 && e <= 177983 || e >= 177984 && e <= 178207 || e >= 178208 && e <= 183983 || e >= 183984 && e <= 191471 || e >= 191472 && e <= 192093 || e >= 194560 && e <= 195103 || e >= 196608 && e <= 201551 || e >= 201552 && e <= 205743 || e >= 205744 && e <= 210041 || e >= 63744 && e <= 64255 || e >= 12288 && e <= 12351 || e >= 12352 && e <= 12447 || e >= 12448 && e <= 12543 || e >= 12592 && e <= 12687 || e >= 44032 && e <= 55215 || e >= 65280 && e <= 65519;
1117
- }
1118
- function oe(e) {
1119
- for (let t = 0; t < e.length; t++) {
1120
- const n = e.charCodeAt(t);
1121
- if (!(n < 12288)) {
1122
- if (n >= 55296 && n <= 56319 && t + 1 < e.length) {
1123
- const x = e.charCodeAt(t + 1);
1124
- if (x >= 56320 && x <= 57343) {
1125
- const i = (n - 55296 << 10) + (x - 56320) + 65536;
1126
- if (Et(i))
1127
- return !0;
1128
- t++;
1129
- continue;
1130
- }
1131
- }
1132
- if (Et(n))
1133
- return !0;
1134
- }
1135
- }
1136
- return !1;
1137
- }
1138
- function Tn(e) {
1139
- const t = De(e);
1140
- return t !== null && (st.has(t) || ge.has(t));
1141
- }
1142
- const Gn = /* @__PURE__ */ new Set([
1143
- " ",
1144
- " ",
1145
- "⁠",
1146
- "\uFEFF"
1147
- ]), Hn = /* @__PURE__ */ new Set([
1148
- "-",
1149
- "‐",
1150
- "–",
1151
- "—"
1152
- ]);
1153
- function _n(e) {
1154
- const t = De(e);
1155
- return t !== null && Gn.has(t);
1156
- }
1157
- function zn(e) {
1158
- const t = De(e);
1159
- return t !== null && Hn.has(t);
1160
- }
1161
- function zt(e, t) {
1162
- return _n(e) ? !1 : t ? !(Tn(e) || zn(e)) : !0;
1163
- }
1164
- const st = /* @__PURE__ */ new Set([
1165
- ",",
1166
- ".",
1167
- "!",
1168
- ":",
1169
- ";",
1170
- "?",
1171
- "、",
1172
- "。",
1173
- "・",
1174
- ")",
1175
- "〕",
1176
- "〉",
1177
- "》",
1178
- "」",
1179
- "』",
1180
- "】",
1181
- "〗",
1182
- "〙",
1183
- "〛",
1184
- "ー",
1185
- "々",
1186
- "〻",
1187
- "ゝ",
1188
- "ゞ",
1189
- "ヽ",
1190
- "ヾ"
1191
- ]), ve = /* @__PURE__ */ new Set([
1192
- '"',
1193
- "(",
1194
- "[",
1195
- "{",
1196
- "¡",
1197
- "¿",
1198
- "“",
1199
- "‘",
1200
- "‚",
1201
- "„",
1202
- "«",
1203
- "‹",
1204
- "⸘",
1205
- "(",
1206
- "〔",
1207
- "〈",
1208
- "《",
1209
- "「",
1210
- "『",
1211
- "【",
1212
- "〖",
1213
- "〘",
1214
- "〚"
1215
- ]), it = /* @__PURE__ */ new Set([
1216
- "'",
1217
- "’"
1218
- ]), ge = /* @__PURE__ */ new Set([
1219
- ".",
1220
- ",",
1221
- "!",
1222
- "?",
1223
- ":",
1224
- ";",
1225
- "،",
1226
- "؛",
1227
- "؟",
1228
- "।",
1229
- "॥",
1230
- "၊",
1231
- "။",
1232
- "၌",
1233
- "၍",
1234
- "၏",
1235
- ")",
1236
- "]",
1237
- "}",
1238
- "%",
1239
- '"',
1240
- "”",
1241
- "’",
1242
- "»",
1243
- "›",
1244
- "…"
1245
- ]), jn = /* @__PURE__ */ new Set([
1246
- ":",
1247
- ".",
1248
- "،",
1249
- "؛"
1250
- ]), Kn = /* @__PURE__ */ new Set([
1251
- "၏"
1252
- ]), Un = /* @__PURE__ */ new Set([
1253
- "”",
1254
- "’",
1255
- "»",
1256
- "›",
1257
- "」",
1258
- "』",
1259
- "】",
1260
- "》",
1261
- "〉",
1262
- "〕",
1263
- ")"
1264
- ]);
1265
- function Jn(e) {
1266
- if (xt(e))
1267
- return !0;
1268
- let t = !1;
1269
- for (const n of e) {
1270
- if (ge.has(n) || Te(n)) {
1271
- t = !0;
1272
- continue;
1273
- }
1274
- if (!(t && Ne.test(n)))
1275
- return !1;
1276
- }
1277
- return t;
1278
- }
1279
- function Qn(e) {
1280
- for (const t of e)
1281
- if (!st.has(t) && !ge.has(t))
1282
- return !1;
1283
- return e.length > 0;
1284
- }
1285
- function $n(e) {
1286
- if (xt(e))
1287
- return !0;
1288
- for (const t of e)
1289
- if (!ve.has(t) && !it.has(t) && !Ne.test(t) && !Te(t))
1290
- return !1;
1291
- return e.length > 0;
1292
- }
1293
- function xt(e) {
1294
- let t = !1;
1295
- for (const n of e)
1296
- if (!(n === "\\" || Ne.test(n))) {
1297
- if (ve.has(n) || ge.has(n) || it.has(n)) {
1298
- t = !0;
1299
- continue;
1300
- }
1301
- return !1;
1302
- }
1303
- return t;
1304
- }
1305
- function Re(e, t) {
1306
- const n = t - 1;
1307
- if (n <= 0)
1308
- return Math.max(n, 0);
1309
- const x = e.charCodeAt(n);
1310
- if (x < 56320 || x > 57343)
1311
- return n;
1312
- const i = n - 1;
1313
- if (i < 0)
1314
- return n;
1315
- const s = e.charCodeAt(i);
1316
- return s >= 55296 && s <= 56319 ? i : n;
1317
- }
1318
- function De(e) {
1319
- if (e.length === 0)
1320
- return null;
1321
- const t = Re(e, e.length);
1322
- return e.slice(t);
1323
- }
1324
- function Yn(e) {
1325
- for (const t of e)
1326
- if (!Ne.test(t))
1327
- return t;
1328
- return null;
1329
- }
1330
- function qn(e) {
1331
- for (let t = e.length; t > 0; ) {
1332
- const n = Re(e, t), x = e.slice(n, t);
1333
- if (!Ne.test(x))
1334
- return x;
1335
- t = n;
1336
- }
1337
- return null;
1338
- }
1339
- const Xn = [
1340
- 36,
1341
- 37,
1342
- 43,
1343
- 43,
1344
- 92,
1345
- 92,
1346
- 162,
1347
- 165,
1348
- 176,
1349
- 177,
1350
- 1423,
1351
- 1423,
1352
- 1545,
1353
- 1547,
1354
- 1642,
1355
- 1642,
1356
- 2046,
1357
- 2047,
1358
- 2546,
1359
- 2547,
1360
- 2553,
1361
- 2555,
1362
- 2801,
1363
- 2801,
1364
- 3065,
1365
- 3065,
1366
- 3449,
1367
- 3449,
1368
- 3647,
1369
- 3647,
1370
- 6107,
1371
- 6107,
1372
- 8240,
1373
- 8247,
1374
- 8279,
1375
- 8279,
1376
- 8352,
1377
- 8399,
1378
- 8451,
1379
- 8451,
1380
- 8457,
1381
- 8457,
1382
- 8470,
1383
- 8470,
1384
- 8722,
1385
- 8723,
1386
- 43064,
1387
- 43064,
1388
- 65020,
1389
- 65020,
1390
- 65129,
1391
- 65130,
1392
- 65284,
1393
- 65285,
1394
- 65504,
1395
- 65505,
1396
- 65509,
1397
- 65510,
1398
- 73693,
1399
- 73696,
1400
- 123647,
1401
- 123647,
1402
- 126124,
1403
- 126124,
1404
- 126128,
1405
- 126128
1406
- ];
1407
- function Vn(e, t) {
1408
- for (let n = 0; n < t.length; n += 2)
1409
- if (e >= t[n] && e <= t[n + 1])
1410
- return !0;
1411
- return !1;
1412
- }
1413
- function Te(e) {
1414
- const t = e.codePointAt(0);
1415
- return t !== void 0 && Vn(t, Xn);
1416
- }
1417
- function Zn(e) {
1418
- const t = qn(e);
1419
- return t !== null && Te(t);
1420
- }
1421
- function e0(e) {
1422
- const t = Yn(e);
1423
- return t !== null && nt.test(t);
1424
- }
1425
- function t0(e) {
1426
- const t = Array.from(e);
1427
- let n = t.length;
1428
- for (; n > 0; ) {
1429
- const x = t[n - 1];
1430
- if (Ne.test(x)) {
1431
- n--;
1432
- continue;
1433
- }
1434
- if (ve.has(x) || it.has(x)) {
1435
- n--;
1436
- continue;
1437
- }
1438
- break;
1439
- }
1440
- return n <= 0 || n === t.length ? null : {
1441
- head: t.slice(0, n).join(""),
1442
- tail: t.slice(n).join("")
1443
- };
1444
- }
1445
- function n0(e, t, n) {
1446
- return n === "text" && !t && e.length === 1 && e !== "-" && e !== "—" ? e : null;
1447
- }
1448
- function Bt(e, t, n, x) {
1449
- const i = t[x], s = e[x];
1450
- if (i == null)
1451
- return s;
1452
- const o = n[x];
1453
- if (s.length === o)
1454
- return s;
1455
- const a = i.repeat(o);
1456
- return e[x] = a, a;
1457
- }
1458
- function Mt(e, t) {
1459
- return e && t !== null && jn.has(t);
1460
- }
1461
- function s0(e) {
1462
- const t = De(e);
1463
- return t !== null && Kn.has(t);
1464
- }
1465
- function i0(e) {
1466
- if (e.length < 2 || e[0] !== " ")
1467
- return null;
1468
- const t = e.slice(1);
1469
- return /^\p{M}+$/u.test(t) ? { space: " ", marks: t } : null;
1470
- }
1471
- function Ye(e) {
1472
- let t = e.length;
1473
- for (; t > 0; ) {
1474
- const n = Re(e, t), x = e.slice(n, t);
1475
- if (Un.has(x))
1476
- return !0;
1477
- if (!ge.has(x))
1478
- return !1;
1479
- t = n;
1480
- }
1481
- return !1;
1482
- }
1483
- function x0(e, t) {
1484
- if (t.preserveOrdinarySpaces || t.preserveHardBreaks) {
1485
- if (e === " ")
1486
- return "preserved-space";
1487
- if (e === " ")
1488
- return "tab";
1489
- if (t.preserveHardBreaks && e === `
1490
- `)
1491
- return "hard-break";
1492
- }
1493
- return e === " " ? "space" : e === " " || e === " " || e === "⁠" || e === "\uFEFF" ? "glue" : e === "​" ? "zero-width-break" : e === "­" ? "soft-hyphen" : "text";
1494
- }
1495
- const r0 = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
1496
- function xe(e) {
1497
- return e.length === 1 ? e[0] : e.join("");
1498
- }
1499
- function o0(e, t) {
1500
- const n = [];
1501
- for (let x = e.length - 1; x >= 0; x--)
1502
- n.push(e[x]);
1503
- return n.push(t), xe(n);
1504
- }
1505
- function l0(e, t, n, x) {
1506
- if (!r0.test(e))
1507
- return [{ text: e, isWordLike: t, kind: "text", start: n }];
1508
- const i = [];
1509
- let s = null, o = [], a = n, l = !1, r = 0;
1510
- for (const c of e) {
1511
- const u = x0(c, x), f = u === "text" && t;
1512
- if (s !== null && u === s && f === l) {
1513
- o.push(c), r += c.length;
1514
- continue;
1515
- }
1516
- s !== null && i.push({
1517
- text: xe(o),
1518
- isWordLike: l,
1519
- kind: s,
1520
- start: a
1521
- }), s = u, o = [c], a = n + r, l = f, r += c.length;
1522
- }
1523
- return s !== null && i.push({
1524
- text: xe(o),
1525
- isWordLike: l,
1526
- kind: s,
1527
- start: a
1528
- }), i;
1529
- }
1530
- function qe(e) {
1531
- return e === "space" || e === "preserved-space" || e === "zero-width-break" || e === "hard-break";
1532
- }
1533
- const c0 = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
1534
- function a0(e, t) {
1535
- const n = e.texts[t];
1536
- return n.startsWith("www.") ? !0 : c0.test(n) && t + 1 < e.len && e.kinds[t + 1] === "text" && e.texts[t + 1] === "//";
1537
- }
1538
- function u0(e) {
1539
- return e.includes("?") && (e.includes("://") || e.startsWith("www."));
1540
- }
1541
- function f0(e) {
1542
- const t = e.texts.slice(), n = e.isWordLike.slice(), x = e.kinds.slice(), i = e.starts.slice();
1543
- for (let o = 0; o < e.len; o++) {
1544
- if (x[o] !== "text" || !a0(e, o))
1545
- continue;
1546
- const a = [t[o]];
1547
- let l = o + 1;
1548
- for (; l < e.len && !qe(x[l]); ) {
1549
- a.push(t[l]), n[o] = !0;
1550
- const r = t[l].includes("?");
1551
- if (x[l] = "text", t[l] = "", l++, r)
1552
- break;
1553
- }
1554
- t[o] = xe(a);
1555
- }
1556
- let s = 0;
1557
- for (let o = 0; o < t.length; o++) {
1558
- const a = t[o];
1559
- a.length !== 0 && (s !== o && (t[s] = a, n[s] = n[o], x[s] = x[o], i[s] = i[o]), s++);
1560
- }
1561
- return t.length = s, n.length = s, x.length = s, i.length = s, {
1562
- len: s,
1563
- texts: t,
1564
- isWordLike: n,
1565
- kinds: x,
1566
- starts: i
1567
- };
1568
- }
1569
- function h0(e) {
1570
- const t = [], n = [], x = [], i = [];
1571
- for (let s = 0; s < e.len; s++) {
1572
- const o = e.texts[s];
1573
- if (t.push(o), n.push(e.isWordLike[s]), x.push(e.kinds[s]), i.push(e.starts[s]), !u0(o))
1574
- continue;
1575
- const a = s + 1;
1576
- if (a >= e.len || qe(e.kinds[a]))
1577
- continue;
1578
- const l = [], r = e.starts[a];
1579
- let c = a;
1580
- for (; c < e.len && !qe(e.kinds[c]); )
1581
- l.push(e.texts[c]), c++;
1582
- l.length > 0 && (t.push(xe(l)), n.push(!0), x.push("text"), i.push(r), s = c - 1);
1583
- }
1584
- return {
1585
- len: t.length,
1586
- texts: t,
1587
- isWordLike: n,
1588
- kinds: x,
1589
- starts: i
1590
- };
1591
- }
1592
- const d0 = /* @__PURE__ */ new Set([
1593
- ":",
1594
- "-",
1595
- "/",
1596
- "×",
1597
- ",",
1598
- ".",
1599
- "+",
1600
- "–",
1601
- "—"
1602
- ]), F0 = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
1603
- function Ct(e) {
1604
- for (let t = e.length; t > 0; ) {
1605
- const n = Re(e, t), x = e.slice(n, t);
1606
- if (Ne.test(x)) {
1607
- t = n;
1608
- continue;
1609
- }
1610
- return F0.has(x) || Te(x);
1611
- }
1612
- return !1;
1613
- }
1614
- function g0(e, t) {
1615
- return t && !oe(e);
1616
- }
1617
- function jt(e) {
1618
- for (const t of e)
1619
- if (nt.test(t))
1620
- return !0;
1621
- return !1;
1622
- }
1623
- function we(e) {
1624
- if (e.length === 0)
1625
- return !1;
1626
- for (const t of e)
1627
- if (!(nt.test(t) || d0.has(t)))
1628
- return !1;
1629
- return !0;
1630
- }
1631
- function N0(e) {
1632
- const t = [], n = [], x = [], i = [];
1633
- for (let s = 0; s < e.len; s++) {
1634
- const o = e.texts[s], a = e.kinds[s];
1635
- if (a === "text" && we(o) && jt(o)) {
1636
- const l = [o];
1637
- let r = s + 1;
1638
- for (; r < e.len && e.kinds[r] === "text" && we(e.texts[r]); )
1639
- l.push(e.texts[r]), r++;
1640
- t.push(xe(l)), n.push(!0), x.push("text"), i.push(e.starts[s]), s = r - 1;
1641
- continue;
1642
- }
1643
- t.push(o), n.push(e.isWordLike[s]), x.push(a), i.push(e.starts[s]);
1644
- }
1645
- return {
1646
- len: t.length,
1647
- texts: t,
1648
- isWordLike: n,
1649
- kinds: x,
1650
- starts: i
1651
- };
1652
- }
1653
- function S0(e) {
1654
- const t = [], n = [], x = [], i = [];
1655
- for (let s = 0; s < e.len; s++) {
1656
- const o = e.texts[s], a = e.kinds[s], l = e.isWordLike[s];
1657
- if (a === "text" && Ct(o) && (l || Zn(o)) && !oe(o)) {
1658
- const r = [o];
1659
- let c = !0, u = s + 1;
1660
- for (; c && u < e.len && e.kinds[u] === "text" && g0(e.texts[u], e.isWordLike[u]); ) {
1661
- const f = e.texts[u];
1662
- r.push(f), c = Ct(f), u++;
1663
- }
1664
- t.push(xe(r)), n.push(!0), x.push("text"), i.push(e.starts[s]), s = u - 1;
1665
- continue;
1666
- }
1667
- t.push(o), n.push(l), x.push(a), i.push(e.starts[s]);
1668
- }
1669
- return {
1670
- len: t.length,
1671
- texts: t,
1672
- isWordLike: n,
1673
- kinds: x,
1674
- starts: i
1675
- };
1676
- }
1677
- function p0(e) {
1678
- const t = [], n = [], x = [], i = [];
1679
- for (let s = 0; s < e.len; s++) {
1680
- const o = e.texts[s];
1681
- if (e.kinds[s] === "text" && o.includes("-")) {
1682
- const a = o.split("-");
1683
- let l = a.length > 1;
1684
- for (let r = 0; r < a.length; r++) {
1685
- const c = a[r];
1686
- if (!l)
1687
- break;
1688
- (c.length === 0 || !jt(c) || !we(c)) && (l = !1);
1689
- }
1690
- if (l) {
1691
- let r = 0;
1692
- for (let c = 0; c < a.length; c++) {
1693
- const u = a[c], f = c < a.length - 1 ? `${u}-` : u;
1694
- t.push(f), n.push(!0), x.push("text"), i.push(e.starts[s] + r), r += f.length;
1695
- }
1696
- continue;
1697
- }
1698
- }
1699
- t.push(o), n.push(e.isWordLike[s]), x.push(e.kinds[s]), i.push(e.starts[s]);
1700
- }
1701
- return {
1702
- len: t.length,
1703
- texts: t,
1704
- isWordLike: n,
1705
- kinds: x,
1706
- starts: i
1707
- };
1708
- }
1709
- function A0(e) {
1710
- const t = [], n = [], x = [], i = [];
1711
- let s = 0;
1712
- for (; s < e.len; ) {
1713
- const o = [e.texts[s]];
1714
- let a = e.isWordLike[s], l = e.kinds[s], r = e.starts[s];
1715
- if (l === "glue") {
1716
- const c = [o[0]], u = r;
1717
- for (s++; s < e.len && e.kinds[s] === "glue"; )
1718
- c.push(e.texts[s]), s++;
1719
- const f = xe(c);
1720
- if (s < e.len && e.kinds[s] === "text")
1721
- o[0] = f, o.push(e.texts[s]), a = e.isWordLike[s], l = "text", r = u, s++;
1722
- else {
1723
- t.push(f), n.push(!1), x.push("glue"), i.push(u);
1724
- continue;
1725
- }
1726
- } else
1727
- s++;
1728
- if (l === "text")
1729
- for (; s < e.len && e.kinds[s] === "glue"; ) {
1730
- const c = [];
1731
- for (; s < e.len && e.kinds[s] === "glue"; )
1732
- c.push(e.texts[s]), s++;
1733
- const u = xe(c);
1734
- if (s < e.len && e.kinds[s] === "text") {
1735
- o.push(u, e.texts[s]), a = a || e.isWordLike[s], s++;
1736
- continue;
1737
- }
1738
- o.push(u);
1739
- }
1740
- t.push(xe(o)), n.push(a), x.push(l), i.push(r);
1741
- }
1742
- return {
1743
- len: t.length,
1744
- texts: t,
1745
- isWordLike: n,
1746
- kinds: x,
1747
- starts: i
1748
- };
1749
- }
1750
- function m0(e) {
1751
- const t = e.texts.slice(), n = e.isWordLike.slice(), x = e.kinds.slice(), i = e.starts.slice();
1752
- for (let s = 0; s < t.length - 1; s++) {
1753
- if (x[s] !== "text" || x[s + 1] !== "text" || !oe(t[s]) || !oe(t[s + 1]))
1754
- continue;
1755
- const o = t0(t[s]);
1756
- o !== null && (t[s] = o.head, t[s + 1] = o.tail + t[s + 1], i[s + 1] = i[s] + o.head.length);
1757
- }
1758
- return {
1759
- len: t.length,
1760
- texts: t,
1761
- isWordLike: n,
1762
- kinds: x,
1763
- starts: i
1764
- };
1765
- }
1766
- function E0(e, t, n) {
1767
- const x = vn();
1768
- let i = 0;
1769
- const s = [], o = [], a = [], l = [], r = [], c = [], u = [], f = [], d = [], S = [], m = [], p = [];
1770
- for (const N of x.segment(e))
1771
- for (const D of l0(N.segment, N.isWordLike ?? !1, N.index, n)) {
1772
- let I = function() {
1773
- c[A] !== null && (o[A] = [
1774
- Bt(s, c, u, A)
1775
- ], c[A] = null), o[A].push(D.text), a[A] = a[A] || D.isWordLike, f[A] = f[A] || P, d[A] = d[A] || W, S[A] = z, m[A] = C, p[A] = Mt(d[A], H);
1776
- };
1777
- const B = D.kind === "text", T = n0(D.text, D.isWordLike, D.kind), P = oe(D.text), W = mt(D.text), H = De(D.text), z = Ye(D.text), C = s0(D.text), A = i - 1;
1778
- t.carryCJKAfterClosingQuote && B && i > 0 && l[A] === "text" && P && f[A] && S[A] || B && i > 0 && l[A] === "text" && Qn(D.text) && f[A] || B && i > 0 && l[A] === "text" && m[A] ? I() : B && i > 0 && l[A] === "text" && D.isWordLike && W && p[A] ? (I(), a[A] = !0) : T !== null && i > 0 && l[A] === "text" && c[A] === T ? u[A] = (u[A] ?? 1) + 1 : B && !D.isWordLike && i > 0 && l[A] === "text" && !f[A] && (Jn(D.text) || D.text === "-" && a[A]) ? I() : (s[i] = D.text, o[i] = [D.text], a[i] = D.isWordLike, l[i] = D.kind, r[i] = D.start, c[i] = T, u[i] = T === null ? 0 : 1, f[i] = P, d[i] = W, S[i] = z, m[i] = C, p[i] = Mt(W, H), i++);
1779
- }
1780
- for (let N = 0; N < i; N++) {
1781
- if (c[N] !== null) {
1782
- s[N] = Bt(s, c, u, N);
1783
- continue;
1784
- }
1785
- s[N] = xe(o[N]);
1786
- }
1787
- for (let N = 1; N < i; N++)
1788
- l[N] === "text" && !a[N] && xt(s[N]) && l[N - 1] === "text" && !f[N - 1] && (s[N - 1] += s[N], a[N - 1] = a[N - 1] || a[N], s[N] = "");
1789
- const M = Array.from({ length: i }, () => null);
1790
- let R = -1;
1791
- for (let N = i - 1; N >= 0; N--) {
1792
- const D = s[N];
1793
- if (D.length !== 0) {
1794
- if (l[N] === "text" && !a[N] && R >= 0 && l[R] === "text" && ($n(D) || D === "-" && e0(s[R]))) {
1795
- const B = M[R] ?? [];
1796
- B.push(D), M[R] = B, r[R] = r[N], s[N] = "";
1797
- continue;
1798
- }
1799
- R = N;
1800
- }
1801
- }
1802
- for (let N = 0; N < i; N++) {
1803
- const D = M[N];
1804
- D != null && (s[N] = o0(D, s[N]));
1805
- }
1806
- let L = 0;
1807
- for (let N = 0; N < i; N++) {
1808
- const D = s[N];
1809
- D.length !== 0 && (L !== N && (s[L] = D, a[L] = a[N], l[L] = l[N], r[L] = r[N]), L++);
1810
- }
1811
- s.length = L, a.length = L, l.length = L, r.length = L;
1812
- const w = A0({
1813
- len: L,
1814
- texts: s,
1815
- isWordLike: a,
1816
- kinds: l,
1817
- starts: r
1818
- }), v = m0(S0(p0(N0(h0(f0(w))))));
1819
- for (let N = 0; N < v.len - 1; N++) {
1820
- const D = i0(v.texts[N]);
1821
- D !== null && (v.kinds[N] !== "space" && v.kinds[N] !== "preserved-space" || v.kinds[N + 1] !== "text" || !mt(v.texts[N + 1]) || (v.texts[N] = D.space, v.isWordLike[N] = !1, v.kinds[N] = v.kinds[N] === "preserved-space" ? "preserved-space" : "space", v.texts[N + 1] = D.marks + v.texts[N + 1], v.starts[N + 1] = v.starts[N] + D.space.length));
1822
- }
1823
- return v;
1824
- }
1825
- function B0(e, t) {
1826
- if (e.len === 0)
1827
- return [];
1828
- if (!t.preserveHardBreaks)
1829
- return [{
1830
- startSegmentIndex: 0,
1831
- endSegmentIndex: e.len,
1832
- consumedEndSegmentIndex: e.len
1833
- }];
1834
- const n = [];
1835
- let x = 0;
1836
- for (let i = 0; i < e.len; i++)
1837
- e.kinds[i] === "hard-break" && (n.push({
1838
- startSegmentIndex: x,
1839
- endSegmentIndex: i,
1840
- consumedEndSegmentIndex: i + 1
1841
- }), x = i + 1);
1842
- return x < e.len && n.push({
1843
- startSegmentIndex: x,
1844
- endSegmentIndex: e.len,
1845
- consumedEndSegmentIndex: e.len
1846
- }), n;
1847
- }
1848
- function M0(e, t, n) {
1849
- if (t.len <= 1)
1850
- return t;
1851
- const x = [], i = [], s = [], o = [];
1852
- let a = -1, l = !1;
1853
- function r(f) {
1854
- x.push(t.texts[f]), i.push(t.isWordLike[f]), s.push("text"), o.push(t.starts[f]);
1855
- }
1856
- function c(f, d) {
1857
- let S = !1;
1858
- for (let M = f; M < d; M++)
1859
- S = S || t.isWordLike[M];
1860
- const m = t.starts[f], p = d < t.len ? t.starts[d] : e.length;
1861
- x.push(e.slice(m, p)), i.push(S), s.push("text"), o.push(m);
1862
- }
1863
- function u(f) {
1864
- if (!(a < 0)) {
1865
- if (l)
1866
- a + 1 === f ? r(a) : c(a, f);
1867
- else
1868
- for (let d = a; d < f; d++)
1869
- r(d);
1870
- a = -1, l = !1;
1871
- }
1872
- }
1873
- for (let f = 0; f < t.len; f++) {
1874
- const d = t.texts[f], S = t.kinds[f];
1875
- if (S === "text") {
1876
- a >= 0 && !zt(t.texts[f - 1], n) && u(f), a < 0 && (a = f), l = l || oe(d);
1877
- continue;
1878
- }
1879
- u(f), x.push(d), i.push(t.isWordLike[f]), s.push(S), o.push(t.starts[f]);
1880
- }
1881
- return u(t.len), {
1882
- len: x.length,
1883
- texts: x,
1884
- isWordLike: i,
1885
- kinds: s,
1886
- starts: o
1887
- };
1888
- }
1889
- function C0(e, t, n = "normal", x = "normal") {
1890
- const i = In(n), s = i.mode === "pre-wrap" ? Pn(e) : wn(e);
1891
- if (s.length === 0)
1892
- return {
1893
- normalized: s,
1894
- chunks: [],
1895
- len: 0,
1896
- texts: [],
1897
- isWordLike: [],
1898
- kinds: [],
1899
- starts: []
1900
- };
1901
- const o = E0(s, t, i), a = x === "keep-all" ? M0(s, o, t.breakKeepAllAfterPunctuation) : o;
1902
- return {
1903
- normalized: s,
1904
- chunks: B0(a, i),
1905
- ...a
1906
- };
1907
- }
1908
- let me = null;
1909
- const kt = /* @__PURE__ */ new Map();
1910
- let Ee = null;
1911
- const k0 = 96, D0 = /\p{Emoji_Presentation}/u, L0 = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
1912
- let Ke = null;
1913
- const Dt = /* @__PURE__ */ new Map();
1914
- function rt() {
1915
- if (me !== null)
1916
- return me;
1917
- if (typeof OffscreenCanvas < "u")
1918
- return me = new OffscreenCanvas(1, 1).getContext("2d"), me;
1919
- if (typeof document < "u")
1920
- return me = document.createElement("canvas").getContext("2d"), me;
1921
- throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
1922
- }
1923
- function O0(e) {
1924
- let t = kt.get(e);
1925
- return t || (t = /* @__PURE__ */ new Map(), kt.set(e, t)), t;
1926
- }
1927
- function ue(e, t) {
1928
- let n = t.get(e);
1929
- return n === void 0 && (n = {
1930
- width: rt().measureText(e).width,
1931
- containsCJK: oe(e)
1932
- }, t.set(e, n)), n;
1933
- }
1934
- function Be() {
1935
- if (Ee !== null)
1936
- return Ee;
1937
- if (typeof navigator > "u")
1938
- return Ee = {
1939
- lineFitEpsilon: 5e-3,
1940
- carryCJKAfterClosingQuote: !1,
1941
- breakKeepAllAfterPunctuation: !0,
1942
- preferPrefixWidthsForBreakableRuns: !1,
1943
- preferEarlySoftHyphenBreak: !1
1944
- }, Ee;
1945
- const e = navigator.userAgent, n = navigator.vendor === "Apple Computer, Inc." && e.includes("Safari/") && !e.includes("Chrome/") && !e.includes("Chromium/") && !e.includes("CriOS/") && !e.includes("FxiOS/") && !e.includes("EdgiOS/"), x = e.includes("Chrome/") || e.includes("Chromium/") || e.includes("CriOS/") || e.includes("Edg/");
1946
- return Ee = {
1947
- lineFitEpsilon: n ? 1 / 64 : 5e-3,
1948
- carryCJKAfterClosingQuote: x,
1949
- breakKeepAllAfterPunctuation: !n,
1950
- preferPrefixWidthsForBreakableRuns: n,
1951
- preferEarlySoftHyphenBreak: n
1952
- }, Ee;
1953
- }
1954
- function b0(e) {
1955
- const t = e.match(/(\d+(?:\.\d+)?)\s*px/);
1956
- return t ? parseFloat(t[1]) : 16;
1957
- }
1958
- function Kt() {
1959
- return Ke === null && (Ke = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ke;
1960
- }
1961
- function y0(e) {
1962
- return D0.test(e) || e.includes("️");
1963
- }
1964
- function I0(e) {
1965
- return L0.test(e);
1966
- }
1967
- function w0(e, t) {
1968
- let n = Dt.get(e);
1969
- if (n !== void 0)
1970
- return n;
1971
- const x = rt();
1972
- x.font = e;
1973
- const i = x.measureText("😀").width;
1974
- if (n = 0, i > t + 0.5 && typeof document < "u" && document.body !== null) {
1975
- const s = document.createElement("span");
1976
- s.style.font = e, s.style.display = "inline-block", s.style.visibility = "hidden", s.style.position = "absolute", s.textContent = "😀", document.body.appendChild(s);
1977
- const o = s.getBoundingClientRect().width;
1978
- document.body.removeChild(s), i - o > 0.5 && (n = i - o);
1979
- }
1980
- return Dt.set(e, n), n;
1981
- }
1982
- function P0(e) {
1983
- let t = 0;
1984
- const n = Kt();
1985
- for (const x of n.segment(e))
1986
- y0(x.segment) && t++;
1987
- return t;
1988
- }
1989
- function W0(e, t) {
1990
- return t.emojiCount === void 0 && (t.emojiCount = P0(e)), t.emojiCount;
1991
- }
1992
- function Fe(e, t, n) {
1993
- return n === 0 ? t.width : t.width - W0(e, t) * n;
1994
- }
1995
- function v0(e, t, n, x, i) {
1996
- if (t.breakableFitAdvances !== void 0 && t.breakableFitMode === i)
1997
- return t.breakableFitAdvances;
1998
- t.breakableFitMode = i;
1999
- const s = Kt(), o = [];
2000
- for (const c of s.segment(e))
2001
- o.push(c.segment);
2002
- if (o.length <= 1)
2003
- return t.breakableFitAdvances = null, t.breakableFitAdvances;
2004
- if (i === "sum-graphemes") {
2005
- const c = [];
2006
- for (const u of o) {
2007
- const f = ue(u, n);
2008
- c.push(Fe(u, f, x));
2009
- }
2010
- return t.breakableFitAdvances = c, t.breakableFitAdvances;
2011
- }
2012
- if (i === "pair-context" || o.length > k0) {
2013
- const c = [];
2014
- let u = null, f = 0;
2015
- for (const d of o) {
2016
- const S = ue(d, n), m = Fe(d, S, x);
2017
- if (u === null)
2018
- c.push(m);
2019
- else {
2020
- const p = u + d, M = ue(p, n);
2021
- c.push(Fe(p, M, x) - f);
2022
- }
2023
- u = d, f = m;
2024
- }
2025
- return t.breakableFitAdvances = c, t.breakableFitAdvances;
2026
- }
2027
- const a = [];
2028
- let l = "", r = 0;
2029
- for (const c of o) {
2030
- l += c;
2031
- const u = ue(l, n), f = Fe(l, u, x);
2032
- a.push(f - r), r = f;
2033
- }
2034
- return t.breakableFitAdvances = a, t.breakableFitAdvances;
2035
- }
2036
- function R0(e, t) {
2037
- const n = rt();
2038
- n.font = e;
2039
- const x = O0(e), i = b0(e), s = t ? w0(e, i) : 0;
2040
- return { cache: x, fontSize: i, emojiCorrection: s };
2041
- }
2042
- function T0(e) {
2043
- return e === "space" || e === "zero-width-break" || e === "soft-hyphen";
2044
- }
2045
- function Ge(e) {
2046
- return e === "space" || e === "preserved-space" || e === "tab" || e === "zero-width-break" || e === "soft-hyphen";
2047
- }
2048
- function ot(e, t, n = e.widths.length) {
2049
- for (; t < n; ) {
2050
- const x = e.kinds[t];
2051
- if (!T0(x))
2052
- break;
2053
- t++;
2054
- }
2055
- return t;
2056
- }
2057
- function Ut(e, t) {
2058
- if (t <= 0)
2059
- return 0;
2060
- const n = e % t;
2061
- return Math.abs(n) <= 1e-6 ? t : t - n;
2062
- }
2063
- function Jt(e, t, n) {
2064
- return e.letterSpacing !== 0 && t && e.spacingGraphemeCounts[n] > 0 ? e.letterSpacing : 0;
2065
- }
2066
- function lt(e, t) {
2067
- return t === 0 ? 0 : e + t;
2068
- }
2069
- function G0(e, t) {
2070
- return e.letterSpacing !== 0 && e.spacingGraphemeCounts[t] > 0 ? e.letterSpacing : 0;
2071
- }
2072
- function Qt(e, t, n, x, i) {
2073
- const s = t === "tab" ? i + G0(e, n) : e.lineEndFitAdvances[n];
2074
- return lt(x, s);
2075
- }
2076
- function Pe(e, t, n, x) {
2077
- const i = t === "tab" ? 0 : e.lineEndFitAdvances[n];
2078
- return lt(x, i);
2079
- }
2080
- function We(e, t, n, x, i) {
2081
- const s = t === "tab" ? i : e.lineEndPaintAdvances[n];
2082
- return lt(x, s);
2083
- }
2084
- function $t(e, t, n) {
2085
- return e.letterSpacing !== 0 && t ? n + e.letterSpacing : n;
2086
- }
2087
- function Yt(e, t) {
2088
- return e.letterSpacing === 0 ? t : t + e.letterSpacing;
2089
- }
2090
- function H0(e, t, n, x, i) {
2091
- if (e.letterSpacing === 0)
2092
- return 0;
2093
- if (i > 0)
2094
- return e.spacingGraphemeCounts[x] > 0 ? e.letterSpacing : 0;
2095
- for (let s = x - 1; s >= t; s--) {
2096
- const o = e.kinds[s];
2097
- if (!(o === "space" || o === "zero-width-break" || o === "hard-break")) {
2098
- if (o === "soft-hyphen") {
2099
- if (s === x - 1)
2100
- return 0;
2101
- continue;
2102
- }
2103
- return s === t && n > 0 || e.spacingGraphemeCounts[s] > 0 ? e.letterSpacing : 0;
2104
- }
2105
- }
2106
- return 0;
2107
- }
2108
- function qt(e, t, n, x, i, s) {
2109
- return t + H0(e, n, x, i, s);
2110
- }
2111
- function _0(e, t) {
2112
- let n = 0, x = e.chunks.length;
2113
- for (; n < x; ) {
2114
- const i = Math.floor((n + x) / 2);
2115
- t < e.chunks[i].consumedEndSegmentIndex ? x = i : n = i + 1;
2116
- }
2117
- return n < e.chunks.length ? n : -1;
2118
- }
2119
- function z0(e, t, n) {
2120
- let x = n.segmentIndex;
2121
- if (n.graphemeIndex > 0)
2122
- return t;
2123
- const i = e.chunks[t];
2124
- return i.startSegmentIndex === i.endSegmentIndex && x === i.startSegmentIndex || (x < i.startSegmentIndex && (x = i.startSegmentIndex), x = ot(e, x, i.endSegmentIndex), x < i.endSegmentIndex) ? (n.segmentIndex = x, n.graphemeIndex = 0, t) : i.consumedEndSegmentIndex >= e.widths.length ? -1 : (n.segmentIndex = i.consumedEndSegmentIndex, n.graphemeIndex = 0, t + 1);
2125
- }
2126
- function j0(e, t) {
2127
- if (t.segmentIndex >= e.widths.length)
2128
- return -1;
2129
- const n = _0(e, t.segmentIndex);
2130
- return n < 0 ? -1 : z0(e, n, t);
2131
- }
2132
- function K0(e, t, n) {
2133
- const { widths: x, kinds: i, breakableFitAdvances: s } = e;
2134
- if (x.length === 0)
2135
- return 0;
2136
- const a = Be().lineFitEpsilon, l = t + a;
2137
- let r = 0, c = 0, u = !1, f = 0, d = 0, S = 0, m = 0, p = -1, M = 0;
2138
- function R() {
2139
- p = -1, M = 0;
2140
- }
2141
- function L(T = S, P = m, W = c) {
2142
- r++, n?.(W, f, d, T, P), c = 0, u = !1, R();
2143
- }
2144
- function w(T, P) {
2145
- u = !0, f = T, d = 0, S = T + 1, m = 0, c = P;
2146
- }
2147
- function v(T, P, W) {
2148
- u = !0, f = T, d = P, S = T, m = P + 1, c = W;
2149
- }
2150
- function N(T, P) {
2151
- if (!u) {
2152
- w(T, P);
2153
- return;
2154
- }
2155
- c += P, S = T + 1, m = 0;
2156
- }
2157
- function D(T, P) {
2158
- const W = s[T];
2159
- for (let H = P; H < W.length; H++) {
2160
- const z = W[H];
2161
- u ? c + z > l ? (L(), v(T, H, z)) : (c += z, S = T, m = H + 1) : v(T, H, z);
2162
- }
2163
- u && S === T && m === W.length && (S = T + 1, m = 0);
2164
- }
2165
- let B = 0;
2166
- for (; B < x.length && !(!u && (B = ot(e, B), B >= x.length)); ) {
2167
- const T = x[B], P = i[B], W = Ge(P);
2168
- if (!u) {
2169
- T > l && s[B] !== null ? D(B, 0) : w(B, T), W && (p = B + 1, M = c - T), B++;
2170
- continue;
2171
- }
2172
- if (c + T > l) {
2173
- if (W) {
2174
- N(B, T), L(B + 1, 0, c - T), B++;
2175
- continue;
2176
- }
2177
- if (p >= 0) {
2178
- if (S > p || S === p && m > 0) {
2179
- L();
2180
- continue;
2181
- }
2182
- L(p, 0, M);
2183
- continue;
2184
- }
2185
- if (T > l && s[B] !== null) {
2186
- L(), D(B, 0), B++;
2187
- continue;
2188
- }
2189
- L();
2190
- continue;
2191
- }
2192
- N(B, T), W && (p = B + 1, M = c - T), B++;
2193
- }
2194
- return u && L(), r;
2195
- }
2196
- function U0(e, t, n) {
2197
- if (e.simpleLineWalkFastPath)
2198
- return K0(e, t, n);
2199
- const { widths: x, kinds: i, breakableFitAdvances: s, discretionaryHyphenWidth: o, chunks: a } = e;
2200
- if (x.length === 0 || a.length === 0)
2201
- return 0;
2202
- const l = Be(), r = l.lineFitEpsilon, c = t + r;
2203
- let u = 0, f = 0, d = !1, S = 0, m = 0, p = 0, M = 0, R = -1, L = 0, w = 0, v = null;
2204
- function N() {
2205
- R = -1, L = 0, w = 0, v = null;
2206
- }
2207
- function D() {
2208
- return v === "soft-hyphen" && R === p && M === 0 ? w : f;
2209
- }
2210
- function B(A = p, I = M, k) {
2211
- u++, n !== void 0 && n(qt(e, k ?? D(), S, m, A, I), S, m, A, I), f = 0, d = !1, N();
2212
- }
2213
- function T(A, I) {
2214
- d = !0, S = A, m = 0, p = A + 1, M = 0, f = I;
2215
- }
2216
- function P(A, I, k) {
2217
- d = !0, S = A, m = I, p = A, M = I + 1, f = k;
2218
- }
2219
- function W(A, I) {
2220
- if (!d) {
2221
- T(A, I);
2222
- return;
2223
- }
2224
- f += I, p = A + 1, M = 0;
2225
- }
2226
- function H(A, I, k, O, U, J) {
2227
- if (!I)
2228
- return;
2229
- const Y = Pe(e, A, k, U), te = We(e, A, k, U, O);
2230
- R = k + 1, L = f - J + Y, w = f - J + te, v = A;
2231
- }
2232
- function z(A, I) {
2233
- const k = s[A];
2234
- for (let O = I; O < k.length; O++) {
2235
- const U = k[O];
2236
- if (!d)
2237
- P(A, O, U);
2238
- else {
2239
- const J = $t(e, !0, U), Y = f + J;
2240
- Yt(e, Y) > c ? (B(), P(A, O, U)) : (f = Y, p = A, M = O + 1);
2241
- }
2242
- }
2243
- d && p === A && M === k.length && (p = A + 1, M = 0);
2244
- }
2245
- function C(A) {
2246
- u++, n?.(0, A.startSegmentIndex, 0, A.consumedEndSegmentIndex, 0), N();
2247
- }
2248
- for (let A = 0; A < a.length; A++) {
2249
- const I = a[A];
2250
- if (I.startSegmentIndex === I.endSegmentIndex) {
2251
- C(I);
2252
- continue;
2253
- }
2254
- d = !1, f = 0, S = I.startSegmentIndex, m = 0, p = I.startSegmentIndex, M = 0, N();
2255
- let k = I.startSegmentIndex;
2256
- for (; k < I.endSegmentIndex && !(!d && (k = ot(e, k, I.endSegmentIndex), k >= I.endSegmentIndex)); ) {
2257
- const O = i[k], U = Ge(O), J = Jt(e, d, k), Y = O === "tab" ? Ut(f + J, e.tabStopAdvance) : x[k], te = J + Y, ne = Qt(e, O, k, J, Y);
2258
- if (O === "soft-hyphen") {
2259
- d && (p = k + 1, M = 0, R = k + 1, L = f + o, w = f + o, v = O), k++;
2260
- continue;
2261
- }
2262
- if (!d) {
2263
- ne > c && s[k] !== null ? z(k, 0) : T(k, Y), H(O, U, k, Y, J, te), k++;
2264
- continue;
2265
- }
2266
- if (f + ne > c) {
2267
- const Z = f + Pe(e, O, k, J), le = f + We(e, O, k, J, Y);
2268
- if (v === "soft-hyphen" && l.preferEarlySoftHyphenBreak && L <= c) {
2269
- B(R, 0, w);
2270
- continue;
2271
- }
2272
- if (U && Z <= c) {
2273
- W(k, te), B(k + 1, 0, le), k++;
2274
- continue;
2275
- }
2276
- if (R >= 0 && L <= c) {
2277
- if (p > R || p === R && M > 0) {
2278
- B();
2279
- continue;
2280
- }
2281
- const re = R;
2282
- B(re, 0, w), k = re;
2283
- continue;
2284
- }
2285
- if (ne > c && s[k] !== null) {
2286
- B(), z(k, 0), k++;
2287
- continue;
2288
- }
2289
- B();
2290
- continue;
2291
- }
2292
- W(k, te), H(O, U, k, Y, J, te), k++;
2293
- }
2294
- if (d) {
2295
- const O = R === I.consumedEndSegmentIndex ? w : f;
2296
- B(I.consumedEndSegmentIndex, 0, O);
2297
- }
2298
- }
2299
- return u;
2300
- }
2301
- function J0(e, t, n, x) {
2302
- const i = e.chunks[n];
2303
- if (i.startSegmentIndex === i.endSegmentIndex)
2304
- return t.segmentIndex = i.consumedEndSegmentIndex, t.graphemeIndex = 0, 0;
2305
- const { widths: s, kinds: o, breakableFitAdvances: a, discretionaryHyphenWidth: l } = e, r = Be(), c = r.lineFitEpsilon, u = x + c, f = t.segmentIndex, d = t.graphemeIndex;
2306
- let S = 0, m = !1, p = t.segmentIndex, M = t.graphemeIndex, R = -1, L = 0, w = 0, v = null;
2307
- function N() {
2308
- return v === "soft-hyphen" && R === p && M === 0 ? w : S;
2309
- }
2310
- function D(C = p, A = M, I = N()) {
2311
- return m ? (t.segmentIndex = C, t.graphemeIndex = A, qt(e, I, f, d, C, A)) : null;
2312
- }
2313
- function B(C, A) {
2314
- m = !0, p = C + 1, M = 0, S = A;
2315
- }
2316
- function T(C, A, I) {
2317
- m = !0, p = C, M = A + 1, S = I;
2318
- }
2319
- function P(C, A) {
2320
- if (!m) {
2321
- B(C, A);
2322
- return;
2323
- }
2324
- S += A, p = C + 1, M = 0;
2325
- }
2326
- function W(C, A, I, k, O, U) {
2327
- if (!A)
2328
- return;
2329
- const J = Pe(e, C, I, O), Y = We(e, C, I, O, k);
2330
- R = I + 1, L = S - U + J, w = S - U + Y, v = C;
2331
- }
2332
- function H(C, A) {
2333
- const I = a[C];
2334
- for (let k = A; k < I.length; k++) {
2335
- const O = I[k];
2336
- if (!m)
2337
- T(C, k, O);
2338
- else {
2339
- const U = $t(e, !0, O), J = S + U;
2340
- if (Yt(e, J) > u)
2341
- return D();
2342
- S = J, p = C, M = k + 1;
2343
- }
2344
- }
2345
- return m && p === C && M === I.length && (p = C + 1, M = 0), null;
2346
- }
2347
- function z() {
2348
- return v !== "soft-hyphen" || R < 0 ? null : L <= u ? D(R, 0, w) : null;
2349
- }
2350
- for (let C = t.segmentIndex; C < i.endSegmentIndex; C++) {
2351
- const A = o[C], I = Ge(A), k = C === t.segmentIndex ? t.graphemeIndex : 0, O = Jt(e, m, C), U = A === "tab" ? Ut(S + O, e.tabStopAdvance) : s[C], J = O + U, Y = Qt(e, A, C, O, U);
2352
- if (A === "soft-hyphen" && k === 0) {
2353
- m && (p = C + 1, M = 0, R = C + 1, L = S + l, w = S + l, v = A);
2354
- continue;
2355
- }
2356
- if (!m) {
2357
- if (k > 0) {
2358
- const ne = H(C, k);
2359
- if (ne !== null)
2360
- return ne;
2361
- } else if (Y > u && a[C] !== null) {
2362
- const ne = H(C, 0);
2363
- if (ne !== null)
2364
- return ne;
2365
- } else
2366
- B(C, U);
2367
- W(A, I, C, U, O, J);
2368
- continue;
2369
- }
2370
- if (S + Y > u) {
2371
- const ne = S + Pe(e, A, C, O), he = S + We(e, A, C, O, U);
2372
- if (v === "soft-hyphen" && r.preferEarlySoftHyphenBreak && L <= u)
2373
- return D(R, 0, w);
2374
- const Z = z();
2375
- if (Z !== null)
2376
- return Z;
2377
- if (I && ne <= u)
2378
- return P(C, J), D(C + 1, 0, he);
2379
- if (R >= 0 && L <= u)
2380
- return p > R || p === R && M > 0 ? D() : D(R, 0, w);
2381
- if (Y > u && a[C] !== null) {
2382
- const le = D();
2383
- if (le !== null)
2384
- return le;
2385
- const re = H(C, 0);
2386
- if (re !== null)
2387
- return re;
2388
- }
2389
- return D();
2390
- }
2391
- P(C, J), W(A, I, C, U, O, J);
2392
- }
2393
- return R === i.consumedEndSegmentIndex && M === 0 ? D(i.consumedEndSegmentIndex, 0, w) : D(i.consumedEndSegmentIndex, 0, S);
2394
- }
2395
- function Q0(e, t, n) {
2396
- const { widths: x, kinds: i, breakableFitAdvances: s } = e, a = Be().lineFitEpsilon, l = n + a;
2397
- let r = 0, c = !1, u = t.segmentIndex, f = t.graphemeIndex, d = -1, S = 0;
2398
- for (let m = t.segmentIndex; m < x.length; m++) {
2399
- const p = i[m], M = Ge(p), R = m === t.segmentIndex ? t.graphemeIndex : 0, L = s[m], w = x[m];
2400
- if (!c) {
2401
- if (R > 0 || w > l && L !== null) {
2402
- const v = L, N = v[R];
2403
- c = !0, r = N, u = m, f = R + 1;
2404
- for (let D = R + 1; D < v.length; D++) {
2405
- const B = v[D];
2406
- if (r + B > l)
2407
- return t.segmentIndex = u, t.graphemeIndex = f, r;
2408
- r += B, u = m, f = D + 1;
2409
- }
2410
- u === m && f === v.length && (u = m + 1, f = 0);
2411
- } else
2412
- c = !0, r = w, u = m + 1, f = 0;
2413
- M && (d = m + 1, S = r - w);
2414
- continue;
2415
- }
2416
- if (r + w > l)
2417
- return M ? (t.segmentIndex = m + 1, t.graphemeIndex = 0, r) : d >= 0 ? u > d || u === d && f > 0 ? (t.segmentIndex = u, t.graphemeIndex = f, r) : (t.segmentIndex = d, t.graphemeIndex = 0, S) : (t.segmentIndex = u, t.graphemeIndex = f, r);
2418
- r += w, u = m + 1, f = 0, M && (d = m + 1, S = r - w);
2419
- }
2420
- return c ? (t.segmentIndex = u, t.graphemeIndex = f, r) : null;
2421
- }
2422
- function $0(e, t, n, x) {
2423
- return e.simpleLineWalkFastPath ? Q0(e, t, x) : J0(e, t, n, x);
2424
- }
2425
- function Xe(e, t, n) {
2426
- const x = j0(e, t);
2427
- return x < 0 ? null : $0(e, t, x, n);
2428
- }
2429
- let Ue = null, Lt = /* @__PURE__ */ new WeakMap();
2430
- function Y0() {
2431
- return Ue === null && (Ue = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ue;
2432
- }
2433
- function Ot(e, t, n) {
2434
- let x = n.get(e);
2435
- if (x !== void 0)
2436
- return x;
2437
- x = [];
2438
- const i = Y0();
2439
- for (const s of i.segment(t[e]))
2440
- x.push(s.segment);
2441
- return n.set(e, x), x;
2442
- }
2443
- function q0(e, t, n) {
2444
- return n > t && e[n - 1] === "soft-hyphen";
2445
- }
2446
- function bt(e, t, n, x) {
2447
- for (let i = n; i < x; i++)
2448
- e += t[i];
2449
- return e;
2450
- }
2451
- function X0(e) {
2452
- let t = Lt.get(e);
2453
- return t !== void 0 || (t = /* @__PURE__ */ new Map(), Lt.set(e, t)), t;
2454
- }
2455
- function V0(e, t, n, x, i, s) {
2456
- let o = "";
2457
- const a = q0(e.kinds, n, i);
2458
- for (let l = n; l < i; l++)
2459
- if (!(e.kinds[l] === "soft-hyphen" || e.kinds[l] === "hard-break"))
2460
- if (l === n && x > 0) {
2461
- const r = Ot(l, e.segments, t);
2462
- o = bt(o, r, x, r.length);
2463
- } else
2464
- o += e.segments[l];
2465
- if (s > 0) {
2466
- a && (o += "-");
2467
- const l = Ot(i, e.segments, t);
2468
- o = bt(o, l, n === i ? x : 0, s);
2469
- } else a && (o += "-");
2470
- return o;
2471
- }
2472
- let Je = null;
2473
- function Xt() {
2474
- return Je === null && (Je = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Je;
2475
- }
2476
- function Z0(e) {
2477
- return {
2478
- widths: [],
2479
- lineEndFitAdvances: [],
2480
- lineEndPaintAdvances: [],
2481
- kinds: [],
2482
- simpleLineWalkFastPath: !0,
2483
- segLevels: null,
2484
- breakableFitAdvances: [],
2485
- letterSpacing: 0,
2486
- spacingGraphemeCounts: [],
2487
- discretionaryHyphenWidth: 0,
2488
- tabStopAdvance: 0,
2489
- chunks: [],
2490
- segments: []
2491
- };
2492
- }
2493
- function es(e, t) {
2494
- const n = [];
2495
- let x = [], i = 0, s = !1, o = !1, a = !1;
2496
- function l() {
2497
- x.length !== 0 && (n.push({
2498
- text: x.length === 1 ? x[0] : x.join(""),
2499
- start: i
2500
- }), x = [], s = !1, o = !1, a = !1);
2501
- }
2502
- function r(u, f, d) {
2503
- x = [u], i = f, s = d, o = Ye(u), a = ve.has(u);
2504
- }
2505
- function c(u, f) {
2506
- x.push(u), s = s || f;
2507
- const d = Ye(u);
2508
- u.length === 1 && ge.has(u) ? o = o || d : o = d, a = !1;
2509
- }
2510
- for (const u of Xt().segment(e)) {
2511
- const f = u.segment, d = oe(f);
2512
- if (x.length === 0) {
2513
- r(f, u.index, d);
2514
- continue;
2515
- }
2516
- if (a || st.has(f) || ge.has(f) || t.carryCJKAfterClosingQuote && d && o) {
2517
- c(f, d);
2518
- continue;
2519
- }
2520
- if (!s && !d) {
2521
- c(f, d);
2522
- continue;
2523
- }
2524
- l(), r(f, u.index, d);
2525
- }
2526
- return l(), n;
2527
- }
2528
- function ts(e, t, n) {
2529
- if (t.length <= 1)
2530
- return t;
2531
- const x = [];
2532
- let i = -1, s = !1;
2533
- function o(l, r) {
2534
- const c = t[l].start, u = r < t.length ? t[r].start : e.length;
2535
- x.push({
2536
- text: e.slice(c, u),
2537
- start: c
2538
- });
2539
- }
2540
- function a(l) {
2541
- if (!(i < 0)) {
2542
- if (s)
2543
- i + 1 === l ? x.push(t[i]) : o(i, l);
2544
- else
2545
- for (let r = i; r < l; r++)
2546
- x.push(t[r]);
2547
- i = -1, s = !1;
2548
- }
2549
- }
2550
- for (let l = 0; l < t.length; l++) {
2551
- const r = t[l];
2552
- i >= 0 && !zt(t[l - 1].text, n) && a(l), i < 0 && (i = l), s = s || oe(r.text);
2553
- }
2554
- return a(t.length), x;
2555
- }
2556
- function yt(e, t) {
2557
- if (t === "zero-width-break" || t === "soft-hyphen" || t === "hard-break")
2558
- return 0;
2559
- if (t === "tab")
2560
- return 1;
2561
- let n = 0;
2562
- const x = Xt();
2563
- for (const i of x.segment(e))
2564
- n++;
2565
- return n;
2566
- }
2567
- function ns(e, t, n) {
2568
- return t > 1 ? e + (t - 1) * n : e;
2569
- }
2570
- function ss(e, t, n, x, i) {
2571
- const s = Be(), { cache: o, emojiCorrection: a } = R0(t, I0(e.normalized)), l = Fe("-", ue("-", o), a) + (i === 0 ? 0 : i * 2), c = Fe(" ", ue(" ", o), a) * 8, u = i !== 0;
2572
- if (e.len === 0)
2573
- return Z0();
2574
- const f = [], d = [], S = [], m = [];
2575
- let p = e.chunks.length <= 1 && !u;
2576
- const M = n ? [] : null, R = [], L = [], w = n ? [] : null, v = Array.from({ length: e.len });
2577
- function N(P, W, H, z, C, A, I, k) {
2578
- C !== "text" && C !== "space" && C !== "zero-width-break" && (p = !1), f.push(W), d.push(H), S.push(z), m.push(C), M?.push(A), R.push(I), u && L.push(k), w !== null && w.push(P);
2579
- }
2580
- function D(P, W, H, z, C) {
2581
- const A = ue(P, o), I = u ? yt(P, W) : 0, k = ns(Fe(P, A, a), I, i), O = W === "space" || W === "preserved-space" || W === "zero-width-break" ? 0 : k, U = O === 0 ? 0 : O + (I > 0 ? i : 0), J = W === "space" || W === "zero-width-break" ? 0 : k;
2582
- if (C && z && P.length > 1) {
2583
- let Y = "sum-graphemes";
2584
- i !== 0 ? Y = "segment-prefixes" : we(P) ? Y = "pair-context" : s.preferPrefixWidthsForBreakableRuns && (Y = "segment-prefixes");
2585
- const te = v0(P, A, o, a, Y);
2586
- N(P, k, U, J, W, H, te, I);
2587
- return;
2588
- }
2589
- N(P, k, U, J, W, H, null, I);
2590
- }
2591
- for (let P = 0; P < e.len; P++) {
2592
- v[P] = f.length;
2593
- const W = e.texts[P], H = e.isWordLike[P], z = e.kinds[P], C = e.starts[P];
2594
- if (z === "soft-hyphen") {
2595
- N(W, 0, l, l, z, C, null, 0);
2596
- continue;
2597
- }
2598
- if (z === "hard-break") {
2599
- N(W, 0, 0, 0, z, C, null, 0);
2600
- continue;
2601
- }
2602
- if (z === "tab") {
2603
- N(W, 0, 0, 0, z, C, null, u ? yt(W, z) : 0);
2604
- continue;
2605
- }
2606
- const A = ue(W, o);
2607
- if (z === "text" && A.containsCJK) {
2608
- const I = es(W, s), k = x === "keep-all" ? ts(W, I, s.breakKeepAllAfterPunctuation) : I;
2609
- for (let O = 0; O < k.length; O++) {
2610
- const U = k[O];
2611
- D(U.text, "text", C + U.start, H, x === "keep-all" || !oe(U.text));
2612
- }
2613
- continue;
2614
- }
2615
- D(W, z, C, H, !0);
2616
- }
2617
- const B = is(e.chunks, v, f.length), T = M === null ? null : On(e.normalized, M);
2618
- return w !== null ? {
2619
- widths: f,
2620
- lineEndFitAdvances: d,
2621
- lineEndPaintAdvances: S,
2622
- kinds: m,
2623
- simpleLineWalkFastPath: p,
2624
- segLevels: T,
2625
- breakableFitAdvances: R,
2626
- letterSpacing: i,
2627
- spacingGraphemeCounts: L,
2628
- discretionaryHyphenWidth: l,
2629
- tabStopAdvance: c,
2630
- chunks: B,
2631
- segments: w
2632
- } : {
2633
- widths: f,
2634
- lineEndFitAdvances: d,
2635
- lineEndPaintAdvances: S,
2636
- kinds: m,
2637
- simpleLineWalkFastPath: p,
2638
- segLevels: T,
2639
- breakableFitAdvances: R,
2640
- letterSpacing: i,
2641
- spacingGraphemeCounts: L,
2642
- discretionaryHyphenWidth: l,
2643
- tabStopAdvance: c,
2644
- chunks: B
2645
- };
2646
- }
2647
- function is(e, t, n) {
2648
- const x = [];
2649
- for (let i = 0; i < e.length; i++) {
2650
- const s = e[i], o = s.startSegmentIndex < t.length ? t[s.startSegmentIndex] : n, a = s.endSegmentIndex < t.length ? t[s.endSegmentIndex] : n, l = s.consumedEndSegmentIndex < t.length ? t[s.consumedEndSegmentIndex] : n;
2651
- x.push({
2652
- startSegmentIndex: o,
2653
- endSegmentIndex: a,
2654
- consumedEndSegmentIndex: l
2655
- });
2656
- }
2657
- return x;
2658
- }
2659
- function xs(e, t, n, x) {
2660
- const i = x?.wordBreak ?? "normal", s = x?.letterSpacing ?? 0, o = C0(e, Be(), x?.whiteSpace, i);
2661
- return ss(o, t, n, i, s);
2662
- }
2663
- function Ve(e, t, n) {
2664
- return xs(e, t, !0, n);
2665
- }
2666
- function It(e) {
2667
- let t = 0;
2668
- return U0(e, Number.POSITIVE_INFINITY, (n) => {
2669
- n > t && (t = n);
2670
- }), t;
2671
- }
2672
- const rs = /[ \t\n\f\r]+/, wt = /^[ \t\n\f\r]+/, Pt = /[ \t\n\f\r]+$/, Wt = { segmentIndex: 0, graphemeIndex: 0 }, os = {
2673
- itemIndex: 0,
2674
- segmentIndex: 0,
2675
- graphemeIndex: 0
2676
- };
2677
- function Qe(e) {
2678
- return {
2679
- segmentIndex: e.segmentIndex,
2680
- graphemeIndex: e.graphemeIndex
2681
- };
2682
- }
2683
- function vt(e) {
2684
- return e.segmentIndex === 0 && e.graphemeIndex === 0;
2685
- }
2686
- function be(e, t, n) {
2687
- const x = `${e}\0${t}`, i = n.get(x);
2688
- if (i !== void 0)
2689
- return i;
2690
- const s = t === 0 ? void 0 : { letterSpacing: t }, o = It(Ve("A A", e, s)), a = It(Ve("AA", e, s)), l = Math.max(0, o - a);
2691
- return n.set(x, l), l;
2692
- }
2693
- function ls(e) {
2694
- const t = { segmentIndex: 0, graphemeIndex: 0 }, n = Xe(e, t, Number.POSITIVE_INFINITY);
2695
- return n === null ? null : {
2696
- endGraphemeIndex: t.graphemeIndex,
2697
- endSegmentIndex: t.segmentIndex,
2698
- width: n
2699
- };
2700
- }
2701
- function cs(e, t) {
2702
- return e === 0 && t > 0;
2703
- }
2704
- function Vt(e) {
2705
- const t = [], n = Array.from({ length: e.length }), x = /* @__PURE__ */ new Map();
2706
- let i = 0;
2707
- for (let s = 0; s < e.length; s++) {
2708
- const o = e[s], a = o.letterSpacing ?? 0, l = wt.test(o.text), r = Pt.test(o.text), c = o.text.replace(wt, "").replace(Pt, "");
2709
- if (c.length === 0) {
2710
- rs.test(o.text) && i === 0 && (i = be(o.font, a, x));
2711
- continue;
2712
- }
2713
- const u = i > 0 ? i : l ? be(o.font, a, x) : 0, f = Ve(c, o.font, a === 0 ? void 0 : { letterSpacing: a }), d = ls(f);
2714
- if (d === null) {
2715
- i = r ? be(o.font, a, x) : 0;
2716
- continue;
2717
- }
2718
- const S = {
2719
- break: o.break ?? "normal",
2720
- endGraphemeIndex: d.endGraphemeIndex,
2721
- endSegmentIndex: d.endSegmentIndex,
2722
- extraWidth: o.extraWidth ?? 0,
2723
- gapBefore: u,
2724
- naturalWidth: d.width,
2725
- prepared: f,
2726
- sourceItemIndex: s
2727
- };
2728
- t.push(S), n[s] = S, i = r ? be(o.font, a, x) : 0;
2729
- }
2730
- return {
2731
- items: t,
2732
- itemsBySourceItemIndex: n
2733
- };
2734
- }
2735
- function as(e, t, n, x) {
2736
- if (e.items.length === 0 || n.itemIndex >= e.items.length)
2737
- return null;
2738
- const i = Math.max(1, t);
2739
- let s = 0, o = i, a = n.itemIndex;
2740
- e: for (; a < e.items.length; ) {
2741
- const l = e.items[a];
2742
- if (!vt(n) && n.segmentIndex === l.endSegmentIndex && n.graphemeIndex === l.endGraphemeIndex) {
2743
- a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2744
- continue;
2745
- }
2746
- const r = s === 0 ? 0 : l.gapBefore, c = vt(n);
2747
- if (l.break === "never") {
2748
- if (!c) {
2749
- a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2750
- continue;
2751
- }
2752
- const M = l.naturalWidth + l.extraWidth, R = r + M;
2753
- if (s > 0 && R > o)
2754
- break e;
2755
- x?.(l, r, M, Qe(Wt), {
2756
- segmentIndex: l.endSegmentIndex,
2757
- graphemeIndex: l.endGraphemeIndex
2758
- }), s += R, o = Math.max(0, i - s), a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2759
- continue;
2760
- }
2761
- const u = r + l.extraWidth;
2762
- if (s > 0 && u >= o)
2763
- break e;
2764
- if (c) {
2765
- const M = u + l.naturalWidth;
2766
- if (M <= o) {
2767
- x?.(l, r, l.naturalWidth + l.extraWidth, Qe(Wt), {
2768
- segmentIndex: l.endSegmentIndex,
2769
- graphemeIndex: l.endGraphemeIndex
2770
- }), s += M, o = Math.max(0, i - s), a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2771
- continue;
2772
- }
2773
- }
2774
- const f = Math.max(1, o - u), d = {
2775
- segmentIndex: n.segmentIndex,
2776
- graphemeIndex: n.graphemeIndex
2777
- }, S = Xe(l.prepared, d, f);
2778
- if (S === null) {
2779
- a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2780
- continue;
2781
- }
2782
- if (n.segmentIndex === d.segmentIndex && n.graphemeIndex === d.graphemeIndex) {
2783
- a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2784
- continue;
2785
- }
2786
- const m = S + l.extraWidth, p = r + m;
2787
- if (s > 0 && c && p > o)
2788
- break e;
2789
- if (s > 0 && c && r > 0 && cs(d.segmentIndex, d.graphemeIndex)) {
2790
- const M = { segmentIndex: 0, graphemeIndex: 0 };
2791
- if (Xe(l.prepared, M, Math.max(1, i - l.extraWidth)) !== null && (M.segmentIndex > d.segmentIndex || M.segmentIndex === d.segmentIndex && M.graphemeIndex > d.graphemeIndex))
2792
- break e;
2793
- }
2794
- if (x?.(l, r, m, Qe(n), {
2795
- segmentIndex: d.segmentIndex,
2796
- graphemeIndex: d.graphemeIndex
2797
- }), s += p, o = Math.max(0, i - s), d.segmentIndex === l.endSegmentIndex && d.graphemeIndex === l.endGraphemeIndex) {
2798
- a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2799
- continue;
2800
- }
2801
- n.segmentIndex = d.segmentIndex, n.graphemeIndex = d.graphemeIndex;
2802
- break;
2803
- }
2804
- return s === 0 ? null : (n.itemIndex = a, s);
2805
- }
2806
- function us(e, t, n = os) {
2807
- const x = e, i = {
2808
- itemIndex: n.itemIndex,
2809
- segmentIndex: n.segmentIndex,
2810
- graphemeIndex: n.graphemeIndex
2811
- }, s = [], o = as(x, t, i, (a, l, r, c, u) => {
2812
- s.push({
2813
- itemIndex: a.sourceItemIndex,
2814
- gapBefore: l,
2815
- occupiedWidth: r,
2816
- start: c,
2817
- end: u
2818
- });
2819
- });
2820
- return o === null ? null : {
2821
- fragments: s,
2822
- width: o,
2823
- end: i
2824
- };
2825
- }
2826
- function fs(e, t) {
2827
- return V0(e.prepared, X0(e.prepared), t.start.segmentIndex, t.start.graphemeIndex, t.end.segmentIndex, t.end.graphemeIndex);
2828
- }
2829
- function hs(e, t) {
2830
- const n = e, x = [];
2831
- for (let i = 0; i < t.fragments.length; i++) {
2832
- const s = t.fragments[i], o = n.itemsBySourceItemIndex[s.itemIndex];
2833
- if (o === void 0)
2834
- throw new Error("Missing rich-text inline item for fragment");
2835
- x.push({
2836
- itemIndex: s.itemIndex,
2837
- text: fs(o, s),
2838
- gapBefore: s.gapBefore,
2839
- occupiedWidth: s.occupiedWidth,
2840
- start: s.start,
2841
- end: s.end
2842
- });
2843
- }
2844
- return {
2845
- fragments: x,
2846
- width: t.width,
2847
- end: t.end
2848
- };
2849
- }
2850
- function ds(e) {
2851
- const t = [];
2852
- let n = [], x = 0, i = 0;
2853
- for (const s of e) {
2854
- let o = 0;
2855
- for (; ; ) {
2856
- const l = s.text.indexOf("\v", o);
2857
- if (l < 0) break;
2858
- const r = s.text.slice(o, l);
2859
- r.length > 0 && n.push({ text: r, style: s.style }), i += l - o, t.push({ runs: n, startOffset: x }), i += 1, x = i, n = [], o = l + 1;
2860
- }
2861
- const a = s.text.slice(o);
2862
- a.length > 0 && n.push({ text: a, style: s.style }), i += a.length;
2863
- }
2864
- return t.push({ runs: n, startOffset: x }), t;
2865
- }
2866
- function Zt(e) {
2867
- return e.map((t) => {
2868
- const n = { text: t.style.hidden ? "" : t.text, font: fe(t.style) };
2869
- return !t.style.hidden && t.style.letterSpacingPx !== void 0 && (n.letterSpacing = t.style.letterSpacingPx), n;
2870
- });
2871
- }
2872
- function Fs(e) {
2873
- return Vt(Zt(e));
2874
- }
2875
- class Ze {
2876
- map = /* @__PURE__ */ new Map();
2877
- get(t) {
2878
- const n = this.map.get(t.id);
2879
- if (n && n.revision === t.revision) return n.segments;
2880
- const x = ds(t.runs).map((i) => ({
2881
- prepared: Vt(Zt(i.runs)),
2882
- runs: i.runs,
2883
- startOffset: i.startOffset
2884
- }));
2885
- return this.map.set(t.id, { revision: t.revision, segments: x }), x;
2886
- }
2887
- evict(t) {
2888
- this.map.delete(t);
2889
- }
2890
- /** Drop every entry whose id is NOT in `keep` (paragraphs no longer in the
2891
- * document). Called after a full layout to bound the cache to live blocks. */
2892
- retainOnly(t) {
2893
- for (const n of this.map.keys()) t.has(n) || this.map.delete(n);
2894
- }
2895
- }
2896
- const $e = 48;
2897
- function gs() {
2898
- const e = new Ze(), t = /* @__PURE__ */ new Map();
2899
- let n = null;
2900
- const x = (i, s) => {
2901
- n?.add(i.id);
2902
- const o = t.get(i.id);
2903
- if (o && o.revision === i.revision && o.width === s) return o.lines;
2904
- const a = sn(i, s, e);
2905
- return t.set(i.id, { revision: i.revision, width: s, lines: a }), a;
2906
- };
2907
- return {
2908
- layout(i, s, o) {
2909
- const a = o?.rawBand ?? null;
2910
- n = a === null ? /* @__PURE__ */ new Set() : null;
2911
- try {
2912
- const l = Cs(i, x, (r) => (n?.add(r.id), e.get(r)), a);
2913
- if (n) {
2914
- for (const r of t.keys()) n.has(r) || t.delete(r);
2915
- e.retainOnly(n);
2916
- }
2917
- return l;
2918
- } finally {
2919
- n = null;
2920
- }
2921
- },
2922
- evict(i) {
2923
- e.evict(i), t.delete(i);
2924
- }
2925
- };
2926
- }
2927
- function Ns(e) {
2928
- let t = 0;
2929
- for (let n = 0; n < e.length; n++) e.charCodeAt(n) === 32 && t++;
2930
- return t;
2931
- }
2932
- const Ss = (e) => e === " " || e === " " || e === `
2933
- ` || e === "\r";
2934
- function ps(e, t, n) {
2935
- const x = e.indexOf(n, t);
2936
- if (x >= 0) return { start: x, end: x + n.length };
2937
- const i = [];
2938
- let s = t, o = 0, a = -1;
2939
- for (; o < n.length && s < e.length; ) {
2940
- if (e[s] === n[o]) {
2941
- a < 0 && (a = s), i.push(s - a), s++, o++;
2942
- continue;
2943
- }
2944
- if (Ss(e[s])) {
2945
- s++;
2946
- continue;
2947
- }
2948
- a = -1;
2949
- break;
2950
- }
2951
- return a >= 0 && o === n.length ? (i.push(s - a), s - a === n.length ? { start: a, end: s } : { start: a, end: s, map: i }) : { start: t, end: t + n.length };
2952
- }
2953
- function ct(e, t) {
2954
- const n = [];
2955
- let x = t;
2956
- for (const i of e)
2957
- n.push(x), x += i.text.length;
2958
- return n;
2959
- }
2960
- function As(e) {
2961
- return mn(e) && !e.style.sectionBreak && !e.style.pageBreakBefore;
2962
- }
2963
- function en(e) {
2964
- const t = e.runs[0]?.style, n = t?.fontSizePx ?? 16, x = t ? Ie(fe(t)) : { ascent: n * 0.8, descent: n * 0.2 }, i = x.ascent + x.descent, s = Math.max(i, e.style.lineHeight * n);
2965
- return { height: s, ascent: (s - i) / 2 + x.ascent };
2966
- }
2967
- function at(e, t, n, x, i, s) {
2968
- const o = us(t.prepared, n, x);
2969
- if (o === null) return null;
2970
- const a = hs(t.prepared, o), l = [];
2971
- let r = 0, c = 0, u = 0, f = 0;
2972
- for (const p of a.fragments) {
2973
- r += p.gapBefore;
2974
- const M = t.runs[p.itemIndex], R = Ie(fe(M.style));
2975
- if (c = Math.max(c, R.ascent), u = Math.max(u, R.descent), f = Math.max(f, M.style.fontSizePx), p.text.length > 0) {
2976
- const L = ps(M.text, s[p.itemIndex], p.text);
2977
- s[p.itemIndex] = L.end;
2978
- const w = {
2979
- blockId: e.id,
2980
- startOffset: i[p.itemIndex] + L.start,
2981
- endOffset: i[p.itemIndex] + L.end,
2982
- text: p.text,
2983
- style: M.style,
2984
- x: r,
2985
- width: p.occupiedWidth
2986
- };
2987
- L.map && (w.offsetMap = L.map), l.push({ frag: w, hadGap: p.gapBefore > 0, spaces: Ns(p.text) });
2988
- }
2989
- r += p.occupiedWidth;
2990
- }
2991
- if (f === 0) {
2992
- const p = e.runs[0]?.style;
2993
- if (p) {
2994
- const M = Ie(fe(p));
2995
- c = M.ascent, u = M.descent, f = p.fontSizePx;
2996
- }
2997
- }
2998
- const d = c + u, S = Math.max(d, e.style.lineHeight * f), m = (S - d) / 2;
2999
- return { frags: l, width: a.width, height: S, ascent: m + c, end: a.end };
3000
- }
3001
- function ms(e, t, n) {
3002
- for (const i of t) if (i.posPx > e + 0.5) return i;
3003
- let x = (Math.floor(e / $e) + 1) * $e;
3004
- return x <= e && (x = e + $e), { posPx: Math.min(x, Math.max(e + 1, n)), align: "left", leader: "none" };
3005
- }
3006
- function Es(e) {
3007
- const t = e.map((i) => i.text).join(""), n = fe(e[0]?.style ?? tn);
3008
- let x = t.indexOf(".");
3009
- return x < 0 && (x = t.indexOf(",")), tt(x < 0 ? t : t.slice(0, x + 1), n);
3010
- }
3011
- const tn = { fontFamily: "Georgia, serif", fontSizePx: 16 };
3012
- function Bs(e, t, n, x, i) {
3013
- const s = [];
3014
- let o = [], a = n, l = n;
3015
- for (const L of t) {
3016
- let w = 0;
3017
- for (; ; ) {
3018
- const N = L.text.indexOf(" ", w);
3019
- if (N < 0) break;
3020
- const D = L.text.slice(w, N);
3021
- D.length > 0 && o.push({ text: D, style: L.style }), l += N - w, s.push({ runs: o, start: a }), l += 1, a = l, o = [], w = N + 1;
3022
- }
3023
- const v = L.text.slice(w);
3024
- v.length > 0 && o.push({ text: v, style: L.style }), l += v.length;
3025
- }
3026
- s.push({ runs: o, start: a });
3027
- const r = (e.style.tabStops ?? []).slice().sort((L, w) => L.posPx - w.posPx), c = t.find((L) => L.text.length > 0)?.style ?? e.runs[0]?.style, u = [];
3028
- let f = [], d = [], S = i, m = 0, p = 0, M = !1;
3029
- const R = (L) => {
3030
- if (m === 0 && c) {
3031
- const w = Ie(fe(c));
3032
- m = Math.max(w.ascent + w.descent, e.style.lineHeight * c.fontSizePx), p = (m - (w.ascent + w.descent)) / 2 + w.ascent;
3033
- }
3034
- u.push({
3035
- frags: f,
3036
- width: S,
3037
- indent: 0,
3038
- // fragment x is already absolute (tab/indent baked in)
3039
- lineMaxWidth: x,
3040
- height: m,
3041
- ascent: p,
3042
- // A tab-positioned line stays ragged (its manual x must not be re-justified);
3043
- // pure wrapped continuation lines justify normally when the paragraph does.
3044
- lastOfSegment: L || M,
3045
- ...d.length > 0 ? { leaders: d } : {}
3046
- }), f = [], d = [], S = 0, m = 0, p = 0, M = !1;
3047
- };
3048
- return s.forEach((L, w) => {
3049
- if (w > 0) {
3050
- const P = ms(S, r, x), W = P.align ?? "left", H = tt(L.runs.map((A) => A.text).join(""), fe(L.runs[0]?.style ?? c ?? tn)), z = S + H <= x;
3051
- let C = P.posPx;
3052
- z && W === "right" ? C = P.posPx - H : z && W === "center" ? C = P.posPx - H / 2 : z && W === "decimal" && (C = P.posPx - Es(L.runs)), C < S && (C = S), (P.leader ?? "none") !== "none" && C > S + 1 && c && d.push({ x1: S, x2: C, kind: P.leader ?? "none", color: c.color, fontSizePx: c.fontSizePx }), S = C, M = !0;
3053
- }
3054
- if (L.runs.length === 0) return;
3055
- const v = { prepared: Fs(L.runs), runs: L.runs, startOffset: L.start }, N = ct(L.runs, L.start), D = L.runs.map(() => 0);
3056
- let B, T = !0;
3057
- for (; ; ) {
3058
- const P = Math.max(24, x - (T ? S : 0)), W = at(e, v, P, B, N, D);
3059
- if (W === null) break;
3060
- T || R(!1);
3061
- const H = T ? S : 0;
3062
- for (const z of W.frags)
3063
- z.frag.x += H, f.push(z);
3064
- S = H + W.width, m = Math.max(m, W.height), p = Math.max(p, W.ascent), B = W.end, T = !1;
3065
- }
3066
- }), R(!0), u;
3067
- }
3068
- function nn(e, t) {
3069
- if (t <= 0) return;
3070
- const n = e.reduce((s, o) => s + o.spaces + (o.hadGap ? 1 : 0), 0);
3071
- if (n <= 0) return;
3072
- const x = t / n;
3073
- let i = 0;
3074
- for (const s of e)
3075
- s.hadGap && (i += x), s.frag.x += i, s.spaces > 0 && (s.frag.wordSpacingPx = x, s.frag.width += s.spaces * x, i += s.spaces * x);
3076
- }
3077
- function sn(e, t, n) {
3078
- const x = n.get(e), i = [], s = [];
3079
- let o = !0;
3080
- for (const l of x) {
3081
- if (l.runs.some((d) => d.text.includes(" "))) {
3082
- s.push(...Bs(e, l.runs, l.startOffset, t, o ? e.style.indentFirstLinePx : 0)), o = !1;
3083
- continue;
3084
- }
3085
- const r = ct(l.runs, l.startOffset), c = l.runs.map(() => 0);
3086
- let u, f = !1;
3087
- for (; ; ) {
3088
- const d = o ? e.style.indentFirstLinePx : 0, S = t - d, m = at(e, l, S, u, r, c);
3089
- if (m === null) break;
3090
- s.push({
3091
- frags: m.frags,
3092
- width: m.width,
3093
- indent: d,
3094
- lineMaxWidth: S,
3095
- height: m.height,
3096
- ascent: m.ascent,
3097
- lastOfSegment: !1
3098
- }), u = m.end, o = !1, f = !0;
3099
- }
3100
- if (f)
3101
- s[s.length - 1].lastOfSegment = !0;
3102
- else {
3103
- const d = en(e);
3104
- s.push({
3105
- frags: [],
3106
- width: 0,
3107
- indent: 0,
3108
- lineMaxWidth: t,
3109
- height: d.height,
3110
- ascent: d.ascent,
3111
- lastOfSegment: !0,
3112
- emptyOffset: l.startOffset
3113
- }), o = !1;
3114
- }
3115
- }
3116
- let a = 0;
3117
- for (const l of s) {
3118
- const r = l.lineMaxWidth - l.width;
3119
- let c = l.indent;
3120
- e.style.align === "center" ? c += r / 2 : e.style.align === "right" ? c += r : e.style.align === "justify" && !l.lastOfSegment && nn(l.frags, r);
3121
- for (const f of l.frags) f.frag.x += c;
3122
- const u = { y: a, height: l.height, ascent: l.ascent, fragments: l.frags.map((f) => f.frag) };
3123
- l.emptyOffset !== void 0 && (u.emptyOffset = l.emptyOffset), l.leaders && l.leaders.length > 0 && (u.leaders = l.leaders.map((f) => ({ ...f, x1: f.x1 + c, x2: f.x2 + c }))), i.push(u), a += l.height;
3124
- }
3125
- return i;
3126
- }
3127
- const Rt = 2, Tt = 2, Ms = 48, xn = ["header", "footer", "headerFirst", "headerEven", "footerFirst", "footerEven"];
3128
- function rn(e, t) {
3129
- const n = {
3130
- pageWidthPx: t.pageWidthPx ?? e.pageWidthPx,
3131
- pageHeightPx: t.pageHeightPx ?? e.pageHeightPx,
3132
- marginPx: t.marginPx ?? e.marginPx
3133
- }, x = t.columns === void 0 ? e.columns : t.columns ?? void 0;
3134
- x && (n.columns = x), t.pageNumberStart !== void 0 && (n.pageNumberStart = t.pageNumberStart);
3135
- const i = t.headerDistancePx ?? e.headerDistancePx;
3136
- i !== void 0 && (n.headerDistancePx = i);
3137
- const s = t.footerDistancePx ?? e.footerDistancePx;
3138
- s !== void 0 && (n.footerDistancePx = s);
3139
- for (const o of xn) {
3140
- const a = t[o] ?? e[o];
3141
- a && (n[o] = a);
3142
- }
3143
- return n;
3144
- }
3145
- function Gt(e, t) {
3146
- return e.headerDistancePx !== void 0 ? e.headerDistancePx : Math.max(8, (e.marginPx.top - t) / 2);
3147
- }
3148
- function Ht(e, t) {
3149
- return e.footerDistancePx !== void 0 ? e.pageHeightPx - e.footerDistancePx - t : e.pageHeightPx - Math.max(8, (e.marginPx.bottom - t) / 2) - t;
3150
- }
3151
- function on(e) {
3152
- const t = [];
3153
- for (let n = 0; n < e.blocks.length; n++) {
3154
- const x = e.blocks[n];
3155
- x.kind === "paragraph" && x.style.sectionBreak && t.push({ props: rn(e.section, x.style.sectionBreak.props), endBlock: n });
3156
- }
3157
- return t.push({ props: e.section, endBlock: e.blocks.length - 1 }), t;
3158
- }
3159
- function Cs(e, t, n, x) {
3160
- const s = /* @__PURE__ */ new Map();
3161
- let o = null;
3162
- const a = (h) => {
3163
- const F = s.get(h);
3164
- if (F) return F;
3165
- let g = h.marginPx.top, E = h.pageHeightPx - h.marginPx.bottom;
3166
- const y = [h.header, h.headerFirst, h.headerEven].filter((_) => !!_), b = [h.footer, h.footerFirst, h.footerEven].filter((_) => !!_);
3167
- if (y.length > 0 || b.length > 0) {
3168
- o ??= new Ze();
3169
- const _ = h.pageWidthPx - h.marginPx.left - h.marginPx.right, j = h.marginPx.left, q = (V) => ye(V, _, j, 999, 999, o, !1).height, K = (V) => {
3170
- const ee = ye(V, _, j, 999, 999, o, !1);
3171
- for (const $ of ee.placed)
3172
- if (!!$.table || !!$.image || $.lines.some((Me) => Me.fragments.some((ae) => ae.text.trim().length > 0))) return ee.height - $.y;
3173
- return 0;
3174
- }, Q = y.reduce((V, ee) => Math.max(V, q(ee)), 0);
3175
- if (Q > 0) {
3176
- const V = Gt(h, Q);
3177
- g = Math.max(g, V + Q + 6);
3178
- }
3179
- const X = b.reduce((V, ee) => Math.max(V, q(ee)), 0);
3180
- if (X > 0)
3181
- if (h.footerDistancePx !== void 0) {
3182
- const V = h.pageHeightPx - h.footerDistancePx, ee = b.reduce(($, Ae) => Math.max($, K(Ae)), 0);
3183
- E = Math.min(E, V - ee);
3184
- } else
3185
- E = Math.min(E, Ht(h, X) - 6);
3186
- E = Math.max(E, g + 24);
3187
- }
3188
- const G = { top: g, bottom: E };
3189
- return s.set(h, G), G;
3190
- }, l = on(e);
3191
- let r = l[0].props, c = 0, u = 0, f = 0, d = 0, S = 1, m = 0, p = 0;
3192
- const M = (h) => {
3193
- r = h;
3194
- const F = a(r);
3195
- c = r.marginPx.left, u = F.top, f = F.bottom, d = r.pageWidthPx - r.marginPx.left - r.marginPx.right, S = Math.max(1, r.columns?.count ?? 1), m = r.columns?.gapPx ?? 24, p = S > 1 ? (d - (S - 1) * m) / S : d;
3196
- };
3197
- M(r);
3198
- const R = e.lists ?? {}, L = (h) => {
3199
- const F = h.style.list;
3200
- if (!F) return null;
3201
- const g = R[F.listId];
3202
- return g ? g.levels[Math.min(F.level, g.levels.length - 1)] ?? null : null;
3203
- }, w = (h) => h.style.indentLeftPx + (L(h)?.indentLeftPx ?? 0), v = (h) => h.style.indentRightPx ?? 0, N = (h) => L(h)?.indentLeftPx ?? 0, D = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map(), T = (h) => {
3204
- const F = h.style.list, g = L(h);
3205
- if (!F || !g) return;
3206
- const E = R[F.listId], y = D.get(F.listId) ?? [];
3207
- y[F.level] = (y[F.level] ?? g.start - 1) + 1, y.length = F.level + 1, D.set(F.listId, y);
3208
- const b = Cn(E, F.level, y);
3209
- if (b.length === 0) return;
3210
- const G = h.runs[0]?.style;
3211
- G && B.set(h.id, {
3212
- text: b,
3213
- style: { ...G, ...g.markerStyle ?? {} },
3214
- hangingPx: g.hangingPx
3215
- });
3216
- }, P = (h) => {
3217
- for (const F of h)
3218
- if (F.kind === "paragraph") T(F);
3219
- else if (F.kind === "table") for (const g of F.rows) for (const E of g.cells) P(E.blocks);
3220
- };
3221
- P(e.blocks);
3222
- const W = { indentOf: N, markers: B }, H = [];
3223
- let z = 0;
3224
- for (let h = 0; h < e.blocks.length; h++) {
3225
- for (; h > l[z].endBlock; ) M(l[++z].props);
3226
- const F = e.blocks[h];
3227
- if (F.kind === "paragraph") {
3228
- if (As(F)) continue;
3229
- const g = F.style.tocEntry ? Ms : 0;
3230
- H.push({
3231
- kind: "para",
3232
- block: F,
3233
- lines: t(F, p - w(F) - v(F) - g)
3234
- });
3235
- } else if (F.kind === "image")
3236
- H.push({ kind: "image", block: F, height: F.heightPx });
3237
- else {
3238
- const g = ut(F, p, t, W);
3239
- H.push({ kind: "table", block: F, ...g });
3240
- }
3241
- }
3242
- z = 0, M(l[0].props);
3243
- const C = [], A = () => (C.push(r), {
3244
- index: C.length - 1,
3245
- number: C.length,
3246
- // provisional; the post-pass sets the real value
3247
- blocks: [],
3248
- widthPx: r.pageWidthPx,
3249
- heightPx: r.pageHeightPx,
3250
- marginPx: r.marginPx,
3251
- contentTopPx: u,
3252
- contentBottomPx: f
3253
- }), I = [A()];
3254
- let k = I[0], O = u;
3255
- const U = /* @__PURE__ */ new Map(), J = 14, Y = 18, te = e.footnotes ?? {}, ne = Object.keys(te).length > 0;
3256
- let he = 0;
3257
- const Z = () => f - he, le = /* @__PURE__ */ new Set(), re = [[]], He = [0], dt = /* @__PURE__ */ new Map(), Ft = (h) => {
3258
- const F = te[h];
3259
- if (!F || F.length === 0) return null;
3260
- const g = Math.max(40, d - Y);
3261
- let E = 0;
3262
- return { paras: F.map((b) => {
3263
- const G = t(b, g);
3264
- return E += b.style.spaceBeforePx + pe(G) + b.style.spaceAfterPx, { p: b, lines: G };
3265
- }), height: E };
3266
- }, cn = (h, F, g) => {
3267
- const E = [];
3268
- for (let y = F; y < F + g; y++)
3269
- for (const b of h[y].fragments) {
3270
- const G = b.style.footnoteRef;
3271
- G && te[G] && !le.has(G) && !E.some(([_]) => _ === G) && E.push([G, b.text]);
3272
- }
3273
- return E;
3274
- };
3275
- let Se = 0, Le = 0;
3276
- const ce = () => c + Se * (p + m), se = () => k.blocks.length > Le, _e = () => {
3277
- Se = 0, Le = 0, k = A(), I.push(k), re.push([]), He.push(0), he = 0, O = u, de = [];
3278
- }, ie = () => {
3279
- Se + 1 < S ? (Se++, Le = k.blocks.length, O = u, de = []) : _e();
3280
- }, an = () => {
3281
- k.blocks.length === 0 ? (k.widthPx = r.pageWidthPx, k.heightPx = r.pageHeightPx, k.marginPx = r.marginPx, k.contentTopPx = u, k.contentBottomPx = f, C[k.index] = r, Se = 0, Le = 0, O = u, de = []) : _e();
3282
- }, un = (h, F, g, E) => {
3283
- const y = {
3284
- blockId: h.id,
3285
- x: ce() + w(h),
3286
- y: O,
3287
- firstLineIndex: g,
3288
- lines: []
3289
- }, b = g === 0 ? B.get(h.id) : void 0;
3290
- b && (y.marker = { text: b.text, style: b.style, x: y.x - b.hangingPx }), h.style.tocEntry && U.set(h.id, { chunk: y, rightEdge: ce() + p, para: h }), k.blocks.push(y);
3291
- for (let G = g; G < g + E; G++) {
3292
- const _ = F[G];
3293
- y.lines.push({ ..._, y: O - y.y }), O += _.height;
3294
- }
3295
- }, fn = (h, F) => {
3296
- let g = 0, E = O;
3297
- for (; F + g < h.length && E + h[F + g].height <= Z(); )
3298
- E += h[F + g].height, g++;
3299
- return g;
3300
- }, gt = (h) => {
3301
- let F = re[k.index].length === 0 ? J : 0;
3302
- const g = [];
3303
- for (const [E, y] of h) {
3304
- const b = Ft(E);
3305
- b && (F += b.height, g.push([E, y, b]));
3306
- }
3307
- return { H: F, measures: g };
3308
- }, Nt = (h, F) => {
3309
- for (const [g, E] of h)
3310
- le.add(g), re[k.index].push(g), dt.set(g, E);
3311
- he += F, He[k.index] = he;
3312
- }, hn = (h) => {
3313
- const F = [], g = (E) => {
3314
- for (const y of E)
3315
- if (y.kind === "paragraph") {
3316
- let b = 0;
3317
- for (const G of y.runs) {
3318
- const _ = G.style.footnoteRef;
3319
- _ && te[_] && !le.has(_) && !F.some(([j]) => j === _) && F.push([_, G.text]), b += G.text.length;
3320
- }
3321
- } else if (y.kind === "table")
3322
- for (const b of y.rows) for (const G of b.cells) g(G.blocks);
3323
- };
3324
- for (const E of h) for (const y of E.cells) g(y.blocks);
3325
- return F;
3326
- }, dn = (h, F, g) => {
3327
- for (; ; ) {
3328
- if (g <= 0) return g;
3329
- const E = cn(h, F, g);
3330
- if (E.length === 0) return g;
3331
- const { H: y, measures: b } = gt(E);
3332
- if (b.length === 0) return g;
3333
- let G = 0;
3334
- for (let j = F; j < F + g; j++) G += h[j].height;
3335
- if (O + G + y <= Z() || g === 1 && !se())
3336
- return Nt(b, y), g;
3337
- g--;
3338
- }
3339
- }, Fn = (h, F) => {
3340
- if (h.style.keepLinesTogether === !0 && se()) {
3341
- const E = pe(F);
3342
- O + E > Z() && E <= f - u && ie();
3343
- }
3344
- let g = 0;
3345
- for (; g < F.length; ) {
3346
- const E = F.length - g, y = fn(F, g);
3347
- let b;
3348
- if (y >= E ? b = E : (b = y, E - b === 1 && (b -= Tt - 1), g === 0 && b > 0 && b < Rt && (b = 0), b <= 0 && (b = se() ? 0 : Math.max(1, y))), b > 0 && ne && (b = dn(F, g, b)), b > 0 && (un(h, F, g, b), g += b), g >= F.length) return;
3349
- ie();
3350
- }
3351
- }, pe = (h) => {
3352
- let F = 0;
3353
- for (const g of h) F += g.height;
3354
- return F;
3355
- };
3356
- let de = [];
3357
- const St = 10, gn = (h) => {
3358
- let F = ce(), g = ce() + p;
3359
- for (const E of de)
3360
- h >= E.bottom || (E.side === "left" ? F = Math.max(F, E.right + St) : g = Math.min(g, E.left - St));
3361
- return { x0: F, width: Math.max(40, g - F) };
3362
- }, Nn = (h) => de.some((F) => F.bottom > h), Sn = (h) => {
3363
- O + h.heightPx > Z() && se() && ie();
3364
- const F = h.wrap === "square" && h.align !== "center", g = p - h.widthPx, E = ce() + (h.align === "center" ? g / 2 : h.align === "right" ? g : 0);
3365
- k.blocks.push({
3366
- blockId: h.id,
3367
- x: E,
3368
- y: O,
3369
- firstLineIndex: 0,
3370
- lines: [],
3371
- image: { src: h.src, width: h.widthPx, height: h.heightPx }
3372
- }), F ? de.push({ left: E, right: E + h.widthPx, bottom: O + h.heightPx, side: h.align === "right" ? "right" : "left" }) : O += h.heightPx;
3373
- }, pn = (h) => {
3374
- const F = n(h);
3375
- let g = !0, E = 0, y = null;
3376
- const b = (G, _, j, q) => {
3377
- if (y === null) {
3378
- y = { blockId: h.id, x: ce() + w(h), y: O, firstLineIndex: E, lines: [] };
3379
- const Q = E === 0 ? B.get(h.id) : void 0;
3380
- Q && (y.marker = { text: Q.text, style: Q.style, x: y.x - Q.hangingPx }), k.blocks.push(y);
3381
- }
3382
- const K = { y: O - y.y, height: _, ascent: j, fragments: G.map((Q) => Q.frag) };
3383
- q !== void 0 && (K.emptyOffset = q), y.lines.push(K), O += _, E++;
3384
- };
3385
- for (const G of F) {
3386
- const _ = ct(G.runs, G.startOffset), j = G.runs.map(() => 0);
3387
- let q, K = !1, Q = null;
3388
- for (; ; ) {
3389
- const X = j.slice(), V = gn(O), ee = g ? h.style.indentFirstLinePx : 0, $ = at(
3390
- h,
3391
- G,
3392
- Math.max(24, V.width - w(h) - ee - v(h)),
3393
- q,
3394
- _,
3395
- j
3396
- );
3397
- if ($ === null) break;
3398
- if (O + $.height > Z() && se()) {
3399
- for (let ae = 0; ae < j.length; ae++) j[ae] = X[ae];
3400
- ie(), y = null;
3401
- continue;
3402
- }
3403
- const Ae = V.width - ee - v(h) - $.width;
3404
- let Me = V.x0 - ce() + ee;
3405
- h.style.align === "center" ? Me += Ae / 2 : h.style.align === "right" && (Me += Ae);
3406
- for (const ae of $.frags) ae.frag.x += Me;
3407
- h.style.align === "justify" && (Q && nn(Q.frags, Q.slack), Q = { frags: $.frags, slack: Ae }), b($.frags, $.height, $.ascent), q = $.end, g = !1, K = !0;
3408
- }
3409
- if (!K) {
3410
- const X = en(h);
3411
- O + X.height > Z() && se() && (ie(), y = null), b([], X.height, X.ascent, G.startOffset), g = !1;
3412
- }
3413
- }
3414
- }, An = (h) => {
3415
- h.block.rows.some((E) => E.cells.some((y) => (y.rowSpan ?? 1) > 1)) && se() && O + h.height > Z() && h.height <= f - u && ie();
3416
- let g = 0;
3417
- for (; g < h.rows.length; ) {
3418
- let E = 0, y = O;
3419
- for (; g + E < h.rows.length && y + h.rows[g + E].height <= Z(); )
3420
- y += h.rows[g + E].height, E++;
3421
- if (E === 0) {
3422
- if (se()) {
3423
- ie();
3424
- continue;
3425
- }
3426
- E = 1;
3427
- }
3428
- let b = [], G = 0;
3429
- for (; ; ) {
3430
- const j = hn(h.block.rows.slice(g, g + E));
3431
- if (j.length === 0) break;
3432
- const { H: q, measures: K } = gt(j);
3433
- if (K.length === 0) break;
3434
- let Q = 0;
3435
- for (let X = g; X < g + E; X++) Q += h.rows[X].height;
3436
- if (O + Q + q <= Z() || E === 1 && !se()) {
3437
- b = K, G = q;
3438
- break;
3439
- }
3440
- if (E--, E === 0) break;
3441
- }
3442
- if (E === 0) {
3443
- ie();
3444
- continue;
3445
- }
3446
- b.length > 0 && Nt(b, G);
3447
- const _ = h.rows.slice(g, g + E);
3448
- k.blocks.push(ht(h.block, _, h.colWidths, ce(), O, p, g, W)), O += _.reduce((j, q) => j + q.height, 0), g += E, g < h.rows.length && ie();
3449
- }
3450
- };
3451
- for (let h = 0; h < H.length; h++) {
3452
- if (h > l[z].endBlock) {
3453
- for (; h > l[z].endBlock; ) M(l[++z].props);
3454
- an();
3455
- }
3456
- const F = H[h], g = (_) => _?.kind === "table" || _?.kind === "image", E = g(H[h - 1]), y = g(H[h + 1]);
3457
- if (F.kind === "image") {
3458
- E || (O += Ce), Sn(F.block), !y && (F.block.wrap !== "square" || F.block.align === "center") && (O += Ce);
3459
- continue;
3460
- }
3461
- if (F.kind === "table") {
3462
- E || (O += Ce);
3463
- for (const _ of de) _.bottom > O && (O = _.bottom);
3464
- An(F), y || (O += Ce);
3465
- continue;
3466
- }
3467
- const { block: b, lines: G } = F;
3468
- if (b.style.pageBreakBefore === !0 && (k.blocks.length > 0 || Se > 0) ? _e() : b.style.columnBreakBefore === !0 && se() && ie(), O += b.style.spaceBeforePx, O >= Z() && se() && ie(), Nn(O)) {
3469
- pn(b), O += b.style.spaceAfterPx;
3470
- continue;
3471
- }
3472
- if (b.style.keepWithNext === !0 && H[h + 1] !== void 0 && se()) {
3473
- let _ = O + pe(G) + b.style.spaceAfterPx, j = _ <= Z();
3474
- for (let q = h + 1; j; q++) {
3475
- const K = H[q];
3476
- if (K === void 0) break;
3477
- if (K.kind !== "para") {
3478
- const $ = K.kind === "table" ? K.rows[0]?.height ?? K.height : K.height;
3479
- _ + Ce + $ > Z() && (j = !1);
3480
- break;
3481
- }
3482
- _ += K.block.style.spaceBeforePx;
3483
- const Q = K.block.style.keepWithNext === !0 && H[q + 1] !== void 0;
3484
- if (Q || K.block.style.keepLinesTogether === !0) {
3485
- const $ = pe(K.lines);
3486
- if (_ + $ > Z()) {
3487
- j = !1;
3488
- break;
3489
- }
3490
- if (_ += $ + K.block.style.spaceAfterPx, !Q) break;
3491
- continue;
3492
- }
3493
- if (H[q + 1] !== void 0 && K.block.runs.every(($) => $.text.trim().length === 0)) {
3494
- const $ = pe(K.lines);
3495
- if (_ + $ > Z()) {
3496
- j = !1;
3497
- break;
3498
- }
3499
- _ += $ + K.block.style.spaceAfterPx;
3500
- continue;
3501
- }
3502
- let X = 0, V = _;
3503
- for (; X < K.lines.length && V + K.lines[X].height <= Z(); )
3504
- V += K.lines[X].height, X++;
3505
- let ee = X;
3506
- X < K.lines.length && (K.lines.length - ee === 1 && (ee -= Tt - 1), ee < Rt && (ee = 0)), ee <= 0 && (j = !1);
3507
- break;
3508
- }
3509
- j || ie();
3510
- }
3511
- Fn(b, G), O += b.style.spaceAfterPx;
3512
- }
3513
- for (const h of I) {
3514
- const F = re[h.index];
3515
- if (!F || F.length === 0) continue;
3516
- const g = C[h.index];
3517
- M(g);
3518
- let E = f - He[h.index];
3519
- h.footnoteRuleY = E + 4, E += J;
3520
- const y = g.marginPx.left;
3521
- for (const b of F) {
3522
- const G = Ft(b);
3523
- if (!G) continue;
3524
- let _ = !0;
3525
- for (const j of G.paras) {
3526
- E += j.p.style.spaceBeforePx;
3527
- const q = {
3528
- blockId: j.p.id,
3529
- x: y + Y,
3530
- y: E,
3531
- firstLineIndex: 0,
3532
- lines: j.lines
3533
- };
3534
- _ && j.p.runs[0] && (q.marker = { text: `${dt.get(b) ?? "•"}.`, style: j.p.runs[0].style, x: y }, _ = !1), h.blocks.push(q), E += pe(j.lines) + j.p.style.spaceAfterPx;
3535
- }
3536
- }
3537
- }
3538
- const ze = [];
3539
- {
3540
- let h = 0;
3541
- for (let F = 0; F < I.length; F++) {
3542
- const g = C[F];
3543
- (F === 0 || C[F - 1] !== g) && g.pageNumberStart !== void 0 ? h = g.pageNumberStart : h++, ze.push(h), I[F].number = h;
3544
- }
3545
- }
3546
- if (U.size > 0) {
3547
- const h = /* @__PURE__ */ new Map(), F = (g, E) => {
3548
- for (const y of g)
3549
- if (h.has(y.blockId) || h.set(y.blockId, E), y.table) for (const b of y.table.rows) for (const G of b.cells) F(G.blocks, E);
3550
- };
3551
- for (const g of I) F(g.blocks, ze[g.index]);
3552
- for (const g of U.values()) {
3553
- const E = g.para.style.tocEntry.targetId, y = h.get(E);
3554
- if (y === void 0) continue;
3555
- const b = g.para.runs[0]?.style;
3556
- if (!b || g.chunk.lines.length === 0) continue;
3557
- const G = String(y);
3558
- g.chunk.toc = {
3559
- numText: G,
3560
- numX: g.rightEdge - tt(G, fe(b)),
3561
- lineIndex: g.chunk.lines.length - 1,
3562
- style: b,
3563
- targetId: E
3564
- };
3565
- }
3566
- }
3567
- const pt = (h, F, g, E) => {
3568
- const y = F === "header" ? h.headerFirst : h.footerFirst, b = F === "header" ? h.headerEven : h.footerEven;
3569
- if (g && y) return { blocks: y, source: F === "header" ? "headerFirst" : "footerFirst" };
3570
- if (E && b) return { blocks: b, source: F === "header" ? "headerEven" : "footerEven" };
3571
- const G = h[F];
3572
- return G ? { blocks: G, source: F } : null;
3573
- };
3574
- if (C.some((h) => xn.some((F) => h[F]))) {
3575
- const h = new Ze();
3576
- for (const F of I) {
3577
- const g = C[F.index], E = g.pageWidthPx - g.marginPx.left - g.marginPx.right, y = g.marginPx.left, b = F.index === 0 || C[F.index - 1] !== g, G = ze[F.index], _ = G % 2 === 0, j = pt(g, "header", b, _);
3578
- if (j) {
3579
- const K = x === "header", Q = ye(j.blocks, E, y, G, I.length, h, K), X = Gt(g, Q.height);
3580
- F.header = Q.placed.map((V) => et(V, X)), F.headerSource = j.source;
3581
- }
3582
- const q = pt(g, "footer", b, _);
3583
- if (q) {
3584
- const K = x === "footer", Q = ye(q.blocks, E, y, G, I.length, h, K), X = Ht(g, Q.height);
3585
- F.footer = Q.placed.map((V) => et(V, X)), F.footerSource = q.source;
3586
- }
3587
- }
3588
- }
3589
- return {
3590
- pages: I,
3591
- pageWidthPx: e.section.pageWidthPx,
3592
- pageHeightPx: e.section.pageHeightPx,
3593
- marginPx: e.section.marginPx
3594
- };
3595
- }
3596
- function ks(e, t) {
3597
- switch (t) {
3598
- case "roman":
3599
- return Oe(e, "lowerRoman");
3600
- case "Roman":
3601
- return Oe(e, "upperRoman");
3602
- case "alpha":
3603
- return Oe(e, "lowerLetter");
3604
- case "Alpha":
3605
- return Oe(e, "upperLetter");
3606
- default:
3607
- return String(e);
3608
- }
3609
- }
3610
- function Ds(e, t, n) {
3611
- return e.replace(/\{page(?::(roman|Roman|alpha|Alpha))?\}/g, (x, i) => ks(t, i)).replace(/\{pages\}/g, String(n)).replace(/\{date\}/g, () => (/* @__PURE__ */ new Date()).toLocaleDateString()).replace(/\{time\}/g, () => (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }));
3612
- }
3613
- function Ls(e, t, n) {
3614
- const x = (i) => i.runs.some((s) => s.text.includes("{")) ? {
3615
- ...i,
3616
- id: `${i.id}@p${t}`,
3617
- // per-page identity keeps the band prepare-cache honest
3618
- runs: i.runs.map((s) => ({ ...s, text: Ds(s.text, t, n) }))
3619
- } : i;
3620
- return e.kind === "paragraph" ? x(e) : e.kind === "table" ? {
3621
- ...e,
3622
- rows: e.rows.map((i) => ({
3623
- cells: i.cells.map((s) => ({
3624
- ...s,
3625
- blocks: s.blocks.map((o) => o.kind === "paragraph" ? x(o) : o)
3626
- }))
3627
- }))
3628
- } : e;
3629
- }
3630
- function ye(e, t, n, x, i, s, o) {
3631
- const a = (c, u) => sn(c, u, s), l = [];
3632
- let r = 0;
3633
- for (const c of e) {
3634
- const u = o ? c : Ls(c, x, i);
3635
- if (u.kind === "paragraph") {
3636
- r += u.style.spaceBeforePx;
3637
- const f = a(u, t);
3638
- l.push({ blockId: u.id, x: n + u.style.indentLeftPx, y: r, firstLineIndex: 0, lines: f }), r += ft(f) + u.style.spaceAfterPx;
3639
- } else if (u.kind === "image") {
3640
- const f = t - u.widthPx, d = n + (u.align === "center" ? f / 2 : u.align === "right" ? f : 0);
3641
- l.push({
3642
- blockId: u.id,
3643
- x: d,
3644
- y: r,
3645
- firstLineIndex: 0,
3646
- lines: [],
3647
- image: { src: u.src, width: u.widthPx, height: u.heightPx }
3648
- }), r += u.heightPx;
3649
- } else {
3650
- const f = ut(u, t, a, _t);
3651
- l.push(ht(u, f.rows, f.colWidths, n, r, t, 0, _t)), r += f.height;
3652
- }
3653
- }
3654
- return { placed: l, height: r };
3655
- }
3656
- function et(e, t) {
3657
- const n = { ...e, y: e.y + t };
3658
- return e.table && (n.table = {
3659
- ...e.table,
3660
- y: e.table.y + t,
3661
- rows: e.table.rows.map((x) => ({
3662
- ...x,
3663
- y: x.y + t,
3664
- cells: x.cells.map((i) => ({
3665
- ...i,
3666
- y: i.y + t,
3667
- blocks: i.blocks.map((s) => et(s, t))
3668
- }))
3669
- }))
3670
- }), n;
3671
- }
3672
- const Ce = 12, Os = { top: 0, right: 7.2, bottom: 0, left: 7.2 }, ln = (e) => e.margin ?? Os, ke = 4, _t = { indentOf: () => 0, markers: /* @__PURE__ */ new Map() };
3673
- function ut(e, t, n, x) {
3674
- const s = En(e).map((c) => c * t), o = s.length, a = new Array(o).fill(0), l = e.rows.map((c) => {
3675
- let u = 0;
3676
- const f = c.cells.map((d) => {
3677
- for (; u < o && a[u] > 0; ) u++;
3678
- const S = Math.max(1, d.colSpan ?? 1), m = Math.max(1, d.rowSpan ?? 1), p = u;
3679
- let M = 0;
3680
- for (let N = 0; N < S; N++) M += s[u + N] ?? s[o - 1] ?? 40;
3681
- if (m > 1) for (let N = 0; N < S && u + N < o; N++) a[u + N] = m;
3682
- u += S;
3683
- const R = ln(d), L = Math.max(8, M - R.left - R.right);
3684
- let w = 0;
3685
- const v = d.blocks.map((N) => {
3686
- if (N.kind === "paragraph") {
3687
- const B = L - N.style.indentLeftPx - x.indentOf(N) - (N.style.indentRightPx ?? 0), T = n(N, Math.max(8, B));
3688
- return w += N.style.spaceBeforePx + ft(T) + N.style.spaceAfterPx, { kind: "para", block: N, lines: T };
3689
- }
3690
- if (N.kind === "image") {
3691
- const B = Math.min(1, L / Math.max(1, N.widthPx)), T = N.widthPx * B, P = N.heightPx * B;
3692
- return w += P + ke, { kind: "image", block: N, width: T, height: P };
3693
- }
3694
- const D = ut(N, L, n, x);
3695
- return w += D.height + ke, { kind: "table", block: N, ...D };
3696
- });
3697
- return { cell: d, items: v, height: w + R.top + R.bottom, width: M, colStart: p, rowSpan: m };
3698
- });
3699
- for (let d = 0; d < o; d++) a[d] > 0 && a[d]--;
3700
- return { cells: f, height: 0 };
3701
- }), r = l.map((c) => Math.max(0, ...c.cells.filter((u) => u.rowSpan === 1).map((u) => u.height)));
3702
- return l.forEach((c, u) => {
3703
- for (const f of c.cells) {
3704
- if (f.rowSpan <= 1) continue;
3705
- const d = Math.min(l.length - 1, u + f.rowSpan - 1);
3706
- let S = 0;
3707
- for (let m = u; m <= d; m++) S += r[m];
3708
- f.height > S && (r[d] += f.height - S);
3709
- }
3710
- }), l.forEach((c, u) => c.height = r[u]), { rows: l, colWidths: s, height: r.reduce((c, u) => c + u, 0) };
3711
- }
3712
- function ft(e) {
3713
- let t = 0;
3714
- for (const n of e) t += n.height;
3715
- return t;
3716
- }
3717
- function ht(e, t, n, x, i, s, o, a) {
3718
- const l = [0];
3719
- for (const f of n) l.push(l[l.length - 1] + f);
3720
- const r = [i];
3721
- for (const f of t) r.push(r[r.length - 1] + f.height);
3722
- const c = [];
3723
- for (let f = 0; f < t.length; f++) {
3724
- const d = t[f], S = r[f], m = [];
3725
- for (const p of d.cells) {
3726
- const M = x + (l[p.colStart] ?? l[l.length - 1]), R = Math.min(t.length - 1, f + p.rowSpan - 1), L = r[R + 1] - S, w = [], v = ln(p.cell), N = p.width - v.left - v.right;
3727
- let D = S + v.top;
3728
- for (const B of p.items)
3729
- if (B.kind === "para") {
3730
- D += B.block.style.spaceBeforePx;
3731
- const T = M + v.left + B.block.style.indentLeftPx + a.indentOf(B.block), P = {
3732
- blockId: B.block.id,
3733
- x: T,
3734
- y: D,
3735
- firstLineIndex: 0,
3736
- lines: B.lines
3737
- // line.y is already block-relative; coords stay consistent
3738
- }, W = a.markers.get(B.block.id);
3739
- W && (P.marker = { text: W.text, style: W.style, x: Math.max(M + 1, T - W.hangingPx) }), w.push(P), D += ft(B.lines) + B.block.style.spaceAfterPx;
3740
- } else if (B.kind === "image") {
3741
- const T = L - v.top - v.bottom;
3742
- if (p.items.length === 1 && T > B.height + 8) {
3743
- const P = Math.max(N / B.block.widthPx, T / B.block.heightPx), W = B.block.widthPx * P, H = B.block.heightPx * P, z = M + v.left, C = S + v.top;
3744
- w.push({
3745
- blockId: B.block.id,
3746
- x: z + (N - W) / 2,
3747
- y: C + (T - H) / 2,
3748
- firstLineIndex: 0,
3749
- lines: [],
3750
- image: { src: B.block.src, width: W, height: H, clip: { x: z, y: C, width: N, height: T } }
3751
- }), D += B.height + ke;
3752
- } else {
3753
- const P = N - B.width, W = M + v.left + (B.block.align === "center" ? P / 2 : B.block.align === "right" ? P : 0);
3754
- w.push({
3755
- blockId: B.block.id,
3756
- x: W,
3757
- y: D,
3758
- firstLineIndex: 0,
3759
- lines: [],
3760
- image: { src: B.block.src, width: B.width, height: B.height }
3761
- }), D += B.height + ke;
3762
- }
3763
- } else
3764
- w.push(ht(B.block, B.rows, B.colWidths, M + v.left, D, N, 0, a)), D += B.height + ke;
3765
- m.push({
3766
- x: M,
3767
- y: S,
3768
- width: p.width,
3769
- height: L,
3770
- originRow: o + f,
3771
- originCol: p.colStart,
3772
- blocks: w,
3773
- ...p.cell.shading !== void 0 ? { shading: p.cell.shading } : {},
3774
- ...p.cell.borders !== void 0 ? { borders: p.cell.borders } : {},
3775
- // Horizontal content band (full cell height): clips over-wide text to the
3776
- // inner box so it never paints onto the border or into the next column.
3777
- contentClip: { x: M + v.left, y: S, width: N, height: L }
3778
- });
3779
- }
3780
- c.push({ y: S, height: d.height, cells: m });
3781
- }
3782
- const u = t.reduce((f, d) => f + d.height, 0);
3783
- return {
3784
- blockId: e.id,
3785
- x,
3786
- y: i,
3787
- firstLineIndex: o,
3788
- // for tables this is the chunk's first ROW index
3789
- lines: [],
3790
- table: { x, y: i, width: s, height: u, rows: c, colWidths: n }
3791
- };
3792
- }
3793
- const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3794
- __proto__: null,
3795
- createLayoutEngine: gs,
3796
- effectiveSection: rn,
3797
- resolveSections: on
3798
- }, Symbol.toStringTag, { value: "Module" }));
3799
- function bs(e) {
3800
- const t = /* @__PURE__ */ new Map(), n = (x, i) => {
3801
- for (const s of x)
3802
- if (t.has(s.blockId) || t.set(s.blockId, i), s.table) for (const o of s.table.rows) for (const a of o.cells) n(a.blocks, i);
3803
- };
3804
- for (const x of e.pages) n(x.blocks, x.number);
3805
- return t;
3806
- }
3807
- function Ws(e, t) {
3808
- const n = bs(t), x = [];
3809
- for (const i of e.blocks) {
3810
- if (i.kind !== "paragraph") continue;
3811
- const s = i.runs.find((u) => u.style.link?.startsWith("#"))?.style.link?.slice(1);
3812
- if (!s) continue;
3813
- const o = e.bookmarks?.[s]?.start.blockId;
3814
- if (!o) continue;
3815
- const a = n.get(o);
3816
- if (a === void 0) continue;
3817
- const l = Bn(i.runs), r = l.match(/\t(\d+)(\s*)$/);
3818
- if (!r || r[1] === String(a)) continue;
3819
- const c = l.length - r[2].length - r[1].length;
3820
- x.push({
3821
- blockId: i.id,
3822
- start: c,
3823
- end: c + r[1].length,
3824
- text: String(a),
3825
- style: Mn(i.runs, c) ?? i.runs[0]?.style
3826
- });
3827
- }
3828
- return x;
3829
- }
3830
- export {
3831
- Ws as a,
3832
- gs as c,
3833
- Ps as e,
3834
- bs as p
3835
- };