@anu3ev/fabric-image-editor 0.7.12 → 0.7.14

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 (2) hide show
  1. package/dist/main.js +1261 -932
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -255,20 +255,20 @@ var M = class {
255
255
  function I(e, t, n, r, i) {
256
256
  e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-12 / 2, -12 / 2, 12, 12, 2), e.fill(), e.stroke(), e.restore();
257
257
  }
258
- function ee(e, t, n, r, i) {
258
+ function L(e, t, n, r, i) {
259
259
  e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-8 / 2, -20 / 2, 8, 20, 100), e.fill(), e.stroke(), e.restore();
260
260
  }
261
- function te(e, t, n, r, i) {
261
+ function ee(e, t, n, r, i) {
262
262
  e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-20 / 2, -8 / 2, 20, 8, 100), e.fill(), e.stroke(), e.restore();
263
263
  }
264
- var L = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ne = new Image();
265
- ne.src = L;
266
- function re(e, t, n, r, i) {
267
- e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = N, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(ne, -16 / 2, -16 / 2, 16, 16), e.restore();
264
+ var R = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", te = new Image();
265
+ te.src = R;
266
+ function ne(e, t, n, r, i) {
267
+ e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = N, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(te, -16 / 2, -16 / 2, 16, 16), e.restore();
268
268
  }
269
269
  //#endregion
270
270
  //#region src/editor/customized-controls/default-controls.ts
271
- var R = {
271
+ var z = {
272
272
  tl: {
273
273
  render: I,
274
274
  sizeX: 12,
@@ -298,41 +298,41 @@ var R = {
298
298
  offsetY: 0
299
299
  },
300
300
  ml: {
301
- render: ee,
301
+ render: L,
302
302
  sizeX: 8,
303
303
  sizeY: 20,
304
304
  offsetX: 0,
305
305
  offsetY: 0
306
306
  },
307
307
  mr: {
308
- render: ee,
308
+ render: L,
309
309
  sizeX: 8,
310
310
  sizeY: 20,
311
311
  offsetX: 0,
312
312
  offsetY: 0
313
313
  },
314
314
  mt: {
315
- render: te,
315
+ render: ee,
316
316
  sizeX: 20,
317
317
  sizeY: 8,
318
318
  offsetX: 0,
319
319
  offsetY: 0
320
320
  },
321
321
  mb: {
322
- render: te,
322
+ render: ee,
323
323
  sizeX: 20,
324
324
  sizeY: 8,
325
325
  offsetX: 0,
326
326
  offsetY: 0
327
327
  },
328
328
  mtr: {
329
- render: re,
329
+ render: ne,
330
330
  sizeX: 32,
331
331
  sizeY: 32,
332
332
  offsetX: 0,
333
333
  offsetY: -32
334
334
  }
335
- }, ie = class t {
335
+ }, re = class t {
336
336
  static wrapWidthControl(e) {
337
337
  if (!e?.actionHandler) return;
338
338
  let t = e.actionHandler;
@@ -342,7 +342,7 @@ var R = {
342
342
  };
343
343
  }
344
344
  static applyControlOverrides(e) {
345
- Object.entries(R).forEach(([t, n]) => {
345
+ Object.entries(z).forEach(([t, n]) => {
346
346
  let r = e[t];
347
347
  r && (Object.assign(r, n), t === "mtr" && (r.cursorStyle = "grab", r.mouseDownHandler = (e, t, n, r) => {
348
348
  let i = t?.target;
@@ -432,7 +432,7 @@ var R = {
432
432
  mr: !0
433
433
  });
434
434
  }
435
- }, z = class e {
435
+ }, B = class e {
436
436
  static {
437
437
  this.registeredFontKeys = /* @__PURE__ */ new Set();
438
438
  }
@@ -585,7 +585,7 @@ var R = {
585
585
  };
586
586
  return Object.entries(e).filter(([, e]) => e != null && `${e}`.length > 0).map(([e, n]) => `${t[e] ?? e}: ${n};`);
587
587
  }
588
- }, B = {
588
+ }, V = {
589
589
  style: {
590
590
  position: "absolute",
591
591
  display: "none",
@@ -687,7 +687,7 @@ var R = {
687
687
  e.layerManager.sendBackwards();
688
688
  }
689
689
  }
690
- }, V = class {
690
+ }, H = class {
691
691
  constructor({ editor: e }) {
692
692
  this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
693
693
  }
@@ -695,22 +695,22 @@ var R = {
695
695
  if (!this.options.showToolbar) return;
696
696
  let e = this.options.toolbar || {};
697
697
  this.config = {
698
- ...B,
698
+ ...V,
699
699
  ...e,
700
700
  style: {
701
- ...B.style,
701
+ ...V.style,
702
702
  ...e.style || {}
703
703
  },
704
704
  btnStyle: {
705
- ...B.btnStyle,
705
+ ...V.btnStyle,
706
706
  ...e.btnStyle || {}
707
707
  },
708
708
  icons: {
709
- ...B.icons,
709
+ ...V.icons,
710
710
  ...e.icons || {}
711
711
  },
712
712
  handlers: {
713
- ...B.handlers,
713
+ ...V.handlers,
714
714
  ...e.handlers || {}
715
715
  }
716
716
  }, this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
@@ -788,7 +788,7 @@ var R = {
788
788
  destroy() {
789
789
  this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
790
790
  }
791
- }, H = {
791
+ }, ie = {
792
792
  position: "absolute",
793
793
  display: "none",
794
794
  background: "#2B2D33",
@@ -807,7 +807,7 @@ var R = {
807
807
  this.isActive = !1, this.currentAngle = 0, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._createDOM(), this._bindEvents();
808
808
  }
809
809
  _createDOM() {
810
- this.el = document.createElement("div"), this.el.className = U, Object.entries(H).forEach(([e, t]) => {
810
+ this.el = document.createElement("div"), this.el.className = U, Object.entries(ie).forEach(([e, t]) => {
811
811
  this.el.style.setProperty(e, t);
812
812
  }), this.canvas.wrapperEl.appendChild(this.el);
813
813
  }
@@ -2807,10 +2807,10 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2807
2807
  width: W,
2808
2808
  height: W,
2809
2809
  internalTextInset: {
2810
- top: .24,
2811
- right: .24,
2812
- bottom: .24,
2813
- left: .24
2810
+ top: .05,
2811
+ right: .05,
2812
+ bottom: .05,
2813
+ left: .05
2814
2814
  }
2815
2815
  },
2816
2816
  {
@@ -2820,13 +2820,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2820
2820
  width: 34,
2821
2821
  height: 34
2822
2822
  }),
2823
- path: "M34 17A17 17 0 1 1 17 0v17z",
2824
- internalTextInset: {
2825
- top: .22,
2826
- right: .26,
2827
- bottom: .14,
2828
- left: .14
2829
- }
2823
+ path: "M34 17A17 17 0 1 1 17 0v17z"
2830
2824
  },
2831
2825
  {
2832
2826
  key: "triangle",
@@ -2837,9 +2831,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2837
2831
  }),
2838
2832
  internalTextInset: {
2839
2833
  top: .34,
2840
- right: .18,
2834
+ right: .24,
2841
2835
  bottom: .12,
2842
- left: .18
2836
+ left: .24
2843
2837
  }
2844
2838
  },
2845
2839
  {
@@ -2873,9 +2867,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2873
2867
  ],
2874
2868
  internalTextInset: {
2875
2869
  top: .3,
2876
- right: .3,
2870
+ right: .24,
2877
2871
  bottom: .3,
2878
- left: .3
2872
+ left: .24
2879
2873
  }
2880
2874
  },
2881
2875
  {
@@ -2909,9 +2903,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2909
2903
  ],
2910
2904
  internalTextInset: {
2911
2905
  top: .24,
2912
- right: .18,
2913
- bottom: .18,
2914
- left: .18
2906
+ right: .08,
2907
+ bottom: .08,
2908
+ left: .08
2915
2909
  }
2916
2910
  },
2917
2911
  {
@@ -2949,9 +2943,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2949
2943
  ],
2950
2944
  internalTextInset: {
2951
2945
  top: .22,
2952
- right: .18,
2953
- bottom: .22,
2954
- left: .18
2946
+ bottom: .22
2955
2947
  }
2956
2948
  },
2957
2949
  {
@@ -3004,9 +2996,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3004
2996
  }
3005
2997
  ],
3006
2998
  internalTextInset: {
3007
- top: .3,
2999
+ top: .38,
3008
3000
  right: .3,
3009
- bottom: .3,
3001
+ bottom: .22,
3010
3002
  left: .3
3011
3003
  }
3012
3004
  },
@@ -3022,10 +3014,10 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3022
3014
  rotation: -Math.PI / 2
3023
3015
  }),
3024
3016
  internalTextInset: {
3025
- top: .24,
3026
- right: .24,
3027
- bottom: .24,
3028
- left: .24
3017
+ top: .05,
3018
+ right: .05,
3019
+ bottom: .05,
3020
+ left: .05
3029
3021
  }
3030
3022
  },
3031
3023
  {
@@ -3059,10 +3051,10 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3059
3051
  "C0 4.477 4.477 0 10 0a9.99 9.99 0 0 1 8 3.999A9.99 9.99 0 0 1 26 0"
3060
3052
  ].join(" "),
3061
3053
  internalTextInset: {
3062
- top: .22,
3063
- right: .22,
3054
+ top: .1,
3055
+ right: .1,
3064
3056
  bottom: .16,
3065
- left: .22
3057
+ left: .1
3066
3058
  }
3067
3059
  },
3068
3060
  {
@@ -3143,10 +3135,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3143
3135
  }
3144
3136
  ],
3145
3137
  internalTextInset: {
3146
- top: .4,
3147
- right: .24,
3148
- bottom: .16,
3149
- left: .24
3138
+ top: .1,
3139
+ right: .35,
3140
+ left: .35
3150
3141
  }
3151
3142
  },
3152
3143
  {
@@ -3187,10 +3178,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3187
3178
  }
3188
3179
  ],
3189
3180
  internalTextInset: {
3190
- top: .2,
3191
- right: .38,
3192
- bottom: .2,
3193
- left: .1
3181
+ top: .3,
3182
+ right: .1,
3183
+ bottom: .3
3194
3184
  }
3195
3185
  },
3196
3186
  {
@@ -3231,10 +3221,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3231
3221
  }
3232
3222
  ],
3233
3223
  internalTextInset: {
3234
- top: .2,
3235
- right: .1,
3236
- bottom: .2,
3237
- left: .38
3224
+ top: .3,
3225
+ bottom: .3,
3226
+ left: .1
3238
3227
  }
3239
3228
  },
3240
3229
  {
@@ -3275,10 +3264,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3275
3264
  }
3276
3265
  ],
3277
3266
  internalTextInset: {
3278
- top: .38,
3279
- right: .2,
3280
- bottom: .1,
3281
- left: .2
3267
+ top: .12,
3268
+ right: .28,
3269
+ left: .28
3282
3270
  }
3283
3271
  },
3284
3272
  {
@@ -3317,10 +3305,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3317
3305
  }
3318
3306
  ],
3319
3307
  internalTextInset: {
3320
- top: .16,
3321
- right: .24,
3322
- bottom: .4,
3323
- left: .24
3308
+ right: .35,
3309
+ bottom: .1,
3310
+ left: .35
3324
3311
  }
3325
3312
  },
3326
3313
  {
@@ -3361,10 +3348,9 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3361
3348
  }
3362
3349
  ],
3363
3350
  internalTextInset: {
3364
- top: .1,
3365
- right: .2,
3366
- bottom: .38,
3367
- left: .2
3351
+ right: .28,
3352
+ bottom: .12,
3353
+ left: .28
3368
3354
  }
3369
3355
  },
3370
3356
  {
@@ -3417,10 +3403,10 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3417
3403
  }
3418
3404
  ],
3419
3405
  internalTextInset: {
3420
- top: .34,
3421
- right: .2,
3422
- bottom: .34,
3423
- left: .2
3406
+ top: .1,
3407
+ right: .3,
3408
+ bottom: .1,
3409
+ left: .3
3424
3410
  }
3425
3411
  },
3426
3412
  {
@@ -3473,10 +3459,10 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3473
3459
  }
3474
3460
  ],
3475
3461
  internalTextInset: {
3476
- top: .2,
3477
- right: .32,
3478
- bottom: .2,
3479
- left: .32
3462
+ top: .3,
3463
+ right: .08,
3464
+ bottom: .3,
3465
+ left: .08
3480
3466
  }
3481
3467
  },
3482
3468
  {
@@ -3508,12 +3494,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3508
3494
  y: 100
3509
3495
  }
3510
3496
  ],
3511
- internalTextInset: {
3512
- top: .14,
3513
- right: .26,
3514
- bottom: .14,
3515
- left: .12
3516
- }
3497
+ internalTextInset: { right: .2 }
3517
3498
  },
3518
3499
  {
3519
3500
  key: "drop",
@@ -3524,10 +3505,10 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3524
3505
  }),
3525
3506
  path: "M0 23C0 11 13 0 13 0s13 11 13 23c0 7.18-5.82 13-13 13S0 30.18 0 23",
3526
3507
  internalTextInset: {
3527
- top: .28,
3528
- right: .26,
3529
- bottom: .18,
3530
- left: .26
3508
+ top: .24,
3509
+ right: .1,
3510
+ bottom: .1,
3511
+ left: .1
3531
3512
  }
3532
3513
  },
3533
3514
  {
@@ -3621,12 +3602,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3621
3602
  y: 100
3622
3603
  }
3623
3604
  ],
3624
- internalTextInset: {
3625
- top: .16,
3626
- right: .18,
3627
- bottom: .28,
3628
- left: .18
3629
- }
3605
+ internalTextInset: { bottom: .22 }
3630
3606
  },
3631
3607
  {
3632
3608
  key: "gear",
@@ -3640,10 +3616,10 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3640
3616
  rotation: -Math.PI / 2
3641
3617
  }),
3642
3618
  internalTextInset: {
3643
- top: .28,
3644
- right: .28,
3645
- bottom: .28,
3646
- left: .28
3619
+ top: .1,
3620
+ right: .1,
3621
+ bottom: .1,
3622
+ left: .1
3647
3623
  }
3648
3624
  },
3649
3625
  {
@@ -3653,10 +3629,8 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3653
3629
  height: W,
3654
3630
  path: "M24 6 H76 L94 24 V76 L76 94 H24 L6 76 V24 Z",
3655
3631
  internalTextInset: {
3656
- top: .24,
3657
- right: .24,
3658
- bottom: .24,
3659
- left: .24
3632
+ top: .1,
3633
+ bottom: .1
3660
3634
  }
3661
3635
  },
3662
3636
  {
@@ -3686,12 +3660,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3686
3660
  y: 100
3687
3661
  }
3688
3662
  ],
3689
- internalTextInset: {
3690
- top: .2,
3691
- right: .22,
3692
- bottom: .34,
3693
- left: .22
3694
- }
3663
+ internalTextInset: { bottom: .24 }
3695
3664
  },
3696
3665
  {
3697
3666
  key: "tag",
@@ -3699,12 +3668,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3699
3668
  width: W,
3700
3669
  height: 130,
3701
3670
  path: "M4 20 L64 20 L96 50 L64 80 L4 80 Z",
3702
- internalTextInset: {
3703
- top: .24,
3704
- right: .34,
3705
- bottom: .24,
3706
- left: .18
3707
- }
3671
+ internalTextInset: { right: .28 }
3708
3672
  },
3709
3673
  {
3710
3674
  key: "moon",
@@ -3719,9 +3683,8 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3719
3683
  ].join(" "),
3720
3684
  internalTextInset: {
3721
3685
  top: .28,
3722
- right: .34,
3723
- bottom: .28,
3724
- left: .2
3686
+ right: .5,
3687
+ bottom: .28
3725
3688
  }
3726
3689
  }
3727
3690
  ], ot = "circle", st = "center", ct = "middle", lt = {};
@@ -4367,51 +4330,124 @@ function en({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
4367
4330
  }
4368
4331
  //#endregion
4369
4332
  //#region src/editor/shape-manager/layout/shape-layout.ts
4370
- var q = 1, tn = .5, nn = 8, rn = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, expandShapeHeightToFitText: l = !0, changedPadding: u }) => {
4371
- let d = zt({ padding: s }), f = Rt({ padding: c }), p = Math.max(q, e.shapeManualBaseWidth ?? r), m = Math.max(q, e.shapeManualBaseHeight ?? i), h = Math.max(q, i), g = Math.max(q, r), _ = en({
4372
- text: n,
4373
- width: g,
4374
- height: h,
4375
- padding: d,
4376
- internalShapeTextInset: f,
4377
- expandShapeHeightToFitText: l,
4378
- changedPadding: u,
4379
- measureTextboxHeightForFrame: pn,
4380
- resolveMinimumTextFrameWidth: mn
4333
+ var q = 1, tn = .5, nn = 8, rn = 20, an = 16;
4334
+ function on({ text: e, alignV: t, width: n, height: r, appliedPadding: i, appliedUserPadding: a }) {
4335
+ let { frame: o, splitByGrapheme: s, textTop: c } = pn({
4336
+ text: e,
4337
+ width: n,
4338
+ height: r,
4339
+ alignV: t,
4340
+ padding: i
4381
4341
  });
4382
- for (let e = 0; e < nn; e += 1) {
4383
- let e = Math.max(g, _.requiredWidth);
4384
- if (e <= g + tn) break;
4385
- g = e, _ = en({
4386
- text: n,
4387
- width: g,
4388
- height: h,
4389
- padding: d,
4390
- internalShapeTextInset: f,
4391
- expandShapeHeightToFitText: l,
4392
- changedPadding: u,
4393
- measureTextboxHeightForFrame: pn,
4394
- resolveMinimumTextFrameWidth: mn
4342
+ return {
4343
+ width: n,
4344
+ height: r,
4345
+ appliedPadding: i,
4346
+ appliedUserPadding: a,
4347
+ frame: o,
4348
+ splitByGrapheme: s,
4349
+ textTop: c
4350
+ };
4351
+ }
4352
+ var sn = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, preserveAspectRatio: s, shapeTextAutoExpandEnabled: c, montageAreaWidth: l, expandShapeHeightToFitText: u = !0, changedPadding: d }) => {
4353
+ let { width: f, height: p, appliedPadding: m, appliedUserPadding: h } = s ? un({
4354
+ text: e,
4355
+ width: t,
4356
+ height: n,
4357
+ padding: i,
4358
+ internalShapeTextInset: a,
4359
+ resolveInternalShapeTextInset: o,
4360
+ shapeTextAutoExpandEnabled: c,
4361
+ montageAreaWidth: l,
4362
+ expandShapeHeightToFitText: u,
4363
+ changedPadding: d
4364
+ }) : yn({
4365
+ text: e,
4366
+ width: t,
4367
+ height: n,
4368
+ padding: i,
4369
+ internalShapeTextInset: a,
4370
+ resolveInternalShapeTextInset: o,
4371
+ expandShapeHeightToFitText: u,
4372
+ changedPadding: d
4373
+ });
4374
+ return on({
4375
+ text: e,
4376
+ alignV: r,
4377
+ width: f,
4378
+ height: p,
4379
+ appliedPadding: m,
4380
+ appliedUserPadding: h
4381
+ });
4382
+ }, cn = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, expandShapeHeightToFitText: s = !0, changedPadding: c }) => {
4383
+ let l = zt({ padding: i }), u = Rt({ padding: a }), d = Math.max(q, t), f = Math.max(q, n), p = en({
4384
+ text: e,
4385
+ width: d,
4386
+ height: f,
4387
+ padding: l,
4388
+ internalShapeTextInset: vn({
4389
+ width: d,
4390
+ height: f,
4391
+ internalShapeTextInset: u,
4392
+ resolveInternalShapeTextInset: o
4393
+ }),
4394
+ expandShapeHeightToFitText: s,
4395
+ changedPadding: c,
4396
+ measureTextboxHeightForFrame: Tn,
4397
+ resolveMinimumTextFrameWidth: En
4398
+ });
4399
+ for (let t = 0; t < nn; t += 1) {
4400
+ let t = Math.max(f, p.requiredHeight);
4401
+ if (t <= f + tn) break;
4402
+ f = t, p = en({
4403
+ text: e,
4404
+ width: d,
4405
+ height: f,
4406
+ padding: l,
4407
+ internalShapeTextInset: vn({
4408
+ width: d,
4409
+ height: f,
4410
+ internalShapeTextInset: u,
4411
+ resolveInternalShapeTextInset: o
4412
+ }),
4413
+ expandShapeHeightToFitText: s,
4414
+ changedPadding: c,
4415
+ measureTextboxHeightForFrame: Tn,
4416
+ resolveMinimumTextFrameWidth: En
4395
4417
  });
4396
4418
  }
4397
- let { appliedPadding: v, appliedUserPadding: y, requiredHeight: b } = _, x = Math.max(q, b);
4398
- xt({
4399
- shape: t,
4400
- width: g,
4401
- height: x,
4402
- rounding: e.shapeRounding,
4403
- strokeWidth: e.shapeStrokeWidth
4419
+ return on({
4420
+ text: e,
4421
+ alignV: r,
4422
+ width: d,
4423
+ height: f,
4424
+ appliedPadding: p.appliedPadding,
4425
+ appliedUserPadding: p.appliedUserPadding
4404
4426
  });
4405
- let { frame: S, splitByGrapheme: C, textTop: w } = sn({
4427
+ }, ln = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, shapeTextAutoExpandEnabled: d, montageAreaWidth: f, expandShapeHeightToFitText: p = !0, changedPadding: m }) => {
4428
+ let h = Math.max(q, e.shapeManualBaseWidth ?? r), g = Math.max(q, e.shapeManualBaseHeight ?? i), { width: _, height: v, appliedUserPadding: y, frame: b, splitByGrapheme: x, textTop: S } = sn({
4406
4429
  text: n,
4407
- width: g,
4408
- height: x,
4430
+ width: r,
4431
+ height: i,
4409
4432
  alignV: o,
4410
- padding: v
4433
+ padding: s,
4434
+ internalShapeTextInset: c,
4435
+ resolveInternalShapeTextInset: l,
4436
+ preserveAspectRatio: u,
4437
+ shapeTextAutoExpandEnabled: d ?? e.shapeTextAutoExpand !== !1,
4438
+ montageAreaWidth: f,
4439
+ expandShapeHeightToFitText: p,
4440
+ changedPadding: m
4411
4441
  });
4412
- n.set({
4442
+ xt({
4443
+ shape: t,
4444
+ width: _,
4445
+ height: v,
4446
+ rounding: e.shapeRounding,
4447
+ strokeWidth: e.shapeStrokeWidth
4448
+ }), n.set({
4413
4449
  autoExpand: !1,
4414
- width: S.width,
4450
+ width: b.width,
4415
4451
  textAlign: a,
4416
4452
  scaleX: 1,
4417
4453
  scaleY: 1,
@@ -4420,56 +4456,159 @@ var q = 1, tn = .5, nn = 8, rn = ({ group: e, shape: t, text: n, width: r, heigh
4420
4456
  skewY: 0,
4421
4457
  flipX: !1,
4422
4458
  flipY: !1,
4423
- left: S.left,
4424
- top: w,
4459
+ left: b.left,
4460
+ top: S,
4425
4461
  originX: "left",
4426
4462
  originY: "top",
4427
- splitByGrapheme: C
4428
- }), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth = g, e.shapeBaseHeight = x, e.shapeManualBaseWidth = p, e.shapeManualBaseHeight = m, e.shapePaddingTop = y.top, e.shapePaddingRight = y.right, e.shapePaddingBottom = y.bottom, e.shapePaddingLeft = y.left, e.shapeAlignHorizontal = a, e.shapeAlignVertical = o, e.set({
4429
- width: g,
4430
- height: x,
4463
+ splitByGrapheme: x
4464
+ }), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth = _, e.shapeBaseHeight = v, e.shapeManualBaseWidth = h, e.shapeManualBaseHeight = g, e.shapePaddingTop = y.top, e.shapePaddingRight = y.right, e.shapePaddingBottom = y.bottom, e.shapePaddingLeft = y.left, e.shapeAlignHorizontal = a, e.shapeAlignVertical = o, e.set({
4465
+ width: _,
4466
+ height: v,
4431
4467
  scaleX: 1,
4432
4468
  scaleY: 1
4433
4469
  }), e.set("dirty", !0), e.setCoords();
4434
- }, an = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i }) => {
4435
- let a = Math.max(q, t), o = Math.max(q, n);
4436
- if (!ln({ text: e })) return o;
4437
- let s = Number.isFinite(i) && i > 0 ? Math.max(q, i) : Math.max(a, o), c = Rt({ padding: r }), l = Math.max(o, s), u = qt({
4438
- width: l,
4439
- padding: c
4440
- }), d = l, f = fn({
4470
+ };
4471
+ function un({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, shapeTextAutoExpandEnabled: o = !0, montageAreaWidth: s, expandShapeHeightToFitText: c = !0, changedPadding: l }) {
4472
+ let u = Math.max(q, t), d = Math.max(q, n), f = Number.isFinite(s) && (s ?? 0) > 0 ? Math.max(q, s ?? q) : null;
4473
+ if (!hn({ text: e })) return yn({
4441
4474
  text: e,
4442
- frameWidth: u
4475
+ width: u,
4476
+ height: d,
4477
+ padding: r,
4478
+ internalShapeTextInset: i,
4479
+ resolveInternalShapeTextInset: a,
4480
+ expandShapeHeightToFitText: c,
4481
+ changedPadding: l
4443
4482
  });
4444
- if (f.hasWrappedLines) return d;
4445
- let p = Math.max(q, f.longestLineWidth), m = Math.max(q, p + c.left + c.right), h = Math.min(d, Math.max(o, m));
4446
- for (let t = 0; t < nn; t += 1) {
4447
- let t = qt({
4448
- width: h,
4449
- padding: c
4450
- }), n = fn({
4483
+ let p = d / u, m = ({ width: t }) => {
4484
+ let n = Math.max(q, t * p), o = yn({
4451
4485
  text: e,
4452
- frameWidth: t
4453
- }), r = t >= p - tn;
4454
- if (!n.hasWrappedLines && r) return h;
4455
- if (h >= d - tn) return d;
4456
- let i = n.hasWrappedLines ? Math.max(m + 1, h + 1) : p;
4457
- h = Math.min(d, Math.max(h + 1, n.hasWrappedLines ? i : m));
4458
- }
4459
- return h;
4460
- }, on = ({ text: e, padding: t }) => {
4461
- if (!ln({ text: e })) return q;
4462
- let n = Rt({ padding: t });
4463
- return mn({ text: e }) + n.left + n.right;
4464
- }, sn = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
4465
- let a = un({
4486
+ width: t,
4487
+ height: n,
4488
+ padding: r,
4489
+ internalShapeTextInset: i,
4490
+ resolveInternalShapeTextInset: a,
4491
+ expandShapeHeightToFitText: c,
4492
+ changedPadding: l
4493
+ });
4494
+ return {
4495
+ candidateHeight: n,
4496
+ frameWidth: qt({
4497
+ width: t,
4498
+ padding: o.appliedPadding
4499
+ }),
4500
+ layoutResolution: o
4501
+ };
4502
+ }, h = ({ candidateWidth: e, candidateHeight: t, layoutResolution: n }) => !(n.width > e + tn || n.height > t + tn);
4503
+ if (!o) {
4504
+ let e = ({ width: e }) => {
4505
+ let { candidateHeight: t, layoutResolution: n } = m({ width: e });
4506
+ return h({
4507
+ candidateWidth: e,
4508
+ candidateHeight: t,
4509
+ layoutResolution: n
4510
+ });
4511
+ }, t = f ? Math.max(u, f) : u;
4512
+ e({ width: t }) || (t = bn({
4513
+ minimumWidth: t,
4514
+ isWidthValid: e
4515
+ }));
4516
+ let { layoutResolution: n } = m({ width: xn({
4517
+ minimumWidth: u,
4518
+ maximumWidth: t,
4519
+ isWidthValid: e
4520
+ }) });
4521
+ return n;
4522
+ }
4523
+ let g = ({ width: t, requiredFrameWidth: n }) => {
4524
+ let { candidateHeight: r, frameWidth: i, layoutResolution: a } = m({ width: t });
4525
+ return !h({
4526
+ candidateWidth: t,
4527
+ candidateHeight: r,
4528
+ layoutResolution: a
4529
+ }) || n !== void 0 && i < n - tn ? !1 : !wn({
4530
+ text: e,
4531
+ frameWidth: i
4532
+ }).hasWrappedLines;
4533
+ }, _ = f ? Math.max(u, f) : bn({
4534
+ minimumWidth: u,
4535
+ isWidthValid: ({ width: e }) => g({ width: e })
4536
+ }), v = m({ width: _ }), y = wn({
4537
+ text: e,
4538
+ frameWidth: v.frameWidth
4539
+ });
4540
+ if (y.hasWrappedLines) return v.layoutResolution;
4541
+ let b = Math.max(q, y.longestLineWidth), { layoutResolution: x } = m({ width: xn({
4542
+ minimumWidth: u,
4543
+ maximumWidth: _,
4544
+ isWidthValid: ({ width: e }) => g({
4545
+ width: e,
4546
+ requiredFrameWidth: b
4547
+ })
4548
+ }) });
4549
+ return x;
4550
+ }
4551
+ var dn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i, resolvePaddingForWidth: a }) => {
4552
+ let o = Math.max(q, t), s = Math.max(q, n);
4553
+ if (!hn({ text: e })) return s;
4554
+ let c = Math.max(s, Number.isFinite(i) && i > 0 ? Math.max(q, i) : Math.max(o, s)), l = qt({
4555
+ width: c,
4556
+ padding: gn({
4557
+ width: c,
4558
+ padding: r,
4559
+ resolvePaddingForWidth: a
4560
+ })
4561
+ }), u = c, d = wn({
4562
+ text: e,
4563
+ frameWidth: l
4564
+ });
4565
+ if (d.hasWrappedLines) return u;
4566
+ let f = Math.max(q, d.longestLineWidth);
4567
+ return xn({
4568
+ minimumWidth: s,
4569
+ maximumWidth: u,
4570
+ isWidthValid: ({ width: t }) => {
4571
+ let n = qt({
4572
+ width: t,
4573
+ padding: gn({
4574
+ width: t,
4575
+ padding: r,
4576
+ resolvePaddingForWidth: a
4577
+ })
4578
+ });
4579
+ return n < f - tn ? !1 : !wn({
4580
+ text: e,
4581
+ frameWidth: n
4582
+ }).hasWrappedLines;
4583
+ }
4584
+ });
4585
+ }, fn = ({ text: e, padding: t, resolvePaddingForWidth: n }) => {
4586
+ if (!hn({ text: e })) return q;
4587
+ let r = En({ text: e }), i = Math.max(q, r), a = ({ width: e }) => qt({
4588
+ width: e,
4589
+ padding: gn({
4590
+ width: e,
4591
+ padding: t,
4592
+ resolvePaddingForWidth: n
4593
+ })
4594
+ }) >= r - tn;
4595
+ return xn({
4596
+ minimumWidth: i,
4597
+ maximumWidth: bn({
4598
+ minimumWidth: i,
4599
+ isWidthValid: a
4600
+ }),
4601
+ isWidthValid: a
4602
+ });
4603
+ }, pn = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
4604
+ let a = Sn({
4466
4605
  width: Math.max(q, t),
4467
4606
  height: Math.max(q, n),
4468
4607
  padding: Rt({ padding: i })
4469
- }), o = _n({
4608
+ }), o = kn({
4470
4609
  text: e,
4471
4610
  frameWidth: a.width
4472
- }), s = pn({
4611
+ }), s = Tn({
4473
4612
  text: e,
4474
4613
  frameWidth: a.width,
4475
4614
  splitByGrapheme: o
@@ -4477,29 +4616,118 @@ var q = 1, tn = .5, nn = 8, rn = ({ group: e, shape: t, text: n, width: r, heigh
4477
4616
  return {
4478
4617
  frame: a,
4479
4618
  splitByGrapheme: o,
4480
- textTop: gn({
4619
+ textTop: On({
4481
4620
  alignV: r,
4482
4621
  frameHeight: a.height,
4483
4622
  frameTop: a.top,
4484
4623
  textHeight: s
4485
4624
  })
4486
4625
  };
4487
- }, cn = ({ text: e, width: t, height: n, padding: r }) => {
4488
- let i = Math.max(q, n);
4489
- if (!ln({ text: e })) return i;
4490
- let a = Math.max(q, t), o = Rt({ padding: r }), s = pn({
4491
- text: e,
4492
- frameWidth: qt({
4493
- width: a,
4494
- padding: o
4495
- })
4496
- });
4497
- return Math.max(i, s + o.top + o.bottom);
4626
+ }, mn = ({ text: e, width: t, height: n, padding: r, resolvePaddingForSize: i }) => {
4627
+ let a = Math.max(q, n);
4628
+ if (!hn({ text: e })) return a;
4629
+ let o = Math.max(q, t), s = a;
4630
+ for (let t = 0; t < nn; t += 1) {
4631
+ let t = _n({
4632
+ width: o,
4633
+ height: s,
4634
+ padding: r,
4635
+ resolvePaddingForSize: i
4636
+ }), n = Tn({
4637
+ text: e,
4638
+ frameWidth: qt({
4639
+ width: o,
4640
+ padding: t
4641
+ })
4642
+ }), c = Math.max(a, n + t.top + t.bottom);
4643
+ if (c <= s + tn) return c;
4644
+ s = c;
4645
+ }
4646
+ return s;
4498
4647
  };
4499
- function ln({ text: e }) {
4648
+ function hn({ text: e }) {
4500
4649
  return (e.text ?? "").trim().length > 0;
4501
4650
  }
4502
- function un({ width: e, height: t, padding: n }) {
4651
+ function gn({ width: e, padding: t, resolvePaddingForWidth: n }) {
4652
+ return Rt(n ? { padding: n({ width: Math.max(q, e) }) } : { padding: t });
4653
+ }
4654
+ function _n({ width: e, height: t, padding: n, resolvePaddingForSize: r }) {
4655
+ return Rt(r ? { padding: r({
4656
+ width: Math.max(q, e),
4657
+ height: Math.max(q, t)
4658
+ }) } : { padding: n });
4659
+ }
4660
+ function vn({ width: e, height: t, internalShapeTextInset: n, resolveInternalShapeTextInset: r }) {
4661
+ return Rt(r ? { padding: r({
4662
+ width: Math.max(q, e),
4663
+ height: Math.max(q, t)
4664
+ }) } : { padding: n });
4665
+ }
4666
+ function yn({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, expandShapeHeightToFitText: o = !0, changedPadding: s }) {
4667
+ let c = zt({ padding: r }), l = Rt({ padding: i }), u = Math.max(q, t), d = Math.max(q, n), f = en({
4668
+ text: e,
4669
+ width: u,
4670
+ height: d,
4671
+ padding: c,
4672
+ internalShapeTextInset: vn({
4673
+ width: u,
4674
+ height: d,
4675
+ internalShapeTextInset: l,
4676
+ resolveInternalShapeTextInset: a
4677
+ }),
4678
+ expandShapeHeightToFitText: o,
4679
+ changedPadding: s,
4680
+ measureTextboxHeightForFrame: Tn,
4681
+ resolveMinimumTextFrameWidth: En
4682
+ });
4683
+ for (let t = 0; t < nn; t += 1) {
4684
+ let t = Math.max(u, f.requiredWidth), n = Math.max(d, f.requiredHeight);
4685
+ if (t <= u + tn && n <= d + tn) break;
4686
+ u = t, d = n, f = en({
4687
+ text: e,
4688
+ width: u,
4689
+ height: d,
4690
+ padding: c,
4691
+ internalShapeTextInset: vn({
4692
+ width: u,
4693
+ height: d,
4694
+ internalShapeTextInset: l,
4695
+ resolveInternalShapeTextInset: a
4696
+ }),
4697
+ expandShapeHeightToFitText: o,
4698
+ changedPadding: s,
4699
+ measureTextboxHeightForFrame: Tn,
4700
+ resolveMinimumTextFrameWidth: En
4701
+ });
4702
+ }
4703
+ return {
4704
+ width: u,
4705
+ height: d,
4706
+ appliedPadding: f.appliedPadding,
4707
+ appliedUserPadding: f.appliedUserPadding
4708
+ };
4709
+ }
4710
+ function bn({ minimumWidth: e, isWidthValid: t }) {
4711
+ let n = Math.max(q, e);
4712
+ if (t({ width: n })) return n;
4713
+ for (let e = 0; e < an; e += 1) if (n = Math.max(n + 1, n * 2), t({ width: n })) return n;
4714
+ return n;
4715
+ }
4716
+ function xn({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
4717
+ let r = Math.max(q, e), i = Math.max(r, t);
4718
+ if (n({ width: r })) return r;
4719
+ if (!n({ width: i })) return i;
4720
+ for (let e = 0; e < rn && !(i - r <= tn); e += 1) {
4721
+ let e = r + (i - r) / 2;
4722
+ if (n({ width: e })) {
4723
+ i = e;
4724
+ continue;
4725
+ }
4726
+ r = e;
4727
+ }
4728
+ return i;
4729
+ }
4730
+ function Sn({ width: e, height: t, padding: n }) {
4503
4731
  let r = Math.max(0, n.left), i = Math.max(0, n.right), a = Math.max(0, n.top), o = Math.max(0, n.bottom);
4504
4732
  return {
4505
4733
  left: -e / 2 + r,
@@ -4508,7 +4736,7 @@ function un({ width: e, height: t, padding: n }) {
4508
4736
  height: Math.max(q, t - a - o)
4509
4737
  };
4510
4738
  }
4511
- function dn({ text: e }) {
4739
+ function Cn({ text: e }) {
4512
4740
  let { height: t } = e;
4513
4741
  if (typeof t == "number" && Number.isFinite(t)) return t;
4514
4742
  if (typeof e.calcTextHeight == "function") {
@@ -4517,18 +4745,18 @@ function dn({ text: e }) {
4517
4745
  }
4518
4746
  return q;
4519
4747
  }
4520
- function fn({ text: e, frameWidth: t }) {
4521
- let n = yn({ text: e }), r = _n({
4748
+ function wn({ text: e, frameWidth: t }) {
4749
+ let n = jn({ text: e }), r = kn({
4522
4750
  text: e,
4523
4751
  frameWidth: t
4524
- }), i = Sn({ text: e });
4752
+ }), i = Pn({ text: e });
4525
4753
  e.set({
4526
4754
  autoExpand: !1,
4527
4755
  width: Math.max(q, t),
4528
4756
  splitByGrapheme: r
4529
4757
  }), e.initDimensions();
4530
- let a = bn({ text: e }) > n, o = Math.ceil(vn({ text: e }));
4531
- return Cn({
4758
+ let a = Mn({ text: e }) > n, o = Math.ceil(An({ text: e }));
4759
+ return Fn({
4532
4760
  text: e,
4533
4761
  state: i
4534
4762
  }), {
@@ -4536,8 +4764,8 @@ function fn({ text: e, frameWidth: t }) {
4536
4764
  longestLineWidth: o
4537
4765
  };
4538
4766
  }
4539
- function pn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4540
- let r = Sn({ text: e }), i = n ?? _n({
4767
+ function Tn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4768
+ let r = Pn({ text: e }), i = n ?? kn({
4541
4769
  text: e,
4542
4770
  frameWidth: t
4543
4771
  });
@@ -4546,71 +4774,71 @@ function pn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4546
4774
  width: Math.max(q, t),
4547
4775
  splitByGrapheme: i
4548
4776
  }), e.initDimensions();
4549
- let a = dn({ text: e });
4550
- return Cn({
4777
+ let a = Cn({ text: e });
4778
+ return Fn({
4551
4779
  text: e,
4552
4780
  state: r
4553
4781
  }), a;
4554
4782
  }
4555
- function mn({ text: e }) {
4556
- let t = hn({
4783
+ function En({ text: e }) {
4784
+ let t = Dn({
4557
4785
  text: e,
4558
4786
  frameWidth: q,
4559
4787
  splitByGrapheme: !0
4560
4788
  });
4561
4789
  return Math.max(q, t);
4562
4790
  }
4563
- function hn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4564
- let r = Sn({ text: e });
4791
+ function Dn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4792
+ let r = Pn({ text: e });
4565
4793
  e.set({
4566
4794
  autoExpand: !1,
4567
4795
  width: Math.max(q, t),
4568
4796
  splitByGrapheme: n
4569
4797
  }), e.initDimensions();
4570
- let i = vn({ text: e });
4571
- return Cn({
4798
+ let i = An({ text: e });
4799
+ return Fn({
4572
4800
  text: e,
4573
4801
  state: r
4574
4802
  }), i;
4575
4803
  }
4576
- function gn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
4804
+ function On({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
4577
4805
  let i = Math.max(0, t - r);
4578
4806
  return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
4579
4807
  }
4580
- function _n({ text: e, frameWidth: t }) {
4581
- let n = Math.max(q, t), r = Sn({ text: e });
4808
+ function kn({ text: e, frameWidth: t }) {
4809
+ let n = Math.max(q, t), r = Pn({ text: e });
4582
4810
  e.set({
4583
4811
  autoExpand: !1,
4584
4812
  width: n,
4585
4813
  splitByGrapheme: !1
4586
4814
  }), e.initDimensions();
4587
- let i = wn({ text: e }) > n + tn;
4588
- return Cn({
4815
+ let i = In({ text: e }) > n + tn;
4816
+ return Fn({
4589
4817
  text: e,
4590
4818
  state: r
4591
4819
  }), i;
4592
4820
  }
4593
- function vn({ text: e }) {
4594
- let t = bn({ text: e });
4595
- if (t > 0) return xn({
4821
+ function An({ text: e }) {
4822
+ let t = Mn({ text: e });
4823
+ if (t > 0) return Nn({
4596
4824
  text: e,
4597
4825
  lineCount: t
4598
4826
  });
4599
4827
  let n = e.text ?? "";
4600
- return xn({
4828
+ return Nn({
4601
4829
  text: e,
4602
4830
  lineCount: Math.max(n.split("\n").length, 1)
4603
4831
  });
4604
4832
  }
4605
- function yn({ text: e }) {
4833
+ function jn({ text: e }) {
4606
4834
  let t = e.text ?? "";
4607
4835
  return Math.max(t.split("\n").length, 1);
4608
4836
  }
4609
- function bn({ text: e }) {
4837
+ function Mn({ text: e }) {
4610
4838
  let t = e;
4611
4839
  return Array.isArray(t.textLines) ? t.textLines.length : 0;
4612
4840
  }
4613
- function xn({ text: e, lineCount: t }) {
4841
+ function Nn({ text: e, lineCount: t }) {
4614
4842
  let n = q;
4615
4843
  for (let r = 0; r < t; r += 1) {
4616
4844
  let t = e.getLineWidth(r);
@@ -4618,7 +4846,7 @@ function xn({ text: e, lineCount: t }) {
4618
4846
  }
4619
4847
  return n;
4620
4848
  }
4621
- function Sn({ text: e }) {
4849
+ function Pn({ text: e }) {
4622
4850
  let { autoExpand: t, splitByGrapheme: n, width: r } = e;
4623
4851
  return {
4624
4852
  autoExpand: t,
@@ -4626,23 +4854,23 @@ function Sn({ text: e }) {
4626
4854
  width: typeof r == "number" ? r : void 0
4627
4855
  };
4628
4856
  }
4629
- function Cn({ text: e, state: t }) {
4857
+ function Fn({ text: e, state: t }) {
4630
4858
  let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
4631
4859
  n !== void 0 && (a.autoExpand = n), r !== void 0 && (a.splitByGrapheme = r), typeof i == "number" && (a.width = i), Object.keys(a).length > 0 && (e.set(a), e.initDimensions());
4632
4860
  }
4633
- function wn({ text: e }) {
4861
+ function In({ text: e }) {
4634
4862
  let { dynamicMinWidth: t } = e;
4635
4863
  return typeof t == "number" && Number.isFinite(t) ? t : 0;
4636
4864
  }
4637
4865
  //#endregion
4638
4866
  //#region src/editor/shape-manager/shape-runtime.ts
4639
- var Tn = ({ group: e }) => {
4867
+ var Ln = ({ group: e }) => {
4640
4868
  let t = e;
4641
4869
  typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
4642
4870
  interactive: !0,
4643
4871
  subTargetCheck: !0
4644
4872
  });
4645
- }, En = ({ text: e }) => {
4873
+ }, Rn = ({ text: e }) => {
4646
4874
  let t = !!(e.locked || e.group?.locked);
4647
4875
  e.set({
4648
4876
  hasBorders: !1,
@@ -4655,7 +4883,7 @@ var Tn = ({ group: e }) => {
4655
4883
  autoExpand: !1,
4656
4884
  shapeNodeType: "text"
4657
4885
  }), e.setCoords();
4658
- }, Dn = ({ group: e }) => {
4886
+ }, zn = ({ group: e }) => {
4659
4887
  let { layoutManager: t } = e;
4660
4888
  if (!t || typeof t.unsubscribeTargets != "function") return;
4661
4889
  let n = e.getObjects();
@@ -4663,7 +4891,7 @@ var Tn = ({ group: e }) => {
4663
4891
  target: e,
4664
4892
  targets: n
4665
4893
  });
4666
- }, On = ({ group: e }) => {
4894
+ }, Bn = ({ group: e }) => {
4667
4895
  let t = e.getObjects();
4668
4896
  for (let e = 0; e < t.length; e += 1) {
4669
4897
  let n = t[e];
@@ -4674,23 +4902,23 @@ var Tn = ({ group: e }) => {
4674
4902
  if (n instanceof _) return n;
4675
4903
  }
4676
4904
  return null;
4677
- }, kn = [
4905
+ }, Vn = [
4678
4906
  "tl",
4679
4907
  "tr",
4680
4908
  "bl",
4681
4909
  "br"
4682
- ], An = ({ transform: e }) => {
4910
+ ], Hn = ({ transform: e }) => {
4683
4911
  let { originX: t, originY: n } = e;
4684
4912
  return (t === "center" || t === .5) && (n === "center" || n === .5);
4685
- }, jn = ({ transform: e, x: t, y: n }) => {
4913
+ }, Un = ({ transform: e, x: t, y: n }) => {
4686
4914
  let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i, s = b.getLocalPoint(r, r.originX, r.originY, t, n), c = Math.sign(s.x || r.signX || 1), l = Math.sign(s.y || r.signY || 1);
4687
4915
  r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
4688
4916
  let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
4689
- An({ transform: r }) && (d *= 2, f *= 2);
4917
+ Hn({ transform: r }) && (d *= 2, f *= 2);
4690
4918
  let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
4691
4919
  return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
4692
- }, Mn = () => {
4693
- let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => jn({
4920
+ }, Wn = () => {
4921
+ let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => Un({
4694
4922
  transform: t,
4695
4923
  x: n,
4696
4924
  y: r
@@ -4706,31 +4934,31 @@ var Tn = ({ group: e }) => {
4706
4934
  a.uniformScaling = s;
4707
4935
  }
4708
4936
  };
4709
- }, Nn = ({ control: e }) => {
4937
+ }, Gn = ({ control: e }) => {
4710
4938
  let t = new r({
4711
4939
  ...e,
4712
- actionHandler: Mn()
4940
+ actionHandler: Wn()
4713
4941
  });
4714
4942
  return t.shapeFreeScaleCornerControl = !0, t;
4715
- }, Pn = ({ group: e }) => {
4943
+ }, Kn = ({ group: e }) => {
4716
4944
  let t = { ...e.controls };
4717
- kn.forEach((n) => {
4945
+ Vn.forEach((n) => {
4718
4946
  let r = e.controls[n];
4719
- r && (r.shapeFreeScaleCornerControl || (t[n] = Nn({ control: r })));
4947
+ r && (r.shapeFreeScaleCornerControl || (t[n] = Gn({ control: r })));
4720
4948
  }), e.controls = t;
4721
- }, Fn = "shape-group";
4722
- function In() {
4949
+ }, qn = "shape-group";
4950
+ function Jn() {
4723
4951
  return { performLayout() {} };
4724
4952
  }
4725
- function Ln({ layoutManager: e }) {
4953
+ function Yn({ layoutManager: e }) {
4726
4954
  let t = y.getClass("layoutManager");
4727
4955
  if (!e) return new t();
4728
4956
  let { strategy: n, type: r } = e, i = y.getClass(r);
4729
4957
  return n ? new i(new (y.getClass(n))()) : new i();
4730
4958
  }
4731
- var Rn = class e extends l {
4959
+ var Xn = class e extends l {
4732
4960
  static {
4733
- this.type = Fn;
4961
+ this.type = qn;
4734
4962
  }
4735
4963
  constructor(e = [], t = {}) {
4736
4964
  let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a, ...o } = t;
@@ -4753,17 +4981,17 @@ var Rn = class e extends l {
4753
4981
  bottom: this.shapePaddingBottom,
4754
4982
  left: this.shapePaddingLeft
4755
4983
  } });
4756
- this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), Tn({ group: this }), Pn({ group: this });
4757
- let t = On({ group: this });
4758
- t && En({ text: t }), Dn({ group: this }), this.setCoords();
4984
+ this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), Ln({ group: this }), Kn({ group: this });
4985
+ let t = Bn({ group: this });
4986
+ t && Rn({ text: t }), zn({ group: this }), this.setCoords();
4759
4987
  }
4760
4988
  static async fromObject({ type: t, objects: n = [], layoutManager: r, ...i }, a) {
4761
4989
  let [o, s] = await Promise.all([C.enlivenObjects(n, a), C.enlivenObjectEnlivables(i, a)]), c = new e(o, {
4762
4990
  ...i,
4763
4991
  ...s,
4764
- layoutManager: In()
4992
+ layoutManager: Jn()
4765
4993
  });
4766
- return c.layoutManager = Ln({ layoutManager: r }), c.layoutManager.subscribeTargets({
4994
+ return c.layoutManager = Yn({ layoutManager: r }), c.layoutManager.subscribeTargets({
4767
4995
  type: "initialization",
4768
4996
  target: c,
4769
4997
  targets: c.getObjects()
@@ -4776,9 +5004,9 @@ var Rn = class e extends l {
4776
5004
  let t = dt({ presetKey: e });
4777
5005
  t && (this.shapeCanRound = gt({ preset: t }));
4778
5006
  }
4779
- }, zn = () => {
4780
- y?.setClass && y.setClass(Rn, Fn);
4781
- }, J = (e) => e instanceof Rn || e instanceof l && e.shapeComposite === !0, Bn = ({ target: e, subTargets: t = [] }) => {
5007
+ }, Zn = () => {
5008
+ y?.setClass && y.setClass(Xn, qn);
5009
+ }, J = (e) => e instanceof Xn || e instanceof l && e.shapeComposite === !0, Qn = ({ target: e, subTargets: t = [] }) => {
4782
5010
  if (J(e)) return e;
4783
5011
  if (e?.group && J(e.group)) return e.group;
4784
5012
  for (let e = 0; e < t.length; e += 1) {
@@ -4788,7 +5016,7 @@ var Rn = class e extends l {
4788
5016
  if (r && J(r)) return r;
4789
5017
  }
4790
5018
  return null;
4791
- }, Vn = ({ group: e }) => {
5019
+ }, $n = ({ group: e }) => {
4792
5020
  let t = e.getObjects();
4793
5021
  for (let e = 0; e < t.length; e += 1) {
4794
5022
  let n = t[e];
@@ -4799,7 +5027,7 @@ var Rn = class e extends l {
4799
5027
  if (!(n instanceof _)) return n;
4800
5028
  }
4801
5029
  return null;
4802
- }, Hn = ({ group: e }) => {
5030
+ }, er = ({ group: e }) => {
4803
5031
  let t = e.getObjects();
4804
5032
  for (let e = 0; e < t.length; e += 1) {
4805
5033
  let n = t[e];
@@ -4811,16 +5039,16 @@ var Rn = class e extends l {
4811
5039
  }
4812
5040
  return null;
4813
5041
  }, Y = ({ group: e }) => ({
4814
- shape: Vn({ group: e }),
4815
- text: Hn({ group: e })
4816
- }), Un = ({ group: e }) => {
4817
- Tn({ group: e });
4818
- }, Wn = ({ transform: e, key: t }) => {
5042
+ shape: $n({ group: e }),
5043
+ text: er({ group: e })
5044
+ }), tr = ({ group: e }) => {
5045
+ Ln({ group: e });
5046
+ }, nr = ({ transform: e, key: t }) => {
4819
5047
  let n = e?.original;
4820
5048
  if (!n || typeof n != "object") return null;
4821
5049
  let r = n[t];
4822
5050
  return typeof r != "number" || !Number.isFinite(r) ? null : r;
4823
- }, Gn = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Kn = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, qn = ({ transform: e }) => {
5051
+ }, rr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, ir = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, ar = ({ transform: e }) => {
4824
5052
  let t = e?.action ?? "", n = typeof e?.corner == "string" ? e.corner : "", r = n === "tl" || n === "tr" || n === "bl" || n === "br", i = t === "scaleX" || n === "ml" || n === "mr", a = t === "scaleY" || n === "mt" || n === "mb", o = i || r, s = a || r;
4825
5053
  return {
4826
5054
  canScaleWidth: o,
@@ -4828,37 +5056,37 @@ var Rn = class e extends l {
4828
5056
  isCornerScaleAction: r,
4829
5057
  isVerticalOnlyScale: s && !o
4830
5058
  };
4831
- }, Jn = ({ event: e, group: t, transform: n, canvas: r }) => {
5059
+ }, or = ({ event: e, group: t, transform: n, canvas: r }) => {
4832
5060
  if (!e) return null;
4833
5061
  let i = t.canvas ?? r, a = i.getScenePoint(e), o = t.getRelativeCenterPoint(), s = t.translateToGivenOrigin(o, "center", "center", n.originX, n.originY), c = t.angle ?? 0, l = (c === 0 ? a : a.rotate(-c * Math.PI / 180, o)).subtract(s), u = t.controls[n.corner], d = i.getZoom() || 1, f = (t.padding ?? 0) / d;
4834
5062
  return l.x >= f && (l.x -= f), l.x <= -f && (l.x += f), l.y >= f && (l.y -= f), l.y <= -f && (l.y += f), l.x -= u?.offsetX ?? 0, l.y -= u?.offsetY ?? 0, l;
4835
- }, Yn = ({ group: e, originX: t, originY: n }) => {
5063
+ }, sr = ({ group: e, originX: t, originY: n }) => {
4836
5064
  if (t === null || n === null) return null;
4837
5065
  let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
4838
5066
  return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
4839
- }, Xn = ({ state: e, transform: t }) => {
5067
+ }, cr = ({ state: e, transform: t }) => {
4840
5068
  if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
4841
- let n = Gn({ value: t.originX }), r = Kn({ value: t.originY });
5069
+ let n = rr({ value: t.originX }), r = ir({ value: t.originY });
4842
5070
  return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
4843
- }, Zn = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5071
+ }, lr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
4844
5072
  //#endregion
4845
5073
  //#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
4846
- function Qn({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
5074
+ function ur({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
4847
5075
  let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
4848
5076
  return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
4849
5077
  }
4850
- function $n({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
5078
+ function dr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
4851
5079
  let c = Math.max(0, e.shapeStrokeWidth ?? 0);
4852
5080
  xt({
4853
5081
  shape: t,
4854
- width: Qn({
5082
+ width: ur({
4855
5083
  size: n,
4856
5084
  scale: i,
4857
5085
  strokeWidth: c,
4858
5086
  minSize: o,
4859
5087
  scaleEpsilon: s
4860
5088
  }),
4861
- height: Qn({
5089
+ height: ur({
4862
5090
  size: r,
4863
5091
  scale: a,
4864
5092
  strokeWidth: c,
@@ -4869,54 +5097,45 @@ function $n({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
4869
5097
  strokeWidth: c
4870
5098
  });
4871
5099
  }
4872
- function er({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
4873
- let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } = sn({
4874
- text: e,
4875
- width: t,
4876
- height: n,
4877
- alignV: a ?? "middle",
4878
- padding: r
4879
- });
5100
+ function fr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
5101
+ let o = Math.max(a, Math.abs(r) || 1), s = Math.max(a, Math.abs(i) || 1), c = n ?? "center";
4880
5102
  e.set({
4881
5103
  autoExpand: !1,
4882
- textAlign: d,
4883
- width: f.width,
4884
- splitByGrapheme: p,
4885
- left: f.left / l,
4886
- top: m / u,
5104
+ textAlign: c,
5105
+ width: t.frame.width,
5106
+ splitByGrapheme: t.splitByGrapheme,
5107
+ left: t.frame.left / o,
5108
+ top: t.textTop / s,
4887
5109
  originX: "left",
4888
5110
  originY: "top",
4889
- scaleX: 1 / l,
4890
- scaleY: 1 / u
5111
+ scaleX: 1 / o,
5112
+ scaleY: 1 / s
4891
5113
  }), e.initDimensions(), e.setCoords();
4892
5114
  }
4893
- var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
4894
- let f = Math.max(d, Math.abs(c) || 1), p = Math.max(d, Math.abs(l) || 1);
5115
+ var pr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
5116
+ let l = Math.max(c, Math.abs(a) || 1), u = Math.max(c, Math.abs(o) || 1);
4895
5117
  e.set({
4896
- width: r / f,
4897
- height: i / p,
5118
+ width: r.width / l,
5119
+ height: r.height / u,
4898
5120
  dirty: !0
4899
- }), $n({
5121
+ }), dr({
4900
5122
  group: e,
4901
5123
  shape: t,
4902
- width: r,
4903
- height: i,
4904
- scaleX: c,
4905
- scaleY: l,
4906
- minSize: u,
4907
- scaleEpsilon: d
4908
- }), er({
5124
+ width: r.width,
5125
+ height: r.height,
5126
+ scaleX: a,
5127
+ scaleY: o,
5128
+ minSize: s,
5129
+ scaleEpsilon: c
5130
+ }), fr({
4909
5131
  text: n,
4910
- width: r,
4911
- height: i,
4912
- padding: a,
4913
- alignH: o,
4914
- alignV: s,
4915
- scaleX: c,
4916
- scaleY: l,
4917
- scaleEpsilon: d
5132
+ layout: r,
5133
+ alignH: i,
5134
+ scaleX: a,
5135
+ scaleY: o,
5136
+ scaleEpsilon: c
4918
5137
  });
4919
- }, X = 1, Z = 1e-4, nr = .5, rr = class e {
5138
+ }, X = 1, Z = 1e-4, mr = .5, hr = class e {
4920
5139
  constructor({ canvas: t }) {
4921
5140
  this.handleObjectScaling = (t) => {
4922
5141
  let { target: n, transform: r } = t;
@@ -4927,117 +5146,132 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4927
5146
  lockScalingFlip: !0,
4928
5147
  centeredScaling: !1
4929
5148
  });
4930
- let s = e._resolveEffectivePadding({ group: i }), c = e._resolveScalingConstraintPadding({ group: i }), l = this._ensureScalingState({
5149
+ let s = e._resolveScalingConstraintPadding({ group: i }), c = this._ensureScalingState({
4931
5150
  group: i,
4932
5151
  text: o,
4933
- constraintPadding: c,
5152
+ constraintPadding: s,
4934
5153
  transform: r
4935
- }), { isCornerScaleAction: u } = qn({ transform: r }), d = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
4936
- l.isProportionalScaling = u && d;
4937
- let f = i.left ?? 0, p = i.top ?? 0, m = !!i.flipX, h = !!i.flipY, g = i.shapeAlignHorizontal ?? "center", _ = i.shapeAlignVertical ?? "middle", v = this._resolveScalingDecision({
5154
+ }), { isCornerScaleAction: l } = ar({ transform: r }), u = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
5155
+ c.isProportionalScaling = l && u;
5156
+ let d = i.left ?? 0, f = i.top ?? 0, p = !!i.flipX, m = !!i.flipY, h = i.shapeAlignHorizontal ?? "center", g = this._resolveScalingDecision({
4938
5157
  group: i,
4939
5158
  text: o,
4940
- constraintPadding: c,
4941
- state: l,
5159
+ constraintPadding: s,
5160
+ state: c,
4942
5161
  transform: r
4943
- }), y = Math.abs(i.scaleX ?? 1) || 1, b = Math.abs(i.scaleY ?? 1) || 1;
4944
- (v.shouldHandleAsNoop || v.shouldRestoreLastAllowedTransform || Math.abs(v.appliedScaleX - y) > Z || Math.abs(v.appliedScaleY - b) > Z) && this._applyResolvedScalingState({
5162
+ }), _ = this._resolvePreviewLayout({
4945
5163
  group: i,
4946
- state: l,
4947
- shouldHandleAsNoop: v.shouldHandleAsNoop,
4948
- scaleX: v.appliedScaleX,
4949
- scaleY: v.appliedScaleY
4950
- }), tr({
5164
+ text: o,
5165
+ state: c,
5166
+ appliedScaleX: g.appliedScaleX,
5167
+ appliedScaleY: g.appliedScaleY,
5168
+ minimumHeight: g.previewHeight
5169
+ }), v = Math.abs(i.scaleX ?? 1) || 1, y = Math.abs(i.scaleY ?? 1) || 1;
5170
+ (g.shouldHandleAsNoop || g.shouldRestoreLastAllowedTransform || Math.abs(g.appliedScaleX - v) > Z || Math.abs(g.appliedScaleY - y) > Z) && this._applyResolvedScalingState({
5171
+ group: i,
5172
+ state: c,
5173
+ shouldHandleAsNoop: g.shouldHandleAsNoop,
5174
+ scaleX: g.appliedScaleX,
5175
+ scaleY: g.appliedScaleY
5176
+ }), pr({
4951
5177
  group: i,
4952
5178
  shape: a,
4953
5179
  text: o,
4954
- width: v.previewWidth,
4955
- height: v.previewHeight,
4956
- padding: s,
4957
- alignH: g,
4958
- alignV: _,
4959
- scaleX: v.appliedScaleX,
4960
- scaleY: v.appliedScaleY,
5180
+ layout: _,
5181
+ alignH: h,
5182
+ scaleX: g.appliedScaleX,
5183
+ scaleY: g.appliedScaleY,
4961
5184
  minSize: X,
4962
5185
  scaleEpsilon: Z
4963
5186
  }), this._restoreScalingAnchorPosition({
4964
5187
  group: i,
4965
- state: l
4966
- }), !v.shouldHandleAsNoop && !v.shouldRestoreLastAllowedTransform && this._storeLastAllowedTransform({
5188
+ state: c
5189
+ }), !g.shouldHandleAsNoop && !g.shouldRestoreLastAllowedTransform && this._storeLastAllowedTransform({
4967
5190
  group: i,
4968
- state: l,
5191
+ state: c,
4969
5192
  scaleX: i.scaleX ?? 1,
4970
5193
  scaleY: i.scaleY ?? 1,
4971
- currentLeft: f,
4972
- currentTop: p,
4973
- currentFlipX: m,
4974
- currentFlipY: h
5194
+ currentLeft: d,
5195
+ currentTop: f,
5196
+ currentFlipX: p,
5197
+ currentFlipY: m
4975
5198
  }), this.canvas.requestRenderAll();
4976
5199
  }, this.handleCanvasMouseMove = (t) => {
4977
5200
  let n = this.canvas._currentTransform;
4978
5201
  if (!n) return;
4979
5202
  let { target: r } = n;
4980
5203
  if (!J(r)) return;
4981
- let { canScaleHeight: i, canScaleWidth: a } = qn({ transform: n });
5204
+ let { canScaleHeight: i, canScaleWidth: a } = ar({ transform: n });
4982
5205
  if (!a && !i) return;
4983
5206
  let o = r, s = this.scalingState.get(o);
4984
5207
  if (!s || s.isProportionalScaling) return;
4985
5208
  let { shape: c, text: l } = Y({ group: o });
4986
5209
  if (!c || !l) return;
4987
- let u = e._resolveEffectivePadding({ group: o }), d = e._resolveScalingConstraintPadding({ group: o }), f = o.shapeAlignHorizontal ?? "center", p = o.shapeAlignVertical ?? "middle", m = Math.abs(o.scaleX ?? s.lastAllowedScaleX ?? 1) || 1, h = Math.abs(o.scaleY ?? s.lastAllowedScaleY ?? 1) || 1, g = {
5210
+ let u = e._resolveScalingConstraintPadding({ group: o }), d = o.shapeAlignHorizontal ?? "center", f = Math.abs(o.scaleX ?? s.lastAllowedScaleX ?? 1) || 1, p = Math.abs(o.scaleY ?? s.lastAllowedScaleY ?? 1) || 1, m = {
4988
5211
  ...t,
4989
5212
  transform: n
4990
- }, _ = m, v = h, y = null, b = !1, x = !1;
5213
+ }, h = f, g = p, _ = null, v = !1, y = !1;
4991
5214
  if (a && this._hasPointerReachedScaleOrigin({
4992
- event: g,
5215
+ event: m,
4993
5216
  group: o,
4994
5217
  axis: "x"
4995
5218
  })) {
4996
- let e = on({
5219
+ let t = fn({
4997
5220
  text: l,
4998
- padding: d
4999
- }), t = Math.max(X / s.startWidth, e / s.startWidth);
5000
- s.lastAllowedScaleX > t + Z && (_ = t, b = !0, x = !0);
5221
+ padding: u,
5222
+ resolvePaddingForWidth: ({ width: t }) => e._resolveScalingConstraintPadding({
5223
+ group: o,
5224
+ width: t,
5225
+ height: Math.max(X, s.startHeight * g)
5226
+ })
5227
+ }), n = Math.max(X / s.startWidth, t / s.startWidth);
5228
+ s.lastAllowedScaleX > n + Z && (h = n, v = !0, y = !0);
5001
5229
  }
5002
5230
  if (i && this._hasPointerReachedScaleOrigin({
5003
- event: g,
5231
+ event: m,
5004
5232
  group: o,
5005
5233
  axis: "y"
5006
5234
  })) {
5007
- y = this._resolveMinimumTextFitHeight({
5235
+ _ = this._resolveMinimumTextFitHeight({
5236
+ group: o,
5008
5237
  text: l,
5009
- width: Math.max(X, s.startWidth * _),
5010
- padding: d
5238
+ width: Math.max(X, s.startWidth * h),
5239
+ padding: u
5011
5240
  });
5012
- let e = Math.max(X / s.startHeight, y / s.startHeight);
5013
- s.lastAllowedScaleY > e + Z && (v = e, x = !0);
5241
+ let e = Math.max(X / s.startHeight, _ / s.startHeight);
5242
+ s.lastAllowedScaleY > e + Z && (g = e, y = !0);
5014
5243
  }
5015
- if (!x) return;
5016
- let S = this._resolvePreviewDimensions({
5244
+ if (!y) return;
5245
+ let b = this._resolvePreviewDimensions({
5246
+ group: o,
5247
+ text: l,
5248
+ constraintPadding: u,
5249
+ state: s,
5250
+ appliedScaleX: h,
5251
+ appliedScaleY: g,
5252
+ minimumHeight: v ? null : _
5253
+ }), x = this._resolvePreviewLayout({
5254
+ group: o,
5017
5255
  text: l,
5018
- constraintPadding: d,
5019
5256
  state: s,
5020
- appliedScaleX: _,
5021
- appliedScaleY: v,
5022
- minimumHeight: b ? null : y
5257
+ appliedScaleX: h,
5258
+ appliedScaleY: g,
5259
+ minimumHeight: b.previewHeight
5023
5260
  });
5024
5261
  this._applyResolvedScalingState({
5025
5262
  group: o,
5026
5263
  state: s,
5027
5264
  shouldHandleAsNoop: !1,
5028
- scaleX: _,
5029
- scaleY: v
5030
- }), tr({
5265
+ scaleX: h,
5266
+ scaleY: g
5267
+ }), pr({
5031
5268
  group: o,
5032
5269
  shape: c,
5033
5270
  text: l,
5034
- width: S.previewWidth,
5035
- height: S.previewHeight,
5036
- padding: u,
5037
- alignH: f,
5038
- alignV: p,
5039
- scaleX: _,
5040
- scaleY: v,
5271
+ layout: x,
5272
+ alignH: d,
5273
+ scaleX: h,
5274
+ scaleY: g,
5041
5275
  minSize: X,
5042
5276
  scaleEpsilon: Z
5043
5277
  }), this._restoreScalingAnchorPosition({
@@ -5046,8 +5280,8 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5046
5280
  }), this._storeLastAllowedTransform({
5047
5281
  group: o,
5048
5282
  state: s,
5049
- scaleX: _,
5050
- scaleY: v,
5283
+ scaleX: h,
5284
+ scaleY: g,
5051
5285
  currentLeft: s.lastAllowedLeft,
5052
5286
  currentTop: s.lastAllowedTop,
5053
5287
  currentFlipX: s.lastAllowedFlipX,
@@ -5074,20 +5308,26 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5074
5308
  this.scalingState.delete(r);
5075
5309
  return;
5076
5310
  }
5077
- let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ? qn({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = on({
5311
+ let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ? ar({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = i?.lastAllowedScaleX ?? a, b = i?.lastAllowedScaleY ?? o, x = fn({
5078
5312
  text: f,
5079
- padding: h
5080
- }), b = i?.lastAllowedScaleX ?? a, x = i?.lastAllowedScaleY ?? o;
5313
+ padding: h,
5314
+ resolvePaddingForWidth: ({ width: t }) => e._resolveScalingConstraintPadding({
5315
+ group: r,
5316
+ width: t,
5317
+ height: Math.max(X, c * b)
5318
+ })
5319
+ });
5081
5320
  if (!i?.isProportionalScaling) {
5082
5321
  this._shouldClampWidthToMinimum({
5083
5322
  event: t,
5084
5323
  group: r,
5085
- minimumWidth: y,
5324
+ minimumWidth: x,
5086
5325
  state: i
5087
- }) && (b = Math.max(X / s, y / s));
5326
+ }) && (y = Math.max(X / s, x / s));
5088
5327
  let e = this._resolveMinimumTextFitHeight({
5328
+ group: r,
5089
5329
  text: f,
5090
- width: Math.max(X, s * b),
5330
+ width: Math.max(X, s * y),
5091
5331
  padding: h
5092
5332
  });
5093
5333
  this._shouldClampHeightToMinimum({
@@ -5095,9 +5335,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5095
5335
  group: r,
5096
5336
  minimumHeight: e,
5097
5337
  state: i
5098
- }) && (x = Math.max(X / c, e / c));
5338
+ }) && (b = Math.max(X / c, e / c));
5099
5339
  }
5100
- let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) > nr, T = Math.abs(C - c) > nr, E = w || T, D = S, O = C;
5340
+ let S = _ ? Math.max(X, s * y) : s, C = v ? Math.max(X, c * b) : u, w = Math.abs(S - s) > mr, T = Math.abs(C - c) > mr, E = w || T, D = S, O = C;
5101
5341
  if (!E && i) {
5102
5342
  this._restoreShapeStateWithoutResize({
5103
5343
  group: r,
@@ -5126,7 +5366,13 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5126
5366
  });
5127
5367
  r.shapeManualBaseWidth = k.width, r.shapeManualBaseHeight = k.height;
5128
5368
  let A = i?.baseRounding ?? Math.max(0, r.shapeRounding ?? 0);
5129
- r.shapeRounding = Math.max(0, A * Math.min(b, x)), rn({
5369
+ r.shapeRounding = Math.max(0, A * Math.min(y, b));
5370
+ let j = e._resolveUserPadding({ group: r }), M = e._resolveInternalShapeTextInset({
5371
+ group: r,
5372
+ width: D,
5373
+ height: O
5374
+ });
5375
+ ln({
5130
5376
  group: r,
5131
5377
  shape: d,
5132
5378
  text: f,
@@ -5134,11 +5380,13 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5134
5380
  height: O,
5135
5381
  alignH: p,
5136
5382
  alignV: m,
5137
- padding: e._resolveUserPadding({ group: r }),
5138
- internalShapeTextInset: e._resolveInternalShapeTextInset({
5383
+ padding: j,
5384
+ shapeTextAutoExpandEnabled: r.shapeTextAutoExpand !== !1,
5385
+ internalShapeTextInset: M,
5386
+ resolveInternalShapeTextInset: ({ width: t, height: n }) => e._resolveInternalShapeTextInset({
5139
5387
  group: r,
5140
- width: D,
5141
- height: O
5388
+ width: t,
5389
+ height: n
5142
5390
  })
5143
5391
  }), r.shapeReplaceBoxWidth = Math.max(1, r.shapeBaseWidth ?? D), r.shapeReplaceBoxHeight = Math.max(1, r.shapeBaseHeight ?? O), f.set({
5144
5392
  scaleX: 1,
@@ -5153,15 +5401,16 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5153
5401
  }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
5154
5402
  }
5155
5403
  _resolveScalingDecision({ group: e, text: t, constraintPadding: n, state: r, transform: i }) {
5156
- let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = Xn({
5404
+ let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = cr({
5157
5405
  state: r,
5158
5406
  transform: i
5159
- }), d = Zn({
5407
+ }), d = lr({
5160
5408
  state: r,
5161
5409
  transform: i
5162
5410
  });
5163
5411
  (l || u || d) && (r.crossedOppositeCorner = !0);
5164
5412
  let f = this._resolveScalingConstraintState({
5413
+ group: e,
5165
5414
  text: t,
5166
5415
  constraintPadding: n,
5167
5416
  state: r,
@@ -5171,6 +5420,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5171
5420
  }), p = Math.abs(e.scaleX ?? 1) || 1, m = Math.abs(e.scaleY ?? 1) || 1, h = f.clampedScaleX ?? p, g = f.clampedScaleY ?? m;
5172
5421
  f.shouldRestoreLastAllowedTransform && (h = r.lastAllowedScaleX, g = r.lastAllowedScaleY), f.shouldHandleAsNoop && (h = r.startScaleX, g = r.startScaleY);
5173
5422
  let _ = !f.shouldHandleAsNoop && !f.shouldRestoreLastAllowedTransform && f.clampedScaleX === null, v = this._resolvePreviewDimensions({
5423
+ group: e,
5174
5424
  text: t,
5175
5425
  constraintPadding: n,
5176
5426
  state: r,
@@ -5187,37 +5437,63 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5187
5437
  shouldRestoreLastAllowedTransform: f.shouldRestoreLastAllowedTransform
5188
5438
  };
5189
5439
  }
5190
- _resolveScalingConstraintState({ text: e, constraintPadding: t, state: n, transform: r, scaleX: i, scaleY: a }) {
5191
- let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } = qn({ transform: r }), S = b && g ? on({
5192
- text: e,
5193
- padding: t
5194
- }) : null, C = y && _ ? this._resolveMinimumTextFitHeight({
5195
- text: e,
5196
- width: m,
5197
- padding: t
5198
- }) : null, w = x && c && v, T = S !== null && m < S + Z, E = C !== null && h < C + Z, D = l || u && (T || E), O = null;
5199
- !u && S !== null && m < S + Z && (O = Math.max(X / s, S / s));
5200
- let k = null;
5201
- return !u && C !== null && h < C + Z && (k = Math.max(X / o, C / o)), {
5202
- shouldHandleAsNoop: w,
5203
- shouldRestoreLastAllowedTransform: D,
5204
- clampedScaleX: O,
5205
- clampedScaleY: k,
5206
- resolvedMinimumHeight: C
5440
+ _resolveScalingConstraintState({ group: t, text: n, constraintPadding: r, state: i, transform: a, scaleX: o, scaleY: s }) {
5441
+ let { startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = i, g = Math.max(X, l * o), _ = Math.max(X, c * s), v = o < p - Z, y = s < m - Z, b = s < h - Z, { canScaleHeight: x, canScaleWidth: S, isVerticalOnlyScale: C } = ar({ transform: a }), w = S && v ? fn({
5442
+ text: n,
5443
+ padding: r,
5444
+ resolvePaddingForWidth: ({ width: n }) => e._resolveScalingConstraintPadding({
5445
+ group: t,
5446
+ width: n,
5447
+ height: _
5448
+ })
5449
+ }) : null, T = x && y ? this._resolveMinimumTextFitHeight({
5450
+ group: t,
5451
+ text: n,
5452
+ width: g,
5453
+ padding: r
5454
+ }) : null, E = C && u && b, D = w !== null && g < w + Z, O = T !== null && _ < T + Z, k = d || f && (D || O), A = null;
5455
+ !f && w !== null && g < w + Z && (A = Math.max(X / l, w / l));
5456
+ let j = null;
5457
+ return !f && T !== null && _ < T + Z && (j = Math.max(X / c, T / c)), {
5458
+ shouldHandleAsNoop: E,
5459
+ shouldRestoreLastAllowedTransform: k,
5460
+ clampedScaleX: A,
5461
+ clampedScaleY: j,
5462
+ resolvedMinimumHeight: T
5207
5463
  };
5208
5464
  }
5209
- _resolvePreviewDimensions({ text: e, constraintPadding: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
5210
- let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a ?? cn({
5211
- text: e,
5212
- width: o,
5213
- height: s,
5214
- padding: t
5465
+ _resolvePreviewDimensions({ group: t, text: n, constraintPadding: r, state: i, appliedScaleX: a, appliedScaleY: o, minimumHeight: s }) {
5466
+ let c = i.canScaleWidth ? Math.max(X, i.startWidth * a) : i.startWidth, l = i.canScaleHeight ? Math.max(X, i.startHeight * o) : i.startManualBaseHeight, u = s ?? mn({
5467
+ text: n,
5468
+ width: c,
5469
+ height: l,
5470
+ padding: r,
5471
+ resolvePaddingForSize: ({ width: n, height: r }) => e._resolveScalingConstraintPadding({
5472
+ group: t,
5473
+ width: n,
5474
+ height: r
5475
+ })
5215
5476
  });
5216
5477
  return {
5217
- previewWidth: o,
5218
- previewHeight: Math.max(s, c)
5478
+ previewWidth: c,
5479
+ previewHeight: Math.max(l, u)
5219
5480
  };
5220
5481
  }
5482
+ _resolvePreviewLayout({ group: t, text: n, state: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o }) {
5483
+ let s = r.canScaleWidth ? Math.max(X, r.startWidth * i) : r.startWidth, c = r.canScaleHeight ? Math.max(X, r.startHeight * a) : r.startManualBaseHeight;
5484
+ return cn({
5485
+ text: n,
5486
+ width: s,
5487
+ height: o == null ? c : Math.max(c, o),
5488
+ alignV: t.shapeAlignVertical ?? "middle",
5489
+ padding: e._resolveUserPadding({ group: t }),
5490
+ resolveInternalShapeTextInset: ({ width: n, height: r }) => e._resolveInternalShapeTextInset({
5491
+ group: t,
5492
+ width: n,
5493
+ height: r
5494
+ })
5495
+ });
5496
+ }
5221
5497
  _applyResolvedScalingState({ group: e, state: t, shouldHandleAsNoop: n, scaleX: r, scaleY: i }) {
5222
5498
  t.blockedScaleAttempt = n, e.shapeScalingNoopTransform = n;
5223
5499
  let a = n ? t.startScaleX : r, o = n ? t.startScaleY : i, s = n ? t.startLeft : t.lastAllowedLeft, c = n ? t.startTop : t.lastAllowedTop;
@@ -5240,7 +5516,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5240
5516
  if (!r) return !1;
5241
5517
  let { transform: i } = e;
5242
5518
  if (!i) return !1;
5243
- let { canScaleWidth: a } = qn({ transform: i });
5519
+ let { canScaleWidth: a } = ar({ transform: i });
5244
5520
  if (!a || !this._hasPointerReachedScaleOrigin({
5245
5521
  event: e,
5246
5522
  group: t,
@@ -5253,7 +5529,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5253
5529
  if (!r) return !1;
5254
5530
  let { transform: i } = e;
5255
5531
  if (!i) return !1;
5256
- let { canScaleHeight: a } = qn({ transform: i });
5532
+ let { canScaleHeight: a } = ar({ transform: i });
5257
5533
  if (!a || !this._hasPointerReachedScaleOrigin({
5258
5534
  event: e,
5259
5535
  group: t,
@@ -5267,7 +5543,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5267
5543
  if (!r) return !1;
5268
5544
  let i = r, a = n === "x" ? i.signX : i.signY;
5269
5545
  if (typeof a != "number" || !Number.isFinite(a)) return !1;
5270
- let o = Jn({
5546
+ let o = or({
5271
5547
  event: e.e,
5272
5548
  group: t,
5273
5549
  transform: r,
@@ -5284,23 +5560,24 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5284
5560
  let a = this._resolveScalingStartDimensions({
5285
5561
  group: e,
5286
5562
  transform: r
5287
- }), o = Wn({
5563
+ }), o = nr({
5288
5564
  transform: r,
5289
5565
  key: "scaleX"
5290
- }), s = Wn({
5566
+ }), s = nr({
5291
5567
  transform: r,
5292
5568
  key: "scaleY"
5293
- }), c = Wn({
5569
+ }), c = nr({
5294
5570
  transform: r,
5295
5571
  key: "left"
5296
- }), l = Wn({
5572
+ }), l = nr({
5297
5573
  transform: r,
5298
5574
  key: "top"
5299
- }), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m = Gn({ value: r?.original?.originX ?? r?.originX }), h = Kn({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = Yn({
5575
+ }), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m = rr({ value: r?.original?.originX ?? r?.originX }), h = ir({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = sr({
5300
5576
  group: e,
5301
5577
  originX: m,
5302
5578
  originY: h
5303
5579
  }), v = this._resolveMinimumTextFitHeight({
5580
+ group: e,
5304
5581
  text: t,
5305
5582
  width: a.startWidth,
5306
5583
  padding: n
@@ -5338,12 +5615,17 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5338
5615
  }
5339
5616
  return i;
5340
5617
  }
5341
- _resolveMinimumTextFitHeight({ text: e, width: t, padding: n }) {
5342
- return cn({
5343
- text: e,
5344
- width: t,
5618
+ _resolveMinimumTextFitHeight({ group: t, text: n, width: r, padding: i }) {
5619
+ return mn({
5620
+ text: n,
5621
+ width: r,
5345
5622
  height: X,
5346
- padding: n
5623
+ padding: i,
5624
+ resolvePaddingForSize: ({ width: n, height: r }) => e._resolveScalingConstraintPadding({
5625
+ group: t,
5626
+ width: n,
5627
+ height: r
5628
+ })
5347
5629
  });
5348
5630
  }
5349
5631
  static _resolveUserPadding({ group: e }) {
@@ -5366,23 +5648,12 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5366
5648
  strokeWidth: e.shapeStrokeWidth
5367
5649
  });
5368
5650
  }
5369
- static _resolveEffectivePadding({ group: t }) {
5370
- let n = Math.max(X, t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), r = Math.max(X, t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X), i = e._resolveUserPadding({ group: t });
5371
- return Ht({
5372
- base: e._resolveInternalShapeTextInset({
5373
- group: t,
5374
- width: n,
5375
- height: r
5376
- }),
5377
- addition: i
5378
- });
5379
- }
5380
- static _resolveScalingConstraintPadding({ group: t }) {
5381
- let n = Math.max(X, t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), r = Math.max(X, t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X);
5651
+ static _resolveScalingConstraintPadding({ group: t, width: n, height: r }) {
5652
+ let i = Math.max(X, n ?? t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), a = Math.max(X, r ?? t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X);
5382
5653
  return e._resolveInternalShapeTextInset({
5383
5654
  group: t,
5384
- width: n,
5385
- height: r
5655
+ width: i,
5656
+ height: a
5386
5657
  });
5387
5658
  }
5388
5659
  _restoreScalingAnchorPosition({ group: e, state: t }) {
@@ -5395,7 +5666,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5395
5666
  }
5396
5667
  _restoreShapeStateWithoutResize({ group: t, shape: n, text: r, state: i, startWidth: a, startHeight: o, alignH: s, alignV: c, userPadding: l }) {
5397
5668
  let u = Math.max(X, t.shapeBaseWidth ?? t.width ?? a), d = Math.max(X, t.shapeBaseHeight ?? t.height ?? o);
5398
- rn({
5669
+ ln({
5399
5670
  group: t,
5400
5671
  shape: n,
5401
5672
  text: r,
@@ -5408,6 +5679,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5408
5679
  group: t,
5409
5680
  width: u,
5410
5681
  height: d
5682
+ }),
5683
+ resolveInternalShapeTextInset: ({ width: n, height: r }) => e._resolveInternalShapeTextInset({
5684
+ group: t,
5685
+ width: n,
5686
+ height: r
5411
5687
  })
5412
5688
  }), t.shapeReplaceBoxWidth = Math.max(1, t.shapeBaseWidth ?? u), t.shapeReplaceBoxHeight = Math.max(1, t.shapeBaseHeight ?? d), t.set({
5413
5689
  left: i.lastAllowedLeft,
@@ -5447,7 +5723,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5447
5723
  });
5448
5724
  }
5449
5725
  _resolveScalingStartDimensions({ group: e, transform: t }) {
5450
- let { canScaleWidth: n, canScaleHeight: r } = qn({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
5726
+ let { canScaleWidth: n, canScaleHeight: r } = ar({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
5451
5727
  return {
5452
5728
  startWidth: i,
5453
5729
  startHeight: a,
@@ -5466,10 +5742,10 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5466
5742
  height: s
5467
5743
  };
5468
5744
  }
5469
- }, ir = class {
5745
+ }, gr = class {
5470
5746
  constructor({ canvas: e }) {
5471
5747
  this.handleMouseDown = (e) => {
5472
- let { target: t, e: n, subTargets: r = [] } = e, i = Bn({
5748
+ let { target: t, e: n, subTargets: r = [] } = e, i = Qn({
5473
5749
  target: t,
5474
5750
  subTargets: r
5475
5751
  });
@@ -5479,7 +5755,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5479
5755
  let o = this.canvas.getActiveObject(), s = o === i;
5480
5756
  if (!(o === a && a.isEditing)) {
5481
5757
  if (!s) {
5482
- a.isEditing || En({ text: a });
5758
+ a.isEditing || Rn({ text: a });
5483
5759
  return;
5484
5760
  }
5485
5761
  n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
@@ -5499,14 +5775,14 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5499
5775
  J(r) && (this._restoreTextEditingInteractionMode({
5500
5776
  group: r,
5501
5777
  text: n
5502
- }), En({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
5778
+ }), Rn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
5503
5779
  }, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
5504
5780
  }
5505
5781
  enterTextEditing({ group: e }) {
5506
5782
  let { text: t } = Y({ group: e });
5507
5783
  if (t) {
5508
5784
  if (e.locked || t.locked) {
5509
- En({ text: t }), this.canvas.requestRenderAll();
5785
+ Rn({ text: t }), this.canvas.requestRenderAll();
5510
5786
  return;
5511
5787
  }
5512
5788
  this._enterTextEditingInteractionMode({
@@ -5556,7 +5832,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5556
5832
  lockMovementY: n.textLockMovementY
5557
5833
  }), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
5558
5834
  }
5559
- }, ar = class e {
5835
+ }, _r = class e {
5560
5836
  constructor({ canvas: e }) {
5561
5837
  this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
5562
5838
  }
@@ -5752,7 +6028,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5752
6028
  }
5753
6029
  }), I;
5754
6030
  }
5755
- }, or = "#B4B7BD", sr = 0, cr = 1, lr = class {
6031
+ }, vr = "#B4B7BD", yr = 0, br = 1, xr = class {
5756
6032
  constructor({ editor: e }) {
5757
6033
  this._handleObjectScaling = (e) => {
5758
6034
  let t = e.target && J(e.target) ? e.target : null;
@@ -5817,7 +6093,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5817
6093
  if (!(t instanceof _)) return;
5818
6094
  let n = t;
5819
6095
  this.lifecycleController.finishTextUpdate({ textNode: n });
5820
- }, this.editor = e, zn(), this.scalingController = new rr({ canvas: e.canvas }), this.editingController = new ir({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new ar({ canvas: e.canvas }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
6096
+ }, this.editor = e, Zn(), this.scalingController = new hr({ canvas: e.canvas }), this.editingController = new gr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new _r({ canvas: e.canvas }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
5821
6097
  }
5822
6098
  async add({ presetKey: e = ot, options: t = {} } = {}) {
5823
6099
  let n = dt({ presetKey: e });
@@ -5831,7 +6107,15 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5831
6107
  }), T = p ?? "middle", E = this._resolveShapeStyle({
5832
6108
  options: t,
5833
6109
  fallback: null
5834
- }), O = zt({ padding: m }), k = Ut({
6110
+ }), O = zt({ padding: m }), k = ({ width: e, height: t }) => Ut({
6111
+ baseInset: mt({
6112
+ preset: b,
6113
+ width: e,
6114
+ height: t
6115
+ }),
6116
+ stroke: E.stroke,
6117
+ strokeWidth: E.strokeWidth
6118
+ }), A = Ut({
5835
6119
  baseInset: mt({
5836
6120
  preset: b,
5837
6121
  width: x,
@@ -5839,34 +6123,41 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5839
6123
  }),
5840
6124
  stroke: E.stroke,
5841
6125
  strokeWidth: E.strokeWidth
5842
- }), A = Ht({
5843
- base: k,
6126
+ }), j = Ht({
6127
+ base: A,
5844
6128
  addition: O
5845
- }), j = Wt({ padding: m }), M = this._createTextNode({
6129
+ }), M = Wt({ padding: m }), N = this._createTextNode({
5846
6130
  text: u,
5847
6131
  textStyle: d,
5848
6132
  width: x,
5849
6133
  align: w,
5850
6134
  opacity: E.opacity
5851
- }), N = this._resolveShapeLayoutWidth({
5852
- text: M,
6135
+ }), P = this._resolveShapeLayoutWidth({
6136
+ text: N,
5853
6137
  currentWidth: x,
5854
6138
  manualWidth: x,
5855
6139
  shapeTextAutoExpandEnabled: C,
5856
- padding: A
5857
- }), P = await Pt({
6140
+ padding: j,
6141
+ resolvePaddingForWidth: ({ width: e }) => Ht({
6142
+ base: k({
6143
+ width: e,
6144
+ height: S
6145
+ }),
6146
+ addition: O
6147
+ })
6148
+ }), F = await Pt({
5858
6149
  preset: b,
5859
- width: N,
6150
+ width: P,
5860
6151
  height: S,
5861
6152
  style: E,
5862
6153
  rounding: h
5863
- }), F = this._createShapeGroup({
6154
+ }), I = this._createShapeGroup({
5864
6155
  id: y ?? `shape-${D()}`,
5865
6156
  presetKey: b.key,
5866
6157
  presetCanRound: gt({ preset: b }),
5867
- shape: P,
5868
- text: M,
5869
- width: N,
6158
+ shape: F,
6159
+ text: N,
6160
+ width: P,
5870
6161
  height: S,
5871
6162
  manualWidth: x,
5872
6163
  manualHeight: S,
@@ -5874,19 +6165,19 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5874
6165
  alignH: w,
5875
6166
  alignV: T,
5876
6167
  padding: O,
5877
- internalShapeTextInset: k,
5878
- changedPadding: j,
6168
+ internalShapeTextInset: A,
6169
+ changedPadding: M,
5879
6170
  style: E,
5880
6171
  rounding: h
5881
- }), I = {
5882
- shape: F,
6172
+ }), L = {
6173
+ shape: I,
5883
6174
  presetKey: b.key,
5884
6175
  options: t
5885
6176
  };
5886
- if (o === void 0 && s === void 0) this.editor.canvasManager.centerObjectToMontageArea({ object: F });
6177
+ if (o === void 0 && s === void 0) this.editor.canvasManager.centerObjectToMontageArea({ object: I });
5887
6178
  else {
5888
6179
  let e = this.editor.canvasManager.resolveObjectPlacement({
5889
- object: F,
6180
+ object: I,
5890
6181
  left: o,
5891
6182
  top: s,
5892
6183
  originX: c,
@@ -5894,18 +6185,18 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5894
6185
  fallbackPoint: this.editor.canvasManager.getMontageAreaSceneCenter()
5895
6186
  });
5896
6187
  this.editor.canvasManager.applyObjectPlacement({
5897
- object: F,
6188
+ object: I,
5898
6189
  placement: e
5899
6190
  });
5900
6191
  }
5901
- if (g) return this.editor.canvas.fire("editor:shape-added", I), F;
6192
+ if (g) return this.editor.canvas.fire("editor:shape-added", L), I;
5902
6193
  this._beginMutation();
5903
6194
  try {
5904
- this.editor.canvas.add(F), _ || this.editor.canvas.setActiveObject(F), this.editor.canvas.requestRenderAll();
6195
+ this.editor.canvas.add(I), _ || this.editor.canvas.setActiveObject(I), this.editor.canvas.requestRenderAll();
5905
6196
  } finally {
5906
6197
  this._endMutation({ withoutSave: v });
5907
6198
  }
5908
- return this.editor.canvas.fire("editor:shape-added", I), F;
6199
+ return this.editor.canvas.fire("editor:shape-added", L), I;
5909
6200
  }
5910
6201
  async update({ target: e, presetKey: t, options: n = {} } = {}) {
5911
6202
  let r = this._resolveShapeGroup({ target: e });
@@ -5921,46 +6212,49 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5921
6212
  }), S = this._resolveCurrentDimensions({ group: r }), C = this._resolveManualDimensions({ group: r }), w = this._resolveReplaceBoxDimensions({ group: r }), T = this._isShapeTextAutoExpandEnabled({ group: r }), E = f === void 0 ? T : f !== !1, D = v ?? r.shapeRounding ?? 0, O = dt({ presetKey: ft({
5922
6213
  preset: i,
5923
6214
  rounding: D
5924
- }) }) ?? i, { width: k, height: A } = O, j = !!d, M = t !== void 0, N = M && !j ? {
6215
+ }) }) ?? i, { width: k, height: A } = O, j = !!d, M = t !== void 0, N = M && !j, P = N ? {
5925
6216
  width: Math.max(1, l ?? w.width),
5926
6217
  height: Math.max(1, u ?? w.height)
5927
- } : null, { width: P, height: F } = N ? this._resolveAspectRatioFittedDimensions({
5928
- targetWidth: N.width,
5929
- targetHeight: N.height,
6218
+ } : null, { width: F, height: I } = P ? this._resolveAspectRatioFittedDimensions({
6219
+ targetWidth: P.width,
6220
+ targetHeight: P.height,
5930
6221
  aspectWidth: k,
5931
6222
  aspectHeight: A
5932
6223
  }) : {
5933
6224
  width: Math.max(1, l ?? S.width),
5934
6225
  height: Math.max(1, u ?? S.height)
5935
- }, I = h ?? r.shapeAlignHorizontal ?? "center", ee = g ?? r.shapeAlignVertical ?? "middle", te = this._resolveGroupUserPadding({ group: r }), L = Wt({ padding: _ }), ne = Vt({
5936
- base: te,
6226
+ }, L = h ?? r.shapeAlignHorizontal ?? "center", ee = g ?? r.shapeAlignVertical ?? "middle", R = this._resolveGroupUserPadding({ group: r }), te = Wt({ padding: _ }), ne = Vt({
6227
+ base: R,
5937
6228
  override: _
5938
- }), re = this._resolveShapeStyle({
6229
+ }), z = this._resolveShapeStyle({
5939
6230
  options: n,
5940
6231
  fallback: r
5941
- }), R = Ut({
6232
+ }), re = ({ width: e, height: t }) => Ut({
5942
6233
  baseInset: mt({
5943
6234
  preset: O,
5944
- width: P,
5945
- height: F
6235
+ width: e,
6236
+ height: t
6237
+ }),
6238
+ stroke: z.stroke,
6239
+ strokeWidth: z.strokeWidth
6240
+ }), B = Ht({
6241
+ base: re({
6242
+ width: F,
6243
+ height: I
5946
6244
  }),
5947
- stroke: re.stroke,
5948
- strokeWidth: re.strokeWidth
5949
- }), ie = Ht({
5950
- base: R,
5951
6245
  addition: ne
5952
- }), z = C.width, B = C.height;
5953
- M && (z = P, B = F), !M && l !== void 0 && (z = Math.max(1, l)), !M && u !== void 0 && (B = Math.max(1, u)), !M && l === void 0 && T && !E && (z = S.width);
5954
- let { shape: V, text: H } = Y({ group: r });
5955
- if (!V || !H) return null;
5956
- let U = this.lifecycleController.createContext({
6246
+ }), V = C.width, H = C.height;
6247
+ M && (V = F, H = I), !M && l !== void 0 && (V = Math.max(1, l)), !M && u !== void 0 && (H = Math.max(1, u)), !M && l === void 0 && T && !E && (V = S.width);
6248
+ let { shape: ie, text: U } = Y({ group: r });
6249
+ if (!ie || !U) return null;
6250
+ let ae = this.lifecycleController.createContext({
5957
6251
  group: r,
5958
6252
  source: "update",
5959
6253
  target: e,
5960
6254
  presetKey: O.key,
5961
6255
  options: n,
5962
6256
  withoutSave: b
5963
- }), ae = {
6257
+ }), oe = {
5964
6258
  angle: 0,
5965
6259
  skewX: 0,
5966
6260
  skewY: 0,
@@ -5973,77 +6267,91 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5973
6267
  top: 0,
5974
6268
  originX: "left",
5975
6269
  originY: "top"
5976
- }, oe = H, se = this._createTextNode({
5977
- text: oe.textCaseRaw ?? H.text ?? "",
5978
- textStyle: this._resolveCurrentTextStyle({ textNode: H }),
5979
- width: Math.max(1, H.width ?? S.width),
5980
- align: I
6270
+ }, se = U, ce = this._createTextNode({
6271
+ text: se.textCaseRaw ?? U.text ?? "",
6272
+ textStyle: this._resolveCurrentTextStyle({ textNode: U }),
6273
+ width: Math.max(1, U.width ?? S.width),
6274
+ align: L
5981
6275
  });
5982
- se.set(ae), this._applyTextUpdates({
5983
- textNode: se,
6276
+ ce.set(oe), this._applyTextUpdates({
6277
+ textNode: ce,
5984
6278
  text: p,
5985
6279
  textStyle: m,
5986
- align: I
6280
+ align: L
5987
6281
  });
5988
- let ce = l === void 0 && u === void 0 && t === void 0 && f === void 0 && v === void 0 && p === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: m }), le = _ !== void 0 && ce, ue = ce ? S.width : this._resolveShapeLayoutWidth({
5989
- text: se,
5990
- currentWidth: P,
5991
- manualWidth: z,
6282
+ let le = l === void 0 && u === void 0 && t === void 0 && f === void 0 && v === void 0 && p === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: m }), ue = _ !== void 0 && le, de = F, fe = I;
6283
+ le ? (de = S.width, fe = S.height) : N || (de = this._resolveShapeLayoutWidth({
6284
+ text: ce,
6285
+ currentWidth: F,
6286
+ manualWidth: V,
5992
6287
  shapeTextAutoExpandEnabled: E,
5993
- padding: ie
5994
- }), de = await Pt({
6288
+ padding: B,
6289
+ resolvePaddingForWidth: ({ width: e }) => Ht({
6290
+ base: re({
6291
+ width: e,
6292
+ height: I
6293
+ }),
6294
+ addition: ne
6295
+ })
6296
+ }));
6297
+ let pe = re({
6298
+ width: de,
6299
+ height: fe
6300
+ }), me = await Pt({
5995
6301
  preset: O,
5996
- width: ue,
5997
- height: F,
5998
- style: re,
6302
+ width: de,
6303
+ height: fe,
6304
+ style: z,
5999
6305
  rounding: D
6000
- }), fe = r.getObjects().indexOf(V);
6001
- if (fe < 0) return null;
6002
- let pe = () => {
6003
- this._detachShapeGroupAutoLayout({ group: r }), H.set(ae), this._applyTextUpdates({
6004
- textNode: H,
6306
+ }), he = r.getObjects().indexOf(ie);
6307
+ if (he < 0) return null;
6308
+ let ge = () => {
6309
+ this._detachShapeGroupAutoLayout({ group: r }), U.set(oe), this._applyTextUpdates({
6310
+ textNode: U,
6005
6311
  text: p,
6006
6312
  textStyle: m,
6007
- align: I
6008
- }), r.remove(V), r.insertAt(fe, de), this._applyShapeGroupMetadata({
6313
+ align: L
6314
+ }), r.remove(ie), r.insertAt(he, me), this._applyShapeGroupMetadata({
6009
6315
  group: r,
6010
6316
  presetKey: O.key,
6011
6317
  presetCanRound: gt({ preset: O }),
6012
- width: ue,
6013
- height: F,
6014
- manualWidth: z,
6015
- manualHeight: B,
6016
- replaceBoxWidth: N?.width,
6017
- replaceBoxHeight: N?.height,
6318
+ width: de,
6319
+ height: fe,
6320
+ manualWidth: V,
6321
+ manualHeight: H,
6322
+ replaceBoxWidth: P?.width,
6323
+ replaceBoxHeight: P?.height,
6018
6324
  shapeTextAutoExpand: E,
6019
- alignH: I,
6325
+ alignH: L,
6020
6326
  alignV: ee,
6021
6327
  padding: ne,
6022
- style: re,
6328
+ style: z,
6023
6329
  rounding: D
6024
6330
  }), this._applyCurrentLayout({
6025
6331
  group: r,
6026
- shape: de,
6027
- text: H,
6332
+ shape: me,
6333
+ text: U,
6028
6334
  placement: x,
6029
- width: ue,
6030
- height: F,
6031
- alignH: I,
6335
+ width: de,
6336
+ height: fe,
6337
+ alignH: L,
6032
6338
  alignV: ee,
6033
- internalShapeTextInset: R,
6034
- minimumReplaceBox: N ?? void 0,
6035
- expandShapeHeightToFitText: !le,
6036
- changedPadding: L
6037
- }), H.isEditing && this.editingPlacements.set(r, x);
6339
+ internalShapeTextInset: pe,
6340
+ resolveInternalShapeTextInset: re,
6341
+ preserveAspectRatio: N,
6342
+ minimumReplaceBox: P ?? void 0,
6343
+ expandShapeHeightToFitText: !ue,
6344
+ changedPadding: te
6345
+ }), N && (r.shapeManualBaseWidth = Math.max(1, r.shapeBaseWidth ?? de), r.shapeManualBaseHeight = Math.max(1, r.shapeBaseHeight ?? fe)), U.isEditing && this.editingPlacements.set(r, x);
6038
6346
  };
6039
- if (!this._isOnCanvas({ object: r })) return pe(), this.lifecycleController.fireBefore({ lifecycle: U }), this.lifecycleController.fireUpdated({ lifecycle: U }), r;
6347
+ if (!this._isOnCanvas({ object: r })) return ge(), this.lifecycleController.fireBefore({ lifecycle: ae }), this.lifecycleController.fireUpdated({ lifecycle: ae }), r;
6040
6348
  this._beginMutation();
6041
6349
  try {
6042
- pe(), !H.isEditing && !y && this.editor.canvas.setActiveObject(r), this.lifecycleController.fireBefore({ lifecycle: U }), this.editor.canvas.requestRenderAll();
6350
+ ge(), !U.isEditing && !y && this.editor.canvas.setActiveObject(r), this.lifecycleController.fireBefore({ lifecycle: ae }), this.editor.canvas.requestRenderAll();
6043
6351
  } finally {
6044
6352
  this._endMutation({ withoutSave: b });
6045
6353
  }
6046
- return this.lifecycleController.fireUpdated({ lifecycle: U }), r;
6354
+ return this.lifecycleController.fireUpdated({ lifecycle: ae }), r;
6047
6355
  }
6048
6356
  _resolveAspectRatioFittedDimensions({ targetWidth: e, targetHeight: t, aspectWidth: n, aspectHeight: r }) {
6049
6357
  let i = Math.max(1, n), a = Math.max(1, r), o = e === void 0 ? void 0 : Math.max(1, e), s = t === void 0 ? void 0 : Math.max(1, t);
@@ -6249,8 +6557,8 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6249
6557
  let { canvas: e } = this.editor;
6250
6558
  e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("mouse:up", this._handleMouseUp), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged), e.on("editor:before:text-updated", this._handleBeforeTextUpdated), e.on("editor:text-updated", this._handleTextUpdated);
6251
6559
  }
6252
- _createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, internalShapeTextInset: p, changedPadding: m, style: h, rounding: g }) {
6253
- let _ = new Rn([r, i], {
6560
+ _createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, internalShapeTextInset: p, resolveInternalShapeTextInset: m, changedPadding: h, style: g, rounding: _ }) {
6561
+ let v = new Xn([r, i], {
6254
6562
  originX: "center",
6255
6563
  originY: "center",
6256
6564
  left: 0,
@@ -6258,9 +6566,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6258
6566
  lockScalingFlip: !0,
6259
6567
  centeredScaling: !1,
6260
6568
  objectCaching: !1
6261
- }), v = _;
6262
- return v.id = e, this._applyShapeGroupMetadata({
6263
- group: _,
6569
+ }), y = v;
6570
+ return y.id = e, this._applyShapeGroupMetadata({
6571
+ group: v,
6264
6572
  presetKey: t,
6265
6573
  presetCanRound: n,
6266
6574
  width: a,
@@ -6271,10 +6579,10 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6271
6579
  alignH: u,
6272
6580
  alignV: d,
6273
6581
  padding: f,
6274
- style: h,
6275
- rounding: g
6276
- }), _.rehydrateRuntimeState(), Un({ group: _ }), En({ text: i }), rn({
6277
- group: _,
6582
+ style: g,
6583
+ rounding: _
6584
+ }), v.rehydrateRuntimeState(), tr({ group: v }), Rn({ text: i }), ln({
6585
+ group: v,
6278
6586
  shape: r,
6279
6587
  text: i,
6280
6588
  width: a,
@@ -6282,9 +6590,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6282
6590
  alignH: u,
6283
6591
  alignV: d,
6284
6592
  padding: f,
6593
+ shapeTextAutoExpandEnabled: l,
6285
6594
  internalShapeTextInset: p,
6286
- changedPadding: m
6287
- }), _.shapeReplaceBoxWidth = Math.max(1, _.shapeBaseWidth ?? a), _.shapeReplaceBoxHeight = Math.max(1, _.shapeBaseHeight ?? o), this._detachShapeGroupAutoLayout({ group: _ }), _;
6595
+ resolveInternalShapeTextInset: m,
6596
+ changedPadding: h
6597
+ }), v.shapeReplaceBoxWidth = Math.max(1, v.shapeBaseWidth ?? a), v.shapeReplaceBoxHeight = Math.max(1, v.shapeBaseHeight ?? o), this._detachShapeGroupAutoLayout({ group: v }), v;
6288
6598
  }
6289
6599
  _applyShapeGroupMetadata({ group: e, presetKey: t, presetCanRound: n, width: r, height: i, manualWidth: a, manualHeight: o, replaceBoxWidth: s, replaceBoxHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, style: p, rounding: m }) {
6290
6600
  let h = p.strokeDashArray ? p.strokeDashArray.slice() : p.strokeDashArray ?? null;
@@ -6334,7 +6644,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6334
6644
  return s.set({
6335
6645
  shapeNodeType: "text",
6336
6646
  splitByGrapheme: !1
6337
- }), En({ text: s }), s;
6647
+ }), Rn({ text: s }), s;
6338
6648
  }
6339
6649
  _applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
6340
6650
  let i = {};
@@ -6442,64 +6752,83 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6442
6752
  let { width: n } = e.getMontageAreaSceneBounds();
6443
6753
  return !Number.isFinite(n) || n <= 0 ? null : n;
6444
6754
  }
6445
- _resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r }) {
6446
- let i = this._resolveMontageAreaWidth();
6447
- return i ? an({
6755
+ _resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, resolvePaddingForWidth: i }) {
6756
+ let a = this._resolveMontageAreaWidth();
6757
+ return a ? dn({
6448
6758
  text: e,
6449
6759
  currentWidth: t,
6450
6760
  minimumWidth: n,
6451
6761
  padding: r,
6452
- montageAreaWidth: i
6762
+ montageAreaWidth: a,
6763
+ resolvePaddingForWidth: i
6453
6764
  }) : Math.max(1, t, n);
6454
6765
  }
6455
- _resolveShapeLayoutWidth({ text: e, currentWidth: t, manualWidth: n, shapeTextAutoExpandEnabled: r, padding: i }) {
6766
+ _resolveShapeLayoutWidth({ text: e, currentWidth: t, manualWidth: n, shapeTextAutoExpandEnabled: r, padding: i, resolvePaddingForWidth: a }) {
6456
6767
  return r ? this._resolveAutoExpandShapeWidth({
6457
6768
  text: e,
6458
6769
  currentWidth: t,
6459
6770
  minimumWidth: n,
6460
- padding: i
6771
+ padding: i,
6772
+ resolvePaddingForWidth: a
6461
6773
  }) : Math.max(1, n);
6462
6774
  }
6463
6775
  _resolveShapeTextHorizontalAlign({ group: e, textStyle: t }) {
6464
6776
  let n = t?.align;
6465
6777
  return n === "left" || n === "center" || n === "right" || n === "justify" ? n : e.shapeAlignHorizontal ?? "center";
6466
6778
  }
6467
- _applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, minimumReplaceBox: l, expandShapeHeightToFitText: u = !0, changedPadding: d }) {
6468
- let f = this._resolveCurrentDimensions({ group: e }), p = this._resolveManualDimensions({ group: e }), m = this._resolveGroupUserPadding({ group: e }), h = f.width;
6469
- h = i === void 0 ? this._resolveShapeLayoutWidth({
6470
- text: n,
6471
- currentWidth: f.width,
6472
- manualWidth: p.width,
6473
- shapeTextAutoExpandEnabled: this._isShapeTextAutoExpandEnabled({ group: e }),
6474
- padding: Ht({
6475
- base: c ?? this._resolveGroupInternalShapeTextInset({
6476
- group: e,
6477
- width: h,
6478
- height: Math.max(1, a ?? f.height)
6479
- }),
6480
- addition: m
6481
- })
6482
- }) : Math.max(1, i);
6483
- let g = Math.max(1, a ?? f.height), _ = c ?? this._resolveGroupInternalShapeTextInset({
6779
+ _applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, minimumReplaceBox: d, expandShapeHeightToFitText: f = !0, changedPadding: p }) {
6780
+ let m = this._resolveCurrentDimensions({ group: e }), h = this._resolveManualDimensions({ group: e }), g = this._resolveGroupUserPadding({ group: e }), _ = this._isShapeTextAutoExpandEnabled({ group: e }), v = l ?? (({ width: t, height: n }) => c ?? this._resolveGroupInternalShapeTextInset({
6484
6781
  group: e,
6485
- width: h,
6486
- height: g
6487
- }), v = r ?? this.editor.canvasManager.getObjectPlacement({ object: e });
6488
- rn({
6782
+ width: t,
6783
+ height: n
6784
+ })), y = m.width;
6785
+ if (i !== void 0) y = Math.max(1, i);
6786
+ else {
6787
+ let e = Math.max(1, a ?? m.height);
6788
+ y = this._resolveShapeLayoutWidth({
6789
+ text: n,
6790
+ currentWidth: m.width,
6791
+ manualWidth: h.width,
6792
+ shapeTextAutoExpandEnabled: _,
6793
+ padding: Ht({
6794
+ base: v({
6795
+ width: y,
6796
+ height: e
6797
+ }),
6798
+ addition: g
6799
+ }),
6800
+ resolvePaddingForWidth: ({ width: t }) => Ht({
6801
+ base: v({
6802
+ width: t,
6803
+ height: e
6804
+ }),
6805
+ addition: g
6806
+ })
6807
+ });
6808
+ }
6809
+ let b = Math.max(1, a ?? m.height), x = v({
6810
+ width: y,
6811
+ height: b
6812
+ }), S = r ?? this.editor.canvasManager.getObjectPlacement({ object: e }), C = u ? this._resolveMontageAreaWidth() : void 0;
6813
+ ln({
6489
6814
  group: e,
6490
6815
  shape: t,
6491
6816
  text: n,
6492
- width: h,
6493
- height: g,
6817
+ width: y,
6818
+ height: b,
6494
6819
  alignH: o ?? e.shapeAlignHorizontal ?? "center",
6495
6820
  alignV: s ?? e.shapeAlignVertical ?? "middle",
6496
- padding: m,
6497
- internalShapeTextInset: _,
6498
- expandShapeHeightToFitText: u,
6499
- changedPadding: d
6500
- }), e.shapeReplaceBoxWidth = Math.max(1, l?.width ?? 0, e.shapeBaseWidth ?? h), e.shapeReplaceBoxHeight = Math.max(1, l?.height ?? 0, e.shapeBaseHeight ?? g), this.editor.canvasManager.applyObjectPlacement({
6821
+ padding: g,
6822
+ shapeTextAutoExpandEnabled: _,
6823
+ internalShapeTextInset: x,
6824
+ resolveInternalShapeTextInset: v,
6825
+ preserveAspectRatio: u,
6826
+ montageAreaWidth: C,
6827
+ expandShapeHeightToFitText: f,
6828
+ changedPadding: p
6829
+ }), e.shapeReplaceBoxWidth = Math.max(1, d?.width ?? 0, e.shapeBaseWidth ?? y), e.shapeReplaceBoxHeight = Math.max(1, d?.height ?? 0, e.shapeBaseHeight ?? b), this.editor.canvasManager.applyObjectPlacement({
6501
6830
  object: e,
6502
- placement: v
6831
+ placement: S
6503
6832
  });
6504
6833
  }
6505
6834
  _syncShapeTextLayoutAfterTextMutation({ textNode: e, textStyle: t }) {
@@ -6525,7 +6854,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6525
6854
  return this.editingPlacements.get(e) || this.editor.canvasManager.getObjectPlacement({ object: e });
6526
6855
  }
6527
6856
  _detachShapeGroupAutoLayout({ group: e }) {
6528
- Dn({ group: e });
6857
+ zn({ group: e });
6529
6858
  }
6530
6859
  _resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
6531
6860
  if (e) return e;
@@ -6544,11 +6873,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6544
6873
  _resolveShapeStyle({ options: e, fallback: t }) {
6545
6874
  let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
6546
6875
  return {
6547
- fill: n ?? t?.shapeFill ?? or,
6876
+ fill: n ?? t?.shapeFill ?? vr,
6548
6877
  stroke: r ?? t?.shapeStroke ?? null,
6549
- strokeWidth: i ?? t?.shapeStrokeWidth ?? sr,
6878
+ strokeWidth: i ?? t?.shapeStrokeWidth ?? yr,
6550
6879
  strokeDashArray: s ?? null,
6551
- opacity: o ?? t?.shapeOpacity ?? cr
6880
+ opacity: o ?? t?.shapeOpacity ?? br
6552
6881
  };
6553
6882
  }
6554
6883
  _collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
@@ -6604,7 +6933,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6604
6933
  }
6605
6934
  return null;
6606
6935
  }
6607
- }, ur = class {
6936
+ }, Sr = class {
6608
6937
  constructor({ editor: e }) {
6609
6938
  this.editor = e, this.clipboard = null;
6610
6939
  }
@@ -6860,12 +7189,12 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6860
7189
  }), !1;
6861
7190
  }
6862
7191
  }
6863
- }, dr = class t {
7192
+ }, Cr = class t {
6864
7193
  constructor({ editor: e }) {
6865
7194
  this.editor = e;
6866
7195
  }
6867
7196
  lockObject({ object: e, skipInnerObjects: n, withoutSave: r } = {}) {
6868
- let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s = Bn({ target: o }) ?? o;
7197
+ let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s = Qn({ target: o }) ?? o;
6869
7198
  if (!s || s.locked) return;
6870
7199
  let c = {
6871
7200
  lockMovementX: !0,
@@ -6887,7 +7216,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6887
7216
  });
6888
7217
  }
6889
7218
  unlockObject({ object: e, withoutSave: n } = {}) {
6890
- let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o = Bn({ target: a }) ?? a;
7219
+ let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o = Qn({ target: a }) ?? a;
6891
7220
  if (!o) return;
6892
7221
  let s = {
6893
7222
  lockMovementX: !1,
@@ -6925,7 +7254,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6925
7254
  !(n instanceof _) || !n.isEditing || n.exitEditing();
6926
7255
  }
6927
7256
  }
6928
- }, fr = class {
7257
+ }, wr = class {
6929
7258
  constructor({ editor: e }) {
6930
7259
  this.editor = e;
6931
7260
  }
@@ -6991,7 +7320,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6991
7320
  i.resumeHistory(), n || i.saveState();
6992
7321
  }
6993
7322
  }
6994
- }, pr = class t {
7323
+ }, Tr = class t {
6995
7324
  constructor({ editor: e }) {
6996
7325
  this.lastSelection = [], this.isCtrlSelectionBoxActive = !1, this.isSelectionMergeInProgress = !1, this.editor = e, this.selectionKey = this._resolveSelectionKey(), this.handleTextEditingEnteredBound = this._handleTextEditingEntered.bind(this), this.handleTextEditingExitedBound = this._handleTextEditingExited.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.handleSelectionMergeBound = this._handleSelectionMerge.bind(this), this.handleSelectionChangeBound = this._handleSelectionChange.bind(this), this.handleSelectionClearedBound = this._handleSelectionCleared.bind(this), this.handleSelectionBoxStartBound = this._handleSelectionBoxStart.bind(this), this.handleSelectionBoxEndBound = this._handleSelectionBoxEnd.bind(this), this._applySelectionKey({ selectionKey: this.selectionKey }), this._bindEvents();
6997
7326
  }
@@ -7185,7 +7514,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7185
7514
  let { options: e } = this.editor, { selectionKey: t } = e;
7186
7515
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
7187
7516
  }
7188
- }, mr = class e {
7517
+ }, Er = class e {
7189
7518
  constructor({ editor: e }) {
7190
7519
  this.editor = e;
7191
7520
  }
@@ -7225,7 +7554,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7225
7554
  };
7226
7555
  return i.fire("editor:objects-deleted", l), l;
7227
7556
  }
7228
- }, hr = {
7557
+ }, Dr = {
7229
7558
  IMAGE_MANAGER: {
7230
7559
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
7231
7560
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -7263,7 +7592,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7263
7592
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
7264
7593
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
7265
7594
  }
7266
- }, gr = class e {
7595
+ }, Or = class e {
7267
7596
  constructor({ editor: e }) {
7268
7597
  this._buffer = [], this.editor = e;
7269
7598
  }
@@ -7321,9 +7650,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7321
7650
  }), this.editor.canvas.fire("editor:warning", s);
7322
7651
  }
7323
7652
  static isValidErrorCode(e) {
7324
- return e ? Object.values(hr).some((t) => Object.values(t).includes(e)) : !1;
7653
+ return e ? Object.values(Dr).some((t) => Object.values(t).includes(e)) : !1;
7325
7654
  }
7326
- }, _r = class {
7655
+ }, kr = class {
7327
7656
  constructor({ editor: e }) {
7328
7657
  this.currentBounds = null, this.editor = e;
7329
7658
  }
@@ -7372,32 +7701,32 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7372
7701
  updateBounds() {
7373
7702
  this.currentBounds = this.calculatePanBounds();
7374
7703
  }
7375
- }, vr = ({ textbox: e }) => {
7704
+ }, Ar = ({ textbox: e }) => {
7376
7705
  if (!e.isEditing) return null;
7377
7706
  let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
7378
7707
  return t === n ? null : {
7379
7708
  start: Math.min(t, n),
7380
7709
  end: Math.max(t, n)
7381
7710
  };
7382
- }, yr = ({ textbox: e }) => {
7711
+ }, jr = ({ textbox: e }) => {
7383
7712
  let t = e.text?.length ?? 0;
7384
7713
  return t <= 0 ? null : {
7385
7714
  start: 0,
7386
7715
  end: t
7387
7716
  };
7388
- }, br = ({ textbox: e, range: t }) => {
7717
+ }, Mr = ({ textbox: e, range: t }) => {
7389
7718
  if (!t) return !1;
7390
7719
  let n = e.text?.length ?? 0;
7391
7720
  return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
7392
- }, xr = ({ textbox: e, styles: t, range: n }) => {
7721
+ }, Nr = ({ textbox: e, styles: t, range: n }) => {
7393
7722
  if (!t || !Object.keys(t).length) return !1;
7394
7723
  let { start: r, end: i } = n;
7395
7724
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
7396
- }, Sr = ({ textbox: e, range: t, property: n }) => {
7725
+ }, Pr = ({ textbox: e, range: t, property: n }) => {
7397
7726
  if (!t) return;
7398
7727
  let r = e.getSelectionStyles(t.start, t.end, !0);
7399
7728
  if (r.length) return r[0]?.[n];
7400
- }, Cr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", wr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Tr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Er = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Dr = class e extends _ {
7729
+ }, Fr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Ir = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Lr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Rr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), zr = class e extends _ {
7401
7730
  static {
7402
7731
  this.type = "background-textbox";
7403
7732
  }
@@ -7531,7 +7860,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7531
7860
  this._removeShadow(e);
7532
7861
  }
7533
7862
  _getDecorationColorAt(e, t) {
7534
- let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = wr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Cr({
7863
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Ir({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Fr({
7535
7864
  strokeColor: i,
7536
7865
  width: r
7537
7866
  });
@@ -7547,22 +7876,22 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7547
7876
  _getCornerRadii({ width: e, height: t }) {
7548
7877
  let n = e / 2, r = t / 2, i = Math.min(n, r);
7549
7878
  return {
7550
- bottomLeft: Er({
7879
+ bottomLeft: Rr({
7551
7880
  value: this.radiusBottomLeft ?? 0,
7552
7881
  min: 0,
7553
7882
  max: i
7554
7883
  }),
7555
- bottomRight: Er({
7884
+ bottomRight: Rr({
7556
7885
  value: this.radiusBottomRight ?? 0,
7557
7886
  min: 0,
7558
7887
  max: i
7559
7888
  }),
7560
- topLeft: Er({
7889
+ topLeft: Rr({
7561
7890
  value: this.radiusTopLeft ?? 0,
7562
7891
  min: 0,
7563
7892
  max: i
7564
7893
  }),
7565
- topRight: Er({
7894
+ topRight: Rr({
7566
7895
  value: this.radiusTopRight ?? 0,
7567
7896
  min: 0,
7568
7897
  max: i
@@ -7580,7 +7909,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7580
7909
  _getEffectiveBackgroundFill() {
7581
7910
  let e = this.backgroundColor;
7582
7911
  if (!e) return null;
7583
- let t = Er({
7912
+ let t = Rr({
7584
7913
  value: this.backgroundOpacity ?? 1,
7585
7914
  min: 0,
7586
7915
  max: 1
@@ -7588,7 +7917,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7588
7917
  try {
7589
7918
  r = new n(e);
7590
7919
  } catch (t) {
7591
- return gr.emitError({
7920
+ return Or.emitError({
7592
7921
  origin: "BackgroundTextbox",
7593
7922
  method: "_getEffectiveBackgroundFill",
7594
7923
  code: "INVALID_COLOR_VALUE",
@@ -7602,19 +7931,19 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7602
7931
  return r.setAlpha(t), r.toRgba();
7603
7932
  }
7604
7933
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
7605
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Er({
7934
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Rr({
7606
7935
  value: c,
7607
7936
  min: 0,
7608
7937
  max: a
7609
- }), p = Er({
7938
+ }), p = Rr({
7610
7939
  value: l,
7611
7940
  min: 0,
7612
7941
  max: a
7613
- }), m = Er({
7942
+ }), m = Rr({
7614
7943
  value: u,
7615
7944
  min: 0,
7616
7945
  max: a
7617
- }), h = Er({
7946
+ }), h = Rr({
7618
7947
  value: d,
7619
7948
  min: 0,
7620
7949
  max: a
@@ -7625,9 +7954,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7625
7954
  let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
7626
7955
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
7627
7956
  }
7628
- }, Or = () => {
7629
- y?.setClass && y.setClass(Dr, "background-textbox");
7630
- }, kr = .01, Ar = ({ textbox: e, lineIndices: t, updates: n }) => {
7957
+ }, Br = () => {
7958
+ y?.setClass && y.setClass(zr, "background-textbox");
7959
+ }, Vr = .01, Hr = ({ textbox: e, lineIndices: t, updates: n }) => {
7631
7960
  if (!t.length) return !1;
7632
7961
  let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
7633
7962
  if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
@@ -7639,7 +7968,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7639
7968
  r !== void 0 && d?.fontFamily !== r && (f.fontFamily = r, p = !0), i !== void 0 && d?.fontSize !== i && (f.fontSize = i, p = !0), a !== void 0 && d?.fill !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && d?.stroke !== void 0 && (delete f.stroke, p = !0), o !== null && d?.stroke !== o && (f.stroke = o, p = !0)), p && (u ||= (c = { ...c }, !0), c[n] = f, l = !0);
7640
7969
  }
7641
7970
  return l && (e.lineFontDefaults = c), l;
7642
- }, jr = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
7971
+ }, Ur = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
7643
7972
  let r = e.length;
7644
7973
  if (r === 0) return {
7645
7974
  lineStyles: t,
@@ -7671,7 +8000,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7671
8000
  lineStyles: l,
7672
8001
  changed: u
7673
8002
  };
7674
- }, Mr = ({ lineFontDefaults: e }) => {
8003
+ }, Wr = ({ lineFontDefaults: e }) => {
7675
8004
  if (!e) return;
7676
8005
  let t = {};
7677
8006
  for (let n in e) {
@@ -7682,7 +8011,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7682
8011
  i && (t[r] = { ...i });
7683
8012
  }
7684
8013
  return t;
7685
- }, Nr = ({ lineFontDefaults: e, scale: t }) => {
8014
+ }, Gr = ({ lineFontDefaults: e, scale: t }) => {
7686
8015
  if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
7687
8016
  let n = {}, r = !1, i = !1;
7688
8017
  for (let a in e) {
@@ -7699,18 +8028,18 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7699
8028
  n[o] = c, r = !0;
7700
8029
  }
7701
8030
  if (!(!r || !i)) return n;
7702
- }, Pr = ({ textbox: e, text: t }) => {
8031
+ }, Kr = ({ textbox: e, text: t }) => {
7703
8032
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
7704
8033
  for (let t = 0; t < r; t += 1) {
7705
8034
  let n = e.getLineWidth(t);
7706
8035
  n > i && (i = n);
7707
8036
  }
7708
8037
  return i;
7709
- }, Fr = ({ origin: e, size: t }) => e === "left" || e === "top" || e === "start" || e === 0 ? 0 : e === "right" || e === "bottom" || e === "end" || e === 1 ? t : t / 2, Ir = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
7710
- let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new p(l + Fr({
8038
+ }, qr = ({ origin: e, size: t }) => e === "left" || e === "top" || e === "start" || e === 0 ? 0 : e === "right" || e === "bottom" || e === "end" || e === 1 ? t : t / 2, Jr = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
8039
+ let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new p(l + qr({
7711
8040
  origin: t,
7712
8041
  size: r
7713
- }), u + Fr({
8042
+ }), u + qr({
7714
8043
  origin: n,
7715
8044
  size: i
7716
8045
  })), f = e.getPointByOrigin("center", "center"), m = e, h = typeof m.calcTransformMatrix == "function" ? m.calcTransformMatrix() : null, g = Array.isArray(h) ? new p(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new p(f.x + d.x, f.y + d.y);
@@ -7720,13 +8049,13 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7720
8049
  originX: t,
7721
8050
  originY: n
7722
8051
  };
7723
- }, Lr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
8052
+ }, Yr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
7724
8053
  e.setCoords();
7725
8054
  let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
7726
8055
  if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
7727
8056
  let s = 0;
7728
8057
  return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
7729
- }, Rr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, zr = ({ stylesList: e }) => {
8058
+ }, Xr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Zr = ({ stylesList: e }) => {
7730
8059
  let t = e.length;
7731
8060
  if (!t) return !1;
7732
8061
  for (let n = 0; n < t; n += 1) {
@@ -7736,16 +8065,16 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7736
8065
  if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
7737
8066
  }
7738
8067
  return !1;
7739
- }, Br = ({ textbox: e }) => {
7740
- let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = Rr({
8068
+ }, Qr = ({ textbox: e }) => {
8069
+ let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = Xr({
7741
8070
  rawValue: t,
7742
8071
  calculatedValue: a
7743
- }), c = Rr({
8072
+ }), c = Xr({
7744
8073
  rawValue: n,
7745
8074
  calculatedValue: o
7746
8075
  }), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
7747
8076
  return l !== null && l !== s && (d.width = Math.max(0, l)), u !== null && u !== c && (d.height = Math.max(0, u)), Object.keys(d).length ? (e.set(d), !0) : !1;
7748
- }, Vr = ({ textbox: e }) => {
8077
+ }, $r = ({ textbox: e }) => {
7749
8078
  let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
7750
8079
  return {
7751
8080
  width: t,
@@ -7763,9 +8092,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7763
8092
  bottomLeft: f
7764
8093
  },
7765
8094
  styles: JSON.parse(JSON.stringify(r)),
7766
- lineFontDefaults: Mr({ lineFontDefaults: i })
8095
+ lineFontDefaults: Wr({ lineFontDefaults: i })
7767
8096
  };
7768
- }, Hr = ({ base: e }) => {
8097
+ }, ei = ({ base: e }) => {
7769
8098
  let t = 1 / Math.max(1, e.width), n = [e.fontSize];
7770
8099
  Object.values(e.styles).forEach((e) => {
7771
8100
  Object.values(e).forEach((e) => {
@@ -7782,7 +8111,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7782
8111
  fontScale: r,
7783
8112
  proportionalScale: Math.max(t, r)
7784
8113
  };
7785
- }, Ur = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
8114
+ }, ti = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
7786
8115
  let { width: f, fontSize: m, padding: h, radii: g, styles: _, lineFontDefaults: v } = n, y = Math.max(1, f * r), b = d ? Math.max(1, Math.round(y)) : y, x = Math.max(Math.min(8, m), m * i), S = Object.keys(_).length > 0, C;
7787
8116
  if (s && S) {
7788
8117
  let e = {};
@@ -7801,7 +8130,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7801
8130
  }), Object.keys(e).length && (C = e);
7802
8131
  }
7803
8132
  let w;
7804
- s && (w = Nr({
8133
+ s && (w = Gr({
7805
8134
  lineFontDefaults: v,
7806
8135
  scale: i
7807
8136
  }));
@@ -7815,7 +8144,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7815
8144
  topRight: Math.max(0, g.topRight * i),
7816
8145
  bottomRight: Math.max(0, g.bottomRight * i),
7817
8146
  bottomLeft: Math.max(0, g.bottomLeft * i)
7818
- } : g, D = e.width ?? f, O = Math.abs(b - D) > kr;
8147
+ } : g, D = e.width ?? f, O = Math.abs(b - D) > Vr;
7819
8148
  u && O && (e.autoExpand = !1), C && (e.styles = C), w && (e.lineFontDefaults = w), e.set({
7820
8149
  width: b,
7821
8150
  fontSize: s ? x : m,
@@ -7837,7 +8166,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7837
8166
  } finally {
7838
8167
  e.shouldRoundDimensionsOnInit = k;
7839
8168
  }
7840
- let A = d ? Br({ textbox: e }) : !1;
8169
+ let A = d ? Qr({ textbox: e }) : !1;
7841
8170
  return A && (e.dirty = !0), o ? (e.set({
7842
8171
  originX: a.originX,
7843
8172
  originY: a.originY
@@ -7851,18 +8180,18 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7851
8180
  appliedWidth: e.width ?? b,
7852
8181
  dimensionsRounded: A
7853
8182
  });
7854
- }, Wr = ({ transform: e }) => {
8183
+ }, ni = ({ transform: e }) => {
7855
8184
  let { corner: t = "", action: n = "" } = e;
7856
8185
  return {
7857
8186
  isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
7858
8187
  isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
7859
8188
  isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
7860
8189
  };
7861
- }, Gr = ({ textbox: e, transform: t, appliedWidth: n }) => {
8190
+ }, ri = ({ textbox: e, transform: t, appliedWidth: n }) => {
7862
8191
  t.scaleX = 1, t.scaleY = 1;
7863
8192
  let { original: r } = t;
7864
8193
  r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
7865
- }, Kr = ({ textbox: e, transform: t, scenePoint: n }) => {
8194
+ }, ii = ({ textbox: e, transform: t, scenePoint: n }) => {
7866
8195
  let { x: r, y: i } = e._getTransformedDimensions();
7867
8196
  if (r <= 0 || i <= 0) return null;
7868
8197
  let a = b.getLocalPoint(t, t.originX, t.originY, n.x, n.y), o = t, s = typeof o.signX == "number" && a.x * o.signX <= 0, c = typeof o.signY == "number" && a.y * o.signY <= 0, l = Math.abs(a.x / r), u = Math.abs(a.y / i);
@@ -7872,27 +8201,27 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7872
8201
  stepScaleX: l,
7873
8202
  stepScaleY: u
7874
8203
  };
7875
- }, qr = 1e-4;
7876
- function Jr(e) {
8204
+ }, ai = 1e-4;
8205
+ function oi(e) {
7877
8206
  return !!e && e instanceof _;
7878
8207
  }
7879
- function Yr(e) {
7880
- if (!Jr(e)) return !1;
8208
+ function si(e) {
8209
+ if (!oi(e)) return !1;
7881
8210
  let t = e.group;
7882
8211
  return e.shapeNodeType === "text" && t?.shapeComposite === !0;
7883
8212
  }
7884
- var Xr = class {
8213
+ var ci = class {
7885
8214
  constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
7886
8215
  this.handleMouseMove = (e) => {
7887
8216
  let t = this.canvas._currentTransform;
7888
8217
  if (!t) return;
7889
8218
  let { target: n } = t;
7890
- if (!Jr(n) || Yr(n)) return;
8219
+ if (!oi(n) || si(n)) return;
7891
8220
  let r = this.scalingState.get(n);
7892
8221
  if (!r || !e.e) return;
7893
- let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Wr({ transform: t });
8222
+ let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = ni({ transform: t });
7894
8223
  if (!a && !o && !i) return;
7895
- let s = Kr({
8224
+ let s = ii({
7896
8225
  textbox: n,
7897
8226
  transform: t,
7898
8227
  scenePoint: this.canvas.getScenePoint(e.e)
@@ -7915,20 +8244,20 @@ var Xr = class {
7915
8244
  }, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
7916
8245
  if (i) {
7917
8246
  let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
7918
- if (Math.abs(t - r.lastAllowedScaleX) <= qr) return;
8247
+ if (Math.abs(t - r.lastAllowedScaleX) <= ai) return;
7919
8248
  j = t, M = t;
7920
8249
  } else {
7921
8250
  if (a) {
7922
8251
  let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
7923
- Math.abs(t - r.lastAllowedScaleX) > qr && (j = t);
8252
+ Math.abs(t - r.lastAllowedScaleX) > ai && (j = t);
7924
8253
  }
7925
8254
  if (o) {
7926
8255
  let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
7927
- Math.abs(t - r.lastAllowedScaleY) > qr && (M = t);
8256
+ Math.abs(t - r.lastAllowedScaleY) > ai && (M = t);
7928
8257
  }
7929
- if (Math.abs(j - r.lastAllowedScaleX) <= qr && Math.abs(M - r.lastAllowedScaleY) <= qr) return;
8258
+ if (Math.abs(j - r.lastAllowedScaleX) <= ai && Math.abs(M - r.lastAllowedScaleY) <= ai) return;
7930
8259
  }
7931
- let { appliedWidth: N, dimensionsRounded: P } = Ur({
8260
+ let { appliedWidth: N, dimensionsRounded: P } = ti({
7932
8261
  textbox: n,
7933
8262
  canvasManager: this.canvasManager,
7934
8263
  base: r.startBase,
@@ -7942,7 +8271,7 @@ var Xr = class {
7942
8271
  shouldDisableAutoExpandOnHorizontalChange: a,
7943
8272
  shouldRoundDimensions: !i
7944
8273
  });
7945
- Gr({
8274
+ ri({
7946
8275
  textbox: n,
7947
8276
  transform: t,
7948
8277
  appliedWidth: N
@@ -7963,12 +8292,12 @@ var Xr = class {
7963
8292
  }), this.canvas.requestRenderAll();
7964
8293
  }, this.handleObjectScaling = (t) => {
7965
8294
  let { target: n, transform: r } = t;
7966
- if (n instanceof e || !Jr(n) || Yr(n) || !r) return;
8295
+ if (n instanceof e || !oi(n) || si(n) || !r) return;
7967
8296
  n.isScaling = !0;
7968
8297
  let i = this._ensureScalingState({
7969
8298
  textbox: n,
7970
8299
  transform: r
7971
- }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Wr({ transform: r }), d = r.corner ?? "", f = c || u;
8300
+ }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = ni({ transform: r }), d = r.corner ?? "", f = c || u;
7972
8301
  if (!l && !u && !c) return;
7973
8302
  let p = n.scaleX ?? r.scaleX ?? 1, m = n.scaleY ?? r.scaleY ?? 1, h = Math.abs(p) || 1, g = Math.abs(m) || 1, _ = r.originX ?? n.originX ?? "center", v = r.originY ?? n.originY ?? "center", y = this.canvasManager.getObjectPlacement({
7974
8303
  object: n,
@@ -7983,7 +8312,7 @@ var Xr = class {
7983
8312
  N = e, P = e;
7984
8313
  }
7985
8314
  } else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
7986
- let { appliedWidth: ee, dimensionsRounded: te } = Ur({
8315
+ let { appliedWidth: L, dimensionsRounded: ee } = ti({
7987
8316
  textbox: n,
7988
8317
  canvasManager: this.canvasManager,
7989
8318
  base: a,
@@ -7997,14 +8326,14 @@ var Xr = class {
7997
8326
  shouldDisableAutoExpandOnHorizontalChange: l,
7998
8327
  shouldRoundDimensions: !c
7999
8328
  });
8000
- Gr({
8329
+ ri({
8001
8330
  textbox: n,
8002
8331
  transform: r,
8003
- appliedWidth: ee
8332
+ appliedWidth: L
8004
8333
  }), this.canvas.requestRenderAll(), I && this._updateScalingStateAfterLiveCommit({
8005
8334
  textbox: n,
8006
8335
  state: i,
8007
- appliedWidth: ee,
8336
+ appliedWidth: L,
8008
8337
  previousFontSize: O ?? s,
8009
8338
  previousPadding: {
8010
8339
  top: b,
@@ -8019,7 +8348,7 @@ var Xr = class {
8019
8348
  bottomLeft: D
8020
8349
  },
8021
8350
  previousWidth: M,
8022
- dimensionsRounded: te,
8351
+ dimensionsRounded: ee,
8023
8352
  isCornerHandle: c,
8024
8353
  isHorizontalHandle: l,
8025
8354
  isVerticalHandle: u,
@@ -8030,7 +8359,7 @@ var Xr = class {
8030
8359
  let { target: n } = t;
8031
8360
  if (n instanceof e) {
8032
8361
  let t = n.getObjects();
8033
- if (!t.some((e) => Jr(e))) return;
8362
+ if (!t.some((e) => oi(e))) return;
8034
8363
  let { scaleX: r = 1, scaleY: i = 1 } = n;
8035
8364
  if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
8036
8365
  this.canvas.discardActiveObject(), t.forEach((e) => {
@@ -8040,7 +8369,7 @@ var Xr = class {
8040
8369
  this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
8041
8370
  return;
8042
8371
  }
8043
- if (!Jr(n) || Yr(n)) return;
8372
+ if (!oi(n) || si(n)) return;
8044
8373
  n.isScaling = !1;
8045
8374
  let r = this.scalingState.get(n);
8046
8375
  if (this.scalingState.delete(n), !r?.hasScalingChange) return;
@@ -8065,11 +8394,11 @@ var Xr = class {
8065
8394
  }, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
8066
8395
  }
8067
8396
  commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
8068
- if (!Jr(e) || Yr(e)) return !1;
8397
+ if (!oi(e) || si(e)) return !1;
8069
8398
  let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
8070
8399
  if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
8071
- let i = Vr({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
8072
- return Ur({
8400
+ let i = $r({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
8401
+ return ti({
8073
8402
  textbox: e,
8074
8403
  canvasManager: this.canvasManager,
8075
8404
  base: i,
@@ -8085,7 +8414,7 @@ var Xr = class {
8085
8414
  _ensureScalingState({ textbox: e, transform: t }) {
8086
8415
  let n = this.scalingState.get(e);
8087
8416
  if (!n) {
8088
- let r = Vr({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = Hr({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
8417
+ let r = $r({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = ei({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
8089
8418
  n = {
8090
8419
  startBase: r,
8091
8420
  startObjectPlacement: i,
@@ -8118,7 +8447,7 @@ var Xr = class {
8118
8447
  topRight: e.radiusTopRight ?? 0,
8119
8448
  bottomRight: e.radiusBottomRight ?? 0,
8120
8449
  bottomLeft: e.radiusBottomLeft ?? 0
8121
- }, v = Math.abs(n - o) > kr, y = Math.abs(h - r) > kr, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
8450
+ }, v = Math.abs(n - o) > Vr, y = Math.abs(h - r) > Vr, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
8122
8451
  if (c) {
8123
8452
  let e = h / Math.max(1, m);
8124
8453
  S = e, C = e;
@@ -8139,7 +8468,7 @@ var Xr = class {
8139
8468
  originY: a
8140
8469
  });
8141
8470
  }
8142
- }, Zr = ({ textbox: e }) => {
8471
+ }, li = ({ textbox: e }) => {
8143
8472
  let t = e.text ?? "";
8144
8473
  if (!t.length) return [];
8145
8474
  let n = t.split("\n"), r = [], i = 0;
@@ -8151,7 +8480,7 @@ var Xr = class {
8151
8480
  });
8152
8481
  }
8153
8482
  return r;
8154
- }, Qr = ({ range: e, text: t }) => {
8483
+ }, ui = ({ range: e, text: t }) => {
8155
8484
  if (!e) return null;
8156
8485
  let n = t.length;
8157
8486
  if (n <= 0) return null;
@@ -8160,8 +8489,8 @@ var Xr = class {
8160
8489
  start: l,
8161
8490
  end: u
8162
8491
  };
8163
- }, $r = ({ textbox: e, range: t }) => {
8164
- let n = Zr({ textbox: e });
8492
+ }, di = ({ textbox: e, range: t }) => {
8493
+ let n = li({ textbox: e });
8165
8494
  if (!n.length) return t;
8166
8495
  let { start: r } = t, { end: i } = t;
8167
8496
  for (let e = 0; e < n.length; e += 1) {
@@ -8174,7 +8503,7 @@ var Xr = class {
8174
8503
  start: r,
8175
8504
  end: i
8176
8505
  };
8177
- }, ei = ({ textbox: e, range: t }) => {
8506
+ }, fi = ({ textbox: e, range: t }) => {
8178
8507
  let n = e.text ?? "";
8179
8508
  if (!n.length) return [];
8180
8509
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -8183,7 +8512,7 @@ var Xr = class {
8183
8512
  i > n && r < c && o.push(e), s = c + 1;
8184
8513
  }
8185
8514
  return o;
8186
- }, ti = ({ textbox: e, range: t }) => {
8515
+ }, pi = ({ textbox: e, range: t }) => {
8187
8516
  let n = e.text ?? "";
8188
8517
  if (!n.length) return [];
8189
8518
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -8192,20 +8521,20 @@ var Xr = class {
8192
8521
  r <= n && i >= c && o.push(e), s = c + 1;
8193
8522
  }
8194
8523
  return o;
8195
- }, ni = ({ previous: e, next: t }) => {
8524
+ }, mi = ({ previous: e, next: t }) => {
8196
8525
  let n = Math.min(e.length, t.length);
8197
8526
  for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
8198
8527
  return n;
8199
- }, ri = ({ text: e, charIndex: t }) => {
8528
+ }, hi = ({ text: e, charIndex: t }) => {
8200
8529
  let n = Math.max(0, Math.min(t, e.length)), r = 0;
8201
8530
  for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
8202
8531
  return r;
8203
- }, ii = ({ text: e, lineIndex: t }) => {
8532
+ }, gi = ({ text: e, lineIndex: t }) => {
8204
8533
  if (t <= 0) return 0;
8205
8534
  let n = 0;
8206
8535
  for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
8207
8536
  return e.length;
8208
- }, ai = class e {
8537
+ }, _i = class e {
8209
8538
  constructor({ editor: t }) {
8210
8539
  this._handleTextEditingEntered = (t) => {
8211
8540
  this.isTextEditingActive = !0;
@@ -8218,7 +8547,7 @@ var Xr = class {
8218
8547
  if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
8219
8548
  let r = e._isShapeOwnedTextbox(n), { text: i = "", uppercase: a, autoExpand: o } = n, s = !!a, c = o !== !1, l = i.toLocaleLowerCase(), u = r ? null : this.editingPlacementState?.get(n) ?? this.editor.canvasManager.getObjectPlacement({ object: n });
8220
8549
  if (s) {
8221
- let e = Tr({ value: l });
8550
+ let e = Lr({ value: l });
8222
8551
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
8223
8552
  } else n.textCaseRaw = i;
8224
8553
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
@@ -8236,7 +8565,7 @@ var Xr = class {
8236
8565
  let r = e._isShapeOwnedTextbox(n);
8237
8566
  this.editingPlacementState?.delete(n);
8238
8567
  let i = n.text ?? "";
8239
- n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Br({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
8568
+ n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Qr({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
8240
8569
  lockMovementX: !1,
8241
8570
  lockMovementY: !1
8242
8571
  }));
@@ -8263,7 +8592,7 @@ var Xr = class {
8263
8592
  transform: r,
8264
8593
  event: i ?? null
8265
8594
  });
8266
- }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new Xr({
8595
+ }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ci({
8267
8596
  canvas: t.canvas,
8268
8597
  canvasManager: t.canvasManager,
8269
8598
  persistScaledTextbox: ({ target: e, style: t }) => {
@@ -8272,15 +8601,15 @@ var Xr = class {
8272
8601
  style: t
8273
8602
  });
8274
8603
  }
8275
- }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Or();
8604
+ }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Br();
8276
8605
  }
8277
8606
  addText({ id: t = `text-${D()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: O = !1, withoutSave: k = !1, withoutAdding: A = !1, emitLifecycleEvents: j = !0 } = {}) {
8278
8607
  let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
8279
8608
  N.suspendHistory();
8280
- let F = i ?? this._getDefaultFontFamily(), I = wr({ width: m }), ee = Cr({
8609
+ let F = i ?? this._getDefaultFontFamily(), I = Ir({ width: m }), L = Fr({
8281
8610
  strokeColor: p,
8282
8611
  width: I
8283
- }), te = {
8612
+ }), ee = {
8284
8613
  id: t,
8285
8614
  fontFamily: F,
8286
8615
  fontSize: a,
@@ -8291,7 +8620,7 @@ var Xr = class {
8291
8620
  linethrough: u,
8292
8621
  textAlign: d,
8293
8622
  fill: f,
8294
- stroke: ee,
8623
+ stroke: L,
8295
8624
  strokeWidth: I,
8296
8625
  strokeUniform: !0,
8297
8626
  opacity: h,
@@ -8306,40 +8635,40 @@ var Xr = class {
8306
8635
  radiusBottomRight: w,
8307
8636
  radiusBottomLeft: T,
8308
8637
  ...E
8309
- }, L = new Dr(n, te), ne = r !== !1;
8310
- L.autoExpand = ne;
8311
- let re = E.left !== void 0 || E.top !== void 0;
8312
- if (L.textCaseRaw = L.text ?? "", l) {
8313
- let e = Tr({ value: L.textCaseRaw });
8314
- e !== L.text && L.set({ text: e });
8315
- }
8316
- Br({ textbox: L }) && (L.dirty = !0);
8317
- let R;
8318
- re && (R = M.resolveObjectPlacement({
8319
- object: L,
8638
+ }, R = new zr(n, ee), te = r !== !1;
8639
+ R.autoExpand = te;
8640
+ let ne = E.left !== void 0 || E.top !== void 0;
8641
+ if (R.textCaseRaw = R.text ?? "", l) {
8642
+ let e = Lr({ value: R.textCaseRaw });
8643
+ e !== R.text && R.set({ text: e });
8644
+ }
8645
+ Qr({ textbox: R }) && (R.dirty = !0);
8646
+ let z;
8647
+ ne && (z = M.resolveObjectPlacement({
8648
+ object: R,
8320
8649
  left: E.left,
8321
8650
  top: E.top,
8322
8651
  originX: E.originX,
8323
8652
  originY: E.originY,
8324
8653
  fallbackPoint: M.getMontageAreaSceneCenter()
8325
8654
  }));
8326
- let ie = ne && e._hasWrappedLinesBeyondExplicitBreaks(L);
8327
- return (re || ie) && this._normalizeTextboxAfterContentChange({
8328
- textbox: L,
8329
- placement: R,
8330
- shouldAutoExpand: ie,
8331
- clampToMontage: re
8332
- }), R || M.centerObjectToMontageArea({ object: L }), A || P.add(L), O || P.setActiveObject(L), P.requestRenderAll(), N.resumeHistory(), k || N.saveState(), j && P.fire("editor:text-added", {
8333
- textbox: L,
8655
+ let re = te && e._hasWrappedLinesBeyondExplicitBreaks(R);
8656
+ return (ne || re) && this._normalizeTextboxAfterContentChange({
8657
+ textbox: R,
8658
+ placement: z,
8659
+ shouldAutoExpand: re,
8660
+ clampToMontage: ne
8661
+ }), z || M.centerObjectToMontageArea({ object: R }), A || P.add(R), O || P.setActiveObject(R), P.requestRenderAll(), N.resumeHistory(), k || N.saveState(), j && P.fire("editor:text-added", {
8662
+ textbox: R,
8334
8663
  options: {
8335
- ...te,
8664
+ ...ee,
8336
8665
  text: n,
8337
8666
  bold: o,
8338
8667
  italic: s,
8339
8668
  strikethrough: u,
8340
8669
  align: d,
8341
8670
  color: f,
8342
- strokeColor: ee,
8671
+ strokeColor: L,
8343
8672
  strokeWidth: I
8344
8673
  },
8345
8674
  flags: {
@@ -8347,118 +8676,118 @@ var Xr = class {
8347
8676
  withoutSave: !!k,
8348
8677
  withoutAdding: !!A
8349
8678
  }
8350
- }), L;
8679
+ }), R;
8351
8680
  }
8352
8681
  updateText({ target: t, style: n = {}, withoutSave: r, skipRender: i, selectionRange: a, emitLifecycleEvents: o = !0 } = {}) {
8353
8682
  let s = this._resolveTextObject(t);
8354
8683
  if (!s) return null;
8355
8684
  let { text: c = "" } = s, { historyManager: l } = this.editor, { canvasManager: u } = this.editor, { canvas: d } = this;
8356
8685
  l.suspendHistory();
8357
- let f = e._getSnapshot(s), { text: p, autoExpand: m, fontFamily: h, fontSize: g, bold: _, italic: v, underline: y, uppercase: b, strikethrough: x, align: S, color: C, strokeColor: w, strokeWidth: T, opacity: E, backgroundColor: D, backgroundOpacity: O, paddingTop: k, paddingRight: A, paddingBottom: j, paddingLeft: M, radiusTopLeft: N, radiusTopRight: P, radiusBottomRight: F, radiusBottomLeft: I, left: ee, top: te, originX: L, originY: ne, ...re } = n, R = { ...re }, ie = u.resolveObjectPlacement({
8686
+ let f = e._getSnapshot(s), { text: p, autoExpand: m, fontFamily: h, fontSize: g, bold: _, italic: v, underline: y, uppercase: b, strikethrough: x, align: S, color: C, strokeColor: w, strokeWidth: T, opacity: E, backgroundColor: D, backgroundOpacity: O, paddingTop: k, paddingRight: A, paddingBottom: j, paddingLeft: M, radiusTopLeft: N, radiusTopRight: P, radiusBottomRight: F, radiusBottomLeft: I, left: L, top: ee, originX: R, originY: te, ...ne } = n, z = { ...ne }, re = u.resolveObjectPlacement({
8358
8687
  object: s,
8359
- left: ee,
8360
- top: te,
8361
- originX: L,
8362
- originY: ne
8363
- }), z = a === void 0 ? vr({ textbox: s }) : Qr({
8688
+ left: L,
8689
+ top: ee,
8690
+ originX: R,
8691
+ originY: te
8692
+ }), B = a === void 0 ? Ar({ textbox: s }) : ui({
8364
8693
  text: c,
8365
8694
  range: a
8366
- }), B = z ? $r({
8695
+ }), V = B ? di({
8367
8696
  textbox: s,
8368
- range: z
8369
- }) : null, V = {}, H = {}, U = {}, ae, oe, se = br({
8697
+ range: B
8698
+ }) : null, H = {}, ie = {}, U = {}, ae, oe, se = Mr({
8370
8699
  textbox: s,
8371
- range: z
8372
- }), ce = !z || se, le = !z;
8373
- if (h !== void 0 && (B && (H.fontFamily = h), ce && (R.fontFamily = h, le && (U.fontFamily = h))), g !== void 0 && (B && (H.fontSize = g), ce && (R.fontSize = g, le && (U.fontSize = g))), _ !== void 0) {
8700
+ range: B
8701
+ }), ce = !B || se, le = !B;
8702
+ if (h !== void 0 && (V && (ie.fontFamily = h), ce && (z.fontFamily = h, le && (U.fontFamily = h))), g !== void 0 && (V && (ie.fontSize = g), ce && (z.fontSize = g, le && (U.fontSize = g))), _ !== void 0) {
8374
8703
  let e = _ ? "bold" : "normal";
8375
- z && (V.fontWeight = e), ce && (R.fontWeight = e, le && (U.fontWeight = e));
8704
+ B && (H.fontWeight = e), ce && (z.fontWeight = e, le && (U.fontWeight = e));
8376
8705
  }
8377
8706
  if (v !== void 0) {
8378
8707
  let e = v ? "italic" : "normal";
8379
- z && (V.fontStyle = e), ce && (R.fontStyle = e, le && (U.fontStyle = e));
8708
+ B && (H.fontStyle = e), ce && (z.fontStyle = e, le && (U.fontStyle = e));
8380
8709
  }
8381
- if (y !== void 0 && (z && (V.underline = y), ce && (R.underline = y, le && (U.underline = y))), x !== void 0 && (z && (V.linethrough = x), ce && (R.linethrough = x, le && (U.linethrough = x))), S !== void 0 && (R.textAlign = S), C !== void 0 && (z && (V.fill = C), ce && (R.fill = C, le && (U.fill = C))), w !== void 0 || T !== void 0) {
8382
- let e = z ? Sr({
8710
+ if (y !== void 0 && (B && (H.underline = y), ce && (z.underline = y, le && (U.underline = y))), x !== void 0 && (B && (H.linethrough = x), ce && (z.linethrough = x, le && (U.linethrough = x))), S !== void 0 && (z.textAlign = S), C !== void 0 && (B && (H.fill = C), ce && (z.fill = C, le && (U.fill = C))), w !== void 0 || T !== void 0) {
8711
+ let e = B ? Pr({
8383
8712
  textbox: s,
8384
- range: z,
8713
+ range: B,
8385
8714
  property: "strokeWidth"
8386
- }) : void 0, t = z ? Sr({
8715
+ }) : void 0, t = B ? Pr({
8387
8716
  textbox: s,
8388
- range: z,
8717
+ range: B,
8389
8718
  property: "stroke"
8390
8719
  }) : void 0;
8391
- oe = wr({ width: T ?? e ?? s.strokeWidth ?? 0 }), ae = Cr({
8720
+ oe = Ir({ width: T ?? e ?? s.strokeWidth ?? 0 }), ae = Fr({
8392
8721
  strokeColor: w ?? t ?? s.stroke ?? void 0,
8393
8722
  width: oe
8394
- }), z && (V.stroke = ae, V.strokeWidth = oe), ce && (R.stroke = ae, R.strokeWidth = oe, le && (U.stroke = ae, U.strokeWidth = oe));
8723
+ }), B && (H.stroke = ae, H.strokeWidth = oe), ce && (z.stroke = ae, z.strokeWidth = oe, le && (U.stroke = ae, U.strokeWidth = oe));
8395
8724
  }
8396
- E !== void 0 && (R.opacity = E), D !== void 0 && (R.backgroundColor = D), O !== void 0 && (R.backgroundOpacity = O), k !== void 0 && (R.paddingTop = k), A !== void 0 && (R.paddingRight = A), j !== void 0 && (R.paddingBottom = j), M !== void 0 && (R.paddingLeft = M), N !== void 0 && (R.radiusTopLeft = N), P !== void 0 && (R.radiusTopRight = P), F !== void 0 && (R.radiusBottomRight = F), I !== void 0 && (R.radiusBottomLeft = I);
8725
+ E !== void 0 && (z.opacity = E), D !== void 0 && (z.backgroundColor = D), O !== void 0 && (z.backgroundOpacity = O), k !== void 0 && (z.paddingTop = k), A !== void 0 && (z.paddingRight = A), j !== void 0 && (z.paddingBottom = j), M !== void 0 && (z.paddingLeft = M), N !== void 0 && (z.radiusTopLeft = N), P !== void 0 && (z.radiusTopRight = P), F !== void 0 && (z.radiusBottomRight = F), I !== void 0 && (z.radiusBottomLeft = I);
8397
8726
  let ue = s.textCaseRaw ?? c, de = !!s.uppercase, fe = p !== void 0, pe = fe ? p ?? "" : ue, me = b ?? de, he = me !== de;
8398
- fe || he ? (R.text = me ? Tr({ value: pe }) : pe, s.textCaseRaw = pe) : s.textCaseRaw === void 0 && (s.textCaseRaw = ue);
8399
- let ge = zr({ stylesList: [
8400
- R,
8401
- V,
8727
+ fe || he ? (z.text = me ? Lr({ value: pe }) : pe, s.textCaseRaw = pe) : s.textCaseRaw === void 0 && (s.textCaseRaw = ue);
8728
+ let ge = Zr({ stylesList: [
8729
+ z,
8402
8730
  H,
8731
+ ie,
8403
8732
  U
8404
8733
  ] }), _e = [
8405
- ee,
8406
- te,
8407
8734
  L,
8408
- ne
8735
+ ee,
8736
+ R,
8737
+ te
8409
8738
  ], ve = [
8410
8739
  k,
8411
8740
  A,
8412
8741
  j,
8413
8742
  M
8414
- ], ye = _e.some((e) => e !== void 0), be = ve.some((e) => e !== void 0), xe = Object.prototype.hasOwnProperty.call(R, "width"), Se = be && !ye && !fe && !he && !ge && !xe, Ce = null;
8415
- Se && (Ce = Ir({
8743
+ ], ye = _e.some((e) => e !== void 0), be = ve.some((e) => e !== void 0), xe = Object.prototype.hasOwnProperty.call(z, "width"), Se = be && !ye && !fe && !he && !ge && !xe, Ce = null;
8744
+ Se && (Ce = Jr({
8416
8745
  textbox: s,
8417
- originX: ie.originX,
8418
- originY: ie.originY
8419
- })), s.uppercase = me, s.set(R);
8746
+ originX: re.originX,
8747
+ originY: re.originY
8748
+ })), s.uppercase = me, s.set(z);
8420
8749
  let we = !1;
8421
- if (z) {
8422
- let e = xr({
8423
- textbox: s,
8424
- styles: V,
8425
- range: z
8426
- }), t = B ? xr({
8750
+ if (B) {
8751
+ let e = Nr({
8427
8752
  textbox: s,
8428
8753
  styles: H,
8429
8754
  range: B
8755
+ }), t = V ? Nr({
8756
+ textbox: s,
8757
+ styles: ie,
8758
+ range: V
8430
8759
  }) : !1;
8431
8760
  we = e || t;
8432
8761
  } else if (Object.keys(U).length) {
8433
- let e = yr({ textbox: s });
8434
- e && (we = xr({
8762
+ let e = jr({ textbox: s });
8763
+ e && (we = Nr({
8435
8764
  textbox: s,
8436
8765
  styles: U,
8437
8766
  range: e
8438
8767
  }));
8439
8768
  }
8440
- let Te = we && zr({ stylesList: [
8441
- V,
8769
+ let Te = we && Zr({ stylesList: [
8442
8770
  H,
8771
+ ie,
8443
8772
  U
8444
8773
  ] });
8445
- if (we && (s.dirty = !0), B && (h !== void 0 || g !== void 0)) {
8446
- let e = ei({
8774
+ if (we && (s.dirty = !0), V && (h !== void 0 || g !== void 0)) {
8775
+ let e = fi({
8447
8776
  textbox: s,
8448
- range: B
8777
+ range: V
8449
8778
  }), t = {};
8450
- h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g), Ar({
8779
+ h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g), Hr({
8451
8780
  textbox: s,
8452
8781
  lineIndices: e,
8453
8782
  updates: t
8454
8783
  });
8455
8784
  }
8456
- if (z && (C !== void 0 || w !== void 0 || T !== void 0)) {
8457
- let e = ti({
8785
+ if (B && (C !== void 0 || w !== void 0 || T !== void 0)) {
8786
+ let e = pi({
8458
8787
  textbox: s,
8459
- range: z
8788
+ range: B
8460
8789
  }), t = {};
8461
- C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)), Ar({
8790
+ C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)), Hr({
8462
8791
  textbox: s,
8463
8792
  lineIndices: e,
8464
8793
  updates: t
@@ -8478,7 +8807,7 @@ var Xr = class {
8478
8807
  let ke = Oe && !xe && (fe || he || ge);
8479
8808
  this._normalizeTextboxAfterContentChange({
8480
8809
  textbox: s,
8481
- placement: ie,
8810
+ placement: re,
8482
8811
  shouldAutoExpand: ke
8483
8812
  }), Ce && this._restoreTextboxContentPlacement({
8484
8813
  textbox: s,
@@ -8487,14 +8816,14 @@ var Xr = class {
8487
8816
  let Ae = {
8488
8817
  withoutSave: !!r,
8489
8818
  skipRender: !!i
8490
- }, je = !!z && Object.keys(V).length > 0, Me = {
8819
+ }, je = !!B && Object.keys(H).length > 0, Me = {
8491
8820
  textbox: s,
8492
8821
  target: t,
8493
8822
  style: n,
8494
8823
  options: Ae,
8495
- updates: R,
8496
- selectionRange: z ?? void 0,
8497
- selectionStyles: je ? V : void 0
8824
+ updates: z,
8825
+ selectionRange: B ?? void 0,
8826
+ selectionStyles: je ? H : void 0
8498
8827
  };
8499
8828
  o && d.fire("editor:before:text-updated", Me), i || d.requestRenderAll();
8500
8829
  let Ne = e._getSnapshot(s);
@@ -8553,7 +8882,7 @@ var Xr = class {
8553
8882
  clampToMontage: r
8554
8883
  }));
8555
8884
  let a = !1;
8556
- i || (a = Br({ textbox: e }));
8885
+ i || (a = Qr({ textbox: e }));
8557
8886
  let o = !1;
8558
8887
  return !i && t && (this.editor.canvasManager.applyObjectPlacement({
8559
8888
  object: e,
@@ -8561,7 +8890,7 @@ var Xr = class {
8561
8890
  }), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
8562
8891
  }
8563
8892
  _restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
8564
- let n = Ir({
8893
+ let n = Jr({
8565
8894
  textbox: e,
8566
8895
  originX: t.originX,
8567
8896
  originY: t.originY
@@ -8581,15 +8910,15 @@ var Xr = class {
8581
8910
  _syncLineFontDefaultsOnTextChanged({ textbox: e }) {
8582
8911
  let { text: t = "", lineFontDefaults: n, styles: r, fontFamily: i, fontSize: a, fill: o, stroke: s, selectionStart: c, isEditing: l } = e, u = t, d = e.__lineDefaultsPrevText ?? u, f = d.split("\n"), p = u.split("\n"), m = f.length, h = p.length - m, g = n, _ = !1, v = !1, y = typeof o == "string" ? o : void 0, b = typeof s == "string" ? s : void 0;
8583
8912
  if (h !== 0 && n && Object.keys(n).length) {
8584
- let e = ni({
8913
+ let e = mi({
8585
8914
  previous: d,
8586
8915
  next: u
8587
- }), t = ri({
8916
+ }), t = hi({
8588
8917
  text: d,
8589
8918
  charIndex: e
8590
8919
  });
8591
8920
  if (h > 0) {
8592
- let r = ii({
8921
+ let r = gi({
8593
8922
  text: d,
8594
8923
  lineIndex: t
8595
8924
  }), i = t + 1;
@@ -8630,7 +8959,7 @@ var Xr = class {
8630
8959
  let t = p[e] ?? "", n = g ? g[e] : void 0;
8631
8960
  if (n && (T = n), t.length !== 0) {
8632
8961
  if (n) {
8633
- let r = jr({
8962
+ let r = Ur({
8634
8963
  lineText: t,
8635
8964
  lineStyles: S ? S[e] : void 0,
8636
8965
  lineDefaults: n
@@ -8670,16 +8999,16 @@ var Xr = class {
8670
8999
  if (!Number.isFinite(f) || f <= 0) return !1;
8671
9000
  let p = a.split("\n").length, m = !1;
8672
9001
  Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
8673
- let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Pr({
9002
+ let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Kr({
8674
9003
  textbox: e,
8675
9004
  text: a
8676
9005
  })), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
8677
- g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Br({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
9006
+ g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Qr({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
8678
9007
  object: e,
8679
9008
  placement: t
8680
9009
  });
8681
9010
  let b = !1;
8682
- return n && (b = Lr({
9011
+ return n && (b = Yr({
8683
9012
  textbox: e,
8684
9013
  montageLeft: o,
8685
9014
  montageRight: o + s
@@ -8737,7 +9066,7 @@ var Xr = class {
8737
9066
  _getDefaultFontFamily() {
8738
9067
  return this.fonts[0]?.family ?? "Arial";
8739
9068
  }
8740
- }, oi = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, si = (e) => {
9069
+ }, vi = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, yi = (e) => {
8741
9070
  if (!e || typeof e != "object") return null;
8742
9071
  let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof a?.color == "string" ? a.color : void 0, c = typeof o?.color == "string" ? o.color : s, l = typeof a?.offset == "number" ? a.offset * 100 : void 0, u = typeof o?.offset == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
8743
9072
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -8748,7 +9077,7 @@ var Xr = class {
8748
9077
  let { x1: e, y1: t, x2: r, y2: i } = n;
8749
9078
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
8750
9079
  type: "linear",
8751
- angle: oi({
9080
+ angle: vi({
8752
9081
  x1: e,
8753
9082
  y1: t,
8754
9083
  x2: r,
@@ -8776,7 +9105,7 @@ var Xr = class {
8776
9105
  };
8777
9106
  }
8778
9107
  return null;
8779
- }, ci = "_templateAnchorX", li = "_templateAnchorY", ui = class t {
9108
+ }, bi = "_templateAnchorX", xi = "_templateAnchorY", Si = class t {
8780
9109
  constructor({ editor: e }) {
8781
9110
  this.editor = e;
8782
9111
  }
@@ -8785,7 +9114,7 @@ var Xr = class {
8785
9114
  if (!p.length) return s.emitWarning({
8786
9115
  origin: "TemplateManager",
8787
9116
  method: "serializeSelection",
8788
- code: hr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
9117
+ code: Dr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
8789
9118
  message: "Нет объектов для сериализации шаблона"
8790
9119
  }), null;
8791
9120
  let m = t._getBounds(o), h = t._getMontageSize({
@@ -8814,14 +9143,14 @@ var Xr = class {
8814
9143
  if (!s?.length) return a.emitWarning({
8815
9144
  origin: "TemplateManager",
8816
9145
  method: "applyTemplate",
8817
- code: hr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
9146
+ code: Dr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
8818
9147
  message: "Шаблон не содержит объектов"
8819
9148
  }), null;
8820
9149
  let u = t._getBounds(r);
8821
9150
  if (!u) return a.emitWarning({
8822
9151
  origin: "TemplateManager",
8823
9152
  method: "applyTemplate",
8824
- code: hr.TEMPLATE_MANAGER.INVALID_TARGET,
9153
+ code: Dr.TEMPLATE_MANAGER.INVALID_TARGET,
8825
9154
  message: "Не удалось определить границы монтажной области"
8826
9155
  }), null;
8827
9156
  let d = t._getMontageSize({
@@ -8840,7 +9169,7 @@ var Xr = class {
8840
9169
  if (!r.length) return a.emitWarning({
8841
9170
  origin: "TemplateManager",
8842
9171
  method: "applyTemplate",
8843
- code: hr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
9172
+ code: Dr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
8844
9173
  message: "Не удалось создать объекты шаблона"
8845
9174
  }), null;
8846
9175
  let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
@@ -8875,7 +9204,7 @@ var Xr = class {
8875
9204
  return a.emitError({
8876
9205
  origin: "TemplateManager",
8877
9206
  method: "applyTemplate",
8878
- code: hr.TEMPLATE_MANAGER.APPLY_FAILED,
9207
+ code: Dr.TEMPLATE_MANAGER.APPLY_FAILED,
8879
9208
  message: "Ошибка применения шаблона",
8880
9209
  data: {
8881
9210
  templateId: l,
@@ -9029,8 +9358,8 @@ var Xr = class {
9029
9358
  baseHeight: a,
9030
9359
  scale: n,
9031
9360
  useRelativePositions: o,
9032
- anchorX: t._resolveAnchor(s, ci),
9033
- anchorY: t._resolveAnchor(s, li)
9361
+ anchorX: t._resolveAnchor(s, bi),
9362
+ anchorY: t._resolveAnchor(s, xi)
9034
9363
  })
9035
9364
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
9036
9365
  e.set({
@@ -9044,7 +9373,7 @@ var Xr = class {
9044
9373
  originX: _,
9045
9374
  originY: v
9046
9375
  }
9047
- }), delete s[ci], delete s[li];
9376
+ }), delete s[bi], delete s[xi];
9048
9377
  }
9049
9378
  static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
9050
9379
  if (!a) return e;
@@ -9108,7 +9437,7 @@ var Xr = class {
9108
9437
  });
9109
9438
  if (!i || !s || !o) return;
9110
9439
  e.setCoords();
9111
- let c = e, l = t._resolveAnchor(c, ci), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
9440
+ let c = e, l = t._resolveAnchor(c, bi), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
9112
9441
  e.set("width", i), e.initDimensions();
9113
9442
  let g = t._getLongestLineWidth({
9114
9443
  textbox: e,
@@ -9137,10 +9466,10 @@ var Xr = class {
9137
9466
  x: (p.left - o) / d,
9138
9467
  y: (p.top - s) / f
9139
9468
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
9140
- return a[ci] = t._detectAnchor({
9469
+ return a[bi] = t._detectAnchor({
9141
9470
  start: h,
9142
9471
  end: _
9143
- }), a[li] = t._detectAnchor({
9472
+ }), a[xi] = t._detectAnchor({
9144
9473
  start: g,
9145
9474
  end: v
9146
9475
  }), a.left = m.x, a.top = m.y, a;
@@ -9165,7 +9494,7 @@ var Xr = class {
9165
9494
  withoutSave: !0
9166
9495
  }), !0;
9167
9496
  if (a === "gradient") {
9168
- let e = si(r);
9497
+ let e = yi(r);
9169
9498
  if (e) return n.setGradientBackground({
9170
9499
  gradient: e,
9171
9500
  customData: o,
@@ -9186,7 +9515,7 @@ var Xr = class {
9186
9515
  r.emitWarning({
9187
9516
  origin: "TemplateManager",
9188
9517
  method: "applyTemplate",
9189
- code: hr.TEMPLATE_MANAGER.APPLY_FAILED,
9518
+ code: Dr.TEMPLATE_MANAGER.APPLY_FAILED,
9190
9519
  message: "Не удалось применить фон из шаблона",
9191
9520
  data: e
9192
9521
  });
@@ -9222,29 +9551,29 @@ var Xr = class {
9222
9551
  enlivenObjectEnlivables(e) {
9223
9552
  return C.enlivenObjectEnlivables(e);
9224
9553
  }
9225
- }, di = "#3D8BF4", fi = .5, pi = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, mi = ({ firstDistance: e, secondDistance: t }) => {
9226
- let n = pi({ distance: e }), r = pi({ distance: t });
9554
+ }, Ci = "#3D8BF4", wi = .5, Ti = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Ei = ({ firstDistance: e, secondDistance: t }) => {
9555
+ let n = Ti({ distance: e }), r = Ti({ distance: t });
9227
9556
  return {
9228
9557
  firstDisplayDistance: n,
9229
9558
  secondDisplayDistance: r,
9230
9559
  displayDistanceDiff: Math.abs(n - r),
9231
9560
  commonDisplayDistance: Math.max(n, r)
9232
9561
  };
9233
- }, hi = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), gi = ({ step: e }) => {
9562
+ }, Di = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Oi = ({ step: e }) => {
9234
9563
  let t = Math.abs(e).toString(), n = t.indexOf(".");
9235
9564
  return n === -1 ? 0 : t.slice(n + 1).length;
9236
- }, _i = ({ value: e, step: t }) => {
9565
+ }, ki = ({ value: e, step: t }) => {
9237
9566
  if (t === 0) return e;
9238
- let n = gi({ step: t }), r = Math.round(e / t) * t;
9567
+ let n = Oi({ step: t }), r = Math.round(e / t) * t;
9239
9568
  return Number(r.toFixed(n));
9240
- }, vi = ({ value: e, step: t }) => {
9569
+ }, Ai = ({ value: e, step: t }) => {
9241
9570
  if (t === 0) return !0;
9242
- let n = _i({
9571
+ let n = ki({
9243
9572
  value: e,
9244
9573
  step: t
9245
- }), r = 10 ** -(gi({ step: t }) + 4);
9574
+ }), r = 10 ** -(Oi({ step: t }) + 4);
9246
9575
  return Math.abs(n - e) <= r;
9247
- }, yi = ({ bounds: e, axis: t }) => {
9576
+ }, ji = ({ bounds: e, axis: t }) => {
9248
9577
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
9249
9578
  return t === "vertical" ? {
9250
9579
  start: i,
@@ -9253,7 +9582,7 @@ var Xr = class {
9253
9582
  start: n,
9254
9583
  end: r
9255
9584
  };
9256
- }, bi = ({ items: e, axis: t }) => {
9585
+ }, Mi = ({ items: e, axis: t }) => {
9257
9586
  for (let n = 1; n < e.length; n += 1) {
9258
9587
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
9259
9588
  for (; o >= 0;) {
@@ -9263,10 +9592,10 @@ var Xr = class {
9263
9592
  }
9264
9593
  e[o + 1] = r;
9265
9594
  }
9266
- }, xi = ({ items: e, index: t, axis: n, direction: r }) => {
9595
+ }, Ni = ({ items: e, index: t, axis: n, direction: r }) => {
9267
9596
  let i = e[t];
9268
9597
  if (!i) return null;
9269
- let { bounds: a } = i, { start: o, end: s } = yi({
9598
+ let { bounds: a } = i, { start: o, end: s } = ji({
9270
9599
  bounds: a,
9271
9600
  axis: n
9272
9601
  });
@@ -9274,7 +9603,7 @@ var Xr = class {
9274
9603
  for (let r = t - 1; r >= 0; --r) {
9275
9604
  let t = e[r];
9276
9605
  if (!t) continue;
9277
- let { bounds: i } = t, { end: a } = yi({
9606
+ let { bounds: i } = t, { end: a } = ji({
9278
9607
  bounds: i,
9279
9608
  axis: n
9280
9609
  });
@@ -9285,26 +9614,26 @@ var Xr = class {
9285
9614
  for (let r = t + 1; r < e.length; r += 1) {
9286
9615
  let t = e[r];
9287
9616
  if (!t) continue;
9288
- let { bounds: i } = t, { start: a } = yi({
9617
+ let { bounds: i } = t, { start: a } = ji({
9289
9618
  bounds: i,
9290
9619
  axis: n
9291
9620
  });
9292
9621
  if (a - s >= 0) return r;
9293
9622
  }
9294
9623
  return null;
9295
- }, Si = ({ items: e }) => {
9624
+ }, Pi = ({ items: e }) => {
9296
9625
  for (let t = 0; t < e.length; t += 1) {
9297
9626
  let { isActive: n } = e[t];
9298
9627
  if (n) return t;
9299
9628
  }
9300
9629
  return -1;
9301
- }, Ci = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
9630
+ }, Fi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
9302
9631
  let i = Math.min(t, n), a = Math.max(t, n);
9303
9632
  return e >= i - r && e <= a + r;
9304
- }, wi = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Ti = ({ baseOption: e, candidateOption: t }) => {
9633
+ }, Ii = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Li = ({ baseOption: e, candidateOption: t }) => {
9305
9634
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
9306
9635
  return n === i && r === a;
9307
- }, Ei = ({ options: e }) => {
9636
+ }, Ri = ({ options: e }) => {
9308
9637
  let t = e[0];
9309
9638
  for (let n = 1; n < e.length; n += 1) {
9310
9639
  let r = e[n];
@@ -9315,11 +9644,11 @@ var Xr = class {
9315
9644
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
9316
9645
  }
9317
9646
  return t;
9318
- }, Di = ({ currentOption: e, nextOption: t }) => {
9647
+ }, zi = ({ currentOption: e, nextOption: t }) => {
9319
9648
  if (!e) return !0;
9320
9649
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
9321
9650
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
9322
- }, Oi = ({ options: e }) => {
9651
+ }, Bi = ({ options: e }) => {
9323
9652
  let t = [], n = null, r = null;
9324
9653
  for (let i of e) {
9325
9654
  let { kind: e, side: a } = i;
@@ -9327,18 +9656,18 @@ var Xr = class {
9327
9656
  t.push(i);
9328
9657
  continue;
9329
9658
  }
9330
- a === "before" && Di({
9659
+ a === "before" && zi({
9331
9660
  currentOption: n,
9332
9661
  nextOption: i
9333
- }) && (n = i), a === "after" && Di({
9662
+ }) && (n = i), a === "after" && zi({
9334
9663
  currentOption: r,
9335
9664
  nextOption: i
9336
9665
  }) && (r = i);
9337
9666
  }
9338
9667
  return n && t.push(n), r && t.push(r), t;
9339
- }, ki = ({ options: e, side: t, baseOption: n }) => {
9668
+ }, Vi = ({ options: e, side: t, baseOption: n }) => {
9340
9669
  let r = null;
9341
- for (let i of e) if (i.side === t && Ti({
9670
+ for (let i of e) if (i.side === t && Li({
9342
9671
  baseOption: n,
9343
9672
  candidateOption: i
9344
9673
  })) {
@@ -9349,63 +9678,63 @@ var Xr = class {
9349
9678
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
9350
9679
  }
9351
9680
  return r;
9352
- }, Ai = ({ option: e }) => {
9681
+ }, Hi = ({ option: e }) => {
9353
9682
  let { side: t, kind: n, guide: { distance: r } } = e;
9354
9683
  return {
9355
9684
  side: t,
9356
9685
  kind: n,
9357
9686
  distance: r
9358
9687
  };
9359
- }, ji = ({ option: e, context: t }) => {
9688
+ }, Ui = ({ option: e, context: t }) => {
9360
9689
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
9361
9690
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
9362
- }, Mi = ({ options: e, context: t }) => {
9691
+ }, Wi = ({ options: e, context: t }) => {
9363
9692
  if (!t) return null;
9364
- for (let n of e) if (ji({
9693
+ for (let n of e) if (Ui({
9365
9694
  option: n,
9366
9695
  context: t
9367
9696
  })) return n;
9368
9697
  return null;
9369
- }, Ni = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
9370
- let i = Mi({
9698
+ }, Gi = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
9699
+ let i = Wi({
9371
9700
  options: e,
9372
9701
  context: n
9373
9702
  });
9374
9703
  if (!i) return t;
9375
9704
  let a = Math.max(0, r);
9376
9705
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
9377
- }, Pi = ({ guides: e, seenGuideKeys: t, guide: n }) => {
9706
+ }, Ki = ({ guides: e, seenGuideKeys: t, guide: n }) => {
9378
9707
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
9379
9708
  t.has(u) || (t.add(u), e.push(n));
9380
- }, Fi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
9709
+ }, qi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
9381
9710
  if (!e.length) return {
9382
9711
  delta: 0,
9383
9712
  guides: [],
9384
9713
  context: null
9385
9714
  };
9386
- let r = Oi({ options: e }), i = [];
9715
+ let r = Bi({ options: e }), i = [];
9387
9716
  for (let e of r) e.kind === "reference" && i.push(e);
9388
- let a = i.length > 0, o = a ? i : r, s = Ni({
9717
+ let a = i.length > 0, o = a ? i : r, s = Gi({
9389
9718
  options: o,
9390
- bestOption: Ei({ options: o }),
9719
+ bestOption: Ri({ options: o }),
9391
9720
  previousContext: t,
9392
9721
  switchDistance: n
9393
- }), c = ki({
9722
+ }), c = Vi({
9394
9723
  options: o,
9395
9724
  side: "before",
9396
9725
  baseOption: s
9397
- }), l = ki({
9726
+ }), l = Vi({
9398
9727
  options: o,
9399
9728
  side: "after",
9400
9729
  baseOption: s
9401
- }), u = ki({
9730
+ }), u = Vi({
9402
9731
  options: a ? r : o,
9403
9732
  side: "center",
9404
9733
  baseOption: s
9405
9734
  }), d = [];
9406
9735
  c && l ? d.push(c, l) : (d.push(s), s.side === "before" && l && d.push(l), s.side === "after" && c && d.push(c), s.side === "center" && (c && !l && d.push(c), l && !c && d.push(l)), a && s.side === "before" && !l && u && d.push(u), a && s.side === "after" && !c && u && d.push(u)), !d.length && u && d.push(u);
9407
9736
  let f = [], p = /* @__PURE__ */ new Set();
9408
- for (let e of d) Pi({
9737
+ for (let e of d) Ki({
9409
9738
  guides: f,
9410
9739
  seenGuideKeys: p,
9411
9740
  guide: e.guide
@@ -9413,15 +9742,15 @@ var Xr = class {
9413
9742
  return {
9414
9743
  delta: s.delta,
9415
9744
  guides: f,
9416
- context: Ai({ option: s })
9745
+ context: Hi({ option: s })
9417
9746
  };
9418
- }, Ii = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
9419
- let s = n - (e - r), c = _i({
9747
+ }, Ji = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
9748
+ let s = n - (e - r), c = ki({
9420
9749
  value: s,
9421
9750
  step: o
9422
9751
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
9423
9752
  for (let d = -l; d <= l; d += 1) {
9424
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = mi({
9753
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Ei({
9425
9754
  firstDistance: m,
9426
9755
  secondDistance: h
9427
9756
  });
@@ -9436,13 +9765,13 @@ var Xr = class {
9436
9765
  });
9437
9766
  }
9438
9767
  return u;
9439
- }, Li = ({ currentGap: e, referenceGap: t }) => {
9440
- let { secondDisplayDistance: n, displayDistanceDiff: r } = mi({
9768
+ }, Yi = ({ currentGap: e, referenceGap: t }) => {
9769
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = Ei({
9441
9770
  firstDistance: e,
9442
9771
  secondDistance: t
9443
9772
  });
9444
9773
  return r > 1 ? null : n;
9445
- }, Ri = ({ anchors: e, positions: t, threshold: n }) => {
9774
+ }, Xi = ({ anchors: e, positions: t, threshold: n }) => {
9446
9775
  let r = 0, i = n + 1, a = null;
9447
9776
  for (let o of t) for (let t of e) {
9448
9777
  let e = Math.abs(t - o);
@@ -9452,8 +9781,8 @@ var Xr = class {
9452
9781
  delta: r,
9453
9782
  guidePosition: a
9454
9783
  };
9455
- }, zi = ({ activeBounds: e, threshold: t, anchors: n }) => {
9456
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ri({
9784
+ }, Zi = ({ activeBounds: e, threshold: t, anchors: n }) => {
9785
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Xi({
9457
9786
  anchors: n.vertical,
9458
9787
  positions: [
9459
9788
  r,
@@ -9461,7 +9790,7 @@ var Xr = class {
9461
9790
  i
9462
9791
  ],
9463
9792
  threshold: t
9464
- }), u = Ri({
9793
+ }), u = Xi({
9465
9794
  anchors: n.horizontal,
9466
9795
  positions: [
9467
9796
  o,
@@ -9481,11 +9810,11 @@ var Xr = class {
9481
9810
  deltaY: u.delta,
9482
9811
  guides: d
9483
9812
  };
9484
- }, Bi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
9813
+ }, Qi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
9485
9814
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
9486
9815
  for (let e of t) {
9487
9816
  let { left: t, right: n } = e;
9488
- hi({
9817
+ Di({
9489
9818
  firstStart: t,
9490
9819
  firstEnd: n,
9491
9820
  secondStart: l,
@@ -9505,22 +9834,22 @@ var Xr = class {
9505
9834
  f.push({
9506
9835
  bounds: e,
9507
9836
  isActive: !0
9508
- }), bi({
9837
+ }), Mi({
9509
9838
  items: f,
9510
9839
  axis: "top"
9511
9840
  });
9512
- let p = Si({ items: f });
9841
+ let p = Pi({ items: f });
9513
9842
  if (p === -1) return {
9514
9843
  delta: 0,
9515
9844
  guides: [],
9516
9845
  context: null
9517
9846
  };
9518
- let m = [], h = c - s, g = xi({
9847
+ let m = [], h = c - s, g = Ni({
9519
9848
  items: f,
9520
9849
  index: p,
9521
9850
  axis: "vertical",
9522
9851
  direction: "prev"
9523
- }), _ = xi({
9852
+ }), _ = Ni({
9524
9853
  items: f,
9525
9854
  index: p,
9526
9855
  axis: "vertical",
@@ -9529,19 +9858,19 @@ var Xr = class {
9529
9858
  if (v && y) {
9530
9859
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
9531
9860
  if (a >= 0) {
9532
- let e = _i({
9861
+ let e = ki({
9533
9862
  value: a / 2,
9534
9863
  step: 1
9535
9864
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
9536
9865
  if (Math.max(u, d) <= n) {
9537
- let t = Ii({
9866
+ let t = Ji({
9538
9867
  activeStart: s,
9539
9868
  activeEnd: c,
9540
9869
  targetGap: e,
9541
9870
  beforeEdge: r,
9542
9871
  afterEdge: i,
9543
9872
  threshold: n,
9544
- step: fi
9873
+ step: wi
9545
9874
  });
9546
9875
  if (t) {
9547
9876
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -9578,16 +9907,16 @@ var Xr = class {
9578
9907
  }
9579
9908
  for (let e of r) {
9580
9909
  let { axis: t, start: r, end: i, distance: a } = e;
9581
- if (!vi({
9910
+ if (!Ai({
9582
9911
  value: a,
9583
9912
  step: .5
9584
- }) || !Ci({
9913
+ }) || !Fi({
9585
9914
  patternAxis: t,
9586
9915
  activeRangeStart: l,
9587
9916
  activeRangeEnd: u,
9588
9917
  tolerance: n
9589
9918
  })) continue;
9590
- let d = wi({
9919
+ let d = Ii({
9591
9920
  patternStart: r,
9592
9921
  patternEnd: i,
9593
9922
  activeStart: s,
@@ -9595,12 +9924,12 @@ var Xr = class {
9595
9924
  });
9596
9925
  if (d) {
9597
9926
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
9598
- let e = _i({
9927
+ let e = ki({
9599
9928
  value: a - b,
9600
9929
  step: 1
9601
9930
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
9602
9931
  if (u > n) continue;
9603
- let d = Li({
9932
+ let d = Yi({
9604
9933
  currentGap: l,
9605
9934
  referenceGap: a
9606
9935
  });
@@ -9624,12 +9953,12 @@ var Xr = class {
9624
9953
  });
9625
9954
  }
9626
9955
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
9627
- let e = _i({
9956
+ let e = ki({
9628
9957
  value: x - a,
9629
9958
  step: 1
9630
9959
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
9631
9960
  if (u > n) continue;
9632
- let d = Li({
9961
+ let d = Yi({
9633
9962
  currentGap: l,
9634
9963
  referenceGap: a
9635
9964
  });
@@ -9654,16 +9983,16 @@ var Xr = class {
9654
9983
  }
9655
9984
  }
9656
9985
  }
9657
- return Fi({
9986
+ return qi({
9658
9987
  options: m,
9659
9988
  previousContext: i,
9660
9989
  switchDistance: a
9661
9990
  });
9662
- }, Vi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
9991
+ }, $i = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
9663
9992
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
9664
9993
  for (let e of t) {
9665
9994
  let { top: t, bottom: n } = e;
9666
- hi({
9995
+ Di({
9667
9996
  firstStart: t,
9668
9997
  firstEnd: n,
9669
9998
  secondStart: l,
@@ -9683,22 +10012,22 @@ var Xr = class {
9683
10012
  f.push({
9684
10013
  bounds: e,
9685
10014
  isActive: !0
9686
- }), bi({
10015
+ }), Mi({
9687
10016
  items: f,
9688
10017
  axis: "left"
9689
10018
  });
9690
- let p = Si({ items: f });
10019
+ let p = Pi({ items: f });
9691
10020
  if (p === -1) return {
9692
10021
  delta: 0,
9693
10022
  guides: [],
9694
10023
  context: null
9695
10024
  };
9696
- let m = [], h = c - s, g = xi({
10025
+ let m = [], h = c - s, g = Ni({
9697
10026
  items: f,
9698
10027
  index: p,
9699
10028
  axis: "horizontal",
9700
10029
  direction: "prev"
9701
- }), _ = xi({
10030
+ }), _ = Ni({
9702
10031
  items: f,
9703
10032
  index: p,
9704
10033
  axis: "horizontal",
@@ -9707,19 +10036,19 @@ var Xr = class {
9707
10036
  if (v && y) {
9708
10037
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
9709
10038
  if (a >= 0) {
9710
- let e = _i({
10039
+ let e = ki({
9711
10040
  value: a / 2,
9712
10041
  step: 1
9713
10042
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
9714
10043
  if (Math.max(u, d) <= n) {
9715
- let t = Ii({
10044
+ let t = Ji({
9716
10045
  activeStart: s,
9717
10046
  activeEnd: c,
9718
10047
  targetGap: e,
9719
10048
  beforeEdge: r,
9720
10049
  afterEdge: i,
9721
10050
  threshold: n,
9722
- step: fi
10051
+ step: wi
9723
10052
  });
9724
10053
  if (t) {
9725
10054
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -9756,16 +10085,16 @@ var Xr = class {
9756
10085
  }
9757
10086
  for (let e of r) {
9758
10087
  let { axis: t, start: r, end: i, distance: a } = e;
9759
- if (!vi({
10088
+ if (!Ai({
9760
10089
  value: a,
9761
10090
  step: .5
9762
- }) || !Ci({
10091
+ }) || !Fi({
9763
10092
  patternAxis: t,
9764
10093
  activeRangeStart: l,
9765
10094
  activeRangeEnd: u,
9766
10095
  tolerance: n
9767
10096
  })) continue;
9768
- let d = wi({
10097
+ let d = Ii({
9769
10098
  patternStart: r,
9770
10099
  patternEnd: i,
9771
10100
  activeStart: s,
@@ -9773,12 +10102,12 @@ var Xr = class {
9773
10102
  });
9774
10103
  if (d) {
9775
10104
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
9776
- let e = _i({
10105
+ let e = ki({
9777
10106
  value: a - b,
9778
10107
  step: 1
9779
10108
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
9780
10109
  if (u > n) continue;
9781
- let d = Li({
10110
+ let d = Yi({
9782
10111
  currentGap: l,
9783
10112
  referenceGap: a
9784
10113
  });
@@ -9802,12 +10131,12 @@ var Xr = class {
9802
10131
  });
9803
10132
  }
9804
10133
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
9805
- let e = _i({
10134
+ let e = ki({
9806
10135
  value: x - a,
9807
10136
  step: 1
9808
10137
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
9809
10138
  if (u > n) continue;
9810
- let d = Li({
10139
+ let d = Yi({
9811
10140
  currentGap: l,
9812
10141
  referenceGap: a
9813
10142
  });
@@ -9832,20 +10161,20 @@ var Xr = class {
9832
10161
  }
9833
10162
  }
9834
10163
  }
9835
- return Fi({
10164
+ return qi({
9836
10165
  options: m,
9837
10166
  previousContext: i,
9838
10167
  switchDistance: a
9839
10168
  });
9840
- }, Hi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
9841
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Bi({
10169
+ }, ea = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
10170
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Qi({
9842
10171
  activeBounds: e,
9843
10172
  candidates: t,
9844
10173
  threshold: n,
9845
10174
  patterns: r.vertical,
9846
10175
  previousContext: o,
9847
10176
  switchDistance: a
9848
- }), l = Vi({
10177
+ }), l = $i({
9849
10178
  activeBounds: e,
9850
10179
  candidates: t,
9851
10180
  threshold: n,
@@ -9864,14 +10193,14 @@ var Xr = class {
9864
10193
  horizontal: l.context
9865
10194
  }
9866
10195
  };
9867
- }, Ui = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
10196
+ }, ta = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
9868
10197
  let o = Math.min(a, r / 2, i / 2);
9869
10198
  e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.quadraticCurveTo(t + r, n, t + r, n + o), e.lineTo(t + r, n + i - o), e.quadraticCurveTo(t + r, n + i, t + r - o, n + i), e.lineTo(t + o, n + i), e.quadraticCurveTo(t, n + i, t, n + i - o), e.lineTo(t, n + o), e.quadraticCurveTo(t, n, t + o, n), e.closePath();
9870
- }, Wi = ({ context: e, type: t, axis: n, start: r, end: i, text: a, zoom: o, color: s, textColor: c = "#ffffff", fontFamily: l = "sans-serif", lineWidth: u = 1, padding: d = 4, radius: f = 4, offsetAlongAxis: p = 0, offsetPerpendicular: m = 0 }) => {
10199
+ }, na = ({ context: e, type: t, axis: n, start: r, end: i, text: a, zoom: o, color: s, textColor: c = "#ffffff", fontFamily: l = "sans-serif", lineWidth: u = 1, padding: d = 4, radius: f = 4, offsetAlongAxis: p = 0, offsetPerpendicular: m = 0 }) => {
9871
10200
  let h = o || 1, g = 12 / h, _ = d / h, v = f / h, y = (r + i) / 2 + p, b = t === "vertical" ? n + m : y, x = t === "vertical" ? y : n + m;
9872
10201
  e.save(), e.setLineDash([]), e.fillStyle = s, e.strokeStyle = s, e.lineWidth = u / h, e.font = `${g}px ${l}`, e.textAlign = "center", e.textBaseline = "middle";
9873
10202
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
9874
- e.beginPath(), Ui({
10203
+ e.beginPath(), ta({
9875
10204
  context: e,
9876
10205
  x: w,
9877
10206
  y: T,
@@ -9879,11 +10208,11 @@ var Xr = class {
9879
10208
  height: C,
9880
10209
  radius: v
9881
10210
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
9882
- }, Gi = ({ context: e, guide: t, zoom: n }) => {
9883
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = pi({ distance: l }).toString();
10211
+ }, ra = ({ context: e, guide: t, zoom: n }) => {
10212
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Ti({ distance: l }).toString();
9884
10213
  e.beginPath(), r === "vertical" ? (e.moveTo(i, a), e.lineTo(i, o), e.moveTo(i, s), e.lineTo(i, c)) : (e.moveTo(a, i), e.lineTo(o, i), e.moveTo(s, i), e.lineTo(c, i)), e.stroke();
9885
- let d = di;
9886
- Wi({
10214
+ let d = Ci;
10215
+ na({
9887
10216
  context: e,
9888
10217
  type: r,
9889
10218
  axis: i,
@@ -9893,7 +10222,7 @@ var Xr = class {
9893
10222
  zoom: n,
9894
10223
  color: d,
9895
10224
  lineWidth: 1
9896
- }), Wi({
10225
+ }), na({
9897
10226
  context: e,
9898
10227
  type: r,
9899
10228
  axis: i,
@@ -9904,10 +10233,10 @@ var Xr = class {
9904
10233
  color: d,
9905
10234
  lineWidth: 1
9906
10235
  });
9907
- }, Ki = ({ anchors: e, bounds: t }) => {
10236
+ }, ia = ({ anchors: e, bounds: t }) => {
9908
10237
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
9909
10238
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
9910
- }, qi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
10239
+ }, aa = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
9911
10240
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
9912
10241
  for (let e = 0; e < s.length; e += 1) {
9913
10242
  let c = s[e], l = null, u = Infinity;
@@ -9928,35 +10257,35 @@ var Xr = class {
9928
10257
  });
9929
10258
  }
9930
10259
  return i;
9931
- }, Ji = ({ bounds: e }) => ({
9932
- vertical: qi({
10260
+ }, oa = ({ bounds: e }) => ({
10261
+ vertical: aa({
9933
10262
  bounds: e,
9934
10263
  axis: "centerX",
9935
10264
  type: "vertical",
9936
10265
  primaryStart: "top",
9937
10266
  primaryEnd: "bottom"
9938
10267
  }),
9939
- horizontal: qi({
10268
+ horizontal: aa({
9940
10269
  bounds: e,
9941
10270
  axis: "centerY",
9942
10271
  type: "horizontal",
9943
10272
  primaryStart: "left",
9944
10273
  primaryEnd: "right"
9945
10274
  })
9946
- }), Yi = [
10275
+ }), sa = [
9947
10276
  "montage-area",
9948
10277
  "background",
9949
10278
  "interaction-blocker"
9950
- ], Xi = ({ activeObject: t }) => {
10279
+ ], ca = ({ activeObject: t }) => {
9951
10280
  let n = /* @__PURE__ */ new Set();
9952
10281
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
9953
- }, Zi = ({ object: e, excluded: t, ignoredIds: n = Yi }) => {
10282
+ }, la = ({ object: e, excluded: t, ignoredIds: n = sa }) => {
9954
10283
  if (t.has(e)) return !0;
9955
10284
  let { visible: r = !0 } = e;
9956
10285
  if (!r) return !0;
9957
10286
  let { id: i } = e;
9958
10287
  return !!(i && n.includes(i));
9959
- }, Qi = class e {
10288
+ }, ua = class e {
9960
10289
  constructor({ editor: e }) {
9961
10290
  this.anchors = {
9962
10291
  vertical: [],
@@ -10009,7 +10338,7 @@ var Xr = class {
10009
10338
  this._clearSpacingContexts(), this._clearGuides();
10010
10339
  return;
10011
10340
  }
10012
- let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = zi({
10341
+ let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Zi({
10013
10342
  activeBounds: a,
10014
10343
  threshold: c,
10015
10344
  anchors: this.anchors
@@ -10021,7 +10350,7 @@ var Xr = class {
10021
10350
  top: t + u
10022
10351
  }), n.setCoords(), a = Ye({ object: n }) ?? a;
10023
10352
  }
10024
- let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Hi({
10353
+ let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = ea({
10025
10354
  activeBounds: a,
10026
10355
  candidates: d,
10027
10356
  threshold: f,
@@ -10042,11 +10371,11 @@ var Xr = class {
10042
10371
  target: n,
10043
10372
  transform: i
10044
10373
  });
10045
- let h = Ye({ object: n }) ?? a, g = zi({
10374
+ let h = Ye({ object: n }) ?? a, g = Zi({
10046
10375
  activeBounds: h,
10047
10376
  threshold: c,
10048
10377
  anchors: this.anchors
10049
- }), _ = Hi({
10378
+ }), _ = ea({
10050
10379
  activeBounds: h,
10051
10380
  candidates: d,
10052
10381
  threshold: c,
@@ -10277,9 +10606,9 @@ var Xr = class {
10277
10606
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
10278
10607
  if (!n) return;
10279
10608
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
10280
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = di, n.setLineDash([4, 4]);
10609
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Ci, n.setLineDash([4, 4]);
10281
10610
  for (let e of this.activeGuides) n.beginPath(), e.type === "vertical" ? (n.moveTo(e.position, a), n.lineTo(e.position, o)) : (n.moveTo(r, e.position), n.lineTo(i, e.position)), n.stroke();
10282
- for (let e of this.activeSpacingGuides) Gi({
10611
+ for (let e of this.activeSpacingGuides) ra({
10283
10612
  context: n,
10284
10613
  guide: e,
10285
10614
  zoom: c
@@ -10490,14 +10819,14 @@ var Xr = class {
10490
10819
  }, r = [];
10491
10820
  for (let e of t) {
10492
10821
  let t = Ye({ object: e });
10493
- t && (Ki({
10822
+ t && (ia({
10494
10823
  anchors: n,
10495
10824
  bounds: t
10496
10825
  }), r.push(t));
10497
10826
  }
10498
10827
  let { montageArea: i } = this.editor, a = Ye({ object: i });
10499
10828
  if (a) {
10500
- Ki({
10829
+ ia({
10501
10830
  anchors: n,
10502
10831
  bounds: a
10503
10832
  });
@@ -10509,12 +10838,12 @@ var Xr = class {
10509
10838
  bottom: i
10510
10839
  };
10511
10840
  } else this.guideBounds = this._calculateViewportBounds();
10512
- this.anchors = n, this.spacingPatterns = Ji({ bounds: r }), this.cachedTargetBounds = r;
10841
+ this.anchors = n, this.spacingPatterns = oa({ bounds: r }), this.cachedTargetBounds = r;
10513
10842
  }
10514
10843
  _collectTargets({ activeObject: e }) {
10515
- let t = Xi({ activeObject: e }), n = [];
10844
+ let t = ca({ activeObject: e }), n = [];
10516
10845
  return this.canvas.forEachObject((e) => {
10517
- Zi({
10846
+ la({
10518
10847
  object: e,
10519
10848
  excluded: t
10520
10849
  }) || n.push(e);
@@ -10537,7 +10866,7 @@ var Xr = class {
10537
10866
  bottom: (r - s) / a
10538
10867
  };
10539
10868
  }
10540
- }, $i = "#3D8BF4", ea = class e {
10869
+ }, da = "#3D8BF4", fa = class e {
10541
10870
  constructor({ editor: e }) {
10542
10871
  this.activeGuides = [], this.isAltPressed = !1, this.pendingEvent = null, this.frameRequest = null, this.isToolbarHidden = !1, this.isTargetMontageArea = !1, this.lastMouseEvent = null, this.editor = e, this.canvas = e.canvas, this._onMouseMove = this._handleMouseMove.bind(this), this._onBeforeRender = this._handleBeforeRender.bind(this), this._onAfterRender = this._handleAfterRender.bind(this), this._onSelectionCleared = this._handleSelectionCleared.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._onKeyUp = this._handleKeyUp.bind(this), this._onWindowBlur = this._handleWindowBlur.bind(this), this._bindEvents();
10543
10872
  }
@@ -10630,8 +10959,8 @@ var Xr = class {
10630
10959
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
10631
10960
  }
10632
10961
  static _resolveTarget({ event: e, activeObject: t }) {
10633
- let { target: n } = e, r = Xi({ activeObject: t });
10634
- return n && !Zi({
10962
+ let { target: n } = e, r = ca({ activeObject: t });
10963
+ return n && !la({
10635
10964
  object: n,
10636
10965
  excluded: r
10637
10966
  }) ? n : null;
@@ -10748,18 +11077,18 @@ var Xr = class {
10748
11077
  let { canvas: e } = this, t = e.getSelectionContext();
10749
11078
  if (!t) return;
10750
11079
  let { viewportTransform: n } = e, r = e.getZoom() || 1, i = this.activeGuides.some((e) => e.type === "vertical"), a = this.activeGuides.some((e) => e.type === "horizontal"), o = i && a && !this.isTargetMontageArea, s = o ? 12 / r : 0;
10751
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = $i, t.setLineDash([]);
11080
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = da, t.setLineDash([]);
10752
11081
  for (let e of this.activeGuides) {
10753
11082
  let { type: n, axis: i, start: a, end: c, distance: l } = e, u = Math.abs(c - a), d = o ? (a <= c ? -1 : 1) * (u / 2 + s) : 0;
10754
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Wi({
11083
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), na({
10755
11084
  context: t,
10756
11085
  type: n,
10757
11086
  axis: i,
10758
11087
  start: a,
10759
11088
  end: c,
10760
- text: pi({ distance: l }).toString(),
11089
+ text: Ti({ distance: l }).toString(),
10761
11090
  zoom: r,
10762
- color: $i,
11091
+ color: da,
10763
11092
  lineWidth: 1,
10764
11093
  offsetAlongAxis: d,
10765
11094
  offsetPerpendicular: 0
@@ -10777,13 +11106,13 @@ var Xr = class {
10777
11106
  let { toolbar: e } = this.editor;
10778
11107
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
10779
11108
  }
10780
- }, ta = class e {
11109
+ }, pa = class e {
10781
11110
  constructor(e, t) {
10782
11111
  this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
10783
11112
  }
10784
11113
  async init() {
10785
11114
  let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, _onReadyCallback: d } = this.options;
10786
- if (ie.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new gr({ editor: this }), this.historyManager = new je({ editor: this }), this.toolbar = new V({ editor: this }), this.transformManager = new He({ editor: this }), this.zoomManager = new Ue({ editor: this }), this.canvasManager = new Ve({ editor: this }), this.imageManager = new Le({ editor: this }), this.layerManager = new et({ editor: this }), this.shapeManager = new lr({ editor: this }), this.interactionBlocker = new Qe({ editor: this }), this.backgroundManager = new $e({ editor: this }), this.clipboardManager = new ur({ editor: this }), this.objectLockManager = new dr({ editor: this }), this.groupingManager = new fr({ editor: this }), this.selectionManager = new pr({ editor: this }), this.deletionManager = new mr({ editor: this }), this.panConstraintManager = new _r({ editor: this }), this.snappingManager = new Qi({ editor: this }), this.measurementManager = new ea({ editor: this }), this.fontManager = new z(this.options.fonts ?? []), this.textManager = new ai({ editor: this }), this.templateManager = new ui({ editor: this }), u && (this.angleIndicator = new ae({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
11115
+ if (re.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new Or({ editor: this }), this.historyManager = new je({ editor: this }), this.toolbar = new H({ editor: this }), this.transformManager = new He({ editor: this }), this.zoomManager = new Ue({ editor: this }), this.canvasManager = new Ve({ editor: this }), this.imageManager = new Le({ editor: this }), this.layerManager = new et({ editor: this }), this.shapeManager = new xr({ editor: this }), this.interactionBlocker = new Qe({ editor: this }), this.backgroundManager = new $e({ editor: this }), this.clipboardManager = new Sr({ editor: this }), this.objectLockManager = new Cr({ editor: this }), this.groupingManager = new wr({ editor: this }), this.selectionManager = new Tr({ editor: this }), this.deletionManager = new Er({ editor: this }), this.panConstraintManager = new kr({ editor: this }), this.snappingManager = new ua({ editor: this }), this.measurementManager = new fa({ editor: this }), this.fontManager = new B(this.options.fonts ?? []), this.textManager = new _i({ editor: this }), this.templateManager = new Si({ editor: this }), u && (this.angleIndicator = new ae({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
10787
11116
  editor: this,
10788
11117
  options: this.options
10789
11118
  }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(n), this.canvasManager.setCanvasWrapperWidth(r), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), await this.fontManager.loadFonts(), c) {
@@ -10891,7 +11220,7 @@ var Xr = class {
10891
11220
  "U+A640-A69F",
10892
11221
  "U+FE2E-FE2F",
10893
11222
  "U+2116"
10894
- ].join(", "), na = {
11223
+ ].join(", "), ma = {
10895
11224
  preserveObjectStacking: !0,
10896
11225
  controlsAboveOverlay: !0,
10897
11226
  centeredRotation: !0,
@@ -11745,20 +12074,20 @@ var Xr = class {
11745
12074
  };
11746
12075
  //#endregion
11747
12076
  //#region src/main.ts
11748
- function ra(e, t = {}) {
12077
+ function ha(e, t = {}) {
11749
12078
  let n = {
11750
- ...na,
12079
+ ...ma,
11751
12080
  ...t
11752
12081
  }, r = document.getElementById(e);
11753
12082
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
11754
12083
  let i = document.createElement("canvas");
11755
12084
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
11756
12085
  n._onReadyCallback = t;
11757
- let r = new ta(i.id, n);
12086
+ let r = new pa(i.id, n);
11758
12087
  window[e] = r;
11759
12088
  });
11760
12089
  }
11761
12090
  //#endregion
11762
- export { ra as default };
12091
+ export { ha as default };
11763
12092
 
11764
12093
  //# sourceMappingURL=main.js.map