@anu3ev/fabric-image-editor 0.8.14 → 0.8.15

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 +449 -433
  2. package/package.json +3 -2
package/dist/main.js CHANGED
@@ -5199,7 +5199,7 @@ var dr = ({ transform: e, key: t }) => {
5199
5199
  if (!n || typeof n != "object") return null;
5200
5200
  let r = n[t];
5201
5201
  return typeof r != "number" || !Number.isFinite(r) ? null : r;
5202
- }, fr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, pr = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, mr = ({ transform: e }) => {
5202
+ }, fr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, pr = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Y = ({ transform: e }) => {
5203
5203
  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;
5204
5204
  return {
5205
5205
  canScaleWidth: o,
@@ -5207,37 +5207,37 @@ var dr = ({ transform: e, key: t }) => {
5207
5207
  isCornerScaleAction: r,
5208
5208
  isVerticalOnlyScale: s && !o
5209
5209
  };
5210
- }, hr = ({ event: e, target: t, transform: n, canvas: r }) => {
5210
+ }, mr = ({ event: e, target: t, transform: n, canvas: r }) => {
5211
5211
  if (!e) return null;
5212
5212
  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;
5213
5213
  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;
5214
- }, gr = ({ group: e, originX: t, originY: n }) => {
5214
+ }, hr = ({ group: e, originX: t, originY: n }) => {
5215
5215
  if (t === null || n === null) return null;
5216
5216
  let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
5217
5217
  return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
5218
- }, _r = ({ state: e, transform: t }) => {
5218
+ }, gr = ({ state: e, transform: t }) => {
5219
5219
  if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
5220
5220
  let n = fr({ value: t.originX }), r = pr({ value: t.originY });
5221
5221
  return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
5222
- }, vr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5222
+ }, _r = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5223
5223
  //#endregion
5224
5224
  //#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
5225
- function yr({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
5225
+ function vr({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
5226
5226
  let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
5227
5227
  return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
5228
5228
  }
5229
- function br({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
5229
+ function yr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
5230
5230
  let c = Math.max(0, e.shapeStrokeWidth ?? 0);
5231
5231
  tn({
5232
5232
  shape: t,
5233
- width: yr({
5233
+ width: vr({
5234
5234
  size: n,
5235
5235
  scale: i,
5236
5236
  strokeWidth: c,
5237
5237
  minSize: o,
5238
5238
  scaleEpsilon: s
5239
5239
  }),
5240
- height: yr({
5240
+ height: vr({
5241
5241
  size: r,
5242
5242
  scale: a,
5243
5243
  strokeWidth: c,
@@ -5248,7 +5248,7 @@ function br({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
5248
5248
  strokeWidth: c
5249
5249
  });
5250
5250
  }
5251
- function xr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
5251
+ function br({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
5252
5252
  let o = Math.max(a, Math.abs(r) || 1), s = Math.max(a, Math.abs(i) || 1), c = n ?? "center";
5253
5253
  e.set({
5254
5254
  autoExpand: !1,
@@ -5263,13 +5263,13 @@ function xr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon:
5263
5263
  scaleY: 1 / s
5264
5264
  }), e.initDimensions(), e.setCoords();
5265
5265
  }
5266
- var Sr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
5266
+ var xr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
5267
5267
  let l = Math.max(c, Math.abs(a) || 1), u = Math.max(c, Math.abs(o) || 1);
5268
5268
  e.set({
5269
5269
  width: r.width / l,
5270
5270
  height: r.height / u,
5271
5271
  dirty: !0
5272
- }), br({
5272
+ }), yr({
5273
5273
  group: e,
5274
5274
  shape: t,
5275
5275
  width: r.width,
@@ -5278,7 +5278,7 @@ var Sr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
5278
5278
  scaleY: o,
5279
5279
  minSize: s,
5280
5280
  scaleEpsilon: c
5281
- }), xr({
5281
+ }), br({
5282
5282
  text: n,
5283
5283
  layout: r,
5284
5284
  alignH: i,
@@ -5286,17 +5286,29 @@ var Sr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
5286
5286
  scaleY: o,
5287
5287
  scaleEpsilon: c
5288
5288
  });
5289
- }, Y = 1e-4, Cr = .5;
5290
- function wr({ width: e, height: t }) {
5289
+ }, X = 1e-4, Sr = .5;
5290
+ function Cr({ width: e, height: t }) {
5291
5291
  return `${Math.round(Math.max(1, e) * 1e6) / 1e6}:${Math.round(Math.max(1, t) * 1e6) / 1e6}`;
5292
5292
  }
5293
- function Tr({ width: e, padding: t }) {
5293
+ function wr({ width: e, padding: t }) {
5294
5294
  return Math.max(1, e - Math.max(0, t.left) - Math.max(0, t.right));
5295
5295
  }
5296
- function Er({ height: e, padding: t }) {
5296
+ function Tr({ height: e, padding: t }) {
5297
5297
  return Math.max(1, e - Math.max(0, t.top) - Math.max(0, t.bottom));
5298
5298
  }
5299
- function Dr({ group: e }) {
5299
+ function Er({ text: e }) {
5300
+ return (e.text ?? "").trim().length > 0;
5301
+ }
5302
+ function Dr({ height: e }) {
5303
+ return {
5304
+ measuredHeight: e,
5305
+ renderedLineCount: 0,
5306
+ longestLineWidth: 0,
5307
+ requiresGraphemeSplit: !1,
5308
+ isValid: !0
5309
+ };
5310
+ }
5311
+ function Or({ group: e }) {
5300
5312
  return Pe({ padding: {
5301
5313
  top: e.shapePaddingTop,
5302
5314
  right: e.shapePaddingRight,
@@ -5304,7 +5316,7 @@ function Dr({ group: e }) {
5304
5316
  left: e.shapePaddingLeft
5305
5317
  } });
5306
5318
  }
5307
- function Or({ group: e, width: t, height: n }) {
5319
+ function kr({ group: e, width: t, height: n }) {
5308
5320
  let r = e.shapePresetKey ?? "", i = r ? Te({ presetKey: r }) : null;
5309
5321
  return Re({
5310
5322
  baseInset: i ? Oe({
@@ -5316,27 +5328,31 @@ function Or({ group: e, width: t, height: n }) {
5316
5328
  strokeWidth: e.shapeStrokeWidth
5317
5329
  });
5318
5330
  }
5319
- function X({ group: e, width: t, height: n }) {
5320
- return Or({
5331
+ function Z({ group: e, width: t, height: n }) {
5332
+ return kr({
5321
5333
  group: e,
5322
5334
  width: Math.max(1, t ?? e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1),
5323
5335
  height: Math.max(1, n ?? e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1)
5324
5336
  });
5325
5337
  }
5326
- function kr({ group: e, text: t, width: n, height: r, measurementCache: i, constraintCache: a }) {
5327
- let o = Math.max(1, n), s = Math.max(1, r), c = wr({
5338
+ function Ar({ group: e, text: t, width: n, height: r, measurementCache: i, constraintCache: a }) {
5339
+ let o = Math.max(1, n), s = Math.max(1, r), c = Cr({
5328
5340
  width: o,
5329
5341
  height: s
5330
5342
  }), l = a?.get(c);
5331
5343
  if (l) return l;
5332
- let u = X({
5344
+ if (!Er({ text: t })) {
5345
+ let e = Dr({ height: s });
5346
+ return a?.set(c, e), e;
5347
+ }
5348
+ let u = Z({
5333
5349
  group: e,
5334
5350
  width: o,
5335
5351
  height: s
5336
- }), d = Tr({
5352
+ }), d = wr({
5337
5353
  width: o,
5338
5354
  padding: u
5339
- }), f = Er({
5355
+ }), f = Tr({
5340
5356
  height: s,
5341
5357
  padding: u
5342
5358
  }), p = Zn({
@@ -5350,9 +5366,9 @@ function kr({ group: e, text: t, width: n, height: r, measurementCache: i, const
5350
5366
  };
5351
5367
  return a?.set(c, m), m;
5352
5368
  }
5353
- function Ar({ group: e, text: t, state: n }) {
5369
+ function jr({ group: e, text: t, state: n }) {
5354
5370
  let { startHeight: r, startWidth: i, startScaleX: a, startScaleY: o, lastAllowedScaleX: s, lastAllowedScaleY: c } = n, l = Math.max(1 / i, 1 / r), u = Math.max(l, a, o, s, c), d = ({ scale: a }) => {
5355
- let o = kr({
5371
+ let o = Ar({
5356
5372
  group: e,
5357
5373
  text: t,
5358
5374
  width: Math.max(1, i * a),
@@ -5383,28 +5399,28 @@ function Ar({ group: e, text: t, state: n }) {
5383
5399
  minimumHeight: g
5384
5400
  };
5385
5401
  }
5386
- function jr({ group: e, text: t, width: n, padding: r, measurementCache: i }) {
5402
+ function Mr({ group: e, text: t, width: n, padding: r, measurementCache: i }) {
5387
5403
  return Vn({
5388
5404
  text: t,
5389
5405
  width: n,
5390
5406
  height: 1,
5391
5407
  padding: r,
5392
5408
  measurementCache: i ?? void 0,
5393
- resolvePaddingForSize: ({ width: t, height: n }) => X({
5409
+ resolvePaddingForSize: ({ width: t, height: n }) => Z({
5394
5410
  group: e,
5395
5411
  width: t,
5396
5412
  height: n
5397
5413
  })
5398
5414
  });
5399
5415
  }
5400
- function Mr({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o, measurementCache: s }) {
5416
+ function Nr({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o, measurementCache: s }) {
5401
5417
  let c = r.canScaleWidth ? Math.max(1, r.startWidth * i) : r.startWidth, l = r.canScaleHeight ? Math.max(1, r.startHeight * a) : r.startManualBaseHeight, u = o ?? Vn({
5402
5418
  text: t,
5403
5419
  width: c,
5404
5420
  height: l,
5405
5421
  padding: n,
5406
5422
  measurementCache: s ?? void 0,
5407
- resolvePaddingForSize: ({ width: t, height: n }) => X({
5423
+ resolvePaddingForSize: ({ width: t, height: n }) => Z({
5408
5424
  group: e,
5409
5425
  width: t,
5410
5426
  height: n
@@ -5415,25 +5431,25 @@ function Mr({ group: e, text: t, constraintPadding: n, startDimensions: r, appli
5415
5431
  previewHeight: Math.max(l, u)
5416
5432
  };
5417
5433
  }
5418
- function Nr({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
5434
+ function Pr({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
5419
5435
  let o = n.canScaleWidth ? Math.max(1, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(1, n.startHeight * i) : n.startManualBaseHeight, c = a == null ? s : Math.max(s, a), l = !n.canScaleHeight;
5420
5436
  return jn({
5421
5437
  text: t,
5422
5438
  width: o,
5423
5439
  height: c,
5424
5440
  alignV: e.shapeAlignVertical ?? "middle",
5425
- padding: Dr({ group: e }),
5441
+ padding: Or({ group: e }),
5426
5442
  expandShapeHeightToFitText: l,
5427
5443
  measurementCache: n.previewTextMeasurementCache ?? void 0,
5428
- resolveInternalShapeTextInset: ({ width: t, height: n }) => Or({
5444
+ resolveInternalShapeTextInset: ({ width: t, height: n }) => kr({
5429
5445
  group: e,
5430
5446
  width: t,
5431
5447
  height: n
5432
5448
  })
5433
5449
  });
5434
5450
  }
5435
- function Pr({ group: e, transform: t }) {
5436
- let { canScaleWidth: n, canScaleHeight: r } = mr({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
5451
+ function Fr({ group: e, transform: t }) {
5452
+ let { canScaleWidth: n, canScaleHeight: r } = Y({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
5437
5453
  return {
5438
5454
  startWidth: i,
5439
5455
  startHeight: a,
@@ -5443,10 +5459,10 @@ function Pr({ group: e, transform: t }) {
5443
5459
  canScaleHeight: r
5444
5460
  };
5445
5461
  }
5446
- function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
5462
+ function Ir({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
5447
5463
  let a = e.get(t);
5448
5464
  if (a) return a;
5449
- let o = Pr({
5465
+ let o = Fr({
5450
5466
  group: t,
5451
5467
  transform: i
5452
5468
  }), s = dr({
@@ -5461,7 +5477,7 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5461
5477
  }), u = dr({
5462
5478
  transform: i,
5463
5479
  key: "top"
5464
- }), d = Math.abs(s ?? t.scaleX ?? 1) || 1, f = Math.abs(c ?? t.scaleY ?? 1) || 1, p = l ?? t.left ?? 0, m = u ?? t.top ?? 0, h = fr({ value: i?.original?.originX ?? i?.originX }), g = pr({ value: i?.original?.originY ?? i?.originY }), _ = typeof i?.corner == "string" ? i.corner : null, v = gr({
5480
+ }), d = Math.abs(s ?? t.scaleX ?? 1) || 1, f = Math.abs(c ?? t.scaleY ?? 1) || 1, p = l ?? t.left ?? 0, m = u ?? t.top ?? 0, h = fr({ value: i?.original?.originX ?? i?.originX }), g = pr({ value: i?.original?.originY ?? i?.originY }), _ = typeof i?.corner == "string" ? i.corner : null, v = hr({
5465
5481
  group: t,
5466
5482
  originX: h,
5467
5483
  originY: g
@@ -5469,7 +5485,7 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5469
5485
  measurementsByKey: /* @__PURE__ */ new Map(),
5470
5486
  splitByGraphemeByFrameWidth: /* @__PURE__ */ new Map(),
5471
5487
  minimumTextFrameWidth: null
5472
- }, x = /* @__PURE__ */ new Map(), S = jr({
5488
+ }, x = /* @__PURE__ */ new Map(), S = Mr({
5473
5489
  group: t,
5474
5490
  text: n,
5475
5491
  width: o.startWidth,
@@ -5483,7 +5499,7 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5483
5499
  startManualBaseHeight: o.startManualBaseHeight,
5484
5500
  canScaleWidth: o.canScaleWidth,
5485
5501
  canScaleHeight: o.canScaleHeight,
5486
- cannotScaleDownAtStart: S >= o.startHeight - Y,
5502
+ cannotScaleDownAtStart: S >= o.startHeight - X,
5487
5503
  isProportionalScaling: !1,
5488
5504
  blockedScaleAttempt: !1,
5489
5505
  startLeft: p,
@@ -5511,15 +5527,15 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5511
5527
  proportionalTextConstraintCache: x
5512
5528
  }, e.set(t, a), a;
5513
5529
  }
5514
- function Ir({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a }) {
5515
- let { previewWidth: o, previewHeight: s } = Mr({
5530
+ function Lr({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a }) {
5531
+ let { previewWidth: o, previewHeight: s } = Nr({
5516
5532
  group: e,
5517
5533
  text: t,
5518
5534
  constraintPadding: n,
5519
5535
  startDimensions: r,
5520
5536
  appliedScaleX: i,
5521
5537
  appliedScaleY: a
5522
- }), { startWidth: c, startHeight: l } = r, u = Math.abs(o - c) > Cr, d = Math.abs(s - l) > Cr;
5538
+ }), { startWidth: c, startHeight: l } = r, u = Math.abs(o - c) > Sr, d = Math.abs(s - l) > Sr;
5523
5539
  return {
5524
5540
  width: o,
5525
5541
  height: s,
@@ -5527,7 +5543,7 @@ function Ir({ group: e, text: t, constraintPadding: n, startDimensions: r, scale
5527
5543
  hasDimensionChange: u || d
5528
5544
  };
5529
5545
  }
5530
- function Lr({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
5546
+ function Rr({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
5531
5547
  let o = e;
5532
5548
  n && (o = i);
5533
5549
  let s = t;
@@ -5536,8 +5552,8 @@ function Lr({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth:
5536
5552
  height: s
5537
5553
  };
5538
5554
  }
5539
- function Rr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d }) {
5540
- let f = Lr({
5555
+ function zr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d }) {
5556
+ let f = Rr({
5541
5557
  startManualBaseWidth: s,
5542
5558
  startManualBaseHeight: c,
5543
5559
  canScaleWidth: l,
@@ -5546,11 +5562,11 @@ function Rr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
5546
5562
  finalHeight: i
5547
5563
  });
5548
5564
  e.shapeManualBaseWidth = f.width, e.shapeManualBaseHeight = f.height, l && d && (e.shapeTextAutoExpand = !1);
5549
- let p = Dr({ group: e }), m = Or({
5565
+ let p = Or({ group: e }), m = kr({
5550
5566
  group: e,
5551
5567
  width: r,
5552
5568
  height: i
5553
- }), h = !u, g = ({ width: t, height: n }) => Or({
5569
+ }), h = !u, g = ({ width: t, height: n }) => kr({
5554
5570
  group: e,
5555
5571
  width: t,
5556
5572
  height: n
@@ -5590,13 +5606,13 @@ function Rr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
5590
5606
  }
5591
5607
  //#endregion
5592
5608
  //#region src/editor/shape-manager/scaling/shape-active-selection-scaling.ts
5593
- var zr = class {
5609
+ var Br = class {
5594
5610
  constructor({ canvas: e, shapeScalingState: t }) {
5595
5611
  this.canvas = e, this.shapeScalingState = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.scalingSessions = /* @__PURE__ */ new WeakMap(), this.groupLayoutScales = /* @__PURE__ */ new WeakMap();
5596
5612
  }
5597
5613
  handleScalingPreview({ selection: e, transform: t, event: n }) {
5598
5614
  if (!t) return;
5599
- let { canScaleWidth: r, canScaleHeight: i, isCornerScaleAction: a } = mr({ transform: t });
5615
+ let { canScaleWidth: r, canScaleHeight: i, isCornerScaleAction: a } = Y({ transform: t });
5600
5616
  if (!r && !i) return;
5601
5617
  let o = this._collectPreviewItems({
5602
5618
  selection: e,
@@ -5640,7 +5656,7 @@ var zr = class {
5640
5656
  } else c = this._resolveShapeLayoutScale({
5641
5657
  item: e,
5642
5658
  selectionScale: p
5643
- }), l = Mr({
5659
+ }), l = Nr({
5644
5660
  group: t,
5645
5661
  text: r,
5646
5662
  constraintPadding: i,
@@ -5649,11 +5665,11 @@ var zr = class {
5649
5665
  appliedScaleY: c.scaleY,
5650
5666
  measurementCache: a.previewTextMeasurementCache
5651
5667
  }).previewHeight;
5652
- Sr({
5668
+ xr({
5653
5669
  group: t,
5654
5670
  shape: n,
5655
5671
  text: r,
5656
- layout: Nr({
5672
+ layout: Pr({
5657
5673
  group: t,
5658
5674
  text: r,
5659
5675
  state: a,
@@ -5665,7 +5681,7 @@ var zr = class {
5665
5681
  scaleX: p.scaleX,
5666
5682
  scaleY: p.scaleY,
5667
5683
  minSize: 1,
5668
- scaleEpsilon: Y
5684
+ scaleEpsilon: X
5669
5685
  }), this.groupLayoutScales.set(t, c), this._positionShapeInSelection({
5670
5686
  group: t,
5671
5687
  sessionItem: o
@@ -5676,13 +5692,13 @@ var zr = class {
5676
5692
  commitGroupScaling({ group: e, scaleX: t, scaleY: n, transform: r }) {
5677
5693
  let { shape: i, text: a } = U({ group: e });
5678
5694
  if (!i || !a) return this.shapeScalingState.delete(e), !1;
5679
- let o = this.shapeScalingState.get(e), s = o ?? Pr({
5695
+ let o = this.shapeScalingState.get(e), s = o ?? Fr({
5680
5696
  group: e,
5681
5697
  transform: r
5682
- }), c = r ? mr({ transform: r }) : null, l = o?.canScaleWidth ?? c?.canScaleWidth ?? Math.abs(t - 1) > 1e-4, u = o?.canScaleHeight ?? c?.canScaleHeight ?? Math.abs(n - 1) > 1e-4, d = e.shapeAlignHorizontal ?? "center", f = e.shapeAlignVertical ?? "middle", p = X({ group: e }), m = this.groupLayoutScales.get(e) ?? {
5698
+ }), c = r ? Y({ transform: r }) : null, l = o?.canScaleWidth ?? c?.canScaleWidth ?? Math.abs(t - 1) > 1e-4, u = o?.canScaleHeight ?? c?.canScaleHeight ?? Math.abs(n - 1) > 1e-4, d = e.shapeAlignHorizontal ?? "center", f = e.shapeAlignVertical ?? "middle", p = Z({ group: e }), m = this.groupLayoutScales.get(e) ?? {
5683
5699
  scaleX: t,
5684
5700
  scaleY: n
5685
- }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = Ir({
5701
+ }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = Lr({
5686
5702
  group: e,
5687
5703
  text: a,
5688
5704
  constraintPadding: p,
@@ -5694,7 +5710,7 @@ var zr = class {
5694
5710
  scaleX: m.scaleX,
5695
5711
  scaleY: m.scaleY
5696
5712
  });
5697
- return v ? (Rr({
5713
+ return v ? (zr({
5698
5714
  group: e,
5699
5715
  shape: i,
5700
5716
  text: a,
@@ -5730,7 +5746,7 @@ var zr = class {
5730
5746
  if (!H(r)) continue;
5731
5747
  let { shape: e, text: i } = U({ group: r });
5732
5748
  if (!e || !i) continue;
5733
- let a = X({ group: r }), o = Fr({
5749
+ let a = Z({ group: r }), o = Ir({
5734
5750
  scalingState: this.shapeScalingState,
5735
5751
  group: r,
5736
5752
  text: i,
@@ -5777,7 +5793,7 @@ var zr = class {
5777
5793
  return this.scalingSessions.set(e, u), u;
5778
5794
  }
5779
5795
  _resolveSelectionScale({ items: e, session: t, transform: n, proportionalLayoutResults: r, scaleX: i, scaleY: a, event: o }) {
5780
- let { canScaleWidth: s, canScaleHeight: c, isCornerScaleAction: l } = mr({ transform: n }), u = !!(o && "shiftKey" in o && o.shiftKey), d = l && !u, f = i, p = a;
5796
+ let { canScaleWidth: s, canScaleHeight: c, isCornerScaleAction: l } = Y({ transform: n }), u = !!(o && "shiftKey" in o && o.shiftKey), d = l && !u, f = i, p = a;
5781
5797
  if (d) {
5782
5798
  let n = Math.max(i, a);
5783
5799
  if (!r) return {
@@ -5851,7 +5867,7 @@ var zr = class {
5851
5867
  return o;
5852
5868
  }
5853
5869
  _resolveSelectionScaleAtPointerBoundary({ selection: e, items: t, session: n, transform: r, selectionScale: i, event: a }) {
5854
- let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = mr({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
5870
+ let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = Y({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
5855
5871
  if (c && !l) return i;
5856
5872
  let u = o && this._hasPointerReachedSelectionScaleOrigin({
5857
5873
  selection: e,
@@ -5970,7 +5986,7 @@ var zr = class {
5970
5986
  _resolveProportionalLayoutResults({ items: e }) {
5971
5987
  let t = /* @__PURE__ */ new Map();
5972
5988
  for (let n of e) {
5973
- let e = Ar({
5989
+ let e = jr({
5974
5990
  group: n.group,
5975
5991
  text: n.text,
5976
5992
  state: n.state
@@ -5988,7 +6004,7 @@ var zr = class {
5988
6004
  text: r,
5989
6005
  padding: i,
5990
6006
  measurementCache: a.previewTextMeasurementCache ?? void 0,
5991
- resolvePaddingForWidth: ({ width: e }) => X({
6007
+ resolvePaddingForWidth: ({ width: e }) => Z({
5992
6008
  group: n,
5993
6009
  width: e,
5994
6010
  height: o
@@ -6001,7 +6017,7 @@ var zr = class {
6001
6017
  }
6002
6018
  _resolveMinimumShapeHeight({ item: e, scaleX: t }) {
6003
6019
  let { group: n, text: r, constraintPadding: i, state: a } = e;
6004
- return jr({
6020
+ return Mr({
6005
6021
  group: n,
6006
6022
  text: r,
6007
6023
  width: Math.max(1, a.startWidth * t),
@@ -6040,7 +6056,7 @@ var zr = class {
6040
6056
  };
6041
6057
  }
6042
6058
  _resolveVerticalAttachment({ selectionBounds: e, shapeBounds: t }) {
6043
- let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= Cr, a = r <= Cr;
6059
+ let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= Sr, a = r <= Sr;
6044
6060
  return i && !a ? "top" : a && !i ? "bottom" : Math.abs(n - r) <= .5 ? "center" : n < r ? "top" : "bottom";
6045
6061
  }
6046
6062
  _resolveOriginOffset({ origin: e }) {
@@ -6061,7 +6077,7 @@ var zr = class {
6061
6077
  _hasPointerReachedSelectionScaleOrigin({ selection: e, transform: t, event: n, axis: r }) {
6062
6078
  let i = t, a = r === "x" ? i.signX : i.signY;
6063
6079
  if (typeof a != "number" || !Number.isFinite(a)) return !1;
6064
- let o = hr({
6080
+ let o = mr({
6065
6081
  target: e,
6066
6082
  transform: t,
6067
6083
  event: n,
@@ -6080,7 +6096,7 @@ var zr = class {
6080
6096
  scaleY: r
6081
6097
  }), c && o !== null && s !== null && e.setPositionByOrigin(c, o, s), e.setCoords();
6082
6098
  }
6083
- }, Br = class {
6099
+ }, Vr = class {
6084
6100
  constructor({ canvas: t }) {
6085
6101
  this.handleObjectScaling = (t) => {
6086
6102
  let { target: n, transform: r } = t;
@@ -6099,7 +6115,7 @@ var zr = class {
6099
6115
  lockScalingFlip: !0,
6100
6116
  centeredScaling: !1
6101
6117
  });
6102
- let s = X({ group: i }), c = Fr({
6118
+ let s = Z({ group: i }), c = Ir({
6103
6119
  scalingState: this.scalingState,
6104
6120
  group: i,
6105
6121
  text: o,
@@ -6128,7 +6144,7 @@ var zr = class {
6128
6144
  });
6129
6145
  return;
6130
6146
  }
6131
- let _ = Nr({
6147
+ let _ = Pr({
6132
6148
  group: i,
6133
6149
  text: o,
6134
6150
  state: c,
@@ -6142,7 +6158,7 @@ var zr = class {
6142
6158
  shouldHandleAsNoop: !1,
6143
6159
  scaleX: g.appliedScaleX,
6144
6160
  scaleY: g.appliedScaleY
6145
- }), Sr({
6161
+ }), xr({
6146
6162
  group: i,
6147
6163
  shape: a,
6148
6164
  text: o,
@@ -6151,7 +6167,7 @@ var zr = class {
6151
6167
  scaleX: g.appliedScaleX,
6152
6168
  scaleY: g.appliedScaleY,
6153
6169
  minSize: 1,
6154
- scaleEpsilon: Y
6170
+ scaleEpsilon: X
6155
6171
  }), this._restoreScalingAnchorPosition({
6156
6172
  group: i,
6157
6173
  state: c
@@ -6182,7 +6198,7 @@ var zr = class {
6182
6198
  if (!a) return;
6183
6199
  let { shape: o, text: s } = U({ group: i });
6184
6200
  if (!o || !s) return;
6185
- let c = X({ group: i }), l = i.shapeAlignHorizontal ?? "center", { canScaleWidth: u, canScaleHeight: d } = a;
6201
+ let c = Z({ group: i }), l = i.shapeAlignHorizontal ?? "center", { canScaleWidth: u, canScaleHeight: d } = a;
6186
6202
  if (!u && !d) return;
6187
6203
  let f = Math.abs(i.scaleX ?? a.startScaleX) || a.startScaleX, p = Math.abs(i.scaleY ?? a.startScaleY) || a.startScaleY, { scaleX: m, scaleY: h } = this._resolveCurrentDragScales({
6188
6204
  group: i,
@@ -6204,7 +6220,7 @@ var zr = class {
6204
6220
  axis: "y"
6205
6221
  });
6206
6222
  if (!e && !t) return;
6207
- let n = Ar({
6223
+ let n = jr({
6208
6224
  group: i,
6209
6225
  text: s,
6210
6226
  state: a
@@ -6221,7 +6237,7 @@ var zr = class {
6221
6237
  let e = zn({
6222
6238
  text: s,
6223
6239
  padding: c,
6224
- resolvePaddingForWidth: ({ width: e }) => X({
6240
+ resolvePaddingForWidth: ({ width: e }) => Z({
6225
6241
  group: i,
6226
6242
  width: e,
6227
6243
  height: Math.max(1, a.startHeight * v)
@@ -6244,7 +6260,7 @@ var zr = class {
6244
6260
  });
6245
6261
  return;
6246
6262
  }
6247
- y = C ?? jr({
6263
+ y = C ?? Mr({
6248
6264
  group: i,
6249
6265
  text: s,
6250
6266
  width: Math.max(1, a.startWidth * _),
@@ -6257,7 +6273,7 @@ var zr = class {
6257
6273
  }
6258
6274
  if (!x && !S) return;
6259
6275
  y ??= C;
6260
- let w = Mr({
6276
+ let w = Nr({
6261
6277
  group: i,
6262
6278
  text: s,
6263
6279
  constraintPadding: c,
@@ -6266,7 +6282,7 @@ var zr = class {
6266
6282
  appliedScaleY: v,
6267
6283
  minimumHeight: b ? null : y,
6268
6284
  measurementCache: a.previewTextMeasurementCache
6269
- }), T = Nr({
6285
+ }), T = Pr({
6270
6286
  group: i,
6271
6287
  text: s,
6272
6288
  state: a,
@@ -6280,7 +6296,7 @@ var zr = class {
6280
6296
  shouldHandleAsNoop: !1,
6281
6297
  scaleX: _,
6282
6298
  scaleY: v
6283
- }), Sr({
6299
+ }), xr({
6284
6300
  group: i,
6285
6301
  shape: o,
6286
6302
  text: s,
@@ -6289,7 +6305,7 @@ var zr = class {
6289
6305
  scaleX: _,
6290
6306
  scaleY: v,
6291
6307
  minSize: 1,
6292
- scaleEpsilon: Y
6308
+ scaleEpsilon: X
6293
6309
  }), this._restoreScalingAnchorPosition({
6294
6310
  group: i,
6295
6311
  state: a
@@ -6324,7 +6340,7 @@ var zr = class {
6324
6340
  startHeight: s,
6325
6341
  alignH: n.shapeAlignHorizontal,
6326
6342
  alignV: n.shapeAlignVertical,
6327
- userPadding: Dr({ group: n })
6343
+ userPadding: Or({ group: n })
6328
6344
  }), n.shapeScalingNoopTransform = !1, this.scalingState.delete(n), this.canvas.requestRenderAll();
6329
6345
  return;
6330
6346
  }
@@ -6333,7 +6349,7 @@ var zr = class {
6333
6349
  this.scalingState.delete(n);
6334
6350
  return;
6335
6351
  }
6336
- let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = X({ group: n }), h = e.transform ? mr({ transform: e.transform }) : null, g = r?.canScaleWidth ?? h?.canScaleWidth ?? Math.abs(i - 1) > 1e-4, _ = r?.canScaleHeight ?? h?.canScaleHeight ?? Math.abs(a - 1) > 1e-4, v = r?.lastAllowedScaleX ?? i, y = r?.lastAllowedScaleY ?? a;
6352
+ let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = Z({ group: n }), h = e.transform ? Y({ transform: e.transform }) : null, g = r?.canScaleWidth ?? h?.canScaleWidth ?? Math.abs(i - 1) > 1e-4, _ = r?.canScaleHeight ?? h?.canScaleHeight ?? Math.abs(a - 1) > 1e-4, v = r?.lastAllowedScaleX ?? i, y = r?.lastAllowedScaleY ?? a;
6337
6353
  if (r?.isProportionalScaling) {
6338
6354
  let t = this._hasPointerReachedScaleOrigin({
6339
6355
  event: e,
@@ -6347,7 +6363,7 @@ var zr = class {
6347
6363
  axis: "y"
6348
6364
  });
6349
6365
  if (t || o) {
6350
- let e = Ar({
6366
+ let e = jr({
6351
6367
  group: n,
6352
6368
  text: d,
6353
6369
  state: r
@@ -6358,7 +6374,7 @@ var zr = class {
6358
6374
  let t = zn({
6359
6375
  text: d,
6360
6376
  padding: m,
6361
- resolvePaddingForWidth: ({ width: e }) => X({
6377
+ resolvePaddingForWidth: ({ width: e }) => Z({
6362
6378
  group: n,
6363
6379
  width: e,
6364
6380
  height: Math.max(1, s * y)
@@ -6370,7 +6386,7 @@ var zr = class {
6370
6386
  minimumWidth: t,
6371
6387
  state: r
6372
6388
  }) && (v = Math.max(1 / o, t / o));
6373
- let i = jr({
6389
+ let i = Mr({
6374
6390
  group: n,
6375
6391
  text: d,
6376
6392
  width: Math.max(1, o * v),
@@ -6383,7 +6399,7 @@ var zr = class {
6383
6399
  state: r
6384
6400
  }) && (y = Math.max(1 / s, i / s));
6385
6401
  }
6386
- let { width: b, height: x, hasWidthChange: S, hasDimensionChange: C } = Ir({
6402
+ let { width: b, height: x, hasWidthChange: S, hasDimensionChange: C } = Lr({
6387
6403
  group: n,
6388
6404
  text: d,
6389
6405
  constraintPadding: m,
@@ -6408,14 +6424,14 @@ var zr = class {
6408
6424
  startHeight: s,
6409
6425
  alignH: f,
6410
6426
  alignV: p,
6411
- userPadding: Dr({ group: n })
6427
+ userPadding: Or({ group: n })
6412
6428
  }), this.scalingState.delete(n), this.canvas.requestRenderAll();
6413
6429
  return;
6414
6430
  }
6415
6431
  r && n.set({
6416
6432
  left: r.lastAllowedLeft,
6417
6433
  top: r.lastAllowedTop
6418
- }), Rr({
6434
+ }), zr({
6419
6435
  group: n,
6420
6436
  shape: u,
6421
6437
  text: d,
@@ -6432,7 +6448,7 @@ var zr = class {
6432
6448
  group: n,
6433
6449
  state: r
6434
6450
  }), n.setCoords(), d.setCoords(), u.setCoords(), this.scalingState.delete(n), n.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
6435
- }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new zr({
6451
+ }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new Br({
6436
6452
  canvas: t,
6437
6453
  shapeScalingState: this.scalingState
6438
6454
  });
@@ -6441,10 +6457,10 @@ var zr = class {
6441
6457
  let a = e.scaleX ?? 1, o = e.scaleY ?? 1, { scaleX: s, scaleY: c } = this._resolveCurrentDragScales({
6442
6458
  group: e,
6443
6459
  state: r
6444
- }), l = r.canScaleWidth && a < 0 || r.canScaleHeight && o < 0, u = _r({
6460
+ }), l = r.canScaleWidth && a < 0 || r.canScaleHeight && o < 0, u = gr({
6445
6461
  state: r,
6446
6462
  transform: i
6447
- }), d = vr({
6463
+ }), d = _r({
6448
6464
  state: r,
6449
6465
  transform: i
6450
6466
  });
@@ -6460,7 +6476,7 @@ var zr = class {
6460
6476
  f.shouldRestoreLastAllowedTransform && (h = r.lastAllowedScaleX, g = r.lastAllowedScaleY), f.shouldHandleAsNoop && (h = r.startScaleX, g = r.startScaleY);
6461
6477
  let _ = f.resolvedMinimumHeight, v = !r.canScaleWidth && r.canScaleHeight ? r.fixedWidthMinimumTextFitHeight : null;
6462
6478
  f.shouldHandleAsNoop ? _ = r.startHeight : _ ??= v;
6463
- let { previewHeight: y } = Mr({
6479
+ let { previewHeight: y } = Nr({
6464
6480
  group: e,
6465
6481
  text: t,
6466
6482
  constraintPadding: n,
@@ -6479,16 +6495,16 @@ var zr = class {
6479
6495
  };
6480
6496
  }
6481
6497
  _resolveScalingConstraintState({ group: e, text: t, constraintPadding: n, state: r, scaleX: i, scaleY: a }) {
6482
- let { canScaleHeight: o, canScaleWidth: s, startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = r, g = o && !s, _ = s ? Math.max(1, l * i) : l, v = o ? Math.max(1, c * a) : c, y = i < p - Y, b = a < m - Y, x = a < h - Y, S = g ? r.fixedWidthMinimumTextFitHeight : null, C = s && y ? zn({
6498
+ let { canScaleHeight: o, canScaleWidth: s, startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = r, g = o && !s, _ = s ? Math.max(1, l * i) : l, v = o ? Math.max(1, c * a) : c, y = i < p - X, b = a < m - X, x = a < h - X, S = g ? r.fixedWidthMinimumTextFitHeight : null, C = s && y ? zn({
6483
6499
  text: t,
6484
6500
  padding: n,
6485
6501
  measurementCache: r.previewTextMeasurementCache ?? void 0,
6486
- resolvePaddingForWidth: ({ width: t }) => X({
6502
+ resolvePaddingForWidth: ({ width: t }) => Z({
6487
6503
  group: e,
6488
6504
  width: t,
6489
6505
  height: v
6490
6506
  })
6491
- }) : null, w = o && b ? S ?? jr({
6507
+ }) : null, w = o && b ? S ?? Mr({
6492
6508
  group: e,
6493
6509
  text: t,
6494
6510
  width: _,
@@ -6496,7 +6512,7 @@ var zr = class {
6496
6512
  measurementCache: r.previewTextMeasurementCache
6497
6513
  }) : null, T = g && u && x;
6498
6514
  if (f && s && o && (y || b)) {
6499
- if (!kr({
6515
+ if (!Ar({
6500
6516
  group: e,
6501
6517
  text: t,
6502
6518
  width: _,
@@ -6504,7 +6520,7 @@ var zr = class {
6504
6520
  measurementCache: r.previewTextMeasurementCache,
6505
6521
  constraintCache: r.proportionalTextConstraintCache
6506
6522
  }).isValid) {
6507
- let n = Ar({
6523
+ let n = jr({
6508
6524
  group: e,
6509
6525
  text: t,
6510
6526
  state: r
@@ -6527,7 +6543,7 @@ var zr = class {
6527
6543
  }
6528
6544
  let E = C !== null && _ < C + 1e-4, D = w !== null && v < w + 1e-4, O = E || D, k = d, A = null, j = null;
6529
6545
  if (f && O) {
6530
- let n = Ar({
6546
+ let n = jr({
6531
6547
  group: e,
6532
6548
  text: t,
6533
6549
  state: r
@@ -6556,11 +6572,11 @@ var zr = class {
6556
6572
  shouldHandleAsNoop: !0,
6557
6573
  scaleX: r.startScaleX,
6558
6574
  scaleY: r.startScaleY
6559
- }), Sr({
6575
+ }), xr({
6560
6576
  group: e,
6561
6577
  shape: t,
6562
6578
  text: n,
6563
- layout: Nr({
6579
+ layout: Pr({
6564
6580
  group: e,
6565
6581
  text: n,
6566
6582
  state: r,
@@ -6572,7 +6588,7 @@ var zr = class {
6572
6588
  scaleX: r.startScaleX,
6573
6589
  scaleY: r.startScaleY,
6574
6590
  minSize: 1,
6575
- scaleEpsilon: Y
6591
+ scaleEpsilon: X
6576
6592
  }), this._restoreScalingAnchorPosition({
6577
6593
  group: e,
6578
6594
  state: r
@@ -6615,7 +6631,7 @@ var zr = class {
6615
6631
  if (!r) return !1;
6616
6632
  let { transform: i } = e;
6617
6633
  if (!i) return !1;
6618
- let { canScaleWidth: a } = mr({ transform: i });
6634
+ let { canScaleWidth: a } = Y({ transform: i });
6619
6635
  if (!a || !this._hasPointerReachedScaleOrigin({
6620
6636
  event: e,
6621
6637
  group: t,
@@ -6623,13 +6639,13 @@ var zr = class {
6623
6639
  axis: "x"
6624
6640
  })) return !1;
6625
6641
  let o = Math.max(1 / r.startWidth, n / r.startWidth);
6626
- return r.lastAllowedScaleX > o + Y;
6642
+ return r.lastAllowedScaleX > o + X;
6627
6643
  }
6628
6644
  _shouldClampHeightToMinimum({ event: e, group: t, minimumHeight: n, state: r }) {
6629
6645
  if (!r) return !1;
6630
6646
  let { transform: i } = e;
6631
6647
  if (!i) return !1;
6632
- let { canScaleHeight: a } = mr({ transform: i });
6648
+ let { canScaleHeight: a } = Y({ transform: i });
6633
6649
  if (!a || !this._hasPointerReachedScaleOrigin({
6634
6650
  event: e,
6635
6651
  group: t,
@@ -6637,14 +6653,14 @@ var zr = class {
6637
6653
  axis: "y"
6638
6654
  })) return !1;
6639
6655
  let o = Math.max(1 / r.startHeight, n / r.startHeight);
6640
- return r.lastAllowedScaleY > o + Y;
6656
+ return r.lastAllowedScaleY > o + X;
6641
6657
  }
6642
6658
  _hasPointerReachedScaleOrigin({ event: e, group: t, state: n, axis: r }) {
6643
6659
  let { transform: i } = e;
6644
6660
  if (!i) return !1;
6645
6661
  let a = i, o = r === "x" ? n?.scaleDirectionX ?? null : n?.scaleDirectionY ?? null, s = this._resolveScaleDirection({ value: r === "x" ? a.signX : a.signY }) ?? o;
6646
6662
  if (s === null) return !1;
6647
- let c = hr({
6663
+ let c = mr({
6648
6664
  event: e.e,
6649
6665
  target: t,
6650
6666
  transform: i,
@@ -6654,7 +6670,7 @@ var zr = class {
6654
6670
  }
6655
6671
  _storeScaleDirectionsForCurrentTransform({ group: e, state: t, event: n, transform: r }) {
6656
6672
  if (!r) return;
6657
- let { canScaleHeight: i, canScaleWidth: a, isCornerScaleAction: o } = mr({ transform: r });
6673
+ let { canScaleHeight: i, canScaleWidth: a, isCornerScaleAction: o } = Y({ transform: r });
6658
6674
  if (!o) return;
6659
6675
  let s = !a || t.scaleDirectionX !== null, c = !i || t.scaleDirectionY !== null;
6660
6676
  if (s && c) return;
@@ -6662,7 +6678,7 @@ var zr = class {
6662
6678
  a && t.scaleDirectionX === null && (t.scaleDirectionX = this._resolveScaleDirection({ value: l.signX })), i && t.scaleDirectionY === null && (t.scaleDirectionY = this._resolveScaleDirection({ value: l.signY }));
6663
6679
  let u = !a || t.scaleDirectionX !== null, d = !i || t.scaleDirectionY !== null;
6664
6680
  if (u && d) return;
6665
- let f = hr({
6681
+ let f = mr({
6666
6682
  event: n,
6667
6683
  target: e,
6668
6684
  transform: r,
@@ -6691,11 +6707,11 @@ var zr = class {
6691
6707
  e.setPositionByOrigin(new m(n, r), i, a), e.setCoords();
6692
6708
  }
6693
6709
  _restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, startWidth: i, startHeight: a, alignH: o, alignV: s, userPadding: c }) {
6694
- let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = Or({
6710
+ let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = kr({
6695
6711
  group: e,
6696
6712
  width: l,
6697
6713
  height: u
6698
- }), f = o ?? "center", p = s ?? "middle", m = ({ width: t, height: n }) => Or({
6714
+ }), f = o ?? "center", p = s ?? "middle", m = ({ width: t, height: n }) => kr({
6699
6715
  group: e,
6700
6716
  width: t,
6701
6717
  height: n
@@ -6734,7 +6750,7 @@ var zr = class {
6734
6750
  state: r
6735
6751
  });
6736
6752
  }
6737
- }, Vr = class {
6753
+ }, Hr = class {
6738
6754
  constructor({ canvas: e }) {
6739
6755
  this.handleMouseDown = (e) => {
6740
6756
  let { target: t, e: n, subTargets: r = [] } = e, i = Ye({
@@ -6858,7 +6874,7 @@ var zr = class {
6858
6874
  let t = this.canvas;
6859
6875
  t.findTarget = e.findTarget, this.editingTargetResolverState = void 0;
6860
6876
  }
6861
- }, Hr = 1e-4, Ur = class {
6877
+ }, Ur = 1e-4, Wr = class {
6862
6878
  constructor({ runtime: t }) {
6863
6879
  this._handleObjectScaling = (e) => {
6864
6880
  this.runtime.collectShapeGroupsFromTarget({
@@ -6943,7 +6959,7 @@ var zr = class {
6943
6959
  let r = t.getObjects(), i = r.filter((e) => H(e));
6944
6960
  if (!i.length) return;
6945
6961
  let { scaleX: a, scaleY: o } = this.runtime.scalingController.resolveActiveSelectionCommittedScale({ selection: t });
6946
- if (!(Math.abs(a - 1) > Hr || Math.abs(o - 1) > Hr)) {
6962
+ if (!(Math.abs(a - 1) > Ur || Math.abs(o - 1) > Ur)) {
6947
6963
  this.runtime.scalingController.clearActiveSelectionState({ selection: t });
6948
6964
  return;
6949
6965
  }
@@ -6961,7 +6977,7 @@ var zr = class {
6961
6977
  }), e.setCoords());
6962
6978
  }), this.runtime.scalingController.clearActiveSelectionState({ selection: t }), s.setActiveObject(new e(r, { canvas: s })), s.requestRenderAll();
6963
6979
  }
6964
- }, Wr = class {
6980
+ }, Gr = class {
6965
6981
  constructor({ editor: e }) {
6966
6982
  this.editor = e;
6967
6983
  }
@@ -7112,7 +7128,7 @@ var zr = class {
7112
7128
  resolvePaddingForWidth: i
7113
7129
  }) : Math.max(1, t, n);
7114
7130
  }
7115
- }, Gr = class e {
7131
+ }, Kr = class e {
7116
7132
  constructor({ canvas: e }) {
7117
7133
  this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
7118
7134
  }
@@ -7308,7 +7324,7 @@ var zr = class {
7308
7324
  }
7309
7325
  }), I;
7310
7326
  }
7311
- }, Kr = .01, qr = ({ textbox: e }) => {
7327
+ }, qr = .01, Jr = ({ textbox: e }) => {
7312
7328
  let t = e.text ?? "";
7313
7329
  if (!t.length) return [];
7314
7330
  let n = t.split("\n"), r = [], i = 0;
@@ -7320,7 +7336,7 @@ var zr = class {
7320
7336
  });
7321
7337
  }
7322
7338
  return r;
7323
- }, Jr = ({ range: e, text: t }) => {
7339
+ }, Yr = ({ range: e, text: t }) => {
7324
7340
  if (!e) return null;
7325
7341
  let n = t.length;
7326
7342
  if (n <= 0) return null;
@@ -7329,8 +7345,8 @@ var zr = class {
7329
7345
  start: l,
7330
7346
  end: u
7331
7347
  };
7332
- }, Yr = ({ textbox: e, range: t }) => {
7333
- let n = qr({ textbox: e });
7348
+ }, Xr = ({ textbox: e, range: t }) => {
7349
+ let n = Jr({ textbox: e });
7334
7350
  if (!n.length) return t;
7335
7351
  let { start: r } = t, { end: i } = t;
7336
7352
  for (let e = 0; e < n.length; e += 1) {
@@ -7343,7 +7359,7 @@ var zr = class {
7343
7359
  start: r,
7344
7360
  end: i
7345
7361
  };
7346
- }, Xr = ({ textbox: e, range: t }) => {
7362
+ }, Zr = ({ textbox: e, range: t }) => {
7347
7363
  let n = e.text ?? "";
7348
7364
  if (!n.length) return [];
7349
7365
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -7352,7 +7368,7 @@ var zr = class {
7352
7368
  i > n && r < c && o.push(e), s = c + 1;
7353
7369
  }
7354
7370
  return o;
7355
- }, Zr = ({ textbox: e, range: t }) => {
7371
+ }, Qr = ({ textbox: e, range: t }) => {
7356
7372
  let n = e.text ?? "";
7357
7373
  if (!n.length) return [];
7358
7374
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -7361,21 +7377,21 @@ var zr = class {
7361
7377
  r <= n && i >= c && o.push(e), s = c + 1;
7362
7378
  }
7363
7379
  return o;
7364
- }, Qr = ({ previous: e, next: t }) => {
7380
+ }, $r = ({ previous: e, next: t }) => {
7365
7381
  let n = Math.min(e.length, t.length);
7366
7382
  for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
7367
7383
  return n;
7368
- }, $r = ({ text: e, charIndex: t }) => {
7384
+ }, ei = ({ text: e, charIndex: t }) => {
7369
7385
  let n = Math.max(0, Math.min(t, e.length)), r = 0;
7370
7386
  for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
7371
7387
  return r;
7372
- }, ei = ({ text: e, lineIndex: t }) => {
7388
+ }, ti = ({ text: e, lineIndex: t }) => {
7373
7389
  if (t <= 0) return 0;
7374
7390
  let n = 0;
7375
7391
  for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
7376
7392
  return e.length;
7377
- }, ti = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousText: i }) => {
7378
- let a = ei({
7393
+ }, ni = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousText: i }) => {
7394
+ let a = ti({
7379
7395
  text: i,
7380
7396
  lineIndex: r
7381
7397
  }), o = r + 1;
@@ -7394,7 +7410,7 @@ var zr = class {
7394
7410
  lineFontDefaults: s,
7395
7411
  changed: !0
7396
7412
  };
7397
- }, ni = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousLines: i, previousText: a }) => {
7413
+ }, ri = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousLines: i, previousText: a }) => {
7398
7414
  let o = Math.abs(e), s = r;
7399
7415
  a[t] === "\n" && (i[r] ?? "").length > 0 && (s = r + 1);
7400
7416
  let c = s + o - 1, l = {}, u = [];
@@ -7417,7 +7433,7 @@ var zr = class {
7417
7433
  lineDefaults: u
7418
7434
  }
7419
7435
  };
7420
- }, ri = ({ lineFontDefaults: e, previousText: t, currentText: n }) => {
7436
+ }, ii = ({ lineFontDefaults: e, previousText: t, currentText: n }) => {
7421
7437
  if (!e || !Object.keys(e).length) return {
7422
7438
  lineFontDefaults: e,
7423
7439
  changed: !1
@@ -7427,20 +7443,20 @@ var zr = class {
7427
7443
  lineFontDefaults: e,
7428
7444
  changed: !1
7429
7445
  };
7430
- let a = Qr({
7446
+ let a = $r({
7431
7447
  previous: t,
7432
7448
  next: n
7433
- }), o = $r({
7449
+ }), o = ei({
7434
7450
  text: t,
7435
7451
  charIndex: a
7436
7452
  });
7437
- return i > 0 ? ti({
7453
+ return i > 0 ? ni({
7438
7454
  deltaLines: i,
7439
7455
  diffIndex: a,
7440
7456
  lineFontDefaults: e,
7441
7457
  lineIndexOld: o,
7442
7458
  previousText: t
7443
- }) : ni({
7459
+ }) : ri({
7444
7460
  deltaLines: i,
7445
7461
  diffIndex: a,
7446
7462
  lineFontDefaults: e,
@@ -7448,10 +7464,10 @@ var zr = class {
7448
7464
  previousLines: r,
7449
7465
  previousText: t
7450
7466
  });
7451
- }, ii = ({ lineDefaults: e }) => {
7467
+ }, ai = ({ lineDefaults: e }) => {
7452
7468
  let t = {};
7453
7469
  return e.fontFamily !== void 0 && (t.fontFamily = e.fontFamily), e.fontSize !== void 0 && (t.fontSize = e.fontSize), e.fontWeight !== void 0 && (t.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (t.fontStyle = e.fontStyle), e.underline !== void 0 && (t.underline = e.underline), e.linethrough !== void 0 && (t.linethrough = e.linethrough), e.fill !== void 0 && (t.fill = e.fill), e.stroke !== void 0 && (t.stroke = e.stroke), e.strokeWidth !== void 0 && (t.strokeWidth = e.strokeWidth), t;
7454
- }, ai = ({ textbox: e, lineIndices: t, updates: n }) => {
7470
+ }, oi = ({ textbox: e, lineIndices: t, updates: n }) => {
7455
7471
  if (!t.length) return !1;
7456
7472
  let { fill: r, fontFamily: i, fontSize: a, fontStyle: o, fontWeight: s, linethrough: c, stroke: l, strokeWidth: u, underline: d } = n;
7457
7473
  if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0 || l !== void 0 || u !== void 0 || d !== void 0)) return !1;
@@ -7463,12 +7479,12 @@ var zr = class {
7463
7479
  i !== void 0 && g?.fontFamily !== i && (_.fontFamily = i, v = !0), a !== void 0 && g?.fontSize !== a && (_.fontSize = a, v = !0), s !== void 0 && g?.fontWeight !== s && (_.fontWeight = s, v = !0), o !== void 0 && g?.fontStyle !== o && (_.fontStyle = o, v = !0), d !== void 0 && g?.underline !== d && (_.underline = d, v = !0), c !== void 0 && g?.linethrough !== c && (_.linethrough = c, v = !0), r !== void 0 && g?.fill !== r && (_.fill = r, v = !0), l !== void 0 && (l === null && g?.stroke !== void 0 && (delete _.stroke, v = !0), l !== null && g?.stroke !== l && (_.stroke = l, v = !0)), u !== void 0 && g?.strokeWidth !== u && (_.strokeWidth = u, v = !0), v && (h ||= (p = { ...p }, !0), p[n] = _, m = !0);
7464
7480
  }
7465
7481
  return m && (e.lineFontDefaults = p), m;
7466
- }, oi = ({ lineStyles: e, lineDefaults: t }) => {
7482
+ }, si = ({ lineStyles: e, lineDefaults: t }) => {
7467
7483
  if (!e) return {
7468
7484
  lineStyles: e,
7469
7485
  changed: !1
7470
7486
  };
7471
- let n = ii({ lineDefaults: t }), r = Object.keys(n);
7487
+ let n = ai({ lineDefaults: t }), r = Object.keys(n);
7472
7488
  if (!r.length) return {
7473
7489
  lineStyles: e,
7474
7490
  changed: !1
@@ -7492,7 +7508,7 @@ var zr = class {
7492
7508
  lineStyles: e,
7493
7509
  changed: !1
7494
7510
  };
7495
- }, si = ({ cleanup: e, lineCount: t, styles: n }) => {
7511
+ }, ci = ({ cleanup: e, lineCount: t, styles: n }) => {
7496
7512
  if (!e) return {
7497
7513
  styles: n,
7498
7514
  changed: !1
@@ -7512,7 +7528,7 @@ var zr = class {
7512
7528
  for (let t = 0; t < e.lineDefaults.length; t += 1) {
7513
7529
  let n = e.lineDefaults[t];
7514
7530
  if (!n) continue;
7515
- let a = oi({
7531
+ let a = si({
7516
7532
  lineStyles: r,
7517
7533
  lineDefaults: n
7518
7534
  });
@@ -7527,19 +7543,19 @@ var zr = class {
7527
7543
  styles: a,
7528
7544
  changed: !0
7529
7545
  };
7530
- }, ci = ({ textbox: e }) => {
7546
+ }, li = ({ textbox: e }) => {
7531
7547
  let { fontFamily: t, fontSize: n, fontStyle: r, fontWeight: i, fill: a, stroke: o, strokeWidth: s, linethrough: c, underline: l } = e, u = {}, d = typeof a == "string" ? a : void 0, f = typeof o == "string" ? o : void 0;
7532
7548
  return t !== void 0 && (u.fontFamily = t), n !== void 0 && (u.fontSize = n), i !== void 0 && (u.fontWeight = i), r !== void 0 && (u.fontStyle = r), l !== void 0 && (u.underline = l), c !== void 0 && (u.linethrough = c), d !== void 0 && (u.fill = d), f !== void 0 && (u.stroke = f), s !== void 0 && (u.strokeWidth = s), u;
7533
- }, li = ({ sourceDefaults: e, globalLineDefaults: t }) => {
7549
+ }, ui = ({ sourceDefaults: e, globalLineDefaults: t }) => {
7534
7550
  let n = {};
7535
7551
  return e?.fontFamily === void 0 ? t.fontFamily !== void 0 && (n.fontFamily = t.fontFamily) : n.fontFamily = e.fontFamily, e?.fontSize === void 0 ? t.fontSize !== void 0 && (n.fontSize = t.fontSize) : n.fontSize = e.fontSize, e?.fontWeight === void 0 ? t.fontWeight !== void 0 && (n.fontWeight = t.fontWeight) : n.fontWeight = e.fontWeight, e?.fontStyle === void 0 ? t.fontStyle !== void 0 && (n.fontStyle = t.fontStyle) : n.fontStyle = e.fontStyle, e?.underline === void 0 ? t.underline !== void 0 && (n.underline = t.underline) : n.underline = e.underline, e?.linethrough === void 0 ? t.linethrough !== void 0 && (n.linethrough = t.linethrough) : n.linethrough = e.linethrough, e?.fill === void 0 ? t.fill !== void 0 && (n.fill = t.fill) : n.fill = e.fill, e?.stroke === void 0 ? t.stroke !== void 0 && (n.stroke = t.stroke) : n.stroke = e.stroke, e?.strokeWidth === void 0 ? n.stroke !== void 0 && t.strokeWidth !== void 0 && (n.strokeWidth = t.strokeWidth) : n.strokeWidth = e.strokeWidth, n;
7536
- }, ui = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
7552
+ }, di = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
7537
7553
  let r = e.length;
7538
7554
  if (r === 0) return {
7539
7555
  lineStyles: t,
7540
7556
  changed: !1
7541
7557
  };
7542
- let i = ii({ lineDefaults: n }), a = Object.keys(i);
7558
+ let i = ai({ lineDefaults: n }), a = Object.keys(i);
7543
7559
  if (!a.length) return {
7544
7560
  lineStyles: t,
7545
7561
  changed: !1
@@ -7565,8 +7581,8 @@ var zr = class {
7565
7581
  lineStyles: o,
7566
7582
  changed: s
7567
7583
  };
7568
- }, di = ({ deletedLineDefaultsCleanup: e, globalLineDefaults: t, lineFontDefaults: n, lines: r, styles: i }) => {
7569
- let a = n, o = !1, s = !1, c = i, l = !1, u = !1, d, f = si({
7584
+ }, fi = ({ deletedLineDefaultsCleanup: e, globalLineDefaults: t, lineFontDefaults: n, lines: r, styles: i }) => {
7585
+ let a = n, o = !1, s = !1, c = i, l = !1, u = !1, d, f = ci({
7570
7586
  styles: c ?? {},
7571
7587
  lineCount: r.length,
7572
7588
  cleanup: e
@@ -7577,7 +7593,7 @@ var zr = class {
7577
7593
  if (i && (d = i), n.length !== 0) {
7578
7594
  let t = i;
7579
7595
  if (!t && d && (t = { ...d }, a || (a = {}, s = !0), s ||= (a = { ...a }, !0), a[e] = t, o = !0), t) {
7580
- let r = ui({
7596
+ let r = di({
7581
7597
  lineText: n,
7582
7598
  lineStyles: c ? c[e] : void 0,
7583
7599
  lineDefaults: t
@@ -7586,12 +7602,12 @@ var zr = class {
7586
7602
  }
7587
7603
  continue;
7588
7604
  }
7589
- let f = li({
7605
+ let f = ui({
7590
7606
  sourceDefaults: i ?? d,
7591
7607
  globalLineDefaults: t
7592
7608
  });
7593
7609
  !i && Object.keys(f).length && (a || (a = {}, s = !0), s ||= (a = { ...a }, !0), a[e] = f, o = !0, d = f), i && (d = i);
7594
- let p = ii({ lineDefaults: f }), m = Object.keys(p).length > 0;
7610
+ let p = ai({ lineDefaults: f }), m = Object.keys(p).length > 0;
7595
7611
  (m || c && c[e]) && (c || (c = {}, u = !0), u ||= (c = { ...c }, !0), m && (c[e] = { 0: p }), !m && c[e] && delete c[e], l = !0);
7596
7612
  }
7597
7613
  return {
@@ -7601,8 +7617,8 @@ var zr = class {
7601
7617
  stylesChanged: l
7602
7618
  };
7603
7619
  };
7604
- function fi({ textbox: e }) {
7605
- let t = (e.text ?? "").split("\n"), n = ci({ textbox: e }), r = di({
7620
+ function pi({ textbox: e }) {
7621
+ let t = (e.text ?? "").split("\n"), n = li({ textbox: e }), r = fi({
7606
7622
  lines: t,
7607
7623
  styles: e.styles,
7608
7624
  lineFontDefaults: e.lineFontDefaults,
@@ -7614,7 +7630,7 @@ function fi({ textbox: e }) {
7614
7630
  if (!Number.isInteger(t) || t < 0) continue;
7615
7631
  let o = r.styles[e];
7616
7632
  if (!o) continue;
7617
- let s = oi({
7633
+ let s = si({
7618
7634
  lineStyles: o,
7619
7635
  lineDefaults: i?.[t] ?? n
7620
7636
  });
@@ -7625,31 +7641,31 @@ function fi({ textbox: e }) {
7625
7641
  styles: a
7626
7642
  };
7627
7643
  }
7628
- var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7629
- let r = ri({
7644
+ var mi = ({ currentText: e, previousText: t, textbox: n }) => {
7645
+ let r = ii({
7630
7646
  lineFontDefaults: n.lineFontDefaults,
7631
7647
  previousText: t,
7632
7648
  currentText: e
7633
- }), i = di({
7649
+ }), i = fi({
7634
7650
  lines: e.split("\n"),
7635
7651
  styles: n.styles,
7636
7652
  lineFontDefaults: r.lineFontDefaults,
7637
7653
  deletedLineDefaultsCleanup: r.deletedLineDefaultsCleanup,
7638
- globalLineDefaults: ci({ textbox: n })
7654
+ globalLineDefaults: li({ textbox: n })
7639
7655
  });
7640
7656
  return {
7641
7657
  ...i,
7642
7658
  lineFontDefaultsChanged: r.changed || i.lineFontDefaultsChanged
7643
7659
  };
7644
- }, mi = ({ textbox: e }) => {
7645
- let t = di({
7660
+ }, hi = ({ textbox: e }) => {
7661
+ let t = fi({
7646
7662
  lines: (e.text ?? "").split("\n"),
7647
7663
  styles: e.styles,
7648
7664
  lineFontDefaults: e.lineFontDefaults,
7649
- globalLineDefaults: ci({ textbox: e })
7665
+ globalLineDefaults: li({ textbox: e })
7650
7666
  }), n = !1;
7651
7667
  return t.lineFontDefaultsChanged && (e.lineFontDefaults = t.lineFontDefaults, n = !0), t.stylesChanged && (e.styles = t.styles, e.dirty = !0, n = !0), n;
7652
- }, hi = ({ lineFontDefaults: e }) => {
7668
+ }, gi = ({ lineFontDefaults: e }) => {
7653
7669
  if (!e) return;
7654
7670
  let t = {};
7655
7671
  for (let n in e) {
@@ -7660,7 +7676,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7660
7676
  i && (t[r] = { ...i });
7661
7677
  }
7662
7678
  return t;
7663
- }, gi = ({ lineFontDefaults: e, scale: t }) => {
7679
+ }, _i = ({ lineFontDefaults: e, scale: t }) => {
7664
7680
  if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
7665
7681
  let n = {}, r = !1, i = !1;
7666
7682
  for (let a in e) {
@@ -7677,18 +7693,18 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7677
7693
  n[o] = c, r = !0;
7678
7694
  }
7679
7695
  if (!(!r || !i)) return n;
7680
- }, _i = ({ textbox: e, text: t }) => {
7696
+ }, vi = ({ textbox: e, text: t }) => {
7681
7697
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
7682
7698
  for (let t = 0; t < r; t += 1) {
7683
7699
  let n = e.getLineWidth(t);
7684
7700
  n > i && (i = n);
7685
7701
  }
7686
7702
  return i;
7687
- }, vi = ({ origin: e, size: t }) => e === "left" || e === "top" || e === 0 ? 0 : e === "right" || e === "bottom" || e === 1 ? t : t / 2, yi = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
7688
- 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 m(l + vi({
7703
+ }, yi = ({ origin: e, size: t }) => e === "left" || e === "top" || e === 0 ? 0 : e === "right" || e === "bottom" || e === 1 ? t : t / 2, bi = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
7704
+ 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 m(l + yi({
7689
7705
  origin: t,
7690
7706
  size: r
7691
- }), u + vi({
7707
+ }), u + yi({
7692
7708
  origin: n,
7693
7709
  size: i
7694
7710
  })), f = e.getPointByOrigin("center", "center"), p = e, h = typeof p.calcTransformMatrix == "function" ? p.calcTransformMatrix() : null, g = Array.isArray(h) ? new m(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new m(f.x + d.x, f.y + d.y);
@@ -7698,13 +7714,13 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7698
7714
  originX: t,
7699
7715
  originY: n
7700
7716
  };
7701
- }, bi = ({ textbox: e, montageLeft: t, montageRight: n }) => {
7717
+ }, xi = ({ textbox: e, montageLeft: t, montageRight: n }) => {
7702
7718
  e.setCoords();
7703
7719
  let r = e.getBoundingRect(), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
7704
7720
  if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
7705
7721
  let s = 0;
7706
7722
  return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
7707
- }, xi = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Si = ({ stylesList: e }) => {
7723
+ }, Si = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Ci = ({ stylesList: e }) => {
7708
7724
  let t = e.length;
7709
7725
  if (!t) return !1;
7710
7726
  for (let n = 0; n < t; n += 1) {
@@ -7714,16 +7730,16 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7714
7730
  if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
7715
7731
  }
7716
7732
  return !1;
7717
- }, Ci = ({ textbox: e }) => {
7718
- 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 = xi({
7733
+ }, wi = ({ textbox: e }) => {
7734
+ 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 = Si({
7719
7735
  rawValue: t,
7720
7736
  calculatedValue: a
7721
- }), c = xi({
7737
+ }), c = Si({
7722
7738
  rawValue: n,
7723
7739
  calculatedValue: o
7724
7740
  }), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
7725
7741
  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;
7726
- }, wi = ({ textbox: e }) => {
7742
+ }, Ti = ({ textbox: e }) => {
7727
7743
  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;
7728
7744
  return {
7729
7745
  width: t,
@@ -7741,9 +7757,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7741
7757
  bottomLeft: f
7742
7758
  },
7743
7759
  styles: JSON.parse(JSON.stringify(r)),
7744
- lineFontDefaults: hi({ lineFontDefaults: i })
7760
+ lineFontDefaults: gi({ lineFontDefaults: i })
7745
7761
  };
7746
- }, Ti = ({ base: e }) => {
7762
+ }, Ei = ({ base: e }) => {
7747
7763
  let t = 1 / Math.max(1, e.width), n = [e.fontSize];
7748
7764
  Object.values(e.styles).forEach((e) => {
7749
7765
  Object.values(e).forEach((e) => {
@@ -7760,7 +7776,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7760
7776
  fontScale: r,
7761
7777
  proportionalScale: Math.max(t, r)
7762
7778
  };
7763
- }, Ei = ({ textbox: e, base: t, scale: n, shouldScaleFontSize: r = !0, shouldScalePadding: i = !0, shouldScaleRadii: a = !0 }) => {
7779
+ }, Di = ({ textbox: e, base: t, scale: n, shouldScaleFontSize: r = !0, shouldScalePadding: i = !0, shouldScaleRadii: a = !0 }) => {
7764
7780
  let { fontSize: o, padding: s, radii: c, styles: l, lineFontDefaults: u } = t, d = Math.max(Math.min(8, o), o * n), f = Object.keys(l).length > 0, p;
7765
7781
  if (r && f) {
7766
7782
  let e = {};
@@ -7779,7 +7795,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7779
7795
  }), Object.keys(e).length && (p = e);
7780
7796
  }
7781
7797
  let m;
7782
- r && (m = gi({
7798
+ r && (m = _i({
7783
7799
  lineFontDefaults: u,
7784
7800
  scale: n
7785
7801
  }));
@@ -7805,9 +7821,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7805
7821
  radiusBottomRight: g.bottomRight,
7806
7822
  radiusBottomLeft: g.bottomLeft
7807
7823
  });
7808
- }, Di = ({ 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 }) => {
7809
- let { width: f } = n, p = Math.max(1, f * r), h = d ? Math.max(1, Math.round(p)) : p, g = e.width ?? f, _ = Math.abs(h - g) > Kr;
7810
- u && _ && (e.autoExpand = !1), Ei({
7824
+ }, Oi = ({ 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 }) => {
7825
+ let { width: f } = n, p = Math.max(1, f * r), h = d ? Math.max(1, Math.round(p)) : p, g = e.width ?? f, _ = Math.abs(h - g) > qr;
7826
+ u && _ && (e.autoExpand = !1), Di({
7811
7827
  textbox: e,
7812
7828
  base: n,
7813
7829
  scale: i,
@@ -7826,7 +7842,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7826
7842
  } finally {
7827
7843
  e.shouldRoundDimensionsOnInit = v;
7828
7844
  }
7829
- let y = d ? Ci({ textbox: e }) : !1;
7845
+ let y = d ? wi({ textbox: e }) : !1;
7830
7846
  return y && (e.dirty = !0), o ? (e.set({
7831
7847
  originX: a.originX,
7832
7848
  originY: a.originY
@@ -7840,7 +7856,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7840
7856
  appliedWidth: e.width ?? h,
7841
7857
  dimensionsRounded: y
7842
7858
  });
7843
- }, Oi = {
7859
+ }, ki = {
7844
7860
  angle: 0,
7845
7861
  skewX: 0,
7846
7862
  skewY: 0,
@@ -7853,7 +7869,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7853
7869
  top: 0,
7854
7870
  originX: "left",
7855
7871
  originY: "top"
7856
- }, ki = class {
7872
+ }, Ai = class {
7857
7873
  constructor({ runtime: e }) {
7858
7874
  this.runtime = e;
7859
7875
  }
@@ -8081,9 +8097,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8081
8097
  }
8082
8098
  _applyRehydratedTextScale({ group: e, text: t, textScale: n }) {
8083
8099
  let r = Number.isFinite(n) && n > 0 ? n : 1;
8084
- Math.abs(r - 1) <= 1e-4 || (Ei({
8100
+ Math.abs(r - 1) <= 1e-4 || (Di({
8085
8101
  textbox: t,
8086
- base: wi({ textbox: t }),
8102
+ base: Ti({ textbox: t }),
8087
8103
  scale: r
8088
8104
  }), e.shapePaddingTop = Math.max(0, (e.shapePaddingTop ?? 0) * r), e.shapePaddingRight = Math.max(0, (e.shapePaddingRight ?? 0) * r), e.shapePaddingBottom = Math.max(0, (e.shapePaddingBottom ?? 0) * r), e.shapePaddingLeft = Math.max(0, (e.shapePaddingLeft ?? 0) * r));
8089
8105
  }
@@ -8311,7 +8327,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8311
8327
  width: Math.max(1, e.width ?? t),
8312
8328
  align: n
8313
8329
  });
8314
- return s.set(Oi), this.runtime.applyTextUpdates({
8330
+ return s.set(ki), this.runtime.applyTextUpdates({
8315
8331
  textNode: s,
8316
8332
  text: r,
8317
8333
  textStyle: i,
@@ -8353,7 +8369,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8353
8369
  }
8354
8370
  _applyPreparedTextState({ preparedUpdate: e }) {
8355
8371
  let { currentGroup: t, currentTextNode: n, text: r, textStyle: i, horizontalAlign: a, syncLineStylesWithText: o } = e;
8356
- this.runtime.detachShapeGroupAutoLayout({ group: t }), n.set(Oi), this.runtime.applyTextUpdates({
8372
+ this.runtime.detachShapeGroupAutoLayout({ group: t }), n.set(ki), this.runtime.applyTextUpdates({
8357
8373
  textNode: n,
8358
8374
  text: r,
8359
8375
  textStyle: i,
@@ -8407,9 +8423,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8407
8423
  let { currentGroup: t, currentTextNode: n, placement: r, resolvedLayoutWidth: i, resolvedLayoutHeight: a, shouldFitReplacementToPreset: o } = e;
8408
8424
  o && (t.shapeManualBaseWidth = Math.max(1, t.shapeBaseWidth ?? i), t.shapeManualBaseHeight = Math.max(1, t.shapeBaseHeight ?? a)), n.isEditing && this.runtime.editingPlacements.set(t, r);
8409
8425
  }
8410
- }, Ai = "#B4B7BD", ji = 0, Mi = 1, Ni = class {
8426
+ }, ji = "#B4B7BD", Mi = 0, Ni = 1, Pi = class {
8411
8427
  constructor({ editor: e }) {
8412
- this.editor = e, Je(), this.scalingController = new Br({ canvas: e.canvas }), this.editingController = new Vr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new Gr({ canvas: e.canvas }), this.layoutController = new Wr({ editor: this.editor }), this.mutationController = new ki({ runtime: {
8428
+ this.editor = e, Je(), this.scalingController = new Vr({ canvas: e.canvas }), this.editingController = new Hr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new Kr({ canvas: e.canvas }), this.layoutController = new Gr({ editor: this.editor }), this.mutationController = new Ai({ runtime: {
8413
8429
  editor: this.editor,
8414
8430
  lifecycleController: this.lifecycleController,
8415
8431
  editingPlacements: this.editingPlacements,
@@ -8433,7 +8449,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8433
8449
  beginMutation: () => this._beginMutation(),
8434
8450
  endMutation: (e) => this._endMutation(e),
8435
8451
  isOnCanvas: (e) => this._isOnCanvas(e)
8436
- } }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this.eventController = new Ur({ runtime: {
8452
+ } }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this.eventController = new Wr({ runtime: {
8437
8453
  editor: this.editor,
8438
8454
  scalingController: this.scalingController,
8439
8455
  editingController: this.editingController,
@@ -8916,11 +8932,11 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8916
8932
  _resolveShapeStyle({ options: e, fallback: t }) {
8917
8933
  let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
8918
8934
  return {
8919
- fill: n ?? t?.shapeFill ?? Ai,
8935
+ fill: n ?? t?.shapeFill ?? ji,
8920
8936
  stroke: r ?? t?.shapeStroke ?? null,
8921
- strokeWidth: i ?? t?.shapeStrokeWidth ?? ji,
8937
+ strokeWidth: i ?? t?.shapeStrokeWidth ?? Mi,
8922
8938
  strokeDashArray: s ?? null,
8923
- opacity: o ?? t?.shapeOpacity ?? Mi
8939
+ opacity: o ?? t?.shapeOpacity ?? Ni
8924
8940
  };
8925
8941
  }
8926
8942
  _collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
@@ -8976,7 +8992,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8976
8992
  }
8977
8993
  return null;
8978
8994
  }
8979
- }, Pi = ({ rootObject: t, enableEvented: n = !0 }) => {
8995
+ }, Fi = ({ rootObject: t, enableEvented: n = !0 }) => {
8980
8996
  let r = [{
8981
8997
  object: t,
8982
8998
  enableEvented: n
@@ -8990,7 +9006,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8990
9006
  enableEvented: o
8991
9007
  });
8992
9008
  }
8993
- }, Fi = class {
9009
+ }, Ii = class {
8994
9010
  constructor({ editor: e }) {
8995
9011
  this.editor = e, this.clipboard = null;
8996
9012
  }
@@ -9148,7 +9164,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9148
9164
  if (!n || n.locked) return !1;
9149
9165
  try {
9150
9166
  let e = await n.clone(Pt);
9151
- return Pi({ rootObject: e }), e.set({
9167
+ return Fi({ rootObject: e }), e.set({
9152
9168
  left: e.left + 10,
9153
9169
  top: e.top + 10
9154
9170
  }), this._materializeCloneGeometry({ clonedObject: e }), this._addClonedObjectToCanvas(e), t.fire("editor:object-duplicated", {
@@ -9215,7 +9231,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9215
9231
  if (!this.clipboard) return !1;
9216
9232
  try {
9217
9233
  let t = await this.clipboard.clone(Pt);
9218
- return e.discardActiveObject(), Pi({ rootObject: t }), t.set({
9234
+ return e.discardActiveObject(), Fi({ rootObject: t }), t.set({
9219
9235
  left: t.left + 10,
9220
9236
  top: t.top + 10
9221
9237
  }), this._materializeCloneGeometry({ clonedObject: t }), this._addClonedObjectToCanvas(t), e.fire("editor:object-pasted", {
@@ -9234,7 +9250,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9234
9250
  }), !1;
9235
9251
  }
9236
9252
  }
9237
- }, Ii = class t {
9253
+ }, Li = class t {
9238
9254
  constructor({ editor: e }) {
9239
9255
  this.editor = e;
9240
9256
  }
@@ -9299,7 +9315,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9299
9315
  !(n instanceof v) || !n.isEditing || n.exitEditing();
9300
9316
  }
9301
9317
  }
9302
- }, Li = class {
9318
+ }, Ri = class {
9303
9319
  constructor({ editor: e }) {
9304
9320
  this.editor = e;
9305
9321
  }
@@ -9365,7 +9381,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9365
9381
  i.resumeHistory(), n || i.saveState();
9366
9382
  }
9367
9383
  }
9368
- }, Ri = class t {
9384
+ }, zi = class t {
9369
9385
  constructor({ editor: e }) {
9370
9386
  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();
9371
9387
  }
@@ -9559,7 +9575,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9559
9575
  let { options: e } = this.editor, { selectionKey: t } = e;
9560
9576
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
9561
9577
  }
9562
- }, zi = class e {
9578
+ }, Bi = class e {
9563
9579
  constructor({ editor: e }) {
9564
9580
  this.editor = e;
9565
9581
  }
@@ -9599,7 +9615,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9599
9615
  };
9600
9616
  return i.fire("editor:objects-deleted", l), l;
9601
9617
  }
9602
- }, Bi = {
9618
+ }, Vi = {
9603
9619
  IMAGE_MANAGER: {
9604
9620
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
9605
9621
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -9637,7 +9653,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9637
9653
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
9638
9654
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
9639
9655
  }
9640
- }, Vi = class e {
9656
+ }, Hi = class e {
9641
9657
  constructor({ editor: e }) {
9642
9658
  this._buffer = [], this.editor = e;
9643
9659
  }
@@ -9695,9 +9711,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9695
9711
  }), this.editor.canvas.fire("editor:warning", s);
9696
9712
  }
9697
9713
  static isValidErrorCode(e) {
9698
- return e ? Object.values(Bi).some((t) => Object.values(t).includes(e)) : !1;
9714
+ return e ? Object.values(Vi).some((t) => Object.values(t).includes(e)) : !1;
9699
9715
  }
9700
- }, Hi = class {
9716
+ }, Ui = class {
9701
9717
  constructor({ editor: e }) {
9702
9718
  this.currentBounds = null, this.editor = e;
9703
9719
  }
@@ -9746,32 +9762,32 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9746
9762
  updateBounds() {
9747
9763
  this.currentBounds = this.calculatePanBounds();
9748
9764
  }
9749
- }, Ui = ({ textbox: e }) => {
9765
+ }, Wi = ({ textbox: e }) => {
9750
9766
  if (!e.isEditing) return null;
9751
9767
  let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
9752
9768
  return t === n ? null : {
9753
9769
  start: Math.min(t, n),
9754
9770
  end: Math.max(t, n)
9755
9771
  };
9756
- }, Wi = ({ textbox: e }) => {
9772
+ }, Gi = ({ textbox: e }) => {
9757
9773
  let t = e.text?.length ?? 0;
9758
9774
  return t <= 0 ? null : {
9759
9775
  start: 0,
9760
9776
  end: t
9761
9777
  };
9762
- }, Gi = ({ textbox: e, range: t }) => {
9778
+ }, Ki = ({ textbox: e, range: t }) => {
9763
9779
  if (!t) return !1;
9764
9780
  let n = e.text?.length ?? 0;
9765
9781
  return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
9766
- }, Ki = ({ textbox: e, styles: t, range: n }) => {
9782
+ }, qi = ({ textbox: e, styles: t, range: n }) => {
9767
9783
  if (!t || !Object.keys(t).length) return !1;
9768
9784
  let { start: r, end: i } = n;
9769
9785
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
9770
- }, qi = ({ textbox: e, range: t, property: n }) => {
9786
+ }, Ji = ({ textbox: e, range: t, property: n }) => {
9771
9787
  if (!t) return;
9772
9788
  let r = e.getSelectionStyles(t.start, t.end, !0);
9773
9789
  if (r.length) return r[0]?.[n];
9774
- }, Ji = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Yi = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Xi = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Z = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Zi = class e extends v {
9790
+ }, Yi = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Xi = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Zi = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Qi = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), $i = class e extends v {
9775
9791
  static {
9776
9792
  this.type = "background-textbox";
9777
9793
  }
@@ -9808,7 +9824,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9808
9824
  ];
9809
9825
  }
9810
9826
  constructor(e, t = {}) {
9811
- if (super(e, t), this.backgroundOpacity = t.backgroundOpacity ?? 1, this.lineFontDefaults = t.lineFontDefaults ?? void 0, this.paddingTop = t.paddingTop ?? 0, this.paddingRight = t.paddingRight ?? 0, this.paddingBottom = t.paddingBottom ?? 0, this.paddingLeft = t.paddingLeft ?? 0, this.radiusTopLeft = t.radiusTopLeft ?? 0, this.radiusTopRight = t.radiusTopRight ?? 0, this.radiusBottomRight = t.radiusBottomRight ?? 0, this.radiusBottomLeft = t.radiusBottomLeft ?? 0, mi({ textbox: this })) {
9827
+ if (super(e, t), this.backgroundOpacity = t.backgroundOpacity ?? 1, this.lineFontDefaults = t.lineFontDefaults ?? void 0, this.paddingTop = t.paddingTop ?? 0, this.paddingRight = t.paddingRight ?? 0, this.paddingBottom = t.paddingBottom ?? 0, this.paddingLeft = t.paddingLeft ?? 0, this.radiusTopLeft = t.radiusTopLeft ?? 0, this.radiusTopRight = t.radiusTopRight ?? 0, this.radiusBottomRight = t.radiusBottomRight ?? 0, this.radiusBottomLeft = t.radiusBottomLeft ?? 0, hi({ textbox: this })) {
9812
9828
  this.initDimensions(), this.dirty = !0;
9813
9829
  return;
9814
9830
  }
@@ -9847,7 +9863,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9847
9863
  });
9848
9864
  }
9849
9865
  toObject(e = []) {
9850
- let t = super.toObject(e), { lineFontDefaults: n, styles: r } = fi({ textbox: this });
9866
+ let t = super.toObject(e), { lineFontDefaults: n, styles: r } = pi({ textbox: this });
9851
9867
  return {
9852
9868
  ...t,
9853
9869
  backgroundOpacity: this.backgroundOpacity,
@@ -9915,7 +9931,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9915
9931
  this._removeShadow(e);
9916
9932
  }
9917
9933
  _getDecorationColorAt(e, t) {
9918
- let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Yi({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Ji({
9934
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Xi({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Yi({
9919
9935
  strokeColor: i,
9920
9936
  width: r
9921
9937
  });
@@ -9931,22 +9947,22 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9931
9947
  _getCornerRadii({ width: e, height: t }) {
9932
9948
  let n = e / 2, r = t / 2, i = Math.min(n, r);
9933
9949
  return {
9934
- bottomLeft: Z({
9950
+ bottomLeft: Qi({
9935
9951
  value: this.radiusBottomLeft ?? 0,
9936
9952
  min: 0,
9937
9953
  max: i
9938
9954
  }),
9939
- bottomRight: Z({
9955
+ bottomRight: Qi({
9940
9956
  value: this.radiusBottomRight ?? 0,
9941
9957
  min: 0,
9942
9958
  max: i
9943
9959
  }),
9944
- topLeft: Z({
9960
+ topLeft: Qi({
9945
9961
  value: this.radiusTopLeft ?? 0,
9946
9962
  min: 0,
9947
9963
  max: i
9948
9964
  }),
9949
- topRight: Z({
9965
+ topRight: Qi({
9950
9966
  value: this.radiusTopRight ?? 0,
9951
9967
  min: 0,
9952
9968
  max: i
@@ -9964,7 +9980,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9964
9980
  _getEffectiveBackgroundFill() {
9965
9981
  let e = this.backgroundColor;
9966
9982
  if (!e) return null;
9967
- let t = Z({
9983
+ let t = Qi({
9968
9984
  value: this.backgroundOpacity ?? 1,
9969
9985
  min: 0,
9970
9986
  max: 1
@@ -9977,19 +9993,19 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9977
9993
  return r.setAlpha(t), r.toRgba();
9978
9994
  }
9979
9995
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
9980
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Z({
9996
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Qi({
9981
9997
  value: c,
9982
9998
  min: 0,
9983
9999
  max: a
9984
- }), p = Z({
10000
+ }), p = Qi({
9985
10001
  value: l,
9986
10002
  min: 0,
9987
10003
  max: a
9988
- }), m = Z({
10004
+ }), m = Qi({
9989
10005
  value: u,
9990
10006
  min: 0,
9991
10007
  max: a
9992
- }), h = Z({
10008
+ }), h = Qi({
9993
10009
  value: d,
9994
10010
  min: 0,
9995
10011
  max: a
@@ -10000,9 +10016,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10000
10016
  let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
10001
10017
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
10002
10018
  }
10003
- }, Qi = () => {
10004
- b?.setClass && b.setClass(Zi, "background-textbox");
10005
- }, $i = class {
10019
+ }, ea = () => {
10020
+ b?.setClass && b.setClass($i, "background-textbox");
10021
+ }, ta = class {
10006
10022
  constructor({ runtime: e }) {
10007
10023
  this.runtime = e;
10008
10024
  }
@@ -10066,16 +10082,16 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10066
10082
  };
10067
10083
  }
10068
10084
  _createSelectionContext({ textbox: e, currentText: t, selectionRangeOverride: n }) {
10069
- let r = n === void 0 ? Ui({ textbox: e }) : Jr({
10085
+ let r = n === void 0 ? Wi({ textbox: e }) : Yr({
10070
10086
  text: t,
10071
10087
  range: n
10072
- }), i = r ? Yr({
10088
+ }), i = r ? Xr({
10073
10089
  textbox: e,
10074
10090
  range: r
10075
- }) : null, a = Gi({
10091
+ }) : null, a = Ki({
10076
10092
  textbox: e,
10077
10093
  range: r
10078
- }), o = Gi({
10094
+ }), o = Ki({
10079
10095
  textbox: e,
10080
10096
  range: i
10081
10097
  }), s = !r || a;
@@ -10163,17 +10179,17 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10163
10179
  t.resolvedStrokeColor = i.stroke, t.resolvedStrokeWidth = i.strokeWidth, r.selectionRange && (t.selectionStyles.stroke = i.stroke, t.selectionStyles.strokeWidth = i.strokeWidth), r.shouldUpdateWholeObject && (t.updates.stroke = i.stroke, t.updates.strokeWidth = i.strokeWidth, r.shouldApplyWholeTextStyles && (t.wholeTextStyles.stroke = i.stroke, t.wholeTextStyles.strokeWidth = i.strokeWidth));
10164
10180
  }
10165
10181
  _resolveStrokeUpdate({ textbox: e, selectionRange: t, strokeColor: n, strokeWidth: r }) {
10166
- let i = t ? qi({
10182
+ let i = t ? Ji({
10167
10183
  textbox: e,
10168
10184
  range: t,
10169
10185
  property: "strokeWidth"
10170
- }) : void 0, a = t ? qi({
10186
+ }) : void 0, a = t ? Ji({
10171
10187
  textbox: e,
10172
10188
  range: t,
10173
10189
  property: "stroke"
10174
- }) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l = Yi({ width: r ?? o ?? e.strokeWidth ?? 0 });
10190
+ }) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l = Xi({ width: r ?? o ?? e.strokeWidth ?? 0 });
10175
10191
  return {
10176
- stroke: Ji({
10192
+ stroke: Yi({
10177
10193
  strokeColor: n ?? s ?? c,
10178
10194
  width: l
10179
10195
  }) ?? null,
@@ -10185,14 +10201,14 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10185
10201
  }
10186
10202
  _applyTextContentUpdate({ textbox: e, style: t, updates: n, currentText: r }) {
10187
10203
  let i = e.textCaseRaw ?? r, a = !!e.uppercase, o = t.text !== void 0, s = o ? t.text ?? "" : i, c = t.uppercase ?? a, l = c !== a, u = e.text ?? "";
10188
- return o || l ? (n.text = c ? Xi({ value: s }) : s, e.textCaseRaw = s) : e.textCaseRaw === void 0 && (e.textCaseRaw = i), e.uppercase = c, {
10204
+ return o || l ? (n.text = c ? Zi({ value: s }) : s, e.textCaseRaw = s) : e.textCaseRaw === void 0 && (e.textCaseRaw = i), e.uppercase = c, {
10189
10205
  hasTextUpdate: o,
10190
10206
  uppercaseChanged: l,
10191
10207
  previousRenderedText: u
10192
10208
  };
10193
10209
  }
10194
10210
  _resolveContentPlacement({ textbox: e, style: t, updates: n, placement: r, styleMaps: i, contentUpdate: a }) {
10195
- let o = Si({ stylesList: [
10211
+ let o = Ci({ stylesList: [
10196
10212
  n,
10197
10213
  i.selectionStyles,
10198
10214
  i.lineSelectionStyles,
@@ -10208,7 +10224,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10208
10224
  t.paddingBottom,
10209
10225
  t.paddingLeft
10210
10226
  ].some((e) => e !== void 0), l = Object.prototype.hasOwnProperty.call(n, "width");
10211
- return c && !s && !a.hasTextUpdate && !a.uppercaseChanged && !o && !l ? yi({
10227
+ return c && !s && !a.hasTextUpdate && !a.uppercaseChanged && !o && !l ? bi({
10212
10228
  textbox: e,
10213
10229
  originX: r.originX,
10214
10230
  originY: r.originY
@@ -10241,24 +10257,24 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10241
10257
  }
10242
10258
  _applyWholeTextStyles({ textbox: e, selection: t, styleMaps: n }) {
10243
10259
  if (t.selectionRange || Object.keys(n.wholeTextStyles).length === 0) return;
10244
- let r = Wi({ textbox: e });
10245
- r && Ki({
10260
+ let r = Gi({ textbox: e });
10261
+ r && qi({
10246
10262
  textbox: e,
10247
10263
  styles: n.wholeTextStyles,
10248
10264
  range: r
10249
- }) && (e.dirty = !0, Si({ stylesList: [n.wholeTextStyles] }) && (e.initDimensions(), e.dirty = !0));
10265
+ }) && (e.dirty = !0, Ci({ stylesList: [n.wholeTextStyles] }) && (e.initDimensions(), e.dirty = !0));
10250
10266
  }
10251
10267
  _applySelectionStyles({ textbox: e, selection: t, styleMaps: n }) {
10252
10268
  if (!t.selectionRange) return;
10253
- let r = Ki({
10269
+ let r = qi({
10254
10270
  textbox: e,
10255
10271
  styles: n.selectionStyles,
10256
10272
  range: t.selectionRange
10257
- }), i = t.fontSelectionRange ? Ki({
10273
+ }), i = t.fontSelectionRange ? qi({
10258
10274
  textbox: e,
10259
10275
  styles: n.lineSelectionStyles,
10260
10276
  range: t.fontSelectionRange
10261
- }) : !1, a = Si({ stylesList: [
10277
+ }) : !1, a = Ci({ stylesList: [
10262
10278
  n.selectionStyles,
10263
10279
  n.lineSelectionStyles,
10264
10280
  n.wholeTextStyles
@@ -10280,9 +10296,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10280
10296
  _applyFontLineDefaultUpdates({ textbox: e, style: t, selection: n }) {
10281
10297
  if (!n.fontSelectionRange || t.fontFamily === void 0 && t.fontSize === void 0) return;
10282
10298
  let r = {};
10283
- t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), ai({
10299
+ t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), oi({
10284
10300
  textbox: e,
10285
- lineIndices: Xr({
10301
+ lineIndices: Zr({
10286
10302
  textbox: e,
10287
10303
  range: n.fontSelectionRange
10288
10304
  }),
@@ -10292,9 +10308,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10292
10308
  _applyDecorationLineDefaultUpdates({ textbox: e, style: t, selection: n, styleMaps: r }) {
10293
10309
  if (!n.selectionRange || !(t.bold !== void 0 || t.italic !== void 0 || t.underline !== void 0 || t.strikethrough !== void 0 || t.color !== void 0 || t.strokeColor !== void 0 || t.strokeWidth !== void 0)) return;
10294
10310
  let i = {};
10295
- r.resolvedFontWeight !== void 0 && (i.fontWeight = r.resolvedFontWeight), r.resolvedFontStyle !== void 0 && (i.fontStyle = r.resolvedFontStyle), t.underline !== void 0 && (i.underline = t.underline), t.strikethrough !== void 0 && (i.linethrough = t.strikethrough), t.color !== void 0 && (i.fill = t.color), (t.strokeColor !== void 0 || t.strokeWidth !== void 0) && (r.resolvedStrokeColor === null && (i.stroke = null), r.resolvedStrokeColor !== null && r.resolvedStrokeColor !== void 0 && (i.stroke = r.resolvedStrokeColor), r.resolvedStrokeWidth !== void 0 && (i.strokeWidth = r.resolvedStrokeWidth)), ai({
10311
+ r.resolvedFontWeight !== void 0 && (i.fontWeight = r.resolvedFontWeight), r.resolvedFontStyle !== void 0 && (i.fontStyle = r.resolvedFontStyle), t.underline !== void 0 && (i.underline = t.underline), t.strikethrough !== void 0 && (i.linethrough = t.strikethrough), t.color !== void 0 && (i.fill = t.color), (t.strokeColor !== void 0 || t.strokeWidth !== void 0) && (r.resolvedStrokeColor === null && (i.stroke = null), r.resolvedStrokeColor !== null && r.resolvedStrokeColor !== void 0 && (i.stroke = r.resolvedStrokeColor), r.resolvedStrokeWidth !== void 0 && (i.strokeWidth = r.resolvedStrokeWidth)), oi({
10296
10312
  textbox: e,
10297
- lineIndices: Zr({
10313
+ lineIndices: Qr({
10298
10314
  textbox: e,
10299
10315
  range: n.selectionRange
10300
10316
  }),
@@ -10340,7 +10356,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10340
10356
  ].some((e) => e !== void 0);
10341
10357
  }
10342
10358
  _resolveShouldAutoExpand({ textbox: e, style: t, styleMaps: n, contentUpdate: r }) {
10343
- let i = t.autoExpand ?? e.autoExpand, a = Si({ stylesList: [
10359
+ let i = t.autoExpand ?? e.autoExpand, a = Ci({ stylesList: [
10344
10360
  n.updates,
10345
10361
  n.selectionStyles,
10346
10362
  n.lineSelectionStyles,
@@ -10385,18 +10401,18 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10385
10401
  };
10386
10402
  this.runtime.canvas.fire("editor:text-updated", m);
10387
10403
  }
10388
- }, ea = ({ transform: e }) => {
10404
+ }, na = ({ transform: e }) => {
10389
10405
  let { corner: t = "", action: n = "" } = e;
10390
10406
  return {
10391
10407
  isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
10392
10408
  isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
10393
10409
  isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
10394
10410
  };
10395
- }, ta = ({ textbox: e, transform: t, appliedWidth: n }) => {
10411
+ }, ra = ({ textbox: e, transform: t, appliedWidth: n }) => {
10396
10412
  t.scaleX = 1, t.scaleY = 1;
10397
10413
  let r = t.original;
10398
10414
  r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
10399
- }, na = ({ textbox: e, transform: t, scenePoint: n }) => {
10415
+ }, ia = ({ textbox: e, transform: t, scenePoint: n }) => {
10400
10416
  let { x: r, y: i } = e._getTransformedDimensions();
10401
10417
  if (r <= 0 || i <= 0) return null;
10402
10418
  let a = x.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);
@@ -10406,27 +10422,27 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10406
10422
  stepScaleX: l,
10407
10423
  stepScaleY: u
10408
10424
  };
10409
- }, ra = 1e-4;
10410
- function ia(e) {
10425
+ }, aa = 1e-4;
10426
+ function oa(e) {
10411
10427
  return !!e && e instanceof v;
10412
10428
  }
10413
- function aa(e) {
10414
- if (!ia(e)) return !1;
10429
+ function sa(e) {
10430
+ if (!oa(e)) return !1;
10415
10431
  let t = e.group;
10416
10432
  return e.shapeNodeType === "text" && t?.shapeComposite === !0;
10417
10433
  }
10418
- var oa = class {
10434
+ var ca = class {
10419
10435
  constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
10420
10436
  this.handleMouseMove = (e) => {
10421
10437
  let t = this.canvas._currentTransform;
10422
10438
  if (!t) return;
10423
10439
  let { target: n } = t;
10424
- if (!ia(n) || aa(n)) return;
10440
+ if (!oa(n) || sa(n)) return;
10425
10441
  let r = this.scalingState.get(n);
10426
10442
  if (!r || !e.e) return;
10427
- let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = ea({ transform: t });
10443
+ let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = na({ transform: t });
10428
10444
  if (!a && !o && !i) return;
10429
- let s = na({
10445
+ let s = ia({
10430
10446
  textbox: n,
10431
10447
  transform: t,
10432
10448
  scenePoint: this.canvas.getScenePoint(e.e)
@@ -10449,20 +10465,20 @@ var oa = class {
10449
10465
  }, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
10450
10466
  if (i) {
10451
10467
  let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
10452
- if (Math.abs(t - r.lastAllowedScaleX) <= ra) return;
10468
+ if (Math.abs(t - r.lastAllowedScaleX) <= aa) return;
10453
10469
  j = t, M = t;
10454
10470
  } else {
10455
10471
  if (a) {
10456
10472
  let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
10457
- Math.abs(t - r.lastAllowedScaleX) > ra && (j = t);
10473
+ Math.abs(t - r.lastAllowedScaleX) > aa && (j = t);
10458
10474
  }
10459
10475
  if (o) {
10460
10476
  let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
10461
- Math.abs(t - r.lastAllowedScaleY) > ra && (M = t);
10477
+ Math.abs(t - r.lastAllowedScaleY) > aa && (M = t);
10462
10478
  }
10463
- if (Math.abs(j - r.lastAllowedScaleX) <= ra && Math.abs(M - r.lastAllowedScaleY) <= ra) return;
10479
+ if (Math.abs(j - r.lastAllowedScaleX) <= aa && Math.abs(M - r.lastAllowedScaleY) <= aa) return;
10464
10480
  }
10465
- let { appliedWidth: N, dimensionsRounded: P } = Di({
10481
+ let { appliedWidth: N, dimensionsRounded: P } = Oi({
10466
10482
  textbox: n,
10467
10483
  canvasManager: this.canvasManager,
10468
10484
  base: r.startBase,
@@ -10476,7 +10492,7 @@ var oa = class {
10476
10492
  shouldDisableAutoExpandOnHorizontalChange: a,
10477
10493
  shouldRoundDimensions: !i
10478
10494
  });
10479
- ta({
10495
+ ra({
10480
10496
  textbox: n,
10481
10497
  transform: t,
10482
10498
  appliedWidth: N
@@ -10497,12 +10513,12 @@ var oa = class {
10497
10513
  }), this.canvas.requestRenderAll();
10498
10514
  }, this.handleObjectScaling = (t) => {
10499
10515
  let { target: n, transform: r } = t;
10500
- if (n instanceof e || !ia(n) || aa(n) || !r) return;
10516
+ if (n instanceof e || !oa(n) || sa(n) || !r) return;
10501
10517
  n.isScaling = !0;
10502
10518
  let i = this._ensureScalingState({
10503
10519
  textbox: n,
10504
10520
  transform: r
10505
- }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = ea({ transform: r }), d = r.corner ?? "", f = c || u;
10521
+ }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = na({ transform: r }), d = r.corner ?? "", f = c || u;
10506
10522
  if (!l && !u && !c) return;
10507
10523
  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({
10508
10524
  object: n,
@@ -10517,7 +10533,7 @@ var oa = class {
10517
10533
  N = e, P = e;
10518
10534
  }
10519
10535
  } else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
10520
- let { appliedWidth: ee, dimensionsRounded: te } = Di({
10536
+ let { appliedWidth: ee, dimensionsRounded: te } = Oi({
10521
10537
  textbox: n,
10522
10538
  canvasManager: this.canvasManager,
10523
10539
  base: a,
@@ -10531,7 +10547,7 @@ var oa = class {
10531
10547
  shouldDisableAutoExpandOnHorizontalChange: l,
10532
10548
  shouldRoundDimensions: !c
10533
10549
  });
10534
- ta({
10550
+ ra({
10535
10551
  textbox: n,
10536
10552
  transform: r,
10537
10553
  appliedWidth: ee
@@ -10564,7 +10580,7 @@ var oa = class {
10564
10580
  let { target: n } = t;
10565
10581
  if (n instanceof e) {
10566
10582
  let t = n.getObjects();
10567
- if (!t.some((e) => ia(e))) return;
10583
+ if (!t.some((e) => oa(e))) return;
10568
10584
  let { scaleX: r = 1, scaleY: i = 1 } = n;
10569
10585
  if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
10570
10586
  this.canvas.discardActiveObject(), t.forEach((e) => {
@@ -10574,7 +10590,7 @@ var oa = class {
10574
10590
  this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
10575
10591
  return;
10576
10592
  }
10577
- if (!ia(n) || aa(n)) return;
10593
+ if (!oa(n) || sa(n)) return;
10578
10594
  n.isScaling = !1;
10579
10595
  let r = this.scalingState.get(n);
10580
10596
  if (this.scalingState.delete(n), !r?.hasScalingChange) return;
@@ -10599,11 +10615,11 @@ var oa = class {
10599
10615
  }, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
10600
10616
  }
10601
10617
  commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
10602
- if (!ia(e) || aa(e)) return !1;
10618
+ if (!oa(e) || sa(e)) return !1;
10603
10619
  let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
10604
10620
  if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
10605
- let i = wi({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
10606
- return Di({
10621
+ let i = Ti({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
10622
+ return Oi({
10607
10623
  textbox: e,
10608
10624
  canvasManager: this.canvasManager,
10609
10625
  base: i,
@@ -10619,7 +10635,7 @@ var oa = class {
10619
10635
  _ensureScalingState({ textbox: e, transform: t }) {
10620
10636
  let n = this.scalingState.get(e);
10621
10637
  if (!n) {
10622
- let r = wi({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = Ti({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
10638
+ let r = Ti({ 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";
10623
10639
  n = {
10624
10640
  startBase: r,
10625
10641
  startObjectPlacement: i,
@@ -10652,7 +10668,7 @@ var oa = class {
10652
10668
  topRight: e.radiusTopRight ?? 0,
10653
10669
  bottomRight: e.radiusBottomRight ?? 0,
10654
10670
  bottomLeft: e.radiusBottomLeft ?? 0
10655
- }, 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;
10671
+ }, v = Math.abs(n - o) > qr, y = Math.abs(h - r) > qr, 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;
10656
10672
  if (c) {
10657
10673
  let e = h / Math.max(1, m);
10658
10674
  S = e, C = e;
@@ -10673,7 +10689,7 @@ var oa = class {
10673
10689
  originY: a
10674
10690
  });
10675
10691
  }
10676
- }, sa = class e {
10692
+ }, la = class e {
10677
10693
  constructor({ editor: t }) {
10678
10694
  this._handleTextEditingEntered = (t) => {
10679
10695
  this.isTextEditingActive = !0;
@@ -10686,7 +10702,7 @@ var oa = class {
10686
10702
  if (!e._isTextbox(n)) return;
10687
10703
  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 });
10688
10704
  if (s) {
10689
- let e = Xi({ value: l });
10705
+ let e = Zi({ value: l });
10690
10706
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
10691
10707
  } else n.textCaseRaw = i;
10692
10708
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
@@ -10704,7 +10720,7 @@ var oa = class {
10704
10720
  let r = e._isShapeOwnedTextbox(n);
10705
10721
  this.editingPlacementState?.delete(n), delete n.__lineDefaultsPrevText;
10706
10722
  let i = n.text ?? "";
10707
- n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Ci({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
10723
+ n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (wi({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
10708
10724
  lockMovementX: !1,
10709
10725
  lockMovementY: !1
10710
10726
  }));
@@ -10731,7 +10747,7 @@ var oa = class {
10731
10747
  transform: r,
10732
10748
  event: i ?? null
10733
10749
  });
10734
- }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new oa({
10750
+ }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ca({
10735
10751
  canvas: t.canvas,
10736
10752
  canvasManager: t.canvasManager,
10737
10753
  persistScaledTextbox: ({ target: e, style: t }) => {
@@ -10740,7 +10756,7 @@ var oa = class {
10740
10756
  style: t
10741
10757
  });
10742
10758
  }
10743
- }), this.updateController = new $i({ runtime: {
10759
+ }), this.updateController = new ta({ runtime: {
10744
10760
  canvas: this.canvas,
10745
10761
  canvasManager: t.canvasManager,
10746
10762
  historyManager: t.historyManager,
@@ -10749,12 +10765,12 @@ var oa = class {
10749
10765
  restoreTextboxContentPlacement: (e) => this._restoreTextboxContentPlacement(e),
10750
10766
  syncLineStylesWithText: (e) => this._syncLineStylesWithText(e),
10751
10767
  getSnapshot: (t) => e._getSnapshot(t)
10752
- } }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), Qi();
10768
+ } }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), ea();
10753
10769
  }
10754
10770
  addText({ id: t = `background-textbox-${O()}`, 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: D = !1, withoutSave: k = !1, withoutAdding: A = !1, emitLifecycleEvents: j = !0 } = {}) {
10755
10771
  let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
10756
10772
  N.suspendHistory();
10757
- let F = i ?? this._getDefaultFontFamily(), I = Yi({ width: m }), ee = Ji({
10773
+ let F = i ?? this._getDefaultFontFamily(), I = Xi({ width: m }), ee = Yi({
10758
10774
  strokeColor: p,
10759
10775
  width: I
10760
10776
  }), te = {
@@ -10783,14 +10799,14 @@ var oa = class {
10783
10799
  radiusBottomRight: w,
10784
10800
  radiusBottomLeft: T,
10785
10801
  ...E
10786
- }, L = new Zi(n, te), ne = r !== !1;
10802
+ }, L = new $i(n, te), ne = r !== !1;
10787
10803
  L.autoExpand = ne;
10788
10804
  let re = E.left !== void 0 || E.top !== void 0;
10789
10805
  if (L.textCaseRaw = L.text ?? "", l) {
10790
- let e = Xi({ value: L.textCaseRaw });
10806
+ let e = Zi({ value: L.textCaseRaw });
10791
10807
  e !== L.text && L.set({ text: e });
10792
10808
  }
10793
- Ci({ textbox: L }) && (L.dirty = !0);
10809
+ wi({ textbox: L }) && (L.dirty = !0);
10794
10810
  let ie;
10795
10811
  re && (ie = M.resolveObjectPlacement({
10796
10812
  object: L,
@@ -10895,7 +10911,7 @@ var oa = class {
10895
10911
  clampToMontage: r
10896
10912
  }));
10897
10913
  let a = !1;
10898
- i || (a = Ci({ textbox: e }));
10914
+ i || (a = wi({ textbox: e }));
10899
10915
  let o = !1;
10900
10916
  return !i && t && (this.editor.canvasManager.applyObjectPlacement({
10901
10917
  object: e,
@@ -10903,7 +10919,7 @@ var oa = class {
10903
10919
  }), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
10904
10920
  }
10905
10921
  _restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
10906
- let n = yi({
10922
+ let n = bi({
10907
10923
  textbox: e,
10908
10924
  originX: t.originX,
10909
10925
  originY: t.originY
@@ -10921,7 +10937,7 @@ var oa = class {
10921
10937
  e.on("object:scaling", this.scalingController.handleObjectScaling), e.on("object:resizing", this._handleObjectResizing), e.on("object:modified", this.scalingController.handleObjectModified), e.on("mouse:move", this.scalingController.handleMouseMove), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged);
10922
10938
  }
10923
10939
  _syncLineStylesWithText({ textbox: e, previousText: t, currentText: n }) {
10924
- let r = n ?? e.text ?? "", i = pi({
10940
+ let r = n ?? e.text ?? "", i = mi({
10925
10941
  textbox: e,
10926
10942
  previousText: t ?? e.__lineDefaultsPrevText ?? r,
10927
10943
  currentText: r
@@ -10939,16 +10955,16 @@ var oa = class {
10939
10955
  if (!Number.isFinite(f) || f <= 0) return !1;
10940
10956
  let p = a.split("\n").length, m = !1;
10941
10957
  Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
10942
- let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(_i({
10958
+ let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(vi({
10943
10959
  textbox: e,
10944
10960
  text: a
10945
10961
  })), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
10946
- g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Ci({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
10962
+ g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), wi({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
10947
10963
  object: e,
10948
10964
  placement: t
10949
10965
  });
10950
10966
  let b = !1;
10951
- return n && (b = bi({
10967
+ return n && (b = xi({
10952
10968
  textbox: e,
10953
10969
  montageLeft: o,
10954
10970
  montageRight: o + s
@@ -11006,7 +11022,7 @@ var oa = class {
11006
11022
  _getDefaultFontFamily() {
11007
11023
  return this.fonts[0]?.family ?? "Arial";
11008
11024
  }
11009
- }, ca = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, la = (e) => {
11025
+ }, ua = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, da = (e) => {
11010
11026
  if (!e || typeof e != "object") return null;
11011
11027
  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) => ({
11012
11028
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -11017,7 +11033,7 @@ var oa = class {
11017
11033
  let { x1: e, y1: t, x2: r, y2: i } = n;
11018
11034
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
11019
11035
  type: "linear",
11020
- angle: ca({
11036
+ angle: ua({
11021
11037
  x1: e,
11022
11038
  y1: t,
11023
11039
  x2: r,
@@ -11045,7 +11061,7 @@ var oa = class {
11045
11061
  };
11046
11062
  }
11047
11063
  return null;
11048
- }, ua = "_templateAnchorX", da = "_templateAnchorY", fa = class t {
11064
+ }, fa = "_templateAnchorX", pa = "_templateAnchorY", ma = class t {
11049
11065
  constructor({ editor: e }) {
11050
11066
  this.editor = e;
11051
11067
  }
@@ -11054,7 +11070,7 @@ var oa = class {
11054
11070
  if (!p.length) return s.emitWarning({
11055
11071
  origin: "TemplateManager",
11056
11072
  method: "serializeSelection",
11057
- code: Bi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
11073
+ code: Vi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
11058
11074
  message: "Нет объектов для сериализации шаблона"
11059
11075
  }), null;
11060
11076
  let m = t._getBounds(o), h = t._getMontageSize({
@@ -11083,14 +11099,14 @@ var oa = class {
11083
11099
  if (!l?.length) return a.emitWarning({
11084
11100
  origin: "TemplateManager",
11085
11101
  method: "applyTemplate",
11086
- code: Bi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11102
+ code: Vi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11087
11103
  message: "Шаблон не содержит объектов"
11088
11104
  }), null;
11089
11105
  let f = t._getBounds(r);
11090
11106
  if (!f) return a.emitWarning({
11091
11107
  origin: "TemplateManager",
11092
11108
  method: "applyTemplate",
11093
- code: Bi.TEMPLATE_MANAGER.INVALID_TARGET,
11109
+ code: Vi.TEMPLATE_MANAGER.INVALID_TARGET,
11094
11110
  message: "Не удалось определить границы монтажной области"
11095
11111
  }), null;
11096
11112
  let p = t._getMontageSize({
@@ -11109,7 +11125,7 @@ var oa = class {
11109
11125
  if (!r.length) return a.emitWarning({
11110
11126
  origin: "TemplateManager",
11111
11127
  method: "applyTemplate",
11112
- code: Bi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11128
+ code: Vi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11113
11129
  message: "Не удалось создать объекты шаблона"
11114
11130
  }), null;
11115
11131
  let { backgroundObject: i, contentObjects: u } = t._extractBackgroundObject(r);
@@ -11131,7 +11147,7 @@ var oa = class {
11131
11147
  }), c.commitStandaloneTextScale({ target: e }), s.commitRehydratedShapeLayout({
11132
11148
  target: e,
11133
11149
  textScale: h
11134
- }), Gt({ object: e }), Pi({ rootObject: e }), n.add(e), e));
11150
+ }), Gt({ object: e }), Fi({ rootObject: e }), n.add(e), e));
11135
11151
  return !d.length && !v ? null : (_ = d.length > 0 || v, d.length && t._activateObjects({
11136
11152
  canvas: n,
11137
11153
  objects: d
@@ -11144,7 +11160,7 @@ var oa = class {
11144
11160
  return a.emitError({
11145
11161
  origin: "TemplateManager",
11146
11162
  method: "applyTemplate",
11147
- code: Bi.TEMPLATE_MANAGER.APPLY_FAILED,
11163
+ code: Vi.TEMPLATE_MANAGER.APPLY_FAILED,
11148
11164
  message: "Ошибка применения шаблона",
11149
11165
  data: {
11150
11166
  templateId: d,
@@ -11301,8 +11317,8 @@ var oa = class {
11301
11317
  baseHeight: a,
11302
11318
  scale: n,
11303
11319
  useRelativePositions: o,
11304
- anchorX: t._resolveAnchor(s, ua),
11305
- anchorY: t._resolveAnchor(s, da)
11320
+ anchorX: t._resolveAnchor(s, fa),
11321
+ anchorY: t._resolveAnchor(s, pa)
11306
11322
  })
11307
11323
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
11308
11324
  e.set({
@@ -11377,7 +11393,7 @@ var oa = class {
11377
11393
  });
11378
11394
  if (!i || !a) return;
11379
11395
  e.setCoords();
11380
- let o = e, s = t._resolveAnchor(o, ua), c = typeof e.left == "number" ? e.left : null, l = e.originX ?? "center", u = e.originY ?? "center", d = e.getPointByOrigin(l, u), f = t._getBoundingRect(e), p = f.left + f.width / 2, m = f.left + f.width;
11396
+ let o = e, s = t._resolveAnchor(o, fa), c = typeof e.left == "number" ? e.left : null, l = e.originX ?? "center", u = e.originY ?? "center", d = e.getPointByOrigin(l, u), f = t._getBoundingRect(e), p = f.left + f.width / 2, m = f.left + f.width;
11381
11397
  e.set("width", i), e.initDimensions();
11382
11398
  let h = t._getLongestLineWidth({
11383
11399
  textbox: e,
@@ -11406,10 +11422,10 @@ var oa = class {
11406
11422
  x: (p.left - o) / d,
11407
11423
  y: (p.top - s) / f
11408
11424
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
11409
- return a[ua] = t._detectAnchor({
11425
+ return a[fa] = t._detectAnchor({
11410
11426
  start: h,
11411
11427
  end: _
11412
- }), a[da] = t._detectAnchor({
11428
+ }), a[pa] = t._detectAnchor({
11413
11429
  start: g,
11414
11430
  end: v
11415
11431
  }), a.left = m.x, a.top = m.y, a;
@@ -11434,7 +11450,7 @@ var oa = class {
11434
11450
  withoutSave: !0
11435
11451
  }), !0;
11436
11452
  if (a === "gradient") {
11437
- let e = la(r);
11453
+ let e = da(r);
11438
11454
  if (e) return n.setGradientBackground({
11439
11455
  gradient: e,
11440
11456
  customData: o,
@@ -11455,7 +11471,7 @@ var oa = class {
11455
11471
  r.emitWarning({
11456
11472
  origin: "TemplateManager",
11457
11473
  method: "applyTemplate",
11458
- code: Bi.TEMPLATE_MANAGER.APPLY_FAILED,
11474
+ code: Vi.TEMPLATE_MANAGER.APPLY_FAILED,
11459
11475
  message: "Не удалось применить фон из шаблона",
11460
11476
  data: e
11461
11477
  });
@@ -11491,29 +11507,29 @@ var oa = class {
11491
11507
  enlivenObjectEnlivables(e) {
11492
11508
  return w.enlivenObjectEnlivables(e);
11493
11509
  }
11494
- }, pa = "#3D8BF4", ma = .5, ha = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, ga = ({ firstDistance: e, secondDistance: t }) => {
11495
- let n = ha({ distance: e }), r = ha({ distance: t });
11510
+ }, ha = "#3D8BF4", ga = .5, _a = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, va = ({ firstDistance: e, secondDistance: t }) => {
11511
+ let n = _a({ distance: e }), r = _a({ distance: t });
11496
11512
  return {
11497
11513
  firstDisplayDistance: n,
11498
11514
  secondDisplayDistance: r,
11499
11515
  displayDistanceDiff: Math.abs(n - r),
11500
11516
  commonDisplayDistance: Math.max(n, r)
11501
11517
  };
11502
- }, _a = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), va = ({ step: e }) => {
11518
+ }, ya = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), ba = ({ step: e }) => {
11503
11519
  let t = Math.abs(e).toString(), n = t.indexOf(".");
11504
11520
  return n === -1 ? 0 : t.slice(n + 1).length;
11505
- }, ya = ({ value: e, step: t }) => {
11521
+ }, xa = ({ value: e, step: t }) => {
11506
11522
  if (t === 0) return e;
11507
- let n = va({ step: t }), r = Math.round(e / t) * t;
11523
+ let n = ba({ step: t }), r = Math.round(e / t) * t;
11508
11524
  return Number(r.toFixed(n));
11509
- }, ba = ({ value: e, step: t }) => {
11525
+ }, Sa = ({ value: e, step: t }) => {
11510
11526
  if (t === 0) return !0;
11511
- let n = ya({
11527
+ let n = xa({
11512
11528
  value: e,
11513
11529
  step: t
11514
- }), r = 10 ** -(va({ step: t }) + 4);
11530
+ }), r = 10 ** -(ba({ step: t }) + 4);
11515
11531
  return Math.abs(n - e) <= r;
11516
- }, xa = ({ bounds: e, axis: t }) => {
11532
+ }, Ca = ({ bounds: e, axis: t }) => {
11517
11533
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
11518
11534
  return t === "vertical" ? {
11519
11535
  start: i,
@@ -11522,7 +11538,7 @@ var oa = class {
11522
11538
  start: n,
11523
11539
  end: r
11524
11540
  };
11525
- }, Sa = ({ items: e, axis: t }) => {
11541
+ }, wa = ({ items: e, axis: t }) => {
11526
11542
  for (let n = 1; n < e.length; n += 1) {
11527
11543
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
11528
11544
  for (; o >= 0;) {
@@ -11532,10 +11548,10 @@ var oa = class {
11532
11548
  }
11533
11549
  e[o + 1] = r;
11534
11550
  }
11535
- }, Ca = ({ items: e, index: t, axis: n, direction: r }) => {
11551
+ }, Ta = ({ items: e, index: t, axis: n, direction: r }) => {
11536
11552
  let i = e[t];
11537
11553
  if (!i) return null;
11538
- let { bounds: a } = i, { start: o, end: s } = xa({
11554
+ let { bounds: a } = i, { start: o, end: s } = Ca({
11539
11555
  bounds: a,
11540
11556
  axis: n
11541
11557
  });
@@ -11543,7 +11559,7 @@ var oa = class {
11543
11559
  for (let r = t - 1; r >= 0; --r) {
11544
11560
  let t = e[r];
11545
11561
  if (!t) continue;
11546
- let { bounds: i } = t, { end: a } = xa({
11562
+ let { bounds: i } = t, { end: a } = Ca({
11547
11563
  bounds: i,
11548
11564
  axis: n
11549
11565
  });
@@ -11554,26 +11570,26 @@ var oa = class {
11554
11570
  for (let r = t + 1; r < e.length; r += 1) {
11555
11571
  let t = e[r];
11556
11572
  if (!t) continue;
11557
- let { bounds: i } = t, { start: a } = xa({
11573
+ let { bounds: i } = t, { start: a } = Ca({
11558
11574
  bounds: i,
11559
11575
  axis: n
11560
11576
  });
11561
11577
  if (a - s >= 0) return r;
11562
11578
  }
11563
11579
  return null;
11564
- }, wa = ({ items: e }) => {
11580
+ }, Ea = ({ items: e }) => {
11565
11581
  for (let t = 0; t < e.length; t += 1) {
11566
11582
  let { isActive: n } = e[t];
11567
11583
  if (n) return t;
11568
11584
  }
11569
11585
  return -1;
11570
- }, Ta = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
11586
+ }, Da = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
11571
11587
  let i = Math.min(t, n), a = Math.max(t, n);
11572
11588
  return e >= i - r && e <= a + r;
11573
- }, Ea = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Da = ({ baseOption: e, candidateOption: t }) => {
11589
+ }, Oa = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, ka = ({ baseOption: e, candidateOption: t }) => {
11574
11590
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
11575
11591
  return n === i && r === a;
11576
- }, Oa = ({ options: e }) => {
11592
+ }, Aa = ({ options: e }) => {
11577
11593
  let t = e[0];
11578
11594
  for (let n = 1; n < e.length; n += 1) {
11579
11595
  let r = e[n];
@@ -11584,11 +11600,11 @@ var oa = class {
11584
11600
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
11585
11601
  }
11586
11602
  return t;
11587
- }, ka = ({ currentOption: e, nextOption: t }) => {
11603
+ }, ja = ({ currentOption: e, nextOption: t }) => {
11588
11604
  if (!e) return !0;
11589
11605
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
11590
11606
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
11591
- }, Aa = ({ options: e }) => {
11607
+ }, Ma = ({ options: e }) => {
11592
11608
  let t = [], n = null, r = null;
11593
11609
  for (let i of e) {
11594
11610
  let { kind: e, side: a } = i;
@@ -11596,18 +11612,18 @@ var oa = class {
11596
11612
  t.push(i);
11597
11613
  continue;
11598
11614
  }
11599
- a === "before" && ka({
11615
+ a === "before" && ja({
11600
11616
  currentOption: n,
11601
11617
  nextOption: i
11602
- }) && (n = i), a === "after" && ka({
11618
+ }) && (n = i), a === "after" && ja({
11603
11619
  currentOption: r,
11604
11620
  nextOption: i
11605
11621
  }) && (r = i);
11606
11622
  }
11607
11623
  return n && t.push(n), r && t.push(r), t;
11608
- }, ja = ({ options: e, side: t, baseOption: n }) => {
11624
+ }, Na = ({ options: e, side: t, baseOption: n }) => {
11609
11625
  let r = null;
11610
- for (let i of e) if (i.side === t && Da({
11626
+ for (let i of e) if (i.side === t && ka({
11611
11627
  baseOption: n,
11612
11628
  candidateOption: i
11613
11629
  })) {
@@ -11618,63 +11634,63 @@ var oa = class {
11618
11634
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
11619
11635
  }
11620
11636
  return r;
11621
- }, Ma = ({ option: e }) => {
11637
+ }, Pa = ({ option: e }) => {
11622
11638
  let { side: t, kind: n, guide: { distance: r } } = e;
11623
11639
  return {
11624
11640
  side: t,
11625
11641
  kind: n,
11626
11642
  distance: r
11627
11643
  };
11628
- }, Na = ({ option: e, context: t }) => {
11644
+ }, Fa = ({ option: e, context: t }) => {
11629
11645
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
11630
11646
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
11631
- }, Pa = ({ options: e, context: t }) => {
11647
+ }, Ia = ({ options: e, context: t }) => {
11632
11648
  if (!t) return null;
11633
- for (let n of e) if (Na({
11649
+ for (let n of e) if (Fa({
11634
11650
  option: n,
11635
11651
  context: t
11636
11652
  })) return n;
11637
11653
  return null;
11638
- }, Fa = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
11639
- let i = Pa({
11654
+ }, La = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
11655
+ let i = Ia({
11640
11656
  options: e,
11641
11657
  context: n
11642
11658
  });
11643
11659
  if (!i) return t;
11644
11660
  let a = Math.max(0, r);
11645
11661
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
11646
- }, Ia = ({ guides: e, seenGuideKeys: t, guide: n }) => {
11662
+ }, Ra = ({ guides: e, seenGuideKeys: t, guide: n }) => {
11647
11663
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
11648
11664
  t.has(u) || (t.add(u), e.push(n));
11649
- }, La = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
11665
+ }, za = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
11650
11666
  if (!e.length) return {
11651
11667
  delta: 0,
11652
11668
  guides: [],
11653
11669
  context: null
11654
11670
  };
11655
- let r = Aa({ options: e }), i = [];
11671
+ let r = Ma({ options: e }), i = [];
11656
11672
  for (let e of r) e.kind === "reference" && i.push(e);
11657
- let a = i.length > 0, o = a ? i : r, s = Fa({
11673
+ let a = i.length > 0, o = a ? i : r, s = La({
11658
11674
  options: o,
11659
- bestOption: Oa({ options: o }),
11675
+ bestOption: Aa({ options: o }),
11660
11676
  previousContext: t,
11661
11677
  switchDistance: n
11662
- }), c = ja({
11678
+ }), c = Na({
11663
11679
  options: o,
11664
11680
  side: "before",
11665
11681
  baseOption: s
11666
- }), l = ja({
11682
+ }), l = Na({
11667
11683
  options: o,
11668
11684
  side: "after",
11669
11685
  baseOption: s
11670
- }), u = ja({
11686
+ }), u = Na({
11671
11687
  options: a ? r : o,
11672
11688
  side: "center",
11673
11689
  baseOption: s
11674
11690
  }), d = [];
11675
11691
  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);
11676
11692
  let f = [], p = /* @__PURE__ */ new Set();
11677
- for (let e of d) Ia({
11693
+ for (let e of d) Ra({
11678
11694
  guides: f,
11679
11695
  seenGuideKeys: p,
11680
11696
  guide: e.guide
@@ -11682,15 +11698,15 @@ var oa = class {
11682
11698
  return {
11683
11699
  delta: s.delta,
11684
11700
  guides: f,
11685
- context: Ma({ option: s })
11701
+ context: Pa({ option: s })
11686
11702
  };
11687
- }, Ra = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
11688
- let s = n - (e - r), c = ya({
11703
+ }, Ba = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
11704
+ let s = n - (e - r), c = xa({
11689
11705
  value: s,
11690
11706
  step: o
11691
11707
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
11692
11708
  for (let d = -l; d <= l; d += 1) {
11693
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = ga({
11709
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = va({
11694
11710
  firstDistance: m,
11695
11711
  secondDistance: h
11696
11712
  });
@@ -11705,13 +11721,13 @@ var oa = class {
11705
11721
  });
11706
11722
  }
11707
11723
  return u;
11708
- }, za = ({ currentGap: e, referenceGap: t }) => {
11709
- let { secondDisplayDistance: n, displayDistanceDiff: r } = ga({
11724
+ }, Va = ({ currentGap: e, referenceGap: t }) => {
11725
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = va({
11710
11726
  firstDistance: e,
11711
11727
  secondDistance: t
11712
11728
  });
11713
11729
  return r > 1 ? null : n;
11714
- }, Ba = ({ anchors: e, positions: t, threshold: n }) => {
11730
+ }, Ha = ({ anchors: e, positions: t, threshold: n }) => {
11715
11731
  let r = 0, i = n + 1, a = null;
11716
11732
  for (let o of t) for (let t of e) {
11717
11733
  let e = Math.abs(t - o);
@@ -11721,8 +11737,8 @@ var oa = class {
11721
11737
  delta: r,
11722
11738
  guidePosition: a
11723
11739
  };
11724
- }, Va = ({ activeBounds: e, threshold: t, anchors: n }) => {
11725
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ba({
11740
+ }, Ua = ({ activeBounds: e, threshold: t, anchors: n }) => {
11741
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ha({
11726
11742
  anchors: n.vertical,
11727
11743
  positions: [
11728
11744
  r,
@@ -11730,7 +11746,7 @@ var oa = class {
11730
11746
  i
11731
11747
  ],
11732
11748
  threshold: t
11733
- }), u = Ba({
11749
+ }), u = Ha({
11734
11750
  anchors: n.horizontal,
11735
11751
  positions: [
11736
11752
  o,
@@ -11750,11 +11766,11 @@ var oa = class {
11750
11766
  deltaY: u.delta,
11751
11767
  guides: d
11752
11768
  };
11753
- }, Ha = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11769
+ }, Wa = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11754
11770
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
11755
11771
  for (let e of t) {
11756
11772
  let { left: t, right: n } = e;
11757
- _a({
11773
+ ya({
11758
11774
  firstStart: t,
11759
11775
  firstEnd: n,
11760
11776
  secondStart: l,
@@ -11774,22 +11790,22 @@ var oa = class {
11774
11790
  f.push({
11775
11791
  bounds: e,
11776
11792
  isActive: !0
11777
- }), Sa({
11793
+ }), wa({
11778
11794
  items: f,
11779
11795
  axis: "top"
11780
11796
  });
11781
- let p = wa({ items: f });
11797
+ let p = Ea({ items: f });
11782
11798
  if (p === -1) return {
11783
11799
  delta: 0,
11784
11800
  guides: [],
11785
11801
  context: null
11786
11802
  };
11787
- let m = [], h = c - s, g = Ca({
11803
+ let m = [], h = c - s, g = Ta({
11788
11804
  items: f,
11789
11805
  index: p,
11790
11806
  axis: "vertical",
11791
11807
  direction: "prev"
11792
- }), _ = Ca({
11808
+ }), _ = Ta({
11793
11809
  items: f,
11794
11810
  index: p,
11795
11811
  axis: "vertical",
@@ -11798,19 +11814,19 @@ var oa = class {
11798
11814
  if (v && y) {
11799
11815
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
11800
11816
  if (a >= 0) {
11801
- let e = ya({
11817
+ let e = xa({
11802
11818
  value: a / 2,
11803
11819
  step: 1
11804
11820
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
11805
11821
  if (Math.max(u, d) <= n) {
11806
- let t = Ra({
11822
+ let t = Ba({
11807
11823
  activeStart: s,
11808
11824
  activeEnd: c,
11809
11825
  targetGap: e,
11810
11826
  beforeEdge: r,
11811
11827
  afterEdge: i,
11812
11828
  threshold: n,
11813
- step: ma
11829
+ step: ga
11814
11830
  });
11815
11831
  if (t) {
11816
11832
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -11847,16 +11863,16 @@ var oa = class {
11847
11863
  }
11848
11864
  for (let e of r) {
11849
11865
  let { axis: t, start: r, end: i, distance: a } = e;
11850
- if (!ba({
11866
+ if (!Sa({
11851
11867
  value: a,
11852
11868
  step: .5
11853
- }) || !Ta({
11869
+ }) || !Da({
11854
11870
  patternAxis: t,
11855
11871
  activeRangeStart: l,
11856
11872
  activeRangeEnd: u,
11857
11873
  tolerance: n
11858
11874
  })) continue;
11859
- let d = Ea({
11875
+ let d = Oa({
11860
11876
  patternStart: r,
11861
11877
  patternEnd: i,
11862
11878
  activeStart: s,
@@ -11864,12 +11880,12 @@ var oa = class {
11864
11880
  });
11865
11881
  if (d) {
11866
11882
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
11867
- let e = ya({
11883
+ let e = xa({
11868
11884
  value: a - b,
11869
11885
  step: 1
11870
11886
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
11871
11887
  if (u > n) continue;
11872
- let d = za({
11888
+ let d = Va({
11873
11889
  currentGap: l,
11874
11890
  referenceGap: a
11875
11891
  });
@@ -11893,12 +11909,12 @@ var oa = class {
11893
11909
  });
11894
11910
  }
11895
11911
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
11896
- let e = ya({
11912
+ let e = xa({
11897
11913
  value: x - a,
11898
11914
  step: 1
11899
11915
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
11900
11916
  if (u > n) continue;
11901
- let d = za({
11917
+ let d = Va({
11902
11918
  currentGap: l,
11903
11919
  referenceGap: a
11904
11920
  });
@@ -11923,16 +11939,16 @@ var oa = class {
11923
11939
  }
11924
11940
  }
11925
11941
  }
11926
- return La({
11942
+ return za({
11927
11943
  options: m,
11928
11944
  previousContext: i,
11929
11945
  switchDistance: a
11930
11946
  });
11931
- }, Ua = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11947
+ }, Ga = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11932
11948
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
11933
11949
  for (let e of t) {
11934
11950
  let { top: t, bottom: n } = e;
11935
- _a({
11951
+ ya({
11936
11952
  firstStart: t,
11937
11953
  firstEnd: n,
11938
11954
  secondStart: l,
@@ -11952,22 +11968,22 @@ var oa = class {
11952
11968
  f.push({
11953
11969
  bounds: e,
11954
11970
  isActive: !0
11955
- }), Sa({
11971
+ }), wa({
11956
11972
  items: f,
11957
11973
  axis: "left"
11958
11974
  });
11959
- let p = wa({ items: f });
11975
+ let p = Ea({ items: f });
11960
11976
  if (p === -1) return {
11961
11977
  delta: 0,
11962
11978
  guides: [],
11963
11979
  context: null
11964
11980
  };
11965
- let m = [], h = c - s, g = Ca({
11981
+ let m = [], h = c - s, g = Ta({
11966
11982
  items: f,
11967
11983
  index: p,
11968
11984
  axis: "horizontal",
11969
11985
  direction: "prev"
11970
- }), _ = Ca({
11986
+ }), _ = Ta({
11971
11987
  items: f,
11972
11988
  index: p,
11973
11989
  axis: "horizontal",
@@ -11976,19 +11992,19 @@ var oa = class {
11976
11992
  if (v && y) {
11977
11993
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
11978
11994
  if (a >= 0) {
11979
- let e = ya({
11995
+ let e = xa({
11980
11996
  value: a / 2,
11981
11997
  step: 1
11982
11998
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
11983
11999
  if (Math.max(u, d) <= n) {
11984
- let t = Ra({
12000
+ let t = Ba({
11985
12001
  activeStart: s,
11986
12002
  activeEnd: c,
11987
12003
  targetGap: e,
11988
12004
  beforeEdge: r,
11989
12005
  afterEdge: i,
11990
12006
  threshold: n,
11991
- step: ma
12007
+ step: ga
11992
12008
  });
11993
12009
  if (t) {
11994
12010
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -12025,16 +12041,16 @@ var oa = class {
12025
12041
  }
12026
12042
  for (let e of r) {
12027
12043
  let { axis: t, start: r, end: i, distance: a } = e;
12028
- if (!ba({
12044
+ if (!Sa({
12029
12045
  value: a,
12030
12046
  step: .5
12031
- }) || !Ta({
12047
+ }) || !Da({
12032
12048
  patternAxis: t,
12033
12049
  activeRangeStart: l,
12034
12050
  activeRangeEnd: u,
12035
12051
  tolerance: n
12036
12052
  })) continue;
12037
- let d = Ea({
12053
+ let d = Oa({
12038
12054
  patternStart: r,
12039
12055
  patternEnd: i,
12040
12056
  activeStart: s,
@@ -12042,12 +12058,12 @@ var oa = class {
12042
12058
  });
12043
12059
  if (d) {
12044
12060
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
12045
- let e = ya({
12061
+ let e = xa({
12046
12062
  value: a - b,
12047
12063
  step: 1
12048
12064
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
12049
12065
  if (u > n) continue;
12050
- let d = za({
12066
+ let d = Va({
12051
12067
  currentGap: l,
12052
12068
  referenceGap: a
12053
12069
  });
@@ -12071,12 +12087,12 @@ var oa = class {
12071
12087
  });
12072
12088
  }
12073
12089
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
12074
- let e = ya({
12090
+ let e = xa({
12075
12091
  value: x - a,
12076
12092
  step: 1
12077
12093
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
12078
12094
  if (u > n) continue;
12079
- let d = za({
12095
+ let d = Va({
12080
12096
  currentGap: l,
12081
12097
  referenceGap: a
12082
12098
  });
@@ -12101,20 +12117,20 @@ var oa = class {
12101
12117
  }
12102
12118
  }
12103
12119
  }
12104
- return La({
12120
+ return za({
12105
12121
  options: m,
12106
12122
  previousContext: i,
12107
12123
  switchDistance: a
12108
12124
  });
12109
- }, Wa = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
12110
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Ha({
12125
+ }, Ka = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
12126
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Wa({
12111
12127
  activeBounds: e,
12112
12128
  candidates: t,
12113
12129
  threshold: n,
12114
12130
  patterns: r.vertical,
12115
12131
  previousContext: o,
12116
12132
  switchDistance: a
12117
- }), l = Ua({
12133
+ }), l = Ga({
12118
12134
  activeBounds: e,
12119
12135
  candidates: t,
12120
12136
  threshold: n,
@@ -12133,14 +12149,14 @@ var oa = class {
12133
12149
  horizontal: l.context
12134
12150
  }
12135
12151
  };
12136
- }, Ga = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
12152
+ }, qa = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
12137
12153
  let o = Math.min(a, r / 2, i / 2);
12138
12154
  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();
12139
- }, Ka = ({ 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 }) => {
12155
+ }, Ja = ({ 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 }) => {
12140
12156
  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;
12141
12157
  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";
12142
12158
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
12143
- e.beginPath(), Ga({
12159
+ e.beginPath(), qa({
12144
12160
  context: e,
12145
12161
  x: w,
12146
12162
  y: T,
@@ -12148,11 +12164,11 @@ var oa = class {
12148
12164
  height: C,
12149
12165
  radius: v
12150
12166
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
12151
- }, qa = ({ context: e, guide: t, zoom: n }) => {
12152
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = ha({ distance: l }).toString();
12167
+ }, Ya = ({ context: e, guide: t, zoom: n }) => {
12168
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = _a({ distance: l }).toString();
12153
12169
  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();
12154
- let d = pa;
12155
- Ka({
12170
+ let d = ha;
12171
+ Ja({
12156
12172
  context: e,
12157
12173
  type: r,
12158
12174
  axis: i,
@@ -12162,7 +12178,7 @@ var oa = class {
12162
12178
  zoom: n,
12163
12179
  color: d,
12164
12180
  lineWidth: 1
12165
- }), Ka({
12181
+ }), Ja({
12166
12182
  context: e,
12167
12183
  type: r,
12168
12184
  axis: i,
@@ -12173,10 +12189,10 @@ var oa = class {
12173
12189
  color: d,
12174
12190
  lineWidth: 1
12175
12191
  });
12176
- }, Ja = ({ anchors: e, bounds: t }) => {
12192
+ }, Xa = ({ anchors: e, bounds: t }) => {
12177
12193
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
12178
12194
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
12179
- }, Ya = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
12195
+ }, Za = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
12180
12196
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
12181
12197
  for (let e = 0; e < s.length; e += 1) {
12182
12198
  let c = s[e], l = null, u = Infinity;
@@ -12197,35 +12213,35 @@ var oa = class {
12197
12213
  });
12198
12214
  }
12199
12215
  return i;
12200
- }, Xa = ({ bounds: e }) => ({
12201
- vertical: Ya({
12216
+ }, Qa = ({ bounds: e }) => ({
12217
+ vertical: Za({
12202
12218
  bounds: e,
12203
12219
  axis: "centerX",
12204
12220
  type: "vertical",
12205
12221
  primaryStart: "top",
12206
12222
  primaryEnd: "bottom"
12207
12223
  }),
12208
- horizontal: Ya({
12224
+ horizontal: Za({
12209
12225
  bounds: e,
12210
12226
  axis: "centerY",
12211
12227
  type: "horizontal",
12212
12228
  primaryStart: "left",
12213
12229
  primaryEnd: "right"
12214
12230
  })
12215
- }), Za = [
12231
+ }), $a = [
12216
12232
  "montage-area",
12217
12233
  "background",
12218
12234
  "interaction-blocker"
12219
- ], Qa = ({ activeObject: t }) => {
12235
+ ], eo = ({ activeObject: t }) => {
12220
12236
  let n = /* @__PURE__ */ new Set();
12221
12237
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
12222
- }, $a = ({ object: e, excluded: t, ignoredIds: n = Za }) => {
12238
+ }, to = ({ object: e, excluded: t, ignoredIds: n = $a }) => {
12223
12239
  if (t.has(e)) return !0;
12224
12240
  let { visible: r = !0 } = e;
12225
12241
  if (!r) return !0;
12226
12242
  let { id: i } = e;
12227
12243
  return !!(i && n.includes(i));
12228
- }, eo = class e {
12244
+ }, no = class e {
12229
12245
  constructor({ editor: e }) {
12230
12246
  this.anchors = {
12231
12247
  vertical: [],
@@ -12278,7 +12294,7 @@ var oa = class {
12278
12294
  this._clearSpacingContexts(), this._clearGuides();
12279
12295
  return;
12280
12296
  }
12281
- let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Va({
12297
+ let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Ua({
12282
12298
  activeBounds: a,
12283
12299
  threshold: c,
12284
12300
  anchors: this.anchors
@@ -12290,7 +12306,7 @@ var oa = class {
12290
12306
  top: t + u
12291
12307
  }), n.setCoords(), a = G({ object: n }) ?? a;
12292
12308
  }
12293
- let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Wa({
12309
+ let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Ka({
12294
12310
  activeBounds: a,
12295
12311
  candidates: d,
12296
12312
  threshold: f,
@@ -12311,11 +12327,11 @@ var oa = class {
12311
12327
  target: n,
12312
12328
  transform: i
12313
12329
  });
12314
- let h = G({ object: n }) ?? a, g = Va({
12330
+ let h = G({ object: n }) ?? a, g = Ua({
12315
12331
  activeBounds: h,
12316
12332
  threshold: c,
12317
12333
  anchors: this.anchors
12318
- }), _ = Wa({
12334
+ }), _ = Ka({
12319
12335
  activeBounds: h,
12320
12336
  candidates: d,
12321
12337
  threshold: c,
@@ -12546,9 +12562,9 @@ var oa = class {
12546
12562
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
12547
12563
  if (!n) return;
12548
12564
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
12549
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = pa, n.setLineDash([4, 4]);
12565
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = ha, n.setLineDash([4, 4]);
12550
12566
  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();
12551
- for (let e of this.activeSpacingGuides) qa({
12567
+ for (let e of this.activeSpacingGuides) Ya({
12552
12568
  context: n,
12553
12569
  guide: e,
12554
12570
  zoom: c
@@ -12759,14 +12775,14 @@ var oa = class {
12759
12775
  }, r = [];
12760
12776
  for (let e of t) {
12761
12777
  let t = G({ object: e });
12762
- t && (Ja({
12778
+ t && (Xa({
12763
12779
  anchors: n,
12764
12780
  bounds: t
12765
12781
  }), r.push(t));
12766
12782
  }
12767
12783
  let { montageArea: i } = this.editor, a = G({ object: i });
12768
12784
  if (a) {
12769
- Ja({
12785
+ Xa({
12770
12786
  anchors: n,
12771
12787
  bounds: a
12772
12788
  });
@@ -12778,12 +12794,12 @@ var oa = class {
12778
12794
  bottom: i
12779
12795
  };
12780
12796
  } else this.guideBounds = this._calculateViewportBounds();
12781
- this.anchors = n, this.spacingPatterns = Xa({ bounds: r }), this.cachedTargetBounds = r;
12797
+ this.anchors = n, this.spacingPatterns = Qa({ bounds: r }), this.cachedTargetBounds = r;
12782
12798
  }
12783
12799
  _collectTargets({ activeObject: e }) {
12784
- let t = Qa({ activeObject: e }), n = [];
12800
+ let t = eo({ activeObject: e }), n = [];
12785
12801
  return this.canvas.forEachObject((e) => {
12786
- $a({
12802
+ to({
12787
12803
  object: e,
12788
12804
  excluded: t
12789
12805
  }) || n.push(e);
@@ -12806,7 +12822,7 @@ var oa = class {
12806
12822
  bottom: (r - s) / a
12807
12823
  };
12808
12824
  }
12809
- }, to = "#3D8BF4", no = class e {
12825
+ }, ro = "#3D8BF4", io = class e {
12810
12826
  constructor({ editor: e }) {
12811
12827
  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();
12812
12828
  }
@@ -12899,8 +12915,8 @@ var oa = class {
12899
12915
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
12900
12916
  }
12901
12917
  static _resolveTarget({ event: e, activeObject: t }) {
12902
- let { target: n } = e, r = Qa({ activeObject: t });
12903
- return n && !$a({
12918
+ let { target: n } = e, r = eo({ activeObject: t });
12919
+ return n && !to({
12904
12920
  object: n,
12905
12921
  excluded: r
12906
12922
  }) ? n : null;
@@ -13017,18 +13033,18 @@ var oa = class {
13017
13033
  let { canvas: e } = this, t = e.getSelectionContext();
13018
13034
  if (!t) return;
13019
13035
  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;
13020
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = to, t.setLineDash([]);
13036
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = ro, t.setLineDash([]);
13021
13037
  for (let e of this.activeGuides) {
13022
13038
  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;
13023
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Ka({
13039
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Ja({
13024
13040
  context: t,
13025
13041
  type: n,
13026
13042
  axis: i,
13027
13043
  start: a,
13028
13044
  end: c,
13029
- text: ha({ distance: l }).toString(),
13045
+ text: _a({ distance: l }).toString(),
13030
13046
  zoom: r,
13031
- color: to,
13047
+ color: ro,
13032
13048
  lineWidth: 1,
13033
13049
  offsetAlongAxis: d,
13034
13050
  offsetPerpendicular: 0
@@ -13046,13 +13062,13 @@ var oa = class {
13046
13062
  let { toolbar: e } = this.editor;
13047
13063
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
13048
13064
  }
13049
- }, ro = class e {
13065
+ }, ao = class e {
13050
13066
  constructor(e, t) {
13051
13067
  this.options = t, this.containerId = e, this.editorId = `${e}-${O()}`, this.init();
13052
13068
  }
13053
13069
  async init() {
13054
13070
  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;
13055
- if (fe.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new j(), this.workerManager = new N(), this.errorManager = new Vi({ editor: this }), this.historyManager = new kt({ editor: this }), this.toolbar = new et({ editor: this }), this.transformManager = new Bt({ editor: this }), this.zoomManager = new Vt({ editor: this }), this.canvasManager = new zt({ editor: this }), this.imageManager = new Ft({ editor: this }), this.layerManager = new Xt({ editor: this }), this.shapeManager = new Ni({ editor: this }), this.interactionBlocker = new Jt({ editor: this }), this.backgroundManager = new Yt({ editor: this }), this.clipboardManager = new Fi({ editor: this }), this.objectLockManager = new Ii({ editor: this }), this.groupingManager = new Li({ editor: this }), this.selectionManager = new Ri({ editor: this }), this.deletionManager = new zi({ editor: this }), this.panConstraintManager = new Hi({ editor: this }), this.snappingManager = new eo({ editor: this }), this.measurementManager = new no({ editor: this }), this.fontManager = new pe(this.options.fonts ?? []), this.textManager = new sa({ editor: this }), this.templateManager = new fa({ editor: this }), u && (this.angleIndicator = new rt({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new A({
13071
+ if (fe.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new j(), this.workerManager = new N(), this.errorManager = new Hi({ editor: this }), this.historyManager = new kt({ editor: this }), this.toolbar = new et({ editor: this }), this.transformManager = new Bt({ editor: this }), this.zoomManager = new Vt({ editor: this }), this.canvasManager = new zt({ editor: this }), this.imageManager = new Ft({ editor: this }), this.layerManager = new Xt({ editor: this }), this.shapeManager = new Pi({ editor: this }), this.interactionBlocker = new Jt({ editor: this }), this.backgroundManager = new Yt({ editor: this }), this.clipboardManager = new Ii({ editor: this }), this.objectLockManager = new Li({ editor: this }), this.groupingManager = new Ri({ editor: this }), this.selectionManager = new zi({ editor: this }), this.deletionManager = new Bi({ editor: this }), this.panConstraintManager = new Ui({ editor: this }), this.snappingManager = new no({ editor: this }), this.measurementManager = new io({ editor: this }), this.fontManager = new pe(this.options.fonts ?? []), this.textManager = new la({ editor: this }), this.templateManager = new ma({ editor: this }), u && (this.angleIndicator = new rt({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new A({
13056
13072
  editor: this,
13057
13073
  options: this.options
13058
13074
  }), 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) {
@@ -13160,7 +13176,7 @@ var oa = class {
13160
13176
  "U+A640-A69F",
13161
13177
  "U+FE2E-FE2F",
13162
13178
  "U+2116"
13163
- ].join(", "), io = {
13179
+ ].join(", "), oo = {
13164
13180
  preserveObjectStacking: !0,
13165
13181
  controlsAboveOverlay: !0,
13166
13182
  centeredRotation: !0,
@@ -14014,20 +14030,20 @@ var oa = class {
14014
14030
  };
14015
14031
  //#endregion
14016
14032
  //#region src/main.ts
14017
- function ao(e, t = {}) {
14033
+ function so(e, t = {}) {
14018
14034
  let n = {
14019
- ...io,
14035
+ ...oo,
14020
14036
  ...t
14021
14037
  }, r = document.getElementById(e);
14022
14038
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
14023
14039
  let i = document.createElement("canvas");
14024
14040
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
14025
14041
  n._onReadyCallback = t;
14026
- let r = new ro(i.id, n);
14042
+ let r = new ao(i.id, n);
14027
14043
  window[e] = r;
14028
14044
  });
14029
14045
  }
14030
14046
  //#endregion
14031
- export { ao as default };
14047
+ export { so as default };
14032
14048
 
14033
14049
  //# sourceMappingURL=main.js.map