@anu3ev/fabric-image-editor 0.6.13 → 0.6.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.
package/dist/main.js CHANGED
@@ -243,7 +243,7 @@ function N(e) {
243
243
  }
244
244
  //#endregion
245
245
  //#region src/editor/worker-manager/index.ts
246
- var P = class {
246
+ var ee = class {
247
247
  constructor(e) {
248
248
  e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new N(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
249
249
  }
@@ -271,26 +271,26 @@ var P = class {
271
271
  terminate() {
272
272
  this.worker.terminate();
273
273
  }
274
- }, F = "#2B2D33", ee = "#3D8BF4", I = "#FFFFFF";
274
+ }, P = "#2B2D33", F = "#3D8BF4", I = "#FFFFFF";
275
275
  //#endregion
276
276
  //#region src/editor/customized-controls/renderers.ts
277
277
  function L(e, t, n, r, i) {
278
- e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = ee, e.lineWidth = 1, e.beginPath(), e.roundRect(-12 / 2, -12 / 2, 12, 12, 2), e.fill(), e.stroke(), e.restore();
278
+ e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = F, e.lineWidth = 1, e.beginPath(), e.roundRect(-12 / 2, -12 / 2, 12, 12, 2), e.fill(), e.stroke(), e.restore();
279
279
  }
280
280
  function te(e, t, n, r, i) {
281
- e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = ee, e.lineWidth = 1, e.beginPath(), e.roundRect(-8 / 2, -20 / 2, 8, 20, 100), e.fill(), e.stroke(), e.restore();
281
+ e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = F, e.lineWidth = 1, e.beginPath(), e.roundRect(-8 / 2, -20 / 2, 8, 20, 100), e.fill(), e.stroke(), e.restore();
282
282
  }
283
283
  function R(e, t, n, r, i) {
284
- e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = ee, e.lineWidth = 1, e.beginPath(), e.roundRect(-20 / 2, -8 / 2, 20, 8, 100), e.fill(), e.stroke(), e.restore();
284
+ e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = F, e.lineWidth = 1, e.beginPath(), e.roundRect(-20 / 2, -8 / 2, 20, 8, 100), e.fill(), e.stroke(), e.restore();
285
285
  }
286
286
  var z = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ne = new Image();
287
287
  ne.src = z;
288
- function re(e, t, n, r, i) {
289
- e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(ne, -16 / 2, -16 / 2, 16, 16), e.restore();
288
+ function B(e, t, n, r, i) {
289
+ e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = P, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(ne, -16 / 2, -16 / 2, 16, 16), e.restore();
290
290
  }
291
291
  //#endregion
292
292
  //#region src/editor/customized-controls/default-controls.ts
293
- var ie = {
293
+ var re = {
294
294
  tl: {
295
295
  render: L,
296
296
  sizeX: 12,
@@ -348,13 +348,13 @@ var ie = {
348
348
  offsetY: 0
349
349
  },
350
350
  mtr: {
351
- render: re,
351
+ render: B,
352
352
  sizeX: 32,
353
353
  sizeY: 32,
354
354
  offsetX: 0,
355
355
  offsetY: -32
356
356
  }
357
- }, B = class t {
357
+ }, V = class t {
358
358
  static wrapWidthControl(e) {
359
359
  if (!(e != null && e.actionHandler)) return;
360
360
  let t = e.actionHandler;
@@ -364,7 +364,7 @@ var ie = {
364
364
  };
365
365
  }
366
366
  static applyControlOverrides(e) {
367
- Object.entries(ie).forEach(([t, n]) => {
367
+ Object.entries(re).forEach(([t, n]) => {
368
368
  let r = e[t];
369
369
  r && (Object.assign(r, n), t === "mtr" && (r.cursorStyle = "grab", r.mouseDownHandler = (e, t, n, r) => {
370
370
  var i;
@@ -457,7 +457,7 @@ var ie = {
457
457
  mr: !0
458
458
  });
459
459
  }
460
- }, ae, oe = class e {
460
+ }, ie, ae = class e {
461
461
  constructor(e = []) {
462
462
  this.fonts = e;
463
463
  }
@@ -608,7 +608,7 @@ var ie = {
608
608
  });
609
609
  }
610
610
  };
611
- ae = oe, ae.registeredFontKeys = /* @__PURE__ */ new Set(), ae.descriptorDefaults = {
611
+ ie = ae, ie.registeredFontKeys = /* @__PURE__ */ new Set(), ie.descriptorDefaults = {
612
612
  style: "normal",
613
613
  weight: "normal",
614
614
  stretch: "normal",
@@ -619,7 +619,7 @@ ae = oe, ae.registeredFontKeys = /* @__PURE__ */ new Set(), ae.descriptorDefault
619
619
  };
620
620
  //#endregion
621
621
  //#region src/editor/ui/toolbar-manager/default-config.ts
622
- var se = {
622
+ var oe = {
623
623
  style: {
624
624
  position: "absolute",
625
625
  display: "none",
@@ -729,36 +729,36 @@ var se = {
729
729
  };
730
730
  //#endregion
731
731
  //#region \0@oxc-project+runtime@0.120.0/helpers/typeof.js
732
- function V(e) {
732
+ function H(e) {
733
733
  "@babel/helpers - typeof";
734
- return V = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
734
+ return H = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
735
735
  return typeof e;
736
736
  } : function(e) {
737
737
  return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
738
- }, V(e);
738
+ }, H(e);
739
739
  }
740
740
  //#endregion
741
741
  //#region \0@oxc-project+runtime@0.120.0/helpers/toPrimitive.js
742
- function ce(e, t) {
743
- if (V(e) != "object" || !e) return e;
742
+ function se(e, t) {
743
+ if (H(e) != "object" || !e) return e;
744
744
  var n = e[Symbol.toPrimitive];
745
745
  if (n !== void 0) {
746
746
  var r = n.call(e, t || "default");
747
- if (V(r) != "object") return r;
747
+ if (H(r) != "object") return r;
748
748
  throw TypeError("@@toPrimitive must return a primitive value.");
749
749
  }
750
750
  return (t === "string" ? String : Number)(e);
751
751
  }
752
752
  //#endregion
753
753
  //#region \0@oxc-project+runtime@0.120.0/helpers/toPropertyKey.js
754
- function le(e) {
755
- var t = ce(e, "string");
756
- return V(t) == "symbol" ? t : t + "";
754
+ function ce(e) {
755
+ var t = se(e, "string");
756
+ return H(t) == "symbol" ? t : t + "";
757
757
  }
758
758
  //#endregion
759
759
  //#region \0@oxc-project+runtime@0.120.0/helpers/defineProperty.js
760
- function ue(e, t, n) {
761
- return (t = le(t)) in e ? Object.defineProperty(e, t, {
760
+ function le(e, t, n) {
761
+ return (t = ce(t)) in e ? Object.defineProperty(e, t, {
762
762
  value: n,
763
763
  enumerable: !0,
764
764
  configurable: !0,
@@ -767,7 +767,7 @@ function ue(e, t, n) {
767
767
  }
768
768
  //#endregion
769
769
  //#region \0@oxc-project+runtime@0.120.0/helpers/objectSpread2.js
770
- function de(e, t) {
770
+ function ue(e, t) {
771
771
  var n = Object.keys(e);
772
772
  if (Object.getOwnPropertySymbols) {
773
773
  var r = Object.getOwnPropertySymbols(e);
@@ -777,12 +777,12 @@ function de(e, t) {
777
777
  }
778
778
  return n;
779
779
  }
780
- function H(e) {
780
+ function U(e) {
781
781
  for (var t = 1; t < arguments.length; t++) {
782
782
  var n = arguments[t] == null ? {} : arguments[t];
783
- t % 2 ? de(Object(n), !0).forEach(function(t) {
784
- ue(e, t, n[t]);
785
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : de(Object(n)).forEach(function(t) {
783
+ t % 2 ? ue(Object(n), !0).forEach(function(t) {
784
+ le(e, t, n[t]);
785
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : ue(Object(n)).forEach(function(t) {
786
786
  Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
787
787
  });
788
788
  }
@@ -790,18 +790,18 @@ function H(e) {
790
790
  }
791
791
  //#endregion
792
792
  //#region src/editor/ui/toolbar-manager/index.ts
793
- var U = class {
793
+ var W = class {
794
794
  constructor({ editor: e }) {
795
795
  this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
796
796
  }
797
797
  _initToolbar() {
798
798
  if (!this.options.showToolbar) return;
799
799
  let e = this.options.toolbar || {};
800
- this.config = H(H(H({}, se), e), {}, {
801
- style: H(H({}, se.style), e.style || {}),
802
- btnStyle: H(H({}, se.btnStyle), e.btnStyle || {}),
803
- icons: H(H({}, se.icons), e.icons || {}),
804
- handlers: H(H({}, se.handlers), e.handlers || {})
800
+ this.config = U(U(U({}, oe), e), {}, {
801
+ style: U(U({}, oe.style), e.style || {}),
802
+ btnStyle: U(U({}, oe.btnStyle), e.btnStyle || {}),
803
+ icons: U(U({}, oe.icons), e.icons || {}),
804
+ handlers: U(U({}, oe.handlers), e.handlers || {})
805
805
  }), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
806
806
  this.el.style.display = "none";
807
807
  }, this._createDOM(), this._bindEvents();
@@ -881,7 +881,7 @@ var U = class {
881
881
  destroy() {
882
882
  this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
883
883
  }
884
- }, W = {
884
+ }, de = {
885
885
  position: "absolute",
886
886
  display: "none",
887
887
  background: "#2B2D33",
@@ -900,7 +900,7 @@ var U = class {
900
900
  this.isActive = !1, this.currentAngle = 0, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._createDOM(), this._bindEvents();
901
901
  }
902
902
  _createDOM() {
903
- this.el = document.createElement("div"), this.el.className = fe, Object.entries(W).forEach(([e, t]) => {
903
+ this.el = document.createElement("div"), this.el.className = fe, Object.entries(de).forEach(([e, t]) => {
904
904
  this.el.style.setProperty(e, t);
905
905
  }), this.canvas.wrapperEl.appendChild(this.el);
906
906
  }
@@ -946,7 +946,7 @@ var U = class {
946
946
  var e;
947
947
  this.canvas && (this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:cleared", this._onSelectionCleared)), (e = this.el) != null && e.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
948
948
  }
949
- }, me = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split(".");
949
+ }, me = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split(".");
950
950
  //#endregion
951
951
  //#region src/editor/history-manager/diff-normalization.ts
952
952
  function he({ state: e }) {
@@ -1438,7 +1438,7 @@ var Ue = class {
1438
1438
  }
1439
1439
  })();
1440
1440
  }
1441
- }, We = .1, Ge = 4096, Ke = 4096, qe = "application/image-editor:", Je = /* @__PURE__ */ "customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), Ye = class e {
1441
+ }, We = .1, Ge = 4096, Ke = 4096, qe = "application/image-editor:", Je = /* @__PURE__ */ "customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), Ye = class e {
1442
1442
  constructor({ editor: e }) {
1443
1443
  this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
1444
1444
  }
@@ -2531,7 +2531,7 @@ var pt = ({ canvas: e, options: t = {}, flags: n = {} }) => {
2531
2531
  let { id: r = `rect-${D()}`, left: i, top: a, width: o = 100, height: s = 100, fill: c = "blue" } = t, l = ut(t, dt);
2532
2532
  return ft({
2533
2533
  canvas: e,
2534
- object: new g(H({
2534
+ object: new g(U({
2535
2535
  id: r,
2536
2536
  left: i,
2537
2537
  top: a,
@@ -3967,10 +3967,10 @@ function Qt() {
3967
3967
  //#region src/editor/shape-manager/shape-layout.ts
3968
3968
  var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s }) => {
3969
3969
  var c, l;
3970
- let u = fn({ padding: s }), d = Math.max(J, (c = e.shapeManualBaseWidth) == null ? r : c), f = Math.max(J, (l = e.shapeManualBaseHeight) == null ? i : l), p = sn({
3970
+ let u = pn({ padding: s }), d = Math.max(J, (c = e.shapeManualBaseWidth) == null ? r : c), f = Math.max(J, (l = e.shapeManualBaseHeight) == null ? i : l), p = cn({
3971
3971
  text: n,
3972
3972
  padding: u
3973
- }), m = Math.max(J, r, p), h = ln({
3973
+ }), m = Math.max(J, r, p), h = un({
3974
3974
  text: n,
3975
3975
  width: m,
3976
3976
  height: i,
@@ -3983,7 +3983,7 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
3983
3983
  rounding: e.shapeRounding,
3984
3984
  strokeWidth: e.shapeStrokeWidth
3985
3985
  });
3986
- let { frame: _, splitByGrapheme: v, textTop: y } = cn({
3986
+ let { frame: _, splitByGrapheme: v, textTop: y } = ln({
3987
3987
  text: n,
3988
3988
  width: m,
3989
3989
  height: g,
@@ -4012,22 +4012,56 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
4012
4012
  scaleX: 1,
4013
4013
  scaleY: 1
4014
4014
  }), e.set("dirty", !0), e.setCoords();
4015
- }, sn = ({ text: e, padding: t }) => {
4016
- if (!pn({ text: e })) return J;
4017
- let n = fn({ padding: t });
4018
- return un({
4019
- frameWidth: yn({ text: e }),
4015
+ }, sn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i, montageAreaWidth: a }) => {
4016
+ let o = Math.max(J, t), s = Math.max(J, n);
4017
+ if (!mn({ text: e })) return s;
4018
+ let c = Number.isFinite(a) && a > 0 ? Math.max(J, a) : Math.max(o, s), l = Math.max(0, i == null ? 0 : i), u = Math.max(s, c);
4019
+ if (l >= u) return Math.max(o, s);
4020
+ let d = pn({ padding: r }), f = u, p = yn({
4021
+ text: e,
4022
+ frameWidth: _n({
4023
+ width: f,
4024
+ padding: d
4025
+ })
4026
+ });
4027
+ if (p.hasWrappedLines) return f;
4028
+ let m = Math.max(J, p.longestLineWidth), h = Math.min(f, Math.max(s, dn({
4029
+ frameWidth: m,
4030
+ padding: d
4031
+ })));
4032
+ for (let t = 0; t < rn; t += 1) {
4033
+ let t = _n({
4034
+ width: h,
4035
+ padding: d
4036
+ }), n = yn({
4037
+ text: e,
4038
+ frameWidth: t
4039
+ }), r = t >= m - $t;
4040
+ if (!n.hasWrappedLines && r) return h;
4041
+ if (h >= f - $t) return f;
4042
+ let i = n.hasWrappedLines ? Math.max(m + 1, t + 1) : m;
4043
+ h = Math.min(f, Math.max(h + 1, dn({
4044
+ frameWidth: i,
4045
+ padding: d
4046
+ })));
4047
+ }
4048
+ return h;
4049
+ }, cn = ({ text: e, padding: t }) => {
4050
+ if (!mn({ text: e })) return J;
4051
+ let n = pn({ padding: t });
4052
+ return dn({
4053
+ frameWidth: xn({ text: e }),
4020
4054
  padding: n
4021
4055
  });
4022
- }, cn = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
4023
- let a = hn({
4056
+ }, ln = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
4057
+ let a = gn({
4024
4058
  width: Math.max(J, t),
4025
4059
  height: Math.max(J, n),
4026
- padding: fn({ padding: i })
4027
- }), o = Cn({
4060
+ padding: pn({ padding: i })
4061
+ }), o = Tn({
4028
4062
  text: e,
4029
4063
  frameWidth: a.width
4030
- }), s = vn({
4064
+ }), s = bn({
4031
4065
  text: e,
4032
4066
  frameWidth: a.width,
4033
4067
  splitByGrapheme: o
@@ -4035,23 +4069,23 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
4035
4069
  return {
4036
4070
  frame: a,
4037
4071
  splitByGrapheme: o,
4038
- textTop: xn({
4072
+ textTop: Cn({
4039
4073
  alignV: r,
4040
4074
  frameHeight: a.height,
4041
4075
  frameTop: a.top,
4042
4076
  textHeight: s
4043
4077
  })
4044
4078
  };
4045
- }, ln = ({ text: e, width: t, height: n, padding: r }) => {
4079
+ }, un = ({ text: e, width: t, height: n, padding: r }) => {
4046
4080
  let i = Math.max(J, n);
4047
- if (!pn({ text: e })) return i;
4048
- let a = Math.max(J, t), o = fn({ padding: r }), s = i;
4081
+ if (!mn({ text: e })) return i;
4082
+ let a = Math.max(J, t), o = pn({ padding: r }), s = i;
4049
4083
  for (let t = 0; t < an; t += 1) {
4050
- let t = hn({
4084
+ let t = gn({
4051
4085
  width: a,
4052
4086
  height: s,
4053
4087
  padding: o
4054
- }), n = vn({
4088
+ }), n = bn({
4055
4089
  text: e,
4056
4090
  frameWidth: t.width
4057
4091
  });
@@ -4061,10 +4095,10 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
4061
4095
  }
4062
4096
  return s;
4063
4097
  };
4064
- function un({ frameWidth: e, padding: t }) {
4098
+ function dn({ frameWidth: e, padding: t }) {
4065
4099
  let n = Math.max(J, e), r = n;
4066
4100
  for (let e = 0; e < rn; e += 1) {
4067
- let e = gn({
4101
+ let e = _n({
4068
4102
  width: r,
4069
4103
  padding: t
4070
4104
  });
@@ -4074,38 +4108,38 @@ function un({ frameWidth: e, padding: t }) {
4074
4108
  }
4075
4109
  return r;
4076
4110
  }
4077
- function dn({ left: e, top: t, canvasCenter: n }) {
4111
+ function fn({ left: e, top: t, canvasCenter: n }) {
4078
4112
  return typeof e == "number" && typeof t == "number" ? new p(e, t) : n;
4079
4113
  }
4080
- function fn({ padding: e }) {
4114
+ function pn({ padding: e }) {
4081
4115
  return {
4082
- top: mn({ value: e.top }),
4083
- right: mn({ value: e.right }),
4084
- bottom: mn({ value: e.bottom }),
4085
- left: mn({ value: e.left })
4116
+ top: hn({ value: e.top }),
4117
+ right: hn({ value: e.right }),
4118
+ bottom: hn({ value: e.bottom }),
4119
+ left: hn({ value: e.left })
4086
4120
  };
4087
4121
  }
4088
- function pn({ text: e }) {
4122
+ function mn({ text: e }) {
4089
4123
  var t;
4090
4124
  return ((t = e.text) == null ? "" : t).trim().length > 0;
4091
4125
  }
4092
- function mn({ value: e }) {
4126
+ function hn({ value: e }) {
4093
4127
  return Math.min(Math.max(e, 0), nn);
4094
4128
  }
4095
- function hn({ width: e, height: t, padding: n }) {
4096
- let r = Sn({
4129
+ function gn({ width: e, height: t, padding: n }) {
4130
+ let r = wn({
4097
4131
  size: e,
4098
4132
  ratio: n.left,
4099
4133
  axis: "horizontal"
4100
- }), i = Sn({
4134
+ }), i = wn({
4101
4135
  size: e,
4102
4136
  ratio: n.right,
4103
4137
  axis: "horizontal"
4104
- }), a = Sn({
4138
+ }), a = wn({
4105
4139
  size: t,
4106
4140
  ratio: n.top,
4107
4141
  axis: "vertical"
4108
- }), o = Sn({
4142
+ }), o = wn({
4109
4143
  size: t,
4110
4144
  ratio: n.bottom,
4111
4145
  axis: "vertical"
@@ -4117,19 +4151,19 @@ function hn({ width: e, height: t, padding: n }) {
4117
4151
  height: Math.max(J, t - a - o)
4118
4152
  };
4119
4153
  }
4120
- function gn({ width: e, padding: t }) {
4121
- let n = Sn({
4154
+ function _n({ width: e, padding: t }) {
4155
+ let n = wn({
4122
4156
  size: e,
4123
4157
  ratio: t.left,
4124
4158
  axis: "horizontal"
4125
- }), r = Sn({
4159
+ }), r = wn({
4126
4160
  size: e,
4127
4161
  ratio: t.right,
4128
4162
  axis: "horizontal"
4129
4163
  });
4130
4164
  return Math.max(J, e - n - r);
4131
4165
  }
4132
- function _n({ text: e }) {
4166
+ function vn({ text: e }) {
4133
4167
  let { height: t } = e;
4134
4168
  if (typeof t == "number" && Number.isFinite(t)) return t;
4135
4169
  if (typeof e.calcTextHeight == "function") {
@@ -4138,8 +4172,27 @@ function _n({ text: e }) {
4138
4172
  }
4139
4173
  return J;
4140
4174
  }
4141
- function vn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4142
- let r = En({ text: e }), i = n == null ? Cn({
4175
+ function yn({ text: e, frameWidth: t }) {
4176
+ let n = Dn({ text: e }), r = Tn({
4177
+ text: e,
4178
+ frameWidth: t
4179
+ }), i = An({ text: e });
4180
+ e.set({
4181
+ autoExpand: !1,
4182
+ width: Math.max(J, t),
4183
+ splitByGrapheme: r
4184
+ }), e.initDimensions();
4185
+ let a = On({ text: e }) > n, o = Math.ceil(En({ text: e }));
4186
+ return jn({
4187
+ text: e,
4188
+ state: i
4189
+ }), {
4190
+ hasWrappedLines: a,
4191
+ longestLineWidth: o
4192
+ };
4193
+ }
4194
+ function bn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4195
+ let r = An({ text: e }), i = n == null ? Tn({
4143
4196
  text: e,
4144
4197
  frameWidth: t
4145
4198
  }) : n;
@@ -4148,68 +4201,77 @@ function vn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4148
4201
  width: Math.max(J, t),
4149
4202
  splitByGrapheme: i
4150
4203
  }), e.initDimensions();
4151
- let a = _n({ text: e });
4152
- return Dn({
4204
+ let a = vn({ text: e });
4205
+ return jn({
4153
4206
  text: e,
4154
4207
  state: r
4155
4208
  }), a;
4156
4209
  }
4157
- function yn({ text: e }) {
4158
- let t = bn({
4210
+ function xn({ text: e }) {
4211
+ let t = Sn({
4159
4212
  text: e,
4160
4213
  frameWidth: J,
4161
4214
  splitByGrapheme: !0
4162
4215
  });
4163
4216
  return Math.max(J, t);
4164
4217
  }
4165
- function bn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4166
- let r = En({ text: e });
4218
+ function Sn({ text: e, frameWidth: t, splitByGrapheme: n }) {
4219
+ let r = An({ text: e });
4167
4220
  e.set({
4168
4221
  autoExpand: !1,
4169
4222
  width: Math.max(J, t),
4170
4223
  splitByGrapheme: n
4171
4224
  }), e.initDimensions();
4172
- let i = wn({ text: e });
4173
- return Dn({
4225
+ let i = En({ text: e });
4226
+ return jn({
4174
4227
  text: e,
4175
4228
  state: r
4176
4229
  }), i;
4177
4230
  }
4178
- function xn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
4231
+ function Cn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
4179
4232
  let i = Math.max(0, t - r);
4180
4233
  return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
4181
4234
  }
4182
- function Sn({ size: e, ratio: t, axis: n }) {
4235
+ function wn({ size: e, ratio: t, axis: n }) {
4183
4236
  let r = n === "horizontal" ? en : tn, i = e * t;
4184
4237
  return Math.max(0, Math.min(i, r));
4185
4238
  }
4186
- function Cn({ text: e, frameWidth: t }) {
4187
- let n = Math.max(J, t), r = En({ text: e });
4239
+ function Tn({ text: e, frameWidth: t }) {
4240
+ let n = Math.max(J, t), r = An({ text: e });
4188
4241
  e.set({
4189
4242
  autoExpand: !1,
4190
4243
  width: n,
4191
4244
  splitByGrapheme: !1
4192
4245
  }), e.initDimensions();
4193
- let i = On({ text: e }) > n + $t;
4194
- return Dn({
4246
+ let i = Mn({ text: e }) > n + $t;
4247
+ return jn({
4195
4248
  text: e,
4196
4249
  state: r
4197
4250
  }), i;
4198
4251
  }
4199
- function wn({ text: e }) {
4252
+ function En({ text: e }) {
4200
4253
  var t;
4201
- let n = e;
4202
- if (Array.isArray(n.textLines) && n.textLines.length > 0) return Tn({
4254
+ let n = On({ text: e });
4255
+ if (n > 0) return kn({
4203
4256
  text: e,
4204
- lineCount: n.textLines.length
4257
+ lineCount: n
4205
4258
  });
4206
- let r = (t = n.text) == null ? "" : t;
4207
- return Tn({
4259
+ let r = (t = e.text) == null ? "" : t;
4260
+ return kn({
4208
4261
  text: e,
4209
4262
  lineCount: Math.max(r.split("\n").length, 1)
4210
4263
  });
4211
4264
  }
4212
- function Tn({ text: e, lineCount: t }) {
4265
+ function Dn({ text: e }) {
4266
+ var t;
4267
+ let n = (t = e.text) == null ? "" : t;
4268
+ return Math.max(n.split("\n").length, 1);
4269
+ }
4270
+ function On({ text: e }) {
4271
+ let t = e;
4272
+ return Array.isArray(t.textLines) ? t.textLines.length : 0;
4273
+ }
4274
+ function kn({ text: e, lineCount: t }) {
4213
4275
  let n = J;
4214
4276
  for (let r = 0; r < t; r += 1) {
4215
4277
  let t = e.getLineWidth(r);
@@ -4217,7 +4279,7 @@ function Tn({ text: e, lineCount: t }) {
4217
4279
  }
4218
4280
  return n;
4219
4281
  }
4220
- function En({ text: e }) {
4282
+ function An({ text: e }) {
4221
4283
  let { autoExpand: t, splitByGrapheme: n, width: r } = e;
4222
4284
  return {
4223
4285
  autoExpand: t,
@@ -4225,32 +4287,33 @@ function En({ text: e }) {
4225
4287
  width: typeof r == "number" ? r : void 0
4226
4288
  };
4227
4289
  }
4228
- function Dn({ text: e, state: t }) {
4290
+ function jn({ text: e, state: t }) {
4229
4291
  let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
4230
4292
  n !== void 0 && (a.autoExpand = n), r !== void 0 && (a.splitByGrapheme = r), typeof i == "number" && (a.width = i), Object.keys(a).length > 0 && (e.set(a), e.initDimensions());
4231
4293
  }
4232
- function On({ text: e }) {
4294
+ function Mn({ text: e }) {
4233
4295
  let { dynamicMinWidth: t } = e;
4234
4296
  return typeof t == "number" && Number.isFinite(t) ? t : 0;
4235
4297
  }
4236
4298
  //#endregion
4237
4299
  //#region src/editor/shape-manager/shape-runtime.ts
4238
- var kn = ({ group: e }) => {
4300
+ var Nn = ({ group: e }) => {
4239
4301
  let t = e;
4240
4302
  typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
4241
4303
  interactive: !0,
4242
4304
  subTargetCheck: !0
4243
4305
  });
4244
- }, An = ({ text: e }) => {
4306
+ }, Pn = ({ text: e }) => {
4245
4307
  e.set({
4246
4308
  hasBorders: !1,
4247
4309
  hasControls: !1,
4248
4310
  evented: !1,
4249
4311
  selectable: !1,
4250
4312
  editable: !0,
4313
+ autoExpand: !1,
4251
4314
  shapeNodeType: "text"
4252
4315
  }), e.setCoords();
4253
- }, jn = ({ group: e }) => {
4316
+ }, Fn = ({ group: e }) => {
4254
4317
  let { layoutManager: t } = e;
4255
4318
  if (!t || typeof t.unsubscribeTargets != "function") return;
4256
4319
  let n = e.getObjects();
@@ -4258,7 +4321,7 @@ var kn = ({ group: e }) => {
4258
4321
  target: e,
4259
4322
  targets: n
4260
4323
  });
4261
- }, Mn = ({ group: e }) => {
4324
+ }, In = ({ group: e }) => {
4262
4325
  let t = e.getObjects();
4263
4326
  for (let e = 0; e < t.length; e += 1) {
4264
4327
  let n = t[e];
@@ -4269,23 +4332,23 @@ var kn = ({ group: e }) => {
4269
4332
  if (n instanceof _) return n;
4270
4333
  }
4271
4334
  return null;
4272
- }, Nn = [
4335
+ }, Ln = [
4273
4336
  "tl",
4274
4337
  "tr",
4275
4338
  "bl",
4276
4339
  "br"
4277
- ], Pn = ({ transform: e }) => {
4340
+ ], Rn = ({ transform: e }) => {
4278
4341
  let { originX: t, originY: n } = e;
4279
4342
  return (t === "center" || t === .5) && (n === "center" || n === .5);
4280
- }, Fn = ({ transform: e, x: t, y: n }) => {
4343
+ }, zn = ({ transform: e, x: t, y: n }) => {
4281
4344
  let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i, s = b.getLocalPoint(r, r.originX, r.originY, t, n), c = Math.sign(s.x || r.signX || 1), l = Math.sign(s.y || r.signY || 1);
4282
4345
  r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
4283
4346
  let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
4284
- Pn({ transform: r }) && (d *= 2, f *= 2);
4347
+ Rn({ transform: r }) && (d *= 2, f *= 2);
4285
4348
  let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
4286
4349
  return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
4287
- }, In = () => {
4288
- let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => Fn({
4350
+ }, Bn = () => {
4351
+ let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => zn({
4289
4352
  transform: t,
4290
4353
  x: n,
4291
4354
  y: r
@@ -4301,38 +4364,38 @@ var kn = ({ group: e }) => {
4301
4364
  a.uniformScaling = s;
4302
4365
  }
4303
4366
  };
4304
- }, Ln = ({ control: e }) => {
4305
- let t = new r(H(H({}, e), {}, { actionHandler: In() }));
4367
+ }, Vn = ({ control: e }) => {
4368
+ let t = new r(U(U({}, e), {}, { actionHandler: Bn() }));
4306
4369
  return t.shapeFreeScaleCornerControl = !0, t;
4307
- }, Rn = ({ group: e }) => {
4308
- let t = H({}, e.controls);
4309
- Nn.forEach((n) => {
4370
+ }, Hn = ({ group: e }) => {
4371
+ let t = U({}, e.controls);
4372
+ Ln.forEach((n) => {
4310
4373
  let r = e.controls[n];
4311
- r && (r.shapeFreeScaleCornerControl || (t[n] = Ln({ control: r })));
4374
+ r && (r.shapeFreeScaleCornerControl || (t[n] = Vn({ control: r })));
4312
4375
  }), e.controls = t;
4313
- }, zn = [
4376
+ }, Un = [
4314
4377
  "layoutManager",
4315
4378
  "objectCaching",
4316
4379
  "centeredScaling",
4317
4380
  "lockScalingFlip"
4318
- ], Bn = [
4381
+ ], Wn = [
4319
4382
  "type",
4320
4383
  "objects",
4321
4384
  "layoutManager"
4322
- ], Vn, Hn = "shape-group";
4323
- function Un() {
4385
+ ], Gn, Kn = "shape-group";
4386
+ function qn() {
4324
4387
  return { performLayout() {} };
4325
4388
  }
4326
- function Wn({ layoutManager: e }) {
4389
+ function Jn({ layoutManager: e }) {
4327
4390
  let t = y.getClass("layoutManager");
4328
4391
  if (!e) return new t();
4329
4392
  let { strategy: n, type: r } = e, i = y.getClass(r);
4330
4393
  return n ? new i(new (y.getClass(n))()) : new i();
4331
4394
  }
4332
- var Gn = class e extends l {
4395
+ var Yn = class e extends l {
4333
4396
  constructor(e = [], t = {}) {
4334
- let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a } = t, o = ut(t, zn);
4335
- super(e, H(H({}, o), {}, {
4397
+ let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a } = t, o = ut(t, Un);
4398
+ super(e, U(U({}, o), {}, {
4336
4399
  layoutManager: n,
4337
4400
  objectCaching: r == null ? !1 : r,
4338
4401
  centeredScaling: i == null ? !1 : i,
@@ -4343,14 +4406,14 @@ var Gn = class e extends l {
4343
4406
  this.set({
4344
4407
  objectCaching: !1,
4345
4408
  shapeComposite: !0
4346
- }), this._syncRoundability(), kn({ group: this }), Rn({ group: this });
4347
- let e = Mn({ group: this });
4348
- e && An({ text: e }), jn({ group: this }), this.setCoords();
4409
+ }), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0), this._syncRoundability(), Nn({ group: this }), Hn({ group: this });
4410
+ let e = In({ group: this });
4411
+ e && Pn({ text: e }), Fn({ group: this }), this.setCoords();
4349
4412
  }
4350
4413
  static fromObject(t, n) {
4351
4414
  return k(function* () {
4352
- let { type: r, objects: i = [], layoutManager: a } = t, o = ut(t, Bn), [s, c] = yield Promise.all([C.enlivenObjects(i, n), C.enlivenObjectEnlivables(o, n)]), l = new e(s, H(H(H({}, o), c), {}, { layoutManager: Un() }));
4353
- return l.layoutManager = Wn({ layoutManager: a }), l.layoutManager.subscribeTargets({
4415
+ let { type: r, objects: i = [], layoutManager: a } = t, o = ut(t, Wn), [s, c] = yield Promise.all([C.enlivenObjects(i, n), C.enlivenObjectEnlivables(o, n)]), l = new e(s, U(U(U({}, o), c), {}, { layoutManager: qn() }));
4416
+ return l.layoutManager = Jn({ layoutManager: a }), l.layoutManager.subscribeTargets({
4354
4417
  type: "initialization",
4355
4418
  target: l,
4356
4419
  targets: l.getObjects()
@@ -4365,10 +4428,10 @@ var Gn = class e extends l {
4365
4428
  t && (this.shapeCanRound = At({ preset: t }));
4366
4429
  }
4367
4430
  };
4368
- Vn = Gn, Vn.type = Hn;
4369
- var Kn = () => {
4370
- y != null && y.setClass && y.setClass(Gn, Hn);
4371
- }, Y = (e) => e instanceof Gn || e instanceof l && e.shapeComposite === !0, qn = ({ target: e, subTargets: t = [] }) => {
4431
+ Gn = Yn, Gn.type = Kn;
4432
+ var Xn = () => {
4433
+ y != null && y.setClass && y.setClass(Yn, Kn);
4434
+ }, Y = (e) => e instanceof Yn || e instanceof l && e.shapeComposite === !0, Zn = ({ target: e, subTargets: t = [] }) => {
4372
4435
  if (Y(e)) return e;
4373
4436
  if (e != null && e.group && Y(e.group)) return e.group;
4374
4437
  for (let e = 0; e < t.length; e += 1) {
@@ -4378,7 +4441,7 @@ var Kn = () => {
4378
4441
  if (r && Y(r)) return r;
4379
4442
  }
4380
4443
  return null;
4381
- }, Jn = ({ group: e }) => {
4444
+ }, Qn = ({ group: e }) => {
4382
4445
  let t = e.getObjects();
4383
4446
  for (let e = 0; e < t.length; e += 1) {
4384
4447
  let n = t[e];
@@ -4389,7 +4452,7 @@ var Kn = () => {
4389
4452
  if (!(n instanceof _)) return n;
4390
4453
  }
4391
4454
  return null;
4392
- }, Yn = ({ group: e }) => {
4455
+ }, $n = ({ group: e }) => {
4393
4456
  let t = e.getObjects();
4394
4457
  for (let e = 0; e < t.length; e += 1) {
4395
4458
  let n = t[e];
@@ -4400,17 +4463,17 @@ var Kn = () => {
4400
4463
  if (n instanceof _) return n;
4401
4464
  }
4402
4465
  return null;
4403
- }, Xn = ({ group: e }) => ({
4404
- shape: Jn({ group: e }),
4405
- text: Yn({ group: e })
4406
- }), Zn = ({ group: e }) => {
4407
- kn({ group: e });
4408
- }, Qn = ({ transform: e, key: t }) => {
4466
+ }, er = ({ group: e }) => ({
4467
+ shape: Qn({ group: e }),
4468
+ text: $n({ group: e })
4469
+ }), tr = ({ group: e }) => {
4470
+ Nn({ group: e });
4471
+ }, nr = ({ transform: e, key: t }) => {
4409
4472
  let n = e == null ? void 0 : e.original;
4410
4473
  if (!n || typeof n != "object") return null;
4411
4474
  let r = n[t];
4412
4475
  return typeof r != "number" || !Number.isFinite(r) ? null : r;
4413
- }, $n = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, er = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, tr = ({ transform: e }) => {
4476
+ }, rr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, ir = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, ar = ({ transform: e }) => {
4414
4477
  var t;
4415
4478
  let n = (t = e == null ? void 0 : e.action) == null ? "" : t, r = typeof (e == null ? void 0 : e.corner) == "string" ? e.corner : "", i = r === "tl" || r === "tr" || r === "bl" || r === "br", a = n === "scaleX" || r === "ml" || r === "mr", o = n === "scaleY" || r === "mt" || r === "mb", s = a || i, c = o || i;
4416
4479
  return {
@@ -4419,39 +4482,39 @@ var Kn = () => {
4419
4482
  isCornerScaleAction: i,
4420
4483
  isVerticalOnlyScale: c && !s
4421
4484
  };
4422
- }, nr = ({ event: e, group: t, transform: n, canvas: r }) => {
4485
+ }, or = ({ event: e, group: t, transform: n, canvas: r }) => {
4423
4486
  var i, a, o, s, c;
4424
4487
  if (!e) return null;
4425
4488
  let l = (i = t.canvas) == null ? r : i, u = l.getScenePoint(e), d = t.getRelativeCenterPoint(), f = t.translateToGivenOrigin(d, "center", "center", n.originX, n.originY), p = (a = t.angle) == null ? 0 : a, m = (p === 0 ? u : u.rotate(-p * Math.PI / 180, d)).subtract(f), h = t.controls[n.corner], g = l.getZoom() || 1, _ = ((o = t.padding) == null ? 0 : o) / g;
4426
4489
  return m.x >= _ && (m.x -= _), m.x <= -_ && (m.x += _), m.y >= _ && (m.y -= _), m.y <= -_ && (m.y += _), m.x -= (s = h == null ? void 0 : h.offsetX) == null ? 0 : s, m.y -= (c = h == null ? void 0 : h.offsetY) == null ? 0 : c, m;
4427
- }, rr = ({ group: e, originX: t, originY: n }) => {
4490
+ }, sr = ({ group: e, originX: t, originY: n }) => {
4428
4491
  if (t === null || n === null) return null;
4429
4492
  let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
4430
4493
  return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
4431
- }, ir = ({ state: e, transform: t }) => {
4494
+ }, cr = ({ state: e, transform: t }) => {
4432
4495
  if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
4433
- let n = $n({ value: t.originX }), r = er({ value: t.originY });
4496
+ let n = rr({ value: t.originX }), r = ir({ value: t.originY });
4434
4497
  return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
4435
- }, ar = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
4498
+ }, lr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
4436
4499
  //#endregion
4437
4500
  //#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
4438
- function or({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
4501
+ function ur({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
4439
4502
  let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
4440
4503
  return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
4441
4504
  }
4442
- function sr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
4505
+ function dr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
4443
4506
  var c;
4444
4507
  let l = Math.max(0, (c = e.shapeStrokeWidth) == null ? 0 : c);
4445
4508
  Pt({
4446
4509
  shape: t,
4447
- width: or({
4510
+ width: ur({
4448
4511
  size: n,
4449
4512
  scale: i,
4450
4513
  strokeWidth: l,
4451
4514
  minSize: o,
4452
4515
  scaleEpsilon: s
4453
4516
  }),
4454
- height: or({
4517
+ height: ur({
4455
4518
  size: r,
4456
4519
  scale: a,
4457
4520
  strokeWidth: l,
@@ -4462,8 +4525,8 @@ function sr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
4462
4525
  strokeWidth: l
4463
4526
  });
4464
4527
  }
4465
- function cr({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
4466
- let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i == null ? Ct : i, { frame: f, splitByGrapheme: p, textTop: m } = cn({
4528
+ function fr({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
4529
+ let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i == null ? Ct : i, { frame: f, splitByGrapheme: p, textTop: m } = ln({
4467
4530
  text: e,
4468
4531
  width: t,
4469
4532
  height: n,
@@ -4483,13 +4546,13 @@ function cr({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, sc
4483
4546
  scaleY: 1 / u
4484
4547
  }), e.initDimensions(), e.setCoords();
4485
4548
  }
4486
- var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
4549
+ var pr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
4487
4550
  let f = Math.max(d, Math.abs(c) || 1), p = Math.max(d, Math.abs(l) || 1);
4488
4551
  e.set({
4489
4552
  width: r / f,
4490
4553
  height: i / p,
4491
4554
  dirty: !0
4492
- }), sr({
4555
+ }), dr({
4493
4556
  group: e,
4494
4557
  shape: t,
4495
4558
  width: r,
@@ -4498,7 +4561,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4498
4561
  scaleY: l,
4499
4562
  minSize: u,
4500
4563
  scaleEpsilon: d
4501
- }), cr({
4564
+ }), fr({
4502
4565
  text: n,
4503
4566
  width: r,
4504
4567
  height: i,
@@ -4509,13 +4572,13 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4509
4572
  scaleY: l,
4510
4573
  scaleEpsilon: d
4511
4574
  });
4512
- }, X = 1, Z = 1e-4, ur = .5, dr = class e {
4575
+ }, X = 1, Z = 1e-4, mr = .5, hr = class e {
4513
4576
  constructor({ canvas: t }) {
4514
4577
  this.handleObjectScaling = (t) => {
4515
4578
  var n, r, i, a, o, s;
4516
4579
  let { target: c, transform: l } = t;
4517
4580
  if (!Y(c)) return;
4518
- let u = c, { shape: d, text: f } = Xn({ group: u });
4581
+ let u = c, { shape: d, text: f } = er({ group: u });
4519
4582
  if (!d || !f) return;
4520
4583
  u.set({
4521
4584
  lockScalingFlip: !0,
@@ -4526,7 +4589,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4526
4589
  text: f,
4527
4590
  padding: p,
4528
4591
  transform: l
4529
- }), { isCornerScaleAction: h } = tr({ transform: l }), g = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
4592
+ }), { isCornerScaleAction: h } = ar({ transform: l }), g = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
4530
4593
  m.isProportionalScaling = h && g;
4531
4594
  let _ = (n = u.left) == null ? 0 : n, v = (r = u.top) == null ? 0 : r, y = !!u.flipX, b = !!u.flipY, x = (i = u.shapeAlignHorizontal) == null ? Ct : i, S = (a = u.shapeAlignVertical) == null ? wt : a, C = this._resolveScalingDecision({
4532
4595
  group: u,
@@ -4541,7 +4604,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4541
4604
  shouldHandleAsNoop: C.shouldHandleAsNoop,
4542
4605
  scaleX: C.appliedScaleX,
4543
4606
  scaleY: C.appliedScaleY
4544
- }), lr({
4607
+ }), pr({
4545
4608
  group: u,
4546
4609
  shape: d,
4547
4610
  text: f,
@@ -4577,22 +4640,22 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4577
4640
  if (!c) return;
4578
4641
  let { target: l } = c;
4579
4642
  if (!Y(l)) return;
4580
- let { canScaleHeight: u, canScaleWidth: d } = tr({ transform: c });
4643
+ let { canScaleHeight: u, canScaleWidth: d } = ar({ transform: c });
4581
4644
  if (!d && !u) return;
4582
4645
  let f = l, p = this.scalingState.get(f);
4583
4646
  if (!p || p.isProportionalScaling) return;
4584
- let { shape: m, text: h } = Xn({ group: f });
4647
+ let { shape: m, text: h } = er({ group: f });
4585
4648
  if (!m || !h) return;
4586
- let g = e._resolvePadding({ group: f }), _ = (n = f.shapeAlignHorizontal) == null ? Ct : n, v = (r = f.shapeAlignVertical) == null ? wt : r, y = Math.abs((i = (a = f.scaleX) == null ? p.lastAllowedScaleX : a) == null ? 1 : i) || 1, b = Math.abs((o = (s = f.scaleY) == null ? p.lastAllowedScaleY : s) == null ? 1 : o) || 1, x = H(H({}, t), {}, { transform: c }), S = y, C = b, w = null, T = !1, E = !1;
4649
+ let g = e._resolvePadding({ group: f }), _ = (n = f.shapeAlignHorizontal) == null ? Ct : n, v = (r = f.shapeAlignVertical) == null ? wt : r, y = Math.abs((i = (a = f.scaleX) == null ? p.lastAllowedScaleX : a) == null ? 1 : i) || 1, b = Math.abs((o = (s = f.scaleY) == null ? p.lastAllowedScaleY : s) == null ? 1 : o) || 1, x = U(U({}, t), {}, { transform: c }), S = y, C = b, w = null, T = !1, E = !1;
4587
4650
  if (d && this._hasPointerReachedScaleOrigin({
4588
4651
  event: x,
4589
4652
  group: f,
4590
4653
  axis: "x"
4591
4654
  })) {
4592
- let e = sn({
4655
+ let e = cn({
4593
4656
  text: h,
4594
4657
  padding: g
4595
- }), t = Math.max(X / p.baseWidth, e / p.baseWidth);
4658
+ }), t = Math.max(X / p.startWidth, e / p.startWidth);
4596
4659
  p.lastAllowedScaleX > t + Z && (S = t, T = !0, E = !0);
4597
4660
  }
4598
4661
  if (u && this._hasPointerReachedScaleOrigin({
@@ -4602,10 +4665,10 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4602
4665
  })) {
4603
4666
  w = this._resolveMinimumTextFitHeight({
4604
4667
  text: h,
4605
- width: Math.max(X, p.baseWidth * S),
4668
+ width: Math.max(X, p.startWidth * S),
4606
4669
  padding: g
4607
4670
  });
4608
- let e = Math.max(X / p.baseHeight, w / p.baseHeight);
4671
+ let e = Math.max(X / p.startHeight, w / p.startHeight);
4609
4672
  p.lastAllowedScaleY > e + Z && (C = e, E = !0);
4610
4673
  }
4611
4674
  if (!E) return;
@@ -4623,7 +4686,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4623
4686
  shouldHandleAsNoop: !1,
4624
4687
  scaleX: S,
4625
4688
  scaleY: C
4626
- }), lr({
4689
+ }), pr({
4627
4690
  group: f,
4628
4691
  shape: m,
4629
4692
  text: h,
@@ -4650,97 +4713,106 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4650
4713
  currentFlipY: p.lastAllowedFlipY
4651
4714
  }), this.canvas.requestRenderAll();
4652
4715
  }, this.handleObjectModified = (t) => {
4653
- var n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _;
4654
- let { target: v } = t;
4655
- if (!Y(v)) return;
4656
- let y = v, b = this.scalingState.get(y), x = Math.abs((n = y.scaleX) == null ? 1 : n) || 1, S = Math.abs((r = y.scaleY) == null ? 1 : r) || 1;
4657
- if (!(Math.abs(x - 1) > Z || Math.abs(S - 1) > Z) && !b) return;
4658
- let C = (i = b == null ? void 0 : b.baseWidth) == null ? Math.max(X, (a = (o = (s = y.shapeManualBaseWidth) == null ? y.shapeBaseWidth : s) == null ? y.width : o) == null ? X : a) : i, w = (c = b == null ? void 0 : b.baseHeight) == null ? Math.max(X, (l = (u = (d = y.shapeManualBaseHeight) == null ? y.shapeBaseHeight : d) == null ? y.height : u) == null ? X : l) : c;
4659
- if (b != null && b.blockedScaleAttempt && b) {
4660
- let { shape: e, text: t } = Xn({ group: y });
4716
+ var n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T;
4717
+ let { target: E } = t;
4718
+ if (!Y(E)) return;
4719
+ let D = E, O = this.scalingState.get(D), k = Math.abs((n = D.scaleX) == null ? 1 : n) || 1, A = Math.abs((r = D.scaleY) == null ? 1 : r) || 1;
4720
+ if (!(Math.abs(k - 1) > Z || Math.abs(A - 1) > Z) && !O) return;
4721
+ let j = (i = O == null ? void 0 : O.startWidth) == null ? Math.max(X, (a = (o = (s = D.shapeBaseWidth) == null ? D.width : s) == null ? D.shapeManualBaseWidth : o) == null ? X : a) : i, M = (c = O == null ? void 0 : O.startHeight) == null ? Math.max(X, (l = (u = (d = D.shapeBaseHeight) == null ? D.height : d) == null ? D.shapeManualBaseHeight : u) == null ? X : l) : c, N = (f = O == null ? void 0 : O.startManualBaseWidth) == null ? Math.max(X, (p = D.shapeManualBaseWidth) == null ? j : p) : f, ee = (m = O == null ? void 0 : O.startManualBaseHeight) == null ? Math.max(X, (h = D.shapeManualBaseHeight) == null ? M : h) : m;
4722
+ if (O != null && O.blockedScaleAttempt && O) {
4723
+ let { shape: e, text: t } = er({ group: D });
4661
4724
  this._restoreGroupTransformOnly({
4662
- group: y,
4725
+ group: D,
4663
4726
  shape: e,
4664
4727
  text: t,
4665
- state: b
4666
- }), y.shapeScalingNoopTransform = !1, this.scalingState.delete(y), this.canvas.requestRenderAll();
4728
+ state: O
4729
+ }), D.shapeScalingNoopTransform = !1, this.scalingState.delete(D), this.canvas.requestRenderAll();
4667
4730
  return;
4668
4731
  }
4669
- let { shape: T, text: E } = Xn({ group: y });
4670
- if (!T || !E) {
4671
- this.scalingState.delete(y);
4732
+ let { shape: P, text: F } = er({ group: D });
4733
+ if (!P || !F) {
4734
+ this.scalingState.delete(D);
4672
4735
  return;
4673
4736
  }
4674
- let D = (f = y.shapeAlignHorizontal) == null ? Ct : f, O = (p = y.shapeAlignVertical) == null ? wt : p, k = e._resolvePadding({ group: y }), A = sn({
4675
- text: E,
4676
- padding: k
4677
- }), j = (m = b == null ? void 0 : b.lastAllowedScaleX) == null ? x : m, M = (h = b == null ? void 0 : b.lastAllowedScaleY) == null ? S : h;
4678
- if (!(b != null && b.isProportionalScaling)) {
4737
+ let I = (g = D.shapeAlignHorizontal) == null ? Ct : g, L = (_ = D.shapeAlignVertical) == null ? wt : _, te = e._resolvePadding({ group: D }), R = t.transform ? ar({ transform: t.transform }) : null, z = (v = (y = O == null ? void 0 : O.canScaleWidth) == null ? R == null ? void 0 : R.canScaleWidth : y) == null ? Math.abs(k - 1) > Z : v, ne = (b = (x = O == null ? void 0 : O.canScaleHeight) == null ? R == null ? void 0 : R.canScaleHeight : x) == null ? Math.abs(A - 1) > Z : b, B = cn({
4738
+ text: F,
4739
+ padding: te
4740
+ }), re = (S = O == null ? void 0 : O.lastAllowedScaleX) == null ? k : S, V = (C = O == null ? void 0 : O.lastAllowedScaleY) == null ? A : C;
4741
+ if (!(O != null && O.isProportionalScaling)) {
4679
4742
  this._shouldClampWidthToMinimum({
4680
4743
  event: t,
4681
- group: y,
4682
- minimumWidth: A,
4683
- state: b
4684
- }) && (j = Math.max(X / C, A / C));
4744
+ group: D,
4745
+ minimumWidth: B,
4746
+ state: O
4747
+ }) && (re = Math.max(X / j, B / j));
4685
4748
  let e = this._resolveMinimumTextFitHeight({
4686
- text: E,
4687
- width: Math.max(X, C * j),
4688
- padding: k
4749
+ text: F,
4750
+ width: Math.max(X, j * re),
4751
+ padding: te
4689
4752
  });
4690
4753
  this._shouldClampHeightToMinimum({
4691
4754
  event: t,
4692
- group: y,
4755
+ group: D,
4693
4756
  minimumHeight: e,
4694
- state: b
4695
- }) && (M = Math.max(X / w, e / w));
4757
+ state: O
4758
+ }) && (V = Math.max(X / M, e / M));
4696
4759
  }
4697
- let N = Math.max(X, C * j), P = Math.max(X, w * M), F = Math.abs(N - C) > ur, ee = Math.abs(P - w) > ur, I = F || ee, L = N, te = P;
4698
- if (!I && b) {
4760
+ let ie = z ? Math.max(X, j * re) : j, ae = ne ? Math.max(X, M * V) : ee, oe = Math.abs(ie - j) > mr, H = Math.abs(ae - M) > mr, se = oe || H, ce = ie, le = ae;
4761
+ if (!se && O) {
4699
4762
  this._restoreShapeStateWithoutResize({
4700
- group: y,
4701
- shape: T,
4702
- text: E,
4703
- state: b,
4704
- baseWidth: C,
4705
- baseHeight: w,
4706
- alignH: D,
4707
- alignV: O,
4708
- padding: k
4709
- }), this.scalingState.delete(y), this.canvas.requestRenderAll();
4763
+ group: D,
4764
+ shape: P,
4765
+ text: F,
4766
+ state: O,
4767
+ startWidth: j,
4768
+ startHeight: M,
4769
+ alignH: I,
4770
+ alignV: L,
4771
+ padding: te
4772
+ }), this.scalingState.delete(D), this.canvas.requestRenderAll();
4710
4773
  return;
4711
4774
  }
4712
- b && y.set({
4713
- left: b.lastAllowedLeft,
4714
- top: b.lastAllowedTop
4715
- }), y.shapeManualBaseWidth = L, y.shapeManualBaseHeight = te;
4716
- let R = (g = b == null ? void 0 : b.baseRounding) == null ? Math.max(0, (_ = y.shapeRounding) == null ? 0 : _) : g;
4717
- y.shapeRounding = Math.max(0, R * Math.min(j, M)), on({
4718
- group: y,
4719
- shape: T,
4720
- text: E,
4721
- width: L,
4722
- height: te,
4723
- alignH: D,
4724
- alignV: O,
4725
- padding: k
4726
- }), E.set({
4775
+ O && D.set({
4776
+ left: O.lastAllowedLeft,
4777
+ top: O.lastAllowedTop
4778
+ });
4779
+ let ue = this._resolveNextManualBaseDimensionsAfterScaling({
4780
+ startManualBaseWidth: N,
4781
+ startManualBaseHeight: ee,
4782
+ canScaleWidth: z,
4783
+ canScaleHeight: ne,
4784
+ finalWidth: ce,
4785
+ finalHeight: le
4786
+ });
4787
+ D.shapeManualBaseWidth = ue.width, D.shapeManualBaseHeight = ue.height;
4788
+ let U = (w = O == null ? void 0 : O.baseRounding) == null ? Math.max(0, (T = D.shapeRounding) == null ? 0 : T) : w;
4789
+ D.shapeRounding = Math.max(0, U * Math.min(re, V)), on({
4790
+ group: D,
4791
+ shape: P,
4792
+ text: F,
4793
+ width: ce,
4794
+ height: le,
4795
+ alignH: I,
4796
+ alignV: L,
4797
+ padding: te
4798
+ }), F.set({
4727
4799
  scaleX: 1,
4728
4800
  scaleY: 1
4729
- }), y.set({
4801
+ }), D.set({
4730
4802
  scaleX: 1,
4731
4803
  scaleY: 1
4732
- }), b && this._restoreScalingAnchorPosition({
4733
- group: y,
4734
- state: b
4735
- }), y.setCoords(), E.setCoords(), T.setCoords(), this.scalingState.delete(y), y.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
4804
+ }), O && this._restoreScalingAnchorPosition({
4805
+ group: D,
4806
+ state: O
4807
+ }), D.setCoords(), F.setCoords(), P.setCoords(), this.scalingState.delete(D), D.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
4736
4808
  }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
4737
4809
  }
4738
4810
  _resolveScalingDecision({ group: e, text: t, padding: n, state: r, transform: i }) {
4739
4811
  var a, o, s, c, l, u;
4740
- let d = (a = e.scaleX) == null ? 1 : a, f = (o = e.scaleY) == null ? 1 : o, p = Math.abs(d) || 1, m = Math.abs(f) || 1, h = d < 0 || f < 0, g = ir({
4812
+ let d = (a = e.scaleX) == null ? 1 : a, f = (o = e.scaleY) == null ? 1 : o, p = Math.abs(d) || 1, m = Math.abs(f) || 1, h = d < 0 || f < 0, g = cr({
4741
4813
  state: r,
4742
4814
  transform: i
4743
- }), _ = ar({
4815
+ }), _ = lr({
4744
4816
  state: r,
4745
4817
  transform: i
4746
4818
  });
@@ -4772,7 +4844,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4772
4844
  };
4773
4845
  }
4774
4846
  _resolveScalingConstraintState({ text: e, padding: t, state: n, transform: r, scaleX: i, scaleY: a }) {
4775
- let { baseHeight: o, baseWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } = tr({ transform: r }), S = b && g ? sn({
4847
+ let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } = ar({ transform: r }), S = b && g ? cn({
4776
4848
  text: e,
4777
4849
  padding: t
4778
4850
  }) : null, C = y && _ ? this._resolveMinimumTextFitHeight({
@@ -4791,7 +4863,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4791
4863
  };
4792
4864
  }
4793
4865
  _resolvePreviewDimensions({ text: e, padding: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
4794
- let o = Math.max(X, n.baseWidth * r), s = Math.max(X, n.baseHeight * i), c = a == null ? ln({
4866
+ let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a == null ? un({
4795
4867
  text: e,
4796
4868
  width: o,
4797
4869
  height: s,
@@ -4825,26 +4897,26 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4825
4897
  if (!r) return !1;
4826
4898
  let { transform: i } = e;
4827
4899
  if (!i) return !1;
4828
- let { canScaleWidth: a } = tr({ transform: i });
4900
+ let { canScaleWidth: a } = ar({ transform: i });
4829
4901
  if (!a || !this._hasPointerReachedScaleOrigin({
4830
4902
  event: e,
4831
4903
  group: t,
4832
4904
  axis: "x"
4833
4905
  })) return !1;
4834
- let o = Math.max(X / r.baseWidth, n / r.baseWidth);
4906
+ let o = Math.max(X / r.startWidth, n / r.startWidth);
4835
4907
  return r.lastAllowedScaleX > o + Z;
4836
4908
  }
4837
4909
  _shouldClampHeightToMinimum({ event: e, group: t, minimumHeight: n, state: r }) {
4838
4910
  if (!r) return !1;
4839
4911
  let { transform: i } = e;
4840
4912
  if (!i) return !1;
4841
- let { canScaleHeight: a } = tr({ transform: i });
4913
+ let { canScaleHeight: a } = ar({ transform: i });
4842
4914
  if (!a || !this._hasPointerReachedScaleOrigin({
4843
4915
  event: e,
4844
4916
  group: t,
4845
4917
  axis: "y"
4846
4918
  })) return !1;
4847
- let o = Math.max(X / r.baseHeight, n / r.baseHeight);
4919
+ let o = Math.max(X / r.startHeight, n / r.startHeight);
4848
4920
  return r.lastAllowedScaleY > o + Z;
4849
4921
  }
4850
4922
  _hasPointerReachedScaleOrigin({ event: e, group: t, axis: n }) {
@@ -4852,7 +4924,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4852
4924
  if (!r) return !1;
4853
4925
  let i = r, a = n === "x" ? i.signX : i.signY;
4854
4926
  if (typeof a != "number" || !Number.isFinite(a)) return !1;
4855
- let o = nr({
4927
+ let o = or({
4856
4928
  event: e.e,
4857
4929
  group: t,
4858
4930
  transform: r,
@@ -4866,59 +4938,66 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4866
4938
  _ensureScalingState({ group: e, text: t, padding: n, transform: r }) {
4867
4939
  let i = this.scalingState.get(e);
4868
4940
  if (!i) {
4869
- var a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x;
4870
- let S = Math.max(X, (a = (o = (s = e.shapeManualBaseWidth) == null ? e.shapeBaseWidth : s) == null ? e.width : o) == null ? X : a), C = Math.max(X, (c = (l = (u = e.shapeManualBaseHeight) == null ? e.shapeBaseHeight : u) == null ? e.height : l) == null ? X : c), w = Qn({
4941
+ var a, o, s, c, l, u, d, f, p, m, h;
4942
+ let g = this._resolveScalingStartDimensions({
4943
+ group: e,
4944
+ transform: r
4945
+ }), _ = nr({
4871
4946
  transform: r,
4872
4947
  key: "scaleX"
4873
- }), T = Qn({
4948
+ }), v = nr({
4874
4949
  transform: r,
4875
4950
  key: "scaleY"
4876
- }), E = Qn({
4951
+ }), y = nr({
4877
4952
  transform: r,
4878
4953
  key: "left"
4879
- }), D = Qn({
4954
+ }), b = nr({
4880
4955
  transform: r,
4881
4956
  key: "top"
4882
- }), O = Math.abs((d = w == null ? e.scaleX : w) == null ? 1 : d) || 1, k = Math.abs((f = T == null ? e.scaleY : T) == null ? 1 : f) || 1, A = (p = E == null ? e.left : E) == null ? 0 : p, j = (m = D == null ? e.top : D) == null ? 0 : m, M = $n({ value: (h = r == null || (g = r.original) == null ? void 0 : g.originX) == null ? r == null ? void 0 : r.originX : h }), N = er({ value: (_ = r == null || (v = r.original) == null ? void 0 : v.originY) == null ? r == null ? void 0 : r.originY : _ }), P = typeof (r == null ? void 0 : r.corner) == "string" ? r.corner : null, F = rr({
4957
+ }), x = Math.abs((a = _ == null ? e.scaleX : _) == null ? 1 : a) || 1, S = Math.abs((o = v == null ? e.scaleY : v) == null ? 1 : o) || 1, C = (s = y == null ? e.left : y) == null ? 0 : s, w = (c = b == null ? e.top : b) == null ? 0 : c, T = rr({ value: (l = r == null || (u = r.original) == null ? void 0 : u.originX) == null ? r == null ? void 0 : r.originX : l }), E = ir({ value: (d = r == null || (f = r.original) == null ? void 0 : f.originY) == null ? r == null ? void 0 : r.originY : d }), D = typeof (r == null ? void 0 : r.corner) == "string" ? r.corner : null, O = sr({
4883
4958
  group: e,
4884
- originX: M,
4885
- originY: N
4886
- }), ee = this._resolveMinimumTextFitHeight({
4959
+ originX: T,
4960
+ originY: E
4961
+ }), k = this._resolveMinimumTextFitHeight({
4887
4962
  text: t,
4888
- width: S,
4963
+ width: g.startWidth,
4889
4964
  padding: n
4890
4965
  });
4891
4966
  i = {
4892
- baseWidth: S,
4893
- baseHeight: C,
4894
- baseRounding: Math.max(0, (y = e.shapeRounding) == null ? 0 : y),
4895
- cannotScaleDownAtStart: ee >= C - Z,
4967
+ startWidth: g.startWidth,
4968
+ startHeight: g.startHeight,
4969
+ startManualBaseWidth: g.startManualBaseWidth,
4970
+ startManualBaseHeight: g.startManualBaseHeight,
4971
+ canScaleWidth: g.canScaleWidth,
4972
+ canScaleHeight: g.canScaleHeight,
4973
+ baseRounding: Math.max(0, (p = e.shapeRounding) == null ? 0 : p),
4974
+ cannotScaleDownAtStart: k >= g.startHeight - Z,
4896
4975
  isProportionalScaling: !1,
4897
4976
  blockedScaleAttempt: !1,
4898
- startLeft: A,
4899
- startTop: j,
4900
- startScaleX: O,
4901
- startScaleY: k,
4902
- startTransformOriginX: M,
4903
- startTransformOriginY: N,
4904
- startTransformCorner: P,
4905
- scalingAnchorX: (b = F == null ? void 0 : F.x) == null ? null : b,
4906
- scalingAnchorY: (x = F == null ? void 0 : F.y) == null ? null : x,
4907
- scalingAnchorOriginX: M,
4908
- scalingAnchorOriginY: N,
4977
+ startLeft: C,
4978
+ startTop: w,
4979
+ startScaleX: x,
4980
+ startScaleY: S,
4981
+ startTransformOriginX: T,
4982
+ startTransformOriginY: E,
4983
+ startTransformCorner: D,
4984
+ scalingAnchorX: (m = O == null ? void 0 : O.x) == null ? null : m,
4985
+ scalingAnchorY: (h = O == null ? void 0 : O.y) == null ? null : h,
4986
+ scalingAnchorOriginX: T,
4987
+ scalingAnchorOriginY: E,
4909
4988
  crossedOppositeCorner: !1,
4910
4989
  lastAllowedFlipX: !!e.flipX,
4911
4990
  lastAllowedFlipY: !!e.flipY,
4912
- lastAllowedScaleX: O,
4913
- lastAllowedScaleY: k,
4914
- lastAllowedLeft: A,
4915
- lastAllowedTop: j
4991
+ lastAllowedScaleX: x,
4992
+ lastAllowedScaleY: S,
4993
+ lastAllowedLeft: C,
4994
+ lastAllowedTop: w
4916
4995
  }, this.scalingState.set(e, i);
4917
4996
  }
4918
4997
  return i;
4919
4998
  }
4920
4999
  _resolveMinimumTextFitHeight({ text: e, width: t, padding: n }) {
4921
- return ln({
5000
+ return un({
4922
5001
  text: e,
4923
5002
  width: t,
4924
5003
  height: X,
@@ -4942,7 +5021,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4942
5021
  }
4943
5022
  e.setPositionByOrigin(new p(n, r), i, a), e.setCoords();
4944
5023
  }
4945
- _restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, baseWidth: i, baseHeight: a, alignH: o, alignV: s, padding: c }) {
5024
+ _restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, startWidth: i, startHeight: a, alignH: o, alignV: s, padding: c }) {
4946
5025
  var l, u, d, f;
4947
5026
  on({
4948
5027
  group: e,
@@ -4967,7 +5046,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4967
5046
  }
4968
5047
  _restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
4969
5048
  var i, a, o, s;
4970
- let c = Math.max(X, (i = (a = e.shapeBaseWidth) == null ? e.width : a) == null ? r.baseWidth : i), l = Math.max(X, (o = (s = e.shapeBaseHeight) == null ? e.height : s) == null ? r.baseHeight : o);
5049
+ let c = Math.max(X, (i = (a = e.shapeBaseWidth) == null ? e.width : a) == null ? r.startWidth : i), l = Math.max(X, (o = (s = e.shapeBaseHeight) == null ? e.height : s) == null ? r.startHeight : o);
4971
5050
  t && (Pt({
4972
5051
  shape: t,
4973
5052
  width: c,
@@ -4991,20 +5070,41 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4991
5070
  state: r
4992
5071
  });
4993
5072
  }
4994
- }, fr = class {
5073
+ _resolveScalingStartDimensions({ group: e, transform: t }) {
5074
+ var n, r, i, a, o, s, c, l;
5075
+ let { canScaleWidth: u, canScaleHeight: d } = ar({ transform: t }), f = Math.max(X, (n = (r = (i = e.shapeBaseWidth) == null ? e.width : i) == null ? e.shapeManualBaseWidth : r) == null ? X : n), p = Math.max(X, (a = (o = (s = e.shapeBaseHeight) == null ? e.height : s) == null ? e.shapeManualBaseHeight : o) == null ? X : a);
5076
+ return {
5077
+ startWidth: f,
5078
+ startHeight: p,
5079
+ startManualBaseWidth: Math.max(X, (c = e.shapeManualBaseWidth) == null ? f : c),
5080
+ startManualBaseHeight: Math.max(X, (l = e.shapeManualBaseHeight) == null ? p : l),
5081
+ canScaleWidth: u,
5082
+ canScaleHeight: d
5083
+ };
5084
+ }
5085
+ _resolveNextManualBaseDimensionsAfterScaling({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
5086
+ let o = e;
5087
+ n && (o = i);
5088
+ let s = t;
5089
+ return r && (s = a), {
5090
+ width: o,
5091
+ height: s
5092
+ };
5093
+ }
5094
+ }, gr = class {
4995
5095
  constructor({ canvas: e }) {
4996
5096
  this.handleMouseDown = (e) => {
4997
- let { target: t, e: n, subTargets: r = [] } = e, i = qn({
5097
+ let { target: t, e: n, subTargets: r = [] } = e, i = Zn({
4998
5098
  target: t,
4999
5099
  subTargets: r
5000
5100
  });
5001
5101
  if (!i) return;
5002
- let { text: a } = Xn({ group: i });
5102
+ let { text: a } = er({ group: i });
5003
5103
  if (!a) return;
5004
5104
  let o = this.canvas.getActiveObject(), s = o === i;
5005
5105
  if (!(o === a && a.isEditing)) {
5006
5106
  if (!s) {
5007
- a.isEditing || An({ text: a });
5107
+ a.isEditing || Pn({ text: a });
5008
5108
  return;
5009
5109
  }
5010
5110
  n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
@@ -5024,11 +5124,11 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5024
5124
  Y(r) && (this._restoreTextEditingInteractionMode({
5025
5125
  group: r,
5026
5126
  text: n
5027
- }), An({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
5127
+ }), Pn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
5028
5128
  }, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
5029
5129
  }
5030
5130
  enterTextEditing({ group: e }) {
5031
- let { text: t } = Xn({ group: e });
5131
+ let { text: t } = er({ group: e });
5032
5132
  t && (this._enterTextEditingInteractionMode({
5033
5133
  group: e,
5034
5134
  text: t
@@ -5039,6 +5139,20 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5039
5139
  lockMovementY: !0
5040
5140
  }), this.canvas.setActiveObject(t), t.isEditing || (t.enterEditing(), t.selectAll()), this.canvas.requestRenderAll());
5041
5141
  }
5142
+ resolveGroupInteractionState({ group: e }) {
5143
+ let t = this.editingInteractionState.get(e);
5144
+ return t ? {
5145
+ selectable: t.groupSelectable,
5146
+ evented: t.groupEvented,
5147
+ lockMovementX: t.groupLockMovementX,
5148
+ lockMovementY: t.groupLockMovementY
5149
+ } : {
5150
+ selectable: e.selectable !== !1,
5151
+ evented: e.evented !== !1,
5152
+ lockMovementX: !!e.lockMovementX,
5153
+ lockMovementY: !!e.lockMovementY
5154
+ };
5155
+ }
5042
5156
  _enterTextEditingInteractionMode({ group: e, text: t }) {
5043
5157
  this.editingInteractionState.has(e) || this.editingInteractionState.set(e, {
5044
5158
  groupSelectable: e.selectable !== !1,
@@ -5075,7 +5189,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5075
5189
  lockMovementY: n.textLockMovementY
5076
5190
  }), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
5077
5191
  }
5078
- }, pr = "#B0B5BF", mr = 0, hr = 1, gr = class {
5192
+ }, _r = "#B0B5BF", vr = 0, yr = 1, br = class {
5079
5193
  constructor({ editor: e }) {
5080
5194
  this._handleObjectScaling = (e) => {
5081
5195
  this.scalingController.handleObjectScaling(e);
@@ -5109,21 +5223,17 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5109
5223
  }, this._handleTextChanged = (e) => {
5110
5224
  let { target: t } = e;
5111
5225
  if (!(t instanceof _)) return;
5112
- let { group: n } = t;
5113
- if (!Y(n)) return;
5114
- let { shape: r, text: i } = Xn({ group: n });
5115
- if (!r || !i) return;
5116
- this._detachShapeGroupAutoLayout({ group: n });
5117
- let a = this._resolveEditingCenter({ group: n }), o = this._resolveManualDimensions({ group: n });
5118
- this._applyCurrentLayout({
5119
- group: n,
5120
- shape: r,
5121
- text: i,
5122
- center: a,
5123
- width: o.width,
5124
- height: o.height
5125
- }), this.editor.canvas.requestRenderAll();
5126
- }, this.editor = e, Kn(), this.scalingController = new dr({ canvas: e.canvas }), this.editingController = new fr({ canvas: e.canvas }), this.editingCenters = /* @__PURE__ */ new WeakMap(), this._bindEvents();
5226
+ let n = t;
5227
+ this._syncShapeTextLayoutAfterTextMutation({ textNode: n }) && this.editor.canvas.requestRenderAll();
5228
+ }, this._handleBeforeTextUpdated = (e) => {
5229
+ let { textbox: t, style: n } = e;
5230
+ if (!(t instanceof _)) return;
5231
+ let r = t;
5232
+ this.internalTextUpdates.has(r) || this._syncShapeTextLayoutAfterTextMutation({
5233
+ textNode: r,
5234
+ textStyle: n
5235
+ });
5236
+ }, this.editor = e, Xn(), this.scalingController = new hr({ canvas: e.canvas }), this.editingController = new gr({ canvas: e.canvas }), this.editingCenters = /* @__PURE__ */ new WeakMap(), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
5127
5237
  }
5128
5238
  add() {
5129
5239
  var e = this;
@@ -5131,56 +5241,66 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5131
5241
  var r;
5132
5242
  let i = Dt({ presetKey: t });
5133
5243
  if (!i) return null;
5134
- let { width: a, height: o, left: s, top: c, text: l, textStyle: u, alignH: d, alignV: f, textPadding: p, rounding: m, withoutAdding: h, withoutSelection: g, withoutSave: _, id: v } = n, y = (r = Dt({ presetKey: Ot({
5244
+ let { width: a, height: o, shapeTextAutoExpand: s, left: c, top: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = n, b = (r = Dt({ presetKey: Ot({
5135
5245
  preset: i,
5136
- rounding: m
5137
- }) })) == null ? i : r, b = Math.max(1, a == null ? y.width : a), x = Math.max(1, o == null ? y.height : o), S = e._resolveHorizontalAlign({
5138
- explicitAlign: d,
5139
- textStyle: u
5140
- }), C = f == null ? wt : f, w = kt({
5141
- preset: y,
5142
- overridePadding: p
5143
- }), T = e._resolveShapeStyle({
5246
+ rounding: h
5247
+ }) })) == null ? i : r, x = Math.max(1, a == null ? b.width : a), S = Math.max(1, o == null ? b.height : o), C = s !== !1, w = e._resolveHorizontalAlign({
5248
+ explicitAlign: f,
5249
+ textStyle: d
5250
+ }), T = p == null ? wt : p, E = kt({
5251
+ preset: b,
5252
+ overridePadding: m
5253
+ }), O = e._resolveShapeStyle({
5144
5254
  options: n,
5145
5255
  fallback: null
5146
- }), E = yield Ft({
5147
- preset: y,
5148
- width: b,
5149
- height: x,
5150
- style: T,
5151
- rounding: m
5152
- }), O = e._createTextNode({
5153
- text: l,
5154
- textStyle: u,
5155
- width: b,
5156
- align: S,
5157
- opacity: T.opacity
5158
- }), k = e._createShapeGroup({
5159
- id: v == null ? `shape-${D()}` : v,
5160
- presetKey: y.key,
5161
- presetCanRound: At({ preset: y }),
5162
- shape: E,
5163
- text: O,
5164
- width: b,
5165
- height: x,
5166
- alignH: S,
5167
- alignV: C,
5168
- padding: w,
5169
- style: T,
5170
- rounding: m
5171
- }), A = dn({
5172
- left: s,
5173
- top: c,
5256
+ }), k = e._createTextNode({
5257
+ text: u,
5258
+ textStyle: d,
5259
+ width: x,
5260
+ align: w,
5261
+ opacity: O.opacity
5262
+ }), A = e._resolveShapeLayoutWidth({
5263
+ text: k,
5264
+ currentWidth: x,
5265
+ manualWidth: x,
5266
+ shapeTextAutoExpandEnabled: C,
5267
+ padding: E,
5268
+ strokeWidth: O.strokeWidth
5269
+ }), j = yield Ft({
5270
+ preset: b,
5271
+ width: A,
5272
+ height: S,
5273
+ style: O,
5274
+ rounding: h
5275
+ }), M = e._createShapeGroup({
5276
+ id: y == null ? `shape-${D()}` : y,
5277
+ presetKey: b.key,
5278
+ presetCanRound: At({ preset: b }),
5279
+ shape: j,
5280
+ text: k,
5281
+ width: A,
5282
+ height: S,
5283
+ manualWidth: x,
5284
+ manualHeight: S,
5285
+ shapeTextAutoExpand: C,
5286
+ alignH: w,
5287
+ alignV: T,
5288
+ padding: E,
5289
+ style: O,
5290
+ rounding: h
5291
+ }), N = fn({
5292
+ left: c,
5293
+ top: l,
5174
5294
  canvasCenter: e.editor.canvas.getCenterPoint()
5175
5295
  });
5176
- if (k.setPositionByOrigin(A, "center", "center"), k.setCoords(), h) return k;
5296
+ if (M.setPositionByOrigin(N, "center", "center"), M.setCoords(), g) return M;
5177
5297
  e._beginMutation();
5178
5298
  try {
5179
- e.editor.canvas.add(k), g || e.editor.canvas.setActiveObject(k), e.editor.canvas.requestRenderAll();
5299
+ e.editor.canvas.add(M), _ || e.editor.canvas.setActiveObject(M), e.editor.canvas.requestRenderAll();
5180
5300
  } finally {
5181
- e._endMutation({ withoutSave: _ });
5301
+ e._endMutation({ withoutSave: v });
5182
5302
  }
5183
- return k;
5303
+ return M;
5184
5304
  }).apply(this, arguments);
5185
5305
  }
5186
5306
  update() {
@@ -5191,23 +5311,25 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5191
5311
  if (!d) return null;
5192
5312
  let f = Dt({ presetKey: (i = n == null ? d.shapePresetKey : n) == null ? St : i });
5193
5313
  if (!f) return null;
5194
- let { width: p, height: m, text: h, textStyle: g, alignH: _, alignV: v, textPadding: y, rounding: b, withoutSelection: x, withoutSave: S } = r, C = e._resolveCurrentDimensions({ group: d }), w = Math.max(1, p == null ? C.width : p), T = Math.max(1, m == null ? C.height : m), E = (a = b == null ? d.shapeRounding : b) == null ? 0 : a, O = (o = Dt({ presetKey: Ot({
5314
+ let { width: p, height: m, shapeTextAutoExpand: h, text: g, textStyle: _, alignH: v, alignV: y, textPadding: b, rounding: x, withoutSelection: S, withoutSave: C } = r, w = e._resolveCurrentDimensions({ group: d }), T = Math.max(1, m == null ? w.height : m), E = e._isShapeTextAutoExpandEnabled({ group: d }), O = h === void 0 ? E : h !== !1, k = (a = x == null ? d.shapeRounding : x) == null ? 0 : a, A = (o = Dt({ presetKey: Ot({
5195
5315
  preset: f,
5196
- rounding: E
5197
- }) })) == null ? f : o, k = (s = _ == null ? d.shapeAlignHorizontal : _) == null ? Ct : s, A = (c = v == null ? d.shapeAlignVertical : v) == null ? wt : c, j = e._resolveGroupPadding({ group: d }), M = kt({
5198
- preset: O,
5199
- overridePadding: y == null ? j : y
5200
- }), N = e._resolveShapeStyle({
5316
+ rounding: k
5317
+ }) })) == null ? f : o, j = (s = v == null ? d.shapeAlignHorizontal : v) == null ? Ct : s, M = (c = y == null ? d.shapeAlignVertical : y) == null ? wt : c, N = e._resolveGroupPadding({ group: d }), ee = kt({
5318
+ preset: A,
5319
+ overridePadding: b == null ? N : b
5320
+ }), P = e._resolveShapeStyle({
5201
5321
  options: r,
5202
5322
  fallback: d
5203
- }), P = Math.max(1, (l = p == null ? d.shapeManualBaseWidth : p) == null ? w : l), F = Math.max(1, (u = m == null ? d.shapeManualBaseHeight : m) == null ? T : u), ee = d.getCenterPoint(), { id: I, angle: L = 0, customData: te, evented: R = !0, flipX: z = !1, flipY: ne = !1, lockMovementX: re = !1, lockMovementY: ie = !1, lockRotation: B = !1, lockScalingX: ae = !1, lockScalingY: oe = !1, lockSkewingX: se = !1, lockSkewingY: V = !1, locked: ce = !1, selectable: le = !0 } = d, { text: ue } = Xn({ group: d });
5204
- if (!ue) return null;
5205
- let de = d.removeAll(), H = e._findTextNode({
5323
+ }), F = Math.max(1, (l = d.shapeManualBaseWidth) == null ? w.width : l);
5324
+ p !== void 0 && (F = Math.max(1, p)), p === void 0 && E && !O && (F = Math.max(1, w.width));
5325
+ let I = Math.max(1, (u = m == null ? d.shapeManualBaseHeight : m) == null ? T : u), L = e.editingController.resolveGroupInteractionState({ group: d }), te = d.getCenterPoint(), { id: R, angle: z = 0, customData: ne, flipX: B = !1, flipY: re = !1, lockRotation: V = !1, lockScalingX: ie = !1, lockScalingY: ae = !1, lockSkewingX: oe = !1, lockSkewingY: H = !1, locked: se = !1 } = d, { selectable: ce, evented: le, lockMovementX: ue, lockMovementY: U } = L, { text: W } = er({ group: d });
5326
+ if (!W) return null;
5327
+ let de = d.removeAll(), fe = e._findTextNode({
5206
5328
  objects: de,
5207
- fallback: ue
5329
+ fallback: W
5208
5330
  });
5209
- if (!H) return null;
5210
- H.set({
5331
+ if (!fe) return null;
5332
+ fe.set({
5211
5333
  angle: 0,
5212
5334
  skewX: 0,
5213
5335
  skewY: 0,
@@ -5221,56 +5343,64 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5221
5343
  originX: "left",
5222
5344
  originY: "top"
5223
5345
  }), e._applyTextUpdates({
5224
- textNode: H,
5225
- text: h,
5226
- textStyle: g,
5227
- align: k
5346
+ textNode: fe,
5347
+ text: g,
5348
+ textStyle: _,
5349
+ align: j
5228
5350
  });
5229
- let U = yield Ft({
5230
- preset: O,
5231
- width: w,
5351
+ let pe = e._resolveShapeLayoutWidth({
5352
+ text: fe,
5353
+ currentWidth: w.width,
5354
+ manualWidth: F,
5355
+ shapeTextAutoExpandEnabled: O,
5356
+ padding: ee,
5357
+ strokeWidth: P.strokeWidth
5358
+ }), me = yield Ft({
5359
+ preset: A,
5360
+ width: pe,
5232
5361
  height: T,
5233
- style: N,
5234
- rounding: E
5235
- }), W = e._createShapeGroup({
5236
- id: I == null ? `shape-${D()}` : I,
5237
- presetKey: O.key,
5238
- presetCanRound: At({ preset: O }),
5239
- shape: U,
5240
- text: H,
5241
- width: w,
5362
+ style: P,
5363
+ rounding: k
5364
+ }), he = e._createShapeGroup({
5365
+ id: R == null ? `shape-${D()}` : R,
5366
+ presetKey: A.key,
5367
+ presetCanRound: At({ preset: A }),
5368
+ shape: me,
5369
+ text: fe,
5370
+ width: pe,
5242
5371
  height: T,
5243
- manualWidth: P,
5244
- manualHeight: F,
5245
- alignH: k,
5246
- alignV: A,
5247
- padding: M,
5248
- style: N,
5249
- rounding: E
5372
+ manualWidth: F,
5373
+ manualHeight: I,
5374
+ shapeTextAutoExpand: O,
5375
+ alignH: j,
5376
+ alignV: M,
5377
+ padding: ee,
5378
+ style: P,
5379
+ rounding: k
5250
5380
  });
5251
- if (W.set({
5252
- angle: L,
5253
- customData: te,
5254
- evented: R,
5255
- flipX: z,
5256
- flipY: ne,
5257
- lockMovementX: re,
5258
- lockMovementY: ie,
5259
- lockRotation: B,
5260
- lockScalingX: ae,
5261
- lockScalingY: oe,
5262
- lockSkewingX: se,
5263
- lockSkewingY: V,
5264
- locked: ce,
5265
- selectable: le
5266
- }), W.setPositionByOrigin(ee, "center", "center"), W.setCoords(), !e._isOnCanvas({ object: d })) return W;
5381
+ if (he.set({
5382
+ angle: z,
5383
+ customData: ne,
5384
+ evented: le,
5385
+ flipX: B,
5386
+ flipY: re,
5387
+ lockMovementX: ue,
5388
+ lockMovementY: U,
5389
+ lockRotation: V,
5390
+ lockScalingX: ie,
5391
+ lockScalingY: ae,
5392
+ lockSkewingX: oe,
5393
+ lockSkewingY: H,
5394
+ locked: se,
5395
+ selectable: ce
5396
+ }), he.setPositionByOrigin(te, "center", "center"), he.setCoords(), !e._isOnCanvas({ object: d })) return he;
5267
5397
  e._beginMutation();
5268
5398
  try {
5269
- e.editor.canvas.remove(d), e.editor.canvas.add(W), x || e.editor.canvas.setActiveObject(W), e.editor.canvas.requestRenderAll();
5399
+ e.editor.canvas.remove(d), e.editor.canvas.add(he), S || e.editor.canvas.setActiveObject(he), e.editor.canvas.requestRenderAll();
5270
5400
  } finally {
5271
- e._endMutation({ withoutSave: S });
5401
+ e._endMutation({ withoutSave: C });
5272
5402
  }
5273
- return W;
5403
+ return he;
5274
5404
  }).apply(this, arguments);
5275
5405
  }
5276
5406
  remove({ target: e, withoutSave: t } = {}) {
@@ -5287,7 +5417,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5287
5417
  setFill({ target: e, fill: t, withoutSave: n }) {
5288
5418
  let r = this._resolveShapeGroup({ target: e });
5289
5419
  if (!r) return null;
5290
- let { shape: i } = Xn({ group: r });
5420
+ let { shape: i } = er({ group: r });
5291
5421
  if (!i) return null;
5292
5422
  this._beginMutation();
5293
5423
  try {
@@ -5303,7 +5433,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5303
5433
  setStroke({ target: e, stroke: t, strokeWidth: n, dash: r, withoutSave: i }) {
5304
5434
  let a = this._resolveShapeGroup({ target: e });
5305
5435
  if (!a) return null;
5306
- let { shape: o, text: s } = Xn({ group: a });
5436
+ let { shape: o, text: s } = er({ group: a });
5307
5437
  if (!o) return null;
5308
5438
  this._beginMutation();
5309
5439
  try {
@@ -5327,7 +5457,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5327
5457
  setOpacity({ target: e, opacity: t, withoutSave: n }) {
5328
5458
  let r = this._resolveShapeGroup({ target: e });
5329
5459
  if (!r) return null;
5330
- let { shape: i, text: a } = Xn({ group: r });
5460
+ let { shape: i, text: a } = er({ group: r });
5331
5461
  if (!i) return null;
5332
5462
  this._beginMutation();
5333
5463
  try {
@@ -5343,45 +5473,46 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5343
5473
  getTextNode({ target: e } = {}) {
5344
5474
  let t = this._resolveShapeGroup({ target: e });
5345
5475
  if (!t) return null;
5346
- let { text: n } = Xn({ group: t });
5476
+ let { text: n } = er({ group: t });
5347
5477
  return n || null;
5348
5478
  }
5349
5479
  updateTextStyle({ target: e, style: t = {}, withoutSave: n } = {}) {
5350
- var r;
5351
- let i = this._resolveShapeGroup({ target: e });
5352
- if (!i) return null;
5353
- let { shape: a, text: o } = Xn({ group: i });
5354
- if (!a || !o) return null;
5355
- if (!(Object.keys(t).length > 0)) return i;
5356
- let s = this._resolveManualDimensions({ group: i }), c = i.getCenterPoint(), l = t.align === "left" || t.align === "center" || t.align === "right" ? t.align : (r = i.shapeAlignHorizontal) == null ? Ct : r;
5480
+ let r = this._resolveShapeGroup({ target: e });
5481
+ if (!r) return null;
5482
+ let { shape: i, text: a } = er({ group: r });
5483
+ if (!i || !a) return null;
5484
+ if (!(Object.keys(t).length > 0)) return r;
5485
+ let o = this._resolveManualDimensions({ group: r }), s = r.getCenterPoint(), c = this._resolveShapeTextHorizontalAlign({
5486
+ group: r,
5487
+ textStyle: t
5488
+ });
5357
5489
  this._beginMutation();
5358
5490
  try {
5359
5491
  this._applyTextUpdates({
5360
- textNode: o,
5492
+ textNode: a,
5361
5493
  textStyle: t,
5362
- align: l
5494
+ align: c
5363
5495
  }), this._applyCurrentLayout({
5364
- group: i,
5365
- shape: a,
5366
- text: o,
5496
+ group: r,
5497
+ shape: i,
5498
+ text: a,
5367
5499
  center: {
5368
- x: c.x,
5369
- y: c.y
5500
+ x: s.x,
5501
+ y: s.y
5370
5502
  },
5371
- width: s.width,
5372
- height: s.height,
5373
- alignH: l
5503
+ height: o.height,
5504
+ alignH: c
5374
5505
  }), this.editor.canvas.requestRenderAll();
5375
5506
  } finally {
5376
5507
  this._endMutation({ withoutSave: n });
5377
5508
  }
5378
- return i;
5509
+ return r;
5379
5510
  }
5380
5511
  setTextAlign({ target: e, horizontal: t, vertical: n, withoutSave: r }) {
5381
5512
  var i, a;
5382
5513
  let o = this._resolveShapeGroup({ target: e });
5383
5514
  if (!o) return null;
5384
- let { shape: s, text: c } = Xn({ group: o });
5515
+ let { shape: s, text: c } = er({ group: o });
5385
5516
  if (!s || !c) return null;
5386
5517
  let l = this._resolveCurrentDimensions({ group: o }), u = (i = t == null ? o.shapeAlignHorizontal : t) == null ? Ct : i, d = (a = n == null ? o.shapeAlignVertical : n) == null ? wt : a, f = this._resolveGroupPadding({ group: o });
5387
5518
  this._beginMutation();
@@ -5425,15 +5556,15 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5425
5556
  }
5426
5557
  destroy() {
5427
5558
  let { canvas: e } = this.editor;
5428
- e.off("object:scaling", this._handleObjectScaling), e.off("object:modified", this._handleObjectModified), e.off("mouse:move", this._handleMouseMove), e.off("mouse:down", this._handleMouseDown), e.off("text:editing:entered", this._handleTextEditingEntered), e.off("text:editing:exited", this._handleTextEditingExited), e.off("text:changed", this._handleTextChanged);
5559
+ e.off("object:scaling", this._handleObjectScaling), e.off("object:modified", this._handleObjectModified), e.off("mouse:move", this._handleMouseMove), e.off("mouse:down", this._handleMouseDown), e.off("text:editing:entered", this._handleTextEditingEntered), e.off("text:editing:exited", this._handleTextEditingExited), e.off("text:changed", this._handleTextChanged), e.off("editor:before:text-updated", this._handleBeforeTextUpdated);
5429
5560
  }
5430
5561
  _bindEvents() {
5431
5562
  let { canvas: e } = this.editor;
5432
- e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged);
5563
+ e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged), e.on("editor:before:text-updated", this._handleBeforeTextUpdated);
5433
5564
  }
5434
- _createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, alignH: l, alignV: u, padding: d, style: f, rounding: p }) {
5435
- var m;
5436
- let h = new Gn([r, i], {
5565
+ _createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, style: p, rounding: m }) {
5566
+ var h;
5567
+ let g = new Yn([r, i], {
5437
5568
  id: e,
5438
5569
  originX: "center",
5439
5570
  originY: "center",
@@ -5442,41 +5573,42 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5442
5573
  lockScalingFlip: !0,
5443
5574
  centeredScaling: !1,
5444
5575
  objectCaching: !1
5445
- }), g = f.strokeDashArray ? f.strokeDashArray.slice() : (m = f.strokeDashArray) == null ? null : m;
5446
- return h.set({
5576
+ }), _ = p.strokeDashArray ? p.strokeDashArray.slice() : (h = p.strokeDashArray) == null ? null : h;
5577
+ return g.set({
5447
5578
  shapeComposite: !0,
5448
5579
  shapePresetKey: t,
5449
5580
  shapeBaseWidth: a,
5450
5581
  shapeBaseHeight: o,
5451
5582
  shapeManualBaseWidth: Math.max(1, s == null ? a : s),
5452
5583
  shapeManualBaseHeight: Math.max(1, c == null ? o : c),
5453
- shapeAlignHorizontal: l,
5454
- shapeAlignVertical: u,
5455
- shapePaddingTop: d.top,
5456
- shapePaddingRight: d.right,
5457
- shapePaddingBottom: d.bottom,
5458
- shapePaddingLeft: d.left,
5459
- shapeFill: f.fill,
5460
- shapeStroke: f.stroke,
5461
- shapeStrokeWidth: f.strokeWidth,
5462
- shapeStrokeDashArray: g,
5463
- shapeOpacity: f.opacity,
5464
- shapeRounding: Math.max(0, p == null ? 0 : p),
5584
+ shapeTextAutoExpand: l,
5585
+ shapeAlignHorizontal: u,
5586
+ shapeAlignVertical: d,
5587
+ shapePaddingTop: f.top,
5588
+ shapePaddingRight: f.right,
5589
+ shapePaddingBottom: f.bottom,
5590
+ shapePaddingLeft: f.left,
5591
+ shapeFill: p.fill,
5592
+ shapeStroke: p.stroke,
5593
+ shapeStrokeWidth: p.strokeWidth,
5594
+ shapeStrokeDashArray: _,
5595
+ shapeOpacity: p.opacity,
5596
+ shapeRounding: Math.max(0, m == null ? 0 : m),
5465
5597
  shapeCanRound: n
5466
- }), h.rehydrateRuntimeState(), Zn({ group: h }), An({ text: i }), on({
5467
- group: h,
5598
+ }), g.rehydrateRuntimeState(), tr({ group: g }), Pn({ text: i }), on({
5599
+ group: g,
5468
5600
  shape: r,
5469
5601
  text: i,
5470
5602
  width: a,
5471
5603
  height: o,
5472
- alignH: l,
5473
- alignV: u,
5474
- padding: d
5475
- }), this._detachShapeGroupAutoLayout({ group: h }), h;
5604
+ alignH: u,
5605
+ alignV: d,
5606
+ padding: f
5607
+ }), this._detachShapeGroupAutoLayout({ group: g }), g;
5476
5608
  }
5477
5609
  _createTextNode({ text: e, textStyle: t, width: n, align: r, opacity: i }) {
5478
5610
  var a;
5479
- let o = t == null ? {} : t, s = H(H({}, o), {}, {
5611
+ let o = t == null ? {} : t, s = U(U({}, o), {}, {
5480
5612
  text: (a = e == null ? o.text : e) == null ? "" : a,
5481
5613
  align: r,
5482
5614
  autoExpand: !1,
@@ -5494,7 +5626,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5494
5626
  return c.set({
5495
5627
  shapeNodeType: "text",
5496
5628
  splitByGrapheme: !1
5497
- }), An({ text: c }), c;
5629
+ }), Pn({ text: c }), c;
5498
5630
  }
5499
5631
  _applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
5500
5632
  let i = {};
@@ -5505,12 +5637,20 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5505
5637
  i[r] = n[r];
5506
5638
  }
5507
5639
  }
5508
- t !== void 0 && (i.text = t), r && (i.align = r), i.autoExpand = !1, i.splitByGrapheme = !1, Object.keys(i).length > 0 && (this.editor.textManager.updateText({
5509
- target: e,
5510
- style: i,
5511
- skipRender: !0,
5512
- withoutSave: !0
5513
- }), e.autoExpand = !1);
5640
+ if (t !== void 0 && (i.text = t), r && (i.align = r), i.autoExpand = !1, i.splitByGrapheme = !1, Object.keys(i).length > 0) {
5641
+ this.internalTextUpdates.add(e);
5642
+ try {
5643
+ this.editor.textManager.updateText({
5644
+ target: e,
5645
+ style: i,
5646
+ skipRender: !0,
5647
+ withoutSave: !0
5648
+ });
5649
+ } finally {
5650
+ this.internalTextUpdates.delete(e);
5651
+ }
5652
+ e.autoExpand = !1;
5653
+ }
5514
5654
  }
5515
5655
  _resolveCurrentDimensions({ group: e }) {
5516
5656
  var t, n, r, i, a, o;
@@ -5535,26 +5675,90 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5535
5675
  left: (i = e.shapePaddingLeft) == null ? .2 : i
5536
5676
  };
5537
5677
  }
5678
+ _isShapeTextAutoExpandEnabled({ group: e }) {
5679
+ return e.shapeTextAutoExpand !== !1;
5680
+ }
5681
+ _resolveMontageAreaWidth() {
5682
+ var e;
5683
+ let { montageArea: t } = this.editor;
5684
+ if (!t) return null;
5685
+ t.setCoords();
5686
+ let n = (e = t.getBoundingRect().width) == null ? 0 : e;
5687
+ return !Number.isFinite(n) || n <= 0 ? null : n;
5688
+ }
5689
+ _resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i }) {
5690
+ let a = this._resolveMontageAreaWidth();
5691
+ return a ? sn({
5692
+ text: e,
5693
+ currentWidth: t,
5694
+ minimumWidth: n,
5695
+ padding: r,
5696
+ strokeWidth: i,
5697
+ montageAreaWidth: a
5698
+ }) : Math.max(1, t, n);
5699
+ }
5700
+ _resolveShapeLayoutWidth({ text: e, currentWidth: t, manualWidth: n, shapeTextAutoExpandEnabled: r, padding: i, strokeWidth: a }) {
5701
+ return r ? this._resolveAutoExpandShapeWidth({
5702
+ text: e,
5703
+ currentWidth: t,
5704
+ minimumWidth: n,
5705
+ padding: i,
5706
+ strokeWidth: a
5707
+ }) : Math.max(1, n);
5708
+ }
5709
+ _resolveShapeTextHorizontalAlign({ group: e, textStyle: t }) {
5710
+ var n;
5711
+ let r = t == null ? void 0 : t.align;
5712
+ return r === "left" || r === "center" || r === "right" ? r : (n = e.shapeAlignHorizontal) == null ? Ct : n;
5713
+ }
5538
5714
  _applyCurrentLayout({ group: e, shape: t, text: n, center: r, width: i, height: a, alignH: o, alignV: s }) {
5539
5715
  var c, l;
5540
- let u = this._resolveCurrentDimensions({ group: e }), d = Math.max(1, i == null ? u.width : i), f = Math.max(1, a == null ? u.height : a), p = this._resolveGroupPadding({ group: e }), m = e.getCenterPoint(), h = r == null ? {
5541
- x: m.x,
5542
- y: m.y
5716
+ let u = this._resolveCurrentDimensions({ group: e }), d = this._resolveManualDimensions({ group: e }), f = this._resolveGroupPadding({ group: e }), p = u.width;
5717
+ p = i === void 0 ? this._resolveShapeLayoutWidth({
5718
+ text: n,
5719
+ currentWidth: u.width,
5720
+ manualWidth: d.width,
5721
+ shapeTextAutoExpandEnabled: this._isShapeTextAutoExpandEnabled({ group: e }),
5722
+ padding: f,
5723
+ strokeWidth: e.shapeStrokeWidth
5724
+ }) : Math.max(1, i);
5725
+ let m = Math.max(1, a == null ? u.height : a), h = e.getCenterPoint(), g = r == null ? {
5726
+ x: h.x,
5727
+ y: h.y
5543
5728
  } : r;
5544
5729
  on({
5545
5730
  group: e,
5546
5731
  shape: t,
5547
5732
  text: n,
5548
- width: d,
5549
- height: f,
5733
+ width: p,
5734
+ height: m,
5550
5735
  alignH: (c = o == null ? e.shapeAlignHorizontal : o) == null ? Ct : c,
5551
5736
  alignV: (l = s == null ? e.shapeAlignVertical : s) == null ? wt : l,
5552
- padding: p
5737
+ padding: f
5553
5738
  }), e.set({
5554
- left: h.x,
5555
- top: h.y
5739
+ left: g.x,
5740
+ top: g.y
5556
5741
  }), e.setCoords();
5557
5742
  }
5743
+ _syncShapeTextLayoutAfterTextMutation({ textNode: e, textStyle: t }) {
5744
+ let { group: n } = e;
5745
+ if (!Y(n)) return !1;
5746
+ let { shape: r, text: i } = er({ group: n });
5747
+ if (!r || !i) return !1;
5748
+ this._detachShapeGroupAutoLayout({ group: n });
5749
+ let a = this._resolveEditingCenter({ group: n }), o = this._resolveManualDimensions({ group: n }), s = this._resolveShapeTextHorizontalAlign({
5750
+ group: n,
5751
+ textStyle: t
5752
+ });
5753
+ return this._applyCurrentLayout({
5754
+ group: n,
5755
+ shape: r,
5756
+ text: i,
5757
+ center: a,
5758
+ height: o.height,
5759
+ alignH: s
5760
+ }), !0;
5761
+ }
5558
5762
  _resolveEditingCenter({ group: e }) {
5559
5763
  let t = this.editingCenters.get(e);
5560
5764
  if (t) return t;
@@ -5565,7 +5769,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5565
5769
  };
5566
5770
  }
5567
5771
  _detachShapeGroupAutoLayout({ group: e }) {
5568
- jn({ group: e });
5772
+ Fn({ group: e });
5569
5773
  }
5570
5774
  _resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
5571
5775
  if (e) return e;
@@ -5576,11 +5780,11 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5576
5780
  var n, r, i, a;
5577
5781
  let { fill: o, stroke: s, strokeWidth: c, strokeDashArray: l, opacity: u } = e, d = l === void 0 ? t == null ? void 0 : t.shapeStrokeDashArray : l;
5578
5782
  return {
5579
- fill: (n = o == null ? t == null ? void 0 : t.shapeFill : o) == null ? pr : n,
5783
+ fill: (n = o == null ? t == null ? void 0 : t.shapeFill : o) == null ? _r : n,
5580
5784
  stroke: (r = s == null ? t == null ? void 0 : t.shapeStroke : s) == null ? null : r,
5581
- strokeWidth: (i = c == null ? t == null ? void 0 : t.shapeStrokeWidth : c) == null ? mr : i,
5785
+ strokeWidth: (i = c == null ? t == null ? void 0 : t.shapeStrokeWidth : c) == null ? vr : i,
5582
5786
  strokeDashArray: d == null ? null : d,
5583
- opacity: (a = u == null ? t == null ? void 0 : t.shapeOpacity : u) == null ? hr : a
5787
+ opacity: (a = u == null ? t == null ? void 0 : t.shapeOpacity : u) == null ? yr : a
5584
5788
  };
5585
5789
  }
5586
5790
  _findTextNode({ objects: e, fallback: t }) {
@@ -5623,7 +5827,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5623
5827
  }
5624
5828
  return null;
5625
5829
  }
5626
- }, _r = class {
5830
+ }, xr = class {
5627
5831
  constructor({ editor: e }) {
5628
5832
  this.editor = e, this.clipboard = null;
5629
5833
  }
@@ -5769,7 +5973,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5769
5973
  var n = this;
5770
5974
  return k(function* () {
5771
5975
  var r;
5772
- let i = H(H({ source: e }, t), {}, { fromClipboard: !0 }), a = yield n.editor.imageManager.importImage(i), o = a == null ? void 0 : a.image, s = (r = a == null ? void 0 : a.source) == null ? e : r;
5976
+ let i = U(U({ source: e }, t), {}, { fromClipboard: !0 }), a = yield n.editor.imageManager.importImage(i), o = a == null ? void 0 : a.image, s = (r = a == null ? void 0 : a.source) == null ? e : r;
5773
5977
  o && n.editor.canvas.fire("editor:object-pasted", {
5774
5978
  imageSource: s,
5775
5979
  fromInternalClipboard: !1,
@@ -5892,7 +6096,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5892
6096
  }
5893
6097
  })();
5894
6098
  }
5895
- }, vr = class t {
6099
+ }, Sr = class t {
5896
6100
  constructor({ editor: e }) {
5897
6101
  this.editor = e;
5898
6102
  }
@@ -5942,7 +6146,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5942
6146
  static _isGroupOrSelection(t) {
5943
6147
  return t instanceof e || t instanceof l;
5944
6148
  }
5945
- }, yr = class {
6149
+ }, Cr = class {
5946
6150
  constructor({ editor: e }) {
5947
6151
  this.editor = e;
5948
6152
  }
@@ -6008,7 +6212,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6008
6212
  i.resumeHistory(), n || i.saveState();
6009
6213
  }
6010
6214
  }
6011
- }, br = class t {
6215
+ }, wr = class t {
6012
6216
  constructor({ editor: e }) {
6013
6217
  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();
6014
6218
  }
@@ -6202,7 +6406,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6202
6406
  let { options: e } = this.editor, { selectionKey: t } = e;
6203
6407
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
6204
6408
  }
6205
- }, xr = class e {
6409
+ }, Tr = class e {
6206
6410
  constructor({ editor: e }) {
6207
6411
  this.editor = e;
6208
6412
  }
@@ -6241,7 +6445,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6241
6445
  };
6242
6446
  return i.fire("editor:objects-deleted", c), c;
6243
6447
  }
6244
- }, Sr = {
6448
+ }, Er = {
6245
6449
  IMAGE_MANAGER: {
6246
6450
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
6247
6451
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -6279,7 +6483,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6279
6483
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
6280
6484
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
6281
6485
  }
6282
- }, Cr = class e {
6486
+ }, Dr = class e {
6283
6487
  constructor({ editor: e }) {
6284
6488
  this._buffer = [], this.editor = e;
6285
6489
  }
@@ -6308,7 +6512,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6308
6512
  message: o,
6309
6513
  data: i
6310
6514
  };
6311
- this._buffer.push(H({ type: "editor:error" }, s)), this.editor.canvas.fire("editor:error", s);
6515
+ this._buffer.push(U({ type: "editor:error" }, s)), this.editor.canvas.fire("editor:error", s);
6312
6516
  }
6313
6517
  emitWarning({ origin: t = "ImageEditor", method: n = "Unknown Method", code: r, message: i, data: a }) {
6314
6518
  if (!e.isValidErrorCode(r)) {
@@ -6328,12 +6532,12 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6328
6532
  message: o,
6329
6533
  data: a
6330
6534
  };
6331
- this._buffer.push(H({ type: "editor:warning" }, s)), this.editor.canvas.fire("editor:warning", s);
6535
+ this._buffer.push(U({ type: "editor:warning" }, s)), this.editor.canvas.fire("editor:warning", s);
6332
6536
  }
6333
6537
  static isValidErrorCode(e) {
6334
- return e ? Object.values(Sr).some((t) => Object.values(t).includes(e)) : !1;
6538
+ return e ? Object.values(Er).some((t) => Object.values(t).includes(e)) : !1;
6335
6539
  }
6336
- }, wr = class {
6540
+ }, Or = class {
6337
6541
  constructor({ editor: e }) {
6338
6542
  this.currentBounds = null, this.editor = e;
6339
6543
  }
@@ -6383,7 +6587,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6383
6587
  updateBounds() {
6384
6588
  this.currentBounds = this.calculatePanBounds();
6385
6589
  }
6386
- }, Tr = ({ textbox: e }) => {
6590
+ }, kr = ({ textbox: e }) => {
6387
6591
  var t, n;
6388
6592
  if (!e.isEditing) return null;
6389
6593
  let r = (t = e.selectionStart) == null ? 0 : t, i = (n = e.selectionEnd) == null ? r : n;
@@ -6391,28 +6595,28 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6391
6595
  start: Math.min(r, i),
6392
6596
  end: Math.max(r, i)
6393
6597
  };
6394
- }, Er = ({ textbox: e }) => {
6598
+ }, Ar = ({ textbox: e }) => {
6395
6599
  var t, n;
6396
6600
  let r = (t = (n = e.text) == null ? void 0 : n.length) == null ? 0 : t;
6397
6601
  return r <= 0 ? null : {
6398
6602
  start: 0,
6399
6603
  end: r
6400
6604
  };
6401
- }, Dr = ({ textbox: e, range: t }) => {
6605
+ }, jr = ({ textbox: e, range: t }) => {
6402
6606
  var n, r;
6403
6607
  if (!t) return !1;
6404
6608
  let i = (n = (r = e.text) == null ? void 0 : r.length) == null ? 0 : n;
6405
6609
  return i <= 0 ? !1 : t.start <= 0 && t.end >= i;
6406
- }, Or = ({ textbox: e, styles: t, range: n }) => {
6610
+ }, Mr = ({ textbox: e, styles: t, range: n }) => {
6407
6611
  if (!t || !Object.keys(t).length) return !1;
6408
6612
  let { start: r, end: i } = n;
6409
6613
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
6410
- }, kr = ({ textbox: e, range: t, property: n }) => {
6614
+ }, Nr = ({ textbox: e, range: t, property: n }) => {
6411
6615
  var r;
6412
6616
  if (!t) return;
6413
6617
  let i = e.getSelectionStyles(t.start, t.end, !0);
6414
6618
  if (i.length) return (r = i[0]) == null ? void 0 : r[n];
6415
- }, Ar = ({ strokeColor: e, width: t }) => t <= 0 ? null : e == null ? "#000000" : e, jr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Mr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Nr, Pr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Fr = class e extends _ {
6619
+ }, Pr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e == null ? "#000000" : e, Fr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Ir = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Lr, Rr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), zr = class e extends _ {
6416
6620
  constructor(e, t = {}) {
6417
6621
  var n, r, i, a, o, s, c, l, u, d;
6418
6622
  super(e, t), this.backgroundOpacity = (n = t.backgroundOpacity) == null ? 1 : n, this.lineFontDefaults = (r = t.lineFontDefaults) == null ? void 0 : r, this.paddingTop = (i = t.paddingTop) == null ? 0 : i, this.paddingRight = (a = t.paddingRight) == null ? 0 : a, this.paddingBottom = (o = t.paddingBottom) == null ? 0 : o, this.paddingLeft = (s = t.paddingLeft) == null ? 0 : s, this.radiusTopLeft = (c = t.radiusTopLeft) == null ? 0 : c, this.radiusTopRight = (l = t.radiusTopRight) == null ? 0 : l, this.radiusBottomRight = (u = t.radiusBottomRight) == null ? 0 : u, this.radiusBottomLeft = (d = t.radiusBottomLeft) == null ? 0 : d, this._roundDimensions();
@@ -6434,13 +6638,13 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6434
6638
  }
6435
6639
  _getTransformedDimensions(e = {}) {
6436
6640
  let { width: t, height: n } = this._getBackgroundDimensions();
6437
- return super._getTransformedDimensions(H(H({}, e), {}, {
6641
+ return super._getTransformedDimensions(U(U({}, e), {}, {
6438
6642
  width: t,
6439
6643
  height: n
6440
6644
  }));
6441
6645
  }
6442
6646
  toObject(e = []) {
6443
- return H(H({}, super.toObject(e)), {}, {
6647
+ return U(U({}, super.toObject(e)), {}, {
6444
6648
  backgroundOpacity: this.backgroundOpacity,
6445
6649
  lineFontDefaults: this.lineFontDefaults,
6446
6650
  paddingTop: this.paddingTop,
@@ -6502,7 +6706,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6502
6706
  this._removeShadow(e);
6503
6707
  }
6504
6708
  _getDecorationColorAt(e, t) {
6505
- let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = jr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Ar({
6709
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Fr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Pr({
6506
6710
  strokeColor: i,
6507
6711
  width: r
6508
6712
  });
@@ -6522,22 +6726,22 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6522
6726
  var n, r, i, a;
6523
6727
  let o = e / 2, s = t / 2, c = Math.min(o, s);
6524
6728
  return {
6525
- bottomLeft: Pr({
6729
+ bottomLeft: Rr({
6526
6730
  value: (n = this.radiusBottomLeft) == null ? 0 : n,
6527
6731
  min: 0,
6528
6732
  max: c
6529
6733
  }),
6530
- bottomRight: Pr({
6734
+ bottomRight: Rr({
6531
6735
  value: (r = this.radiusBottomRight) == null ? 0 : r,
6532
6736
  min: 0,
6533
6737
  max: c
6534
6738
  }),
6535
- topLeft: Pr({
6739
+ topLeft: Rr({
6536
6740
  value: (i = this.radiusTopLeft) == null ? 0 : i,
6537
6741
  min: 0,
6538
6742
  max: c
6539
6743
  }),
6540
- topRight: Pr({
6744
+ topRight: Rr({
6541
6745
  value: (a = this.radiusTopRight) == null ? 0 : a,
6542
6746
  min: 0,
6543
6747
  max: c
@@ -6557,7 +6761,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6557
6761
  var e;
6558
6762
  let t = this.backgroundColor;
6559
6763
  if (!t) return null;
6560
- let r = Pr({
6764
+ let r = Rr({
6561
6765
  value: (e = this.backgroundOpacity) == null ? 1 : e,
6562
6766
  min: 0,
6563
6767
  max: 1
@@ -6565,7 +6769,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6565
6769
  try {
6566
6770
  i = new n(t);
6567
6771
  } catch (e) {
6568
- return Cr.emitError({
6772
+ return Dr.emitError({
6569
6773
  origin: "BackgroundTextbox",
6570
6774
  method: "_getEffectiveBackgroundFill",
6571
6775
  code: "INVALID_COLOR_VALUE",
@@ -6579,19 +6783,19 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6579
6783
  return i.setAlpha(r), i.toRgba();
6580
6784
  }
6581
6785
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
6582
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Pr({
6786
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Rr({
6583
6787
  value: c,
6584
6788
  min: 0,
6585
6789
  max: a
6586
- }), p = Pr({
6790
+ }), p = Rr({
6587
6791
  value: l,
6588
6792
  min: 0,
6589
6793
  max: a
6590
- }), m = Pr({
6794
+ }), m = Rr({
6591
6795
  value: u,
6592
6796
  min: 0,
6593
6797
  max: a
6594
- }), h = Pr({
6798
+ }), h = Rr({
6595
6799
  value: d,
6596
6800
  min: 0,
6597
6801
  max: a
@@ -6603,7 +6807,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6603
6807
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
6604
6808
  }
6605
6809
  };
6606
- Nr = Fr, Nr.type = "background-textbox", Nr.cacheProperties = [
6810
+ Lr = zr, Lr.type = "background-textbox", Lr.cacheProperties = [
6607
6811
  ...Array.isArray(_.cacheProperties) ? _.cacheProperties : [],
6608
6812
  "backgroundColor",
6609
6813
  "backgroundOpacity",
@@ -6616,7 +6820,7 @@ Nr = Fr, Nr.type = "background-textbox", Nr.cacheProperties = [
6616
6820
  "radiusTopRight",
6617
6821
  "radiusBottomRight",
6618
6822
  "radiusBottomLeft"
6619
- ], Nr.stateProperties = [
6823
+ ], Lr.stateProperties = [
6620
6824
  ...Array.isArray(_.stateProperties) ? _.stateProperties : [],
6621
6825
  "backgroundColor",
6622
6826
  "backgroundOpacity",
@@ -6630,9 +6834,9 @@ Nr = Fr, Nr.type = "background-textbox", Nr.cacheProperties = [
6630
6834
  "radiusBottomRight",
6631
6835
  "radiusBottomLeft"
6632
6836
  ];
6633
- var Ir = () => {
6634
- y != null && y.setClass && y.setClass(Fr, "background-textbox");
6635
- }, Lr = .01, Rr = ({ textbox: e, lineIndices: t, updates: n }) => {
6837
+ var Br = () => {
6838
+ y != null && y.setClass && y.setClass(zr, "background-textbox");
6839
+ }, Vr = .01, Hr = ({ textbox: e, lineIndices: t, updates: n }) => {
6636
6840
  if (!t.length) return !1;
6637
6841
  let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
6638
6842
  if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
@@ -6640,11 +6844,11 @@ var Ir = () => {
6640
6844
  for (let e = 0; e < t.length; e += 1) {
6641
6845
  let n = t[e];
6642
6846
  if (!Number.isFinite(n)) continue;
6643
- let d = u ? c[n] : s == null ? void 0 : s[n], f = d ? H({}, d) : {}, p = !1;
6644
- r !== void 0 && (d == null ? void 0 : d.fontFamily) !== r && (f.fontFamily = r, p = !0), i !== void 0 && (d == null ? void 0 : d.fontSize) !== i && (f.fontSize = i, p = !0), a !== void 0 && (d == null ? void 0 : d.fill) !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && (d == null ? void 0 : d.stroke) !== void 0 && (delete f.stroke, p = !0), o !== null && (d == null ? void 0 : d.stroke) !== o && (f.stroke = o, p = !0)), p && (u || (c = H({}, c), u = !0), c[n] = f, l = !0);
6847
+ let d = u ? c[n] : s == null ? void 0 : s[n], f = d ? U({}, d) : {}, p = !1;
6848
+ r !== void 0 && (d == null ? void 0 : d.fontFamily) !== r && (f.fontFamily = r, p = !0), i !== void 0 && (d == null ? void 0 : d.fontSize) !== i && (f.fontSize = i, p = !0), a !== void 0 && (d == null ? void 0 : d.fill) !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && (d == null ? void 0 : d.stroke) !== void 0 && (delete f.stroke, p = !0), o !== null && (d == null ? void 0 : d.stroke) !== o && (f.stroke = o, p = !0)), p && (u || (c = U({}, c), u = !0), c[n] = f, l = !0);
6645
6849
  }
6646
6850
  return l && (e.lineFontDefaults = c), l;
6647
- }, zr = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
6851
+ }, Ur = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
6648
6852
  let r = e.length;
6649
6853
  if (r === 0) return {
6650
6854
  lineStyles: t,
@@ -6661,23 +6865,23 @@ var Ir = () => {
6661
6865
  if (t) for (let e in t) {
6662
6866
  if (!Object.prototype.hasOwnProperty.call(t, e)) continue;
6663
6867
  let n = Number(e);
6664
- Number.isInteger(n) && n >= 0 && n < r || (d || (l = H({}, t), d = !0), l && Object.prototype.hasOwnProperty.call(l, e) && delete l[e], u = !0);
6868
+ Number.isInteger(n) && n >= 0 && n < r || (d || (l = U({}, t), d = !0), l && Object.prototype.hasOwnProperty.call(l, e) && delete l[e], u = !0);
6665
6869
  }
6666
6870
  for (let e = 0; e < r; e += 1) {
6667
6871
  var f;
6668
6872
  let n = (f = l) == null ? t : f, r = n ? n[e] : void 0;
6669
6873
  if (!r) {
6670
- l || (l = {}, d = !0), d || (l = H({}, l), d = !0), l[e] = H({}, c), u = !0;
6874
+ l || (l = {}, d = !0), d || (l = U({}, l), d = !0), l[e] = U({}, c), u = !0;
6671
6875
  continue;
6672
6876
  }
6673
6877
  let p = null;
6674
- i !== void 0 && r.fontFamily === void 0 && (p = H({}, r), p.fontFamily = i), a !== void 0 && r.fontSize === void 0 && (p || (p = H({}, r)), p.fontSize = a), o !== void 0 && r.fill === void 0 && (p || (p = H({}, r)), p.fill = o), s !== void 0 && r.stroke === void 0 && (p || (p = H({}, r)), p.stroke = s), p && (l || (l = {}, d = !0), d || (l = H({}, l), d = !0), l[e] = p, u = !0);
6878
+ i !== void 0 && r.fontFamily === void 0 && (p = U({}, r), p.fontFamily = i), a !== void 0 && r.fontSize === void 0 && (p || (p = U({}, r)), p.fontSize = a), o !== void 0 && r.fill === void 0 && (p || (p = U({}, r)), p.fill = o), s !== void 0 && r.stroke === void 0 && (p || (p = U({}, r)), p.stroke = s), p && (l || (l = {}, d = !0), d || (l = U({}, l), d = !0), l[e] = p, u = !0);
6675
6879
  }
6676
6880
  return {
6677
6881
  lineStyles: l,
6678
6882
  changed: u
6679
6883
  };
6680
- }, Br = ({ lineFontDefaults: e }) => {
6884
+ }, Wr = ({ lineFontDefaults: e }) => {
6681
6885
  if (!e) return;
6682
6886
  let t = {};
6683
6887
  for (let n in e) {
@@ -6685,10 +6889,10 @@ var Ir = () => {
6685
6889
  let r = Number(n);
6686
6890
  if (!Number.isFinite(r)) continue;
6687
6891
  let i = e[r];
6688
- i && (t[r] = H({}, i));
6892
+ i && (t[r] = U({}, i));
6689
6893
  }
6690
6894
  return t;
6691
- }, Vr = ({ lineFontDefaults: e, scale: t }) => {
6895
+ }, Gr = ({ lineFontDefaults: e, scale: t }) => {
6692
6896
  if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
6693
6897
  let n = {}, r = !1, i = !1;
6694
6898
  for (let a in e) {
@@ -6697,11 +6901,11 @@ var Ir = () => {
6697
6901
  if (!Number.isFinite(o)) continue;
6698
6902
  let s = e[o];
6699
6903
  if (!s) continue;
6700
- let c = H({}, s);
6904
+ let c = U({}, s);
6701
6905
  typeof s.fontSize == "number" && (c.fontSize = Math.max(1, s.fontSize * t), i = !0), n[o] = c, r = !0;
6702
6906
  }
6703
6907
  if (!(!r || !i)) return n;
6704
- }, Hr = ({ textbox: e }) => {
6908
+ }, Kr = ({ textbox: e }) => {
6705
6909
  var t;
6706
6910
  let n = (t = e.text) == null ? "" : t;
6707
6911
  if (!n.length) return [];
@@ -6715,7 +6919,7 @@ var Ir = () => {
6715
6919
  });
6716
6920
  }
6717
6921
  return i;
6718
- }, Ur = ({ range: e, text: t }) => {
6922
+ }, qr = ({ range: e, text: t }) => {
6719
6923
  if (!e) return null;
6720
6924
  let n = t.length;
6721
6925
  if (n <= 0) return null;
@@ -6724,8 +6928,8 @@ var Ir = () => {
6724
6928
  start: l,
6725
6929
  end: u
6726
6930
  };
6727
- }, Wr = ({ textbox: e, range: t }) => {
6728
- let n = Hr({ textbox: e });
6931
+ }, Jr = ({ textbox: e, range: t }) => {
6932
+ let n = Kr({ textbox: e });
6729
6933
  if (!n.length) return t;
6730
6934
  let { start: r } = t, { end: i } = t;
6731
6935
  for (let e = 0; e < n.length; e += 1) {
@@ -6738,7 +6942,7 @@ var Ir = () => {
6738
6942
  start: r,
6739
6943
  end: i
6740
6944
  };
6741
- }, Gr = ({ textbox: e, range: t }) => {
6945
+ }, Yr = ({ textbox: e, range: t }) => {
6742
6946
  var n;
6743
6947
  let r = (n = e.text) == null ? "" : n;
6744
6948
  if (!r.length) return [];
@@ -6749,7 +6953,7 @@ var Ir = () => {
6749
6953
  a > n && i < r && s.push(e), c = r + 1;
6750
6954
  }
6751
6955
  return s;
6752
- }, Kr = ({ textbox: e, range: t }) => {
6956
+ }, Xr = ({ textbox: e, range: t }) => {
6753
6957
  var n;
6754
6958
  let r = (n = e.text) == null ? "" : n;
6755
6959
  if (!r.length) return [];
@@ -6760,34 +6964,34 @@ var Ir = () => {
6760
6964
  i <= n && a >= r && s.push(e), c = r + 1;
6761
6965
  }
6762
6966
  return s;
6763
- }, qr = ({ previous: e, next: t }) => {
6967
+ }, Zr = ({ previous: e, next: t }) => {
6764
6968
  let n = Math.min(e.length, t.length);
6765
6969
  for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
6766
6970
  return n;
6767
- }, Jr = ({ text: e, charIndex: t }) => {
6971
+ }, Qr = ({ text: e, charIndex: t }) => {
6768
6972
  let n = Math.max(0, Math.min(t, e.length)), r = 0;
6769
6973
  for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
6770
6974
  return r;
6771
- }, Yr = ({ text: e, lineIndex: t }) => {
6975
+ }, $r = ({ text: e, lineIndex: t }) => {
6772
6976
  if (t <= 0) return 0;
6773
6977
  let n = 0;
6774
6978
  for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
6775
6979
  return e.length;
6776
- }, Xr = ({ textbox: e, text: t }) => {
6980
+ }, ei = ({ textbox: e, text: t }) => {
6777
6981
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
6778
6982
  for (let t = 0; t < r; t += 1) {
6779
6983
  let n = e.getLineWidth(t);
6780
6984
  n > i && (i = n);
6781
6985
  }
6782
6986
  return i;
6783
- }, Zr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
6987
+ }, ti = ({ textbox: e, montageLeft: t, montageRight: n }) => {
6784
6988
  var r, i, a, o;
6785
6989
  e.setCoords();
6786
6990
  let s = e.getBoundingRect(!1, !0), c = (r = s.left) == null ? 0 : r, l = c + ((i = s.width) == null ? 0 : i), u = n - t;
6787
6991
  if (u > 0 && ((a = s.width) == null ? 0 : a) >= u - .01) return !1;
6788
6992
  let d = 0;
6789
6993
  return c < t ? d = t - c : l > n && (d = n - l), Math.abs(d) <= .01 ? !1 : (e.set({ left: ((o = e.left) == null ? 0 : o) + d }), !0);
6790
- }, Qr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, $r = ({ stylesList: e }) => {
6994
+ }, ni = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, ri = ({ stylesList: e }) => {
6791
6995
  let t = e.length;
6792
6996
  if (!t) return !1;
6793
6997
  for (let n = 0; n < t; n += 1) {
@@ -6797,16 +7001,16 @@ var Ir = () => {
6797
7001
  if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
6798
7002
  }
6799
7003
  return !1;
6800
- }, ei = ({ textbox: e }) => {
6801
- 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 = Qr({
7004
+ }, ii = ({ textbox: e }) => {
7005
+ 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 = ni({
6802
7006
  rawValue: t,
6803
7007
  calculatedValue: a
6804
- }), c = Qr({
7008
+ }), c = ni({
6805
7009
  rawValue: n,
6806
7010
  calculatedValue: o
6807
7011
  }), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
6808
7012
  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;
6809
- }, ti = [
7013
+ }, ai = [
6810
7014
  "id",
6811
7015
  "text",
6812
7016
  "autoExpand",
@@ -6832,7 +7036,7 @@ var Ir = () => {
6832
7036
  "radiusTopRight",
6833
7037
  "radiusBottomRight",
6834
7038
  "radiusBottomLeft"
6835
- ], ni = [
7039
+ ], oi = [
6836
7040
  "text",
6837
7041
  "autoExpand",
6838
7042
  "fontFamily",
@@ -6857,7 +7061,7 @@ var Ir = () => {
6857
7061
  "radiusTopRight",
6858
7062
  "radiusBottomRight",
6859
7063
  "radiusBottomLeft"
6860
- ], ri = class t {
7064
+ ], si = class t {
6861
7065
  constructor({ editor: n }) {
6862
7066
  var r;
6863
7067
  this._handleTextEditingEntered = (e) => {
@@ -6878,14 +7082,14 @@ var Ir = () => {
6878
7082
  if (!t._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
6879
7083
  let { text: r = "", uppercase: i, autoExpand: a } = n, o = !!i, s = a !== !1, c = r.toLocaleLowerCase();
6880
7084
  if (o) {
6881
- let e = Mr({ value: c });
7085
+ let e = Ir({ value: c });
6882
7086
  e !== r && n.set({ text: e }), n.textCaseRaw = c;
6883
7087
  } else n.textCaseRaw = r;
6884
7088
  a === void 0 && (n.autoExpand = !0);
6885
7089
  let l = !1;
6886
7090
  s && (l = this._autoExpandTextboxWidth(n));
6887
7091
  let u = !1;
6888
- l || (u = ei({ textbox: n })), (l || u) && (n.setCoords(), n.dirty = !0), this._syncLineFontDefaultsOnTextChanged({ textbox: n });
7092
+ l || (u = ii({ textbox: n })), (l || u) && (n.setCoords(), n.dirty = !0), this._syncLineFontDefaultsOnTextChanged({ textbox: n });
6889
7093
  }, this._handleTextEditingExited = (e) => {
6890
7094
  var n, r;
6891
7095
  let { target: i } = e;
@@ -6896,7 +7100,7 @@ var Ir = () => {
6896
7100
  var o;
6897
7101
  i.textCaseRaw = (o = i.textCaseRaw) == null ? a.toLocaleLowerCase() : o;
6898
7102
  } else i.textCaseRaw = a;
6899
- ei({ textbox: i }) && (i.setCoords(), i.dirty = !0, this.canvas.requestRenderAll()), i.locked || i.set({
7103
+ ii({ textbox: i }) && (i.setCoords(), i.dirty = !0, this.canvas.requestRenderAll()), i.locked || i.set({
6900
7104
  lockMovementX: !1,
6901
7105
  lockMovementY: !1
6902
7106
  });
@@ -6928,42 +7132,42 @@ var Ir = () => {
6928
7132
  let { target: g, transform: _ } = n;
6929
7133
  if (g instanceof e || !t._isTextbox(g) || !_) return;
6930
7134
  g.isScaling = !0;
6931
- let v = this._ensureScalingState(g), { baseWidth: y, baseLeft: b, baseFontSize: x, basePadding: S, baseRadii: C, baseStyles: w, baseLineFontDefaults: T } = v, E = typeof ((r = _.original) == null ? void 0 : r.width) == "number" ? _.original.width : void 0, D = typeof ((i = _.original) == null ? void 0 : i.left) == "number" ? _.original.left : void 0, O = E == null ? y : E, k = D == null ? b : D, A = (a = _.corner) == null ? "" : a, j = (o = _.action) == null ? "" : o, M = ["ml", "mr"].includes(A) || j === "scaleX", N = ["mt", "mb"].includes(A) || j === "scaleY", P = [
7135
+ let v = this._ensureScalingState(g), { baseWidth: y, baseLeft: b, baseFontSize: x, basePadding: S, baseRadii: C, baseStyles: w, baseLineFontDefaults: T } = v, E = typeof ((r = _.original) == null ? void 0 : r.width) == "number" ? _.original.width : void 0, D = typeof ((i = _.original) == null ? void 0 : i.left) == "number" ? _.original.left : void 0, O = E == null ? y : E, k = D == null ? b : D, A = (a = _.corner) == null ? "" : a, j = (o = _.action) == null ? "" : o, M = ["ml", "mr"].includes(A) || j === "scaleX", N = ["mt", "mb"].includes(A) || j === "scaleY", ee = [
6932
7136
  "tl",
6933
7137
  "tr",
6934
7138
  "bl",
6935
7139
  "br"
6936
- ].includes(A) || j === "scale", F = P || N;
6937
- if (!M && !N && !P) return;
6938
- let ee = Math.abs((s = (c = g.scaleX) == null ? _.scaleX : c) == null ? 1 : s) || 1, I = Math.abs((l = (u = g.scaleY) == null ? _.scaleY : u) == null ? 1 : l) || 1, L = Math.max(1, O * ee), te = Math.max(1, Math.round(L)), R = Math.max(1, x * I), { paddingTop: z = 0, paddingRight: ne = 0, paddingBottom: re = 0, paddingLeft: ie = 0, radiusTopLeft: B = 0, radiusTopRight: ae = 0, radiusBottomRight: oe = 0, radiusBottomLeft: se = 0, fontSize: V, width: ce, originX: le = "left" } = g, ue = P || N, de = P || N, U = ue ? {
7140
+ ].includes(A) || j === "scale", P = ee || N;
7141
+ if (!M && !N && !ee) return;
7142
+ let F = Math.abs((s = (c = g.scaleX) == null ? _.scaleX : c) == null ? 1 : s) || 1, I = Math.abs((l = (u = g.scaleY) == null ? _.scaleY : u) == null ? 1 : l) || 1, L = Math.max(1, O * F), te = Math.max(1, Math.round(L)), R = Math.max(1, x * I), { paddingTop: z = 0, paddingRight: ne = 0, paddingBottom: B = 0, paddingLeft: re = 0, radiusTopLeft: V = 0, radiusTopRight: ie = 0, radiusBottomRight: ae = 0, radiusBottomLeft: oe = 0, fontSize: H, width: se, originX: ce = "left" } = g, le = ee || N, ue = ee || N, W = le ? {
6939
7143
  top: Math.max(0, S.top * I),
6940
7144
  right: Math.max(0, S.right * I),
6941
7145
  bottom: Math.max(0, S.bottom * I),
6942
7146
  left: Math.max(0, S.left * I)
6943
- } : S, W = de ? {
7147
+ } : S, de = ue ? {
6944
7148
  topLeft: Math.max(0, C.topLeft * I),
6945
7149
  topRight: Math.max(0, C.topRight * I),
6946
7150
  bottomRight: Math.max(0, C.bottomRight * I),
6947
7151
  bottomLeft: Math.max(0, C.bottomLeft * I)
6948
7152
  } : C, fe = Object.keys(w).length > 0, pe;
6949
- if (F && fe) {
7153
+ if (P && fe) {
6950
7154
  let e = {};
6951
7155
  Object.entries(w).forEach(([t, n]) => {
6952
7156
  if (!n) return;
6953
7157
  let r = {};
6954
7158
  Object.entries(n).forEach(([e, t]) => {
6955
7159
  if (!t) return;
6956
- let n = H({}, t);
7160
+ let n = U({}, t);
6957
7161
  typeof t.fontSize == "number" && (n.fontSize = Math.max(1, t.fontSize * I)), r[e] = n;
6958
7162
  }), Object.keys(r).length && (e[t] = r);
6959
7163
  }), Object.keys(e).length && (pe = e);
6960
7164
  }
6961
7165
  let me;
6962
- F && (me = Vr({
7166
+ P && (me = Gr({
6963
7167
  lineFontDefaults: T,
6964
7168
  scale: I
6965
7169
  }));
6966
- let he = (d = (f = _.originX) == null ? le : f) == null ? "left" : d, ge = k + O, _e = k + O / 2, ve = ce == null ? O : ce, ye = te !== ve, be = Math.abs(R - (V == null ? x : V)) > Lr, xe = Math.abs(U.top - z) > .01 || Math.abs(U.right - ne) > .01 || Math.abs(U.bottom - re) > .01 || Math.abs(U.left - ie) > .01, Se = Math.abs(W.topLeft - B) > .01 || Math.abs(W.topRight - ae) > .01 || Math.abs(W.bottomRight - oe) > .01 || Math.abs(W.bottomLeft - se) > .01;
7170
+ let he = (d = (f = _.originX) == null ? ce : f) == null ? "left" : d, ge = k + O, _e = k + O / 2, ve = se == null ? O : se, ye = te !== ve, be = Math.abs(R - (H == null ? x : H)) > Vr, xe = Math.abs(W.top - z) > .01 || Math.abs(W.right - ne) > .01 || Math.abs(W.bottom - B) > .01 || Math.abs(W.left - re) > .01, Se = Math.abs(de.topLeft - V) > .01 || Math.abs(de.topRight - ie) > .01 || Math.abs(de.bottomRight - ae) > .01 || Math.abs(de.bottomLeft - oe) > .01;
6967
7171
  if (!ye && !be && !xe && !Se) {
6968
7172
  g.set({
6969
7173
  scaleX: 1,
@@ -6973,33 +7177,33 @@ var Ir = () => {
6973
7177
  }
6974
7178
  pe && (g.styles = pe), me && (g.lineFontDefaults = me), g.set({
6975
7179
  width: te,
6976
- fontSize: F ? R : x,
6977
- paddingTop: U.top,
6978
- paddingRight: U.right,
6979
- paddingBottom: U.bottom,
6980
- paddingLeft: U.left,
6981
- radiusTopLeft: W.topLeft,
6982
- radiusTopRight: W.topRight,
6983
- radiusBottomRight: W.bottomRight,
6984
- radiusBottomLeft: W.bottomLeft,
7180
+ fontSize: P ? R : x,
7181
+ paddingTop: W.top,
7182
+ paddingRight: W.right,
7183
+ paddingBottom: W.bottom,
7184
+ paddingLeft: W.left,
7185
+ radiusTopLeft: de.topLeft,
7186
+ radiusTopRight: de.topRight,
7187
+ radiusBottomRight: de.bottomRight,
7188
+ radiusBottomLeft: de.bottomLeft,
6985
7189
  scaleX: 1,
6986
7190
  scaleY: 1
6987
7191
  });
6988
- let Ce = ei({ textbox: g });
7192
+ let Ce = ii({ textbox: g });
6989
7193
  Ce && (g.dirty = !0);
6990
7194
  let we = (p = g.width) == null ? te : p, Te = we !== ve, Ee = k;
6991
- Te && (M || P) && (he === "right" ? Ee = ge - we : he === "center" && (Ee = _e - we / 2)), g.set({ left: Ee }), v.baseLeft = Ee, _.scaleX = 1, _.scaleY = 1;
7195
+ Te && (M || ee) && (he === "right" ? Ee = ge - we : he === "center" && (Ee = _e - we / 2)), g.set({ left: Ee }), v.baseLeft = Ee, _.scaleX = 1, _.scaleY = 1;
6992
7196
  let { original: De } = _;
6993
- De && (De.scaleX = 1, De.scaleY = 1, De.width = we, De.height = g.height, De.left = Ee), g.setCoords(), this.canvas.requestRenderAll(), v.baseWidth = we, v.baseFontSize = (m = g.fontSize) == null ? R : m, v.baseStyles = JSON.parse(JSON.stringify((h = g.styles) == null ? {} : h)), v.baseLineFontDefaults = Br({ lineFontDefaults: g.lineFontDefaults }), v.basePadding = {
6994
- top: U.top,
6995
- right: U.right,
6996
- bottom: U.bottom,
6997
- left: U.left
7197
+ De && (De.scaleX = 1, De.scaleY = 1, De.width = we, De.height = g.height, De.left = Ee), g.setCoords(), this.canvas.requestRenderAll(), v.baseWidth = we, v.baseFontSize = (m = g.fontSize) == null ? R : m, v.baseStyles = JSON.parse(JSON.stringify((h = g.styles) == null ? {} : h)), v.baseLineFontDefaults = Wr({ lineFontDefaults: g.lineFontDefaults }), v.basePadding = {
7198
+ top: W.top,
7199
+ right: W.right,
7200
+ bottom: W.bottom,
7201
+ left: W.left
6998
7202
  }, v.baseRadii = {
6999
- topLeft: W.topLeft,
7000
- topRight: W.topRight,
7001
- bottomRight: W.bottomRight,
7002
- bottomLeft: W.bottomLeft
7203
+ topLeft: de.topLeft,
7204
+ topRight: de.topRight,
7205
+ bottomRight: de.bottomRight,
7206
+ bottomLeft: de.bottomLeft
7003
7207
  }, v.hasWidthChange = Te || be || xe || Se || Ce;
7004
7208
  }, this._handleObjectModified = (n) => {
7005
7209
  var r, i, a;
@@ -7028,16 +7232,16 @@ var Ir = () => {
7028
7232
  typeof e.fontSize == "number" && (e.fontSize = Math.max(1, e.fontSize * l));
7029
7233
  });
7030
7234
  }));
7031
- let S = Vr({
7235
+ let S = Gr({
7032
7236
  lineFontDefaults: e.lineFontDefaults,
7033
7237
  scale: l
7034
- }), C = H(H(H({
7238
+ }), C = U(U(U({
7035
7239
  fontSize: s,
7036
7240
  width: c,
7037
7241
  scaleX: 1,
7038
7242
  scaleY: 1
7039
7243
  }, y), b), {}, { styles: x });
7040
- S && (C.lineFontDefaults = S), e.set(C), ei({ textbox: e });
7244
+ S && (C.lineFontDefaults = S), e.set(C), ii({ textbox: e });
7041
7245
  }
7042
7246
  e.setCoords();
7043
7247
  });
@@ -7067,18 +7271,18 @@ var Ir = () => {
7067
7271
  scaleX: 1,
7068
7272
  scaleY: 1
7069
7273
  }), o.setCoords();
7070
- }, this.editor = n, this.canvas = n.canvas, this.fonts = (r = n.options.fonts) == null ? [] : r, this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Ir();
7274
+ }, this.editor = n, this.canvas = n.canvas, this.fonts = (r = n.options.fonts) == null ? [] : r, this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Br();
7071
7275
  }
7072
7276
  addText(e = {}, { withoutSelection: t = !1, withoutSave: n = !1, withoutAdding: r = !1 } = {}) {
7073
7277
  var i;
7074
- let { id: a = `text-${D()}`, text: o = "Новый текст", autoExpand: s = !0, fontFamily: c, fontSize: l = 48, bold: u = !1, italic: d = !1, underline: f = !1, uppercase: p = !1, strikethrough: m = !1, align: h = "left", color: g = "#000000", strokeColor: _, strokeWidth: v = 0, opacity: y = 1, backgroundColor: b, backgroundOpacity: x = 1, paddingTop: S = 0, paddingRight: C = 0, paddingBottom: w = 0, paddingLeft: T = 0, radiusTopLeft: E = 0, radiusTopRight: O = 0, radiusBottomRight: k = 0, radiusBottomLeft: A = 0 } = e, j = ut(e, ti), { historyManager: M } = this.editor, { canvas: N } = this;
7278
+ let { id: a = `text-${D()}`, text: o = "Новый текст", autoExpand: s = !0, fontFamily: c, fontSize: l = 48, bold: u = !1, italic: d = !1, underline: f = !1, uppercase: p = !1, strikethrough: m = !1, align: h = "left", color: g = "#000000", strokeColor: _, strokeWidth: v = 0, opacity: y = 1, backgroundColor: b, backgroundOpacity: x = 1, paddingTop: S = 0, paddingRight: C = 0, paddingBottom: w = 0, paddingLeft: T = 0, radiusTopLeft: E = 0, radiusTopRight: O = 0, radiusBottomRight: k = 0, radiusBottomLeft: A = 0 } = e, j = ut(e, ai), { historyManager: M } = this.editor, { canvas: N } = this;
7075
7279
  M.suspendHistory();
7076
- let P = c == null ? this._getDefaultFontFamily() : c, F = jr({ width: v }), ee = Ar({
7280
+ let ee = c == null ? this._getDefaultFontFamily() : c, P = Fr({ width: v }), F = Pr({
7077
7281
  strokeColor: _,
7078
- width: F
7079
- }), I = H({
7282
+ width: P
7283
+ }), I = U({
7080
7284
  id: a,
7081
- fontFamily: P,
7285
+ fontFamily: ee,
7082
7286
  fontSize: l,
7083
7287
  fontWeight: u ? "bold" : "normal",
7084
7288
  fontStyle: d ? "italic" : "normal",
@@ -7087,8 +7291,8 @@ var Ir = () => {
7087
7291
  linethrough: m,
7088
7292
  textAlign: h,
7089
7293
  fill: g,
7090
- stroke: ee,
7091
- strokeWidth: F,
7294
+ stroke: F,
7295
+ strokeWidth: P,
7092
7296
  strokeUniform: !0,
7093
7297
  opacity: y,
7094
7298
  backgroundColor: b,
@@ -7101,22 +7305,22 @@ var Ir = () => {
7101
7305
  radiusTopRight: O,
7102
7306
  radiusBottomRight: k,
7103
7307
  radiusBottomLeft: A
7104
- }, j), L = new Fr(o, I);
7308
+ }, j), L = new zr(o, I);
7105
7309
  if (L.autoExpand = s !== !1, L.textCaseRaw = (i = L.text) == null ? "" : i, p) {
7106
- let e = Mr({ value: L.textCaseRaw });
7310
+ let e = Ir({ value: L.textCaseRaw });
7107
7311
  e !== L.text && L.set({ text: e });
7108
7312
  }
7109
- return ei({ textbox: L }) && (L.dirty = !0), j.left === void 0 && j.top === void 0 && N.centerObject(L), r || N.add(L), t || N.setActiveObject(L), N.requestRenderAll(), M.resumeHistory(), n || M.saveState(), N.fire("editor:text-added", {
7313
+ return ii({ textbox: L }) && (L.dirty = !0), j.left === void 0 && j.top === void 0 && N.centerObject(L), r || N.add(L), t || N.setActiveObject(L), N.requestRenderAll(), M.resumeHistory(), n || M.saveState(), N.fire("editor:text-added", {
7110
7314
  textbox: L,
7111
- options: H(H({}, I), {}, {
7315
+ options: U(U({}, I), {}, {
7112
7316
  text: o,
7113
7317
  bold: u,
7114
7318
  italic: d,
7115
7319
  strikethrough: m,
7116
7320
  align: h,
7117
7321
  color: g,
7118
- strokeColor: ee,
7119
- strokeWidth: F
7322
+ strokeColor: F,
7323
+ strokeWidth: P
7120
7324
  }),
7121
7325
  flags: {
7122
7326
  withoutSelection: !!t,
@@ -7135,115 +7339,120 @@ var Ir = () => {
7135
7339
  originY: p,
7136
7340
  x: m.x,
7137
7341
  y: m.y
7138
- }, { text: g, autoExpand: _, fontFamily: v, fontSize: y, bold: b, italic: x, underline: S, uppercase: C, strikethrough: w, align: T, color: E, strokeColor: D, strokeWidth: O, opacity: k, backgroundColor: A, backgroundOpacity: j, paddingTop: M, paddingRight: N, paddingBottom: P, paddingLeft: F, radiusTopLeft: ee, radiusTopRight: I, radiusBottomRight: L, radiusBottomLeft: te } = n, R = H({}, ut(n, ni)), z = a === void 0 ? Tr({ textbox: c }) : Ur({
7342
+ }, { text: g, autoExpand: _, fontFamily: v, fontSize: y, bold: b, italic: x, underline: S, uppercase: C, strikethrough: w, align: T, color: E, strokeColor: D, strokeWidth: O, opacity: k, backgroundColor: A, backgroundOpacity: j, paddingTop: M, paddingRight: N, paddingBottom: ee, paddingLeft: P, radiusTopLeft: F, radiusTopRight: I, radiusBottomRight: L, radiusBottomLeft: te } = n, R = U({}, ut(n, oi)), z = a === void 0 ? kr({ textbox: c }) : qr({
7139
7343
  text: l,
7140
7344
  range: a
7141
- }), ne = z ? Wr({
7345
+ }), ne = z ? Jr({
7142
7346
  textbox: c,
7143
7347
  range: z
7144
- }) : null, re = {}, ie = {}, B = {}, ae, oe, se = Dr({
7348
+ }) : null, B = {}, re = {}, V = {}, ie, ae, oe = jr({
7145
7349
  textbox: c,
7146
7350
  range: z
7147
- }), V = !z || se, ce = !z;
7148
- if (v !== void 0 && (ne && (ie.fontFamily = v), V && (R.fontFamily = v, ce && (B.fontFamily = v))), y !== void 0 && (ne && (ie.fontSize = y), V && (R.fontSize = y, ce && (B.fontSize = y))), b !== void 0) {
7351
+ }), H = !z || oe, se = !z;
7352
+ if (v !== void 0 && (ne && (re.fontFamily = v), H && (R.fontFamily = v, se && (V.fontFamily = v))), y !== void 0 && (ne && (re.fontSize = y), H && (R.fontSize = y, se && (V.fontSize = y))), b !== void 0) {
7149
7353
  let e = b ? "bold" : "normal";
7150
- z && (re.fontWeight = e), V && (R.fontWeight = e, ce && (B.fontWeight = e));
7354
+ z && (B.fontWeight = e), H && (R.fontWeight = e, se && (V.fontWeight = e));
7151
7355
  }
7152
7356
  if (x !== void 0) {
7153
7357
  let e = x ? "italic" : "normal";
7154
- z && (re.fontStyle = e), V && (R.fontStyle = e, ce && (B.fontStyle = e));
7358
+ z && (B.fontStyle = e), H && (R.fontStyle = e, se && (V.fontStyle = e));
7155
7359
  }
7156
- if (S !== void 0 && (z && (re.underline = S), V && (R.underline = S, ce && (B.underline = S))), w !== void 0 && (z && (re.linethrough = w), V && (R.linethrough = w, ce && (B.linethrough = w))), T !== void 0 && (R.textAlign = T), E !== void 0 && (z && (re.fill = E), V && (R.fill = E, ce && (B.fill = E))), D !== void 0 || O !== void 0) {
7157
- var le, ue, de, U;
7158
- let e = z ? kr({
7360
+ if (S !== void 0 && (z && (B.underline = S), H && (R.underline = S, se && (V.underline = S))), w !== void 0 && (z && (B.linethrough = w), H && (R.linethrough = w, se && (V.linethrough = w))), T !== void 0 && (R.textAlign = T), E !== void 0 && (z && (B.fill = E), H && (R.fill = E, se && (V.fill = E))), D !== void 0 || O !== void 0) {
7361
+ var ce, le, ue, W;
7362
+ let e = z ? Nr({
7159
7363
  textbox: c,
7160
7364
  range: z,
7161
7365
  property: "strokeWidth"
7162
- }) : void 0, t = z ? kr({
7366
+ }) : void 0, t = z ? Nr({
7163
7367
  textbox: c,
7164
7368
  range: z,
7165
7369
  property: "stroke"
7166
7370
  }) : void 0;
7167
- oe = jr({ width: (le = (ue = O == null ? e : O) == null ? c.strokeWidth : ue) == null ? 0 : le }), ae = Ar({
7168
- strokeColor: (de = (U = D == null ? t : D) == null ? c.stroke : U) == null ? void 0 : de,
7169
- width: oe
7170
- }), z && (re.stroke = ae, re.strokeWidth = oe), V && (R.stroke = ae, R.strokeWidth = oe, ce && (B.stroke = ae, B.strokeWidth = oe));
7171
- }
7172
- k !== void 0 && (R.opacity = k), A !== void 0 && (R.backgroundColor = A), j !== void 0 && (R.backgroundOpacity = j), M !== void 0 && (R.paddingTop = M), N !== void 0 && (R.paddingRight = N), P !== void 0 && (R.paddingBottom = P), F !== void 0 && (R.paddingLeft = F), ee !== void 0 && (R.radiusTopLeft = ee), I !== void 0 && (R.radiusTopRight = I), L !== void 0 && (R.radiusBottomRight = L), te !== void 0 && (R.radiusBottomLeft = te);
7173
- let W = (s = c.textCaseRaw) == null ? l : s, fe = !!c.uppercase, pe = g !== void 0, me = pe ? g == null ? "" : g : W, he = C == null ? fe : C, ge = he !== fe;
7174
- pe || ge ? (R.text = he ? Mr({ value: me }) : me, c.textCaseRaw = me) : c.textCaseRaw === void 0 && (c.textCaseRaw = W), c.uppercase = he, c.set(R);
7371
+ ae = Fr({ width: (ce = (le = O == null ? e : O) == null ? c.strokeWidth : le) == null ? 0 : ce }), ie = Pr({
7372
+ strokeColor: (ue = (W = D == null ? t : D) == null ? c.stroke : W) == null ? void 0 : ue,
7373
+ width: ae
7374
+ }), z && (B.stroke = ie, B.strokeWidth = ae), H && (R.stroke = ie, R.strokeWidth = ae, se && (V.stroke = ie, V.strokeWidth = ae));
7375
+ }
7376
+ k !== void 0 && (R.opacity = k), A !== void 0 && (R.backgroundColor = A), j !== void 0 && (R.backgroundOpacity = j), M !== void 0 && (R.paddingTop = M), N !== void 0 && (R.paddingRight = N), ee !== void 0 && (R.paddingBottom = ee), P !== void 0 && (R.paddingLeft = P), F !== void 0 && (R.radiusTopLeft = F), I !== void 0 && (R.radiusTopRight = I), L !== void 0 && (R.radiusBottomRight = L), te !== void 0 && (R.radiusBottomLeft = te);
7377
+ let de = (s = c.textCaseRaw) == null ? l : s, fe = !!c.uppercase, pe = g !== void 0, me = pe ? g == null ? "" : g : de, he = C == null ? fe : C, ge = he !== fe;
7378
+ pe || ge ? (R.text = he ? Ir({ value: me }) : me, c.textCaseRaw = me) : c.textCaseRaw === void 0 && (c.textCaseRaw = de), c.uppercase = he, c.set(R);
7175
7379
  let _e = !1;
7176
7380
  if (z) {
7177
- let e = Or({
7381
+ let e = Mr({
7178
7382
  textbox: c,
7179
- styles: re,
7383
+ styles: B,
7180
7384
  range: z
7181
- }), t = ne ? Or({
7385
+ }), t = ne ? Mr({
7182
7386
  textbox: c,
7183
- styles: ie,
7387
+ styles: re,
7184
7388
  range: ne
7185
7389
  }) : !1;
7186
7390
  _e = e || t;
7187
- } else if (Object.keys(B).length) {
7188
- let e = Er({ textbox: c });
7189
- e && (_e = Or({
7391
+ } else if (Object.keys(V).length) {
7392
+ let e = Ar({ textbox: c });
7393
+ e && (_e = Mr({
7190
7394
  textbox: c,
7191
- styles: B,
7395
+ styles: V,
7192
7396
  range: e
7193
7397
  }));
7194
7398
  }
7195
- let ve = _e && $r({ stylesList: [
7399
+ let ve = _e && ri({ stylesList: [
7400
+ B,
7196
7401
  re,
7197
- ie,
7198
- B
7402
+ V
7199
7403
  ] });
7200
7404
  if (_e && (c.dirty = !0), ne && (v !== void 0 || y !== void 0)) {
7201
- let e = Gr({
7405
+ let e = Yr({
7202
7406
  textbox: c,
7203
7407
  range: ne
7204
7408
  }), t = {};
7205
- v !== void 0 && (t.fontFamily = v), y !== void 0 && (t.fontSize = y), Rr({
7409
+ v !== void 0 && (t.fontFamily = v), y !== void 0 && (t.fontSize = y), Hr({
7206
7410
  textbox: c,
7207
7411
  lineIndices: e,
7208
7412
  updates: t
7209
7413
  });
7210
7414
  }
7211
7415
  if (z && (E !== void 0 || D !== void 0 || O !== void 0)) {
7212
- let e = Kr({
7416
+ let e = Xr({
7213
7417
  textbox: c,
7214
7418
  range: z
7215
7419
  }), t = {};
7216
- E !== void 0 && (t.fill = E), (D !== void 0 || O !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)), Rr({
7420
+ E !== void 0 && (t.fill = E), (D !== void 0 || O !== void 0) && (ie === null && (t.stroke = null), ie != null && (t.stroke = ie)), Hr({
7217
7421
  textbox: c,
7218
7422
  lineIndices: e,
7219
7423
  updates: t
7220
7424
  });
7221
7425
  }
7222
- ve && (c.initDimensions(), c.dirty = !0), (A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || P !== void 0 || F !== void 0 || ee !== void 0 || I !== void 0 || L !== void 0 || te !== void 0) && (c.dirty = !0);
7223
- let ye = $r({ stylesList: [
7426
+ ve && (c.initDimensions(), c.dirty = !0), (A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || ee !== void 0 || P !== void 0 || F !== void 0 || I !== void 0 || L !== void 0 || te !== void 0) && (c.dirty = !0);
7427
+ let ye = ri({ stylesList: [
7224
7428
  R,
7429
+ B,
7225
7430
  re,
7226
- ie,
7227
- B
7431
+ V
7228
7432
  ] }), { autoExpand: be } = c, xe = _ !== void 0, Se = (_ == null ? be : _) !== !1;
7229
7433
  xe ? c.autoExpand = _ !== !1 : be === void 0 && (c.autoExpand = !0);
7230
7434
  let Ce = Object.prototype.hasOwnProperty.call(R, "width"), we = Se && !Ce && (pe || ge || ye), Te = !1;
7231
- we && (Te = this._autoExpandTextboxWidth(c, { anchor: h }), Te && (c.dirty = !0)), !Te && ei({ textbox: c }) && (c.dirty = !0), c.setCoords(), i || d.requestRenderAll(), u.resumeHistory(), r || u.saveState();
7232
- let Ee = t._getSnapshot(c);
7233
- return d.fire("editor:text-updated", {
7435
+ we && (Te = this._autoExpandTextboxWidth(c, { anchor: h }), Te && (c.dirty = !0)), !Te && ii({ textbox: c }) && (c.dirty = !0), c.setCoords();
7436
+ let Ee = {
7437
+ withoutSave: !!r,
7438
+ skipRender: !!i
7439
+ }, De = !!z && Object.keys(B).length > 0, Oe = {
7234
7440
  textbox: c,
7235
7441
  target: e,
7236
7442
  style: n,
7237
- options: {
7238
- withoutSave: !!r,
7239
- skipRender: !!i
7240
- },
7443
+ options: Ee,
7241
7444
  updates: R,
7242
- before: f,
7243
- after: Ee,
7244
7445
  selectionRange: z == null ? void 0 : z,
7245
- selectionStyles: z && Object.keys(re).length ? re : void 0
7246
- }), c;
7446
+ selectionStyles: De ? B : void 0
7447
+ };
7448
+ d.fire("editor:before:text-updated", Oe), i || d.requestRenderAll();
7449
+ let ke = t._getSnapshot(c);
7450
+ u.resumeHistory(), r || u.saveState();
7451
+ let Ae = U(U({}, Oe), {}, {
7452
+ before: f,
7453
+ after: ke
7454
+ });
7455
+ return d.fire("editor:text-updated", Ae), c;
7247
7456
  }
7248
7457
  stylesFromArray(e, t) {
7249
7458
  return C.stylesFromArray(e, t);
@@ -7276,15 +7485,15 @@ var Ir = () => {
7276
7485
  var t;
7277
7486
  let { text: n = "", lineFontDefaults: r, styles: i, fontFamily: a, fontSize: o, fill: s, stroke: c, selectionStart: l, isEditing: u } = e, d = n, f = (t = e.__lineDefaultsPrevText) == null ? d : t, p = f.split("\n"), m = d.split("\n"), h = p.length, g = m.length - h, _ = r, v = !1, y = !1, b = typeof s == "string" ? s : void 0, x = typeof c == "string" ? c : void 0;
7278
7487
  if (g !== 0 && r && Object.keys(r).length) {
7279
- let e = qr({
7488
+ let e = Zr({
7280
7489
  previous: f,
7281
7490
  next: d
7282
- }), t = Jr({
7491
+ }), t = Qr({
7283
7492
  text: f,
7284
7493
  charIndex: e
7285
7494
  });
7286
7495
  if (g > 0) {
7287
- let n = Yr({
7496
+ let n = $r({
7288
7497
  text: f,
7289
7498
  lineIndex: t
7290
7499
  }), i = t + 1;
@@ -7297,7 +7506,7 @@ var Ir = () => {
7297
7506
  let n = r[t];
7298
7507
  if (!n) continue;
7299
7508
  let o = t >= i ? t + g : t;
7300
- a[o] = H({}, n);
7509
+ a[o] = U({}, n);
7301
7510
  }
7302
7511
  _ = a, v = !0, y = !0;
7303
7512
  }
@@ -7313,7 +7522,7 @@ var Ir = () => {
7313
7522
  let t = Number(e);
7314
7523
  if (!Number.isFinite(t)) continue;
7315
7524
  let n = r[t];
7316
- n && (t < i && (o[t] = H({}, n)), t > a && (o[t + g] = H({}, n)));
7525
+ n && (t < i && (o[t] = U({}, n)), t > a && (o[t + g] = U({}, n)));
7317
7526
  }
7318
7527
  _ = o, v = !0, y = !0;
7319
7528
  }
@@ -7329,21 +7538,21 @@ var Ir = () => {
7329
7538
  let t = (k = m[e]) == null ? "" : k, n = _ ? _[e] : void 0;
7330
7539
  if (n && (D = n), t.length !== 0) {
7331
7540
  if (n) {
7332
- let r = zr({
7541
+ let r = Ur({
7333
7542
  lineText: t,
7334
7543
  lineStyles: w ? w[e] : void 0,
7335
7544
  lineDefaults: n
7336
7545
  });
7337
- r.changed && (w || (w = {}, E = !0), E || (w = H({}, w), E = !0), r.lineStyles && (w[e] = r.lineStyles), !r.lineStyles && w[e] && delete w[e], T = !0);
7546
+ r.changed && (w || (w = {}, E = !0), E || (w = U({}, w), E = !0), r.lineStyles && (w[e] = r.lineStyles), !r.lineStyles && w[e] && delete w[e], T = !0);
7338
7547
  }
7339
7548
  continue;
7340
7549
  }
7341
7550
  let r = n == null ? D : n, i = {};
7342
- (r == null ? void 0 : r.fontFamily) === void 0 ? a !== void 0 && (i.fontFamily = a) : i.fontFamily = r.fontFamily, (r == null ? void 0 : r.fontSize) === void 0 ? o !== void 0 && (i.fontSize = o) : i.fontSize = r.fontSize, (r == null ? void 0 : r.fill) === void 0 ? b !== void 0 && (i.fill = b) : i.fill = r.fill, (r == null ? void 0 : r.stroke) === void 0 ? x !== void 0 && (i.stroke = x) : i.stroke = r.stroke, !n && Object.keys(i).length && (_ || (_ = {}, y = !0), y || (_ = H({}, _), y = !0), _[e] = i, v = !0, D = i), n && (D = n), C !== null && C === e && (O = i);
7551
+ (r == null ? void 0 : r.fontFamily) === void 0 ? a !== void 0 && (i.fontFamily = a) : i.fontFamily = r.fontFamily, (r == null ? void 0 : r.fontSize) === void 0 ? o !== void 0 && (i.fontSize = o) : i.fontSize = r.fontSize, (r == null ? void 0 : r.fill) === void 0 ? b !== void 0 && (i.fill = b) : i.fill = r.fill, (r == null ? void 0 : r.stroke) === void 0 ? x !== void 0 && (i.stroke = x) : i.stroke = r.stroke, !n && Object.keys(i).length && (_ || (_ = {}, y = !0), y || (_ = U({}, _), y = !0), _[e] = i, v = !0, D = i), n && (D = n), C !== null && C === e && (O = i);
7343
7552
  let s = {};
7344
7553
  i.fontFamily !== void 0 && (s.fontFamily = i.fontFamily), i.fontSize !== void 0 && (s.fontSize = i.fontSize), i.fill !== void 0 && (s.fill = i.fill), i.stroke !== void 0 && (s.stroke = i.stroke);
7345
7554
  let c = Object.keys(s).length > 0;
7346
- (c || w && w[e]) && (w || (w = {}, E = !0), E || (w = H({}, w), E = !0), c && (w[e] = { 0: s }), !c && w[e] && delete w[e], T = !0);
7555
+ (c || w && w[e]) && (w || (w = {}, E = !0), E || (w = U({}, w), E = !0), c && (w[e] = { 0: s }), !c && w[e] && delete w[e], T = !0);
7347
7556
  }
7348
7557
  if (v && _ && (e.lineFontDefaults = _), T && (e.styles = w, e.dirty = !0), O && typeof l == "number") {
7349
7558
  let t = {};
@@ -7371,17 +7580,17 @@ var Ir = () => {
7371
7580
  if (!Number.isFinite(E) || E <= 0) return !1;
7372
7581
  let D = _.split("\n").length, O = !1;
7373
7582
  Math.abs(((u = e.width) == null ? 0 : u) - E) > .01 && (e.set({ width: E }), O = !0), e.initDimensions();
7374
- let { textLines: k } = e, A = Array.isArray(k) && k.length > D, j = Math.ceil(Xr({
7583
+ let { textLines: k } = e, A = Array.isArray(k) && k.length > D, j = Math.ceil(ei({
7375
7584
  textbox: e,
7376
7585
  text: _
7377
7586
  })), M = Math.min((d = e.minWidth) == null ? 1 : d, E), N = Math.min(E, Math.max(j, M));
7378
- A && (N = E), Math.abs(((f = e.width) == null ? 0 : f) - N) > .01 && (e.set({ width: N }), e.initDimensions(), O = !0), ei({ textbox: e }) && (O = !0), b && (e.setPositionByOrigin(new p(b.x, b.y), "center", x), O = !0);
7379
- let P = Zr({
7587
+ A && (N = E), Math.abs(((f = e.width) == null ? 0 : f) - N) > .01 && (e.set({ width: N }), e.initDimensions(), O = !0), ii({ textbox: e }) && (O = !0), b && (e.setPositionByOrigin(new p(b.x, b.y), "center", x), O = !0);
7588
+ let ee = ti({
7380
7589
  textbox: e,
7381
7590
  montageLeft: (m = v.left) == null ? 0 : m,
7382
7591
  montageRight: ((h = v.left) == null ? 0 : h) + y
7383
7592
  });
7384
- return O || P;
7593
+ return O || ee;
7385
7594
  }
7386
7595
  _ensureEditingAnchorState() {
7387
7596
  return this.editingAnchorState || (this.editingAnchorState = /* @__PURE__ */ new WeakMap()), this.editingAnchorState;
@@ -7408,7 +7617,7 @@ var Ir = () => {
7408
7617
  bottomLeft: _
7409
7618
  },
7410
7619
  baseStyles: JSON.parse(JSON.stringify(c)),
7411
- baseLineFontDefaults: Br({ lineFontDefaults: l }),
7620
+ baseLineFontDefaults: Wr({ lineFontDefaults: l }),
7412
7621
  hasWidthChange: !1
7413
7622
  }, this.scalingState.set(e, t);
7414
7623
  }
@@ -7419,13 +7628,13 @@ var Ir = () => {
7419
7628
  Object.entries(t).forEach(([t, n]) => {
7420
7629
  n != null && (e[t] = n);
7421
7630
  });
7422
- }, { id: n, text: r, textCaseRaw: i, uppercase: a, autoExpand: o, fontFamily: s, fontSize: c, fontWeight: l, fontStyle: u, underline: d, linethrough: f, textAlign: p, fill: m, stroke: h, strokeWidth: g, opacity: _, backgroundColor: v, backgroundOpacity: y, paddingTop: b, paddingRight: x, paddingBottom: S, paddingLeft: C, radiusTopLeft: w, radiusTopRight: T, radiusBottomRight: E, radiusBottomLeft: D, left: O, top: k, width: A, height: j, angle: M, scaleX: N, scaleY: P } = e, F = {
7631
+ }, { id: n, text: r, textCaseRaw: i, uppercase: a, autoExpand: o, fontFamily: s, fontSize: c, fontWeight: l, fontStyle: u, underline: d, linethrough: f, textAlign: p, fill: m, stroke: h, strokeWidth: g, opacity: _, backgroundColor: v, backgroundOpacity: y, paddingTop: b, paddingRight: x, paddingBottom: S, paddingLeft: C, radiusTopLeft: w, radiusTopRight: T, radiusBottomRight: E, radiusBottomLeft: D, left: O, top: k, width: A, height: j, angle: M, scaleX: N, scaleY: ee } = e, P = {
7423
7632
  id: n,
7424
7633
  uppercase: !!a,
7425
7634
  textAlign: p
7426
7635
  };
7427
7636
  return t({
7428
- snapshot: F,
7637
+ snapshot: P,
7429
7638
  entries: {
7430
7639
  text: r,
7431
7640
  textCaseRaw: i,
@@ -7456,15 +7665,15 @@ var Ir = () => {
7456
7665
  height: j,
7457
7666
  angle: M,
7458
7667
  scaleX: N,
7459
- scaleY: P
7668
+ scaleY: ee
7460
7669
  }
7461
- }), F;
7670
+ }), P;
7462
7671
  }
7463
7672
  _getDefaultFontFamily() {
7464
7673
  var e, t;
7465
7674
  return (e = (t = this.fonts[0]) == null ? void 0 : t.family) == null ? "Arial" : e;
7466
7675
  }
7467
- }, ii = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, ai = (e) => {
7676
+ }, ci = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, li = (e) => {
7468
7677
  if (!e || typeof e != "object") return null;
7469
7678
  let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof (a == null ? void 0 : a.color) == "string" ? a.color : void 0, c = typeof (o == null ? void 0 : o.color) == "string" ? o.color : s, l = typeof (a == null ? void 0 : a.offset) == "number" ? a.offset * 100 : void 0, u = typeof (o == null ? void 0 : o.offset) == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
7470
7679
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -7475,7 +7684,7 @@ var Ir = () => {
7475
7684
  let { x1: e, y1: t, x2: r, y2: i } = n;
7476
7685
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
7477
7686
  type: "linear",
7478
- angle: ii({
7687
+ angle: ci({
7479
7688
  x1: e,
7480
7689
  y1: t,
7481
7690
  x2: r,
@@ -7503,7 +7712,7 @@ var Ir = () => {
7503
7712
  };
7504
7713
  }
7505
7714
  return null;
7506
- }, oi = ["baseWidth", "baseHeight"], si = "_templateCenterX", ci = "_templateCenterY", li = "_templateAnchorX", ui = "_templateAnchorY", di = class t {
7715
+ }, ui = ["baseWidth", "baseHeight"], di = "_templateCenterX", fi = "_templateCenterY", pi = "_templateAnchorX", mi = "_templateAnchorY", hi = class t {
7507
7716
  constructor({ editor: e }) {
7508
7717
  this.editor = e;
7509
7718
  }
@@ -7512,7 +7721,7 @@ var Ir = () => {
7512
7721
  if (!p.length) return s.emitWarning({
7513
7722
  origin: "TemplateManager",
7514
7723
  method: "serializeSelection",
7515
- code: Sr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
7724
+ code: Er.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
7516
7725
  message: "Нет объектов для сериализации шаблона"
7517
7726
  }), null;
7518
7727
  let m = t._getBounds(o), h = t._getMontageSize({
@@ -7524,7 +7733,7 @@ var Ir = () => {
7524
7733
  baseWidth: g,
7525
7734
  baseHeight: _,
7526
7735
  montageArea: o == null ? null : o
7527
- })), y = H(H({}, r), {}, {
7736
+ })), y = U(U({}, r), {}, {
7528
7737
  baseWidth: g,
7529
7738
  baseHeight: _,
7530
7739
  positionsNormalized: !0,
@@ -7543,14 +7752,14 @@ var Ir = () => {
7543
7752
  if (!(c != null && c.length)) return o.emitWarning({
7544
7753
  origin: "TemplateManager",
7545
7754
  method: "applyTemplate",
7546
- code: Sr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7755
+ code: Er.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7547
7756
  message: "Шаблон не содержит объектов"
7548
7757
  }), null;
7549
7758
  let d = t._getBounds(i);
7550
7759
  if (!d) return o.emitWarning({
7551
7760
  origin: "TemplateManager",
7552
7761
  method: "applyTemplate",
7553
- code: Sr.TEMPLATE_MANAGER.INVALID_TARGET,
7762
+ code: Er.TEMPLATE_MANAGER.INVALID_TARGET,
7554
7763
  message: "Не удалось определить границы монтажной области"
7555
7764
  }), null;
7556
7765
  let f = t._getMontageSize({
@@ -7569,7 +7778,7 @@ var Ir = () => {
7569
7778
  if (!a.length) return o.emitWarning({
7570
7779
  origin: "TemplateManager",
7571
7780
  method: "applyTemplate",
7572
- code: Sr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7781
+ code: Er.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7573
7782
  message: "Не удалось создать объекты шаблона"
7574
7783
  }), null;
7575
7784
  let { backgroundObject: l, contentObjects: u } = t._extractBackgroundObject(a);
@@ -7606,7 +7815,7 @@ var Ir = () => {
7606
7815
  return o.emitError({
7607
7816
  origin: "TemplateManager",
7608
7817
  method: "applyTemplate",
7609
- code: Sr.TEMPLATE_MANAGER.APPLY_FAILED,
7818
+ code: Er.TEMPLATE_MANAGER.APPLY_FAILED,
7610
7819
  message: "Ошибка применения шаблона",
7611
7820
  data: {
7612
7821
  templateId: u,
@@ -7722,7 +7931,7 @@ var Ir = () => {
7722
7931
  })();
7723
7932
  }
7724
7933
  static _prepareSerializableProps(e) {
7725
- let t = H({}, e);
7934
+ let t = U({}, e);
7726
7935
  return delete t.svgMarkup, delete t.objects, delete t.path, delete t.paths, delete t.type, delete t.version, t;
7727
7936
  }
7728
7937
  static _isSvgObject(e) {
@@ -7756,8 +7965,8 @@ var Ir = () => {
7756
7965
  baseHeight: o,
7757
7966
  useRelativePositions: c,
7758
7967
  centerKeys: {
7759
- x: si,
7760
- y: ci
7968
+ x: di,
7969
+ y: fi
7761
7970
  }
7762
7971
  }), { scaleX: f, scaleY: p } = e, m = G({
7763
7972
  value: f,
@@ -7774,8 +7983,8 @@ var Ir = () => {
7774
7983
  baseHeight: o,
7775
7984
  scale: n,
7776
7985
  useRelativePositions: c,
7777
- anchorX: t._resolveAnchor(l, li),
7778
- anchorY: t._resolveAnchor(l, ui)
7986
+ anchorX: t._resolveAnchor(l, pi),
7987
+ anchorY: t._resolveAnchor(l, mi)
7779
7988
  }),
7780
7989
  targetSize: i,
7781
7990
  montageArea: s
@@ -7783,7 +7992,7 @@ var Ir = () => {
7783
7992
  e.set({
7784
7993
  scaleX: _,
7785
7994
  scaleY: v
7786
- }), e.setPositionByOrigin(g, "center", "center"), e.setCoords(), delete l[si], delete l[ci], delete l[li], delete l[ui];
7995
+ }), e.setPositionByOrigin(g, "center", "center"), e.setCoords(), delete l[di], delete l[fi], delete l[pi], delete l[mi];
7787
7996
  }
7788
7997
  static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
7789
7998
  if (!a) return e;
@@ -7811,8 +8020,8 @@ var Ir = () => {
7811
8020
  return Math.abs(u) <= .1 ? "center" : u < 0 ? "start" : "end";
7812
8021
  }
7813
8022
  static _normalizeMeta({ meta: e, fallback: t }) {
7814
- let { width: n, height: r } = t, i = e || {}, { baseWidth: a = n, baseHeight: o = r } = i, s = ut(i, oi);
7815
- return H({
8023
+ let { width: n, height: r } = t, i = e || {}, { baseWidth: a = n, baseHeight: o = r } = i, s = ut(i, ui);
8024
+ return U({
7816
8025
  baseWidth: a,
7817
8026
  baseHeight: o
7818
8027
  }, s);
@@ -7859,7 +8068,7 @@ var Ir = () => {
7859
8068
  }), g = h * p, v = d * p, y = f * p, b = g + v + y + m;
7860
8069
  if (!a || !h || !l) return;
7861
8070
  e.setCoords();
7862
- let x = e, S = x[si], C = typeof S == "number" ? S : null, w = t._resolveAnchor(x, li), T = b / l, E = C === null ? null : C - T / 2, D = C === null ? null : C + T / 2, O = e.getCenterPoint();
8071
+ let x = e, S = x[di], C = typeof S == "number" ? S : null, w = t._resolveAnchor(x, pi), T = b / l, E = C === null ? null : C - T / 2, D = C === null ? null : C + T / 2, O = e.getCenterPoint();
7863
8072
  e.set("width", a), e.initDimensions();
7864
8073
  let k = t._getLongestLineWidth({
7865
8074
  textbox: e,
@@ -7867,7 +8076,7 @@ var Ir = () => {
7867
8076
  }), A = k > h ? k + 1 : h;
7868
8077
  e.set("width", A), e.initDimensions(), e.setPositionByOrigin(O, "center", "center"), e.setCoords();
7869
8078
  let j = (A * p + v + y + m) / l, M = C;
7870
- w === "start" && E !== null ? M = Math.max(0, E) + j / 2 : w === "end" && D !== null && (M = Math.min(1, D) - j / 2), typeof M == "number" && (x[si] = M);
8079
+ w === "start" && E !== null ? M = Math.max(0, E) + j / 2 : w === "end" && D !== null && (M = Math.min(1, D) - j / 2), typeof M == "number" && (x[di] = M);
7871
8080
  }
7872
8081
  static _getLongestLineWidth({ textbox: e, text: t }) {
7873
8082
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
@@ -7895,11 +8104,11 @@ var Ir = () => {
7895
8104
  y: (t.y - c) / p
7896
8105
  };
7897
8106
  })() : m, g = (d.left - s) / f, _ = (d.top - c) / p, v = g + d.width / f, y = _ + d.height / p;
7898
- return o[si] = h.x, o[ci] = h.y, o[li] = t._detectAnchor({
8107
+ return o[di] = h.x, o[fi] = h.y, o[pi] = t._detectAnchor({
7899
8108
  center: h.x,
7900
8109
  start: g,
7901
8110
  end: v
7902
- }), o[ui] = t._detectAnchor({
8111
+ }), o[mi] = t._detectAnchor({
7903
8112
  center: h.y,
7904
8113
  start: _,
7905
8114
  end: y
@@ -7926,7 +8135,7 @@ var Ir = () => {
7926
8135
  withoutSave: !0
7927
8136
  }), !0;
7928
8137
  if (a === "gradient") {
7929
- let e = ai(r);
8138
+ let e = li(r);
7930
8139
  if (e) return n.setGradientBackground({
7931
8140
  gradient: e,
7932
8141
  customData: o,
@@ -7947,7 +8156,7 @@ var Ir = () => {
7947
8156
  r.emitWarning({
7948
8157
  origin: "TemplateManager",
7949
8158
  method: "applyTemplate",
7950
- code: Sr.TEMPLATE_MANAGER.APPLY_FAILED,
8159
+ code: Er.TEMPLATE_MANAGER.APPLY_FAILED,
7951
8160
  message: "Не удалось применить фон из шаблона",
7952
8161
  data: e
7953
8162
  });
@@ -7970,7 +8179,7 @@ var Ir = () => {
7970
8179
  };
7971
8180
  }
7972
8181
  static _cloneCustomData(e) {
7973
- if (!(!e || typeof e != "object")) return H({}, e);
8182
+ if (!(!e || typeof e != "object")) return U({}, e);
7974
8183
  }
7975
8184
  static _getImageSource(e) {
7976
8185
  let t = e;
@@ -7988,29 +8197,29 @@ var Ir = () => {
7988
8197
  enlivenObjectEnlivables(e) {
7989
8198
  return C.enlivenObjectEnlivables(e);
7990
8199
  }
7991
- }, fi = "#3D8BF4", pi = .5, mi = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, hi = ({ firstDistance: e, secondDistance: t }) => {
7992
- let n = mi({ distance: e }), r = mi({ distance: t });
8200
+ }, gi = "#3D8BF4", _i = .5, vi = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, yi = ({ firstDistance: e, secondDistance: t }) => {
8201
+ let n = vi({ distance: e }), r = vi({ distance: t });
7993
8202
  return {
7994
8203
  firstDisplayDistance: n,
7995
8204
  secondDisplayDistance: r,
7996
8205
  displayDistanceDiff: Math.abs(n - r),
7997
8206
  commonDisplayDistance: Math.max(n, r)
7998
8207
  };
7999
- }, gi = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), _i = ({ step: e }) => {
8208
+ }, bi = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), xi = ({ step: e }) => {
8000
8209
  let t = Math.abs(e).toString(), n = t.indexOf(".");
8001
8210
  return n === -1 ? 0 : t.slice(n + 1).length;
8002
- }, vi = ({ value: e, step: t }) => {
8211
+ }, Si = ({ value: e, step: t }) => {
8003
8212
  if (t === 0) return e;
8004
- let n = _i({ step: t }), r = Math.round(e / t) * t;
8213
+ let n = xi({ step: t }), r = Math.round(e / t) * t;
8005
8214
  return Number(r.toFixed(n));
8006
- }, yi = ({ value: e, step: t }) => {
8215
+ }, Ci = ({ value: e, step: t }) => {
8007
8216
  if (t === 0) return !0;
8008
- let n = vi({
8217
+ let n = Si({
8009
8218
  value: e,
8010
8219
  step: t
8011
- }), r = _i({ step: t }), i = Math.pow(10, -(r + 4));
8220
+ }), r = xi({ step: t }), i = Math.pow(10, -(r + 4));
8012
8221
  return Math.abs(n - e) <= i;
8013
- }, bi = ({ bounds: e, axis: t }) => {
8222
+ }, wi = ({ bounds: e, axis: t }) => {
8014
8223
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
8015
8224
  return t === "vertical" ? {
8016
8225
  start: i,
@@ -8019,7 +8228,7 @@ var Ir = () => {
8019
8228
  start: n,
8020
8229
  end: r
8021
8230
  };
8022
- }, xi = ({ items: e, axis: t }) => {
8231
+ }, Ti = ({ items: e, axis: t }) => {
8023
8232
  for (let n = 1; n < e.length; n += 1) {
8024
8233
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
8025
8234
  for (; o >= 0;) {
@@ -8029,10 +8238,10 @@ var Ir = () => {
8029
8238
  }
8030
8239
  e[o + 1] = r;
8031
8240
  }
8032
- }, Si = ({ items: e, index: t, axis: n, direction: r }) => {
8241
+ }, Ei = ({ items: e, index: t, axis: n, direction: r }) => {
8033
8242
  let i = e[t];
8034
8243
  if (!i) return null;
8035
- let { bounds: a } = i, { start: o, end: s } = bi({
8244
+ let { bounds: a } = i, { start: o, end: s } = wi({
8036
8245
  bounds: a,
8037
8246
  axis: n
8038
8247
  });
@@ -8040,7 +8249,7 @@ var Ir = () => {
8040
8249
  for (let r = t - 1; r >= 0; --r) {
8041
8250
  let t = e[r];
8042
8251
  if (!t) continue;
8043
- let { bounds: i } = t, { end: a } = bi({
8252
+ let { bounds: i } = t, { end: a } = wi({
8044
8253
  bounds: i,
8045
8254
  axis: n
8046
8255
  });
@@ -8051,26 +8260,26 @@ var Ir = () => {
8051
8260
  for (let r = t + 1; r < e.length; r += 1) {
8052
8261
  let t = e[r];
8053
8262
  if (!t) continue;
8054
- let { bounds: i } = t, { start: a } = bi({
8263
+ let { bounds: i } = t, { start: a } = wi({
8055
8264
  bounds: i,
8056
8265
  axis: n
8057
8266
  });
8058
8267
  if (a - s >= 0) return r;
8059
8268
  }
8060
8269
  return null;
8061
- }, Ci = ({ items: e }) => {
8270
+ }, Di = ({ items: e }) => {
8062
8271
  for (let t = 0; t < e.length; t += 1) {
8063
8272
  let { isActive: n } = e[t];
8064
8273
  if (n) return t;
8065
8274
  }
8066
8275
  return -1;
8067
- }, wi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
8276
+ }, Oi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
8068
8277
  let i = Math.min(t, n), a = Math.max(t, n);
8069
8278
  return e >= i - r && e <= a + r;
8070
- }, Ti = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Ei = ({ baseOption: e, candidateOption: t }) => {
8279
+ }, ki = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Ai = ({ baseOption: e, candidateOption: t }) => {
8071
8280
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
8072
8281
  return n === i && r === a;
8073
- }, Di = ({ options: e }) => {
8282
+ }, ji = ({ options: e }) => {
8074
8283
  let t = e[0];
8075
8284
  for (let n = 1; n < e.length; n += 1) {
8076
8285
  let r = e[n];
@@ -8081,11 +8290,11 @@ var Ir = () => {
8081
8290
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
8082
8291
  }
8083
8292
  return t;
8084
- }, Oi = ({ currentOption: e, nextOption: t }) => {
8293
+ }, Mi = ({ currentOption: e, nextOption: t }) => {
8085
8294
  if (!e) return !0;
8086
8295
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
8087
8296
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
8088
- }, ki = ({ options: e }) => {
8297
+ }, Ni = ({ options: e }) => {
8089
8298
  let t = [], n = null, r = null;
8090
8299
  for (let i of e) {
8091
8300
  let { kind: e, side: a } = i;
@@ -8093,18 +8302,18 @@ var Ir = () => {
8093
8302
  t.push(i);
8094
8303
  continue;
8095
8304
  }
8096
- a === "before" && Oi({
8305
+ a === "before" && Mi({
8097
8306
  currentOption: n,
8098
8307
  nextOption: i
8099
- }) && (n = i), a === "after" && Oi({
8308
+ }) && (n = i), a === "after" && Mi({
8100
8309
  currentOption: r,
8101
8310
  nextOption: i
8102
8311
  }) && (r = i);
8103
8312
  }
8104
8313
  return n && t.push(n), r && t.push(r), t;
8105
- }, Ai = ({ options: e, side: t, baseOption: n }) => {
8314
+ }, Pi = ({ options: e, side: t, baseOption: n }) => {
8106
8315
  let r = null;
8107
- for (let i of e) if (i.side === t && Ei({
8316
+ for (let i of e) if (i.side === t && Ai({
8108
8317
  baseOption: n,
8109
8318
  candidateOption: i
8110
8319
  })) {
@@ -8115,63 +8324,63 @@ var Ir = () => {
8115
8324
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
8116
8325
  }
8117
8326
  return r;
8118
- }, ji = ({ option: e }) => {
8327
+ }, Fi = ({ option: e }) => {
8119
8328
  let { side: t, kind: n, guide: { distance: r } } = e;
8120
8329
  return {
8121
8330
  side: t,
8122
8331
  kind: n,
8123
8332
  distance: r
8124
8333
  };
8125
- }, Mi = ({ option: e, context: t }) => {
8334
+ }, Ii = ({ option: e, context: t }) => {
8126
8335
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
8127
8336
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
8128
- }, Ni = ({ options: e, context: t }) => {
8337
+ }, Li = ({ options: e, context: t }) => {
8129
8338
  if (!t) return null;
8130
- for (let n of e) if (Mi({
8339
+ for (let n of e) if (Ii({
8131
8340
  option: n,
8132
8341
  context: t
8133
8342
  })) return n;
8134
8343
  return null;
8135
- }, Pi = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
8136
- let i = Ni({
8344
+ }, Ri = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
8345
+ let i = Li({
8137
8346
  options: e,
8138
8347
  context: n
8139
8348
  });
8140
8349
  if (!i) return t;
8141
8350
  let a = Math.max(0, r);
8142
8351
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
8143
- }, Fi = ({ guides: e, seenGuideKeys: t, guide: n }) => {
8352
+ }, zi = ({ guides: e, seenGuideKeys: t, guide: n }) => {
8144
8353
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
8145
8354
  t.has(u) || (t.add(u), e.push(n));
8146
- }, Ii = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
8355
+ }, Bi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
8147
8356
  if (!e.length) return {
8148
8357
  delta: 0,
8149
8358
  guides: [],
8150
8359
  context: null
8151
8360
  };
8152
- let r = ki({ options: e }), i = [];
8361
+ let r = Ni({ options: e }), i = [];
8153
8362
  for (let e of r) e.kind === "reference" && i.push(e);
8154
- let a = i.length > 0, o = a ? i : r, s = Pi({
8363
+ let a = i.length > 0, o = a ? i : r, s = Ri({
8155
8364
  options: o,
8156
- bestOption: Di({ options: o }),
8365
+ bestOption: ji({ options: o }),
8157
8366
  previousContext: t,
8158
8367
  switchDistance: n
8159
- }), c = Ai({
8368
+ }), c = Pi({
8160
8369
  options: o,
8161
8370
  side: "before",
8162
8371
  baseOption: s
8163
- }), l = Ai({
8372
+ }), l = Pi({
8164
8373
  options: o,
8165
8374
  side: "after",
8166
8375
  baseOption: s
8167
- }), u = Ai({
8376
+ }), u = Pi({
8168
8377
  options: a ? r : o,
8169
8378
  side: "center",
8170
8379
  baseOption: s
8171
8380
  }), d = [];
8172
8381
  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);
8173
8382
  let f = [], p = /* @__PURE__ */ new Set();
8174
- for (let e of d) Fi({
8383
+ for (let e of d) zi({
8175
8384
  guides: f,
8176
8385
  seenGuideKeys: p,
8177
8386
  guide: e.guide
@@ -8179,15 +8388,15 @@ var Ir = () => {
8179
8388
  return {
8180
8389
  delta: s.delta,
8181
8390
  guides: f,
8182
- context: ji({ option: s })
8391
+ context: Fi({ option: s })
8183
8392
  };
8184
- }, Li = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
8185
- let s = n - (e - r), c = vi({
8393
+ }, Vi = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
8394
+ let s = n - (e - r), c = Si({
8186
8395
  value: s,
8187
8396
  step: o
8188
8397
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
8189
8398
  for (let d = -l; d <= l; d += 1) {
8190
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = hi({
8399
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = yi({
8191
8400
  firstDistance: m,
8192
8401
  secondDistance: h
8193
8402
  });
@@ -8202,13 +8411,13 @@ var Ir = () => {
8202
8411
  });
8203
8412
  }
8204
8413
  return u;
8205
- }, Ri = ({ currentGap: e, referenceGap: t }) => {
8206
- let { secondDisplayDistance: n, displayDistanceDiff: r } = hi({
8414
+ }, Hi = ({ currentGap: e, referenceGap: t }) => {
8415
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = yi({
8207
8416
  firstDistance: e,
8208
8417
  secondDistance: t
8209
8418
  });
8210
8419
  return r > 1 ? null : n;
8211
- }, zi = ({ anchors: e, positions: t, threshold: n }) => {
8420
+ }, Ui = ({ anchors: e, positions: t, threshold: n }) => {
8212
8421
  let r = 0, i = n + 1, a = null;
8213
8422
  for (let o of t) for (let t of e) {
8214
8423
  let e = Math.abs(t - o);
@@ -8218,8 +8427,8 @@ var Ir = () => {
8218
8427
  delta: r,
8219
8428
  guidePosition: a
8220
8429
  };
8221
- }, Bi = ({ activeBounds: e, threshold: t, anchors: n }) => {
8222
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = zi({
8430
+ }, Wi = ({ activeBounds: e, threshold: t, anchors: n }) => {
8431
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ui({
8223
8432
  anchors: n.vertical,
8224
8433
  positions: [
8225
8434
  r,
@@ -8227,7 +8436,7 @@ var Ir = () => {
8227
8436
  i
8228
8437
  ],
8229
8438
  threshold: t
8230
- }), u = zi({
8439
+ }), u = Ui({
8231
8440
  anchors: n.horizontal,
8232
8441
  positions: [
8233
8442
  o,
@@ -8247,11 +8456,11 @@ var Ir = () => {
8247
8456
  deltaY: u.delta,
8248
8457
  guides: d
8249
8458
  };
8250
- }, Vi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8459
+ }, Gi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8251
8460
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
8252
8461
  for (let e of t) {
8253
8462
  let { left: t, right: n } = e;
8254
- gi({
8463
+ bi({
8255
8464
  firstStart: t,
8256
8465
  firstEnd: n,
8257
8466
  secondStart: l,
@@ -8271,22 +8480,22 @@ var Ir = () => {
8271
8480
  f.push({
8272
8481
  bounds: e,
8273
8482
  isActive: !0
8274
- }), xi({
8483
+ }), Ti({
8275
8484
  items: f,
8276
8485
  axis: "top"
8277
8486
  });
8278
- let p = Ci({ items: f });
8487
+ let p = Di({ items: f });
8279
8488
  if (p === -1) return {
8280
8489
  delta: 0,
8281
8490
  guides: [],
8282
8491
  context: null
8283
8492
  };
8284
- let m = [], h = c - s, g = Si({
8493
+ let m = [], h = c - s, g = Ei({
8285
8494
  items: f,
8286
8495
  index: p,
8287
8496
  axis: "vertical",
8288
8497
  direction: "prev"
8289
- }), _ = Si({
8498
+ }), _ = Ei({
8290
8499
  items: f,
8291
8500
  index: p,
8292
8501
  axis: "vertical",
@@ -8295,19 +8504,19 @@ var Ir = () => {
8295
8504
  if (v && y) {
8296
8505
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
8297
8506
  if (a >= 0) {
8298
- let e = vi({
8507
+ let e = Si({
8299
8508
  value: a / 2,
8300
8509
  step: 1
8301
8510
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
8302
8511
  if (Math.max(u, d) <= n) {
8303
- let t = Li({
8512
+ let t = Vi({
8304
8513
  activeStart: s,
8305
8514
  activeEnd: c,
8306
8515
  targetGap: e,
8307
8516
  beforeEdge: r,
8308
8517
  afterEdge: i,
8309
8518
  threshold: n,
8310
- step: pi
8519
+ step: _i
8311
8520
  });
8312
8521
  if (t) {
8313
8522
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -8344,16 +8553,16 @@ var Ir = () => {
8344
8553
  }
8345
8554
  for (let e of r) {
8346
8555
  let { axis: t, start: r, end: i, distance: a } = e;
8347
- if (!yi({
8556
+ if (!Ci({
8348
8557
  value: a,
8349
8558
  step: .5
8350
- }) || !wi({
8559
+ }) || !Oi({
8351
8560
  patternAxis: t,
8352
8561
  activeRangeStart: l,
8353
8562
  activeRangeEnd: u,
8354
8563
  tolerance: n
8355
8564
  })) continue;
8356
- let d = Ti({
8565
+ let d = ki({
8357
8566
  patternStart: r,
8358
8567
  patternEnd: i,
8359
8568
  activeStart: s,
@@ -8361,12 +8570,12 @@ var Ir = () => {
8361
8570
  });
8362
8571
  if (d) {
8363
8572
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
8364
- let e = vi({
8573
+ let e = Si({
8365
8574
  value: a - b,
8366
8575
  step: 1
8367
8576
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
8368
8577
  if (u > n) continue;
8369
- let d = Ri({
8578
+ let d = Hi({
8370
8579
  currentGap: l,
8371
8580
  referenceGap: a
8372
8581
  });
@@ -8390,12 +8599,12 @@ var Ir = () => {
8390
8599
  });
8391
8600
  }
8392
8601
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
8393
- let e = vi({
8602
+ let e = Si({
8394
8603
  value: x - a,
8395
8604
  step: 1
8396
8605
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
8397
8606
  if (u > n) continue;
8398
- let d = Ri({
8607
+ let d = Hi({
8399
8608
  currentGap: l,
8400
8609
  referenceGap: a
8401
8610
  });
@@ -8420,16 +8629,16 @@ var Ir = () => {
8420
8629
  }
8421
8630
  }
8422
8631
  }
8423
- return Ii({
8632
+ return Bi({
8424
8633
  options: m,
8425
8634
  previousContext: i,
8426
8635
  switchDistance: a
8427
8636
  });
8428
- }, Hi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8637
+ }, Ki = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8429
8638
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
8430
8639
  for (let e of t) {
8431
8640
  let { top: t, bottom: n } = e;
8432
- gi({
8641
+ bi({
8433
8642
  firstStart: t,
8434
8643
  firstEnd: n,
8435
8644
  secondStart: l,
@@ -8449,22 +8658,22 @@ var Ir = () => {
8449
8658
  f.push({
8450
8659
  bounds: e,
8451
8660
  isActive: !0
8452
- }), xi({
8661
+ }), Ti({
8453
8662
  items: f,
8454
8663
  axis: "left"
8455
8664
  });
8456
- let p = Ci({ items: f });
8665
+ let p = Di({ items: f });
8457
8666
  if (p === -1) return {
8458
8667
  delta: 0,
8459
8668
  guides: [],
8460
8669
  context: null
8461
8670
  };
8462
- let m = [], h = c - s, g = Si({
8671
+ let m = [], h = c - s, g = Ei({
8463
8672
  items: f,
8464
8673
  index: p,
8465
8674
  axis: "horizontal",
8466
8675
  direction: "prev"
8467
- }), _ = Si({
8676
+ }), _ = Ei({
8468
8677
  items: f,
8469
8678
  index: p,
8470
8679
  axis: "horizontal",
@@ -8473,19 +8682,19 @@ var Ir = () => {
8473
8682
  if (v && y) {
8474
8683
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
8475
8684
  if (a >= 0) {
8476
- let e = vi({
8685
+ let e = Si({
8477
8686
  value: a / 2,
8478
8687
  step: 1
8479
8688
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
8480
8689
  if (Math.max(u, d) <= n) {
8481
- let t = Li({
8690
+ let t = Vi({
8482
8691
  activeStart: s,
8483
8692
  activeEnd: c,
8484
8693
  targetGap: e,
8485
8694
  beforeEdge: r,
8486
8695
  afterEdge: i,
8487
8696
  threshold: n,
8488
- step: pi
8697
+ step: _i
8489
8698
  });
8490
8699
  if (t) {
8491
8700
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -8522,16 +8731,16 @@ var Ir = () => {
8522
8731
  }
8523
8732
  for (let e of r) {
8524
8733
  let { axis: t, start: r, end: i, distance: a } = e;
8525
- if (!yi({
8734
+ if (!Ci({
8526
8735
  value: a,
8527
8736
  step: .5
8528
- }) || !wi({
8737
+ }) || !Oi({
8529
8738
  patternAxis: t,
8530
8739
  activeRangeStart: l,
8531
8740
  activeRangeEnd: u,
8532
8741
  tolerance: n
8533
8742
  })) continue;
8534
- let d = Ti({
8743
+ let d = ki({
8535
8744
  patternStart: r,
8536
8745
  patternEnd: i,
8537
8746
  activeStart: s,
@@ -8539,12 +8748,12 @@ var Ir = () => {
8539
8748
  });
8540
8749
  if (d) {
8541
8750
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
8542
- let e = vi({
8751
+ let e = Si({
8543
8752
  value: a - b,
8544
8753
  step: 1
8545
8754
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
8546
8755
  if (u > n) continue;
8547
- let d = Ri({
8756
+ let d = Hi({
8548
8757
  currentGap: l,
8549
8758
  referenceGap: a
8550
8759
  });
@@ -8568,12 +8777,12 @@ var Ir = () => {
8568
8777
  });
8569
8778
  }
8570
8779
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
8571
- let e = vi({
8780
+ let e = Si({
8572
8781
  value: x - a,
8573
8782
  step: 1
8574
8783
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
8575
8784
  if (u > n) continue;
8576
- let d = Ri({
8785
+ let d = Hi({
8577
8786
  currentGap: l,
8578
8787
  referenceGap: a
8579
8788
  });
@@ -8598,20 +8807,20 @@ var Ir = () => {
8598
8807
  }
8599
8808
  }
8600
8809
  }
8601
- return Ii({
8810
+ return Bi({
8602
8811
  options: m,
8603
8812
  previousContext: i,
8604
8813
  switchDistance: a
8605
8814
  });
8606
- }, Ui = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
8607
- let { vertical: o = null, horizontal: s = null } = i == null ? {} : i, c = Vi({
8815
+ }, qi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
8816
+ let { vertical: o = null, horizontal: s = null } = i == null ? {} : i, c = Gi({
8608
8817
  activeBounds: e,
8609
8818
  candidates: t,
8610
8819
  threshold: n,
8611
8820
  patterns: r.vertical,
8612
8821
  previousContext: o,
8613
8822
  switchDistance: a
8614
- }), l = Hi({
8823
+ }), l = Ki({
8615
8824
  activeBounds: e,
8616
8825
  candidates: t,
8617
8826
  threshold: n,
@@ -8630,14 +8839,14 @@ var Ir = () => {
8630
8839
  horizontal: l.context
8631
8840
  }
8632
8841
  };
8633
- }, Wi = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
8842
+ }, Ji = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
8634
8843
  let o = Math.min(a, r / 2, i / 2);
8635
8844
  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();
8636
- }, Gi = ({ 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 }) => {
8845
+ }, Yi = ({ 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 }) => {
8637
8846
  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;
8638
8847
  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";
8639
8848
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
8640
- e.beginPath(), Wi({
8849
+ e.beginPath(), Ji({
8641
8850
  context: e,
8642
8851
  x: w,
8643
8852
  y: T,
@@ -8645,11 +8854,11 @@ var Ir = () => {
8645
8854
  height: C,
8646
8855
  radius: v
8647
8856
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
8648
- }, Ki = ({ context: e, guide: t, zoom: n }) => {
8649
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = mi({ distance: l }).toString();
8857
+ }, Xi = ({ context: e, guide: t, zoom: n }) => {
8858
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = vi({ distance: l }).toString();
8650
8859
  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();
8651
- let d = fi;
8652
- Gi({
8860
+ let d = gi;
8861
+ Yi({
8653
8862
  context: e,
8654
8863
  type: r,
8655
8864
  axis: i,
@@ -8659,7 +8868,7 @@ var Ir = () => {
8659
8868
  zoom: n,
8660
8869
  color: d,
8661
8870
  lineWidth: 1
8662
- }), Gi({
8871
+ }), Yi({
8663
8872
  context: e,
8664
8873
  type: r,
8665
8874
  axis: i,
@@ -8670,10 +8879,10 @@ var Ir = () => {
8670
8879
  color: d,
8671
8880
  lineWidth: 1
8672
8881
  });
8673
- }, qi = ({ anchors: e, bounds: t }) => {
8882
+ }, Zi = ({ anchors: e, bounds: t }) => {
8674
8883
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
8675
8884
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
8676
- }, Ji = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
8885
+ }, Qi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
8677
8886
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
8678
8887
  for (let e = 0; e < s.length; e += 1) {
8679
8888
  let c = s[e], l = null, u = Infinity;
@@ -8694,35 +8903,35 @@ var Ir = () => {
8694
8903
  });
8695
8904
  }
8696
8905
  return i;
8697
- }, Yi = ({ bounds: e }) => ({
8698
- vertical: Ji({
8906
+ }, $i = ({ bounds: e }) => ({
8907
+ vertical: Qi({
8699
8908
  bounds: e,
8700
8909
  axis: "centerX",
8701
8910
  type: "vertical",
8702
8911
  primaryStart: "top",
8703
8912
  primaryEnd: "bottom"
8704
8913
  }),
8705
- horizontal: Ji({
8914
+ horizontal: Qi({
8706
8915
  bounds: e,
8707
8916
  axis: "centerY",
8708
8917
  type: "horizontal",
8709
8918
  primaryStart: "left",
8710
8919
  primaryEnd: "right"
8711
8920
  })
8712
- }), Xi = [
8921
+ }), ea = [
8713
8922
  "montage-area",
8714
8923
  "background",
8715
8924
  "interaction-blocker"
8716
- ], Zi = ({ activeObject: t }) => {
8925
+ ], ta = ({ activeObject: t }) => {
8717
8926
  let n = /* @__PURE__ */ new Set();
8718
8927
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
8719
- }, Qi = ({ object: e, excluded: t, ignoredIds: n = Xi }) => {
8928
+ }, na = ({ object: e, excluded: t, ignoredIds: n = ea }) => {
8720
8929
  if (t.has(e)) return !0;
8721
8930
  let { visible: r = !0 } = e;
8722
8931
  if (!r) return !0;
8723
8932
  let { id: i } = e;
8724
8933
  return !!(i && n.includes(i));
8725
- }, $i = class e {
8934
+ }, ra = class e {
8726
8935
  constructor({ editor: e }) {
8727
8936
  this.anchors = {
8728
8937
  vertical: [],
@@ -8758,70 +8967,76 @@ var Ir = () => {
8758
8967
  }
8759
8968
  _handleObjectMoving(t) {
8760
8969
  var n;
8761
- let { target: r, e: i } = t;
8970
+ let { target: r, e: i, transform: a } = t;
8762
8971
  if (!r) {
8763
8972
  this._clearSpacingContexts(), this._clearGuides();
8764
8973
  return;
8765
8974
  }
8766
8975
  if (i != null && i.ctrlKey) {
8767
- this._clearSpacingContexts(), this._clearGuides(), e._applyMovementStep({ target: r });
8976
+ this._clearSpacingContexts(), this._clearGuides();
8768
8977
  return;
8769
8978
  }
8770
- e._applyMovementStep({ target: r }), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: r });
8771
- let a = ct({ object: r });
8772
- if (!a) {
8979
+ e._applyMovementStep({
8980
+ target: r,
8981
+ transform: a
8982
+ }), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: r });
8983
+ let o = ct({ object: r });
8984
+ if (!o) {
8773
8985
  this._clearSpacingContexts(), this._clearGuides();
8774
8986
  return;
8775
8987
  }
8776
- let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Bi({
8777
- activeBounds: a,
8778
- threshold: c,
8988
+ let { canvas: s } = this, c = s.getZoom() || 1, l = 5 / c, { deltaX: u, deltaY: d } = Wi({
8989
+ activeBounds: o,
8990
+ threshold: l,
8779
8991
  anchors: this.anchors
8780
8992
  });
8781
- if (l !== 0 || u !== 0) {
8782
- var d;
8993
+ if (u !== 0 || d !== 0) {
8994
+ var f;
8783
8995
  let { left: e = 0, top: t = 0 } = r;
8784
8996
  r.set({
8785
- left: e + l,
8786
- top: t + u
8787
- }), r.setCoords(), a = (d = ct({ object: r })) == null ? a : d;
8788
- }
8789
- let f = this._resolveCurrentTargetBounds({ activeObject: r }), p = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, m = Ui({
8790
- activeBounds: a,
8791
- candidates: f,
8792
- threshold: p,
8997
+ left: e + u,
8998
+ top: t + d
8999
+ }), r.setCoords(), o = (f = ct({ object: r })) == null ? o : f;
9000
+ }
9001
+ let p = this._resolveCurrentTargetBounds({ activeObject: r }), m = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / c : l, h = qi({
9002
+ activeBounds: o,
9003
+ candidates: p,
9004
+ threshold: m,
8793
9005
  spacingPatterns: this.spacingPatterns,
8794
9006
  previousContexts: this.spacingContexts,
8795
9007
  switchDistance: 5
8796
9008
  });
8797
- this.spacingContexts = m.contexts;
8798
- let h = m.deltaX !== 0 || m.deltaY !== 0;
8799
- if (h) {
8800
- var g;
9009
+ this.spacingContexts = h.contexts;
9010
+ let g = h.deltaX !== 0 || h.deltaY !== 0;
9011
+ if (g) {
9012
+ var _;
8801
9013
  let { left: e = 0, top: t = 0 } = r;
8802
9014
  r.set({
8803
- left: e + m.deltaX,
8804
- top: t + m.deltaY
8805
- }), r.setCoords(), a = (g = ct({ object: r })) == null ? a : g;
8806
- }
8807
- h || e._applyMovementStep({ target: r });
8808
- let _ = (n = ct({ object: r })) == null ? a : n, v = Bi({
8809
- activeBounds: _,
8810
- threshold: c,
9015
+ left: e + h.deltaX,
9016
+ top: t + h.deltaY
9017
+ }), r.setCoords(), o = (_ = ct({ object: r })) == null ? o : _;
9018
+ }
9019
+ g || e._applyMovementStep({
9020
+ target: r,
9021
+ transform: a
9022
+ });
9023
+ let v = (n = ct({ object: r })) == null ? o : n, y = Wi({
9024
+ activeBounds: v,
9025
+ threshold: l,
8811
9026
  anchors: this.anchors
8812
- }), y = Ui({
8813
- activeBounds: _,
8814
- candidates: f,
8815
- threshold: c,
9027
+ }), b = qi({
9028
+ activeBounds: v,
9029
+ candidates: p,
9030
+ threshold: l,
8816
9031
  spacingPatterns: this.spacingPatterns,
8817
9032
  previousContexts: this.spacingContexts,
8818
9033
  switchDistance: 5
8819
9034
  });
8820
- this.spacingContexts = y.contexts;
8821
- let b = y.deltaX === 0 && y.deltaY === 0;
9035
+ this.spacingContexts = b.contexts;
9036
+ let x = b.deltaX === 0 && b.deltaY === 0;
8822
9037
  this._applyGuides({
8823
- guides: v.guides,
8824
- spacingGuides: b ? y.guides : []
9038
+ guides: y.guides,
9039
+ spacingGuides: x ? b.guides : []
8825
9040
  });
8826
9041
  }
8827
9042
  _handleObjectScaling(t) {
@@ -9025,9 +9240,9 @@ var Ir = () => {
9025
9240
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
9026
9241
  if (!n) return;
9027
9242
  let { left: r, right: i, top: a, bottom: o } = t == null ? this._calculateViewportBounds() : t, { viewportTransform: s } = e, c = e.getZoom() || 1;
9028
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = fi, n.setLineDash([4, 4]);
9243
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = gi, n.setLineDash([4, 4]);
9029
9244
  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();
9030
- for (let e of this.activeSpacingGuides) Ki({
9245
+ for (let e of this.activeSpacingGuides) Xi({
9031
9246
  context: n,
9032
9247
  guide: e,
9033
9248
  zoom: c
@@ -9204,12 +9419,10 @@ var Ir = () => {
9204
9419
  let { paddingLeft: n = 0, paddingRight: r = 0, strokeWidth: i = 0 } = e, a = t - n - r - i;
9205
9420
  return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
9206
9421
  }
9207
- static _applyMovementStep({ target: e }) {
9208
- let { left: t = 0, top: n = 0 } = e, r = Math.round(t / 1) * 1, i = Math.round(n / 1) * 1;
9209
- r === t && i === n || (e.set({
9210
- left: r,
9211
- top: i
9212
- }), e.setCoords());
9422
+ static _applyMovementStep({ target: e, transform: t }) {
9423
+ var n, r;
9424
+ let { left: i = 0, top: a = 0 } = e, o = Math.round(i / 1) * 1, s = Math.round(a / 1) * 1, c = typeof (t == null || (n = t.original) == null ? void 0 : n.left) == "number" ? t.original.left : null, l = typeof (t == null || (r = t.original) == null ? void 0 : r.top) == "number" ? t.original.top : null, u = c === null || c !== i, d = l === null || l !== a, f = {};
9425
+ u && o !== i && (f.left = o), d && s !== a && (f.top = s), !(!("left" in f) && !("top" in f)) && (e.set(f), e.setCoords());
9213
9426
  }
9214
9427
  static _applyScalingStep({ target: t, transform: n }) {
9215
9428
  let { scaleX: r = 1, scaleY: i = 1 } = t, { width: a, height: o } = e._resolveEffectiveDimensions({ target: t }), s = r === i, c = r, l = i;
@@ -9237,14 +9450,14 @@ var Ir = () => {
9237
9450
  }, r = [];
9238
9451
  for (let e of t) {
9239
9452
  let t = ct({ object: e });
9240
- t && (qi({
9453
+ t && (Zi({
9241
9454
  anchors: n,
9242
9455
  bounds: t
9243
9456
  }), r.push(t));
9244
9457
  }
9245
9458
  let { montageArea: i } = this.editor, a = ct({ object: i });
9246
9459
  if (a) {
9247
- qi({
9460
+ Zi({
9248
9461
  anchors: n,
9249
9462
  bounds: a
9250
9463
  });
@@ -9256,12 +9469,12 @@ var Ir = () => {
9256
9469
  bottom: i
9257
9470
  };
9258
9471
  } else this.guideBounds = this._calculateViewportBounds();
9259
- this.anchors = n, this.spacingPatterns = Yi({ bounds: r }), this.cachedTargetBounds = r;
9472
+ this.anchors = n, this.spacingPatterns = $i({ bounds: r }), this.cachedTargetBounds = r;
9260
9473
  }
9261
9474
  _collectTargets({ activeObject: e }) {
9262
- let t = Zi({ activeObject: e }), n = [];
9475
+ let t = ta({ activeObject: e }), n = [];
9263
9476
  return this.canvas.forEachObject((e) => {
9264
- Qi({
9477
+ na({
9265
9478
  object: e,
9266
9479
  excluded: t
9267
9480
  }) || n.push(e);
@@ -9284,7 +9497,7 @@ var Ir = () => {
9284
9497
  bottom: (r - s) / a
9285
9498
  };
9286
9499
  }
9287
- }, ea = "#3D8BF4", ta = class e {
9500
+ }, ia = "#3D8BF4", aa = class e {
9288
9501
  constructor({ editor: e }) {
9289
9502
  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();
9290
9503
  }
@@ -9377,8 +9590,8 @@ var Ir = () => {
9377
9590
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
9378
9591
  }
9379
9592
  static _resolveTarget({ event: e, activeObject: t }) {
9380
- let { target: n } = e, r = Zi({ activeObject: t });
9381
- return n && !Qi({
9593
+ let { target: n } = e, r = ta({ activeObject: t });
9594
+ return n && !na({
9382
9595
  object: n,
9383
9596
  excluded: r
9384
9597
  }) ? n : null;
@@ -9495,18 +9708,18 @@ var Ir = () => {
9495
9708
  let { canvas: e } = this, t = e.getSelectionContext();
9496
9709
  if (!t) return;
9497
9710
  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;
9498
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = ea, t.setLineDash([]);
9711
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = ia, t.setLineDash([]);
9499
9712
  for (let e of this.activeGuides) {
9500
9713
  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;
9501
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Gi({
9714
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Yi({
9502
9715
  context: t,
9503
9716
  type: n,
9504
9717
  axis: i,
9505
9718
  start: a,
9506
9719
  end: c,
9507
- text: mi({ distance: l }).toString(),
9720
+ text: vi({ distance: l }).toString(),
9508
9721
  zoom: r,
9509
- color: ea,
9722
+ color: ia,
9510
9723
  lineWidth: 1,
9511
9724
  offsetAlongAxis: d,
9512
9725
  offsetPerpendicular: 0
@@ -9526,15 +9739,15 @@ var Ir = () => {
9526
9739
  let { toolbar: t } = this.editor;
9527
9740
  t == null || (e = t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
9528
9741
  }
9529
- }, na = [
9742
+ }, oa = [
9530
9743
  "source",
9531
9744
  "scale",
9532
9745
  "withoutSave"
9533
- ], ra = [
9746
+ ], sa = [
9534
9747
  "source",
9535
9748
  "scale",
9536
9749
  "withoutSave"
9537
- ], ia = class e {
9750
+ ], ca = class e {
9538
9751
  constructor(e, t) {
9539
9752
  this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
9540
9753
  }
@@ -9543,7 +9756,7 @@ var Ir = () => {
9543
9756
  return k(function* () {
9544
9757
  var n;
9545
9758
  let { editorContainerWidth: r, editorContainerHeight: i, canvasWrapperWidth: a, canvasWrapperHeight: o, canvasCSSWidth: s, canvasCSSHeight: c, initialImage: l, initialState: u, scaleType: d, showRotationAngle: f, _onReadyCallback: p } = e.options;
9546
- if (B.apply(), e.canvas = new t(e.containerId, e.options), e.moduleLoader = new M(), e.workerManager = new P(), e.errorManager = new Cr({ editor: e }), e.historyManager = new Ue({ editor: e }), e.toolbar = new U({ editor: e }), e.transformManager = new tt({ editor: e }), e.zoomManager = new nt({ editor: e }), e.canvasManager = new et({ editor: e }), e.imageManager = new Ye({ editor: e }), e.layerManager = new gt({ editor: e }), e.shapeManager = new gr({ editor: e }), e.interactionBlocker = new mt({ editor: e }), e.backgroundManager = new ht({ editor: e }), e.clipboardManager = new _r({ editor: e }), e.objectLockManager = new vr({ editor: e }), e.groupingManager = new yr({ editor: e }), e.selectionManager = new br({ editor: e }), e.deletionManager = new xr({ editor: e }), e.panConstraintManager = new wr({ editor: e }), e.snappingManager = new $i({ editor: e }), e.measurementManager = new ta({ editor: e }), e.fontManager = new oe((n = e.options.fonts) == null ? [] : n), e.textManager = new ri({ editor: e }), e.templateManager = new di({ editor: e }), f && (e.angleIndicator = new pe({ editor: e })), e._createMontageArea(), e._createClippingArea(), e.listeners = new j({
9759
+ if (V.apply(), e.canvas = new t(e.containerId, e.options), e.moduleLoader = new M(), e.workerManager = new ee(), e.errorManager = new Dr({ editor: e }), e.historyManager = new Ue({ editor: e }), e.toolbar = new W({ editor: e }), e.transformManager = new tt({ editor: e }), e.zoomManager = new nt({ editor: e }), e.canvasManager = new et({ editor: e }), e.imageManager = new Ye({ editor: e }), e.layerManager = new gt({ editor: e }), e.shapeManager = new br({ editor: e }), e.interactionBlocker = new mt({ editor: e }), e.backgroundManager = new ht({ editor: e }), e.clipboardManager = new xr({ editor: e }), e.objectLockManager = new Sr({ editor: e }), e.groupingManager = new Cr({ editor: e }), e.selectionManager = new wr({ editor: e }), e.deletionManager = new Tr({ editor: e }), e.panConstraintManager = new Or({ editor: e }), e.snappingManager = new ra({ editor: e }), e.measurementManager = new aa({ editor: e }), e.fontManager = new ae((n = e.options.fonts) == null ? [] : n), e.textManager = new si({ editor: e }), e.templateManager = new hi({ editor: e }), f && (e.angleIndicator = new pe({ editor: e })), e._createMontageArea(), e._createClippingArea(), e.listeners = new j({
9547
9760
  editor: e,
9548
9761
  options: e.options
9549
9762
  }), e.canvasManager.setEditorContainerWidth(r), e.canvasManager.setEditorContainerHeight(i), e.canvasManager.setCanvasWrapperWidth(a), e.canvasManager.setCanvasWrapperHeight(o), e.canvasManager.setCanvasCSSWidth(s), e.canvasManager.setCanvasCSSHeight(c), e.canvasManager.updateCanvas(), e.zoomManager.calculateAndApplyDefaultZoom(), yield e.fontManager.loadFonts(), u) {
@@ -9553,8 +9766,8 @@ var Ir = () => {
9553
9766
  yield e.historyManager.loadStateFromFullState(t);
9554
9767
  } catch (t) {
9555
9768
  if (l != null && l.source) {
9556
- let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l, na);
9557
- yield e.imageManager.importImage(H({
9769
+ let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l, oa);
9770
+ yield e.imageManager.importImage(U({
9558
9771
  source: t,
9559
9772
  scale: n,
9560
9773
  withoutSave: r
@@ -9571,8 +9784,8 @@ var Ir = () => {
9571
9784
  e.historyManager.resumeHistory();
9572
9785
  }
9573
9786
  } else if (l != null && l.source) {
9574
- let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l, ra);
9575
- yield e.imageManager.importImage(H({
9787
+ let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l, sa);
9788
+ yield e.imageManager.importImage(U({
9576
9789
  source: t,
9577
9790
  scale: n,
9578
9791
  withoutSave: r
@@ -9649,7 +9862,7 @@ var Ir = () => {
9649
9862
  "U+A640-A69F",
9650
9863
  "U+FE2E-FE2F",
9651
9864
  "U+2116"
9652
- ].join(", "), aa = {
9865
+ ].join(", "), la = {
9653
9866
  preserveObjectStacking: !0,
9654
9867
  controlsAboveOverlay: !0,
9655
9868
  centeredRotation: !0,
@@ -10523,17 +10736,17 @@ var Ir = () => {
10523
10736
  };
10524
10737
  //#endregion
10525
10738
  //#region src/main.ts
10526
- function oa(e, t = {}) {
10527
- let n = H(H({}, aa), t), r = document.getElementById(e);
10739
+ function ua(e, t = {}) {
10740
+ let n = U(U({}, la), t), r = document.getElementById(e);
10528
10741
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
10529
10742
  let i = document.createElement("canvas");
10530
10743
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
10531
10744
  n._onReadyCallback = t;
10532
- let r = new ia(i.id, n);
10745
+ let r = new ca(i.id, n);
10533
10746
  window[e] = r;
10534
10747
  });
10535
10748
  }
10536
10749
  //#endregion
10537
- export { oa as default };
10750
+ export { ua as default };
10538
10751
 
10539
10752
  //# sourceMappingURL=main.js.map