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