@anu3ev/fabric-image-editor 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +531 -500
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -2,24 +2,24 @@ var ds = Object.defineProperty, ls = Object.defineProperties;
2
2
  var hs = Object.getOwnPropertyDescriptors;
3
3
  var Gt = Object.getOwnPropertySymbols;
4
4
  var _e = Object.prototype.hasOwnProperty, Ne = Object.prototype.propertyIsEnumerable;
5
- var Re = (l, t, e) => t in l ? ds(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e, _ = (l, t) => {
5
+ var Re = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, _ = (h, t) => {
6
6
  for (var e in t || (t = {}))
7
- _e.call(t, e) && Re(l, e, t[e]);
7
+ _e.call(t, e) && Re(h, e, t[e]);
8
8
  if (Gt)
9
9
  for (var e of Gt(t))
10
- Ne.call(t, e) && Re(l, e, t[e]);
11
- return l;
12
- }, yt = (l, t) => ls(l, hs(t));
13
- var vt = (l, t) => {
10
+ Ne.call(t, e) && Re(h, e, t[e]);
11
+ return h;
12
+ }, yt = (h, t) => ls(h, hs(t));
13
+ var vt = (h, t) => {
14
14
  var e = {};
15
- for (var s in l)
16
- _e.call(l, s) && t.indexOf(s) < 0 && (e[s] = l[s]);
17
- if (l != null && Gt)
18
- for (var s of Gt(l))
19
- t.indexOf(s) < 0 && Ne.call(l, s) && (e[s] = l[s]);
15
+ for (var s in h)
16
+ _e.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
17
+ if (h != null && Gt)
18
+ for (var s of Gt(h))
19
+ t.indexOf(s) < 0 && Ne.call(h, s) && (e[s] = h[s]);
20
20
  return e;
21
21
  };
22
- var N = (l, t, e) => new Promise((s, o) => {
22
+ var N = (h, t, e) => new Promise((s, o) => {
23
23
  var n = (r) => {
24
24
  try {
25
25
  a(e.next(r));
@@ -33,7 +33,7 @@ var N = (l, t, e) => new Promise((s, o) => {
33
33
  o(c);
34
34
  }
35
35
  }, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(n, i);
36
- a((e = e.apply(l, t)).next());
36
+ a((e = e.apply(h, t)).next());
37
37
  });
38
38
  import { ActiveSelection as k, Textbox as nt, util as dt, controlsUtils as xe, InteractiveFabricObject as Be, Point as tt, FitContentLayout as ke, loadSVGFromURL as us, FabricImage as zt, Gradient as ze, Rect as gs, Circle as fs, Triangle as ps, Group as Et, Color as ms, classRegistry as Pe, loadSVGFromString as ys, Canvas as vs, Pattern as bs } from "fabric";
39
39
  import { create as Ms } from "jsondiffpatch";
@@ -361,11 +361,11 @@ class Ut {
361
361
  if (c != null && c.length && r)
362
362
  for (const d of c)
363
363
  try {
364
- const h = r;
365
- if (h.matches && h.matches(d) || h.closest && h.closest(d))
364
+ const l = r;
365
+ if (l.matches && l.matches(d) || l.closest && l.closest(d))
366
366
  return !0;
367
- } catch (h) {
368
- console.warn(`Error checking selection container with selector "${d}":`, h);
367
+ } catch (l) {
368
+ console.warn(`Error checking selection container with selector "${d}":`, l);
369
369
  }
370
370
  }
371
371
  return !1;
@@ -409,11 +409,11 @@ class As {
409
409
  return this.loaders[t] ? (this.cache.has(t) || this.cache.set(t, this.loaders[t]()), this.cache.get(t)) : Promise.reject(new Error(`Unknown module "${t}"`));
410
410
  }
411
411
  }
412
- function js(l) {
412
+ function js(h) {
413
413
  return new Worker(
414
414
  "" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
415
415
  {
416
- name: l == null ? void 0 : l.name
416
+ name: h == null ? void 0 : h.name
417
417
  }
418
418
  );
419
419
  }
@@ -464,23 +464,23 @@ class Is {
464
464
  }
465
465
  }
466
466
  const rt = 12, Cs = 2, le = 8, he = 20, Ts = 100, ue = 20, ge = 8, Es = 100, qt = 32, ye = 1, Os = "#2B2D33", ve = "#3D8BF4", be = "#FFFFFF";
467
- function Vt(l, t, e, s, o) {
467
+ function Vt(h, t, e, s, o) {
468
468
  const n = rt, i = Cs;
469
- l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = be, l.strokeStyle = ve, l.lineWidth = ye, l.beginPath(), l.roundRect(-n / 2, -n / 2, n, n, i), l.fill(), l.stroke(), l.restore();
469
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = be, h.strokeStyle = ve, h.lineWidth = ye, h.beginPath(), h.roundRect(-n / 2, -n / 2, n, n, i), h.fill(), h.stroke(), h.restore();
470
470
  }
471
- function Ue(l, t, e, s, o) {
471
+ function Ue(h, t, e, s, o) {
472
472
  const n = le, i = he, a = Ts;
473
- l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = be, l.strokeStyle = ve, l.lineWidth = ye, l.beginPath(), l.roundRect(-n / 2, -i / 2, n, i, a), l.fill(), l.stroke(), l.restore();
473
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = be, h.strokeStyle = ve, h.lineWidth = ye, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
474
474
  }
475
- function Ye(l, t, e, s, o) {
475
+ function Ye(h, t, e, s, o) {
476
476
  const n = ue, i = ge, a = Es;
477
- l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = be, l.strokeStyle = ve, l.lineWidth = ye, l.beginPath(), l.roundRect(-n / 2, -i / 2, n, i, a), l.fill(), l.stroke(), l.restore();
477
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = be, h.strokeStyle = ve, h.lineWidth = ye, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
478
478
  }
479
479
  const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", es = new Image();
480
480
  es.src = Ls;
481
- function Ds(l, t, e, s, o) {
481
+ function Ds(h, t, e, s, o) {
482
482
  const i = qt / 2;
483
- l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = Os, l.beginPath(), l.arc(0, 0, i, 0, 2 * Math.PI), l.fill(), l.drawImage(es, -i / 2, -i / 2, i, i), l.restore();
483
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = Os, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(es, -i / 2, -i / 2, i, i), h.restore();
484
484
  }
485
485
  const Rs = {
486
486
  // Угловые точки
@@ -602,14 +602,14 @@ class J {
602
602
  });
603
603
  if (!a)
604
604
  return e ? e.apply(this, n) : void 0;
605
- const { left: r, top: c, width: d, height: h } = a;
605
+ const { left: r, top: c, width: d, height: l } = a;
606
606
  this.set({
607
607
  flipX: !1,
608
608
  flipY: !1,
609
609
  width: d,
610
- height: h
610
+ height: l
611
611
  });
612
- const u = new tt(r + d / 2, c + h / 2);
612
+ const u = new tt(r + d / 2, c + l / 2);
613
613
  return this.setPositionByOrigin(u, "center", "center"), a;
614
614
  };
615
615
  const s = t._onAfterObjectsChange;
@@ -624,7 +624,7 @@ class J {
624
624
  objects: r
625
625
  });
626
626
  if (!c) return a;
627
- const { left: d, top: h, width: u, height: g } = c, f = new tt(d + u / 2, h + g / 2);
627
+ const { left: d, top: l, width: u, height: g } = c, f = new tt(d + u / 2, l + g / 2);
628
628
  return this.set({
629
629
  width: u,
630
630
  height: g
@@ -644,7 +644,7 @@ class J {
644
644
  const d = J.calculateActiveSelectionBounds({ objects: n });
645
645
  if (!d)
646
646
  return o.call(this, n, i);
647
- const { left: h, top: u, width: g, height: f } = d, p = new tt(g, f), m = new tt(h + g / 2, u + f / 2);
647
+ const { left: l, top: u, width: g, height: f } = d, p = new tt(g, f), m = new tt(l + g / 2, u + f / 2);
648
648
  return r === "initialization" ? {
649
649
  center: m,
650
650
  relativeCorrection: new tt(0, 0),
@@ -720,8 +720,8 @@ const B = class B {
720
720
  const u = yield new FontFace(o, i, t.descriptors).load();
721
721
  e.fonts.add(u), B.registeredFontKeys.add(r);
722
722
  return;
723
- } catch (h) {
724
- console.warn(`Не удалось загрузить шрифт "${o}" через FontFace API`, h);
723
+ } catch (l) {
724
+ console.warn(`Не удалось загрузить шрифт "${o}" через FontFace API`, l);
725
725
  }
726
726
  B.injectFontFace({
727
727
  font: t,
@@ -747,7 +747,7 @@ const B = class B {
747
747
  "@font-face {",
748
748
  ` font-family: ${B.formatFontFamilyForCss(i)};`,
749
749
  ` src: ${e};`,
750
- ...r.map((h) => ` ${h}`),
750
+ ...r.map((l) => ` ${l}`),
751
751
  "}"
752
752
  ];
753
753
  a.textContent = c.join(`
@@ -932,29 +932,29 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
932
932
  sendBackwards: ks
933
933
  },
934
934
  handlers: {
935
- copyPaste: (l) => N(null, null, function* () {
936
- l.clipboardManager.copyPaste();
935
+ copyPaste: (h) => N(null, null, function* () {
936
+ h.clipboardManager.copyPaste();
937
937
  }),
938
- delete: (l) => {
939
- l.deletionManager.deleteSelectedObjects();
938
+ delete: (h) => {
939
+ h.deletionManager.deleteSelectedObjects();
940
940
  },
941
- lock: (l) => {
942
- l.objectLockManager.lockObject();
941
+ lock: (h) => {
942
+ h.objectLockManager.lockObject();
943
943
  },
944
- unlock: (l) => {
945
- l.objectLockManager.unlockObject();
944
+ unlock: (h) => {
945
+ h.objectLockManager.unlockObject();
946
946
  },
947
- bringForward: (l) => {
948
- l.layerManager.bringForward();
947
+ bringForward: (h) => {
948
+ h.layerManager.bringForward();
949
949
  },
950
- bringToFront: (l) => {
951
- l.layerManager.bringToFront();
950
+ bringToFront: (h) => {
951
+ h.layerManager.bringToFront();
952
952
  },
953
- sendToBack: (l) => {
954
- l.layerManager.sendToBack();
953
+ sendToBack: (h) => {
954
+ h.layerManager.sendToBack();
955
955
  },
956
- sendBackwards: (l) => {
957
- l.layerManager.sendBackwards();
956
+ sendBackwards: (h) => {
957
+ h.layerManager.sendBackwards();
958
958
  }
959
959
  }
960
960
  };
@@ -1381,14 +1381,14 @@ class Jt {
1381
1381
  if (!t) return;
1382
1382
  console.log("loadStateFromFullState fullState", t);
1383
1383
  const { canvas: e, canvasManager: s, interactionBlocker: o, backgroundManager: n } = this.editor, { width: i, height: a } = e;
1384
- o.overlayMask = null, Jt._serializeCustomData(t), yield e.loadFromJSON(t, (h, u) => {
1385
- Jt._deserializeCustomData(h, u);
1384
+ o.overlayMask = null, Jt._serializeCustomData(t), yield e.loadFromJSON(t, (l, u) => {
1385
+ Jt._deserializeCustomData(l, u);
1386
1386
  });
1387
- const r = e.getObjects().find((h) => h.id === "montage-area");
1387
+ const r = e.getObjects().find((l) => l.id === "montage-area");
1388
1388
  r && (this.editor.montageArea = r, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
1389
- const c = e.getObjects().find((h) => h.id === "overlay-mask");
1389
+ const c = e.getObjects().find((l) => l.id === "overlay-mask");
1390
1390
  c && (o.overlayMask = c, o.overlayMask.visible = !1);
1391
- const d = e.getObjects().find((h) => h.id === "background");
1391
+ const d = e.getObjects().find((l) => l.id === "background");
1392
1392
  d ? (n.backgroundObject = d, n.refresh()) : n.removeBackground({ withoutSave: !0 }), e.renderAll(), e.fire("editor:history-state-loaded", {
1393
1393
  fullState: t,
1394
1394
  currentIndex: this.currentIndex,
@@ -1479,8 +1479,8 @@ class Jt {
1479
1479
  ((i = (n = (o = this.canvas).getObjects) == null ? void 0 : n.call(o)) != null ? i : []).forEach((a) => {
1480
1480
  const r = typeof a.type == "string" ? a.type.toLowerCase() : "";
1481
1481
  if (!(r === "textbox" || r === "i-text" || typeof a.isEditing == "boolean") || a.locked) return;
1482
- const d = !!a.lockMovementX, h = !!a.lockMovementY;
1483
- !d && !h || (e.push({
1482
+ const d = !!a.lockMovementX, l = !!a.lockMovementY;
1483
+ !d && !l || (e.push({
1484
1484
  object: a,
1485
1485
  lockMovementX: a.lockMovementX,
1486
1486
  lockMovementY: a.lockMovementY,
@@ -1538,7 +1538,7 @@ class ct {
1538
1538
  withoutSelection: a = !1
1539
1539
  } = t;
1540
1540
  if (!e) return null;
1541
- const { canvas: r, montageArea: c, transformManager: d, historyManager: h, errorManager: u } = this.editor, g = yield this.getContentType(e), f = ct.getFormatFromContentType(g), { acceptContentTypes: p, acceptFormats: m } = this;
1541
+ const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f = ct.getFormatFromContentType(g), { acceptContentTypes: p, acceptFormats: m } = this;
1542
1542
  if (!this.isAllowedContentType(g)) {
1543
1543
  const v = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1544
1544
  return u.emitError({
@@ -1558,7 +1558,7 @@ class ct {
1558
1558
  }
1559
1559
  }), null;
1560
1560
  }
1561
- h.suspendHistory();
1561
+ l.suspendHistory();
1562
1562
  try {
1563
1563
  let v, b;
1564
1564
  if (e instanceof File)
@@ -1593,21 +1593,21 @@ class ct {
1593
1593
  const A = b.getElement();
1594
1594
  let j = "";
1595
1595
  if (A instanceof HTMLImageElement ? j = A.src : A instanceof HTMLCanvasElement && (j = A.toDataURL()), y > wt || I > Mt) {
1596
- const M = yield this.resizeImageToBoundaries(j, "max"), T = URL.createObjectURL(M);
1596
+ const w = yield this.resizeImageToBoundaries(j, "max"), T = URL.createObjectURL(w);
1597
1597
  this._createdBlobUrls.push(T), b = yield zt.fromURL(T, { crossOrigin: "anonymous" });
1598
1598
  } else if (y < _t || I < Rt) {
1599
- const M = yield this.resizeImageToBoundaries(j, "min"), T = URL.createObjectURL(M);
1599
+ const w = yield this.resizeImageToBoundaries(j, "min"), T = URL.createObjectURL(w);
1600
1600
  this._createdBlobUrls.push(T), b = yield zt.fromURL(T, { crossOrigin: "anonymous" });
1601
1601
  }
1602
1602
  }
1603
1603
  if (b.set("id", `${b.type}-${G()}`), b.set("format", f), s === "scale-montage")
1604
1604
  this.editor.canvasManager.scaleMontageAreaToImage({ object: b, withoutSave: !0 });
1605
1605
  else {
1606
- const { width: A, height: j } = c, M = this.calculateScaleFactor({ imageObject: b, scaleType: s });
1607
- s === "image-contain" && M < 1 ? d.fitObject({ object: b, type: "contain", withoutSave: !0 }) : s === "image-cover" && (I > A || y > j) && d.fitObject({ object: b, type: "cover", withoutSave: !0 });
1606
+ const { width: A, height: j } = c, w = this.calculateScaleFactor({ imageObject: b, scaleType: s });
1607
+ s === "image-contain" && w < 1 ? d.fitObject({ object: b, type: "contain", withoutSave: !0 }) : s === "image-cover" && (I > A || y > j) && d.fitObject({ object: b, type: "cover", withoutSave: !0 });
1608
1608
  }
1609
- r.add(b), r.centerObject(b), a || r.setActiveObject(b), r.renderAll(), h.resumeHistory(), o || h.saveState();
1610
- const w = {
1609
+ r.add(b), r.centerObject(b), a || r.setActiveObject(b), r.renderAll(), l.resumeHistory(), o || l.saveState();
1610
+ const M = {
1611
1611
  image: b,
1612
1612
  format: f,
1613
1613
  contentType: g,
@@ -1618,7 +1618,7 @@ class ct {
1618
1618
  isBackground: i,
1619
1619
  withoutSelection: a
1620
1620
  };
1621
- return r.fire("editor:image-imported", w), w;
1621
+ return r.fire("editor:image-imported", M), M;
1622
1622
  } catch (v) {
1623
1623
  return u.emitError({
1624
1624
  origin: "ImageManager",
@@ -1635,7 +1635,7 @@ class ct {
1635
1635
  isBackground: i,
1636
1636
  withoutSelection: a
1637
1637
  }
1638
- }), h.resumeHistory(), null;
1638
+ }), l.resumeHistory(), null;
1639
1639
  }
1640
1640
  });
1641
1641
  }
@@ -1688,10 +1688,10 @@ class ct {
1688
1688
  exportAsBlob: n = !1
1689
1689
  } = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
1690
1690
  try {
1691
- const d = s === "application/pdf", h = d ? "image/jpg" : s, u = ct.getFormatFromContentType(h);
1691
+ const d = s === "application/pdf", l = d ? "image/jpg" : s, u = ct.getFormatFromContentType(l);
1692
1692
  a.setCoords();
1693
1693
  const { left: g, top: f, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
1694
- v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(h) && (v.backgroundColor = "#ffffff");
1694
+ v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
1695
1695
  const b = v.getObjects().find((S) => S.id === a.id);
1696
1696
  if (b && (b.visible = !1), c != null && c.isBlocked) {
1697
1697
  const S = v.getObjects().find((C) => C.id === c.overlayMask.id);
@@ -1723,33 +1723,33 @@ class ct {
1723
1723
  const S = {
1724
1724
  image: y,
1725
1725
  format: u,
1726
- contentType: h,
1726
+ contentType: l,
1727
1727
  fileName: e
1728
1728
  };
1729
1729
  return i.fire("editor:canvas-exported", S), S;
1730
1730
  }
1731
- const w = yield createImageBitmap(y), A = yield r.post(
1731
+ const M = yield createImageBitmap(y), A = yield r.post(
1732
1732
  "toDataURL",
1733
- { format: u, quality: 1, bitmap: w },
1734
- [w]
1733
+ { format: u, quality: 1, bitmap: M },
1734
+ [M]
1735
1735
  );
1736
1736
  if (d) {
1737
- const C = p * 0.264583, x = m * 0.264583, F = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, U = new F({
1737
+ const C = p * 0.264583, x = m * 0.264583, W = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, Y = new W({
1738
1738
  orientation: C > x ? "landscape" : "portrait",
1739
1739
  unit: "mm",
1740
1740
  format: [C, x]
1741
1741
  });
1742
- if (U.addImage(String(A), "JPG", 0, 0, C, x), o) {
1743
- const z = {
1744
- image: U.output("datauristring"),
1742
+ if (Y.addImage(String(A), "JPG", 0, 0, C, x), o) {
1743
+ const P = {
1744
+ image: Y.output("datauristring"),
1745
1745
  format: "pdf",
1746
1746
  contentType: "application/pdf",
1747
1747
  fileName: e
1748
1748
  };
1749
- return i.fire("editor:canvas-exported", z), z;
1749
+ return i.fire("editor:canvas-exported", P), P;
1750
1750
  }
1751
- const W = U.output("blob"), L = {
1752
- image: new File([W], e, { type: "application/pdf" }),
1751
+ const H = Y.output("blob"), L = {
1752
+ image: new File([H], e, { type: "application/pdf" }),
1753
1753
  format: "pdf",
1754
1754
  contentType: "application/pdf",
1755
1755
  fileName: e
@@ -1760,15 +1760,15 @@ class ct {
1760
1760
  const S = {
1761
1761
  image: A,
1762
1762
  format: u,
1763
- contentType: h,
1763
+ contentType: l,
1764
1764
  fileName: e
1765
1765
  };
1766
1766
  return i.fire("editor:canvas-exported", S), S;
1767
1767
  }
1768
1768
  const j = u === "svg" && !I ? e.replace(/\.[^/.]+$/, ".png") : e, T = {
1769
- image: new File([y], j, { type: h }),
1769
+ image: new File([y], j, { type: l }),
1770
1770
  format: u,
1771
- contentType: h,
1771
+ contentType: l,
1772
1772
  fileName: j
1773
1773
  };
1774
1774
  return i.fire("editor:canvas-exported", T), T;
@@ -1845,10 +1845,10 @@ class ct {
1845
1845
  };
1846
1846
  return a.fire("editor:object-exported", v), v;
1847
1847
  }
1848
- const h = c.toCanvasElement({
1848
+ const l = c.toCanvasElement({
1849
1849
  enableRetinaScaling: !1
1850
1850
  }), u = yield new Promise((p, m) => {
1851
- h.toBlob((v) => {
1851
+ l.toBlob((v) => {
1852
1852
  v ? p(v) : m(new Error("Failed to create Blob from canvas"));
1853
1853
  });
1854
1854
  });
@@ -1998,9 +1998,9 @@ class ct {
1998
1998
  return e ? e[1] : "";
1999
1999
  }
2000
2000
  }
2001
- const Tt = (l, t, e) => Math.max(Math.min(l, e), t), Ge = (l, t) => l * t, Xs = (l, t) => new tt(l / 2, t / 2);
2002
- function Ks(l) {
2003
- return ((l == null ? void 0 : l.type) === "image" || (l == null ? void 0 : l.format) === "svg") && typeof (l == null ? void 0 : l.width) == "number" && typeof (l == null ? void 0 : l.height) == "number";
2001
+ const Tt = (h, t, e) => Math.max(Math.min(h, e), t), Ge = (h, t) => h * t, Xs = (h, t) => new tt(h / 2, t / 2);
2002
+ function Ks(h) {
2003
+ return ((h == null ? void 0 : h.type) === "image" || (h == null ? void 0 : h.format) === "svg") && typeof (h == null ? void 0 : h.width) == "number" && typeof (h == null ? void 0 : h.height) == "number";
2004
2004
  }
2005
2005
  class Qs {
2006
2006
  /**
@@ -2039,8 +2039,8 @@ class Qs {
2039
2039
  this.setResolutionHeight(m);
2040
2040
  return;
2041
2041
  }
2042
- const { left: h, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
2043
- n.setViewportTransform([g, 0, 0, g, h, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-width-changed", {
2042
+ const { left: l, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
2043
+ n.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-width-changed", {
2044
2044
  width: d,
2045
2045
  preserveProportional: e,
2046
2046
  withoutSave: s,
@@ -2069,8 +2069,8 @@ class Qs {
2069
2069
  this.setResolutionWidth(m);
2070
2070
  return;
2071
2071
  }
2072
- const { left: h, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
2073
- n.setViewportTransform([g, 0, 0, g, h, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-height-changed", {
2072
+ const { left: l, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
2073
+ n.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-height-changed", {
2074
2074
  height: d,
2075
2075
  preserveProportional: e,
2076
2076
  withoutSave: s,
@@ -2156,22 +2156,22 @@ class Qs {
2156
2156
  if (a !== 0 || r !== 0) {
2157
2157
  const c = t.getActiveObject(), d = [];
2158
2158
  if ((c == null ? void 0 : c.type) === "activeselection") {
2159
- const h = c;
2160
- d.push(...h.getObjects()), t.discardActiveObject();
2159
+ const l = c;
2160
+ d.push(...l.getObjects()), t.discardActiveObject();
2161
2161
  }
2162
- if (t.getObjects().forEach((h) => {
2163
- h.id === "montage-area" || h.id === "overlay-mask" || h.id === "background" || (h.set({
2164
- left: h.left + a,
2165
- top: h.top + r
2166
- }), h.setCoords());
2162
+ if (t.getObjects().forEach((l) => {
2163
+ l.id === "montage-area" || l.id === "overlay-mask" || l.id === "background" || (l.set({
2164
+ left: l.left + a,
2165
+ top: l.top + r
2166
+ }), l.setCoords());
2167
2167
  }), d.length > 0)
2168
2168
  if (d.length === 1)
2169
2169
  t.setActiveObject(d[0]);
2170
2170
  else {
2171
- const h = new k(d, {
2171
+ const l = new k(d, {
2172
2172
  canvas: t
2173
2173
  });
2174
- t.setActiveObject(h);
2174
+ t.setActiveObject(l);
2175
2175
  }
2176
2176
  }
2177
2177
  t.renderAll(), t.fire("editor:canvas-updated", {
@@ -2335,16 +2335,16 @@ class Qs {
2335
2335
  }
2336
2336
  } = this.editor, c = t || o.getActiveObject();
2337
2337
  if (!Ks(c)) return;
2338
- const { width: d, height: h } = c;
2339
- let u = Math.min(d, Mt), g = Math.min(h, wt);
2338
+ const { width: d, height: l } = c;
2339
+ let u = Math.min(d, Mt), g = Math.min(l, wt);
2340
2340
  if (e) {
2341
2341
  const {
2342
2342
  width: f,
2343
2343
  height: p
2344
- } = n, m = d / f, v = h / p, b = Math.max(m, v);
2344
+ } = n, m = d / f, v = l / p, b = Math.max(m, v);
2345
2345
  u = f * b, g = p * b;
2346
2346
  }
2347
- this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a || h > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), o.centerObject(c), o.renderAll(), s || this.editor.historyManager.saveState(), o.fire("editor:montage-area-scaled-to-image", {
2347
+ this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a || l > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), o.centerObject(c), o.renderAll(), s || this.editor.historyManager.saveState(), o.fire("editor:montage-area-scaled-to-image", {
2348
2348
  object: c,
2349
2349
  width: u,
2350
2350
  height: g,
@@ -2506,7 +2506,7 @@ class qs {
2506
2506
  * @private
2507
2507
  */
2508
2508
  _fitSingleObject(t, e) {
2509
- const { canvas: s, montageArea: o } = this.editor, { width: n, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = n * Math.abs(a), h = i * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), p = d * g + h * f, m = d * f + h * g, v = o.width, b = o.height;
2509
+ const { canvas: s, montageArea: o } = this.editor, { width: n, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = n * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), p = d * g + l * f, m = d * f + l * g, v = o.width, b = o.height;
2510
2510
  let I;
2511
2511
  e === "contain" ? I = Math.min(v / p, b / m) : I = Math.max(v / p, b / m), t.set({
2512
2512
  scaleX: a * I,
@@ -2547,11 +2547,11 @@ class qs {
2547
2547
  }), e)
2548
2548
  this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
2549
2549
  else {
2550
- const { width: h, height: u } = n, { width: g, height: f } = c, p = i.calculateScaleFactor({
2550
+ const { width: l, height: u } = n, { width: g, height: f } = c, p = i.calculateScaleFactor({
2551
2551
  imageObject: c,
2552
2552
  scaleType: r
2553
2553
  });
2554
- r === "contain" && p < 1 || r === "cover" && (g > h || f > u) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
2554
+ r === "contain" && p < 1 || r === "cover" && (g > l || f > u) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
2555
2555
  }
2556
2556
  c.set({ flipX: !1, flipY: !1, angle: 0 }), o.centerObject(c), o.renderAll(), a.resumeHistory(), s || a.saveState(), o.fire("editor:object-reset", {
2557
2557
  object: c,
@@ -2584,7 +2584,7 @@ class Js {
2584
2584
  * @private
2585
2585
  */
2586
2586
  _getClampedPointerCoordinates(t) {
2587
- const { canvas: e, montageArea: s } = this.editor, o = e.getPointer(t, !0), n = e.viewportTransform, i = e.getZoom(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, h = a * i + n[4], u = r * i + n[4], g = c * i + n[5], f = d * i + n[5], p = Math.max(h, Math.min(u, o.x)), m = Math.max(g, Math.min(f, o.y));
2587
+ const { canvas: e, montageArea: s } = this.editor, o = e.getPointer(t, !0), n = e.viewportTransform, i = e.getZoom(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = a * i + n[4], u = r * i + n[4], g = c * i + n[5], f = d * i + n[5], p = Math.max(l, Math.min(u, o.x)), m = Math.max(g, Math.min(f, o.y));
2588
2588
  return {
2589
2589
  x: p,
2590
2590
  y: m
@@ -2619,9 +2619,9 @@ class Js {
2619
2619
  * @private
2620
2620
  */
2621
2621
  _calculateEmptySpaceRatio(t) {
2622
- const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, h = -o[4] / t, u = (-o[4] + n) / t, g = -o[5] / t, f = (-o[5] + i) / t, p = h < a, m = u > r, v = g < c, b = f > d;
2622
+ const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -o[4] / t, u = (-o[4] + n) / t, g = -o[5] / t, f = (-o[5] + i) / t, p = l < a, m = u > r, v = g < c, b = f > d;
2623
2623
  if (!(p || m || v || b)) return 0;
2624
- const y = Math.max(0, a - h), w = Math.max(0, u - r), A = Math.max(0, c - g), j = Math.max(0, f - d), M = Math.max(y, w), T = Math.max(A, j), S = M / n, C = T / i;
2624
+ const y = Math.max(0, a - l), M = Math.max(0, u - r), A = Math.max(0, c - g), j = Math.max(0, f - d), w = Math.max(y, M), T = Math.max(A, j), S = w / n, C = T / i;
2625
2625
  return Math.max(S, C);
2626
2626
  }
2627
2627
  /**
@@ -2635,11 +2635,11 @@ class Js {
2635
2635
  * @private
2636
2636
  */
2637
2637
  _calculateSmoothCenteringStep(t, e, s, o, n) {
2638
- const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), h = t.x - r[4], u = t.y - r[5], g = Math.abs(o), f = e - s;
2638
+ const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], g = Math.abs(o), f = e - s;
2639
2639
  if (Math.abs(f) / g <= 0.1)
2640
- return { x: h, y: u };
2641
- const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, w = v - I * s, A = (y - r[4]) / (e - s), j = (w - r[5]) / (e - s), M = A * g, T = j * g, S = M * n, C = T * n, x = Math.abs(S) > Math.abs(h) ? h : S, F = Math.abs(C) > Math.abs(u) ? u : C;
2642
- return { x, y: F };
2640
+ return { x: l, y: u };
2641
+ const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, M = v - I * s, A = (y - r[4]) / (e - s), j = (M - r[5]) / (e - s), w = A * g, T = j * g, S = w * n, C = T * n, x = Math.abs(S) > Math.abs(l) ? l : S, W = Math.abs(C) > Math.abs(u) ? u : C;
2642
+ return { x, y: W };
2643
2643
  }
2644
2644
  /**
2645
2645
  * Применяет плавное центрирование viewport при приближении к defaultZoom.
@@ -2712,10 +2712,10 @@ class Js {
2712
2712
  });
2713
2713
  return;
2714
2714
  }
2715
- const h = this._getClampedPointerCoordinates(e);
2715
+ const l = this._getClampedPointerCoordinates(e);
2716
2716
  this.zoom(t, {
2717
- pointX: h.x,
2718
- pointY: h.y
2717
+ pointX: l.x,
2718
+ pointY: l.y
2719
2719
  });
2720
2720
  }
2721
2721
  /**
@@ -2729,13 +2729,13 @@ class Js {
2729
2729
  zoom(t = He, e = {}) {
2730
2730
  var g, f;
2731
2731
  if (!t) return;
2732
- const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, h = new tt(c, d);
2732
+ const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new tt(c, d);
2733
2733
  this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
2734
2734
  let u = Number((a + Number(t)).toFixed(3));
2735
- u > o && (u = o), u < s && (u = s), n.zoomToPoint(h, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), n.fire("editor:zoom-changed", {
2735
+ u > o && (u = o), u < s && (u = s), n.zoomToPoint(l, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), n.fire("editor:zoom-changed", {
2736
2736
  currentZoom: n.getZoom(),
2737
2737
  zoom: u,
2738
- point: h
2738
+ point: l
2739
2739
  });
2740
2740
  }
2741
2741
  /**
@@ -3125,7 +3125,7 @@ class Ot {
3125
3125
  centerX: r = 50,
3126
3126
  centerY: c = 50,
3127
3127
  radius: d = 50
3128
- } = t, h = {
3128
+ } = t, l = {
3129
3129
  x1: r / 100,
3130
3130
  y1: c / 100,
3131
3131
  x2: r / 100,
@@ -3136,7 +3136,7 @@ class Ot {
3136
3136
  return new ze({
3137
3137
  type: "radial",
3138
3138
  gradientUnits: "percentage",
3139
- coords: h,
3139
+ coords: l,
3140
3140
  colorStops: a
3141
3141
  });
3142
3142
  }
@@ -3321,14 +3321,14 @@ class to {
3321
3321
  * @param flags.withoutAdding - Не добавлять объект в canvas
3322
3322
  */
3323
3323
  addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
3324
- var h = d, {
3324
+ var l = d, {
3325
3325
  id: t = `rect-${G()}`,
3326
3326
  left: e,
3327
3327
  top: s,
3328
3328
  width: o = 100,
3329
3329
  height: n = 100,
3330
3330
  fill: i = "blue"
3331
- } = h, a = vt(h, [
3331
+ } = l, a = vt(l, [
3332
3332
  "id",
3333
3333
  "left",
3334
3334
  "top",
@@ -3376,14 +3376,14 @@ class to {
3376
3376
  "radius",
3377
3377
  "fill"
3378
3378
  ]);
3379
- const { canvas: h } = this.editor, u = new fs(_({
3379
+ const { canvas: l } = this.editor, u = new fs(_({
3380
3380
  id: t,
3381
3381
  left: e,
3382
3382
  top: s,
3383
3383
  fill: n,
3384
3384
  radius: o
3385
3385
  }, i));
3386
- return !e && !s && h.centerObject(u), r || (h.add(u), a || h.setActiveObject(u), h.renderAll()), u;
3386
+ return !e && !s && l.centerObject(u), r || (l.add(u), a || l.setActiveObject(u), l.renderAll()), u;
3387
3387
  }
3388
3388
  /**
3389
3389
  * Добавление треугольника
@@ -3403,14 +3403,14 @@ class to {
3403
3403
  * @param flags.withoutAdding - Не добавлять объект в canvas
3404
3404
  */
3405
3405
  addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
3406
- var h = d, {
3406
+ var l = d, {
3407
3407
  id: t = `triangle-${G()}`,
3408
3408
  left: e,
3409
3409
  top: s,
3410
3410
  width: o = 100,
3411
3411
  height: n = 100,
3412
3412
  fill: i = "yellow"
3413
- } = h, a = vt(h, [
3413
+ } = l, a = vt(l, [
3414
3414
  "id",
3415
3415
  "left",
3416
3416
  "top",
@@ -3507,8 +3507,8 @@ class eo {
3507
3507
  return N(this, null, function* () {
3508
3508
  try {
3509
3509
  const o = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), n = o.slice(5).split(";")[0], i = o.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
3510
- for (let h = 0; h < a.length; h += 1)
3511
- r[h] = a.charCodeAt(h);
3510
+ for (let l = 0; l < a.length; l += 1)
3511
+ r[l] = a.charCodeAt(l);
3512
3512
  const c = new Blob([r.buffer], { type: n }), d = new ClipboardItem({ [n]: c });
3513
3513
  return yield navigator.clipboard.write([d]), console.info("Image copied to clipboard successfully"), !0;
3514
3514
  } catch (s) {
@@ -3627,13 +3627,13 @@ class eo {
3627
3627
  if (n.type !== "text/html" && i) {
3628
3628
  const c = new FileReader();
3629
3629
  c.onload = (d) => {
3630
- d.target && this._handleImageImport(d.target.result).catch((h) => {
3630
+ d.target && this._handleImageImport(d.target.result).catch((l) => {
3631
3631
  this.editor.errorManager.emitError({
3632
3632
  origin: "ClipboardManager",
3633
3633
  method: "handlePasteEvent",
3634
3634
  code: "PASTE_IMAGE_FAILED",
3635
3635
  message: "Ошибка вставки изображения из буфера обмена",
3636
- data: h
3636
+ data: l
3637
3637
  });
3638
3638
  });
3639
3639
  }, c.readAsDataURL(i);
@@ -3641,9 +3641,9 @@ class eo {
3641
3641
  }
3642
3642
  const a = t.getData("text/html");
3643
3643
  if (a) {
3644
- const h = new DOMParser().parseFromString(a, "text/html").querySelector("img");
3645
- if (h != null && h.src) {
3646
- this._handleImageImport(h.src).catch((u) => {
3644
+ const l = new DOMParser().parseFromString(a, "text/html").querySelector("img");
3645
+ if (l != null && l.src) {
3646
+ this._handleImageImport(l.src).catch((u) => {
3647
3647
  this.editor.errorManager.emitError({
3648
3648
  origin: "ClipboardManager",
3649
3649
  method: "handlePasteEvent",
@@ -3840,8 +3840,8 @@ class so {
3840
3840
  const i = [];
3841
3841
  n.forEach((c) => {
3842
3842
  const d = c.removeAll();
3843
- s.remove(c), d.forEach((h) => {
3844
- s.add(h), i.push(h);
3843
+ s.remove(c), d.forEach((l) => {
3844
+ s.add(l), i.push(l);
3845
3845
  });
3846
3846
  });
3847
3847
  const a = new k(i, {
@@ -3922,8 +3922,8 @@ class we {
3922
3922
  const r = [];
3923
3923
  if (a.forEach((d) => {
3924
3924
  if (we._isUngroupableGroup(d)) {
3925
- const h = this._handleGroupDeletion(d);
3926
- r.push(...h);
3925
+ const l = this._handleGroupDeletion(d);
3926
+ r.push(...l);
3927
3927
  return;
3928
3928
  }
3929
3929
  o.remove(d), r.push(d);
@@ -4173,12 +4173,12 @@ class no {
4173
4173
  constrainPan(t, e) {
4174
4174
  if (!this.currentBounds || !this.currentBounds.canPan)
4175
4175
  return { x: 0, y: 0 };
4176
- const { canvas: s, montageArea: o } = this.editor, n = s.getZoom(), i = o.left, a = o.top, r = s.getWidth() / 2, c = s.getHeight() / 2, d = i * n + t - r, h = a * n + e - c, u = Math.max(
4176
+ const { canvas: s, montageArea: o } = this.editor, n = s.getZoom(), i = o.left, a = o.top, r = s.getWidth() / 2, c = s.getHeight() / 2, d = i * n + t - r, l = a * n + e - c, u = Math.max(
4177
4177
  this.currentBounds.minX,
4178
4178
  Math.min(this.currentBounds.maxX, d)
4179
4179
  ), g = Math.max(
4180
4180
  this.currentBounds.minY,
4181
- Math.min(this.currentBounds.maxY, h)
4181
+ Math.min(this.currentBounds.maxY, l)
4182
4182
  ), f = u + r - i * n, p = g + c - a * n;
4183
4183
  return {
4184
4184
  x: f,
@@ -4209,13 +4209,13 @@ class no {
4209
4209
  }
4210
4210
  }
4211
4211
  const at = ({
4212
- value: l,
4212
+ value: h,
4213
4213
  min: t,
4214
4214
  max: e
4215
- }) => Math.min(Math.max(l, t), e), Dt = class Dt extends nt {
4215
+ }) => Math.min(Math.max(h, t), e), Dt = class Dt extends nt {
4216
4216
  constructor(t, e = {}) {
4217
- var s, o, n, i, a, r, c, d, h;
4218
- super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (n = e.paddingRight) != null ? n : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (h = e.radiusBottomLeft) != null ? h : 0, this._roundDimensions();
4217
+ var s, o, n, i, a, r, c, d, l;
4218
+ super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (n = e.paddingRight) != null ? n : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (l = e.radiusBottomLeft) != null ? l : 0, this._roundDimensions();
4219
4219
  }
4220
4220
  /**
4221
4221
  * Пересчитывает размеры текста и округляет их до целых значений.
@@ -4263,11 +4263,11 @@ const at = ({
4263
4263
  var s, o;
4264
4264
  const e = this._getEffectiveBackgroundFill();
4265
4265
  if (e && e) {
4266
- const n = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (o = this.height) != null ? o : 0, r = i + n.left + n.right, c = a + n.top + n.bottom, d = this._getCornerRadii({ width: r, height: c }), h = this._getLeftOffset() - n.left, u = this._getTopOffset() - n.top;
4266
+ const n = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (o = this.height) != null ? o : 0, r = i + n.left + n.right, c = a + n.top + n.bottom, d = this._getCornerRadii({ width: r, height: c }), l = this._getLeftOffset() - n.left, u = this._getTopOffset() - n.top;
4267
4267
  t.save(), Dt._renderRoundedRect({
4268
4268
  ctx: t,
4269
4269
  height: c,
4270
- left: h,
4270
+ left: l,
4271
4271
  radii: d,
4272
4272
  top: u,
4273
4273
  width: r
@@ -4331,9 +4331,9 @@ const at = ({
4331
4331
  const a = s + i, r = n + e, {
4332
4332
  topLeft: c,
4333
4333
  topRight: d,
4334
- bottomRight: h,
4334
+ bottomRight: l,
4335
4335
  bottomLeft: u
4336
- } = o, g = at({ value: c, min: 0, max: i }), f = at({ value: d, min: 0, max: i }), p = at({ value: h, min: 0, max: i }), m = at({ value: u, min: 0, max: i });
4336
+ } = o, g = at({ value: c, min: 0, max: i }), f = at({ value: d, min: 0, max: i }), p = at({ value: l, min: 0, max: i }), m = at({ value: u, min: 0, max: i });
4337
4337
  t.beginPath(), t.moveTo(s + g, n), t.lineTo(a - f, n), t.quadraticCurveTo(a, n, a, n + f), t.lineTo(a, r - p), t.quadraticCurveTo(a, r, a - p, r), t.lineTo(s + m, r), t.quadraticCurveTo(s, r, s, r - m), t.lineTo(s, n + g), t.quadraticCurveTo(s, n, s + g, n), t.closePath();
4338
4338
  }
4339
4339
  /**
@@ -4374,77 +4374,67 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
4374
4374
  ];
4375
4375
  let ee = Dt;
4376
4376
  const io = () => {
4377
- var l;
4378
- (l = Pe) != null && l.setClass && Pe.setClass(ee, "background-textbox");
4379
- }, ao = ({ textbox: l }) => {
4377
+ var h;
4378
+ (h = Pe) != null && h.setClass && Pe.setClass(ee, "background-textbox");
4379
+ }, ao = ({ textbox: h }) => {
4380
4380
  var s, o;
4381
- if (!l.isEditing) return null;
4382
- const t = (s = l.selectionStart) != null ? s : 0, e = (o = l.selectionEnd) != null ? o : t;
4381
+ if (!h.isEditing) return null;
4382
+ const t = (s = h.selectionStart) != null ? s : 0, e = (o = h.selectionEnd) != null ? o : t;
4383
4383
  return t === e ? null : {
4384
4384
  start: Math.min(t, e),
4385
4385
  end: Math.max(t, e)
4386
4386
  };
4387
- }, ro = ({ textbox: l }) => {
4387
+ }, ro = ({ textbox: h }) => {
4388
4388
  var e, s;
4389
- const t = (s = (e = l.text) == null ? void 0 : e.length) != null ? s : 0;
4389
+ const t = (s = (e = h.text) == null ? void 0 : e.length) != null ? s : 0;
4390
4390
  return t <= 0 ? null : { start: 0, end: t };
4391
- }, co = ({ textbox: l, range: t }) => {
4391
+ }, co = ({ textbox: h, range: t }) => {
4392
4392
  var s, o;
4393
4393
  if (!t) return !1;
4394
- const e = (o = (s = l.text) == null ? void 0 : s.length) != null ? o : 0;
4394
+ const e = (o = (s = h.text) == null ? void 0 : s.length) != null ? o : 0;
4395
4395
  return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
4396
4396
  }, ne = ({
4397
- textbox: l,
4397
+ textbox: h,
4398
4398
  styles: t,
4399
4399
  range: e
4400
4400
  }) => {
4401
4401
  if (!t || !Object.keys(t).length) return !1;
4402
4402
  const { start: s, end: o } = e;
4403
- return o <= s ? !1 : (l.setSelectionStyles(t, s, o), !0);
4403
+ return o <= s ? !1 : (h.setSelectionStyles(t, s, o), !0);
4404
4404
  }, Ve = ({
4405
- textbox: l,
4405
+ textbox: h,
4406
4406
  range: t,
4407
4407
  property: e
4408
4408
  }) => {
4409
4409
  var o;
4410
4410
  if (!t) return;
4411
- const s = l.getSelectionStyles(
4411
+ const s = h.getSelectionStyles(
4412
4412
  t.start,
4413
4413
  t.end,
4414
4414
  !0
4415
4415
  );
4416
4416
  if (s.length)
4417
4417
  return (o = s[0]) == null ? void 0 : o[e];
4418
- }, Xe = ({ strokeColor: l, width: t }) => {
4418
+ }, Xe = ({ strokeColor: h, width: t }) => {
4419
4419
  if (!(t <= 0))
4420
- return l != null ? l : "#000000";
4421
- }, Ke = ({ width: l = 0 }) => l ? Math.max(0, l) : 0, ie = ({ value: l }) => typeof l == "string" ? l.toLocaleUpperCase() : "", st = 0.01;
4422
- class Z {
4420
+ return h != null ? h : "#000000";
4421
+ }, Ke = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ie = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", st = 0.01;
4422
+ class z {
4423
4423
  constructor({ editor: t }) {
4424
4424
  var e;
4425
4425
  this._handleTextEditingEntered = () => {
4426
4426
  this.isTextEditingActive = !0;
4427
- }, this._handleTextChanged = (s) => {
4428
- const { target: o } = s;
4429
- if (!Z._isTextbox(o)) return;
4430
- const { text: n = "", uppercase: i } = o, a = !!i, r = n.toLocaleLowerCase();
4431
- if (a) {
4432
- const d = ie({ value: r });
4433
- d !== n && o.set({ text: d }), o.textCaseRaw = r;
4434
- } else
4435
- o.textCaseRaw = n;
4436
- Z._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0);
4437
4427
  }, this._handleTextEditingExited = (s) => {
4438
4428
  var r, c;
4439
4429
  const { target: o } = s;
4440
- if (!Z._isTextbox(o)) return;
4430
+ if (!z._isTextbox(o)) return;
4441
4431
  const n = (r = o.text) != null ? r : "";
4442
4432
  if (!!o.uppercase) {
4443
4433
  const d = (c = o.textCaseRaw) != null ? c : n.toLocaleLowerCase();
4444
4434
  o.textCaseRaw = d;
4445
4435
  } else
4446
4436
  o.textCaseRaw = n;
4447
- Z._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0, this.canvas.requestRenderAll()), o.locked || o.set({
4437
+ z._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0, this.canvas.requestRenderAll()), o.locked || o.set({
4448
4438
  lockMovementX: !1,
4449
4439
  lockMovementY: !1
4450
4440
  }), setTimeout(() => {
@@ -4453,40 +4443,40 @@ class Z {
4453
4443
  }, this._handleObjectScaling = (s) => {
4454
4444
  var X, It, Wt, mt, Ht, Ct, Ae, je, Ie, Ce, Te, Ee, Oe;
4455
4445
  const { target: o, transform: n } = s;
4456
- if (o instanceof k || !Z._isTextbox(o) || !n) return;
4446
+ if (o instanceof k || !z._isTextbox(o) || !n) return;
4457
4447
  o.isScaling = !0;
4458
4448
  const i = this._ensureScalingState(o), {
4459
4449
  baseWidth: a,
4460
4450
  baseLeft: r,
4461
4451
  baseFontSize: c,
4462
4452
  basePadding: d,
4463
- baseRadii: h,
4453
+ baseRadii: l,
4464
4454
  baseStyles: u
4465
- } = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Wt = n.corner) != null ? Wt : "", b = (mt = n.action) != null ? mt : "", I = ["ml", "mr"].includes(v) || b === "scaleX", y = ["mt", "mb"].includes(v) || b === "scaleY", w = ["tl", "tr", "bl", "br"].includes(v) || b === "scale", A = w || y;
4466
- if (!I && !y && !w) return;
4467
- const j = Math.abs((Ct = (Ht = o.scaleX) != null ? Ht : n.scaleX) != null ? Ct : 1) || 1, M = Math.abs((je = (Ae = o.scaleY) != null ? Ae : n.scaleY) != null ? je : 1) || 1, T = Math.max(1, p * j), S = Math.max(1, Math.round(T)), C = Math.max(1, c * M), {
4455
+ } = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Wt = n.corner) != null ? Wt : "", b = (mt = n.action) != null ? mt : "", I = ["ml", "mr"].includes(v) || b === "scaleX", y = ["mt", "mb"].includes(v) || b === "scaleY", M = ["tl", "tr", "bl", "br"].includes(v) || b === "scale", A = M || y;
4456
+ if (!I && !y && !M) return;
4457
+ const j = Math.abs((Ct = (Ht = o.scaleX) != null ? Ht : n.scaleX) != null ? Ct : 1) || 1, w = Math.abs((je = (Ae = o.scaleY) != null ? Ae : n.scaleY) != null ? je : 1) || 1, T = Math.max(1, p * j), S = Math.max(1, Math.round(T)), C = Math.max(1, c * w), {
4468
4458
  paddingTop: x = 0,
4469
- paddingRight: F = 0,
4470
- paddingBottom: U = 0,
4471
- paddingLeft: W = 0,
4459
+ paddingRight: W = 0,
4460
+ paddingBottom: Y = 0,
4461
+ paddingLeft: H = 0,
4472
4462
  radiusTopLeft: V = 0,
4473
4463
  radiusTopRight: L = 0,
4474
4464
  radiusBottomRight: D = 0,
4475
- radiusBottomLeft: z = 0,
4476
- fontSize: H,
4477
- width: P,
4465
+ radiusBottomLeft: P = 0,
4466
+ fontSize: Z,
4467
+ width: U,
4478
4468
  originX: K = "left"
4479
- } = o, $ = w || y, q = w || y, Y = $ ? {
4480
- top: Math.max(0, d.top * M),
4481
- right: Math.max(0, d.right * M),
4482
- bottom: Math.max(0, d.bottom * M),
4483
- left: Math.max(0, d.left * M)
4469
+ } = o, $ = M || y, q = M || y, F = $ ? {
4470
+ top: Math.max(0, d.top * w),
4471
+ right: Math.max(0, d.right * w),
4472
+ bottom: Math.max(0, d.bottom * w),
4473
+ left: Math.max(0, d.left * w)
4484
4474
  } : d, Q = q ? {
4485
- topLeft: Math.max(0, h.topLeft * M),
4486
- topRight: Math.max(0, h.topRight * M),
4487
- bottomRight: Math.max(0, h.bottomRight * M),
4488
- bottomLeft: Math.max(0, h.bottomLeft * M)
4489
- } : h, St = Object.keys(u).length > 0;
4475
+ topLeft: Math.max(0, l.topLeft * w),
4476
+ topRight: Math.max(0, l.topRight * w),
4477
+ bottomRight: Math.max(0, l.bottomRight * w),
4478
+ bottomLeft: Math.max(0, l.bottomLeft * w)
4479
+ } : l, St = Object.keys(u).length > 0;
4490
4480
  let et;
4491
4481
  if (A && St) {
4492
4482
  const se = {};
@@ -4496,11 +4486,11 @@ class Z {
4496
4486
  Object.entries(Le).forEach(([cs, Zt]) => {
4497
4487
  if (!Zt) return;
4498
4488
  const De = _({}, Zt);
4499
- typeof Zt.fontSize == "number" && (De.fontSize = Math.max(1, Zt.fontSize * M)), oe[cs] = De;
4489
+ typeof Zt.fontSize == "number" && (De.fontSize = Math.max(1, Zt.fontSize * w)), oe[cs] = De;
4500
4490
  }), Object.keys(oe).length && (se[rs] = oe);
4501
4491
  }), Object.keys(se).length && (et = se);
4502
4492
  }
4503
- const lt = (Ce = (Ie = n.originX) != null ? Ie : K) != null ? Ce : "left", pt = m + p, At = m + p / 2, ht = P != null ? P : p, jt = S !== ht, Ft = Math.abs(C - (H != null ? H : c)) > st, Nt = Math.abs(Y.top - x) > st || Math.abs(Y.right - F) > st || Math.abs(Y.bottom - U) > st || Math.abs(Y.left - W) > st, xt = Math.abs(Q.topLeft - V) > st || Math.abs(Q.topRight - L) > st || Math.abs(Q.bottomRight - D) > st || Math.abs(Q.bottomLeft - z) > st;
4493
+ const lt = (Ce = (Ie = n.originX) != null ? Ie : K) != null ? Ce : "left", pt = m + p, At = m + p / 2, ht = U != null ? U : p, jt = S !== ht, Ft = Math.abs(C - (Z != null ? Z : c)) > st, Nt = Math.abs(F.top - x) > st || Math.abs(F.right - W) > st || Math.abs(F.bottom - Y) > st || Math.abs(F.left - H) > st, xt = Math.abs(Q.topLeft - V) > st || Math.abs(Q.topRight - L) > st || Math.abs(Q.bottomRight - D) > st || Math.abs(Q.bottomLeft - P) > st;
4504
4494
  if (!jt && !Ft && !Nt && !xt) {
4505
4495
  o.set({ scaleX: 1, scaleY: 1 }), n.scaleX = 1, n.scaleY = 1;
4506
4496
  return;
@@ -4508,10 +4498,10 @@ class Z {
4508
4498
  et && (o.styles = et), o.set({
4509
4499
  width: S,
4510
4500
  fontSize: A ? C : c,
4511
- paddingTop: Y.top,
4512
- paddingRight: Y.right,
4513
- paddingBottom: Y.bottom,
4514
- paddingLeft: Y.left,
4501
+ paddingTop: F.top,
4502
+ paddingRight: F.right,
4503
+ paddingBottom: F.bottom,
4504
+ paddingLeft: F.left,
4515
4505
  radiusTopLeft: Q.topLeft,
4516
4506
  radiusTopRight: Q.topRight,
4517
4507
  radiusBottomRight: Q.bottomRight,
@@ -4519,17 +4509,17 @@ class Z {
4519
4509
  scaleX: 1,
4520
4510
  scaleY: 1
4521
4511
  });
4522
- const Bt = Z._roundTextboxDimensions({ textbox: o });
4512
+ const Bt = z._roundTextboxDimensions({ textbox: o });
4523
4513
  Bt && (o.dirty = !0);
4524
4514
  const ut = (Te = o.width) != null ? Te : S, kt = ut !== ht;
4525
4515
  let gt = m;
4526
- kt && (I || w) && (lt === "right" ? gt = pt - ut : lt === "center" && (gt = At - ut / 2)), o.set({ left: gt }), i.baseLeft = gt, n.scaleX = 1, n.scaleY = 1;
4516
+ kt && (I || M) && (lt === "right" ? gt = pt - ut : lt === "center" && (gt = At - ut / 2)), o.set({ left: gt }), i.baseLeft = gt, n.scaleX = 1, n.scaleY = 1;
4527
4517
  const { original: it } = n;
4528
4518
  it && (it.scaleX = 1, it.scaleY = 1, it.width = ut, it.height = o.height, it.left = gt), o.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = ut, i.baseFontSize = (Ee = o.fontSize) != null ? Ee : C, i.baseStyles = JSON.parse(JSON.stringify((Oe = o.styles) != null ? Oe : {})), i.basePadding = {
4529
- top: Y.top,
4530
- right: Y.right,
4531
- bottom: Y.bottom,
4532
- left: Y.left
4519
+ top: F.top,
4520
+ right: F.right,
4521
+ bottom: F.bottom,
4522
+ left: F.left
4533
4523
  }, i.baseRadii = {
4534
4524
  topLeft: Q.topLeft,
4535
4525
  topRight: Q.topRight,
@@ -4540,38 +4530,38 @@ class Z {
4540
4530
  var b, I, y;
4541
4531
  const { target: o } = s;
4542
4532
  if (o instanceof k) {
4543
- const w = o.getObjects();
4544
- if (!w.some((S) => Z._isTextbox(S))) return;
4545
- const { scaleX: j = 1, scaleY: M = 1 } = o;
4546
- if (Math.abs(j - 1) < st && Math.abs(M - 1) < st) return;
4547
- this.canvas.discardActiveObject(), w.forEach((S) => {
4548
- var C, x, F, U;
4549
- if (Z._isTextbox(S)) {
4550
- const W = (C = S.scaleX) != null ? C : 1, V = (x = S.scaleY) != null ? x : 1, L = ((F = S.fontSize) != null ? F : 16) * V, D = ((U = S.width) != null ? U : 0) * W, z = V, {
4551
- paddingTop: H = 0,
4552
- paddingRight: P = 0,
4533
+ const M = o.getObjects();
4534
+ if (!M.some((S) => z._isTextbox(S))) return;
4535
+ const { scaleX: j = 1, scaleY: w = 1 } = o;
4536
+ if (Math.abs(j - 1) < st && Math.abs(w - 1) < st) return;
4537
+ this.canvas.discardActiveObject(), M.forEach((S) => {
4538
+ var C, x, W, Y;
4539
+ if (z._isTextbox(S)) {
4540
+ const H = (C = S.scaleX) != null ? C : 1, V = (x = S.scaleY) != null ? x : 1, L = ((W = S.fontSize) != null ? W : 16) * V, D = ((Y = S.width) != null ? Y : 0) * H, P = V, {
4541
+ paddingTop: Z = 0,
4542
+ paddingRight: U = 0,
4553
4543
  paddingBottom: K = 0,
4554
4544
  paddingLeft: $ = 0,
4555
4545
  radiusTopLeft: q = 0,
4556
- radiusTopRight: Y = 0,
4546
+ radiusTopRight: F = 0,
4557
4547
  radiusBottomRight: Q = 0,
4558
4548
  radiusBottomLeft: St = 0,
4559
4549
  styles: et
4560
4550
  } = S, lt = {
4561
- paddingTop: Math.max(0, H * z),
4562
- paddingRight: Math.max(0, P * z),
4563
- paddingBottom: Math.max(0, K * z),
4564
- paddingLeft: Math.max(0, $ * z)
4551
+ paddingTop: Math.max(0, Z * P),
4552
+ paddingRight: Math.max(0, U * P),
4553
+ paddingBottom: Math.max(0, K * P),
4554
+ paddingLeft: Math.max(0, $ * P)
4565
4555
  }, pt = {
4566
- radiusTopLeft: Math.max(0, q * z),
4567
- radiusTopRight: Math.max(0, Y * z),
4568
- radiusBottomRight: Math.max(0, Q * z),
4569
- radiusBottomLeft: Math.max(0, St * z)
4556
+ radiusTopLeft: Math.max(0, q * P),
4557
+ radiusTopRight: Math.max(0, F * P),
4558
+ radiusBottomRight: Math.max(0, Q * P),
4559
+ radiusBottomLeft: Math.max(0, St * P)
4570
4560
  };
4571
4561
  let At = et;
4572
4562
  et && Object.keys(et).length > 0 && (At = JSON.parse(JSON.stringify(et)), Object.values(At).forEach((ht) => {
4573
4563
  Object.values(ht).forEach((jt) => {
4574
- typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize * z));
4564
+ typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize * P));
4575
4565
  });
4576
4566
  })), S.set(yt(_(_({
4577
4567
  fontSize: L,
@@ -4580,24 +4570,24 @@ class Z {
4580
4570
  scaleY: 1
4581
4571
  }, lt), pt), {
4582
4572
  styles: At
4583
- })), Z._roundTextboxDimensions({ textbox: S });
4573
+ })), z._roundTextboxDimensions({ textbox: S });
4584
4574
  }
4585
4575
  S.setCoords();
4586
4576
  });
4587
- const T = new k(w, {
4577
+ const T = new k(M, {
4588
4578
  canvas: this.canvas
4589
4579
  });
4590
4580
  this.canvas.setActiveObject(T), this.canvas.requestRenderAll();
4591
4581
  return;
4592
4582
  }
4593
- if (!Z._isTextbox(o)) return;
4583
+ if (!z._isTextbox(o)) return;
4594
4584
  o.isScaling = !1;
4595
4585
  const n = this.scalingState.get(o);
4596
4586
  if (this.scalingState.delete(o), !(n != null && n.hasWidthChange)) return;
4597
4587
  const i = (b = o.width) != null ? b : o.calcTextWidth(), a = (y = (I = o.fontSize) != null ? I : n == null ? void 0 : n.baseFontSize) != null ? y : 16, r = !!(n.baseStyles && Object.keys(n.baseStyles).length), {
4598
4588
  paddingTop: c = 0,
4599
4589
  paddingRight: d = 0,
4600
- paddingBottom: h = 0,
4590
+ paddingBottom: l = 0,
4601
4591
  paddingLeft: u = 0,
4602
4592
  radiusTopLeft: g = 0,
4603
4593
  radiusTopRight: f = 0,
@@ -4607,7 +4597,7 @@ class Z {
4607
4597
  width: i,
4608
4598
  paddingTop: c,
4609
4599
  paddingRight: d,
4610
- paddingBottom: h,
4600
+ paddingBottom: l,
4611
4601
  paddingLeft: u,
4612
4602
  radiusTopLeft: g,
4613
4603
  radiusTopRight: f,
@@ -4625,8 +4615,8 @@ class Z {
4625
4615
  * @param options — настройки текста
4626
4616
  * @param flags — флаги поведения
4627
4617
  */
4628
- addText(F = {}, { withoutSelection: S = !1, withoutSave: C = !1, withoutAdding: x = !1 } = {}) {
4629
- var U = F, {
4618
+ addText(W = {}, { withoutSelection: S = !1, withoutSave: C = !1, withoutAdding: x = !1 } = {}) {
4619
+ var Y = W, {
4630
4620
  id: t = `text-${G()}`,
4631
4621
  text: e = "Новый текст",
4632
4622
  fontFamily: s,
@@ -4637,7 +4627,7 @@ class Z {
4637
4627
  uppercase: r = !1,
4638
4628
  strikethrough: c = !1,
4639
4629
  align: d = "left",
4640
- color: h = "#000000",
4630
+ color: l = "#000000",
4641
4631
  strokeColor: u,
4642
4632
  strokeWidth: g = 0,
4643
4633
  opacity: f = 1,
@@ -4647,11 +4637,11 @@ class Z {
4647
4637
  paddingRight: b = 0,
4648
4638
  paddingBottom: I = 0,
4649
4639
  paddingLeft: y = 0,
4650
- radiusTopLeft: w = 0,
4640
+ radiusTopLeft: M = 0,
4651
4641
  radiusTopRight: A = 0,
4652
4642
  radiusBottomRight: j = 0,
4653
- radiusBottomLeft: M = 0
4654
- } = U, T = vt(U, [
4643
+ radiusBottomLeft: w = 0
4644
+ } = Y, T = vt(Y, [
4655
4645
  "id",
4656
4646
  "text",
4657
4647
  "fontFamily",
@@ -4678,12 +4668,12 @@ class Z {
4678
4668
  "radiusBottomLeft"
4679
4669
  ]);
4680
4670
  var $;
4681
- const { historyManager: W } = this.editor, { canvas: V } = this;
4682
- W.suspendHistory();
4683
- const L = s != null ? s : this._getDefaultFontFamily(), D = Ke({ width: g }), z = Xe({
4671
+ const { historyManager: H } = this.editor, { canvas: V } = this;
4672
+ H.suspendHistory();
4673
+ const L = s != null ? s : this._getDefaultFontFamily(), D = Ke({ width: g }), P = Xe({
4684
4674
  strokeColor: u,
4685
4675
  width: D
4686
- }), H = _({
4676
+ }), Z = _({
4687
4677
  id: t,
4688
4678
  fontFamily: L,
4689
4679
  fontSize: o,
@@ -4693,8 +4683,8 @@ class Z {
4693
4683
  uppercase: r,
4694
4684
  linethrough: c,
4695
4685
  textAlign: d,
4696
- fill: h,
4697
- stroke: z,
4686
+ fill: l,
4687
+ stroke: P,
4698
4688
  strokeWidth: D,
4699
4689
  strokeUniform: !0,
4700
4690
  opacity: f,
@@ -4704,25 +4694,25 @@ class Z {
4704
4694
  paddingRight: b,
4705
4695
  paddingBottom: I,
4706
4696
  paddingLeft: y,
4707
- radiusTopLeft: w,
4697
+ radiusTopLeft: M,
4708
4698
  radiusTopRight: A,
4709
4699
  radiusBottomRight: j,
4710
- radiusBottomLeft: M
4711
- }, T), P = new ee(e, H);
4712
- if (P.textCaseRaw = ($ = P.text) != null ? $ : "", r) {
4713
- const q = ie({ value: P.textCaseRaw });
4714
- q !== P.text && P.set({ text: q });
4715
- }
4716
- return Z._roundTextboxDimensions({ textbox: P }) && (P.dirty = !0), T.left === void 0 && T.top === void 0 && V.centerObject(P), x || V.add(P), S || V.setActiveObject(P), V.requestRenderAll(), W.resumeHistory(), C || W.saveState(), V.fire("editor:text-added", {
4717
- textbox: P,
4718
- options: yt(_({}, H), {
4700
+ radiusBottomLeft: w
4701
+ }, T), U = new ee(e, Z);
4702
+ if (U.textCaseRaw = ($ = U.text) != null ? $ : "", r) {
4703
+ const q = ie({ value: U.textCaseRaw });
4704
+ q !== U.text && U.set({ text: q });
4705
+ }
4706
+ return z._roundTextboxDimensions({ textbox: U }) && (U.dirty = !0), T.left === void 0 && T.top === void 0 && V.centerObject(U), x || V.add(U), S || V.setActiveObject(U), V.requestRenderAll(), H.resumeHistory(), C || H.saveState(), V.fire("editor:text-added", {
4707
+ textbox: U,
4708
+ options: yt(_({}, Z), {
4719
4709
  text: e,
4720
4710
  bold: n,
4721
4711
  italic: i,
4722
4712
  strikethrough: c,
4723
4713
  align: d,
4724
- color: h,
4725
- strokeColor: z,
4714
+ color: l,
4715
+ strokeColor: P,
4726
4716
  strokeWidth: D
4727
4717
  }),
4728
4718
  flags: {
@@ -4730,7 +4720,7 @@ class Z {
4730
4720
  withoutSave: !!C,
4731
4721
  withoutAdding: !!x
4732
4722
  }
4733
- }), P;
4723
+ }), U;
4734
4724
  }
4735
4725
  /**
4736
4726
  * Обновляет текстовый объект.
@@ -4746,10 +4736,10 @@ class Z {
4746
4736
  if (!n) return null;
4747
4737
  const { historyManager: i } = this.editor, { canvas: a } = this;
4748
4738
  i.suspendHistory();
4749
- const r = Z._getSnapshot(n), Nt = e, {
4739
+ const r = z._getSnapshot(n), Nt = e, {
4750
4740
  text: c,
4751
4741
  fontFamily: d,
4752
- fontSize: h,
4742
+ fontSize: l,
4753
4743
  bold: u,
4754
4744
  italic: g,
4755
4745
  underline: f,
@@ -4759,17 +4749,17 @@ class Z {
4759
4749
  color: b,
4760
4750
  strokeColor: I,
4761
4751
  strokeWidth: y,
4762
- opacity: w,
4752
+ opacity: M,
4763
4753
  backgroundColor: A,
4764
4754
  backgroundOpacity: j,
4765
- paddingTop: M,
4755
+ paddingTop: w,
4766
4756
  paddingRight: T,
4767
4757
  paddingBottom: S,
4768
4758
  paddingLeft: C,
4769
4759
  radiusTopLeft: x,
4770
- radiusTopRight: F,
4771
- radiusBottomRight: U,
4772
- radiusBottomLeft: W
4760
+ radiusTopRight: W,
4761
+ radiusBottomRight: Y,
4762
+ radiusBottomLeft: H
4773
4763
  } = Nt, V = vt(Nt, [
4774
4764
  "text",
4775
4765
  "fontFamily",
@@ -4794,23 +4784,23 @@ class Z {
4794
4784
  "radiusTopRight",
4795
4785
  "radiusBottomRight",
4796
4786
  "radiusBottomLeft"
4797
- ]), L = _({}, V), D = ao({ textbox: n }), z = D ? this._expandRangeToFullLines({ textbox: n, range: D }) : null, H = {}, P = {}, K = {}, $ = co({ textbox: n, range: D }), q = !D || $, Y = !D;
4798
- if (d !== void 0 && (z && (P.fontFamily = d), q && (L.fontFamily = d, Y && (K.fontFamily = d))), h !== void 0 && (z && (P.fontSize = h), q && (L.fontSize = h, Y && (K.fontSize = h))), u !== void 0) {
4787
+ ]), L = _({}, V), D = ao({ textbox: n }), P = D ? z._expandRangeToFullLines({ textbox: n, range: D }) : null, Z = {}, U = {}, K = {}, $ = co({ textbox: n, range: D }), q = !D || $, F = !D;
4788
+ if (d !== void 0 && (P && (U.fontFamily = d), q && (L.fontFamily = d, F && (K.fontFamily = d))), l !== void 0 && (P && (U.fontSize = l), q && (L.fontSize = l, F && (K.fontSize = l))), u !== void 0) {
4799
4789
  const X = u ? "bold" : "normal";
4800
- D && (H.fontWeight = X), q && (L.fontWeight = X, Y && (K.fontWeight = X));
4790
+ D && (Z.fontWeight = X), q && (L.fontWeight = X, F && (K.fontWeight = X));
4801
4791
  }
4802
4792
  if (g !== void 0) {
4803
4793
  const X = g ? "italic" : "normal";
4804
- D && (H.fontStyle = X), q && (L.fontStyle = X, Y && (K.fontStyle = X));
4794
+ D && (Z.fontStyle = X), q && (L.fontStyle = X, F && (K.fontStyle = X));
4805
4795
  }
4806
- if (f !== void 0 && (D && (H.underline = f), q && (L.underline = f, Y && (K.underline = f))), m !== void 0 && (D && (H.linethrough = m), q && (L.linethrough = m, Y && (K.linethrough = m))), v !== void 0 && (L.textAlign = v), b !== void 0 && (D && (H.fill = b), q && (L.fill = b, Y && (K.fill = b))), I !== void 0 || y !== void 0) {
4796
+ if (f !== void 0 && (D && (Z.underline = f), q && (L.underline = f, F && (K.underline = f))), m !== void 0 && (D && (Z.linethrough = m), q && (L.linethrough = m, F && (K.linethrough = m))), v !== void 0 && (L.textAlign = v), b !== void 0 && (D && (Z.fill = b), q && (L.fill = b, F && (K.fill = b))), I !== void 0 || y !== void 0) {
4807
4797
  const X = D ? Ve({ textbox: n, range: D, property: "strokeWidth" }) : void 0, It = D ? Ve({ textbox: n, range: D, property: "stroke" }) : void 0, Wt = (Bt = (xt = y != null ? y : X) != null ? xt : n.strokeWidth) != null ? Bt : 0, mt = Ke({ width: Wt }), Ht = (kt = (ut = I != null ? I : It) != null ? ut : n.stroke) != null ? kt : void 0, Ct = Xe({
4808
4798
  strokeColor: Ht,
4809
4799
  width: mt
4810
4800
  });
4811
- D && (H.stroke = Ct, H.strokeWidth = mt), q && (L.stroke = Ct, L.strokeWidth = mt, Y && (K.stroke = Ct, K.strokeWidth = mt));
4801
+ D && (Z.stroke = Ct, Z.strokeWidth = mt), q && (L.stroke = Ct, L.strokeWidth = mt, F && (K.stroke = Ct, K.strokeWidth = mt));
4812
4802
  }
4813
- w !== void 0 && (L.opacity = w), A !== void 0 && (L.backgroundColor = A), j !== void 0 && (L.backgroundOpacity = j), M !== void 0 && (L.paddingTop = M), T !== void 0 && (L.paddingRight = T), S !== void 0 && (L.paddingBottom = S), C !== void 0 && (L.paddingLeft = C), x !== void 0 && (L.radiusTopLeft = x), F !== void 0 && (L.radiusTopRight = F), U !== void 0 && (L.radiusBottomRight = U), W !== void 0 && (L.radiusBottomLeft = W);
4803
+ M !== void 0 && (L.opacity = M), A !== void 0 && (L.backgroundColor = A), j !== void 0 && (L.backgroundOpacity = j), w !== void 0 && (L.paddingTop = w), T !== void 0 && (L.paddingRight = T), S !== void 0 && (L.paddingBottom = S), C !== void 0 && (L.paddingLeft = C), x !== void 0 && (L.radiusTopLeft = x), W !== void 0 && (L.radiusTopRight = W), Y !== void 0 && (L.radiusBottomRight = Y), H !== void 0 && (L.radiusBottomLeft = H);
4814
4804
  const Q = (it = n.textCaseRaw) != null ? it : (gt = n.text) != null ? gt : "", St = !!n.uppercase, et = c !== void 0, lt = et ? c != null ? c : "" : Q, pt = p != null ? p : St;
4815
4805
  if (et || pt !== St) {
4816
4806
  const X = pt ? ie({ value: lt }) : lt;
@@ -4819,14 +4809,14 @@ class Z {
4819
4809
  n.uppercase = pt, n.set(L);
4820
4810
  let ht = !1;
4821
4811
  if (D) {
4822
- const X = ne({ textbox: n, styles: H, range: D }), It = z ? ne({ textbox: n, styles: P, range: z }) : !1;
4812
+ const X = ne({ textbox: n, styles: Z, range: D }), It = P ? ne({ textbox: n, styles: U, range: P }) : !1;
4823
4813
  ht = X || It;
4824
4814
  } else if (Object.keys(K).length) {
4825
4815
  const X = ro({ textbox: n });
4826
4816
  X && (ht = ne({ textbox: n, styles: K, range: X }));
4827
4817
  }
4828
- ht && (n.dirty = !0), (A !== void 0 || j !== void 0 || M !== void 0 || T !== void 0 || S !== void 0 || C !== void 0 || x !== void 0 || F !== void 0 || U !== void 0 || W !== void 0) && (n.dirty = !0), Z._roundTextboxDimensions({ textbox: n }) && (n.dirty = !0), n.setCoords(), o || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
4829
- const Ft = Z._getSnapshot(n);
4818
+ ht && (n.dirty = !0), (A !== void 0 || j !== void 0 || w !== void 0 || T !== void 0 || S !== void 0 || C !== void 0 || x !== void 0 || W !== void 0 || Y !== void 0 || H !== void 0) && (n.dirty = !0), z._roundTextboxDimensions({ textbox: n }) && (n.dirty = !0), n.setCoords(), o || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
4819
+ const Ft = z._getSnapshot(n);
4830
4820
  return a.fire("editor:text-updated", {
4831
4821
  textbox: n,
4832
4822
  target: t,
@@ -4839,7 +4829,7 @@ class Z {
4839
4829
  before: r,
4840
4830
  after: Ft,
4841
4831
  selectionRange: D != null ? D : void 0,
4842
- selectionStyles: D && Object.keys(H).length ? H : void 0
4832
+ selectionStyles: D && Object.keys(Z).length ? Z : void 0
4843
4833
  }), n;
4844
4834
  }
4845
4835
  /**
@@ -4847,7 +4837,7 @@ class Z {
4847
4837
  */
4848
4838
  destroy() {
4849
4839
  const { canvas: t } = this;
4850
- t.off("object:scaling", this._handleObjectScaling), t.off("object:modified", this._handleObjectModified), t.off("text:editing:exited", this._handleTextEditingExited), t.off("text:editing:entered", this._handleTextEditingEntered), t.off("text:changed", this._handleTextChanged);
4840
+ t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing", z._handleObjectResizing), t.off("object:modified", this._handleObjectModified), t.off("text:editing:exited", this._handleTextEditingExited), t.off("text:editing:entered", this._handleTextEditingEntered), t.off("text:changed", z._handleTextChanged);
4851
4841
  }
4852
4842
  /**
4853
4843
  * Возвращает активный текст или ищет по id.
@@ -4857,10 +4847,10 @@ class Z {
4857
4847
  const { canvas: e } = this;
4858
4848
  if (!t) {
4859
4849
  const s = e.getActiveObject();
4860
- return Z._isTextbox(s) ? s : null;
4850
+ return z._isTextbox(s) ? s : null;
4861
4851
  }
4862
4852
  if (typeof t == "string") {
4863
- const s = e.getObjects().find((o) => Z._isTextbox(o) && o.id === t);
4853
+ const s = e.getObjects().find((o) => z._isTextbox(o) && o.id === t);
4864
4854
  return s != null ? s : null;
4865
4855
  }
4866
4856
  return null;
@@ -4876,12 +4866,53 @@ class Z {
4876
4866
  */
4877
4867
  _bindEvents() {
4878
4868
  const { canvas: t } = this;
4879
- t.on("object:scaling", this._handleObjectScaling), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed", this._handleTextChanged);
4869
+ t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing", z._handleObjectResizing), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed", z._handleTextChanged);
4870
+ }
4871
+ /**
4872
+ * Реагирует на изменение текста в режиме редактирования: синхронизирует textCaseRaw и uppercase.
4873
+ */
4874
+ static _handleTextChanged(t) {
4875
+ const { target: e } = t;
4876
+ if (!z._isTextbox(e)) return;
4877
+ const { text: s = "", uppercase: o } = e, n = !!o, i = s.toLocaleLowerCase();
4878
+ if (n) {
4879
+ const r = ie({ value: i });
4880
+ r !== s && e.set({ text: r }), e.textCaseRaw = i;
4881
+ } else
4882
+ e.textCaseRaw = s;
4883
+ z._roundTextboxDimensions({ textbox: e }) && (e.setCoords(), e.dirty = !0);
4884
+ }
4885
+ /**
4886
+ * Обрабатывает изменение ширины текстового объекта (resizing).
4887
+ * Корректирует ширину, вычитая паддинги, так как Fabric при изменении ширины
4888
+ * устанавливает значение, включающее визуальные отступы.
4889
+ * Также корректирует позицию при ресайзе слева, чтобы компенсировать смещение.
4890
+ */
4891
+ static _handleObjectResizing(t) {
4892
+ var l, u, g, f, p, m;
4893
+ const { target: e, transform: s } = t;
4894
+ if (!z._isTextbox(e)) return;
4895
+ const {
4896
+ paddingLeft: o = 0,
4897
+ paddingRight: n = 0
4898
+ } = e, i = o + n;
4899
+ if (i === 0) return;
4900
+ const a = (l = e.width) != null ? l : 0, r = Math.max(0, a - i);
4901
+ if (a === r) return;
4902
+ e.set({ width: r });
4903
+ const c = (u = e.width) != null ? u : 0, d = a - c;
4904
+ if (d !== 0 && s && s.corner === "ml") {
4905
+ const b = ((g = e.angle) != null ? g : 0) * Math.PI / 180, I = Math.cos(b), y = Math.sin(b), M = (f = e.scaleX) != null ? f : 1, A = d * M;
4906
+ e.set({
4907
+ left: ((p = e.left) != null ? p : 0) + A * I,
4908
+ top: ((m = e.top) != null ? m : 0) + A * y
4909
+ });
4910
+ }
4880
4911
  }
4881
4912
  /**
4882
4913
  * Возвращает диапазоны символов для каждой строки текста без учёта символов переноса.
4883
4914
  */
4884
- _getLineRanges({ textbox: t }) {
4915
+ static _getLineRanges({ textbox: t }) {
4885
4916
  var n;
4886
4917
  const e = (n = t.text) != null ? n : "";
4887
4918
  if (!e.length) return [];
@@ -4896,11 +4927,11 @@ class Z {
4896
4927
  /**
4897
4928
  * Расширяет выделение до полных строк, которые оно пересекает.
4898
4929
  */
4899
- _expandRangeToFullLines({
4930
+ static _expandRangeToFullLines({
4900
4931
  textbox: t,
4901
4932
  range: e
4902
4933
  }) {
4903
- const s = this._getLineRanges({ textbox: t });
4934
+ const s = z._getLineRanges({ textbox: t });
4904
4935
  if (!s.length) return e;
4905
4936
  let { start: o } = e, { end: n } = e;
4906
4937
  return s.forEach(({ start: i, end: a }) => {
@@ -4916,7 +4947,7 @@ class Z {
4916
4947
  if (!e) {
4917
4948
  const i = (s = t.width) != null ? s : t.calcTextWidth(), a = (o = t.left) != null ? o : 0, r = (n = t.fontSize) != null ? n : 16, { styles: c = {} } = t, {
4918
4949
  paddingTop: d = 0,
4919
- paddingRight: h = 0,
4950
+ paddingRight: l = 0,
4920
4951
  paddingBottom: u = 0,
4921
4952
  paddingLeft: g = 0
4922
4953
  } = t, {
@@ -4931,7 +4962,7 @@ class Z {
4931
4962
  baseLeft: a,
4932
4963
  basePadding: {
4933
4964
  top: d,
4934
- right: h,
4965
+ right: l,
4935
4966
  bottom: u,
4936
4967
  left: g
4937
4968
  },
@@ -4962,25 +4993,25 @@ class Z {
4962
4993
  static _roundTextboxDimensions({
4963
4994
  textbox: t
4964
4995
  }) {
4965
- const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r = Z._resolveDimension({
4996
+ const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r = z._resolveDimension({
4966
4997
  rawValue: e,
4967
4998
  calculatedValue: i
4968
- }), c = Z._resolveDimension({
4999
+ }), c = z._resolveDimension({
4969
5000
  rawValue: s,
4970
5001
  calculatedValue: a
4971
- }), d = Number.isFinite(r) ? Math.round(r) : null, h = Number.isFinite(c) ? Math.round(c) : null, u = {};
4972
- return d !== null && d !== r && (u.width = Math.max(0, d)), h !== null && h !== c && (u.height = Math.max(0, h)), Object.keys(u).length ? (t.set(u), !0) : !1;
5002
+ }), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
5003
+ return d !== null && d !== r && (u.width = Math.max(0, d)), l !== null && l !== c && (u.height = Math.max(0, l)), Object.keys(u).length ? (t.set(u), !0) : !1;
4973
5004
  }
4974
5005
  /**
4975
5006
  * Формирует снимок текущих свойств текстового объекта для истории и событий.
4976
5007
  */
4977
5008
  static _getSnapshot(t) {
4978
5009
  const e = ({
4979
- snapshot: H,
4980
- entries: P
5010
+ snapshot: Z,
5011
+ entries: U
4981
5012
  }) => {
4982
- Object.entries(P).forEach(([K, $]) => {
4983
- $ != null && (H[K] = $);
5013
+ Object.entries(U).forEach(([K, $]) => {
5014
+ $ != null && (Z[K] = $);
4984
5015
  });
4985
5016
  }, {
4986
5017
  id: s,
@@ -4991,7 +5022,7 @@ class Z {
4991
5022
  fontSize: r,
4992
5023
  fontWeight: c,
4993
5024
  fontStyle: d,
4994
- underline: h,
5025
+ underline: l,
4995
5026
  linethrough: u,
4996
5027
  textAlign: g,
4997
5028
  fill: f,
@@ -5001,27 +5032,27 @@ class Z {
5001
5032
  backgroundColor: b,
5002
5033
  backgroundOpacity: I,
5003
5034
  paddingTop: y,
5004
- paddingRight: w,
5035
+ paddingRight: M,
5005
5036
  paddingBottom: A,
5006
5037
  paddingLeft: j,
5007
- radiusTopLeft: M,
5038
+ radiusTopLeft: w,
5008
5039
  radiusTopRight: T,
5009
5040
  radiusBottomRight: S,
5010
5041
  radiusBottomLeft: C,
5011
5042
  left: x,
5012
- top: F,
5013
- width: U,
5014
- height: W,
5043
+ top: W,
5044
+ width: Y,
5045
+ height: H,
5015
5046
  angle: V,
5016
5047
  scaleX: L,
5017
5048
  scaleY: D
5018
- } = t, z = {
5049
+ } = t, P = {
5019
5050
  id: s,
5020
5051
  uppercase: !!i,
5021
5052
  textAlign: g
5022
5053
  };
5023
5054
  return e({
5024
- snapshot: z,
5055
+ snapshot: P,
5025
5056
  entries: {
5026
5057
  text: o,
5027
5058
  textCaseRaw: n,
@@ -5029,7 +5060,7 @@ class Z {
5029
5060
  fontSize: r,
5030
5061
  fontWeight: c,
5031
5062
  fontStyle: d,
5032
- underline: h,
5063
+ underline: l,
5033
5064
  linethrough: u,
5034
5065
  fill: f,
5035
5066
  stroke: p,
@@ -5038,22 +5069,22 @@ class Z {
5038
5069
  backgroundColor: b,
5039
5070
  backgroundOpacity: I,
5040
5071
  paddingTop: y,
5041
- paddingRight: w,
5072
+ paddingRight: M,
5042
5073
  paddingBottom: A,
5043
5074
  paddingLeft: j,
5044
- radiusTopLeft: M,
5075
+ radiusTopLeft: w,
5045
5076
  radiusTopRight: T,
5046
5077
  radiusBottomRight: S,
5047
5078
  radiusBottomLeft: C,
5048
5079
  left: x,
5049
- top: F,
5050
- width: U,
5051
- height: W,
5080
+ top: W,
5081
+ width: Y,
5082
+ height: H,
5052
5083
  angle: V,
5053
5084
  scaleX: L,
5054
5085
  scaleY: D
5055
5086
  }
5056
- }), z;
5087
+ }), P;
5057
5088
  }
5058
5089
  /**
5059
5090
  * Возвращает первый доступный шрифт или дефолтный Arial.
@@ -5064,23 +5095,23 @@ class Z {
5064
5095
  }
5065
5096
  }
5066
5097
  const ot = ({
5067
- value: l,
5098
+ value: h,
5068
5099
  fallback: t = 0
5069
- }) => typeof l == "number" && Number.isFinite(l) ? l : typeof t == "number" && Number.isFinite(t) ? t : 0, Kt = ({
5070
- value: l,
5100
+ }) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, Kt = ({
5101
+ value: h,
5071
5102
  dimension: t,
5072
5103
  useRelativePositions: e
5073
5104
  }) => {
5074
- const s = ot({ value: l });
5105
+ const s = ot({ value: h });
5075
5106
  return e ? s : s / (t || 1);
5076
5107
  }, lo = ({
5077
- object: l,
5108
+ object: h,
5078
5109
  baseWidth: t,
5079
5110
  baseHeight: e,
5080
5111
  useRelativePositions: s,
5081
5112
  centerKeys: o
5082
5113
  }) => {
5083
- const n = l;
5114
+ const n = h;
5084
5115
  if (typeof n[o.x] == "number" && typeof n[o.y] == "number")
5085
5116
  return {
5086
5117
  x: Kt({
@@ -5094,7 +5125,7 @@ const ot = ({
5094
5125
  useRelativePositions: s
5095
5126
  })
5096
5127
  };
5097
- const { left: a, top: r, width: c, height: d } = l, h = Kt({
5128
+ const { left: a, top: r, width: c, height: d } = h, l = Kt({
5098
5129
  value: a,
5099
5130
  dimension: t,
5100
5131
  useRelativePositions: s
@@ -5104,11 +5135,11 @@ const ot = ({
5104
5135
  useRelativePositions: s
5105
5136
  }), g = ot({ value: c }) / (t || 1), f = ot({ value: d }) / (e || 1);
5106
5137
  return {
5107
- x: h + g / 2,
5138
+ x: l + g / 2,
5108
5139
  y: u + f / 2
5109
5140
  };
5110
5141
  }, ho = ({
5111
- normalizedX: l,
5142
+ normalizedX: h,
5112
5143
  normalizedY: t,
5113
5144
  bounds: e,
5114
5145
  targetSize: s,
@@ -5116,33 +5147,33 @@ const ot = ({
5116
5147
  }) => {
5117
5148
  const { left: n, top: i, width: a, height: r } = e;
5118
5149
  if (!o) {
5119
- const { width: h, height: u } = s, g = n + l * (h || a), f = i + t * (u || r);
5150
+ const { width: l, height: u } = s, g = n + h * (l || a), f = i + t * (u || r);
5120
5151
  return new tt(g, f);
5121
5152
  }
5122
- const c = n + l * a, d = i + t * r;
5153
+ const c = n + h * a, d = i + t * r;
5123
5154
  return new tt(c, d);
5124
5155
  }, uo = ({
5125
- object: l,
5156
+ object: h,
5126
5157
  montageArea: t,
5127
5158
  bounds: e
5128
5159
  }) => {
5129
5160
  if (!t || !e) return null;
5130
5161
  try {
5131
- const s = l.getCenterPoint(), { left: o, top: n, width: i, height: a } = e, r = s.x - o, c = s.y - n, d = r / i, h = c / a;
5162
+ const s = h.getCenterPoint(), { left: o, top: n, width: i, height: a } = e, r = s.x - o, c = s.y - n, d = r / i, l = c / a;
5132
5163
  return {
5133
5164
  x: d,
5134
- y: h
5165
+ y: l
5135
5166
  };
5136
5167
  } catch (s) {
5137
5168
  return null;
5138
5169
  }
5139
5170
  }, ft = ({
5140
- object: l
5171
+ object: h
5141
5172
  }) => {
5142
- if (!l) return null;
5173
+ if (!h) return null;
5143
5174
  try {
5144
- l.setCoords();
5145
- const t = l.getBoundingRect(!1, !0), {
5175
+ h.setCoords();
5176
+ const t = h.getBoundingRect(!1, !0), {
5146
5177
  left: e = 0,
5147
5178
  top: s = 0,
5148
5179
  width: o = 0,
@@ -5160,13 +5191,13 @@ const ot = ({
5160
5191
  return null;
5161
5192
  }
5162
5193
  }, go = ({
5163
- x1: l,
5194
+ x1: h,
5164
5195
  y1: t,
5165
5196
  x2: e,
5166
5197
  y2: s
5167
- }) => (Math.atan2(s - t, e - l) * 180 / Math.PI + 360) % 360, fo = (l) => {
5168
- if (!l || typeof l != "object") return null;
5169
- const { type: t, coords: e, colorStops: s } = l, o = Array.isArray(s) ? s : [], n = o[0], i = o[o.length - 1], a = typeof (n == null ? void 0 : n.color) == "string" ? n.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (n == null ? void 0 : n.offset) == "number" ? n.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, h = o.map((u) => ({
5198
+ }) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360, fo = (h) => {
5199
+ if (!h || typeof h != "object") return null;
5200
+ const { type: t, coords: e, colorStops: s } = h, o = Array.isArray(s) ? s : [], n = o[0], i = o[o.length - 1], a = typeof (n == null ? void 0 : n.color) == "string" ? n.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (n == null ? void 0 : n.offset) == "number" ? n.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, l = o.map((u) => ({
5170
5201
  color: typeof u.color == "string" ? u.color : "#000000",
5171
5202
  offset: typeof u.offset == "number" ? u.offset * 100 : 0
5172
5203
  }));
@@ -5181,7 +5212,7 @@ const ot = ({
5181
5212
  endColor: r,
5182
5213
  startPosition: c,
5183
5214
  endPosition: d,
5184
- colorStops: h
5215
+ colorStops: l
5185
5216
  };
5186
5217
  }
5187
5218
  if (t === "radial") {
@@ -5196,7 +5227,7 @@ const ot = ({
5196
5227
  endColor: r,
5197
5228
  startPosition: c,
5198
5229
  endPosition: d,
5199
- colorStops: h
5230
+ colorStops: l
5200
5231
  };
5201
5232
  }
5202
5233
  return null;
@@ -5220,7 +5251,7 @@ class R {
5220
5251
  montageArea: i,
5221
5252
  errorManager: a,
5222
5253
  backgroundManager: r
5223
- } = this.editor, c = n.getActiveObject(), d = R._collectObjects(c), { backgroundObject: h } = r != null ? r : {}, u = o && h ? [h] : [], g = [...d, ...u];
5254
+ } = this.editor, c = n.getActiveObject(), d = R._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = o && l ? [l] : [], g = [...d, ...u];
5224
5255
  if (!g.length)
5225
5256
  return a.emitWarning({
5226
5257
  origin: "TemplateManager",
@@ -5228,8 +5259,8 @@ class R {
5228
5259
  code: bt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
5229
5260
  message: "Нет объектов для сериализации шаблона"
5230
5261
  }), null;
5231
- const f = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height, b = g.map((w) => R._serializeObject({
5232
- object: w,
5262
+ const f = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height, b = g.map((M) => R._serializeObject({
5263
+ object: M,
5233
5264
  bounds: f,
5234
5265
  baseWidth: m,
5235
5266
  baseHeight: v,
@@ -5263,7 +5294,7 @@ class R {
5263
5294
  historyManager: i,
5264
5295
  errorManager: a,
5265
5296
  backgroundManager: r
5266
- } = this.editor, { objects: c, meta: d, id: h } = t != null ? t : {};
5297
+ } = this.editor, { objects: c, meta: d, id: l } = t != null ? t : {};
5267
5298
  if (!(c != null && c.length))
5268
5299
  return a.emitWarning({
5269
5300
  origin: "TemplateManager",
@@ -5291,13 +5322,13 @@ class R {
5291
5322
  code: bt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
5292
5323
  message: "Не удалось создать объекты шаблона"
5293
5324
  }), null;
5294
- const { backgroundObject: y, contentObjects: w } = R._extractBackgroundObject(I);
5325
+ const { backgroundObject: y, contentObjects: M } = R._extractBackgroundObject(I);
5295
5326
  y && (b = yield R._applyBackgroundFromObject({
5296
5327
  backgroundObject: y,
5297
5328
  backgroundManager: r,
5298
5329
  errorManager: a
5299
5330
  }));
5300
- const A = w.map((j) => (R._applyTextOverrides({ object: j, data: e }), R._transformObject({
5331
+ const A = M.map((j) => (R._applyTextOverrides({ object: j, data: e }), R._transformObject({
5301
5332
  object: j,
5302
5333
  scale: p,
5303
5334
  bounds: u,
@@ -5322,7 +5353,7 @@ class R {
5322
5353
  code: bt.TEMPLATE_MANAGER.APPLY_FAILED,
5323
5354
  message: "Ошибка применения шаблона",
5324
5355
  data: {
5325
- templateId: h,
5356
+ templateId: l,
5326
5357
  error: I
5327
5358
  }
5328
5359
  }), null;
@@ -5386,7 +5417,7 @@ class R {
5386
5417
  scaleY: a
5387
5418
  } = e, r = t, c = "getElement" in r && typeof r.getElement == "function" ? r.getElement() : null, {
5388
5419
  naturalWidth: d = 0,
5389
- naturalHeight: h = 0,
5420
+ naturalHeight: l = 0,
5390
5421
  width: u = 0,
5391
5422
  height: g = 0
5392
5423
  } = c instanceof HTMLImageElement ? c : {
@@ -5394,8 +5425,8 @@ class R {
5394
5425
  naturalHeight: 0,
5395
5426
  width: 0,
5396
5427
  height: 0
5397
- }, f = ot({ value: d || u || r.width, fallback: 0 }), p = ot({ value: h || g || r.height, fallback: 0 }), m = ot({ value: o, fallback: f }), v = ot({ value: n, fallback: p }), b = ot({ value: i, fallback: r.scaleX || 1 }), I = ot({ value: a, fallback: r.scaleY || 1 }), y = m * b, w = v * I, A = f ? y / f : null, j = p ? w / p : null, M = {};
5398
- f > 0 && (M.width = f), p > 0 && (M.height = p), A && A > 0 && (M.scaleX = A), j && j > 0 && (M.scaleY = j), r.set(M);
5428
+ }, f = ot({ value: d || u || r.width, fallback: 0 }), p = ot({ value: l || g || r.height, fallback: 0 }), m = ot({ value: o, fallback: f }), v = ot({ value: n, fallback: p }), b = ot({ value: i, fallback: r.scaleX || 1 }), I = ot({ value: a, fallback: r.scaleY || 1 }), y = m * b, M = v * I, A = f ? y / f : null, j = p ? M / p : null, w = {};
5429
+ f > 0 && (w.width = f), p > 0 && (w.height = p), A && A > 0 && (w.scaleX = A), j && j > 0 && (w.scaleY = j), r.set(w);
5399
5430
  }
5400
5431
  /**
5401
5432
  * Проверяет, содержит ли сериализованный объект инлайн SVG.
@@ -5470,7 +5501,7 @@ class R {
5470
5501
  montageArea: a,
5471
5502
  useRelativePositions: r
5472
5503
  }) {
5473
- const c = t, { x: d, y: h } = lo({
5504
+ const c = t, { x: d, y: l } = lo({
5474
5505
  object: t,
5475
5506
  baseWidth: n,
5476
5507
  baseHeight: i,
@@ -5489,7 +5520,7 @@ class R {
5489
5520
  anchorY: R._resolveAnchor(c, de)
5490
5521
  }), v = ho({
5491
5522
  normalizedX: d,
5492
- normalizedY: h,
5523
+ normalizedY: l,
5493
5524
  bounds: m,
5494
5525
  targetSize: o,
5495
5526
  montageArea: a
@@ -5513,7 +5544,7 @@ class R {
5513
5544
  anchorY: a
5514
5545
  }) {
5515
5546
  if (!n) return t;
5516
- const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r, h = t.height - c, u = t.left + R._calculateAnchorOffset(i, d), g = t.top + R._calculateAnchorOffset(a, h);
5547
+ const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r, l = t.height - c, u = t.left + R._calculateAnchorOffset(i, d), g = t.top + R._calculateAnchorOffset(a, l);
5517
5548
  return {
5518
5549
  left: u,
5519
5550
  top: g,
@@ -5610,7 +5641,7 @@ class R {
5610
5641
  top: r,
5611
5642
  width: c,
5612
5643
  height: d
5613
- } = e, h = t.getBoundingRect(!1, !0), u = s || c || 1, g = o || d || 1, f = uo({
5644
+ } = e, l = t.getBoundingRect(!1, !0), u = s || c || 1, g = o || d || 1, f = uo({
5614
5645
  object: t,
5615
5646
  montageArea: n,
5616
5647
  bounds: e
@@ -5620,7 +5651,7 @@ class R {
5620
5651
  x: (y.x - a) / u,
5621
5652
  y: (y.y - r) / g
5622
5653
  };
5623
- })(), m = (h.left - a) / u, v = (h.top - r) / g, b = m + h.width / u, I = v + h.height / g;
5654
+ })(), m = (l.left - a) / u, v = (l.top - r) / g, b = m + l.width / u, I = v + l.height / g;
5624
5655
  return i[ae] = p.x, i[re] = p.y, i[ce] = R._detectAnchor({
5625
5656
  center: p.x,
5626
5657
  start: m,
@@ -5740,13 +5771,13 @@ class R {
5740
5771
  }
5741
5772
  }
5742
5773
  const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5743
- anchors: l,
5774
+ anchors: h,
5744
5775
  positions: t,
5745
5776
  threshold: e
5746
5777
  }) => {
5747
5778
  let s = 0, o = e + 1, n = null;
5748
5779
  for (const i of t)
5749
- for (const a of l) {
5780
+ for (const a of h) {
5750
5781
  const r = Math.abs(a - i);
5751
5782
  r > e || r >= o || (s = a - i, o = r, n = a);
5752
5783
  }
@@ -5755,11 +5786,11 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5755
5786
  guidePosition: n
5756
5787
  };
5757
5788
  }, mo = ({
5758
- activeBounds: l,
5789
+ activeBounds: h,
5759
5790
  threshold: t,
5760
5791
  anchors: e
5761
5792
  }) => {
5762
- const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = l, c = Qe({
5793
+ const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = h, c = Qe({
5763
5794
  anchors: e.vertical,
5764
5795
  positions: [s, n, o],
5765
5796
  threshold: t
@@ -5767,20 +5798,20 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5767
5798
  anchors: e.horizontal,
5768
5799
  positions: [i, r, a],
5769
5800
  threshold: t
5770
- }), h = [];
5771
- return c.guidePosition !== null && h.push({
5801
+ }), l = [];
5802
+ return c.guidePosition !== null && l.push({
5772
5803
  type: "vertical",
5773
5804
  position: c.guidePosition
5774
- }), d.guidePosition !== null && h.push({
5805
+ }), d.guidePosition !== null && l.push({
5775
5806
  type: "horizontal",
5776
5807
  position: d.guidePosition
5777
5808
  }), {
5778
5809
  deltaX: c.delta,
5779
5810
  deltaY: d.delta,
5780
- guides: h
5811
+ guides: l
5781
5812
  };
5782
5813
  }, ns = ({
5783
- activeBounds: l,
5814
+ activeBounds: h,
5784
5815
  aligned: t,
5785
5816
  threshold: e,
5786
5817
  patterns: s,
@@ -5792,59 +5823,59 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5792
5823
  bottom: i,
5793
5824
  left: a,
5794
5825
  right: r
5795
- } = l, c = [];
5826
+ } = h, c = [];
5796
5827
  for (const d of s)
5797
- for (const h of t)
5828
+ for (const l of t)
5798
5829
  if (o === "vertical") {
5799
- const u = n - h.bottom, g = Math.abs(u - d.distance);
5830
+ const u = n - l.bottom, g = Math.abs(u - d.distance);
5800
5831
  if (g <= e) {
5801
5832
  const m = d.distance - u, v = {
5802
5833
  type: o,
5803
5834
  axis: d.axis,
5804
5835
  refStart: d.start,
5805
5836
  refEnd: d.end,
5806
- activeStart: h.bottom,
5807
- activeEnd: h.bottom + d.distance,
5837
+ activeStart: l.bottom,
5838
+ activeEnd: l.bottom + d.distance,
5808
5839
  distance: d.distance
5809
5840
  };
5810
5841
  c.push({ delta: m, guide: v, diff: g });
5811
5842
  }
5812
- const f = h.top - i, p = Math.abs(f - d.distance);
5843
+ const f = l.top - i, p = Math.abs(f - d.distance);
5813
5844
  if (p <= e) {
5814
5845
  const m = d.distance - f, v = {
5815
5846
  type: o,
5816
5847
  axis: d.axis,
5817
5848
  refStart: d.start,
5818
5849
  refEnd: d.end,
5819
- activeStart: h.top - d.distance,
5820
- activeEnd: h.top,
5850
+ activeStart: l.top - d.distance,
5851
+ activeEnd: l.top,
5821
5852
  distance: d.distance
5822
5853
  };
5823
5854
  c.push({ delta: m, guide: v, diff: p });
5824
5855
  }
5825
5856
  } else {
5826
- const u = a - h.right, g = Math.abs(u - d.distance);
5857
+ const u = a - l.right, g = Math.abs(u - d.distance);
5827
5858
  if (g <= e) {
5828
5859
  const m = d.distance - u, v = {
5829
5860
  type: o,
5830
5861
  axis: d.axis,
5831
5862
  refStart: d.start,
5832
5863
  refEnd: d.end,
5833
- activeStart: h.right,
5834
- activeEnd: h.right + d.distance,
5864
+ activeStart: l.right,
5865
+ activeEnd: l.right + d.distance,
5835
5866
  distance: d.distance
5836
5867
  };
5837
5868
  c.push({ delta: m, guide: v, diff: g });
5838
5869
  }
5839
- const f = h.left - r, p = Math.abs(f - d.distance);
5870
+ const f = l.left - r, p = Math.abs(f - d.distance);
5840
5871
  if (p <= e) {
5841
5872
  const m = d.distance - f, v = {
5842
5873
  type: o,
5843
5874
  axis: d.axis,
5844
5875
  refStart: d.start,
5845
5876
  refEnd: d.end,
5846
- activeStart: h.left - d.distance,
5847
- activeEnd: h.left,
5877
+ activeStart: l.left - d.distance,
5878
+ activeEnd: l.left,
5848
5879
  distance: d.distance
5849
5880
  };
5850
5881
  c.push({ delta: m, guide: v, diff: p });
@@ -5852,7 +5883,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5852
5883
  }
5853
5884
  return c;
5854
5885
  }, yo = ({
5855
- activeBounds: l,
5886
+ activeBounds: h,
5856
5887
  candidates: t,
5857
5888
  threshold: e,
5858
5889
  patterns: s
@@ -5863,68 +5894,68 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5863
5894
  bottom: i,
5864
5895
  left: a,
5865
5896
  right: r
5866
- } = l, c = t.filter((y) => Math.min(y.right, r) - Math.max(y.left, a) >= -e);
5897
+ } = h, c = t.filter((y) => Math.min(y.right, r) - Math.max(y.left, a) >= -e);
5867
5898
  if (!c.length)
5868
5899
  return { delta: 0, guide: null };
5869
5900
  const d = [
5870
5901
  ...c.map((y) => ({ bounds: y, isActive: !1 })),
5871
- { bounds: l, isActive: !0 }
5902
+ { bounds: h, isActive: !0 }
5872
5903
  ];
5873
- d.sort((y, w) => y.bounds.top - w.bounds.top);
5874
- const h = d.findIndex((y) => y.isActive);
5875
- if (h === -1)
5904
+ d.sort((y, M) => y.bounds.top - M.bounds.top);
5905
+ const l = d.findIndex((y) => y.isActive);
5906
+ if (l === -1)
5876
5907
  return { delta: 0, guide: null };
5877
- const u = d[h - 1], g = d[h - 2], f = d[h + 1], p = d[h + 2], m = [], v = i - n;
5908
+ const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
5878
5909
  if (u && g) {
5879
- const { bounds: y } = u, { bounds: w } = g, A = y.top - w.bottom, j = n - y.bottom, M = Math.abs(j - A);
5880
- if (M <= e) {
5910
+ const { bounds: y } = u, { bounds: M } = g, A = y.top - M.bottom, j = n - y.bottom, w = Math.abs(j - A);
5911
+ if (w <= e) {
5881
5912
  const T = A - j, S = n + T, C = {
5882
5913
  type: "vertical",
5883
5914
  axis: o,
5884
- refStart: w.bottom,
5915
+ refStart: M.bottom,
5885
5916
  refEnd: y.top,
5886
5917
  activeStart: y.bottom,
5887
5918
  activeEnd: S,
5888
5919
  distance: A
5889
5920
  };
5890
- m.push({ delta: T, guide: C, diff: M });
5921
+ m.push({ delta: T, guide: C, diff: w });
5891
5922
  }
5892
5923
  }
5893
5924
  if (f && p) {
5894
- const { bounds: y } = f, { bounds: w } = p, A = w.top - y.bottom, j = y.top - i, M = Math.abs(j - A);
5895
- if (M <= e) {
5925
+ const { bounds: y } = f, { bounds: M } = p, A = M.top - y.bottom, j = y.top - i, w = Math.abs(j - A);
5926
+ if (w <= e) {
5896
5927
  const T = j - A, S = i + T, C = {
5897
5928
  type: "vertical",
5898
5929
  axis: o,
5899
5930
  refStart: y.bottom,
5900
- refEnd: w.top,
5931
+ refEnd: M.top,
5901
5932
  activeStart: S,
5902
5933
  activeEnd: y.top,
5903
5934
  distance: A
5904
5935
  };
5905
- m.push({ delta: T, guide: C, diff: M });
5936
+ m.push({ delta: T, guide: C, diff: w });
5906
5937
  }
5907
5938
  }
5908
5939
  if (u && f) {
5909
- const { bounds: y } = u, { bounds: w } = f, j = w.top - y.bottom - v;
5940
+ const { bounds: y } = u, { bounds: M } = f, j = M.top - y.bottom - v;
5910
5941
  if (j >= 0) {
5911
- const M = j / 2, T = n - y.bottom, S = w.top - i, C = Math.abs(T - M), x = Math.abs(S - M), F = Math.max(C, x);
5912
- if (F <= e) {
5913
- const U = M - T, W = i + U, V = {
5942
+ const w = j / 2, T = n - y.bottom, S = M.top - i, C = Math.abs(T - w), x = Math.abs(S - w), W = Math.max(C, x);
5943
+ if (W <= e) {
5944
+ const Y = w - T, H = i + Y, V = {
5914
5945
  type: "vertical",
5915
5946
  axis: o,
5916
5947
  refStart: y.bottom,
5917
- refEnd: y.bottom + M,
5918
- activeStart: W,
5919
- activeEnd: W + M,
5920
- distance: M
5948
+ refEnd: y.bottom + w,
5949
+ activeStart: H,
5950
+ activeEnd: H + w,
5951
+ distance: w
5921
5952
  };
5922
- m.push({ delta: U, guide: V, diff: F });
5953
+ m.push({ delta: Y, guide: V, diff: W });
5923
5954
  }
5924
5955
  }
5925
5956
  }
5926
5957
  const b = ns({
5927
- activeBounds: l,
5958
+ activeBounds: h,
5928
5959
  aligned: c,
5929
5960
  threshold: e,
5930
5961
  patterns: s,
@@ -5932,13 +5963,13 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5932
5963
  });
5933
5964
  if (m.push(...b), !m.length)
5934
5965
  return { delta: 0, guide: null };
5935
- const I = m.reduce((y, w) => w.diff < y.diff ? w : y, m[0]);
5966
+ const I = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
5936
5967
  return {
5937
5968
  delta: I.delta,
5938
5969
  guide: I.guide
5939
5970
  };
5940
5971
  }, vo = ({
5941
- activeBounds: l,
5972
+ activeBounds: h,
5942
5973
  candidates: t,
5943
5974
  threshold: e,
5944
5975
  patterns: s
@@ -5949,68 +5980,68 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
5949
5980
  right: i,
5950
5981
  top: a,
5951
5982
  bottom: r
5952
- } = l, c = t.filter((y) => Math.min(y.bottom, r) - Math.max(y.top, a) >= -e);
5983
+ } = h, c = t.filter((y) => Math.min(y.bottom, r) - Math.max(y.top, a) >= -e);
5953
5984
  if (!c.length)
5954
5985
  return { delta: 0, guide: null };
5955
5986
  const d = [
5956
5987
  ...c.map((y) => ({ bounds: y, isActive: !1 })),
5957
- { bounds: l, isActive: !0 }
5988
+ { bounds: h, isActive: !0 }
5958
5989
  ];
5959
- d.sort((y, w) => y.bounds.left - w.bounds.left);
5960
- const h = d.findIndex((y) => y.isActive);
5961
- if (h === -1)
5990
+ d.sort((y, M) => y.bounds.left - M.bounds.left);
5991
+ const l = d.findIndex((y) => y.isActive);
5992
+ if (l === -1)
5962
5993
  return { delta: 0, guide: null };
5963
- const u = d[h - 1], g = d[h - 2], f = d[h + 1], p = d[h + 2], m = [], v = i - n;
5994
+ const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
5964
5995
  if (u && g) {
5965
- const { bounds: y } = u, { bounds: w } = g, A = y.left - w.right, j = n - y.right, M = Math.abs(j - A);
5966
- if (M <= e) {
5996
+ const { bounds: y } = u, { bounds: M } = g, A = y.left - M.right, j = n - y.right, w = Math.abs(j - A);
5997
+ if (w <= e) {
5967
5998
  const T = A - j, S = n + T, C = {
5968
5999
  type: "horizontal",
5969
6000
  axis: o,
5970
- refStart: w.right,
6001
+ refStart: M.right,
5971
6002
  refEnd: y.left,
5972
6003
  activeStart: y.right,
5973
6004
  activeEnd: S,
5974
6005
  distance: A
5975
6006
  };
5976
- m.push({ delta: T, guide: C, diff: M });
6007
+ m.push({ delta: T, guide: C, diff: w });
5977
6008
  }
5978
6009
  }
5979
6010
  if (f && p) {
5980
- const { bounds: y } = f, { bounds: w } = p, A = w.left - y.right, j = y.left - i, M = Math.abs(j - A);
5981
- if (M <= e) {
6011
+ const { bounds: y } = f, { bounds: M } = p, A = M.left - y.right, j = y.left - i, w = Math.abs(j - A);
6012
+ if (w <= e) {
5982
6013
  const T = j - A, S = i + T, C = {
5983
6014
  type: "horizontal",
5984
6015
  axis: o,
5985
6016
  refStart: y.right,
5986
- refEnd: w.left,
6017
+ refEnd: M.left,
5987
6018
  activeStart: S,
5988
6019
  activeEnd: y.left,
5989
6020
  distance: A
5990
6021
  };
5991
- m.push({ delta: T, guide: C, diff: M });
6022
+ m.push({ delta: T, guide: C, diff: w });
5992
6023
  }
5993
6024
  }
5994
6025
  if (u && f) {
5995
- const { bounds: y } = u, { bounds: w } = f, j = w.left - y.right - v;
6026
+ const { bounds: y } = u, { bounds: M } = f, j = M.left - y.right - v;
5996
6027
  if (j >= 0) {
5997
- const M = j / 2, T = n - y.right, S = w.left - i, C = Math.abs(T - M), x = Math.abs(S - M), F = Math.max(C, x);
5998
- if (F <= e) {
5999
- const U = M - T, W = i + U, V = {
6028
+ const w = j / 2, T = n - y.right, S = M.left - i, C = Math.abs(T - w), x = Math.abs(S - w), W = Math.max(C, x);
6029
+ if (W <= e) {
6030
+ const Y = w - T, H = i + Y, V = {
6000
6031
  type: "horizontal",
6001
6032
  axis: o,
6002
6033
  refStart: y.right,
6003
- refEnd: y.right + M,
6004
- activeStart: W,
6005
- activeEnd: W + M,
6006
- distance: M
6034
+ refEnd: y.right + w,
6035
+ activeStart: H,
6036
+ activeEnd: H + w,
6037
+ distance: w
6007
6038
  };
6008
- m.push({ delta: U, guide: V, diff: F });
6039
+ m.push({ delta: Y, guide: V, diff: W });
6009
6040
  }
6010
6041
  }
6011
6042
  }
6012
6043
  const b = ns({
6013
- activeBounds: l,
6044
+ activeBounds: h,
6014
6045
  aligned: c,
6015
6046
  threshold: e,
6016
6047
  patterns: s,
@@ -6018,24 +6049,24 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
6018
6049
  });
6019
6050
  if (m.push(...b), !m.length)
6020
6051
  return { delta: 0, guide: null };
6021
- const I = m.reduce((y, w) => w.diff < y.diff ? w : y, m[0]);
6052
+ const I = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
6022
6053
  return {
6023
6054
  delta: I.delta,
6024
6055
  guide: I.guide
6025
6056
  };
6026
6057
  }, bo = ({
6027
- activeBounds: l,
6058
+ activeBounds: h,
6028
6059
  candidates: t,
6029
6060
  threshold: e,
6030
6061
  spacingPatterns: s
6031
6062
  }) => {
6032
6063
  const o = yo({
6033
- activeBounds: l,
6064
+ activeBounds: h,
6034
6065
  candidates: t,
6035
6066
  threshold: e,
6036
6067
  patterns: s.vertical
6037
6068
  }), n = vo({
6038
- activeBounds: l,
6069
+ activeBounds: h,
6039
6070
  candidates: t,
6040
6071
  threshold: e,
6041
6072
  patterns: s.horizontal
@@ -6046,7 +6077,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
6046
6077
  guides: i
6047
6078
  };
6048
6079
  }, Mo = ({
6049
- context: l,
6080
+ context: h,
6050
6081
  x: t,
6051
6082
  y: e,
6052
6083
  width: s,
@@ -6054,9 +6085,9 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
6054
6085
  radius: n
6055
6086
  }) => {
6056
6087
  const i = Math.min(n, s / 2, o / 2);
6057
- l.moveTo(t + i, e), l.lineTo(t + s - i, e), l.quadraticCurveTo(t + s, e, t + s, e + i), l.lineTo(t + s, e + o - i), l.quadraticCurveTo(t + s, e + o, t + s - i, e + o), l.lineTo(t + i, e + o), l.quadraticCurveTo(t, e + o, t, e + o - i), l.lineTo(t, e + i), l.quadraticCurveTo(t, e, t + i, e), l.closePath();
6088
+ h.moveTo(t + i, e), h.lineTo(t + s - i, e), h.quadraticCurveTo(t + s, e, t + s, e + i), h.lineTo(t + s, e + o - i), h.quadraticCurveTo(t + s, e + o, t + s - i, e + o), h.lineTo(t + i, e + o), h.quadraticCurveTo(t, e + o, t, e + o - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
6058
6089
  }, me = ({
6059
- context: l,
6090
+ context: h,
6060
6091
  type: t,
6061
6092
  axis: e,
6062
6093
  start: s,
@@ -6067,24 +6098,24 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
6067
6098
  textColor: r = "#ffffff",
6068
6099
  fontFamily: c = "sans-serif",
6069
6100
  lineWidth: d = 1,
6070
- padding: h = 4,
6101
+ padding: l = 4,
6071
6102
  radius: u = 4,
6072
6103
  offsetAlongAxis: g = 0,
6073
6104
  offsetPerpendicular: f = 0
6074
6105
  }) => {
6075
- const p = i || 1, m = 12 / p, v = h / p, b = u / p, I = (s + o) / 2 + g, y = t === "vertical" ? e + f : I, w = t === "vertical" ? I : e + f;
6076
- l.save(), l.setLineDash([]), l.fillStyle = a, l.strokeStyle = a, l.lineWidth = d / p, l.font = `${m}px ${c}`, l.textAlign = "center", l.textBaseline = "middle";
6077
- const j = l.measureText(n).width + v * 2, M = m + v * 2, T = y - j / 2, S = w - M / 2;
6078
- l.beginPath(), Mo({
6079
- context: l,
6106
+ const p = i || 1, m = 12 / p, v = l / p, b = u / p, I = (s + o) / 2 + g, y = t === "vertical" ? e + f : I, M = t === "vertical" ? I : e + f;
6107
+ h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = d / p, h.font = `${m}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
6108
+ const j = h.measureText(n).width + v * 2, w = m + v * 2, T = y - j / 2, S = M - w / 2;
6109
+ h.beginPath(), Mo({
6110
+ context: h,
6080
6111
  x: T,
6081
6112
  y: S,
6082
6113
  width: j,
6083
- height: M,
6114
+ height: w,
6084
6115
  radius: b
6085
- }), l.fill(), l.fillStyle = r, l.fillText(n, y, w), l.restore();
6116
+ }), h.fill(), h.fillStyle = r, h.fillText(n, y, M), h.restore();
6086
6117
  }, wo = ({
6087
- context: l,
6118
+ context: h,
6088
6119
  guide: t,
6089
6120
  zoom: e
6090
6121
  }) => {
@@ -6097,31 +6128,31 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
6097
6128
  activeEnd: r,
6098
6129
  distance: c
6099
6130
  } = t, d = Math.round(c).toString();
6100
- l.beginPath(), s === "vertical" ? (l.moveTo(o, n), l.lineTo(o, i), l.moveTo(o, a), l.lineTo(o, r)) : (l.moveTo(n, o), l.lineTo(i, o), l.moveTo(a, o), l.lineTo(r, o)), l.stroke();
6101
- const h = os;
6131
+ h.beginPath(), s === "vertical" ? (h.moveTo(o, n), h.lineTo(o, i), h.moveTo(o, a), h.lineTo(o, r)) : (h.moveTo(n, o), h.lineTo(i, o), h.moveTo(a, o), h.lineTo(r, o)), h.stroke();
6132
+ const l = os;
6102
6133
  me({
6103
- context: l,
6134
+ context: h,
6104
6135
  type: s,
6105
6136
  axis: o,
6106
6137
  start: n,
6107
6138
  end: i,
6108
6139
  text: d,
6109
6140
  zoom: e,
6110
- color: h,
6141
+ color: l,
6111
6142
  lineWidth: pe
6112
6143
  }), me({
6113
- context: l,
6144
+ context: h,
6114
6145
  type: s,
6115
6146
  axis: o,
6116
6147
  start: a,
6117
6148
  end: r,
6118
6149
  text: d,
6119
6150
  zoom: e,
6120
- color: h,
6151
+ color: l,
6121
6152
  lineWidth: pe
6122
6153
  });
6123
6154
  }, qe = ({
6124
- anchors: l,
6155
+ anchors: h,
6125
6156
  bounds: t
6126
6157
  }) => {
6127
6158
  const {
@@ -6132,24 +6163,24 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
6132
6163
  bottom: i,
6133
6164
  centerY: a
6134
6165
  } = t;
6135
- l.vertical.push(e, o, s), l.horizontal.push(n, a, i);
6166
+ h.vertical.push(e, o, s), h.horizontal.push(n, a, i);
6136
6167
  }, Je = ({
6137
- bounds: l,
6168
+ bounds: h,
6138
6169
  type: t,
6139
6170
  primaryStart: e,
6140
6171
  primaryEnd: s
6141
6172
  }) => {
6142
- const o = [], n = e === "top" ? "left" : "top", i = s === "bottom" ? "right" : "bottom", a = [...l].sort((r, c) => r[e] - c[e]);
6173
+ const o = [], n = e === "top" ? "left" : "top", i = s === "bottom" ? "right" : "bottom", a = [...h].sort((r, c) => r[e] - c[e]);
6143
6174
  for (let r = 0; r < a.length; r += 1) {
6144
6175
  const c = a[r];
6145
- let d = null, h = Number.POSITIVE_INFINITY;
6176
+ let d = null, l = Number.POSITIVE_INFINITY;
6146
6177
  for (let p = r + 1; p < a.length; p += 1) {
6147
6178
  const m = a[p];
6148
6179
  if (Math.min(c[i], m[i]) - Math.max(c[n], m[n]) < 0) continue;
6149
6180
  const b = m[e] - c[s];
6150
- b < 0 || b < h && (h = b, d = m);
6181
+ b < 0 || b < l && (l = b, d = m);
6151
6182
  }
6152
- if (!d || h === Number.POSITIVE_INFINITY) continue;
6183
+ if (!d || l === Number.POSITIVE_INFINITY) continue;
6153
6184
  const u = Math.max(c[n], d[n]), g = Math.min(c[i], d[i]), f = (u + g) / 2;
6154
6185
  o.push({
6155
6186
  type: t,
@@ -6161,34 +6192,34 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
6161
6192
  }
6162
6193
  return o;
6163
6194
  }, So = ({
6164
- bounds: l
6195
+ bounds: h
6165
6196
  }) => {
6166
6197
  const t = Je({
6167
- bounds: l,
6198
+ bounds: h,
6168
6199
  type: "vertical",
6169
6200
  primaryStart: "top",
6170
6201
  primaryEnd: "bottom"
6171
6202
  }), e = Je({
6172
- bounds: l,
6203
+ bounds: h,
6173
6204
  type: "horizontal",
6174
6205
  primaryStart: "left",
6175
6206
  primaryEnd: "right"
6176
6207
  });
6177
6208
  return { vertical: t, horizontal: e };
6178
6209
  }, Ao = ["montage-area", "background", "interaction-blocker"], is = ({
6179
- activeObject: l
6210
+ activeObject: h
6180
6211
  }) => {
6181
6212
  const t = /* @__PURE__ */ new Set();
6182
- return l && (t.add(l), l instanceof k && l.getObjects().forEach((e) => t.add(e))), t;
6213
+ return h && (t.add(h), h instanceof k && h.getObjects().forEach((e) => t.add(e))), t;
6183
6214
  }, as = ({
6184
- object: l,
6215
+ object: h,
6185
6216
  excluded: t,
6186
6217
  ignoredIds: e = Ao
6187
6218
  }) => {
6188
- if (t.has(l)) return !0;
6189
- const { visible: s = !0 } = l;
6219
+ if (t.has(h)) return !0;
6220
+ const { visible: s = !0 } = h;
6190
6221
  if (!s) return !0;
6191
- const { id: o } = l;
6222
+ const { id: o } = h;
6192
6223
  return !!(o && e.includes(o));
6193
6224
  };
6194
6225
  class jo {
@@ -6258,12 +6289,12 @@ class jo {
6258
6289
  activeBounds: n,
6259
6290
  threshold: r,
6260
6291
  anchors: this.anchors
6261
- }), { deltaX: d, deltaY: h, guides: u } = c;
6262
- if (d !== 0 || h !== 0) {
6292
+ }), { deltaX: d, deltaY: l, guides: u } = c;
6293
+ if (d !== 0 || l !== 0) {
6263
6294
  const { left: v = 0, top: b = 0 } = e;
6264
6295
  e.set({
6265
6296
  left: v + d,
6266
- top: b + h
6297
+ top: b + l
6267
6298
  }), e.setCoords(), n = (p = ft({ object: e })) != null ? p : n;
6268
6299
  }
6269
6300
  const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => ft({ object: v })).filter((v) => !!v), f = bo({
@@ -6306,12 +6337,12 @@ class jo {
6306
6337
  if (!s) return;
6307
6338
  const o = e != null ? e : this._calculateViewportBounds(), { left: n, right: i, top: a, bottom: r } = o, { viewportTransform: c } = t, d = t.getZoom() || 1;
6308
6339
  s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = pe / d, s.strokeStyle = os, s.setLineDash([4, 4]);
6309
- for (const h of this.activeGuides)
6310
- s.beginPath(), h.type === "vertical" ? (s.moveTo(h.position, a), s.lineTo(h.position, r)) : (s.moveTo(n, h.position), s.lineTo(i, h.position)), s.stroke();
6311
- for (const h of this.activeSpacingGuides)
6340
+ for (const l of this.activeGuides)
6341
+ s.beginPath(), l.type === "vertical" ? (s.moveTo(l.position, a), s.lineTo(l.position, r)) : (s.moveTo(n, l.position), s.lineTo(i, l.position)), s.stroke();
6342
+ for (const l of this.activeSpacingGuides)
6312
6343
  wo({
6313
6344
  context: s,
6314
- guide: h,
6345
+ guide: l,
6315
6346
  zoom: d
6316
6347
  });
6317
6348
  s.restore();
@@ -6394,10 +6425,10 @@ class jo {
6394
6425
  i = 1,
6395
6426
  a = 0,
6396
6427
  r = 0
6397
- ] = e != null ? e : [], c = (0 - a) / n, d = (0 - r) / i, h = (s - a) / n, u = (o - r) / i;
6428
+ ] = e != null ? e : [], c = (0 - a) / n, d = (0 - r) / i, l = (s - a) / n, u = (o - r) / i;
6398
6429
  return {
6399
6430
  left: c,
6400
- right: h,
6431
+ right: l,
6401
6432
  top: d,
6402
6433
  bottom: u
6403
6434
  };
@@ -6582,7 +6613,7 @@ class Lt {
6582
6613
  centerY: c = 0
6583
6614
  } = t, {
6584
6615
  left: d = 0,
6585
- right: h = 0,
6616
+ right: l = 0,
6586
6617
  top: u = 0,
6587
6618
  bottom: g = 0,
6588
6619
  centerY: f = 0
@@ -6598,31 +6629,31 @@ class Lt {
6598
6629
  distance: C
6599
6630
  }), o;
6600
6631
  }
6601
- if (h <= n) {
6632
+ if (l <= n) {
6602
6633
  if (s) return o;
6603
- const C = n - h;
6634
+ const C = n - l;
6604
6635
  return C > 0 && o.push({
6605
6636
  type: "horizontal",
6606
6637
  axis: b,
6607
- start: h,
6638
+ start: l,
6608
6639
  end: n,
6609
6640
  distance: C
6610
6641
  }), o;
6611
6642
  }
6612
6643
  if (!s) return o;
6613
- const I = n < d, y = i > h, w = Math.min(n, d), A = Math.max(n, d), j = A - w;
6644
+ const I = n < d, y = i > l, M = Math.min(n, d), A = Math.max(n, d), j = A - M;
6614
6645
  j > 0 && !I && o.push({
6615
6646
  type: "horizontal",
6616
6647
  axis: b,
6617
- start: w,
6648
+ start: M,
6618
6649
  end: A,
6619
6650
  distance: j
6620
6651
  });
6621
- const M = Math.min(i, h), T = Math.max(i, h), S = T - M;
6652
+ const w = Math.min(i, l), T = Math.max(i, l), S = T - w;
6622
6653
  return S > 0 && !y && o.push({
6623
6654
  type: "horizontal",
6624
6655
  axis: b,
6625
- start: M,
6656
+ start: w,
6626
6657
  end: T,
6627
6658
  distance: S
6628
6659
  }), o;
@@ -6643,7 +6674,7 @@ class Lt {
6643
6674
  centerX: c = 0
6644
6675
  } = t, {
6645
6676
  top: d = 0,
6646
- bottom: h = 0,
6677
+ bottom: l = 0,
6647
6678
  left: u = 0,
6648
6679
  right: g = 0,
6649
6680
  centerX: f = 0
@@ -6659,31 +6690,31 @@ class Lt {
6659
6690
  distance: C
6660
6691
  }), o;
6661
6692
  }
6662
- if (h <= n) {
6693
+ if (l <= n) {
6663
6694
  if (s) return o;
6664
- const C = n - h;
6695
+ const C = n - l;
6665
6696
  return C > 0 && o.push({
6666
6697
  type: "vertical",
6667
6698
  axis: b,
6668
- start: h,
6699
+ start: l,
6669
6700
  end: n,
6670
6701
  distance: C
6671
6702
  }), o;
6672
6703
  }
6673
6704
  if (!s) return o;
6674
- const I = n < d, y = i > h, w = Math.min(n, d), A = Math.max(n, d), j = A - w;
6705
+ const I = n < d, y = i > l, M = Math.min(n, d), A = Math.max(n, d), j = A - M;
6675
6706
  j > 0 && !I && o.push({
6676
6707
  type: "vertical",
6677
6708
  axis: b,
6678
- start: w,
6709
+ start: M,
6679
6710
  end: A,
6680
6711
  distance: j
6681
6712
  });
6682
- const M = Math.min(i, h), T = Math.max(i, h), S = T - M;
6713
+ const w = Math.min(i, l), T = Math.max(i, l), S = T - w;
6683
6714
  return S > 0 && !y && o.push({
6684
6715
  type: "vertical",
6685
6716
  axis: b,
6686
- start: M,
6717
+ start: w,
6687
6718
  end: T,
6688
6719
  distance: S
6689
6720
  }), o;
@@ -6715,11 +6746,11 @@ class Lt {
6715
6746
  const { viewportTransform: s } = t, o = t.getZoom() || 1, n = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = n && i && !this.isTargetMontageArea, r = a ? 12 / o : 0;
6716
6747
  e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = ts / o, e.strokeStyle = $e, e.setLineDash([]);
6717
6748
  for (const c of this.activeGuides) {
6718
- const { type: d, axis: h, start: u, end: g, distance: f } = c, p = Math.abs(g - u), m = u <= g ? -1 : 1, v = a ? m * (p / 2 + r) : 0, b = 0;
6719
- e.beginPath(), d === "vertical" ? (e.moveTo(h, u), e.lineTo(h, g)) : (e.moveTo(u, h), e.lineTo(g, h)), e.stroke(), me({
6749
+ const { type: d, axis: l, start: u, end: g, distance: f } = c, p = Math.abs(g - u), m = u <= g ? -1 : 1, v = a ? m * (p / 2 + r) : 0, b = 0;
6750
+ e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, g)) : (e.moveTo(u, l), e.lineTo(g, l)), e.stroke(), me({
6720
6751
  context: e,
6721
6752
  type: d,
6722
- axis: h,
6753
+ axis: l,
6723
6754
  start: u,
6724
6755
  end: g,
6725
6756
  text: Math.round(f).toString(),
@@ -6779,9 +6810,9 @@ class Se {
6779
6810
  initialStateJSON: r,
6780
6811
  scaleType: c,
6781
6812
  showRotationAngle: d,
6782
- _onReadyCallback: h
6813
+ _onReadyCallback: l
6783
6814
  } = this.options;
6784
- if (J.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Yt({ editor: this }), this.historyManager = new Jt({ editor: this }), this.toolbar = new Ys({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new Js({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ct({ editor: this }), this.layerManager = new $t({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new te({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new we({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new fe((u = this.options.fonts) != null ? u : []), this.textManager = new Z({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new Me({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ut({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(o), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
6815
+ if (J.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Yt({ editor: this }), this.historyManager = new Jt({ editor: this }), this.toolbar = new Ys({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new Js({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ct({ editor: this }), this.layerManager = new $t({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new te({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new we({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new fe((u = this.options.fonts) != null ? u : []), this.textManager = new z({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new Me({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ut({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(o), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
6785
6816
  const {
6786
6817
  source: g,
6787
6818
  scale: f = `image-${c}`,
@@ -6789,7 +6820,7 @@ class Se {
6789
6820
  } = a;
6790
6821
  yield this.imageManager.importImage({ source: g, scale: f, withoutSave: p });
6791
6822
  }
6792
- r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof h == "function" && h(this);
6823
+ r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
6793
6824
  });
6794
6825
  }
6795
6826
  /**
@@ -7770,15 +7801,15 @@ const E = [
7770
7801
  */
7771
7802
  fonts: Io
7772
7803
  };
7773
- function Do(l, t = {}) {
7774
- const e = _(_({}, Co), t), s = document.getElementById(l);
7804
+ function Do(h, t = {}) {
7805
+ const e = _(_({}, Co), t), s = document.getElementById(h);
7775
7806
  if (!s)
7776
- return Promise.reject(new Error(`Контейнер с ID "${l}" не найден.`));
7807
+ return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
7777
7808
  const o = document.createElement("canvas");
7778
- return o.id = `${l}-canvas`, s.appendChild(o), e.editorContainer = s, new Promise((n) => {
7809
+ return o.id = `${h}-canvas`, s.appendChild(o), e.editorContainer = s, new Promise((n) => {
7779
7810
  e._onReadyCallback = n;
7780
7811
  const i = new Se(o.id, e);
7781
- window[l] = i;
7812
+ window[h] = i;
7782
7813
  });
7783
7814
  }
7784
7815
  export {