@formulaxjs/ckeditor5 0.3.1 → 0.4.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 (48) hide show
  1. package/README.md +24 -21
  2. package/README.zh-CN.md +24 -21
  3. package/dist/base.css +47 -0
  4. package/dist/canvg-runtime-UR3JNX5Q.js +2759 -0
  5. package/dist/canvg-runtime-UR3JNX5Q.js.map +1 -0
  6. package/dist/chunk-4NHESKRD.js +3407 -0
  7. package/dist/chunk-4NHESKRD.js.map +1 -0
  8. package/dist/images/scrollbar/custom/bar-bg.png +0 -0
  9. package/dist/images/scrollbar/custom/bar.png +0 -0
  10. package/dist/images/scrollbar/custom/bg.png +0 -0
  11. package/dist/images/scrollbar/custom/bottom.png +0 -0
  12. package/dist/images/scrollbar/custom/btn.png +0 -0
  13. package/dist/images/scrollbar/custom/down.png +0 -0
  14. package/dist/images/scrollbar/custom/top.png +0 -0
  15. package/dist/images/scrollbar/custom/up.png +0 -0
  16. package/dist/images/scrollbar/edit/bar-bg.png +0 -0
  17. package/dist/images/scrollbar/edit/bar-left.png +0 -0
  18. package/dist/images/scrollbar/edit/bar-right.png +0 -0
  19. package/dist/images/scrollbar/edit/thumb-bg.png +0 -0
  20. package/dist/images/scrollbar/edit/thumb-left.png +0 -0
  21. package/dist/images/scrollbar/edit/thumb-right.png +0 -0
  22. package/dist/images/toolbar/btn.png +0 -0
  23. package/dist/index.cjs +24080 -70
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +81 -0
  26. package/dist/index.d.ts +81 -0
  27. package/dist/index.global.js +162 -156
  28. package/dist/index.global.js.map +1 -1
  29. package/dist/index.js +3768 -21
  30. package/dist/index.js.map +1 -1
  31. package/dist/install-XGCSWTLU.js +5464 -0
  32. package/dist/install-XGCSWTLU.js.map +1 -0
  33. package/dist/install-XVTKACEN.js +1349 -0
  34. package/dist/install-XVTKACEN.js.map +1 -0
  35. package/dist/other.png +0 -0
  36. package/dist/scrollbar.css +78 -0
  37. package/dist/start-CRRRBVTN.js +4926 -0
  38. package/dist/start-CRRRBVTN.js.map +1 -0
  39. package/dist/ui.css +625 -0
  40. package/package.json +12 -7
  41. /package/dist/{KF_AMS_BB-5QF7FUSO.woff → KF_AMS_BB.woff} +0 -0
  42. /package/dist/{KF_AMS_CAL-NXRNLAZN.woff → KF_AMS_CAL.woff} +0 -0
  43. /package/dist/{KF_AMS_FRAK-CO33WWN4.woff → KF_AMS_FRAK.woff} +0 -0
  44. /package/dist/{KF_AMS_MAIN-25QJVAWY.woff → KF_AMS_MAIN.woff} +0 -0
  45. /package/dist/{KF_AMS_ROMAN-243BR7HH.woff → KF_AMS_ROMAN.woff} +0 -0
  46. /package/dist/{btn-5DANP6JY.png → btn.png} +0 -0
  47. /package/dist/{editor-JT5KLVXX.css → editor.css} +0 -0
  48. /package/dist/{other-OMWJFGL5.png → images/toolbar/other.png} +0 -0
package/dist/index.js CHANGED
@@ -1,3 +1,26 @@
1
+ import {
2
+ DEFAULT_FORMULAX_LOCALE,
3
+ createLegacyBaseComponent,
4
+ getFormulaXRuntimeMessage,
5
+ kityAssetManifest,
6
+ legacyBaseUtils,
7
+ legacyBoxType,
8
+ legacyEleType,
9
+ legacyEventListener,
10
+ legacyGroupType,
11
+ legacyInputFilter,
12
+ legacyItemType,
13
+ legacyKfEvent,
14
+ legacyKfExtDef,
15
+ legacyOtherPosition,
16
+ legacySysconf,
17
+ legacyUiDef,
18
+ legacyUiUtils,
19
+ normalizeFormulaXLocale,
20
+ setToolbarAssetUrls,
21
+ utils_default
22
+ } from "./chunk-4NHESKRD.js";
23
+
1
24
  // src/index.ts
2
25
  import {
3
26
  DEFAULT_FORMULA_ATTRIBUTE as DEFAULT_FORMULA_ATTRIBUTE2,
@@ -14,6 +37,3723 @@ import {
14
37
  toWidget,
15
38
  viewToModelPositionOutsideModelElement
16
39
  } from "ckeditor5";
40
+
41
+ // ../kity-runtime/src/vendor/char-position.ts
42
+ var legacyCharPosition = {
43
+ "\\pm": {
44
+ "x": 5,
45
+ "y": 0
46
+ },
47
+ "\\infty": {
48
+ "x": 42,
49
+ "y": 0
50
+ },
51
+ "=": {
52
+ "x": 79,
53
+ "y": 0
54
+ },
55
+ "\\sim": {
56
+ "x": 116,
57
+ "y": 0
58
+ },
59
+ "\\times": {
60
+ "x": 153,
61
+ "y": 0
62
+ },
63
+ "\\div": {
64
+ "x": 190,
65
+ "y": 0
66
+ },
67
+ "!": {
68
+ "x": 227,
69
+ "y": 0
70
+ },
71
+ "<": {
72
+ "x": 264,
73
+ "y": 0
74
+ },
75
+ "\\ll": {
76
+ "x": 301,
77
+ "y": 0
78
+ },
79
+ ">": {
80
+ "x": 338,
81
+ "y": 0
82
+ },
83
+ "\\gg": {
84
+ "x": 375,
85
+ "y": 0
86
+ },
87
+ "\\leq": {
88
+ "x": 412,
89
+ "y": 0
90
+ },
91
+ "\\geq": {
92
+ "x": 449,
93
+ "y": 0
94
+ },
95
+ "\\mp": {
96
+ "x": 486,
97
+ "y": 0
98
+ },
99
+ "\\cong": {
100
+ "x": 523,
101
+ "y": 0
102
+ },
103
+ "\\equiv": {
104
+ "x": 560,
105
+ "y": 0
106
+ },
107
+ "\\propto": {
108
+ "x": 597,
109
+ "y": 0
110
+ },
111
+ "\\approx": {
112
+ "x": 634,
113
+ "y": 0
114
+ },
115
+ "\\forall": {
116
+ "x": 671,
117
+ "y": 0
118
+ },
119
+ "\\partial": {
120
+ "x": 708,
121
+ "y": 0
122
+ },
123
+ "\\surd": {
124
+ "x": 745,
125
+ "y": 0
126
+ },
127
+ "\\cup": {
128
+ "x": 782,
129
+ "y": 0
130
+ },
131
+ "\\cap": {
132
+ "x": 819,
133
+ "y": 0
134
+ },
135
+ "\\varnothing": {
136
+ "x": 856,
137
+ "y": 0
138
+ },
139
+ "%": {
140
+ "x": 893,
141
+ "y": 0
142
+ },
143
+ "\\circ": {
144
+ "x": 930,
145
+ "y": 0
146
+ },
147
+ "\\exists": {
148
+ "x": 967,
149
+ "y": 0
150
+ },
151
+ "\\nexists": {
152
+ "x": 1004,
153
+ "y": 0
154
+ },
155
+ "\\in": {
156
+ "x": 1041,
157
+ "y": 0
158
+ },
159
+ "\\ni": {
160
+ "x": 1078,
161
+ "y": 0
162
+ },
163
+ "\\gets": {
164
+ "x": 5,
165
+ "y": 37
166
+ },
167
+ "\\uparrow": {
168
+ "x": 42,
169
+ "y": 37
170
+ },
171
+ "\\to": {
172
+ "x": 79,
173
+ "y": 37
174
+ },
175
+ "\\downarrow": {
176
+ "x": 116,
177
+ "y": 37
178
+ },
179
+ "\\leftrightarrow": {
180
+ "x": 153,
181
+ "y": 37
182
+ },
183
+ "\\therefore": {
184
+ "x": 190,
185
+ "y": 37
186
+ },
187
+ "\\because": {
188
+ "x": 227,
189
+ "y": 37
190
+ },
191
+ "+": {
192
+ "x": 264,
193
+ "y": 37
194
+ },
195
+ "-": {
196
+ "x": 301,
197
+ "y": 37
198
+ },
199
+ "\\neg": {
200
+ "x": 338,
201
+ "y": 37
202
+ },
203
+ "\\ast": {
204
+ "x": 375,
205
+ "y": 37
206
+ },
207
+ "\\cdot": {
208
+ "x": 412,
209
+ "y": 37
210
+ },
211
+ "\\vdots": {
212
+ "x": 449,
213
+ "y": 37
214
+ },
215
+ "\\ddots": {
216
+ "x": 486,
217
+ "y": 37
218
+ },
219
+ "\\aleph": {
220
+ "x": 523,
221
+ "y": 37
222
+ },
223
+ "\\beth": {
224
+ "x": 560,
225
+ "y": 37
226
+ },
227
+ "\\blacksquare": {
228
+ "x": 597,
229
+ "y": 37
230
+ },
231
+ "\\alpha": {
232
+ "x": 634,
233
+ "y": 37
234
+ },
235
+ "\\beta": {
236
+ "x": 671,
237
+ "y": 37
238
+ },
239
+ "\\gamma": {
240
+ "x": 708,
241
+ "y": 37
242
+ },
243
+ "\\delta": {
244
+ "x": 745,
245
+ "y": 37
246
+ },
247
+ "\\epsilon": {
248
+ "x": 782,
249
+ "y": 37
250
+ },
251
+ "\\zeta": {
252
+ "x": 819,
253
+ "y": 37
254
+ },
255
+ "\\eta": {
256
+ "x": 856,
257
+ "y": 37
258
+ },
259
+ "\\theta": {
260
+ "x": 893,
261
+ "y": 37
262
+ },
263
+ "\\iota": {
264
+ "x": 930,
265
+ "y": 37
266
+ },
267
+ "\\kappa": {
268
+ "x": 967,
269
+ "y": 37
270
+ },
271
+ "\\lambda": {
272
+ "x": 1004,
273
+ "y": 37
274
+ },
275
+ "\\mu": {
276
+ "x": 1041,
277
+ "y": 37
278
+ },
279
+ "\\nu": {
280
+ "x": 1078,
281
+ "y": 37
282
+ },
283
+ "\\xi": {
284
+ "x": 5,
285
+ "y": 74
286
+ },
287
+ "\\omicron": {
288
+ "x": 42,
289
+ "y": 74
290
+ },
291
+ "\\pi": {
292
+ "x": 79,
293
+ "y": 74
294
+ },
295
+ "\\rho": {
296
+ "x": 116,
297
+ "y": 74
298
+ },
299
+ "\\sigma": {
300
+ "x": 153,
301
+ "y": 74
302
+ },
303
+ "\\tau": {
304
+ "x": 190,
305
+ "y": 74
306
+ },
307
+ "\\upsilon": {
308
+ "x": 227,
309
+ "y": 74
310
+ },
311
+ "\\phi": {
312
+ "x": 264,
313
+ "y": 74
314
+ },
315
+ "\\chi": {
316
+ "x": 301,
317
+ "y": 74
318
+ },
319
+ "\\psi": {
320
+ "x": 338,
321
+ "y": 74
322
+ },
323
+ "\\omega": {
324
+ "x": 375,
325
+ "y": 74
326
+ },
327
+ "\\Alpha": {
328
+ "x": 412,
329
+ "y": 74
330
+ },
331
+ "\\Beta": {
332
+ "x": 449,
333
+ "y": 74
334
+ },
335
+ "\\Gamma": {
336
+ "x": 486,
337
+ "y": 74
338
+ },
339
+ "\\Delta": {
340
+ "x": 523,
341
+ "y": 74
342
+ },
343
+ "\\Epsilon": {
344
+ "x": 560,
345
+ "y": 74
346
+ },
347
+ "\\Zeta": {
348
+ "x": 597,
349
+ "y": 74
350
+ },
351
+ "\\Eta": {
352
+ "x": 634,
353
+ "y": 74
354
+ },
355
+ "\\Theta": {
356
+ "x": 671,
357
+ "y": 74
358
+ },
359
+ "\\Iota": {
360
+ "x": 708,
361
+ "y": 74
362
+ },
363
+ "\\Kappa": {
364
+ "x": 745,
365
+ "y": 74
366
+ },
367
+ "\\Lambda": {
368
+ "x": 782,
369
+ "y": 74
370
+ },
371
+ "\\Mu": {
372
+ "x": 819,
373
+ "y": 74
374
+ },
375
+ "\\Nu": {
376
+ "x": 856,
377
+ "y": 74
378
+ },
379
+ "\\Xi": {
380
+ "x": 893,
381
+ "y": 74
382
+ },
383
+ "\\Omicron": {
384
+ "x": 930,
385
+ "y": 74
386
+ },
387
+ "\\Pi": {
388
+ "x": 967,
389
+ "y": 74
390
+ },
391
+ "\\Rho": {
392
+ "x": 1004,
393
+ "y": 74
394
+ },
395
+ "\\Sigma": {
396
+ "x": 1041,
397
+ "y": 74
398
+ },
399
+ "\\Tau": {
400
+ "x": 1078,
401
+ "y": 74
402
+ },
403
+ "\\Upsilon": {
404
+ "x": 5,
405
+ "y": 111
406
+ },
407
+ "\\Phi": {
408
+ "x": 42,
409
+ "y": 111
410
+ },
411
+ "\\Chi": {
412
+ "x": 79,
413
+ "y": 111
414
+ },
415
+ "\\Psi": {
416
+ "x": 116,
417
+ "y": 111
418
+ },
419
+ "\\Omega": {
420
+ "x": 153,
421
+ "y": 111
422
+ },
423
+ "\\digamma": {
424
+ "x": 190,
425
+ "y": 111
426
+ },
427
+ "\\varepsilon": {
428
+ "x": 227,
429
+ "y": 111
430
+ },
431
+ "\\varkappa": {
432
+ "x": 264,
433
+ "y": 111
434
+ },
435
+ "\\varphi": {
436
+ "x": 301,
437
+ "y": 111
438
+ },
439
+ "\\varpi": {
440
+ "x": 338,
441
+ "y": 111
442
+ },
443
+ "\\varrho": {
444
+ "x": 375,
445
+ "y": 111
446
+ },
447
+ "\\varsigma": {
448
+ "x": 412,
449
+ "y": 111
450
+ },
451
+ "\\vartheta": {
452
+ "x": 449,
453
+ "y": 111
454
+ },
455
+ "\\neq": {
456
+ "x": 486,
457
+ "y": 111
458
+ },
459
+ "\\nless": {
460
+ "x": 523,
461
+ "y": 111
462
+ },
463
+ "\\ngtr": {
464
+ "x": 560,
465
+ "y": 111
466
+ },
467
+ "\\nleq": {
468
+ "x": 597,
469
+ "y": 111
470
+ },
471
+ "\\ngeq": {
472
+ "x": 634,
473
+ "y": 111
474
+ },
475
+ "\\nsim": {
476
+ "x": 671,
477
+ "y": 111
478
+ },
479
+ "\\lneqq": {
480
+ "x": 708,
481
+ "y": 111
482
+ },
483
+ "\\gneqq": {
484
+ "x": 745,
485
+ "y": 111
486
+ },
487
+ "\\nprec": {
488
+ "x": 782,
489
+ "y": 111
490
+ },
491
+ "\\nsucc": {
492
+ "x": 819,
493
+ "y": 111
494
+ },
495
+ "\\notin": {
496
+ "x": 856,
497
+ "y": 111
498
+ },
499
+ "\\nsubseteq": {
500
+ "x": 893,
501
+ "y": 111
502
+ },
503
+ "\\nsupseteq": {
504
+ "x": 930,
505
+ "y": 111
506
+ },
507
+ "\\subsetneq": {
508
+ "x": 967,
509
+ "y": 111
510
+ },
511
+ "\\supsetneq": {
512
+ "x": 1004,
513
+ "y": 111
514
+ },
515
+ "\\lnsim": {
516
+ "x": 1041,
517
+ "y": 111
518
+ },
519
+ "\\gnsim": {
520
+ "x": 1078,
521
+ "y": 111
522
+ },
523
+ "\\precnsim": {
524
+ "x": 5,
525
+ "y": 148
526
+ },
527
+ "\\succnsim": {
528
+ "x": 42,
529
+ "y": 148
530
+ },
531
+ "\\ntriangleleft": {
532
+ "x": 79,
533
+ "y": 148
534
+ },
535
+ "\\ntriangleright": {
536
+ "x": 116,
537
+ "y": 148
538
+ },
539
+ "\\ntrianglelefteq": {
540
+ "x": 153,
541
+ "y": 148
542
+ },
543
+ "\\ntrianglerighteq": {
544
+ "x": 190,
545
+ "y": 148
546
+ },
547
+ "\\nmid": {
548
+ "x": 227,
549
+ "y": 148
550
+ },
551
+ "\\nparallel": {
552
+ "x": 264,
553
+ "y": 148
554
+ },
555
+ "\\nvdash": {
556
+ "x": 301,
557
+ "y": 148
558
+ },
559
+ "\\nVdash": {
560
+ "x": 338,
561
+ "y": 148
562
+ },
563
+ "\\nvDash": {
564
+ "x": 375,
565
+ "y": 148
566
+ },
567
+ "\\nVDash": {
568
+ "x": 412,
569
+ "y": 148
570
+ },
571
+ "\\daleth": {
572
+ "x": 449,
573
+ "y": 148
574
+ },
575
+ "\\gimel": {
576
+ "x": 486,
577
+ "y": 148
578
+ },
579
+ "\\complement": {
580
+ "x": 523,
581
+ "y": 148
582
+ },
583
+ "\\ell": {
584
+ "x": 560,
585
+ "y": 148
586
+ },
587
+ "\\eth": {
588
+ "x": 597,
589
+ "y": 148
590
+ },
591
+ "\\hbar": {
592
+ "x": 634,
593
+ "y": 148
594
+ },
595
+ "\\hslash": {
596
+ "x": 671,
597
+ "y": 148
598
+ },
599
+ "\\mho": {
600
+ "x": 708,
601
+ "y": 148
602
+ },
603
+ "\\wp": {
604
+ "x": 745,
605
+ "y": 148
606
+ },
607
+ "\\circledS": {
608
+ "x": 782,
609
+ "y": 148
610
+ },
611
+ "\\Bbbk": {
612
+ "x": 819,
613
+ "y": 148
614
+ },
615
+ "\\Finv": {
616
+ "x": 856,
617
+ "y": 148
618
+ },
619
+ "\\Game": {
620
+ "x": 893,
621
+ "y": 148
622
+ },
623
+ "\\Im": {
624
+ "x": 930,
625
+ "y": 148
626
+ },
627
+ "\\Re": {
628
+ "x": 967,
629
+ "y": 148
630
+ },
631
+ "\\updownarrow": {
632
+ "x": 1004,
633
+ "y": 148
634
+ },
635
+ "\\Leftarrow": {
636
+ "x": 1041,
637
+ "y": 148
638
+ },
639
+ "\\Rightarrow": {
640
+ "x": 1078,
641
+ "y": 148
642
+ },
643
+ "\\Uparrow": {
644
+ "x": 5,
645
+ "y": 185
646
+ },
647
+ "\\Downarrow": {
648
+ "x": 42,
649
+ "y": 185
650
+ },
651
+ "\\Leftrightarrow": {
652
+ "x": 79,
653
+ "y": 185
654
+ },
655
+ "\\Updownarrow": {
656
+ "x": 116,
657
+ "y": 185
658
+ },
659
+ "\\longleftarrow": {
660
+ "x": 153,
661
+ "y": 185
662
+ },
663
+ "\\longrightarrow": {
664
+ "x": 190,
665
+ "y": 185
666
+ },
667
+ "\\longleftrightarrow": {
668
+ "x": 227,
669
+ "y": 185
670
+ },
671
+ "\\Longleftarrow": {
672
+ "x": 264,
673
+ "y": 185
674
+ },
675
+ "\\Longrightarrow": {
676
+ "x": 301,
677
+ "y": 185
678
+ },
679
+ "\\Longleftrightarrow": {
680
+ "x": 338,
681
+ "y": 185
682
+ },
683
+ "\\nearrow": {
684
+ "x": 375,
685
+ "y": 185
686
+ },
687
+ "\\nwarrow": {
688
+ "x": 412,
689
+ "y": 185
690
+ },
691
+ "\\searrow": {
692
+ "x": 449,
693
+ "y": 185
694
+ },
695
+ "\\swarrow": {
696
+ "x": 486,
697
+ "y": 185
698
+ },
699
+ "\\nleftarrow": {
700
+ "x": 523,
701
+ "y": 185
702
+ },
703
+ "\\nrightarrow": {
704
+ "x": 560,
705
+ "y": 185
706
+ },
707
+ "\\nLeftarrow": {
708
+ "x": 597,
709
+ "y": 185
710
+ },
711
+ "\\nRightarrow": {
712
+ "x": 634,
713
+ "y": 185
714
+ },
715
+ "\\nLeftrightarrow": {
716
+ "x": 671,
717
+ "y": 185
718
+ },
719
+ "\\leftharpoonup": {
720
+ "x": 708,
721
+ "y": 185
722
+ },
723
+ "\\leftharpoondown": {
724
+ "x": 745,
725
+ "y": 185
726
+ },
727
+ "\\rightharpoonup": {
728
+ "x": 782,
729
+ "y": 185
730
+ },
731
+ "\\rightharpoondown": {
732
+ "x": 819,
733
+ "y": 185
734
+ },
735
+ "\\upharpoonleft": {
736
+ "x": 856,
737
+ "y": 185
738
+ },
739
+ "\\upharpoonright": {
740
+ "x": 893,
741
+ "y": 185
742
+ },
743
+ "\\downharpoonleft": {
744
+ "x": 930,
745
+ "y": 185
746
+ },
747
+ "\\downharpoonright": {
748
+ "x": 967,
749
+ "y": 185
750
+ },
751
+ "\\leftrightharpoons": {
752
+ "x": 1004,
753
+ "y": 185
754
+ },
755
+ "\\rightleftharpoons": {
756
+ "x": 1041,
757
+ "y": 185
758
+ },
759
+ "\\leftleftarrows": {
760
+ "x": 1078,
761
+ "y": 185
762
+ },
763
+ "\\rightrightarrows": {
764
+ "x": 5,
765
+ "y": 222
766
+ },
767
+ "\\upuparrows": {
768
+ "x": 42,
769
+ "y": 222
770
+ },
771
+ "\\downdownarrows": {
772
+ "x": 79,
773
+ "y": 222
774
+ },
775
+ "\\leftrightarrows": {
776
+ "x": 116,
777
+ "y": 222
778
+ },
779
+ "\\rightleftarrows": {
780
+ "x": 153,
781
+ "y": 222
782
+ },
783
+ "\\looparrowleft": {
784
+ "x": 190,
785
+ "y": 222
786
+ },
787
+ "\\looparrowright": {
788
+ "x": 227,
789
+ "y": 222
790
+ },
791
+ "\\leftarrowtail": {
792
+ "x": 264,
793
+ "y": 222
794
+ },
795
+ "\\rightarrowtail": {
796
+ "x": 301,
797
+ "y": 222
798
+ },
799
+ "\\Lsh": {
800
+ "x": 338,
801
+ "y": 222
802
+ },
803
+ "\\Rsh": {
804
+ "x": 375,
805
+ "y": 222
806
+ },
807
+ "\\Lleftarrow": {
808
+ "x": 412,
809
+ "y": 222
810
+ },
811
+ "\\Rrightarrow": {
812
+ "x": 449,
813
+ "y": 222
814
+ },
815
+ "\\curvearrowleft": {
816
+ "x": 486,
817
+ "y": 222
818
+ },
819
+ "\\curvearrowright": {
820
+ "x": 523,
821
+ "y": 222
822
+ },
823
+ "\\circlearrowleft": {
824
+ "x": 560,
825
+ "y": 222
826
+ },
827
+ "\\circlearrowright": {
828
+ "x": 597,
829
+ "y": 222
830
+ },
831
+ "\\multimap": {
832
+ "x": 634,
833
+ "y": 222
834
+ },
835
+ "\\leftrightsquigarrow": {
836
+ "x": 671,
837
+ "y": 222
838
+ },
839
+ "\\twoheadleftarrow": {
840
+ "x": 708,
841
+ "y": 222
842
+ },
843
+ "\\twoheadrightarrow": {
844
+ "x": 745,
845
+ "y": 222
846
+ },
847
+ "\\rightsquigarrow": {
848
+ "x": 782,
849
+ "y": 222
850
+ },
851
+ "\\mathcal{A}": {
852
+ "x": 819,
853
+ "y": 222
854
+ },
855
+ "\\mathcal{B}": {
856
+ "x": 856,
857
+ "y": 222
858
+ },
859
+ "\\mathcal{C}": {
860
+ "x": 893,
861
+ "y": 222
862
+ },
863
+ "\\mathcal{D}": {
864
+ "x": 930,
865
+ "y": 222
866
+ },
867
+ "\\mathcal{E}": {
868
+ "x": 967,
869
+ "y": 222
870
+ },
871
+ "\\mathcal{F}": {
872
+ "x": 1004,
873
+ "y": 222
874
+ },
875
+ "\\mathcal{G}": {
876
+ "x": 1041,
877
+ "y": 222
878
+ },
879
+ "\\mathcal{H}": {
880
+ "x": 1078,
881
+ "y": 222
882
+ },
883
+ "\\mathcal{I}": {
884
+ "x": 5,
885
+ "y": 259
886
+ },
887
+ "\\mathcal{J}": {
888
+ "x": 42,
889
+ "y": 259
890
+ },
891
+ "\\mathcal{K}": {
892
+ "x": 79,
893
+ "y": 259
894
+ },
895
+ "\\mathcal{L}": {
896
+ "x": 116,
897
+ "y": 259
898
+ },
899
+ "\\mathcal{M}": {
900
+ "x": 153,
901
+ "y": 259
902
+ },
903
+ "\\mathcal{N}": {
904
+ "x": 190,
905
+ "y": 259
906
+ },
907
+ "\\mathcal{O}": {
908
+ "x": 227,
909
+ "y": 259
910
+ },
911
+ "\\mathcal{P}": {
912
+ "x": 264,
913
+ "y": 259
914
+ },
915
+ "\\mathcal{Q}": {
916
+ "x": 301,
917
+ "y": 259
918
+ },
919
+ "\\mathcal{R}": {
920
+ "x": 338,
921
+ "y": 259
922
+ },
923
+ "\\mathcal{S}": {
924
+ "x": 375,
925
+ "y": 259
926
+ },
927
+ "\\mathcal{T}": {
928
+ "x": 412,
929
+ "y": 259
930
+ },
931
+ "\\mathcal{U}": {
932
+ "x": 449,
933
+ "y": 259
934
+ },
935
+ "\\mathcal{V}": {
936
+ "x": 486,
937
+ "y": 259
938
+ },
939
+ "\\mathcal{W}": {
940
+ "x": 523,
941
+ "y": 259
942
+ },
943
+ "\\mathcal{X}": {
944
+ "x": 560,
945
+ "y": 259
946
+ },
947
+ "\\mathcal{Y}": {
948
+ "x": 597,
949
+ "y": 259
950
+ },
951
+ "\\mathcal{Z}": {
952
+ "x": 634,
953
+ "y": 259
954
+ },
955
+ "\\mathfrak{A}": {
956
+ "x": 671,
957
+ "y": 259
958
+ },
959
+ "\\mathfrak{B}": {
960
+ "x": 708,
961
+ "y": 259
962
+ },
963
+ "\\mathfrak{C}": {
964
+ "x": 745,
965
+ "y": 259
966
+ },
967
+ "\\mathfrak{D}": {
968
+ "x": 782,
969
+ "y": 259
970
+ },
971
+ "\\mathfrak{E}": {
972
+ "x": 819,
973
+ "y": 259
974
+ },
975
+ "\\mathfrak{F}": {
976
+ "x": 856,
977
+ "y": 259
978
+ },
979
+ "\\mathfrak{G}": {
980
+ "x": 893,
981
+ "y": 259
982
+ },
983
+ "\\mathfrak{H}": {
984
+ "x": 930,
985
+ "y": 259
986
+ },
987
+ "\\mathfrak{I}": {
988
+ "x": 967,
989
+ "y": 259
990
+ },
991
+ "\\mathfrak{J}": {
992
+ "x": 1004,
993
+ "y": 259
994
+ },
995
+ "\\mathfrak{K}": {
996
+ "x": 1041,
997
+ "y": 259
998
+ },
999
+ "\\mathfrak{L}": {
1000
+ "x": 1078,
1001
+ "y": 259
1002
+ },
1003
+ "\\mathfrak{M}": {
1004
+ "x": 5,
1005
+ "y": 296
1006
+ },
1007
+ "\\mathfrak{N}": {
1008
+ "x": 42,
1009
+ "y": 296
1010
+ },
1011
+ "\\mathfrak{O}": {
1012
+ "x": 79,
1013
+ "y": 296
1014
+ },
1015
+ "\\mathfrak{P}": {
1016
+ "x": 116,
1017
+ "y": 296
1018
+ },
1019
+ "\\mathfrak{Q}": {
1020
+ "x": 153,
1021
+ "y": 296
1022
+ },
1023
+ "\\mathfrak{R}": {
1024
+ "x": 190,
1025
+ "y": 296
1026
+ },
1027
+ "\\mathfrak{S}": {
1028
+ "x": 227,
1029
+ "y": 296
1030
+ },
1031
+ "\\mathfrak{T}": {
1032
+ "x": 264,
1033
+ "y": 296
1034
+ },
1035
+ "\\mathfrak{U}": {
1036
+ "x": 301,
1037
+ "y": 296
1038
+ },
1039
+ "\\mathfrak{V}": {
1040
+ "x": 338,
1041
+ "y": 296
1042
+ },
1043
+ "\\mathfrak{W}": {
1044
+ "x": 375,
1045
+ "y": 296
1046
+ },
1047
+ "\\mathfrak{X}": {
1048
+ "x": 412,
1049
+ "y": 296
1050
+ },
1051
+ "\\mathfrak{Y}": {
1052
+ "x": 449,
1053
+ "y": 296
1054
+ },
1055
+ "\\mathfrak{Z}": {
1056
+ "x": 486,
1057
+ "y": 296
1058
+ },
1059
+ "\\mathfrak{a}": {
1060
+ "x": 523,
1061
+ "y": 296
1062
+ },
1063
+ "\\mathfrak{b}": {
1064
+ "x": 560,
1065
+ "y": 296
1066
+ },
1067
+ "\\mathfrak{c}": {
1068
+ "x": 597,
1069
+ "y": 296
1070
+ },
1071
+ "\\mathfrak{d}": {
1072
+ "x": 634,
1073
+ "y": 296
1074
+ },
1075
+ "\\mathfrak{e}": {
1076
+ "x": 671,
1077
+ "y": 296
1078
+ },
1079
+ "\\mathfrak{f}": {
1080
+ "x": 708,
1081
+ "y": 296
1082
+ },
1083
+ "\\mathfrak{g}": {
1084
+ "x": 745,
1085
+ "y": 296
1086
+ },
1087
+ "\\mathfrak{h}": {
1088
+ "x": 782,
1089
+ "y": 296
1090
+ },
1091
+ "\\mathfrak{i}": {
1092
+ "x": 819,
1093
+ "y": 296
1094
+ },
1095
+ "\\mathfrak{j}": {
1096
+ "x": 856,
1097
+ "y": 296
1098
+ },
1099
+ "\\mathfrak{k}": {
1100
+ "x": 893,
1101
+ "y": 296
1102
+ },
1103
+ "\\mathfrak{l}": {
1104
+ "x": 930,
1105
+ "y": 296
1106
+ },
1107
+ "\\mathfrak{m}": {
1108
+ "x": 967,
1109
+ "y": 296
1110
+ },
1111
+ "\\mathfrak{n}": {
1112
+ "x": 1004,
1113
+ "y": 296
1114
+ },
1115
+ "\\mathfrak{o}": {
1116
+ "x": 1041,
1117
+ "y": 296
1118
+ },
1119
+ "\\mathfrak{p}": {
1120
+ "x": 1078,
1121
+ "y": 296
1122
+ },
1123
+ "\\mathfrak{q}": {
1124
+ "x": 5,
1125
+ "y": 333
1126
+ },
1127
+ "\\mathfrak{r}": {
1128
+ "x": 42,
1129
+ "y": 333
1130
+ },
1131
+ "\\mathfrak{s}": {
1132
+ "x": 79,
1133
+ "y": 333
1134
+ },
1135
+ "\\mathfrak{t}": {
1136
+ "x": 116,
1137
+ "y": 333
1138
+ },
1139
+ "\\mathfrak{u}": {
1140
+ "x": 153,
1141
+ "y": 333
1142
+ },
1143
+ "\\mathfrak{v}": {
1144
+ "x": 190,
1145
+ "y": 333
1146
+ },
1147
+ "\\mathfrak{w}": {
1148
+ "x": 227,
1149
+ "y": 333
1150
+ },
1151
+ "\\mathfrak{x}": {
1152
+ "x": 264,
1153
+ "y": 333
1154
+ },
1155
+ "\\mathfrak{y}": {
1156
+ "x": 301,
1157
+ "y": 333
1158
+ },
1159
+ "\\mathfrak{z}": {
1160
+ "x": 338,
1161
+ "y": 333
1162
+ },
1163
+ "\\mathbb{A}": {
1164
+ "x": 375,
1165
+ "y": 333
1166
+ },
1167
+ "\\mathbb{B}": {
1168
+ "x": 412,
1169
+ "y": 333
1170
+ },
1171
+ "\\mathbb{C}": {
1172
+ "x": 449,
1173
+ "y": 333
1174
+ },
1175
+ "\\mathbb{D}": {
1176
+ "x": 486,
1177
+ "y": 333
1178
+ },
1179
+ "\\mathbb{E}": {
1180
+ "x": 523,
1181
+ "y": 333
1182
+ },
1183
+ "\\mathbb{F}": {
1184
+ "x": 560,
1185
+ "y": 333
1186
+ },
1187
+ "\\mathbb{G}": {
1188
+ "x": 597,
1189
+ "y": 333
1190
+ },
1191
+ "\\mathbb{H}": {
1192
+ "x": 634,
1193
+ "y": 333
1194
+ },
1195
+ "\\mathbb{I}": {
1196
+ "x": 671,
1197
+ "y": 333
1198
+ },
1199
+ "\\mathbb{J}": {
1200
+ "x": 708,
1201
+ "y": 333
1202
+ },
1203
+ "\\mathbb{K}": {
1204
+ "x": 745,
1205
+ "y": 333
1206
+ },
1207
+ "\\mathbb{L}": {
1208
+ "x": 782,
1209
+ "y": 333
1210
+ },
1211
+ "\\mathbb{M}": {
1212
+ "x": 819,
1213
+ "y": 333
1214
+ },
1215
+ "\\mathbb{N}": {
1216
+ "x": 856,
1217
+ "y": 333
1218
+ },
1219
+ "\\mathbb{O}": {
1220
+ "x": 893,
1221
+ "y": 333
1222
+ },
1223
+ "\\mathbb{P}": {
1224
+ "x": 930,
1225
+ "y": 333
1226
+ },
1227
+ "\\mathbb{Q}": {
1228
+ "x": 967,
1229
+ "y": 333
1230
+ },
1231
+ "\\mathbb{R}": {
1232
+ "x": 1004,
1233
+ "y": 333
1234
+ },
1235
+ "\\mathbb{S}": {
1236
+ "x": 1041,
1237
+ "y": 333
1238
+ },
1239
+ "\\mathbb{T}": {
1240
+ "x": 1078,
1241
+ "y": 333
1242
+ },
1243
+ "\\mathbb{U}": {
1244
+ "x": 5,
1245
+ "y": 370
1246
+ },
1247
+ "\\mathbb{V}": {
1248
+ "x": 42,
1249
+ "y": 370
1250
+ },
1251
+ "\\mathbb{W}": {
1252
+ "x": 79,
1253
+ "y": 370
1254
+ },
1255
+ "\\mathbb{X}": {
1256
+ "x": 116,
1257
+ "y": 370
1258
+ },
1259
+ "\\mathbb{Y}": {
1260
+ "x": 153,
1261
+ "y": 370
1262
+ },
1263
+ "\\mathbb{Z}": {
1264
+ "x": 190,
1265
+ "y": 370
1266
+ },
1267
+ "\\mathrm{A}": {
1268
+ "x": 227,
1269
+ "y": 370
1270
+ },
1271
+ "\\mathrm{B}": {
1272
+ "x": 264,
1273
+ "y": 370
1274
+ },
1275
+ "\\mathrm{C}": {
1276
+ "x": 301,
1277
+ "y": 370
1278
+ },
1279
+ "\\mathrm{D}": {
1280
+ "x": 338,
1281
+ "y": 370
1282
+ },
1283
+ "\\mathrm{E}": {
1284
+ "x": 375,
1285
+ "y": 370
1286
+ },
1287
+ "\\mathrm{F}": {
1288
+ "x": 412,
1289
+ "y": 370
1290
+ },
1291
+ "\\mathrm{G}": {
1292
+ "x": 449,
1293
+ "y": 370
1294
+ },
1295
+ "\\mathrm{H}": {
1296
+ "x": 486,
1297
+ "y": 370
1298
+ },
1299
+ "\\mathrm{I}": {
1300
+ "x": 523,
1301
+ "y": 370
1302
+ },
1303
+ "\\mathrm{J}": {
1304
+ "x": 560,
1305
+ "y": 370
1306
+ },
1307
+ "\\mathrm{K}": {
1308
+ "x": 597,
1309
+ "y": 370
1310
+ },
1311
+ "\\mathrm{L}": {
1312
+ "x": 634,
1313
+ "y": 370
1314
+ },
1315
+ "\\mathrm{M}": {
1316
+ "x": 671,
1317
+ "y": 370
1318
+ },
1319
+ "\\mathrm{N}": {
1320
+ "x": 708,
1321
+ "y": 370
1322
+ },
1323
+ "\\mathrm{O}": {
1324
+ "x": 745,
1325
+ "y": 370
1326
+ },
1327
+ "\\mathrm{P}": {
1328
+ "x": 782,
1329
+ "y": 370
1330
+ },
1331
+ "\\mathrm{Q}": {
1332
+ "x": 819,
1333
+ "y": 370
1334
+ },
1335
+ "\\mathrm{R}": {
1336
+ "x": 856,
1337
+ "y": 370
1338
+ },
1339
+ "\\mathrm{S}": {
1340
+ "x": 893,
1341
+ "y": 370
1342
+ },
1343
+ "\\mathrm{T}": {
1344
+ "x": 930,
1345
+ "y": 370
1346
+ },
1347
+ "\\mathrm{U}": {
1348
+ "x": 967,
1349
+ "y": 370
1350
+ },
1351
+ "\\mathrm{V}": {
1352
+ "x": 1004,
1353
+ "y": 370
1354
+ },
1355
+ "\\mathrm{W}": {
1356
+ "x": 1041,
1357
+ "y": 370
1358
+ },
1359
+ "\\mathrm{X}": {
1360
+ "x": 1078,
1361
+ "y": 370
1362
+ },
1363
+ "\\mathrm{Y}": {
1364
+ "x": 5,
1365
+ "y": 407
1366
+ },
1367
+ "\\mathrm{Z}": {
1368
+ "x": 42,
1369
+ "y": 407
1370
+ },
1371
+ "\\mathrm{a}": {
1372
+ "x": 79,
1373
+ "y": 407
1374
+ },
1375
+ "\\mathrm{b}": {
1376
+ "x": 116,
1377
+ "y": 407
1378
+ },
1379
+ "\\mathrm{c}": {
1380
+ "x": 153,
1381
+ "y": 407
1382
+ },
1383
+ "\\mathrm{d}": {
1384
+ "x": 190,
1385
+ "y": 407
1386
+ },
1387
+ "\\mathrm{e}": {
1388
+ "x": 227,
1389
+ "y": 407
1390
+ },
1391
+ "\\mathrm{f}": {
1392
+ "x": 264,
1393
+ "y": 407
1394
+ },
1395
+ "\\mathrm{g}": {
1396
+ "x": 301,
1397
+ "y": 407
1398
+ },
1399
+ "\\mathrm{h}": {
1400
+ "x": 338,
1401
+ "y": 407
1402
+ },
1403
+ "\\mathrm{i}": {
1404
+ "x": 375,
1405
+ "y": 407
1406
+ },
1407
+ "\\mathrm{j}": {
1408
+ "x": 412,
1409
+ "y": 407
1410
+ },
1411
+ "\\mathrm{k}": {
1412
+ "x": 449,
1413
+ "y": 407
1414
+ },
1415
+ "\\mathrm{l}": {
1416
+ "x": 486,
1417
+ "y": 407
1418
+ },
1419
+ "\\mathrm{m}": {
1420
+ "x": 523,
1421
+ "y": 407
1422
+ },
1423
+ "\\mathrm{n}": {
1424
+ "x": 560,
1425
+ "y": 407
1426
+ },
1427
+ "\\mathrm{o}": {
1428
+ "x": 597,
1429
+ "y": 407
1430
+ },
1431
+ "\\mathrm{p}": {
1432
+ "x": 634,
1433
+ "y": 407
1434
+ },
1435
+ "\\mathrm{q}": {
1436
+ "x": 671,
1437
+ "y": 407
1438
+ },
1439
+ "\\mathrm{r}": {
1440
+ "x": 708,
1441
+ "y": 407
1442
+ },
1443
+ "\\mathrm{s}": {
1444
+ "x": 745,
1445
+ "y": 407
1446
+ },
1447
+ "\\mathrm{t}": {
1448
+ "x": 782,
1449
+ "y": 407
1450
+ },
1451
+ "\\mathrm{u}": {
1452
+ "x": 819,
1453
+ "y": 407
1454
+ },
1455
+ "\\mathrm{v}": {
1456
+ "x": 856,
1457
+ "y": 407
1458
+ },
1459
+ "\\mathrm{w}": {
1460
+ "x": 893,
1461
+ "y": 407
1462
+ },
1463
+ "\\mathrm{x}": {
1464
+ "x": 930,
1465
+ "y": 407
1466
+ },
1467
+ "\\mathrm{y}": {
1468
+ "x": 967,
1469
+ "y": 407
1470
+ },
1471
+ "\\mathrm{z}": {
1472
+ "x": 1004,
1473
+ "y": 407
1474
+ }
1475
+ };
1476
+
1477
+ // ../kity-runtime/src/vendor/legacy-common.ts
1478
+ var legacyCommonUtils = {
1479
+ contains: legacyBaseUtils.contains,
1480
+ getRect: legacyBaseUtils.getRect
1481
+ };
1482
+
1483
+ // ../kity-runtime/src/kity/class-system.ts
1484
+ function Class() {
1485
+ }
1486
+ var ClassProto = Class.prototype;
1487
+ ClassProto.base = function(name) {
1488
+ const stack = this.__kityCallStack__;
1489
+ const info = stack[stack.length - 1];
1490
+ const method = info.cls.__KityBaseClass.prototype[name];
1491
+ return method.apply(this, Array.prototype.slice.call(arguments, 1));
1492
+ };
1493
+ ClassProto.callBase = function() {
1494
+ const stack = this.__kityCallStack__;
1495
+ const info = stack[stack.length - 1];
1496
+ const method = info.cls.__KityBaseClass.prototype[info.methodName];
1497
+ return method.apply(this, arguments);
1498
+ };
1499
+ ClassProto.mixin = function(name) {
1500
+ const stack = this.__kityCallStack__;
1501
+ const info = stack[stack.length - 1];
1502
+ const mixins = info.cls.__KityMixins;
1503
+ if (!mixins) return this;
1504
+ return mixins[name].apply(this, Array.prototype.slice.call(arguments, 1));
1505
+ };
1506
+ ClassProto.callMixin = function() {
1507
+ const stack = this.__kityCallStack__;
1508
+ const info = stack[stack.length - 1];
1509
+ const methodName = info.methodName;
1510
+ const mixins = info.cls.__KityMixins;
1511
+ if (!mixins) return this;
1512
+ const method = mixins[methodName];
1513
+ if (methodName === "constructor") {
1514
+ for (let i = 0; i < method.length; i++) method[i].call(this);
1515
+ return this;
1516
+ }
1517
+ return method.apply(this, arguments);
1518
+ };
1519
+ ClassProto.pipe = function(fn) {
1520
+ if (typeof fn === "function") fn.call(this, this);
1521
+ return this;
1522
+ };
1523
+ ClassProto.getType = function() {
1524
+ return this.__KityClassName;
1525
+ };
1526
+ ClassProto.getClass = function() {
1527
+ return this.constructor;
1528
+ };
1529
+ function wrapMethod(cls, methodName, originalMethod) {
1530
+ const wrapped = function() {
1531
+ this.__kityCallStack__ = this.__kityCallStack__ || [];
1532
+ this.__kityCallStack__.push({ cls, methodName });
1533
+ try {
1534
+ return originalMethod.apply(this, arguments);
1535
+ } finally {
1536
+ this.__kityCallStack__.pop();
1537
+ }
1538
+ };
1539
+ wrapped.__KityMethodClass = cls;
1540
+ wrapped.__KityMethodName = methodName;
1541
+ return wrapped;
1542
+ }
1543
+ function inherit(constructor, BaseClass) {
1544
+ const KityClass = function() {
1545
+ const meta2 = KityClass;
1546
+ meta2.__KityConstructor.apply(this, arguments);
1547
+ };
1548
+ const meta = KityClass;
1549
+ meta.__KityConstructor = constructor;
1550
+ KityClass.prototype = Object.create(BaseClass.prototype);
1551
+ for (const methodName in BaseClass.prototype) {
1552
+ if (Object.prototype.hasOwnProperty.call(BaseClass.prototype, methodName) && methodName.indexOf("__Kity") !== 0) {
1553
+ KityClass.prototype[methodName] = BaseClass.prototype[methodName];
1554
+ }
1555
+ }
1556
+ KityClass.prototype.constructor = KityClass;
1557
+ return KityClass;
1558
+ }
1559
+ function legacyMixin(NewClass, mixins) {
1560
+ if (!(mixins instanceof Array)) return NewClass;
1561
+ const meta = NewClass;
1562
+ meta.__KityMixins = { constructor: [] };
1563
+ for (let i = 0; i < mixins.length; i++) {
1564
+ const proto = mixins[i].prototype;
1565
+ for (const method in proto) {
1566
+ if (!Object.prototype.hasOwnProperty.call(proto, method)) continue;
1567
+ if (method === "constructor") {
1568
+ meta.__KityMixins["constructor"].push(proto[method]);
1569
+ } else {
1570
+ NewClass.prototype[method] = meta.__KityMixins[method] = proto[method];
1571
+ }
1572
+ }
1573
+ }
1574
+ return NewClass;
1575
+ }
1576
+ function extend(BaseClass, extension) {
1577
+ for (const methodName in extension) {
1578
+ if (Object.prototype.hasOwnProperty.call(extension, methodName) && methodName !== "constructor" && methodName.indexOf("__Kity") !== 0) {
1579
+ BaseClass.prototype[methodName] = wrapMethod(
1580
+ BaseClass,
1581
+ methodName,
1582
+ extension[methodName]
1583
+ );
1584
+ }
1585
+ }
1586
+ return BaseClass;
1587
+ }
1588
+ function checkBaseConstructorCall(targetClass, classname) {
1589
+ if (!/this\.callBase/.test(targetClass.toString())) {
1590
+ throw new Error(
1591
+ `${classname}: the constructor must call the base constructor for compatibility with the legacy kity class system.`
1592
+ );
1593
+ }
1594
+ }
1595
+ function createClass(classname, defines) {
1596
+ let constructor;
1597
+ let NewClass;
1598
+ let BaseClass;
1599
+ if (arguments.length === 1) {
1600
+ defines = arguments[0];
1601
+ classname = "AnonymousClass";
1602
+ }
1603
+ defines = defines || {};
1604
+ BaseClass = defines.base || Class;
1605
+ if (Object.prototype.hasOwnProperty.call(defines, "constructor")) {
1606
+ constructor = defines.constructor;
1607
+ if (BaseClass !== Class) {
1608
+ checkBaseConstructorCall(constructor, classname);
1609
+ }
1610
+ } else {
1611
+ constructor = function() {
1612
+ this.callBase.apply(this, arguments);
1613
+ this.callMixin.apply(this, arguments);
1614
+ };
1615
+ }
1616
+ const originalConstructor = constructor;
1617
+ constructor = function() {
1618
+ this.__kityCallStack__ = this.__kityCallStack__ || [];
1619
+ this.__kityCallStack__.push({
1620
+ cls: NewClass,
1621
+ methodName: "constructor"
1622
+ });
1623
+ try {
1624
+ return originalConstructor.apply(this, arguments);
1625
+ } finally {
1626
+ this.__kityCallStack__.pop();
1627
+ }
1628
+ };
1629
+ NewClass = inherit(constructor, BaseClass);
1630
+ NewClass = legacyMixin(NewClass, defines.mixins || []);
1631
+ const meta = NewClass;
1632
+ meta.__KityClassName = constructor.__KityClassName = classname;
1633
+ meta.__KityBaseClass = constructor.__KityBaseClass = BaseClass;
1634
+ constructor.__KityMethodName = "constructor";
1635
+ constructor.__KityMethodClass = NewClass;
1636
+ delete defines.mixins;
1637
+ delete defines.constructor;
1638
+ delete defines.base;
1639
+ NewClass = extend(NewClass, defines);
1640
+ return NewClass;
1641
+ }
1642
+ function extendClass(clazz, extension) {
1643
+ return extend(clazz, extension);
1644
+ }
1645
+
1646
+ // ../kity-runtime/src/kity/geometry.ts
1647
+ var Box = createClass("Box", {
1648
+ constructor(x, y, width, height) {
1649
+ const box = arguments[0];
1650
+ if (box && typeof box === "object" && ("x" in box || "left" in box)) {
1651
+ x = box.x ?? box.left;
1652
+ y = box.y ?? box.top;
1653
+ width = box.width;
1654
+ height = box.height;
1655
+ }
1656
+ const w = width ?? 0;
1657
+ const h = height ?? 0;
1658
+ if (w < 0) {
1659
+ x = x - (width = -w);
1660
+ }
1661
+ if (h < 0) {
1662
+ y = y - (height = -h);
1663
+ }
1664
+ this.x = x || 0;
1665
+ this.y = y || 0;
1666
+ this.width = width || 0;
1667
+ this.height = height || 0;
1668
+ this.left = this.x;
1669
+ this.right = this.x + this.width;
1670
+ this.top = this.y;
1671
+ this.bottom = this.y + this.height;
1672
+ this.cx = this.x + this.width / 2;
1673
+ this.cy = this.y + this.height / 2;
1674
+ },
1675
+ getRangeX() {
1676
+ return [this.left, this.right];
1677
+ },
1678
+ getRangeY() {
1679
+ return [this.top, this.bottom];
1680
+ },
1681
+ merge(another) {
1682
+ if (this.isEmpty()) return new Box(another.x, another.y, another.width, another.height);
1683
+ const left = Math.min(this.left, another.left);
1684
+ const right = Math.max(this.right, another.right);
1685
+ const top = Math.min(this.top, another.top);
1686
+ const bottom = Math.max(this.bottom, another.bottom);
1687
+ return new Box(left, top, right - left, bottom - top);
1688
+ },
1689
+ intersect(another) {
1690
+ if (!(another instanceof Box) || this.isEmpty() || another.isEmpty()) return new Box();
1691
+ if (this.right <= another.left || another.right <= this.left || this.bottom <= another.top || another.bottom <= this.top)
1692
+ return new Box();
1693
+ const x = Math.max(this.left, another.left), y = Math.max(this.top, another.top);
1694
+ return new Box(
1695
+ x,
1696
+ y,
1697
+ Math.min(this.right, another.right) - x,
1698
+ Math.min(this.bottom, another.bottom) - y
1699
+ );
1700
+ },
1701
+ expand(top, right, bottom, left) {
1702
+ if (arguments.length < 4) {
1703
+ right = top;
1704
+ bottom = top;
1705
+ left = top;
1706
+ }
1707
+ return new Box(
1708
+ this.x - left,
1709
+ this.y - top,
1710
+ this.width + right + left,
1711
+ this.height + top + bottom
1712
+ );
1713
+ },
1714
+ valueOf() {
1715
+ return [this.x, this.y, this.width, this.height];
1716
+ },
1717
+ toString() {
1718
+ return this.valueOf().join(" ");
1719
+ },
1720
+ isEmpty() {
1721
+ return !this.width || !this.height;
1722
+ }
1723
+ });
1724
+ Box.parse = function(unknown) {
1725
+ if (!unknown) return new Box();
1726
+ if (unknown instanceof Box) return unknown;
1727
+ if (typeof unknown === "string") return Box.parse(unknown.split(/\s*[\s,]\s*/));
1728
+ if ("0" in unknown && "1" in unknown && "2" in unknown && "3" in unknown)
1729
+ return new Box(unknown[0], unknown[1], unknown[2], unknown[3]);
1730
+ return new Box();
1731
+ };
1732
+ var Point = createClass("Point", {
1733
+ constructor(x, y) {
1734
+ this.x = x || 0;
1735
+ this.y = y || 0;
1736
+ },
1737
+ offset(dx, dy) {
1738
+ if (arguments.length === 1) {
1739
+ dy = dx.y;
1740
+ dx = dx.x;
1741
+ }
1742
+ return new Point(this.x + dx, this.y + dy);
1743
+ },
1744
+ valueOf() {
1745
+ return [this.x, this.y];
1746
+ },
1747
+ toString() {
1748
+ return this.valueOf().join(" ");
1749
+ },
1750
+ spof() {
1751
+ return new Point((this.x | 0) + 0.5, (this.y | 0) + 0.5);
1752
+ },
1753
+ round() {
1754
+ return new Point(this.x | 0, this.y | 0);
1755
+ },
1756
+ isOrigin() {
1757
+ return this.x === 0 && this.y === 0;
1758
+ }
1759
+ });
1760
+ Point.fromPolar = function(radius, angle, unit) {
1761
+ if (unit !== "rad") angle = angle / 180 * Math.PI;
1762
+ return new Point(radius * Math.cos(angle), radius * Math.sin(angle));
1763
+ };
1764
+ Point.parse = function(unknown) {
1765
+ if (!unknown) return new Point();
1766
+ if (unknown instanceof Point) return unknown;
1767
+ if (typeof unknown === "string") return Point.parse(unknown.split(/\s*[\s,]\s*/));
1768
+ if ("0" in unknown && "1" in unknown) return new Point(unknown[0], unknown[1]);
1769
+ return new Point();
1770
+ };
1771
+ var g = {};
1772
+ g.pathToString = function(pathSegment) {
1773
+ pathSegment = pathSegment || this;
1774
+ if (typeof pathSegment === "string") return pathSegment;
1775
+ if (pathSegment instanceof Array)
1776
+ return utils_default.flatten(pathSegment).join(",").replace(/,?([achlmqrstvxz]),?/gi, "$1");
1777
+ return "";
1778
+ };
1779
+ function d2r(deg) {
1780
+ return deg * Math.PI / 180;
1781
+ }
1782
+ function mergeMatrixData(m2, m1) {
1783
+ return {
1784
+ a: m1.a * m2.a + m1.c * m2.b,
1785
+ b: m1.b * m2.a + m1.d * m2.b,
1786
+ c: m1.a * m2.c + m1.c * m2.d,
1787
+ d: m1.b * m2.c + m1.d * m2.d,
1788
+ e: m1.a * m2.e + m1.c * m2.f + m1.e,
1789
+ f: m1.b * m2.e + m1.d * m2.f + m1.f
1790
+ };
1791
+ }
1792
+ var mPattern = /matrix\s*\((.+)\)/i;
1793
+ var Matrix = createClass("Matrix", {
1794
+ constructor(..._args) {
1795
+ if (arguments.length) {
1796
+ this.setMatrix.apply(this, arguments);
1797
+ } else {
1798
+ this.setMatrix(1, 0, 0, 1, 0, 0);
1799
+ }
1800
+ },
1801
+ translate(x, y) {
1802
+ this.m = mergeMatrixData(this.m, {
1803
+ a: 1,
1804
+ c: 0,
1805
+ e: x,
1806
+ b: 0,
1807
+ d: 1,
1808
+ f: y
1809
+ });
1810
+ return this;
1811
+ },
1812
+ rotate(deg) {
1813
+ const r = d2r(deg), s = Math.sin(r), c = Math.cos(r);
1814
+ this.m = mergeMatrixData(this.m, {
1815
+ a: c,
1816
+ c: -s,
1817
+ e: 0,
1818
+ b: s,
1819
+ d: c,
1820
+ f: 0
1821
+ });
1822
+ return this;
1823
+ },
1824
+ scale(sx, sy) {
1825
+ if (sy === void 0) sy = sx;
1826
+ this.m = mergeMatrixData(this.m, {
1827
+ a: sx,
1828
+ c: 0,
1829
+ e: 0,
1830
+ b: 0,
1831
+ d: sy,
1832
+ f: 0
1833
+ });
1834
+ return this;
1835
+ },
1836
+ skew(degX, degY) {
1837
+ if (degY === void 0) degY = degX;
1838
+ this.m = mergeMatrixData(this.m, {
1839
+ a: 1,
1840
+ c: Math.tan(d2r(degX)),
1841
+ e: 0,
1842
+ b: Math.tan(d2r(degY)),
1843
+ d: 1,
1844
+ f: 0
1845
+ });
1846
+ return this;
1847
+ },
1848
+ inverse() {
1849
+ const m = this.m, k = m.a * m.d - m.b * m.c;
1850
+ return new Matrix(
1851
+ m.d / k,
1852
+ -m.b / k,
1853
+ -m.c / k,
1854
+ m.a / k,
1855
+ (m.c * m.f - m.e * m.d) / k,
1856
+ (m.b * m.e - m.a * m.f) / k
1857
+ );
1858
+ },
1859
+ setMatrix(a, b, c, d, e, f) {
1860
+ if (arguments.length === 1) {
1861
+ this.m = utils_default.clone(arguments[0]);
1862
+ } else {
1863
+ this.m = {
1864
+ a,
1865
+ b,
1866
+ c,
1867
+ d,
1868
+ e,
1869
+ f
1870
+ };
1871
+ }
1872
+ return this;
1873
+ },
1874
+ getMatrix() {
1875
+ return utils_default.clone(this.m);
1876
+ },
1877
+ getTranslate() {
1878
+ const m = this.m;
1879
+ return { x: m.e / m.a, y: m.f / m.d };
1880
+ },
1881
+ mergeMatrix(matrix) {
1882
+ return new Matrix(mergeMatrixData(this.m, matrix.m));
1883
+ },
1884
+ merge(matrix) {
1885
+ return this.mergeMatrix(matrix);
1886
+ },
1887
+ toString() {
1888
+ return this.valueOf().join(" ");
1889
+ },
1890
+ valueOf() {
1891
+ const m = this.m;
1892
+ return [m.a, m.b, m.c, m.d, m.e, m.f];
1893
+ },
1894
+ equals(matrix) {
1895
+ const m1 = this.m, m2 = matrix.m;
1896
+ return m1.a === m2.a && m1.b === m2.b && m1.c === m2.c && m1.d === m2.d && m1.e === m2.e && m1.f === m2.f;
1897
+ },
1898
+ transformPoint() {
1899
+ return Matrix.transformPoint.apply(
1900
+ null,
1901
+ [].slice.call(arguments).concat([this.m])
1902
+ );
1903
+ },
1904
+ transformBox(box) {
1905
+ return Matrix.transformBox(box, this.m);
1906
+ },
1907
+ clone() {
1908
+ return new Matrix(this.m);
1909
+ },
1910
+ reverse() {
1911
+ return this.inverse();
1912
+ }
1913
+ });
1914
+ Matrix.parse = function(str) {
1915
+ const f = parseFloat;
1916
+ if (str instanceof Array)
1917
+ return new Matrix({
1918
+ a: f(str[0]),
1919
+ b: f(str[1]),
1920
+ c: f(str[2]),
1921
+ d: f(str[3]),
1922
+ e: f(str[4]),
1923
+ f: f(str[5])
1924
+ });
1925
+ const match = mPattern.exec(str);
1926
+ if (match) {
1927
+ let values = match[1].split(",");
1928
+ if (values.length !== 6) values = match[1].split(" ");
1929
+ return new Matrix({
1930
+ a: f(values[0]),
1931
+ b: f(values[1]),
1932
+ c: f(values[2]),
1933
+ d: f(values[3]),
1934
+ e: f(values[4]),
1935
+ f: f(values[5])
1936
+ });
1937
+ }
1938
+ return new Matrix();
1939
+ };
1940
+ Matrix.transformPoint = function(x, y, m) {
1941
+ if (arguments.length === 2) {
1942
+ m = y;
1943
+ y = x.y;
1944
+ x = x.x;
1945
+ }
1946
+ return new Point(
1947
+ m.a * x + m.c * y + m.e,
1948
+ m.b * x + m.d * y + m.f
1949
+ );
1950
+ };
1951
+ Matrix.transformBox = function(box, matrix) {
1952
+ let xMin = Number.MAX_VALUE, xMax = -Number.MAX_VALUE, yMin = Number.MAX_VALUE, yMax = -Number.MAX_VALUE;
1953
+ const bps = [
1954
+ [box.x, box.y],
1955
+ [box.x + box.width, box.y],
1956
+ [box.x, box.y + box.height],
1957
+ [box.x + box.width, box.y + box.height]
1958
+ ];
1959
+ const rps = [];
1960
+ let bp;
1961
+ while (bp = bps.pop()) {
1962
+ const rp = Matrix.transformPoint(bp[0], bp[1], matrix);
1963
+ rps.push(rp);
1964
+ xMin = Math.min(xMin, rp.x);
1965
+ xMax = Math.max(xMax, rp.x);
1966
+ yMin = Math.min(yMin, rp.y);
1967
+ yMax = Math.max(yMax, rp.y);
1968
+ }
1969
+ const result = new Box({
1970
+ x: xMin,
1971
+ y: yMin,
1972
+ width: xMax - xMin,
1973
+ height: yMax - yMin
1974
+ });
1975
+ utils_default.extend(result, { closurePoints: rps });
1976
+ return result;
1977
+ };
1978
+ function getTransformToElement(target, source) {
1979
+ try {
1980
+ return source.getScreenCTM().inverse().multiply(target.getScreenCTM());
1981
+ } catch {
1982
+ throw new Error("Unable to invert the source element's transformation matrix.");
1983
+ }
1984
+ }
1985
+ Matrix.getCTM = function(target, refer) {
1986
+ let ctm = {
1987
+ a: 1,
1988
+ b: 0,
1989
+ c: 0,
1990
+ d: 1,
1991
+ e: 0,
1992
+ f: 0
1993
+ };
1994
+ const node = target.shapeNode || target.node;
1995
+ refer = refer || "parent";
1996
+ switch (refer) {
1997
+ case "screen":
1998
+ ctm = node.getScreenCTM();
1999
+ break;
2000
+ case "doc":
2001
+ case "paper":
2002
+ ctm = node.getCTM();
2003
+ break;
2004
+ case "view":
2005
+ case "top":
2006
+ if (target.getPaper()) {
2007
+ ctm = getTransformToElement(node, target.getPaper().shapeNode);
2008
+ }
2009
+ break;
2010
+ case "parent":
2011
+ if (target.node.parentNode) {
2012
+ ctm = getTransformToElement(node, target.node.parentNode);
2013
+ }
2014
+ break;
2015
+ default:
2016
+ if (refer && refer.node) {
2017
+ ctm = getTransformToElement(node, refer.shapeNode || refer.node);
2018
+ }
2019
+ }
2020
+ return new Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f);
2021
+ };
2022
+
2023
+ // ../kity-runtime/src/kity/graphics.ts
2024
+ var pc = Point;
2025
+ var mc = Matrix;
2026
+ var _svgId = { id: 0 };
2027
+ var svg = {
2028
+ ns: "http://www.w3.org/2000/svg",
2029
+ xlink: "http://www.w3.org/1999/xlink",
2030
+ defaults: {
2031
+ stroke: "none",
2032
+ fill: "none"
2033
+ },
2034
+ createNode(name) {
2035
+ const node = document.createElementNS(svg.ns, name);
2036
+ node.id = "kity_" + name + "_" + _svgId.id++;
2037
+ return node;
2038
+ }
2039
+ };
2040
+ var INNER_HANDLER_CACHE = {};
2041
+ var USER_HANDLER_CACHE = {};
2042
+ var _guid = 0;
2043
+ function getEventUid(target) {
2044
+ const eventUid = target._EVENT_UID ?? target._EVNET_UID;
2045
+ if (eventUid === void 0) {
2046
+ throw new Error("Event handler instance is missing an event uid.");
2047
+ }
2048
+ return eventUid;
2049
+ }
2050
+ function setLegacyEventUid(target, eventUid) {
2051
+ target._EVENT_UID = eventUid;
2052
+ if (Object.prototype.hasOwnProperty.call(target, "_EVNET_UID")) {
2053
+ target._EVNET_UID = eventUid;
2054
+ return;
2055
+ }
2056
+ Object.defineProperty(target, "_EVNET_UID", {
2057
+ configurable: true,
2058
+ enumerable: true,
2059
+ get() {
2060
+ return target._EVENT_UID;
2061
+ },
2062
+ set(value) {
2063
+ target._EVENT_UID = value;
2064
+ }
2065
+ });
2066
+ }
2067
+ function bindDomEvent(node, type, handler) {
2068
+ node.addEventListener(type, handler, false);
2069
+ }
2070
+ function deleteDomEvent(node, type, handler) {
2071
+ node.removeEventListener(type, handler, false);
2072
+ }
2073
+ function sendMessage(messageObj, type, msg) {
2074
+ const handlers = INNER_HANDLER_CACHE[getEventUid(messageObj)];
2075
+ if (!handlers) {
2076
+ return;
2077
+ }
2078
+ const handler = handlers[type];
2079
+ if (!handler) {
2080
+ return;
2081
+ }
2082
+ const event = utils_default.extend({ type, target: messageObj }, msg || {});
2083
+ handler.call(messageObj, event);
2084
+ }
2085
+ function listen(node, type, handler, isOnce, targetObject) {
2086
+ const eid = getEventUid(targetObject);
2087
+ if (!INNER_HANDLER_CACHE[eid]) {
2088
+ INNER_HANDLER_CACHE[eid] = {};
2089
+ }
2090
+ if (!INNER_HANDLER_CACHE[eid][type]) {
2091
+ INNER_HANDLER_CACHE[eid][type] = function kityEventHandler(e) {
2092
+ e = new ShapeEvent(e || window.event);
2093
+ const list = USER_HANDLER_CACHE[eid][type];
2094
+ if (!list) {
2095
+ return;
2096
+ }
2097
+ for (let i = 0; i < list.length; i++) {
2098
+ const fn = list[i];
2099
+ if (fn) {
2100
+ const result = fn.call(targetObject, e);
2101
+ if (isOnce) {
2102
+ targetObject.off(type, fn);
2103
+ }
2104
+ if (result === false) {
2105
+ return false;
2106
+ }
2107
+ }
2108
+ }
2109
+ return;
2110
+ };
2111
+ }
2112
+ if (!USER_HANDLER_CACHE[eid]) {
2113
+ USER_HANDLER_CACHE[eid] = {};
2114
+ }
2115
+ if (!USER_HANDLER_CACHE[eid][type]) {
2116
+ USER_HANDLER_CACHE[eid][type] = [handler];
2117
+ if (!!node && "on" + type in node) {
2118
+ bindDomEvent(node, type, INNER_HANDLER_CACHE[eid][type]);
2119
+ }
2120
+ } else {
2121
+ USER_HANDLER_CACHE[eid][type].push(handler);
2122
+ }
2123
+ }
2124
+ function _addEvent(type, handler, isOnce) {
2125
+ isOnce = !!isOnce;
2126
+ if (utils_default.isString(type)) {
2127
+ type = type.match(/\S+/g) || [];
2128
+ }
2129
+ utils_default.each(type, (currentType) => {
2130
+ listen(this.node, currentType, handler, isOnce, this);
2131
+ });
2132
+ return this;
2133
+ }
2134
+ function _removeEvent(type, handler) {
2135
+ const eventId = String(getEventUid(this));
2136
+ const userHandlerList = USER_HANDLER_CACHE[eventId][type];
2137
+ let isRemoveAll = handler === void 0;
2138
+ if (!isRemoveAll && userHandlerList) {
2139
+ isRemoveAll = true;
2140
+ utils_default.each(userHandlerList, (fn, index) => {
2141
+ if (fn === handler) {
2142
+ delete userHandlerList[index];
2143
+ } else {
2144
+ isRemoveAll = false;
2145
+ }
2146
+ });
2147
+ }
2148
+ if (isRemoveAll) {
2149
+ deleteDomEvent(this.node, type, INNER_HANDLER_CACHE[eventId][type]);
2150
+ delete USER_HANDLER_CACHE[eventId][type];
2151
+ delete INNER_HANDLER_CACHE[eventId][type];
2152
+ }
2153
+ return this;
2154
+ }
2155
+ var EventHandler = createClass("EventHandler", {
2156
+ constructor() {
2157
+ setLegacyEventUid(this, ++_guid);
2158
+ },
2159
+ addEventListener(type, handler) {
2160
+ return _addEvent.call(this, type, handler, false);
2161
+ },
2162
+ addOnceEventListener(type, handler) {
2163
+ return _addEvent.call(this, type, handler, true);
2164
+ },
2165
+ removeEventListener(type, handler) {
2166
+ return _removeEvent.call(this, type, handler);
2167
+ },
2168
+ on(type, handler) {
2169
+ return this.addEventListener(type, handler);
2170
+ },
2171
+ once(type, handler) {
2172
+ return this.addOnceEventListener(type, handler);
2173
+ },
2174
+ off(type, handler) {
2175
+ return this.removeEventListener(type, handler);
2176
+ },
2177
+ fire(type, params) {
2178
+ return this.trigger(type, params);
2179
+ },
2180
+ trigger(type, params) {
2181
+ sendMessage(this, type, params);
2182
+ return this;
2183
+ }
2184
+ });
2185
+ var ShapeEvent = createClass("ShapeEvent", {
2186
+ constructor(event) {
2187
+ let target = null;
2188
+ if (!utils_default.isObject(event.target)) {
2189
+ this.type = event.type;
2190
+ target = event.target;
2191
+ if (target.correspondingUseElement) {
2192
+ target = target.correspondingUseElement;
2193
+ }
2194
+ this.originEvent = event;
2195
+ this.targetShape = target.shape || target.paper || event.currentTarget && (event.currentTarget.shape || event.currentTarget.paper);
2196
+ if (event._kityParam) {
2197
+ utils_default.extend(this, event._kityParam);
2198
+ }
2199
+ } else {
2200
+ utils_default.extend(this, event);
2201
+ }
2202
+ },
2203
+ preventDefault() {
2204
+ const evt = this.originEvent;
2205
+ if (!evt) {
2206
+ return true;
2207
+ }
2208
+ evt.preventDefault();
2209
+ return evt.cancelable;
2210
+ },
2211
+ getPosition(refer, touchIndex) {
2212
+ if (!this.originEvent) {
2213
+ return null;
2214
+ }
2215
+ const eventClient = this.originEvent.touches ? this.originEvent.touches[touchIndex || 0] : this.originEvent;
2216
+ const target = this.targetShape;
2217
+ const targetNode = target.shapeNode || target.node;
2218
+ const pScreen = new pc(
2219
+ eventClient && eventClient.clientX || 0,
2220
+ eventClient && eventClient.clientY || 0
2221
+ );
2222
+ const pTarget = mc.transformPoint(pScreen, targetNode.getScreenCTM().inverse());
2223
+ const pRefer = mc.getCTM(target, refer || "view").transformPoint(pTarget);
2224
+ return pRefer;
2225
+ },
2226
+ stopPropagation() {
2227
+ const evt = this.originEvent;
2228
+ if (!evt) {
2229
+ return true;
2230
+ }
2231
+ evt.stopPropagation();
2232
+ }
2233
+ });
2234
+ var _ClassListProto = {
2235
+ constructor(node) {
2236
+ this._node = node;
2237
+ this._list = node.className.toString().split(" ");
2238
+ },
2239
+ _update() {
2240
+ this._node.className = this._list.join(" ");
2241
+ },
2242
+ add(name) {
2243
+ this._list.push(name);
2244
+ this._update();
2245
+ },
2246
+ remove(name) {
2247
+ const index = this._list.indexOf(name);
2248
+ if (~index) {
2249
+ this._list.splice(index, 1);
2250
+ }
2251
+ this._update();
2252
+ },
2253
+ contains(name) {
2254
+ return !!~this._list.indexOf(name);
2255
+ }
2256
+ };
2257
+ function _getClassList(node) {
2258
+ if (!node.classList) {
2259
+ node.classList = new (createClass("ClassList", _ClassListProto))(node);
2260
+ }
2261
+ return node.classList;
2262
+ }
2263
+ var Styled = createClass("Styled", {
2264
+ addClass(name) {
2265
+ _getClassList(this.node).add(name);
2266
+ return this;
2267
+ },
2268
+ removeClass(name) {
2269
+ _getClassList(this.node).remove(name);
2270
+ return this;
2271
+ },
2272
+ hasClass(name) {
2273
+ return _getClassList(this.node).contains(name);
2274
+ },
2275
+ setStyle(styleOrName, value) {
2276
+ if (arguments.length === 2 && typeof styleOrName === "string") {
2277
+ this.node.style[styleOrName] = value;
2278
+ return this;
2279
+ }
2280
+ if (typeof styleOrName === "object") {
2281
+ for (const name in styleOrName) {
2282
+ if (Object.prototype.hasOwnProperty.call(styleOrName, name)) {
2283
+ this.node.style[name] = styleOrName[name];
2284
+ }
2285
+ }
2286
+ }
2287
+ return this;
2288
+ }
2289
+ });
2290
+ var Data = createClass("Data", {
2291
+ constructor() {
2292
+ this._data = {};
2293
+ },
2294
+ setData(name, value) {
2295
+ this._data[name] = value;
2296
+ return this;
2297
+ },
2298
+ getData(name) {
2299
+ return this._data[name];
2300
+ },
2301
+ removeData(name) {
2302
+ delete this._data[name];
2303
+ return this;
2304
+ }
2305
+ });
2306
+ function itemRemove() {
2307
+ this.container.removeItem(this);
2308
+ return this;
2309
+ }
2310
+ var Container = createClass("Container", {
2311
+ getItems() {
2312
+ return this.items || (this.items = []);
2313
+ },
2314
+ getItem(index) {
2315
+ return this.getItems()[index];
2316
+ },
2317
+ getFirstItem() {
2318
+ return this.getItem(0);
2319
+ },
2320
+ getLastItem() {
2321
+ return this.getItem(this.getItems().length - 1);
2322
+ },
2323
+ indexOf(item) {
2324
+ return this.getItems().indexOf(item);
2325
+ },
2326
+ eachItem(fn) {
2327
+ const items = this.getItems();
2328
+ for (let i = 0; i < items.length; i++) {
2329
+ fn.call(this, i, items[i]);
2330
+ }
2331
+ return this;
2332
+ },
2333
+ addItem(item, pos, noEvent) {
2334
+ const items = this.getItems();
2335
+ const length = items.length;
2336
+ if (~items.indexOf(item)) {
2337
+ return this;
2338
+ }
2339
+ if (!(pos >= 0 && pos < length)) {
2340
+ pos = length;
2341
+ }
2342
+ items.splice(pos, 0, item);
2343
+ if (typeof item === "object") {
2344
+ item.container = this;
2345
+ item.remove = itemRemove;
2346
+ }
2347
+ this.handleAdd(item, pos);
2348
+ if (!noEvent) {
2349
+ this.onContainerChanged("add", [item]);
2350
+ }
2351
+ return this;
2352
+ },
2353
+ addItems(items) {
2354
+ for (let i = 0, l = items.length; i < l; i++) {
2355
+ this.addItem(items[i], -1, true);
2356
+ }
2357
+ this.onContainerChanged("add", items);
2358
+ return this;
2359
+ },
2360
+ setItems(items) {
2361
+ return this.clear().addItems(items);
2362
+ },
2363
+ appendItem(item) {
2364
+ return this.addItem(item);
2365
+ },
2366
+ prependItem(item) {
2367
+ return this.addItem(item, 0);
2368
+ },
2369
+ removeItem(pos, noEvent) {
2370
+ if (typeof pos !== "number") {
2371
+ return this.removeItem(this.indexOf(pos));
2372
+ }
2373
+ const items = this.getItems();
2374
+ const item = items[pos];
2375
+ if (item === void 0) {
2376
+ return this;
2377
+ }
2378
+ items.splice(pos, 1);
2379
+ if (item.container) {
2380
+ delete item.container;
2381
+ }
2382
+ if (item.remove) {
2383
+ delete item.remove;
2384
+ }
2385
+ this.handleRemove(item, pos);
2386
+ if (!noEvent) {
2387
+ this.onContainerChanged("remove", [item]);
2388
+ }
2389
+ return this;
2390
+ },
2391
+ clear() {
2392
+ const removed = [];
2393
+ let item;
2394
+ while ((item = this.getFirstItem()) !== void 0) {
2395
+ removed.push(item);
2396
+ this.removeItem(0, true);
2397
+ }
2398
+ this.onContainerChanged("remove", removed);
2399
+ return this;
2400
+ },
2401
+ onContainerChanged(_type, _items) {
2402
+ },
2403
+ handleAdd(_item, _index) {
2404
+ },
2405
+ handleRemove(_item, _index) {
2406
+ }
2407
+ });
2408
+ var Shape = createClass("Shape", {
2409
+ mixins: [EventHandler, Styled, Data],
2410
+ constructor(tagName) {
2411
+ this.node = svg.createNode(tagName);
2412
+ this.node.shape = this;
2413
+ this.transform = {
2414
+ translate: null,
2415
+ rotate: null,
2416
+ scale: null,
2417
+ matrix: null
2418
+ };
2419
+ this.callMixin();
2420
+ },
2421
+ getId() {
2422
+ return this.node.id;
2423
+ },
2424
+ setId(id) {
2425
+ this.node.id = id;
2426
+ return this;
2427
+ },
2428
+ getNode() {
2429
+ return this.node;
2430
+ },
2431
+ getBoundaryBox() {
2432
+ let box;
2433
+ try {
2434
+ box = this.node.getBBox();
2435
+ } catch {
2436
+ box = {
2437
+ x: this.node.clientLeft,
2438
+ y: this.node.clientTop,
2439
+ width: this.node.clientWidth,
2440
+ height: this.node.clientHeight
2441
+ };
2442
+ }
2443
+ return new Box(box);
2444
+ },
2445
+ getRenderBox(refer) {
2446
+ const box = this.getBoundaryBox();
2447
+ const matrix = this.getTransform(refer);
2448
+ return matrix.transformBox(box);
2449
+ },
2450
+ getWidth() {
2451
+ return this.getRenderBox().width;
2452
+ },
2453
+ getHeight() {
2454
+ return this.getRenderBox().height;
2455
+ },
2456
+ getSize() {
2457
+ const box = this.getRenderBox();
2458
+ delete box.x;
2459
+ delete box.y;
2460
+ return box;
2461
+ },
2462
+ setOpacity(value) {
2463
+ this.node.setAttribute("opacity", String(value));
2464
+ return this;
2465
+ },
2466
+ getOpacity() {
2467
+ const opacity = this.node.getAttribute("opacity");
2468
+ return opacity ? +opacity : 1;
2469
+ },
2470
+ setVisible(value) {
2471
+ if (value) {
2472
+ this.node.removeAttribute("display");
2473
+ } else {
2474
+ this.node.setAttribute("display", "none");
2475
+ }
2476
+ return this;
2477
+ },
2478
+ getVisible() {
2479
+ this.node.getAttribute("display");
2480
+ },
2481
+ hasAncestor(node) {
2482
+ let parent = this.container;
2483
+ while (parent) {
2484
+ if (parent === node) {
2485
+ return true;
2486
+ }
2487
+ parent = parent.container;
2488
+ }
2489
+ return false;
2490
+ },
2491
+ getTransform(refer) {
2492
+ return mc.getCTM(this, refer);
2493
+ },
2494
+ clearTransform() {
2495
+ this.node.removeAttribute("transform");
2496
+ this.transform = {
2497
+ translate: null,
2498
+ rotate: null,
2499
+ scale: null,
2500
+ matrix: null
2501
+ };
2502
+ this.trigger("shapeupdate", {
2503
+ type: "transform"
2504
+ });
2505
+ return this;
2506
+ },
2507
+ _applyTransform() {
2508
+ const t = this.transform;
2509
+ const result = [];
2510
+ if (t.translate) {
2511
+ result.push(["translate(", t.translate, ")"]);
2512
+ }
2513
+ if (t.rotate) {
2514
+ result.push(["rotate(", t.rotate, ")"]);
2515
+ }
2516
+ if (t.scale) {
2517
+ result.push(["scale(", t.scale, ")"]);
2518
+ }
2519
+ if (t.matrix) {
2520
+ result.push(["matrix(", t.matrix, ")"]);
2521
+ }
2522
+ this.node.setAttribute("transform", utils_default.flatten(result).join(" "));
2523
+ return this;
2524
+ },
2525
+ setMatrix(m) {
2526
+ this.transform.matrix = m;
2527
+ return this._applyTransform();
2528
+ },
2529
+ setTranslate(t) {
2530
+ this.transform.translate = t !== null && [].slice.call(arguments) || null;
2531
+ return this._applyTransform();
2532
+ },
2533
+ setRotate(r) {
2534
+ this.transform.rotate = r !== null && [].slice.call(arguments) || null;
2535
+ return this._applyTransform();
2536
+ },
2537
+ setScale(s) {
2538
+ this.transform.scale = s !== null && [].slice.call(arguments) || null;
2539
+ return this._applyTransform();
2540
+ },
2541
+ translate(dx, dy) {
2542
+ let m = this.transform.matrix || new mc();
2543
+ if (dy === void 0) {
2544
+ dy = 0;
2545
+ }
2546
+ this.transform.matrix = m.translate(dx, dy);
2547
+ return this._applyTransform();
2548
+ },
2549
+ rotate(deg) {
2550
+ let m = this.transform.matrix || new mc();
2551
+ this.transform.matrix = m.rotate(deg);
2552
+ return this._applyTransform();
2553
+ },
2554
+ scale(sx, sy) {
2555
+ let m = this.transform.matrix || new mc();
2556
+ if (sy === void 0) {
2557
+ sy = sx;
2558
+ }
2559
+ this.transform.matrix = m.scale(sx, sy);
2560
+ return this._applyTransform();
2561
+ },
2562
+ skew(sx, sy) {
2563
+ let m = this.transform.matrix || new mc();
2564
+ if (sy === void 0) {
2565
+ sy = sx;
2566
+ }
2567
+ this.transform.matrix = m.skew(sx, sy);
2568
+ return this._applyTransform();
2569
+ },
2570
+ stroke(pen, width) {
2571
+ if (pen && pen.stroke) {
2572
+ pen.stroke(this);
2573
+ } else if (pen) {
2574
+ this.node.setAttribute("stroke", pen.toString());
2575
+ if (width) {
2576
+ this.node.setAttribute("stroke-width", String(width));
2577
+ }
2578
+ } else if (pen === null) {
2579
+ this.node.removeAttribute("stroke");
2580
+ }
2581
+ return this;
2582
+ },
2583
+ fill(brush) {
2584
+ if (brush) {
2585
+ this.node.setAttribute("fill", brush.toString());
2586
+ }
2587
+ if (brush === null) {
2588
+ this.node.removeAttribute("fill");
2589
+ }
2590
+ return this;
2591
+ },
2592
+ setAttr(a, v) {
2593
+ if (utils_default.isObject(a)) {
2594
+ utils_default.each(a, (val, key) => {
2595
+ this.setAttr(key, val);
2596
+ });
2597
+ return this;
2598
+ }
2599
+ if (v === void 0 || v === null || v === "") {
2600
+ this.node.removeAttribute(a);
2601
+ } else {
2602
+ this.node.setAttribute(a, v);
2603
+ }
2604
+ return this;
2605
+ },
2606
+ getAttr(a) {
2607
+ return this.node.getAttribute(a);
2608
+ }
2609
+ });
2610
+ var ShapeContainer = createClass("ShapeContainer", {
2611
+ base: Container,
2612
+ isShapeContainer: true,
2613
+ handleAdd(shape, index) {
2614
+ const parent = this.getShapeNode();
2615
+ parent.insertBefore(shape.node, parent.childNodes[index] || null);
2616
+ shape.trigger("add", { container: this });
2617
+ if (shape.notifyTreeModification) {
2618
+ shape.notifyTreeModification("treeadd", this);
2619
+ }
2620
+ },
2621
+ handleRemove(shape, _index) {
2622
+ const parent = this.getShapeNode();
2623
+ parent.removeChild(shape.node);
2624
+ shape.trigger("remove", {
2625
+ container: this
2626
+ });
2627
+ if (shape.notifyTreeModification) {
2628
+ shape.notifyTreeModification("treeremove", this);
2629
+ }
2630
+ },
2631
+ notifyTreeModification(type, container) {
2632
+ this.eachItem((_index, shape) => {
2633
+ if (shape.notifyTreeModification) {
2634
+ shape.notifyTreeModification(type, container);
2635
+ }
2636
+ shape.trigger(type, { container });
2637
+ });
2638
+ },
2639
+ getShape(index) {
2640
+ return this.getItem(index);
2641
+ },
2642
+ addShape(shape, index) {
2643
+ return this.addItem(shape, index);
2644
+ },
2645
+ put(shape) {
2646
+ this.addShape(shape);
2647
+ return shape;
2648
+ },
2649
+ appendShape(shape) {
2650
+ return this.addShape(shape);
2651
+ },
2652
+ prependShape(shape) {
2653
+ return this.addShape(shape, 0);
2654
+ },
2655
+ replaceShape(replacer, origin) {
2656
+ const index = this.indexOf(origin);
2657
+ if (index === -1) {
2658
+ return;
2659
+ }
2660
+ this.removeShape(index);
2661
+ this.addShape(replacer, index);
2662
+ return this;
2663
+ },
2664
+ addShapeBefore(shape, refer) {
2665
+ const index = this.indexOf(refer);
2666
+ return this.addShape(shape, index);
2667
+ },
2668
+ addShapeAfter(shape, refer) {
2669
+ const index = this.indexOf(refer);
2670
+ return this.addShape(shape, index === -1 ? void 0 : index + 1);
2671
+ },
2672
+ addShapes(shapes) {
2673
+ return this.addItems(shapes);
2674
+ },
2675
+ removeShape(index) {
2676
+ return this.removeItem(index);
2677
+ },
2678
+ getShapes() {
2679
+ return this.getItems();
2680
+ },
2681
+ getShapesByType(name) {
2682
+ const shapes = [];
2683
+ const getShapes = (shape) => {
2684
+ if (name.toLowerCase() === shape.getType().toLowerCase()) {
2685
+ shapes.push(shape);
2686
+ }
2687
+ if (shape.isShapeContainer) {
2688
+ utils_default.each(shape.getShapes(), (n) => {
2689
+ getShapes(n);
2690
+ });
2691
+ }
2692
+ };
2693
+ getShapes(this);
2694
+ return shapes;
2695
+ },
2696
+ getShapeById(id) {
2697
+ return this.getShapeNode().getElementById(id).shape;
2698
+ },
2699
+ arrangeShape(shape, index) {
2700
+ return this.removeShape(shape).addShape(shape, index);
2701
+ },
2702
+ getShapeNode() {
2703
+ return this.shapeNode || this.node;
2704
+ }
2705
+ });
2706
+ extendClass(Shape, {
2707
+ bringTo(index) {
2708
+ this.container.arrangeShape(this, index);
2709
+ return this;
2710
+ },
2711
+ bringFront() {
2712
+ return this.bringTo(this.container.indexOf(this) + 1);
2713
+ },
2714
+ bringBack() {
2715
+ return this.bringTo(this.container.indexOf(this) - 1);
2716
+ },
2717
+ bringTop() {
2718
+ this.container.removeShape(this).addShape(this);
2719
+ return this;
2720
+ },
2721
+ bringRear() {
2722
+ return this.bringTo(0);
2723
+ },
2724
+ bringRefer(referShape, offset) {
2725
+ if (referShape.container) {
2726
+ if (this.remove) {
2727
+ this.remove();
2728
+ }
2729
+ referShape.container.addShape(this, referShape.container.indexOf(referShape) + (offset || 0));
2730
+ }
2731
+ return this;
2732
+ },
2733
+ bringAbove(referShape) {
2734
+ return this.bringRefer(referShape);
2735
+ },
2736
+ bringBelow(referShape) {
2737
+ return this.bringRefer(referShape, 1);
2738
+ },
2739
+ replaceBy(newShape) {
2740
+ if (this.container) {
2741
+ newShape.bringAbove(this);
2742
+ this.remove();
2743
+ }
2744
+ return this;
2745
+ }
2746
+ });
2747
+ var ViewBox = createClass("ViewBox", {
2748
+ getViewBox() {
2749
+ const attr = this.node.getAttribute("viewBox");
2750
+ if (attr === null) {
2751
+ return {
2752
+ x: 0,
2753
+ y: 0,
2754
+ width: this.node.clientWidth || this.node.parentNode?.clientWidth || 0,
2755
+ height: this.node.clientHeight || this.node.parentNode?.clientHeight || 0
2756
+ };
2757
+ } else {
2758
+ const parts = attr.split(" ");
2759
+ return {
2760
+ x: +parts[0],
2761
+ y: +parts[1],
2762
+ width: +parts[2],
2763
+ height: +parts[3]
2764
+ };
2765
+ }
2766
+ },
2767
+ setViewBox(x, y, width, height) {
2768
+ this.node.setAttribute("viewBox", [x, y, width, height].join(" "));
2769
+ return this;
2770
+ }
2771
+ });
2772
+ var TextContent = createClass("TextContent", {
2773
+ base: Shape,
2774
+ constructor(nodeType) {
2775
+ this.callBase(nodeType);
2776
+ this.shapeNode = this.shapeNode || this.node;
2777
+ this.shapeNode.setAttribute("text-rendering", "geometricPrecision");
2778
+ },
2779
+ clearContent() {
2780
+ while (this.shapeNode.firstChild) {
2781
+ this.shapeNode.removeChild(this.shapeNode.firstChild);
2782
+ }
2783
+ return this;
2784
+ },
2785
+ setContent(content) {
2786
+ this.shapeNode.textContent = content;
2787
+ return this;
2788
+ },
2789
+ getContent() {
2790
+ return this.shapeNode.textContent;
2791
+ },
2792
+ appendContent(content) {
2793
+ this.shapeNode.textContent += content;
2794
+ return this;
2795
+ },
2796
+ setSize(value) {
2797
+ return this.setFontSize(value);
2798
+ },
2799
+ setFontSize(value) {
2800
+ return this.setFont({
2801
+ size: value
2802
+ });
2803
+ },
2804
+ setFontFamily(value) {
2805
+ return this.setFont({
2806
+ family: value
2807
+ });
2808
+ },
2809
+ setFontBold(bold) {
2810
+ return this.setFont({
2811
+ weight: bold ? "bold" : "normal"
2812
+ });
2813
+ },
2814
+ setFontItalic(italic) {
2815
+ return this.setFont({
2816
+ style: italic ? "italic" : "normal"
2817
+ });
2818
+ },
2819
+ setFont(font) {
2820
+ const node = this.node;
2821
+ ["family", "size", "weight", "style"].forEach((section) => {
2822
+ if (font[section] === null) {
2823
+ node.removeAttribute("font-" + section);
2824
+ } else if (font[section]) {
2825
+ node.setAttribute("font-" + section, font[section]);
2826
+ }
2827
+ });
2828
+ return this;
2829
+ },
2830
+ getExtentOfChar(index) {
2831
+ return this.node.getExtentOfChar(index);
2832
+ },
2833
+ getRotationOfChar(index) {
2834
+ return this.node.getRotationOfChar(index);
2835
+ },
2836
+ getCharNumAtPosition(x, y) {
2837
+ return this.node.getCharNumAtPosition({ x, y });
2838
+ }
2839
+ });
2840
+ var _offsetHash = {};
2841
+ function _getTextBoundOffset(text) {
2842
+ const font = text._cachedFontHash;
2843
+ if (_offsetHash[font]) {
2844
+ return _offsetHash[font];
2845
+ }
2846
+ const textContent = text.getContent();
2847
+ text.setContent("\u767E\u5EA6Fex");
2848
+ const bbox = text.getBoundaryBox();
2849
+ const y = text.getY();
2850
+ if (!bbox.height) {
2851
+ return { top: 0, bottom: 0, middle: 0 };
2852
+ }
2853
+ const topOffset = y - bbox.y + +text.node.getAttribute("dy");
2854
+ const bottomOffset = topOffset - bbox.height;
2855
+ text.setContent(textContent);
2856
+ _offsetHash[font] = {
2857
+ top: topOffset,
2858
+ bottom: bottomOffset,
2859
+ middle: (topOffset + bottomOffset) / 2
2860
+ };
2861
+ return _offsetHash[font];
2862
+ }
2863
+ var Text = createClass("Text", {
2864
+ base: TextContent,
2865
+ mixins: [ShapeContainer],
2866
+ constructor(content) {
2867
+ this.callBase("text");
2868
+ if (content !== void 0) {
2869
+ this.setContent(content);
2870
+ }
2871
+ this._buildFontHash();
2872
+ },
2873
+ fixPosition() {
2874
+ if (!this.__fixedPosition) {
2875
+ this.setVerticalAlign(this.getVerticalAlign());
2876
+ }
2877
+ },
2878
+ _buildFontHash() {
2879
+ const style = window.getComputedStyle(this.node);
2880
+ this._cachedFontHash = [
2881
+ style.fontFamily,
2882
+ style.fontSize,
2883
+ style.fontStretch,
2884
+ style.fontStyle,
2885
+ style.fontVariant,
2886
+ style.fontWeight
2887
+ ].join("-");
2888
+ },
2889
+ _fontChanged(font) {
2890
+ const last = this._lastFont;
2891
+ const current = utils_default.extend({}, last, font);
2892
+ if (!last) {
2893
+ this._lastFont = font;
2894
+ return true;
2895
+ }
2896
+ const changed = last.family !== current.family || last.size !== current.size || last.style !== current.style || last.weight !== current.weight;
2897
+ this._lastFont = current;
2898
+ return changed;
2899
+ },
2900
+ setX(x) {
2901
+ this.node.setAttribute("x", String(x));
2902
+ return this;
2903
+ },
2904
+ setPosition(x, y) {
2905
+ return this.setX(x).setY(y);
2906
+ },
2907
+ setY(y) {
2908
+ this.node.setAttribute("y", String(y));
2909
+ return this;
2910
+ },
2911
+ getX() {
2912
+ return +(this.node.getAttribute("x") || "0");
2913
+ },
2914
+ getY() {
2915
+ return +(this.node.getAttribute("y") || "0");
2916
+ },
2917
+ setFont(font) {
2918
+ this.callBase(font);
2919
+ if (this._fontChanged(font)) {
2920
+ this._buildFontHash();
2921
+ this.setVerticalAlign(this.getVerticalAlign());
2922
+ }
2923
+ return this;
2924
+ },
2925
+ setTextAnchor(anchor) {
2926
+ this.node.setAttribute("text-anchor", anchor);
2927
+ return this;
2928
+ },
2929
+ getTextAnchor() {
2930
+ return this.node.getAttribute("text-anchor") || "start";
2931
+ },
2932
+ setVerticalAlign(align) {
2933
+ this.whenPaperReady(() => {
2934
+ let dy;
2935
+ switch (align) {
2936
+ case "top":
2937
+ dy = _getTextBoundOffset(this).top;
2938
+ break;
2939
+ case "bottom":
2940
+ dy = _getTextBoundOffset(this).bottom;
2941
+ break;
2942
+ case "middle":
2943
+ dy = _getTextBoundOffset(this).middle;
2944
+ break;
2945
+ default:
2946
+ dy = 0;
2947
+ }
2948
+ if (dy) {
2949
+ this.__fixedPosition = true;
2950
+ }
2951
+ this.node.setAttribute("dy", dy);
2952
+ });
2953
+ this.verticalAlign = align;
2954
+ return this;
2955
+ },
2956
+ getVerticalAlign() {
2957
+ return this.verticalAlign || "baseline";
2958
+ },
2959
+ setStartOffset(offset) {
2960
+ if (this.shapeNode !== this.node) {
2961
+ this.shapeNode.setAttribute("startOffset", offset * 100 + "%");
2962
+ }
2963
+ },
2964
+ addSpan(span) {
2965
+ this.addShape(span);
2966
+ return this;
2967
+ },
2968
+ setPath(path) {
2969
+ let textpath = this.shapeNode;
2970
+ if (this.shapeNode === this.node) {
2971
+ textpath = this.shapeNode = svg.createNode("textPath");
2972
+ while (this.node.firstChild) {
2973
+ this.shapeNode.appendChild(this.node.firstChild);
2974
+ }
2975
+ this.node.appendChild(textpath);
2976
+ }
2977
+ textpath.setAttributeNS(svg.xlink, "xlink:href", "#" + path.node.id);
2978
+ this.setTextAnchor(this.getTextAnchor());
2979
+ return this;
2980
+ }
2981
+ });
2982
+ var PathDrawer = createClass("PathDrawer", {
2983
+ constructor(path) {
2984
+ this.segment = [];
2985
+ this.path = path;
2986
+ this.__clear = false;
2987
+ },
2988
+ getPath() {
2989
+ return this.path;
2990
+ },
2991
+ redraw() {
2992
+ this._transation = this._transation || [];
2993
+ return this.clear();
2994
+ },
2995
+ done() {
2996
+ const transation = this._transation;
2997
+ this._transation = null;
2998
+ this.push(transation);
2999
+ return this;
3000
+ },
3001
+ clear() {
3002
+ if (this._transation) {
3003
+ this._transation = [];
3004
+ } else {
3005
+ this.path.setPathData("M 0 0");
3006
+ }
3007
+ this._clear = true;
3008
+ return this;
3009
+ },
3010
+ push() {
3011
+ const segment = [].slice.call(arguments);
3012
+ let originData;
3013
+ if (this._transation) {
3014
+ this._transation.push(segment);
3015
+ return this;
3016
+ }
3017
+ if (this._clear) {
3018
+ originData = "";
3019
+ this._clear = false;
3020
+ } else {
3021
+ originData = this.path.getPathData();
3022
+ }
3023
+ originData = originData || "";
3024
+ this.path.setPathData(originData + g.pathToString(segment));
3025
+ return this;
3026
+ },
3027
+ moveTo(_x, _y) {
3028
+ return this.push("M", [].slice.call(arguments));
3029
+ },
3030
+ moveBy(_dx, _dy) {
3031
+ return this.push("m", [].slice.call(arguments));
3032
+ },
3033
+ lineTo(_x, _y) {
3034
+ return this.push("L", [].slice.call(arguments));
3035
+ },
3036
+ lineBy(_dx, _dy) {
3037
+ return this.push("l", [].slice.call(arguments));
3038
+ },
3039
+ arcTo(_rx, _ry, _xr, _laf, _sf, _x, _y) {
3040
+ return this.push("A", [].slice.call(arguments));
3041
+ },
3042
+ arcBy(_rx, _ry, _xr, _laf, _sf, _dx, _dy) {
3043
+ return this.push("a", arguments);
3044
+ },
3045
+ carcTo(r, _laf, _sf, _x, _y) {
3046
+ return this.push("A", [r, r, 0].concat([].slice.call(arguments, 1)));
3047
+ },
3048
+ carcBy(r, _laf, _sf, _dx, _dy) {
3049
+ return this.push("a", [r, r, 0].concat([].slice.call(arguments, 1)));
3050
+ },
3051
+ bezierTo(_x1, _y1, _x2, _y2, _x, _y) {
3052
+ return this.push("C", [].slice.call(arguments));
3053
+ },
3054
+ bezierBy(_dx1, _dy1, _dx2, _dy2, _dx, _dy) {
3055
+ return this.push("c", [].slice.call(arguments));
3056
+ },
3057
+ close() {
3058
+ return this.push("z");
3059
+ }
3060
+ });
3061
+ var Path = createClass("Path", {
3062
+ base: Shape,
3063
+ constructor(data) {
3064
+ this.callBase("path");
3065
+ if (data) {
3066
+ this.setPathData(data);
3067
+ }
3068
+ this.node.setAttribute("fill", svg.defaults.fill);
3069
+ this.node.setAttribute("stroke", svg.defaults.stroke);
3070
+ },
3071
+ setPathData(data) {
3072
+ data = data || "M0,0";
3073
+ this.pathdata = g.pathToString(data);
3074
+ this.node.setAttribute("d", this.pathdata);
3075
+ this.trigger("shapeupdate", {
3076
+ type: "pathdata"
3077
+ });
3078
+ return this;
3079
+ },
3080
+ getPathData() {
3081
+ return this.pathdata || "";
3082
+ },
3083
+ getDrawer() {
3084
+ return new PathDrawer(this);
3085
+ },
3086
+ isClosed() {
3087
+ const data = this.getPathData();
3088
+ return !!~data.indexOf("z") || !!~data.indexOf("Z");
3089
+ }
3090
+ });
3091
+ var RectUtils = {
3092
+ formatRadius(width, height, radius) {
3093
+ const minValue = Math.floor(Math.min(width / 2, height / 2));
3094
+ return Math.min(minValue, radius);
3095
+ }
3096
+ };
3097
+ var Rect = createClass("Rect", {
3098
+ base: Path,
3099
+ constructor(width, height, x, y, radius) {
3100
+ this.callBase();
3101
+ this.x = x || 0;
3102
+ this.y = y || 0;
3103
+ this.width = width || 0;
3104
+ this.height = height || 0;
3105
+ this.radius = RectUtils.formatRadius(this.width, this.height, radius || 0);
3106
+ this.update();
3107
+ },
3108
+ update() {
3109
+ const x = this.x, y = this.y, w = this.width, h = this.height, r = this.radius;
3110
+ const drawer = this.getDrawer().redraw();
3111
+ if (!r) {
3112
+ drawer.push("M", x, y);
3113
+ drawer.push("h", w);
3114
+ drawer.push("v", h);
3115
+ drawer.push("h", -w);
3116
+ drawer.push("z");
3117
+ } else {
3118
+ const w2 = w - 2 * r;
3119
+ const h2 = h - 2 * r;
3120
+ drawer.push("M", x + r, y);
3121
+ drawer.push("h", w2);
3122
+ drawer.push("a", r, r, 0, 0, 1, r, r);
3123
+ drawer.push("v", h2);
3124
+ drawer.push("a", r, r, 0, 0, 1, -r, r);
3125
+ drawer.push("h", -w2);
3126
+ drawer.push("a", r, r, 0, 0, 1, -r, -r);
3127
+ drawer.push("v", -h2);
3128
+ drawer.push("a", r, r, 0, 0, 1, r, -r);
3129
+ drawer.push("z");
3130
+ }
3131
+ drawer.done();
3132
+ return this;
3133
+ },
3134
+ setWidth(width) {
3135
+ this.width = width;
3136
+ return this.update();
3137
+ },
3138
+ setHeight(height) {
3139
+ this.height = height;
3140
+ return this.update();
3141
+ },
3142
+ setSize(width, height) {
3143
+ this.width = width;
3144
+ this.height = height;
3145
+ return this.update();
3146
+ },
3147
+ setBox(box) {
3148
+ this.x = box.x;
3149
+ this.y = box.y;
3150
+ this.width = box.width;
3151
+ this.height = box.height;
3152
+ return this.update();
3153
+ },
3154
+ getBox() {
3155
+ return new Box(this.x, this.y, this.width, this.height);
3156
+ },
3157
+ getRadius() {
3158
+ return this.radius;
3159
+ },
3160
+ setRadius(radius) {
3161
+ this.radius = RectUtils.formatRadius(this.width, this.height, radius || 0);
3162
+ return this.update();
3163
+ },
3164
+ getPosition() {
3165
+ return new pc(this.x, this.y);
3166
+ },
3167
+ setPosition(xOrP, y) {
3168
+ if (arguments.length === 1) {
3169
+ const p = pc.parse(arguments[0]);
3170
+ y = p.y;
3171
+ xOrP = p.x;
3172
+ }
3173
+ this.x = xOrP;
3174
+ this.y = y;
3175
+ return this.update();
3176
+ },
3177
+ getWidth() {
3178
+ return this.width;
3179
+ },
3180
+ getHeight() {
3181
+ return this.height;
3182
+ },
3183
+ getPositionX() {
3184
+ return this.x;
3185
+ },
3186
+ getPositionY() {
3187
+ return this.y;
3188
+ },
3189
+ setPositionX(x) {
3190
+ this.x = x;
3191
+ return this.update();
3192
+ },
3193
+ setPositionY(y) {
3194
+ this.y = y;
3195
+ return this.update();
3196
+ }
3197
+ });
3198
+ var Group = createClass("Group", {
3199
+ mixins: [ShapeContainer],
3200
+ base: Shape,
3201
+ constructor() {
3202
+ this.callBase("g");
3203
+ }
3204
+ });
3205
+ var Use = createClass("Use", {
3206
+ base: Shape,
3207
+ constructor(shape) {
3208
+ this.callBase("use");
3209
+ this.ref(shape);
3210
+ },
3211
+ ref(shape) {
3212
+ if (!shape) {
3213
+ this.node.removeAttributeNS(svg.xlink, "xlink:href");
3214
+ return this;
3215
+ }
3216
+ const shapeId = shape.getId();
3217
+ if (shapeId) {
3218
+ this.node.setAttributeNS(svg.xlink, "xlink:href", "#" + shapeId);
3219
+ }
3220
+ if (shape.node.getAttribute("fill") === "none") {
3221
+ shape.node.removeAttribute("fill");
3222
+ }
3223
+ if (shape.node.getAttribute("stroke") === "none") {
3224
+ shape.node.removeAttribute("stroke");
3225
+ }
3226
+ return this;
3227
+ }
3228
+ });
3229
+ extendClass(Shape, {
3230
+ use() {
3231
+ return new Use(this);
3232
+ }
3233
+ });
3234
+ var Paper = createClass("Paper", {
3235
+ mixins: [ShapeContainer, EventHandler, Styled, ViewBox],
3236
+ constructor(container) {
3237
+ this.callBase();
3238
+ this.node = this.createSVGNode();
3239
+ this.node.paper = this;
3240
+ this.node.appendChild(this.resourceNode = svg.createNode("defs"));
3241
+ this.node.appendChild(this.shapeNode = svg.createNode("g"));
3242
+ this.resources = new Container();
3243
+ this.setWidth("100%").setHeight("100%");
3244
+ if (container) {
3245
+ this.renderTo(container);
3246
+ }
3247
+ this.callMixin();
3248
+ },
3249
+ renderTo(container) {
3250
+ if (utils_default.isString(container)) {
3251
+ container = document.getElementById(container);
3252
+ }
3253
+ this.container = container;
3254
+ container.appendChild(this.node);
3255
+ },
3256
+ createSVGNode() {
3257
+ const node = svg.createNode("svg");
3258
+ node.setAttribute("xmlns", "http://www.w3.org/2000/svg");
3259
+ node.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
3260
+ node.setAttribute("version", "1.1");
3261
+ return node;
3262
+ },
3263
+ getNode() {
3264
+ return this.node;
3265
+ },
3266
+ getContainer() {
3267
+ return this.container;
3268
+ },
3269
+ getWidth() {
3270
+ return this.node.clientWidth;
3271
+ },
3272
+ setWidth(width) {
3273
+ this.node.setAttribute("width", String(width));
3274
+ return this;
3275
+ },
3276
+ getHeight() {
3277
+ return this.node.clientHeight;
3278
+ },
3279
+ setHeight(height) {
3280
+ this.node.setAttribute("height", String(height));
3281
+ return this;
3282
+ },
3283
+ setViewPort(cx, cy, zoom) {
3284
+ let viewport, box;
3285
+ if (arguments.length === 1) {
3286
+ viewport = arguments[0];
3287
+ cx = viewport.center.x;
3288
+ cy = viewport.center.y;
3289
+ zoom = viewport.zoom;
3290
+ }
3291
+ zoom = zoom || 1;
3292
+ box = this.getViewBox();
3293
+ const matrix = new mc();
3294
+ const dx = box.x + box.width / 2 - cx;
3295
+ const dy = box.y + box.height / 2 - cy;
3296
+ matrix.translate(-cx, -cy);
3297
+ matrix.scale(zoom);
3298
+ matrix.translate(cx, cy);
3299
+ matrix.translate(dx, dy);
3300
+ this.shapeNode.setAttribute("transform", "matrix(" + matrix + ")");
3301
+ this.viewport = {
3302
+ center: { x: cx, y: cy },
3303
+ offset: { x: dx, y: dy },
3304
+ zoom
3305
+ };
3306
+ return this;
3307
+ },
3308
+ getViewPort() {
3309
+ if (!this.viewport) {
3310
+ const box = this.getViewBox();
3311
+ return {
3312
+ zoom: 1,
3313
+ center: {
3314
+ x: box.x + box.width / 2,
3315
+ y: box.y + box.height / 2
3316
+ },
3317
+ offset: { x: 0, y: 0 }
3318
+ };
3319
+ }
3320
+ return this.viewport;
3321
+ },
3322
+ getViewPortMatrix() {
3323
+ return mc.parse(this.shapeNode.getAttribute("transform"));
3324
+ },
3325
+ getViewPortTransform() {
3326
+ const m = this.shapeNode.getCTM();
3327
+ return new mc(m.a, m.b, m.c, m.d, m.e, m.f);
3328
+ },
3329
+ getTransform() {
3330
+ return this.getViewPortTransform().reverse();
3331
+ },
3332
+ addResource(resource) {
3333
+ this.resources.appendItem(resource);
3334
+ if (resource.node) {
3335
+ this.resourceNode.appendChild(resource.node);
3336
+ }
3337
+ return this;
3338
+ },
3339
+ removeResource(resource) {
3340
+ if (resource.remove) {
3341
+ resource.remove();
3342
+ }
3343
+ if (resource.node) {
3344
+ this.resourceNode.removeChild(resource.node);
3345
+ }
3346
+ return this;
3347
+ },
3348
+ getPaper() {
3349
+ return this;
3350
+ }
3351
+ });
3352
+ extendClass(Shape, {
3353
+ getPaper() {
3354
+ let parent = this.container;
3355
+ while (parent && parent instanceof Paper === false) {
3356
+ parent = parent.container;
3357
+ }
3358
+ return parent;
3359
+ },
3360
+ isAttached() {
3361
+ return !!this.getPaper();
3362
+ },
3363
+ whenPaperReady(fn) {
3364
+ const me = this;
3365
+ function check() {
3366
+ const paper = me.getPaper();
3367
+ if (paper && fn) {
3368
+ fn.call(me, paper);
3369
+ }
3370
+ return paper;
3371
+ }
3372
+ if (!check()) {
3373
+ this.on("add treeadd", function listen2() {
3374
+ if (check()) {
3375
+ me.off("add", listen2);
3376
+ me.off("treeadd", listen2);
3377
+ }
3378
+ });
3379
+ }
3380
+ return this;
3381
+ }
3382
+ });
3383
+
3384
+ // ../kity-runtime/src/kity/index.ts
3385
+ var kity = {
3386
+ version: "2.0.5",
3387
+ createClass,
3388
+ extendClass,
3389
+ Utils: utils_default,
3390
+ Class,
3391
+ Box,
3392
+ Point,
3393
+ Matrix,
3394
+ g,
3395
+ Container,
3396
+ Shape,
3397
+ ShapeContainer,
3398
+ Group,
3399
+ Rect,
3400
+ Path,
3401
+ Text,
3402
+ Paper,
3403
+ Use,
3404
+ ViewBox,
3405
+ EventHandler,
3406
+ Styled,
3407
+ Data,
3408
+ PathDrawer,
3409
+ svg
3410
+ };
3411
+ function installKityRuntime(targetWindow = window) {
3412
+ if (targetWindow.kity) {
3413
+ return;
3414
+ }
3415
+ targetWindow.kity = kity;
3416
+ }
3417
+
3418
+ // ../kity-runtime/src/perf.ts
3419
+ function getPerfHost() {
3420
+ return globalThis;
3421
+ }
3422
+ function getPerfState() {
3423
+ const host = getPerfHost();
3424
+ host.__FORMULAX_PERF_STATE__ ??= {
3425
+ reportedMeasureCount: 0,
3426
+ reportScheduled: false
3427
+ };
3428
+ return host.__FORMULAX_PERF_STATE__;
3429
+ }
3430
+ function hasPerfSupport() {
3431
+ return typeof performance !== "undefined" && typeof performance.mark === "function" && typeof performance.measure === "function" && typeof performance.getEntriesByType === "function";
3432
+ }
3433
+ function isPerfDebugEnabled() {
3434
+ return getPerfHost().__FORMULAX_PERF__ === true;
3435
+ }
3436
+ function schedulePerfReport() {
3437
+ if (!hasPerfSupport() || !isPerfDebugEnabled()) {
3438
+ return;
3439
+ }
3440
+ const state = getPerfState();
3441
+ if (state.reportScheduled) {
3442
+ return;
3443
+ }
3444
+ state.reportScheduled = true;
3445
+ queueMicrotask(() => {
3446
+ state.reportScheduled = false;
3447
+ const entries = performance.getEntriesByType("measure").filter((entry) => entry.name.startsWith("fx:")).sort((left, right) => left.startTime - right.startTime);
3448
+ const nextEntries = entries.slice(state.reportedMeasureCount);
3449
+ state.reportedMeasureCount = entries.length;
3450
+ if (!nextEntries.length) {
3451
+ return;
3452
+ }
3453
+ console.table(nextEntries.map((entry) => ({
3454
+ name: entry.name,
3455
+ duration: Number(entry.duration.toFixed(2)),
3456
+ startTime: Number(entry.startTime.toFixed(2))
3457
+ })));
3458
+ });
3459
+ }
3460
+ function markFormulaXPerf(name) {
3461
+ if (!hasPerfSupport()) {
3462
+ return null;
3463
+ }
3464
+ const markName = `${name}::${Date.now()}::${Math.random().toString(36).slice(2, 8)}`;
3465
+ performance.mark(markName);
3466
+ return markName;
3467
+ }
3468
+ function measureFormulaXPerf(name, startMark, endMark) {
3469
+ if (!hasPerfSupport() || !startMark) {
3470
+ return null;
3471
+ }
3472
+ const resolvedEndMark = endMark ?? markFormulaXPerf(`${name}:end`);
3473
+ if (!resolvedEndMark) {
3474
+ return null;
3475
+ }
3476
+ performance.measure(name, startMark, resolvedEndMark);
3477
+ schedulePerfReport();
3478
+ return resolvedEndMark;
3479
+ }
3480
+ function clearFormulaXPerfMarks(...marks) {
3481
+ if (!hasPerfSupport()) {
3482
+ return;
3483
+ }
3484
+ for (const mark of marks) {
3485
+ if (!mark) {
3486
+ continue;
3487
+ }
3488
+ performance.clearMarks(mark);
3489
+ }
3490
+ }
3491
+
3492
+ // ../kity-runtime/src/create-editor.ts
3493
+ var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
3494
+ var DEFAULT_EDITOR_HEIGHT = "auto";
3495
+ var KITY_STYLE_ID = "formulax-kity-editor-styles";
3496
+ var runtimePromise = null;
3497
+ function resolveContainer(el) {
3498
+ if (typeof el === "string") {
3499
+ const element = document.querySelector(el);
3500
+ if (!(element instanceof HTMLElement)) {
3501
+ throw new Error(`Kity editor mount target not found: ${el}`);
3502
+ }
3503
+ return element;
3504
+ }
3505
+ return el;
3506
+ }
3507
+ function normalizeCssSize(value, fallback) {
3508
+ if (typeof value === "number") {
3509
+ return `${value}px`;
3510
+ }
3511
+ return value ?? fallback;
3512
+ }
3513
+ function resolveEditorAssets(assets) {
3514
+ return {
3515
+ fonts: {
3516
+ ...kityAssetManifest.fonts,
3517
+ ...assets?.fonts
3518
+ },
3519
+ toolbar: {
3520
+ ...kityAssetManifest.toolbar,
3521
+ ...assets?.toolbar
3522
+ },
3523
+ styles: {
3524
+ ...kityAssetManifest.styles,
3525
+ ...assets?.styles
3526
+ }
3527
+ };
3528
+ }
3529
+ function ensureKityStylesheet(doc, href) {
3530
+ if (doc.getElementById(KITY_STYLE_ID)) {
3531
+ return false;
3532
+ }
3533
+ const link = doc.createElement("link");
3534
+ link.id = KITY_STYLE_ID;
3535
+ link.rel = "stylesheet";
3536
+ link.href = href;
3537
+ doc.head.appendChild(link);
3538
+ return true;
3539
+ }
3540
+ function hydrateLegacyKf(runtimeWindow) {
3541
+ const requireFormula = runtimeWindow.__kityFormulaRequire__;
3542
+ if (!requireFormula) {
3543
+ return;
3544
+ }
3545
+ runtimeWindow.kf = {
3546
+ ...runtimeWindow.kf ?? {},
3547
+ ResourceManager: requireFormula("resource-manager"),
3548
+ Operator: requireFormula("operator/operator"),
3549
+ Expression: requireFormula("expression/expression"),
3550
+ CompoundExpression: requireFormula("expression/compound"),
3551
+ TextExpression: requireFormula("expression/text"),
3552
+ EmptyExpression: requireFormula("expression/empty"),
3553
+ CombinationExpression: requireFormula("expression/compound-exp/combination"),
3554
+ FunctionExpression: requireFormula("expression/compound-exp/func"),
3555
+ FractionExpression: requireFormula("expression/compound-exp/fraction"),
3556
+ IntegrationExpression: requireFormula("expression/compound-exp/integration"),
3557
+ RadicalExpression: requireFormula("expression/compound-exp/radical"),
3558
+ ScriptExpression: requireFormula("expression/compound-exp/script"),
3559
+ SuperscriptExpression: requireFormula("expression/compound-exp/binary-exp/superscript"),
3560
+ SubscriptExpression: requireFormula("expression/compound-exp/binary-exp/subscript"),
3561
+ SummationExpression: requireFormula("expression/compound-exp/summation"),
3562
+ BracketsExpression: requireFormula("expression/compound-exp/brackets")
3563
+ };
3564
+ }
3565
+ function installLegacyRuntime(runtimeWindow) {
3566
+ runtimeWindow.__FORMULAX_KITY_RUNTIME__ = {
3567
+ baseComponent: runtimeWindow.kity ? createLegacyBaseComponent(
3568
+ runtimeWindow.kity
3569
+ ) : void 0,
3570
+ baseUtils: legacyBaseUtils,
3571
+ boxType: legacyBoxType,
3572
+ sysconf: legacySysconf,
3573
+ charPosition: legacyCharPosition,
3574
+ commonUtils: legacyCommonUtils,
3575
+ eleType: legacyEleType,
3576
+ eventListener: legacyEventListener,
3577
+ groupType: legacyGroupType,
3578
+ inputFilter: legacyInputFilter,
3579
+ itemType: legacyItemType,
3580
+ kf: runtimeWindow.kf,
3581
+ kfExtDef: legacyKfExtDef,
3582
+ kfEvent: legacyKfEvent,
3583
+ kity: runtimeWindow.kity,
3584
+ otherPosition: legacyOtherPosition,
3585
+ uiDef: legacyUiDef,
3586
+ uiUtils: legacyUiUtils
3587
+ };
3588
+ }
3589
+ async function ensureKityRuntime() {
3590
+ if (runtimePromise) {
3591
+ return runtimePromise;
3592
+ }
3593
+ runtimePromise = (async () => {
3594
+ const runtimeTotalStart = markFormulaXPerf("fx:kity-runtime:total");
3595
+ const runtimeWindow = window;
3596
+ runtimeWindow.kf = runtimeWindow.kf ?? {};
3597
+ installKityRuntime(runtimeWindow);
3598
+ try {
3599
+ const formulaImportStart = markFormulaXPerf("fx:kity-runtime:formula-import");
3600
+ const { installLegacyKityFormulaRuntime } = await import("./install-XGCSWTLU.js");
3601
+ const formulaImportEnd = markFormulaXPerf("fx:kity-runtime:formula-import:end");
3602
+ measureFormulaXPerf("fx:kity-runtime:formula-import", formulaImportStart, formulaImportEnd);
3603
+ clearFormulaXPerfMarks(formulaImportStart, formulaImportEnd);
3604
+ const formulaInstallStart = markFormulaXPerf("fx:kity-runtime:formula-install");
3605
+ installLegacyKityFormulaRuntime(runtimeWindow);
3606
+ hydrateLegacyKf(runtimeWindow);
3607
+ const formulaInstallEnd = markFormulaXPerf("fx:kity-runtime:formula-install:end");
3608
+ measureFormulaXPerf("fx:kity-runtime:formula-install", formulaInstallStart, formulaInstallEnd);
3609
+ clearFormulaXPerfMarks(formulaInstallStart, formulaInstallEnd);
3610
+ const parserImportStart = markFormulaXPerf("fx:kity-runtime:parser-import");
3611
+ const { installLegacyParserRuntime } = await import("./install-XVTKACEN.js");
3612
+ const parserImportEnd = markFormulaXPerf("fx:kity-runtime:parser-import:end");
3613
+ measureFormulaXPerf("fx:kity-runtime:parser-import", parserImportStart, parserImportEnd);
3614
+ clearFormulaXPerfMarks(parserImportStart, parserImportEnd);
3615
+ const parserInstallStart = markFormulaXPerf("fx:kity-runtime:parser-install");
3616
+ installLegacyParserRuntime(runtimeWindow);
3617
+ const parserInstallEnd = markFormulaXPerf("fx:kity-runtime:parser-install:end");
3618
+ measureFormulaXPerf("fx:kity-runtime:parser-install", parserInstallStart, parserInstallEnd);
3619
+ clearFormulaXPerfMarks(parserInstallStart, parserInstallEnd);
3620
+ installLegacyRuntime(runtimeWindow);
3621
+ const bootImportStart = markFormulaXPerf("fx:kity-runtime:boot-import");
3622
+ const { installKityEditorStart } = await import("./start-CRRRBVTN.js");
3623
+ const bootImportEnd = markFormulaXPerf("fx:kity-runtime:boot-import:end");
3624
+ measureFormulaXPerf("fx:kity-runtime:boot-import", bootImportStart, bootImportEnd);
3625
+ clearFormulaXPerfMarks(bootImportStart, bootImportEnd);
3626
+ const bootInstallStart = markFormulaXPerf("fx:kity-runtime:boot-install");
3627
+ installKityEditorStart(runtimeWindow);
3628
+ const bootInstallEnd = markFormulaXPerf("fx:kity-runtime:boot-install:end");
3629
+ measureFormulaXPerf("fx:kity-runtime:boot-install", bootInstallStart, bootInstallEnd);
3630
+ clearFormulaXPerfMarks(bootInstallStart, bootInstallEnd);
3631
+ } finally {
3632
+ const runtimeTotalEnd = markFormulaXPerf("fx:kity-runtime:total:end");
3633
+ measureFormulaXPerf("fx:kity-runtime:total", runtimeTotalStart, runtimeTotalEnd);
3634
+ clearFormulaXPerfMarks(runtimeTotalStart, runtimeTotalEnd);
3635
+ }
3636
+ })();
3637
+ return runtimePromise;
3638
+ }
3639
+ async function createKityEditor(container, options = {}) {
3640
+ const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
3641
+ const fontsize = options.render?.fontsize ?? 40;
3642
+ const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
3643
+ const locale = normalizeFormulaXLocale(options.locale ?? DEFAULT_FORMULAX_LOCALE);
3644
+ const assets = resolveEditorAssets(options.assets);
3645
+ try {
3646
+ legacySysconf.rootPlaceholder.content = getFormulaXRuntimeMessage("editor.placeholder.root", locale);
3647
+ const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
3648
+ if (stylesheetInserted) {
3649
+ const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
3650
+ measureFormulaXPerf("fx:kity-css:link-inserted", createEditorStart, stylesheetInsertedMark);
3651
+ clearFormulaXPerfMarks(stylesheetInsertedMark);
3652
+ }
3653
+ setToolbarAssetUrls(assets.toolbar);
3654
+ await ensureKityRuntime();
3655
+ const runtimeReadyMark = markFormulaXPerf("fx:kity-runtime:ready-for-editor");
3656
+ measureFormulaXPerf("fx:kity-runtime:ready-for-editor", createEditorStart, runtimeReadyMark);
3657
+ clearFormulaXPerfMarks(runtimeReadyMark);
3658
+ const runtimeWindow = window;
3659
+ if (!runtimeWindow.kf?.EditorFactory) {
3660
+ throw new Error("Kity editor runtime did not initialize");
3661
+ }
3662
+ container.innerHTML = "";
3663
+ const host = document.createElement("div");
3664
+ host.className = "kf-editor";
3665
+ host.style.width = "100%";
3666
+ host.style.height = editorHeight;
3667
+ container.appendChild(host);
3668
+ const factoryCreateStart = markFormulaXPerf("fx:kity-editor-factory:create");
3669
+ const factory = runtimeWindow.kf.EditorFactory.create(host, {
3670
+ render: {
3671
+ fontsize
3672
+ },
3673
+ ui: {
3674
+ locale
3675
+ },
3676
+ resource: {
3677
+ path: "",
3678
+ fonts: assets.fonts
3679
+ }
3680
+ });
3681
+ const factoryCreateEnd = markFormulaXPerf("fx:kity-editor-factory:create:end");
3682
+ measureFormulaXPerf("fx:kity-editor-factory:create", factoryCreateStart, factoryCreateEnd);
3683
+ clearFormulaXPerfMarks(factoryCreateStart, factoryCreateEnd);
3684
+ return {
3685
+ ready: factory.ready.bind(factory),
3686
+ execCommand(name, value) {
3687
+ factory.ready(function execWhenReady() {
3688
+ this.execCommand(name, value);
3689
+ });
3690
+ },
3691
+ focus() {
3692
+ factory.ready(function focusWhenReady() {
3693
+ this.execCommand("focus");
3694
+ });
3695
+ },
3696
+ destroy() {
3697
+ container.innerHTML = "";
3698
+ },
3699
+ host,
3700
+ raw: factory
3701
+ };
3702
+ } finally {
3703
+ const createEditorEnd = markFormulaXPerf("fx:create-kity-editor:total:end");
3704
+ measureFormulaXPerf("fx:create-kity-editor:total", createEditorStart, createEditorEnd);
3705
+ clearFormulaXPerfMarks(createEditorStart, createEditorEnd);
3706
+ }
3707
+ }
3708
+ async function mountKityEditor(container, options = {}) {
3709
+ const editor = await createKityEditor(container, options);
3710
+ const initialLatex = options.initialLatex ?? DEFAULT_LATEX;
3711
+ const shouldFocus = options.autofocus ?? true;
3712
+ editor.ready(function ready() {
3713
+ this.execCommand("render", initialLatex);
3714
+ if (shouldFocus) {
3715
+ this.execCommand("focus");
3716
+ }
3717
+ });
3718
+ return editor;
3719
+ }
3720
+ var FormulaXEditor = class {
3721
+ container;
3722
+ options;
3723
+ handlePromise;
3724
+ constructor(options) {
3725
+ const { el, ...editorOptions } = options;
3726
+ this.container = resolveContainer(el);
3727
+ this.options = editorOptions;
3728
+ this.handlePromise = mountKityEditor(this.container, this.options);
3729
+ }
3730
+ ready(callback) {
3731
+ void this.handlePromise.then((handle) => handle.ready(callback));
3732
+ return this;
3733
+ }
3734
+ async execCommand(name, value) {
3735
+ const handle = await this.handlePromise;
3736
+ handle.execCommand(name, value);
3737
+ return this;
3738
+ }
3739
+ async focus() {
3740
+ const handle = await this.handlePromise;
3741
+ handle.focus();
3742
+ return this;
3743
+ }
3744
+ async destroy() {
3745
+ const handle = await this.handlePromise;
3746
+ handle.destroy();
3747
+ }
3748
+ async getHandle() {
3749
+ return this.handlePromise;
3750
+ }
3751
+ };
3752
+ if (typeof window !== "undefined") {
3753
+ window.FormulaXEditor = FormulaXEditor;
3754
+ }
3755
+
3756
+ // src/plugin.ts
17
3757
  import {
18
3758
  DEFAULT_FORMULA_ATTRIBUTE,
19
3759
  DEFAULT_FORMULA_CLASS,
@@ -22,14 +3762,18 @@ import {
22
3762
  ensureFormulaXBaseStyles
23
3763
  } from "@formulaxjs/renderer";
24
3764
  import { createKityFormulaRenderer } from "@formulaxjs/renderer-kity";
25
- import { ensureFormulaXModalStyles as ensureFormulaXModalStyles2, scheduleFormulaXEditorPreload } from "@formulaxjs/editor";
3765
+ import {
3766
+ ensureFormulaXModalStyles as ensureFormulaXModalStyles2,
3767
+ getFormulaXEditorMessage,
3768
+ scheduleFormulaXEditorPreload
3769
+ } from "@formulaxjs/editor";
26
3770
 
27
3771
  // src/modal.ts
28
3772
  import {
29
- clearFormulaXPerfMarks,
3773
+ clearFormulaXPerfMarks as clearFormulaXPerfMarks2,
30
3774
  ensureFormulaXModalStyles,
31
- markFormulaXPerf,
32
- measureFormulaXPerf,
3775
+ markFormulaXPerf as markFormulaXPerf2,
3776
+ measureFormulaXPerf as measureFormulaXPerf2,
33
3777
  mountFormulaXEditor,
34
3778
  recordFormulaXPerfPoint,
35
3779
  renderFormulaXEditorLoadingState,
@@ -38,7 +3782,7 @@ import {
38
3782
  import { escapeAttribute, escapeHtml } from "@formulaxjs/renderer";
39
3783
  function openFormulaXModal(input) {
40
3784
  recordFormulaXPerfPoint("fx:modal:open:start");
41
- const modalOpenStart = markFormulaXPerf("fx:modal:open:start:scope");
3785
+ const modalOpenStart = markFormulaXPerf2("fx:modal:open:start:scope");
42
3786
  ensureFormulaXModalStyles(document);
43
3787
  const root = document.createElement("div");
44
3788
  root.className = "fx-formula-modal-root";
@@ -62,13 +3806,13 @@ function openFormulaXModal(input) {
62
3806
  `;
63
3807
  document.body.appendChild(root);
64
3808
  document.body.classList.add("fx-formula-modal-open");
65
- const modalDomReadyMark = markFormulaXPerf("fx:modal:dom-ready");
66
- measureFormulaXPerf("fx:modal:dom-ready", modalOpenStart, modalDomReadyMark);
67
- clearFormulaXPerfMarks(modalDomReadyMark);
3809
+ const modalDomReadyMark = markFormulaXPerf2("fx:modal:dom-ready");
3810
+ measureFormulaXPerf2("fx:modal:dom-ready", modalOpenStart, modalDomReadyMark);
3811
+ clearFormulaXPerfMarks2(modalDomReadyMark);
68
3812
  const host = root.querySelector(".fx-formula-editor-host");
69
3813
  if (!host) {
70
3814
  root.remove();
71
- clearFormulaXPerfMarks(modalOpenStart);
3815
+ clearFormulaXPerfMarks2(modalOpenStart);
72
3816
  return Promise.reject(new Error("[FormulaX] CKEditor 5 modal host not found."));
73
3817
  }
74
3818
  renderFormulaXEditorLoadingState(host);
@@ -76,25 +3820,26 @@ function openFormulaXModal(input) {
76
3820
  let mounted = null;
77
3821
  const mountedPromise = waitForFormulaXAnimationFrame().then(() => {
78
3822
  if (closed) {
79
- clearFormulaXPerfMarks(modalOpenStart);
3823
+ clearFormulaXPerfMarks2(modalOpenStart);
80
3824
  return null;
81
3825
  }
82
- const mountStartMark = markFormulaXPerf("fx:modal:editor-mount-start");
83
- measureFormulaXPerf("fx:modal:editor-mount-start", modalOpenStart, mountStartMark);
84
- clearFormulaXPerfMarks(mountStartMark);
3826
+ const mountStartMark = markFormulaXPerf2("fx:modal:editor-mount-start");
3827
+ measureFormulaXPerf2("fx:modal:editor-mount-start", modalOpenStart, mountStartMark);
3828
+ clearFormulaXPerfMarks2(mountStartMark);
85
3829
  const nextMounted = mountFormulaXEditor(host, {
86
3830
  initialLatex: input.initialLatex,
87
3831
  height: input.options.editor.height,
88
3832
  autofocus: input.options.editor.autofocus,
3833
+ locale: input.options.editor.locale,
89
3834
  assets: input.options.editor.assets,
90
3835
  render: {
91
3836
  fontsize: input.options.editor.render.fontsize
92
3837
  }
93
3838
  });
94
3839
  mounted = nextMounted;
95
- const mountedMark = markFormulaXPerf("fx:modal:editor-mounted");
96
- measureFormulaXPerf("fx:modal:editor-mounted", modalOpenStart, mountedMark);
97
- clearFormulaXPerfMarks(mountedMark, modalOpenStart);
3840
+ const mountedMark = markFormulaXPerf2("fx:modal:editor-mounted");
3841
+ measureFormulaXPerf2("fx:modal:editor-mounted", modalOpenStart, mountedMark);
3842
+ clearFormulaXPerfMarks2(mountedMark, modalOpenStart);
98
3843
  queueMicrotask(() => {
99
3844
  if (!closed) {
100
3845
  nextMounted.root.focus();
@@ -102,7 +3847,7 @@ function openFormulaXModal(input) {
102
3847
  });
103
3848
  return nextMounted;
104
3849
  }).catch((error) => {
105
- clearFormulaXPerfMarks(modalOpenStart);
3850
+ clearFormulaXPerfMarks2(modalOpenStart);
106
3851
  throw error;
107
3852
  });
108
3853
  return new Promise((resolve) => {
@@ -163,6 +3908,7 @@ function openFormulaXModal(input) {
163
3908
  var DEFAULT_BUTTON_NAME = "formulaX";
164
3909
  var DEFAULT_MODEL_NAME = "formulaX";
165
3910
  function resolveOptions(options = {}) {
3911
+ const locale = options.editor?.locale ?? DEFAULT_FORMULAX_LOCALE;
166
3912
  return {
167
3913
  name: options.name ?? DEFAULT_MODEL_NAME,
168
3914
  buttonName: options.buttonName ?? DEFAULT_BUTTON_NAME,
@@ -178,15 +3924,16 @@ function resolveOptions(options = {}) {
178
3924
  }),
179
3925
  preload: options.preload ?? "idle",
180
3926
  modal: {
181
- title: options.modal?.title ?? "FormulaX Editor",
182
- insertText: options.modal?.insertText ?? "Insert",
183
- updateText: options.modal?.updateText ?? "Update",
184
- cancelText: options.modal?.cancelText ?? "Cancel",
3927
+ title: options.modal?.title ?? getFormulaXEditorMessage("modal.title", locale),
3928
+ insertText: options.modal?.insertText ?? getFormulaXEditorMessage("modal.insert", locale),
3929
+ updateText: options.modal?.updateText ?? getFormulaXEditorMessage("modal.update", locale),
3930
+ cancelText: options.modal?.cancelText ?? getFormulaXEditorMessage("modal.cancel", locale),
185
3931
  closeOnBackdrop: options.modal?.closeOnBackdrop ?? true
186
3932
  },
187
3933
  editor: {
188
3934
  height: options.editor?.height ?? "100%",
189
3935
  autofocus: options.editor?.autofocus ?? true,
3936
+ locale,
190
3937
  assets: options.editor?.assets ?? {},
191
3938
  render: {
192
3939
  fontsize: options.editor?.render?.fontsize ?? 40