@anu3ev/fabric-image-editor 0.7.1 → 0.7.3

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
@@ -801,7 +801,7 @@ var re = {
801
801
  "pointer-events": "none",
802
802
  "white-space": "nowrap",
803
803
  "box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
804
- }, H = "fabric-editor-angle-indicator", oe = class e {
804
+ }, H = "fabric-editor-angle-indicator", U = class e {
805
805
  constructor({ editor: e }) {
806
806
  this.isActive = !1, this.currentAngle = 0, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._createDOM(), this._bindEvents();
807
807
  }
@@ -851,30 +851,30 @@ var re = {
851
851
  destroy() {
852
852
  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)), this.el?.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
853
853
  }
854
- }, se = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.originX.originY.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(".");
854
+ }, oe = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.originX.originY.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(".");
855
855
  //#endregion
856
856
  //#region src/editor/history-manager/diff-normalization.ts
857
- function ce({ state: e }) {
857
+ function se({ state: e }) {
858
858
  return JSON.parse(JSON.stringify(e));
859
859
  }
860
- function U({ value: e }) {
860
+ function ce({ value: e }) {
861
861
  if (Array.isArray(e)) {
862
862
  let t = [];
863
- for (let n = 0; n < e.length; n += 1) t.push(U({ value: e[n] }));
863
+ for (let n = 0; n < e.length; n += 1) t.push(ce({ value: e[n] }));
864
864
  return t;
865
865
  }
866
866
  if (e && typeof e == "object") {
867
867
  let t = {}, n = Object.keys(e).sort();
868
868
  for (let r = 0; r < n.length; r += 1) {
869
869
  let i = n[r];
870
- t[i] = U({ value: e[i] });
870
+ t[i] = ce({ value: e[i] });
871
871
  }
872
872
  return t;
873
873
  }
874
874
  return e;
875
875
  }
876
876
  function le({ value: e }) {
877
- let t = U({ value: e });
877
+ let t = ce({ value: e });
878
878
  return JSON.stringify(t);
879
879
  }
880
880
  function ue({ prevState: e, nextState: t }) {
@@ -924,7 +924,7 @@ function he({ prevState: e, nextState: t }) {
924
924
  o !== c || s !== l || (t.width = n, t.height = r);
925
925
  }
926
926
  function ge({ prevState: e, nextState: t }) {
927
- let n = ce({ state: e }), r = ce({ state: t });
927
+ let n = se({ state: e }), r = se({ state: t });
928
928
  return me({ objects: n.objects }), me({ objects: r.objects }), he({
929
929
  prevState: n,
930
930
  nextState: r
@@ -1120,7 +1120,7 @@ var je = class {
1120
1120
  }
1121
1121
  _serializeCanvasState() {
1122
1122
  let { canvas: e } = this;
1123
- return e.toDatalessObject([...se]);
1123
+ return e.toDatalessObject([...oe]);
1124
1124
  }
1125
1125
  _handlePendingSaveTimeout() {
1126
1126
  if (this._pendingSaveTimeoutId === null) return;
@@ -1162,7 +1162,7 @@ var je = class {
1162
1162
  try {
1163
1163
  let e = Ae({
1164
1164
  canvas: this.canvas,
1165
- callback: () => this.canvas.toDatalessObject([...se])
1165
+ callback: () => this.canvas.toDatalessObject([...oe])
1166
1166
  });
1167
1167
  if (console.timeEnd("saveState"), !this.baseState) {
1168
1168
  this.baseState = e, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
@@ -1205,7 +1205,11 @@ var je = class {
1205
1205
  let f = t.getObjects().find((e) => e.id === "montage-area"), p = !1, m = !1;
1206
1206
  f && (this.editor.montageArea = f, n.placeMontageAreaAtCanonicalScenePosition(), p = f.width !== l || f.height !== u, m = s !== t.getWidth() || c !== t.getHeight());
1207
1207
  let h = t.getObjects().find((e) => e.id === "background");
1208
- h ? i.backgroundObject = h : i.removeBackground({ withoutSave: !0 }), f && (r.ensureOverlay(), m ? n.updateCanvas() : p ? (a.calculateAndApplyDefaultZoom(), n.refreshMontageDerivedState()) : (a.updateDefaultZoom(), n.centerViewportToMontageArea(), n.refreshMontageDerivedState(), o.updateBounds())), t.renderAll(), t.fire("editor:history-state-loaded", {
1208
+ h ? i.backgroundObject = h : i.removeBackground({ withoutSave: !0 });
1209
+ let { textManager: g } = this.editor;
1210
+ g && t.getObjects().forEach((e) => {
1211
+ g.commitStandaloneTextScale({ target: e });
1212
+ }), f && (r.ensureOverlay(), m ? n.updateCanvas() : p ? (a.calculateAndApplyDefaultZoom(), n.refreshMontageDerivedState()) : (a.updateDefaultZoom(), n.centerViewportToMontageArea(), n.refreshMontageDerivedState(), o.updateBounds())), t.renderAll(), t.fire("editor:history-state-loaded", {
1209
1213
  fullState: e,
1210
1214
  currentIndex: this.currentIndex,
1211
1215
  totalChangesCount: this.totalChangesCount,
@@ -1786,19 +1790,23 @@ var Ve = class {
1786
1790
  };
1787
1791
  }
1788
1792
  getObjectPlacement({ object: e, originX: t, originY: n }) {
1789
- let r = t ?? e.originX ?? "center", i = n ?? e.originY ?? "center", a = e.getPointByOrigin(r, i);
1793
+ let r = t ?? e.originX ?? "center", i = n ?? e.originY ?? "center", a = e.getPointByOrigin(r, i), o = e.group ? a.transform(e.group.calcTransformMatrix()) : a;
1790
1794
  return {
1791
- left: a.x,
1792
- top: a.y,
1795
+ left: o.x,
1796
+ top: o.y,
1793
1797
  originX: r,
1794
1798
  originY: i
1795
1799
  };
1796
1800
  }
1797
1801
  resolveObjectPlacement({ object: e, left: t, top: n, originX: r, originY: i, fallbackPoint: a }) {
1798
- let o = r ?? e.originX ?? "center", s = i ?? e.originY ?? "center", c = a ?? e.getPointByOrigin(o, s);
1802
+ let o = r ?? e.originX ?? "center", s = i ?? e.originY ?? "center", c = this.getObjectPlacement({
1803
+ object: e,
1804
+ originX: o,
1805
+ originY: s
1806
+ });
1799
1807
  return {
1800
- left: t ?? c.x,
1801
- top: n ?? c.y,
1808
+ left: t ?? a?.x ?? c.left,
1809
+ top: n ?? a?.y ?? c.top,
1802
1810
  originX: o,
1803
1811
  originY: s
1804
1812
  };
@@ -1808,7 +1816,7 @@ var Ve = class {
1808
1816
  e.set({
1809
1817
  originX: i,
1810
1818
  originY: a
1811
- }), e.setPositionByOrigin(new p(n, r), i, a), e.setCoords();
1819
+ }), e.setXY(new p(n, r), i, a), e.setCoords();
1812
1820
  }
1813
1821
  centerObjectToMontageArea({ object: e }) {
1814
1822
  let t = this.getMontageAreaSceneCenter();
@@ -2265,24 +2273,13 @@ var Ve = class {
2265
2273
  }), Ke = ({ normalizedX: e, normalizedY: t, bounds: n }) => {
2266
2274
  let { left: r, top: i, width: a, height: o } = n;
2267
2275
  return new p(r + e * a, i + t * o);
2268
- }, qe = ({ object: e, bounds: t }) => {
2269
- if (!t) return null;
2270
- try {
2271
- let n = e.originX ?? "center", r = e.originY ?? "center", i = e.getPointByOrigin(n, r), { left: a, top: o, width: s, height: c } = t;
2272
- return {
2273
- x: (i.x - a) / s,
2274
- y: (i.y - o) / c
2275
- };
2276
- } catch {
2277
- return null;
2278
- }
2279
- }, Je = ({ object: e }) => {
2280
- let { left: t = 0, top: n = 0, width: r = 0, height: i = 0, scaleX: a = 1, scaleY: o = 1, strokeWidth: s = 0, strokeUniform: c = !1 } = e, l = e.type === "Textbox", u = c ? 0 : s, d = r + u, f = i + u, p = {
2276
+ }, qe = ({ object: e }) => {
2277
+ let { left: t = 0, top: n = 0, width: r = 0, height: i = 0, scaleX: a = 1, scaleY: o = 1, strokeWidth: s = 0, strokeUniform: c = !1 } = e, l = typeof e.type == "string" ? e.type.toLowerCase() : "", u = e instanceof _ || l === "textbox" || l === "background-textbox", d = c ? 0 : s, f = r + d, p = i + d, m = {
2281
2278
  left: Math.round(t),
2282
2279
  top: Math.round(n)
2283
2280
  };
2284
- l || (d > 0 && (p.scaleX = Math.max(1, Math.round(d * a)) / d), f > 0 && (p.scaleY = Math.max(1, Math.round(f * o)) / f)), e.set(p), e.setCoords();
2285
- }, Ye = ({ object: e }) => {
2281
+ u || (f > 0 && (m.scaleX = Math.max(1, Math.round(f * a)) / f), p > 0 && (m.scaleY = Math.max(1, Math.round(p * o)) / p)), e.set(m), e.setCoords();
2282
+ }, Je = ({ object: e }) => {
2286
2283
  if (!e) return null;
2287
2284
  try {
2288
2285
  e.setCoords();
@@ -2301,17 +2298,17 @@ var Ve = class {
2301
2298
  };
2302
2299
  //#endregion
2303
2300
  //#region src/editor/utils/primitive-shapes.ts
2304
- function Xe({ canvas: e, object: t, left: n, top: r, centerPoint: i, flags: a }) {
2301
+ function Ye({ canvas: e, object: t, left: n, top: r, centerPoint: i, flags: a }) {
2305
2302
  let { withoutSelection: o, withoutAdding: s } = a;
2306
2303
  if (n === void 0 && r === void 0) {
2307
2304
  let n = i ?? e.getCenterPoint();
2308
2305
  t.setPositionByOrigin(n, "center", "center"), t.setCoords();
2309
2306
  }
2310
- return Je({ object: t }), s ? t : (e.add(t), o || e.setActiveObject(t), e.renderAll(), t);
2307
+ return qe({ object: t }), s ? t : (e.add(t), o || e.setActiveObject(t), e.renderAll(), t);
2311
2308
  }
2312
- var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2309
+ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2313
2310
  let { id: i = `rect-${D()}`, left: a, top: o, width: s = 100, height: c = 100, fill: l = "blue", ...u } = t;
2314
- return Xe({
2311
+ return Ye({
2315
2312
  canvas: e,
2316
2313
  object: new g({
2317
2314
  id: i,
@@ -2327,7 +2324,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2327
2324
  centerPoint: n,
2328
2325
  flags: r
2329
2326
  });
2330
- }, Qe = class {
2327
+ }, Ze = class {
2331
2328
  constructor({ editor: e }) {
2332
2329
  this.editor = e, this.isBlocked = !1, this.overlayMask = null;
2333
2330
  }
@@ -2349,7 +2346,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2349
2346
  }
2350
2347
  _createOverlay() {
2351
2348
  let { historyManager: e, options: { overlayMaskColor: t = "rgba(0,0,0,0.5)" } } = this.editor;
2352
- e.suspendHistory(), this.overlayMask = Ze({
2349
+ e.suspendHistory(), this.overlayMask = Xe({
2353
2350
  canvas: this.editor.canvas,
2354
2351
  options: {
2355
2352
  ...this._getOverlayGeometry(),
@@ -2387,7 +2384,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2387
2384
  e.evented = !0, e.selectable = !0;
2388
2385
  }), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), n.resumeHistory(), n.flushDeferredSaveAfterUnblock();
2389
2386
  }
2390
- }, $e = class e {
2387
+ }, Qe = class e {
2391
2388
  constructor({ editor: e }) {
2392
2389
  this.editor = e, this.backgroundObject = null;
2393
2390
  }
@@ -2579,7 +2576,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2579
2576
  this.backgroundObject && a !== i + 1 && e.moveObjectTo(this.backgroundObject, i + 1), e.requestRenderAll(), n.resumeHistory();
2580
2577
  }
2581
2578
  _createColorBackground(e) {
2582
- this.backgroundObject = Ze({
2579
+ this.backgroundObject = Xe({
2583
2580
  canvas: this.editor.canvas,
2584
2581
  options: {
2585
2582
  ...this._getMontageBackgroundRectOptions(),
@@ -2596,7 +2593,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2596
2593
  }), this.refresh();
2597
2594
  }
2598
2595
  _createGradientBackground(t) {
2599
- this.backgroundObject = Ze({
2596
+ this.backgroundObject = Xe({
2600
2597
  canvas: this.editor.canvas,
2601
2598
  options: {
2602
2599
  ...this._getMontageBackgroundRectOptions(),
@@ -2695,7 +2692,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2695
2692
  return e.color === n.color && Math.abs(e.offset - n.offset) < 1e-4;
2696
2693
  }) ? !1 : e.type === "linear" && t.type === "linear" ? Math.abs(e.coords.x1 - t.coords.x1) < 1e-4 && Math.abs(e.coords.y1 - t.coords.y1) < 1e-4 && Math.abs(e.coords.x2 - t.coords.x2) < 1e-4 && Math.abs(e.coords.y2 - t.coords.y2) < 1e-4 : e.type === "radial" && t.type === "radial" ? Math.abs(e.coords.x1 - t.coords.x1) < 1e-4 && Math.abs(e.coords.y1 - t.coords.y1) < 1e-4 && Math.abs(e.coords.x2 - t.coords.x2) < 1e-4 && Math.abs(e.coords.y2 - t.coords.y2) < 1e-4 && Math.abs(e.coords.r1 - t.coords.r1) < 1e-4 && Math.abs(e.coords.r2 - t.coords.r2) < 1e-4 : !1;
2697
2694
  }
2698
- }, et = class t {
2695
+ }, $e = class t {
2699
2696
  constructor({ editor: e }) {
2700
2697
  this.editor = e;
2701
2698
  }
@@ -2769,32 +2766,32 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2769
2766
  e.sendObjectBackwards(t.obj);
2770
2767
  });
2771
2768
  }
2772
- }, G = 180, tt = {
2769
+ }, G = 180, et = {
2773
2770
  top: .2,
2774
2771
  right: .2,
2775
2772
  bottom: .2,
2776
2773
  left: .2
2777
- }, nt = ({ value: e }) => Number(e.toFixed(4)), rt = ({ sides: e, radius: t = 50, centerX: n = 50, centerY: r = 50, rotation: i = -Math.PI / 2 }) => {
2774
+ }, tt = ({ value: e }) => Number(e.toFixed(4)), nt = ({ sides: e, radius: t = 50, centerX: n = 50, centerY: r = 50, rotation: i = -Math.PI / 2 }) => {
2778
2775
  let a = [];
2779
2776
  for (let o = 0; o < e; o += 1) {
2780
2777
  let s = i + o * Math.PI * 2 / e;
2781
2778
  a.push({
2782
- x: nt({ value: n + t * Math.cos(s) }),
2783
- y: nt({ value: r + t * Math.sin(s) })
2779
+ x: tt({ value: n + t * Math.cos(s) }),
2780
+ y: tt({ value: r + t * Math.sin(s) })
2784
2781
  });
2785
2782
  }
2786
2783
  return a;
2787
- }, it = ({ spikes: e, outerRadius: t = 50, innerRadius: n = 22, centerX: r = 50, centerY: i = 50, rotation: a = -Math.PI / 2 }) => {
2784
+ }, rt = ({ spikes: e, outerRadius: t = 50, innerRadius: n = 22, centerX: r = 50, centerY: i = 50, rotation: a = -Math.PI / 2 }) => {
2788
2785
  let o = [], s = e * 2;
2789
2786
  for (let c = 0; c < s; c += 1) {
2790
2787
  let s = c % 2 == 0 ? t : n, l = a + c * Math.PI / e;
2791
2788
  o.push({
2792
- x: nt({ value: r + s * Math.cos(l) }),
2793
- y: nt({ value: i + s * Math.sin(l) })
2789
+ x: tt({ value: r + s * Math.cos(l) }),
2790
+ y: tt({ value: i + s * Math.sin(l) })
2794
2791
  });
2795
2792
  }
2796
2793
  return o;
2797
- }, at = [
2794
+ }, it = [
2798
2795
  {
2799
2796
  key: "circle",
2800
2797
  type: "ellipse",
@@ -2860,7 +2857,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2860
2857
  type: "polygon",
2861
2858
  width: G,
2862
2859
  height: G,
2863
- points: rt({
2860
+ points: nt({
2864
2861
  sides: 5,
2865
2862
  radius: 50,
2866
2863
  rotation: -Math.PI / 2
@@ -2877,7 +2874,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2877
2874
  type: "polygon",
2878
2875
  width: G,
2879
2876
  height: G,
2880
- points: rt({
2877
+ points: nt({
2881
2878
  sides: 6,
2882
2879
  radius: 50,
2883
2880
  rotation: 0
@@ -2894,7 +2891,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2894
2891
  type: "polygon",
2895
2892
  width: G,
2896
2893
  height: G,
2897
- points: it({
2894
+ points: rt({
2898
2895
  spikes: 5,
2899
2896
  outerRadius: 50,
2900
2897
  innerRadius: 21,
@@ -2912,7 +2909,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
2912
2909
  type: "polygon",
2913
2910
  width: G,
2914
2911
  height: G,
2915
- points: it({
2912
+ points: rt({
2916
2913
  spikes: 4,
2917
2914
  outerRadius: 50,
2918
2915
  innerRadius: 16,
@@ -3299,7 +3296,7 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3299
3296
  type: "polygon",
3300
3297
  width: G,
3301
3298
  height: G,
3302
- points: it({
3299
+ points: rt({
3303
3300
  spikes: 14,
3304
3301
  outerRadius: 50,
3305
3302
  innerRadius: 40,
@@ -3390,21 +3387,21 @@ var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
3390
3387
  left: .2
3391
3388
  }
3392
3389
  }
3393
- ], ot = "circle", st = "center", ct = {};
3394
- for (let e = 0; e < at.length; e += 1) {
3395
- let t = at[e];
3396
- ct[t.key] = t;
3390
+ ], at = "circle", ot = "center", st = {};
3391
+ for (let e = 0; e < it.length; e += 1) {
3392
+ let t = it[e];
3393
+ st[t.key] = t;
3397
3394
  }
3398
- var lt = ct, ut = ({ presetKey: e }) => lt[e] ?? null, dt = ({ preset: e, rounding: t }) => (typeof t == "number" ? t : 0) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key, ft = ({ preset: e, overridePadding: t }) => {
3395
+ var ct = st, lt = ({ presetKey: e }) => ct[e] ?? null, ut = ({ preset: e, rounding: t }) => (typeof t == "number" ? t : 0) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key, dt = ({ preset: e, overridePadding: t }) => {
3399
3396
  let n = e.textPadding ?? {};
3400
3397
  return {
3401
- top: t?.top ?? n.top ?? tt.top,
3402
- right: t?.right ?? n.right ?? tt.right,
3403
- bottom: t?.bottom ?? n.bottom ?? tt.bottom,
3404
- left: t?.left ?? n.left ?? tt.left
3398
+ top: t?.top ?? n.top ?? et.top,
3399
+ right: t?.right ?? n.right ?? et.right,
3400
+ bottom: t?.bottom ?? n.bottom ?? et.bottom,
3401
+ left: t?.left ?? n.left ?? et.left
3405
3402
  };
3406
- }, pt = ({ preset: e }) => e.type === "rect" || e.type === "triangle" || e.type === "polygon" || e.type === "polyline" ? !0 : e.type === "ellipse" || e.type === "svg" ? !1 : mt({ path: e.path });
3407
- function mt({ path: e }) {
3403
+ }, ft = ({ preset: e }) => e.type === "rect" || e.type === "triangle" || e.type === "polygon" || e.type === "polyline" ? !0 : e.type === "ellipse" || e.type === "svg" ? !1 : pt({ path: e.path });
3404
+ function pt({ path: e }) {
3408
3405
  let t = e.match(/[a-zA-Z]/g) ?? [], n = new Set([
3409
3406
  "M",
3410
3407
  "L",
@@ -3420,11 +3417,11 @@ function mt({ path: e }) {
3420
3417
  }
3421
3418
  //#endregion
3422
3419
  //#region src/editor/shape-manager/shape-factory.ts
3423
- var ht = 1, gt = 1e-4;
3424
- function _t({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
3425
- let a = xt({
3426
- width: Math.max(ht, t),
3427
- height: Math.max(ht, n),
3420
+ var mt = 1, ht = 1e-4;
3421
+ function gt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
3422
+ let a = bt({
3423
+ width: Math.max(mt, t),
3424
+ height: Math.max(mt, n),
3428
3425
  strokeWidth: i
3429
3426
  });
3430
3427
  if (e instanceof g) {
@@ -3443,7 +3440,7 @@ function _t({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
3443
3440
  }), e.setCoords();
3444
3441
  return;
3445
3442
  }
3446
- let { width: o = ht, height: s = ht } = e, c = Math.max(ht, o), l = Math.max(ht, s);
3443
+ let { width: o = mt, height: s = mt } = e, c = Math.max(mt, o), l = Math.max(mt, s);
3447
3444
  e.set({
3448
3445
  scaleX: a.width / c,
3449
3446
  scaleY: a.height / l,
@@ -3453,15 +3450,15 @@ function _t({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
3453
3450
  originY: "center"
3454
3451
  }), e.setCoords();
3455
3452
  }
3456
- async function vt({ preset: e, width: t, height: n, style: r, rounding: i }) {
3457
- let a = await bt({
3453
+ async function _t({ preset: e, width: t, height: n, style: r, rounding: i }) {
3454
+ let a = await yt({
3458
3455
  preset: e,
3459
3456
  rounding: i
3460
3457
  });
3461
- return yt({
3458
+ return vt({
3462
3459
  shape: a,
3463
3460
  style: r
3464
- }), _t({
3461
+ }), gt({
3465
3462
  shape: a,
3466
3463
  width: t,
3467
3464
  height: n,
@@ -3475,11 +3472,11 @@ async function vt({ preset: e, width: t, height: n, style: r, rounding: i }) {
3475
3472
  shapeNodeType: "shape"
3476
3473
  }), a;
3477
3474
  }
3478
- function yt({ shape: e, style: t }) {
3475
+ function vt({ shape: e, style: t }) {
3479
3476
  let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = t;
3480
3477
  if (e instanceof l) {
3481
3478
  let n = e.getObjects();
3482
- for (let e = 0; e < n.length; e += 1) yt({
3479
+ for (let e = 0; e < n.length; e += 1) vt({
3483
3480
  shape: n[e],
3484
3481
  style: t
3485
3482
  });
@@ -3493,7 +3490,7 @@ function yt({ shape: e, style: t }) {
3493
3490
  };
3494
3491
  n !== void 0 && (s.fill = n), r !== void 0 && (s.stroke = r), i !== void 0 && (s.strokeWidth = i), a !== void 0 && (s.strokeDashArray = a), o !== void 0 && (s.opacity = o), e.set(s), e.setCoords();
3495
3492
  }
3496
- async function bt({ preset: e, rounding: t }) {
3493
+ async function yt({ preset: e, rounding: t }) {
3497
3494
  return e.type === "rect" ? new g({
3498
3495
  width: 100,
3499
3496
  height: 100,
@@ -3508,18 +3505,18 @@ async function bt({ preset: e, rounding: t }) {
3508
3505
  originY: "center",
3509
3506
  left: 0,
3510
3507
  top: 0
3511
- }) : e.type === "triangle" ? St({ rounding: t }) : e.type === "polygon" ? wt({
3508
+ }) : e.type === "triangle" ? xt({ rounding: t }) : e.type === "polygon" ? Ct({
3512
3509
  points: e.points,
3513
3510
  type: "polygon",
3514
3511
  rounding: t
3515
- }) : e.type === "polyline" ? wt({
3512
+ }) : e.type === "polyline" ? Ct({
3516
3513
  points: e.points,
3517
3514
  type: "polyline",
3518
3515
  rounding: t
3519
- }) : e.type === "path" ? Ct({
3516
+ }) : e.type === "path" ? St({
3520
3517
  path: e.path,
3521
3518
  rounding: t
3522
- }) : e.type === "svg" ? Mt({ svg: e.svg }) : new g({
3519
+ }) : e.type === "svg" ? jt({ svg: e.svg }) : new g({
3523
3520
  width: 100,
3524
3521
  height: 100,
3525
3522
  originX: "center",
@@ -3528,15 +3525,15 @@ async function bt({ preset: e, rounding: t }) {
3528
3525
  top: 0
3529
3526
  });
3530
3527
  }
3531
- function xt({ width: e, height: t, strokeWidth: n }) {
3528
+ function bt({ width: e, height: t, strokeWidth: n }) {
3532
3529
  let r = Math.max(0, n ?? 0);
3533
3530
  return {
3534
- width: Math.max(ht, e - r),
3535
- height: Math.max(ht, t - r)
3531
+ width: Math.max(mt, e - r),
3532
+ height: Math.max(mt, t - r)
3536
3533
  };
3537
3534
  }
3538
- function St({ rounding: e }) {
3539
- return jt({ rounding: e }) ? Dt({
3535
+ function xt({ rounding: e }) {
3536
+ return At({ rounding: e }) ? Et({
3540
3537
  points: [
3541
3538
  {
3542
3539
  x: 50,
@@ -3562,13 +3559,13 @@ function St({ rounding: e }) {
3562
3559
  top: 0
3563
3560
  });
3564
3561
  }
3565
- function Ct({ path: e, rounding: t }) {
3566
- return jt({ rounding: t }) && Et({
3562
+ function St({ path: e, rounding: t }) {
3563
+ return At({ rounding: t }) && Tt({
3567
3564
  path: e,
3568
3565
  rounding: Math.max(0, t ?? 0)
3569
- }) || Tt({ path: e });
3566
+ }) || wt({ path: e });
3570
3567
  }
3571
- function wt({ points: e, type: t, rounding: n }) {
3568
+ function Ct({ points: e, type: t, rounding: n }) {
3572
3569
  let r = e.length > 0 ? e : [
3573
3570
  {
3574
3571
  x: 0,
@@ -3583,13 +3580,13 @@ function wt({ points: e, type: t, rounding: n }) {
3583
3580
  y: 100
3584
3581
  }
3585
3582
  ];
3586
- if (jt({ rounding: n })) {
3587
- if (t === "polygon" && r.length >= 3) return Dt({
3583
+ if (At({ rounding: n })) {
3584
+ if (t === "polygon" && r.length >= 3) return Et({
3588
3585
  points: r,
3589
3586
  rounding: Math.max(0, n ?? 0),
3590
3587
  closed: !0
3591
3588
  });
3592
- if (t === "polyline" && r.length >= 2) return Dt({
3589
+ if (t === "polyline" && r.length >= 2) return Et({
3593
3590
  points: r,
3594
3591
  rounding: Math.max(0, n ?? 0),
3595
3592
  closed: !1
@@ -3607,7 +3604,7 @@ function wt({ points: e, type: t, rounding: n }) {
3607
3604
  top: 0
3608
3605
  });
3609
3606
  }
3610
- function Tt({ path: e }) {
3607
+ function wt({ path: e }) {
3611
3608
  return new d(e, {
3612
3609
  originX: "center",
3613
3610
  originY: "center",
@@ -3615,8 +3612,8 @@ function Tt({ path: e }) {
3615
3612
  top: 0
3616
3613
  });
3617
3614
  }
3618
- function Et({ path: e, rounding: t }) {
3619
- let n = Tt({ path: e }).path ?? [], r = C.makePathSimpler(n), i = [], a = !1;
3615
+ function Tt({ path: e, rounding: t }) {
3616
+ let n = wt({ path: e }).path ?? [], r = C.makePathSimpler(n), i = [], a = !1;
3620
3617
  for (let e = 0; e < r.length; e += 1) {
3621
3618
  let t = r[e];
3622
3619
  if (!t) return null;
@@ -3636,14 +3633,14 @@ function Et({ path: e, rounding: t }) {
3636
3633
  }
3637
3634
  return null;
3638
3635
  }
3639
- return i.length < 2 || a && i.length < 3 ? null : Dt({
3636
+ return i.length < 2 || a && i.length < 3 ? null : Et({
3640
3637
  points: i,
3641
3638
  rounding: t,
3642
3639
  closed: a
3643
3640
  });
3644
3641
  }
3645
- function Dt({ points: e, rounding: t, closed: n }) {
3646
- return new d(Ot({
3642
+ function Et({ points: e, rounding: t, closed: n }) {
3643
+ return new d(Dt({
3647
3644
  points: e,
3648
3645
  radius: t,
3649
3646
  closed: n
@@ -3654,7 +3651,7 @@ function Dt({ points: e, rounding: t, closed: n }) {
3654
3651
  top: 0
3655
3652
  });
3656
3653
  }
3657
- function Ot({ points: e, radius: t, closed: n }) {
3654
+ function Dt({ points: e, radius: t, closed: n }) {
3658
3655
  let r = e.length;
3659
3656
  if (r === 0) return "";
3660
3657
  if (!n && r === 1) {
@@ -3662,14 +3659,14 @@ function Ot({ points: e, radius: t, closed: n }) {
3662
3659
  return `M ${K({ value: t.x })} ${K({ value: t.y })}`;
3663
3660
  }
3664
3661
  let i = Math.max(0, t);
3665
- if (i <= 0) return kt({
3662
+ if (i <= 0) return Ot({
3666
3663
  points: e,
3667
3664
  closed: n
3668
3665
  });
3669
3666
  if (n) {
3670
3667
  let t = [];
3671
3668
  for (let n = 0; n < r; n += 1) {
3672
- let a = n === 0 ? r - 1 : n - 1, o = n === r - 1 ? 0 : n + 1, s = At({
3669
+ let a = n === 0 ? r - 1 : n - 1, o = n === r - 1 ? 0 : n + 1, s = kt({
3673
3670
  previous: e[a],
3674
3671
  current: e[n],
3675
3672
  next: e[o],
@@ -3684,13 +3681,13 @@ function Ot({ points: e, radius: t, closed: n }) {
3684
3681
  }
3685
3682
  return a += " Z", a;
3686
3683
  }
3687
- if (r === 2) return kt({
3684
+ if (r === 2) return Ot({
3688
3685
  points: e,
3689
3686
  closed: !1
3690
3687
  });
3691
3688
  let a = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
3692
3689
  for (let t = 1; t < r - 1; t += 1) {
3693
- let n = At({
3690
+ let n = kt({
3694
3691
  previous: e[t - 1],
3695
3692
  current: e[t],
3696
3693
  next: e[t + 1],
@@ -3701,7 +3698,7 @@ function Ot({ points: e, radius: t, closed: n }) {
3701
3698
  let o = e[r - 1];
3702
3699
  return a += ` L ${K({ value: o.x })} ${K({ value: o.y })}`, a;
3703
3700
  }
3704
- function kt({ points: e, closed: t }) {
3701
+ function Ot({ points: e, closed: t }) {
3705
3702
  if (e.length === 0) return "";
3706
3703
  let n = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
3707
3704
  for (let t = 1; t < e.length; t += 1) {
@@ -3710,7 +3707,7 @@ function kt({ points: e, closed: t }) {
3710
3707
  }
3711
3708
  return t && (n += " Z"), n;
3712
3709
  }
3713
- function At({ previous: e, current: t, next: n, radius: r }) {
3710
+ function kt({ previous: e, current: t, next: n, radius: r }) {
3714
3711
  let i = {
3715
3712
  x: e.x - t.x,
3716
3713
  y: e.y - t.y
@@ -3718,7 +3715,7 @@ function At({ previous: e, current: t, next: n, radius: r }) {
3718
3715
  x: n.x - t.x,
3719
3716
  y: n.y - t.y
3720
3717
  }, o = Math.hypot(i.x, i.y), s = Math.hypot(a.x, a.y);
3721
- if (o <= gt || s <= gt) return {
3718
+ if (o <= ht || s <= ht) return {
3722
3719
  start: {
3723
3720
  x: K({ value: t.x }),
3724
3721
  y: K({ value: t.y })
@@ -3740,13 +3737,13 @@ function At({ previous: e, current: t, next: n, radius: r }) {
3740
3737
  }
3741
3738
  };
3742
3739
  }
3743
- function jt({ rounding: e }) {
3740
+ function At({ rounding: e }) {
3744
3741
  return Math.max(0, e ?? 0) > 0;
3745
3742
  }
3746
3743
  function K({ value: e }) {
3747
3744
  return Number(e.toFixed(4));
3748
3745
  }
3749
- async function Mt({ svg: e }) {
3746
+ async function jt({ svg: e }) {
3750
3747
  let t = await x(e), n = C.groupSVGElements(t.objects, t.options);
3751
3748
  return n.set({
3752
3749
  originX: "center",
@@ -3757,24 +3754,24 @@ async function Mt({ svg: e }) {
3757
3754
  }
3758
3755
  //#endregion
3759
3756
  //#region src/editor/shape-manager/shape-layout.ts
3760
- var q = 1, Nt = .5, Pt = 12, Ft = 12, It = .45, Lt = 8, Rt = 8, zt = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s }) => {
3761
- let c = Gt({ padding: s }), l = Math.max(q, e.shapeManualBaseWidth ?? r), u = Math.max(q, e.shapeManualBaseHeight ?? i), d = Vt({
3757
+ var q = 1, Mt = .5, Nt = 12, Pt = 12, Ft = .45, It = 8, Lt = 8, Rt = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s }) => {
3758
+ let c = Wt({ padding: s }), l = Math.max(q, e.shapeManualBaseWidth ?? r), u = Math.max(q, e.shapeManualBaseHeight ?? i), d = Bt({
3762
3759
  text: n,
3763
3760
  padding: c
3764
- }), f = Math.max(q, r, d), p = Ut({
3761
+ }), f = Math.max(q, r, d), p = Ht({
3765
3762
  text: n,
3766
3763
  width: f,
3767
3764
  height: i,
3768
3765
  padding: c
3769
3766
  }), m = Math.max(q, p);
3770
- _t({
3767
+ gt({
3771
3768
  shape: t,
3772
3769
  width: f,
3773
3770
  height: m,
3774
3771
  rounding: e.shapeRounding,
3775
3772
  strokeWidth: e.shapeStrokeWidth
3776
3773
  });
3777
- let { frame: h, splitByGrapheme: g, textTop: _ } = Ht({
3774
+ let { frame: h, splitByGrapheme: g, textTop: _ } = Vt({
3778
3775
  text: n,
3779
3776
  width: f,
3780
3777
  height: m,
@@ -3803,56 +3800,56 @@ var q = 1, Nt = .5, Pt = 12, Ft = 12, It = .45, Lt = 8, Rt = 8, zt = ({ group: e
3803
3800
  scaleX: 1,
3804
3801
  scaleY: 1
3805
3802
  }), e.set("dirty", !0), e.setCoords();
3806
- }, Bt = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i, montageAreaWidth: a }) => {
3803
+ }, zt = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i, montageAreaWidth: a }) => {
3807
3804
  let o = Math.max(q, t), s = Math.max(q, n);
3808
- if (!Kt({ text: e })) return s;
3805
+ if (!Gt({ text: e })) return s;
3809
3806
  let c = Number.isFinite(a) && a > 0 ? Math.max(q, a) : Math.max(o, s), l = Math.max(0, i ?? 0), u = Math.max(s, c);
3810
3807
  if (l >= u) return Math.max(o, s);
3811
- let d = Gt({ padding: r }), f = u, p = Zt({
3808
+ let d = Wt({ padding: r }), f = u, p = Xt({
3812
3809
  text: e,
3813
- frameWidth: Yt({
3810
+ frameWidth: Jt({
3814
3811
  width: f,
3815
3812
  padding: d
3816
3813
  })
3817
3814
  });
3818
3815
  if (p.hasWrappedLines) return f;
3819
- let m = Math.max(q, p.longestLineWidth), h = Math.min(f, Math.max(s, Wt({
3816
+ let m = Math.max(q, p.longestLineWidth), h = Math.min(f, Math.max(s, Ut({
3820
3817
  frameWidth: m,
3821
3818
  padding: d
3822
3819
  })));
3823
- for (let t = 0; t < Lt; t += 1) {
3824
- let t = Yt({
3820
+ for (let t = 0; t < It; t += 1) {
3821
+ let t = Jt({
3825
3822
  width: h,
3826
3823
  padding: d
3827
- }), n = Zt({
3824
+ }), n = Xt({
3828
3825
  text: e,
3829
3826
  frameWidth: t
3830
- }), r = t >= m - Nt;
3827
+ }), r = t >= m - Mt;
3831
3828
  if (!n.hasWrappedLines && r) return h;
3832
- if (h >= f - Nt) return f;
3829
+ if (h >= f - Mt) return f;
3833
3830
  let i = n.hasWrappedLines ? Math.max(m + 1, t + 1) : m;
3834
- h = Math.min(f, Math.max(h + 1, Wt({
3831
+ h = Math.min(f, Math.max(h + 1, Ut({
3835
3832
  frameWidth: i,
3836
3833
  padding: d
3837
3834
  })));
3838
3835
  }
3839
3836
  return h;
3840
- }, Vt = ({ text: e, padding: t }) => {
3841
- if (!Kt({ text: e })) return q;
3842
- let n = Gt({ padding: t });
3843
- return Wt({
3844
- frameWidth: $t({ text: e }),
3837
+ }, Bt = ({ text: e, padding: t }) => {
3838
+ if (!Gt({ text: e })) return q;
3839
+ let n = Wt({ padding: t });
3840
+ return Ut({
3841
+ frameWidth: Qt({ text: e }),
3845
3842
  padding: n
3846
3843
  });
3847
- }, Ht = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
3848
- let a = Jt({
3844
+ }, Vt = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
3845
+ let a = qt({
3849
3846
  width: Math.max(q, t),
3850
3847
  height: Math.max(q, n),
3851
- padding: Gt({ padding: i })
3852
- }), o = rn({
3848
+ padding: Wt({ padding: i })
3849
+ }), o = nn({
3853
3850
  text: e,
3854
3851
  frameWidth: a.width
3855
- }), s = Qt({
3852
+ }), s = Zt({
3856
3853
  text: e,
3857
3854
  frameWidth: a.width,
3858
3855
  splitByGrapheme: o
@@ -3860,73 +3857,73 @@ var q = 1, Nt = .5, Pt = 12, Ft = 12, It = .45, Lt = 8, Rt = 8, zt = ({ group: e
3860
3857
  return {
3861
3858
  frame: a,
3862
3859
  splitByGrapheme: o,
3863
- textTop: tn({
3860
+ textTop: en({
3864
3861
  alignV: r,
3865
3862
  frameHeight: a.height,
3866
3863
  frameTop: a.top,
3867
3864
  textHeight: s
3868
3865
  })
3869
3866
  };
3870
- }, Ut = ({ text: e, width: t, height: n, padding: r }) => {
3867
+ }, Ht = ({ text: e, width: t, height: n, padding: r }) => {
3871
3868
  let i = Math.max(q, n);
3872
- if (!Kt({ text: e })) return i;
3873
- let a = Math.max(q, t), o = Gt({ padding: r }), s = i;
3874
- for (let t = 0; t < Rt; t += 1) {
3875
- let t = Jt({
3869
+ if (!Gt({ text: e })) return i;
3870
+ let a = Math.max(q, t), o = Wt({ padding: r }), s = i;
3871
+ for (let t = 0; t < Lt; t += 1) {
3872
+ let t = qt({
3876
3873
  width: a,
3877
3874
  height: s,
3878
3875
  padding: o
3879
- }), n = Qt({
3876
+ }), n = Zt({
3880
3877
  text: e,
3881
3878
  frameWidth: t.width
3882
3879
  });
3883
- if (n <= t.height + Nt) return s;
3880
+ if (n <= t.height + Mt) return s;
3884
3881
  let r = n - t.height;
3885
3882
  s = Math.max(s + r, s * 1.05);
3886
3883
  }
3887
3884
  return s;
3888
3885
  };
3889
- function Wt({ frameWidth: e, padding: t }) {
3886
+ function Ut({ frameWidth: e, padding: t }) {
3890
3887
  let n = Math.max(q, e), r = n;
3891
- for (let e = 0; e < Lt; e += 1) {
3892
- let e = Yt({
3888
+ for (let e = 0; e < It; e += 1) {
3889
+ let e = Jt({
3893
3890
  width: r,
3894
3891
  padding: t
3895
3892
  });
3896
- if (e >= n - Nt) return r;
3893
+ if (e >= n - Mt) return r;
3897
3894
  let i = n - e;
3898
3895
  r = Math.max(r + i, r * 1.05);
3899
3896
  }
3900
3897
  return r;
3901
3898
  }
3902
- function Gt({ padding: e }) {
3899
+ function Wt({ padding: e }) {
3903
3900
  return {
3904
- top: qt({ value: e.top }),
3905
- right: qt({ value: e.right }),
3906
- bottom: qt({ value: e.bottom }),
3907
- left: qt({ value: e.left })
3901
+ top: Kt({ value: e.top }),
3902
+ right: Kt({ value: e.right }),
3903
+ bottom: Kt({ value: e.bottom }),
3904
+ left: Kt({ value: e.left })
3908
3905
  };
3909
3906
  }
3910
- function Kt({ text: e }) {
3907
+ function Gt({ text: e }) {
3911
3908
  return (e.text ?? "").trim().length > 0;
3912
3909
  }
3913
- function qt({ value: e }) {
3914
- return Math.min(Math.max(e, 0), It);
3910
+ function Kt({ value: e }) {
3911
+ return Math.min(Math.max(e, 0), Ft);
3915
3912
  }
3916
- function Jt({ width: e, height: t, padding: n }) {
3917
- let r = nn({
3913
+ function qt({ width: e, height: t, padding: n }) {
3914
+ let r = tn({
3918
3915
  size: e,
3919
3916
  ratio: n.left,
3920
3917
  axis: "horizontal"
3921
- }), i = nn({
3918
+ }), i = tn({
3922
3919
  size: e,
3923
3920
  ratio: n.right,
3924
3921
  axis: "horizontal"
3925
- }), a = nn({
3922
+ }), a = tn({
3926
3923
  size: t,
3927
3924
  ratio: n.top,
3928
3925
  axis: "vertical"
3929
- }), o = nn({
3926
+ }), o = tn({
3930
3927
  size: t,
3931
3928
  ratio: n.bottom,
3932
3929
  axis: "vertical"
@@ -3938,19 +3935,19 @@ function Jt({ width: e, height: t, padding: n }) {
3938
3935
  height: Math.max(q, t - a - o)
3939
3936
  };
3940
3937
  }
3941
- function Yt({ width: e, padding: t }) {
3942
- let n = nn({
3938
+ function Jt({ width: e, padding: t }) {
3939
+ let n = tn({
3943
3940
  size: e,
3944
3941
  ratio: t.left,
3945
3942
  axis: "horizontal"
3946
- }), r = nn({
3943
+ }), r = tn({
3947
3944
  size: e,
3948
3945
  ratio: t.right,
3949
3946
  axis: "horizontal"
3950
3947
  });
3951
3948
  return Math.max(q, e - n - r);
3952
3949
  }
3953
- function Xt({ text: e }) {
3950
+ function Yt({ text: e }) {
3954
3951
  let { height: t } = e;
3955
3952
  if (typeof t == "number" && Number.isFinite(t)) return t;
3956
3953
  if (typeof e.calcTextHeight == "function") {
@@ -3959,18 +3956,18 @@ function Xt({ text: e }) {
3959
3956
  }
3960
3957
  return q;
3961
3958
  }
3962
- function Zt({ text: e, frameWidth: t }) {
3963
- let n = on({ text: e }), r = rn({
3959
+ function Xt({ text: e, frameWidth: t }) {
3960
+ let n = an({ text: e }), r = nn({
3964
3961
  text: e,
3965
3962
  frameWidth: t
3966
- }), i = ln({ text: e });
3963
+ }), i = cn({ text: e });
3967
3964
  e.set({
3968
3965
  autoExpand: !1,
3969
3966
  width: Math.max(q, t),
3970
3967
  splitByGrapheme: r
3971
3968
  }), e.initDimensions();
3972
- let a = sn({ text: e }) > n, o = Math.ceil(an({ text: e }));
3973
- return un({
3969
+ let a = on({ text: e }) > n, o = Math.ceil(rn({ text: e }));
3970
+ return ln({
3974
3971
  text: e,
3975
3972
  state: i
3976
3973
  }), {
@@ -3978,8 +3975,8 @@ function Zt({ text: e, frameWidth: t }) {
3978
3975
  longestLineWidth: o
3979
3976
  };
3980
3977
  }
3981
- function Qt({ text: e, frameWidth: t, splitByGrapheme: n }) {
3982
- let r = ln({ text: e }), i = n ?? rn({
3978
+ function Zt({ text: e, frameWidth: t, splitByGrapheme: n }) {
3979
+ let r = cn({ text: e }), i = n ?? nn({
3983
3980
  text: e,
3984
3981
  frameWidth: t
3985
3982
  });
@@ -3988,75 +3985,75 @@ function Qt({ text: e, frameWidth: t, splitByGrapheme: n }) {
3988
3985
  width: Math.max(q, t),
3989
3986
  splitByGrapheme: i
3990
3987
  }), e.initDimensions();
3991
- let a = Xt({ text: e });
3992
- return un({
3988
+ let a = Yt({ text: e });
3989
+ return ln({
3993
3990
  text: e,
3994
3991
  state: r
3995
3992
  }), a;
3996
3993
  }
3997
- function $t({ text: e }) {
3998
- let t = en({
3994
+ function Qt({ text: e }) {
3995
+ let t = $t({
3999
3996
  text: e,
4000
3997
  frameWidth: q,
4001
3998
  splitByGrapheme: !0
4002
3999
  });
4003
4000
  return Math.max(q, t);
4004
4001
  }
4005
- function en({ text: e, frameWidth: t, splitByGrapheme: n }) {
4006
- let r = ln({ text: e });
4002
+ function $t({ text: e, frameWidth: t, splitByGrapheme: n }) {
4003
+ let r = cn({ text: e });
4007
4004
  e.set({
4008
4005
  autoExpand: !1,
4009
4006
  width: Math.max(q, t),
4010
4007
  splitByGrapheme: n
4011
4008
  }), e.initDimensions();
4012
- let i = an({ text: e });
4013
- return un({
4009
+ let i = rn({ text: e });
4010
+ return ln({
4014
4011
  text: e,
4015
4012
  state: r
4016
4013
  }), i;
4017
4014
  }
4018
- function tn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
4015
+ function en({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
4019
4016
  let i = Math.max(0, t - r);
4020
4017
  return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
4021
4018
  }
4022
- function nn({ size: e, ratio: t, axis: n }) {
4023
- let r = n === "horizontal" ? Pt : Ft, i = e * t;
4019
+ function tn({ size: e, ratio: t, axis: n }) {
4020
+ let r = n === "horizontal" ? Nt : Pt, i = e * t;
4024
4021
  return Math.max(0, Math.min(i, r));
4025
4022
  }
4026
- function rn({ text: e, frameWidth: t }) {
4027
- let n = Math.max(q, t), r = ln({ text: e });
4023
+ function nn({ text: e, frameWidth: t }) {
4024
+ let n = Math.max(q, t), r = cn({ text: e });
4028
4025
  e.set({
4029
4026
  autoExpand: !1,
4030
4027
  width: n,
4031
4028
  splitByGrapheme: !1
4032
4029
  }), e.initDimensions();
4033
- let i = dn({ text: e }) > n + Nt;
4034
- return un({
4030
+ let i = un({ text: e }) > n + Mt;
4031
+ return ln({
4035
4032
  text: e,
4036
4033
  state: r
4037
4034
  }), i;
4038
4035
  }
4039
- function an({ text: e }) {
4040
- let t = sn({ text: e });
4041
- if (t > 0) return cn({
4036
+ function rn({ text: e }) {
4037
+ let t = on({ text: e });
4038
+ if (t > 0) return sn({
4042
4039
  text: e,
4043
4040
  lineCount: t
4044
4041
  });
4045
4042
  let n = e.text ?? "";
4046
- return cn({
4043
+ return sn({
4047
4044
  text: e,
4048
4045
  lineCount: Math.max(n.split("\n").length, 1)
4049
4046
  });
4050
4047
  }
4051
- function on({ text: e }) {
4048
+ function an({ text: e }) {
4052
4049
  let t = e.text ?? "";
4053
4050
  return Math.max(t.split("\n").length, 1);
4054
4051
  }
4055
- function sn({ text: e }) {
4052
+ function on({ text: e }) {
4056
4053
  let t = e;
4057
4054
  return Array.isArray(t.textLines) ? t.textLines.length : 0;
4058
4055
  }
4059
- function cn({ text: e, lineCount: t }) {
4056
+ function sn({ text: e, lineCount: t }) {
4060
4057
  let n = q;
4061
4058
  for (let r = 0; r < t; r += 1) {
4062
4059
  let t = e.getLineWidth(r);
@@ -4064,7 +4061,7 @@ function cn({ text: e, lineCount: t }) {
4064
4061
  }
4065
4062
  return n;
4066
4063
  }
4067
- function ln({ text: e }) {
4064
+ function cn({ text: e }) {
4068
4065
  let { autoExpand: t, splitByGrapheme: n, width: r } = e;
4069
4066
  return {
4070
4067
  autoExpand: t,
@@ -4072,23 +4069,23 @@ function ln({ text: e }) {
4072
4069
  width: typeof r == "number" ? r : void 0
4073
4070
  };
4074
4071
  }
4075
- function un({ text: e, state: t }) {
4072
+ function ln({ text: e, state: t }) {
4076
4073
  let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
4077
4074
  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());
4078
4075
  }
4079
- function dn({ text: e }) {
4076
+ function un({ text: e }) {
4080
4077
  let { dynamicMinWidth: t } = e;
4081
4078
  return typeof t == "number" && Number.isFinite(t) ? t : 0;
4082
4079
  }
4083
4080
  //#endregion
4084
4081
  //#region src/editor/shape-manager/shape-runtime.ts
4085
- var fn = ({ group: e }) => {
4082
+ var dn = ({ group: e }) => {
4086
4083
  let t = e;
4087
4084
  typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
4088
4085
  interactive: !0,
4089
4086
  subTargetCheck: !0
4090
4087
  });
4091
- }, pn = ({ text: e }) => {
4088
+ }, fn = ({ text: e }) => {
4092
4089
  e.set({
4093
4090
  hasBorders: !1,
4094
4091
  hasControls: !1,
@@ -4100,7 +4097,7 @@ var fn = ({ group: e }) => {
4100
4097
  autoExpand: !1,
4101
4098
  shapeNodeType: "text"
4102
4099
  }), e.setCoords();
4103
- }, mn = ({ group: e }) => {
4100
+ }, pn = ({ group: e }) => {
4104
4101
  let { layoutManager: t } = e;
4105
4102
  if (!t || typeof t.unsubscribeTargets != "function") return;
4106
4103
  let n = e.getObjects();
@@ -4108,7 +4105,7 @@ var fn = ({ group: e }) => {
4108
4105
  target: e,
4109
4106
  targets: n
4110
4107
  });
4111
- }, hn = ({ group: e }) => {
4108
+ }, mn = ({ group: e }) => {
4112
4109
  let t = e.getObjects();
4113
4110
  for (let e = 0; e < t.length; e += 1) {
4114
4111
  let n = t[e];
@@ -4119,23 +4116,23 @@ var fn = ({ group: e }) => {
4119
4116
  if (n instanceof _) return n;
4120
4117
  }
4121
4118
  return null;
4122
- }, gn = [
4119
+ }, hn = [
4123
4120
  "tl",
4124
4121
  "tr",
4125
4122
  "bl",
4126
4123
  "br"
4127
- ], _n = ({ transform: e }) => {
4124
+ ], gn = ({ transform: e }) => {
4128
4125
  let { originX: t, originY: n } = e;
4129
4126
  return (t === "center" || t === .5) && (n === "center" || n === .5);
4130
- }, vn = ({ transform: e, x: t, y: n }) => {
4127
+ }, _n = ({ transform: e, x: t, y: n }) => {
4131
4128
  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);
4132
4129
  r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
4133
4130
  let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
4134
- _n({ transform: r }) && (d *= 2, f *= 2);
4131
+ gn({ transform: r }) && (d *= 2, f *= 2);
4135
4132
  let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
4136
4133
  return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
4137
- }, yn = () => {
4138
- let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => vn({
4134
+ }, vn = () => {
4135
+ let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => _n({
4139
4136
  transform: t,
4140
4137
  x: n,
4141
4138
  y: r
@@ -4151,31 +4148,31 @@ var fn = ({ group: e }) => {
4151
4148
  a.uniformScaling = s;
4152
4149
  }
4153
4150
  };
4154
- }, bn = ({ control: e }) => {
4151
+ }, yn = ({ control: e }) => {
4155
4152
  let t = new r({
4156
4153
  ...e,
4157
- actionHandler: yn()
4154
+ actionHandler: vn()
4158
4155
  });
4159
4156
  return t.shapeFreeScaleCornerControl = !0, t;
4160
- }, xn = ({ group: e }) => {
4157
+ }, bn = ({ group: e }) => {
4161
4158
  let t = { ...e.controls };
4162
- gn.forEach((n) => {
4159
+ hn.forEach((n) => {
4163
4160
  let r = e.controls[n];
4164
- r && (r.shapeFreeScaleCornerControl || (t[n] = bn({ control: r })));
4161
+ r && (r.shapeFreeScaleCornerControl || (t[n] = yn({ control: r })));
4165
4162
  }), e.controls = t;
4166
- }, Sn = "shape-group";
4167
- function Cn() {
4163
+ }, xn = "shape-group";
4164
+ function Sn() {
4168
4165
  return { performLayout() {} };
4169
4166
  }
4170
- function wn({ layoutManager: e }) {
4167
+ function Cn({ layoutManager: e }) {
4171
4168
  let t = y.getClass("layoutManager");
4172
4169
  if (!e) return new t();
4173
4170
  let { strategy: n, type: r } = e, i = y.getClass(r);
4174
4171
  return n ? new i(new (y.getClass(n))()) : new i();
4175
4172
  }
4176
- var Tn = class e extends l {
4173
+ var wn = class e extends l {
4177
4174
  static {
4178
- this.type = Sn;
4175
+ this.type = xn;
4179
4176
  }
4180
4177
  constructor(e = [], t = {}) {
4181
4178
  let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a, ...o } = t;
@@ -4191,17 +4188,17 @@ var Tn = class e extends l {
4191
4188
  this.set({
4192
4189
  objectCaching: !1,
4193
4190
  shapeComposite: !0
4194
- }), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0), this._syncRoundability(), fn({ group: this }), xn({ group: this });
4195
- let e = hn({ group: this });
4196
- e && pn({ text: e }), mn({ group: this }), this.setCoords();
4191
+ }), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0), this._syncRoundability(), dn({ group: this }), bn({ group: this });
4192
+ let e = mn({ group: this });
4193
+ e && fn({ text: e }), pn({ group: this }), this.setCoords();
4197
4194
  }
4198
4195
  static async fromObject({ type: t, objects: n = [], layoutManager: r, ...i }, a) {
4199
4196
  let [o, s] = await Promise.all([C.enlivenObjects(n, a), C.enlivenObjectEnlivables(i, a)]), c = new e(o, {
4200
4197
  ...i,
4201
4198
  ...s,
4202
- layoutManager: Cn()
4199
+ layoutManager: Sn()
4203
4200
  });
4204
- return c.layoutManager = wn({ layoutManager: r }), c.layoutManager.subscribeTargets({
4201
+ return c.layoutManager = Cn({ layoutManager: r }), c.layoutManager.subscribeTargets({
4205
4202
  type: "initialization",
4206
4203
  target: c,
4207
4204
  targets: c.getObjects()
@@ -4211,12 +4208,12 @@ var Tn = class e extends l {
4211
4208
  if (typeof this.shapeCanRound == "boolean") return;
4212
4209
  let e = this.shapePresetKey;
4213
4210
  if (!e) return;
4214
- let t = ut({ presetKey: e });
4215
- t && (this.shapeCanRound = pt({ preset: t }));
4211
+ let t = lt({ presetKey: e });
4212
+ t && (this.shapeCanRound = ft({ preset: t }));
4216
4213
  }
4217
- }, En = () => {
4218
- y?.setClass && y.setClass(Tn, Sn);
4219
- }, J = (e) => e instanceof Tn || e instanceof l && e.shapeComposite === !0, Dn = ({ target: e, subTargets: t = [] }) => {
4214
+ }, Tn = () => {
4215
+ y?.setClass && y.setClass(wn, xn);
4216
+ }, J = (e) => e instanceof wn || e instanceof l && e.shapeComposite === !0, En = ({ target: e, subTargets: t = [] }) => {
4220
4217
  if (J(e)) return e;
4221
4218
  if (e?.group && J(e.group)) return e.group;
4222
4219
  for (let e = 0; e < t.length; e += 1) {
@@ -4226,7 +4223,7 @@ var Tn = class e extends l {
4226
4223
  if (r && J(r)) return r;
4227
4224
  }
4228
4225
  return null;
4229
- }, On = ({ group: e }) => {
4226
+ }, Dn = ({ group: e }) => {
4230
4227
  let t = e.getObjects();
4231
4228
  for (let e = 0; e < t.length; e += 1) {
4232
4229
  let n = t[e];
@@ -4237,7 +4234,7 @@ var Tn = class e extends l {
4237
4234
  if (!(n instanceof _)) return n;
4238
4235
  }
4239
4236
  return null;
4240
- }, kn = ({ group: e }) => {
4237
+ }, On = ({ group: e }) => {
4241
4238
  let t = e.getObjects();
4242
4239
  for (let e = 0; e < t.length; e += 1) {
4243
4240
  let n = t[e];
@@ -4249,16 +4246,16 @@ var Tn = class e extends l {
4249
4246
  }
4250
4247
  return null;
4251
4248
  }, Y = ({ group: e }) => ({
4252
- shape: On({ group: e }),
4253
- text: kn({ group: e })
4254
- }), An = ({ group: e }) => {
4255
- fn({ group: e });
4256
- }, jn = ({ transform: e, key: t }) => {
4249
+ shape: Dn({ group: e }),
4250
+ text: On({ group: e })
4251
+ }), kn = ({ group: e }) => {
4252
+ dn({ group: e });
4253
+ }, An = ({ transform: e, key: t }) => {
4257
4254
  let n = e?.original;
4258
4255
  if (!n || typeof n != "object") return null;
4259
4256
  let r = n[t];
4260
4257
  return typeof r != "number" || !Number.isFinite(r) ? null : r;
4261
- }, Mn = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Nn = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Pn = ({ transform: e }) => {
4258
+ }, jn = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Mn = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Nn = ({ transform: e }) => {
4262
4259
  let t = e?.action ?? "", n = typeof e?.corner == "string" ? e.corner : "", r = n === "tl" || n === "tr" || n === "bl" || n === "br", i = t === "scaleX" || n === "ml" || n === "mr", a = t === "scaleY" || n === "mt" || n === "mb", o = i || r, s = a || r;
4263
4260
  return {
4264
4261
  canScaleWidth: o,
@@ -4266,37 +4263,37 @@ var Tn = class e extends l {
4266
4263
  isCornerScaleAction: r,
4267
4264
  isVerticalOnlyScale: s && !o
4268
4265
  };
4269
- }, Fn = ({ event: e, group: t, transform: n, canvas: r }) => {
4266
+ }, Pn = ({ event: e, group: t, transform: n, canvas: r }) => {
4270
4267
  if (!e) return null;
4271
4268
  let i = t.canvas ?? r, a = i.getScenePoint(e), o = t.getRelativeCenterPoint(), s = t.translateToGivenOrigin(o, "center", "center", n.originX, n.originY), c = t.angle ?? 0, l = (c === 0 ? a : a.rotate(-c * Math.PI / 180, o)).subtract(s), u = t.controls[n.corner], d = i.getZoom() || 1, f = (t.padding ?? 0) / d;
4272
4269
  return l.x >= f && (l.x -= f), l.x <= -f && (l.x += f), l.y >= f && (l.y -= f), l.y <= -f && (l.y += f), l.x -= u?.offsetX ?? 0, l.y -= u?.offsetY ?? 0, l;
4273
- }, In = ({ group: e, originX: t, originY: n }) => {
4270
+ }, Fn = ({ group: e, originX: t, originY: n }) => {
4274
4271
  if (t === null || n === null) return null;
4275
4272
  let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
4276
4273
  return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
4277
- }, Ln = ({ state: e, transform: t }) => {
4274
+ }, In = ({ state: e, transform: t }) => {
4278
4275
  if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
4279
- let n = Mn({ value: t.originX }), r = Nn({ value: t.originY });
4276
+ let n = jn({ value: t.originX }), r = Mn({ value: t.originY });
4280
4277
  return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
4281
- }, Rn = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
4278
+ }, Ln = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
4282
4279
  //#endregion
4283
4280
  //#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
4284
- function zn({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
4281
+ function Rn({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
4285
4282
  let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
4286
4283
  return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
4287
4284
  }
4288
- function Bn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
4285
+ function zn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
4289
4286
  let c = Math.max(0, e.shapeStrokeWidth ?? 0);
4290
- _t({
4287
+ gt({
4291
4288
  shape: t,
4292
- width: zn({
4289
+ width: Rn({
4293
4290
  size: n,
4294
4291
  scale: i,
4295
4292
  strokeWidth: c,
4296
4293
  minSize: o,
4297
4294
  scaleEpsilon: s
4298
4295
  }),
4299
- height: zn({
4296
+ height: Rn({
4300
4297
  size: r,
4301
4298
  scale: a,
4302
4299
  strokeWidth: c,
@@ -4307,8 +4304,8 @@ function Bn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
4307
4304
  strokeWidth: c
4308
4305
  });
4309
4306
  }
4310
- function Vn({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
4311
- let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } = Ht({
4307
+ function Bn({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
4308
+ let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } = Vt({
4312
4309
  text: e,
4313
4310
  width: t,
4314
4311
  height: n,
@@ -4328,13 +4325,13 @@ function Vn({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, sc
4328
4325
  scaleY: 1 / u
4329
4326
  }), e.initDimensions(), e.setCoords();
4330
4327
  }
4331
- var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
4328
+ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
4332
4329
  let f = Math.max(d, Math.abs(c) || 1), p = Math.max(d, Math.abs(l) || 1);
4333
4330
  e.set({
4334
4331
  width: r / f,
4335
4332
  height: i / p,
4336
4333
  dirty: !0
4337
- }), Bn({
4334
+ }), zn({
4338
4335
  group: e,
4339
4336
  shape: t,
4340
4337
  width: r,
@@ -4343,7 +4340,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4343
4340
  scaleY: l,
4344
4341
  minSize: u,
4345
4342
  scaleEpsilon: d
4346
- }), Vn({
4343
+ }), Bn({
4347
4344
  text: n,
4348
4345
  width: r,
4349
4346
  height: i,
@@ -4354,7 +4351,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4354
4351
  scaleY: l,
4355
4352
  scaleEpsilon: d
4356
4353
  });
4357
- }, X = 1, Z = 1e-4, Un = .5, Wn = class e {
4354
+ }, X = 1, Z = 1e-4, Hn = .5, Un = class e {
4358
4355
  constructor({ canvas: t }) {
4359
4356
  this.handleObjectScaling = (t) => {
4360
4357
  let { target: n, transform: r } = t;
@@ -4370,7 +4367,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4370
4367
  text: o,
4371
4368
  padding: s,
4372
4369
  transform: r
4373
- }), { isCornerScaleAction: l } = Pn({ transform: r }), u = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
4370
+ }), { isCornerScaleAction: l } = Nn({ transform: r }), u = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
4374
4371
  c.isProportionalScaling = l && u;
4375
4372
  let d = i.left ?? 0, f = i.top ?? 0, p = !!i.flipX, m = !!i.flipY, h = i.shapeAlignHorizontal ?? "center", g = i.shapeAlignVertical ?? "middle", _ = this._resolveScalingDecision({
4376
4373
  group: i,
@@ -4385,7 +4382,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4385
4382
  shouldHandleAsNoop: _.shouldHandleAsNoop,
4386
4383
  scaleX: _.appliedScaleX,
4387
4384
  scaleY: _.appliedScaleY
4388
- }), Hn({
4385
+ }), Vn({
4389
4386
  group: i,
4390
4387
  shape: a,
4391
4388
  text: o,
@@ -4416,7 +4413,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4416
4413
  if (!n) return;
4417
4414
  let { target: r } = n;
4418
4415
  if (!J(r)) return;
4419
- let { canScaleHeight: i, canScaleWidth: a } = Pn({ transform: n });
4416
+ let { canScaleHeight: i, canScaleWidth: a } = Nn({ transform: n });
4420
4417
  if (!a && !i) return;
4421
4418
  let o = r, s = this.scalingState.get(o);
4422
4419
  if (!s || s.isProportionalScaling) return;
@@ -4431,7 +4428,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4431
4428
  group: o,
4432
4429
  axis: "x"
4433
4430
  })) {
4434
- let e = Vt({
4431
+ let e = Bt({
4435
4432
  text: l,
4436
4433
  padding: u
4437
4434
  }), t = Math.max(X / s.startWidth, e / s.startWidth);
@@ -4465,7 +4462,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4465
4462
  shouldHandleAsNoop: !1,
4466
4463
  scaleX: g,
4467
4464
  scaleY: _
4468
- }), Hn({
4465
+ }), Vn({
4469
4466
  group: o,
4470
4467
  shape: c,
4471
4468
  text: l,
@@ -4512,7 +4509,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4512
4509
  this.scalingState.delete(r);
4513
4510
  return;
4514
4511
  }
4515
- let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolvePadding({ group: r }), g = t.transform ? Pn({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = Vt({
4512
+ let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolvePadding({ group: r }), g = t.transform ? Nn({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = Bt({
4516
4513
  text: f,
4517
4514
  padding: h
4518
4515
  }), b = i?.lastAllowedScaleX ?? a, x = i?.lastAllowedScaleY ?? o;
@@ -4535,7 +4532,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4535
4532
  state: i
4536
4533
  }) && (x = Math.max(X / c, e / c));
4537
4534
  }
4538
- let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) > Un, T = Math.abs(C - c) > Un, E = w || T, D = S, O = C;
4535
+ let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) > Hn, T = Math.abs(C - c) > Hn, E = w || T, D = S, O = C;
4539
4536
  if (!E && i) {
4540
4537
  this._restoreShapeStateWithoutResize({
4541
4538
  group: r,
@@ -4564,7 +4561,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4564
4561
  });
4565
4562
  r.shapeManualBaseWidth = k.width, r.shapeManualBaseHeight = k.height;
4566
4563
  let A = i?.baseRounding ?? Math.max(0, r.shapeRounding ?? 0);
4567
- r.shapeRounding = Math.max(0, A * Math.min(b, x)), zt({
4564
+ r.shapeRounding = Math.max(0, A * Math.min(b, x)), Rt({
4568
4565
  group: r,
4569
4566
  shape: d,
4570
4567
  text: f,
@@ -4586,10 +4583,10 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4586
4583
  }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
4587
4584
  }
4588
4585
  _resolveScalingDecision({ group: e, text: t, padding: n, state: r, transform: i }) {
4589
- let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = Ln({
4586
+ let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = In({
4590
4587
  state: r,
4591
4588
  transform: i
4592
- }), d = Rn({
4589
+ }), d = Ln({
4593
4590
  state: r,
4594
4591
  transform: i
4595
4592
  });
@@ -4621,7 +4618,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4621
4618
  };
4622
4619
  }
4623
4620
  _resolveScalingConstraintState({ text: e, padding: t, state: n, transform: r, scaleX: i, scaleY: a }) {
4624
- 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 } = Pn({ transform: r }), S = b && g ? Vt({
4621
+ 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 } = Nn({ transform: r }), S = b && g ? Bt({
4625
4622
  text: e,
4626
4623
  padding: t
4627
4624
  }) : null, C = y && _ ? this._resolveMinimumTextFitHeight({
@@ -4640,7 +4637,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4640
4637
  };
4641
4638
  }
4642
4639
  _resolvePreviewDimensions({ text: e, padding: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
4643
- 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 ?? Ut({
4640
+ 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 ?? Ht({
4644
4641
  text: e,
4645
4642
  width: o,
4646
4643
  height: s,
@@ -4673,7 +4670,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4673
4670
  if (!r) return !1;
4674
4671
  let { transform: i } = e;
4675
4672
  if (!i) return !1;
4676
- let { canScaleWidth: a } = Pn({ transform: i });
4673
+ let { canScaleWidth: a } = Nn({ transform: i });
4677
4674
  if (!a || !this._hasPointerReachedScaleOrigin({
4678
4675
  event: e,
4679
4676
  group: t,
@@ -4686,7 +4683,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4686
4683
  if (!r) return !1;
4687
4684
  let { transform: i } = e;
4688
4685
  if (!i) return !1;
4689
- let { canScaleHeight: a } = Pn({ transform: i });
4686
+ let { canScaleHeight: a } = Nn({ transform: i });
4690
4687
  if (!a || !this._hasPointerReachedScaleOrigin({
4691
4688
  event: e,
4692
4689
  group: t,
@@ -4700,7 +4697,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4700
4697
  if (!r) return !1;
4701
4698
  let i = r, a = n === "x" ? i.signX : i.signY;
4702
4699
  if (typeof a != "number" || !Number.isFinite(a)) return !1;
4703
- let o = Fn({
4700
+ let o = Pn({
4704
4701
  event: e.e,
4705
4702
  group: t,
4706
4703
  transform: r,
@@ -4717,19 +4714,19 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4717
4714
  let a = this._resolveScalingStartDimensions({
4718
4715
  group: e,
4719
4716
  transform: r
4720
- }), o = jn({
4717
+ }), o = An({
4721
4718
  transform: r,
4722
4719
  key: "scaleX"
4723
- }), s = jn({
4720
+ }), s = An({
4724
4721
  transform: r,
4725
4722
  key: "scaleY"
4726
- }), c = jn({
4723
+ }), c = An({
4727
4724
  transform: r,
4728
4725
  key: "left"
4729
- }), l = jn({
4726
+ }), l = An({
4730
4727
  transform: r,
4731
4728
  key: "top"
4732
- }), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m = Mn({ value: r?.original?.originX ?? r?.originX }), h = Nn({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = In({
4729
+ }), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m = jn({ value: r?.original?.originX ?? r?.originX }), h = Mn({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = Fn({
4733
4730
  group: e,
4734
4731
  originX: m,
4735
4732
  originY: h
@@ -4772,7 +4769,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4772
4769
  return i;
4773
4770
  }
4774
4771
  _resolveMinimumTextFitHeight({ text: e, width: t, padding: n }) {
4775
- return Ut({
4772
+ return Ht({
4776
4773
  text: e,
4777
4774
  width: t,
4778
4775
  height: X,
@@ -4796,7 +4793,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4796
4793
  e.setPositionByOrigin(new p(n, r), i, a), e.setCoords();
4797
4794
  }
4798
4795
  _restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, startWidth: i, startHeight: a, alignH: o, alignV: s, padding: c }) {
4799
- zt({
4796
+ Rt({
4800
4797
  group: e,
4801
4798
  shape: t,
4802
4799
  text: n,
@@ -4819,7 +4816,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4819
4816
  }
4820
4817
  _restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
4821
4818
  let i = Math.max(X, e.shapeBaseWidth ?? e.width ?? r.startWidth), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? r.startHeight);
4822
- t && (_t({
4819
+ t && (gt({
4823
4820
  shape: t,
4824
4821
  width: i,
4825
4822
  height: a,
@@ -4843,7 +4840,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4843
4840
  });
4844
4841
  }
4845
4842
  _resolveScalingStartDimensions({ group: e, transform: t }) {
4846
- let { canScaleWidth: n, canScaleHeight: r } = Pn({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
4843
+ let { canScaleWidth: n, canScaleHeight: r } = Nn({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
4847
4844
  return {
4848
4845
  startWidth: i,
4849
4846
  startHeight: a,
@@ -4862,10 +4859,10 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4862
4859
  height: s
4863
4860
  };
4864
4861
  }
4865
- }, Gn = class {
4862
+ }, Wn = class {
4866
4863
  constructor({ canvas: e }) {
4867
4864
  this.handleMouseDown = (e) => {
4868
- let { target: t, e: n, subTargets: r = [] } = e, i = Dn({
4865
+ let { target: t, e: n, subTargets: r = [] } = e, i = En({
4869
4866
  target: t,
4870
4867
  subTargets: r
4871
4868
  });
@@ -4875,7 +4872,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4875
4872
  let o = this.canvas.getActiveObject(), s = o === i;
4876
4873
  if (!(o === a && a.isEditing)) {
4877
4874
  if (!s) {
4878
- a.isEditing || pn({ text: a });
4875
+ a.isEditing || fn({ text: a });
4879
4876
  return;
4880
4877
  }
4881
4878
  n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
@@ -4895,7 +4892,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4895
4892
  J(r) && (this._restoreTextEditingInteractionMode({
4896
4893
  group: r,
4897
4894
  text: n
4898
- }), pn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
4895
+ }), fn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
4899
4896
  }, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
4900
4897
  }
4901
4898
  enterTextEditing({ group: e }) {
@@ -4946,7 +4943,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4946
4943
  lockMovementY: n.textLockMovementY
4947
4944
  }), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
4948
4945
  }
4949
- }, Kn = "#B0B5BF", qn = 0, Jn = 1, Yn = class {
4946
+ }, Gn = "#B0B5BF", Kn = 0, qn = 1, Jn = class {
4950
4947
  constructor({ editor: e }) {
4951
4948
  this._handleObjectScaling = (e) => {
4952
4949
  this.scalingController.handleObjectScaling(e);
@@ -4983,18 +4980,18 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
4983
4980
  textNode: r,
4984
4981
  textStyle: n
4985
4982
  });
4986
- }, this.editor = e, En(), this.scalingController = new Wn({ canvas: e.canvas }), this.editingController = new Gn({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
4983
+ }, this.editor = e, Tn(), this.scalingController = new Un({ canvas: e.canvas }), this.editingController = new Wn({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
4987
4984
  }
4988
- async add({ presetKey: e = ot, options: t = {} } = {}) {
4989
- let n = ut({ presetKey: e });
4985
+ async add({ presetKey: e = at, options: t = {} } = {}) {
4986
+ let n = lt({ presetKey: e });
4990
4987
  if (!n) return null;
4991
- let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b = ut({ presetKey: dt({
4988
+ let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b = lt({ presetKey: ut({
4992
4989
  preset: n,
4993
4990
  rounding: h
4994
4991
  }) }) ?? n, x = Math.max(1, r ?? b.width), S = Math.max(1, i ?? b.height), C = a !== !1, w = this._resolveHorizontalAlign({
4995
4992
  explicitAlign: f,
4996
4993
  textStyle: d
4997
- }), T = p ?? "middle", E = ft({
4994
+ }), T = p ?? "middle", E = dt({
4998
4995
  preset: b,
4999
4996
  overridePadding: m
5000
4997
  }), O = this._resolveShapeStyle({
@@ -5013,7 +5010,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5013
5010
  shapeTextAutoExpandEnabled: C,
5014
5011
  padding: E,
5015
5012
  strokeWidth: O.strokeWidth
5016
- }), j = await vt({
5013
+ }), j = await _t({
5017
5014
  preset: b,
5018
5015
  width: A,
5019
5016
  height: S,
@@ -5022,7 +5019,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5022
5019
  }), M = this._createShapeGroup({
5023
5020
  id: y ?? `shape-${D()}`,
5024
5021
  presetKey: b.key,
5025
- presetCanRound: pt({ preset: b }),
5022
+ presetCanRound: ft({ preset: b }),
5026
5023
  shape: j,
5027
5024
  text: k,
5028
5025
  width: A,
@@ -5063,7 +5060,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5063
5060
  async update({ target: e, presetKey: t, options: n = {} } = {}) {
5064
5061
  let r = this._resolveShapeGroup({ target: e });
5065
5062
  if (!r) return null;
5066
- let i = ut({ presetKey: t ?? r.shapePresetKey ?? "circle" });
5063
+ let i = lt({ presetKey: t ?? r.shapePresetKey ?? "circle" });
5067
5064
  if (!i) return null;
5068
5065
  let { left: a, top: o, originX: s, originY: c, width: l, height: u, shapeTextAutoExpand: d, text: f, textStyle: p, alignH: m, alignV: h, textPadding: g, rounding: _, withoutSelection: v, withoutSave: y } = n, b = this.editor.canvasManager.resolveObjectPlacement({
5069
5066
  object: r,
@@ -5071,10 +5068,10 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5071
5068
  top: o,
5072
5069
  originX: s,
5073
5070
  originY: c
5074
- }), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E = ut({ presetKey: dt({
5071
+ }), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E = lt({ presetKey: ut({
5075
5072
  preset: i,
5076
5073
  rounding: T
5077
- }) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this._resolveGroupPadding({ group: r }), A = ft({
5074
+ }) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this._resolveGroupPadding({ group: r }), A = dt({
5078
5075
  preset: E,
5079
5076
  overridePadding: g ?? k
5080
5077
  }), j = this._resolveShapeStyle({
@@ -5116,7 +5113,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5116
5113
  shapeTextAutoExpandEnabled: w,
5117
5114
  padding: A,
5118
5115
  strokeWidth: j.strokeWidth
5119
- }), te = await vt({
5116
+ }), te = await _t({
5120
5117
  preset: E,
5121
5118
  width: L,
5122
5119
  height: S,
@@ -5133,7 +5130,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5133
5130
  }), r.remove(P), r.insertAt(ne, te), this._applyShapeGroupMetadata({
5134
5131
  group: r,
5135
5132
  presetKey: E.key,
5136
- presetCanRound: pt({ preset: E }),
5133
+ presetCanRound: ft({ preset: E }),
5137
5134
  width: L,
5138
5135
  height: S,
5139
5136
  manualWidth: M,
@@ -5182,7 +5179,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5182
5179
  if (!i) return null;
5183
5180
  this._beginMutation();
5184
5181
  try {
5185
- yt({
5182
+ vt({
5186
5183
  shape: i,
5187
5184
  style: { fill: t }
5188
5185
  }), r.shapeFill = t, r.setCoords(), this.editor.canvas.requestRenderAll();
@@ -5198,7 +5195,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5198
5195
  if (!o) return null;
5199
5196
  this._beginMutation();
5200
5197
  try {
5201
- yt({
5198
+ vt({
5202
5199
  shape: o,
5203
5200
  style: {
5204
5201
  stroke: t,
@@ -5222,7 +5219,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5222
5219
  if (!i) return null;
5223
5220
  this._beginMutation();
5224
5221
  try {
5225
- yt({
5222
+ vt({
5226
5223
  shape: i,
5227
5224
  style: { opacity: t }
5228
5225
  }), a && (a.set({ opacity: t }), a.setCoords()), r.shapeOpacity = t, r.setCoords(), this.editor.canvas.requestRenderAll();
@@ -5315,7 +5312,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5315
5312
  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);
5316
5313
  }
5317
5314
  _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 }) {
5318
- let h = new Tn([r, i], {
5315
+ let h = new wn([r, i], {
5319
5316
  id: e,
5320
5317
  originX: "center",
5321
5318
  originY: "center",
@@ -5339,7 +5336,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5339
5336
  padding: f,
5340
5337
  style: p,
5341
5338
  rounding: m
5342
- }), h.rehydrateRuntimeState(), An({ group: h }), pn({ text: i }), zt({
5339
+ }), h.rehydrateRuntimeState(), kn({ group: h }), fn({ text: i }), Rt({
5343
5340
  group: h,
5344
5341
  shape: r,
5345
5342
  text: i,
@@ -5395,7 +5392,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5395
5392
  return s.set({
5396
5393
  shapeNodeType: "text",
5397
5394
  splitByGrapheme: !1
5398
- }), pn({ text: s }), s;
5395
+ }), fn({ text: s }), s;
5399
5396
  }
5400
5397
  _applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
5401
5398
  let i = {};
@@ -5485,7 +5482,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5485
5482
  }
5486
5483
  _resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i }) {
5487
5484
  let a = this._resolveMontageAreaWidth();
5488
- return a ? Bt({
5485
+ return a ? zt({
5489
5486
  text: e,
5490
5487
  currentWidth: t,
5491
5488
  minimumWidth: n,
@@ -5518,7 +5515,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5518
5515
  strokeWidth: e.shapeStrokeWidth
5519
5516
  }) : Math.max(1, i);
5520
5517
  let f = Math.max(1, a ?? c.height), p = r ?? this.editor.canvasManager.getObjectPlacement({ object: e });
5521
- zt({
5518
+ Rt({
5522
5519
  group: e,
5523
5520
  shape: t,
5524
5521
  text: n,
@@ -5555,21 +5552,21 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5555
5552
  return this.editingPlacements.get(e) || this.editor.canvasManager.getObjectPlacement({ object: e });
5556
5553
  }
5557
5554
  _detachShapeGroupAutoLayout({ group: e }) {
5558
- mn({ group: e });
5555
+ pn({ group: e });
5559
5556
  }
5560
5557
  _resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
5561
5558
  if (e) return e;
5562
5559
  let n = t?.align;
5563
- return n === "left" || n === "center" || n === "right" ? n : st;
5560
+ return n === "left" || n === "center" || n === "right" ? n : ot;
5564
5561
  }
5565
5562
  _resolveShapeStyle({ options: e, fallback: t }) {
5566
5563
  let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
5567
5564
  return {
5568
- fill: n ?? t?.shapeFill ?? Kn,
5565
+ fill: n ?? t?.shapeFill ?? Gn,
5569
5566
  stroke: r ?? t?.shapeStroke ?? null,
5570
- strokeWidth: i ?? t?.shapeStrokeWidth ?? qn,
5567
+ strokeWidth: i ?? t?.shapeStrokeWidth ?? Kn,
5571
5568
  strokeDashArray: s ?? null,
5572
- opacity: o ?? t?.shapeOpacity ?? Jn
5569
+ opacity: o ?? t?.shapeOpacity ?? qn
5573
5570
  };
5574
5571
  }
5575
5572
  _beginMutation() {
@@ -5605,7 +5602,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5605
5602
  }
5606
5603
  return null;
5607
5604
  }
5608
- }, Xn = class {
5605
+ }, Yn = class {
5609
5606
  constructor({ editor: e }) {
5610
5607
  this.editor = e, this.clipboard = null;
5611
5608
  }
@@ -5698,6 +5695,18 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5698
5695
  }
5699
5696
  n.add(t), n.setActiveObject(t), n.requestRenderAll();
5700
5697
  }
5698
+ _commitStandaloneTextScaleOnClone({ clonedObject: t }) {
5699
+ let { textManager: n } = this.editor;
5700
+ if (n) {
5701
+ if (t instanceof e) {
5702
+ t.forEachObject((e) => {
5703
+ n.commitStandaloneTextScale({ target: e });
5704
+ }), t.setCoords();
5705
+ return;
5706
+ }
5707
+ n.commitStandaloneTextScale({ target: t });
5708
+ }
5709
+ }
5701
5710
  async _handleImageImport(e) {
5702
5711
  let { canvas: t, errorManager: n } = this.editor, r = !1, i = !1, a = null, o = null, s = new Promise((e, t) => {
5703
5712
  a = (t) => {
@@ -5759,7 +5768,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5759
5768
  left: t.left + 10,
5760
5769
  top: t.top + 10,
5761
5770
  evented: !0
5762
- }), this._addClonedObjectToCanvas(t), n.fire("editor:object-duplicated", {
5771
+ }), this._commitStandaloneTextScaleOnClone({ clonedObject: t }), this._addClonedObjectToCanvas(t), n.fire("editor:object-duplicated", {
5763
5772
  targetObject: r,
5764
5773
  clonedObject: t
5765
5774
  }), !0;
@@ -5833,7 +5842,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5833
5842
  left: n.left + 10,
5834
5843
  top: n.top + 10,
5835
5844
  evented: !0
5836
- }), this._addClonedObjectToCanvas(n), t.fire("editor:object-pasted", {
5845
+ }), this._commitStandaloneTextScaleOnClone({ clonedObject: n }), this._addClonedObjectToCanvas(n), t.fire("editor:object-pasted", {
5837
5846
  fromInternalClipboard: !0,
5838
5847
  clipboardObject: this.clipboard,
5839
5848
  object: n
@@ -5849,7 +5858,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5849
5858
  }), !1;
5850
5859
  }
5851
5860
  }
5852
- }, Zn = class t {
5861
+ }, Xn = class t {
5853
5862
  constructor({ editor: e }) {
5854
5863
  this.editor = e;
5855
5864
  }
@@ -5899,7 +5908,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5899
5908
  static _isGroupOrSelection(t) {
5900
5909
  return t instanceof e || t instanceof l;
5901
5910
  }
5902
- }, Qn = class {
5911
+ }, Zn = class {
5903
5912
  constructor({ editor: e }) {
5904
5913
  this.editor = e;
5905
5914
  }
@@ -5965,7 +5974,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
5965
5974
  i.resumeHistory(), n || i.saveState();
5966
5975
  }
5967
5976
  }
5968
- }, $n = class t {
5977
+ }, Qn = class t {
5969
5978
  constructor({ editor: e }) {
5970
5979
  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();
5971
5980
  }
@@ -6159,7 +6168,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6159
6168
  let { options: e } = this.editor, { selectionKey: t } = e;
6160
6169
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
6161
6170
  }
6162
- }, er = class e {
6171
+ }, $n = class e {
6163
6172
  constructor({ editor: e }) {
6164
6173
  this.editor = e;
6165
6174
  }
@@ -6197,7 +6206,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6197
6206
  };
6198
6207
  return i.fire("editor:objects-deleted", c), c;
6199
6208
  }
6200
- }, tr = {
6209
+ }, er = {
6201
6210
  IMAGE_MANAGER: {
6202
6211
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
6203
6212
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -6235,7 +6244,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6235
6244
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
6236
6245
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
6237
6246
  }
6238
- }, nr = class e {
6247
+ }, tr = class e {
6239
6248
  constructor({ editor: e }) {
6240
6249
  this._buffer = [], this.editor = e;
6241
6250
  }
@@ -6293,9 +6302,9 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6293
6302
  }), this.editor.canvas.fire("editor:warning", s);
6294
6303
  }
6295
6304
  static isValidErrorCode(e) {
6296
- return e ? Object.values(tr).some((t) => Object.values(t).includes(e)) : !1;
6305
+ return e ? Object.values(er).some((t) => Object.values(t).includes(e)) : !1;
6297
6306
  }
6298
- }, rr = class {
6307
+ }, nr = class {
6299
6308
  constructor({ editor: e }) {
6300
6309
  this.currentBounds = null, this.editor = e;
6301
6310
  }
@@ -6344,32 +6353,32 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6344
6353
  updateBounds() {
6345
6354
  this.currentBounds = this.calculatePanBounds();
6346
6355
  }
6347
- }, ir = ({ textbox: e }) => {
6356
+ }, rr = ({ textbox: e }) => {
6348
6357
  if (!e.isEditing) return null;
6349
6358
  let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
6350
6359
  return t === n ? null : {
6351
6360
  start: Math.min(t, n),
6352
6361
  end: Math.max(t, n)
6353
6362
  };
6354
- }, ar = ({ textbox: e }) => {
6363
+ }, ir = ({ textbox: e }) => {
6355
6364
  let t = e.text?.length ?? 0;
6356
6365
  return t <= 0 ? null : {
6357
6366
  start: 0,
6358
6367
  end: t
6359
6368
  };
6360
- }, or = ({ textbox: e, range: t }) => {
6369
+ }, ar = ({ textbox: e, range: t }) => {
6361
6370
  if (!t) return !1;
6362
6371
  let n = e.text?.length ?? 0;
6363
6372
  return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
6364
- }, sr = ({ textbox: e, styles: t, range: n }) => {
6373
+ }, or = ({ textbox: e, styles: t, range: n }) => {
6365
6374
  if (!t || !Object.keys(t).length) return !1;
6366
6375
  let { start: r, end: i } = n;
6367
6376
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
6368
- }, cr = ({ textbox: e, range: t, property: n }) => {
6377
+ }, sr = ({ textbox: e, range: t, property: n }) => {
6369
6378
  if (!t) return;
6370
6379
  let r = e.getSelectionStyles(t.start, t.end, !0);
6371
6380
  if (r.length) return r[0]?.[n];
6372
- }, lr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", ur = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, dr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", fr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), pr = class e extends _ {
6381
+ }, cr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", lr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, ur = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", dr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), fr = class e extends _ {
6373
6382
  static {
6374
6383
  this.type = "background-textbox";
6375
6384
  }
@@ -6494,7 +6503,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6494
6503
  this._removeShadow(e);
6495
6504
  }
6496
6505
  _getDecorationColorAt(e, t) {
6497
- let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = ur({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : lr({
6506
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = lr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : cr({
6498
6507
  strokeColor: i,
6499
6508
  width: r
6500
6509
  });
@@ -6510,22 +6519,22 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6510
6519
  _getCornerRadii({ width: e, height: t }) {
6511
6520
  let n = e / 2, r = t / 2, i = Math.min(n, r);
6512
6521
  return {
6513
- bottomLeft: fr({
6522
+ bottomLeft: dr({
6514
6523
  value: this.radiusBottomLeft ?? 0,
6515
6524
  min: 0,
6516
6525
  max: i
6517
6526
  }),
6518
- bottomRight: fr({
6527
+ bottomRight: dr({
6519
6528
  value: this.radiusBottomRight ?? 0,
6520
6529
  min: 0,
6521
6530
  max: i
6522
6531
  }),
6523
- topLeft: fr({
6532
+ topLeft: dr({
6524
6533
  value: this.radiusTopLeft ?? 0,
6525
6534
  min: 0,
6526
6535
  max: i
6527
6536
  }),
6528
- topRight: fr({
6537
+ topRight: dr({
6529
6538
  value: this.radiusTopRight ?? 0,
6530
6539
  min: 0,
6531
6540
  max: i
@@ -6543,7 +6552,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6543
6552
  _getEffectiveBackgroundFill() {
6544
6553
  let e = this.backgroundColor;
6545
6554
  if (!e) return null;
6546
- let t = fr({
6555
+ let t = dr({
6547
6556
  value: this.backgroundOpacity ?? 1,
6548
6557
  min: 0,
6549
6558
  max: 1
@@ -6551,7 +6560,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6551
6560
  try {
6552
6561
  r = new n(e);
6553
6562
  } catch (t) {
6554
- return nr.emitError({
6563
+ return tr.emitError({
6555
6564
  origin: "BackgroundTextbox",
6556
6565
  method: "_getEffectiveBackgroundFill",
6557
6566
  code: "INVALID_COLOR_VALUE",
@@ -6565,19 +6574,19 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6565
6574
  return r.setAlpha(t), r.toRgba();
6566
6575
  }
6567
6576
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
6568
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = fr({
6577
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = dr({
6569
6578
  value: c,
6570
6579
  min: 0,
6571
6580
  max: a
6572
- }), p = fr({
6581
+ }), p = dr({
6573
6582
  value: l,
6574
6583
  min: 0,
6575
6584
  max: a
6576
- }), m = fr({
6585
+ }), m = dr({
6577
6586
  value: u,
6578
6587
  min: 0,
6579
6588
  max: a
6580
- }), h = fr({
6589
+ }), h = dr({
6581
6590
  value: d,
6582
6591
  min: 0,
6583
6592
  max: a
@@ -6588,9 +6597,9 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6588
6597
  let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
6589
6598
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
6590
6599
  }
6591
- }, mr = () => {
6592
- y?.setClass && y.setClass(pr, "background-textbox");
6593
- }, hr = .01, gr = ({ textbox: e, lineIndices: t, updates: n }) => {
6600
+ }, pr = () => {
6601
+ y?.setClass && y.setClass(fr, "background-textbox");
6602
+ }, mr = .01, hr = ({ textbox: e, lineIndices: t, updates: n }) => {
6594
6603
  if (!t.length) return !1;
6595
6604
  let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
6596
6605
  if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
@@ -6602,7 +6611,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6602
6611
  r !== void 0 && d?.fontFamily !== r && (f.fontFamily = r, p = !0), i !== void 0 && d?.fontSize !== i && (f.fontSize = i, p = !0), a !== void 0 && d?.fill !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && d?.stroke !== void 0 && (delete f.stroke, p = !0), o !== null && d?.stroke !== o && (f.stroke = o, p = !0)), p && (u ||= (c = { ...c }, !0), c[n] = f, l = !0);
6603
6612
  }
6604
6613
  return l && (e.lineFontDefaults = c), l;
6605
- }, _r = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
6614
+ }, gr = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
6606
6615
  let r = e.length;
6607
6616
  if (r === 0) return {
6608
6617
  lineStyles: t,
@@ -6634,7 +6643,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6634
6643
  lineStyles: l,
6635
6644
  changed: u
6636
6645
  };
6637
- }, vr = ({ lineFontDefaults: e }) => {
6646
+ }, _r = ({ lineFontDefaults: e }) => {
6638
6647
  if (!e) return;
6639
6648
  let t = {};
6640
6649
  for (let n in e) {
@@ -6645,7 +6654,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6645
6654
  i && (t[r] = { ...i });
6646
6655
  }
6647
6656
  return t;
6648
- }, yr = ({ lineFontDefaults: e, scale: t }) => {
6657
+ }, vr = ({ lineFontDefaults: e, scale: t }) => {
6649
6658
  if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
6650
6659
  let n = {}, r = !1, i = !1;
6651
6660
  for (let a in e) {
@@ -6658,7 +6667,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6658
6667
  typeof s.fontSize == "number" && (c.fontSize = Math.max(1, s.fontSize * t), i = !0), n[o] = c, r = !0;
6659
6668
  }
6660
6669
  if (!(!r || !i)) return n;
6661
- }, br = ({ textbox: e }) => {
6670
+ }, yr = ({ textbox: e }) => {
6662
6671
  let t = e.text ?? "";
6663
6672
  if (!t.length) return [];
6664
6673
  let n = t.split("\n"), r = [], i = 0;
@@ -6670,7 +6679,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6670
6679
  });
6671
6680
  }
6672
6681
  return r;
6673
- }, xr = ({ range: e, text: t }) => {
6682
+ }, br = ({ range: e, text: t }) => {
6674
6683
  if (!e) return null;
6675
6684
  let n = t.length;
6676
6685
  if (n <= 0) return null;
@@ -6679,8 +6688,8 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6679
6688
  start: l,
6680
6689
  end: u
6681
6690
  };
6682
- }, Sr = ({ textbox: e, range: t }) => {
6683
- let n = br({ textbox: e });
6691
+ }, xr = ({ textbox: e, range: t }) => {
6692
+ let n = yr({ textbox: e });
6684
6693
  if (!n.length) return t;
6685
6694
  let { start: r } = t, { end: i } = t;
6686
6695
  for (let e = 0; e < n.length; e += 1) {
@@ -6693,7 +6702,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6693
6702
  start: r,
6694
6703
  end: i
6695
6704
  };
6696
- }, Cr = ({ textbox: e, range: t }) => {
6705
+ }, Sr = ({ textbox: e, range: t }) => {
6697
6706
  let n = e.text ?? "";
6698
6707
  if (!n.length) return [];
6699
6708
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -6702,7 +6711,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6702
6711
  i > n && r < c && o.push(e), s = c + 1;
6703
6712
  }
6704
6713
  return o;
6705
- }, wr = ({ textbox: e, range: t }) => {
6714
+ }, Cr = ({ textbox: e, range: t }) => {
6706
6715
  let n = e.text ?? "";
6707
6716
  if (!n.length) return [];
6708
6717
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -6711,33 +6720,33 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6711
6720
  r <= n && i >= c && o.push(e), s = c + 1;
6712
6721
  }
6713
6722
  return o;
6714
- }, Tr = ({ previous: e, next: t }) => {
6723
+ }, wr = ({ previous: e, next: t }) => {
6715
6724
  let n = Math.min(e.length, t.length);
6716
6725
  for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
6717
6726
  return n;
6718
- }, Er = ({ text: e, charIndex: t }) => {
6727
+ }, Tr = ({ text: e, charIndex: t }) => {
6719
6728
  let n = Math.max(0, Math.min(t, e.length)), r = 0;
6720
6729
  for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
6721
6730
  return r;
6722
- }, Dr = ({ text: e, lineIndex: t }) => {
6731
+ }, Er = ({ text: e, lineIndex: t }) => {
6723
6732
  if (t <= 0) return 0;
6724
6733
  let n = 0;
6725
6734
  for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
6726
6735
  return e.length;
6727
- }, Or = ({ textbox: e, text: t }) => {
6736
+ }, Dr = ({ textbox: e, text: t }) => {
6728
6737
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
6729
6738
  for (let t = 0; t < r; t += 1) {
6730
6739
  let n = e.getLineWidth(t);
6731
6740
  n > i && (i = n);
6732
6741
  }
6733
6742
  return i;
6734
- }, kr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
6743
+ }, Or = ({ textbox: e, montageLeft: t, montageRight: n }) => {
6735
6744
  e.setCoords();
6736
6745
  let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
6737
6746
  if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
6738
6747
  let s = 0;
6739
6748
  return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
6740
- }, Ar = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, jr = ({ stylesList: e }) => {
6749
+ }, kr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Ar = ({ stylesList: e }) => {
6741
6750
  let t = e.length;
6742
6751
  if (!t) return !1;
6743
6752
  for (let n = 0; n < t; n += 1) {
@@ -6747,16 +6756,16 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6747
6756
  if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
6748
6757
  }
6749
6758
  return !1;
6750
- }, Mr = ({ textbox: e }) => {
6751
- 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 = Ar({
6759
+ }, jr = ({ textbox: e }) => {
6760
+ 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 = kr({
6752
6761
  rawValue: t,
6753
6762
  calculatedValue: a
6754
- }), c = Ar({
6763
+ }), c = kr({
6755
6764
  rawValue: n,
6756
6765
  calculatedValue: o
6757
6766
  }), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
6758
6767
  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;
6759
- }, Nr = class t {
6768
+ }, Mr = class t {
6760
6769
  constructor({ editor: n }) {
6761
6770
  this._handleTextEditingEntered = (e) => {
6762
6771
  this.isTextEditingActive = !0;
@@ -6769,7 +6778,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6769
6778
  if (!t._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
6770
6779
  let r = t._isShapeOwnedTextbox(n), { text: i = "", uppercase: a, autoExpand: o } = n, s = !!a, c = o !== !1, l = i.toLocaleLowerCase(), u = r ? null : this.editingPlacementState?.get(n) ?? this.editor.canvasManager.getObjectPlacement({ object: n });
6771
6780
  if (s) {
6772
- let e = dr({ value: l });
6781
+ let e = ur({ value: l });
6773
6782
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
6774
6783
  } else n.textCaseRaw = i;
6775
6784
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
@@ -6787,7 +6796,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6787
6796
  let r = t._isShapeOwnedTextbox(n);
6788
6797
  this.editingPlacementState?.delete(n);
6789
6798
  let i = n.text ?? "";
6790
- n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Mr({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
6799
+ n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (jr({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
6791
6800
  lockMovementX: !1,
6792
6801
  lockMovementY: !1
6793
6802
  }));
@@ -6836,74 +6845,41 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6836
6845
  topRight: Math.max(0, u.topRight * x),
6837
6846
  bottomRight: Math.max(0, u.bottomRight * x),
6838
6847
  bottomLeft: Math.max(0, u.bottomLeft * x)
6839
- } : u, te = Object.keys(d).length > 0, ne;
6840
- if (y && te) {
6841
- let e = {};
6842
- Object.entries(d).forEach(([t, n]) => {
6843
- if (!n) return;
6844
- let r = {};
6845
- Object.entries(n).forEach(([e, t]) => {
6846
- if (!t) return;
6847
- let n = { ...t };
6848
- typeof t.fontSize == "number" && (n.fontSize = Math.max(1, t.fontSize * x)), r[e] = n;
6849
- }), Object.keys(r).length && (e[t] = r);
6850
- }), Object.keys(e).length && (ne = e);
6851
- }
6852
- let R;
6853
- y && (R = yr({
6854
- lineFontDefaults: f,
6855
- scale: x
6856
- }));
6857
- let re = a.getObjectPlacement({
6848
+ } : u, te = a.getObjectPlacement({
6858
6849
  object: r,
6859
6850
  originX: i.originX ?? r.originX,
6860
6851
  originY: i.originY ?? r.originY
6861
- }), z = P ?? p, ie = C !== z, B = Math.abs(w - (N ?? c)) > hr, ae = Math.abs(I.top - T) > .01 || Math.abs(I.right - E) > .01 || Math.abs(I.bottom - D) > .01 || Math.abs(I.left - O) > .01, V = Math.abs(L.topLeft - k) > .01 || Math.abs(L.topRight - A) > .01 || Math.abs(L.bottomRight - j) > .01 || Math.abs(L.bottomLeft - M) > .01;
6862
- if (!ie && !B && !ae && !V) {
6852
+ }), ne = P ?? p, R = C !== ne, re = Math.abs(w - (N ?? c)) > mr, z = Math.abs(I.top - T) > .01 || Math.abs(I.right - E) > .01 || Math.abs(I.bottom - D) > .01 || Math.abs(I.left - O) > .01, ie = Math.abs(L.topLeft - k) > .01 || Math.abs(L.topRight - A) > .01 || Math.abs(L.bottomRight - j) > .01 || Math.abs(L.bottomLeft - M) > .01;
6853
+ if (!R && !re && !z && !ie) {
6863
6854
  r.set({
6864
6855
  scaleX: 1,
6865
6856
  scaleY: 1
6866
6857
  }), i.scaleX = 1, i.scaleY = 1;
6867
6858
  return;
6868
6859
  }
6869
- g && ie && (r.autoExpand = !1), ne && (r.styles = ne), R && (r.lineFontDefaults = R), r.set({
6870
- width: C,
6871
- fontSize: y ? w : c,
6872
- paddingTop: I.top,
6873
- paddingRight: I.right,
6874
- paddingBottom: I.bottom,
6875
- paddingLeft: I.left,
6876
- radiusTopLeft: L.topLeft,
6877
- radiusTopRight: L.topRight,
6878
- radiusBottomRight: L.bottomRight,
6879
- radiusBottomLeft: L.bottomLeft,
6880
- scaleX: 1,
6881
- scaleY: 1
6882
- });
6883
- let H = !1;
6884
- if (y && r.autoExpand !== !1) {
6885
- let e = this._getTextboxUnwrappedWidth({ textbox: r });
6886
- e !== null && Math.abs((r.width ?? 0) - e) > .01 && (r.set({ width: e }), r.initDimensions(), H = !0);
6887
- } else r.initDimensions();
6888
- let oe = Mr({ textbox: r });
6889
- (oe || H) && (r.dirty = !0), a.applyObjectPlacement({
6890
- object: r,
6891
- placement: re
6892
- });
6893
- let se = r.width ?? C, ce = se !== z;
6860
+ let { appliedWidth: B, dimensionsRounded: ae } = this._commitStandaloneTextboxScale({
6861
+ textbox: r,
6862
+ base: {
6863
+ baseWidth: p,
6864
+ baseFontSize: c,
6865
+ basePadding: l,
6866
+ baseRadii: u,
6867
+ baseStyles: d,
6868
+ baseLineFontDefaults: f
6869
+ },
6870
+ widthScale: b,
6871
+ heightScale: x,
6872
+ placement: te,
6873
+ shouldScaleFontSize: y,
6874
+ shouldScalePadding: F,
6875
+ shouldScaleRadii: ee,
6876
+ shouldDisableAutoExpandOnHorizontalChange: g
6877
+ }), V = B !== ne;
6894
6878
  i.scaleX = 1, i.scaleY = 1;
6895
- let { original: U } = i;
6896
- U && (U.scaleX = 1, U.scaleY = 1, U.width = se, U.height = r.height, U.left = r.left, U.top = r.top), r.setCoords(), this.canvas.requestRenderAll(), o.baseWidth = se, o.baseFontSize = r.fontSize ?? w, o.baseStyles = JSON.parse(JSON.stringify(r.styles ?? {})), o.baseLineFontDefaults = vr({ lineFontDefaults: r.lineFontDefaults }), o.basePadding = {
6897
- top: I.top,
6898
- right: I.right,
6899
- bottom: I.bottom,
6900
- left: I.left
6901
- }, o.baseRadii = {
6902
- topLeft: L.topLeft,
6903
- topRight: L.topRight,
6904
- bottomRight: L.bottomRight,
6905
- bottomLeft: L.bottomLeft
6906
- }, o.hasWidthChange = ce || B || ae || V || H || oe;
6879
+ let { original: H } = i;
6880
+ H && (H.scaleX = 1, H.scaleY = 1, H.width = B, H.height = r.height, H.left = r.left, H.top = r.top), this.canvas.requestRenderAll();
6881
+ let U = t._captureTextScaleBase({ textbox: r });
6882
+ o.baseWidth = U.baseWidth, o.baseFontSize = U.baseFontSize, o.baseStyles = U.baseStyles, o.baseLineFontDefaults = U.baseLineFontDefaults, o.basePadding = U.basePadding, o.baseRadii = U.baseRadii, o.hasWidthChange = V || re || z || ie || ae;
6907
6883
  }, this._handleObjectModified = (n) => {
6908
6884
  let { target: r } = n;
6909
6885
  if (r instanceof e) {
@@ -6912,38 +6888,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6912
6888
  let { scaleX: i = 1, scaleY: a = 1 } = r;
6913
6889
  if (Math.abs(i - 1) < .01 && Math.abs(a - 1) < .01) return;
6914
6890
  this.canvas.discardActiveObject(), n.forEach((e) => {
6915
- if (t._isTextbox(e)) {
6916
- let t = e.scaleX ?? 1, n = e.scaleY ?? 1, r = (e.fontSize ?? 16) * n, i = (e.width ?? 0) * t, a = n, { paddingTop: o = 0, paddingRight: s = 0, paddingBottom: c = 0, paddingLeft: l = 0, radiusTopLeft: u = 0, radiusTopRight: d = 0, radiusBottomRight: f = 0, radiusBottomLeft: p = 0, styles: m } = e, h = {
6917
- paddingTop: Math.max(0, o * a),
6918
- paddingRight: Math.max(0, s * a),
6919
- paddingBottom: Math.max(0, c * a),
6920
- paddingLeft: Math.max(0, l * a)
6921
- }, g = {
6922
- radiusTopLeft: Math.max(0, u * a),
6923
- radiusTopRight: Math.max(0, d * a),
6924
- radiusBottomRight: Math.max(0, f * a),
6925
- radiusBottomLeft: Math.max(0, p * a)
6926
- }, _ = m;
6927
- m && Object.keys(m).length > 0 && (_ = JSON.parse(JSON.stringify(m)), Object.values(_).forEach((e) => {
6928
- Object.values(e).forEach((e) => {
6929
- typeof e.fontSize == "number" && (e.fontSize = Math.max(1, e.fontSize * a));
6930
- });
6931
- }));
6932
- let v = yr({
6933
- lineFontDefaults: e.lineFontDefaults,
6934
- scale: a
6935
- }), y = {
6936
- fontSize: r,
6937
- width: i,
6938
- scaleX: 1,
6939
- scaleY: 1,
6940
- ...h,
6941
- ...g,
6942
- styles: _
6943
- };
6944
- v && (y.lineFontDefaults = v), e.set(y), Mr({ textbox: e });
6945
- }
6946
- e.setCoords();
6891
+ this.commitStandaloneTextScale({ target: e }), e.setCoords();
6947
6892
  });
6948
6893
  let o = new e(n, { canvas: this.canvas });
6949
6894
  this.canvas.setActiveObject(o), this.canvas.requestRenderAll();
@@ -6971,12 +6916,12 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
6971
6916
  scaleX: 1,
6972
6917
  scaleY: 1
6973
6918
  }), r.setCoords();
6974
- }, this.editor = n, this.canvas = n.canvas, this.fonts = n.options.fonts ?? [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), mr();
6919
+ }, this.editor = n, this.canvas = n.canvas, this.fonts = n.options.fonts ?? [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), pr();
6975
6920
  }
6976
6921
  addText({ id: e = `text-${D()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: O = !1, withoutSave: k = !1, withoutAdding: A = !1 } = {}) {
6977
6922
  let { canvasManager: j, historyManager: M } = this.editor, { canvas: N } = this;
6978
6923
  M.suspendHistory();
6979
- let P = i ?? this._getDefaultFontFamily(), F = ur({ width: m }), ee = lr({
6924
+ let P = i ?? this._getDefaultFontFamily(), F = lr({ width: m }), ee = cr({
6980
6925
  strokeColor: p,
6981
6926
  width: F
6982
6927
  }), I = {
@@ -7005,14 +6950,14 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7005
6950
  radiusBottomRight: w,
7006
6951
  radiusBottomLeft: T,
7007
6952
  ...E
7008
- }, L = new pr(n, I), te = r !== !1;
6953
+ }, L = new fr(n, I), te = r !== !1;
7009
6954
  L.autoExpand = te;
7010
6955
  let ne = E.left !== void 0 || E.top !== void 0;
7011
6956
  if (L.textCaseRaw = L.text ?? "", l) {
7012
- let e = dr({ value: L.textCaseRaw });
6957
+ let e = ur({ value: L.textCaseRaw });
7013
6958
  e !== L.text && L.set({ text: e });
7014
6959
  }
7015
- Mr({ textbox: L }) && (L.dirty = !0);
6960
+ jr({ textbox: L }) && (L.dirty = !0);
7016
6961
  let R;
7017
6962
  ne && (R = j.resolveObjectPlacement({
7018
6963
  object: L,
@@ -7059,91 +7004,91 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7059
7004
  top: I,
7060
7005
  originX: L,
7061
7006
  originY: te
7062
- }), z = a === void 0 ? ir({ textbox: o }) : xr({
7007
+ }), z = a === void 0 ? rr({ textbox: o }) : br({
7063
7008
  text: s,
7064
7009
  range: a
7065
- }), ie = z ? Sr({
7010
+ }), ie = z ? xr({
7066
7011
  textbox: o,
7067
7012
  range: z
7068
- }) : null, B = {}, ae = {}, V = {}, H, oe, se = or({
7013
+ }) : null, B = {}, ae = {}, V = {}, H, U, oe = ar({
7069
7014
  textbox: o,
7070
7015
  range: z
7071
- }), ce = !z || se, U = !z;
7072
- if (m !== void 0 && (ie && (ae.fontFamily = m), ce && (R.fontFamily = m, U && (V.fontFamily = m))), h !== void 0 && (ie && (ae.fontSize = h), ce && (R.fontSize = h, U && (V.fontSize = h))), g !== void 0) {
7016
+ }), se = !z || oe, ce = !z;
7017
+ if (m !== void 0 && (ie && (ae.fontFamily = m), se && (R.fontFamily = m, ce && (V.fontFamily = m))), h !== void 0 && (ie && (ae.fontSize = h), se && (R.fontSize = h, ce && (V.fontSize = h))), g !== void 0) {
7073
7018
  let e = g ? "bold" : "normal";
7074
- z && (B.fontWeight = e), ce && (R.fontWeight = e, U && (V.fontWeight = e));
7019
+ z && (B.fontWeight = e), se && (R.fontWeight = e, ce && (V.fontWeight = e));
7075
7020
  }
7076
7021
  if (_ !== void 0) {
7077
7022
  let e = _ ? "italic" : "normal";
7078
- z && (B.fontStyle = e), ce && (R.fontStyle = e, U && (V.fontStyle = e));
7023
+ z && (B.fontStyle = e), se && (R.fontStyle = e, ce && (V.fontStyle = e));
7079
7024
  }
7080
- if (v !== void 0 && (z && (B.underline = v), ce && (R.underline = v, U && (V.underline = v))), b !== void 0 && (z && (B.linethrough = b), ce && (R.linethrough = b, U && (V.linethrough = b))), x !== void 0 && (R.textAlign = x), S !== void 0 && (z && (B.fill = S), ce && (R.fill = S, U && (V.fill = S))), C !== void 0 || w !== void 0) {
7081
- let e = z ? cr({
7025
+ if (v !== void 0 && (z && (B.underline = v), se && (R.underline = v, ce && (V.underline = v))), b !== void 0 && (z && (B.linethrough = b), se && (R.linethrough = b, ce && (V.linethrough = b))), x !== void 0 && (R.textAlign = x), S !== void 0 && (z && (B.fill = S), se && (R.fill = S, ce && (V.fill = S))), C !== void 0 || w !== void 0) {
7026
+ let e = z ? sr({
7082
7027
  textbox: o,
7083
7028
  range: z,
7084
7029
  property: "strokeWidth"
7085
- }) : void 0, t = z ? cr({
7030
+ }) : void 0, t = z ? sr({
7086
7031
  textbox: o,
7087
7032
  range: z,
7088
7033
  property: "stroke"
7089
7034
  }) : void 0;
7090
- oe = ur({ width: w ?? e ?? o.strokeWidth ?? 0 }), H = lr({
7035
+ U = lr({ width: w ?? e ?? o.strokeWidth ?? 0 }), H = cr({
7091
7036
  strokeColor: C ?? t ?? o.stroke ?? void 0,
7092
- width: oe
7093
- }), z && (B.stroke = H, B.strokeWidth = oe), ce && (R.stroke = H, R.strokeWidth = oe, U && (V.stroke = H, V.strokeWidth = oe));
7037
+ width: U
7038
+ }), z && (B.stroke = H, B.strokeWidth = U), se && (R.stroke = H, R.strokeWidth = U, ce && (V.stroke = H, V.strokeWidth = U));
7094
7039
  }
7095
7040
  T !== void 0 && (R.opacity = T), E !== void 0 && (R.backgroundColor = E), D !== void 0 && (R.backgroundOpacity = D), O !== void 0 && (R.paddingTop = O), k !== void 0 && (R.paddingRight = k), A !== void 0 && (R.paddingBottom = A), j !== void 0 && (R.paddingLeft = j), M !== void 0 && (R.radiusTopLeft = M), N !== void 0 && (R.radiusTopRight = N), P !== void 0 && (R.radiusBottomRight = P), F !== void 0 && (R.radiusBottomLeft = F);
7096
7041
  let le = o.textCaseRaw ?? s, ue = !!o.uppercase, de = f !== void 0, fe = de ? f ?? "" : le, pe = y ?? ue, me = pe !== ue;
7097
- de || me ? (R.text = pe ? dr({ value: fe }) : fe, o.textCaseRaw = fe) : o.textCaseRaw === void 0 && (o.textCaseRaw = le), o.uppercase = pe, o.set(R);
7042
+ de || me ? (R.text = pe ? ur({ value: fe }) : fe, o.textCaseRaw = fe) : o.textCaseRaw === void 0 && (o.textCaseRaw = le), o.uppercase = pe, o.set(R);
7098
7043
  let he = !1;
7099
7044
  if (z) {
7100
- let e = sr({
7045
+ let e = or({
7101
7046
  textbox: o,
7102
7047
  styles: B,
7103
7048
  range: z
7104
- }), t = ie ? sr({
7049
+ }), t = ie ? or({
7105
7050
  textbox: o,
7106
7051
  styles: ae,
7107
7052
  range: ie
7108
7053
  }) : !1;
7109
7054
  he = e || t;
7110
7055
  } else if (Object.keys(V).length) {
7111
- let e = ar({ textbox: o });
7112
- e && (he = sr({
7056
+ let e = ir({ textbox: o });
7057
+ e && (he = or({
7113
7058
  textbox: o,
7114
7059
  styles: V,
7115
7060
  range: e
7116
7061
  }));
7117
7062
  }
7118
- let ge = he && jr({ stylesList: [
7063
+ let ge = he && Ar({ stylesList: [
7119
7064
  B,
7120
7065
  ae,
7121
7066
  V
7122
7067
  ] });
7123
7068
  if (he && (o.dirty = !0), ie && (m !== void 0 || h !== void 0)) {
7124
- let e = Cr({
7069
+ let e = Sr({
7125
7070
  textbox: o,
7126
7071
  range: ie
7127
7072
  }), t = {};
7128
- m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h), gr({
7073
+ m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h), hr({
7129
7074
  textbox: o,
7130
7075
  lineIndices: e,
7131
7076
  updates: t
7132
7077
  });
7133
7078
  }
7134
7079
  if (z && (S !== void 0 || C !== void 0 || w !== void 0)) {
7135
- let e = wr({
7080
+ let e = Cr({
7136
7081
  textbox: o,
7137
7082
  range: z
7138
7083
  }), t = {};
7139
- S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (H === null && (t.stroke = null), H != null && (t.stroke = H)), gr({
7084
+ S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (H === null && (t.stroke = null), H != null && (t.stroke = H)), hr({
7140
7085
  textbox: o,
7141
7086
  lineIndices: e,
7142
7087
  updates: t
7143
7088
  });
7144
7089
  }
7145
7090
  ge && (o.initDimensions(), o.dirty = !0), (E !== void 0 || D !== void 0 || O !== void 0 || k !== void 0 || A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || P !== void 0 || F !== void 0) && (o.dirty = !0);
7146
- let _e = jr({ stylesList: [
7091
+ let _e = Ar({ stylesList: [
7147
7092
  R,
7148
7093
  B,
7149
7094
  ae,
@@ -7185,6 +7130,23 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7185
7130
  let { canvas: e } = this;
7186
7131
  e.off("object:scaling", this._handleObjectScaling), e.off("object:resizing", this._handleObjectResizing), e.off("object:modified", this._handleObjectModified), e.off("text:editing:exited", this._handleTextEditingExited), e.off("text:editing:entered", this._handleTextEditingEntered), e.off("text:changed", this._handleTextChanged);
7187
7132
  }
7133
+ commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: n = !1 }) {
7134
+ if (!t._isTextbox(e) || t._isShapeOwnedTextbox(e)) return !1;
7135
+ let r = Math.abs(e.scaleX ?? 1) || 1, i = Math.abs(e.scaleY ?? 1) || 1;
7136
+ if (!(Math.abs(r - 1) > .01 || Math.abs(i - 1) > .01)) return !1;
7137
+ let a = t._captureTextScaleBase({ textbox: e }), o = this.editor.canvasManager.getObjectPlacement({ object: e });
7138
+ return this._commitStandaloneTextboxScale({
7139
+ textbox: e,
7140
+ base: a,
7141
+ widthScale: r,
7142
+ heightScale: i,
7143
+ placement: o,
7144
+ shouldScaleFontSize: !0,
7145
+ shouldScalePadding: !0,
7146
+ shouldScaleRadii: !0,
7147
+ shouldDisableAutoExpandOnHorizontalChange: n
7148
+ }), !0;
7149
+ }
7188
7150
  _resolveTextObject(e) {
7189
7151
  if (e instanceof _) return e;
7190
7152
  let { canvas: n } = this;
@@ -7208,6 +7170,80 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7208
7170
  let n = t.split("\n").length, { textLines: r } = e;
7209
7171
  return Array.isArray(r) && r.length > n;
7210
7172
  }
7173
+ static _captureTextScaleBase({ textbox: e }) {
7174
+ let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
7175
+ return {
7176
+ baseWidth: t,
7177
+ baseFontSize: n,
7178
+ basePadding: {
7179
+ top: a,
7180
+ right: o,
7181
+ bottom: s,
7182
+ left: c
7183
+ },
7184
+ baseRadii: {
7185
+ topLeft: l,
7186
+ topRight: u,
7187
+ bottomRight: d,
7188
+ bottomLeft: f
7189
+ },
7190
+ baseStyles: JSON.parse(JSON.stringify(r)),
7191
+ baseLineFontDefaults: _r({ lineFontDefaults: i })
7192
+ };
7193
+ }
7194
+ _commitStandaloneTextboxScale({ textbox: e, base: t, widthScale: n, heightScale: r, placement: i, shouldScaleFontSize: a, shouldScalePadding: o, shouldScaleRadii: s, shouldDisableAutoExpandOnHorizontalChange: c = !1 }) {
7195
+ let { baseWidth: l, baseFontSize: u, basePadding: d, baseRadii: f, baseStyles: p, baseLineFontDefaults: m } = t, h = Math.max(1, l * n), g = Math.max(1, Math.round(h)), _ = Math.max(1, u * r), v = Object.keys(p).length > 0, y;
7196
+ if (a && v) {
7197
+ let e = {};
7198
+ Object.entries(p).forEach(([t, n]) => {
7199
+ if (!n) return;
7200
+ let i = {};
7201
+ Object.entries(n).forEach(([e, t]) => {
7202
+ if (!t) return;
7203
+ let n = { ...t };
7204
+ typeof t.fontSize == "number" && (n.fontSize = Math.max(1, t.fontSize * r)), i[e] = n;
7205
+ }), Object.keys(i).length && (e[t] = i);
7206
+ }), Object.keys(e).length && (y = e);
7207
+ }
7208
+ let b;
7209
+ a && (b = vr({
7210
+ lineFontDefaults: m,
7211
+ scale: r
7212
+ }));
7213
+ let x = o ? {
7214
+ top: Math.max(0, d.top * r),
7215
+ right: Math.max(0, d.right * r),
7216
+ bottom: Math.max(0, d.bottom * r),
7217
+ left: Math.max(0, d.left * r)
7218
+ } : d, S = s ? {
7219
+ topLeft: Math.max(0, f.topLeft * r),
7220
+ topRight: Math.max(0, f.topRight * r),
7221
+ bottomRight: Math.max(0, f.bottomRight * r),
7222
+ bottomLeft: Math.max(0, f.bottomLeft * r)
7223
+ } : f, C = g !== (e.width ?? l);
7224
+ c && C && (e.autoExpand = !1), y && (e.styles = y), b && (e.lineFontDefaults = b), e.set({
7225
+ width: g,
7226
+ fontSize: a ? _ : u,
7227
+ paddingTop: x.top,
7228
+ paddingRight: x.right,
7229
+ paddingBottom: x.bottom,
7230
+ paddingLeft: x.left,
7231
+ radiusTopLeft: S.topLeft,
7232
+ radiusTopRight: S.topRight,
7233
+ radiusBottomRight: S.bottomRight,
7234
+ radiusBottomLeft: S.bottomLeft,
7235
+ scaleX: 1,
7236
+ scaleY: 1
7237
+ }), e.initDimensions();
7238
+ let w = jr({ textbox: e });
7239
+ return w && (e.dirty = !0), this.editor.canvasManager.applyObjectPlacement({
7240
+ object: e,
7241
+ placement: i
7242
+ }), e.setCoords(), {
7243
+ appliedWidth: e.width ?? g,
7244
+ dimensionsRounded: w
7245
+ };
7246
+ }
7211
7247
  _normalizeTextboxAfterContentChange({ textbox: e, placement: t, shouldAutoExpand: n, clampToMontage: r = !0 }) {
7212
7248
  let i = !1;
7213
7249
  n && (i = this._autoExpandTextboxWidth(e, {
@@ -7215,33 +7251,13 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7215
7251
  clampToMontage: r
7216
7252
  }));
7217
7253
  let a = !1;
7218
- i || (a = Mr({ textbox: e }));
7254
+ i || (a = jr({ textbox: e }));
7219
7255
  let o = !1;
7220
7256
  return !i && t && (this.editor.canvasManager.applyObjectPlacement({
7221
7257
  object: e,
7222
7258
  placement: t
7223
7259
  }), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
7224
7260
  }
7225
- _getTextboxUnwrappedWidth({ textbox: e }) {
7226
- let t = typeof e.text == "string" ? e.text : "";
7227
- if (!t.length) return null;
7228
- e.initDimensions();
7229
- let n = e, { _textLines: r, _unwrappedTextLines: i, __lineWidths: a, __charBounds: o } = n;
7230
- if (!Array.isArray(i) || i.length === 0) {
7231
- let n = Math.ceil(Or({
7232
- textbox: e,
7233
- text: t
7234
- }));
7235
- return Number.isFinite(n) ? Math.max(n, e.minWidth ?? 1) : null;
7236
- }
7237
- n._textLines = i, n.__lineWidths = [], n.__charBounds = [];
7238
- try {
7239
- let t = Math.ceil(e.calcTextWidth());
7240
- return Number.isFinite(t) ? Math.max(t, e.minWidth ?? 1) : null;
7241
- } finally {
7242
- n._textLines = r, n.__lineWidths = a ?? [], n.__charBounds = o ?? [];
7243
- }
7244
- }
7245
7261
  _bindEvents() {
7246
7262
  let { canvas: e } = this;
7247
7263
  e.on("object:scaling", this._handleObjectScaling), e.on("object:resizing", this._handleObjectResizing), e.on("object:modified", this._handleObjectModified), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged);
@@ -7249,15 +7265,15 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7249
7265
  _syncLineFontDefaultsOnTextChanged({ textbox: e }) {
7250
7266
  let { text: t = "", lineFontDefaults: n, styles: r, fontFamily: i, fontSize: a, fill: o, stroke: s, selectionStart: c, isEditing: l } = e, u = t, d = e.__lineDefaultsPrevText ?? u, f = d.split("\n"), p = u.split("\n"), m = f.length, h = p.length - m, g = n, _ = !1, v = !1, y = typeof o == "string" ? o : void 0, b = typeof s == "string" ? s : void 0;
7251
7267
  if (h !== 0 && n && Object.keys(n).length) {
7252
- let e = Tr({
7268
+ let e = wr({
7253
7269
  previous: d,
7254
7270
  next: u
7255
- }), t = Er({
7271
+ }), t = Tr({
7256
7272
  text: d,
7257
7273
  charIndex: e
7258
7274
  });
7259
7275
  if (h > 0) {
7260
- let r = Dr({
7276
+ let r = Er({
7261
7277
  text: d,
7262
7278
  lineIndex: t
7263
7279
  }), i = t + 1;
@@ -7298,7 +7314,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7298
7314
  let t = p[e] ?? "", n = g ? g[e] : void 0;
7299
7315
  if (n && (T = n), t.length !== 0) {
7300
7316
  if (n) {
7301
- let r = _r({
7317
+ let r = gr({
7302
7318
  lineText: t,
7303
7319
  lineStyles: S ? S[e] : void 0,
7304
7320
  lineDefaults: n
@@ -7338,16 +7354,16 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7338
7354
  if (!Number.isFinite(f) || f <= 0) return !1;
7339
7355
  let p = a.split("\n").length, m = !1;
7340
7356
  Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
7341
- let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Or({
7357
+ let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Dr({
7342
7358
  textbox: e,
7343
7359
  text: a
7344
7360
  })), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
7345
- g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Mr({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
7361
+ g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), jr({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
7346
7362
  object: e,
7347
7363
  placement: t
7348
7364
  });
7349
7365
  let b = !1;
7350
- return n && (b = kr({
7366
+ return n && (b = Or({
7351
7367
  textbox: e,
7352
7368
  montageLeft: o,
7353
7369
  montageRight: o + s
@@ -7357,30 +7373,11 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7357
7373
  return this.editingPlacementState ||= /* @__PURE__ */ new WeakMap(), this.editingPlacementState;
7358
7374
  }
7359
7375
  _ensureScalingState(e) {
7360
- let t = this.scalingState.get(e);
7361
- if (!t) {
7362
- let n = e.width ?? e.calcTextWidth(), r = e.fontSize ?? 16, { styles: i = {} } = e, { lineFontDefaults: a } = e, { paddingTop: o = 0, paddingRight: s = 0, paddingBottom: c = 0, paddingLeft: l = 0 } = e, { radiusTopLeft: u = 0, radiusTopRight: d = 0, radiusBottomRight: f = 0, radiusBottomLeft: p = 0 } = e;
7363
- t = {
7364
- baseWidth: n,
7365
- baseFontSize: r,
7366
- basePadding: {
7367
- top: o,
7368
- right: s,
7369
- bottom: c,
7370
- left: l
7371
- },
7372
- baseRadii: {
7373
- topLeft: u,
7374
- topRight: d,
7375
- bottomRight: f,
7376
- bottomLeft: p
7377
- },
7378
- baseStyles: JSON.parse(JSON.stringify(i)),
7379
- baseLineFontDefaults: vr({ lineFontDefaults: a }),
7380
- hasWidthChange: !1
7381
- }, this.scalingState.set(e, t);
7382
- }
7383
- return t;
7376
+ let n = this.scalingState.get(e);
7377
+ return n || (n = {
7378
+ ...t._captureTextScaleBase({ textbox: e }),
7379
+ hasWidthChange: !1
7380
+ }, this.scalingState.set(e, n)), n;
7384
7381
  }
7385
7382
  static _getSnapshot(e) {
7386
7383
  let t = ({ snapshot: e, entries: t }) => {
@@ -7431,7 +7428,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7431
7428
  _getDefaultFontFamily() {
7432
7429
  return this.fonts[0]?.family ?? "Arial";
7433
7430
  }
7434
- }, Pr = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, Fr = (e) => {
7431
+ }, Nr = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, Pr = (e) => {
7435
7432
  if (!e || typeof e != "object") return null;
7436
7433
  let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof a?.color == "string" ? a.color : void 0, c = typeof o?.color == "string" ? o.color : s, l = typeof a?.offset == "number" ? a.offset * 100 : void 0, u = typeof o?.offset == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
7437
7434
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -7442,7 +7439,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7442
7439
  let { x1: e, y1: t, x2: r, y2: i } = n;
7443
7440
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
7444
7441
  type: "linear",
7445
- angle: Pr({
7442
+ angle: Nr({
7446
7443
  x1: e,
7447
7444
  y1: t,
7448
7445
  x2: r,
@@ -7470,7 +7467,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7470
7467
  };
7471
7468
  }
7472
7469
  return null;
7473
- }, Ir = "_templateAnchorX", Lr = "_templateAnchorY", Rr = class t {
7470
+ }, Fr = "_templateAnchorX", Ir = "_templateAnchorY", Lr = class t {
7474
7471
  constructor({ editor: e }) {
7475
7472
  this.editor = e;
7476
7473
  }
@@ -7479,13 +7476,13 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7479
7476
  if (!p.length) return s.emitWarning({
7480
7477
  origin: "TemplateManager",
7481
7478
  method: "serializeSelection",
7482
- code: tr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
7479
+ code: er.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
7483
7480
  message: "Нет объектов для сериализации шаблона"
7484
7481
  }), null;
7485
7482
  let m = t._getBounds(o), h = t._getMontageSize({
7486
7483
  montageArea: o,
7487
7484
  bounds: m
7488
- }), g = h.width, _ = h.height, v = p.map((e) => t._serializeObject({
7485
+ }), g = h.width, _ = h.height, v = p.map((e) => this._serializeObject({
7489
7486
  object: e,
7490
7487
  bounds: m,
7491
7488
  baseWidth: g,
@@ -7508,14 +7505,14 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7508
7505
  if (!s?.length) return a.emitWarning({
7509
7506
  origin: "TemplateManager",
7510
7507
  method: "applyTemplate",
7511
- code: tr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7508
+ code: er.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7512
7509
  message: "Шаблон не содержит объектов"
7513
7510
  }), null;
7514
7511
  let u = t._getBounds(r);
7515
7512
  if (!u) return a.emitWarning({
7516
7513
  origin: "TemplateManager",
7517
7514
  method: "applyTemplate",
7518
- code: tr.TEMPLATE_MANAGER.INVALID_TARGET,
7515
+ code: er.TEMPLATE_MANAGER.INVALID_TARGET,
7519
7516
  message: "Не удалось определить границы монтажной области"
7520
7517
  }), null;
7521
7518
  let d = t._getMontageSize({
@@ -7534,7 +7531,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7534
7531
  if (!r.length) return a.emitWarning({
7535
7532
  origin: "TemplateManager",
7536
7533
  method: "applyTemplate",
7537
- code: tr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7534
+ code: er.TEMPLATE_MANAGER.INVALID_TEMPLATE,
7538
7535
  message: "Не удалось создать объекты шаблона"
7539
7536
  }), null;
7540
7537
  let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
@@ -7546,14 +7543,14 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7546
7543
  let l = c.map((e) => (this._adaptTextboxWidth({
7547
7544
  object: e,
7548
7545
  baseWidth: f.baseWidth
7549
- }), t._transformObject({
7546
+ }), this._transformObject({
7550
7547
  object: e,
7551
7548
  scale: p,
7552
7549
  bounds: u,
7553
7550
  baseWidth: f.baseWidth,
7554
7551
  baseHeight: f.baseHeight,
7555
7552
  useRelativePositions: m
7556
- }), Je({ object: e }), e.set({
7553
+ }), this.editor.textManager?.commitStandaloneTextScale({ target: e }), qe({ object: e }), e.set({
7557
7554
  id: `${e.type}-${D()}`,
7558
7555
  evented: !0
7559
7556
  }), n.add(e), e));
@@ -7569,7 +7566,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7569
7566
  return a.emitError({
7570
7567
  origin: "TemplateManager",
7571
7568
  method: "applyTemplate",
7572
- code: tr.TEMPLATE_MANAGER.APPLY_FAILED,
7569
+ code: er.TEMPLATE_MANAGER.APPLY_FAILED,
7573
7570
  message: "Ошибка применения шаблона",
7574
7571
  data: {
7575
7572
  templateId: l,
@@ -7702,7 +7699,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7702
7699
  return null;
7703
7700
  }
7704
7701
  }
7705
- static _transformObject({ object: e, scale: n, bounds: r, baseWidth: i, baseHeight: a, useRelativePositions: o }) {
7702
+ _transformObject({ object: e, scale: n, bounds: r, baseWidth: i, baseHeight: a, useRelativePositions: o }) {
7706
7703
  let s = e, { x: c, y: l } = Ge({
7707
7704
  object: e,
7708
7705
  baseWidth: i,
@@ -7723,14 +7720,22 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7723
7720
  baseHeight: a,
7724
7721
  scale: n,
7725
7722
  useRelativePositions: o,
7726
- anchorX: t._resolveAnchor(s, Ir),
7727
- anchorY: t._resolveAnchor(s, Lr)
7723
+ anchorX: t._resolveAnchor(s, Fr),
7724
+ anchorY: t._resolveAnchor(s, Ir)
7728
7725
  })
7729
7726
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
7730
7727
  e.set({
7731
7728
  scaleX: h,
7732
7729
  scaleY: g
7733
- }), e.setPositionByOrigin(m, _, v), e.setCoords(), delete s[Ir], delete s[Lr];
7730
+ }), this.editor.canvasManager.applyObjectPlacement({
7731
+ object: e,
7732
+ placement: {
7733
+ left: m.x,
7734
+ top: m.y,
7735
+ originX: _,
7736
+ originY: v
7737
+ }
7738
+ }), delete s[Fr], delete s[Ir];
7734
7739
  }
7735
7740
  static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
7736
7741
  if (!a) return e;
@@ -7794,7 +7799,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7794
7799
  });
7795
7800
  if (!i || !s || !o) return;
7796
7801
  e.setCoords();
7797
- let c = e, l = t._resolveAnchor(c, Ir), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
7802
+ let c = e, l = t._resolveAnchor(c, Fr), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
7798
7803
  e.set("width", i), e.initDimensions();
7799
7804
  let g = t._getLongestLineWidth({
7800
7805
  textbox: e,
@@ -7812,30 +7817,24 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7812
7817
  }
7813
7818
  return i;
7814
7819
  }
7815
- static _serializeObject({ object: e, bounds: n, baseWidth: r, baseHeight: i }) {
7816
- let a = e.toDatalessObject([...se]);
7820
+ _serializeObject({ object: e, bounds: n, baseWidth: r, baseHeight: i }) {
7821
+ let a = e.toDatalessObject([...oe]);
7817
7822
  if (t._isSvgObject(e)) {
7818
7823
  let n = t._extractSvgMarkup(e);
7819
7824
  n && (a.svgMarkup = n, delete a.objects, delete a.path);
7820
7825
  }
7821
7826
  if (!n) return a;
7822
- let { left: o, top: s, width: c, height: l } = n, u = e.getBoundingRect(!1, !0), d = r || c || 1, f = i || l || 1, p = qe({
7823
- object: e,
7824
- bounds: n
7825
- }) ?? (() => {
7826
- let t = e.originX ?? "center", n = e.originY ?? "center", r = e.getPointByOrigin(t, n);
7827
- return {
7828
- x: (r.x - o) / d,
7829
- y: (r.y - s) / f
7830
- };
7831
- })(), m = (u.left - o) / d, h = (u.top - s) / f, g = m + u.width / d, _ = h + u.height / f;
7832
- return a[Ir] = t._detectAnchor({
7833
- start: m,
7834
- end: g
7835
- }), a[Lr] = t._detectAnchor({
7827
+ let { left: o, top: s, width: c, height: l } = n, u = e.getBoundingRect(!1, !0), d = r || c || 1, f = i || l || 1, p = this.editor.canvasManager.getObjectPlacement({ object: e }), m = {
7828
+ x: (p.left - o) / d,
7829
+ y: (p.top - s) / f
7830
+ }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
7831
+ return a[Fr] = t._detectAnchor({
7836
7832
  start: h,
7837
7833
  end: _
7838
- }), a.left = p.x, a.top = p.y, a;
7834
+ }), a[Ir] = t._detectAnchor({
7835
+ start: g,
7836
+ end: v
7837
+ }), a.left = m.x, a.top = m.y, a;
7839
7838
  }
7840
7839
  static _extractBackgroundObject(e) {
7841
7840
  let t = e.findIndex((e) => e.id === "background");
@@ -7857,7 +7856,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7857
7856
  withoutSave: !0
7858
7857
  }), !0;
7859
7858
  if (a === "gradient") {
7860
- let e = Fr(r);
7859
+ let e = Pr(r);
7861
7860
  if (e) return n.setGradientBackground({
7862
7861
  gradient: e,
7863
7862
  customData: o,
@@ -7878,7 +7877,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7878
7877
  r.emitWarning({
7879
7878
  origin: "TemplateManager",
7880
7879
  method: "applyTemplate",
7881
- code: tr.TEMPLATE_MANAGER.APPLY_FAILED,
7880
+ code: er.TEMPLATE_MANAGER.APPLY_FAILED,
7882
7881
  message: "Не удалось применить фон из шаблона",
7883
7882
  data: e
7884
7883
  });
@@ -7914,29 +7913,29 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7914
7913
  enlivenObjectEnlivables(e) {
7915
7914
  return C.enlivenObjectEnlivables(e);
7916
7915
  }
7917
- }, zr = "#3D8BF4", Br = .5, Vr = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Hr = ({ firstDistance: e, secondDistance: t }) => {
7918
- let n = Vr({ distance: e }), r = Vr({ distance: t });
7916
+ }, Rr = "#3D8BF4", zr = .5, Br = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Vr = ({ firstDistance: e, secondDistance: t }) => {
7917
+ let n = Br({ distance: e }), r = Br({ distance: t });
7919
7918
  return {
7920
7919
  firstDisplayDistance: n,
7921
7920
  secondDisplayDistance: r,
7922
7921
  displayDistanceDiff: Math.abs(n - r),
7923
7922
  commonDisplayDistance: Math.max(n, r)
7924
7923
  };
7925
- }, Ur = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Wr = ({ step: e }) => {
7924
+ }, Hr = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Ur = ({ step: e }) => {
7926
7925
  let t = Math.abs(e).toString(), n = t.indexOf(".");
7927
7926
  return n === -1 ? 0 : t.slice(n + 1).length;
7928
- }, Gr = ({ value: e, step: t }) => {
7927
+ }, Wr = ({ value: e, step: t }) => {
7929
7928
  if (t === 0) return e;
7930
- let n = Wr({ step: t }), r = Math.round(e / t) * t;
7929
+ let n = Ur({ step: t }), r = Math.round(e / t) * t;
7931
7930
  return Number(r.toFixed(n));
7932
- }, Kr = ({ value: e, step: t }) => {
7931
+ }, Gr = ({ value: e, step: t }) => {
7933
7932
  if (t === 0) return !0;
7934
- let n = Gr({
7933
+ let n = Wr({
7935
7934
  value: e,
7936
7935
  step: t
7937
- }), r = 10 ** -(Wr({ step: t }) + 4);
7936
+ }), r = 10 ** -(Ur({ step: t }) + 4);
7938
7937
  return Math.abs(n - e) <= r;
7939
- }, qr = ({ bounds: e, axis: t }) => {
7938
+ }, Kr = ({ bounds: e, axis: t }) => {
7940
7939
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
7941
7940
  return t === "vertical" ? {
7942
7941
  start: i,
@@ -7945,7 +7944,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7945
7944
  start: n,
7946
7945
  end: r
7947
7946
  };
7948
- }, Jr = ({ items: e, axis: t }) => {
7947
+ }, qr = ({ items: e, axis: t }) => {
7949
7948
  for (let n = 1; n < e.length; n += 1) {
7950
7949
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
7951
7950
  for (; o >= 0;) {
@@ -7955,10 +7954,10 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7955
7954
  }
7956
7955
  e[o + 1] = r;
7957
7956
  }
7958
- }, Yr = ({ items: e, index: t, axis: n, direction: r }) => {
7957
+ }, Jr = ({ items: e, index: t, axis: n, direction: r }) => {
7959
7958
  let i = e[t];
7960
7959
  if (!i) return null;
7961
- let { bounds: a } = i, { start: o, end: s } = qr({
7960
+ let { bounds: a } = i, { start: o, end: s } = Kr({
7962
7961
  bounds: a,
7963
7962
  axis: n
7964
7963
  });
@@ -7966,7 +7965,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7966
7965
  for (let r = t - 1; r >= 0; --r) {
7967
7966
  let t = e[r];
7968
7967
  if (!t) continue;
7969
- let { bounds: i } = t, { end: a } = qr({
7968
+ let { bounds: i } = t, { end: a } = Kr({
7970
7969
  bounds: i,
7971
7970
  axis: n
7972
7971
  });
@@ -7977,26 +7976,26 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
7977
7976
  for (let r = t + 1; r < e.length; r += 1) {
7978
7977
  let t = e[r];
7979
7978
  if (!t) continue;
7980
- let { bounds: i } = t, { start: a } = qr({
7979
+ let { bounds: i } = t, { start: a } = Kr({
7981
7980
  bounds: i,
7982
7981
  axis: n
7983
7982
  });
7984
7983
  if (a - s >= 0) return r;
7985
7984
  }
7986
7985
  return null;
7987
- }, Xr = ({ items: e }) => {
7986
+ }, Yr = ({ items: e }) => {
7988
7987
  for (let t = 0; t < e.length; t += 1) {
7989
7988
  let { isActive: n } = e[t];
7990
7989
  if (n) return t;
7991
7990
  }
7992
7991
  return -1;
7993
- }, Zr = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
7992
+ }, Xr = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
7994
7993
  let i = Math.min(t, n), a = Math.max(t, n);
7995
7994
  return e >= i - r && e <= a + r;
7996
- }, Qr = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, $r = ({ baseOption: e, candidateOption: t }) => {
7995
+ }, Zr = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Qr = ({ baseOption: e, candidateOption: t }) => {
7997
7996
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
7998
7997
  return n === i && r === a;
7999
- }, ei = ({ options: e }) => {
7998
+ }, $r = ({ options: e }) => {
8000
7999
  let t = e[0];
8001
8000
  for (let n = 1; n < e.length; n += 1) {
8002
8001
  let r = e[n];
@@ -8007,11 +8006,11 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8007
8006
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
8008
8007
  }
8009
8008
  return t;
8010
- }, ti = ({ currentOption: e, nextOption: t }) => {
8009
+ }, ei = ({ currentOption: e, nextOption: t }) => {
8011
8010
  if (!e) return !0;
8012
8011
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
8013
8012
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
8014
- }, ni = ({ options: e }) => {
8013
+ }, ti = ({ options: e }) => {
8015
8014
  let t = [], n = null, r = null;
8016
8015
  for (let i of e) {
8017
8016
  let { kind: e, side: a } = i;
@@ -8019,18 +8018,18 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8019
8018
  t.push(i);
8020
8019
  continue;
8021
8020
  }
8022
- a === "before" && ti({
8021
+ a === "before" && ei({
8023
8022
  currentOption: n,
8024
8023
  nextOption: i
8025
- }) && (n = i), a === "after" && ti({
8024
+ }) && (n = i), a === "after" && ei({
8026
8025
  currentOption: r,
8027
8026
  nextOption: i
8028
8027
  }) && (r = i);
8029
8028
  }
8030
8029
  return n && t.push(n), r && t.push(r), t;
8031
- }, ri = ({ options: e, side: t, baseOption: n }) => {
8030
+ }, ni = ({ options: e, side: t, baseOption: n }) => {
8032
8031
  let r = null;
8033
- for (let i of e) if (i.side === t && $r({
8032
+ for (let i of e) if (i.side === t && Qr({
8034
8033
  baseOption: n,
8035
8034
  candidateOption: i
8036
8035
  })) {
@@ -8041,63 +8040,63 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8041
8040
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
8042
8041
  }
8043
8042
  return r;
8044
- }, ii = ({ option: e }) => {
8043
+ }, ri = ({ option: e }) => {
8045
8044
  let { side: t, kind: n, guide: { distance: r } } = e;
8046
8045
  return {
8047
8046
  side: t,
8048
8047
  kind: n,
8049
8048
  distance: r
8050
8049
  };
8051
- }, ai = ({ option: e, context: t }) => {
8050
+ }, ii = ({ option: e, context: t }) => {
8052
8051
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
8053
8052
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
8054
- }, oi = ({ options: e, context: t }) => {
8053
+ }, ai = ({ options: e, context: t }) => {
8055
8054
  if (!t) return null;
8056
- for (let n of e) if (ai({
8055
+ for (let n of e) if (ii({
8057
8056
  option: n,
8058
8057
  context: t
8059
8058
  })) return n;
8060
8059
  return null;
8061
- }, si = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
8062
- let i = oi({
8060
+ }, oi = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
8061
+ let i = ai({
8063
8062
  options: e,
8064
8063
  context: n
8065
8064
  });
8066
8065
  if (!i) return t;
8067
8066
  let a = Math.max(0, r);
8068
8067
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
8069
- }, ci = ({ guides: e, seenGuideKeys: t, guide: n }) => {
8068
+ }, si = ({ guides: e, seenGuideKeys: t, guide: n }) => {
8070
8069
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
8071
8070
  t.has(u) || (t.add(u), e.push(n));
8072
- }, li = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
8071
+ }, ci = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
8073
8072
  if (!e.length) return {
8074
8073
  delta: 0,
8075
8074
  guides: [],
8076
8075
  context: null
8077
8076
  };
8078
- let r = ni({ options: e }), i = [];
8077
+ let r = ti({ options: e }), i = [];
8079
8078
  for (let e of r) e.kind === "reference" && i.push(e);
8080
- let a = i.length > 0, o = a ? i : r, s = si({
8079
+ let a = i.length > 0, o = a ? i : r, s = oi({
8081
8080
  options: o,
8082
- bestOption: ei({ options: o }),
8081
+ bestOption: $r({ options: o }),
8083
8082
  previousContext: t,
8084
8083
  switchDistance: n
8085
- }), c = ri({
8084
+ }), c = ni({
8086
8085
  options: o,
8087
8086
  side: "before",
8088
8087
  baseOption: s
8089
- }), l = ri({
8088
+ }), l = ni({
8090
8089
  options: o,
8091
8090
  side: "after",
8092
8091
  baseOption: s
8093
- }), u = ri({
8092
+ }), u = ni({
8094
8093
  options: a ? r : o,
8095
8094
  side: "center",
8096
8095
  baseOption: s
8097
8096
  }), d = [];
8098
8097
  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);
8099
8098
  let f = [], p = /* @__PURE__ */ new Set();
8100
- for (let e of d) ci({
8099
+ for (let e of d) si({
8101
8100
  guides: f,
8102
8101
  seenGuideKeys: p,
8103
8102
  guide: e.guide
@@ -8105,15 +8104,15 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8105
8104
  return {
8106
8105
  delta: s.delta,
8107
8106
  guides: f,
8108
- context: ii({ option: s })
8107
+ context: ri({ option: s })
8109
8108
  };
8110
- }, ui = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
8111
- let s = n - (e - r), c = Gr({
8109
+ }, li = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
8110
+ let s = n - (e - r), c = Wr({
8112
8111
  value: s,
8113
8112
  step: o
8114
8113
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
8115
8114
  for (let d = -l; d <= l; d += 1) {
8116
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Hr({
8115
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Vr({
8117
8116
  firstDistance: m,
8118
8117
  secondDistance: h
8119
8118
  });
@@ -8128,13 +8127,13 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8128
8127
  });
8129
8128
  }
8130
8129
  return u;
8131
- }, di = ({ currentGap: e, referenceGap: t }) => {
8132
- let { secondDisplayDistance: n, displayDistanceDiff: r } = Hr({
8130
+ }, ui = ({ currentGap: e, referenceGap: t }) => {
8131
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = Vr({
8133
8132
  firstDistance: e,
8134
8133
  secondDistance: t
8135
8134
  });
8136
8135
  return r > 1 ? null : n;
8137
- }, fi = ({ anchors: e, positions: t, threshold: n }) => {
8136
+ }, di = ({ anchors: e, positions: t, threshold: n }) => {
8138
8137
  let r = 0, i = n + 1, a = null;
8139
8138
  for (let o of t) for (let t of e) {
8140
8139
  let e = Math.abs(t - o);
@@ -8144,8 +8143,8 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8144
8143
  delta: r,
8145
8144
  guidePosition: a
8146
8145
  };
8147
- }, pi = ({ activeBounds: e, threshold: t, anchors: n }) => {
8148
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = fi({
8146
+ }, fi = ({ activeBounds: e, threshold: t, anchors: n }) => {
8147
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = di({
8149
8148
  anchors: n.vertical,
8150
8149
  positions: [
8151
8150
  r,
@@ -8153,7 +8152,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8153
8152
  i
8154
8153
  ],
8155
8154
  threshold: t
8156
- }), u = fi({
8155
+ }), u = di({
8157
8156
  anchors: n.horizontal,
8158
8157
  positions: [
8159
8158
  o,
@@ -8173,11 +8172,11 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8173
8172
  deltaY: u.delta,
8174
8173
  guides: d
8175
8174
  };
8176
- }, mi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8175
+ }, pi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8177
8176
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
8178
8177
  for (let e of t) {
8179
8178
  let { left: t, right: n } = e;
8180
- Ur({
8179
+ Hr({
8181
8180
  firstStart: t,
8182
8181
  firstEnd: n,
8183
8182
  secondStart: l,
@@ -8197,22 +8196,22 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8197
8196
  f.push({
8198
8197
  bounds: e,
8199
8198
  isActive: !0
8200
- }), Jr({
8199
+ }), qr({
8201
8200
  items: f,
8202
8201
  axis: "top"
8203
8202
  });
8204
- let p = Xr({ items: f });
8203
+ let p = Yr({ items: f });
8205
8204
  if (p === -1) return {
8206
8205
  delta: 0,
8207
8206
  guides: [],
8208
8207
  context: null
8209
8208
  };
8210
- let m = [], h = c - s, g = Yr({
8209
+ let m = [], h = c - s, g = Jr({
8211
8210
  items: f,
8212
8211
  index: p,
8213
8212
  axis: "vertical",
8214
8213
  direction: "prev"
8215
- }), _ = Yr({
8214
+ }), _ = Jr({
8216
8215
  items: f,
8217
8216
  index: p,
8218
8217
  axis: "vertical",
@@ -8221,19 +8220,19 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8221
8220
  if (v && y) {
8222
8221
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
8223
8222
  if (a >= 0) {
8224
- let e = Gr({
8223
+ let e = Wr({
8225
8224
  value: a / 2,
8226
8225
  step: 1
8227
8226
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
8228
8227
  if (Math.max(u, d) <= n) {
8229
- let t = ui({
8228
+ let t = li({
8230
8229
  activeStart: s,
8231
8230
  activeEnd: c,
8232
8231
  targetGap: e,
8233
8232
  beforeEdge: r,
8234
8233
  afterEdge: i,
8235
8234
  threshold: n,
8236
- step: Br
8235
+ step: zr
8237
8236
  });
8238
8237
  if (t) {
8239
8238
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -8270,16 +8269,16 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8270
8269
  }
8271
8270
  for (let e of r) {
8272
8271
  let { axis: t, start: r, end: i, distance: a } = e;
8273
- if (!Kr({
8272
+ if (!Gr({
8274
8273
  value: a,
8275
8274
  step: .5
8276
- }) || !Zr({
8275
+ }) || !Xr({
8277
8276
  patternAxis: t,
8278
8277
  activeRangeStart: l,
8279
8278
  activeRangeEnd: u,
8280
8279
  tolerance: n
8281
8280
  })) continue;
8282
- let d = Qr({
8281
+ let d = Zr({
8283
8282
  patternStart: r,
8284
8283
  patternEnd: i,
8285
8284
  activeStart: s,
@@ -8287,12 +8286,12 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8287
8286
  });
8288
8287
  if (d) {
8289
8288
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
8290
- let e = Gr({
8289
+ let e = Wr({
8291
8290
  value: a - b,
8292
8291
  step: 1
8293
8292
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
8294
8293
  if (u > n) continue;
8295
- let d = di({
8294
+ let d = ui({
8296
8295
  currentGap: l,
8297
8296
  referenceGap: a
8298
8297
  });
@@ -8316,12 +8315,12 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8316
8315
  });
8317
8316
  }
8318
8317
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
8319
- let e = Gr({
8318
+ let e = Wr({
8320
8319
  value: x - a,
8321
8320
  step: 1
8322
8321
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
8323
8322
  if (u > n) continue;
8324
- let d = di({
8323
+ let d = ui({
8325
8324
  currentGap: l,
8326
8325
  referenceGap: a
8327
8326
  });
@@ -8346,16 +8345,16 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8346
8345
  }
8347
8346
  }
8348
8347
  }
8349
- return li({
8348
+ return ci({
8350
8349
  options: m,
8351
8350
  previousContext: i,
8352
8351
  switchDistance: a
8353
8352
  });
8354
- }, hi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8353
+ }, mi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
8355
8354
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
8356
8355
  for (let e of t) {
8357
8356
  let { top: t, bottom: n } = e;
8358
- Ur({
8357
+ Hr({
8359
8358
  firstStart: t,
8360
8359
  firstEnd: n,
8361
8360
  secondStart: l,
@@ -8375,22 +8374,22 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8375
8374
  f.push({
8376
8375
  bounds: e,
8377
8376
  isActive: !0
8378
- }), Jr({
8377
+ }), qr({
8379
8378
  items: f,
8380
8379
  axis: "left"
8381
8380
  });
8382
- let p = Xr({ items: f });
8381
+ let p = Yr({ items: f });
8383
8382
  if (p === -1) return {
8384
8383
  delta: 0,
8385
8384
  guides: [],
8386
8385
  context: null
8387
8386
  };
8388
- let m = [], h = c - s, g = Yr({
8387
+ let m = [], h = c - s, g = Jr({
8389
8388
  items: f,
8390
8389
  index: p,
8391
8390
  axis: "horizontal",
8392
8391
  direction: "prev"
8393
- }), _ = Yr({
8392
+ }), _ = Jr({
8394
8393
  items: f,
8395
8394
  index: p,
8396
8395
  axis: "horizontal",
@@ -8399,19 +8398,19 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8399
8398
  if (v && y) {
8400
8399
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
8401
8400
  if (a >= 0) {
8402
- let e = Gr({
8401
+ let e = Wr({
8403
8402
  value: a / 2,
8404
8403
  step: 1
8405
8404
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
8406
8405
  if (Math.max(u, d) <= n) {
8407
- let t = ui({
8406
+ let t = li({
8408
8407
  activeStart: s,
8409
8408
  activeEnd: c,
8410
8409
  targetGap: e,
8411
8410
  beforeEdge: r,
8412
8411
  afterEdge: i,
8413
8412
  threshold: n,
8414
- step: Br
8413
+ step: zr
8415
8414
  });
8416
8415
  if (t) {
8417
8416
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -8448,16 +8447,16 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8448
8447
  }
8449
8448
  for (let e of r) {
8450
8449
  let { axis: t, start: r, end: i, distance: a } = e;
8451
- if (!Kr({
8450
+ if (!Gr({
8452
8451
  value: a,
8453
8452
  step: .5
8454
- }) || !Zr({
8453
+ }) || !Xr({
8455
8454
  patternAxis: t,
8456
8455
  activeRangeStart: l,
8457
8456
  activeRangeEnd: u,
8458
8457
  tolerance: n
8459
8458
  })) continue;
8460
- let d = Qr({
8459
+ let d = Zr({
8461
8460
  patternStart: r,
8462
8461
  patternEnd: i,
8463
8462
  activeStart: s,
@@ -8465,12 +8464,12 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8465
8464
  });
8466
8465
  if (d) {
8467
8466
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
8468
- let e = Gr({
8467
+ let e = Wr({
8469
8468
  value: a - b,
8470
8469
  step: 1
8471
8470
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
8472
8471
  if (u > n) continue;
8473
- let d = di({
8472
+ let d = ui({
8474
8473
  currentGap: l,
8475
8474
  referenceGap: a
8476
8475
  });
@@ -8494,12 +8493,12 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8494
8493
  });
8495
8494
  }
8496
8495
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
8497
- let e = Gr({
8496
+ let e = Wr({
8498
8497
  value: x - a,
8499
8498
  step: 1
8500
8499
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
8501
8500
  if (u > n) continue;
8502
- let d = di({
8501
+ let d = ui({
8503
8502
  currentGap: l,
8504
8503
  referenceGap: a
8505
8504
  });
@@ -8524,20 +8523,20 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8524
8523
  }
8525
8524
  }
8526
8525
  }
8527
- return li({
8526
+ return ci({
8528
8527
  options: m,
8529
8528
  previousContext: i,
8530
8529
  switchDistance: a
8531
8530
  });
8532
- }, gi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
8533
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = mi({
8531
+ }, hi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
8532
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = pi({
8534
8533
  activeBounds: e,
8535
8534
  candidates: t,
8536
8535
  threshold: n,
8537
8536
  patterns: r.vertical,
8538
8537
  previousContext: o,
8539
8538
  switchDistance: a
8540
- }), l = hi({
8539
+ }), l = mi({
8541
8540
  activeBounds: e,
8542
8541
  candidates: t,
8543
8542
  threshold: n,
@@ -8556,14 +8555,14 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8556
8555
  horizontal: l.context
8557
8556
  }
8558
8557
  };
8559
- }, _i = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
8558
+ }, gi = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
8560
8559
  let o = Math.min(a, r / 2, i / 2);
8561
8560
  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();
8562
- }, vi = ({ 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 }) => {
8561
+ }, _i = ({ 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 }) => {
8563
8562
  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;
8564
8563
  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";
8565
8564
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
8566
- e.beginPath(), _i({
8565
+ e.beginPath(), gi({
8567
8566
  context: e,
8568
8567
  x: w,
8569
8568
  y: T,
@@ -8571,11 +8570,11 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8571
8570
  height: C,
8572
8571
  radius: v
8573
8572
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
8574
- }, yi = ({ context: e, guide: t, zoom: n }) => {
8575
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Vr({ distance: l }).toString();
8573
+ }, vi = ({ context: e, guide: t, zoom: n }) => {
8574
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Br({ distance: l }).toString();
8576
8575
  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();
8577
- let d = zr;
8578
- vi({
8576
+ let d = Rr;
8577
+ _i({
8579
8578
  context: e,
8580
8579
  type: r,
8581
8580
  axis: i,
@@ -8585,7 +8584,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8585
8584
  zoom: n,
8586
8585
  color: d,
8587
8586
  lineWidth: 1
8588
- }), vi({
8587
+ }), _i({
8589
8588
  context: e,
8590
8589
  type: r,
8591
8590
  axis: i,
@@ -8596,10 +8595,10 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8596
8595
  color: d,
8597
8596
  lineWidth: 1
8598
8597
  });
8599
- }, bi = ({ anchors: e, bounds: t }) => {
8598
+ }, yi = ({ anchors: e, bounds: t }) => {
8600
8599
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
8601
8600
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
8602
- }, xi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
8601
+ }, bi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
8603
8602
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
8604
8603
  for (let e = 0; e < s.length; e += 1) {
8605
8604
  let c = s[e], l = null, u = Infinity;
@@ -8620,35 +8619,35 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8620
8619
  });
8621
8620
  }
8622
8621
  return i;
8623
- }, Si = ({ bounds: e }) => ({
8624
- vertical: xi({
8622
+ }, xi = ({ bounds: e }) => ({
8623
+ vertical: bi({
8625
8624
  bounds: e,
8626
8625
  axis: "centerX",
8627
8626
  type: "vertical",
8628
8627
  primaryStart: "top",
8629
8628
  primaryEnd: "bottom"
8630
8629
  }),
8631
- horizontal: xi({
8630
+ horizontal: bi({
8632
8631
  bounds: e,
8633
8632
  axis: "centerY",
8634
8633
  type: "horizontal",
8635
8634
  primaryStart: "left",
8636
8635
  primaryEnd: "right"
8637
8636
  })
8638
- }), Ci = [
8637
+ }), Si = [
8639
8638
  "montage-area",
8640
8639
  "background",
8641
8640
  "interaction-blocker"
8642
- ], wi = ({ activeObject: t }) => {
8641
+ ], Ci = ({ activeObject: t }) => {
8643
8642
  let n = /* @__PURE__ */ new Set();
8644
8643
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
8645
- }, Ti = ({ object: e, excluded: t, ignoredIds: n = Ci }) => {
8644
+ }, wi = ({ object: e, excluded: t, ignoredIds: n = Si }) => {
8646
8645
  if (t.has(e)) return !0;
8647
8646
  let { visible: r = !0 } = e;
8648
8647
  if (!r) return !0;
8649
8648
  let { id: i } = e;
8650
8649
  return !!(i && n.includes(i));
8651
- }, Ei = class e {
8650
+ }, Ti = class e {
8652
8651
  constructor({ editor: e }) {
8653
8652
  this.anchors = {
8654
8653
  vertical: [],
@@ -8696,12 +8695,12 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8696
8695
  target: n,
8697
8696
  transform: i
8698
8697
  }), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: n });
8699
- let a = Ye({ object: n });
8698
+ let a = Je({ object: n });
8700
8699
  if (!a) {
8701
8700
  this._clearSpacingContexts(), this._clearGuides();
8702
8701
  return;
8703
8702
  }
8704
- let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = pi({
8703
+ let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = fi({
8705
8704
  activeBounds: a,
8706
8705
  threshold: c,
8707
8706
  anchors: this.anchors
@@ -8711,9 +8710,9 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8711
8710
  n.set({
8712
8711
  left: e + l,
8713
8712
  top: t + u
8714
- }), n.setCoords(), a = Ye({ object: n }) ?? a;
8713
+ }), n.setCoords(), a = Je({ object: n }) ?? a;
8715
8714
  }
8716
- let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = gi({
8715
+ let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = hi({
8717
8716
  activeBounds: a,
8718
8717
  candidates: d,
8719
8718
  threshold: f,
@@ -8728,17 +8727,17 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8728
8727
  n.set({
8729
8728
  left: e + p.deltaX,
8730
8729
  top: t + p.deltaY
8731
- }), n.setCoords(), a = Ye({ object: n }) ?? a;
8730
+ }), n.setCoords(), a = Je({ object: n }) ?? a;
8732
8731
  }
8733
8732
  m || e._applyMovementStep({
8734
8733
  target: n,
8735
8734
  transform: i
8736
8735
  });
8737
- let h = Ye({ object: n }) ?? a, g = pi({
8736
+ let h = Je({ object: n }) ?? a, g = fi({
8738
8737
  activeBounds: h,
8739
8738
  threshold: c,
8740
8739
  anchors: this.anchors
8741
- }), _ = gi({
8740
+ }), _ = hi({
8742
8741
  activeBounds: h,
8743
8742
  candidates: d,
8744
8743
  threshold: c,
@@ -8778,53 +8777,53 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8778
8777
  }
8779
8778
  let { anchors: l } = this, { vertical: u, horizontal: d } = l;
8780
8779
  !u.length && !d.length && this._cacheAnchors({ activeObject: n });
8781
- let f = Ye({ object: n });
8780
+ let f = Je({ object: n });
8782
8781
  if (!f) {
8783
8782
  this._clearGuides();
8784
8783
  return;
8785
8784
  }
8786
- let { canvas: m } = this, h = 5 / (m.getZoom() || 1), { originX: g, originY: _ } = i, { originX: v = "left", originY: y = "top", scaleX: b = 1, scaleY: x = 1 } = n, S = g ?? v, C = _ ?? y, w = e._collectVerticalSnapCandidates({
8785
+ let { canvas: p } = this, m = 5 / (p.getZoom() || 1), { originX: h, originY: g } = i, { originX: _ = "left", originY: v = "top", scaleX: y = 1, scaleY: b = 1 } = n, x = h ?? _, S = g ?? v, C = e._collectVerticalSnapCandidates({
8787
8786
  bounds: f,
8788
- originX: S,
8787
+ originX: x,
8789
8788
  shouldSnapX: o
8790
- }), T = e._collectHorizontalSnapCandidates({
8789
+ }), w = e._collectHorizontalSnapCandidates({
8791
8790
  bounds: f,
8792
- originY: C,
8791
+ originY: S,
8793
8792
  shouldSnapY: s
8794
- }), E = e._findAxisSnapCandidate({
8793
+ }), T = e._findAxisSnapCandidate({
8795
8794
  anchors: u,
8796
- candidates: w,
8797
- threshold: h
8798
- }), D = e._findAxisSnapCandidate({
8795
+ candidates: C,
8796
+ threshold: m
8797
+ }), E = e._findAxisSnapCandidate({
8799
8798
  anchors: d,
8800
- candidates: T,
8801
- threshold: h
8802
- }), { guidePosition: O } = E, { guidePosition: k } = D, A = O !== null, j = k !== null;
8803
- if (!A && !j) {
8799
+ candidates: w,
8800
+ threshold: m
8801
+ }), { guidePosition: D } = T, { guidePosition: O } = E, k = D !== null, A = O !== null;
8802
+ if (!k && !A) {
8804
8803
  this._clearGuides();
8805
8804
  return;
8806
8805
  }
8807
- let M = [], N = null, P = null;
8806
+ let j = [], M = null, N = null;
8808
8807
  if (c) {
8809
8808
  let t = e._resolveUniformScale({
8810
8809
  bounds: f,
8811
- originX: S,
8812
- originY: C,
8813
- verticalSnap: E,
8814
- horizontalSnap: D
8810
+ originX: x,
8811
+ originY: S,
8812
+ verticalSnap: T,
8813
+ horizontalSnap: E
8815
8814
  });
8816
8815
  if (t) {
8817
8816
  let { scaleFactor: e, guide: n } = t;
8818
- N = b * e, P = x * e, M.push(n);
8817
+ M = y * e, N = b * e, j.push(n);
8819
8818
  }
8820
8819
  }
8821
8820
  if (!c) {
8822
- let { angle: t = 0 } = n, { width: r, height: i } = e._resolveBaseDimensions({ target: n }), a = Math.abs(b) || 1, o = Math.abs(x) || 1;
8823
- if (A) {
8821
+ let { angle: t = 0 } = n, { width: r, height: i } = e._resolveBaseDimensions({ target: n }), a = Math.abs(y) || 1, o = Math.abs(b) || 1;
8822
+ if (k) {
8824
8823
  let n = e._resolveDesiredWidth({
8825
8824
  bounds: f,
8826
- originX: S,
8827
- snap: E
8825
+ originX: x,
8826
+ snap: T
8828
8827
  });
8829
8828
  if (n !== null) {
8830
8829
  let a = e._resolveScaleForWidth({
@@ -8834,17 +8833,17 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8834
8833
  scaleY: o,
8835
8834
  angle: t
8836
8835
  });
8837
- a !== null && (N = a * (b < 0 ? -1 : 1), O !== null && M.push({
8836
+ a !== null && (M = a * (y < 0 ? -1 : 1), D !== null && j.push({
8838
8837
  type: "vertical",
8839
- position: O
8838
+ position: D
8840
8839
  }));
8841
8840
  }
8842
8841
  }
8843
- if (j) {
8842
+ if (A) {
8844
8843
  let n = e._resolveDesiredHeight({
8845
8844
  bounds: f,
8846
- originY: C,
8847
- snap: D
8845
+ originY: S,
8846
+ snap: E
8848
8847
  });
8849
8848
  if (n !== null) {
8850
8849
  let o = e._resolveScaleForHeight({
@@ -8854,31 +8853,34 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8854
8853
  scaleX: a,
8855
8854
  angle: t
8856
8855
  });
8857
- o !== null && (P = o * (x < 0 ? -1 : 1), k !== null && M.push({
8856
+ o !== null && (N = o * (b < 0 ? -1 : 1), O !== null && j.push({
8858
8857
  type: "horizontal",
8859
- position: k
8858
+ position: O
8860
8859
  }));
8861
8860
  }
8862
8861
  }
8863
8862
  }
8864
- let F = N !== null || P !== null;
8865
- if (!F && !M.length) {
8863
+ let P = M !== null || N !== null;
8864
+ if (!P && !j.length) {
8866
8865
  this._clearGuides();
8867
8866
  return;
8868
8867
  }
8869
- if (F) {
8868
+ if (P) {
8870
8869
  let e = this.editor.canvasManager.getObjectPlacement({
8871
8870
  object: n,
8872
- originX: S,
8873
- originY: C
8871
+ originX: x,
8872
+ originY: S
8874
8873
  }), t = {};
8875
- N !== null && (t.scaleX = N, i.scaleX = N), P !== null && (t.scaleY = P, i.scaleY = P), Object.keys(t).length && (n.set(t), n.setPositionByOrigin(new p(e.left, e.top), S, C), n.setCoords());
8874
+ M !== null && (t.scaleX = M, i.scaleX = M), N !== null && (t.scaleY = N, i.scaleY = N), Object.keys(t).length && (n.set(t), this.editor.canvasManager.applyObjectPlacement({
8875
+ object: n,
8876
+ placement: e
8877
+ }));
8876
8878
  }
8877
8879
  a && e._applyScalingStep({
8878
8880
  target: n,
8879
8881
  transform: i
8880
8882
  }), this._applyGuides({
8881
- guides: M,
8883
+ guides: j,
8882
8884
  spacingGuides: []
8883
8885
  });
8884
8886
  }
@@ -8899,54 +8901,57 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8899
8901
  }
8900
8902
  let { anchors: a } = this, { vertical: o, horizontal: s } = a;
8901
8903
  !o.length && !s.length && this._cacheAnchors({ activeObject: t });
8902
- let c = Ye({ object: t });
8904
+ let c = Je({ object: t });
8903
8905
  if (!c) {
8904
8906
  this._clearGuides();
8905
8907
  return;
8906
8908
  }
8907
- let { canvas: l } = this, u = 5 / (l.getZoom() || 1), { originX: d, originY: f } = n, { originX: m = "left", originY: h = "top" } = t, g = d ?? m, v = f ?? h, y = e._collectVerticalSnapCandidates({
8909
+ let { canvas: l } = this, u = 5 / (l.getZoom() || 1), { originX: d, originY: f } = n, { originX: p = "left", originY: m = "top" } = t, h = d ?? p, g = f ?? m, v = e._collectVerticalSnapCandidates({
8908
8910
  bounds: c,
8909
- originX: g,
8911
+ originX: h,
8910
8912
  shouldSnapX: !0
8911
- }), b = e._findAxisSnapCandidate({
8913
+ }), y = e._findAxisSnapCandidate({
8912
8914
  anchors: o,
8913
- candidates: y,
8915
+ candidates: v,
8914
8916
  threshold: u
8915
- }), { guidePosition: x } = b;
8916
- if (x === null) {
8917
+ }), { guidePosition: b } = y;
8918
+ if (b === null) {
8917
8919
  this._clearGuides();
8918
8920
  return;
8919
8921
  }
8920
- let S = e._resolveDesiredWidth({
8922
+ let x = e._resolveDesiredWidth({
8921
8923
  bounds: c,
8922
- originX: g,
8923
- snap: b
8924
+ originX: h,
8925
+ snap: y
8924
8926
  });
8925
- if (S === null) {
8927
+ if (x === null) {
8926
8928
  this._clearGuides();
8927
8929
  return;
8928
8930
  }
8929
- let C = e._resolveTextWidthForBounds({
8931
+ let S = e._resolveTextWidthForBounds({
8930
8932
  target: t,
8931
- boundsWidth: S
8933
+ boundsWidth: x
8932
8934
  });
8933
- if (C === null) {
8935
+ if (S === null) {
8934
8936
  this._clearGuides();
8935
8937
  return;
8936
8938
  }
8937
- let { width: w = 0 } = t;
8938
- if (C !== w) {
8939
+ let { width: C = 0 } = t;
8940
+ if (S !== C) {
8939
8941
  let e = this.editor.canvasManager.getObjectPlacement({
8940
8942
  object: t,
8941
- originX: g,
8942
- originY: v
8943
+ originX: h,
8944
+ originY: g
8945
+ });
8946
+ t.set({ width: S }), this.editor.canvasManager.applyObjectPlacement({
8947
+ object: t,
8948
+ placement: e
8943
8949
  });
8944
- t.set({ width: C }), t.setPositionByOrigin(new p(e.left, e.top), g, v), t.setCoords();
8945
8950
  }
8946
8951
  this._applyGuides({
8947
8952
  guides: [{
8948
8953
  type: "vertical",
8949
- position: x
8954
+ position: b
8950
8955
  }],
8951
8956
  spacingGuides: []
8952
8957
  });
@@ -8963,9 +8968,9 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
8963
8968
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
8964
8969
  if (!n) return;
8965
8970
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
8966
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = zr, n.setLineDash([4, 4]);
8971
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Rr, n.setLineDash([4, 4]);
8967
8972
  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();
8968
- for (let e of this.activeSpacingGuides) yi({
8973
+ for (let e of this.activeSpacingGuides) vi({
8969
8974
  context: n,
8970
8975
  guide: e,
8971
8976
  zoom: c
@@ -9143,7 +9148,8 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9143
9148
  return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
9144
9149
  }
9145
9150
  static _shouldApplyPixelScalingStep({ target: e }) {
9146
- return !(e instanceof a);
9151
+ let t = typeof e.type == "string" ? e.type.toLowerCase() : "", n = e instanceof _ || t === "textbox" || t === "background-textbox";
9152
+ return !(e instanceof a) && !n;
9147
9153
  }
9148
9154
  static _applyMovementStep({ target: e, transform: t }) {
9149
9155
  let { left: n = 0, top: r = 0 } = e, i = Math.round(n / 1) * 1, a = Math.round(r / 1) * 1, o = typeof t?.original?.left == "number" ? t.original.left : null, s = typeof t?.original?.top == "number" ? t.original.top : null, c = o === null || o !== n, l = s === null || s !== r, u = {};
@@ -9174,15 +9180,15 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9174
9180
  horizontal: []
9175
9181
  }, r = [];
9176
9182
  for (let e of t) {
9177
- let t = Ye({ object: e });
9178
- t && (bi({
9183
+ let t = Je({ object: e });
9184
+ t && (yi({
9179
9185
  anchors: n,
9180
9186
  bounds: t
9181
9187
  }), r.push(t));
9182
9188
  }
9183
- let { montageArea: i } = this.editor, a = Ye({ object: i });
9189
+ let { montageArea: i } = this.editor, a = Je({ object: i });
9184
9190
  if (a) {
9185
- bi({
9191
+ yi({
9186
9192
  anchors: n,
9187
9193
  bounds: a
9188
9194
  });
@@ -9194,12 +9200,12 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9194
9200
  bottom: i
9195
9201
  };
9196
9202
  } else this.guideBounds = this._calculateViewportBounds();
9197
- this.anchors = n, this.spacingPatterns = Si({ bounds: r }), this.cachedTargetBounds = r;
9203
+ this.anchors = n, this.spacingPatterns = xi({ bounds: r }), this.cachedTargetBounds = r;
9198
9204
  }
9199
9205
  _collectTargets({ activeObject: e }) {
9200
- let t = wi({ activeObject: e }), n = [];
9206
+ let t = Ci({ activeObject: e }), n = [];
9201
9207
  return this.canvas.forEachObject((e) => {
9202
- Ti({
9208
+ wi({
9203
9209
  object: e,
9204
9210
  excluded: t
9205
9211
  }) || n.push(e);
@@ -9208,7 +9214,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9208
9214
  _resolveCurrentTargetBounds({ activeObject: e }) {
9209
9215
  let t = this._collectTargets({ activeObject: e }), n = [];
9210
9216
  for (let e of t) {
9211
- let t = Ye({ object: e });
9217
+ let t = Je({ object: e });
9212
9218
  t && n.push(t);
9213
9219
  }
9214
9220
  return n;
@@ -9222,7 +9228,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9222
9228
  bottom: (r - s) / a
9223
9229
  };
9224
9230
  }
9225
- }, Di = "#3D8BF4", Oi = class e {
9231
+ }, Ei = "#3D8BF4", Di = class e {
9226
9232
  constructor({ editor: e }) {
9227
9233
  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();
9228
9234
  }
@@ -9286,7 +9292,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9286
9292
  this._clearGuides();
9287
9293
  return;
9288
9294
  }
9289
- let a = Ye({ object: i });
9295
+ let a = Je({ object: i });
9290
9296
  if (!a) {
9291
9297
  this._clearGuides();
9292
9298
  return;
@@ -9294,7 +9300,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9294
9300
  let o = e._resolveTarget({
9295
9301
  event: t,
9296
9302
  activeObject: i
9297
- }), { montageArea: s } = r, c = o ?? s, l = c === s, u = Ye({ object: c });
9303
+ }), { montageArea: s } = r, c = o ?? s, l = c === s, u = Je({ object: c });
9298
9304
  if (!u) {
9299
9305
  this._clearGuides();
9300
9306
  return;
@@ -9315,8 +9321,8 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9315
9321
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
9316
9322
  }
9317
9323
  static _resolveTarget({ event: e, activeObject: t }) {
9318
- let { target: n } = e, r = wi({ activeObject: t });
9319
- return n && !Ti({
9324
+ let { target: n } = e, r = Ci({ activeObject: t });
9325
+ return n && !wi({
9320
9326
  object: n,
9321
9327
  excluded: r
9322
9328
  }) ? n : null;
@@ -9433,18 +9439,18 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9433
9439
  let { canvas: e } = this, t = e.getSelectionContext();
9434
9440
  if (!t) return;
9435
9441
  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;
9436
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Di, t.setLineDash([]);
9442
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Ei, t.setLineDash([]);
9437
9443
  for (let e of this.activeGuides) {
9438
9444
  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;
9439
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), vi({
9445
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), _i({
9440
9446
  context: t,
9441
9447
  type: n,
9442
9448
  axis: i,
9443
9449
  start: a,
9444
9450
  end: c,
9445
- text: Vr({ distance: l }).toString(),
9451
+ text: Br({ distance: l }).toString(),
9446
9452
  zoom: r,
9447
- color: Di,
9453
+ color: Ei,
9448
9454
  lineWidth: 1,
9449
9455
  offsetAlongAxis: d,
9450
9456
  offsetPerpendicular: 0
@@ -9462,13 +9468,13 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9462
9468
  let { toolbar: e } = this.editor;
9463
9469
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
9464
9470
  }
9465
- }, ki = class e {
9471
+ }, Oi = class e {
9466
9472
  constructor(e, t) {
9467
9473
  this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
9468
9474
  }
9469
9475
  async init() {
9470
9476
  let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, _onReadyCallback: d } = this.options;
9471
- if (z.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new nr({ editor: this }), this.historyManager = new je({ editor: this }), this.toolbar = new ae({ editor: this }), this.transformManager = new He({ editor: this }), this.zoomManager = new Ue({ editor: this }), this.canvasManager = new Ve({ editor: this }), this.imageManager = new Le({ editor: this }), this.layerManager = new et({ editor: this }), this.shapeManager = new Yn({ editor: this }), this.interactionBlocker = new Qe({ editor: this }), this.backgroundManager = new $e({ editor: this }), this.clipboardManager = new Xn({ editor: this }), this.objectLockManager = new Zn({ editor: this }), this.groupingManager = new Qn({ editor: this }), this.selectionManager = new $n({ editor: this }), this.deletionManager = new er({ editor: this }), this.panConstraintManager = new rr({ editor: this }), this.snappingManager = new Ei({ editor: this }), this.measurementManager = new Oi({ editor: this }), this.fontManager = new ie(this.options.fonts ?? []), this.textManager = new Nr({ editor: this }), this.templateManager = new Rr({ editor: this }), u && (this.angleIndicator = new oe({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
9477
+ if (z.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new tr({ editor: this }), this.historyManager = new je({ editor: this }), this.toolbar = new ae({ editor: this }), this.transformManager = new He({ editor: this }), this.zoomManager = new Ue({ editor: this }), this.canvasManager = new Ve({ editor: this }), this.imageManager = new Le({ editor: this }), this.layerManager = new $e({ editor: this }), this.shapeManager = new Jn({ editor: this }), this.interactionBlocker = new Ze({ editor: this }), this.backgroundManager = new Qe({ editor: this }), this.clipboardManager = new Yn({ editor: this }), this.objectLockManager = new Xn({ editor: this }), this.groupingManager = new Zn({ editor: this }), this.selectionManager = new Qn({ editor: this }), this.deletionManager = new $n({ editor: this }), this.panConstraintManager = new nr({ editor: this }), this.snappingManager = new Ti({ editor: this }), this.measurementManager = new Di({ editor: this }), this.fontManager = new ie(this.options.fonts ?? []), this.textManager = new Mr({ editor: this }), this.templateManager = new Lr({ editor: this }), u && (this.angleIndicator = new U({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
9472
9478
  editor: this,
9473
9479
  options: this.options
9474
9480
  }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(n), this.canvasManager.setCanvasWrapperWidth(r), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), await this.fontManager.loadFonts(), c) {
@@ -9509,7 +9515,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9509
9515
  }
9510
9516
  _createMontageArea() {
9511
9517
  let { montageAreaWidth: t, montageAreaHeight: n } = this.options, r = new p(t / 2, n / 2);
9512
- this.montageArea = Ze({
9518
+ this.montageArea = Xe({
9513
9519
  canvas: this.canvas,
9514
9520
  centerPoint: r,
9515
9521
  options: {
@@ -9533,7 +9539,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9533
9539
  }
9534
9540
  _createClippingArea() {
9535
9541
  let { montageAreaWidth: e, montageAreaHeight: t } = this.options, n = new p(e / 2, t / 2);
9536
- this.canvas.clipPath = Ze({
9542
+ this.canvas.clipPath = Xe({
9537
9543
  canvas: this.canvas,
9538
9544
  centerPoint: n,
9539
9545
  options: {
@@ -9576,7 +9582,7 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
9576
9582
  "U+A640-A69F",
9577
9583
  "U+FE2E-FE2F",
9578
9584
  "U+2116"
9579
- ].join(", "), Ai = {
9585
+ ].join(", "), ki = {
9580
9586
  preserveObjectStacking: !0,
9581
9587
  controlsAboveOverlay: !0,
9582
9588
  centeredRotation: !0,
@@ -10430,20 +10436,20 @@ var Hn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
10430
10436
  };
10431
10437
  //#endregion
10432
10438
  //#region src/main.ts
10433
- function ji(e, t = {}) {
10439
+ function Ai(e, t = {}) {
10434
10440
  let n = {
10435
- ...Ai,
10441
+ ...ki,
10436
10442
  ...t
10437
10443
  }, r = document.getElementById(e);
10438
10444
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
10439
10445
  let i = document.createElement("canvas");
10440
10446
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
10441
10447
  n._onReadyCallback = t;
10442
- let r = new ki(i.id, n);
10448
+ let r = new Oi(i.id, n);
10443
10449
  window[e] = r;
10444
10450
  });
10445
10451
  }
10446
10452
  //#endregion
10447
- export { ji as default };
10453
+ export { Ai as default };
10448
10454
 
10449
10455
  //# sourceMappingURL=main.js.map